summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/8_3_names.test197
-rw-r--r--test/affinity2.test136
-rw-r--r--test/affinity3.test123
-rw-r--r--test/aggerror.test78
-rw-r--r--test/aggnested.test365
-rw-r--r--test/alias.test140
-rw-r--r--test/all.test51
-rw-r--r--test/alter.test938
-rw-r--r--test/alter2.test470
-rw-r--r--test/alter3.test443
-rw-r--r--test/alter4.test427
-rw-r--r--test/alterauth.test72
-rw-r--r--test/alterauth2.test119
-rw-r--r--test/altercol.test934
-rw-r--r--test/altercorrupt.test181
-rw-r--r--test/alterdropcol.test339
-rw-r--r--test/alterdropcol2.test222
-rw-r--r--test/alterfault.test41
-rw-r--r--test/alterlegacy.test469
-rw-r--r--test/altermalloc.test71
-rw-r--r--test/altermalloc2.test127
-rw-r--r--test/altermalloc3.test89
-rw-r--r--test/alterqf.test120
-rw-r--r--test/altertab.test984
-rw-r--r--test/altertab2.test363
-rw-r--r--test/altertab3.test739
-rw-r--r--test/altertrig.test163
-rw-r--r--test/amatch1.test117
-rw-r--r--test/analyze.test380
-rw-r--r--test/analyze3.test739
-rw-r--r--test/analyze4.test117
-rw-r--r--test/analyze5.test247
-rw-r--r--test/analyze6.test126
-rw-r--r--test/analyze7.test114
-rw-r--r--test/analyze8.test115
-rw-r--r--test/analyze9.test1235
-rw-r--r--test/analyzeC.test181
-rw-r--r--test/analyzeD.test107
-rw-r--r--test/analyzeE.test242
-rw-r--r--test/analyzeF.test150
-rw-r--r--test/analyzeG.test84
-rw-r--r--test/analyzer1.test55
-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.test68
-rw-r--r--test/atof1.test88
-rw-r--r--test/atomic.test41
-rw-r--r--test/atomic2.test95
-rw-r--r--test/atrc.c150
-rw-r--r--test/attach.test928
-rw-r--r--test/attach2.test391
-rw-r--r--test/attach3.test353
-rw-r--r--test/attach4.test137
-rw-r--r--test/attachmalloc.test78
-rw-r--r--test/auth.test2663
-rw-r--r--test/auth2.test160
-rw-r--r--test/auth3.test134
-rw-r--r--test/autoanalyze1.test123
-rw-r--r--test/autoinc.test883
-rw-r--r--test/autoindex1.test564
-rw-r--r--test/autoindex2.test232
-rw-r--r--test/autoindex3.test93
-rw-r--r--test/autoindex4.test201
-rw-r--r--test/autoindex5.test234
-rw-r--r--test/autovacuum.test715
-rw-r--r--test/autovacuum2.test87
-rw-r--r--test/autovacuum_ioerr2.test132
-rw-r--r--test/avfs.test395
-rw-r--r--test/avtrans.test927
-rw-r--r--test/backcompat.test524
-rw-r--r--test/backup.test981
-rw-r--r--test/backup2.test187
-rw-r--r--test/backup4.test108
-rw-r--r--test/backup5.test65
-rw-r--r--test/backup_ioerr.test286
-rw-r--r--test/backup_malloc.test119
-rw-r--r--test/badutf.test143
-rw-r--r--test/badutf2.test127
-rw-r--r--test/bc_common.tcl75
-rw-r--r--test/bestindex1.test344
-rw-r--r--test/bestindex2.test145
-rw-r--r--test/bestindex3.test185
-rw-r--r--test/bestindex4.test182
-rw-r--r--test/bestindex5.test252
-rw-r--r--test/bestindex6.test113
-rw-r--r--test/bestindex7.test82
-rw-r--r--test/bestindex8.test463
-rw-r--r--test/bestindex9.test108
-rw-r--r--test/between.test143
-rw-r--r--test/bigfile.test203
-rw-r--r--test/bigfile2.test62
-rw-r--r--test/bigmmap.test108
-rw-r--r--test/bigrow.test223
-rw-r--r--test/bigsort.test57
-rw-r--r--test/bind.test758
-rw-r--r--test/bind2.test63
-rw-r--r--test/bindxfer.test76
-rw-r--r--test/bitvec.test195
-rw-r--r--test/blob.test147
-rw-r--r--test/bloom1.test70
-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.tcl289
-rw-r--r--test/boundary3.test12456
-rw-r--r--test/boundary4.tcl340
-rw-r--r--test/boundary4.test343
-rw-r--r--test/btree01.test156
-rw-r--r--test/btree02.test62
-rw-r--r--test/btreefault.test106
-rw-r--r--test/busy.test139
-rw-r--r--test/busy2.test171
-rw-r--r--test/cache.test140
-rw-r--r--test/cacheflush.test323
-rw-r--r--test/cachespill.test77
-rw-r--r--test/capi2.test803
-rw-r--r--test/capi3.test1276
-rw-r--r--test/capi3b.test145
-rw-r--r--test/capi3c.test1400
-rw-r--r--test/capi3d.test289
-rw-r--r--test/capi3e.test126
-rw-r--r--test/carray01.test132
-rw-r--r--test/cast.test487
-rw-r--r--test/cffault.test158
-rw-r--r--test/changes.test90
-rw-r--r--test/changes2.test95
-rw-r--r--test/check.test615
-rw-r--r--test/checkfault.test41
-rw-r--r--test/chunksize.test41
-rw-r--r--test/close.test89
-rw-r--r--test/closure01.test295
-rw-r--r--test/coalesce.test84
-rw-r--r--test/collate1.test452
-rw-r--r--test/collate2.test742
-rw-r--r--test/collate3.test531
-rw-r--r--test/collate4.test704
-rw-r--r--test/collate5.test328
-rw-r--r--test/collate6.test153
-rw-r--r--test/collate7.test72
-rw-r--r--test/collate8.test157
-rw-r--r--test/collate9.test178
-rw-r--r--test/collateA.test217
-rw-r--r--test/collateB.test77
-rw-r--r--test/colmeta.test110
-rw-r--r--test/colname.test447
-rw-r--r--test/columncount.test62
-rw-r--r--test/conflict.test860
-rw-r--r--test/conflict2.test858
-rw-r--r--test/conflict3.test437
-rw-r--r--test/contrib01.test90
-rw-r--r--test/corrupt.test349
-rw-r--r--test/corrupt2.test611
-rw-r--r--test/corrupt3.test121
-rw-r--r--test/corrupt4.test149
-rw-r--r--test/corrupt5.test50
-rw-r--r--test/corrupt6.test259
-rw-r--r--test/corrupt7.test112
-rw-r--r--test/corrupt8.test108
-rw-r--r--test/corrupt9.test140
-rw-r--r--test/corruptA.test83
-rw-r--r--test/corruptB.test193
-rw-r--r--test/corruptC.test428
-rw-r--r--test/corruptD.test145
-rw-r--r--test/corruptE.test152
-rw-r--r--test/corruptF.test153
-rw-r--r--test/corruptG.test75
-rw-r--r--test/corruptH.test176
-rw-r--r--test/corruptI.test263
-rw-r--r--test/corruptJ.test80
-rw-r--r--test/corruptK.test234
-rw-r--r--test/corruptL.test1504
-rw-r--r--test/corruptM.test186
-rw-r--r--test/corruptN.test279
-rw-r--r--test/cost.test289
-rw-r--r--test/count.test251
-rw-r--r--test/countofview.test56
-rw-r--r--test/coveridxscan.test119
-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.test127
-rw-r--r--test/crash6.test118
-rw-r--r--test/crash7.test116
-rw-r--r--test/crash8.test419
-rw-r--r--test/crashM.test80
-rw-r--r--test/crashtest1.c96
-rw-r--r--test/createtab.test154
-rw-r--r--test/cse.test200
-rw-r--r--test/csv01.test279
-rw-r--r--test/ctime.test259
-rw-r--r--test/cursorhint.test162
-rw-r--r--test/cursorhint2.test204
-rw-r--r--test/dataversion1.test87
-rw-r--r--test/date.test547
-rw-r--r--test/date2.test176
-rw-r--r--test/date3.test149
-rw-r--r--test/dbdata.test115
-rw-r--r--test/dbfuzz.c754
-rw-r--r--test/dbfuzz001.test374
-rw-r--r--test/dbfuzz2-seed1.dbbin0 -> 3584 bytes
-rw-r--r--test/dbfuzz2.c402
-rw-r--r--test/dbpage.test111
-rw-r--r--test/dbpagefault.test88
-rw-r--r--test/dbstatus.test457
-rw-r--r--test/dbstatus2.test115
-rw-r--r--test/decimal.test186
-rw-r--r--test/default.test140
-rw-r--r--test/delete.test419
-rw-r--r--test/delete2.test119
-rw-r--r--test/delete3.test57
-rw-r--r--test/delete4.test272
-rw-r--r--test/delete_db.test222
-rw-r--r--test/descidx1.test365
-rw-r--r--test/descidx2.test186
-rw-r--r--test/descidx3.test155
-rw-r--r--test/diskfull.test115
-rw-r--r--test/distinct.test352
-rw-r--r--test/distinct2.test304
-rw-r--r--test/distinctagg.test217
-rw-r--r--test/e_blobbytes.test79
-rw-r--r--test/e_blobclose.test175
-rw-r--r--test/e_blobopen.test553
-rw-r--r--test/e_blobwrite.test208
-rw-r--r--test/e_changes.test443
-rw-r--r--test/e_createtable.test1969
-rw-r--r--test/e_delete.test477
-rw-r--r--test/e_droptrigger.test218
-rw-r--r--test/e_dropview.test192
-rw-r--r--test/e_expr.test1988
-rw-r--r--test/e_fkey.test3047
-rw-r--r--test/e_fts3.test707
-rw-r--r--test/e_insert.test431
-rw-r--r--test/e_reindex.test299
-rw-r--r--test/e_resolve.test135
-rw-r--r--test/e_select.test2174
-rw-r--r--test/e_select2.test580
-rw-r--r--test/e_totalchanges.test214
-rw-r--r--test/e_update.test605
-rw-r--r--test/e_uri.test465
-rw-r--r--test/e_vacuum.test347
-rw-r--r--test/e_wal.test231
-rw-r--r--test/e_walauto.test214
-rw-r--r--test/e_walckpt.test753
-rw-r--r--test/e_walhook.test200
-rw-r--r--test/emptytable.test50
-rw-r--r--test/enc.test252
-rw-r--r--test/enc2.test567
-rw-r--r--test/enc3.test107
-rw-r--r--test/enc4.test137
-rw-r--r--test/eqp.test850
-rw-r--r--test/errmsg.test118
-rw-r--r--test/eval.test87
-rw-r--r--test/exclusive.test540
-rw-r--r--test/exclusive2.test324
-rw-r--r--test/exec.test37
-rw-r--r--test/exists.test199
-rw-r--r--test/expr.test1084
-rw-r--r--test/expr2.test54
-rw-r--r--test/exprfault.test35
-rw-r--r--test/extension01.test83
-rw-r--r--test/external_reader.test74
-rw-r--r--test/extraquick.test16
-rw-r--r--test/fallocate.test157
-rw-r--r--test/filectrl.test72
-rw-r--r--test/filefmt.test254
-rw-r--r--test/filter1.test225
-rw-r--r--test/filter2.tcl132
-rw-r--r--test/filter2.test156
-rw-r--r--test/filterfault.test44
-rw-r--r--test/fkey1.test275
-rw-r--r--test/fkey2.test2047
-rw-r--r--test/fkey3.test186
-rw-r--r--test/fkey4.test57
-rw-r--r--test/fkey5.test492
-rw-r--r--test/fkey6.test229
-rw-r--r--test/fkey7.test121
-rw-r--r--test/fkey8.test253
-rw-r--r--test/fkey_malloc.test134
-rw-r--r--test/fordelete.test209
-rw-r--r--test/format4.test66
-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.tcl420
-rw-r--r--test/fts3aa.test265
-rw-r--r--test/fts3ab.test147
-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.test93
-rw-r--r--test/fts3ah.test71
-rw-r--r--test/fts3ai.test92
-rw-r--r--test/fts3aj.test87
-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.test250
-rw-r--r--test/fts3atoken.test287
-rw-r--r--test/fts3auto.test717
-rw-r--r--test/fts3aux1.test531
-rw-r--r--test/fts3aux2.test168
-rw-r--r--test/fts3b.test230
-rw-r--r--test/fts3c.test255
-rw-r--r--test/fts3comp1.test115
-rw-r--r--test/fts3conf.test254
-rw-r--r--test/fts3corrupt.test234
-rw-r--r--test/fts3corrupt2.test111
-rw-r--r--test/fts3corrupt3.test66
-rw-r--r--test/fts3corrupt4.test7667
-rw-r--r--test/fts3corrupt5.test59
-rw-r--r--test/fts3corrupt6.test79
-rw-r--r--test/fts3cov.test434
-rw-r--r--test/fts3d.test372
-rw-r--r--test/fts3defer.test531
-rw-r--r--test/fts3defer2.test165
-rw-r--r--test/fts3defer3.test84
-rw-r--r--test/fts3drop.test61
-rw-r--r--test/fts3dropmod.test44
-rw-r--r--test/fts3e.test125
-rw-r--r--test/fts3expr.test521
-rw-r--r--test/fts3expr2.test166
-rw-r--r--test/fts3expr3.test238
-rw-r--r--test/fts3expr4.test82
-rw-r--r--test/fts3expr5.test66
-rw-r--r--test/fts3f.test57
-rw-r--r--test/fts3fault.test263
-rw-r--r--test/fts3fault2.test250
-rw-r--r--test/fts3first.test163
-rw-r--r--test/fts3fuzz001.test114
-rw-r--r--test/fts3join.test106
-rw-r--r--test/fts3malloc.test307
-rw-r--r--test/fts3matchinfo.test556
-rw-r--r--test/fts3matchinfo2.test35
-rw-r--r--test/fts3misc.test326
-rw-r--r--test/fts3near.test597
-rw-r--r--test/fts3offsets.test135
-rw-r--r--test/fts3prefix.test295
-rw-r--r--test/fts3prefix2.test61
-rw-r--r--test/fts3query.test293
-rw-r--r--test/fts3rank.test69
-rw-r--r--test/fts3rnd.test460
-rw-r--r--test/fts3shared.test176
-rw-r--r--test/fts3snippet.test592
-rw-r--r--test/fts3snippet2.test59
-rw-r--r--test/fts3sort.test184
-rw-r--r--test/fts3tok1.test124
-rw-r--r--test/fts3tok_err.test47
-rw-r--r--test/fts3varint.test121
-rw-r--r--test/fts4aa.test256
-rw-r--r--test/fts4check.test217
-rw-r--r--test/fts4content.test674
-rw-r--r--test/fts4docid.test116
-rw-r--r--test/fts4growth.test441
-rw-r--r--test/fts4growth2.test92
-rw-r--r--test/fts4incr.test77
-rw-r--r--test/fts4langid.test507
-rw-r--r--test/fts4lastrowid.test72
-rw-r--r--test/fts4merge.test347
-rw-r--r--test/fts4merge2.test38
-rw-r--r--test/fts4merge3.test105
-rw-r--r--test/fts4merge4.test102
-rw-r--r--test/fts4merge5.test58
-rw-r--r--test/fts4min.test53
-rw-r--r--test/fts4noti.test230
-rw-r--r--test/fts4onepass.test160
-rw-r--r--test/fts4opt.test214
-rw-r--r--test/fts4record.test120
-rw-r--r--test/fts4rename.test43
-rw-r--r--test/fts4umlaut.test64
-rw-r--r--test/fts4unicode.test588
-rw-r--r--test/fts4upfrom.test139
-rw-r--r--test/full.test20
-rw-r--r--test/func.test1525
-rw-r--r--test/func2.test511
-rw-r--r--test/func3.test211
-rw-r--r--test/func4.test758
-rw-r--r--test/func5.test64
-rw-r--r--test/func6.test183
-rw-r--r--test/func7.test251
-rw-r--r--test/fuzz-oss1.test2007
-rw-r--r--test/fuzz.test379
-rw-r--r--test/fuzz2.test139
-rw-r--r--test/fuzz3.test175
-rw-r--r--test/fuzz4.test82
-rw-r--r--test/fuzz_common.tcl392
-rw-r--r--test/fuzz_malloc.test100
-rw-r--r--test/fuzzcheck.c2471
-rw-r--r--test/fuzzdata1.dbbin0 -> 4421632 bytes
-rw-r--r--test/fuzzdata2.dbbin0 -> 17021952 bytes
-rw-r--r--test/fuzzdata3.dbbin0 -> 11848704 bytes
-rw-r--r--test/fuzzdata4.dbbin0 -> 2021376 bytes
-rw-r--r--test/fuzzdata5.dbbin0 -> 7197696 bytes
-rw-r--r--test/fuzzdata6.dbbin0 -> 1785856 bytes
-rw-r--r--test/fuzzdata7.dbbin0 -> 16819200 bytes
-rw-r--r--test/fuzzdata8.dbbin0 -> 3298304 bytes
-rw-r--r--test/fuzzer1.test1820
-rw-r--r--test/fuzzer2.test72
-rw-r--r--test/fuzzerfault.test111
-rw-r--r--test/fuzzinvariants.c487
-rw-r--r--test/gcfault.test56
-rw-r--r--test/gencol1.test618
-rw-r--r--test/genesis.tcl1560
-rw-r--r--test/having.test191
-rw-r--r--test/hexlit.test125
-rw-r--r--test/hidden.test153
-rw-r--r--test/hook.test1024
-rw-r--r--test/hook2.test218
-rw-r--r--test/icu.test167
-rw-r--r--test/ieee754.test60
-rw-r--r--test/imposter1.test141
-rw-r--r--test/in.test810
-rw-r--r--test/in2.test67
-rw-r--r--test/in3.test289
-rw-r--r--test/in4.test520
-rw-r--r--test/in5.test269
-rw-r--r--test/in6.test119
-rw-r--r--test/incrblob.test693
-rw-r--r--test/incrblob2.test453
-rw-r--r--test/incrblob3.test314
-rw-r--r--test/incrblob4.test109
-rw-r--r--test/incrblob_err.test140
-rw-r--r--test/incrblobfault.test74
-rw-r--r--test/incrcorrupt.test126
-rw-r--r--test/incrvacuum.test892
-rw-r--r--test/incrvacuum2.test213
-rw-r--r--test/incrvacuum3.test153
-rw-r--r--test/incrvacuum_ioerr.test182
-rw-r--r--test/index.test769
-rw-r--r--test/index2.test73
-rw-r--r--test/index3.test96
-rw-r--r--test/index4.test126
-rw-r--r--test/index5.test80
-rw-r--r--test/index6.test531
-rw-r--r--test/index7.test355
-rw-r--r--test/index8.test60
-rw-r--r--test/index9.test96
-rw-r--r--test/indexedby.test385
-rw-r--r--test/indexexpr1.test509
-rw-r--r--test/indexexpr2.test375
-rw-r--r--test/indexfault.test352
-rw-r--r--test/init.test82
-rw-r--r--test/insert.test603
-rw-r--r--test/insert2.test298
-rw-r--r--test/insert3.test205
-rw-r--r--test/insert4.test628
-rw-r--r--test/insert5.test117
-rw-r--r--test/insertfault.test36
-rw-r--r--test/instr.test281
-rw-r--r--test/instrfault.test92
-rw-r--r--test/intarray.test116
-rw-r--r--test/interrupt.test185
-rw-r--r--test/interrupt2.test159
-rw-r--r--test/intpkey.test645
-rw-r--r--test/intreal.test98
-rw-r--r--test/io.test645
-rw-r--r--test/ioerr.test466
-rw-r--r--test/ioerr2.test176
-rw-r--r--test/ioerr3.test42
-rw-r--r--test/ioerr4.test100
-rw-r--r--test/ioerr5.test216
-rw-r--r--test/ioerr6.test91
-rw-r--r--test/istrue.test206
-rw-r--r--test/join.test1210
-rw-r--r--test/join2.test358
-rw-r--r--test/join3.test62
-rw-r--r--test/join4.test98
-rw-r--r--test/join5.test430
-rw-r--r--test/join6.test176
-rw-r--r--test/join7.test355
-rw-r--r--test/join8.test804
-rw-r--r--test/join9.test565
-rw-r--r--test/joinA.test214
-rw-r--r--test/joinB.test7252
-rw-r--r--test/joinC.test4594
-rw-r--r--test/joinD.test35136
-rw-r--r--test/joinE.test443
-rw-r--r--test/joinF.test613
-rw-r--r--test/joinH.test93
-rw-r--r--test/journal1.test72
-rw-r--r--test/journal2.test233
-rw-r--r--test/journal3.test69
-rw-r--r--test/jrnlmode.test585
-rw-r--r--test/jrnlmode2.test128
-rw-r--r--test/jrnlmode3.test149
-rw-r--r--test/json101.test888
-rw-r--r--test/json102.test391
-rw-r--r--test/json103.test93
-rw-r--r--test/json104.test153
-rw-r--r--test/json105.test113
-rw-r--r--test/keyword1.test121
-rw-r--r--test/kvtest.c1137
-rw-r--r--test/lastinsert.test377
-rw-r--r--test/laststmtchanges.test331
-rw-r--r--test/lemon-test01.y75
-rw-r--r--test/like.test1143
-rw-r--r--test/like2.test1017
-rw-r--r--test/like3.test278
-rw-r--r--test/limit.test668
-rw-r--r--test/limit2.test217
-rw-r--r--test/loadext.test299
-rw-r--r--test/loadext2.test168
-rw-r--r--test/lock.test453
-rw-r--r--test/lock2.test111
-rw-r--r--test/lock3.test79
-rw-r--r--test/lock4.test126
-rw-r--r--test/lock5.test196
-rw-r--r--test/lock6.test167
-rw-r--r--test/lock7.test60
-rw-r--r--test/lock_common.tcl206
-rw-r--r--test/lookaside.test136
-rw-r--r--test/main.test538
-rw-r--r--test/make-where7.tcl120
-rw-r--r--test/malloc.test954
-rw-r--r--test/malloc3.test703
-rw-r--r--test/malloc4.test194
-rw-r--r--test/malloc5.test421
-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.test127
-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.test73
-rw-r--r--test/mallocH.test73
-rw-r--r--test/mallocI.test75
-rw-r--r--test/mallocJ.test73
-rw-r--r--test/mallocK.test175
-rw-r--r--test/mallocL.test42
-rw-r--r--test/mallocM.test48
-rw-r--r--test/malloc_common.tcl698
-rw-r--r--test/malloctraceviewer.tcl253
-rw-r--r--test/manydb.test102
-rw-r--r--test/mem5.test66
-rw-r--r--test/memdb.test431
-rw-r--r--test/memdb1.test270
-rw-r--r--test/memjournal.test48
-rw-r--r--test/memjournal2.test63
-rw-r--r--test/memleak.test97
-rw-r--r--test/memsubsys1.test189
-rw-r--r--test/memsubsys2.test176
-rw-r--r--test/merge1.test145
-rw-r--r--test/minmax.test661
-rw-r--r--test/minmax2.test426
-rw-r--r--test/minmax3.test288
-rw-r--r--test/minmax4.test236
-rw-r--r--test/misc1.test769
-rw-r--r--test/misc2.test444
-rw-r--r--test/misc3.test355
-rw-r--r--test/misc4.test233
-rw-r--r--test/misc5.test1895
-rw-r--r--test/misc6.test48
-rw-r--r--test/misc7.test573
-rw-r--r--test/misc8.test141
-rw-r--r--test/misuse.test210
-rw-r--r--test/mjournal.test162
-rw-r--r--test/mmap1.test323
-rw-r--r--test/mmap2.test87
-rw-r--r--test/mmap3.test101
-rw-r--r--test/mmap4.test104
-rw-r--r--test/mmapfault.test76
-rw-r--r--test/mmapwarm.test81
-rw-r--r--test/multiplex.test615
-rw-r--r--test/multiplex2.test70
-rw-r--r--test/multiplex3.test166
-rw-r--r--test/multiplex4.test132
-rw-r--r--test/mutex1.test215
-rw-r--r--test/mutex2.test105
-rw-r--r--test/nan.test375
-rw-r--r--test/nockpt.test147
-rw-r--r--test/nolock.test220
-rw-r--r--test/normalize.test394
-rw-r--r--test/notify1.test500
-rw-r--r--test/notify2.test267
-rw-r--r--test/notify3.test152
-rw-r--r--test/notnull.test608
-rw-r--r--test/notnull2.test132
-rw-r--r--test/notnullfault.test55
-rw-r--r--test/null.test307
-rw-r--r--test/nulls1.test343
-rw-r--r--test/numcast.test46
-rw-r--r--test/numindex1.test79
-rw-r--r--test/offset1.test202
-rw-r--r--test/openv2.test55
-rw-r--r--test/optfuzz-db01.c947
-rw-r--r--test/optfuzz-db01.txt142
-rw-r--r--test/optfuzz.c308
-rw-r--r--test/orderby1.test566
-rw-r--r--test/orderby2.test117
-rw-r--r--test/orderby3.test123
-rw-r--r--test/orderby4.test56
-rw-r--r--test/orderby5.test187
-rw-r--r--test/orderby6.test183
-rw-r--r--test/orderby7.test106
-rw-r--r--test/orderby8.test41
-rw-r--r--test/orderby9.test62
-rw-r--r--test/orderbyA.test147
-rw-r--r--test/oserror.test142
-rw-r--r--test/ossfuzz.c201
-rw-r--r--test/ossshell.c100
-rw-r--r--test/ovfl.test47
-rw-r--r--test/pager1.test2956
-rw-r--r--test/pager2.test168
-rw-r--r--test/pager3.test37
-rw-r--r--test/pager4.test99
-rw-r--r--test/pagerfault.test1553
-rw-r--r--test/pagerfault2.test98
-rw-r--r--test/pagerfault3.test63
-rw-r--r--test/pageropt.test209
-rw-r--r--test/pagesize.test237
-rw-r--r--test/parser1.test103
-rw-r--r--test/pcache.test182
-rw-r--r--test/pcache2.test84
-rw-r--r--test/percentile.test209
-rw-r--r--test/permutations.test1258
-rw-r--r--test/pg_common.tcl175
-rw-r--r--test/pragma.test2006
-rw-r--r--test/pragma2.test275
-rw-r--r--test/pragma3.test287
-rw-r--r--test/pragma4.test268
-rw-r--r--test/pragma5.test70
-rw-r--r--test/pragmafault.test39
-rw-r--r--test/prefixes.test88
-rw-r--r--test/printf.test3789
-rw-r--r--test/printf2.test213
-rw-r--r--test/progress.test178
-rw-r--r--test/ptrchng.test223
-rw-r--r--test/pushdown.test91
-rw-r--r--test/queryonly.test72
-rw-r--r--test/quick.test15
-rw-r--r--test/quota-glob.test87
-rw-r--r--test/quota.test532
-rw-r--r--test/quota2.test302
-rw-r--r--test/quote.test186
-rw-r--r--test/randexpr1.tcl342
-rw-r--r--test/randexpr1.test7837
-rw-r--r--test/rbu.test17
-rw-r--r--test/rdonly.test95
-rw-r--r--test/recover.test179
-rw-r--r--test/regexp1.test335
-rw-r--r--test/regexp2.test144
-rw-r--r--test/reindex.test205
-rw-r--r--test/releasetest_data.tcl657
-rw-r--r--test/resetdb.test258
-rw-r--r--test/resolver01.test216
-rw-r--r--test/returning1.test403
-rw-r--r--test/returningfault.test36
-rw-r--r--test/rollback.test152
-rw-r--r--test/rollback2.test156
-rw-r--r--test/rollbackfault.test82
-rw-r--r--test/round1.test42
-rw-r--r--test/rowallock.test67
-rw-r--r--test/rowhash.test59
-rw-r--r--test/rowid.test820
-rw-r--r--test/rowvalue.test785
-rw-r--r--test/rowvalue2.test279
-rw-r--r--test/rowvalue3.test221
-rw-r--r--test/rowvalue4.test305
-rw-r--r--test/rowvalue5.test117
-rw-r--r--test/rowvalue6.test36
-rw-r--r--test/rowvalue7.test68
-rw-r--r--test/rowvalue8.test59
-rw-r--r--test/rowvalue9.test314
-rw-r--r--test/rowvalueA.test77
-rw-r--r--test/rowvaluefault.test89
-rw-r--r--test/rowvaluevtab.test95
-rw-r--r--test/rtree.test18
-rw-r--r--test/run-wordcount.sh78
-rw-r--r--test/savepoint.test1058
-rw-r--r--test/savepoint2.test154
-rw-r--r--test/savepoint4.test169
-rw-r--r--test/savepoint5.test46
-rw-r--r--test/savepoint6.test281
-rw-r--r--test/savepoint7.test132
-rw-r--r--test/savepointfault.test137
-rw-r--r--test/scanstatus.test400
-rw-r--r--test/schema.test403
-rw-r--r--test/schema2.test340
-rw-r--r--test/schema3.test103
-rw-r--r--test/schema4.test175
-rw-r--r--test/schema5.test69
-rw-r--r--test/schema6.test164
-rw-r--r--test/schemafault.test31
-rw-r--r--test/securedel.test100
-rw-r--r--test/securedel2.test94
-rw-r--r--test/seekscan1.test63
-rw-r--r--test/select1.test1213
-rw-r--r--test/select2.test185
-rw-r--r--test/select3.test437
-rw-r--r--test/select4.test1043
-rw-r--r--test/select5.test262
-rw-r--r--test/select6.test631
-rw-r--r--test/select7.test218
-rw-r--r--test/select8.test61
-rw-r--r--test/select9.test472
-rw-r--r--test/selectA.test1510
-rw-r--r--test/selectB.test426
-rw-r--r--test/selectC.test270
-rw-r--r--test/selectD.test174
-rw-r--r--test/selectE.test100
-rw-r--r--test/selectF.test49
-rw-r--r--test/selectG.test59
-rw-r--r--test/server1.test180
-rw-r--r--test/session.test22
-rw-r--r--test/sessionfuzz-data1.dbbin0 -> 258048 bytes
-rw-r--r--test/sessionfuzz.c1023
-rw-r--r--test/shared.test1184
-rw-r--r--test/shared2.test139
-rw-r--r--test/shared3.test142
-rw-r--r--test/shared4.test236
-rw-r--r--test/shared6.test255
-rw-r--r--test/shared7.test58
-rw-r--r--test/shared8.test113
-rw-r--r--test/shared9.test230
-rw-r--r--test/sharedA.test198
-rw-r--r--test/sharedB.test65
-rw-r--r--test/shared_err.test528
-rw-r--r--test/sharedlock.test82
-rw-r--r--test/shell1.test1260
-rw-r--r--test/shell2.test206
-rw-r--r--test/shell3.test138
-rw-r--r--test/shell4.test150
-rw-r--r--test/shell5.test573
-rw-r--r--test/shell6.test129
-rw-r--r--test/shell7.test52
-rw-r--r--test/shell8.test196
-rw-r--r--test/shmlock.test180
-rw-r--r--test/shortread1.test52
-rw-r--r--test/show_speedtest1_rtree.tcl57
-rw-r--r--test/shrink.test48
-rw-r--r--test/sidedelete.test92
-rw-r--r--test/skipscan1.test422
-rw-r--r--test/skipscan2.test205
-rw-r--r--test/skipscan3.test73
-rw-r--r--test/skipscan5.test182
-rw-r--r--test/skipscan6.test191
-rw-r--r--test/snapshot.test497
-rw-r--r--test/snapshot2.test240
-rw-r--r--test/snapshot3.test99
-rw-r--r--test/snapshot4.test74
-rw-r--r--test/snapshot_fault.test251
-rw-r--r--test/snapshot_up.test183
-rw-r--r--test/soak.test90
-rw-r--r--test/softheap1.test74
-rw-r--r--test/sort.test598
-rw-r--r--test/sort2.test88
-rw-r--r--test/sort3.test113
-rw-r--r--test/sort4.test208
-rw-r--r--test/sort5.test122
-rw-r--r--test/sorterref.test56
-rw-r--r--test/sortfault.test171
-rw-r--r--test/speed1.test298
-rw-r--r--test/speed1p.explain366
-rw-r--r--test/speed1p.test347
-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.test291
-rw-r--r--test/speedtest1.c2658
-rw-r--r--test/spellfix.test405
-rw-r--r--test/spellfix2.test118
-rw-r--r--test/spellfix3.test52
-rw-r--r--test/spellfix4.test353
-rw-r--r--test/sqldiff1.test66
-rw-r--r--test/sqllimits1.test926
-rw-r--r--test/sqllog.test113
-rw-r--r--test/startup.c628
-rw-r--r--test/stat.test328
-rw-r--r--test/statfault.test55
-rw-r--r--test/stmt.test104
-rw-r--r--test/stmtvtab1.test82
-rw-r--r--test/strict1.test165
-rw-r--r--test/strict2.test158
-rw-r--r--test/subjournal.test69
-rw-r--r--test/subquery.test616
-rw-r--r--test/subquery2.test218
-rw-r--r--test/subselect.test210
-rw-r--r--test/substr.test158
-rw-r--r--test/subtype1.test59
-rw-r--r--test/superlock.test268
-rw-r--r--test/swarmvtab.test246
-rw-r--r--test/swarmvtab2.test75
-rw-r--r--test/swarmvtab3.test235
-rw-r--r--test/swarmvtabfault.test65
-rw-r--r--test/symlink.test210
-rw-r--r--test/symlink2.test116
-rw-r--r--test/sync.test105
-rw-r--r--test/sync2.test161
-rw-r--r--test/syscall.test278
-rw-r--r--test/sysfault.test278
-rw-r--r--test/tabfunc01.test331
-rw-r--r--test/table.test840
-rw-r--r--test/tableapi.test252
-rw-r--r--test/tableopts.test76
-rw-r--r--test/tclsqlite.test892
-rw-r--r--test/tempdb.test98
-rw-r--r--test/tempdb2.test99
-rw-r--r--test/tempfault.test134
-rw-r--r--test/temptable.test441
-rw-r--r--test/temptable2.test360
-rw-r--r--test/temptable3.test41
-rw-r--r--test/temptrigger.test279
-rw-r--r--test/tester.tcl2600
-rw-r--r--test/testrunner.tcl705
-rw-r--r--test/thread001.test147
-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.c1584
-rw-r--r--test/threadtest4.c484
-rw-r--r--test/threadtest5.c339
-rw-r--r--test/time-wordcount.sh34
-rw-r--r--test/tkt-02a8e81d44.test36
-rw-r--r--test/tkt-18458b1a.test52
-rw-r--r--test/tkt-26ff0c2d1e.test35
-rw-r--r--test/tkt-2a5629202f.test76
-rw-r--r--test/tkt-2d1a5c67d.test128
-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-385a5b56b9.test50
-rw-r--r--test/tkt-38cb5df375.test326
-rw-r--r--test/tkt-3998683a16.test46
-rw-r--r--test/tkt-3a77c9714e.test86
-rw-r--r--test/tkt-3fe897352e.test60
-rw-r--r--test/tkt-4a03edc4c8.test46
-rw-r--r--test/tkt-4c86b126f2.test49
-rw-r--r--test/tkt-4dd95f6943.test151
-rw-r--r--test/tkt-4ef7e3cfca.test68
-rw-r--r--test/tkt-54844eea3f.test67
-rw-r--r--test/tkt-5d863f876e.test55
-rw-r--r--test/tkt-5e10420e8d.test50
-rw-r--r--test/tkt-5ee23731f.test42
-rw-r--r--test/tkt-6bfb98dfc0.test61
-rw-r--r--test/tkt-752e1646fc.test30
-rw-r--r--test/tkt-78e04e52ea.test66
-rw-r--r--test/tkt-7a31705a7e6.test27
-rw-r--r--test/tkt-7bbfb7d442.test154
-rw-r--r--test/tkt-80ba201079.test195
-rw-r--r--test/tkt-80e031a00f.test205
-rw-r--r--test/tkt-8454a207b9.test73
-rw-r--r--test/tkt-868145d012.test64
-rw-r--r--test/tkt-8c63ff0ec.test48
-rw-r--r--test/tkt-91e2e8ba6f.test52
-rw-r--r--test/tkt-94c04eaadb.test72
-rw-r--r--test/tkt-9a8b09f8e6.test323
-rw-r--r--test/tkt-9d68c883.test55
-rw-r--r--test/tkt-9f2eb3abac.test78
-rw-r--r--test/tkt-a7b7803e.test84
-rw-r--r--test/tkt-a7debbe0.test102
-rw-r--r--test/tkt-a8a0d2996a.test95
-rw-r--r--test/tkt-b1d3a2e531.test109
-rw-r--r--test/tkt-b351d95f9.test47
-rw-r--r--test/tkt-b72787b1.test82
-rw-r--r--test/tkt-b75a9ca6b0.test77
-rw-r--r--test/tkt-ba7cbfaedc.test63
-rw-r--r--test/tkt-bd484a090c.test38
-rw-r--r--test/tkt-bdc6bbbb38.test90
-rw-r--r--test/tkt-c48d99d690.test25
-rw-r--r--test/tkt-c694113d5.test36
-rw-r--r--test/tkt-cbd054fa6b.test107
-rw-r--r--test/tkt-d11f09d36e.test61
-rw-r--r--test/tkt-d635236375.test38
-rw-r--r--test/tkt-d82e3f3721.test85
-rw-r--r--test/tkt-f3e5abed55.test116
-rw-r--r--test/tkt-f67b41381a.test58
-rw-r--r--test/tkt-f777251dc7a.test105
-rw-r--r--test/tkt-f7b4edec.test75
-rw-r--r--test/tkt-f973c7ac31.test86
-rw-r--r--test/tkt-fa7bf5ec.test39
-rw-r--r--test/tkt-fc62af4523.test84
-rw-r--r--test/tkt-fc7bd6358f.test78
-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.test82
-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.test346
-rw-r--r--test/tkt2832.test67
-rw-r--r--test/tkt2854.test139
-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.test86
-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.test62
-rw-r--r--test/tkt3457.test105
-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.test123
-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.test43
-rw-r--r--test/tkt3791.test28
-rw-r--r--test/tkt3793.test112
-rw-r--r--test/tkt3810.test103
-rw-r--r--test/tkt3824.test99
-rw-r--r--test/tkt3832.test41
-rw-r--r--test/tkt3838.test58
-rw-r--r--test/tkt3841.test49
-rw-r--r--test/tkt3871.test53
-rw-r--r--test/tkt3879.test52
-rw-r--r--test/tkt3911.test58
-rw-r--r--test/tkt3918.test59
-rw-r--r--test/tkt3922.test89
-rw-r--r--test/tkt3929.test52
-rw-r--r--test/tkt3935.test57
-rw-r--r--test/tkt3992.test81
-rw-r--r--test/tkt3997.test73
-rw-r--r--test/tkt4018.test90
-rw-r--r--test/tokenize.test65
-rw-r--r--test/tpch01.test200
-rw-r--r--test/trace.test269
-rw-r--r--test/trace2.test155
-rw-r--r--test/trace3.test333
-rw-r--r--test/trans.test994
-rw-r--r--test/trans2.test232
-rw-r--r--test/trans3.test76
-rw-r--r--test/transitive1.test429
-rw-r--r--test/trigger1.test841
-rw-r--r--test/trigger2.test793
-rw-r--r--test/trigger3.test200
-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.test253
-rw-r--r--test/triggerA.test230
-rw-r--r--test/triggerB.test153
-rw-r--r--test/triggerC.test1074
-rw-r--r--test/triggerD.test219
-rw-r--r--test/triggerE.test114
-rw-r--r--test/triggerF.test71
-rw-r--r--test/triggerG.test94
-rw-r--r--test/triggerupfrom.test173
-rw-r--r--test/trustschema1.test251
-rw-r--r--test/tt3_checkpoint.c148
-rw-r--r--test/tt3_index.c74
-rw-r--r--test/tt3_lookaside1.c99
-rw-r--r--test/tt3_shared.c55
-rw-r--r--test/tt3_stress.c364
-rw-r--r--test/tt3_vacuum.c90
-rw-r--r--test/types.test325
-rw-r--r--test/types2.test340
-rw-r--r--test/types3.test99
-rw-r--r--test/unionall.test444
-rw-r--r--test/unionall2.test58
-rw-r--r--test/unionallfault.test36
-rw-r--r--test/unionvtab.test457
-rw-r--r--test/unionvtabfault.test83
-rw-r--r--test/unique.test261
-rw-r--r--test/unique2.test86
-rw-r--r--test/unixexcl.test129
-rw-r--r--test/unordered.test69
-rw-r--r--test/update.test735
-rw-r--r--test/update2.test235
-rw-r--r--test/upfrom1.tcl115
-rw-r--r--test/upfrom1.test210
-rw-r--r--test/upfrom2.test405
-rw-r--r--test/upfrom3.test261
-rw-r--r--test/upfrom4.test130
-rw-r--r--test/upfromfault.test139
-rw-r--r--test/upsert1.test258
-rw-r--r--test/upsert2.test170
-rw-r--r--test/upsert3.test58
-rw-r--r--test/upsert4.test407
-rw-r--r--test/upsert5.test411
-rw-r--r--test/upsertfault.test38
-rw-r--r--test/uri.test345
-rw-r--r--test/uri2.test63
-rw-r--r--test/userauth01.test257
-rw-r--r--test/utf16align.test96
-rw-r--r--test/vacuum-into.test190
-rw-r--r--test/vacuum.test404
-rw-r--r--test/vacuum2.test251
-rw-r--r--test/vacuum3.test350
-rw-r--r--test/vacuum4.test69
-rw-r--r--test/vacuum5.test155
-rw-r--r--test/vacuum6.test113
-rw-r--r--test/vacuummem.test74
-rw-r--r--test/varint.test34
-rw-r--r--test/veryquick.test18
-rw-r--r--test/view.test779
-rw-r--r--test/view2.test49
-rw-r--r--test/view3.test60
-rw-r--r--test/vt02.c1019
-rw-r--r--test/vtab1.test1593
-rw-r--r--test/vtab2.test163
-rw-r--r--test/vtab3.test140
-rw-r--r--test/vtab4.test193
-rw-r--r--test/vtab5.test154
-rw-r--r--test/vtab6.test583
-rw-r--r--test/vtab7.test207
-rw-r--r--test/vtab8.test78
-rw-r--r--test/vtab9.test70
-rw-r--r--test/vtabA.test164
-rw-r--r--test/vtabB.test79
-rw-r--r--test/vtabC.test116
-rw-r--r--test/vtabD.test69
-rw-r--r--test/vtabE.test52
-rw-r--r--test/vtabF.test45
-rw-r--r--test/vtabH.test261
-rw-r--r--test/vtabI.test126
-rw-r--r--test/vtabJ.test154
-rw-r--r--test/vtabK.test83
-rw-r--r--test/vtab_alter.test103
-rw-r--r--test/vtab_err.test87
-rw-r--r--test/vtab_shared.test278
-rw-r--r--test/vtabdistinct.test41
-rw-r--r--test/vtabdrop.test127
-rw-r--r--test/vtabrhs1.test76
-rw-r--r--test/wal.test1550
-rw-r--r--test/wal2.test1353
-rw-r--r--test/wal3.test652
-rw-r--r--test/wal4.test64
-rw-r--r--test/wal5.test478
-rw-r--r--test/wal6.test269
-rw-r--r--test/wal64k.test63
-rw-r--r--test/wal7.test118
-rw-r--r--test/wal8.test91
-rw-r--r--test/wal9.test94
-rw-r--r--test/wal_common.tcl93
-rw-r--r--test/walbak.test359
-rw-r--r--test/walbig.test78
-rw-r--r--test/walblock.test114
-rw-r--r--test/walcksum.test338
-rw-r--r--test/walcrash.test296
-rw-r--r--test/walcrash2.test98
-rw-r--r--test/walcrash3.test128
-rw-r--r--test/walcrash4.test85
-rw-r--r--test/walfault.test590
-rw-r--r--test/walfault2.test91
-rw-r--r--test/walhook.test109
-rw-r--r--test/walmode.test393
-rw-r--r--test/walnoshm.test184
-rw-r--r--test/waloverwrite.test162
-rw-r--r--test/walpersist.test126
-rw-r--r--test/walprotocol.test201
-rw-r--r--test/walprotocol2.test97
-rw-r--r--test/walro.test300
-rw-r--r--test/walro2.test411
-rw-r--r--test/walrofault.test60
-rw-r--r--test/walsetlk.test199
-rw-r--r--test/walshared.test62
-rw-r--r--test/walslow.test231
-rw-r--r--test/walthread.test529
-rw-r--r--test/walvfs.test437
-rw-r--r--test/wapp.tcl987
-rwxr-xr-xtest/wapptest.tcl909
-rw-r--r--test/where.test1637
-rw-r--r--test/where2.test781
-rw-r--r--test/where3.test496
-rw-r--r--test/where4.test307
-rw-r--r--test/where5.test288
-rw-r--r--test/where6.test154
-rw-r--r--test/where7.test23388
-rw-r--r--test/where8.test773
-rw-r--r--test/where9.test1004
-rw-r--r--test/whereA.test189
-rw-r--r--test/whereB.test543
-rw-r--r--test/whereC.test70
-rw-r--r--test/whereD.test433
-rw-r--r--test/whereE.test68
-rw-r--r--test/whereF.test312
-rw-r--r--test/whereG.test388
-rw-r--r--test/whereH.test139
-rw-r--r--test/whereI.test99
-rw-r--r--test/whereJ.test674
-rw-r--r--test/whereK.test72
-rw-r--r--test/whereL.test193
-rw-r--r--test/whereM.test112
-rw-r--r--test/wherefault.test83
-rw-r--r--test/wherelfault.test82
-rw-r--r--test/wherelimit.test342
-rw-r--r--test/wherelimit2.test303
-rw-r--r--test/widetab1.test156
-rw-r--r--test/win32heap.test73
-rw-r--r--test/win32lock.test184
-rw-r--r--test/win32longpath.test139
-rw-r--r--test/win32nolock.test126
-rw-r--r--test/window1.test2213
-rw-r--r--test/window2.tcl494
-rw-r--r--test/window2.test976
-rw-r--r--test/window3.tcl363
-rw-r--r--test/window3.test40613
-rw-r--r--test/window4.tcl424
-rw-r--r--test/window4.test1390
-rw-r--r--test/window5.test96
-rw-r--r--test/window6.test371
-rw-r--r--test/window7.tcl91
-rw-r--r--test/window7.test186
-rw-r--r--test/window8.tcl495
-rw-r--r--test/window8.test6543
-rw-r--r--test/window9.test285
-rw-r--r--test/windowA.test309
-rw-r--r--test/windowB.test413
-rw-r--r--test/windowC.test85
-rw-r--r--test/windowD.test94
-rw-r--r--test/windowE.test58
-rw-r--r--test/windowerr.tcl72
-rw-r--r--test/windowerr.test116
-rw-r--r--test/windowfault.test334
-rw-r--r--test/windowpushd.test236
-rw-r--r--test/with1.test1240
-rw-r--r--test/with2.test628
-rw-r--r--test/with3.test247
-rw-r--r--test/with4.test52
-rw-r--r--test/with5.test194
-rw-r--r--test/with6.test322
-rw-r--r--test/withM.test74
-rw-r--r--test/without_rowid1.test490
-rw-r--r--test/without_rowid2.test125
-rw-r--r--test/without_rowid3.test2111
-rw-r--r--test/without_rowid4.test764
-rw-r--r--test/without_rowid5.test289
-rw-r--r--test/without_rowid6.test134
-rw-r--r--test/without_rowid7.test60
-rw-r--r--test/wordcount.c659
-rw-r--r--test/writecrash.test68
-rw-r--r--test/zeroblob.test343
-rw-r--r--test/zeroblobfault.test28
-rw-r--r--test/zerodamage.test122
-rw-r--r--test/zipfile.test858
-rw-r--r--test/zipfile2.test243
-rw-r--r--test/zipfilefault.test166
1221 files changed, 520675 insertions, 0 deletions
diff --git a/test/8_3_names.test b/test/8_3_names.test
new file mode 100644
index 0000000..1d63f5d
--- /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
+ load_static_extension db wholenumber
+ 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
+ load_static_extension db2 wholenumber
+ 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/affinity2.test b/test/affinity2.test
new file mode 100644
index 0000000..6ad257a
--- /dev/null
+++ b/test/affinity2.test
@@ -0,0 +1,136 @@
+# 2015-06-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 type affinity in comparison operations.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix affinity2
+
+do_execsql_test affinity2-100 {
+ CREATE TABLE t1(
+ xi INTEGER,
+ xr REAL,
+ xb BLOB,
+ xn NUMERIC,
+ xt TEXT
+ );
+ INSERT INTO t1(rowid,xi,xr,xb,xn,xt) VALUES(1,1,1,1,1,1);
+ INSERT INTO t1(rowid,xi,xr,xb,xn,xt) VALUES(2,'2','2','2','2','2');
+ INSERT INTO t1(rowid,xi,xr,xb,xn,xt) VALUES(3,'03','03','03','03','03');
+
+} {}
+do_execsql_test affinity2-110 {
+ SELECT xi, typeof(xi) FROM t1 ORDER BY rowid;
+} {1 integer 2 integer 3 integer}
+do_execsql_test affinity2-120 {
+ SELECT xr, typeof(xr) FROM t1 ORDER BY rowid;
+} {1.0 real 2.0 real 3.0 real}
+do_execsql_test affinity2-130 {
+ SELECT xb, typeof(xb) FROM t1 ORDER BY rowid;
+} {1 integer 2 text 03 text}
+do_execsql_test affinity2-140 {
+ SELECT xn, typeof(xn) FROM t1 ORDER BY rowid;
+} {1 integer 2 integer 3 integer}
+do_execsql_test affinity2-150 {
+ SELECT xt, typeof(xt) FROM t1 ORDER BY rowid;
+} {1 text 2 text 03 text}
+
+do_execsql_test affinity2-200 {
+ SELECT rowid, xi==xt, xi==xb, xi==+xt FROM t1 ORDER BY rowid;
+} {1 1 1 1 2 1 1 1 3 1 1 1}
+do_execsql_test affinity2-210 {
+ SELECT rowid, xr==xt, xr==xb, xr==+xt FROM t1 ORDER BY rowid;
+} {1 1 1 1 2 1 1 1 3 1 1 1}
+do_execsql_test affinity2-220 {
+ SELECT rowid, xn==xt, xn==xb, xn==+xt FROM t1 ORDER BY rowid;
+} {1 1 1 1 2 1 1 1 3 1 1 1}
+
+do_execsql_test affinity2-300 {
+ SELECT rowid, xt==+xi, xt==xi, xt==xb FROM t1 ORDER BY rowid;
+} {1 1 1 0 2 1 1 1 3 0 1 1}
+
+#-------------------------------------------------------------------------
+do_execsql_test 400 {
+ CREATE TABLE ttt(c0, c1);
+ CREATE INDEX ii ON ttt(CAST(c0 AS NUMERIC));
+ INSERT INTO ttt VALUES('abc', '-1');
+}
+do_execsql_test 410 {
+ SELECT * FROM ttt WHERE CAST(c0 AS NUMERIC) > c1 GROUP BY rowid;
+} {abc -1}
+do_execsql_test 420 {
+ SELECT * FROM ttt INDEXED BY ii WHERE CAST(c0 AS NUMERIC) > c1 GROUP BY rowid;
+} {abc -1}
+
+do_execsql_test 430 {
+ CREATE TABLE t3(a, b, c INTEGER);
+ CREATE INDEX t3ac ON t3(a, c-1);
+ INSERT INTO t3 VALUES(1, 1, 1);
+ INSERT INTO t3 VALUES(2, 1, 0);
+ INSERT INTO t3 VALUES(3, 1, 1);
+ INSERT INTO t3 VALUES(4, 1, 0);
+ INSERT INTO t3 VALUES(5, 1, 1);
+}
+do_execsql_test 440 {
+ SELECT * FROM t3 WHERE c='0' ORDER BY a;
+} {2 1 0 4 1 0}
+
+# 2019-08-22 ticket https://sqlite.org/src/info/d99f1ffe836c591ac57f
+# False positive in sqlite3ExprNeedsNoAffinityChange()
+#
+do_execsql_test 500 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 TEXT UNIQUE, c1);
+ INSERT INTO t0(c0) VALUES (-1);
+ SELECT quote(- x'ce'), quote(t0.c0), quote(- x'ce' >= t0.c0) FROM t0;
+} {0 '-1' 1}
+do_execsql_test 501 {
+ SELECT * FROM t0 WHERE - x'ce' >= t0.c0;
+} {-1 {}}
+do_execsql_test 502 {
+ SELECT quote(+-+x'ce'), quote(t0.c0), quote(+-+x'ce' >= t0.c0) FROM t0;
+} {0 '-1' 1}
+do_execsql_test 503 {
+ SELECT * FROM t0 WHERE +-+x'ce' >= t0.c0;
+} {-1 {}}
+do_execsql_test 504 {
+ SELECT quote(- 'ce'), quote(t0.c0), quote(- 'ce' >= t0.c0) FROM t0;
+} {0 '-1' 1}
+do_execsql_test 505 {
+ SELECT * FROM t0 WHERE - 'ce' >= t0.c0;
+} {-1 {}}
+do_execsql_test 506 {
+ SELECT quote(+-+'ce'), quote(t0.c0), quote(+-+'ce' >= t0.c0) FROM t0;
+} {0 '-1' 1}
+do_execsql_test 507 {
+ SELECT * FROM t0 WHERE +-+'ce' >= t0.c0;
+} {-1 {}}
+
+# 2019-08-30 ticket https://www.sqlite.org/src/info/40812aea1fde9594
+#
+# Due to some differences in floating point computations, these tests do not
+# work under valgrind.
+#
+if {![info exists ::G(valgrind)]} {
+ do_execsql_test 600 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 REAL UNIQUE);
+ INSERT INTO t0(c0) VALUES (3175546974276630385);
+ SELECT 3175546974276630385 < c0 FROM t0;
+ } {1}
+ do_execsql_test 601 {
+ SELECT 1 FROM t0 WHERE 3175546974276630385 < c0;
+ } {1}
+}
+
+finish_test
diff --git a/test/affinity3.test b/test/affinity3.test
new file mode 100644
index 0000000..48942de
--- /dev/null
+++ b/test/affinity3.test
@@ -0,0 +1,123 @@
+# 2017-01-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.
+#
+#***********************************************************************
+#
+# Test cases for bugs:
+#
+# https://www.sqlite.org/src/info/91e2e8ba6ff2e2
+# https://www.sqlite.org/src/info/7ffd1ca1d2ad4ecf
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Ticket https://www.sqlite.org/src/info/91e2e8ba6ff2e2 (2011-09-19)
+# Automatic index causes undesired type conversions
+#
+do_execsql_test affinity3-100 {
+ CREATE TABLE customer (id INT PRIMARY KEY);
+ CREATE TABLE apr (id INT PRIMARY KEY, apr REAL);
+
+ CREATE VIEW v1 AS
+ SELECT c.id, i.apr
+ FROM customer c
+ LEFT JOIN apr i ON i.id=c.id;
+
+ CREATE VIEW v1rj AS
+ SELECT c.id, i.apr
+ FROM apr i
+ RIGHT JOIN customer c ON i.id=c.id;
+
+ CREATE VIEW v2 AS
+ SELECT c.id, v1.apr
+ FROM customer c
+ LEFT JOIN v1 ON v1.id=c.id;
+
+ CREATE VIEW v2rj AS
+ SELECT c.id, v1.apr
+ FROM v1 RIGHT JOIN customer c ON v1.id=c.id;
+
+ CREATE VIEW v2rjrj AS
+ SELECT c.id, v1rj.apr
+ FROM v1rj RIGHT JOIN customer c ON v1rj.id=c.id;
+
+ INSERT INTO customer (id) VALUES (1);
+ INSERT INTO apr (id, apr) VALUES (1, 12);
+ INSERT INTO customer (id) VALUES (2);
+ INSERT INTO apr (id, apr) VALUES (2, 12.01);
+}
+do_execsql_test affinity3-110 {
+ PRAGMA automatic_index=ON;
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v1;
+} {1 0.12 real 2 0.1201 real}
+do_execsql_test affinity3-111 {
+ PRAGMA automatic_index=ON;
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v1rj;
+} {1 0.12 real 2 0.1201 real}
+do_execsql_test affinity3-120 {
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v2;
+} {1 0.12 real 2 0.1201 real}
+do_execsql_test affinity3-121 {
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v2rj;
+} {1 0.12 real 2 0.1201 real}
+do_execsql_test affinity3-122 {
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v2rjrj;
+} {1 0.12 real 2 0.1201 real}
+do_execsql_test affinity3-130 {
+ PRAGMA automatic_index=OFF;
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v1;
+} {1 0.12 real 2 0.1201 real}
+do_execsql_test affinity3-131 {
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v1rj;
+} {1 0.12 real 2 0.1201 real}
+do_execsql_test affinity3-140 {
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v2;
+} {1 0.12 real 2 0.1201 real}
+do_execsql_test affinity3-141 {
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v2rj;
+} {1 0.12 real 2 0.1201 real}
+do_execsql_test affinity3-142 {
+ SELECT id, (apr / 100), typeof(apr) apr_type FROM v2rjrj;
+} {1 0.12 real 2 0.1201 real}
+
+# Ticket https://www.sqlite.org/src/info/7ffd1ca1d2ad4ecf (2017-01-16)
+# Incorrect affinity when using automatic indexes
+#
+do_execsql_test affinity3-200 {
+ CREATE TABLE map_integer (id INT, name);
+ INSERT INTO map_integer VALUES(1,'a');
+ CREATE TABLE map_text (id TEXT, name);
+ INSERT INTO map_text VALUES('4','e');
+ CREATE TABLE data (id TEXT, name);
+ INSERT INTO data VALUES(1,'abc');
+ INSERT INTO data VALUES('4','xyz');
+ CREATE VIEW idmap as
+ SELECT * FROM map_integer
+ UNION SELECT * FROM map_text;
+ CREATE TABLE mzed AS SELECT * FROM idmap;
+}
+
+#do_execsql_test affinity3-210 {
+ #PRAGMA automatic_index=ON;
+ #SELECT * FROM data JOIN idmap USING(id);
+#} {1 abc a 4 xyz e}
+do_execsql_test affinity3-220 {
+ SELECT * FROM data JOIN mzed USING(id);
+} {1 abc a 4 xyz e}
+
+do_execsql_test affinity3-250 {
+ PRAGMA automatic_index=OFF;
+ SELECT * FROM data JOIN idmap USING(id);
+} {1 abc a 4 xyz e}
+do_execsql_test affinity3-260 {
+ SELECT * FROM data JOIN mzed USING(id);
+} {1 abc a 4 xyz e}
+
+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/aggnested.test b/test/aggnested.test
new file mode 100644
index 0000000..1b8b608
--- /dev/null
+++ b/test/aggnested.test
@@ -0,0 +1,365 @@
+# 2012-08-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 for processing aggregate queries with
+# subqueries in which the subqueries hold the aggregate functions
+# or in which the subqueries are themselves aggregate queries
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix aggnested
+
+do_test aggnested-1.1 {
+ db eval {
+ CREATE TABLE t1(a1 INTEGER);
+ INSERT INTO t1 VALUES(1), (2), (3);
+ CREATE TABLE t2(b1 INTEGER);
+ INSERT INTO t2 VALUES(4), (5);
+ SELECT (SELECT group_concat(a1,'x') FROM t2) FROM t1;
+ }
+} {1x2x3}
+do_test aggnested-1.2 {
+ db eval {
+ SELECT
+ (SELECT group_concat(a1,'x') || '-' || group_concat(b1,'y') FROM t2)
+ FROM t1;
+ }
+} {1x2x3-4y5}
+do_test aggnested-1.3 {
+ db eval {
+ SELECT (SELECT group_concat(b1,a1) FROM t2) FROM t1;
+ }
+} {415 425 435}
+do_test aggnested-1.4 {
+ db eval {
+ SELECT (SELECT group_concat(a1,b1) FROM t2) FROM t1;
+ }
+} {151 252 353}
+
+
+# This test case is a copy of the one in
+# http://www.mail-archive.com/sqlite-users@sqlite.org/msg70787.html
+#
+do_test aggnested-2.0 {
+ sqlite3 db2 :memory:
+ db2 eval {
+ CREATE TABLE t1 (A1 INTEGER NOT NULL,A2 INTEGER NOT NULL,A3 INTEGER NOT
+ NULL,A4 INTEGER NOT NULL,PRIMARY KEY(A1));
+ REPLACE INTO t1 VALUES(1,11,111,1111);
+ REPLACE INTO t1 VALUES(2,22,222,2222);
+ REPLACE INTO t1 VALUES(3,33,333,3333);
+ CREATE TABLE t2 (B1 INTEGER NOT NULL,B2 INTEGER NOT NULL,B3 INTEGER NOT
+ NULL,B4 INTEGER NOT NULL,PRIMARY KEY(B1));
+ REPLACE INTO t2 VALUES(1,88,888,8888);
+ REPLACE INTO t2 VALUES(2,99,999,9999);
+ SELECT (SELECT GROUP_CONCAT(CASE WHEN a1=1 THEN'A' ELSE 'B' END) FROM t2),
+ t1.*
+ FROM t1;
+ }
+} {A,B,B 1 11 111 1111}
+db2 close
+
+##################### Test cases for ticket [bfbf38e5e9956ac69f] ############
+#
+# This first test case is the original problem report:
+do_test aggnested-3.0 {
+ db eval {
+ CREATE TABLE AAA (
+ aaa_id INTEGER PRIMARY KEY AUTOINCREMENT
+ );
+ CREATE TABLE RRR (
+ rrr_id INTEGER PRIMARY KEY AUTOINCREMENT,
+ rrr_date INTEGER NOT NULL,
+ rrr_aaa INTEGER
+ );
+ CREATE TABLE TTT (
+ ttt_id INTEGER PRIMARY KEY AUTOINCREMENT,
+ target_aaa INTEGER NOT NULL,
+ source_aaa INTEGER NOT NULL
+ );
+ insert into AAA (aaa_id) values (2);
+ insert into TTT (ttt_id, target_aaa, source_aaa)
+ values (4469, 2, 2);
+ insert into TTT (ttt_id, target_aaa, source_aaa)
+ values (4476, 2, 1);
+ insert into RRR (rrr_id, rrr_date, rrr_aaa)
+ values (0, 0, NULL);
+ insert into RRR (rrr_id, rrr_date, rrr_aaa)
+ values (2, 4312, 2);
+ SELECT i.aaa_id,
+ (SELECT sum(CASE WHEN (t.source_aaa == i.aaa_id) THEN 1 ELSE 0 END)
+ FROM TTT t
+ ) AS segfault
+ FROM
+ (SELECT curr.rrr_aaa as aaa_id
+ FROM RRR curr
+ -- you also can comment out the next line
+ -- it causes segfault to happen after one row is outputted
+ INNER JOIN AAA a ON (curr.rrr_aaa = aaa_id)
+ LEFT JOIN RRR r ON (r.rrr_id <> 0 AND r.rrr_date < curr.rrr_date)
+ GROUP BY curr.rrr_id
+ HAVING r.rrr_date IS NULL
+ ) i;
+ }
+} {2 1}
+
+# Further variants of the test case, as found in the ticket
+#
+do_test aggnested-3.1 {
+ db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1 (
+ id1 INTEGER PRIMARY KEY AUTOINCREMENT,
+ value1 INTEGER
+ );
+ INSERT INTO t1 VALUES(4469,2),(4476,1);
+ CREATE TABLE t2 (
+ id2 INTEGER PRIMARY KEY AUTOINCREMENT,
+ value2 INTEGER
+ );
+ INSERT INTO t2 VALUES(0,1),(2,2);
+ SELECT
+ (SELECT sum(value2==xyz) FROM t2)
+ FROM
+ (SELECT curr.value1 as xyz
+ FROM t1 AS curr LEFT JOIN t1 AS other
+ GROUP BY curr.id1);
+ }
+} {1 1}
+do_test aggnested-3.1-rj {
+ db eval {
+ SELECT
+ (SELECT sum(value2==xyz) FROM t2)
+ FROM
+ (SELECT curr.value1 as xyz
+ FROM t1 AS other RIGHT JOIN t1 AS curr
+ GROUP BY curr.id1);
+ }
+} {1 1}
+
+do_test aggnested-3.2 {
+ db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1 (
+ id1 INTEGER,
+ value1 INTEGER,
+ x1 INTEGER
+ );
+ INSERT INTO t1 VALUES(4469,2,98),(4469,1,99),(4469,3,97);
+ CREATE TABLE t2 (
+ value2 INTEGER
+ );
+ INSERT INTO t2 VALUES(1);
+ SELECT
+ (SELECT sum(value2==xyz) FROM t2)
+ FROM
+ (SELECT value1 as xyz, max(x1) AS pqr
+ FROM t1
+ GROUP BY id1);
+ SELECT
+ (SELECT sum(value2<>xyz) FROM t2)
+ FROM
+ (SELECT value1 as xyz, max(x1) AS pqr
+ FROM t1
+ GROUP BY id1);
+ }
+} {1 0}
+do_test aggnested-3.3 {
+ db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(id1, value1);
+ INSERT INTO t1 VALUES(4469,2),(4469,1);
+ CREATE TABLE t2 (value2);
+ INSERT INTO t2 VALUES(1);
+ SELECT (SELECT sum(value2=value1) FROM t2), max(value1)
+ FROM t1
+ GROUP BY id1;
+ }
+} {0 2}
+
+# A batch of queries all doing approximately the same operation involving
+# two nested aggregate queries.
+#
+do_test aggnested-3.11 {
+ db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(id1, value1);
+ INSERT INTO t1 VALUES(4469,12),(4469,11),(4470,34);
+ CREATE INDEX t1id1 ON t1(id1);
+ CREATE TABLE t2 (value2);
+ INSERT INTO t2 VALUES(12),(34),(34);
+ INSERT INTO t2 SELECT value2 FROM t2;
+
+ SELECT max(value1), (SELECT count(*) FROM t2 WHERE value2=max(value1))
+ FROM t1
+ GROUP BY id1;
+ }
+} {12 2 34 4}
+do_test aggnested-3.12 {
+ db eval {
+ SELECT max(value1), (SELECT count(*) FROM t2 WHERE value2=value1)
+ FROM t1
+ GROUP BY id1;
+ }
+} {12 2 34 4}
+do_test aggnested-3.13 {
+ db eval {
+ SELECT value1, (SELECT sum(value2=value1) FROM t2)
+ FROM t1;
+ }
+} {12 2 11 0 34 4}
+do_test aggnested-3.14 {
+ db eval {
+ SELECT value1, (SELECT sum(value2=value1) FROM t2)
+ FROM t1
+ WHERE value1 IN (SELECT max(value1) FROM t1 GROUP BY id1);
+ }
+} {12 2 34 4}
+do_test aggnested-3.15 {
+ # FIXME: If case 3.16 works, then this case really ought to work too...
+ catchsql {
+ SELECT max(value1), (SELECT sum(value2=max(value1)) FROM t2)
+ FROM t1
+ GROUP BY id1;
+ }
+} {1 {misuse of aggregate function max()}}
+do_test aggnested-3.16 {
+ db eval {
+ SELECT max(value1), (SELECT sum(value2=value1) FROM t2)
+ FROM t1
+ GROUP BY id1;
+ }
+} {12 2 34 4}
+
+# 2019-08-31
+# Problem found by dbsqlfuzz
+#
+do_execsql_test aggnested-4.1 {
+ DROP TABLE IF EXISTS aa;
+ DROP TABLE IF EXISTS bb;
+ CREATE TABLE aa(x INT); INSERT INTO aa(x) VALUES(123);
+ CREATE TABLE bb(y INT); INSERT INTO bb(y) VALUES(456);
+ SELECT (SELECT sum(x+(SELECT y)) FROM bb) FROM aa;
+} {579}
+do_execsql_test aggnested-4.2 {
+ SELECT (SELECT sum(x+y) FROM bb) FROM aa;
+} {579}
+do_execsql_test aggnested-4.3 {
+ DROP TABLE IF EXISTS tx;
+ DROP TABLE IF EXISTS ty;
+ CREATE TABLE tx(x INT);
+ INSERT INTO tx VALUES(1),(2),(3),(4),(5);
+ CREATE TABLE ty(y INT);
+ INSERT INTO ty VALUES(91),(92),(93);
+ SELECT min((SELECT count(y) FROM ty)) FROM tx;
+} {3}
+do_execsql_test aggnested-4.4 {
+ SELECT max((SELECT a FROM (SELECT count(*) AS a FROM ty) AS s)) FROM tx;
+} {3}
+
+#--------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE x1(a, b);
+ INSERT INTO x1 VALUES(1, 2);
+ CREATE TABLE x2(x);
+ INSERT INTO x2 VALUES(NULL), (NULL), (NULL);
+}
+
+# At one point, aggregate "total()" in the query below was being processed
+# as part of the outer SELECT, not as part of the sub-select with no FROM
+# clause.
+do_execsql_test 5.1 {
+ SELECT ( SELECT total( (SELECT b FROM x1) ) ) FROM x2;
+} {2.0 2.0 2.0}
+
+do_execsql_test 5.2 {
+ SELECT ( SELECT total( (SELECT 2 FROM x1) ) ) FROM x2;
+} {2.0 2.0 2.0}
+
+do_execsql_test 5.3 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b);
+}
+
+do_execsql_test 5.4 {
+ SELECT(
+ SELECT max(b) LIMIT (
+ SELECT total( (SELECT a FROM t1) )
+ )
+ )
+ FROM t2;
+} {{}}
+
+do_execsql_test 5.5 {
+ CREATE TABLE a(b);
+ WITH c AS(SELECT a)
+ SELECT(SELECT(SELECT group_concat(b, b)
+ LIMIT(SELECT 0.100000 *
+ AVG(DISTINCT(SELECT 0 FROM a ORDER BY b, b, b))))
+ FROM a GROUP BY b,
+ b, b) FROM a EXCEPT SELECT b FROM a ORDER BY b,
+ b, b;
+}
+
+#-------------------------------------------------------------------------
+# dbsqlfuzz a779227f721a834df95f4f42d0c31550a1f8b8a2
+#
+reset_db
+do_execsql_test 6.0 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b);
+
+ INSERT INTO t1 VALUES('x');
+ INSERT INTO t2 VALUES(1);
+}
+
+do_execsql_test 6.1.1 {
+ SELECT (
+ SELECT t2.b FROM (SELECT t2.b AS c FROM t1) GROUP BY 1 HAVING t2.b
+ )
+ FROM t2 GROUP BY 'constant_string';
+} {1}
+do_execsql_test 6.1.2 {
+ SELECT (
+ SELECT c FROM (SELECT t2.b AS c FROM t1) GROUP BY c HAVING t2.b
+ )
+ FROM t2 GROUP BY 'constant_string';
+} {1}
+
+do_execsql_test 6.2.0 {
+ UPDATE t2 SET b=0
+}
+do_execsql_test 6.2.1 {
+ SELECT (
+ SELECT t2.b FROM (SELECT t2.b AS c FROM t1) GROUP BY 1 HAVING t2.b
+ )
+ FROM t2 GROUP BY 'constant_string';
+} {{}}
+do_execsql_test 6.2.2 {
+ SELECT (
+ SELECT c FROM (SELECT t2.b AS c FROM t1) GROUP BY c HAVING t2.b
+ )
+ FROM t2 GROUP BY 'constant_string';
+} {{}}
+
+
+
+
+
+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..46e8115
--- /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
+
+ifcapable rbu { run_test_suite rbu }
+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
+run_test_suite mmap
+
+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..0088858
--- /dev/null
+++ b/test/alter.test
@@ -0,0 +1,938 @@
+# 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 temp.sqlite_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 temp.sqlite_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);
+ -- Different case for the table name in the trigger.
+ 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 temp.sqlite_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_column() and
+# rename_table() functions do not crash when handed bad input.
+#
+sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+do_test alter-9.1 {
+ execsql {SELECT SQLITE_RENAME_COLUMN(0,0,0,0,0,0,0,0,0)}
+} {{}}
+foreach {tn sql} {
+ 1 { SELECT SQLITE_RENAME_TABLE(0,0,0,0,0,0,0) }
+ 2 { SELECT SQLITE_RENAME_TABLE(10,20,30,40,50,60,70) }
+ 3 { SELECT SQLITE_RENAME_TABLE('foo','foo','foo','foo','foo','foo','foo') }
+} {
+ do_test alter-9.2.$tn {
+ catch { execsql $sql }
+ } 1
+}
+sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+
+# If the INTERNAL_FUNCTIONS test-control is disabled (which is the default),
+# then the sqlite_rename_table() SQL function is not accessible to ordinary SQL.
+#
+do_catchsql_test alter-9.3 {
+ SELECT sqlite_rename_table(0,0,0,0,0,0,0);
+} {1 {no such function: sqlite_rename_table}}
+
+#------------------------------------------------------------------------
+# 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);
+ INSERT INTO t3651 VALUES(5);
+ 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 stat4 { lappend system_table_list 4 sqlite_stat4 }
+
+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"]
+}
+
+#------------------------------------------------------------------------
+# Verify that ALTER TABLE works on tables with the WITHOUT rowid option.
+#
+do_execsql_test alter-16.1 {
+ CREATE TABLE t16a(a TEXT, b REAL, c INT, PRIMARY KEY(a,b)) WITHOUT rowid;
+ INSERT INTO t16a VALUES('abc',1.25,99);
+ ALTER TABLE t16a ADD COLUMN d TEXT DEFAULT 'xyzzy';
+ INSERT INTO t16a VALUES('cba',5.5,98,'fizzle');
+ SELECT * FROM t16a ORDER BY a;
+} {abc 1.25 99 xyzzy cba 5.5 98 fizzle}
+do_execsql_test alter-16.2 {
+ ALTER TABLE t16a RENAME TO t16a_rn;
+ SELECT * FROM t16a_rn ORDER BY a;
+} {abc 1.25 99 xyzzy cba 5.5 98 fizzle}
+
+# 2018-09-16 ticket b41031ea2b5372378cb3d2d43cf9fe2a4a5c2510
+#
+ifcapable rtree {
+ db close
+ sqlite3 db :memory:
+ do_execsql_test alter-17.100 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE VIRTUAL TABLE t2 USING rtree(id,x0,x1);
+ INSERT INTO t1 VALUES(1,'apple'),(2,'fig'),(3,'pear');
+ INSERT INTO t2 VALUES(1,1.0,2.0),(2,2.0,3.0),(3,1.5,3.5);
+ CREATE TRIGGER r1 AFTER UPDATE ON t1 BEGIN
+ DELETE FROM t2 WHERE id = OLD.a;
+ END;
+ ALTER TABLE t1 RENAME TO t3;
+ UPDATE t3 SET b='peach' WHERE a=2;
+ SELECT * FROM t2 ORDER BY 1;
+ } {1 1.0 2.0 3 1.5 3.5}
+}
+
+# 2021-03-08 dbsqlfuzz 3f0a7245b69cd08617d7d7781ebaedb0fe765a93
+reset_db
+do_catchsql_test alter-18.1 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE log(a INTEGER PRIMARY KEY,b,c);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO logx(a,b,c) VALUES(new.a,new.b,new.c)
+ ON CONFLICT(a) DO UPDATE SET c=excluded.c, b=new.b;
+ END;
+ ALTER TABLE log RENAME COLUMN a TO x;
+} {1 {error in trigger tr1: no such table: main.logx}}
+
+# 2021-10-13 dbsqlfuzz e89174cbfad2d904f06b5e24df0a22510b6a1c1e
+reset_db
+do_execsql_test alter-19.1 {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(c);
+ CREATE TRIGGER r1 AFTER INSERT ON t2 BEGIN
+ UPDATE t2 SET (c)=(
+ EXISTS(SELECT 1 WHERE (WITH cte1(a) AS (SELECT 1 FROM t1 WHERE (SELECT 1 WHERE (WITH cte2(b) AS (VALUES(1))SELECT b FROM cte2)))SELECT a FROM cte1))
+ );
+ END;
+ ALTER TABLE t2 RENAME TO t3;
+} {}
+do_execsql_test alter-19.2 {
+ SELECT name FROM sqlite_schema WHERE sql LIKE '%t2%';
+} {}
+do_execsql_test alter-19.3 {
+ SELECT name FROM sqlite_schema WHERE sql LIKE '%t3%' ORDER BY name;
+} {r1 t3}
+
+
+finish_test
diff --git a/test/alter2.test b/test/alter2.test
new file mode 100644
index 0000000..aae0061
--- /dev/null
+++ b/test/alter2.test
@@ -0,0 +1,470 @@
+# 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]
+ sqlite3_db_config dbat DEFENSIVE 0
+ 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.
+#
+sqlite3_db_config db DEFENSIVE 0
+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..c6f26b0
--- /dev/null
+++ b/test/alter3.test
@@ -0,0 +1,443 @@
+# 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".
+#
+
+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 {
+ sqlite3_db_config db LEGACY_FILE_FORMAT 1
+ execsql {
+ 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);
+ INSERT INTO t1 VALUES(1,2);
+ }
+ 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]
+ sqlite3_db_config db LEGACY_FILE_FORMAT 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-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]
+ } {3 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
+ } {3}
+ 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]
+
+# 2021-07-20: Add support for detecting CHECK and NOT NULL constraint
+# violations in ALTER TABLE ADD COLUMN
+#
+reset_db
+do_execsql_test alter3-9.1 {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1, 2), ('null!',NULL), (3,4);
+} {}
+do_catchsql_test alter3-9.2 {
+ ALTER TABLE t1 ADD COLUMN c CHECK(a!=1);
+} {1 {CHECK constraint failed}}
+do_catchsql_test alter3-9.3 {
+ ALTER TABLE t1 ADD COLUMN c CHECK(a!=3);
+} {1 {CHECK constraint failed}}
+do_catchsql_test alter3-9.4 {
+ ALTER TABLE t1 ADD COLUMN c CHECK(a!=2);
+} {0 {}}
+do_catchsql_test alter3-9.5 {
+ ALTER TABLE t1 ADD COLUMN d AS (b+1) NOT NULL;
+} {1 {NOT NULL constraint failed}}
+do_catchsql_test alter3-9.6 {
+ ALTER TABLE t1 ADD COLUMN d AS (b+1) NOT NULL CHECK(a!=1);
+} {1 {CHECK constraint failed}}
+do_catchsql_test alter3-9.7 {
+ ALTER TABLE t1 ADD COLUMN d AS (b+1) NOT NULL CHECK(a!=3);
+} {1 {NOT NULL constraint failed}}
+
+do_execsql_test alter3-9.10 {
+ CREATE TEMP TABLE t0(m,n);
+ INSERT INTO t0 VALUES(1, 2), ('null!',NULL), (3,4);
+ ATTACH ':memory:' AS aux1;
+ CREATE TABLE aux1.t2(x,y);
+ INSERT INTO t2 VALUES(1, 2), ('null!',NULL), (3,4);
+} {}
+do_catchsql_test alter3-9.11 {
+ ALTER TABLE t0 ADD COLUMN xtra1 AS (n+1) NOT NULL CHECK(m!=1);
+} {1 {CHECK constraint failed}}
+do_catchsql_test alter3-9.12 {
+ ALTER TABLE t0 ADD COLUMN xtra1 AS (n+1) NOT NULL CHECK(m!=3);
+} {1 {NOT NULL constraint failed}}
+do_catchsql_test alter3-9.13 {
+ ALTER TABLE t2 ADD COLUMN xtra1 AS (y+1) NOT NULL CHECK(x!=1);
+} {1 {CHECK constraint failed}}
+do_catchsql_test alter3-9.14 {
+ ALTER TABLE t2 ADD COLUMN xtra1 AS (y+1) NOT NULL CHECK(x!=3);
+} {1 {NOT NULL constraint failed}}
+
+finish_test
diff --git a/test/alter4.test b/test/alter4.test
new file mode 100644
index 0000000..c63ba6b
--- /dev/null
+++ b/test/alter4.test
@@ -0,0 +1,427 @@
+# 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.1b {
+ execsql {
+ SELECT sql FROM temp.sqlite_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.2b {
+ execsql {
+ SELECT sql FROM temp.sqlite_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.3b {
+ execsql {
+ SELECT sql FROM temp.sqlite_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.4b {
+ execsql {
+ SELECT sql FROM temp.sqlite_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);
+ INSERT INTO t1 VALUES(1,2);
+ }
+ 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.7 {
+ catchsql {
+ alter table t1 add column d default (-5+1);
+ }
+} {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 ORDER BY trig, a, b;
+ }
+ } {a 1 2 b 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 ORDER BY trig, a, b;
+ }
+ } {a 1 2 a 3 4 b 1 2 b 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]
+
+
+# Test that a default value equal to -1 multipied by the smallest possible
+# 64-bit integer is correctly converted to a real.
+do_execsql_test alter4-9.1 {
+ CREATE TABLE t5(
+ a INTEGER DEFAULT -9223372036854775808,
+ b INTEGER DEFAULT (-(-9223372036854775808))
+ );
+ INSERT INTO t5 DEFAULT VALUES;
+}
+
+do_execsql_test alter4-9.2 { SELECT typeof(a), a, typeof(b), b FROM t5; } {
+ integer -9223372036854775808
+ real 9.22337203685478e+18
+}
+
+do_execsql_test alter4-9.3 {
+ ALTER TABLE t5 ADD COLUMN c INTEGER DEFAULT (-(-9223372036854775808));
+ SELECT typeof(c), c FROM t5;
+} {real 9.22337203685478e+18}
+
+# Confirm that doing an ALTER TABLE on a legacy format database
+# does not corrupt DESC indexes.
+#
+# Ticket https://www.sqlite.org/src/tktview/f68bf68513a1c
+#
+do_test alter4-10.1 {
+ db close
+ sqlite3 db :memory:
+ sqlite3_db_config db LEGACY_FILE_FORMAT 1
+ db eval {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1a ON t1(a DESC);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(2,3,4);
+ ALTER TABLE t1 ADD COLUMN d;
+ PRAGMA integrity_check;
+ }
+} {ok}
+
+reset_db
+do_execsql_test alter4-11.0 {
+ CREATE TABLE t1(c INTEGER PRIMARY KEY, d);
+ INSERT INTO t1(c,d) VALUES(1,2);
+ PRAGMA foreign_keys = on;
+ ALTER TABLE t1 ADD COLUMN e;
+}
+
+do_execsql_test alter4-11.1 {
+ ALTER TABLE t1 ADD COLUMN f REFERENCES t1;
+}
+
+do_catchsql_test alter4-11.2 {
+ ALTER TABLE t1 ADD COLUMN g REFERENCES t1 DEFAULT 4;
+} {1 {Cannot add a REFERENCES column with non-NULL default value}}
+
+do_catchsql_test alter4-11.3 {
+ ALTER TABLE t2 ADD COLUMN g;
+} {1 {no such table: t2}}
+
+ifcapable fts5 {
+ do_execsql_test alter4-11.4 {
+ CREATE VIRTUAL TABLE fff USING fts5(f);
+ }
+ do_catchsql_test alter4-11.2 {
+ ALTER TABLE fff ADD COLUMN g;
+ } {1 {virtual tables may not be altered}}
+}
+
+finish_test
diff --git a/test/alterauth.test b/test/alterauth.test
new file mode 100644
index 0000000..12645b3
--- /dev/null
+++ b/test/alterauth.test
@@ -0,0 +1,72 @@
+# 2018 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+set testprefix alterauth
+
+set ::auth [list]
+proc xAuth {type args} {
+ if {$type == "SQLITE_ALTER_TABLE"} {
+ lappend ::auth [concat $type [lrange $args 0 3]]
+ }
+ return SQLITE_OK
+}
+db auth xAuth
+
+do_execsql_test 1.0 { CREATE TABLE t1(a, b, c); }
+
+do_test 1.1 {
+ set ::auth [list]
+ execsql { ALTER TABLE t1 RENAME TO t2 }
+ set ::auth
+} {{SQLITE_ALTER_TABLE main t1 {} {}}}
+
+do_test 1.2 {
+ set ::auth [list]
+ execsql { ALTER TABLE t2 RENAME c TO ccc }
+ set ::auth
+} {{SQLITE_ALTER_TABLE main t2 {} {}}}
+
+do_test 1.3 {
+ set ::auth [list]
+ execsql { ALTER TABLE t2 ADD COLUMN d }
+ set ::auth
+} {{SQLITE_ALTER_TABLE main t2 {} {}}}
+
+proc xAuth {type args} {
+ if {$type == "SQLITE_ALTER_TABLE"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+}
+
+do_test 2.1 {
+ catchsql { ALTER TABLE t2 RENAME TO t3 }
+} {1 {not authorized}}
+
+do_test 2.2 {
+ catchsql { ALTER TABLE t2 RENAME d TO ddd }
+} {1 {not authorized}}
+
+do_test 2.3 {
+ catchsql { ALTER TABLE t2 ADD COLUMN e }
+} {1 {not authorized}}
+
+finish_test
diff --git a/test/alterauth2.test b/test/alterauth2.test
new file mode 100644
index 0000000..6f9242d
--- /dev/null
+++ b/test/alterauth2.test
@@ -0,0 +1,119 @@
+# 2018 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+
+source $testdir/tester.tcl
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+set testprefix alterauth2
+
+set ::auth [list]
+proc xAuth {type args} {
+ lappend ::auth [concat $type [lrange $args 0 3]]
+ if {$type=="SQLITE_READ" && [lindex $args 0] == "t2"} breakpoint
+ return SQLITE_OK
+}
+db auth xAuth
+
+proc do_auth_test {tn sql authcode} {
+ set script "
+ set ::auth \[list\]
+ execsql {$sql}
+ lsort -unique \[set ::auth\]
+ "
+
+ set normal [list {*}$authcode]
+ uplevel [list do_test $tn $script $normal]
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ DELETE FROM t1 WHERE a<new.a;
+ END;
+
+ CREATE TEMP TRIGGER tr2 AFTER UPDATE OF a, b ON t1 BEGIN
+ UPDATE t1 SET a=a+1 WHERE new.b<b;
+ END;
+}
+
+do_auth_test 1.1 {
+ ALTER TABLE t1 RENAME TO t2;
+} {
+ {SQLITE_ALTER_TABLE main t1 {} {}}
+ {SQLITE_FUNCTION {} like {} {}}
+ {SQLITE_FUNCTION {} sqlite_rename_table {} {}}
+ {SQLITE_FUNCTION {} sqlite_rename_test {} {}}
+ {SQLITE_FUNCTION {} substr {} {}}
+ {SQLITE_READ sqlite_master name main {}}
+ {SQLITE_READ sqlite_master sql main {}}
+ {SQLITE_READ sqlite_master tbl_name main {}}
+ {SQLITE_READ sqlite_master type main {}}
+ {SQLITE_READ sqlite_temp_master name temp {}}
+ {SQLITE_READ sqlite_temp_master sql temp {}}
+ {SQLITE_READ sqlite_temp_master tbl_name temp {}}
+ {SQLITE_READ sqlite_temp_master type temp {}}
+ {SQLITE_SELECT {} {} {} {}}
+ {SQLITE_UPDATE sqlite_master name main {}}
+ {SQLITE_UPDATE sqlite_master sql main {}}
+ {SQLITE_UPDATE sqlite_master tbl_name main {}}
+ {SQLITE_UPDATE sqlite_temp_master sql temp {}}
+ {SQLITE_UPDATE sqlite_temp_master tbl_name temp {}}
+}
+
+do_auth_test 1.2 {
+ ALTER TABLE t2 RENAME a TO aaa;
+} {
+ {SQLITE_ALTER_TABLE main t2 {} {}}
+ {SQLITE_FUNCTION {} like {} {}}
+ {SQLITE_FUNCTION {} sqlite_rename_column {} {}}
+ {SQLITE_FUNCTION {} sqlite_rename_quotefix {} {}}
+ {SQLITE_FUNCTION {} sqlite_rename_test {} {}}
+ {SQLITE_READ sqlite_master name main {}}
+ {SQLITE_READ sqlite_master sql main {}}
+ {SQLITE_READ sqlite_master tbl_name main {}}
+ {SQLITE_READ sqlite_master type main {}}
+ {SQLITE_READ sqlite_temp_master name temp {}}
+ {SQLITE_READ sqlite_temp_master sql temp {}}
+ {SQLITE_READ sqlite_temp_master type temp {}}
+ {SQLITE_SELECT {} {} {} {}}
+ {SQLITE_UPDATE sqlite_master sql main {}}
+ {SQLITE_UPDATE sqlite_temp_master sql temp {}}
+}
+
+do_auth_test 1.3 {
+ ALTER TABLE t2 DROP COLUMN c;
+} {
+ {SQLITE_ALTER_TABLE main t2 c {}}
+ {SQLITE_FUNCTION {} like {} {}}
+ {SQLITE_FUNCTION {} sqlite_drop_column {} {}}
+ {SQLITE_FUNCTION {} sqlite_rename_quotefix {} {}}
+ {SQLITE_FUNCTION {} sqlite_rename_test {} {}}
+ {SQLITE_READ sqlite_master name main {}}
+ {SQLITE_READ sqlite_master sql main {}}
+ {SQLITE_READ sqlite_master tbl_name main {}}
+ {SQLITE_READ sqlite_master type main {}}
+ {SQLITE_READ sqlite_temp_master name temp {}}
+ {SQLITE_READ sqlite_temp_master sql temp {}}
+ {SQLITE_READ sqlite_temp_master type temp {}}
+ {SQLITE_SELECT {} {} {} {}}
+ {SQLITE_UPDATE sqlite_master sql main {}}
+ {SQLITE_UPDATE sqlite_temp_master sql temp {}}
+}
+
+finish_test
diff --git a/test/altercol.test b/test/altercol.test
new file mode 100644
index 0000000..e39793a
--- /dev/null
+++ b/test/altercol.test
@@ -0,0 +1,934 @@
+# 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 ... RENAME COLUMN ... TO".
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix altercol
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+# Drop all the tables and views in the 'main' database of database connect
+# [db]. Sort the objects by name before dropping them.
+#
+proc drop_all_tables_and_views {db} {
+ set SQL {
+ SELECT name, type FROM sqlite_master
+ WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%'
+ ORDER BY 1
+ }
+ foreach {z t} [db eval $SQL] {
+ db eval "DROP $t $z"
+ }
+}
+
+foreach {tn before after} {
+ 1 {CREATE TABLE t1(a INTEGER, b TEXT, c BLOB)}
+ {CREATE TABLE t1(a INTEGER, d TEXT, c BLOB)}
+
+ 2 {CREATE TABLE t1(a INTEGER, x TEXT, "b" BLOB)}
+ {CREATE TABLE t1(a INTEGER, x TEXT, "d" BLOB)}
+
+ 3 {CREATE TABLE t1(a INTEGER, b TEXT, c BLOB, CHECK(b!=''))}
+ {CREATE TABLE t1(a INTEGER, d TEXT, c BLOB, CHECK(d!=''))}
+
+ 4 {CREATE TABLE t1(a INTEGER, b TEXT, c BLOB, CHECK(t1.b!=''))}
+ {CREATE TABLE t1(a INTEGER, d TEXT, c BLOB, CHECK(t1.d!=''))}
+
+ 5 {CREATE TABLE t1(a INTEGER, b TEXT, c BLOB, CHECK( coalesce(b,c) ))}
+ {CREATE TABLE t1(a INTEGER, d TEXT, c BLOB, CHECK( coalesce(d,c) ))}
+
+ 6 {CREATE TABLE t1(a INTEGER, "b"TEXT, c BLOB, CHECK( coalesce(b,c) ))}
+ {CREATE TABLE t1(a INTEGER, "d"TEXT, c BLOB, CHECK( coalesce(d,c) ))}
+
+ 7 {CREATE TABLE t1(a INTEGER, b TEXT, c BLOB, PRIMARY KEY(b, c))}
+ {CREATE TABLE t1(a INTEGER, d TEXT, c BLOB, PRIMARY KEY(d, c))}
+
+ 8 {CREATE TABLE t1(a INTEGER, b TEXT PRIMARY KEY, c BLOB)}
+ {CREATE TABLE t1(a INTEGER, d TEXT PRIMARY KEY, c BLOB)}
+
+ 9 {CREATE TABLE t1(a, b TEXT, c, PRIMARY KEY(a, b), UNIQUE("B"))}
+ {CREATE TABLE t1(a, d TEXT, c, PRIMARY KEY(a, d), UNIQUE("d"))}
+
+ 10 {CREATE TABLE t1(a, b, c); CREATE INDEX t1i ON t1(a, c)}
+ {{CREATE TABLE t1(a, d, c)} {CREATE INDEX t1i ON t1(a, c)}}
+
+ 11 {CREATE TABLE t1(a, b, c); CREATE INDEX t1i ON t1(b, c)}
+ {{CREATE TABLE t1(a, d, c)} {CREATE INDEX t1i ON t1(d, c)}}
+
+ 12 {CREATE TABLE t1(a, b, c); CREATE INDEX t1i ON t1(b+b+b+b, c) WHERE b>0}
+ {{CREATE TABLE t1(a, d, c)} {CREATE INDEX t1i ON t1(d+d+d+d, c) WHERE d>0}}
+
+ 13 {CREATE TABLE t1(a, b, c, FOREIGN KEY (b) REFERENCES t2)}
+ {CREATE TABLE t1(a, d, c, FOREIGN KEY (d) REFERENCES t2)}
+
+ 14 {CREATE TABLE t1(a INTEGER, b TEXT, c BLOB, PRIMARY KEY(b))}
+ {CREATE TABLE t1(a INTEGER, d TEXT, c BLOB, PRIMARY KEY(d))}
+
+ 15 {CREATE TABLE t1(a INTEGER, b INTEGER, c BLOB, PRIMARY KEY(b))}
+ {CREATE TABLE t1(a INTEGER, d INTEGER, c BLOB, PRIMARY KEY(d))}
+
+ 16 {CREATE TABLE t1(a INTEGER, b INTEGER PRIMARY KEY, c BLOB)}
+ {CREATE TABLE t1(a INTEGER, d INTEGER PRIMARY KEY, c BLOB)}
+
+ 17 {CREATE TABLE t1(a INTEGER, b INTEGER PRIMARY KEY, c BLOB, FOREIGN KEY (b) REFERENCES t2)}
+ {CREATE TABLE t1(a INTEGER, d INTEGER PRIMARY KEY, c BLOB, FOREIGN KEY (d) REFERENCES t2)}
+
+} {
+ reset_db
+ do_execsql_test 1.$tn.0 $before
+
+ do_execsql_test 1.$tn.1 {
+ INSERT INTO t1 VALUES(1, 2, 3);
+ }
+
+ do_execsql_test 1.$tn.2 {
+ ALTER TABLE t1 RENAME COLUMN b TO d;
+ }
+
+ do_execsql_test 1.$tn.3 {
+ SELECT * FROM t1;
+ } {1 2 3}
+
+ if {[string first INDEX $before]>0} {
+ set res $after
+ } else {
+ set res [list $after]
+ }
+ do_execsql_test 1.$tn.4 {
+ SELECT sql FROM sqlite_master WHERE tbl_name='t1' AND sql!=''
+ } $res
+}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 2.0 {
+ CREATE TABLE t3(a, b, c, d, e, f, g, h, i, j, k, l, m, FOREIGN KEY (b, c, d, e, f, g, h, i, j, k, l, m) REFERENCES t4);
+}
+
+sqlite3 db2 test.db
+do_execsql_test -db db2 2.1 { SELECT b FROM t3 }
+
+do_execsql_test 2.2 {
+ ALTER TABLE t3 RENAME b TO biglongname;
+ SELECT sql FROM sqlite_master WHERE name='t3';
+} {{CREATE TABLE t3(a, biglongname, c, d, e, f, g, h, i, j, k, l, m, FOREIGN KEY (biglongname, c, d, e, f, g, h, i, j, k, l, m) REFERENCES t4)}}
+
+do_execsql_test -db db2 2.3 { SELECT biglongname FROM t3 }
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 3.0 {
+ CREATE TABLE t4(x, y, z);
+ CREATE TRIGGER ttt AFTER INSERT ON t4 WHEN new.y<0 BEGIN
+ SELECT x, y, z FROM t4;
+ DELETE FROM t4 WHERE y=32;
+ UPDATE t4 SET x=y+1, y=0 WHERE y=32;
+ INSERT INTO t4(x, y, z) SELECT 4, 5, 6 WHERE 0;
+ END;
+ INSERT INTO t4 VALUES(3, 2, 1);
+}
+
+do_execsql_test 3.1 {
+ ALTER TABLE t4 RENAME y TO abc;
+ SELECT sql FROM sqlite_master WHERE name='t4';
+} {{CREATE TABLE t4(x, abc, z)}}
+
+do_execsql_test 3.2 {
+ SELECT * FROM t4;
+} {3 2 1}
+
+do_execsql_test 3.3 { INSERT INTO t4 VALUES(6, 5, 4); } {}
+
+do_execsql_test 3.4 { SELECT sql FROM sqlite_master WHERE type='trigger' } {
+{CREATE TRIGGER ttt AFTER INSERT ON t4 WHEN new.abc<0 BEGIN
+ SELECT x, abc, z FROM t4;
+ DELETE FROM t4 WHERE abc=32;
+ UPDATE t4 SET x=abc+1, abc=0 WHERE abc=32;
+ INSERT INTO t4(x, abc, z) SELECT 4, 5, 6 WHERE 0;
+ END}
+}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 4.0 {
+ CREATE TABLE c1(a, b, FOREIGN KEY (a, b) REFERENCES p1(c, d));
+ CREATE TABLE p1(c, d, PRIMARY KEY(c, d));
+ PRAGMA foreign_keys = 1;
+ INSERT INTO p1 VALUES(1, 2);
+ INSERT INTO p1 VALUES(3, 4);
+}
+
+do_execsql_test 4.1 {
+ ALTER TABLE p1 RENAME d TO "silly name";
+ SELECT sql FROM sqlite_master WHERE name IN ('c1', 'p1');
+} {
+ {CREATE TABLE c1(a, b, FOREIGN KEY (a, b) REFERENCES p1(c, "silly name"))}
+ {CREATE TABLE p1(c, "silly name", PRIMARY KEY(c, "silly name"))}
+}
+
+do_execsql_test 4.2 { INSERT INTO c1 VALUES(1, 2); }
+
+do_execsql_test 4.3 {
+ CREATE TABLE c2(a, b, FOREIGN KEY (a, b) REFERENCES p1);
+}
+
+do_execsql_test 4.4 {
+ ALTER TABLE p1 RENAME "silly name" TO reasonable;
+ SELECT sql FROM sqlite_master WHERE name IN ('c1', 'c2', 'p1');
+} {
+ {CREATE TABLE c1(a, b, FOREIGN KEY (a, b) REFERENCES p1(c, "reasonable"))}
+ {CREATE TABLE p1(c, "reasonable", PRIMARY KEY(c, "reasonable"))}
+ {CREATE TABLE c2(a, b, FOREIGN KEY (a, b) REFERENCES p1)}
+}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 5.0 {
+ CREATE TABLE t5(a, b, c);
+ CREATE INDEX t5a ON t5(a);
+ INSERT INTO t5 VALUES(1, 2, 3), (4, 5, 6);
+ ANALYZE;
+}
+
+do_execsql_test 5.1 {
+ ALTER TABLE t5 RENAME b TO big;
+ SELECT big FROM t5;
+} {2 5}
+
+do_catchsql_test 6.1 {
+ ALTER TABLE sqlite_stat1 RENAME tbl TO thetable;
+} {1 {table sqlite_stat1 may not be altered}}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 6.0 {
+ CREATE TABLE blob(
+ rid INTEGER PRIMARY KEY,
+ rcvid INTEGER,
+ size INTEGER,
+ uuid TEXT UNIQUE NOT NULL,
+ content BLOB,
+ CHECK( length(uuid)>=40 AND rid>0 )
+ );
+}
+
+do_execsql_test 6.1 {
+ ALTER TABLE "blob" RENAME COLUMN "rid" TO "a1";
+}
+
+do_catchsql_test 6.2 {
+ ALTER TABLE "blob" RENAME COLUMN "a1" TO [where];
+} {0 {}}
+
+do_execsql_test 6.3 {
+ SELECT "where" FROM blob;
+} {}
+
+#-------------------------------------------------------------------------
+# Triggers.
+#
+db close
+db2 close
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE c(x);
+ INSERT INTO c VALUES(0);
+ CREATE TABLE t6("col a", "col b", "col c");
+ CREATE TRIGGER zzz AFTER UPDATE OF "col a", "col c" ON t6 BEGIN
+ UPDATE c SET x=x+1;
+ END;
+}
+
+do_execsql_test 7.1.1 {
+ INSERT INTO t6 VALUES(0, 0, 0);
+ UPDATE t6 SET "col c" = 1;
+ SELECT * FROM c;
+} {1}
+
+do_execsql_test 7.1.2 {
+ ALTER TABLE t6 RENAME "col c" TO "col 3";
+}
+
+do_execsql_test 7.1.3 {
+ UPDATE t6 SET "col 3" = 0;
+ SELECT * FROM c;
+} {2}
+
+#-------------------------------------------------------------------------
+# Views.
+#
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE a1(x INTEGER, y TEXT, z BLOB, PRIMARY KEY(x));
+ CREATE TABLE a2(a, b, c);
+ CREATE VIEW v1 AS SELECT x, y, z FROM a1;
+}
+
+do_execsql_test 8.1 {
+ ALTER TABLE a1 RENAME y TO yyy;
+ SELECT sql FROM sqlite_master WHERE type='view';
+} {{CREATE VIEW v1 AS SELECT x, yyy, z FROM a1}}
+
+do_execsql_test 8.2.1 {
+ DROP VIEW v1;
+ CREATE VIEW v2 AS SELECT x, x+x, a, a+a FROM a1, a2;
+} {}
+do_execsql_test 8.2.2 {
+ ALTER TABLE a1 RENAME x TO xxx;
+}
+do_execsql_test 8.2.3 {
+ SELECT sql FROM sqlite_master WHERE type='view';
+} {{CREATE VIEW v2 AS SELECT xxx, xxx+xxx, a, a+a FROM a1, a2}}
+
+do_execsql_test 8.3.1 {
+ DROP TABLE a2;
+ DROP VIEW v2;
+ CREATE TABLE a2(a INTEGER PRIMARY KEY, b, c);
+ CREATE VIEW v2 AS SELECT xxx, xxx+xxx, a, a+a FROM a1, a2;
+} {}
+do_execsql_test 8.3.2 {
+ ALTER TABLE a1 RENAME xxx TO x;
+}
+do_execsql_test 8.3.3 {
+ SELECT sql FROM sqlite_master WHERE type='view';
+} {{CREATE VIEW v2 AS SELECT x, x+x, a, a+a FROM a1, a2}}
+
+do_execsql_test 8.4.0 {
+ CREATE TABLE b1(a, b, c);
+ CREATE TABLE b2(x, y, z);
+}
+
+do_execsql_test 8.4.1 {
+ CREATE VIEW vvv AS SELECT c+c || coalesce(c, c) FROM b1, b2 WHERE x=c GROUP BY c HAVING c>0;
+ ALTER TABLE b1 RENAME c TO "a;b";
+ SELECT sql FROM sqlite_master WHERE name='vvv';
+} {{CREATE VIEW vvv AS SELECT "a;b"+"a;b" || coalesce("a;b", "a;b") FROM b1, b2 WHERE x="a;b" GROUP BY "a;b" HAVING "a;b">0}}
+
+do_execsql_test 8.4.2 {
+ CREATE VIEW www AS SELECT b FROM b1 UNION ALL SELECT y FROM b2;
+ ALTER TABLE b1 RENAME b TO bbb;
+ SELECT sql FROM sqlite_master WHERE name='www';
+} {{CREATE VIEW www AS SELECT bbb FROM b1 UNION ALL SELECT y FROM b2}}
+
+db collate nocase {string compare}
+
+do_execsql_test 8.4.3 {
+ CREATE VIEW xxx AS SELECT a FROM b1 UNION SELECT x FROM b2 ORDER BY 1 COLLATE nocase;
+}
+
+do_execsql_test 8.4.4 {
+ ALTER TABLE b2 RENAME x TO hello;
+ SELECT sql FROM sqlite_master WHERE name='xxx';
+} {{CREATE VIEW xxx AS SELECT a FROM b1 UNION SELECT hello FROM b2 ORDER BY 1 COLLATE nocase}}
+
+do_catchsql_test 8.4.5 {
+ CREATE VIEW zzz AS SELECT george, ringo FROM b1;
+ ALTER TABLE b1 RENAME a TO aaa;
+} {1 {error in view zzz: no such column: george}}
+
+#-------------------------------------------------------------------------
+# More triggers.
+#
+proc do_rename_column_test {tn old new lSchema} {
+ for {set i 0} {$i < 2} {incr i} {
+ drop_all_tables_and_views db
+
+ set lSorted [list]
+ foreach sql $lSchema {
+ execsql $sql
+ lappend lSorted [string trim $sql]
+ }
+ set lSorted [lsort $lSorted]
+
+ do_execsql_test $tn.$i.1 {
+ SELECT sql FROM sqlite_master WHERE sql!='' ORDER BY 1
+ } $lSorted
+
+ if {$i==1} {
+ db close
+ sqlite3 db test.db
+ }
+
+ do_execsql_test $tn.$i.2 "ALTER TABLE t1 RENAME $old TO $new"
+
+ do_execsql_test $tn.$i.3 {
+ SELECT sql FROM sqlite_master ORDER BY 1
+ } [string map [list $old $new] $lSorted]
+ }
+}
+
+foreach {tn old new lSchema} {
+ 1 _x_ _xxx_ {
+ { CREATE TABLE t1(a, b, _x_) }
+ { CREATE TRIGGER AFTER INSERT ON t1 BEGIN
+ SELECT _x_ FROM t1;
+ END }
+ }
+
+ 2 _x_ _xxx_ {
+ { CREATE TABLE t1(a, b, _x_) }
+ { CREATE TABLE t2(c, d, e) }
+ { CREATE TRIGGER ttt AFTER INSERT ON t2 BEGIN
+ SELECT _x_ FROM t1;
+ END }
+ }
+
+ 3 _x_ _xxx_ {
+ { CREATE TABLE t1(a, b, _x_ INTEGER, PRIMARY KEY(_x_), CHECK(_x_>0)) }
+ { CREATE TABLE t2(c, d, e) }
+ { CREATE TRIGGER ttt AFTER UPDATE ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.a, new.b, new._x_);
+ END }
+ }
+
+ 4 _x_ _xxx_ {
+ { CREATE TABLE t1(a, b, _x_ INTEGER, PRIMARY KEY(_x_), CHECK(_x_>0)) }
+ { CREATE TRIGGER ttt AFTER UPDATE ON t1 BEGIN
+ INSERT INTO t1 VALUES(new.a, new.b, new._x_)
+ ON CONFLICT (_x_) WHERE _x_>10 DO UPDATE SET _x_ = _x_+1;
+ END }
+ }
+
+ 4 _x_ _xxx_ {
+ { CREATE TABLE t1(a, b, _x_ INTEGER, PRIMARY KEY(_x_), CHECK(_x_>0)) }
+ { CREATE TRIGGER ttt AFTER UPDATE ON t1 BEGIN
+ INSERT INTO t1 VALUES(new.a, new.b, new._x_)
+ ON CONFLICT (_x_) WHERE _x_>10 DO NOTHING;
+ END }
+ }
+} {
+ do_rename_column_test 9.$tn $old $new $lSchema
+}
+
+#-------------------------------------------------------------------------
+# Test that views can be edited even if there are missing collation
+# sequences or user defined functions.
+#
+reset_db
+
+ifcapable vtab {
+ foreach {tn old new lSchema} {
+ 1 _x_ _xxx_ {
+ { CREATE TABLE t1(a, b, _x_) }
+ { CREATE VIEW s1 AS SELECT a, b, _x_ FROM t1 WHERE _x_='abc' COLLATE xyz }
+ }
+
+ 2 _x_ _xxx_ {
+ { CREATE TABLE t1(a, b, _x_) }
+ { CREATE VIEW v1 AS SELECT a, b, _x_ FROM t1 WHERE scalar(_x_) }
+ }
+
+ 3 _x_ _xxx_ {
+ { CREATE TABLE t1(a, b, _x_) }
+ { CREATE VIEW v1 AS SELECT a, b, _x_ FROM t1 WHERE _x_ = unicode(1, 2, 3) }
+ }
+
+ 4 _x_ _xxx_ {
+ { CREATE TABLE t1(a, b, _x_) }
+ { CREATE VIRTUAL TABLE e1 USING echo(t1) }
+ }
+ } {
+ register_echo_module db
+ do_rename_column_test 10.$tn $old $new $lSchema
+ }
+
+ #--------------------------------------------------------------------------
+ # Test that if a view or trigger refers to a virtual table for which the
+ # module is not available, RENAME COLUMN cannot proceed.
+ #
+ reset_db
+ register_echo_module db
+ do_execsql_test 11.0 {
+ CREATE TABLE x1(a, b, c);
+ CREATE VIRTUAL TABLE e1 USING echo(x1);
+ }
+ db close
+ sqlite3 db test.db
+
+ do_execsql_test 11.1 {
+ ALTER TABLE x1 RENAME b TO bbb;
+ SELECT sql FROM sqlite_master;
+ } { {CREATE TABLE x1(a, bbb, c)} {CREATE VIRTUAL TABLE e1 USING echo(x1)} }
+
+ do_execsql_test 11.2 {
+ CREATE VIEW v1 AS SELECT e1.*, x1.c FROM e1, x1;
+ }
+
+ do_catchsql_test 11.3 {
+ ALTER TABLE x1 RENAME c TO ccc;
+ } {1 {error in view v1: no such module: echo}}
+}
+
+#-------------------------------------------------------------------------
+# Test some error conditions:
+#
+# 1. Renaming a column of a system table,
+# 2. Renaming a column of a VIEW,
+# 3. Renaming a column of a virtual table.
+# 4. Renaming a column that does not exist.
+# 5. Renaming a column of a table that does not exist.
+#
+reset_db
+do_execsql_test 12.1.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX t1a ON t1(a);
+ INSERT INTO t1 VALUES(1, 1), (2, 2), (3, 4);
+ ANALYZE;
+}
+do_catchsql_test 12.1.2 {
+ ALTER TABLE sqlite_stat1 RENAME idx TO theindex;
+} {1 {table sqlite_stat1 may not be altered}}
+do_execsql_test 12.1.3 {
+ SELECT sql FROM sqlite_master WHERE tbl_name = 'sqlite_stat1'
+} {{CREATE TABLE sqlite_stat1(tbl,idx,stat)}}
+
+do_execsql_test 12.2.1 {
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE VIEW v2(c, d) AS SELECT * FROM t1;
+}
+do_catchsql_test 12.2.2 {
+ ALTER TABLE v1 RENAME a TO z;
+} {1 {cannot rename columns of view "v1"}}
+do_catchsql_test 12.2.3 {
+ ALTER TABLE v2 RENAME c TO y;
+} {1 {cannot rename columns of view "v2"}}
+
+ifcapable fts5 {
+ do_execsql_test 12.3.1 {
+ CREATE VIRTUAL TABLE ft USING fts5(a, b, c);
+ }
+ do_catchsql_test 12.3.2 {
+ ALTER TABLE ft RENAME a TO z;
+ } {1 {cannot rename columns of virtual table "ft"}}
+}
+
+do_execsql_test 12.4.1 {
+ CREATE TABLE t2(x, y, z);
+}
+do_catchsql_test 12.4.2 {
+ ALTER TABLE t2 RENAME COLUMN a TO b;
+} {1 {no such column: "a"}}
+
+do_catchsql_test 12.5.1 {
+ ALTER TABLE t3 RENAME COLUMN a TO b;
+} {1 {no such table: t3}}
+
+#-------------------------------------------------------------------------
+# Test the effect of some parse/resolve errors.
+#
+reset_db
+do_execsql_test 13.1.1 {
+ CREATE TABLE x1(i INTEGER, t TEXT UNIQUE);
+ CREATE TRIGGER tr1 AFTER INSERT ON x1 BEGIN
+ SELECT * FROM nosuchtable;
+ END;
+}
+
+do_catchsql_test 13.1.2 {
+ ALTER TABLE x1 RENAME COLUMN t TO ttt;
+} {1 {error in trigger tr1: no such table: main.nosuchtable}}
+
+do_execsql_test 13.1.3 {
+ DROP TRIGGER tr1;
+ CREATE INDEX x1i ON x1(i);
+ SELECT sql FROM sqlite_master WHERE name='x1i';
+} {{CREATE INDEX x1i ON x1(i)}}
+
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 13.1.4 {
+ PRAGMA writable_schema = ON;
+ UPDATE sqlite_master SET sql = 'CREATE INDEX x1i ON x1(j)' WHERE name='x1i';
+ PRAGMA writable_schema = OFF;
+} {}
+
+do_catchsql_test 13.1.5 {
+ ALTER TABLE x1 RENAME COLUMN t TO ttt;
+} {1 {error in index x1i: no such column: j}}
+
+do_execsql_test 13.1.6 {
+ PRAGMA writable_schema = ON;
+ UPDATE sqlite_master SET sql = '' WHERE name='x1i';
+ PRAGMA writable_schema = OFF;
+} {}
+
+do_catchsql_test 13.1.7 {
+ ALTER TABLE x1 RENAME COLUMN t TO ttt;
+} {1 {error in index x1i: }}
+
+do_execsql_test 13.1.8 {
+ PRAGMA writable_schema = ON;
+ DELETE FROM sqlite_master WHERE name = 'x1i';
+ PRAGMA writable_schema = OFF;
+}
+
+do_execsql_test 13.2.0 {
+ CREATE TABLE data(x UNIQUE, y, z);
+}
+foreach {tn trigger error} {
+ 1 {
+ CREATE TRIGGER tr1 AFTER INSERT ON x1 BEGIN
+ UPDATE data SET x=x+1 WHERE zzz=new.i;
+ END;
+ } {no such column: zzz}
+
+ 2 {
+ CREATE TRIGGER tr1 AFTER INSERT ON x1 BEGIN
+ INSERT INTO data(x, y) VALUES(new.i, new.t, 1)
+ ON CONFLICT (x) DO UPDATE SET z=zz+1;
+ END;
+ } {no such column: zz}
+
+ 3 {
+ CREATE TRIGGER tr1 AFTER INSERT ON x1 BEGIN
+ INSERT INTO x1(i, t) VALUES(new.i+1, new.t||'1')
+ ON CONFLICT (tttttt) DO UPDATE SET t=i+1;
+ END;
+ } {no such column: tttttt}
+
+ 4 {
+ CREATE TRIGGER tr1 AFTER INSERT ON x1 BEGIN
+ INSERT INTO nosuchtable VALUES(new.i, new.t);
+ END;
+ } {no such table: main.nosuchtable}
+} {
+ do_execsql_test 13.2.$tn.1 "
+ DROP TRIGGER IF EXISTS tr1;
+ $trigger
+ "
+
+ do_catchsql_test 13.2.$tn.2 {
+ ALTER TABLE x1 RENAME COLUMN t TO ttt;
+ } "1 {error in trigger tr1: $error}"
+}
+
+#-------------------------------------------------------------------------
+# Passing invalid parameters directly to sqlite_rename_column().
+#
+sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+do_execsql_test 14.1 {
+ CREATE TABLE ddd(sql, type, object, db, tbl, icol, znew, bquote);
+ INSERT INTO ddd VALUES(
+ 'CREATE TABLE x1(i INTEGER, t TEXT)',
+ 'table', 'x1', 'main', 'x1', -1, 'zzz', 0
+ ), (
+ 'CREATE TABLE x1(i INTEGER, t TEXT)',
+ 'table', 'x1', 'main', 'x1', 2, 'zzz', 0
+ ), (
+ 'CREATE TABLE x1(i INTEGER, t TEXT)',
+ 'table', 'x1', 'main', 'notable', 0, 'zzz', 0
+ ), (
+ 'CREATE TABLE x1(i INTEGER, t TEXT)',
+ 'table', 'x1', 'main', 'ddd', -1, 'zzz', 0
+ );
+} {}
+
+do_execsql_test 14.2 {
+ SELECT
+ sqlite_rename_column(sql, type, object, db, tbl, icol, znew, bquote, 0)
+ FROM ddd;
+} {{} {} {} {}}
+sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+
+# If the INTERNAL_FUNCTIONS test-control is disabled (which is the default)
+# then the sqlite_rename_table() SQL function is not accessible to
+# ordinary SQL.
+#
+do_catchsql_test 14.3 {
+ SELECT sqlite_rename_column(0,0,0,0,0,0,0,0,0);
+} {1 {no such function: sqlite_rename_column}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 15.0 {
+ CREATE TABLE xxx(a, b, c);
+ SELECT a AS d FROM xxx WHERE d=0;
+}
+
+do_execsql_test 15.1 {
+ CREATE VIEW vvv AS SELECT a AS d FROM xxx WHERE d=0;
+ ALTER TABLE xxx RENAME a TO xyz;
+}
+
+do_execsql_test 15.2 {
+ SELECT sql FROM sqlite_master WHERE type='view';
+} {{CREATE VIEW vvv AS SELECT xyz AS d FROM xxx WHERE d=0}}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 16.1.0 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE t2(d,e,f);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t2 VALUES(4,5,6);
+ CREATE VIEW v4 AS SELECT a, d FROM t1, t2;
+ SELECT * FROM v4;
+} {1 4}
+
+do_catchsql_test 16.1.1 {
+ ALTER TABLE t2 RENAME d TO a;
+} {1 {error in view v4 after rename: ambiguous column name: a}}
+
+do_execsql_test 16.1.2 {
+ SELECT * FROM v4;
+} {1 4}
+
+do_execsql_test 16.1.3 {
+ CREATE UNIQUE INDEX t2d ON t2(d);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.a, new.b, new.c)
+ ON CONFLICT(d) DO UPDATE SET f = excluded.f;
+ END;
+}
+
+do_execsql_test 16.1.4 {
+ INSERT INTO t1 VALUES(4, 8, 456);
+ SELECT * FROM t2;
+} {4 5 456}
+
+do_execsql_test 16.1.5 {
+ ALTER TABLE t2 RENAME COLUMN f TO "big f";
+ INSERT INTO t1 VALUES(4, 0, 20456);
+ SELECT * FROM t2;
+} {4 5 20456}
+
+do_execsql_test 16.1.6 {
+ ALTER TABLE t1 RENAME COLUMN c TO "big c";
+ INSERT INTO t1 VALUES(4, 0, 0);
+ SELECT * FROM t2;
+} {4 5 0}
+
+do_execsql_test 16.2.1 {
+ CREATE VIEW temp.v5 AS SELECT "big c" FROM t1;
+ SELECT * FROM v5;
+} {3 456 20456 0}
+
+do_execsql_test 16.2.2 {
+ ALTER TABLE t1 RENAME COLUMN "big c" TO reallybigc;
+} {}
+
+do_execsql_test 16.2.3 {
+ SELECT * FROM v5;
+} {3 456 20456 0}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 17.0 {
+ CREATE TABLE u7(x, y, z);
+ CREATE TRIGGER u7t AFTER INSERT ON u7 BEGIN
+ INSERT INTO u8 VALUES(new.x, new.y, new.z);
+ END;
+} {}
+do_catchsql_test 17.1 {
+ ALTER TABLE u7 RENAME x TO xxx;
+} {1 {error in trigger u7t: no such table: main.u8}}
+
+do_execsql_test 17.2 {
+ CREATE TEMP TABLE uu7(x, y, z);
+ CREATE TRIGGER uu7t AFTER INSERT ON uu7 BEGIN
+ INSERT INTO u8 VALUES(new.x, new.y, new.z);
+ END;
+} {}
+do_catchsql_test 17.3 {
+ ALTER TABLE uu7 RENAME x TO xxx;
+} {1 {error in trigger uu7t: no such table: u8}}
+
+reset_db
+forcedelete test.db2
+do_execsql_test 18.0 {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE t1(a);
+ CREATE TABLE aux.log(v);
+ CREATE TEMP TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES(new.a);
+ END;
+ INSERT INTO t1 VALUES(111);
+ SELECT v FROM log;
+} {111}
+
+do_execsql_test 18.1 {
+ ALTER TABLE t1 RENAME a TO b;
+}
+
+reset_db
+do_execsql_test 19.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ CREATE VIEW v2(e) AS SELECT coalesce(t2.c,t1.a) FROM t1, t2 WHERE t1.b=t2.d;
+}
+
+do_execsql_test 19.1 {
+ ALTER TABLE t1 RENAME a TO f;
+ SELECT sql FROM sqlite_master WHERE name = 'v2';
+} {
+ {CREATE VIEW v2(e) AS SELECT coalesce(t2.c,t1.f) FROM t1, t2 WHERE t1.b=t2.d}
+}
+
+# 2019-01-08: https://www.sqlite.org/src/tktview/bc8d94f0fbd633fd9a051e3
+#
+# ALTER TABLE RENAME COLUMN does not work for tables that have redundant
+# UNIQUE constraints.
+#
+sqlite3 db :memory:
+do_execsql_test 20.100 {
+ CREATE TABLE t1(aaa,b,c,UNIQUE(aaA),PRIMARY KEY(aAa),UNIQUE(aAA));
+ ALTER TABLE t1 RENAME aaa TO bbb;
+ SELECT sql FROM sqlite_master WHERE name='t1';
+} {{CREATE TABLE t1(bbb,b,c,UNIQUE(bbb),PRIMARY KEY(bbb),UNIQUE(bbb))}}
+do_execsql_test 20.105 {
+ DROP TABLE t1;
+ CREATE TABLE t1(aaa,b,c,UNIQUE(aaA),PRIMARY KEY(aAa),UNIQUE(aAA))WITHOUT ROWID;
+ ALTER TABLE t1 RENAME aaa TO bbb;
+ SELECT sql FROM sqlite_master WHERE name='t1';
+} {{CREATE TABLE t1(bbb,b,c,UNIQUE(bbb),PRIMARY KEY(bbb),UNIQUE(bbb))WITHOUT ROWID}}
+do_execsql_test 20.110 {
+ DROP TABLE t1;
+ CREATE TABLE t1(aa UNIQUE,bb UNIQUE,cc UNIQUE,UNIQUE(aA),PRIMARY KEY(bB),UNIQUE(cC));
+ ALTER TABLE t1 RENAME aa TO xx;
+ ALTER TABLE t1 RENAME bb TO yy;
+ ALTER TABLE t1 RENAME cc TO zz;
+ SELECT sql FROM sqlite_master WHERE name='t1';
+} {{CREATE TABLE t1(xx UNIQUE,yy UNIQUE,zz UNIQUE,UNIQUE(xx),PRIMARY KEY(yy),UNIQUE(zz))}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 21.0 {
+ CREATE TABLE t1(a, b, c NOT NULL);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN new.c IS NOT NULL BEGIN
+ SELECT c NOT NULL FROM t1;
+ END;
+}
+
+do_execsql_test 21.1 {
+ ALTER TABLE t1 RENAME c TO d;
+}
+
+do_execsql_test 21.2 {
+ SELECT sql FROM sqlite_schema WHERE name IS 'tr1'
+} {{CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN new.d IS NOT NULL BEGIN
+ SELECT d NOT NULL FROM t1;
+ END}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 22.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, othername, extra AS (c + 1));
+ ALTER TABLE t1 RENAME a to othername;
+ SELECT sql FROM sqlite_schema;
+} {
+ {CREATE TABLE t1(othername, b)}
+ {CREATE TABLE t2(c, othername, extra AS (c + 1))}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+do_execsql_test 22.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX x1 on t1("c"=b);
+ INSERT INTO t1 VALUES('a', 'a');
+ INSERT INTO t1 VALUES('b', 'b');
+ INSERT INTO t1 VALUES('c', 'c');
+ ALTER TABLE t1 RENAME COLUMN a TO "c";
+ PRAGMA integrity_check;
+} {ok}
+
+reset_db
+do_execsql_test 23.0 {
+ CREATE TABLE t1('a'"b",c);
+ CREATE INDEX i1 ON t1('a');
+ INSERT INTO t1 VALUES(1,2), (3,4);
+ ALTER TABLE t1 RENAME COLUMN a TO x;
+ PRAGMA integrity_check;
+ SELECT sql FROM sqlite_schema WHERE name='t1';
+
+} {ok {CREATE TABLE t1("x" "b",c)}}
+
+# 2022-02-04
+# Do not complain about syntax errors in the schema if
+# in PRAGMA writable_schema=ON mode.
+#
+reset_db
+do_execsql_test 23.0 {
+ CREATE TABLE t1(a INT, b REAL, c TEXT, d BLOB, e ANY);
+ CREATE INDEX t1abx ON t1(a, b, a+b) WHERE c IS NOT NULL;
+ CREATE VIEW t2 AS SELECT a+10, b*5.0, xyz FROM t1; -- unknown column "xyz"
+ CREATE TABLE schema_copy(name TEXT, sql TEXT);
+ INSERT INTO schema_copy(name,sql) SELECT name, sql FROM sqlite_schema WHERE sql IS NOT NULL;
+} {}
+do_catchsql_test 23.1 {
+ ALTER TABLE t1 RENAME COLUMN e TO eeee;
+} {1 {error in view t2: no such column: xyz}}
+do_execsql_test 23.2 {
+ SELECT name, sql FROM sqlite_master
+ EXCEPT SELECT name, sql FROM schema_copy;
+} {}
+do_execsql_test 23.3 {
+ BEGIN;
+ PRAGMA writable_schema=ON;
+ ALTER TABLE t1 RENAME COLUMN e TO eeee;
+ PRAGMA writable_schema=OFF;
+ SELECT name FROM sqlite_master
+ WHERE (name, sql) NOT IN (SELECT name, sql FROM schema_copy);
+ ROLLBACK;
+} {t1}
+do_execsql_test 23.10 {
+ DROP VIEW t2;
+ CREATE TRIGGER r3 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t3(x,y) VALUES(new.a, new.b);
+ INSERT INTO t4(p) VALUES(new.c); -- no such table "t4"
+ END;
+ DELETE FROM schema_copy;
+ INSERT INTO schema_copy(name,sql) SELECT name, sql FROM sqlite_schema WHERE sql IS NOT NULL;
+} {}
+do_catchsql_test 23.11 {
+ ALTER TABLE t1 RENAME COLUMN e TO eeee;
+} {1 {error in trigger r3: no such table: main.t3}}
+do_execsql_test 23.12 {
+ SELECT name, sql FROM sqlite_master
+ EXCEPT SELECT name, sql FROM schema_copy;
+} {}
+do_execsql_test 23.13 {
+ BEGIN;
+ PRAGMA writable_schema=ON;
+ ALTER TABLE t1 RENAME COLUMN e TO eeee;
+ PRAGMA writable_schema=OFF;
+ SELECT name FROM sqlite_master
+ WHERE (name, sql) NOT IN (SELECT name, sql FROM schema_copy);
+ ROLLBACK;
+} {t1}
+do_execsql_test 23.20 {
+ CREATE TABLE t4(id INTEGER PRIMARY KEY, c1 INT, c2 INT);
+ CREATE VIEW t4v1 AS SELECT id, c1, c99 FROM t4;
+ DELETE FROM schema_copy;
+ INSERT INTO schema_copy SELECT name, sql FROM sqlite_schema;
+ BEGIN;
+ PRAGMA writable_schema=ON;
+ ALTER TABLE t4 RENAME to t4new;
+ SELECT name FROM sqlite_schema WHERE (name,sql) NOT IN (SELECT * FROM schema_copy);
+ ROLLBACK;
+} {t4new}
+
+finish_test
diff --git a/test/altercorrupt.test b/test/altercorrupt.test
new file mode 100644
index 0000000..f24cb30
--- /dev/null
+++ b/test/altercorrupt.test
@@ -0,0 +1,181 @@
+# 2019-01-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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix altercorrupt
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+database_may_be_corrupt
+
+#--------------------------------------------------------------------------
+reset_db
+do_test 1.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 24576 pagesize 4096 filename crash-685346d89b5e5f.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06 .....@ ........
+| 32: 00 00 63 00 00 05 f0 00 00 00 00 04 10 00 00 04 ..c.............
+| 48: 00 00 00 00 00 00 0f f0 00 00 00 01 00 00 00 00 ................
+| 64: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0f f8 00 05 0e cf 00 0f 79 0f d3 .............y..
+| 112: 0f 2e 0e f3 0e cf 00 00 00 00 00 00 00 00 00 00 ................
+| 3776: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 ................
+| 3792: 05 06 17 11 11 01 31 74 61 62 6c 65 74 34 74 34 ......1tablet4t4
+| 3808: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 34 .CREATE TABLE t4
+| 3824: 28 7a 29 39 04 06 17 11 11 01 5f 74 61 62 6c 65 (z)9......_table
+| 3840: 74 33 74 33 05 43 52 45 41 54 45 20 54 41 42 4c t3t3.CREATE TABL
+| 3856: 45 20 74 33 28 78 20 49 4e 54 45 47 45 52 20 50 E t3(x INTEGER P
+| 3872: 52 49 4d 41 52 59 20 4b 45 59 2c 20 79 29 49 03 RIMARY KEY, y)I.
+| 3888: 06 17 11 11 01 7f 74 61 62 6c 65 74 32 74 32 04 ......tablet2t2.
+| 3904: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 CREATE TABLE t2(
+| 3920: 61 2c 62 2c 63 20 50 52 49 4d 41 52 59 20 4b 45 a,b,c PRIMARY KE
+| 3936: 59 2c 20 64 2c 20 65 2c 20 66 29 20 57 49 54 48 Y, d, e, f) WITH
+| 3952: 4f 55 54 20 52 4f 57 49 44 58 03 07 17 11 11 01 OUT ROWIDX......
+| 3968: 81 1b 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 ..tablet1t1.CREA
+| 3984: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 2c TE TABLE t1(a,b,
+| 4000: 63 20 41 53 20 28 2d 62 29 20 56 49 52 54 55 41 c AS (-b) VIRTUA
+| 4016: 4c 2c 64 20 43 48 45 43 4b 28 64 3e 35 29 2c 65 L,d CHECK(d>5),e
+| 4032: 20 55 4e 49 51 55 45 2c 20 66 20 41 53 20 28 2b UNIQUE, f AS (+
+| 4048: 62 29 29 23 02 06 17 37 11 01 00 69 6e 64 65 78 b))#...7...index
+| 4064: 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 sqlite_autoindex
+| 4080: 5f 74 31 5f 31 74 31 03 00 00 00 08 00 00 00 00 _t1_1t1.........
+| page 2 offset 4096
+| 0: 0d 00 00 00 0a 0f 93 00 0f f6 0f eb 0f e0 0f d5 ................
+| 16: 0f ca 0f 8f 0f b4 0f a9 0f 9e 0f 93 00 00 00 00 ................
+| 3984: 00 00 00 09 0a 05 01 01 01 01 0a 64 6e 14 09 09 ...........dn...
+| 4000: 05 01 01 01 01 09 5a 6d 12 09 08 05 01 01 01 01 ......Zm........
+| 4016: 08 50 6c 10 09 07 05 01 01 01 01 07 46 6b 0e 09 .Pl.........Fk..
+| 4032: 06 05 01 01 01 01 06 3c 6a 0c 09 05 05 01 01 01 .......<j.......
+| 4048: 01 05 32 69 0a 09 04 05 01 01 01 01 04 28 68 08 ..2i.........(h.
+| 4064: 09 03 05 01 01 01 01 03 1e 67 06 09 02 05 01 01 .........g......
+| 4080: 01 01 02 14 66 04 08 01 05 09 01 01 01 0a 65 02 ....f.........e.
+| page 3 offset 8192
+| 0: 0a 00 00 00 0a 0f c5 00 0f fb 0f f5 0f ef 0f e9 ................
+| 16: 0f e3 0f dd 0f d7 0f d1 0f cb 0f c5 00 00 00 00 ................
+| 4032: 00 00 00 00 00 05 03 01 01 14 0a 05 03 01 01 12 ................
+| 4048: 09 05 03 01 01 10 08 05 03 01 01 0e 07 05 03 01 ................
+| 4064: 01 0c 06 05 03 01 01 0a 05 05 03 01 01 08 04 05 ................
+| 4080: 03 01 01 06 03 05 03 01 01 04 02 04 03 01 09 02 ................
+| page 4 offset 12288
+| 0: 0a 00 00 00 0a 0f 75 00 0f 75 0f 83 0f 91 0f 9f ......u..u......
+| 16: 0f ad 0f bb 0f 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3952: 00 00 00 00 00 0d 07 01 01 01 01 01 01 9c 0a 64 ...............d
+| 3968: 6e 14 64 0d 07 02 01 01 01 01 01 a6 09 5a 6d 12 n.d..........Zm.
+| 3984: 5a 0d 07 01 01 01 01 01 01 b0 08 50 6c 10 50 0d Z..........Pl.P.
+| 4000: 07 01 01 01 01 01 01 ba 07 46 6b 0e 46 0d 07 01 .........Fk.F...
+| 4016: 01 01 01 01 01 c4 06 3c 6a 0c 3c 0d 07 01 01 01 .......<j.<.....
+| 4032: 01 01 01 ce 05 32 69 0a 32 0d 07 01 01 01 01 01 .....2i.2.......
+| 4048: 01 d8 04 28 68 08 28 0d 07 01 01 01 01 01 01 e2 ...(h.(.........
+| 4064: 03 1e 67 06 1e 0d 07 01 01 01 01 01 01 ec 02 14 ..g.............
+| 4080: 66 04 14 0c 07 01 09 01 01 01 01 f6 0a 65 02 0a f............e..
+| page 5 offset 16384
+| 0: 0d 00 00 00 03 0f e9 00 0f e9 0f fb 0f f6 00 00 ................
+| 16: 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 03 ff ff ff ff ff ff ................
+| 4080: ff ff 9c 03 00 00 03 64 03 00 00 03 01 03 00 00 .......d........
+| page 6 offset 20480
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| end crash-685346d89b5e5f.db
+}]} {}
+
+do_catchsql_test 1.1 {
+ ALTER TABLE t2 DROP COLUMN e;
+ ALTER TABLE t1 DROP COLUMN f;
+} {1 {database disk image is malformed}}
+
+
+#--------------------------------------------------------------------------
+reset_db
+do_test 2.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 24576 pagesize 4096 filename crash-0572db8f391431.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06 .....@ ........
+| 32: 00 00 63 00 10 05 f0 00 00 00 00 04 10 00 00 04 ..c.............
+| 48: 00 00 00 00 00 00 0f f0 00 00 00 00 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0f f8 00 05 0e cf 00 0f 79 0f d3 .............y..
+| 112: 0f 2e 0e f3 0e cf 00 00 00 00 00 00 00 00 00 00 ................
+| 3776: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 ................
+| 3792: 05 06 17 11 11 01 31 74 61 62 6c 65 74 34 74 34 ......1tablet4t4
+| 3808: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 34 .CREATE TABLE t4
+| 3824: 28 7a 29 39 04 06 17 11 11 01 5f 74 61 62 6c 65 (z)9......_table
+| 3840: 74 33 74 33 05 43 52 45 41 54 45 20 54 41 42 4c t3t3.CREATE TABL
+| 3856: 45 20 74 33 28 78 20 49 4e 54 55 47 45 52 20 50 E t3(x INTUGER P
+| 3872: 52 49 4d 41 52 59 20 4b 45 59 2c 20 79 29 49 03 RIMARY KEY, y)I.
+| 3888: 06 17 11 11 01 7f 74 61 62 6c 65 74 32 74 32 04 ......tablet2t2.
+| 3904: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 CREATE TABLE t2(
+| 3920: 61 2c 62 2c 63 20 50 52 49 4d 41 52 59 20 4b 45 a,b,c PRIMARY KE
+| 3936: 59 2c 20 64 2c 20 65 2c 20 66 29 20 57 49 54 48 Y, d, e, f) WITH
+| 3952: 4f 55 54 20 52 4f 57 49 44 58 05 07 17 11 11 01 OUT ROWIDX......
+| 3968: 81 1b 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 ..tablet1t1.CREA
+| 3984: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 2c TE TABLE t1(a,b,
+| 4000: 63 20 41 53 20 28 2d 62 29 20 56 49 52 54 55 41 c AS (-b) VIRTUA
+| 4016: 4c 2c 64 20 43 48 45 43 4b 28 64 3e 35 29 2c 65 L,d CHECK(d>5),e
+| 4032: 20 55 4e 49 51 55 45 2c 20 66 20 41 53 20 28 2b UNIQUE, f AS (+
+| 4048: 62 29 29 23 02 06 17 37 11 01 00 69 6e 64 65 78 b))#...7...index
+| 4064: 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 sqlite_autoindex
+| 4080: 5f 74 31 5f 31 84 31 03 01 00 00 08 00 00 00 00 _t1_1.1.........
+| page 2 offset 4096
+| 0: 0d 00 00 00 0a 0f 93 00 0f f6 0f eb 0f e0 0f d5 ................
+| 16: 0f ca 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3984: 00 00 00 09 0a 05 01 01 01 01 0a 64 6e 14 09 09 ...........dn...
+| 4000: 05 01 01 01 01 09 5a 6d 12 09 08 05 01 00 f1 01 ......Zm........
+| 4016: 08 50 6c 10 09 07 05 01 01 01 01 07 46 6b 0e 09 .Pl.........Fk..
+| 4032: 06 05 01 00 f1 01 06 3c 6a 0c 09 05 05 01 01 01 .......<j.......
+| 4048: 01 05 32 69 0a 09 04 05 01 01 01 01 04 28 68 08 ..2i.........(h.
+| 4064: 57 03 05 01 01 01 01 03 1e 67 06 09 02 05 01 01 W........g......
+| 4080: 01 01 02 14 66 04 08 01 05 09 01 01 01 0a 65 02 ....f.........e.
+| page 3 offset 8192
+| 0: 09 ff ff ff fa 0f c5 00 0f fb 0f f5 0f ef 0f e9 ................
+| 16: 0f e3 0f dd 0f d7 00 00 00 00 00 00 00 00 00 00 ................
+| 4032: 00 00 00 00 00 05 03 01 01 14 0a 05 03 01 01 12 ................
+| 4048: 09 05 03 01 01 10 08 05 03 01 01 0e 07 05 03 01 ................
+| 4064: 01 0c 06 05 03 01 01 0a 05 05 03 01 01 08 04 05 ................
+| 4080: 03 01 01 06 03 05 03 01 01 04 02 04 03 01 09 02 ................
+| page 4 offset 12288
+| 0: 0a 00 00 00 0a 0f 75 00 0f 75 0f 83 0f 91 0f 9f ......u..u......
+| 16: 0f ad 0f bb 0f 00 00 00 00 00 01 00 00 00 00 00 ................
+| 3952: 00 00 00 00 00 0d 07 01 01 01 01 01 01 9c 0a 64 ...............d
+| 3968: 6e 14 64 0d 07 02 01 01 01 01 01 a6 09 5a 6d 12 n.d..........Zm.
+| 3984: 5a 0d 07 01 01 01 01 d4 01 b0 08 50 6c 10 50 0d Z..........Pl.P.
+| 4000: 07 01 01 01 01 01 01 ba 07 46 6b 0e 46 0d 07 00 .........Fk.F...
+| 4016: 01 01 01 01 01 c4 06 3c 6a 0c 3c 0d 07 01 01 01 .......<j.<.....
+| 4032: 01 01 01 ce 05 32 69 0a 32 0d 07 01 01 01 01 01 .....2i.2.......
+| 4048: 01 d8 04 28 68 08 28 0d 07 01 01 01 01 01 01 e2 ...(h.(.........
+| 4064: 03 1e 67 06 1e 0d 07 01 01 01 01 01 01 ec 02 14 ..g.............
+| 4080: 66 04 14 0c 07 01 09 01 01 00 f1 f6 0a 65 02 0a f............e..
+| page 5 offset 16384
+| 0: 0d 00 00 00 03 0f e9 00 0f e9 0f fb 0f f6 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 03 ff ff ff ff ff ff ................
+| 4080: ff ff 9c 03 00 00 03 64 03 00 01 03 01 03 00 00 .......d........
+| page 6 offset 20480
+| 0: 0d 00 10 00 00 10 01 00 00 00 00 00 00 00 00 00 ................
+| end crash-0572db8f391431.db
+}]} {}
+
+do_catchsql_test 2.1 {
+ ALTER TABLE t1 DROP COLUMN a;
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/alterdropcol.test b/test/alterdropcol.test
new file mode 100644
index 0000000..8674e98
--- /dev/null
+++ b/test/alterdropcol.test
@@ -0,0 +1,339 @@
+# 2021 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix alterdropcol
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y, z UNIQUE);
+ CREATE INDEX t2y ON t2(y);
+
+ CREATE TABLE t3(q, r, s);
+ CREATE INDEX t3rs ON t3(r+s);
+}
+
+do_catchsql_test 1.1 {
+ ALTER TABLE nosuch DROP COLUMN z;
+} {1 {no such table: nosuch}}
+
+do_catchsql_test 1.2 {
+ ALTER TABLE v1 DROP COLUMN c;
+} {1 {cannot drop column from view "v1"}}
+
+ifcapable fts5 {
+ do_execsql_test 1.3.1 {
+ CREATE VIRTUAL TABLE ft1 USING fts5(one, two);
+ }
+ do_catchsql_test 1.3.2 {
+ ALTER TABLE ft1 DROP COLUMN two;
+ } {1 {cannot drop column from virtual table "ft1"}}
+}
+
+do_catchsql_test 1.4 {
+ ALTER TABLE sqlite_schema DROP COLUMN sql;
+} {1 {table sqlite_master may not be altered}}
+
+do_catchsql_test 1.5 {
+ ALTER TABLE t1 DROP COLUMN d;
+} {1 {no such column: "d"}}
+
+do_execsql_test 1.6.1 {
+ ALTER TABLE t1 DROP COLUMN b;
+}
+do_execsql_test 1.6.2 {
+ SELECT sql FROM sqlite_schema WHERE name = 't1'
+} {{CREATE TABLE t1(a, c)}}
+
+do_execsql_test 1.7.1 {
+ ALTER TABLE t1 DROP COLUMN c;
+}
+do_execsql_test 1.7.2 {
+ SELECT sql FROM sqlite_schema WHERE name = 't1'
+} {{CREATE TABLE t1(a)}}
+
+do_catchsql_test 1.7.3 {
+ ALTER TABLE t1 DROP COLUMN a;
+} {1 {cannot drop column "a": no other columns exist}}
+
+
+do_catchsql_test 1.8 {
+ ALTER TABLE t2 DROP COLUMN z
+} {1 {cannot drop UNIQUE column: "z"}}
+
+do_catchsql_test 1.9 {
+ ALTER TABLE t2 DROP COLUMN x
+} {1 {cannot drop PRIMARY KEY column: "x"}}
+
+do_catchsql_test 1.10 {
+ ALTER TABLE t2 DROP COLUMN y
+} {1 {error in index t2y after drop column: no such column: y}}
+
+do_catchsql_test 1.11 {
+ ALTER TABLE t3 DROP COLUMN s
+} {1 {error in index t3rs after drop column: no such column: s}}
+
+#-------------------------------------------------------------------------
+
+foreach {tn wo} {
+ 1 {}
+ 2 {WITHOUT ROWID}
+} { eval [string map [list %TN% $tn %WO% $wo] {
+
+ reset_db
+ do_execsql_test 2.%TN%.0 {
+ CREATE TABLE t1(x, y INTEGER PRIMARY KEY, z) %WO% ;
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ INSERT INTO t1 VALUES(7, 8, 9);
+ }
+
+ do_execsql_test 2.%TN%.1 {
+ ALTER TABLE t1 DROP COLUMN x;
+ SELECT * FROM t1;
+ } {
+ 2 3 5 6 8 9
+ }
+ do_execsql_test 2.%TN%.2 {
+ ALTER TABLE t1 DROP COLUMN z;
+ SELECT * FROM t1;
+ } {
+ 2 5 8
+ }
+}]}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 3.0 {
+ CREATE TABLE t12(a, b, c, CHECK(c>10));
+ CREATE TABLE t13(a, b, c CHECK(c>10));
+}
+do_catchsql_test 3.1 {
+ ALTER TABLE t12 DROP COLUMN c;
+} {1 {error in table t12 after drop column: no such column: c}}
+
+do_catchsql_test 3.2 {
+ ALTER TABLE t13 DROP COLUMN c;
+} {0 {}}
+
+#-------------------------------------------------------------------------
+# Test that generated columns can be dropped. And that other columns from
+# tables that contain generated columns can be dropped.
+#
+foreach {tn wo vs} {
+ 1 "" ""
+ 2 "" VIRTUAL
+ 3 "" STORED
+ 4 "WITHOUT ROWID" STORED
+ 5 "WITHOUT ROWID" VIRTUAL
+} {
+ reset_db
+
+ do_execsql_test 4.$tn.0 "
+ CREATE TABLE 'my table'(a, b PRIMARY KEY, c AS (a+b) $vs, d) $wo
+ "
+ do_execsql_test 4.$tn.1 {
+ INSERT INTO "my table"(a, b, d) VALUES(1, 2, 'hello');
+ INSERT INTO "my table"(a, b, d) VALUES(3, 4, 'world');
+
+ SELECT * FROM "my table"
+ } {
+ 1 2 3 hello
+ 3 4 7 world
+ }
+
+ do_execsql_test 4.$tn.2 {
+ ALTER TABLE "my table" DROP COLUMN c;
+ }
+ do_execsql_test 4.$tn.3 {
+ SELECT * FROM "my table"
+ } {
+ 1 2 hello
+ 3 4 world
+ }
+
+ do_execsql_test 4.$tn.4 "
+ CREATE TABLE x1(a, b, c PRIMARY KEY, d AS (b+c) $vs, e) $wo
+ "
+ do_execsql_test 4.$tn.5 {
+ INSERT INTO x1(a, b, c, e) VALUES(1, 2, 3, 4);
+ INSERT INTO x1(a, b, c, e) VALUES(5, 6, 7, 8);
+ INSERT INTO x1(a, b, c, e) VALUES(9, 10, 11, 12);
+ SELECT * FROM x1;
+ } {
+ 1 2 3 5 4
+ 5 6 7 13 8
+ 9 10 11 21 12
+ }
+
+ do_execsql_test 4.$tn.6 {
+ ALTER TABLE x1 DROP COLUMN a
+ }
+ do_execsql_test 4.$tn.7 {
+ SELECT * FROM x1
+ } {
+ 2 3 5 4
+ 6 7 13 8
+ 10 11 21 12
+ }
+ do_execsql_test 4.$tn.8 {
+ ALTER TABLE x1 DROP COLUMN e
+ }
+ do_execsql_test 4.$tn.9 {
+ SELECT * FROM x1
+ } {
+ 2 3 5
+ 6 7 13
+ 10 11 21
+ }
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE p1(a PRIMARY KEY, b UNIQUE);
+ CREATE TABLE c1(x, y, z REFERENCES p1(c));
+ CREATE TABLE c2(x, y, z, w REFERENCES p1(b));
+}
+do_execsql_test 5.1 {
+ ALTER TABLE c1 DROP COLUMN z;
+ ALTER TABLE c2 DROP COLUMN z;
+ SELECT sql FROM sqlite_schema WHERE name IN ('c1', 'c2');
+} {
+ {CREATE TABLE c1(x, y)}
+ {CREATE TABLE c2(x, y, w REFERENCES p1(b))}
+}
+
+do_execsql_test 5.2.1 {
+ CREATE VIEW v1 AS SELECT d, e FROM p1
+}
+do_catchsql_test 5.2.2 {
+ ALTER TABLE c1 DROP COLUMN x
+} {1 {error in view v1: no such column: d}}
+do_execsql_test 5.3.1 {
+ DROP VIEW v1;
+ CREATE VIEW v1 AS SELECT x, y FROM c1;
+}
+do_catchsql_test 5.3.2 {
+ ALTER TABLE c1 DROP COLUMN x
+} {1 {error in view v1 after drop column: no such column: x}}
+
+do_execsql_test 5.4.1 {
+ CREATE TRIGGER tr AFTER INSERT ON c1 BEGIN
+ INSERT INTO p1 VALUES(new.y, new.xyz);
+ END;
+}
+do_catchsql_test 5.4.2 {
+ ALTER TABLE c1 DROP COLUMN y
+} {1 {error in trigger tr: no such column: new.xyz}}
+do_execsql_test 5.5.1 {
+ DROP TRIGGER tr;
+ CREATE TRIGGER tr AFTER INSERT ON c1 BEGIN
+ INSERT INTO p1 VALUES(new.y, new.z);
+ END;
+}
+do_catchsql_test 5.5.2 {
+ ALTER TABLE c1 DROP COLUMN y
+} {1 {error in trigger tr: no such column: new.z}}
+
+# 2021-03-06 dbsqlfuzz crash-419aa525df93db6e463772c686ac6da27b46da9e
+reset_db
+do_catchsql_test 6.0 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE t2(x,y,z);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_schema SET sql='CREATE INDEX t1b ON t1(b)' WHERE name='t2';
+ PRAGMA writable_schema=OFF;
+ ALTER TABLE t2 DROP COLUMN z;
+} {1 {database disk image is malformed}}
+reset_db
+do_catchsql_test 6.1 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE t2(x,y,z);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_schema SET sql='CREATE VIEW t2(x,y,z) AS SELECT b,a,c FROM t1'
+ WHERE name='t2';
+ PRAGMA writable_schema=OFF;
+ ALTER TABLE t2 DROP COLUMN z;
+} {1 {database disk image is malformed}}
+
+# 2021-04-06 dbsqlfuzz crash-331c5c29bb76257b198f1318eef3288f9624c8ce
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a, b, c, PRIMARY KEY(a COLLATE nocase, a)) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+}
+do_execsql_test 7.1 {
+ ALTER TABLE t1 DROP COLUMN c;
+}
+do_execsql_test 7.2 {
+ SELECT sql FROM sqlite_schema;
+} {{CREATE TABLE t1(a, b, PRIMARY KEY(a COLLATE nocase, a)) WITHOUT ROWID}}
+do_execsql_test 7.3 {
+ SELECT * FROM t1;
+} {1 2 4 5}
+
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_schema
+ SET sql = 'CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b)'
+}
+db close
+sqlite3 db test.db
+do_execsql_test 8.1 {
+ ALTER TABLE t1 DROP COLUMN b;
+}
+do_execsql_test 8.2 {
+ SELECT sql FROM sqlite_schema;
+} {{CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT)}}
+
+#-------------------------------------------------------------------------
+
+foreach {tn wo} {
+ 1 {}
+ 2 {WITHOUT ROWID}
+} {
+ reset_db
+ do_execsql_test 9.$tn.0 "
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c) $wo;
+ "
+ do_execsql_test 9.$tn.1 {
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50000
+ )
+ INSERT INTO t1(a, b, c) SELECT i, 123, 456 FROM s;
+ }
+ do_execsql_test 9.$tn.2 {
+ ALTER TABLE t1 DROP COLUMN b;
+ }
+
+ do_execsql_test 9.$tn.3 {
+ SELECT count(*), c FROM t1 GROUP BY c;
+ } {50000 456}
+}
+
+
+
+finish_test
diff --git a/test/alterdropcol2.test b/test/alterdropcol2.test
new file mode 100644
index 0000000..d60e7db
--- /dev/null
+++ b/test/alterdropcol2.test
@@ -0,0 +1,222 @@
+# 2021 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix alterdropcol2
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+# EVIDENCE-OF: R-58318-35349 The DROP COLUMN syntax is used to remove an
+# existing column from a table.
+do_execsql_test 1.0 {
+ CREATE TABLE t1(c, b, a, PRIMARY KEY(b, a)) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1, 2, 3), (4, 5, 6);
+}
+do_execsql_test 1.1 {
+ ALTER TABLE t1 DROP c;
+}
+
+# EVIDENCE-OF: The DROP COLUMN command removes the named column from the table,
+# and also rewrites the entire table to purge the data associated with that
+# column.
+do_execsql_test 1.2.1 {
+ SELECT * FROM t1;
+} {2 3 5 6}
+
+do_execsql_test 1.2.2 {
+ SELECT sql FROM sqlite_schema;
+} {
+ {CREATE TABLE t1(b, a, PRIMARY KEY(b, a)) WITHOUT ROWID}
+}
+
+proc do_atdc_error_test {tn schema atdc error} {
+ reset_db
+ execsql $schema
+ uplevel [list do_catchsql_test $tn $atdc [list 1 [string trim $error]]]
+}
+
+#-------------------------------------------------------------------------
+# Test cases 2.* attempt to verify the following:
+#
+# EVIDENCE-OF: R-24098-10282 The DROP COLUMN command only works if the column
+# is not referenced by any other parts of the schema and is not a PRIMARY KEY
+# and does not have a UNIQUE constraint.
+#
+
+# EVIDENCE-OF: R-52436-31752 The column is a PRIMARY KEY or part of one.
+#
+do_atdc_error_test 2.1.1 {
+ CREATE TABLE x1(a PRIMARY KEY, b, c);
+} {
+ ALTER TABLE x1 DROP COLUMN a
+} {
+ cannot drop PRIMARY KEY column: "a"
+}
+do_atdc_error_test 2.1.2 {
+ CREATE TABLE x1(a,b,c,d,e, PRIMARY KEY(b,c,d));
+} {
+ ALTER TABLE x1 DROP COLUMN c
+} {
+ cannot drop PRIMARY KEY column: "c"
+}
+
+# EVIDENCE-OF: R-43412-16016 The column has a UNIQUE constraint.
+#
+do_atdc_error_test 2.2.1 {
+ CREATE TABLE x1(a PRIMARY KEY, b, c UNIQUE);
+} {
+ ALTER TABLE x1 DROP COLUMN c
+} {
+ cannot drop UNIQUE column: "c"
+}
+do_atdc_error_test 2.2.2 {
+ CREATE TABLE x1(a PRIMARY KEY, b, c, UNIQUE(b, c));
+} {
+ ALTER TABLE x1 DROP COLUMN c
+} {
+ error in table x1 after drop column: no such column: c
+}
+
+# EVIDENCE-OF: R-46731-08965 The column is indexed.
+#
+do_atdc_error_test 2.3.1 {
+ CREATE TABLE 'one two'('x y', 'z 1', 'a b');
+ CREATE INDEX idx ON 'one two'('z 1');
+} {
+ ALTER TABLE 'one two' DROP COLUMN 'z 1'
+} {
+ error in index idx after drop column: no such column: z 1
+}
+do_atdc_error_test 2.3.2 {
+ CREATE TABLE x1(a, b, c);
+ CREATE INDEX idx ON x1(a);
+} {
+ ALTER TABLE x1 DROP COLUMN a;
+} {
+ error in index idx after drop column: no such column: a
+}
+
+# EVIDENCE-OF: R-46731-08965 The column is indexed.
+#
+do_atdc_error_test 2.4.1 {
+ CREATE TABLE x1234(a, b, c PRIMARY KEY) WITHOUT ROWID;
+ CREATE INDEX i1 ON x1234(b) WHERE ((a+5) % 10)==0;
+} {
+ ALTER TABLE x1234 DROP a
+} {
+ error in index i1 after drop column: no such column: a
+}
+
+# EVIDENCE-OF: R-47838-03249 The column is named in a table or column
+# CHECK constraint not associated with the column being dropped.
+#
+do_atdc_error_test 2.5.1 {
+ CREATE TABLE x1234(a, b, c PRIMARY KEY, CHECK(((a+5)%10)!=0)) WITHOUT ROWID;
+} {
+ ALTER TABLE x1234 DROP a
+} {
+ error in table x1234 after drop column: no such column: a
+}
+
+# EVIDENCE-OF: R-55640-01652 The column is used in a foreign key constraint.
+#
+do_atdc_error_test 2.6.1 {
+ CREATE TABLE p1(x, y UNIQUE);
+ CREATE TABLE c1(u, v, FOREIGN KEY (v) REFERENCES p1(y))
+} {
+ ALTER TABLE c1 DROP v
+} {
+ error in table c1 after drop column: unknown column "v" in foreign key definition
+}
+
+# EVIDENCE-OF: R-20795-39479 The column is used in the expression of a
+# generated column.
+do_atdc_error_test 2.7.1 {
+ CREATE TABLE c1(u, v, w AS (u+v));
+} {
+ ALTER TABLE c1 DROP v
+} {
+ error in table c1 after drop column: no such column: v
+}
+do_atdc_error_test 2.7.2 {
+ CREATE TABLE c1(u, v, w AS (u+v) STORED);
+} {
+ ALTER TABLE c1 DROP u
+} {
+ error in table c1 after drop column: no such column: u
+}
+
+# EVIDENCE-OF: R-01515-49025 The column appears in a trigger or view.
+#
+do_atdc_error_test 2.8.1 {
+ CREATE TABLE log(l);
+ CREATE TABLE c1(u, v, w);
+ CREATE TRIGGER tr1 AFTER INSERT ON c1 BEGIN
+ INSERT INTO log VALUES(new.w);
+ END;
+} {
+ ALTER TABLE c1 DROP w
+} {
+ error in trigger tr1 after drop column: no such column: new.w
+}
+do_atdc_error_test 2.8.2 {
+ CREATE TABLE c1(u, v, w);
+ CREATE VIEW v1 AS SELECT u, v, w FROM c1;
+} {
+ ALTER TABLE c1 DROP w
+} {
+ error in view v1 after drop column: no such column: w
+}
+do_atdc_error_test 2.8.3 {
+ CREATE TABLE c1(u, v, w);
+ CREATE VIEW v1 AS SELECT * FROM c1 WHERE w IS NOT NULL;
+} {
+ ALTER TABLE c1 DROP w
+} {
+ error in view v1 after drop column: no such column: w
+}
+
+#-------------------------------------------------------------------------
+# Verify that a column that is part of a CHECK constraint may be dropped
+# if the CHECK constraint was specified as part of the column definition.
+#
+
+# STALE-EVIDENCE: R-60924-11170 However, the column being deleted can be used in a
+# column CHECK constraint because the column CHECK constraint is dropped
+# together with the column itself.
+do_execsql_test 3.0 {
+ CREATE TABLE yyy(q, w, e CHECK (e > 0), r);
+ INSERT INTO yyy VALUES(1,1,1,1), (2,2,2,2);
+
+ CREATE TABLE zzz(q, w, e, r, CHECK (e > 0));
+ INSERT INTO zzz VALUES(1,1,1,1), (2,2,2,2);
+}
+do_catchsql_test 3.1.1 {
+ INSERT INTO yyy VALUES(0,0,0,0);
+} {1 {CHECK constraint failed: e > 0}}
+do_catchsql_test 3.1.2 {
+ INSERT INTO yyy VALUES(0,0,0,0);
+} {1 {CHECK constraint failed: e > 0}}
+
+do_execsql_test 3.2.1 {
+ ALTER TABLE yyy DROP e;
+}
+do_catchsql_test 3.2.2 {
+ ALTER TABLE zzz DROP e;
+} {1 {error in table zzz after drop column: no such column: e}}
+
+finish_test
diff --git a/test/alterfault.test b/test/alterfault.test
new file mode 100644
index 0000000..b6b4297
--- /dev/null
+++ b/test/alterfault.test
@@ -0,0 +1,41 @@
+# 2021 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix alterfault
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a);
+}
+faultsim_save_and_close
+
+do_faultsim_test 1.1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ ALTER TABLE t1 ADD COLUMN b CHECK (a!=1)
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+
+finish_test
diff --git a/test/alterlegacy.test b/test/alterlegacy.test
new file mode 100644
index 0000000..dfa1716
--- /dev/null
+++ b/test/alterlegacy.test
@@ -0,0 +1,469 @@
+# 2018 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix alterlegacy
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE TABLE t1(a, b, CHECK(t1.a != t1.b));
+ CREATE TABLE t2(a, b);
+ CREATE INDEX t2expr ON t2(a) WHERE t2.b>0;
+}
+
+do_execsql_test 1.1 {
+ SELECT sql FROM sqlite_master
+} {
+ {CREATE TABLE t1(a, b, CHECK(t1.a != t1.b))}
+ {CREATE TABLE t2(a, b)}
+ {CREATE INDEX t2expr ON t2(a) WHERE t2.b>0}
+}
+
+# Legacy behavior is to corrupt the schema in this case, as the table name in
+# the CHECK constraint is incorrect after "t1" is renamed. This version is
+# slightly different - it rejects the change and rolls back the transaction.
+do_catchsql_test 1.2 {
+ ALTER TABLE t1 RENAME TO t1new;
+} {1 {error in table t1new after rename: no such column: t1.a}}
+
+do_execsql_test 1.3 {
+ CREATE TABLE t3(c, d);
+ ALTER TABLE t3 RENAME TO t3new;
+ DROP TABLE t3new;
+}
+
+do_execsql_test 1.4 {
+ SELECT sql FROM sqlite_master
+} {
+ {CREATE TABLE t1(a, b, CHECK(t1.a != t1.b))}
+ {CREATE TABLE t2(a, b)}
+ {CREATE INDEX t2expr ON t2(a) WHERE t2.b>0}
+}
+
+
+do_catchsql_test 1.3 {
+ ALTER TABLE t2 RENAME TO t2new;
+} {1 {error in index t2expr after rename: no such column: t2.b}}
+do_execsql_test 1.4 {
+ SELECT sql FROM sqlite_master
+} {
+ {CREATE TABLE t1(a, b, CHECK(t1.a != t1.b))}
+ {CREATE TABLE t2(a, b)}
+ {CREATE INDEX t2expr ON t2(a) WHERE t2.b>0}
+}
+
+
+#-------------------------------------------------------------------------
+reset_db
+ifcapable vtab {
+ register_echo_module db
+
+ do_execsql_test 2.0 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ CREATE VIRTUAL TABLE eee USING echo('abc');
+ SELECT * FROM eee;
+ } {1 2 3}
+
+ do_execsql_test 2.1 {
+ ALTER TABLE eee RENAME TO fff;
+ SELECT * FROM fff;
+ } {1 2 3}
+
+ db close
+ sqlite3 db test.db
+
+ do_catchsql_test 2.2 {
+ ALTER TABLE fff RENAME TO ggg;
+ } {1 {no such module: echo}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 3.0 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE TABLE txx(a, b, c);
+ INSERT INTO txx VALUES(1, 2, 3);
+ CREATE VIEW vvv AS SELECT main.txx.a, txx.b, c FROM txx;
+ CREATE VIEW uuu AS SELECT main.one.a, one.b, c FROM txx AS one;
+ CREATE VIEW temp.ttt AS SELECT main.txx.a, txx.b, one.b, main.one.a FROM txx AS one, txx;
+}
+
+do_execsql_test 3.1.1 {
+ SELECT * FROM vvv;
+} {1 2 3}
+do_execsql_test 3.1.2a {
+ ALTER TABLE txx RENAME TO "t xx";
+}
+do_catchsql_test 3.1.2b {
+ SELECT * FROM vvv;
+} {1 {no such table: main.txx}}
+do_execsql_test 3.1.3 {
+ SELECT sql FROM sqlite_master WHERE name='vvv';
+} {{CREATE VIEW vvv AS SELECT main.txx.a, txx.b, c FROM txx}}
+
+
+do_catchsql_test 3.2.1 {
+ SELECT * FROM uuu;
+} {1 {no such table: main.txx}}
+do_execsql_test 3.2.2 {
+ SELECT sql FROM sqlite_master WHERE name='uuu';;
+} {{CREATE VIEW uuu AS SELECT main.one.a, one.b, c FROM txx AS one}}
+
+do_catchsql_test 3.3.1 {
+ SELECT * FROM ttt;
+} {1 {no such table: txx}}
+do_execsql_test 3.3.2 {
+ SELECT sql FROM sqlite_temp_master WHERE name='ttt';
+} {{CREATE VIEW ttt AS SELECT main.txx.a, txx.b, one.b, main.one.a FROM txx AS one, txx}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE table t1(x, y);
+ CREATE table t2(a, b);
+
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ SELECT t1.x, * FROM t1, t2;
+ INSERT INTO t2 VALUES(new.x, new.y);
+ END;
+}
+
+do_execsql_test 4.1 {
+ INSERT INTO t1 VALUES(1, 1);
+ ALTER TABLE t1 RENAME TO t11;
+}
+do_catchsql_test 4.1a {
+ INSERT INTO t11 VALUES(2, 2);
+} {1 {no such table: main.t1}}
+do_execsql_test 4.1b {
+ ALTER TABLE t11 RENAME TO t1;
+ ALTER TABLE t2 RENAME TO t22;
+}
+do_catchsql_test 4.1c {
+ INSERT INTO t1 VALUES(3, 3);
+} {1 {no such table: main.t2}}
+
+proc squish {a} {
+ string trim [regsub -all {[[:space:]][[:space:]]*} $a { }]
+}
+db func squish squish
+do_test 4.2 {
+ execsql { SELECT squish(sql) FROM sqlite_master WHERE name = 'tr1' }
+} [list [squish {
+ CREATE TRIGGER tr1 AFTER INSERT ON "t1" BEGIN
+ SELECT t1.x, * FROM t1, t2;
+ INSERT INTO t2 VALUES(new.x, new.y);
+ END
+}]]
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE TABLE t9(a, b, c);
+ CREATE TABLE t10(a, b, c);
+ CREATE TEMP TABLE t9(a, b, c);
+
+ CREATE TRIGGER temp.t9t AFTER INSERT ON temp.t9 BEGIN
+ INSERT INTO t10 VALUES(new.a, new.b, new.c);
+ END;
+
+ INSERT INTO temp.t9 VALUES(1, 2, 3);
+ SELECT * FROM t10;
+} {1 2 3}
+
+do_execsql_test 5.1 {
+ ALTER TABLE temp.t9 RENAME TO 't1234567890'
+}
+
+do_execsql_test 5.2 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ CREATE VIEW v AS SELECT one.a, one.b, t2.a, t2.b FROM t1 AS one, t2;
+ SELECT * FROM v;
+} {1 2 3 4}
+
+do_execsql_test 5.3 {
+ ALTER TABLE t2 RENAME TO one;
+} {}
+
+do_catchsql_test 5.4 {
+ SELECT * FROM v
+} {1 {no such table: main.t2}}
+
+do_execsql_test 5.5 {
+ ALTER TABLE one RENAME TO t2;
+ DROP VIEW v;
+ CREATE VIEW temp.vv AS SELECT one.a, one.b, t2.a, t2.b FROM t1 AS one, t2;
+ SELECT * FROM vv;
+} {1 2 3 4}
+
+do_execsql_test 5.6 {
+ ALTER TABLE t2 RENAME TO one;
+} {}
+do_catchsql_test 5.7 {
+ SELECT * FROM vv
+} {1 {no such table: t2}}
+
+#-------------------------------------------------------------------------
+
+ifcapable vtab {
+ register_tcl_module db
+ proc tcl_command {method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(a, b, c)"
+ }
+ }
+ return {}
+ }
+
+ do_execsql_test 6.0 {
+ CREATE VIRTUAL TABLE x1 USING tcl(tcl_command);
+ }
+
+ do_execsql_test 6.1 {
+ ALTER TABLE x1 RENAME TO x2;
+ SELECT sql FROM sqlite_master WHERE name = 'x2'
+ } {{CREATE VIRTUAL TABLE "x2" USING tcl(tcl_command)}}
+
+ do_execsql_test 7.1 {
+ CREATE TABLE ddd(db, sql, zOld, zNew, bTemp);
+ INSERT INTO ddd VALUES(
+ 'main', 'CREATE TABLE x1(i INTEGER, t TEXT)', 'ddd', NULL, 0
+ ), (
+ 'main', 'CREATE TABLE x1(i INTEGER, t TEXT)', NULL, 'eee', 0
+ ), (
+ 'main', NULL, 'ddd', 'eee', 0
+ );
+ } {}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+forcedelete test.db2
+do_execsql_test 8.1 {
+ PRAGMA legacy_alter_table = 1;
+ ATTACH 'test.db2' AS aux;
+ PRAGMA foreign_keys = on;
+ CREATE TABLE aux.p1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE aux.c1(x INTEGER PRIMARY KEY, y REFERENCES p1(a));
+ INSERT INTO aux.p1 VALUES(1, 1);
+ INSERT INTO aux.p1 VALUES(2, 2);
+ INSERT INTO aux.c1 VALUES(NULL, 2);
+ CREATE TABLE aux.c2(x INTEGER PRIMARY KEY, y REFERENCES c1(a));
+}
+
+do_execsql_test 8.2 {
+ ALTER TABLE aux.p1 RENAME TO ppp;
+}
+
+do_execsql_test 8.2 {
+ INSERT INTO aux.c1 VALUES(NULL, 1);
+ SELECT sql FROM aux.sqlite_master WHERE name = 'c1';
+} {{CREATE TABLE c1(x INTEGER PRIMARY KEY, y REFERENCES "ppp"(a))}}
+
+reset_db
+do_execsql_test 9.0 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE TABLE t1(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t2;
+}
+do_execsql_test 9.1 {
+ ALTER TABLE t1 RENAME TO t3;
+} {}
+do_execsql_test 9.1b {
+ ALTER TABLE t3 RENAME TO t1;
+} {}
+do_execsql_test 9.2 {
+ DROP VIEW v1;
+ CREATE TRIGGER tr AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.a);
+ END;
+}
+do_execsql_test 9.3 {
+ ALTER TABLE t1 RENAME TO t3;
+} {}
+
+forcedelete test.db2
+do_execsql_test 9.4 {
+ ALTER TABLE t3 RENAME TO t1;
+ DROP TRIGGER tr;
+
+ ATTACH 'test.db2' AS aux;
+ CREATE TRIGGER tr AFTER INSERT ON t1 WHEN new.a IS NULL BEGIN SELECT 1, 2, 3; END;
+
+ CREATE TABLE aux.t1(x);
+ CREATE TEMP TRIGGER tr AFTER INSERT ON aux.t1 BEGIN SELECT 1, 2, 3; END;
+}
+do_execsql_test 9.5 {
+ ALTER TABLE main.t1 RENAME TO t3;
+}
+do_execsql_test 9.6 {
+ SELECT sql FROM sqlite_temp_master;
+ SELECT sql FROM sqlite_master WHERE type='trigger';
+} {
+ {CREATE TRIGGER tr AFTER INSERT ON aux.t1 BEGIN SELECT 1, 2, 3; END}
+ {CREATE TRIGGER tr AFTER INSERT ON "t3" WHEN new.a IS NULL BEGIN SELECT 1, 2, 3; END}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+ifcapable fts5 {
+ do_execsql_test 10.0 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE VIRTUAL TABLE fff USING fts5(x, y, z);
+ }
+
+ do_execsql_test 10.1 {
+ BEGIN;
+ INSERT INTO fff VALUES('a', 'b', 'c');
+ ALTER TABLE fff RENAME TO ggg;
+ COMMIT;
+ }
+
+ do_execsql_test 10.2 {
+ SELECT * FROM ggg;
+ } {a b c}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+forcedelete test.db2
+db func trigger trigger
+set ::trigger [list]
+proc trigger {args} {
+ lappend ::trigger $args
+}
+do_execsql_test 11.0 {
+ PRAGMA legacy_alter_table = 1;
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t1(a, b, c);
+ CREATE TABLE main.t1(a, b, c);
+ CREATE TEMP TRIGGER tr AFTER INSERT ON aux.t1 BEGIN
+ SELECT trigger(new.a, new.b, new.c);
+ END;
+}
+
+do_execsql_test 11.1 {
+ INSERT INTO main.t1 VALUES(1, 2, 3);
+ INSERT INTO aux.t1 VALUES(4, 5, 6);
+}
+do_test 11.2 { set ::trigger } {{4 5 6}}
+
+do_execsql_test 11.3 {
+ SELECT name, tbl_name FROM sqlite_temp_master;
+} {tr t1}
+
+do_execsql_test 11.4 {
+ ALTER TABLE main.t1 RENAME TO t2;
+ SELECT name, tbl_name FROM sqlite_temp_master;
+} {tr t1}
+
+do_execsql_test 11.5 {
+ ALTER TABLE aux.t1 RENAME TO t2;
+ SELECT name, tbl_name FROM sqlite_temp_master;
+} {tr t2}
+
+do_execsql_test 11.6 {
+ INSERT INTO aux.t2 VALUES(7, 8, 9);
+}
+do_test 11.7 { set ::trigger } {{4 5 6} {7 8 9}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 12.0 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(w);
+ CREATE TRIGGER temp.r1 AFTER INSERT ON main.t2 BEGIN
+ INSERT INTO t1(a) VALUES(new.w);
+ END;
+ CREATE TEMP TABLE t2(x);
+}
+
+do_execsql_test 12.1 {
+ ALTER TABLE main.t2 RENAME TO t3;
+}
+
+do_execsql_test 12.2 {
+ INSERT INTO t3 VALUES('WWW');
+ SELECT * FROM t1;
+} {WWW}
+
+
+#-------------------------------------------------------------------------
+reset_db
+
+ifcapable rtree {
+ do_execsql_test 14.0 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE VIRTUAL TABLE rt USING rtree(id, minx, maxx, miny, maxy);
+
+ CREATE TABLE "mytable" ( "fid" INTEGER PRIMARY KEY, "geom" BLOB);
+
+ CREATE TRIGGER tr1 AFTER UPDATE OF "geom" ON "mytable"
+ WHEN OLD."fid" = NEW."fid" AND NEW."geom" IS NULL BEGIN
+ DELETE FROM rt WHERE id = OLD."fid";
+ END;
+
+ INSERT INTO mytable VALUES(1, X'abcd');
+ }
+
+ do_execsql_test 14.1 {
+ UPDATE mytable SET geom = X'1234'
+ }
+
+ do_execsql_test 14.2 {
+ ALTER TABLE mytable RENAME TO mytable_renamed;
+ }
+
+ do_execsql_test 14.3 {
+ CREATE TRIGGER tr2 AFTER INSERT ON mytable_renamed BEGIN
+ DELETE FROM rt WHERE id=(SELECT min(id) FROM rt);
+ END;
+ }
+
+ do_execsql_test 14.4 {
+ ALTER TABLE mytable_renamed RENAME TO mytable2;
+ }
+}
+
+reset_db
+do_execsql_test 14.5 {
+ PRAGMA legacy_alter_table = 1;
+ CREATE TABLE t1(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE TRIGGER xyz AFTER INSERT ON t1 BEGIN
+ SELECT a, b FROM v1;
+ END;
+}
+do_execsql_test 14.6 {
+ ALTER TABLE t1 RENAME TO tt1;
+}
+
+
+finish_test
diff --git a/test/altermalloc.test b/test/altermalloc.test
new file mode 100644
index 0000000..22ea158
--- /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 {
+ 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/altermalloc2.test b/test/altermalloc2.test
new file mode 100644
index 0000000..a90be88
--- /dev/null
+++ b/test/altermalloc2.test
@@ -0,0 +1,127 @@
+# 2018 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix altermalloc2
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(abcd, efgh);
+}
+faultsim_save_and_close
+
+set ::TMPDBERROR [list 1 \
+ {unable to open a temporary database file for storing temporary tables}
+]
+
+
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ ALTER TABLE t1 RENAME abcd TO dcba
+ }
+} -test {
+ faultsim_test_result {0 {}} $::TMPDBERROR
+}
+
+catch {db close}
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 2.0 {
+ PRAGMA encoding = 'utf-16';
+ CREATE TABLE t1(abcd, efgh);
+}
+faultsim_save_and_close
+
+do_faultsim_test 2 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ ALTER TABLE t1 RENAME abcd TO dcba
+ }
+} -test {
+ faultsim_test_result {0 {}} $::TMPDBERROR
+}
+
+
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(abcd, efgh);
+ CREATE VIEW v1 AS SELECT * FROM t1 WHERE abcd>efgh;
+}
+faultsim_save_and_close
+
+do_faultsim_test 3 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ ALTER TABLE t1 RENAME abcd TO dcba
+ }
+} -test {
+ faultsim_test_result {0 {}} $::TMPDBERROR
+}
+
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE rr(a, b);
+ CREATE VIEW vv AS SELECT * FROM rr;
+
+ CREATE TRIGGER vv1 INSTEAD OF INSERT ON vv BEGIN
+ SELECT 1, 2, 3;
+ END;
+ CREATE TRIGGER tr1 AFTER INSERT ON rr BEGIN
+ INSERT INTO vv VALUES(new.a, new.b);
+ END;
+} {}
+
+faultsim_save_and_close
+do_faultsim_test 4 -faults oom-* -prep {
+ faultsim_restore_and_reopen
+ execsql { SELECT * FROM sqlite_master }
+} -body {
+ execsql {
+ ALTER TABLE rr RENAME a TO c;
+ }
+} -test {
+ faultsim_test_result {0 {}} $::TMPDBERROR
+}
+
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE rr(a, b);
+ CREATE VIEW vv AS SELECT * FROM (
+ WITH abc(d, e) AS (SELECT * FROM rr)
+ SELECT * FROM abc
+ );
+} {}
+
+faultsim_save_and_close
+do_faultsim_test 5 -faults oom-* -prep {
+ faultsim_restore_and_reopen
+ execsql { SELECT * FROM sqlite_master }
+} -body {
+ execsql {
+ ALTER TABLE rr RENAME TO c;
+ }
+} -test {
+ faultsim_test_result {0 {}} $::TMPDBERROR
+}
+
+finish_test
diff --git a/test/altermalloc3.test b/test/altermalloc3.test
new file mode 100644
index 0000000..2dc0b46
--- /dev/null
+++ b/test/altermalloc3.test
@@ -0,0 +1,89 @@
+# 2021 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix altermalloc3
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+
+set ::TMPDBERROR [list 1 \
+ {unable to open a temporary database file for storing temporary tables}
+]
+
+do_execsql_test 1.0 {
+ CREATE TABLE x1(
+ one, two, three, PRIMARY KEY(one),
+ CHECK (three!="xyz"), CHECK (two!="one")
+ ) WITHOUT ROWID;
+ CREATE INDEX x1i ON x1(one+"two"+"four") WHERE "five";
+ CREATE TEMP TRIGGER AFTER INSERT ON x1 BEGIN
+ UPDATE x1 SET two=new.three || "new" WHERE one=new.one||"";
+ END;
+ CREATE TABLE t1(a, b, c, d, PRIMARY KEY(d, b)) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1, 2, 3, 4);
+}
+faultsim_save_and_close
+
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { ALTER TABLE t1 DROP COLUMN c }
+} -test {
+ faultsim_test_result {0 {}} $::TMPDBERROR
+}
+
+
+#-------------------------------------------------------------------------
+# dbsqlfuzz e3dd84cda3848016a6a6024c7249d09bc2ef2615
+#
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t2(k,v);
+ CREATE TRIGGER r2 AFTER INSERT ON t2 BEGIN
+ UPDATE t2 SET (k,v)= (
+ (WITH cte1(a) AS ( SELECT 1 FROM ( SELECT * FROM t2 ) )
+ SELECT a FROM cte1
+ ), 1);
+ END;
+
+ CREATE TRIGGER r1 AFTER INSERT ON t2 BEGIN
+ UPDATE t2 SET k=1 FROM t2 AS one, t2 AS two NATURAL JOIN t2 AS three
+ WHERE one.k=two.v;
+ END;
+}
+
+faultsim_save_and_close
+faultsim_restore_and_reopen
+
+do_execsql_test 2.1 {
+ ALTER TABLE t2 RENAME TO t2x;
+}
+
+do_faultsim_test 2.2 -prep {
+ faultsim_restore_and_reopen
+ db eval { SELECT * FROM sqlite_master }
+} -body {
+ execsql {
+ ALTER TABLE t2 RENAME TO t2x;
+ }
+} -test {
+ faultsim_test_result {0 {}} $::TMPDBERROR
+}
+
+finish_test
diff --git a/test/alterqf.test b/test/alterqf.test
new file mode 100644
index 0000000..423a9fa
--- /dev/null
+++ b/test/alterqf.test
@@ -0,0 +1,120 @@
+# 2021 March 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
+# script focuses on testing internal function sqlite_rename_quotefix().
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix alterqf
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+
+sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+}
+
+foreach {tn before after} {
+ 1 {CREATE VIEW v1 AS SELECT "a", "b", "notacolumn!", "c" FROM t1}
+ {CREATE VIEW v1 AS SELECT "a", "b", 'notacolumn!', "c" FROM t1}
+
+ 2 {CREATE VIEW v1 AS SELECT "a", "b", "not'a'column!", "c" FROM t1}
+ {CREATE VIEW v1 AS SELECT "a", "b", 'not''a''column!', "c" FROM t1}
+
+ 3 {CREATE VIEW v1 AS SELECT "a", "b", "not""a""column!", "c" FROM t1}
+ {CREATE VIEW v1 AS SELECT "a", "b", 'not"a"column!', "c" FROM t1}
+
+ 4 {CREATE VIEW v1 AS SELECT "val", count("b") FROM t1 GROUP BY "abc"}
+ {CREATE VIEW v1 AS SELECT 'val', count("b") FROM t1 GROUP BY 'abc'}
+
+ 5 {CREATE TABLE xyz(a CHECK (a!="str"), b AS (a||"str"))}
+ {CREATE TABLE xyz(a CHECK (a!='str'), b AS (a||'str'))}
+
+ 6 {CREATE INDEX i1 ON t1(a || "str", "b", "val")}
+ {CREATE INDEX i1 ON t1(a || 'str', "b", 'val')}
+
+ 7 {CREATE TRIGGER tr AFTER INSERT ON t1 BEGIN SELECT "abcd"; END}
+ {CREATE TRIGGER tr AFTER INSERT ON t1 BEGIN SELECT 'abcd'; END}
+
+ 8 {CREATE VIEW v1 AS SELECT "string"'alias' FROM t1}
+ {CREATE VIEW v1 AS SELECT 'string' 'alias' FROM t1}
+
+ 9 {CREATE INDEX i1 ON t1(a) WHERE "b"="bb"}
+ {CREATE INDEX i1 ON t1(a) WHERE "b"='bb'}
+
+ 10 {CREATE TABLE t2(abc, xyz CHECK (xyz != "123"))}
+ {CREATE TABLE t2(abc, xyz CHECK (xyz != '123'))}
+
+ 11 {CREATE TRIGGER ott AFTER UPDATE ON t1 BEGIN
+ SELECT max("str", new."a") FROM t1
+ WHERE group_concat("b", ",") OVER (ORDER BY c||"str");
+ UPDATE t1 SET c= b + "str";
+ DELETE FROM t1 WHERE EXISTS (
+ SELECT 1 FROM t1 AS o WHERE o."a" = "o.a" AND t1.b IN("t1.b")
+ );
+ END;
+ } {CREATE TRIGGER ott AFTER UPDATE ON t1 BEGIN
+ SELECT max('str', new."a") FROM t1
+ WHERE group_concat("b", ',') OVER (ORDER BY c||'str');
+ UPDATE t1 SET c= b + 'str';
+ DELETE FROM t1 WHERE EXISTS (
+ SELECT 1 FROM t1 AS o WHERE o."a" = 'o.a' AND t1.b IN('t1.b')
+ );
+ END;
+ }
+
+} {
+ do_execsql_test 1.$tn {
+ SELECT sqlite_rename_quotefix('main', $before)
+ } [list $after]
+}
+
+#-------------------------------------------------------------------------
+reset_db
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+do_execsql_test 2.0 {
+ CREATE TABLE x1(
+ one, two, three, PRIMARY KEY(one),
+ CHECK (three!="xyz"), CHECK (two!="one")
+ ) WITHOUT ROWID;
+ CREATE INDEX x1i ON x1(one+"two"+"four") WHERE "five";
+ CREATE TEMP TRIGGER AFTER INSERT ON x1 BEGIN
+ UPDATE x1 SET two=new.three || "new" WHERE one=new.one||"";
+ END;
+}
+
+do_execsql_test 2.1 {
+ ALTER TABLE x1 RENAME two TO 'four';
+ SELECT sql FROM sqlite_schema;
+ SELECT sql FROM sqlite_temp_schema;
+} {{CREATE TABLE x1(
+ one, "four", three, PRIMARY KEY(one),
+ CHECK (three!='xyz'), CHECK ("four"!="one")
+ ) WITHOUT ROWID}
+ {CREATE INDEX x1i ON x1(one+"four"+'four') WHERE 'five'}
+ {CREATE TRIGGER AFTER INSERT ON x1 BEGIN
+ UPDATE x1 SET "four"=new.three || 'new' WHERE one=new.one||'';
+ END}
+}
+
+
+finish_test
diff --git a/test/altertab.test b/test/altertab.test
new file mode 100644
index 0000000..6d8347e
--- /dev/null
+++ b/test/altertab.test
@@ -0,0 +1,984 @@
+# 2018 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
+set testprefix altertab
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, CHECK(t1.a != t1.b));
+
+ CREATE TABLE t2(a, b);
+ CREATE INDEX t2expr ON t2(a) WHERE t2.b>0;
+}
+
+do_execsql_test 1.1 {
+ SELECT sql FROM sqlite_master
+} {
+ {CREATE TABLE t1(a, b, CHECK(t1.a != t1.b))}
+ {CREATE TABLE t2(a, b)}
+ {CREATE INDEX t2expr ON t2(a) WHERE t2.b>0}
+}
+
+do_execsql_test 1.2 {
+ ALTER TABLE t1 RENAME TO t1new;
+}
+
+do_execsql_test 1.3 {
+ CREATE TABLE t3(c, d);
+ ALTER TABLE t3 RENAME TO t3new;
+ DROP TABLE t3new;
+}
+
+do_execsql_test 1.4 {
+ SELECT sql FROM sqlite_master
+} {
+ {CREATE TABLE "t1new"(a, b, CHECK("t1new".a != "t1new".b))}
+ {CREATE TABLE t2(a, b)}
+ {CREATE INDEX t2expr ON t2(a) WHERE t2.b>0}
+}
+
+
+do_execsql_test 1.3 {
+ ALTER TABLE t2 RENAME TO t2new;
+}
+do_execsql_test 1.4 {
+ SELECT sql FROM sqlite_master
+} {
+ {CREATE TABLE "t1new"(a, b, CHECK("t1new".a != "t1new".b))}
+ {CREATE TABLE "t2new"(a, b)}
+ {CREATE INDEX t2expr ON "t2new"(a) WHERE "t2new".b>0}
+}
+
+
+#-------------------------------------------------------------------------
+reset_db
+ifcapable vtab {
+ register_echo_module db
+
+ do_execsql_test 2.0 {
+ CREATE TABLE abc(a, b, c);
+ INSERT INTO abc VALUES(1, 2, 3);
+ CREATE VIRTUAL TABLE eee USING echo('abc');
+ SELECT * FROM eee;
+ } {1 2 3}
+
+ do_execsql_test 2.1 {
+ ALTER TABLE eee RENAME TO fff;
+ SELECT * FROM fff;
+ } {1 2 3}
+
+ db close
+ sqlite3 db test.db
+
+ do_catchsql_test 2.2 {
+ ALTER TABLE fff RENAME TO ggg;
+ } {1 {no such module: echo}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 3.0 {
+ CREATE TABLE txx(a, b, c);
+ INSERT INTO txx VALUES(1, 2, 3);
+ CREATE VIEW vvv AS SELECT main.txx.a, txx.b, c FROM txx;
+ CREATE VIEW uuu AS SELECT main.one.a, one.b, c FROM txx AS one;
+ CREATE VIEW temp.ttt AS SELECT main.txx.a, txx.b, one.b, main.one.a FROM txx AS one, txx;
+}
+
+do_execsql_test 3.1.1 {
+ SELECT * FROM vvv;
+} {1 2 3}
+do_execsql_test 3.1.2 {
+ ALTER TABLE txx RENAME TO "t xx";
+ SELECT * FROM vvv;
+} {1 2 3}
+do_execsql_test 3.1.3 {
+ SELECT sql FROM sqlite_master WHERE name='vvv';
+} {{CREATE VIEW vvv AS SELECT main."t xx".a, "t xx".b, c FROM "t xx"}}
+
+
+do_execsql_test 3.2.1 {
+ SELECT * FROM uuu;
+} {1 2 3}
+do_execsql_test 3.2.2 {
+ SELECT sql FROM sqlite_master WHERE name='uuu';;
+} {{CREATE VIEW uuu AS SELECT main.one.a, one.b, c FROM "t xx" AS one}}
+
+do_execsql_test 3.3.1 {
+ SELECT * FROM ttt;
+} {1 2 2 1}
+do_execsql_test 3.3.2 {
+ SELECT sql FROM sqlite_temp_master WHERE name='ttt';
+} {{CREATE VIEW ttt AS SELECT main."t xx".a, "t xx".b, one.b, main.one.a FROM "t xx" AS one, "t xx"}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE table t1(x, y);
+ CREATE table t2(a, b);
+
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ SELECT t1.x, * FROM t1, t2;
+ INSERT INTO t2 VALUES(new.x, new.y);
+ END;
+}
+
+do_execsql_test 4.1 {
+ INSERT INTO t1 VALUES(1, 1);
+ ALTER TABLE t1 RENAME TO t11;
+ INSERT INTO t11 VALUES(2, 2);
+ ALTER TABLE t2 RENAME TO t22;
+ INSERT INTO t11 VALUES(3, 3);
+}
+
+proc squish {a} {
+ string trim [regsub -all {[[:space:]][[:space:]]*} $a { }]
+}
+db func squish squish
+do_test 4.2 {
+ execsql { SELECT squish(sql) FROM sqlite_master WHERE name = 'tr1' }
+} [list [squish {
+ CREATE TRIGGER tr1 AFTER INSERT ON "t11" BEGIN
+ SELECT "t11".x, * FROM "t11", "t22";
+ INSERT INTO "t22" VALUES(new.x, new.y);
+ END
+}]]
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t9(a, b, c);
+ CREATE TABLE t10(a, b, c);
+ CREATE TEMP TABLE t9(a, b, c);
+
+ CREATE TRIGGER temp.t9t AFTER INSERT ON temp.t9 BEGIN
+ INSERT INTO t10 VALUES(new.a, new.b, new.c);
+ END;
+
+ INSERT INTO temp.t9 VALUES(1, 2, 3);
+ SELECT * FROM t10;
+} {1 2 3}
+
+do_execsql_test 5.1 {
+ ALTER TABLE temp.t9 RENAME TO 't1234567890'
+}
+
+do_execsql_test 5.2 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ CREATE VIEW v AS SELECT one.a, one.b, t2.a, t2.b FROM t1 AS one, t2;
+ SELECT * FROM v;
+} {1 2 3 4}
+
+do_catchsql_test 5.3 {
+ ALTER TABLE t2 RENAME TO one;
+} {1 {error in view v after rename: ambiguous column name: one.a}}
+
+do_execsql_test 5.4 {
+ SELECT * FROM v
+} {1 2 3 4}
+
+do_execsql_test 5.5 {
+ DROP VIEW v;
+ CREATE VIEW temp.vv AS SELECT one.a, one.b, t2.a, t2.b FROM t1 AS one, t2;
+ SELECT * FROM vv;
+} {1 2 3 4}
+
+do_catchsql_test 5.6 {
+ ALTER TABLE t2 RENAME TO one;
+} {1 {error in view vv after rename: ambiguous column name: one.a}}
+
+#-------------------------------------------------------------------------
+
+ifcapable vtab {
+ register_tcl_module db
+ proc tcl_command {method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(a, b, c)"
+ }
+ }
+ return {}
+ }
+
+ do_execsql_test 6.0 {
+ CREATE VIRTUAL TABLE x1 USING tcl(tcl_command);
+ }
+
+ do_execsql_test 6.1 {
+ ALTER TABLE x1 RENAME TO x2;
+ SELECT sql FROM sqlite_master WHERE name = 'x2'
+ } {{CREATE VIRTUAL TABLE "x2" USING tcl(tcl_command)}}
+
+ do_execsql_test 7.1 {
+ CREATE TABLE ddd(db, sql, zOld, zNew, bTemp);
+ INSERT INTO ddd VALUES(
+ 'main', 'CREATE TABLE x1(i INTEGER, t TEXT)', 'ddd', NULL, 0
+ ), (
+ 'main', 'CREATE TABLE x1(i INTEGER, t TEXT)', NULL, 'eee', 0
+ ), (
+ 'main', NULL, 'ddd', 'eee', 0
+ );
+ } {}
+
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+ do_execsql_test 7.2 {
+ SELECT
+ sqlite_rename_table(db, 0, 0, sql, zOld, zNew, bTemp)
+ FROM ddd;
+ } {{} {} {}}
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+forcedelete test.db2
+do_execsql_test 8.1 {
+ ATTACH 'test.db2' AS aux;
+ PRAGMA foreign_keys = on;
+ CREATE TABLE aux.p1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE aux.c1(x INTEGER PRIMARY KEY, y REFERENCES p1(a));
+ INSERT INTO aux.p1 VALUES(1, 1);
+ INSERT INTO aux.p1 VALUES(2, 2);
+ INSERT INTO aux.c1 VALUES(NULL, 2);
+ CREATE TABLE aux.c2(x INTEGER PRIMARY KEY, y REFERENCES c1(a));
+}
+
+do_execsql_test 8.2 {
+ ALTER TABLE aux.p1 RENAME TO ppp;
+}
+
+do_execsql_test 8.2 {
+ INSERT INTO aux.c1 VALUES(NULL, 1);
+ SELECT sql FROM aux.sqlite_master WHERE name = 'c1';
+} {{CREATE TABLE c1(x INTEGER PRIMARY KEY, y REFERENCES "ppp"(a))}}
+
+reset_db
+do_execsql_test 9.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t2;
+}
+do_catchsql_test 9.1 {
+ ALTER TABLE t1 RENAME TO t3;
+} {1 {error in view v1: no such table: main.t2}}
+do_execsql_test 9.2 {
+ DROP VIEW v1;
+ CREATE TRIGGER tr AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.a);
+ END;
+}
+do_catchsql_test 9.3 {
+ ALTER TABLE t1 RENAME TO t3;
+} {1 {error in trigger tr: no such table: main.t2}}
+
+forcedelete test.db2
+do_execsql_test 9.4 {
+ DROP TRIGGER tr;
+
+ ATTACH 'test.db2' AS aux;
+ CREATE TRIGGER tr AFTER INSERT ON t1 WHEN new.a IS NULL BEGIN SELECT 1, 2, 3; END;
+
+ CREATE TABLE aux.t1(x);
+ CREATE TEMP TRIGGER tr AFTER INSERT ON aux.t1 BEGIN SELECT 1, 2, 3; END;
+}
+do_execsql_test 9.5 {
+ ALTER TABLE main.t1 RENAME TO t3;
+}
+do_execsql_test 9.6 {
+ SELECT sql FROM sqlite_temp_master;
+ SELECT sql FROM sqlite_master WHERE type='trigger';
+} {
+ {CREATE TRIGGER tr AFTER INSERT ON aux.t1 BEGIN SELECT 1, 2, 3; END}
+ {CREATE TRIGGER tr AFTER INSERT ON "t3" WHEN new.a IS NULL BEGIN SELECT 1, 2, 3; END}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+ifcapable fts5 {
+ do_execsql_test 10.0 {
+ CREATE VIRTUAL TABLE fff USING fts5(x, y, z);
+ }
+
+ do_execsql_test 10.1 {
+ BEGIN;
+ INSERT INTO fff VALUES('a', 'b', 'c');
+ ALTER TABLE fff RENAME TO ggg;
+ COMMIT;
+ }
+
+ do_execsql_test 10.2 {
+ SELECT * FROM ggg;
+ } {a b c}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+forcedelete test.db2
+db func trigger trigger
+set ::trigger [list]
+proc trigger {args} {
+ lappend ::trigger $args
+}
+do_execsql_test 11.0 {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t1(a, b, c);
+ CREATE TABLE main.t1(a, b, c);
+ CREATE TEMP TRIGGER tr AFTER INSERT ON aux.t1 BEGIN
+ SELECT trigger(new.a, new.b, new.c);
+ END;
+}
+
+do_execsql_test 11.1 {
+ INSERT INTO main.t1 VALUES(1, 2, 3);
+ INSERT INTO aux.t1 VALUES(4, 5, 6);
+}
+do_test 11.2 { set ::trigger } {{4 5 6}}
+
+do_execsql_test 11.3 {
+ SELECT name, tbl_name FROM sqlite_temp_master;
+} {tr t1}
+
+do_execsql_test 11.4 {
+ ALTER TABLE main.t1 RENAME TO t2;
+ SELECT name, tbl_name FROM sqlite_temp_master;
+} {tr t1}
+
+do_execsql_test 11.5 {
+ ALTER TABLE aux.t1 RENAME TO t2;
+ SELECT name, tbl_name FROM sqlite_temp_master;
+} {tr t2}
+
+do_execsql_test 11.6 {
+ INSERT INTO aux.t2 VALUES(7, 8, 9);
+}
+do_test 11.7 { set ::trigger } {{4 5 6} {7 8 9}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 12.0 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(w);
+ CREATE TRIGGER temp.r1 AFTER INSERT ON main.t2 BEGIN
+ INSERT INTO t1(a) VALUES(new.w);
+ END;
+ CREATE TEMP TABLE t2(x);
+}
+
+do_execsql_test 12.1 {
+ ALTER TABLE main.t2 RENAME TO t3;
+}
+
+do_execsql_test 12.2 {
+ INSERT INTO t3 VALUES('WWW');
+ SELECT * FROM t1;
+} {WWW}
+
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 13.0 {
+ CREATE TABLE t1(x, y);
+ CREATE TABLE t2(a, b);
+ CREATE TABLE log(c);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO log SELECT y FROM t1, t2;
+ END;
+}
+
+do_execsql_test 13.1 {
+ INSERT INTO t1 VALUES(1, 2);
+}
+
+do_catchsql_test 13.2 {
+ ALTER TABLE t2 RENAME b TO y;
+} {1 {error in trigger tr1 after rename: ambiguous column name: y}}
+
+#-------------------------------------------------------------------------
+reset_db
+
+ifcapable rtree {
+ do_execsql_test 14.0 {
+ CREATE VIRTUAL TABLE rt USING rtree(id, minx, maxx, miny, maxy);
+
+ CREATE TABLE "mytable" ( "fid" INTEGER PRIMARY KEY, "geom" BLOB);
+
+ CREATE TRIGGER tr1 AFTER UPDATE OF "geom" ON "mytable"
+ WHEN OLD."fid" = NEW."fid" AND NEW."geom" IS NULL BEGIN
+ DELETE FROM rt WHERE id = OLD."fid";
+ END;
+
+ INSERT INTO mytable VALUES(1, X'abcd');
+ }
+
+ do_execsql_test 14.1 {
+ UPDATE mytable SET geom = X'1234'
+ }
+
+ do_execsql_test 14.2 {
+ ALTER TABLE mytable RENAME TO mytable_renamed;
+ }
+
+ do_execsql_test 14.3 {
+ CREATE TRIGGER tr2 AFTER INSERT ON mytable_renamed BEGIN
+ DELETE FROM rt WHERE id=(SELECT min(id) FROM rt);
+ END;
+ }
+
+ do_execsql_test 14.4 {
+ ALTER TABLE mytable_renamed RENAME TO mytable2;
+ }
+}
+
+reset_db
+do_execsql_test 14.5 {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE TRIGGER xyz AFTER INSERT ON t1 BEGIN
+ SELECT a, b FROM v1;
+ END;
+}
+do_execsql_test 14.6 {
+ ALTER TABLE t1 RENAME TO tt1;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 15.0 {
+ CREATE TABLE t1(a integer NOT NULL PRIMARY KEY);
+ CREATE VIEW v1 AS SELECT a FROM t1;
+ CREATE TRIGGER tr1 INSTEAD OF INSERT ON v1 BEGIN
+ UPDATE t1 SET a = NEW.a;
+ END;
+ CREATE TRIGGER tr2 INSTEAD OF INSERT ON v1 BEGIN
+ SELECT new.a;
+ END;
+ CREATE TABLE t2 (b);
+}
+
+do_execsql_test 15.1 {
+ INSERT INTO v1 VALUES(1);
+ ALTER TABLE t2 RENAME TO t3;
+}
+
+do_execsql_test 15.2 {
+ CREATE TABLE x(f1 integer NOT NULL);
+ CREATE VIEW y AS SELECT f1 AS f1 FROM x;
+ CREATE TRIGGER t INSTEAD OF UPDATE OF f1 ON y BEGIN
+ UPDATE x SET f1 = NEW.f1;
+ END;
+ CREATE TABLE z (f1 integer NOT NULL PRIMARY KEY);
+ ALTER TABLE z RENAME TO z2;
+}
+
+do_execsql_test 15.3 {
+ INSERT INTO x VALUES(1), (2), (3);
+ ALTER TABLE x RENAME f1 TO f2;
+ SELECT * FROM x;
+} {1 2 3}
+
+do_execsql_test 15.4 {
+ UPDATE y SET f1 = 'x' WHERE f1 = 1;
+ SELECT * FROM x;
+} {x x x}
+
+do_execsql_test 15.5 {
+ SELECT sql FROM sqlite_master WHERE name = 'y';
+} {{CREATE VIEW y AS SELECT f2 AS f1 FROM x}}
+
+#-------------------------------------------------------------------------
+# Test that it is not possible to rename a shadow table in DEFENSIVE mode.
+#
+ifcapable fts3 {
+ proc vtab_command {method args} {
+ switch -- $method {
+ xConnect {
+ if {[info exists ::vtab_connect_sql]} {
+ execsql $::vtab_connect_sql
+ }
+ return "CREATE TABLE t1(a, b, c)"
+ }
+
+ xBestIndex {
+ set clist [lindex $args 0]
+ if {[llength $clist]!=1} { error "unexpected constraint list" }
+ catch { array unset C }
+ array set C [lindex $clist 0]
+ if {$C(usable)} {
+ return "omit 0 cost 0 rows 1 idxnum 555 idxstr eq!"
+ } else {
+ return "cost 1000000 rows 0 idxnum 0 idxstr scan..."
+ }
+ }
+ }
+
+ return {}
+ }
+
+ register_tcl_module db
+
+ sqlite3_db_config db DEFENSIVE 1
+
+ do_execsql_test 16.0 {
+ CREATE VIRTUAL TABLE y1 USING fts3;
+ VACUUM;
+ }
+
+ do_catchsql_test 16.10 {
+ INSERT INTO y1_segments VALUES(1, X'1234567890');
+ } {1 {table y1_segments may not be modified}}
+
+ do_catchsql_test 16.20 {
+ DROP TABLE y1_segments;
+ } {1 {table y1_segments may not be dropped}}
+
+ do_catchsql_test 16.20 {
+ ALTER TABLE y1_segments RENAME TO abc;
+ } {1 {table y1_segments may not be altered}}
+ sqlite3_db_config db DEFENSIVE 0
+ do_catchsql_test 16.22 {
+ ALTER TABLE y1_segments RENAME TO abc;
+ } {0 {}}
+ sqlite3_db_config db DEFENSIVE 1
+ do_catchsql_test 16.23 {
+ CREATE TABLE y1_segments AS SELECT * FROM abc;
+ } {1 {object name reserved for internal use: y1_segments}}
+ do_catchsql_test 16.24 {
+ CREATE VIEW y1_segments AS SELECT * FROM abc;
+ } {1 {object name reserved for internal use: y1_segments}}
+ sqlite3_db_config db DEFENSIVE 0
+ do_catchsql_test 16.25 {
+ ALTER TABLE abc RENAME TO y1_segments;
+ } {0 {}}
+ sqlite3_db_config db DEFENSIVE 1
+
+ do_execsql_test 16.30 {
+ ALTER TABLE y1 RENAME TO z1;
+ }
+
+ do_execsql_test 16.40 {
+ SELECT * FROM z1_segments;
+ }
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 17.0 {
+ CREATE TABLE sqlite1234 (id integer);
+ ALTER TABLE sqlite1234 RENAME TO User;
+ SELECT name, sql FROM sqlite_master WHERE sql IS NOT NULL;
+} {
+ User {CREATE TABLE "User" (id integer)}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 18.1.0 {
+ CREATE TABLE t0 (c0 INTEGER, PRIMARY KEY(c0)) WITHOUT ROWID;
+}
+do_execsql_test 18.1.1 {
+ ALTER TABLE t0 RENAME COLUMN c0 TO c1;
+}
+do_execsql_test 18.1.2 {
+ SELECT sql FROM sqlite_master;
+} {{CREATE TABLE t0 (c1 INTEGER, PRIMARY KEY(c1)) WITHOUT ROWID}}
+
+reset_db
+do_execsql_test 18.2.0 {
+ CREATE TABLE t0 (c0 INTEGER, PRIMARY KEY(c0));
+}
+do_execsql_test 18.2.1 {
+ ALTER TABLE t0 RENAME COLUMN c0 TO c1;
+}
+do_execsql_test 18.2.2 {
+ SELECT sql FROM sqlite_master;
+} {{CREATE TABLE t0 (c1 INTEGER, PRIMARY KEY(c1))}}
+
+# 2020-02-23 ticket f50af3e8a565776b
+reset_db
+do_execsql_test 19.100 {
+ CREATE TABLE t1(x);
+ CREATE VIEW t2 AS SELECT 1 FROM t1, (t1 AS a0, t1);
+ ALTER TABLE t1 RENAME TO t3;
+ SELECT sql FROM sqlite_master;
+} {{CREATE TABLE "t3"(x)} {CREATE VIEW t2 AS SELECT 1 FROM "t3", ("t3" AS a0, "t3")}}
+do_execsql_test 19.110 {
+ INSERT INTO t3(x) VALUES(123);
+ SELECT * FROM t2;
+} {1}
+do_execsql_test 19.120 {
+ INSERT INTO t3(x) VALUES('xyz');
+ SELECT * FROM t2;
+} {1 1 1 1 1 1 1 1}
+
+# Ticket 4722bdab08cb14
+reset_db
+do_execsql_test 20.0 {
+ CREATE TABLE a(a);
+ CREATE VIEW b AS SELECT(SELECT *FROM c JOIN a USING(d, a, a, a) JOIN a) IN();
+}
+do_execsql_test 20.1 {
+ ALTER TABLE a RENAME a TO e;
+} {}
+
+reset_db
+do_execsql_test 21.0 {
+ CREATE TABLE a(b);
+ CREATE VIEW c AS
+ SELECT NULL INTERSECT
+ SELECT NULL ORDER BY
+ likelihood(NULL, (d, (SELECT c)));
+} {}
+do_catchsql_test 21.1 {
+ SELECT likelihood(NULL, (d, (SELECT c)));
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+do_catchsql_test 21.2 {
+ SELECT * FROM c;
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+do_catchsql_test 21.3 {
+ ALTER TABLE a RENAME TO e;
+} {1 {error in view c: 1st ORDER BY term does not match any column in the result set}}
+
+# After forum thread https://sqlite.org/forum/forumpost/ddbe1c7efa
+# Ensure that PRAGMA schema_version=N causes a full schema reload.
+#
+reset_db
+do_execsql_test 22.0 {
+ CREATE TABLE t1(a INT, b TEXT NOT NULL);
+ INSERT INTO t1 VALUES(1,2),('a','b');
+ BEGIN;
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_schema SET sql='CREATE TABLE t1(a INT, b TEXT)' WHERE name LIKE 't1';
+ PRAGMA schema_version=1234;
+ COMMIT;
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test 22.1 {
+ ALTER TABLE t1 ADD COLUMN c INT DEFAULT 78;
+ SELECT * FROM t1;
+} {1 2 78 a b 78}
+
+#-------------------------------------------------------------------------
+reset_db
+db collate compare64 compare64
+
+do_execsql_test 23.1 {
+ CREATE TABLE gigo(a text);
+ CREATE TABLE idx(x text COLLATE compare64);
+ CREATE VIEW v1 AS SELECT * FROM idx WHERE x='abc';
+}
+db close
+sqlite3 db test.db
+
+do_execsql_test 23.2 {
+ alter table gigo rename to ggiiggoo;
+ alter table idx rename to idx2;
+}
+
+do_execsql_test 23.3 {
+ SELECT sql FROM sqlite_master;
+} {
+ {CREATE TABLE "ggiiggoo"(a text)}
+ {CREATE TABLE "idx2"(x text COLLATE compare64)}
+ {CREATE VIEW v1 AS SELECT * FROM "idx2" WHERE x='abc'}
+}
+
+do_execsql_test 23.4 {
+ ALTER TABLE idx2 RENAME x TO y;
+ SELECT sql FROM sqlite_master;
+} {
+ {CREATE TABLE "ggiiggoo"(a text)}
+ {CREATE TABLE "idx2"(y text COLLATE compare64)}
+ {CREATE VIEW v1 AS SELECT * FROM "idx2" WHERE y='abc'}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 24.1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TRIGGER AFTER INSERT ON t1 BEGIN
+ INSERT INTO nosuchtable VALUES(new.a) ON CONFLICT(a) DO NOTHING;
+ END;
+}
+do_catchsql_test 24.1.1 {
+ ALTER TABLE t1 RENAME TO t2;
+} {1 {error in trigger AFTER: no such table: main.nosuchtable}}
+
+reset_db
+do_execsql_test 24.2.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TRIGGER AFTER INSERT ON t1 BEGIN
+ INSERT INTO v1 VALUES(new.a) ON CONFLICT(a) DO NOTHING;
+ END;
+ CREATE VIEW v1 AS SELECT * FROM nosuchtable;
+}
+do_catchsql_test 24.2.1 {
+ ALTER TABLE t1 RENAME TO t2;
+} {1 {error in trigger AFTER: no such table: main.nosuchtable}}
+
+#--------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 25.1 {
+ CREATE TABLE xx(x);
+ CREATE VIEW v3(b) AS WITH b AS (SELECT b FROM (SELECT * FROM t2)) VALUES(1);
+}
+
+ifcapable json1&&vtab {
+ do_catchsql_test 25.2 {
+ ALTER TABLE json_each RENAME TO t4;
+ } {1 {table json_each may not be altered}}
+}
+
+# 2021-05-01 dbsqlfuzz bc17a306a09329bba0ecc61547077f6178bcf321
+# Remove a NEVER() inserted on 2019-12-09 that is reachable after all.
+#
+reset_db
+do_execsql_test 26.1 {
+ CREATE TABLE t1(k,v);
+ CREATE TABLE t2_a(k,v);
+ CREATE VIEW t2 AS SELECT * FROM t2_a;
+ CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN
+ UPDATE t1
+ SET (k,v)=((WITH cte1(a) AS (SELECT 1 FROM t2) SELECT t2.k FROM t2, cte1),1);
+ END;
+ ALTER TABLE t1 RENAME TO t1x;
+ INSERT INTO t2_a VALUES(2,3);
+ INSERT INTO t1x VALUES(98,99);
+ SELECT * FROM t1x;
+} {2 1}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 27.1 {
+
+ create table t_sa (
+ c_muyat INTEGER NOT NULL,
+ c_d4u TEXT
+ );
+
+ create table t2 ( abc );
+
+ CREATE TRIGGER trig AFTER DELETE ON t_sa
+ BEGIN
+ DELETE FROM t_sa WHERE (
+ SELECT 123 FROM t2
+ WINDOW oamat7fzf AS ( PARTITION BY t_sa.c_d4u )
+ );
+ END;
+}
+
+do_execsql_test 27.2 {
+ alter table t_sa rename column c_muyat to c_dg;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 29.1 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('a', 'b', 'c');
+
+ CREATE VIEW v0 AS
+ WITH p AS ( SELECT 1 FROM t1 ),
+ g AS ( SELECT 1 FROM p, t1 )
+ SELECT 1 FROM g;
+}
+
+do_execsql_test 29.2 {
+ SELECT * FROM v0
+} 1
+
+do_execsql_test 29.2 {
+ ALTER TABLE t1 RENAME TO t2
+}
+
+do_execsql_test 29.3 {
+ SELECT sql FROM sqlite_schema WHERE name='v0'
+} {{CREATE VIEW v0 AS
+ WITH p AS ( SELECT 1 FROM "t2" ),
+ g AS ( SELECT 1 FROM p, "t2" )
+ SELECT 1 FROM g}}
+
+do_execsql_test 29.4 {
+ CREATE VIEW v2 AS
+ WITH p AS ( SELECT 1 FROM t2 ),
+ g AS ( SELECT 1 FROM (
+ WITH i AS (SELECT 1 FROM p, t2)
+ SELECT * FROM i
+ )
+ )
+ SELECT 1 FROM g;
+}
+
+do_execsql_test 29.4 {
+ SELECT * FROM v2;
+} 1
+
+do_execsql_test 29.5 {
+ ALTER TABLE t2 RENAME TO t3;
+}
+
+do_execsql_test 29.5 {
+ SELECT sql FROM sqlite_schema WHERE name='v2'
+} {{CREATE VIEW v2 AS
+ WITH p AS ( SELECT 1 FROM "t3" ),
+ g AS ( SELECT 1 FROM (
+ WITH i AS (SELECT 1 FROM p, "t3")
+ SELECT * FROM i
+ )
+ )
+ SELECT 1 FROM g}}
+
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 28.1 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b,c);
+ CREATE TABLE t4(b,c);
+ INSERT INTO t2 VALUES(1,2),(1,3),(2,5);
+ INSERT INTO t4 VALUES(1,2),(1,3),(2,5);
+
+ CREATE VIEW v3 AS
+ WITH RECURSIVE t3(x,y,z) AS (
+ SELECT b,c,NULL FROM t4
+ UNION
+ SELECT x,y,NULL FROM t3, t2
+ )
+ SELECT * FROM t3 AS xyz;
+}
+
+do_execsql_test 28.2 {
+ SELECT * FROM v3
+} {
+ 1 2 {} 1 3 {} 2 5 {}
+}
+
+do_execsql_test 28.3 {
+ ALTER TABLE t1 RENAME a TO a2; -- fails in v3
+}
+
+do_execsql_test 28.4 {
+ ALTER TABLE t2 RENAME TO t5;
+}
+
+do_execsql_test 28.5 {
+ SELECT sql FROM sqlite_schema WHERE name='v3'
+} {{CREATE VIEW v3 AS
+ WITH RECURSIVE t3(x,y,z) AS (
+ SELECT b,c,NULL FROM t4
+ UNION
+ SELECT x,y,NULL FROM t3, "t5"
+ )
+ SELECT * FROM t3 AS xyz}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 30.0 {
+ CREATE TABLE t1(a,b,c,d,e,f);
+ CREATE TABLE t2(a,b,c);
+ CREATE INDEX t1abc ON t1(a,b,c+d+e);
+ CREATE VIEW v1(x,y) AS
+ SELECT t1.b,t2.b FROM t1,t2 WHERE t1.a=t2.a
+ GROUP BY 1 HAVING t2.c NOT NULL LIMIT 10;
+ CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN 'no' NOT NULL BEGIN
+ INSERT INTO t2(a,a,b,c) VALUES(new.b,new.a,new.c-7);
+ WITH c1(x) AS (
+ VALUES(0)
+ UNION ALL
+ SELECT current_time+x FROM c1 WHERE x
+ UNION ALL
+ SELECT 1+x FROM c1 WHERE x<1
+ ), c2(x) AS (VALUES(0),(1))
+ SELECT * FROM c1 AS x1, c2 AS x2, (
+ SELECT x+1 FROM c1 WHERE x IS NOT TRUE
+ UNION ALL
+ SELECT 1+x FROM c1 WHERE 1<x
+ ) AS x3, c2 x5;
+ END;
+}
+
+do_execsql_test 30.1 {
+ ALTER TABLE t1 RENAME TO t1x;
+}
+
+do_execsql_test 30.2 {
+ SELECT sql FROM sqlite_schema ORDER BY rowid
+} {
+ {CREATE TABLE "t1x"(a,b,c,d,e,f)}
+ {CREATE TABLE t2(a,b,c)}
+ {CREATE INDEX t1abc ON "t1x"(a,b,c+d+e)}
+ {CREATE VIEW v1(x,y) AS
+ SELECT "t1x".b,t2.b FROM "t1x",t2 WHERE "t1x".a=t2.a
+ GROUP BY 1 HAVING t2.c NOT NULL LIMIT 10}
+ {CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN 'no' NOT NULL BEGIN
+ INSERT INTO t2(a,a,b,c) VALUES(new.b,new.a,new.c-7);
+ WITH c1(x) AS (
+ VALUES(0)
+ UNION ALL
+ SELECT current_time+x FROM c1 WHERE x
+ UNION ALL
+ SELECT 1+x FROM c1 WHERE x<1
+ ), c2(x) AS (VALUES(0),(1))
+ SELECT * FROM c1 AS x1, c2 AS x2, (
+ SELECT x+1 FROM c1 WHERE x IS NOT TRUE
+ UNION ALL
+ SELECT 1+x FROM c1 WHERE 1<x
+ ) AS x3, c2 x5;
+ END}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 31.0 {
+ CREATE TABLE t1(q);
+ CREATE VIEW vvv AS WITH x AS (WITH y AS (SELECT * FROM x) SELECT 1) SELECT 1;
+}
+
+do_execsql_test 31.1 {
+ SELECT * FROM vvv;
+} {1}
+
+do_execsql_test 31.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+}
+
+do_execsql_test 31.3 {
+ ALTER TABLE t1x RENAME q TO x;
+}
+
+# 2021-07-02 OSSFuzz https://oss-fuzz.com/testcase-detail/5517690440646656
+# Bad assert() statement
+#
+reset_db
+do_catchsql_test 32.0 {
+ CREATE TABLE t1(x);
+ CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
+ UPDATE t1 SET x=x FROM (SELECT*);
+ END;
+ ALTER TABLE t1 RENAME TO x;
+} {1 {error in trigger r1: no tables specified}}
+
+finish_test
diff --git a/test/altertab2.test b/test/altertab2.test
new file mode 100644
index 0000000..def9e56
--- /dev/null
+++ b/test/altertab2.test
@@ -0,0 +1,363 @@
+# 2018 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix altertab2
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+ifcapable fts5 {
+ do_execsql_test 1.0 {
+ CREATE TABLE rr(a, b);
+ CREATE VIRTUAL TABLE ff USING fts5(a, b);
+ CREATE TRIGGER tr1 AFTER INSERT ON rr BEGIN
+ INSERT INTO ff VALUES(new.a, new.b);
+ END;
+ INSERT INTO rr VALUES('hello', 'world');
+ SELECT * FROM ff;
+ } {hello world}
+
+ do_execsql_test 1.1 {
+ ALTER TABLE ff RENAME TO ffff;
+ }
+
+ do_execsql_test 1.2 {
+ INSERT INTO rr VALUES('in', 'tcl');
+ SELECT * FROM ffff;
+ } {hello world in tcl}
+}
+
+#-------------------------------------------------------------------------
+# Check that table names that appear in REFERENCES clauses are updated
+# when a table is renamed unless:
+#
+# a) "PRAGMA legacy_alter_table" is true, and
+# b) "PRAGMA foreign_keys" is false.
+#
+do_execsql_test 2.0 {
+ CREATE TABLE p1(a PRIMARY KEY, b);
+ CREATE TABLE c1(x REFERENCES p1);
+ CREATE TABLE c2(x, FOREIGN KEY (x) REFERENCES p1);
+ CREATE TABLE c3(x, FOREIGN KEY (x) REFERENCES p1(a));
+}
+
+do_execsql_test 2.1 {
+ ALTER TABLE p1 RENAME TO p2;
+ SELECT sql FROM sqlite_master WHERE name LIKE 'c%';
+} {
+ {CREATE TABLE c1(x REFERENCES "p2")}
+ {CREATE TABLE c2(x, FOREIGN KEY (x) REFERENCES "p2")}
+ {CREATE TABLE c3(x, FOREIGN KEY (x) REFERENCES "p2"(a))}
+}
+
+do_execsql_test 2.2 {
+ PRAGMA legacy_alter_table = 1;
+ ALTER TABLE p2 RENAME TO p3;
+ SELECT sql FROM sqlite_master WHERE name LIKE 'c%';
+} {
+ {CREATE TABLE c1(x REFERENCES "p2")}
+ {CREATE TABLE c2(x, FOREIGN KEY (x) REFERENCES "p2")}
+ {CREATE TABLE c3(x, FOREIGN KEY (x) REFERENCES "p2"(a))}
+}
+
+do_execsql_test 2.3 {
+ ALTER TABLE p3 RENAME TO p2;
+ PRAGMA foreign_keys = 1;
+ ALTER TABLE p2 RENAME TO p3;
+ SELECT sql FROM sqlite_master WHERE name LIKE 'c%';
+} {
+ {CREATE TABLE c1(x REFERENCES "p3")}
+ {CREATE TABLE c2(x, FOREIGN KEY (x) REFERENCES "p3")}
+ {CREATE TABLE c3(x, FOREIGN KEY (x) REFERENCES "p3"(a))}
+}
+
+#-------------------------------------------------------------------------
+# Table name in WITH clauses that are part of views or triggers.
+#
+foreach {tn schema} {
+ 1 {
+ CREATE TABLE log_entry(col1, y);
+ CREATE INDEX i1 ON log_entry(col1);
+ }
+
+ 2 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(x);
+ CREATE TABLE log_entry(col1);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 SELECT col1 FROM log_entry;
+ END;
+ }
+
+ 3 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(x);
+ CREATE TABLE log_entry(col1);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2
+ WITH xyz(x) AS (SELECT col1 FROM log_entry)
+ SELECT x FROM xyz;
+ END;
+ }
+
+ 4 {
+ CREATE TABLE log_entry(col1);
+ CREATE VIEW ttt AS
+ WITH xyz(x) AS (SELECT col1 FROM log_entry)
+ SELECT x FROM xyz;
+ }
+} {
+ reset_db
+ do_execsql_test 3.$tn.1 $schema
+ set expect [db eval "SELECT sql FROM sqlite_master"]
+ set expect [string map {log_entry {"newname"}} $expect]
+
+ do_execsql_test 3.$tn.2 {
+ ALTER TABLE log_entry RENAME TO newname;
+ SELECT sql FROM sqlite_master;
+ } $expect
+
+ reset_db
+ do_execsql_test 3.$tn.3 $schema
+ set expect [db eval "SELECT sql FROM sqlite_master"]
+ set expect [string map {col1 newname} $expect]
+
+ do_execsql_test 3.$tn.4 {
+ ALTER TABLE log_entry RENAME col1 TO newname;
+ SELECT sql FROM sqlite_master;
+ } $expect
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1(a,b,c,d,e,f);
+ CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.a NOT NULL BEGIN
+ UPDATE t1 SET (c,d)=(a,b);
+ END;
+}
+
+do_execsql_test 4.1 {
+ ALTER TABLE t1 RENAME TO t1x;
+ SELECT sql FROM sqlite_master WHERE type = 'trigger';
+} {
+{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.a NOT NULL BEGIN
+ UPDATE "t1x" SET (c,d)=(a,b);
+ END}
+}
+
+do_execsql_test 4.2 {
+ ALTER TABLE t1x RENAME a TO aaa;
+ SELECT sql FROM sqlite_master WHERE type = 'trigger';
+} {
+{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.aaa NOT NULL BEGIN
+ UPDATE "t1x" SET (c,d)=(aaa,b);
+ END}
+}
+
+do_execsql_test 4.3 {
+ ALTER TABLE t1x RENAME d TO ddd;
+ SELECT sql FROM sqlite_master WHERE type = 'trigger';
+} {
+{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.aaa NOT NULL BEGIN
+ UPDATE "t1x" SET (c,ddd)=(aaa,b);
+ END}
+}
+
+#-------------------------------------------------------------------------
+ifcapable windowfunc {
+do_execsql_test 5.0 {
+ CREATE TABLE t2(a);
+ CREATE TRIGGER r2 AFTER INSERT ON t2 WHEN new.a NOT NULL BEGIN
+ SELECT a, sum(a) OVER w1 FROM t2
+ WINDOW w1 AS (
+ PARTITION BY a ORDER BY a
+ ROWS BETWEEN 2 PRECEDING AND 3 FOLLOWING
+ ),
+ w2 AS (
+ PARTITION BY a
+ ORDER BY rowid ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ );
+ END;
+} {}
+
+do_execsql_test 5.0.1 {
+ INSERT INTO t2 VALUES(1);
+} {}
+
+do_execsql_test 5.1 {
+ ALTER TABLE t2 RENAME TO t2x;
+ SELECT sql FROM sqlite_master WHERE name = 'r2';
+} {
+ {CREATE TRIGGER r2 AFTER INSERT ON "t2x" WHEN new.a NOT NULL BEGIN
+ SELECT a, sum(a) OVER w1 FROM "t2x"
+ WINDOW w1 AS (
+ PARTITION BY a ORDER BY a
+ ROWS BETWEEN 2 PRECEDING AND 3 FOLLOWING
+ ),
+ w2 AS (
+ PARTITION BY a
+ ORDER BY rowid ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ );
+ END}
+}
+
+do_execsql_test 5.2 {
+ ALTER TABLE t2x RENAME a TO aaaa;
+ SELECT sql FROM sqlite_master WHERE name = 'r2';
+} {
+ {CREATE TRIGGER r2 AFTER INSERT ON "t2x" WHEN new.aaaa NOT NULL BEGIN
+ SELECT aaaa, sum(aaaa) OVER w1 FROM "t2x"
+ WINDOW w1 AS (
+ PARTITION BY aaaa ORDER BY aaaa
+ ROWS BETWEEN 2 PRECEDING AND 3 FOLLOWING
+ ),
+ w2 AS (
+ PARTITION BY aaaa
+ ORDER BY rowid ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ );
+ END}
+}
+
+do_execsql_test 5.3 {
+ INSERT INTO t2x VALUES(1);
+} {}
+} ;# windowfunc
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 6.0 {
+ CREATE TABLE t3(a,b,c,d);
+ CREATE TRIGGER r3 AFTER INSERT ON t3 WHEN new.a NOT NULL BEGIN
+ SELECT a,b,c FROM t3 EXCEPT SELECT a,b,c FROM t3 ORDER BY a;
+ SELECT rowid, * FROM t3;
+ END;
+} {}
+
+do_execsql_test 6.1 {
+ ALTER TABLE t3 RENAME TO t3x;
+ SELECT sql FROM sqlite_master WHERE name = 'r3';
+} {
+ {CREATE TRIGGER r3 AFTER INSERT ON "t3x" WHEN new.a NOT NULL BEGIN
+ SELECT a,b,c FROM "t3x" EXCEPT SELECT a,b,c FROM "t3x" ORDER BY a;
+ SELECT rowid, * FROM "t3x";
+ END}
+}
+
+do_execsql_test 6.2 {
+ ALTER TABLE t3x RENAME a TO abcd;
+ SELECT sql FROM sqlite_master WHERE name = 'r3';
+} {
+ {CREATE TRIGGER r3 AFTER INSERT ON "t3x" WHEN new.abcd NOT NULL BEGIN
+ SELECT abcd,b,c FROM "t3x" EXCEPT SELECT abcd,b,c FROM "t3x" ORDER BY abcd;
+ SELECT rowid, * FROM "t3x";
+ END}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a,b,c,d,e,f);
+ INSERT INTO t1 VALUES(1,2,3,4,5,6);
+ CREATE TABLE t2(x,y,z);
+}
+
+do_execsql_test 7.1 {
+ SELECT a,b,c FROM t1 UNION SELECT d,e,f FROM t1 ORDER BY b,c;
+} {1 2 3 4 5 6}
+
+do_execsql_test 7.2 {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2
+ SELECT a,b,c FROM t1 UNION SELECT d,e,f FROM t1 ORDER BY b,c;
+ END;
+ INSERT INTO t1 VALUES(2,3,4,5,6,7);
+ SELECT * FROM t2;
+} {1 2 3 2 3 4 4 5 6 5 6 7}
+
+do_execsql_test 7.3 {
+ ALTER TABLE t1 RENAME TO xyzzy;
+ SELECT sql FROM sqlite_master WHERE name='r1'
+} {
+ {CREATE TRIGGER r1 AFTER INSERT ON "xyzzy" BEGIN
+ INSERT INTO t2
+ SELECT a,b,c FROM "xyzzy" UNION SELECT d,e,f FROM "xyzzy" ORDER BY b,c;
+ END}
+}
+
+do_execsql_test 7.3 {
+ ALTER TABLE xyzzy RENAME c TO ccc;
+ SELECT sql FROM sqlite_master WHERE name='r1'
+} {
+ {CREATE TRIGGER r1 AFTER INSERT ON "xyzzy" BEGIN
+ INSERT INTO t2
+ SELECT a,b,ccc FROM "xyzzy" UNION SELECT d,e,f FROM "xyzzy" ORDER BY b,ccc;
+ END}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ CREATE TABLE t3(d, e, f);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE TRIGGER tr AFTER INSERT ON t3 BEGIN
+ UPDATE t2 SET a = new.d;
+ SELECT a, b, c FROM v1;
+ END;
+}
+
+do_execsql_test 8.1 {
+ INSERT INTO t3 VALUES(1, 2, 3);
+}
+
+# The following ALTER TABLE fails as if column "t1.a" is renamed the "a"
+# in the "SELECT a, b, c FROM v1" within the trigger can no longer be
+# resolved. But at one point there was a bug allowing the ALTER TABLE
+# succeed. Which meant the subsequent INSERT statement would fail.
+do_catchsql_test 8.2 {
+ ALTER TABLE t1 RENAME a TO aaa;
+} {1 {error in trigger tr after rename: no such column: a}}
+do_execsql_test 8.3 {
+ INSERT INTO t3 VALUES(4, 5, 6);
+}
+
+do_execsql_test 8.4 {
+ CREATE TABLE t4(a, b);
+ CREATE VIEW v4 AS SELECT * FROM t4 WHERE (a=1 AND 0) OR b=2;
+}
+
+# Branches of an expression tree that are optimized out by the AND
+# optimization are renamed.
+#
+do_execsql_test 8.5 {
+ ALTER TABLE t4 RENAME a TO c;
+ SELECT sql FROM sqlite_master WHERE name = 'v4'
+} {{CREATE VIEW v4 AS SELECT * FROM t4 WHERE (c=1 AND 0) OR b=2}}
+
+# 2019-06-10 https://www.sqlite.org/src/info/533010b8cacebe82
+reset_db
+do_catchsql_test 8.6 {
+ CREATE TABLE t0(c0);
+ CREATE INDEX i0 ON t0(likelihood(1,2) AND 0);
+ ALTER TABLE t0 RENAME TO t1;
+ SELECT sql FROM sqlite_master WHERE name='i0';
+} {1 {error in index i0: second argument to likelihood() must be a constant between 0.0 and 1.0}}
+
+finish_test
diff --git a/test/altertab3.test b/test/altertab3.test
new file mode 100644
index 0000000..5fd17f3
--- /dev/null
+++ b/test/altertab3.test
@@ -0,0 +1,739 @@
+# 2019 January 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
+set testprefix altertab3
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+ifcapable windowfunc {
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ SELECT sum(b) OVER w FROM t1 WINDOW w AS (ORDER BY a);
+ END;
+}
+
+do_execsql_test 1.1 {
+ ALTER TABLE t1 RENAME a TO aaa;
+}
+
+do_execsql_test 1.2 {
+ SELECT sql FROM sqlite_master WHERE name='tr1'
+} {{CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ SELECT sum(b) OVER w FROM t1 WINDOW w AS (ORDER BY aaa);
+ END}}
+
+do_execsql_test 1.3 {
+ INSERT INTO t1 VALUES(1, 2);
+}
+} ;# windowfunc
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE t2(a,b,c);
+ CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.a NOT NULL BEGIN
+ SELECT a,b, a name FROM t1
+ INTERSECT
+ SELECT a,b,c FROM t1 WHERE b>='d' ORDER BY name;
+ SELECT new.c;
+ END;
+}
+
+do_execsql_test 2.1 {
+ ALTER TABLE t1 RENAME TO t1x;
+ SELECT sql FROM sqlite_master WHERE name = 'r1';
+} {{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.a NOT NULL BEGIN
+ SELECT a,b, a name FROM "t1x"
+ INTERSECT
+ SELECT a,b,c FROM "t1x" WHERE b>='d' ORDER BY name;
+ SELECT new.c;
+ END}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(a, b, c, d);
+ CREATE VIEW v1 AS SELECT * FROM t1 WHERE a=1 OR (b IN ());
+}
+
+do_execsql_test 3.1 {
+ ALTER TABLE t1 RENAME b TO bbb;
+}
+
+do_execsql_test 3.2 {
+ SELECT sql FROM sqlite_master WHERE name = 'v1'
+} {{CREATE VIEW v1 AS SELECT * FROM t1 WHERE a=1 OR (b IN ())}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t3(e, f);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.a, new.b);
+ END;
+}
+
+do_catchsql_test 4.1.2 {
+ BEGIN;
+ ALTER TABLE t3 RENAME TO t4;
+} {1 {error in trigger tr1: no such table: main.t2}}
+do_execsql_test 4.1.2 {
+ COMMIT;
+}
+do_execsql_test 4.1.3 {
+ SELECT type, name, tbl_name, sql
+ FROM sqlite_master WHERE type='table' AND name!='t1';
+} {table t3 t3 {CREATE TABLE t3(e, f)}}
+
+
+do_catchsql_test 4.2.1 {
+ BEGIN;
+ ALTER TABLE t3 RENAME e TO eee;
+} {1 {error in trigger tr1: no such table: main.t2}}
+do_execsql_test 4.2.2 {
+ COMMIT;
+}
+do_execsql_test 4.2.3 {
+ SELECT type, name, tbl_name, sql
+ FROM sqlite_master WHERE type='table' AND name!='t1';
+} {table t3 t3 {CREATE TABLE t3(e, f)}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1 (
+ c1 integer, c2, PRIMARY KEY(c1 collate rtrim),
+ UNIQUE(c2)
+ )
+}
+do_execsql_test 5.1 {
+ ALTER TABLE t1 RENAME c1 TO c3;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 6.0 {
+ CREATE TEMPORARY TABLE Table0 (
+ Col0 INTEGER,
+ PRIMARY KEY(Col0 COLLATE RTRIM),
+ FOREIGN KEY (Col0) REFERENCES Table0
+ );
+}
+
+do_execsql_test 6.1 {
+ ALTER TABLE Table0 RENAME Col0 TO Col0;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 7.1.0 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TRIGGER AFTER INSERT ON t1 BEGIN
+ SELECT a, rank() OVER w1 FROM t1
+ WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1);
+ END;
+}
+
+do_execsql_test 7.1.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+ SELECT sql FROM sqlite_master;
+} {
+ {CREATE TABLE "t1x"(a,b,c)}
+ {CREATE TRIGGER AFTER INSERT ON "t1x" BEGIN
+ SELECT a, rank() OVER w1 FROM "t1x"
+ WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1);
+ END}
+}
+
+do_execsql_test 7.2.1 {
+ DROP TRIGGER after;
+ CREATE TRIGGER AFTER INSERT ON t1x BEGIN
+ SELECT a, rank() OVER w1 FROM t1x
+ WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1 ORDER BY d);
+ END;
+}
+
+do_catchsql_test 7.2.2 {
+ ALTER TABLE t1x RENAME TO t1;
+} {1 {error in trigger AFTER: no such column: d}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE t0(c0);
+ CREATE INDEX i0 ON t0('1' IN ());
+}
+do_execsql_test 8.1 {
+ ALTER TABLE t0 RENAME TO t1;
+ SELECT sql FROM sqlite_master;
+} {
+ {CREATE TABLE "t1"(c0)}
+ {CREATE INDEX i0 ON "t1"('1' IN ())}
+}
+do_execsql_test 8.2.1 {
+ CREATE TABLE t2 (c0);
+ CREATE INDEX i2 ON t2((LIKELIHOOD(c0, 100) IN ()));
+ ALTER TABLE t2 RENAME COLUMN c0 TO c1;
+}
+do_execsql_test 8.2.2 {
+ SELECT sql FROM sqlite_master WHERE tbl_name = 't2';
+} {
+ {CREATE TABLE t2 (c1)}
+ {CREATE INDEX i2 ON t2((LIKELIHOOD(c0, 100) IN ()))}
+}
+do_test 8.2.3 {
+ sqlite3 db2 test.db
+ db2 eval { INSERT INTO t2 VALUES (1), (2), (3) }
+ db close
+} {}
+db2 close
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 9.1 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TRIGGER AFTER INSERT ON t1 WHEN new.a NOT NULL BEGIN
+ SELECT true WHERE (SELECT a, b FROM (t1)) IN ();
+ END;
+}
+do_execsql_test 9.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 10.1 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t1 WHERE (
+ SELECT t1.a FROM t1, t2
+ ) IN () OR t1.a=5;
+}
+
+do_execsql_test 10.2 {
+ ALTER TABLE t2 RENAME TO t3;
+ SELECT sql FROM sqlite_master WHERE name='v1';
+} {
+ {CREATE VIEW v1 AS SELECT * FROM t1 WHERE (
+ SELECT t1.a FROM t1, t2
+ ) IN () OR t1.a=5}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 11.1 {
+ CREATE TABLE t1(
+ a,b,c,d,e,f,g,h,j,jj,jjb,k,aa,bb,cc,dd,ee DEFAULT 3.14,
+ ff DEFAULT('hiccup'),Wg NOD NULL DEFAULT(false)
+ );
+
+ CREATE TRIGGER b AFTER INSERT ON t1 WHEN new.a BEGIN
+ SELECT a, sum() w3 FROM t1
+ WINDOW b AS (ORDER BY NOT EXISTS(SELECT 1 FROM abc));
+ END;
+}
+
+do_catchsql_test 11.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+} {1 {error in trigger b: no such table: main.abc}}
+
+do_execsql_test 11.3 {
+ DROP TRIGGER b;
+ CREATE TRIGGER b AFTER INSERT ON t1 WHEN new.a BEGIN
+ SELECT a, sum() w3 FROM t1
+ WINDOW b AS (ORDER BY NOT EXISTS(SELECT 1 FROM t1));
+ END;
+} {}
+
+do_execsql_test 11.4 {
+ ALTER TABLE t1 RENAME TO t1x;
+ SELECT sql FROM sqlite_master WHERE name = 'b';
+} {
+{CREATE TRIGGER b AFTER INSERT ON "t1x" WHEN new.a BEGIN
+ SELECT a, sum() w3 FROM "t1x"
+ WINDOW b AS (ORDER BY NOT EXISTS(SELECT 1 FROM "t1x"));
+ END}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 12.1 {
+CREATE TABLE t1(a,b,c,d,e,f,g,h,j,jj,Zjj,k,aQ,bb,cc,dd,ee DEFAULT 3.14,
+ff DEFAULT('hiccup'),gg NOD NULL DEFAULT(false));
+CREATE TRIGGER AFTER INSERT ON t1 WHEN new.a NOT NULL BEGIN
+
+SELECT b () OVER , dense_rank() OVER d, d () OVER w1
+FROM t1
+WINDOW
+w1 AS
+( w1 ORDER BY d
+ROWS BETWEEN 2 NOT IN(SELECT a, sum(d) w2,max(d)OVER FROM t1
+WINDOW
+w1 AS
+(PARTITION BY d
+ROWS BETWEEN '' PRECEDING AND false FOLLOWING),
+d AS
+(PARTITION BY b ORDER BY d
+ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+) PRECEDING AND 1 FOLLOWING),
+w2 AS
+(PARTITION BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+w3 AS
+(PARTITION BY b ORDER BY d
+ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+;
+SELECT a, sum(d) w2,max(d)OVER FROM t1
+WINDOW
+w1 AS
+(PARTITION BY d
+ROWS BETWEEN '' PRECEDING AND false FOLLOWING),
+d AS
+(PARTITION BY b ORDER BY d
+ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+;
+
+END;
+}
+
+do_execsql_test 12.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 13.1 {
+ CREATE TABLE t1(a);
+ CREATE TRIGGER r1 INSERT ON t1 BEGIN
+ SELECT a(*) OVER (ORDER BY (SELECT 1)) FROM t1;
+ END;
+}
+
+do_execsql_test 13.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 14.1 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b);
+ CREATE TRIGGER AFTER INSERT ON t1 BEGIN
+ SELECT sum() FILTER (WHERE (SELECT sum() FILTER (WHERE 0)) AND a);
+ END;
+}
+
+do_catchsql_test 14.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+} {1 {error in trigger AFTER: no such column: a}}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 16.1 {
+ CREATE TABLE t1(x);
+ CREATE TRIGGER AFTER INSERT ON t1 BEGIN
+ SELECT (WITH t2 AS (WITH t3 AS (SELECT true)
+ SELECT * FROM t3 ORDER BY true COLLATE nocase)
+ SELECT 11);
+
+ WITH t4 AS (SELECT * FROM t1) SELECT 33;
+ END;
+}
+do_execsql_test 16.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 17.1 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TRIGGER AFTER INSERT ON t1 WHEN new.a NOT NULL BEGIN
+ SELECT a () FILTER (WHERE a>0) FROM t1;
+ END;
+}
+
+do_execsql_test 17.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+ ALTER TABLE t1x RENAME a TO aaa;
+ SELECT sql FROM sqlite_master WHERE type='trigger';
+} {
+{CREATE TRIGGER AFTER INSERT ON "t1x" WHEN new.aaa NOT NULL BEGIN
+ SELECT a () FILTER (WHERE aaa>0) FROM "t1x";
+ END}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 18.1 {
+ CREATE TABLE t1(a,b);
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ SELECT a, b FROM t1
+ INTERSECT SELECT b,a FROM t1
+ ORDER BY b IN (
+ SELECT a UNION SELECT b
+ FROM t1
+ ORDER BY b COLLATE nocase
+ )
+ ;
+ END;
+}
+
+do_catchsql_test 18.2 {
+ SELECT a, b FROM t1
+ INTERSECT
+ SELECT b,a FROM t1
+ ORDER BY b IN (
+ SELECT a UNION SELECT b
+ FROM t1
+ ORDER BY b COLLATE nocase
+ );
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+do_catchsql_test 18.3 {
+ ALTER TABLE t1 RENAME TO t1x;
+} {1 {error in trigger r1: 1st ORDER BY term does not match any column in the result set}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 19.0 {
+ CREATE TABLE a(a,h CONSTRAINT a UNIQUE ON CONFLICT FAIL,CONSTRAINT a);
+}
+
+foreach {tn v res} {
+ 1 {
+ CREATE VIEW q AS SELECT 123
+
+ WINDOW x AS (
+ RANGE BETWEEN UNBOUNDED PRECEDING AND INDEXED() OVER(
+ PARTITION BY ( WITH x AS(VALUES(col1)) VALUES(453) )
+ )
+ FOLLOWING
+ )
+ } {1 {error in view q: no such column: col1}}
+
+ 2 {
+ CREATE VIEW q AS SELECT
+ CAST(CAST(CAST(CAST(CAST(CAST(CAST(CAST(CAST(CAST(CAST(RIGHT
+ AS)AS)AS)AS)AS)AS)AS)AS)AS)AS)AS)WINDOW x AS(RANGE BETWEEN UNBOUNDED
+ PRECEDING AND INDEXED(*)OVER(PARTITION BY
+ CROSS,CROSS,NATURAL,sqlite_master(*)OVER a,(WITH a AS(VALUES(LEFT)UNION
+ VALUES(LEFT)UNION VALUES(LEFT)UNION VALUES(LEFT)UNION VALUES(LEFT)UNION
+ VALUES(LEFT)UNION VALUES(LEFT))VALUES(LEFT))IN
+ STORED,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT)*LEFT FOLLOWING)ORDER BY
+ LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT LIMIT
+ LEFT,INDEXED(*)OVER(PARTITION BY
+ CROSS,CROSS,CROSS,LEFT,INDEXED(*)OVER(PARTITION BY
+ CROSS,CROSS,CROSS),INDEXED(*)OVER(PARTITION BY
+ LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT,LEFT),
+ LEFT,LEFT,INNER,CROSS,CROSS,CROSS,INNER,NATURAL ORDER BY
+ OUTER,NATURAL,NATURAL,NATURAL,NATURAL,NATURAL,NATURAL,NATURAL,INNER,
+ INNER,INNER NULLS LAST GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
+ FOLLOWING);
+ } {1 {error in view q: no such column: LEFT}}
+
+ 3 {
+ CREATE VIEW q AS SELECT 99 WINDOW x AS (RANGE BETWEEN UNBOUNDED PRECEDING
+ AND count(*)OVER(PARTITION BY (WITH a AS(VALUES(2),(x3))VALUES(0)))
+ FOLLOWING)ORDER BY x2,sum(1)OVER(PARTITION BY avg(5)OVER(PARTITION BY x1));
+ } {1 {error in view q: no such column: x3}}
+} {
+ do_execsql_test 19.$tn.1 "
+ DROP VIEW IF EXISTS q;
+ $v
+ " {}
+
+ do_catchsql_test 19.$tn.2 {
+ ALTER TABLE a RENAME TO g;
+ } $res
+}
+
+# Verify that the "if( pParse->nErr ) return WRC_Abort" at the top of the
+# renameUnmapSelectCb() routine in alter.c (2019-12-04) is really required.
+#
+sqlite3 db :memory:
+do_catchsql_test 20.10 {
+ CREATE TABLE s(a, b, c);
+ CREATE INDEX k ON s( (WITH s AS( SELECT * ) VALUES(2) ) IN () );
+ ALTER TABLE s RENAME a TO a2;
+} {1 {error in index k: no tables specified}}
+
+#------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 21.1 {
+ CREATE TABLE s(col);
+ CREATE VIEW v AS SELECT (
+ WITH x(a) AS(SELECT * FROM s) VALUES(RIGHT)
+ ) IN() ;
+ CREATE TABLE a(a);
+ ALTER TABLE a RENAME a TO b;
+}
+
+#------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 22.1 {
+ CREATE TABLE t1(a);
+ CREATE VIEW v2(b) AS SELECT * FROM v2;
+}
+
+do_catchsql_test 22.2 {
+ ALTER TABLE t1 RENAME TO t4;
+} {1 {error in view v2: view v2 is circularly defined}}
+
+do_execsql_test 22.3 {
+ DROP VIEW v2;
+ CREATE VIEW v2(b) AS WITH t3 AS (SELECT b FROM v2) SELECT * FROM t3;
+}
+
+do_catchsql_test 22.4 {
+ ALTER TABLE t1 RENAME TO t4;
+} {1 {error in view v2: view v2 is circularly defined}}
+
+do_execsql_test 22.5 {
+ DROP VIEW v2;
+ CREATE VIEW v2(b) AS WITH t3 AS (SELECT b FROM v2) VALUES(1);
+}
+
+do_catchsql_test 22.6 {
+ ALTER TABLE t1 RENAME TO t4;
+} {0 {}}
+
+#------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 23.1 {
+ CREATE TABLE t1(x);
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ UPDATE t1 SET (c,d)=((SELECT 1 FROM t1 JOIN t2 ON b=x),1);
+ END;
+}
+
+do_catchsql_test 23.2 {
+ ALTER TABLE t1 RENAME TO t1x;
+} {1 {error in trigger r1: no such table: main.t2}}
+
+#------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 23.1 {
+ CREATE TABLE v0 (a);
+ CREATE VIEW v2 (v3) AS
+ WITH x1 AS (SELECT * FROM v2)
+ SELECT v3 AS x, v3 AS y FROM v2;
+}
+
+do_catchsql_test 23.2 {
+ SELECT * FROM v2
+} {1 {view v2 is circularly defined}}
+
+db close
+sqlite3 db test.db
+
+do_catchsql_test 23.3 {
+ ALTER TABLE v0 RENAME TO t3 ;
+} {1 {error in view v2: view v2 is circularly defined}}
+
+#------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 24.1 {
+ CREATE TABLE v0 (v1);
+ CREATE TABLE v2 (v3 INTEGER UNIQUE ON CONFLICT ABORT);
+ CREATE TRIGGER x AFTER INSERT ON v2 WHEN (
+ ( SELECT v1 AS PROMO_REVENUE FROM v2 JOIN v0 USING ( VALUE ) ) AND 0 )
+ BEGIN
+ DELETE FROM v2;
+ END;
+}
+do_catchsql_test 24.2 {
+ ALTER TABLE v0 RENAME TO x ;
+} {1 {error in trigger x: cannot join using column VALUE - column not present in both tables}}
+
+do_execsql_test 24.3 {
+ DROP TRIGGER x;
+ CREATE TRIGGER x AFTER INSERT ON v2 WHEN (
+ 0 AND (SELECT rowid FROM v0)
+ ) BEGIN
+ DELETE FROM v2;
+ END;
+}
+
+do_execsql_test 24.4 {
+ ALTER TABLE v0 RENAME TO xyz;
+ SELECT sql FROM sqlite_master WHERE type='trigger'
+} {{CREATE TRIGGER x AFTER INSERT ON v2 WHEN (
+ 0 AND (SELECT rowid FROM "xyz")
+ ) BEGIN
+ DELETE FROM v2;
+ END}}
+
+#------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 25.1 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+ CREATE TRIGGER ttt AFTER INSERT ON t1 BEGIN
+ UPDATE t1 SET a=t2.a FROM t2 WHERE t1.a=t2.a;
+ END;
+}
+#do_execsql_test 25.2 {
+# ALTER TABLE t2 RENAME COLUMN a TO aaa;
+#}
+
+#------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 26.1 {
+ CREATE TABLE t1(x);
+
+ CREATE TABLE t3(y);
+ CREATE TABLE t4(z);
+
+ CREATE TRIGGER tr1 INSERT ON t3 BEGIN
+ UPDATE t3 SET y=z FROM (SELECT z FROM t4);
+ END;
+
+ CREATE TRIGGER tr2 INSERT ON t3 BEGIN
+ UPDATE t3 SET y=abc FROM (SELECT x AS abc FROM t1);
+ END;
+}
+
+do_execsql_test 26.2 {
+ ALTER TABLE t1 RENAME TO t2;
+}
+
+do_execsql_test 26.3 {
+ ALTER TABLE t2 RENAME x TO xx;
+}
+
+do_execsql_test 26.4 {
+ SELECT sql FROM sqlite_schema WHERE name='tr2'
+} {
+{CREATE TRIGGER tr2 INSERT ON t3 BEGIN
+ UPDATE t3 SET y=abc FROM (SELECT xx AS abc FROM "t2");
+ END}
+}
+
+# 2020-11-02 OSSFuzz
+#
+reset_db
+do_execsql_test 26.5 {
+ CREATE TABLE t1(xx);
+ CREATE TRIGGER xx INSERT ON t1 BEGIN
+ UPDATE t1 SET xx=xx FROM(SELECT xx);
+ END;
+} {}
+do_catchsql_test 26.6 {
+ ALTER TABLE t1 RENAME TO t2;
+} {1 {error in trigger xx: no such column: xx}}
+
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 27.1 {
+ CREATE TABLE t1(a, b AS ((WITH w1 (xyz) AS ( SELECT t1.b FROM t1 ) SELECT 123) IN ()), c);
+}
+
+do_execsql_test 27.2 {
+ ALTER TABLE t1 DROP COLUMN c;
+ SELECT sql FROM sqlite_schema WHERE name = 't1';
+} {
+ {CREATE TABLE t1(a, b AS ((WITH w1 (xyz) AS ( SELECT t1.b FROM t1 ) SELECT 123) IN ()))}
+}
+
+do_execsql_test 27.3 {
+ CREATE TABLE t0(c0 , c1 AS (CASE TRUE NOT IN () WHEN NULL THEN CASE + 0xa ISNULL WHEN NOT + 0x9 THEN t0.c1 ELSE CURRENT_TIME LIKE CAST (t0.c1 REGEXP '-([1-9]\d*.\d*|0\.\d*[1-9]\d*)'ESCAPE (c1) COLLATE BINARY BETWEEN c1 AND c1 NOT IN (WITH t4 (c0) AS (WITH t3 (c0) AS NOT MATERIALIZED (WITH RECURSIVE t2 (c0) AS (WITH RECURSIVE t1 AS (VALUES (x'717171ff71717171' ) ) SELECT DISTINCT t0.c0 FROM t0 NOT INDEXED WHERE t0.c0 =t0.c0 GROUP BY 0x9 ) SELECT DISTINCT t0.c0 FROM t0 NOT INDEXED WHERE t0.c0 =t0.c1 ) SELECT DISTINCT t0.c0 FROM t0 NOT INDEXED WHERE t0.c0 =t0.c0 GROUP BY typeof(0x9 ) ) SELECT DISTINCT t0.c0 FROM t0 NOT INDEXED WHERE t0.c0 =t0.c0 GROUP BY typeof(typeof(0x9 ) ) ) IN t0 BETWEEN typeof(typeof(typeof(hex(*) FILTER (WHERE + x'5ccd1e68' ) ) ) ) AND 1 >0xa AS BLOB (+4.4E4 , -0xe ) ) END <> c1 IN () END ) VIRTUAL , c35 PRIMARY KEY , c60 , c64 NUMERIC (-6.8 , -0xE ) ) WITHOUT ROWID ;
+} {}
+
+do_execsql_test 27.4 {
+ ALTER TABLE t0 DROP COLUMN c60;
+} {}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 28.1 {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE TRIGGER AFTER INSERT ON t1 BEGIN
+ UPDATE t1 SET (c,d)=(a,b);
+ END;
+ ALTER TABLE t1 RENAME TO t2;
+}
+
+do_execsql_test 28.2 {
+ SELECT sql FROM sqlite_schema WHERE type='trigger'
+} {{CREATE TRIGGER AFTER INSERT ON "t2" BEGIN
+ UPDATE "t2" SET (c,d)=(a,b);
+ END}}
+
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 29.1 {
+ CREATE TABLE t1(x, y);
+ CREATE TRIGGER Trigger1 DELETE ON t1
+ BEGIN
+ SELECT t1.*, t1.x FROM t1 ORDER BY t1.x;
+ END;
+}
+
+
+do_execsql_test 29.2 {
+ ALTER TABLE t1 RENAME x TO z;
+}
+
+do_execsql_test 29.3 {
+ ALTER TABLE t1 RENAME TO t2;
+}
+
+do_execsql_test 29.4 {
+ CREATE TRIGGER tr2 AFTER DELETE ON t2 BEGIN
+ SELECT z, y FROM (
+ SELECT t2.* FROM t2
+ );
+ END;
+}
+
+do_execsql_test 29.5 {
+ DELETE FROM t2
+}
+
+do_execsql_test 29.6 {
+ ALTER TABLE t2 RENAME TO t3;
+}
+
+do_execsql_test 29.7 {
+ SELECT sql FROM sqlite_schema WHERE type='trigger'
+} {
+ {CREATE TRIGGER Trigger1 DELETE ON "t3"
+ BEGIN
+ SELECT "t3".*, "t3".z FROM "t3" ORDER BY "t3".z;
+ END}
+ {CREATE TRIGGER tr2 AFTER DELETE ON "t3" BEGIN
+ SELECT z, y FROM (
+ SELECT "t3".* FROM "t3"
+ );
+ END}
+}
+
+finish_test
diff --git a/test/altertrig.test b/test/altertrig.test
new file mode 100644
index 0000000..934a636
--- /dev/null
+++ b/test/altertrig.test
@@ -0,0 +1,163 @@
+# 2022 May 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix altertrig
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+proc collapse_whitespace {in} {
+ regsub -all {[ \t\n]+} [string trim $in] { }
+}
+
+proc do_whitespace_sql_test {tn sql res} {
+ set got [execsql $sql]
+ set wgot [list]
+ set wres [list]
+ foreach g $got { lappend wgot [collapse_whitespace $g] }
+ foreach r $res { lappend wres [collapse_whitespace $r] }
+
+ uplevel [list do_test $tn [list set {} $wgot] $wres]
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(y);
+ CREATE TABLE t3(z);
+ CREATE TABLE t4(a);
+
+ CREATE TRIGGER r1 INSERT ON t1 BEGIN
+ UPDATE t1 SET d='xyz' FROM t2, t3;
+ END;
+}
+
+do_whitespace_sql_test 1.1 {
+ ALTER TABLE t3 RENAME TO t5;
+ SELECT sql FROM sqlite_schema WHERE type='trigger';
+} {{
+ CREATE TRIGGER r1 INSERT ON t1 BEGIN
+ UPDATE t1 SET d='xyz' FROM t2, "t5";
+ END
+}}
+
+do_execsql_test 1.2 {
+ DROP TRIGGER r1;
+ CREATE TRIGGER r1 INSERT ON t1 BEGIN
+ UPDATE t1 SET d='xyz' FROM t2, (SELECT * FROM t5);
+ END;
+}
+
+do_whitespace_sql_test 1.3 {
+ ALTER TABLE t5 RENAME TO t3;
+ SELECT sql FROM sqlite_schema WHERE type='trigger';
+} {{
+ CREATE TRIGGER r1 INSERT ON t1 BEGIN
+ UPDATE t1 SET d='xyz' FROM t2, (SELECT * FROM "t3");
+ END
+}}
+
+foreach {tn alter update final} {
+ 1 {
+ ALTER TABLE t3 RENAME TO t10
+ } {
+ UPDATE t1 SET d='xyz' FROM t2, (SELECT * FROM t3)
+ } {
+ UPDATE t1 SET d='xyz' FROM t2, (SELECT * FROM "t10")
+ }
+
+ 2 {
+ ALTER TABLE t3 RENAME TO t10
+ } {
+ UPDATE t1 SET a='xyz' FROM t3, (SELECT * FROM (SELECT e FROM t3))
+ } {
+ UPDATE t1 SET a='xyz' FROM "t10", (SELECT * FROM (SELECT e FROM "t10"))
+ }
+
+ 3 {
+ ALTER TABLE t3 RENAME e TO abc
+ } {
+ UPDATE t1 SET a='xyz' FROM t3, (SELECT * FROM (SELECT e FROM t3))
+ } {
+ UPDATE t1 SET a='xyz' FROM t3, (SELECT * FROM (SELECT abc FROM t3))
+ }
+
+ 4 {
+ ALTER TABLE t2 RENAME c TO abc
+ } {
+ UPDATE t1 SET a='xyz' FROM t3, (SELECT 1 FROM t2 WHERE c)
+ } {
+ UPDATE t1 SET a='xyz' FROM t3, (SELECT 1 FROM t2 WHERE abc)
+ }
+
+ 5 {
+ ALTER TABLE t2 RENAME c TO abc
+ } {
+ UPDATE t1 SET a=t2.c FROM t2
+ } {
+ UPDATE t1 SET a=t2.abc FROM t2
+ }
+
+ 6 {
+ ALTER TABLE t2 RENAME c TO abc
+ } {
+ UPDATE t1 SET a=t2.c FROM t2, t3
+ } {
+ UPDATE t1 SET a=t2.abc FROM t2, t3
+ }
+
+ 7 {
+ ALTER TABLE t4 RENAME e TO abc
+ } {
+ UPDATE t1 SET a=1 FROM t3 NATURAL JOIN t4 WHERE t4.e=a
+ } {
+ UPDATE t1 SET a=1 FROM t3 NATURAL JOIN t4 WHERE t4.abc=a
+ }
+
+ 8 {
+ ALTER TABLE t4 RENAME TO abc
+ } {
+ UPDATE t1 SET a=1 FROM t3 NATURAL JOIN t4 WHERE t4.e=a
+ } {
+ UPDATE t1 SET a=1 FROM t3 NATURAL JOIN "abc" WHERE "abc".e=a
+ }
+
+} {
+ reset_db
+ do_execsql_test 2.$tn.1 {
+ CREATE TABLE t1(a,b);
+ CREATE TABLE t2(c,d);
+ CREATE TABLE t3(e,f);
+ CREATE TABLE t4(e,f);
+ }
+ do_execsql_test 2.$tn.2 "
+ CREATE TRIGGER r1 INSERT ON t1 BEGIN
+ $update;
+ END
+ "
+ do_execsql_test 2.$tn.3 $alter
+
+ do_whitespace_sql_test 2.$tn.4 {
+ SELECT sqL FROM sqlite_schema WHERE type='trigger'
+ } "{
+ CREATE TRIGGER r1 INSERT ON t1 BEGIN
+ $final;
+ END
+ }"
+}
+
+finish_test
+
diff --git a/test/amatch1.test b/test/amatch1.test
new file mode 100644
index 0000000..cc0f77a
--- /dev/null
+++ b/test/amatch1.test
@@ -0,0 +1,117 @@
+# 2013-09-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 "approximate_match" virtual
+# table that is in the "amatch.c" extension.
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_ENABLE_FTS4 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Create the fts_kjv_genesis procedure which fills and FTS3/4 table with
+# the complete text of the Book of Genesis.
+#
+source $testdir/genesis.tcl
+
+
+
+do_test amatch1-1.0 {
+ db eval {
+ CREATE VIRTUAL TABLE t1 USING fts4(words); --, tokenize porter);
+ }
+ fts_kjv_genesis
+ db eval {
+ INSERT INTO t1(t1) VALUES('optimize');
+ CREATE VIRTUAL TABLE temp.t1aux USING fts4aux(main, t1);
+ SELECT term FROM t1aux WHERE col=0 ORDER BY 1 LIMIT 5
+ }
+} {a abated abel abelmizraim abidah}
+do_test amatch1-1.1 {
+ db eval {
+ SELECT term FROM t1aux WHERE term>'b' AND col=0 ORDER BY 1 LIMIT 5
+ }
+} {baalhanan babel back backward bad}
+do_test amatch1-1.2 {
+ db eval {
+ SELECT term FROM t1aux WHERE term>'b' AND col=0 LIMIT 5
+ }
+} {baalhanan babel back backward bad}
+
+# Load the amatch extension
+load_static_extension db amatch
+
+do_execsql_test amatch1-2.0 {
+ CREATE TABLE costs(iLang, cFrom, cTo, Cost);
+ INSERT INTO costs VALUES(0, '', '?', 100);
+ INSERT INTO costs VALUES(0, '?', '', 100);
+ INSERT INTO costs VALUES(0, '?', '?', 150);
+ CREATE TABLE vocab(w TEXT UNIQUE);
+ INSERT OR IGNORE INTO vocab SELECT term FROM t1aux;
+ CREATE VIRTUAL TABLE t2 USING approximate_match(
+ vocabulary_table=t1aux,
+ vocabulary_word=term,
+ edit_distances=costs
+ );
+ CREATE VIRTUAL TABLE t3 USING approximate_match(
+ vocabulary_table=vocab,
+ vocabulary_word=w,
+ edit_distances=costs
+ );
+ CREATE VIRTUAL TABLE t4 USING approximate_match(
+ vocabulary_table=vtemp,
+ vocabulary_word=w,
+ edit_distances=costs
+ );
+} {}
+puts "Query against fts4aux: [time {
+ do_execsql_test amatch1-2.1 {
+ SELECT word, distance FROM t2
+ WHERE word MATCH 'josxph' AND distance<300;
+ } {joseph 150}} 1]"
+puts "Query against ordinary table: [time {
+ do_execsql_test amatch1-2.2 {
+ SELECT word, distance FROM t3
+ WHERE word MATCH 'josxph' AND distance<300;
+ } {joseph 150}} 1]"
+puts "Temp table initialized from fts4aux: [time {
+ do_execsql_test amatch1-2.3a {
+ CREATE TEMP TABLE vtemp(w TEXT UNIQUE);
+ INSERT OR IGNORE INTO vtemp SELECT term FROM t1aux;
+ } {}} 1]"
+puts "Query against temp table: [time {
+ do_execsql_test amatch1-2.3b {
+ SELECT word, distance FROM t4
+ WHERE word MATCH 'josxph' AND distance<300;
+ } {joseph 150}} 1]"
+do_execsql_test amatch1-2.11 {
+ SELECT word, distance FROM t2
+ WHERE word MATCH 'joxxph' AND distance<=300;
+} {joseph 300}
+do_execsql_test amatch1-2.12 {
+ SELECT word, distance FROM t3
+ WHERE word MATCH 'joxxph' AND distance<=300;
+} {joseph 300}
+do_execsql_test amatch1-2.21 {
+ SELECT word, distance FROM t2
+ WHERE word MATCH 'joxxph' AND distance<300;
+} {}
+do_execsql_test amatch1-2.22 {
+ SELECT word, distance FROM t3
+ WHERE word MATCH 'joxxph' AND distance<300;
+} {}
+
+finish_test
diff --git a/test/analyze.test b/test/analyze.test
new file mode 100644
index 0000000..ca6c9b0
--- /dev/null
+++ b/test/analyze.test
@@ -0,0 +1,380 @@
+# 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_stat4 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 stat4 {
+ do_test analyze-5.1 {
+ execsql {
+ SELECT DISTINCT idx FROM sqlite_stat4 ORDER BY 1;
+ SELECT DISTINCT tbl FROM sqlite_stat4 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 stat4 {
+ do_test analyze-5.3 {
+ execsql {
+ SELECT DISTINCT idx FROM sqlite_stat4 ORDER BY 1;
+ SELECT DISTINCT tbl FROM sqlite_stat4 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 stat4 {
+ do_test analyze-5.5 {
+ execsql {
+ SELECT DISTINCT idx FROM sqlite_stat4 ORDER BY 1;
+ SELECT DISTINCT tbl FROM sqlite_stat4 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-5.99 {
+ sqlite3_db_config db DEFENSIVE 0
+ 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)}}
+
+# Verify that tables whose names begin with "sqlite" but not
+# "sqlite_" are analyzed.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test analyze-6.1 {
+ CREATE TABLE sqliteDemo(a);
+ INSERT INTO sqliteDemo(a) VALUES(1),(2),(3),(4),(5);
+ CREATE TABLE SQLiteDemo2(a INTEGER PRIMARY KEY AUTOINCREMENT);
+ INSERT INTO SQLiteDemo2 SELECT * FROM sqliteDemo;
+ CREATE TABLE t1(b);
+ INSERT INTO t1(b) SELECT a FROM sqliteDemo;
+ ANALYZE;
+ SELECT tbl FROM sqlite_stat1 WHERE idx IS NULL ORDER BY tbl;
+} {SQLiteDemo2 sqliteDemo t1}
+
+finish_test
diff --git a/test/analyze3.test b/test/analyze3.test
new file mode 100644
index 0000000..7469c53
--- /dev/null
+++ b/test/analyze3.test
@@ -0,0 +1,739 @@
+# 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
+set testprefix analyze3
+
+ifcapable !stat4 {
+ finish_test
+ return
+}
+
+# This test cannot be run with the sqlite3_prepare() permutation, as it
+# tests that stat4 data can be used to influence the plans of queries
+# based on bound variable values. And this is not possible when using
+# sqlite3_prepare() - as queries cannot be internally re-prepared after
+# binding values are available.
+if {[permutation]=="prepare"} {
+ 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.
+#
+# analyze3-6.*: Test that the problem fixed by commit [127a5b776d] is fixed.
+#
+# analyze3-7.*: Test that some memory leaks discovered by fuzz testing
+# have been fixed.
+#
+
+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;
+ }
+
+ execsql { SELECT count(*)>0 FROM sqlite_stat4; }
+} {1}
+
+do_execsql_test analyze3-1.1.x {
+ SELECT count(*) FROM t1 WHERE x>200 AND x<300;
+ SELECT count(*) FROM t1 WHERE x>0 AND x<1100;
+} {99 1000}
+
+# The first of the following two SELECT statements visits 99 rows. So
+# it is better to use the index. But the second visits every row in
+# the table (1000 in total) so it is better to do a full-table scan.
+#
+do_eqp_test analyze3-1.1.2 {
+ SELECT sum(y) FROM t1 WHERE x>200 AND x<300
+} {SEARCH t1 USING INDEX i1 (x>? AND x<?)}
+do_eqp_test analyze3-1.1.3 {
+ SELECT sum(y) FROM t1 WHERE x>0 AND x<1100
+} {SCAN t1}
+
+# 2017-06-26: Verify that the SQLITE_DBCONFIG_ENABLE_QPSG setting disables
+# the use of bound parameters by STAT4
+#
+db cache flush
+unset -nocomplain l
+unset -nocomplain u
+do_eqp_test analyze3-1.1.3.100 {
+ SELECT sum(y) FROM t1 WHERE x>$l AND x<$u
+} {SEARCH t1 USING INDEX i1 (x>? AND x<?)}
+set l 200
+set u 300
+do_eqp_test analyze3-1.1.3.101 {
+ SELECT sum(y) FROM t1 WHERE x>$l AND x<$u
+} {SEARCH t1 USING INDEX i1 (x>? AND x<?)}
+set l 0
+set u 1100
+do_eqp_test analyze3-1.1.3.102 {
+ SELECT sum(y) FROM t1 WHERE x>$l AND x<$u
+} {SCAN t1}
+db cache flush
+sqlite3_db_config db ENABLE_QPSG 1
+do_eqp_test analyze3-1.1.3.103 {
+ SELECT sum(y) FROM t1 WHERE x>$l AND x<$u
+} {SEARCH t1 USING INDEX i1 (x>? AND x<?)}
+db cache flush
+sqlite3_db_config db ENABLE_QPSG 0
+do_eqp_test analyze3-1.1.3.104 {
+ SELECT sum(y) FROM t1 WHERE x>$l AND x<$u
+} {SCAN t1}
+
+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 }
+} {999 999 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 }
+} {999 999 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 }
+} {999 999 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_execsql_test analyze3-2.1.x {
+ SELECT count(*) FROM t2 WHERE x>1 AND x<2;
+ SELECT count(*) FROM t2 WHERE x>0 AND x<99;
+} {200 990}
+do_eqp_test analyze3-1.2.2 {
+ SELECT sum(y) FROM t2 WHERE x>1 AND x<2
+} {SEARCH t2 USING INDEX i2 (x>? AND x<?)}
+do_eqp_test analyze3-1.2.3 {
+ SELECT sum(y) FROM t2 WHERE x>0 AND x<99
+} {SCAN t2}
+
+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 }
+} {999 999 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}
+} {999 999 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}
+} {999 999 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_execsql_test analyze3-1.3.x {
+ SELECT count(*) FROM t3 WHERE x>200 AND x<300;
+ SELECT count(*) FROM t3 WHERE x>0 AND x<1100
+} {99 1000}
+do_eqp_test analyze3-1.3.2 {
+ SELECT sum(y) FROM t3 WHERE x>200 AND x<300
+} {SEARCH t3 USING INDEX i3 (x>? AND x<?)}
+do_eqp_test analyze3-1.3.3 {
+ SELECT sum(y) FROM t3 WHERE x>0 AND x<1100
+} {SCAN t3}
+
+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 }
+} {999 999 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 }
+} {999 999 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 }
+} {999 999 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%'
+} {SEARCH t1 USING INDEX i1 (b>? AND b<?)}
+do_eqp_test analyze3-2.3 {
+ SELECT count(a) FROM t1 WHERE b LIKE '%a'
+} {SCAN t1}
+
+# Return the first argument if like_match_blobs is true (the default)
+# or the second argument if not
+#
+proc ilmb {a b} {
+ ifcapable like_match_blobs {return $a}
+ return $b
+}
+
+do_test analyze3-2.4 {
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE 'a%' }
+} [list [ilmb 102 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.6 {
+ set like "a%"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} [list [ilmb 102 101] 0 100]
+do_test analyze3-2.7 {
+ set like "%a"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} {999 999 100}
+do_test analyze3-2.8 {
+ set like "a"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} [list [ilmb 102 101] 0 0]
+do_test analyze3-2.9 {
+ set like "ab"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} [list [ilmb 12 11] 0 0]
+do_test analyze3-2.10 {
+ set like "abc"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} [list [ilmb 3 2] 0 1]
+do_test analyze3-2.11 {
+ set like "a_c"
+ sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }
+} [list [ilmb 102 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
+} {1}
+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}
+
+#-------------------------------------------------------------------------
+
+do_test analyze3-6.1 {
+ execsql { DROP TABLE IF EXISTS t1 }
+ execsql BEGIN
+ execsql { CREATE TABLE t1(a, b, c) }
+ for {set i 0} {$i < 1000} {incr i} {
+ execsql "INSERT INTO t1 VALUES([expr $i/100], 'x', [expr $i/10])"
+ }
+ execsql {
+ CREATE INDEX i1 ON t1(a, b);
+ CREATE INDEX i2 ON t1(c);
+ }
+ execsql COMMIT
+ execsql ANALYZE
+} {}
+
+do_eqp_test analyze3-6-3 {
+ SELECT * FROM t1 WHERE a = 5 AND c = 13;
+} {SEARCH t1 USING INDEX i2 (c=?)}
+
+do_eqp_test analyze3-6-2 {
+ SELECT * FROM t1 WHERE a = 5 AND b > 'w' AND c = 13;
+} {SEARCH t1 USING INDEX i2 (c=?)}
+
+#-----------------------------------------------------------------------------
+# 2015-04-20.
+# Memory leak in sqlite3Stat4ProbeFree(). (Discovered while fuzzing.)
+#
+do_execsql_test analyze-7.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ INSERT INTO t1 VALUES(1,1,'0000');
+ CREATE INDEX t0b ON t1(b);
+ ANALYZE;
+ SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND hex(1);
+} {}
+
+# At one point duplicate stat1 entries were causing a memory leak.
+#
+reset_db
+do_execsql_test 7.2 {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1a ON t1(a);
+ ANALYZE;
+ SELECT * FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000');
+ INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000');
+ ANALYZE sqlite_master;
+}
+
+finish_test
diff --git a/test/analyze4.test b/test/analyze4.test
new file mode 100644
index 0000000..d4f1921
--- /dev/null
+++ b/test/analyze4.test
@@ -0,0 +1,117 @@
+# 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
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+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}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+
+# 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..e58457a
--- /dev/null
+++ b/test/analyze5.test
@@ -0,0 +1,247 @@
+# 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_stat4 histogram data on tables
+# with many repeated values and only a few distinct values.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !stat4 {
+ finish_test
+ return
+}
+
+set testprefix analyze5
+
+proc eqp {sql {db db}} {
+ uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db
+}
+
+proc alpha {blob} {
+ set ret ""
+ foreach c [split $blob {}] {
+ if {[string is alpha $c]} {append ret $c}
+ }
+ return $ret
+}
+db func alpha alpha
+
+db func lindex lindex
+
+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;
+ }
+ db eval {
+ SELECT DISTINCT lindex(test_decode(sample),0)
+ FROM sqlite_stat4 WHERE idx='t1u' ORDER BY nlt;
+ }
+} {alpha bravo charlie delta}
+
+do_test analyze5-1.1 {
+ db eval {
+ SELECT DISTINCT lower(lindex(test_decode(sample), 0))
+ FROM sqlite_stat4 WHERE idx='t1v' ORDER BY 1
+ }
+} {alpha bravo charlie delta}
+do_test analyze5-1.2 {
+ db eval {SELECT idx, count(*) FROM sqlite_stat4 GROUP BY 1 ORDER BY 1}
+} {t1t 8 t1u 8 t1v 8 t1w 8 t1x 8 t1y 9 t1z 8}
+
+# 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
+ # No longer valid due to an EXPLAIN QUERY PLAN output format change
+ # 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
+ # No longer valid due to an EXPLAIN QUERY PLAN format change
+ # 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}
+}
+
+finish_test
diff --git a/test/analyze6.test b/test/analyze6.test
new file mode 100644
index 0000000..807fec1
--- /dev/null
+++ b/test/analyze6.test
@@ -0,0 +1,126 @@
+# 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 !stat4 {
+ 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, yz TEXT);
+ CREATE UNIQUE INDEX catx ON cat(x);
+ /* Give cat 16 unique integers */
+ INSERT INTO cat(x) VALUES(1);
+ INSERT INTO cat(x) VALUES(2);
+ INSERT INTO cat(x) SELECT x+2 FROM cat;
+ INSERT INTO cat(x) SELECT x+4 FROM cat;
+ INSERT INTO cat(x) 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}
+} {/*SCAN cat USING COVERING INDEX catx*SEARCH ev USING COVERING INDEX evy (y=?)*/}
+
+# The same plan is chosen regardless of the order of the tables in the
+# FROM clause.
+#
+do_eqp_test analyze6-1.2 {
+ SELECT count(*) FROM cat, ev WHERE x=y
+} {
+ QUERY PLAN
+ |--SCAN cat USING COVERING INDEX catx
+ `--SEARCH ev USING COVERING INDEX evy (y=?)
+}
+
+
+# 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}
+} {/*SEARCH t201 USING INDEX t201z (z=?)*/}
+do_test analyze6-2.2 {
+ eqp {SELECT * FROM t201 WHERE y=5}
+} {/*SEARCH t201 USING INDEX sqlite_autoindex_t201_1 (y=?)*/}
+do_test analyze6-2.3 {
+ eqp {SELECT * FROM t201 WHERE x=5}
+} {/*SEARCH t201 USING INTEGER PRIMARY KEY (rowid=?)*/}
+do_test analyze6-2.4 {
+ execsql {
+ INSERT INTO t201 VALUES(1,2,3),(2,3,4),(3,4,5);
+ ANALYZE t201;
+ }
+ eqp {SELECT * FROM t201 WHERE z=5}
+} {/*SEARCH t201 USING INDEX t201z (z=?)*/}
+do_test analyze6-2.5 {
+ eqp {SELECT * FROM t201 WHERE y=5}
+} {/*SEARCH t201 USING INDEX sqlite_autoindex_t201_1 (y=?)*/}
+do_test analyze6-2.6 {
+ eqp {SELECT * FROM t201 WHERE x=5}
+} {/*SEARCH t201 USING INTEGER PRIMARY KEY (rowid=?)*/}
+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}
+} {/*SEARCH t201 USING INDEX t201z (z=?)*/}
+do_test analyze6-2.8 {
+ eqp {SELECT * FROM t201 WHERE y=5}
+} {/*SEARCH t201 USING INDEX sqlite_autoindex_t201_1 (y=?)*/}
+do_test analyze6-2.9 {
+ eqp {SELECT * FROM t201 WHERE x=5}
+} {/*SEARCH t201 USING INTEGER PRIMARY KEY (rowid=?)*/}
+
+finish_test
diff --git a/test/analyze7.test b/test/analyze7.test
new file mode 100644
index 0000000..53a80f6
--- /dev/null
+++ b/test/analyze7.test
@@ -0,0 +1,114 @@
+# 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 {
+ load_static_extension db wholenumber
+ 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;
+ }
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+do_test analyze7-1.1 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}
+} {/*SEARCH t1 USING INDEX t1b (b=?)*/}
+do_test analyze7-1.2 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
+} {/*SEARCH t1 USING INDEX t1cd (c=?)*/}
+
+# 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;}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+do_test analyze7-2.1 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}
+} {/*SEARCH t1 USING INDEX t1b (b=?)*/}
+do_test analyze7-2.2 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
+} {/*SEARCH t1 USING INDEX t1cd (c=?)*/}
+
+# 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}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+
+# 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;}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+do_test analyze7-3.1 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}
+} {/*SEARCH t1 USING INDEX t1b (b=?)*/}
+do_test analyze7-3.2.1 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=?;}
+} {/*SEARCH t1 USING INDEX t1cd (c=?)*/}
+ifcapable stat4 {
+ # If ENABLE_STAT4 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;}
+ } {/*SEARCH t1 USING INDEX t1cd (c=?)*/}
+} else {
+ # If ENABLE_STAT4 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;}
+ } {/*SEARCH t1 USING INDEX t1cd (c=?)*/}
+}
+do_test analyze7-3.3 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND b=123}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+
+ifcapable {!stat4} {
+ do_test analyze7-3.4 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=123 AND b=123}
+ } {/*SEARCH t1 USING INDEX t1b (b=?)*/}
+ do_test analyze7-3.5 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND c=123}
+ } {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+}
+do_test analyze7-3.6 {
+ execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=123 AND d=123 AND b=123}
+} {/*SEARCH t1 USING INDEX t1cd (c=? AND d=?)*/}
+
+finish_test
diff --git a/test/analyze8.test b/test/analyze8.test
new file mode 100644
index 0000000..69605fd
--- /dev/null
+++ b/test/analyze8.test
@@ -0,0 +1,115 @@
+# 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_stat4.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !stat4 {
+ 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}
+} {/*SEARCH t1 USING INDEX t1b (b=?)*/}
+do_test 1.2 {
+ eqp {SELECT * FROM t1 WHERE a=99 AND b=55}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+do_test 1.3 {
+ eqp {SELECT * FROM t1 WHERE a=101 AND b=55}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+do_test 1.4 {
+ eqp {SELECT * FROM t1 WHERE a=100 AND b=56}
+} {/*SEARCH t1 USING INDEX t1b (b=?)*/}
+do_test 1.5 {
+ eqp {SELECT * FROM t1 WHERE a=99 AND b=56}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+do_test 1.6 {
+ eqp {SELECT * FROM t1 WHERE a=101 AND b=56}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+do_test 2.1 {
+ eqp {SELECT * FROM t1 WHERE a=100 AND b BETWEEN 50 AND 54}
+} {/*SEARCH t1 USING INDEX t1b (b>? AND b<?)*/}
+
+# 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.
+#
+# Test 3.2 is a little unstable. It depends on the planner estimating
+# that (b BETWEEN 30 AND 34) will match more rows than (c BETWEEN
+# 800000 AND 900000). Which is a pretty close call (50 vs. 32), so
+# the planner could get it wrong with an unlucky set of samples. This
+# case happens to work, but others ("b BETWEEN 40 AND 44" for example)
+# will fail.
+#
+do_execsql_test 3.0 {
+ SELECT count(*) FROM t1 WHERE b BETWEEN 30 AND 34;
+ SELECT count(*) FROM t1 WHERE c BETWEEN 0 AND 100000;
+ SELECT count(*) FROM t1 WHERE c BETWEEN 800000 AND 900000;
+} {50 376 32}
+do_test 3.1 {
+ eqp {SELECT * FROM t1 WHERE b BETWEEN 30 AND 34 AND c BETWEEN 0 AND 100000}
+} {/*SEARCH t1 USING INDEX t1b (b>? AND b<?)*/}
+do_test 3.2 {
+ eqp {SELECT * FROM t1
+ WHERE b BETWEEN 30 AND 34 AND c BETWEEN 800000 AND 900000}
+} {/*SEARCH t1 USING INDEX t1c (c>? AND c<?)*/}
+do_test 3.3 {
+ eqp {SELECT * FROM t1 WHERE a=100 AND c BETWEEN 0 AND 100000}
+} {/*SEARCH t1 USING INDEX t1a (a=?)*/}
+do_test 3.4 {
+ eqp {SELECT * FROM t1
+ WHERE a=100 AND c BETWEEN 800000 AND 900000}
+} {/*SEARCH t1 USING INDEX t1c (c>? AND c<?)*/}
+
+finish_test
diff --git a/test/analyze9.test b/test/analyze9.test
new file mode 100644
index 0000000..b2121fd
--- /dev/null
+++ b/test/analyze9.test
@@ -0,0 +1,1235 @@
+# 2013 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 contains automated tests used to verify that the sqlite_stat4
+# functionality is working.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix analyze9
+
+ifcapable !stat4 {
+ finish_test
+ return
+}
+
+proc s {blob} {
+ set ret ""
+ binary scan $blob c* bytes
+ foreach b $bytes {
+ set t [binary format c $b]
+ if {[string is print $t]} {
+ append ret $t
+ } else {
+ append ret .
+ }
+ }
+ return $ret
+}
+db function s s
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a TEXT, b TEXT);
+ INSERT INTO t1 VALUES('(0)', '(0)');
+ INSERT INTO t1 VALUES('(1)', '(1)');
+ INSERT INTO t1 VALUES('(2)', '(2)');
+ INSERT INTO t1 VALUES('(3)', '(3)');
+ INSERT INTO t1 VALUES('(4)', '(4)');
+ CREATE INDEX i1 ON t1(a, b);
+} {}
+
+
+do_execsql_test 1.1 {
+ ANALYZE;
+} {}
+
+do_execsql_test 1.2 {
+ SELECT tbl,idx,nEq,nLt,nDLt,test_decode(sample) FROM sqlite_stat4;
+} {
+ t1 i1 {1 1 1} {0 0 0} {0 0 0} {(0) (0) 1}
+ t1 i1 {1 1 1} {1 1 1} {1 1 1} {(1) (1) 2}
+ t1 i1 {1 1 1} {2 2 2} {2 2 2} {(2) (2) 3}
+ t1 i1 {1 1 1} {3 3 3} {3 3 3} {(3) (3) 4}
+ t1 i1 {1 1 1} {4 4 4} {4 4 4} {(4) (4) 5}
+}
+
+if {[permutation] != "utf16"} {
+ do_execsql_test 1.3 {
+ SELECT tbl,idx,nEq,nLt,nDLt,s(sample) FROM sqlite_stat4;
+ } {
+ t1 i1 {1 1 1} {0 0 0} {0 0 0} ....(0)(0)
+ t1 i1 {1 1 1} {1 1 1} {1 1 1} ....(1)(1).
+ t1 i1 {1 1 1} {2 2 2} {2 2 2} ....(2)(2).
+ t1 i1 {1 1 1} {3 3 3} {3 3 3} ....(3)(3).
+ t1 i1 {1 1 1} {4 4 4} {4 4 4} ....(4)(4).
+ }
+}
+
+
+#-------------------------------------------------------------------------
+# This is really just to test SQL user function "test_decode".
+#
+reset_db
+do_execsql_test 2.1 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('some text', 14, NULL);
+ INSERT INTO t1 VALUES(22.0, NULL, x'656667');
+ CREATE INDEX i1 ON t1(a, b, c);
+ ANALYZE;
+ SELECT test_decode(sample) FROM sqlite_stat4;
+} {
+ {22.0 NULL x'656667' 2}
+ {{some text} 14 NULL 1}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 3.1 {
+ CREATE TABLE t2(a, b);
+ CREATE INDEX i2 ON t2(a, b);
+ BEGIN;
+}
+
+do_test 3.2 {
+ for {set i 0} {$i < 1000} {incr i} {
+ set a [expr $i / 10]
+ set b [expr int(rand() * 15.0)]
+ execsql { INSERT INTO t2 VALUES($a, $b) }
+ }
+ execsql COMMIT
+} {}
+
+db func lindex lindex
+
+# Each value of "a" occurs exactly 10 times in the table.
+#
+do_execsql_test 3.3.1 {
+ SELECT count(*) FROM t2 GROUP BY a;
+} [lrange [string repeat "10 " 100] 0 99]
+
+# The first element in the "nEq" list of all samples should therefore be 10.
+#
+do_execsql_test 3.3.2 {
+ ANALYZE;
+ SELECT lindex(nEq, 0) FROM sqlite_stat4;
+} [lrange [string repeat "10 " 100] 0 23]
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 3.4 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ INSERT INTO t1 VALUES(1, 1, 'one-a');
+ INSERT INTO t1 VALUES(11, 1, 'one-b');
+ INSERT INTO t1 VALUES(21, 1, 'one-c');
+ INSERT INTO t1 VALUES(31, 1, 'one-d');
+ INSERT INTO t1 VALUES(41, 1, 'one-e');
+ INSERT INTO t1 VALUES(51, 1, 'one-f');
+ INSERT INTO t1 VALUES(61, 1, 'one-g');
+ INSERT INTO t1 VALUES(71, 1, 'one-h');
+ INSERT INTO t1 VALUES(81, 1, 'one-i');
+ INSERT INTO t1 VALUES(91, 1, 'one-j');
+ INSERT INTO t1 SELECT a+1,2,'two' || substr(c,4) FROM t1;
+ INSERT INTO t1 SELECT a+2,3,'three'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';
+ INSERT INTO t1 SELECT a+3,4,'four'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';
+ INSERT INTO t1 SELECT a+4,5,'five'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';
+ INSERT INTO t1 SELECT a+5,6,'six'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';
+ CREATE INDEX t1b ON t1(b);
+ ANALYZE;
+ SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND 60;
+} {three-d three-e three-f}
+
+
+#-------------------------------------------------------------------------
+# These tests verify that the sample selection for stat4 appears to be
+# working as designed.
+#
+
+reset_db
+db func lindex lindex
+db func lrange lrange
+
+do_execsql_test 4.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(c, b, a);
+}
+
+
+proc insert_filler_rows_n {iStart args} {
+ set A(-ncopy) 1
+ set A(-nval) 1
+
+ foreach {k v} $args {
+ if {[info exists A($k)]==0} { error "no such option: $k" }
+ set A($k) $v
+ }
+ if {[llength $args] % 2} {
+ error "option requires an argument: [lindex $args end]"
+ }
+
+ for {set i 0} {$i < $A(-nval)} {incr i} {
+ set iVal [expr $iStart+$i]
+ for {set j 0} {$j < $A(-ncopy)} {incr j} {
+ execsql { INSERT INTO t1 VALUES($iVal, $iVal, $iVal) }
+ }
+ }
+}
+
+do_test 4.1 {
+ execsql { BEGIN }
+ insert_filler_rows_n 0 -ncopy 10 -nval 19
+ insert_filler_rows_n 20 -ncopy 1 -nval 100
+
+ execsql {
+ INSERT INTO t1(c, b, a) VALUES(200, 1, 'a');
+ INSERT INTO t1(c, b, a) VALUES(200, 1, 'b');
+ INSERT INTO t1(c, b, a) VALUES(200, 1, 'c');
+
+ INSERT INTO t1(c, b, a) VALUES(200, 2, 'e');
+ INSERT INTO t1(c, b, a) VALUES(200, 2, 'f');
+
+ INSERT INTO t1(c, b, a) VALUES(201, 3, 'g');
+ INSERT INTO t1(c, b, a) VALUES(201, 4, 'h');
+
+ ANALYZE;
+ SELECT count(*) FROM sqlite_stat4;
+ SELECT count(*) FROM t1;
+ }
+} {24 297}
+
+do_execsql_test 4.2 {
+ SELECT
+ neq,
+ lrange(nlt, 0, 2),
+ lrange(ndlt, 0, 2),
+ lrange(test_decode(sample), 0, 2)
+ FROM sqlite_stat4
+ ORDER BY rowid LIMIT 16;
+} {
+ {10 10 10 1} {0 0 0} {0 0 0} {0 0 0}
+ {10 10 10 1} {10 10 10} {1 1 1} {1 1 1}
+ {10 10 10 1} {20 20 20} {2 2 2} {2 2 2}
+ {10 10 10 1} {30 30 30} {3 3 3} {3 3 3}
+ {10 10 10 1} {40 40 40} {4 4 4} {4 4 4}
+ {10 10 10 1} {50 50 50} {5 5 5} {5 5 5}
+ {10 10 10 1} {60 60 60} {6 6 6} {6 6 6}
+ {10 10 10 1} {70 70 70} {7 7 7} {7 7 7}
+ {10 10 10 1} {80 80 80} {8 8 8} {8 8 8}
+ {10 10 10 1} {90 90 90} {9 9 9} {9 9 9}
+ {10 10 10 1} {100 100 100} {10 10 10} {10 10 10}
+ {10 10 10 1} {110 110 110} {11 11 11} {11 11 11}
+ {10 10 10 1} {120 120 120} {12 12 12} {12 12 12}
+ {10 10 10 1} {130 130 130} {13 13 13} {13 13 13}
+ {10 10 10 1} {140 140 140} {14 14 14} {14 14 14}
+ {10 10 10 1} {150 150 150} {15 15 15} {15 15 15}
+}
+
+do_execsql_test 4.3 {
+ SELECT
+ neq,
+ lrange(nlt, 0, 2),
+ lrange(ndlt, 0, 2),
+ lrange(test_decode(sample), 0, 1)
+ FROM sqlite_stat4
+ ORDER BY rowid DESC LIMIT 2;
+} {
+ {2 1 1 1} {295 296 296} {120 122 125} {201 4}
+ {5 3 1 1} {290 290 290} {119 119 119} {200 1}
+}
+
+do_execsql_test 4.4 { SELECT count(DISTINCT c) FROM t1 WHERE c<201 } 120
+do_execsql_test 4.5 { SELECT count(DISTINCT c) FROM t1 WHERE c<200 } 119
+
+# Check that the perioidic samples are present.
+do_execsql_test 4.6 {
+ SELECT count(*) FROM sqlite_stat4
+ WHERE lindex(test_decode(sample), 3) IN
+ ('34', '68', '102', '136', '170', '204', '238', '272')
+} {8}
+
+reset_db
+do_test 4.7 {
+ execsql {
+ BEGIN;
+ CREATE TABLE t1(o,t INTEGER PRIMARY KEY);
+ CREATE INDEX i1 ON t1(o);
+ }
+ for {set i 0} {$i<10000} {incr i [expr (($i<1000)?1:10)]} {
+ execsql { INSERT INTO t1 VALUES('x', $i) }
+ }
+ execsql {
+ COMMIT;
+ ANALYZE;
+ SELECT count(*) FROM sqlite_stat4;
+ }
+} {8}
+do_execsql_test 4.8 {
+ SELECT test_decode(sample) FROM sqlite_stat4;
+} {
+ {x 211} {x 423} {x 635} {x 847}
+ {x 1590} {x 3710} {x 5830} {x 7950}
+}
+
+
+#-------------------------------------------------------------------------
+# The following would cause a crash at one point.
+#
+reset_db
+do_execsql_test 5.1 {
+ PRAGMA encoding = 'utf-16';
+ CREATE TABLE t0(v);
+ ANALYZE;
+}
+
+#-------------------------------------------------------------------------
+# This was also crashing (corrupt sqlite_stat4 table).
+#
+reset_db
+do_execsql_test 6.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 2);
+ INSERT INTO t1 VALUES(3, 3);
+ INSERT INTO t1 VALUES(4, 4);
+ INSERT INTO t1 VALUES(5, 5);
+ ANALYZE;
+ PRAGMA writable_schema = 1;
+ CREATE TEMP TABLE x1 AS
+ SELECT tbl,idx,neq,nlt,ndlt,sample FROM sqlite_stat4
+ ORDER BY (rowid%5), rowid;
+ DELETE FROM sqlite_stat4;
+ INSERT INTO sqlite_stat4 SELECT * FROM x1;
+ PRAGMA writable_schema = 0;
+ ANALYZE sqlite_master;
+}
+do_execsql_test 6.2 {
+ SELECT * FROM t1 WHERE a = 'abc';
+}
+
+#-------------------------------------------------------------------------
+# The following tests experiment with adding corrupted records to the
+# 'sample' column of the sqlite_stat4 table.
+#
+reset_db
+sqlite3_db_config_lookaside db 0 0 0
+
+database_may_be_corrupt
+do_execsql_test 7.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 2);
+ INSERT INTO t1 VALUES(3, 3);
+ INSERT INTO t1 VALUES(4, 4);
+ INSERT INTO t1 VALUES(5, 5);
+ ANALYZE;
+ UPDATE sqlite_stat4 SET sample = X'' WHERE rowid = 1;
+ ANALYZE sqlite_master;
+}
+
+do_execsql_test 7.2 {
+ UPDATE sqlite_stat4 SET sample = X'FFFF';
+ ANALYZE sqlite_master;
+ SELECT * FROM t1 WHERE a = 1;
+} {1 1}
+
+do_execsql_test 7.3 {
+ ANALYZE;
+ UPDATE sqlite_stat4 SET neq = '0 0 0';
+ ANALYZE sqlite_master;
+ SELECT * FROM t1 WHERE a = 1;
+} {1 1}
+
+do_execsql_test 7.4 {
+ ANALYZE;
+ UPDATE sqlite_stat4 SET ndlt = '0 0 0';
+ ANALYZE sqlite_master;
+ SELECT * FROM t1 WHERE a = 3;
+} {3 3}
+
+do_execsql_test 7.5 {
+ ANALYZE;
+ UPDATE sqlite_stat4 SET nlt = '0 0 0';
+ ANALYZE sqlite_master;
+ SELECT * FROM t1 WHERE a = 5;
+} {5 5}
+
+database_never_corrupt
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 8.1 {
+ CREATE TABLE t1(x TEXT);
+ CREATE INDEX i1 ON t1(x);
+ INSERT INTO t1 VALUES('1');
+ INSERT INTO t1 VALUES('2');
+ INSERT INTO t1 VALUES('3');
+ INSERT INTO t1 VALUES('4');
+ ANALYZE;
+}
+do_execsql_test 8.2 {
+ SELECT * FROM t1 WHERE x = 3;
+} {3}
+
+#-------------------------------------------------------------------------
+# Check that the bug fixed by [91733bc485] really is fixed.
+#
+reset_db
+do_execsql_test 9.1 {
+ CREATE TABLE t1(a, b, c, d, e);
+ CREATE INDEX i1 ON t1(a, b, c, d);
+ CREATE INDEX i2 ON t1(e);
+}
+do_test 9.2 {
+ execsql BEGIN;
+ for {set i 0} {$i < 100} {incr i} {
+ execsql "INSERT INTO t1 VALUES('x', 'y', 'z', $i, [expr $i/2])"
+ }
+ for {set i 0} {$i < 21} {incr i} {
+ execsql "INSERT INTO t1 VALUES('x', 'y', 'z', 101, $i)"
+ }
+ for {set i 102} {$i < 200} {incr i} {
+ execsql "INSERT INTO t1 VALUES('x', 'y', 'z', $i, [expr $i/2])"
+ }
+ execsql COMMIT
+ execsql ANALYZE
+} {}
+
+do_eqp_test 9.3.1 {
+ SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=101 AND e=5;
+} {/t1 USING INDEX i2/}
+do_eqp_test 9.3.2 {
+ SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=99 AND e=5;
+} {/t1 USING INDEX i1/}
+
+set value_d [expr 101]
+do_eqp_test 9.4.1 {
+ SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=$value_d AND e=5
+} {/t1 USING INDEX i2/}
+set value_d [expr 99]
+do_eqp_test 9.4.2 {
+ SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=$value_d AND e=5
+} {/t1 USING INDEX i1/}
+
+#-------------------------------------------------------------------------
+# Check that the planner takes stat4 data into account when considering
+# "IS NULL" and "IS NOT NULL" constraints.
+#
+do_execsql_test 10.1.1 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a, b);
+ CREATE INDEX t3a ON t3(a);
+ CREATE INDEX t3b ON t3(b);
+}
+do_test 10.1.2 {
+ for {set i 1} {$i < 100} {incr i} {
+ if {$i>90} { set a $i } else { set a NULL }
+ set b [expr $i % 5]
+ execsql "INSERT INTO t3 VALUES($a, $b)"
+ }
+ execsql ANALYZE
+} {}
+do_eqp_test 10.1.3 {
+ SELECT * FROM t3 WHERE a IS NULL AND b = 2
+} {/t3 USING INDEX t3b/}
+do_eqp_test 10.1.4 {
+ SELECT * FROM t3 WHERE a IS NOT NULL AND b = 2
+} {/t3 USING INDEX t3a/}
+
+do_execsql_test 10.2.1 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(x, a, b);
+ CREATE INDEX t3a ON t3(x, a);
+ CREATE INDEX t3b ON t3(x, b);
+}
+do_test 10.2.2 {
+ for {set i 1} {$i < 100} {incr i} {
+ if {$i>90} { set a $i } else { set a NULL }
+ set b [expr $i % 5]
+ execsql "INSERT INTO t3 VALUES('xyz', $a, $b)"
+ }
+ execsql ANALYZE
+} {}
+do_eqp_test 10.2.3 {
+ SELECT * FROM t3 WHERE x = 'xyz' AND a IS NULL AND b = 2
+} {/t3 USING INDEX t3b/}
+do_eqp_test 10.2.4 {
+ SELECT * FROM t3 WHERE x = 'xyz' AND a IS NOT NULL AND b = 2
+} {/t3 USING INDEX t3a/}
+
+#-------------------------------------------------------------------------
+# Check that stat4 data is used correctly with non-default collation
+# sequences.
+#
+foreach {tn schema} {
+ 1 {
+ CREATE TABLE t4(a COLLATE nocase, b);
+ CREATE INDEX t4a ON t4(a);
+ CREATE INDEX t4b ON t4(b);
+ }
+ 2 {
+ CREATE TABLE t4(a, b);
+ CREATE INDEX t4a ON t4(a COLLATE nocase);
+ CREATE INDEX t4b ON t4(b);
+ }
+} {
+ drop_all_tables
+ do_test 11.$tn.1 { execsql $schema } {}
+
+ do_test 11.$tn.2 {
+ for {set i 0} {$i < 100} {incr i} {
+ if { ($i % 10)==0 } { set a ABC } else { set a DEF }
+ set b [expr $i % 5]
+ execsql { INSERT INTO t4 VALUES($a, $b) }
+ }
+ execsql ANALYZE
+ } {}
+
+ do_eqp_test 11.$tn.3 {
+ SELECT * FROM t4 WHERE a = 'def' AND b = 3;
+ } {/t4 USING INDEX t4b/}
+
+ if {$tn==1} {
+ set sql "SELECT * FROM t4 WHERE a = 'abc' AND b = 3;"
+ do_eqp_test 11.$tn.4 $sql {/t4 USING INDEX t4a/}
+ } else {
+
+ set sql "SELECT * FROM t4 WHERE a = 'abc' COLLATE nocase AND b = 3;"
+ do_eqp_test 11.$tn.5 $sql {/t4 USING INDEX t4a/}
+
+ set sql "SELECT * FROM t4 WHERE a COLLATE nocase = 'abc' AND b = 3;"
+ do_eqp_test 11.$tn.6 $sql {/t4 USING INDEX t4a/}
+ }
+}
+
+foreach {tn schema} {
+ 1 {
+ CREATE TABLE t4(x, a COLLATE nocase, b);
+ CREATE INDEX t4a ON t4(x, a);
+ CREATE INDEX t4b ON t4(x, b);
+ }
+ 2 {
+ CREATE TABLE t4(x, a, b);
+ CREATE INDEX t4a ON t4(x, a COLLATE nocase);
+ CREATE INDEX t4b ON t4(x, b);
+ }
+} {
+ drop_all_tables
+ do_test 12.$tn.1 { execsql $schema } {}
+
+ do_test 12.$tn.2 {
+ for {set i 0} {$i < 100} {incr i} {
+ if { ($i % 10)==0 } { set a ABC } else { set a DEF }
+ set b [expr $i % 5]
+ execsql { INSERT INTO t4 VALUES(X'abcdef', $a, $b) }
+ }
+ execsql ANALYZE
+ } {}
+
+ do_eqp_test 12.$tn.3 {
+ SELECT * FROM t4 WHERE x=X'abcdef' AND a = 'def' AND b = 3;
+ } {/t4 USING INDEX t4b/}
+
+ if {$tn==1} {
+ set sql "SELECT * FROM t4 WHERE x=X'abcdef' AND a = 'abc' AND b = 3;"
+ do_eqp_test 12.$tn.4 $sql {/t4 USING INDEX t4a/}
+ } else {
+ set sql {
+ SELECT * FROM t4 WHERE x=X'abcdef' AND a = 'abc' COLLATE nocase AND b = 3
+ }
+ do_eqp_test 12.$tn.5 $sql {/t4 USING INDEX t4a/}
+ set sql {
+ SELECT * FROM t4 WHERE x=X'abcdef' AND a COLLATE nocase = 'abc' AND b = 3
+ }
+ do_eqp_test 12.$tn.6 $sql {/t4 USING INDEX t4a/}
+ }
+}
+
+#-------------------------------------------------------------------------
+# Check that affinities are taken into account when using stat4 data to
+# estimate the number of rows scanned by a rowid constraint.
+#
+drop_all_tables
+do_test 13.1 {
+ execsql {
+ CREATE TABLE t1(a, b, c, d);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b, c);
+ }
+ for {set i 0} {$i<100} {incr i} {
+ if {$i %2} {set a abc} else {set a def}
+ execsql { INSERT INTO t1(rowid, a, b, c) VALUES($i, $a, $i, $i) }
+ }
+ execsql ANALYZE
+} {}
+do_eqp_test 13.2.1 {
+ SELECT * FROM t1 WHERE a='abc' AND rowid<15 AND b<12
+} {/SEARCH t1 USING INDEX i1/}
+do_eqp_test 13.2.2 {
+ SELECT * FROM t1 WHERE a='abc' AND rowid<'15' AND b<12
+} {/SEARCH t1 USING INDEX i1/}
+do_eqp_test 13.3.1 {
+ SELECT * FROM t1 WHERE a='abc' AND rowid<100 AND b<12
+} {/SEARCH t1 USING INDEX i2/}
+do_eqp_test 13.3.2 {
+ SELECT * FROM t1 WHERE a='abc' AND rowid<'100' AND b<12
+} {/SEARCH t1 USING INDEX i2/}
+
+#-------------------------------------------------------------------------
+# Check also that affinities are taken into account when using stat4 data
+# to estimate the number of rows scanned by any other constraint on a
+# column other than the leftmost.
+#
+drop_all_tables
+do_test 14.1 {
+ execsql { CREATE TABLE t1(a, b INTEGER, c) }
+ for {set i 0} {$i<100} {incr i} {
+ set c [expr $i % 3]
+ execsql { INSERT INTO t1 VALUES('ott', $i, $c) }
+ }
+ execsql {
+ CREATE INDEX i1 ON t1(a, b);
+ CREATE INDEX i2 ON t1(c);
+ ANALYZE;
+ }
+} {}
+do_eqp_test 13.2.1 {
+ SELECT * FROM t1 WHERE a='ott' AND b<10 AND c=1
+} {/SEARCH t1 USING INDEX i1/}
+do_eqp_test 13.2.2 {
+ SELECT * FROM t1 WHERE a='ott' AND b<'10' AND c=1
+} {/SEARCH t1 USING INDEX i1/}
+
+#-------------------------------------------------------------------------
+# By default, 16 non-periodic samples are collected for the stat4 table.
+# The following tests attempt to verify that the most common keys are
+# being collected.
+#
+proc check_stat4 {tn} {
+ db eval ANALYZE
+ db eval {SELECT a, b, c, d FROM t1} {
+ incr k($a)
+ incr k([list $a $b])
+ incr k([list $a $b $c])
+ if { [info exists k([list $a $b $c $d])]==0 } { incr nRow }
+ incr k([list $a $b $c $d])
+ }
+
+ set L [list]
+ foreach key [array names k] {
+ lappend L [list $k($key) $key]
+ }
+
+ set nSample $nRow
+ if {$nSample>16} {set nSample 16}
+
+ set nThreshold [lindex [lsort -decr -integer -index 0 $L] [expr $nSample-1] 0]
+ foreach key [array names k] {
+ if {$k($key)>$nThreshold} {
+ set expect($key) 1
+ }
+ if {$k($key)==$nThreshold} {
+ set possible($key) 1
+ }
+ }
+
+
+ set nPossible [expr $nSample - [llength [array names expect]]]
+
+ #puts "EXPECT: [array names expect]"
+ #puts "POSSIBLE($nPossible/[array size possible]): [array names possible]"
+ #puts "HAVE: [db eval {SELECT test_decode(sample) FROM sqlite_stat4 WHERE idx='i1'}]"
+
+ db eval {SELECT test_decode(sample) AS s FROM sqlite_stat4 WHERE idx='i1'} {
+ set seen 0
+ for {set i 0} {$i<4} {incr i} {
+ unset -nocomplain expect([lrange $s 0 $i])
+ if {[info exists possible([lrange $s 0 $i])]} {
+ set seen 1
+ unset -nocomplain possible([lrange $s 0 $i])
+ }
+ }
+ if {$seen} {incr nPossible -1}
+ }
+ if {$nPossible<0} {set nPossible 0}
+
+ set res [list [llength [array names expect]] $nPossible]
+ uplevel [list do_test $tn [list set {} $res] {0 0}]
+}
+
+drop_all_tables
+do_test 14.1.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE INDEX i1 ON t1(a,b,c,d);
+ }
+ for {set i 0} {$i < 160} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i,$i,$i,$i) }
+ if {($i % 10)==0} { execsql { INSERT INTO t1 VALUES($i,$i,$i,$i) } }
+ }
+} {}
+check_stat4 14.1.2
+
+do_test 14.2.1 {
+ execsql { DELETE FROM t1 }
+ for {set i 0} {$i < 1600} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i/10,$i/17,$i/27,$i/37) }
+ }
+} {}
+check_stat4 14.2.2
+
+do_test 14.3.1 {
+ for {set i 0} {$i < 10} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }
+ }
+} {}
+check_stat4 14.3.2
+
+do_test 14.4.1 {
+ execsql {DELETE FROM t1}
+ for {set i 1} {$i < 160} {incr i} {
+ set b [expr $i % 10]
+ if {$b==0 || $b==2} {set b 1}
+ execsql { INSERT INTO t1 VALUES($i/10,$b,$i,$i) }
+ }
+} {}
+check_stat4 14.4.2
+db func lrange lrange
+db func lindex lindex
+do_execsql_test 14.4.3 {
+ SELECT lrange(test_decode(sample), 0, 1) AS s FROM sqlite_stat4
+ WHERE lindex(s, 1)=='1' ORDER BY rowid
+} {
+ {0 1} {1 1} {2 1} {3 1}
+ {4 1} {5 1} {6 1} {7 1}
+ {8 1} {9 1} {10 1} {11 1}
+ {12 1} {13 1} {14 1} {15 1}
+}
+
+#-------------------------------------------------------------------------
+# Test that nothing untoward happens if the stat4 table contains entries
+# for indexes that do not exist. Or NULL values in the idx column.
+# Or NULL values in any of the other columns.
+#
+drop_all_tables
+do_execsql_test 15.1 {
+ CREATE TABLE x1(a, b, UNIQUE(a, b));
+ INSERT INTO x1 VALUES(1, 2);
+ INSERT INTO x1 VALUES(3, 4);
+ INSERT INTO x1 VALUES(5, 6);
+ ANALYZE;
+ INSERT INTO sqlite_stat4 VALUES(NULL, NULL, NULL, NULL, NULL, NULL);
+}
+db close
+sqlite3 db test.db
+do_execsql_test 15.2 { SELECT * FROM x1 } {1 2 3 4 5 6}
+
+do_execsql_test 15.3 {
+ INSERT INTO sqlite_stat4 VALUES(42, 42, 42, 42, 42, 42);
+}
+db close
+sqlite3 db test.db
+do_execsql_test 15.4 { SELECT * FROM x1 } {1 2 3 4 5 6}
+
+do_execsql_test 15.5 {
+ UPDATE sqlite_stat1 SET stat = NULL;
+}
+db close
+sqlite3 db test.db
+do_execsql_test 15.6 { SELECT * FROM x1 } {1 2 3 4 5 6}
+
+do_execsql_test 15.7 {
+ ANALYZE;
+ UPDATE sqlite_stat1 SET tbl = 'no such tbl';
+}
+db close
+sqlite3 db test.db
+do_execsql_test 15.8 { SELECT * FROM x1 } {1 2 3 4 5 6}
+
+do_execsql_test 15.9 {
+ ANALYZE;
+ UPDATE sqlite_stat4 SET neq = NULL, nlt=NULL, ndlt=NULL;
+}
+db close
+sqlite3 db test.db
+do_execsql_test 15.10 { SELECT * FROM x1 } {1 2 3 4 5 6}
+
+# This is just for coverage....
+do_execsql_test 15.11 {
+ ANALYZE;
+ UPDATE sqlite_stat1 SET stat = stat || ' unordered';
+}
+db close
+sqlite3 db test.db
+do_execsql_test 15.12 { SELECT * FROM x1 } {1 2 3 4 5 6}
+
+#-------------------------------------------------------------------------
+# Test that allocations used for sqlite_stat4 samples are included in
+# the quantity returned by SQLITE_DBSTATUS_SCHEMA_USED.
+#
+set one [string repeat x 1000]
+set two [string repeat x 2000]
+do_test 16.1 {
+ reset_db
+ execsql {
+ CREATE TABLE t1(a, UNIQUE(a));
+ INSERT INTO t1 VALUES($one);
+ ANALYZE;
+ }
+ set nByte [lindex [sqlite3_db_status db SCHEMA_USED 0] 1]
+
+ reset_db
+ execsql {
+ CREATE TABLE t1(a, UNIQUE(a));
+ INSERT INTO t1 VALUES($two);
+ ANALYZE;
+ }
+ set nByte2 [lindex [sqlite3_db_status db SCHEMA_USED 0] 1]
+ puts -nonewline " (nByte=$nByte nByte2=$nByte2)"
+
+ expr {$nByte2 > $nByte+900 && $nByte2 < $nByte+1100}
+} {1}
+
+#-------------------------------------------------------------------------
+# Test that stat4 data may be used with partial indexes.
+#
+do_test 17.1 {
+ reset_db
+ execsql {
+ CREATE TABLE t1(a, b, c, d);
+ CREATE INDEX i1 ON t1(a, b) WHERE d IS NOT NULL;
+ INSERT INTO t1 VALUES(-1, -1, -1, NULL);
+ INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;
+ INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;
+ INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;
+ INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;
+ INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;
+ INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;
+ }
+
+ for {set i 0} {$i < 32} {incr i} {
+ if {$i<8} {set b 0} else { set b $i }
+ execsql { INSERT INTO t1 VALUES($i%2, $b, $i/2, 'abc') }
+ }
+ execsql {ANALYZE main.t1}
+} {}
+
+do_catchsql_test 17.1.2 {
+ ANALYZE temp.t1;
+} {1 {no such table: temp.t1}}
+
+do_eqp_test 17.2 {
+ SELECT * FROM t1 WHERE d IS NOT NULL AND a=0 AND b=10 AND c=10;
+} {/USING INDEX i1/}
+do_eqp_test 17.3 {
+ SELECT * FROM t1 WHERE d IS NOT NULL AND a=0 AND b=0 AND c=10;
+} {/USING INDEX i1/}
+
+do_execsql_test 17.4 {
+ CREATE INDEX i2 ON t1(c, d);
+ ANALYZE main.i2;
+}
+do_eqp_test 17.5 {
+ SELECT * FROM t1 WHERE d IS NOT NULL AND a=0 AND b=10 AND c=10;
+} {/USING INDEX i1/}
+do_eqp_test 17.6 {
+ SELECT * FROM t1 WHERE d IS NOT NULL AND a=0 AND b=0 AND c=10;
+} {/USING INDEX i2/}
+
+#-------------------------------------------------------------------------
+#
+do_test 18.1 {
+ reset_db
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ }
+ for {set i 0} {$i < 9} {incr i} {
+ execsql {
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ INSERT INTO t1 VALUES($i, 0);
+ }
+ }
+ execsql ANALYZE
+ execsql { SELECT count(*) FROM sqlite_stat4 }
+} {9}
+
+#-------------------------------------------------------------------------
+# For coverage.
+#
+ifcapable view {
+ do_test 19.1 {
+ reset_db
+ execsql {
+ CREATE TABLE t1(x, y);
+ CREATE INDEX i1 ON t1(x, y);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ ANALYZE;
+ }
+ } {}
+}
+ifcapable auth {
+ proc authproc {op args} {
+ if {$op == "SQLITE_ANALYZE"} { return "SQLITE_DENY" }
+ return "SQLITE_OK"
+ }
+ do_test 19.2 {
+ reset_db
+ db auth authproc
+ execsql {
+ CREATE TABLE t1(x, y);
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ }
+ catchsql ANALYZE
+ } {1 {not authorized}}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+proc r {args} { expr rand() }
+db func r r
+db func lrange lrange
+do_test 20.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE INDEX i1 ON t1(a,b,c,d);
+ }
+ for {set i 0} {$i < 16} {incr i} {
+ execsql {
+ INSERT INTO t1 VALUES($i, r(), r(), r());
+ INSERT INTO t1 VALUES($i, $i, r(), r());
+ INSERT INTO t1 VALUES($i, $i, $i, r());
+ INSERT INTO t1 VALUES($i, $i, $i, $i);
+ INSERT INTO t1 VALUES($i, $i, $i, $i);
+ INSERT INTO t1 VALUES($i, $i, $i, r());
+ INSERT INTO t1 VALUES($i, $i, r(), r());
+ INSERT INTO t1 VALUES($i, r(), r(), r());
+ }
+ }
+} {}
+do_execsql_test 20.2 { ANALYZE }
+for {set i 0} {$i<16} {incr i} {
+ set val "$i $i $i $i"
+ do_execsql_test 20.3.$i {
+ SELECT count(*) FROM sqlite_stat4
+ WHERE lrange(test_decode(sample), 0, 3)=$val
+ } {1}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+
+do_execsql_test 21.0 {
+ CREATE TABLE t2(a, b);
+ CREATE INDEX i2 ON t2(a);
+}
+
+do_test 21.1 {
+ for {set i 1} {$i < 100} {incr i} {
+ execsql {
+ INSERT INTO t2 VALUES(CASE WHEN $i < 80 THEN 'one' ELSE 'two' END, $i)
+ }
+ }
+ execsql ANALYZE
+} {}
+
+# Condition (a='one') matches 80% of the table. (rowid<10) reduces this to
+# 10%, but (rowid<50) only reduces it to 50%. So in the first case below
+# the index is used. In the second, it is not.
+#
+do_eqp_test 21.2 {
+ SELECT * FROM t2 WHERE a='one' AND rowid < 10
+} {/*USING INDEX i2 (a=? AND rowid<?)*/}
+do_eqp_test 21.3 {
+ SELECT * FROM t2 WHERE a='one' AND rowid < 50
+} {/*USING INTEGER PRIMARY KEY*/}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 22.0 {
+ CREATE TABLE t3(a, b, c, d, PRIMARY KEY(a, b)) WITHOUT ROWID;
+ SELECT * FROM t3;
+} {}
+do_execsql_test 22.1 {
+ WITH r(x) AS (
+ SELECT 1
+ UNION ALL
+ SELECT x+1 FROM r WHERE x<=100
+ )
+
+ INSERT INTO t3 SELECT
+ CASE WHEN (x>45 AND x<96) THEN 'B' ELSE 'A' END, /* Column "a" */
+ x, /* Column "b" */
+ CASE WHEN (x<51) THEN 'one' ELSE 'two' END, /* Column "c" */
+ x /* Column "d" */
+ FROM r;
+
+ CREATE INDEX i3 ON t3(c);
+ CREATE INDEX i4 ON t3(d);
+ ANALYZE;
+}
+
+# Expression (c='one' AND a='B') matches 5 table rows. But (c='one' AND a=A')
+# matches 45. Expression (d<?) matches 20. Neither index is a covering index.
+#
+# Therefore, with stat4 data, SQLite prefers (c='one' AND a='B') over (d<20),
+# and (d<20) over (c='one' AND a='A').
+foreach {tn where res} {
+ 1 "c='one' AND a='B' AND d < 20" {/*INDEX i3 (c=? AND a=?)*/}
+ 2 "c='one' AND a='A' AND d < 20" {/*INDEX i4 (d<?)*/}
+} {
+ do_eqp_test 22.2.$tn "SELECT * FROM t3 WHERE $where" $res
+}
+
+proc int_to_char {i} {
+ set ret ""
+ set char [list a b c d e f g h i j]
+ foreach {div} {1000 100 10 1} {
+ append ret [lindex $char [expr ($i / $div) % 10]]
+ }
+ set ret
+}
+db func int_to_char int_to_char
+
+do_execsql_test 23.0 {
+ CREATE TABLE t4(
+ a COLLATE nocase, b, c,
+ d, e, f,
+ PRIMARY KEY(c, b, a)
+ ) WITHOUT ROWID;
+ CREATE INDEX i41 ON t4(e);
+ CREATE INDEX i42 ON t4(f);
+
+ WITH data(a, b, c, d, e, f) AS (
+ SELECT int_to_char(0), 'xyz', 'zyx', '*', 0, 0
+ UNION ALL
+ SELECT
+ int_to_char(f+1), b, c, d, (e+1) % 2, f+1
+ FROM data WHERE f<1024
+ )
+ INSERT INTO t4 SELECT a, b, c, d, e, f FROM data;
+ ANALYZE;
+} {}
+
+do_eqp_test 23.1 {
+ SELECT * FROM t4 WHERE
+ (e=1 AND b='xyz' AND c='zyx' AND a<'AEA') AND f<300
+ -- Formerly used index i41. But i41 is not a covering index whereas
+ -- the PRIMARY KEY is a covering index, and so as of 2017-10-15, the
+ -- PRIMARY KEY is preferred.
+} {SEARCH t4 USING PRIMARY KEY (c=? AND b=? AND a<?)}
+do_eqp_test 23.2 {
+ SELECT * FROM t4 WHERE
+ (e=1 AND b='xyz' AND c='zyx' AND a<'JJJ') AND f<300
+} {SEARCH t4 USING INDEX i42 (f<?)}
+
+do_execsql_test 24.0 {
+ CREATE TABLE t5(c, d, b, e, a, PRIMARY KEY(a, b, c)) WITHOUT ROWID;
+ WITH data(a, b, c, d, e) AS (
+ SELECT 'z', 'y', 0, 0, 0
+ UNION ALL
+ SELECT
+ a, CASE WHEN b='y' THEN 'n' ELSE 'y' END, c+1, e/250, e+1
+ FROM data
+ WHERE e<1000
+ )
+ INSERT INTO t5(a, b, c, d, e) SELECT * FROM data;
+ CREATE INDEX t5d ON t5(d);
+ CREATE INDEX t5e ON t5(e);
+ ANALYZE;
+}
+
+foreach {tn where eqp} {
+ 1 "d=0 AND a='z' AND b='n' AND e<200" {/*t5d (d=? AND a=? AND b=?)*/}
+ 2 "d=0 AND a='z' AND b='n' AND e<100" {/*t5e (e<?)*/}
+
+ 3 "d=0 AND e<300" {/*t5d (d=?)*/}
+ 4 "d=0 AND e<200" {/*t5e (e<?)*/}
+} {
+ do_eqp_test 24.$tn "SeLeCt * FROM t5 WHERE $where" $eqp
+}
+
+#-------------------------------------------------------------------------
+# Test that if stat4 data is available but cannot be used because the
+# rhs of a range constraint is a complex expression, the default estimates
+# are used instead.
+ifcapable stat4&&cte {
+ do_execsql_test 25.1 {
+ CREATE TABLE t6(a, b);
+ WITH ints(i,j) AS (
+ SELECT 1,1 UNION ALL SELECT i+1,j+1 FROM ints WHERE i<100
+ ) INSERT INTO t6 SELECT * FROM ints;
+ CREATE INDEX aa ON t6(a);
+ CREATE INDEX bb ON t6(b);
+ ANALYZE;
+ }
+
+ # Term (b<?) is estimated at 25%. Better than (a<30) but not as
+ # good as (a<20).
+ do_eqp_test 25.2.1 { SELECT * FROM t6 WHERE a<30 AND b<? } \
+ {SEARCH t6 USING INDEX bb (b<?)}
+ do_eqp_test 25.2.2 { SELECT * FROM t6 WHERE a<20 AND b<? } \
+ {SEARCH t6 USING INDEX aa (a<?)}
+
+ # Term (b BETWEEN ? AND ?) is estimated at 1/64.
+ do_eqp_test 25.3.1 {
+ SELECT * FROM t6 WHERE a BETWEEN 5 AND 10 AND b BETWEEN ? AND ?
+ } {SEARCH t6 USING INDEX bb (b>? AND b<?)}
+
+ # Term (b BETWEEN ? AND 60) is estimated to return roughly 15 rows -
+ # 60 from (b<=60) multiplied by 0.25 for the b>=? term. Better than
+ # (a<20) but not as good as (a<10).
+ do_eqp_test 25.4.1 {
+ SELECT * FROM t6 WHERE a < 10 AND (b BETWEEN ? AND 60)
+ } {SEARCH t6 USING INDEX aa (a<?)}
+
+ do_eqp_test 25.4.2 {
+ SELECT * FROM t6 WHERE a < 20 AND (b BETWEEN ? AND 60)
+ } {SEARCH t6 USING INDEX bb (b>? AND b<?)}
+}
+
+#-------------------------------------------------------------------------
+# Check that a problem in they way stat4 data is used has been
+# resolved (see below).
+#
+reset_db
+do_test 26.1.1 {
+ db transaction {
+ execsql {
+ CREATE TABLE t1(x, y, z);
+ CREATE INDEX t1xy ON t1(x, y);
+ CREATE INDEX t1z ON t1(z);
+ }
+ for {set i 0} {$i < 10000} {incr i} {
+ execsql { INSERT INTO t1(x, y) VALUES($i, $i) }
+ }
+ for {set i 0} {$i < 10} {incr i} {
+ execsql {
+ WITH cnt(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM cnt WHERE x<100)
+ INSERT INTO t1(x, y) SELECT 10000+$i, x FROM cnt;
+ INSERT INTO t1(x, y) SELECT 10000+$i, 100;
+ }
+ }
+ execsql {
+ UPDATE t1 SET z = rowid / 20;
+ ANALYZE;
+ }
+ }
+} {}
+
+do_execsql_test 26.1.2 {
+ SELECT count(*) FROM t1 WHERE x = 10000 AND y < 50;
+} {49}
+do_execsql_test 26.1.3 {
+ SELECT count(*) FROM t1 WHERE z = 444;
+} {20}
+
+# The analyzer knows that any (z=?) expression matches 20 rows. So it
+# will use index "t1z" if the estimate of hits for (x=10000 AND y<50)
+# is greater than 20 rows.
+#
+# And it should be. The analyzer has a stat4 sample as follows:
+#
+# sample=(x=10000, y=100) nLt=(10000 10099)
+#
+# There should be no other samples that start with (x=10000). So it knows
+# that (x=10000 AND y<50) must match somewhere between 0 and 99 rows, but
+# no more than that. Guessing less than 20 is therefore unreasonable.
+#
+# At one point though, due to a problem in whereKeyStats(), the planner was
+# estimating that (x=10000 AND y<50) would match only 2 rows.
+#
+do_eqp_test 26.1.4 {
+ SELECT * FROM t1 WHERE x = 10000 AND y < 50 AND z = 444;
+} {SEARCH t1 USING INDEX t1z (z=?)}
+
+
+# This test - 26.2.* - tests that another manifestation of the same problem
+# is no longer present in the library. Assuming:
+#
+# CREATE INDEX t1xy ON t1(x, y)
+#
+# and that have samples for index t1xy as follows:
+#
+#
+# sample=('A', 70) nEq=(100, 2) nLt=(900, 970)
+# sample=('B', 70) nEq=(100, 2) nLt=(1000, 1070)
+#
+# the planner should estimate that (x = 'B' AND y > 25) matches 76 rows
+# (70 * 2/3 + 30). Before, due to the problem, the planner was estimating
+# that this matched 100 rows.
+#
+reset_db
+do_execsql_test 26.2.1 {
+ BEGIN;
+ CREATE TABLE t1(x, y, z);
+ CREATE INDEX i1 ON t1(x, y);
+ CREATE INDEX i2 ON t1(z);
+
+ WITH
+ cnt(y) AS (SELECT 0 UNION ALL SELECT y+1 FROM cnt WHERE y<99),
+ letters(x) AS (
+ SELECT 'A' UNION SELECT 'B' UNION SELECT 'C' UNION SELECT 'D'
+ )
+ INSERT INTO t1(x, y) SELECT x, y FROM letters, cnt;
+
+ WITH
+ letters(x) AS (
+ SELECT 'A' UNION SELECT 'B' UNION SELECT 'C' UNION SELECT 'D'
+ )
+ INSERT INTO t1(x, y) SELECT x, 70 FROM letters;
+
+ WITH
+ cnt(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM cnt WHERE i<9999)
+ INSERT INTO t1(x, y) SELECT i, i FROM cnt;
+
+ UPDATE t1 SET z = (rowid / 95);
+ ANALYZE;
+ COMMIT;
+}
+
+do_eqp_test 26.2.2 {
+ SELECT * FROM t1 WHERE x='B' AND y>25 AND z=?;
+} {SEARCH t1 USING INDEX i1 (x=? AND y>?)}
+
+
+finish_test
diff --git a/test/analyzeC.test b/test/analyzeC.test
new file mode 100644
index 0000000..2f43d57
--- /dev/null
+++ b/test/analyzeC.test
@@ -0,0 +1,181 @@
+# 2014-07-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 automated tests used to verify that the text terms
+# at the end of sqlite_stat1.stat are processed correctly.
+#
+# (1) "unordered" means that the index cannot be used for ORDER BY
+# or for range queries
+#
+# (2) "sz=NNN" sets the relative size of the index entries
+#
+# (3) All other fields are silently ignored
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix analyzeC
+
+# Baseline case. Range queries work OK. Indexes can be used for
+# ORDER BY.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1(a,b,c)
+ VALUES(1,2,3),(7,8,9),(4,5,6),(10,11,12),(4,8,12),(1,11,111);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ ANALYZE;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat)
+ VALUES('t1','t1a','12345 2'),('t1','t1b','12345 4');
+ ANALYZE sqlite_master;
+ SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;
+} {4 5 6 # 7 8 9 # 4 8 12 #}
+do_execsql_test 1.1 {
+ EXPLAIN QUERY PLAN
+ SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;
+} {/.* USING INDEX t1a .a>. AND a<...*/}
+do_execsql_test 1.2 {
+ SELECT c FROM t1 ORDER BY a;
+} {3 111 6 12 9 12}
+do_execsql_test 1.3 {
+ EXPLAIN QUERY PLAN
+ SELECT c FROM t1 ORDER BY a;
+} {/.*SCAN t1 USING INDEX t1a.*/}
+do_execsql_test 1.3x {
+ EXPLAIN QUERY PLAN
+ SELECT c FROM t1 ORDER BY a;
+} {~/.*B-TREE FOR ORDER BY.*/}
+
+# Now mark the t1a index as "unordered". Range queries and ORDER BY no
+# longer use the index, but equality queries do.
+#
+do_execsql_test 2.0 {
+ UPDATE sqlite_stat1 SET stat='12345 2 unordered' WHERE idx='t1a';
+ ANALYZE sqlite_master;
+ SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;
+} {4 5 6 # 7 8 9 # 4 8 12 #}
+do_execsql_test 2.1 {
+ EXPLAIN QUERY PLAN
+ SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;
+} {~/.*USING INDEX.*/}
+do_execsql_test 2.2 {
+ SELECT c FROM t1 ORDER BY a;
+} {3 111 6 12 9 12}
+do_execsql_test 2.3 {
+ EXPLAIN QUERY PLAN
+ SELECT c FROM t1 ORDER BY a;
+} {~/.*USING INDEX.*/}
+do_execsql_test 2.3x {
+ EXPLAIN QUERY PLAN
+ SELECT c FROM t1 ORDER BY a;
+} {/.*B-TREE FOR ORDER BY.*/}
+
+# Ignore extraneous text parameters in the sqlite_stat1.stat field.
+#
+do_execsql_test 3.0 {
+ UPDATE sqlite_stat1 SET stat='12345 2 whatever=5 unordered xyzzy=11'
+ WHERE idx='t1a';
+ ANALYZE sqlite_master;
+ SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;
+} {4 5 6 # 7 8 9 # 4 8 12 #}
+do_execsql_test 3.1 {
+ EXPLAIN QUERY PLAN
+ SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;
+} {~/.*USING INDEX.*/}
+do_execsql_test 3.2 {
+ SELECT c FROM t1 ORDER BY a;
+} {3 111 6 12 9 12}
+do_execsql_test 3.3 {
+ EXPLAIN QUERY PLAN
+ SELECT c FROM t1 ORDER BY a;
+} {~/.*USING INDEX.*/}
+do_execsql_test 3.3x {
+ EXPLAIN QUERY PLAN
+ SELECT c FROM t1 ORDER BY a;
+} {/.*B-TREE FOR ORDER BY.*/}
+
+# The sz=NNN parameter determines which index to scan
+#
+do_execsql_test 4.0 {
+ DROP INDEX t1a;
+ CREATE INDEX t1ab ON t1(a,b);
+ CREATE INDEX t1ca ON t1(c,a);
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat)
+ VALUES('t1','t1ab','12345 3 2 sz=10'),('t1','t1ca','12345 3 2 sz=20');
+ ANALYZE sqlite_master;
+ SELECT count(a) FROM t1;
+} {6}
+do_execsql_test 4.1 {
+ EXPLAIN QUERY PLAN
+ SELECT count(a) FROM t1;
+} {/.*INDEX t1ab.*/}
+do_execsql_test 4.2 {
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat)
+ VALUES('t1','t1ab','12345 3 2 sz=20'),('t1','t1ca','12345 3 2 sz=10');
+ ANALYZE sqlite_master;
+ SELECT count(a) FROM t1;
+} {6}
+do_execsql_test 4.3 {
+ EXPLAIN QUERY PLAN
+ SELECT count(a) FROM t1;
+} {/.*INDEX t1ca.*/}
+
+# 2019-08-15.
+# Ticket https://www.sqlite.org/src/tktview/e4598ecbdd18bd82945f602901
+# The sz=N parameter in the sqlite_stat1 table needs to have a value of
+# 2 or more to avoid a division by zero in the query planner.
+#
+do_execsql_test 4.4 {
+ DROP TABLE IF EXISTS t44;
+ CREATE TABLE t44(a PRIMARY KEY);
+ INSERT INTO sqlite_stat1 VALUES('t44',null,'sz=0');
+ ANALYZE sqlite_master;
+ SELECT 0 FROM t44 WHERE a IN(1,2,3);
+} {}
+
+
+
+# The sz=NNN parameter works even if there is other extraneous text
+# in the sqlite_stat1.stat column.
+#
+do_execsql_test 5.0 {
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat)
+ VALUES('t1','t1ab','12345 3 2 x=5 sz=10 y=10'),
+ ('t1','t1ca','12345 3 2 whatever sz=20 junk');
+ ANALYZE sqlite_master;
+ SELECT count(a) FROM t1;
+} {6}
+do_execsql_test 5.1 {
+ EXPLAIN QUERY PLAN
+ SELECT count(a) FROM t1;
+} {/.*INDEX t1ab.*/}
+do_execsql_test 5.2 {
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat)
+ VALUES('t1','t1ca','12345 3 2 x=5 sz=10 y=10'),
+ ('t1','t1ab','12345 3 2 whatever sz=20 junk');
+ ANALYZE sqlite_master;
+ SELECT count(a) FROM t1;
+} {6}
+do_execsql_test 5.3 {
+ EXPLAIN QUERY PLAN
+ SELECT count(a) FROM t1;
+} {/.*INDEX t1ca.*/}
+
+
+
+
+finish_test
diff --git a/test/analyzeD.test b/test/analyzeD.test
new file mode 100644
index 0000000..7a51785
--- /dev/null
+++ b/test/analyzeD.test
@@ -0,0 +1,107 @@
+# 2014-10-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 the ANALYZE command.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix analyzeD
+
+ifcapable {!stat4} {
+ finish_test
+ return
+}
+
+
+# Set up a table with the following properties:
+#
+# * Contains 1000 rows.
+# * Column a contains even integers between 0 and 18, inclusive (so that
+# a=? for any such integer matches 100 rows).
+# * Column b contains integers between 0 and 9, inclusive.
+# * Column c contains integers between 0 and 199, inclusive (so that
+# for any such integer, c=? matches 5 rows).
+# * Then add 7 rows with a new value for "a" - 3001. The stat4 table will
+# not contain any samples with a=3001.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+}
+do_test 1.1 {
+ for {set i 1} {$i < 1000} {incr i} {
+ set c [expr $i % 200]
+ execsql { INSERT INTO t1(a, b, c) VALUES( 2*($i/100), $i%10, $c ) }
+ }
+
+ execsql {
+ INSERT INTO t1 VALUES(3001, 3001, 3001);
+ INSERT INTO t1 VALUES(3001, 3001, 3002);
+ INSERT INTO t1 VALUES(3001, 3001, 3003);
+ INSERT INTO t1 VALUES(3001, 3001, 3004);
+ INSERT INTO t1 VALUES(3001, 3001, 3005);
+ INSERT INTO t1 VALUES(3001, 3001, 3006);
+ INSERT INTO t1 VALUES(3001, 3001, 3007);
+
+ CREATE INDEX t1_ab ON t1(a, b);
+ CREATE INDEX t1_c ON t1(c);
+
+ ANALYZE;
+ }
+} {}
+
+# With full ANALYZE data, SQLite sees that c=150 (5 rows) is better than
+# a=3001 (7 rows).
+#
+do_eqp_test 1.2 {
+ SELECT * FROM t1 WHERE a=3001 AND c=150;
+} {SEARCH t1 USING INDEX t1_c (c=?)}
+
+do_test 1.3 {
+ execsql { DELETE FROM sqlite_stat1 }
+ db close
+ sqlite3 db test.db
+} {}
+
+# Without stat1, because 3001 is larger than all samples in the stat4
+# table, SQLite thinks that a=3001 matches just 1 row. So it (incorrectly)
+# chooses it over the c=150 index (5 rows). Even with stat1 data, things
+# worked this way before commit [e6f7f97dbc].
+#
+do_eqp_test 1.4 {
+ SELECT * FROM t1 WHERE a=3001 AND c=150;
+} {SEARCH t1 USING INDEX t1_ab (a=?)}
+
+do_test 1.5 {
+ execsql {
+ UPDATE t1 SET a=13 WHERE a = 3001;
+ ANALYZE;
+ }
+} {}
+
+do_eqp_test 1.6 {
+ SELECT * FROM t1 WHERE a=13 AND c=150;
+} {SEARCH t1 USING INDEX t1_c (c=?)}
+
+do_test 1.7 {
+ execsql { DELETE FROM sqlite_stat1 }
+ db close
+ sqlite3 db test.db
+} {}
+
+# Same test as 1.4, except this time the 7 rows that match the a=? condition
+# do not feature larger values than all rows in the stat4 table. So SQLite
+# gets this right, even without stat1 data.
+do_eqp_test 1.8 {
+ SELECT * FROM t1 WHERE a=13 AND c=150;
+} {SEARCH t1 USING INDEX t1_c (c=?)}
+
+finish_test
diff --git a/test/analyzeE.test b/test/analyzeE.test
new file mode 100644
index 0000000..733b793
--- /dev/null
+++ b/test/analyzeE.test
@@ -0,0 +1,242 @@
+# 2014-10-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 tests for using STAT4 information
+# on a descending index in a range query.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix analyzeE
+
+ifcapable {!stat4} {
+ finish_test
+ return
+}
+
+# Verify that range queries on an ASCENDING index will use the
+# index only if the range covers only a small fraction of the
+# entries.
+#
+do_execsql_test analyzeE-1.0 {
+ CREATE TABLE t1(a,b);
+ WITH RECURSIVE
+ cnt(x) AS (VALUES(1000) UNION ALL SELECT x+1 FROM cnt WHERE x<2000)
+ INSERT INTO t1(a,b) SELECT x, x FROM cnt;
+ CREATE INDEX t1a ON t1(a);
+ ANALYZE;
+} {}
+do_execsql_test analyzeE-1.1 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 500 AND 2500;
+} {/SCAN t1/}
+do_execsql_test analyzeE-1.2 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 2900 AND 3000;
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-1.3 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 1700 AND 1750;
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-1.4 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 1 AND 500
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-1.5 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 3000 AND 3000000
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-1.6 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<500
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-1.7 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>2500
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-1.8 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>1900
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-1.9 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>1100
+} {/SCAN t1/}
+do_execsql_test analyzeE-1.10 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<1100
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-1.11 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<1900
+} {/SCAN t1/}
+
+# Verify that everything works the same on a DESCENDING index.
+#
+do_execsql_test analyzeE-2.0 {
+ DROP INDEX t1a;
+ CREATE INDEX t1a ON t1(a DESC);
+ ANALYZE;
+} {}
+do_execsql_test analyzeE-2.1 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 500 AND 2500;
+} {/SCAN t1/}
+do_execsql_test analyzeE-2.2 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 2900 AND 3000;
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-2.3 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 1700 AND 1750;
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-2.4 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 1 AND 500
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-2.5 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 3000 AND 3000000
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-2.6 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<500
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-2.7 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>2500
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-2.8 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>1900
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-2.9 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>1100
+} {/SCAN t1/}
+do_execsql_test analyzeE-2.10 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<1100
+} {/SEARCH t1 USING INDEX t1a/}
+do_execsql_test analyzeE-2.11 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<1900
+} {/SCAN t1/}
+
+# Now do a range query on the second term of an ASCENDING index
+# where the first term is constrained by equality.
+#
+do_execsql_test analyzeE-3.0 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c);
+ WITH RECURSIVE
+ cnt(x) AS (VALUES(1000) UNION ALL SELECT x+1 FROM cnt WHERE x<2000)
+ INSERT INTO t1(a,b,c) SELECT x, x, 123 FROM cnt;
+ CREATE INDEX t1ca ON t1(c,a);
+ ANALYZE;
+} {}
+do_execsql_test analyzeE-3.1 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 500 AND 2500 AND c=123;
+} {/SCAN t1/}
+do_execsql_test analyzeE-3.2 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 2900 AND 3000 AND c=123;
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-3.3 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 1700 AND 1750 AND c=123;
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-3.4 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 1 AND 500 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-3.5 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 3000 AND 3000000 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-3.6 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<500 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-3.7 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>2500 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-3.8 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>1900 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-3.9 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>1100 AND c=123
+} {/SCAN t1/}
+do_execsql_test analyzeE-3.10 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<1100 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-3.11 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<1900 AND c=123
+} {/SCAN t1/}
+
+# Repeat the 3.x tests using a DESCENDING index
+#
+do_execsql_test analyzeE-4.0 {
+ DROP INDEX t1ca;
+ CREATE INDEX t1ca ON t1(c ASC,a DESC);
+ ANALYZE;
+} {}
+do_execsql_test analyzeE-4.1 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 500 AND 2500 AND c=123;
+} {/SCAN t1/}
+do_execsql_test analyzeE-4.2 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 2900 AND 3000 AND c=123;
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-4.3 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 1700 AND 1750 AND c=123;
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-4.4 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 1 AND 500 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-4.5 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a BETWEEN 3000 AND 3000000 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-4.6 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<500 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-4.7 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>2500 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-4.8 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>1900 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-4.9 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a>1100 AND c=123
+} {/SCAN t1/}
+do_execsql_test analyzeE-4.10 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<1100 AND c=123
+} {/SEARCH t1 USING INDEX t1ca/}
+do_execsql_test analyzeE-4.11 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a<1900 AND c=123
+} {/SCAN t1/}
+
+finish_test
diff --git a/test/analyzeF.test b/test/analyzeF.test
new file mode 100644
index 0000000..0010799
--- /dev/null
+++ b/test/analyzeF.test
@@ -0,0 +1,150 @@
+# 2015-03-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.
+#
+#***********************************************************************
+# Test that deterministic scalar functions passed constant arguments
+# are used with stat4 data.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix analyzeF
+
+ifcapable {!stat4} {
+ finish_test
+ return
+}
+
+proc isqrt {i} { expr { int(sqrt($i)) } }
+db func isqrt isqrt
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x INTEGER, y INTEGER);
+ WITH data(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM data
+ )
+ INSERT INTO t1 SELECT isqrt(i), isqrt(i) FROM data LIMIT 400;
+ CREATE INDEX t1x ON t1(x);
+ CREATE INDEX t1y ON t1(y);
+ ANALYZE;
+}
+
+proc str {a} { return $a }
+db func str str
+
+# Note: tests 7 to 12 might be unstable - as they assume SQLite will
+# prefer the expression to the right of the AND clause. Which of
+# course could change.
+#
+# Note 2: tests 9 and 10 depend on the tcl interface creating functions
+# without the SQLITE_DETERMINISTIC flag set.
+#
+foreach {tn where idx} {
+ 1 "x = 4 AND y = 19" {t1x (x=?)}
+ 2 "x = 19 AND y = 4" {t1y (y=?)}
+ 3 "x = '4' AND y = '19'" {t1x (x=?)}
+ 4 "x = '19' AND y = '4'" {t1y (y=?)}
+ 5 "x = substr('5195', 2, 2) AND y = substr('145', 2, 1)" {t1y (y=?)}
+ 6 "x = substr('145', 2, 1) AND y = substr('5195', 2, 2)" {t1x (x=?)}
+
+ 7 "x = substr('5195', 2, 2+0) AND y = substr('145', 2, 1+0)" {t1y (y=?)}
+ 8 "x = substr('145', 2, 1+0) AND y = substr('5195', 2, 2+0)" {t1y (y=?)}
+
+ 9 "x = str('19') AND y = str('4')" {t1y (y=?)}
+ 10 "x = str('4') AND y = str('19')" {t1y (y=?)}
+
+ 11 "x = nullif('19', 0) AND y = nullif('4', 0)" {t1y (y=?)}
+ 12 "x = nullif('4', 0) AND y = nullif('19', 0)" {t1y (y=?)}
+} {
+ set res "SEARCH t1 USING INDEX $idx"
+ do_eqp_test 1.$tn "SELECT * FROM t1 WHERE $where" $res
+}
+
+# Test that functions that do not exist - "func()" - do not cause an error.
+#
+do_catchsql_test 2.1 {
+ SELECT * FROM t1 WHERE x = substr('145', 2, 1) AND y = func(1, 2, 3)
+} {1 {no such function: func}}
+do_catchsql_test 2.2 {
+ UPDATE t1 SET y=y+1 WHERE x = substr('145', 2, 1) AND y = func(1, 2, 3)
+} {1 {no such function: func}}
+
+
+# Check that functions that accept zero arguments do not cause problems.
+#
+proc ret {x} { return $x }
+
+db func det4 -deterministic [list ret 4]
+db func nondet4 [list ret 4]
+db func det19 -deterministic [list ret 19]
+db func nondet19 [list ret 19]
+
+foreach {tn where idx} {
+ 1 "x = det4() AND y = det19()" {t1x (x=?)}
+ 2 "x = det19() AND y = det4()" {t1y (y=?)}
+
+ 3 "x = nondet4() AND y = nondet19()" {t1y (y=?)}
+ 4 "x = nondet19() AND y = nondet4()" {t1y (y=?)}
+} {
+ set res "SEARCH t1 USING INDEX $idx"
+ do_eqp_test 3.$tn "SELECT * FROM t1 WHERE $where" $res
+}
+
+
+execsql { DELETE FROM t1 }
+
+proc throw_error {err} { error $err }
+db func error -deterministic throw_error
+do_catchsql_test 4.1 {
+ SELECT * FROM t1 WHERE x = error('error one') AND y = 4;
+} {1 {error one}}
+
+do_catchsql_test 4.2 {
+ SELECT * FROM t1 WHERE x = zeroblob(2200000000) AND y = 4;
+} {1 {string or blob too big}}
+
+sqlite3_limit db SQLITE_LIMIT_LENGTH 1000000
+proc dstr {} { return [string repeat x 1100000] }
+db func dstr -deterministic dstr
+do_catchsql_test 4.3 {
+ SELECT * FROM t1 WHERE x = dstr() AND y = 11;
+} {1 {string or blob too big}}
+
+do_catchsql_test 4.4 {
+ SELECT * FROM t1 WHERE x = test_zeroblob(1100000) AND y = 4;
+} {1 {string or blob too big}}
+
+# 2016-12-08: Constraints of the form "x=? AND x IS NOT NULL" were being
+# mishandled. The sqlite3Stat4ProbeSetValue() routine was assuming that
+# valueNew() was returning a Mem object that was preset to NULL, which is
+# not the case. The consequence was the the "x IS NOT NULL" constraint
+# was used to drive the index (via the "x>NULL" pseudo-constraint) rather
+# than the "x=?" constraint.
+#
+do_execsql_test 5.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10000)
+ INSERT INTO t1(a, c) SELECT x, x FROM c;
+ UPDATE t1 SET b=printf('x%02x',a/500) WHERE a>4000;
+ UPDATE t1 SET b='xyz' where a>=9998;
+ CREATE INDEX t1b ON t1(b);
+ ANALYZE;
+ SELECT count(*), b FROM t1 GROUP BY 2 ORDER BY 2;
+} {4000 {} 499 x08 500 x09 500 x0a 500 x0b 500 x0c 500 x0d 500 x0e 500 x0f 500 x10 500 x11 500 x12 498 x13 3 xyz}
+do_execsql_test 5.2 {
+ explain query plan
+ SELECT * FROM t1 WHERE b='xyz' AND b IS NOT NULL ORDER BY +a;
+ /* v---- Should be "=", not ">" */
+} {/USING INDEX t1b .b=/}
+do_execsql_test 5.3 {
+ SELECT * FROM t1 WHERE b='xyz' AND b IS NOT NULL ORDER BY +a;
+} {9998 xyz 9998 9999 xyz 9999 10000 xyz 10000}
+
+finish_test
diff --git a/test/analyzeG.test b/test/analyzeG.test
new file mode 100644
index 0000000..ca65bc3
--- /dev/null
+++ b/test/analyzeG.test
@@ -0,0 +1,84 @@
+# 2020-02-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 for functionality related to ANALYZE.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !stat4 {
+ finish_test
+ return
+}
+set testprefix analyzeG
+
+#-------------------------------------------------------------------------
+# Test cases 1.* seek to verify that even if an index is not used, its
+# stat4 data may be used by the planner to estimate the number of
+# rows that match an unindexed constraint on the same column.
+#
+do_execsql_test 1.0 {
+ PRAGMA automatic_index = 0;
+ CREATE TABLE t1(a, x);
+ CREATE TABLE t2(b, y);
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
+ )
+ INSERT INTO t1 SELECT (i%50), NULL FROM s;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
+ )
+ INSERT INTO t2 SELECT (CASE WHEN i<95 THEN 44 ELSE i END), NULL FROM s;
+}
+
+# Join tables t1 and t2. Both contain 100 rows. (a=44) matches 2 rows
+# in "t1", (b=44) matches 95 rows in table "t2". But the planner doesn't
+# know this, so it has no preference as to which order the tables are
+# scanned in. In practice this means that tables are scanned in the order
+# they are specified in in the FROM clause.
+do_eqp_test 1.1.1 {
+ SELECT * FROM t1, t2 WHERE a=44 AND b=44;
+} {
+
+}
+do_eqp_test 1.1.2 {
+ SELECT * FROM t2, t1 WHERE a=44 AND b=44
+} {
+ QUERY PLAN
+ |--SCAN t2
+ `--SCAN t1
+}
+
+do_execsql_test 1.2 {
+ CREATE INDEX t2b ON t2(b);
+ ANALYZE;
+}
+
+# Now, with the ANALYZE data, the planner knows that (b=44) matches a
+# large number of rows. So it elects to scan table "t1" first, regardless
+# of the order in which the tables are specified in the FROM clause.
+do_eqp_test 1.3.1 {
+ SELECT * FROM t1, t2 WHERE a=44 AND b=44;
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SCAN t2
+}
+do_eqp_test 1.3.2 {
+ SELECT * FROM t2, t1 WHERE a=44 AND b=44
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SCAN t2
+}
+
+
+finish_test
diff --git a/test/analyzer1.test b/test/analyzer1.test
new file mode 100644
index 0000000..51b5f8b
--- /dev/null
+++ b/test/analyzer1.test
@@ -0,0 +1,55 @@
+# 2015-05-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.
+#
+#***********************************************************************
+#
+# Quick tests for the sqlite3_analyzer tool
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+if {$tcl_platform(platform)=="windows"} {
+ set PROG "sqlite3_analyzer.exe"
+} else {
+ set PROG "./sqlite3_analyzer"
+}
+if {![file exe $PROG]} {
+ set PROG [file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $PROG]]
+ if {![file exe $PROG]} {
+ puts "analyzer1 cannot run because $PROG is not available"
+ finish_test
+ return
+ }
+}
+db close
+forcedelete test.db test.db-journal test.db-wal
+sqlite3 db test.db
+
+do_test analyzer1-1.0 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<250)
+ INSERT INTO t1(a,b) SELECT x, randomblob(200) FROM c;
+ INSERT INTO t2(a,b) SELECT a, b FROM t1;
+ }
+ set line "exec $PROG test.db"
+ unset -nocomplain ::MSG
+ catch {eval $line} ::MSG
+} {0}
+do_test analyzer1-1.1 {
+ regexp {^/\*\* Disk-Space Utilization.*COMMIT;\W*$} $::MSG
+} {1}
+
+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..abac11f
--- /dev/null
+++ b/test/async5.test
@@ -0,0 +1,68 @@
+# 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/atof1.test b/test/atof1.test
new file mode 100644
index 0000000..5959c5d
--- /dev/null
+++ b/test/atof1.test
@@ -0,0 +1,88 @@
+# 2012 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.
+#
+#***********************************************************************
+#
+# Tests of the sqlite3AtoF() function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {$::longdouble_size<=8} {
+ finish_test
+ return
+}
+if {$::tcl_platform(machine)!="x86_64"} {
+ finish_test
+ return
+}
+
+expr srand(1)
+for {set i 1} {$i<20000} {incr i} {
+ set pow [expr {int((rand()-0.5)*100)}]
+ set x [expr {pow((rand()-0.5)*2*rand(),$pow)}]
+ set xf [format %.32e $x]
+
+ # Verify that text->real conversions get exactly same ieee754 floating-
+ # point value in SQLite as they do in TCL.
+ #
+ do_test atof1-1.$i.1 {
+ set y [db eval "SELECT $xf=\$x"]
+ if {!$y} {
+ puts -nonewline \173[db eval "SELECT real2hex($xf), real2hex(\$x)"]\175
+ db eval "SELECT $xf+0.0 AS a, \$x AS b" {
+ puts [format "\n%.60e\n%.60e\n%.60e" $x $a $b]
+ }
+ }
+ set y
+ } {1}
+
+ # Verify that round-trip real->text->real conversions using the quote()
+ # function preserve the bits of the numeric value exactly.
+ #
+ do_test atof1-1.$i.2 {
+ set y [db eval {SELECT $x=CAST(quote($x) AS real)}]
+ if {!$y} {
+ db eval {SELECT real2hex($x) a, real2hex(CAST(quote($x) AS real)) b} {}
+ puts "\nIN: $a $xf"
+ puts [format {QUOTE: %16s %s} {} [db eval {SELECT quote($x)}]]
+ db eval {SELECT CAST(quote($x) AS real) c} {}
+ puts "OUT: $b [format %.32e $c]"
+ }
+ set y
+ } {1}
+}
+
+# 2020-01-08 ticket 9eda2697f5cc1aba
+# When running sqlite3AtoF() on a blob with an odd number of bytes using
+# UTF16, ignore the last byte so that the string has an integer number of
+# UTF16 code points.
+#
+reset_db
+do_execsql_test atof1-2.10 {
+ PRAGMA encoding = 'UTF16be';
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1(rowid,a) VALUES (1,x'00'),(2,3);
+ SELECT substr(a,',') is true FROM t1 ORDER BY rowid;
+} {0 1}
+do_execsql_test atof1-2.20 {
+ SELECT substr(a,',') is true FROM t1 ORDER BY rowid DESC;
+} {1 0}
+do_execsql_test atof1-2.30 {
+ CREATE INDEX i1 ON t1(a);
+ SELECT count(*) FROM t1 WHERE substr(a,',');
+} {1}
+# 2020-08-27 OSSFuzz find related to the above.
+do_execsql_test atof1-2.40 {
+ SELECT randomblob(0) - 1;
+} {-1}
+
+
+finish_test
diff --git a/test/atomic.test b/test/atomic.test
new file mode 100644
index 0000000..6ce6deb
--- /dev/null
+++ b/test/atomic.test
@@ -0,0 +1,41 @@
+# 2015-11-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 file is testing the WITH clause.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix atomic
+
+db close
+if {[atomic_batch_write test.db]==0} {
+ puts "No f2fs atomic-batch-write support. Skipping tests..."
+ finish_test
+ return
+}
+
+reset_db
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+}
+
+do_test 1.1 { file exists test.db-journal } {0}
+
+do_execsql_test 1.2 {
+ COMMIT;
+}
+
+
+finish_test
diff --git a/test/atomic2.test b/test/atomic2.test
new file mode 100644
index 0000000..5b78658
--- /dev/null
+++ b/test/atomic2.test
@@ -0,0 +1,95 @@
+# 2018-07-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 if an IO error is encountered
+# as part of an atomic F2FS commit, an attempt is made to commit the
+# transaction using a legacy journal commit.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set ::testprefix atomic2
+
+db close
+if {[atomic_batch_write test.db]==0} {
+ puts "No f2fs atomic-batch-write support. Skipping tests..."
+ finish_test
+ return
+}
+
+reset_db
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+ CREATE INDEX i1x ON t1(x);
+ CREATE INDEX i2x ON t1(y);
+
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100 )
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
+}
+
+set setup [list \
+ -injectstart at_injectstart \
+ -injectstop at_injectstop \
+]
+
+set ::at_fail 0
+set ::at_nfail 0
+
+proc at_injectstart {iFail} {
+ set ::at_fail $iFail
+ set ::at_nfail 0
+}
+proc at_injectstop {} {
+ set ::at_fail 0
+ return $::at_nfail
+}
+
+proc at_vfs_callback {method file z args} {
+ if {$::at_fail>0} {
+ incr ::at_fail -1
+ if {$::at_fail==0} {
+ incr ::at_nfail
+ return SQLITE_IOERR
+ } elseif {$method=="xFileControl" && $z=="COMMIT_ATOMIC_WRITE"} {
+ set ::at_fail 0
+ }
+ }
+ return SQLITE_OK
+}
+
+testvfs tvfs -default 1
+tvfs script at_vfs_callback
+tvfs filter {xFileControl xWrite}
+
+faultsim_save_and_close
+
+do_one_faultsim_test 2.0 {*}$setup -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100 )
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+
+ set res [execsql {SELECT count(*) FROM t1; PRAGMA integrity_check}]
+ if {$res!="200 ok"} {
+ error "expected {200 ok}, got $res"
+ }
+}
+
+db close
+tvfs delete
+
+finish_test
diff --git a/test/atrc.c b/test/atrc.c
new file mode 100644
index 0000000..673f12c
--- /dev/null
+++ b/test/atrc.c
@@ -0,0 +1,150 @@
+/*
+** This program generates a script that stresses the ALTER TABLE statement.
+** Compile like this:
+**
+** gcc -g -c sqlite3.c
+** gcc -g -o atrc atrc.c sqlite3.o -ldl -lpthread
+**
+** Run the program this way:
+**
+** ./atrc DATABASE | ./sqlite3 DATABASE
+**
+** This program "atrc" generates a script that can be fed into an ordinary
+** command-line shell. The script performs many ALTER TABLE statements,
+** runs ".schema --indent" and "PRAGMA integrity_check;", does more
+** ALTER TABLE statements to restore the original schema, and then
+** runs "PRAGMA integrity_check" again. Every table and column has its
+** name changed. The entire script is contained within BEGIN...ROLLBACK
+** so that no changes are ever actually made to the database.
+*/
+#include "sqlite3.h"
+#include <stdio.h>
+
+/*
+** Generate the text of ALTER TABLE statements that will rename
+** every column in table zTable to a generic name composed from
+** zColPrefix and a sequential number. The generated text is
+** appended pConvert. If pUndo is not NULL, then SQL text that
+** will undo the change is appended to pUndo.
+**
+** The table to be converted must be in the "main" schema.
+*/
+int rename_all_columns_of_table(
+ sqlite3 *db, /* Database connection */
+ const char *zTab, /* Table whose columns should all be renamed */
+ const char *zColPrefix, /* Prefix for new column names */
+ sqlite3_str *pConvert, /* Append ALTER TABLE statements here */
+ sqlite3_str *pUndo /* SQL to undo the change, if not NULL */
+){
+ sqlite3_stmt *pStmt;
+ int rc;
+ int cnt = 0;
+
+ rc = sqlite3_prepare_v2(db,
+ "SELECT name FROM pragma_table_info(?1);",
+ -1, &pStmt, 0);
+ if( rc ) return rc;
+ sqlite3_bind_text(pStmt, 1, zTab, -1, SQLITE_STATIC);
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ const char *zCol = (const char*)sqlite3_column_text(pStmt, 0);
+ cnt++;
+ sqlite3_str_appendf(pConvert,
+ "ALTER TABLE \"%w\" RENAME COLUMN \"%w\" TO \"%w%d\";\n",
+ zTab, zCol, zColPrefix, cnt
+ );
+ if( pUndo ){
+ sqlite3_str_appendf(pUndo,
+ "ALTER TABLE \"%w\" RENAME COLUMN \"%w%d\" TO \"%w\";\n",
+ zTab, zColPrefix, cnt, zCol
+ );
+ }
+ }
+ sqlite3_finalize(pStmt);
+ return SQLITE_OK;
+}
+
+/* Rename all tables and their columns in the main database
+*/
+int rename_all_tables(
+ sqlite3 *db, /* Database connection */
+ sqlite3_str *pConvert, /* Append SQL to do the rename here */
+ sqlite3_str *pUndo /* Append SQL to undo the rename here */
+){
+ sqlite3_stmt *pStmt;
+ int rc;
+ int cnt = 0;
+
+ rc = sqlite3_prepare_v2(db,
+ "SELECT name FROM sqlite_schema WHERE type='table'"
+ " AND name NOT LIKE 'sqlite_%';",
+ -1, &pStmt, 0);
+ if( rc ) return rc;
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ const char *zTab = (const char*)sqlite3_column_text(pStmt, 0);
+ char *zNewTab;
+ char zPrefix[2];
+
+ zPrefix[0] = (cnt%26) + 'a';
+ zPrefix[1] = 0;
+ zNewTab = sqlite3_mprintf("tx%d", ++cnt);
+ if( pUndo ){
+ sqlite3_str_appendf(pUndo,
+ "ALTER TABLE \"%s\" RENAME TO \"%w\";\n",
+ zNewTab, zTab
+ );
+ }
+ rename_all_columns_of_table(db, zTab, zPrefix, pConvert, pUndo);
+ sqlite3_str_appendf(pConvert,
+ "ALTER TABLE \"%w\" RENAME TO \"%s\";\n",
+ zTab, zNewTab
+ );
+ sqlite3_free(zNewTab);
+ }
+ sqlite3_finalize(pStmt);
+ return SQLITE_OK;
+}
+
+/*
+** Generate a script that does this:
+**
+** (1) Start a transaction
+** (2) Rename all tables and columns to use generic names.
+** (3) Print the schema after this rename
+** (4) Run pragma integrity_check
+** (5) Do more ALTER TABLE statements to change the names back
+** (6) Run pragma integrity_check again
+** (7) Rollback the transaction
+*/
+int main(int argc, char **argv){
+ sqlite3 *db;
+ int rc;
+ sqlite3_str *pConvert;
+ sqlite3_str *pUndo;
+ char *zDbName;
+ char *zSql1, *zSql2;
+ if( argc!=2 ){
+ fprintf(stderr, "Usage: %s DATABASE\n", argv[0]);
+ }
+ zDbName = argv[1];
+ rc = sqlite3_open(zDbName, &db);
+ if( rc ){
+ fprintf(stderr, "sqlite3_open() returns %d\n", rc);
+ return 1;
+ }
+ pConvert = sqlite3_str_new(db);
+ pUndo = sqlite3_str_new(db);
+ rename_all_tables(db, pConvert, pUndo);
+ zSql1 = sqlite3_str_finish(pConvert);
+ zSql2 = sqlite3_str_finish(pUndo);
+ sqlite3_close(db);
+ printf("BEGIN;\n");
+ printf("%s", zSql1);
+ sqlite3_free(zSql1);
+ printf(".schema --indent\n");
+ printf("PRAGMA integrity_check;\n");
+ printf("%s", zSql2);
+ sqlite3_free(zSql2);
+ printf("PRAGMA integrity_check;\n");
+ printf("ROLLBACK;\n");
+ return 0;
+}
diff --git a/test/attach.test b/test/attach.test
new file mode 100644
index 0000000..557201d
--- /dev/null
+++ b/test/attach.test
@@ -0,0 +1,928 @@
+# 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}
+
+# Tests for the sqlite3_db_filename interface
+#
+do_test attach-1.3.1 {
+ file tail [sqlite3_db_filename db main]
+} {test.db}
+do_test attach-1.3.2 {
+ file tail [sqlite3_db_filename db MAIN]
+} {test.db}
+do_test attach-1.3.3 {
+ file tail [sqlite3_db_filename db temp]
+} {}
+do_test attach-1.3.4 {
+ file tail [sqlite3_db_filename db two]
+} {test2.db}
+do_test attach-1.3.5 {
+ file tail [sqlite3_db_filename db three]
+} {}
+
+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_catchsql_test attach-1.15 {
+ 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_catchsql_test attach-1.17 {
+ 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 temp.sqlite_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
+ifcapable json1&&vtab {
+ do_test attach-5.10 {
+ db close
+ catch {db2 close}
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(a,b);
+ CREATE TRIGGER x1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2(a,b) SELECT key, value FROM json_each(NEW.x);
+ END;
+ INSERT INTO t1(x) VALUES('{"a":1}');
+ SELECT * FROM t2;
+ }
+ } {a 1}
+ do_test attach-5.11 {
+ sqlite3 db2 :memory:
+ db2 eval {
+ CREATE TABLE t3(y);
+ ATTACH 'test.db' AS aux;
+ INSERT INTO aux.t1(x) VALUES('{"b":2}');
+ SELECT * FROM aux.t2;
+ }
+ } {a 1 b 2}
+} ;# endif json1
+} ;# 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 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 {}}
+
+# Attach with a very long URI filename.
+#
+db close
+sqlite3 db test.db -uri 1
+do_execsql_test attach-11.1 {
+ ATTACH printf('file:%09000x/x.db?mode=memory&cache=shared',1) AS aux1;
+ CREATE TABLE aux1.t1(x,y);
+ INSERT INTO aux1.t1(x,y) VALUES(1,2),(3,4);
+ SELECT * FROM aux1.t1;
+} {1 2 3 4}
+
+# Ticket https://sqlite.org/src/tktview/a4e06e75a9ab61a1 2017-07-15
+# False positive when running integrity_check on a connection with
+# attached databases.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test attach-12.1 {
+ CREATE TABLE Table1 (col TEXT NOT NULL PRIMARY KEY);
+ ATTACH ':memory:' AS db2;
+ CREATE TABLE db2.Table2(col1 INTEGER, col2 INTEGER, col3 INTEGER, col4);
+ CREATE UNIQUE INDEX db2.idx_col1_unique ON Table2 (col1);
+ CREATE UNIQUE INDEX db2.idx_col23_unique ON Table2 (col2, col3);
+ CREATE INDEX db2.idx_col2 ON Table2 (col2);
+ INSERT INTO Table2 VALUES(1,2,3,4);
+ PRAGMA integrity_check;
+} {ok}
+
+# 2021-03-10 Forum post https://sqlite.org/forum/forumpost/a006d86f72
+#
+reset_db
+do_test attach-13.1 {
+ sqlite3 db :memory:
+ db eval {CREATE TABLE base(x);}
+ for {set i 0} {$i<$SQLITE_MAX_ATTACHED} {incr i} {
+ db eval "ATTACH ':memory:' AS a$i"
+ }
+ set m "a[expr {$SQLITE_MAX_ATTACHED-1}]"
+ db eval "CREATE TABLE $m.t1(a INTEGER PRIMARY KEY, b);"
+ db eval "CREATE TABLE $m.t2(a INTEGER PRIMARY KEY, b);"
+ db eval {SELECT a FROM t1 WHERE b IN (SELECT a FROM t2);}
+} {}
+
+finish_test
diff --git a/test/attach2.test b/test/attach2.test
new file mode 100644
index 0000000..eb87b60
--- /dev/null
+++ b/test/attach2.test
@@ -0,0 +1,391 @@
+# 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;
+ DETACH aux2;
+ }
+} {0 {}}
+
+# As of version 3.21.0: it is ok to DETACH from within a transaction
+#
+do_test attach2-6.3 {
+ catchsql {
+ DETACH aux;
+ }
+} {0 {}}
+
+db close
+
+finish_test
diff --git a/test/attach3.test b/test/attach3.test
new file mode 100644
index 0000000..1c8601c
--- /dev/null
+++ b/test/attach3.test
@@ -0,0 +1,353 @@
+# 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 temp.sqlite_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 temp.sqlite_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 {
+ 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..9d54e7d
--- /dev/null
+++ b/test/attach4.test
@@ -0,0 +1,137 @@
+# 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 }
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ ATTACH DATABASE '' AS aux;
+ CREATE TABLE IF NOT EXISTS aux.t1(a, b);
+ CREATE TEMPORARY TRIGGER tr1 DELETE ON t1 BEGIN
+ DELETE FROM t1;
+ END;
+ CREATE TABLE temp.t1(a, b);
+}
+
+do_execsql_test 2.1 {
+ DETACH DATABASE aux;
+}
+
+do_execsql_test 2.2 {
+ DROP TRIGGER tr1;
+}
+
+finish_test
diff --git a/test/attachmalloc.test b/test/attachmalloc.test
new file mode 100644
index 0000000..3c6a075
--- /dev/null
+++ b/test/attachmalloc.test
@@ -0,0 +1,78 @@
+# 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 !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;
+}
+
+ifcapable shared_cache {
+ 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..d8afa2d
--- /dev/null
+++ b/test/auth.test
@@ -0,0 +1,2663 @@
+# 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 authx {code arg1 arg2 arg3 arg4 args} {return SQLITE_DENY}
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ db authorizer ::authx
+ # EVIDENCE-OF: R-03993-24285 Only a single authorizer can be in place on
+ # a database connection at a time. Each call to sqlite3_set_authorizer
+ # overrides the previous call.
+ #
+ # The authx authorizer above is overridden by the auth authorizer below
+ # authx is never invoked.
+ 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}
+} {}
+# EVIDENCE-OF: R-04452-49349 When the callback returns SQLITE_DENY, the
+# sqlite3_prepare_v2() or equivalent call that triggered the authorizer
+# will fail with an error message explaining that access is denied.
+do_test auth-1.3.1 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+ } {}
+ do_test auth-1.7.1 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+ } {}
+ do_test auth-1.15 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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}
+}
+# EVIDENCE-OF: R-38392-49970 If the action code is SQLITE_READ and the
+# callback returns SQLITE_IGNORE then the prepared statement statement
+# is constructed to substitute a NULL value in place of the table column
+# that would have been read if SQLITE_OK had been returned.
+do_test auth-1.36 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+ } {t1}
+}
+
+do_test auth-1.91 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+ } {t1 v1}
+ do_test auth-1.114 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+ } {t1 v1}
+ do_test auth-1.122 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+} {t1}
+do_test auth-1.141 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+} {t1}
+do_test auth-1.146 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+} {t1 r1}
+
+do_test auth-1.151 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+} {t1 r1}
+do_test auth-1.166 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+} {t1 r1}
+do_test auth-1.171 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+} {t1}
+} ;# ifcapable trigger
+
+do_test auth-1.177 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+ } {t1}
+ do_test auth-1.195 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+ } {t1 i1}
+}
+
+do_test auth-1.203 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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.205a {
+ set ::authargs
+} {i2 t2 main {}}
+db eval {
+ ATTACH ':memory:' as di205;
+ CREATE TABLE di205.t1(x);
+ CREATE INDEX di205.t1x ON t1(x);
+}
+do_catchsql_test auth-1.205b {
+ DROP INDEX di205.t1x;
+} {1 {not authorized}}
+db eval {
+ DETACH di205;
+}
+do_test auth-1.206 {
+ set ::authargs
+} {t1x t1 di205 {}}
+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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_master}
+ } {t1 i1}
+ do_test auth-1.223 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 temp.sqlite_master}
+ } {t1 i1}
+ do_test auth-1.226 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 temp.sqlite_master}
+ } {t1}
+}
+
+do_test auth-1.229 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 {
+ # EVIDENCE-OF: R-52112-44167 Disable the authorizer by installing a NULL
+ # callback.
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 temp.sqlite_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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 [lrange $args 0 3]]
+ }
+ 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 [lrange $args 0 3]]
+ 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 [lrange $args 0 3]]
+ }
+ 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 args} {
+ 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 {} {}}
+ db eval BEGIN
+ set authargs {}
+ do_execsql_test auth-1.302-drop-1 {
+ ALTER TABLE t5 DROP COLUMN new_col_1;
+ } {}
+ db eval ROLLBACK
+ do_test auth-1.302-drop-2 {
+ set authargs
+ } {main t5 new_col_1 {}}
+ do_test auth-1.303 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 {} {}}
+ db eval BEGIN
+ set authargs {}
+ do_execsql_test auth-1.305-drop-1 {
+ ALTER TABLE t5 DROP COLUMN new_col_1;
+ SELECT 1 FROM sqlite_schema WHERE name='t5' AND sql LIKE '%new_col_1%';
+ } {1}
+ db eval ROLLBACK
+ do_test auth-1.305-drop-2 {
+ set authargs
+ } {main t5 new_col_1 {}}
+ do_test auth-1.306 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 temp.sqlite_master WHERE type='t5'}]
+ regexp new_col_3 $x
+ } {0}
+ do_test auth-1.308 {
+ set authargs
+ } {main t5 {} {}}
+ db eval BEGIN
+ set authargs {}
+ do_catchsql_test auth-1.308-drop-1 {
+ ALTER TABLE t5 DROP COLUMN new_col_1;
+ } {1 {not authorized}}
+ do_execsql_test auth-1.308-drop-2 {
+ SELECT 1 FROM sqlite_schema WHERE name='t5' AND sql LIKE '%new_col_1%';
+ } {1}
+ do_test auth-1.308-drop-3 {
+ set authargs
+ } {main t5 new_col_1 {}}
+ db eval ROLLBACK
+
+ execsql {DROP TABLE t5}
+} ;# ifcapable altertable
+
+ifcapable {cte} {
+ do_test auth-1.310 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ if {$code=="SQLITE_RECURSIVE"} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2),(3,4),(5,6);
+ }
+ } {}
+ do_catchsql_test auth-1.311 {
+ WITH
+ auth1311(x,y) AS (SELECT a+b, b-a FROM t1)
+ SELECT * FROM auth1311 ORDER BY x;
+ } {0 {3 1 7 1 11 1}}
+ do_catchsql_test auth-1.312 {
+ WITH RECURSIVE
+ auth1312(x,y) AS (SELECT a+b, b-a FROM t1)
+ SELECT x, y FROM auth1312 ORDER BY x;
+ } {0 {3 1 7 1 11 1}}
+ do_catchsql_test auth-1.313 {
+ WITH RECURSIVE
+ auth1313(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM auth1313 WHERE x<5)
+ SELECT * FROM t1;
+ } {0 {1 2 3 4 5 6}}
+ do_catchsql_test auth-1.314 {
+ WITH RECURSIVE
+ auth1314(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM auth1314 WHERE x<5)
+ SELECT * FROM t1 LEFT JOIN auth1314;
+ } {1 {not authorized}}
+} ;# ifcapable cte
+
+#
+# db eval {SELECT sql FROM temp.sqlite_master} {puts "TEMP: $sql;"}
+# db eval {SELECT sql FROM main.sqlite_master} {puts "MAIN: $sql;"}
+#
+# MAIN: CREATE TABLE "t2"(a,b,c);
+# MAIN: CREATE TABLE t4(a,b,c);
+# MAIN: CREATE INDEX t4i1 ON t4(a);
+# MAIN: CREATE INDEX t4i2 ON t4(b,a,c);
+# MAIN: CREATE TABLE sqlite_stat1(tbl,idx,stat);
+# MAIN: CREATE TABLE t1(a,b);
+#
+ifcapable altertable&&vtab {
+ do_test auth-1.350 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_OK
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t1 RENAME COLUMN b TO bcdefg;
+ }
+ } {0 {}}
+ do_execsql_test auth-1.351 {
+ SELECT name FROM pragma_table_info('t1') ORDER BY cid;
+ } {a bcdefg}
+ do_test auth-1.352 {
+ set authargs
+ } {main t1 {} {}}
+ do_test auth-1.353 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_IGNORE
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t1 RENAME COLUMN bcdefg TO b;
+ }
+ } {0 {}}
+ do_execsql_test auth-1.354 {
+ SELECT name FROM pragma_table_info('t1') ORDER BY cid;
+ } {a bcdefg}
+ do_test auth-1.355 {
+ set authargs
+ } {main t1 {} {}}
+ do_test auth-1.356 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ if {$code=="SQLITE_ALTER_TABLE"} {
+ set ::authargs [list $arg1 $arg2 $arg3 $arg4]
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ catchsql {
+ ALTER TABLE t1 RENAME COLUMN bcdefg TO b;
+ }
+ } {1 {not authorized}}
+ do_execsql_test auth-1.357 {
+ SELECT name FROM pragma_table_info('t1') ORDER BY cid;
+ } {a bcdefg}
+ do_test auth-1.358 {
+ set authargs
+ } {main t1 {} {}}
+}
+
+
+do_test auth-2.1 {
+ proc auth {code arg1 arg2 arg3 arg4 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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 args} {
+ 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_READ v1 x main v1 \
+ SQLITE_READ v1 x main v1 \
+ SQLITE_SELECT {} {} {} v1 \
+ 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_READ v1 x main v1 \
+ SQLITE_READ v1 x main v1 \
+ SQLITE_SELECT {} {} {} v1 \
+ 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 args} {
+ 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 stat4 {
+ set stat4 "sqlite_stat4 "
+ } else {
+ set stat4 ""
+ }
+ do_test auth-5.2 {
+ execsql {
+ SELECT name FROM (
+ SELECT * FROM sqlite_master UNION ALL SELECT * FROM temp.sqlite_master)
+ WHERE type='table'
+ ORDER BY name
+ }
+ } "sqlite_stat1 ${stat4}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 [lrange $args 0 4]
+ 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}
+}
+
+# Ticket [0eb70d77cb05bb22720]: Invalid pointer passsed to the authorizer
+# callback when updating a ROWID.
+#
+do_test auth-6.1 {
+ execsql {
+ CREATE TABLE t6(a,b,c,d,e,f,g,h);
+ INSERT INTO t6 VALUES(1,2,3,4,5,6,7,8);
+ }
+} {}
+set ::authargs [list]
+proc auth {args} {
+ eval lappend ::authargs [lrange $args 0 4]
+ return SQLITE_OK
+}
+do_test auth-6.2 {
+ execsql {UPDATE t6 SET rowID=rowID+100}
+ set ::authargs
+} [list SQLITE_READ t6 ROWID main {} \
+ SQLITE_UPDATE t6 ROWID main {} \
+]
+do_test auth-6.3 {
+ execsql {SELECT rowid, * FROM t6}
+} {101 1 2 3 4 5 6 7 8}
+
+#-------------------------------------------------------------------------
+# Test that view names are included as zArg4.
+#
+do_execsql_test auth-7.1 {
+ CREATE TABLE t7(a, b, c);
+ CREATE VIEW v7 AS SELECT * FROM t7;
+} {}
+set ::authargs [list]
+proc auth {args} {
+ eval lappend ::authargs [lrange $args 0 4]
+ return SQLITE_OK
+}
+
+do_test auth-7.2 {
+ execsql {SELECT a, c FROM v7}
+ set ::authargs
+} [list \
+ SQLITE_SELECT {} {} {} {} \
+ SQLITE_READ t7 a main v7 \
+ SQLITE_READ t7 b main v7 \
+ SQLITE_READ t7 c main v7 \
+ SQLITE_READ v7 a main {} \
+ SQLITE_READ v7 c main {} \
+ SQLITE_SELECT {} {} {} v7 \
+]
+
+set ::authargs [list]
+do_test auth-7.3 {
+ execsql {SELECT a, c FROM t7}
+ set ::authargs
+} [list \
+ SQLITE_SELECT {} {} {} {} \
+ SQLITE_READ t7 a main {} \
+ SQLITE_READ t7 c main {} \
+]
+
+set ::authargs [list]
+do_test auth-7.4 {
+ execsql {SELECT a, c FROM t7 AS v7}
+ set ::authargs
+} [list \
+ SQLITE_SELECT {} {} {} {} \
+ SQLITE_READ t7 a main {} \
+ SQLITE_READ t7 c main {} \
+]
+
+# If a table is referenced but no columns are read from the table,
+# that causes a single SQLITE_READ authorization with a NULL column
+# name.
+#
+# EVIDENCE-OF: R-31520-16302 When a table is referenced by a SELECT but
+# no column values are extracted from that table (for example in a query
+# like "SELECT count(*) FROM tab") then the SQLITE_READ authorizer
+# callback is invoked once for that table with a column name that is an
+# empty string.
+#
+set ::authargs [list]
+do_test auth-8.1 {
+ execsql {SELECT count(*) FROM t7}
+ set ::authargs
+} [list \
+ SQLITE_SELECT {} {} {} {} \
+ SQLITE_FUNCTION {} count {} {} \
+ SQLITE_READ t7 {} {} {} \
+ ]
+set ::authargs [list]
+
+do_test auth-8.2 {
+ execsql {SELECT t6.a FROM t6, t7}
+ set ::authargs
+} [list \
+ SQLITE_SELECT {} {} {} {} \
+ SQLITE_READ t6 a main {} \
+ SQLITE_READ t7 {} {} {} \
+ ]
+
+# Test also that if SQLITE_DENY is returned from an SQLITE_READ authorizer
+# invocation with no column name specified, compilation fails.
+#
+set ::authargs [list]
+proc auth {op args} {
+ foreach {a b c d} $args break
+ lappend ::authargs $op $a $b $c $d
+ if {$op == "SQLITE_READ"} { return "SQLITE_DENY" }
+ return "SQLITE_OK"
+}
+set ::authargs [list]
+do_catchsql_test auth-8.3 {
+ SELECT count(*) FROM t7
+} {1 {not authorized}}
+do_test auth-8.4 {
+ set ::authargs
+} [list \
+ SQLITE_SELECT {} {} {} {} \
+ SQLITE_FUNCTION {} count {} {} \
+ SQLITE_READ t7 {} {} {} \
+]
+
+
+rename proc {}
+rename proc_real proc
+finish_test
diff --git a/test/auth2.test b/test/auth2.test
new file mode 100644
index 0000000..08d46ca
--- /dev/null
+++ b/test/auth2.test
@@ -0,0 +1,160 @@
+# 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 args} {
+ 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 [lrange $args 0 4]\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 {}
+}
+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 {}
+}
+do_test auth2-2.3 {
+ set ::authargs {}
+ db eval {
+ SELECT a, b FROM v2;
+ }
+ set ::authargs
+} {SQLITE_SELECT {} {} {} {}
+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_READ v2 a main {}
+SQLITE_READ v2 b main {}
+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 t2 x main v2
+SQLITE_READ t2 y main v2
+SQLITE_READ t2 y main v2
+SQLITE_READ t2 z main v2
+SQLITE_READ v2 b main {}
+SQLITE_READ v2 a main {}
+SQLITE_SELECT {} {} {} v2
+SQLITE_SELECT {} {} {} {}
+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_READ v2 b main {}
+SQLITE_READ v2 a main {}
+SQLITE_SELECT {} {} {} v2
+}
+db2 close
+
+finish_test
diff --git a/test/auth3.test b/test/auth3.test
new file mode 100644
index 0000000..abc9734
--- /dev/null
+++ b/test/auth3.test
@@ -0,0 +1,134 @@
+# 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.
+#
+# Test that authorizer is disabled during schema parsing.
+
+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 args} {
+ 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}}
+# EVIDENCE-OF: R-64962-58611 If the authorizer callback returns any
+# value other than SQLITE_IGNORE, SQLITE_OK, or SQLITE_DENY then the
+# sqlite3_prepare_v2() or equivalent call that triggered the authorizer
+# will fail with an error message.
+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}
+
+# 2016-07-28. A problem report from a private client complaining about
+# an authorizer failure during an ALTER TABLE. The solution (I think) is
+# to disable the authorizer during schema parsing.
+#
+ifcapable altertable {
+ proc auth {code args} {
+ if {$code=="SQLITE_READ" && [regexp {DoNotRead} $args]} {
+ return SQLITE_DENY
+ }
+ return SQLITE_OK
+ }
+ do_execsql_test auth3-3.0 {
+ CREATE TEMPORARY TABLE TempTable (
+ key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE,
+ value TEXT NOT NULL ON CONFLICT FAIL);
+ ALTER TABLE TempTable RENAME TO DoNotRead;
+ SELECT name FROM temp.sqlite_master;
+ } {DoNotRead sqlite_autoindex_DoNotRead_1}
+}
+
+finish_test
diff --git a/test/autoanalyze1.test b/test/autoanalyze1.test
new file mode 100644
index 0000000..71e5d6c
--- /dev/null
+++ b/test/autoanalyze1.test
@@ -0,0 +1,123 @@
+# 2017-02-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 tests for the logic used to estimate when
+# running ANALYZE would be beneficial.
+#
+# Note that this test uses some hard-coded bitmask values from sqliteInt.h.
+# If any of the following constants changes:
+#
+# define TF_HasStat1 0x0010
+# define TF_StatsUsed 0x0100
+#
+# then some of the magic numbers in test results below might need to be
+# adjusted.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# There is nothing to test if ANALYZE is disable for this build.
+# These tests also use "PRAGMA stats" which are only enabled for
+# debugging builds.
+#
+ifcapable {!debug || !analyze || !vtab} {
+ finish_test
+ return
+}
+
+do_execsql_test autoanalyze1-100 {
+ -- Build up a test table with some indexes
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);
+ CREATE UNIQUE INDEX t1bc ON t1(b,c);
+ CREATE INDEX t1d ON t1(d);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c,d) SELECT x, x, x, x FROM c;
+ -- Verify that the hasStat1 flag is clear on on indexes
+ SELECT idx, flgs FROM pragma_stats
+ WHERE idx IS NOT NULL
+ ORDER BY idx;
+ -- Verify that the TF_HasStat1 flag is clear on the table
+ SELECT tbl, (flgs & 0x10)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {t1bc 0 t1d 0 t1 0}
+
+# No use of stat1 recorded so far
+do_execsql_test autoanalyze1-110 {
+ SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {0}
+
+# Access using a unique index does not set the TF_StatsUsed flag.
+#
+do_execsql_test autoanalyze1-200 {
+ SELECT * FROM t1 WHERE a=55;
+} {55 55 55 55}
+do_execsql_test autoanalyze1-201 {
+ SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {0}
+
+do_execsql_test autoanalyze1-210 {
+ SELECT * FROM t1 WHERE a IN (55,199,299);
+} {55 55 55 55}
+do_execsql_test autoanalyze1-211 {
+ SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {0}
+
+do_execsql_test autoanalyze1-220 {
+ SELECT * FROM t1 WHERE (b,c)=(45,45);
+} {45 45 45 45}
+do_execsql_test autoanalyze1-221 {
+ SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {0}
+
+# Any use of the non-unique t1d index triggers the use of stats.
+#
+sqlite3 db test.db
+do_execsql_test autoanalyze1-300 {
+ SELECT * FROM t1 WHERE d=45;
+} {45 45 45 45}
+do_execsql_test autoanalyze1-301 {
+ SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {1}
+
+sqlite3 db test.db
+do_execsql_test autoanalyze1-310 {
+ SELECT * FROM t1 WHERE d=45 AND a=45;
+} {45 45 45 45}
+do_execsql_test autoanalyze1-311 {
+ SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {0} ;# The ROWID lookup short-circuits the d=45 constraint
+
+sqlite3 db test.db
+do_execsql_test autoanalyze1-320 {
+ SELECT * FROM t1 WHERE d=45 AND a IN (45,46);
+} {45 45 45 45}
+do_execsql_test autoanalyze1-321 {
+ SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {1}
+
+# Any use of prefix of a unique index triggers the use of stats
+#
+sqlite3 db test.db
+do_execsql_test autoanalyze1-400 {
+ SELECT * FROM t1 WHERE b=45;
+} {45 45 45 45}
+do_execsql_test autoanalyze1-401 {
+ SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {1}
+
+# The TF_StatsUsed flag is reset when the database is reopened
+#
+sqlite3 db test.db
+do_execsql_test autoanalyze1-500 {
+ SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;
+} {0}
+
+finish_test
diff --git a/test/autoinc.test b/test/autoinc.test
new file mode 100644
index 0000000..2c7ee2a
--- /dev/null
+++ b/test/autoinc.test
@@ -0,0 +1,883 @@
+# 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
+set testprefix autoinc
+
+# If the library is not compiled with autoincrement support then
+# skip all tests in this file.
+#
+ifcapable {!autoinc} {
+ finish_test
+ return
+}
+
+if {[permutation]=="inmemory_journal"} {
+ 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 temp.sqlite_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}
+}
+
+# 2016-10-03 ticket https://www.sqlite.org/src/tktview/7b3328086a5c1
+# Make sure autoincrement plays nicely with the xfer optimization
+#
+do_execsql_test autoinc-10.1 {
+ DELETE FROM sqlite_sequence;
+ CREATE TABLE t10a(a INTEGER PRIMARY KEY AUTOINCREMENT, b UNIQUE);
+ INSERT INTO t10a VALUES(888,9999);
+ CREATE TABLE t10b(x INTEGER PRIMARY KEY AUTOINCREMENT, y UNIQUE);
+ INSERT INTO t10b SELECT * FROM t10a;
+ SELECT * FROM sqlite_sequence;
+} {t10a 888 t10b 888}
+
+# 2018-04-21 autoincrement does not cause problems for upsert
+#
+do_execsql_test autoinc-11.1 {
+ CREATE TABLE t11(a INTEGER PRIMARY KEY AUTOINCREMENT,b UNIQUE);
+ INSERT INTO t11(a,b) VALUES(2,3),(5,6),(4,3),(1,2)
+ ON CONFLICT(b) DO UPDATE SET a=a+1000;
+ SELECT seq FROM sqlite_sequence WHERE name='t11';
+} {5}
+
+# 2018-05-23 ticket d8dc2b3a58cd5dc2918a1d4acbba4676a23ada4c
+# Does not crash if the sqlite_sequence table schema is missing
+# or corrupt.
+#
+do_test autoinc-12.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config db DEFENSIVE 0
+ db eval {
+ CREATE TABLE fake_sequence(name TEXT PRIMARY KEY,seq) WITHOUT ROWID;
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET
+ sql=replace(sql,'fake_','sqlite_'),
+ name='sqlite_sequence',
+ tbl_name='sqlite_sequence'
+ WHERE name='fake_sequence';
+ }
+ db close
+ sqlite3 db test.db
+ set res [catch {db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT);
+ INSERT INTO t1(b) VALUES('one');
+ }} msg]
+ lappend res $msg
+} {1 {database disk image is malformed}}
+do_test autoinc-12.2 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config db DEFENSIVE 0
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT);
+ INSERT INTO t1(b) VALUES('one');
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET
+ sql=replace(sql,'sqlite_','x_'),
+ name='x_sequence',
+ tbl_name='x_sequence'
+ WHERE name='sqlite_sequence';
+ }
+ db close
+ sqlite3 db test.db
+ set res [catch {db eval {
+ INSERT INTO t1(b) VALUES('two');
+ }} msg]
+ lappend res $msg
+} {1 {database disk image is malformed}}
+ifcapable vtab {
+ set err "database disk image is malformed"
+} else {
+ set err {malformed database schema (sqlite_sequence) - near "VIRTUAL": syntax error}
+}
+do_test autoinc-12.3 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config db DEFENSIVE 0
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT);
+ INSERT INTO t1(b) VALUES('one');
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET
+ sql='CREATE VIRTUAL TABLE sqlite_sequence USING sqlite_dbpage'
+ WHERE name='sqlite_sequence';
+ }
+ db close
+ sqlite3 db test.db
+ set res [catch {db eval {
+ INSERT INTO t1(b) VALUES('two');
+ }} msg]
+ lappend res $msg
+} [list 1 $err]
+do_test autoinc-12.4 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT);
+ INSERT INTO t1(b) VALUES('one');
+ CREATE TABLE fake(name TEXT PRIMARY KEY,seq) WITHOUT ROWID;
+ }
+ set root1 [db one {SELECT rootpage FROM sqlite_master
+ WHERE name='sqlite_sequence'}]
+ set root2 [db one {SELECT rootpage FROM sqlite_master
+ WHERE name='fake'}]
+ sqlite3_db_config db DEFENSIVE 0
+ db eval {
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET rootpage=$root2
+ WHERE name='sqlite_sequence';
+ UPDATE sqlite_master SET rootpage=$root1
+ WHERE name='fake';
+ }
+ db close
+ sqlite3 db test.db
+ set res [catch {db eval {
+ INSERT INTO t1(b) VALUES('two');
+ }} msg]
+ lappend res $msg
+} {1 {database disk image is malformed}}
+breakpoint
+do_test autoinc-12.5 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config db DEFENSIVE 0
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT);
+ INSERT INTO t1(b) VALUES('one');
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET
+ sql='CREATE TABLE sqlite_sequence(x)'
+ WHERE name='sqlite_sequence';
+ }
+ db close
+ sqlite3 db test.db
+ set res [catch {db eval {
+ INSERT INTO t1(b) VALUES('two');
+ }} msg]
+ lappend res $msg
+} {1 {database disk image is malformed}}
+do_test autoinc-12.6 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config db DEFENSIVE 0
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT);
+ INSERT INTO t1(b) VALUES('one');
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET
+ sql='CREATE TABLE sqlite_sequence(x,y INTEGER PRIMARY KEY)'
+ WHERE name='sqlite_sequence';
+ }
+ db close
+ sqlite3 db test.db
+ set res [catch {db eval {
+ INSERT INTO t1(b) VALUES('two'),('three'),('four');
+ INSERT INTO t1(b) VALUES('five');
+ PRAGMA integrity_check;
+ }} msg]
+ lappend res $msg
+} {0 ok}
+do_test autoinc-12.7 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config db DEFENSIVE 0
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT);
+ INSERT INTO t1(b) VALUES('one');
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET
+ sql='CREATE TABLE sqlite_sequence(y INTEGER PRIMARY KEY,x)'
+ WHERE name='sqlite_sequence';
+ }
+ db close
+ sqlite3 db test.db
+ set res [catch {db eval {
+ INSERT INTO t1(b) VALUES('two'),('three'),('four');
+ INSERT INTO t1(b) VALUES('five');
+ PRAGMA integrity_check;
+ }} msg]
+ lappend res $msg
+} {0 ok}
+
+#--------------------------------------------------------------------------
+reset_db
+do_execsql_test 13.0 {
+ CREATE TABLE t1(i INTEGER PRIMARY KEY AUTOINCREMENT, j);
+ CREATE TABLE t2(i INTEGER PRIMARY KEY AUTOINCREMENT, j);
+ CREATE TABLE t3(i INTEGER PRIMARY KEY AUTOINCREMENT, j);
+
+ INSERT INTO t1 VALUES(NULL, 1);
+ INSERT INTO t2 VALUES(NULL, 2);
+ INSERT INTO t3 VALUES(NULL, 3);
+
+ SELECT name FROM sqlite_sequence;
+} {t1 t2 t3}
+
+do_execsql_test 13.1 {
+ UPDATE sqlite_sequence SET name=NULL WHERE name='t2';
+ INSERT INTO t3 VALUES(NULL, 4);
+ DELETE FROM t3;
+ INSERT INTO t3 VALUES(NULL, 5);
+ SELECT * FROM t3;
+} {3 5}
+
+
+finish_test
diff --git a/test/autoindex1.test b/test/autoindex1.test
new file mode 100644
index 0000000..4b290c7
--- /dev/null
+++ b/test/autoindex1.test
@@ -0,0 +1,564 @@
+# 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.
+#
+# EVIDENCE-OF: R-34271-33106 PRAGMA automatic_index; PRAGMA
+# automatic_index = boolean; Query, set, or clear the automatic indexing
+# capability.
+
+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
+}
+
+# Setup for logging
+db close
+sqlite3_shutdown
+test_sqlite3_log [list lappend ::log]
+set ::log [list]
+sqlite3 db test.db
+
+
+# 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}
+do_test autoindex1-113 {
+ set ::log
+} {SQLITE_WARNING_AUTOINDEX {automatic index on t2(c)}}
+
+db close
+sqlite3_shutdown
+test_sqlite3_log
+sqlite3_initialize
+sqlite3 db test.db
+
+# 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;
+ ANALYZE;
+ UPDATE sqlite_stat1 SET stat='10000' WHERE tbl='t1';
+ -- Table t2 actually contains 8 rows.
+ UPDATE sqlite_stat1 SET stat='16' WHERE tbl='t2';
+ ANALYZE sqlite_master;
+ 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_execsql_test autoindex1-299 {
+ UPDATE sqlite_stat1 SET stat='10000' WHERE tbl='t2';
+ ANALYZE sqlite_master;
+ EXPLAIN QUERY PLAN
+ SELECT b, d FROM t1 CROSS JOIN t2 ON (c=a);
+} {/AUTOMATIC COVERING INDEX/}
+do_test autoindex1-300 {
+ set r {}
+ db eval {SELECT b, d FROM t1 CROSS 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);
+ INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t501',null,'1000000');
+ INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t502',null,'1000');
+ ANALYZE sqlite_master;
+}
+do_eqp_test autoindex1-500.1 {
+ SELECT b FROM t501
+ WHERE t501.a IN (SELECT x FROM t502 WHERE y=?);
+} {
+ QUERY PLAN
+ |--SEARCH t501 USING INTEGER PRIMARY KEY (rowid=?)
+ `--LIST SUBQUERY xxxxxx
+ `--SCAN t502
+}
+do_eqp_test autoindex1-501 {
+ SELECT b FROM t501
+ WHERE t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
+} {
+ QUERY PLAN
+ |--SCAN t501
+ `--CORRELATED LIST SUBQUERY xxxxxx
+ `--SEARCH t502 USING AUTOMATIC COVERING INDEX (y=?)
+}
+do_eqp_test autoindex1-502 {
+ SELECT b FROM t501
+ WHERE t501.a=123
+ AND t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
+} {
+ QUERY PLAN
+ |--SEARCH t501 USING INTEGER PRIMARY KEY (rowid=?)
+ `--CORRELATED LIST SUBQUERY xxxxxx
+ `--SCAN t502
+}
+
+# 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);
+}
+do_eqp_test autoindex1-600a {
+ 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;
+} {
+ QUERY PLAN
+ |--MATERIALIZE y
+ | |--SCAN s
+ | |--SEARCH prev USING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date<?)
+ | `--CORRELATED SCALAR SUBQUERY xxxxxx
+ | `--SEARCH later USING COVERING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date>? AND owner_change_date<?)
+ |--SCAN x USING INDEX sheep_reg_flock_index
+ `--SEARCH y USING AUTOMATIC COVERING INDEX (sheep_no=?) LEFT-JOIN
+}
+
+
+do_execsql_test autoindex1-700 {
+ CREATE TABLE t5(a, b, c);
+}
+do_eqp_test autoindex1-700a {
+ SELECT a FROM t5 WHERE b=10 ORDER BY c;
+} {
+ QUERY PLAN
+ |--SCAN t5
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+# The following checks a performance issue reported on the sqlite-dev
+# mailing list on 2013-01-10
+#
+do_execsql_test autoindex1-800 {
+ CREATE TABLE accounts(
+ _id INTEGER PRIMARY KEY AUTOINCREMENT,
+ account_name TEXT,
+ account_type TEXT,
+ data_set TEXT
+ );
+ CREATE TABLE data(
+ _id INTEGER PRIMARY KEY AUTOINCREMENT,
+ package_id INTEGER REFERENCES package(_id),
+ mimetype_id INTEGER REFERENCES mimetype(_id) NOT NULL,
+ raw_contact_id INTEGER REFERENCES raw_contacts(_id) NOT NULL,
+ is_read_only INTEGER NOT NULL DEFAULT 0,
+ is_primary INTEGER NOT NULL DEFAULT 0,
+ is_super_primary INTEGER NOT NULL DEFAULT 0,
+ data_version INTEGER NOT NULL DEFAULT 0,
+ data1 TEXT,
+ data2 TEXT,
+ data3 TEXT,
+ data4 TEXT,
+ data5 TEXT,
+ data6 TEXT,
+ data7 TEXT,
+ data8 TEXT,
+ data9 TEXT,
+ data10 TEXT,
+ data11 TEXT,
+ data12 TEXT,
+ data13 TEXT,
+ data14 TEXT,
+ data15 TEXT,
+ data_sync1 TEXT,
+ data_sync2 TEXT,
+ data_sync3 TEXT,
+ data_sync4 TEXT
+ );
+ CREATE TABLE mimetypes(
+ _id INTEGER PRIMARY KEY AUTOINCREMENT,
+ mimetype TEXT NOT NULL
+ );
+ CREATE TABLE raw_contacts(
+ _id INTEGER PRIMARY KEY AUTOINCREMENT,
+ account_id INTEGER REFERENCES accounts(_id),
+ sourceid TEXT,
+ raw_contact_is_read_only INTEGER NOT NULL DEFAULT 0,
+ version INTEGER NOT NULL DEFAULT 1,
+ dirty INTEGER NOT NULL DEFAULT 0,
+ deleted INTEGER NOT NULL DEFAULT 0,
+ contact_id INTEGER REFERENCES contacts(_id),
+ aggregation_mode INTEGER NOT NULL DEFAULT 0,
+ aggregation_needed INTEGER NOT NULL DEFAULT 1,
+ custom_ringtone TEXT,
+ send_to_voicemail INTEGER NOT NULL DEFAULT 0,
+ times_contacted INTEGER NOT NULL DEFAULT 0,
+ last_time_contacted INTEGER,
+ starred INTEGER NOT NULL DEFAULT 0,
+ display_name TEXT,
+ display_name_alt TEXT,
+ display_name_source INTEGER NOT NULL DEFAULT 0,
+ phonetic_name TEXT,
+ phonetic_name_style TEXT,
+ sort_key TEXT,
+ sort_key_alt TEXT,
+ name_verified INTEGER NOT NULL DEFAULT 0,
+ sync1 TEXT,
+ sync2 TEXT,
+ sync3 TEXT,
+ sync4 TEXT,
+ sync_uid TEXT,
+ sync_version INTEGER NOT NULL DEFAULT 1,
+ has_calendar_event INTEGER NOT NULL DEFAULT 0,
+ modified_time INTEGER,
+ is_restricted INTEGER DEFAULT 0,
+ yp_source TEXT,
+ method_selected INTEGER DEFAULT 0,
+ custom_vibration_type INTEGER DEFAULT 0,
+ custom_ringtone_path TEXT,
+ message_notification TEXT,
+ message_notification_path TEXT
+ );
+ CREATE INDEX data_mimetype_data1_index ON data (mimetype_id,data1);
+ CREATE INDEX data_raw_contact_id ON data (raw_contact_id);
+ CREATE UNIQUE INDEX mime_type ON mimetypes (mimetype);
+ CREATE INDEX raw_contact_sort_key1_index ON raw_contacts (sort_key);
+ CREATE INDEX raw_contact_sort_key2_index ON raw_contacts (sort_key_alt);
+ CREATE INDEX raw_contacts_contact_id_index ON raw_contacts (contact_id);
+ CREATE INDEX raw_contacts_source_id_account_id_index
+ ON raw_contacts (sourceid, account_id);
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1
+ VALUES('raw_contacts','raw_contact_sort_key2_index','1600 4');
+ INSERT INTO sqlite_stat1
+ VALUES('raw_contacts','raw_contact_sort_key1_index','1600 4');
+ INSERT INTO sqlite_stat1
+ VALUES('raw_contacts','raw_contacts_source_id_account_id_index',
+ '1600 1600 1600');
+ INSERT INTO sqlite_stat1
+ VALUES('raw_contacts','raw_contacts_contact_id_index','1600 1');
+ INSERT INTO sqlite_stat1 VALUES('mimetypes','mime_type','12 1');
+ INSERT INTO sqlite_stat1
+ VALUES('data','data_mimetype_data1_index','9819 2455 3');
+ INSERT INTO sqlite_stat1 VALUES('data','data_raw_contact_id','9819 7');
+ INSERT INTO sqlite_stat1 VALUES('accounts',NULL,'1');
+ DROP TABLE IF EXISTS sqlite_stat3;
+ ANALYZE sqlite_master;
+
+ EXPLAIN QUERY PLAN
+ SELECT * FROM
+ data JOIN mimetypes ON (data.mimetype_id=mimetypes._id)
+ JOIN raw_contacts ON (data.raw_contact_id=raw_contacts._id)
+ JOIN accounts ON (raw_contacts.account_id=accounts._id)
+ WHERE mimetype_id=10 AND data14 IS NOT NULL;
+} {/SEARCH data .*SEARCH raw_contacts/}
+do_execsql_test autoindex1-801 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM
+ data JOIN mimetypes ON (data.mimetype_id=mimetypes._id)
+ JOIN raw_contacts ON (data.raw_contact_id=raw_contacts._id)
+ JOIN accounts ON (raw_contacts.account_id=accounts._id)
+ WHERE mimetypes._id=10 AND data14 IS NOT NULL;
+} {/SEARCH data .*SEARCH raw_contacts/}
+
+# Another test case from an important user of SQLite. The key feature of
+# this test is that the "aggindex" subquery should make use of an
+# automatic index. If it does, the query is fast. If it does not, the
+# query is deathly slow. It worked OK in 3.7.17 but started going slow
+# with version 3.8.0. The problem was fixed for 3.8.7 by reducing the
+# cost estimate for automatic indexes on views and subqueries.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test autoindex1-900 {
+ CREATE TABLE messages (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, message_id, document_id BLOB, in_reply_to, remote_id INTEGER, sender INTEGER, subject_prefix, subject INTEGER, date_sent INTEGER, date_received INTEGER, date_created INTEGER, date_last_viewed INTEGER, mailbox INTEGER, remote_mailbox INTEGER, original_mailbox INTEGER, flags INTEGER, read, flagged, size INTEGER, color, encoding, type INTEGER, pad, conversation_id INTEGER DEFAULT -1, snippet TEXT DEFAULT NULL, fuzzy_ancestor INTEGER DEFAULT NULL, automated_conversation INTEGER DEFAULT 0, root_status INTEGER DEFAULT -1, conversation_position INTEGER DEFAULT -1);
+ CREATE INDEX date_index ON messages(date_received);
+ CREATE INDEX date_last_viewed_index ON messages(date_last_viewed);
+ CREATE INDEX date_created_index ON messages(date_created);
+ CREATE INDEX message_message_id_mailbox_index ON messages(message_id, mailbox);
+ CREATE INDEX message_document_id_index ON messages(document_id);
+ CREATE INDEX message_read_index ON messages(read);
+ CREATE INDEX message_flagged_index ON messages(flagged);
+ CREATE INDEX message_mailbox_index ON messages(mailbox, date_received);
+ CREATE INDEX message_remote_mailbox_index ON messages(remote_mailbox, remote_id);
+ CREATE INDEX message_type_index ON messages(type);
+ CREATE INDEX message_conversation_id_conversation_position_index ON messages(conversation_id, conversation_position);
+ CREATE INDEX message_fuzzy_ancestor_index ON messages(fuzzy_ancestor);
+ CREATE INDEX message_subject_fuzzy_ancestor_index ON messages(subject, fuzzy_ancestor);
+ CREATE INDEX message_sender_subject_automated_conversation_index ON messages(sender, subject, automated_conversation);
+ CREATE INDEX message_sender_index ON messages(sender);
+ CREATE INDEX message_root_status ON messages(root_status);
+ CREATE TABLE subjects (ROWID INTEGER PRIMARY KEY, subject COLLATE RTRIM, normalized_subject COLLATE RTRIM);
+ CREATE INDEX subject_subject_index ON subjects(subject);
+ CREATE INDEX subject_normalized_subject_index ON subjects(normalized_subject);
+ CREATE TABLE addresses (ROWID INTEGER PRIMARY KEY, address COLLATE NOCASE, comment, UNIQUE(address, comment));
+ CREATE INDEX addresses_address_index ON addresses(address);
+ CREATE TABLE mailboxes (ROWID INTEGER PRIMARY KEY, url UNIQUE, total_count INTEGER DEFAULT 0, unread_count INTEGER DEFAULT 0, unseen_count INTEGER DEFAULT 0, deleted_count INTEGER DEFAULT 0, unread_count_adjusted_for_duplicates INTEGER DEFAULT 0, change_identifier, source INTEGER, alleged_change_identifier);
+ CREATE INDEX mailboxes_source_index ON mailboxes(source);
+ CREATE TABLE labels (ROWID INTEGER PRIMARY KEY, message_id INTEGER NOT NULL, mailbox_id INTEGER NOT NULL, UNIQUE(message_id, mailbox_id));
+ CREATE INDEX labels_message_id_mailbox_id_index ON labels(message_id, mailbox_id);
+ CREATE INDEX labels_mailbox_id_index ON labels(mailbox_id);
+
+ explain query plan
+ SELECT messages.ROWID,
+ messages.message_id,
+ messages.remote_id,
+ messages.date_received,
+ messages.date_sent,
+ messages.flags,
+ messages.size,
+ messages.color,
+ messages.date_last_viewed,
+ messages.subject_prefix,
+ subjects.subject,
+ sender.comment,
+ sender.address,
+ NULL,
+ messages.mailbox,
+ messages.original_mailbox,
+ NULL,
+ NULL,
+ messages.type,
+ messages.document_id,
+ sender,
+ NULL,
+ messages.conversation_id,
+ messages.conversation_position,
+ agglabels.labels
+ FROM mailboxes AS mailbox
+ JOIN messages ON mailbox.ROWID = messages.mailbox
+ LEFT OUTER JOIN subjects ON messages.subject = subjects.ROWID
+ LEFT OUTER JOIN addresses AS sender ON messages.sender = sender.ROWID
+ LEFT OUTER JOIN (
+ SELECT message_id, group_concat(mailbox_id) as labels
+ FROM labels GROUP BY message_id
+ ) AS agglabels ON messages.ROWID = agglabels.message_id
+ WHERE (mailbox.url = 'imap://email.app@imap.gmail.com/%5BGmail%5D/All%20Mail')
+ AND (messages.ROWID IN (
+ SELECT labels.message_id
+ FROM labels JOIN mailboxes ON labels.mailbox_id = mailboxes.ROWID
+ WHERE mailboxes.url = 'imap://email.app@imap.gmail.com/INBOX'))
+ AND messages.mailbox in (6,12,18,24,30,36,42,1,7,13,19,25,31,37,43,2,8,
+ 14,20,26,32,38,3,9,15,21,27,33,39,4,10,16,22,28,
+ 34,40,5,11,17,23,35,41)
+ ORDER BY date_received DESC;
+} {/agglabels USING AUTOMATIC COVERING INDEX/}
+
+# A test case for VIEWs
+#
+do_execsql_test autoindex1-901 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);
+ CREATE TABLE t2(a, b);
+ CREATE VIEW agg2 AS SELECT a, sum(b) AS m FROM t2 GROUP BY a;
+ EXPLAIN QUERY PLAN
+ SELECT t1.z, agg2.m
+ FROM t1 JOIN agg2 ON t1.y=agg2.m
+ WHERE t1.x IN (1,2,3);
+} {/USING AUTOMATIC COVERING INDEX/}
+
+# 2015-04-15: A NULL CollSeq pointer in automatic index creation.
+#
+do_execsql_test autoindex1-920 {
+ CREATE TABLE t920(x);
+ INSERT INTO t920 VALUES(3),(4),(5);
+ SELECT * FROM t920,(SELECT 0 FROM t920),(VALUES(9)) WHERE 5 IN (x);
+} {5 0 9 5 0 9 5 0 9}
+
+#-------------------------------------------------------------------------
+# An IS term from the WHERE clause of a LEFT JOIN cannot be used as an
+# index driver for the RHS of a LEFT JOIN. Prior to this being fixed,
+# the following SELECT count(*) would incorrectly return 1.
+#
+do_execsql_test autoindex1-1010 {
+ CREATE TABLE t11(w);
+ CREATE TABLE t12(y);
+ INSERT INTO t11 VALUES(NULL);
+ INSERT INTO t12 VALUES('notnull');
+}
+do_execsql_test autoindex1-1020 {
+ SELECT count(*) FROM t11 LEFT JOIN t12 WHERE t12.y IS t11.w;
+} 0
+
+# 2022-04-25
+# https://sqlite.org/forum/forumpost/0d3200f4f3bcd3a3
+#
+reset_db
+do_execsql_test autoindex-1100 {
+ CREATE TABLE t1(a INT, b INT);
+ CREATE TABLE t2(c INT, d INT);
+ CREATE TABLE t3(e TEXT, f TEXT);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t2 VALUES(1, 2);
+ INSERT INTO t3 VALUES('abc', 'def');
+} {}
+do_execsql_test autoindex-1110 {
+ SELECT * FROM t1, t2 LEFT JOIN t3 ON (t2.d=1) WHERE t2.c = +t1.a;
+} {1 1 1 2 {} {}}
+do_execsql_test autoindex-1120 {
+ SELECT * FROM t1 LEFT JOIN t2 ON (t2.c=+t1.a) LEFT JOIN t3 ON (t2.d IS NULL);
+} {1 1 1 2 {} {}}
+
+finish_test
diff --git a/test/autoindex2.test b/test/autoindex2.test
new file mode 100644
index 0000000..afd4a66
--- /dev/null
+++ b/test/autoindex2.test
@@ -0,0 +1,232 @@
+# 2014-06-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 automatic index creation logic.
+#
+# This file contains a single real-world test case that was giving
+# suboptimal performance because of over-use of automatic indexes.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+do_execsql_test autoindex2-100 {
+ CREATE TABLE t1(
+ t1_id largeint,
+ did char(9),
+ ptime largeint,
+ exbyte char(4),
+ pe_id int,
+ field_id int,
+ mass float,
+ param10 float,
+ param11 float,
+ exmass float,
+ deviation float,
+ trange float,
+ vstatus int,
+ commit_status int,
+ formula char(329),
+ tier int DEFAULT 2,
+ ssid int DEFAULT 0,
+ last_operation largeint DEFAULT 0,
+ admin_uuid int DEFAULT 0,
+ previous_value float,
+ job_id largeint,
+ last_t1 largeint DEFAULT 0,
+ data_t1 int,
+ previous_date largeint DEFAULT 0,
+ flg8 int DEFAULT 1,
+ failed_fields char(100)
+ );
+ CREATE INDEX t1x0 on t1 (t1_id);
+ CREATE INDEX t1x1 on t1 (ptime, vstatus);
+ CREATE INDEX t1x2 on t1 (did, ssid, ptime, vstatus, exbyte, t1_id);
+ CREATE INDEX t1x3 on t1 (job_id);
+
+ CREATE TABLE t2(
+ did char(9),
+ client_did char(30),
+ description char(49),
+ uid int,
+ tzid int,
+ privilege int,
+ param2 int,
+ type char(30),
+ subtype char(32),
+ dparam1 char(7) DEFAULT '',
+ param5 char(3) DEFAULT '',
+ notional float DEFAULT 0.000000,
+ create_time largeint,
+ sample_time largeint DEFAULT 0,
+ param6 largeint,
+ frequency int,
+ expiration largeint,
+ uw_status int,
+ next_sample largeint,
+ last_sample largeint,
+ reserve1 char(29) DEFAULT '',
+ reserve2 char(29) DEFAULT '',
+ reserve3 char(29) DEFAULT '',
+ bxcdr char(19) DEFAULT 'XY',
+ ssid int DEFAULT 1,
+ last_t1_id largeint,
+ reserve4 char(29) DEFAULT '',
+ reserve5 char(29) DEFAULT '',
+ param12 int DEFAULT 0,
+ long_did char(100) DEFAULT '',
+ gr_code int DEFAULT 0,
+ drx char(100) DEFAULT '',
+ parent_id char(9) DEFAULT '',
+ param13 int DEFAULT 0,
+ position float DEFAULT 1.000000,
+ client_did3 char(100) DEFAULT '',
+ client_did4 char(100) DEFAULT '',
+ dlib_id char(9) DEFAULT ''
+ );
+ CREATE INDEX t2x0 on t2 (did);
+ CREATE INDEX t2x1 on t2 (client_did);
+ CREATE INDEX t2x2 on t2 (long_did);
+ CREATE INDEX t2x3 on t2 (uid);
+ CREATE INDEX t2x4 on t2 (param2);
+ CREATE INDEX t2x5 on t2 (type);
+ CREATE INDEX t2x6 on t2 (subtype);
+ CREATE INDEX t2x7 on t2 (last_sample);
+ CREATE INDEX t2x8 on t2 (param6);
+ CREATE INDEX t2x9 on t2 (frequency);
+ CREATE INDEX t2x10 on t2 (privilege);
+ CREATE INDEX t2x11 on t2 (sample_time);
+ CREATE INDEX t2x12 on t2 (notional);
+ CREATE INDEX t2x13 on t2 (tzid);
+ CREATE INDEX t2x14 on t2 (gr_code);
+ CREATE INDEX t2x15 on t2 (parent_id);
+
+ CREATE TABLE t3(
+ uid int,
+ param3 int,
+ uuid int,
+ acc_id int,
+ cust_num int,
+ numerix_id int,
+ pfy char(29),
+ param4 char(29),
+ param15 int DEFAULT 0,
+ flg7 int DEFAULT 0,
+ param21 int DEFAULT 0,
+ bxcdr char(2) DEFAULT 'PC',
+ c31 int DEFAULT 0,
+ c33 int DEFAULT 0,
+ c35 int DEFAULT 0,
+ c37 int,
+ mgr_uuid int,
+ back_up_uuid int,
+ priv_mars int DEFAULT 0,
+ is_qc int DEFAULT 0,
+ c41 int DEFAULT 0,
+ deleted int DEFAULT 0,
+ c47 int DEFAULT 1
+ );
+ CREATE INDEX t3x0 on t3 (uid);
+ CREATE INDEX t3x1 on t3 (param3);
+ CREATE INDEX t3x2 on t3 (uuid);
+ CREATE INDEX t3x3 on t3 (acc_id);
+ CREATE INDEX t3x4 on t3 (param4);
+ CREATE INDEX t3x5 on t3 (pfy);
+ CREATE INDEX t3x6 on t3 (is_qc);
+ SELECT count(*) FROM sqlite_master;
+} {30}
+do_execsql_test autoindex2-110 {
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1x3','10747267 260');
+ INSERT INTO sqlite_stat1 VALUES('t1','t1x2','10747267 121 113 2 2 2 1');
+ INSERT INTO sqlite_stat1 VALUES('t1','t1x1','10747267 50 40');
+ INSERT INTO sqlite_stat1 VALUES('t1','t1x0','10747267 1');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x15','39667 253');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x14','39667 19834');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x13','39667 13223');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x12','39667 7');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x11','39667 17');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x10','39667 19834');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x9','39667 7934');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x8','39667 11');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x7','39667 5');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x6','39667 242');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x5','39667 1984');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x4','39667 4408');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x3','39667 81');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x2','39667 551');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x1','39667 2');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2x0','39667 1');
+ INSERT INTO sqlite_stat1 VALUES('t3','t3x6','569 285');
+ INSERT INTO sqlite_stat1 VALUES('t3','t3x5','569 2');
+ INSERT INTO sqlite_stat1 VALUES('t3','t3x4','569 2');
+ INSERT INTO sqlite_stat1 VALUES('t3','t3x3','569 5');
+ INSERT INTO sqlite_stat1 VALUES('t3','t3x2','569 3');
+ INSERT INTO sqlite_stat1 VALUES('t3','t3x1','569 6');
+ INSERT INTO sqlite_stat1 VALUES('t3','t3x0','569 1');
+ ANALYZE sqlite_master;
+} {}
+do_execsql_test autoindex2-120 {
+ EXPLAIN QUERY PLAN
+ SELECT
+ t1_id,
+ t1.did,
+ param2,
+ param3,
+ t1.ptime,
+ t1.trange,
+ t1.exmass,
+ t1.mass,
+ t1.vstatus,
+ type,
+ subtype,
+ t1.deviation,
+ t1.formula,
+ dparam1,
+ reserve1,
+ reserve2,
+ param4,
+ t1.last_operation,
+ t1.admin_uuid,
+ t1.previous_value,
+ t1.job_id,
+ client_did,
+ t1.last_t1,
+ t1.data_t1,
+ t1.previous_date,
+ param5,
+ param6,
+ mgr_uuid
+ FROM
+ t1,
+ t2,
+ t3
+ WHERE
+ t1.ptime > 1393520400
+ AND param3<>9001
+ AND t3.flg7 = 1
+ AND t1.did = t2.did
+ AND t2.uid = t3.uid
+ ORDER BY t1.ptime desc LIMIT 500;
+} {~/AUTO/}
+#
+# ^^^--- Before being fixed, the above was using an automatic covering
+# on t3 and reordering the tables so that t3 was in the outer loop and
+# implementing the ORDER BY clause using a B-Tree.
+#
+# This test is sanitized data received from a user. The original unsanitized
+# data and STAT4 data is found in the th3private test repository. See one of
+# the th3private check-ins on 2016-02-25. The test is much more accurate when
+# STAT4 data is used.
+
+finish_test
diff --git a/test/autoindex3.test b/test/autoindex3.test
new file mode 100644
index 0000000..824a829
--- /dev/null
+++ b/test/autoindex3.test
@@ -0,0 +1,93 @@
+# 2014-06-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 automatic index creation logic,
+# and specifically that an automatic index will not be created that
+# shadows a declared index.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix autoindex3
+
+# The t1b and t2d indexes are not very selective. It used to be that
+# the autoindex mechanism would create automatic indexes on t1(b) or
+# t2(d), make assumptions that they were reasonably selective, and use
+# them instead of t1b or t2d. But that would be cheating, because the
+# automatic index cannot be any more selective than the real index.
+#
+# This test verifies that the cheat is no longer allowed.
+#
+do_execsql_test autoindex3-100 {
+ CREATE TABLE t1(a,b,x);
+ CREATE TABLE t2(c,d,y);
+ CREATE INDEX t1b ON t1(b);
+ CREATE INDEX t2d ON t2(d);
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1b','10000 500');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2d','10000 500');
+ ANALYZE sqlite_master;
+ EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d=b;
+} {~/AUTO/}
+
+# Automatic indexes can still be used if existing indexes do not
+# participate in == constraints.
+#
+do_execsql_test autoindex3-110 {
+ EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d>b AND x=y;
+} {/AUTO/}
+do_execsql_test autoindex3-120 {
+ EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d<b AND x=y;
+} {/AUTO/}
+do_execsql_test autoindex3-130 {
+ EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d IS NULL AND x=y;
+} {/AUTO/}
+do_execsql_test autoindex3-140 {
+ EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d IN (5,b) AND x=y;
+} {/AUTO/}
+
+reset_db
+do_execsql_test 210 {
+ CREATE TABLE v(b, d, e);
+ CREATE TABLE u(a, b, c);
+ ANALYZE sqlite_master;
+ INSERT INTO "sqlite_stat1" VALUES('u','uab','40000 400 1');
+ INSERT INTO "sqlite_stat1" VALUES('v','vbde','40000 400 1 1');
+ INSERT INTO "sqlite_stat1" VALUES('v','ve','40000 21');
+
+ CREATE INDEX uab on u(a, b);
+ CREATE INDEX ve on v(e);
+ CREATE INDEX vbde on v(b,d,e);
+
+ DROP TABLE IF EXISTS sqlite_stat4;
+ ANALYZE sqlite_master;
+}
+
+# At one point, SQLite was using the inferior plan:
+#
+# 0|0|1|SEARCH v USING INDEX ve (e>?)
+# 0|1|0|SEARCH u USING COVERING INDEX uab (ANY(a) AND b=?)
+#
+# on the basis that the real index "uab" must be better than the automatic
+# index. This is not right - a skip-scan is not necessarily better than an
+# automatic index scan.
+#
+do_eqp_test 220 {
+ select count(*) from u, v where u.b = v.b and v.e > 34;
+} {
+ QUERY PLAN
+ |--SEARCH v USING INDEX ve (e>?)
+ `--SEARCH u USING AUTOMATIC COVERING INDEX (b=?)
+}
+
+
+finish_test
diff --git a/test/autoindex4.test b/test/autoindex4.test
new file mode 100644
index 0000000..d9ab783
--- /dev/null
+++ b/test/autoindex4.test
@@ -0,0 +1,201 @@
+# 2014-10-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 automatic index creation logic,
+# and specifically creation of automatic partial indexes.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test autoindex4-1.0 {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(123,'abc'),(234,'def'),(234,'ghi'),(345,'jkl');
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(987,'zyx'),(654,'wvu'),(987,'rqp');
+
+ SELECT *, '|' FROM t1, t2 WHERE a=234 AND x=987 ORDER BY +b;
+} {234 def 987 rqp | 234 def 987 zyx | 234 ghi 987 rqp | 234 ghi 987 zyx |}
+do_execsql_test autoindex4-1.1 {
+ SELECT *, '|' FROM t1, t2 WHERE a=234 AND x=555;
+} {}
+
+do_execsql_test autoindex4-1.2 {
+ SELECT *, '|' FROM t1 LEFT JOIN t2 ON a=234 AND x=555;
+} {123 abc {} {} | 234 def {} {} | 234 ghi {} {} | 345 jkl {} {} |}
+do_execsql_test autoindex4-1.2-rj {
+ SELECT t1.*, t2.*, '|' FROM t2 RIGHT JOIN t1 ON a=234 AND x=555;
+} {123 abc {} {} | 234 def {} {} | 234 ghi {} {} | 345 jkl {} {} |}
+do_execsql_test autoindex4-1.3 {
+ SELECT *, '|' FROM t1 LEFT JOIN t2 ON x=555 WHERE a=234;
+} {234 def {} {} | 234 ghi {} {} |}
+do_execsql_test autoindex4-1.3-rj {
+ SELECT t1.*, t2.*, '|' FROM t2 RIGHT JOIN t1 ON x=555 WHERE a=234;
+} {234 def {} {} | 234 ghi {} {} |}
+do_execsql_test autoindex4-1.4 {
+ SELECT *, '|' FROM t1 LEFT JOIN t2 WHERE a=234 AND x=555;
+} {}
+do_execsql_test autoindex4-1.4-rj {
+ SELECT t1.*, t2.*, '|' FROM t2 RIGHT JOIN t1 WHERE a=234 AND x=555;
+} {}
+
+
+do_execsql_test autoindex4-2.0 {
+ CREATE TABLE t3(e,f);
+ INSERT INTO t3 VALUES(123,654),(555,444),(234,987);
+
+ SELECT (SELECT count(*) FROM t1, t2 WHERE a=e AND x=f), e, f, '|'
+ FROM t3
+ ORDER BY rowid;
+} {1 123 654 | 0 555 444 | 4 234 987 |}
+
+# Ticket [2326c258d02ead33d]
+# Two joins, one with and the other without an ORDER BY clause.
+# The one without ORDER BY correctly returns two rows of result.
+# The one with ORDER BY returns no rows.
+#
+do_execsql_test autoindex4-3.0 {
+ CREATE TABLE A(Name text);
+ CREATE TABLE Items(ItemName text , Name text);
+ INSERT INTO Items VALUES('Item1','Parent');
+ INSERT INTO Items VALUES('Item2','Parent');
+ CREATE TABLE B(Name text);
+
+ SELECT Items.ItemName
+ FROM Items
+ LEFT JOIN A ON (A.Name = Items.ItemName and Items.ItemName = 'dummy')
+ LEFT JOIN B ON (B.Name = Items.ItemName)
+ WHERE Items.Name = 'Parent'
+ ORDER BY Items.ItemName;
+} {Item1 Item2}
+do_execsql_test autoindex4-3.1 {
+ SELECT Items.ItemName
+ FROM A
+ RIGHT JOIN Items ON (A.Name = Items.ItemName and Items.ItemName = 'dummy')
+ LEFT JOIN B ON (B.Name = Items.ItemName)
+ WHERE Items.Name = 'Parent'
+ ORDER BY Items.ItemName;
+} {Item1 Item2}
+do_execsql_test autoindex4-3.10 {
+ CREATE INDEX Items_x1 ON Items(ItemName,Name) WHERE ItemName = 'dummy';
+
+ SELECT Items.ItemName
+ FROM Items
+ LEFT JOIN A ON (A.Name = Items.ItemName and Items.ItemName = 'dummy')
+ LEFT JOIN B ON (B.Name = Items.ItemName)
+ WHERE Items.Name = 'Parent'
+ ORDER BY Items.ItemName;
+} {Item1 Item2}
+do_execsql_test autoindex4-3.11 {
+ SELECT Items.ItemName
+ FROM A
+ RIGHT JOIN Items ON (A.Name = Items.ItemName and Items.ItemName = 'dummy')
+ LEFT JOIN B ON (B.Name = Items.ItemName)
+ WHERE Items.Name = 'Parent'
+ ORDER BY Items.ItemName;
+} {Item1 Item2}
+
+# 2021-11-30 - Enhancement to help the automatic index mechanism to
+# create a partial index more often.
+#
+unset -nocomplain id data1 data2 jointype onclause whereclause answer
+foreach {id data1 data2 jointype onclause whereclause answer} {
+ 1
+ VALUES(1,2),(3,4)
+ VALUES(1,2),(3,4)
+ {LEFT JOIN}
+ a=x
+ {y=4 OR y IS NULL}
+ {3 4 3 4}
+
+ 2
+ VALUES(1,2),(3,4)
+ VALUES(1,2),(3,4)
+ {LEFT JOIN}
+ {a=x AND y=4}
+ {coalesce(y,4)==4}
+ {1 2 {} {} 3 4 3 4}
+
+ 3
+ VALUES(1,2),(3,4)
+ VALUES(1,2),(3,4)
+ {JOIN}
+ {a=x}
+ {y=4 OR y IS NULL}
+ {3 4 3 4}
+
+ 4
+ VALUES(1,2),(3,4)
+ VALUES(1,2),(3,4)
+ {JOIN}
+ {a=x AND y=4}
+ {coalesce(y,4)==4}
+ {3 4 3 4}
+
+ 5
+ VALUES(1,2),(3,4),(NULL,4)
+ VALUES(1,2),(3,4)
+ {LEFT JOIN}
+ a=x
+ {y=4 OR y IS NULL}
+ {3 4 3 4 {} 4 {} {}}
+
+ 6
+ VALUES(1,2),(3,4)
+ VALUES(1,2),(3,4),(NULL,4)
+ {LEFT JOIN}
+ {a=x AND y=4}
+ {coalesce(y,4)==4}
+ {1 2 {} {} 3 4 3 4}
+
+ 7
+ VALUES(1,2),(3,4),(NULL,4)
+ VALUES(1,2),(3,4),(NULL,4)
+ {JOIN}
+ {a=x}
+ {y=4 OR y IS NULL}
+ {3 4 3 4}
+
+ 8
+ VALUES(1,2),(3,4)
+ VALUES(1,2),(3,4)
+ {JOIN}
+ {a=x AND y=4}
+ {coalesce(y,4)==4}
+ {3 4 3 4}
+} {
+ do_test autoindex4-4.$id.0 {
+ db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INT, b INT);
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x INT, y INT);
+ }
+ db eval "INSERT INTO t1(a,b) $data1;"
+ db eval "INSERT INTO t2(x,y) $data2;"
+ } {}
+ set sql "SELECT * FROM t1 $jointype t2 ON $onclause WHERE $whereclause"
+ # puts "sql = $sql"
+ do_test autoindex4-4.$id.1 {
+ db eval {PRAGMA automatic_index=ON;}
+ db eval $sql
+ } $answer
+ do_test autoindex4-4.$id.2 {
+ db eval {PRAGMA automatic_index=OFF;}
+ db eval $sql
+ } $answer
+}
+
+
+
+
+finish_test
diff --git a/test/autoindex5.test b/test/autoindex5.test
new file mode 100644
index 0000000..aa8dec2
--- /dev/null
+++ b/test/autoindex5.test
@@ -0,0 +1,234 @@
+# 2014-10-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 automatic index creation logic,
+# and specifically ensuring that automatic indexes can be used with
+# co-routine subqueries.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix autoindex5
+
+# Schema is from the Debian security database
+#
+do_execsql_test autoindex5-1.0 {
+ CREATE TABLE source_package_status
+ (bug_name TEXT NOT NULL,
+ package INTEGER NOT NULL,
+ vulnerable INTEGER NOT NULL,
+ urgency TEXT NOT NULL,
+ PRIMARY KEY (bug_name, package));
+ CREATE INDEX source_package_status_package
+ ON source_package_status(package);
+
+ CREATE TABLE source_packages
+ (name TEXT NOT NULL,
+ release TEXT NOT NULL,
+ subrelease TEXT NOT NULL,
+ archive TEXT NOT NULL,
+ version TEXT NOT NULL,
+ version_id INTEGER NOT NULL DEFAULT 0,
+ PRIMARY KEY (name, release, subrelease, archive));
+
+ CREATE TABLE bugs
+ (name TEXT NOT NULL PRIMARY KEY,
+ cve_status TEXT NOT NULL
+ CHECK (cve_status IN
+ ('', 'CANDIDATE', 'ASSIGNED', 'RESERVED', 'REJECTED')),
+ not_for_us INTEGER NOT NULL CHECK (not_for_us IN (0, 1)),
+ description TEXT NOT NULL,
+ release_date TEXT NOT NULL,
+ source_file TEXT NOT NULL,
+ source_line INTEGER NOT NULL);
+
+ CREATE TABLE package_notes
+ (id INTEGER NOT NULL PRIMARY KEY,
+ bug_name TEXT NOT NULL,
+ package TEXT NOT NULL,
+ fixed_version TEXT
+ CHECK (fixed_version IS NULL OR fixed_version <> ''),
+ fixed_version_id INTEGER NOT NULL DEFAULT 0,
+ release TEXT NOT NULL,
+ package_kind TEXT NOT NULL DEFAULT 'unknown',
+ urgency TEXT NOT NULL,
+ bug_origin TEXT NOT NULL DEFAULT '');
+ CREATE INDEX package_notes_package
+ ON package_notes(package);
+ CREATE UNIQUE INDEX package_notes_bug
+ ON package_notes(bug_name, package, release);
+
+ CREATE TABLE debian_bugs
+ (bug INTEGER NOT NULL,
+ note INTEGER NOT NULL,
+ PRIMARY KEY (bug, note));
+
+
+ CREATE VIEW debian_cve AS
+ SELECT DISTINCT debian_bugs.bug, st.bug_name
+ FROM package_notes, debian_bugs, source_package_status AS st
+ WHERE package_notes.bug_name = st.bug_name
+ AND debian_bugs.note = package_notes.id
+ ORDER BY debian_bugs.bug;
+} {}
+
+# The following query should use an automatic index for the view
+# in FROM clause of the subquery of the second result column.
+#
+do_eqp_test autoindex5-1.1 {
+ SELECT
+ st.bug_name,
+ (SELECT ALL debian_cve.bug FROM debian_cve
+ WHERE debian_cve.bug_name = st.bug_name
+ ORDER BY debian_cve.bug),
+ sp.release
+ FROM
+ source_package_status AS st,
+ source_packages AS sp,
+ bugs
+ WHERE
+ sp.rowid = st.package
+ AND st.bug_name = bugs.name
+ AND ( st.bug_name LIKE 'CVE-%' OR st.bug_name LIKE 'TEMP-%' )
+ AND ( sp.release = 'sid' OR sp.release = 'stretch' OR sp.release = 'jessie'
+ OR sp.release = 'wheezy' OR sp.release = 'squeeze' )
+ ORDER BY sp.name, st.bug_name, sp.release, sp.subrelease;
+} {SEARCH debian_cve USING AUTOMATIC COVERING INDEX (bug_name=?)}
+
+#-------------------------------------------------------------------------
+# Test that ticket [8a2adec1] has been fixed.
+#
+do_execsql_test 2.1 {
+ CREATE TABLE one(o);
+ INSERT INTO one DEFAULT VALUES;
+
+ CREATE TABLE t1(x, z);
+ INSERT INTO t1 VALUES('aaa', 4.0);
+ INSERT INTO t1 VALUES('aaa', 4.0);
+ CREATE VIEW vvv AS
+ SELECT * FROM t1
+ UNION ALL
+ SELECT 0, 0 WHERE 0;
+
+ SELECT (
+ SELECT sum(z) FROM vvv WHERE x='aaa'
+ ) FROM one;
+} {8.0}
+
+# At one point the following was returning "no such column: rowid". This
+# was incorrect - "rowid" matches against the rowid of table t1 in this
+# query.
+do_catchsql_test 2.2 {
+ DROP TABLE t1;
+ CREATE TABLE t1(aaa);
+ INSERT INTO t1(aaa) VALUES(9);
+ SELECT (
+ SELECT aaa FROM t1 GROUP BY (
+ SELECT bbb FROM (
+ SELECT ccc AS bbb FROM (
+ SELECT 1 ccc
+ ) WHERE rowid IS NOT 1
+ ) WHERE bbb = 1
+ )
+ );
+} {0 9}
+
+# Ticket https://www.sqlite.org/src/info/787fa716be3a7f65
+# Segfault due to multiple uses of the same subquery where the
+# subquery is implemented via coroutine.
+#
+ifcapable windowfunc {
+sqlite3 db :memory:
+do_execsql_test 3.0 {
+ -- This is the original test case reported on the mailing list
+ CREATE TABLE artists (
+ id integer NOT NULL PRIMARY KEY AUTOINCREMENT,
+ name varchar(255)
+ );
+ CREATE TABLE albums (
+ id integer NOT NULL PRIMARY KEY AUTOINCREMENT,
+ name varchar(255),
+ artist_id integer REFERENCES artists
+ );
+ INSERT INTO artists (name) VALUES ('Ar');
+ INSERT INTO albums (name, artist_id) VALUES ('Al', 1);
+ SELECT artists.*
+ FROM artists
+ INNER JOIN artists AS 'b' ON (b.id = artists.id)
+ WHERE (artists.id IN (
+ SELECT albums.artist_id
+ FROM albums
+ WHERE ((name = 'Al')
+ AND (albums.artist_id IS NOT NULL)
+ AND (albums.id IN (
+ SELECT id
+ FROM (
+ SELECT albums.id,
+ row_number() OVER (
+ PARTITION BY albums.artist_id
+ ORDER BY name
+ ) AS 'x'
+ FROM albums
+ WHERE (name = 'Al')
+ ) AS 't1'
+ WHERE (x = 1)
+ ))
+ AND (albums.id IN (1, 2)))
+ ));
+} {1 Ar}
+} ;# windowfunc
+
+# The remaining test cases were discovered (by Dan) during trouble-shooting
+sqlite3 db :memory:
+do_execsql_test 3.1 {
+ CREATE TABLE t1 (a); INSERT INTO t1 (a) VALUES (104);
+ CREATE TABLE t2 (b); INSERT INTO t2 (b) VALUES (104);
+ CREATE TABLE t3 (c); INSERT INTO t3 (c) VALUES (104);
+ CREATE TABLE t4 (d); INSERT INTO t4 (d) VALUES (104);
+ SELECT *
+ FROM t1 CROSS JOIN t2 ON (t1.a = t2.b) WHERE t2.b IN (
+ SELECT t3.c
+ FROM t3
+ WHERE t3.c IN (
+ SELECT d FROM (SELECT DISTINCT d FROM t4) AS x WHERE x.d=104
+ )
+ );
+} {104 104}
+sqlite3 db :memory:
+do_execsql_test 3.2 {
+ CREATE TABLE t5(a, b, c, d);
+ CREATE INDEX t5a ON t5(a);
+ CREATE INDEX t5b ON t5(b);
+ CREATE TABLE t6(e);
+ INSERT INTO t6 VALUES(1);
+ INSERT INTO t5 VALUES(1,1,1,1), (2,2,2,2);
+ SELECT * FROM t5 WHERE (a=1 OR b=2) AND c IN (
+ SELECT e FROM (SELECT DISTINCT e FROM t6) WHERE e=1
+ );
+} {1 1 1 1}
+sqlite3 db :memory:
+do_execsql_test 3.3 {
+ CREATE TABLE t1(a1, a2, a3);
+ CREATE INDEX t1a2 ON t1(a2, a1);
+ CREATE INDEX t1a3 ON t1(a3, a1);
+ CREATE TABLE t2(d);
+ INSERT INTO t1 VALUES(3, 1, 1), (3, 2, 2);
+ INSERT INTO t2 VALUES(3);
+ SELECT *, 'x' FROM t1 WHERE (a2=1 OR a3=2) AND a1 = (
+ SELECT d FROM (SELECT DISTINCT d FROM t2) WHERE d=3
+ );
+} {3 1 1 x 3 2 2 x}
+
+
+
+
+finish_test
diff --git a/test/autovacuum.test b/test/autovacuum.test
new file mode 100644
index 0000000..245ea8b
--- /dev/null
+++ b/test/autovacuum.test
@@ -0,0 +1,715 @@
+# 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 autovacuum feature.
+#
+
+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 order by rowid
+ }
+ } $::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
+# all 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]
+
+# unusable_pages
+# These are either the pending_byte page or the pointer map pages
+#
+unset -nocomplain unusable_page
+if {[sqlite3 -has-codec]} {
+ array set unusable_page {205 1 408 1}
+} else {
+ array set unusable_page {207 1 412 1}
+}
+set unusable_page($pending_byte_page) 1
+
+for {set i 3} {$i<=532} {incr i} {
+ if {![info exists unusable_page($i)]} {
+ 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 {UNIQUE constraint failed: av1.a}}
+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
+
+do_execsql_test autovacuum-10.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(25, randomblob(104));
+ REPLACE INTO t1 VALUES(25, randomblob(1117));
+ PRAGMA integrity_check;
+} {ok}
+
+finish_test
diff --git a/test/autovacuum2.test b/test/autovacuum2.test
new file mode 100644
index 0000000..a3c4098
--- /dev/null
+++ b/test/autovacuum2.test
@@ -0,0 +1,87 @@
+# 2021-10-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 sqlite3_autovacuum_pages() interface
+#
+
+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
+}
+
+# Demonstrate basic sqlite3_autovacuum_pages functionality
+#
+do_execsql_test autovacuum2-1.0 {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum=FULL;
+ CREATE TABLE t1(x);
+ VACUUM;
+ INSERT INTO t1(x) VALUES(zeroblob(10000));
+ PRAGMA page_count;
+} {12}
+proc autovac_page_callback {schema filesize freesize pagesize} {
+ global autovac_callback_data
+ lappend autovac_callback_data $schema $filesize $freesize $pagesize
+ return [expr {$freesize/2}]
+}
+sqlite3_autovacuum_pages db autovac_page_callback
+set autovac_callback_data {}
+do_execsql_test autovacuum2-1.1 {
+ BEGIN;
+ DELETE FROM t1;
+ PRAGMA freelist_count;
+ PRAGMA page_count;
+} {9 12}
+do_execsql_test autovacuum2-1.2 {
+ COMMIT;
+} {}
+do_test autovacuum2-1.3 {
+ set autovac_callback_data
+} {main 12 9 1024}
+do_execsql_test autovacuum2-1.4 {
+ PRAGMA freelist_count;
+ PRAGMA page_count;
+} {5 8}
+do_execsql_test autovacuum2-1.5 {
+ PRAGMA integrity_check;
+} {ok}
+
+# Disable the autovacuum-pages callback. Then do any transaction.
+# The database should shrink to minimal size
+#
+sqlite3_autovacuum_pages db
+do_execsql_test autovacuum2-1.10 {
+ CREATE TABLE t2(x);
+ PRAGMA freelist_count;
+} {0}
+
+# Rig the autovacuum-pages callback to always return zero. No
+# autovacuum will happen.
+#
+proc autovac_page_callback_off {schema filesize freesize pagesize} {
+ return 0
+}
+sqlite3_autovacuum_pages db autovac_page_callback_off
+do_execsql_test autovacuum2-1.20 {
+ BEGIN;
+ INSERT INTO t1(x) VALUES(zeroblob(10000));
+ DELETE FROM t1;
+ PRAGMA freelist_count;
+ COMMIT;
+ PRAGMA freelist_count;
+} {9 9}
+
+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/avfs.test b/test/avfs.test
new file mode 100644
index 0000000..2ebd608
--- /dev/null
+++ b/test/avfs.test
@@ -0,0 +1,395 @@
+# 2021-03-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 tests for the appendvfs extension.
+#
+# Tests performed:
+# avfs-1.0. Test that an appendvfs DB can be added to an empty (ZLF) file.
+# avfs-1.1. Test that the DB can be read with correct content upon reopen.
+# avfs-1.2. Test that an appendvfs DB can be added to a simple text file.
+# avfs-1.3. Test that the DB can be read with correct content upon reopen.
+# avfs-1.4. Test that appended DB is aligned to default page boundary.
+# avfs-2.1. Test that the simple text file retains its initial text.
+# avfs-3.1. Test that the appendvfs can grow and shrink, remaining intact.
+# avfs-3.2. Test that appendvfs is intact after grow/shrink/close/reopen.
+# avfs-3.3. Test that appendvfs can grow by many pages and be written.
+# avfs-3.4. Test that grown appendvfs can be reopened and appear intact.
+# avfs-3.5. Test that much grown appendvfs can shrink and reopen intact.
+# avfs-4.1. Test shell's ability to append to a non-appendvfs file.
+# avfs-4.2. Test shell's ability to append to empty or nonexistent file.
+# avfs-4.3. Test shell's ability to reopen and alter an appendvfs file.
+# avfs-5.1. Test appendvfs refusal to open too-tiny DB appended onto ZLF.
+# avfs-5.2. Test appendvfs refusal to open too-tiny DB appended on other.
+# ...
+# (more to come)
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix avfs
+
+# Do not attempt this test if SQLITE_OMIT_VIRTUALTABLE is defined.
+#
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+set CLI [test_find_cli]
+db close
+# forcedelete test.db
+
+load_static_extension db appendvfs
+
+set ::fa avfs.adb
+set ::fza avfs.sdb
+forcedelete $::fa $::fza
+set ::result {}
+
+proc shellDoesAr {} {
+ set shdo "sh_app1.sql"
+ forcedelete $shdo
+ set fd [open $shdo w]
+ puts $fd ".help\n.q"
+ close $fd
+ set res [catchcmd "-batch -cmd \".read $shdo\""]
+ return [regexp {^.archive} [lindex $res 1]]
+}
+
+set ::vf "&vfs=apndvfs"
+
+# Return file offset of appendvfs portion of a file, or {} if none such.
+proc fosAvfs {fname} {
+ if {[file size $fname] < 25} {
+ return {}
+ }
+ if {[catch {set fd [open $fname rb]}]} {
+ return {}
+ }
+ seek $fd -25 end
+ set am [read $fd 17]
+ set ao [read $fd 8]
+ close $fd
+ if {$am ne "Start-Of-SQLite3-"} {
+ return {}
+ }
+ binary scan $ao "W" rvo
+ return $rvo
+}
+
+do_test 1.0 {
+ set results {}
+ set out [open $::fza wb]
+ close $out
+ sqlite3 adb "file:$::fza?mode=rwc$::vf" -uri 1
+ adb eval {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=10;
+ CREATE TABLE t1(a TEXT);
+ INSERT INTO t1 VALUES ('dog'),('cat');
+ SELECT group_concat(a) as pets FROM (SELECT a FROM t1 ORDER BY a);
+ } { lappend results $pets }
+ adb close
+ lappend results [fosAvfs $fza]
+ set ::result [join $results " | "]
+} {cat,dog | 0}
+
+do_test 1.1 {
+ set results {}
+ sqlite3 adb "file:$::fza?mode=rw$::vf" -uri 1
+ adb eval {
+ SELECT group_concat(a) as pets FROM (SELECT a FROM t1 ORDER BY a DESC);
+ } { lappend results $pets }
+ adb close
+ set ::result [join $results " | "]
+} {dog,cat}
+
+do_test 1.2 {
+ set results {}
+ set out [open $::fa wb]
+ set ::tlo { "Just some text," "and more text," "ending at 3 lines." }
+ puts $out [join $::tlo "\n"]
+ close $out
+ set adbSz [file size $::fa]
+ sqlite3 adb "file:$::fa?mode=rwc$::vf" -uri 1
+ adb eval {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size=512;
+ PRAGMA cache_size=0;
+ CREATE TABLE t1(a TEXT);
+ INSERT INTO t1 VALUES ('dog'),('cat'),('pig');
+ SELECT group_concat(a) as pets FROM (SELECT a FROM t1 ORDER BY a);
+ } { lappend results $pets }
+ adb close
+ set adaSz [file size $::fa]
+ lappend results "Bytes before/after $adbSz/$adaSz"
+ set ::result [join $results " | "]
+} {cat,dog,pig | Bytes before/after 50/5145}
+
+do_test 1.3 {
+ set results {}
+ sqlite3 adb "file:$::fa?mode=rw$::vf" -uri 1
+ adb eval {
+ SELECT group_concat(a) as pets FROM (SELECT a FROM t1 ORDER BY a DESC);
+ } { lappend results $pets }
+ adb close
+ set ::result [join $results " | "]
+} {pig,dog,cat}
+
+do_test 1.4 {
+ set ::result [fosAvfs $fa]
+} {4096}
+
+do_test 2.1 {
+ set in [open $::fa r]
+ set tli {}
+ for {set i [llength $::tlo]} {$i > 0} {incr i -1} {
+ lappend tli [gets $in]
+ }
+ close $in
+ if { [join $tli ":"] ne [join $::tlo ":"] } {
+ set ::result "Appendee changed."
+ } else {
+ set ::result "Appendee intact."
+ }
+} {Appendee intact.}
+
+# Set of repeatable random integers for a couple tests.
+set ::nrint 50000
+proc rint {v} {
+ return [::tcl::mathfunc::int [expr $v * 100000]]
+}
+array set ::randints [list 0 [rint [::tcl::mathfunc::srand 0]]]
+for {set i 1} {$i < $::nrint} {incr i} {
+ set ::randints($i) [rint [::tcl::mathfunc::rand]]
+}
+
+do_test 3.1 {
+ set results {}
+ sqlite3 adb "file:$::fa?mode=rw$::vf" -uri 1
+ adb eval {
+ DROP TABLE t1;
+ PRAGMA cache_size=10;
+ CREATE TABLE ri (i INTEGER);
+ BEGIN;
+ }
+ for {set i 0} {$i < $::nrint} {incr i} {
+ set r $::randints($i)
+ set s $::randints([incr i])
+ set t $::randints([incr i])
+ set u $::randints([incr i])
+ set v $::randints([incr i])
+ adb eval {
+ INSERT INTO ri VALUES ($r),($s),($t),($u),($v)
+ }
+ }
+ adb eval {
+ COMMIT;
+ SELECT integrity_check as ic FROM pragma_integrity_check();
+ } { lappend results $ic }
+ set adbSz [file size $::fa]
+ set qr {}
+ adb eval {
+ SELECT count(*) as ic FROM ri;
+ DELETE FROM ri WHERE (i % 50) <> 25;
+ SELECT integrity_check as ic FROM pragma_integrity_check();
+ VACUUM;
+ SELECT integrity_check as ic FROM pragma_integrity_check();
+ SELECT count(*) as ic FROM ri;
+ } { lappend qr $ic }
+ adb close
+ set adaSz [file size $::fa]
+ set adba [expr ($adbSz + 0.1)/$adaSz]
+ # lappend results $adba
+ set results [concat $results [lrange $qr 0 2]]
+ lappend results [expr {$adba > 10.0}]
+ set ::result [join $results " | "]
+} "ok | $::nrint | ok | ok | 1"
+
+do_test 3.2 {
+ set results {}
+ sqlite3 adb "file:$::fa?mode=rw$::vf" -uri 1
+ adb eval {
+ SELECT integrity_check as ic FROM pragma_integrity_check();
+ } { lappend results $ic }
+ adb close
+ set ::result [join $results " | "]
+} {ok}
+
+# avfs-3.3. Test that appendvfs can grow by many pages and be written.
+do_test 3.3 {
+ set results {}
+ sqlite3 adb "file:$::fa?mode=rw$::vf" -uri 1
+ set npages 300
+ adb eval { BEGIN }
+ while {$npages > 0} {
+ adb eval { INSERT INTO ri VALUES (randomblob(1500)) }
+ incr npages -1
+ }
+ adb eval { COMMIT }
+ adb eval {
+ SELECT integrity_check as ic FROM pragma_integrity_check();
+ } { lappend results $ic }
+ adb close
+ set adaSzr [expr [file size $::fa] / 300.0 / 1500 ]
+ set okSzr [expr $adaSzr > 1.0 && $adaSzr < 1.3 ]
+ lappend results $okSzr
+ set ::result [join $results " | "]
+} {ok | 1}
+
+# avfs-3.4. Test that grown appendvfs can be reopened and appear intact.
+do_test 3.4 {
+ set results {}
+ sqlite3 adb "file:$::fa?mode=rw$::vf" -uri 1
+ adb eval {
+ SELECT integrity_check as ic FROM pragma_integrity_check();
+ } { lappend results $ic }
+ adb close
+ set ::result $ic
+} {ok}
+
+# avfs-3.5. Test that much grown appendvfs can shrink and reopen intact.
+do_test 3.5 {
+ set results {}
+ set adbsz [file size $::fa]
+ sqlite3 adb "file:$::fa?mode=rw$::vf" -uri 1
+ adb eval {
+ DELETE FROM ri WHERE rowid % 8 <> 0;
+ SELECT integrity_check as ic FROM pragma_integrity_check();
+ VACUUM;
+ SELECT integrity_check as ic FROM pragma_integrity_check();
+ } { lappend results $ic }
+ adb close
+ set adasz [file size $::fa]
+ lappend results [expr {$adbsz/$adasz > 5}]
+ sqlite3 adb "file:$::fa?mode=rw$::vf" -uri 1
+ adb eval {
+ SELECT integrity_check as ic FROM pragma_integrity_check();
+ } { lappend results $ic }
+ adb close
+ set ::result [join $results " | "]
+} {ok | ok | 1 | ok}
+
+set ::cliDoesAr [shellDoesAr]
+
+do_test 4.1 {
+ set shdo "sh_app1.sql"
+ set shod "sh_app1.adb"
+ forcedelete $shdo $shod
+ set ofd [open $shdo w]
+ if {$::cliDoesAr} {
+ puts $ofd ".ar -c"
+ } else {
+ puts $ofd "pragma page_size=512;"
+ puts $ofd "create table sqlar (a);"
+ }
+ puts $ofd ".tables"
+ puts $ofd ".q"
+ close $ofd
+ set ofd [open $shod wb]
+ puts $ofd "Some text."
+ close $ofd
+ set res [catchcmd "-append -batch -init $shdo $shod" ""]
+ lappend res [fosAvfs $shod]
+ forcedelete $shdo $shod
+ set ::result [join $res " | "]
+} {0 | sqlar | 4096}
+
+do_test 4.2 {
+ set shdo "sh_app1.sql"
+ set shod "sh_app1.adb"
+ forcedelete $shdo $shod
+ set ofd [open $shdo w]
+ if {$::cliDoesAr} {
+ puts $ofd ".ar -c"
+ } else {
+ puts $ofd "pragma page_size=512;"
+ puts $ofd "create table sqlar (a);"
+ }
+ puts $ofd ".tables"
+ puts $ofd ".q"
+ close $ofd
+ set ofd [open $shod wb]
+ close $ofd
+ set res [catchcmd "-append -batch -init $shdo $shod" ""]
+ lappend res [fosAvfs $shod]
+ forcedelete $shdo ; # Leave $shod for next test.
+ set ::result [join $res " | "]
+} {0 | sqlar | 0}
+
+do_test 4.3 {
+ set shdo "sh_app1.sql"
+ set shod "sh_app1.adb" ; # Same as test 4.2, reusing ADB.
+ forcedelete $shdo
+ set ofd [open $shdo w]
+ if {$::cliDoesAr} {
+ puts $ofd ".ar -u $shdo"
+ puts $ofd "select count(*) from sqlar where name = '$shdo';"
+ } else {
+ puts $ofd "insert into sqlar values (1);"
+ puts $ofd "select count(*) from sqlar;"
+ }
+ puts $ofd ".q"
+ close $ofd
+ set res [catchcmd "-append -batch -init $shdo $shod" ""]
+ sqlite3 adb "file:$shod?mode=rw$::vf" -uri 1
+ adb eval {
+ SELECT count(*) as n FROM sqlar
+ } { lappend res $n }
+ adb close
+ forcedelete $shdo $shod;
+ set ::result [join $res " | "]
+} {0 | 1 | 1}
+
+do_test 5.1 {
+ set fake "faketiny.sdb"
+ forcedelete $fake
+ set ofd [open $fake wb]
+ puts -nonewline $ofd "SQLite format 3"
+ puts -nonewline $ofd [binary format "c" 0]
+ puts -nonewline $ofd "Start-Of-SQLite3-"
+ puts -nonewline $ofd [binary format "W" 0]
+ close $ofd
+ if {[catch {sqlite3 adb "file:$fake?mode=rw$::vf" -uri 1}]} {
+ set res "Open failed."
+ } else {
+ adb close
+ set res "Opened when should not."
+ }
+ forcedelete $fake
+ set ::result $res
+} {Open failed.}
+
+do_test 5.2 {
+ set fake "faketiny.sdb"
+ forcedelete $fake
+ set ofd [open $fake wb]
+ set fakeAppendee "Dog ate my homework.\n"
+ puts -nonewline $ofd $fakeAppendee
+ puts -nonewline $ofd "SQLite format 3"
+ puts -nonewline $ofd [binary format "c" 0]
+ puts -nonewline $ofd "Start-Of-SQLite3-"
+ puts -nonewline $ofd [binary format "W" [string length $fakeAppendee]]
+ close $ofd
+ if {[catch {sqlite3 adb "file:$fake?mode=rw$::vf" -uri 1}]} {
+ set res "Open failed."
+ } else {
+ adb close
+ set res "Opened when should not."
+ }
+ forcedelete $fake
+ set ::result $res
+} {Open failed.}
+
+forcedelete $::fa $::fza
+
+unset -nocomplain ::fa ::fza ::tlo ::result ::randints ::nrint ::cliDoesAr
+
+finish_test
diff --git a/test/avtrans.test b/test/avtrans.test
new file mode 100644
index 0000000..6fc4a3e
--- /dev/null
+++ b/test/avtrans.test
@@ -0,0 +1,927 @@
+# 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=full }
+ 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.0.1 { execsql { PRAGMA auto_vacuum } } 1
+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..87ffc4b
--- /dev/null
+++ b/test/backcompat.test
@@ -0,0 +1,524 @@
+# 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
+source $testdir/bc_common.tcl
+db close
+
+if {"" == [bc_find_binaries backcompat.test]} {
+ finish_test
+ return
+}
+
+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 }
+
+ foreach c {code1 code2} {
+ $c {
+ set v [split [db version] .]
+ if {[llength $v]==3} {lappend v 0}
+ set ::sqlite_libversion [format \
+ "%d%.2d%.2d%.2d" [lindex $v 0] [lindex $v 1] [lindex $v 2] [lindex $v 3]
+ ]
+ }
+ }
+
+ 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 $::BC(binaries) {
+ set nErr [set_test_counter errors]
+ foreach dir {0 1} {
+
+ set bintag $bin
+ regsub {.*testfixture\.} $bintag {} bintag
+ 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}
+
+ do_test backcompat-2.1 {
+ sql1 {
+ CREATE TABLE t2(a UNIQUE, b PRIMARY KEY, c UNIQUE);
+ INSERT INTO t2 VALUES(1,9,5);
+ INSERT INTO t2 VALUES(5,5,1);
+ INSERT INTO t2 VALUES(9,1,9);
+ SELECT * FROM t2 ORDER BY a;
+ }
+ } {1 9 5 5 5 1 9 1 9}
+ do_test backcompat-2.2 {
+ sql2 {
+ SELECT * FROM sqlite_master WHERE rootpage=-1;
+ SELECT * FROM t2 ORDER BY a;
+ }
+ } {1 9 5 5 5 1 9 1 9}
+ do_test backcompat-2.3 {
+ sql1 {
+ SELECT * FROM t2 ORDER BY b;
+ }
+ } {9 1 9 5 5 1 1 9 5}
+ do_test backcompat-2.4 {
+ sql2 {
+ SELECT * FROM t2 ORDER BY b;
+ }
+ } {9 1 9 5 5 1 1 9 5}
+ do_test backcompat-2.5 {
+ sql1 {
+ SELECT * FROM t2 ORDER BY c;
+ }
+ } {5 5 1 1 9 5 9 1 9}
+ do_test backcompat-2.6 {
+ sql2 {
+ SELECT * FROM t2 ORDER BY c;
+ }
+ } {5 5 1 1 9 5 9 1 9}
+}
+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"
+ && [code1 {set ::sqlite_options(wal)}]
+ && [code2 {sqlite3 -version}] >= "3.7.0"
+ && [code2 {set ::sqlite_options(wal)}]
+ } {
+
+ 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.
+#
+ifcapable fts3 {
+ 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]
+ }
+
+ # Now test that an incremental merge can be started by one version
+ # and finished by another. And that the integrity-check still
+ # passes.
+ do_test backcompat-3.8 {
+ sql1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(docid, words);
+ CREATE VIRTUAL TABLE t2 USING fts3(words);
+ }
+ code1 [list source $testdir/genesis.tcl]
+ code1 { fts_kjv_genesis }
+ sql1 {
+ INSERT INTO t2 SELECT words FROM t1;
+ INSERT INTO t2 SELECT words FROM t1;
+ INSERT INTO t2 SELECT words FROM t1;
+ INSERT INTO t2 SELECT words FROM t1;
+ INSERT INTO t2 SELECT words FROM t1;
+ INSERT INTO t2 SELECT words FROM t1;
+ SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level;
+ }
+ } {0 {0 1 2 3 4 5}}
+
+ if {[code1 { set ::sqlite_libversion }] >=3071200
+ && [code2 { set ::sqlite_libversion }] >=3071200
+ } {
+ if {[code1 { set ::sqlite_libversion }]<3120000} {
+ set res {0 {0 1} 1 0}
+ } else {
+ set res {1 0}
+ }
+
+ do_test backcompat-3.9 {
+ sql1 { INSERT INTO t2(t2) VALUES('merge=100,4'); }
+ sql2 { INSERT INTO t2(t2) VALUES('merge=100,4'); }
+ sql1 { INSERT INTO t2(t2) VALUES('merge=100,4'); }
+ sql2 { INSERT INTO t2(t2) VALUES('merge=2500,4'); }
+ sql2 {
+ SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level;
+ }
+ } $res
+
+ do_test backcompat-3.10 {
+ sql1 { INSERT INTO t2(t2) VALUES('integrity-check') }
+ sql2 { INSERT INTO t2(t2) VALUES('integrity-check') }
+ } {}
+ }
+ }
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that Rtree tables may be read/written by different versions of
+# SQLite.
+#
+ifcapable rtree {
+ 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..1572ded
--- /dev/null
+++ b/test/backup.test
@@ -0,0 +1,981 @@
+# 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 4096} {
+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" }]
+
+ 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 ""
+ }
+
+ if { $isMemDest==0 || $pgsz_dest==1024 || $rows_dest==0 } {
+
+ # 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
+ }
+ execsql COMMIT $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 unfinalized statements or unfinished backups}
+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-4.* 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
+}
+
+# 2021-01-31 https://sqlite.org/forum/forumpost/8b39fbf3e7
+#
+do_test backup-11.1 {
+ sqlite3 db1 :memory:
+ sqlite3 db2 :memory:
+ sqlite3_backup B db1 main db2 temp
+ B finish
+} {SQLITE_OK}
+
+finish_test
diff --git a/test/backup2.test b/test/backup2.test
new file mode 100644
index 0000000..1822e2d
--- /dev/null
+++ b/test/backup2.test
@@ -0,0 +1,187 @@
+# 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 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"} {
+ set msg {cannot open source database: unable to open database file}
+} elseif {[string match *BSD $tcl_platform(os)]} {
+ set msg {}
+} else {
+ set msg {cannot open source database: disk I/O error}
+}
+do_test backup2-10 {
+ forcedelete bu3.db
+ file mkdir bu3.db
+ set rc [catch {db restore temp bu3.db} res]
+ if {[string match *BSD $tcl_platform(os)]} { set res "" }
+ list $rc $res
+} [list 1 $msg]
+
+# 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 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/backup4.test b/test/backup4.test
new file mode 100644
index 0000000..2756995
--- /dev/null
+++ b/test/backup4.test
@@ -0,0 +1,108 @@
+# 2012 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.
+#
+#***********************************************************************
+#
+# The tests in this file verify that if an empty database (zero bytes in
+# size) is used as the source of a backup operation, the final destination
+# database is one page in size.
+#
+# The destination must consist of at least one page as truncating a
+# database file to zero bytes is equivalent to resetting the database
+# schema cookie and change counter. Doing that could cause other clients
+# to become confused and continue using out-of-date cache data.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix backup4
+
+# The codec logic does not work for zero-length database files. A database
+# file must contain at least one page in order to be recognized as an
+# encrypted database.
+do_not_use_codec
+
+#-------------------------------------------------------------------------
+# At one point this test was failing because [db] was using an out of
+# date schema in test case 1.2.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y, UNIQUE(x, y));
+ INSERT INTO t1 VALUES('one', 'two');
+ SELECT * FROM t1 WHERE x='one';
+ PRAGMA integrity_check;
+} {one two ok}
+
+do_test 1.1 {
+ sqlite3 db1 :memory:
+ db1 backup test.db
+ sqlite3 db1 test.db
+ db1 eval {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('one', 'two');
+ }
+ db1 close
+} {}
+
+do_execsql_test 1.2 {
+ SELECT * FROM t1 WHERE x='one';
+ PRAGMA integrity_check;
+} {one two ok}
+
+db close
+forcedelete test.db
+forcedelete test.db2
+sqlite3 db test.db
+
+#-------------------------------------------------------------------------
+# Test that if the source is zero bytes, the destination database
+# consists of a single page only.
+#
+do_execsql_test 2.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+}
+do_test 2.2 { file size test.db } [expr $AUTOVACUUM ? 4096 : 3072]
+
+do_test 2.3 {
+ sqlite3 db1 test.db2
+ db1 backup test.db
+ db1 close
+ file size test.db
+} {1024}
+
+do_test 2.4 { file size test.db2 } 0
+
+db close
+forcedelete test.db
+forcedelete test.db2
+sqlite3 db test.db
+
+#-------------------------------------------------------------------------
+# Test that if the destination has a page-size larger than the implicit
+# page-size of the source, the final destination database still consists
+# of a single page.
+#
+do_execsql_test 3.1 {
+ PRAGMA page_size = 4096;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+}
+do_test 3.2 { file size test.db } [expr $AUTOVACUUM ? 16384 : 12288]
+
+do_test 3.3 {
+ sqlite3 db1 test.db2
+ db1 backup test.db
+ db1 close
+ file size test.db
+} {1024}
+
+do_test 3.4 { file size test.db2 } 0
+
+finish_test
diff --git a/test/backup5.test b/test/backup5.test
new file mode 100644
index 0000000..c789adf
--- /dev/null
+++ b/test/backup5.test
@@ -0,0 +1,65 @@
+# 2014 November 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix backup5
+
+forcedelete test2.db
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES(1, 1);
+ INSERT INTO t2 VALUES(2, 2);
+ INSERT INTO t2 VALUES(3, 3);
+}
+
+do_test 1.1 {
+ forcecopy test.db test.db2
+ db eval {
+ DROP TABLE t2;
+ INSERT INTO t1 VALUES(zeroblob(1000), zeroblob(1000));
+ INSERT INTO t1 VALUES(randomblob(1000), randomblob(1000));
+ }
+} {}
+
+do_test 1.2 {
+ sqlite3 db2 test.db2
+ set stmt [sqlite3_prepare_v2 db2 "SELECT * FROM t2" -1 dummy]
+ sqlite3_step $stmt
+} {SQLITE_ROW}
+
+do_test 1.3 {
+ list [catch { sqlite3_backup B db2 main db main } msg] $msg
+} {1 {sqlite3_backup_init() failed}}
+
+do_test 1.4 {
+ sqlite3_errmsg db2
+} {destination database is in use}
+
+do_test 1.5 {
+ sqlite3_reset $stmt
+ sqlite3_backup B db2 main db main
+ B step 200
+ B finish
+} {SQLITE_OK}
+
+do_test 1.6 {
+ list [sqlite3_step $stmt] [sqlite3_finalize $stmt]
+} {SQLITE_ERROR SQLITE_ERROR}
+
+do_test 1.7 {
+ sqlite3_errmsg db2
+} {no such table: t2}
+
+finish_test
diff --git a/test/backup_ioerr.test b/test/backup_ioerr.test
new file mode 100644
index 0000000..ca3fd32
--- /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 occurred 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 occurred 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..5444a70
--- /dev/null
+++ b/test/backup_malloc.test
@@ -0,0 +1,119 @@
+# 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
+}
+
+reset_db
+do_execsql_test 3.0 {
+ PRAGMA page_size = 16384;
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ COMMIT;
+}
+
+do_faultsim_test 3 -faults oom* -prep {
+ catch { db close }
+ catch { db2 close }
+
+ forcedelete test2.db
+ sqlite3 db2 test2.db
+ sqlite3 db test.db
+ sqlite3_backup B db2 main db main
+} -body {
+
+ set rc [B step 50]
+ if {$rc == "SQLITE_NOMEM" || $rc == "SQLITE_IOERR_NOMEM"} {
+ error "out of memory"
+ }
+
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+
+ # Finalize the backup.
+ catch { B finish }
+}
+
+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..64a730d
--- /dev/null
+++ b/test/badutf2.test
@@ -0,0 +1,127 @@
+# 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
+ }
+
+ # Tcl 8.7 and later do automatic bad-utf8 correction for
+ # characters 0x80 thru 0x9f so test case 5 does not work here.
+ if {$i==5 && $tcl_version>=8.7} {
+ # no-op
+ } else {
+ 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/bc_common.tcl b/test/bc_common.tcl
new file mode 100644
index 0000000..c47f996
--- /dev/null
+++ b/test/bc_common.tcl
@@ -0,0 +1,75 @@
+
+
+
+proc bc_find_binaries {zCaption} {
+ # 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 self [info nameofexec]
+ set pattern "$self?*"
+ if {$::tcl_platform(platform)=="windows"} {
+ set pattern [string map {\.exe {}} $pattern]
+ }
+ foreach file [glob -nocomplain $pattern] {
+ if {$file==$self} continue
+ if {[file executable $file] && [file isfile $file]} {lappend binaries $file}
+ }
+
+ if {[llength $binaries]==0} {
+ puts "WARNING: No historical binaries to test against."
+ puts "WARNING: Omitting backwards-compatibility tests"
+ }
+
+ foreach bin $binaries {
+ puts -nonewline "Testing against $bin - "
+ flush stdout
+ puts "version [get_version $bin]"
+ }
+
+ set ::BC(binaries) $binaries
+ return $binaries
+}
+
+proc get_version {binary} {
+ set chan [launch_testfixture $binary]
+ set v [testfixture $chan { sqlite3 -version }]
+ close $chan
+ set v
+}
+
+proc do_bc_test {bin script} {
+
+ forcedelete test.db
+ set ::bc_chan [launch_testfixture $bin]
+
+ proc code1 {tcl} { uplevel #0 $tcl }
+ proc code2 {tcl} { testfixture $::bc_chan $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 }
+
+ set bintag $bin
+ regsub {.*testfixture\.} $bintag {} bintag
+ set bintag [string map {\.exe {}} $bintag]
+ if {$bintag == ""} {set bintag self}
+ set saved_prefix $::testprefix
+ append ::testprefix ".$bintag"
+
+ uplevel $script
+
+ set ::testprefix $saved_prefix
+
+ catch { code1 { db close } }
+ catch { code2 { db close } }
+ catch { close $::bc_chan }
+}
+
+proc do_all_bc_test {script} {
+ foreach bin $::BC(binaries) {
+ uplevel [list do_bc_test $bin $script]
+ }
+}
diff --git a/test/bestindex1.test b/test/bestindex1.test
new file mode 100644
index 0000000..e505a8b
--- /dev/null
+++ b/test/bestindex1.test
@@ -0,0 +1,344 @@
+# 2016-03-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.
+#
+#***********************************************************************
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bestindex1
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_tcl_module db
+
+proc vtab_command {method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(a, b, c)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+
+ if {[llength $clist]!=1} { error "unexpected constraint list" }
+ catch { array unset C }
+ array set C [lindex $clist 0]
+ if {$C(usable)} {
+ return "omit 0 cost 0 rows 1 idxnum 555 idxstr eq!"
+ } else {
+ return "cost 1000000 rows 0 idxnum 0 idxstr scan..."
+ }
+ }
+
+ }
+
+ return {}
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
+} {}
+
+do_eqp_test 1.1 {
+ SELECT * FROM x1 WHERE a = 'abc'
+} {SCAN x1 VIRTUAL TABLE INDEX 555:eq!}
+
+do_eqp_test 1.2 {
+ SELECT * FROM x1 WHERE a IN ('abc', 'def');
+} {SCAN x1 VIRTUAL TABLE INDEX 555:eq!}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+register_tcl_module db
+
+# Parameter $mode may be one of:
+#
+# "omit" - Implement filtering. Set the omit flag.
+# "use" - Implement filtering. Use the constraint, but do not set omit.
+# "use2" - Do not implement filtering. Use the constraint anyway.
+#
+#
+proc t1_vtab {mode method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(a, b)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+
+ set SQL_FILTER {SELECT * FROM t1x WHERE a='%1%'}
+ set SQL_SCAN {SELECT * FROM t1x}
+
+ set idx 0
+ for {set idx 0} {$idx < [llength $clist]} {incr idx} {
+ array unset C
+ array set C [lindex $clist $idx]
+ if {$C(column)==0 && $C(op)=="eq" && $C(usable)} {
+ switch -- $mode {
+ "omit" {
+ return [list omit $idx rows 10 cost 10 idxstr $SQL_FILTER]
+ }
+ "use" {
+ return [list use $idx rows 10 cost 10 idxstr $SQL_FILTER]
+ }
+ "use2" {
+ return [list use $idx rows 10 cost 10 idxstr $SQL_SCAN]
+ }
+ default {
+ error "Bad mode - $mode"
+ }
+ }
+ }
+ }
+
+ return [list idxstr {SELECT * FROM t1x}]
+ }
+
+ xFilter {
+ set map [list %1% [lindex $args 2 0]]
+ set sql [string map $map [lindex $args 1]]
+ return [list sql $sql]
+ }
+ }
+
+ return {}
+}
+
+do_execsql_test 2.1 {
+ CREATE TABLE t1x(i INTEGER PRIMARY KEY, a, b);
+ INSERT INTO t1x VALUES(1, 'one', 1);
+ INSERT INTO t1x VALUES(2, 'two', 2);
+ INSERT INTO t1x VALUES(3, 'three', 3);
+ INSERT INTO t1x VALUES(4, 'four', 4);
+}
+
+foreach {tn mode} {
+ 1 use 2 omit 3 use2
+} {
+ do_execsql_test 2.2.$mode.1 "
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING tcl(t1_vtab $mode);
+ "
+
+ do_execsql_test 2.2.$mode.2 {SELECT * FROM t1} {one 1 two 2 three 3 four 4}
+ do_execsql_test 2.2.$mode.3 {SELECT rowid FROM t1} {1 2 3 4}
+ do_execsql_test 2.2.$mode.4 {SELECT rowid FROM t1 WHERE a='two'} {2}
+
+ do_execsql_test 2.2.$mode.5 {
+ SELECT rowid FROM t1 WHERE a IN ('one', 'four') ORDER BY +rowid
+ } {1 4}
+
+ set plan(use) {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 0:SELECT * FROM t1x WHERE a='%1%'
+ `--USE TEMP B-TREE FOR ORDER BY
+ }
+ set plan(omit) {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 0:SELECT * FROM t1x WHERE a='%1%'
+ `--USE TEMP B-TREE FOR ORDER BY
+ }
+ set plan(use2) {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 0:SELECT * FROM t1x
+ `--USE TEMP B-TREE FOR ORDER BY
+ }
+
+ do_eqp_test 2.2.$mode.6 {
+ SELECT rowid FROM t1 WHERE a IN ('one', 'four') ORDER BY +rowid
+ } [string map {"\n " "\n"} $plan($mode)]
+}
+
+# 2016-04-09.
+# Demonstrate a register overwrite problem when using two virtual
+# tables where the outer loop uses the IN operator.
+#
+set G(collist) [list PrimaryKey flagA columnA]
+set G(cols) [join $G(collist) ,]
+set G(nulls) "NULL"
+
+proc vtab_command {method args} {
+ global G
+
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1($G(cols))"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+
+ #puts $clist
+ set W [list]
+ set U [list]
+
+ set i 0
+ for {set idx 0} {$idx < [llength $clist]} {incr idx} {
+ array set c [lindex $clist $idx]
+ if {$c(op)=="eq" && $c(usable)} {
+ lappend W "[lindex $G(collist) $c(column)] = %$i%"
+ lappend U use $idx
+ incr i
+ }
+ }
+
+ if {$W==""} {
+ set sql "SELECT rowid, * FROM t1"
+ } else {
+ set sql "SELECT rowid, * FROM t1 WHERE [join $W { AND }]"
+ }
+
+ return [concat [list idxstr $sql] $U]
+ }
+
+ xFilter {
+ foreach {idxnum idxstr vals} $args {}
+
+ set map [list]
+ for {set i 0} {$i < [llength $vals]} {incr i} {
+ lappend map "%$i%"
+ set v [lindex $vals $i]
+ if {[string is integer $v]} {
+ lappend map $v
+ } else {
+ lappend map "'$v'"
+ }
+ }
+ set sql [string map $map $idxstr]
+
+ #puts "SQL: $sql"
+ return [list sql $sql]
+ }
+ }
+
+ return {}
+}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+register_tcl_module db
+
+do_execsql_test 3.1 "
+ CREATE TABLE t1($G(cols));
+ INSERT INTO t1 VALUES(1, 0, 'ValueA');
+ INSERT INTO t1 VALUES(2, 0, 'ValueA');
+ INSERT INTO t1 VALUES(3, 0, 'ValueB');
+ INSERT INTO t1 VALUES(4, 0, 'ValueB');
+"
+
+do_execsql_test 3.2 {
+ CREATE VIRTUAL TABLE VirtualTableA USING tcl(vtab_command);
+ CREATE VIRTUAL TABLE VirtualTableB USING tcl(vtab_command);
+}
+
+do_execsql_test 3.3 { SELECT primarykey FROM VirtualTableA } {1 2 3 4}
+
+do_execsql_test 3.4 {
+ SELECT * FROM
+ VirtualTableA a CROSS JOIN VirtualTableB b ON b.PrimaryKey=a.PrimaryKey
+ WHERE a.ColumnA IN ('ValueA', 'ValueB') AND a.FlagA=0
+} {
+ 1 0 ValueA 1 0 ValueA
+ 2 0 ValueA 2 0 ValueA
+ 3 0 ValueB 3 0 ValueB
+ 4 0 ValueB 4 0 ValueB
+}
+
+do_execsql_test 3.5 {
+ SELECT * FROM
+ VirtualTableA a CROSS JOIN VirtualTableB b ON b.PrimaryKey=a.PrimaryKey
+ WHERE a.FlagA=0 AND a.ColumnA IN ('ValueA', 'ValueB')
+} {
+ 1 0 ValueA 1 0 ValueA
+ 2 0 ValueA 2 0 ValueA
+ 3 0 ValueB 3 0 ValueB
+ 4 0 ValueB 4 0 ValueB
+}
+
+#-------------------------------------------------------------------------
+# If there is an IN(..) condition in the WHERE clause of a query on a
+# virtual table, the xBestIndex method is first invoked with the IN(...)
+# represented by a "usable" SQLITE_INDEX_CONSTRAINT_EQ constraint. If
+# the virtual table elects to use the IN(...) constraint, then the
+# xBestIndex method is invoked again, this time with the IN(...) marked
+# as "not usable". Depending on the relative costs of the two plans as
+# defined by the virtual table implementation, and the cardinality of the
+# IN(...) operator, SQLite chooses the most efficient plan.
+#
+# At one point the second invocation of xBestIndex() was only being made
+# for join queries. The following tests check that this problem has been
+# fixed.
+#
+proc vtab_command {method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(a, b, c, d)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+
+ lappend ::bestindex_calls $clist
+ set ret "cost 1000000 idxnum 555"
+ for {set i 0} {$i < [llength $clist]} {incr i} {
+ array set C [lindex $clist $i]
+ if {$C(usable)} {
+ lappend ret use $i
+ }
+ }
+ return $ret
+ }
+ }
+ return {}
+}
+
+do_execsql_test 4.0 {
+ CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
+} {}
+
+do_test 4.1 {
+ set ::bestindex_calls [list]
+ execsql {
+ SELECT * FROM x1 WHERE a=? AND b BETWEEN ? AND ? AND c IN (1, 2, 3, 4);
+ }
+ set ::bestindex_calls
+} [list \
+ [list {op eq column 0 usable 1} \
+ {op eq column 2 usable 1} \
+ {op ge column 1 usable 1} \
+ {op le column 1 usable 1} \
+ ] \
+ [list {op eq column 0 usable 1} \
+ {op eq column 2 usable 0} \
+ {op ge column 1 usable 1} \
+ {op le column 1 usable 1}
+ ]
+]
+
+do_catchsql_test 5.0 {
+ SELECT * FROM tcl('abc');
+} {1 {wrong number of arguments}}
+
+finish_test
diff --git a/test/bestindex2.test b/test/bestindex2.test
new file mode 100644
index 0000000..c47a721
--- /dev/null
+++ b/test/bestindex2.test
@@ -0,0 +1,145 @@
+# 2016 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.
+#
+#***********************************************************************
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bestindex2
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Virtual table callback for table named $tbl, with the columns specified
+# by list argument $cols. e.g. if the function is invoked as:
+#
+# vtab_cmd t1 {a b c} ...
+#
+# The table created is:
+#
+# "CREATE TABLE t1 (a, b, c)"
+#
+# The tables xBestIndex method behaves as if all possible combinations of
+# "=" constraints (but no others) may be optimized. The cost of a full table
+# scan is:
+#
+# "WHERE 1" "cost 1000000 rows 1000000"
+#
+# If one or more "=" constraints are in use, the cost and estimated number
+# of rows returned are both is (11 - nCons)*1000, where nCons is the number
+# of constraints used. e.g.
+#
+# "WHERE a=? AND b=?" -> "cost 900 rows 900"
+# "WHERE c=? AND b<?" -> "cost 1000 rows 1000"
+#
+proc vtab_cmd {tbl cols method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE $tbl ([join $cols ,])"
+ }
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+ set mask [$hdl mask]
+
+ set cons [list]
+ set used [list]
+
+ for {set i 0} {$i < [llength $clist]} {incr i} {
+ array unset C
+ array set C [lindex $clist $i]
+ if {$C(op)=="eq" && $C(usable) && [lsearch $cons $C(column)]<0} {
+ lappend used use $i
+ lappend cons $C(column)
+ }
+ }
+
+ set nCons [llength $cons]
+ if {$nCons==0} {
+ return "cost 1000000 rows 1000000"
+ } else {
+ set cost [expr (11-$nCons) * 1000]
+ set ret [concat $used "cost $cost rows $cost"]
+
+ set txt [list]
+ foreach c $cons { lappend txt "[lindex $cols $c]=?" }
+ lappend ret idxstr "indexed([join $txt { AND }])"
+
+ return $ret
+ }
+ }
+ }
+ return ""
+}
+
+register_tcl_module db
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING tcl("vtab_cmd t1 {a b}");
+ CREATE VIRTUAL TABLE t2 USING tcl("vtab_cmd t2 {c d}");
+ CREATE VIRTUAL TABLE t3 USING tcl("vtab_cmd t3 {e f}");
+}
+
+do_eqp_test 1.1 {
+ SELECT * FROM t1 WHERE a='abc'
+} {SCAN t1 VIRTUAL TABLE INDEX 0:indexed(a=?)}
+
+do_eqp_test 1.2 {
+ SELECT * FROM t1 WHERE a='abc' AND b='def'
+} {SCAN t1 VIRTUAL TABLE INDEX 0:indexed(a=? AND b=?)}
+
+do_eqp_test 1.3 {
+ SELECT * FROM t1 WHERE a='abc' AND a='def'
+} {SCAN t1 VIRTUAL TABLE INDEX 0:indexed(a=?)}
+
+do_eqp_test 1.4 {
+ SELECT * FROM t1,t2 WHERE c=a
+} {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 0:
+ `--SCAN t2 VIRTUAL TABLE INDEX 0:indexed(c=?)
+}
+
+do_eqp_test 1.5 {
+ SELECT * FROM t1, t2 CROSS JOIN t3 WHERE t2.c = +t1.b AND t3.e=t2.d
+} {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 0:
+ |--SCAN t2 VIRTUAL TABLE INDEX 0:indexed(c=?)
+ `--SCAN t3 VIRTUAL TABLE INDEX 0:indexed(e=?)
+}
+
+do_eqp_test 1.6 {
+ SELECT * FROM t1, t2, t3 WHERE t2.c = +t1.b AND t3.e = t2.d
+} {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 0:
+ |--SCAN t2 VIRTUAL TABLE INDEX 0:indexed(c=?)
+ `--SCAN t3 VIRTUAL TABLE INDEX 0:indexed(e=?)
+}
+
+do_execsql_test 1.7.1 {
+ CREATE TABLE x1(a, b);
+}
+do_eqp_test 1.7.2 {
+ SELECT * FROM x1 CROSS JOIN t1, t2, t3
+ WHERE t1.a = t2.c AND t1.b = t3.e
+} {
+ QUERY PLAN
+ |--SCAN x1
+ |--SCAN t1 VIRTUAL TABLE INDEX 0:
+ |--SCAN t2 VIRTUAL TABLE INDEX 0:indexed(c=?)
+ `--SCAN t3 VIRTUAL TABLE INDEX 0:indexed(e=?)
+}
+
+finish_test
diff --git a/test/bestindex3.test b/test/bestindex3.test
new file mode 100644
index 0000000..6aa3321
--- /dev/null
+++ b/test/bestindex3.test
@@ -0,0 +1,185 @@
+# 2016 May 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
+set testprefix bestindex3
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Virtual table callback for a virtual table named $tbl.
+#
+# The table created is:
+#
+# "CREATE TABLE t1 (a, b, c)"
+#
+# This virtual table supports both LIKE and = operators on all columns.
+#
+proc vtab_cmd {bOmit method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(a, b, c)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+ set mask [$hdl mask]
+
+ set ret [list]
+ set use use
+ if {$bOmit} {set use omit}
+
+ for {set i 0} {$i < [llength $clist]} {incr i} {
+ array unset C
+ array set C [lindex $clist $i]
+ if {$C(usable) && ($C(op)=="like" || $C(op)=="eq")} {
+ lappend ret $use $i
+ lappend ret idxstr
+ lappend ret "[lindex {a b c} $C(column)] [string toupper $C(op)] ?"
+ break
+ }
+ }
+
+ if {$ret==""} {
+ lappend ret cost 1000000 rows 1000000
+ } else {
+ lappend ret cost 100 rows 10
+ }
+ return $ret
+ }
+
+ xFilter {
+ foreach {idxnum idxstr param} $args {}
+ set where ""
+ if {$bOmit && $idxstr != ""} {
+ set where " WHERE [string map [list ? '$param' EQ =] $idxstr]"
+ }
+ return [list sql "SELECT rowid, * FROM ttt$where"]
+ }
+ }
+ return ""
+}
+
+register_tcl_module db
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING tcl("vtab_cmd 0");
+}
+
+do_eqp_test 1.1 {
+ SELECT * FROM t1 WHERE a LIKE 'abc';
+} {SCAN t1 VIRTUAL TABLE INDEX 0:a LIKE ?}
+
+do_eqp_test 1.2 {
+ SELECT * FROM t1 WHERE a = 'abc';
+} {SCAN t1 VIRTUAL TABLE INDEX 0:a EQ ?}
+
+do_eqp_test 1.3 {
+ SELECT * FROM t1 WHERE a = 'abc' OR b = 'def';
+} {
+ QUERY PLAN
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SCAN t1 VIRTUAL TABLE INDEX 0:a EQ ?
+ `--INDEX 2
+ `--SCAN t1 VIRTUAL TABLE INDEX 0:b EQ ?
+}
+
+do_eqp_test 1.4 {
+ SELECT * FROM t1 WHERE a LIKE 'abc%' OR b = 'def';
+} {
+ QUERY PLAN
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SCAN t1 VIRTUAL TABLE INDEX 0:a LIKE ?
+ `--INDEX 2
+ `--SCAN t1 VIRTUAL TABLE INDEX 0:b EQ ?
+}
+
+do_execsql_test 1.5 {
+ CREATE TABLE ttt(a, b, c);
+
+ INSERT INTO ttt VALUES(1, 'two', 'three');
+ INSERT INTO ttt VALUES(2, 'one', 'two');
+ INSERT INTO ttt VALUES(3, 'three', 'one');
+ INSERT INTO ttt VALUES(4, 'y', 'one');
+ INSERT INTO ttt VALUES(5, 'x', 'two');
+ INSERT INTO ttt VALUES(6, 'y', 'three');
+}
+
+foreach omit {0 1} {
+ do_execsql_test 1.6.$omit.0 "
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING tcl('vtab_cmd $omit');
+ "
+ do_execsql_test 1.6.$omit.1 {
+ SELECT rowid FROM t1 WHERE c LIKE 'o%'
+ } {3 4}
+
+ do_execsql_test 1.6.$omit.2 {
+ SELECT rowid FROM t1 WHERE c LIKE 'o%' OR b='y'
+ } {3 4 6}
+
+ do_execsql_test 1.6.$omit.3 {
+ SELECT rowid FROM t1 WHERE c = 'three' OR c LIKE 'o%'
+ } {1 6 3 4}
+}
+
+#-------------------------------------------------------------------------
+# Test the same pattern works with ordinary tables.
+#
+# This test does not work if the ICU extension is enabled. ICU overrides
+# LIKE - and this optimization only works with the built-in LIKE function.
+#
+ifcapable !icu {
+ do_execsql_test 2.1 {
+ CREATE TABLE t2(x TEXT COLLATE nocase, y TEXT);
+ CREATE INDEX t2x ON t2(x COLLATE nocase);
+ CREATE INDEX t2y ON t2(y);
+ }
+
+ do_eqp_test 2.2 {
+ SELECT * FROM t2 WHERE x LIKE 'abc%' OR y = 'def'
+ } [string map {"\n " \n} {
+ QUERY PLAN
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SEARCH t2 USING INDEX t2x (x>? AND x<?)
+ `--INDEX 2
+ `--SEARCH t2 USING INDEX t2y (y=?)
+ }]
+}
+
+#-------------------------------------------------------------------------
+# Test that any PRIMARY KEY within a sqlite3_decl_vtab() CREATE TABLE
+# statement is currently ignored.
+#
+proc vvv_command {method args} {
+ switch -- $method {
+ xConnect { return "CREATE TABLE t1(a PRIMARY KEY, b, c)" }
+ }
+}
+proc yyy_command {method args} {
+ switch -- $method {
+ xConnect { return "CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b))" }
+ }
+}
+
+do_execsql_test 3.1 { CREATE VIRTUAL TABLE t3 USING tcl('vvv_command') }
+do_execsql_test 3.2 { CREATE VIRTUAL TABLE t4 USING tcl('yyy_command') }
+
+finish_test
diff --git a/test/bestindex4.test b/test/bestindex4.test
new file mode 100644
index 0000000..483656d
--- /dev/null
+++ b/test/bestindex4.test
@@ -0,0 +1,182 @@
+# 2016 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.
+#
+#***********************************************************************
+# Test the virtual table interface. In particular the xBestIndex
+# method.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bestindex4
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Virtual table callback for a virtual table named $tbl.
+#
+# The table created is:
+#
+# "CREATE TABLE t1 (id, host, class)"
+#
+# The virtual table supports == operators on a subset of its columns. The
+# exact subset depends on the value of bitmask paramater $param.
+#
+# 0x01 - == on "id" supported
+# 0x02 - == on "host" supported
+# 0x04 - == on "class" supported
+#
+# $param also supports the following bits:
+#
+# 0x08 - ignore the "usable" flag (malfunction)
+#
+#
+#
+proc vtab_cmd {param method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(id TEXT, host TEXT, class TEXT)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+ set mask [$hdl mask]
+
+ set ret [list]
+
+ set use use
+
+
+ for {set i 0} {$i < [llength $clist]} {incr i} {
+ array unset C
+ array set C [lindex $clist $i]
+ if { ($C(usable) || ($param & 0x08))
+ && $C(op)=="eq" && ($param & 1<<$C(column))
+ } {
+ lappend ret $use $i
+ break
+ }
+ }
+
+ set score 1000000
+ if {$ret!=""} {
+ set score [expr $score / [llength $ret]]
+ }
+ lappend ret cost $score rows $score
+
+ return $ret
+ }
+
+ xFilter {
+ }
+ }
+ return ""
+}
+
+register_tcl_module db
+
+for {set param1 0} {$param1<16} {incr param1} {
+ for {set param2 0} {$param2<16} {incr param2} {
+ reset_db
+ register_tcl_module db
+ do_execsql_test 1.$param1.$param2.1 "
+ CREATE VIRTUAL TABLE t1 USING tcl('vtab_cmd $param1');
+ CREATE VIRTUAL TABLE t2 USING tcl('vtab_cmd $param2');
+ "
+
+ foreach {tn sql} {
+ 2 "select t1.id as ID from t1, t2 where t1.id=t2.host and t2.class='xx'"
+ 3 {
+ select t1.id as ID from t1, t2 where t2.class ='xx' and t2.id = t1.host
+ }
+ 4 {
+ select t1.id as ID from t1, t2 where t1.host = t2.id and t2. class ='xx'
+ }
+ } {
+
+ if {($param1 & 0x08)==0 && ($param2 & 0x08)==0} {
+
+ do_execsql_test 1.$param1.$param2.$tn.a $sql {}
+
+ } else {
+ do_test 1.$param1.$param2.$tn.b {
+ catchsql $sql
+ set {} {}
+ } {}
+ }
+ }
+
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that a parameter passed to a table-valued function cannot be
+# used to drive an index. i.e. that in the following:
+#
+# SELECT * FROM tbl, vtab(tbl.x);
+#
+# The implicit constraint "tbl.x = vtab.hidden" is not optimized using
+# an index on tbl.x.
+#
+reset_db
+register_tcl_module db
+proc vtab_command {method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(a, b, c, d HIDDEN)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+ set mask [$hdl mask]
+
+ if {[llength $clist]!=1} { error "unexpected constraint list" }
+ catch { array unset C }
+ array set C [lindex $clist 0]
+ if {$C(usable)} {
+ return [list omit 0 idxnum 555 rows 10 cost 100]
+ }
+ return [list cost 100000000]
+ }
+
+ }
+
+ return {}
+}
+
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
+ CREATE TABLE t1 (x INT PRIMARY KEY);
+} {}
+
+do_eqp_test 2.1 {
+ SELECT * FROM t1, x1 WHERE x1.d=t1.x;
+} {
+ QUERY PLAN
+ |--SCAN x1 VIRTUAL TABLE INDEX 0:
+ `--SEARCH t1 USING COVERING INDEX sqlite_autoindex_t1_1 (x=?)
+}
+
+do_eqp_test 2.2 {
+ SELECT * FROM t1, x1(t1.x)
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SCAN x1 VIRTUAL TABLE INDEX 555:
+}
+
+
+finish_test
diff --git a/test/bestindex5.test b/test/bestindex5.test
new file mode 100644
index 0000000..35df58a
--- /dev/null
+++ b/test/bestindex5.test
@@ -0,0 +1,252 @@
+# 2017 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.
+#
+#***********************************************************************
+# Test the virtual table interface. In particular the xBestIndex
+# method.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bestindex5
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Virtual table callback for a virtual table named $tbl.
+#
+proc vtab_cmd {method args} {
+
+ set binops(ne) !=
+ set binops(eq) =
+ set binops(isnot) "IS NOT"
+ set binops(is) "IS"
+
+ set unops(isnotnull) "IS NOT NULL"
+ set unops(isnull) "IS NULL"
+
+ set cols(0) a
+ set cols(1) b
+ set cols(2) c
+
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(a, b, c)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+ set mask [$hdl mask]
+
+ set cost 1000000.0
+ set ret [list]
+ set str [list]
+
+ set v 0
+ for {set i 0} {$i < [llength $clist]} {incr i} {
+ array unset C
+ array set C [lindex $clist $i]
+ if {$C(usable)} {
+ if {[info exists binops($C(op))]} {
+ lappend ret omit $i
+ lappend str "$cols($C(column)) $binops($C(op)) %$v%"
+ incr v
+ set cost [expr $cost / 2]
+ }
+ if {[info exists unops($C(op))]} {
+ lappend ret omit $i
+ lappend str "$cols($C(column)) $unops($C(op))"
+ incr v
+ set cost [expr $cost / 2]
+ }
+ }
+ }
+
+ lappend ret idxstr [join $str " AND "]
+ lappend ret cost $cost
+ return $ret
+ }
+
+ xFilter {
+ set q [lindex $args 1]
+ set a [lindex $args 2]
+ for {set v 0} {$v < [llength $a]} {incr v} {
+ set val [lindex $a $v]
+ set q [string map [list %$v% '$val'] $q]
+ }
+ if {$q==""} { set q 1 }
+ lappend ::xFilterQueries "WHERE $q"
+ return [list sql "SELECT rowid, * FROM t1x WHERE $q"]
+ }
+ }
+ return ""
+}
+
+proc vtab_simple {method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t2(x)"
+ }
+ xBestIndex {
+ return [list cost 999999.0]
+ }
+ xFilter {
+ return [list sql "SELECT rowid, * FROM t2x"]
+ }
+ }
+ return ""
+}
+
+register_tcl_module db
+
+proc do_vtab_query_test {tn query result} {
+ set ::xFilterQueries [list]
+ uplevel [list
+ do_test $tn [string map [list %QUERY% $query] {
+ set r [execsql {%QUERY%}]
+ set r [concat $::xFilterQueries $r]
+ set r
+ }] [list {*}$result]
+ ]
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING tcl('vtab_cmd');
+ CREATE TABLE t1x(a INTEGER, b TEXT, c REAL);
+ INSERT INTO t1x VALUES(1, 2, 3);
+ INSERT INTO t1x VALUES(4, 5, 6);
+ INSERT INTO t1x VALUES(7, 8, 9);
+
+ CREATE VIRTUAL TABLE t2 USING tcl('vtab_simple');
+ CREATE TABLE t2x(x INTEGER);
+ INSERT INTO t2x VALUES(1);
+}
+
+do_vtab_query_test 1.1 { SELECT * FROM t1 WHERE a!='hello'; } {
+ "WHERE a != 'hello'"
+ 1 2 3.0 4 5 6.0 7 8 9.0
+}
+
+do_vtab_query_test 1.2.1 { SELECT * FROM t1 WHERE b!=8 } {
+ "WHERE b != '8'"
+ 1 2 3.0 4 5 6.0
+}
+do_vtab_query_test 1.2.2 { SELECT * FROM t1 WHERE 8!=b } {
+ "WHERE b != '8'"
+ 1 2 3.0 4 5 6.0
+}
+
+do_vtab_query_test 1.3 { SELECT * FROM t1 WHERE c IS NOT 3 } {
+ "WHERE c IS NOT '3'"
+ 4 5 6.0 7 8 9.0
+}
+do_vtab_query_test 1.3.2 { SELECT * FROM t1 WHERE 3 IS NOT c } {
+ "WHERE c IS NOT '3'"
+ 4 5 6.0 7 8 9.0
+}
+
+do_vtab_query_test 1.4.1 { SELECT * FROM t1, t2 WHERE x != a } {
+ "WHERE a != '1'"
+ 4 5 6.0 1 7 8 9.0 1
+}
+do_vtab_query_test 1.4.2 { SELECT * FROM t1, t2 WHERE a != x } {
+ "WHERE a != '1'"
+ 4 5 6.0 1 7 8 9.0 1
+}
+
+do_vtab_query_test 1.5.1 { SELECT * FROM t1 WHERE a IS NOT NULL } {
+ "WHERE a IS NOT NULL"
+ 1 2 3.0 4 5 6.0 7 8 9.0
+}
+do_vtab_query_test 1.5.2 { SELECT * FROM t1 WHERE NULL IS NOT a } {
+ "WHERE a IS NOT ''"
+ 1 2 3.0 4 5 6.0 7 8 9.0
+}
+
+do_vtab_query_test 1.6.1 { SELECT * FROM t1 WHERE a IS NULL } {
+ "WHERE a IS NULL"
+}
+
+do_vtab_query_test 1.6.2 { SELECT * FROM t1 WHERE NULL IS a } {
+ "WHERE a IS ''"
+}
+
+do_vtab_query_test 1.7.1 { SELECT * FROM t1 WHERE (a, b) IS (1, 2) } {
+ "WHERE a IS '1' AND b IS '2'"
+ 1 2 3.0
+}
+do_vtab_query_test 1.7.2 { SELECT * FROM t1 WHERE (5, 4) IS (b, a) } {
+ {WHERE b IS '5' AND a IS '4'}
+ 4 5 6.0
+}
+
+#---------------------------------------------------------------------
+do_execsql_test 2.0.0 {
+ DELETE FROM t1x;
+ INSERT INTO t1x VALUES('a', 'b', 'c');
+}
+do_execsql_test 2.0.1 { SELECT * FROM t1 } {a b c}
+do_execsql_test 2.0.2 { SELECT * FROM t1 WHERE (a, b) != ('a', 'b'); } {}
+
+do_execsql_test 2.1.0 {
+ DELETE FROM t1x;
+ INSERT INTO t1x VALUES(7, 8, 9);
+}
+do_execsql_test 2.1.1 { SELECT * FROM t1 } {7 8 9.0}
+do_execsql_test 2.1.2 { SELECT * FROM t1 WHERE (a, b) != (7, '8') } {}
+do_execsql_test 2.1.3 { SELECT * FROM t1 WHERE a!=7 OR b!='8' }
+do_execsql_test 2.1.4 { SELECT * FROM t1 WHERE a!=7 OR b!='8' }
+
+
+do_execsql_test 2.2.1 {
+ CREATE TABLE t3(a INTEGER, b TEXT);
+ INSERT INTO t3 VALUES(45, 46);
+}
+do_execsql_test 2.2.2 { SELECT * FROM t3 WHERE (a, b) != (45, 46); }
+do_execsql_test 2.2.3 { SELECT * FROM t3 WHERE (a, b) != ('45', '46'); }
+do_execsql_test 2.2.4 { SELECT * FROM t3 WHERE (a, b) == (45, 46); } {45 46}
+do_execsql_test 2.2.5 { SELECT * FROM t3 WHERE (a, b) == ('45', '46'); } {45 46}
+
+#---------------------------------------------------------------------
+# Test the != operator on a virtual table with column affinities.
+#
+proc vtab_simple_integer {method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t4(x INTEGER)"
+ }
+ xBestIndex {
+ return [list cost 999999.0]
+ }
+ xFilter {
+ return [list sql "SELECT rowid, * FROM t4x"]
+ }
+ }
+ return ""
+}
+
+do_execsql_test 3.0 {
+ CREATE TABLE t4x(a INTEGER);
+ INSERT INTO t4x VALUES(245);
+ CREATE VIRTUAL TABLE t4 USING tcl('vtab_simple_integer');
+}
+do_execsql_test 3.1 { SELECT rowid, * FROM t4 WHERE x=245; } {1 245}
+do_execsql_test 3.2 { SELECT rowid, * FROM t4 WHERE x='245'; } {1 245}
+do_execsql_test 3.3 { SELECT rowid, * FROM t4 WHERE x!=245; } {}
+do_execsql_test 3.4 { SELECT rowid, * FROM t4 WHERE x!='245'; } {}
+
+do_execsql_test 3.5 { SELECT rowid, * FROM t4 WHERE rowid!=1 OR x!='245'; } {}
+
+
+finish_test
diff --git a/test/bestindex6.test b/test/bestindex6.test
new file mode 100644
index 0000000..8926ec4
--- /dev/null
+++ b/test/bestindex6.test
@@ -0,0 +1,113 @@
+# 2018-09-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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bestindex6
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_tcl_module db
+
+proc vtab_command {src method args} {
+ switch -- $method {
+ xConnect {
+ return [db one {SELECT sql FROM sqlite_master where name = $src}]
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+ set mask [$hdl mask]
+
+ set wlist 1
+
+ set iCons 0
+ set ret [list]
+ foreach cons $clist {
+ catch { array unset C }
+ array set C $cons
+
+ if {$C(usable)} {
+ set col [db one {
+ SELECT name FROM pragma_table_info($src) WHERE cid=$C(column)
+ }]
+ switch $C(op) {
+ isnull {
+ lappend wlist "$col IS NULL"
+ lappend ret omit $iCons
+ }
+ eq {
+ lappend wlist "$col = %$iCons%"
+ lappend ret omit $iCons
+ }
+ }
+ }
+ incr iCons
+ }
+ #puts "xBestIndex: $ret"
+ lappend ret idxStr [join $wlist " AND "]
+ return $ret
+ }
+
+ xFilter {
+ foreach {idxnum idxstr aa} $args {}
+ set map [list]
+ for {set iCons 0} {$iCons < [llength $aa]} {incr iCons} {
+ lappend map %$iCons% [lindex $aa $iCons]
+ }
+ set ret [list sql \
+ "SELECT rowid, * FROM $src WHERE [string map $map $idxstr]"
+ ]
+ # puts "xFilter: $ret"
+ return $ret
+ }
+
+ }
+
+ return {}
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(id int, value text);
+ CREATE TABLE t2(ctx int, id int, value text);
+
+ INSERT INTO t1 VALUES(1,'try');
+ INSERT INTO t2 VALUES(1,1,'good');
+ INSERT INTO t2 VALUES(2,2,'evil');
+
+ CREATE VIRTUAL TABLE vt1 USING tcl(vtab_command t1);
+ CREATE VIRTUAL TABLE vt2 USING tcl(vtab_command t2);
+}
+
+do_execsql_test 1.1 {
+ select * from t2 left join t1 on t1.id=t2.ctx where t1.value is null;
+} {2 2 evil {} {}}
+
+do_execsql_test 1.2 {
+ select * from vt2 left join vt1 on vt1.id=vt2.ctx where vt1.value is null;
+} {2 2 evil {} {}}
+
+unset -nocomplain xxx
+do_execsql_test 1.3 {
+ select * from vt2 left join vt1 on vt1.id=vt2.ctx where vt1.value is $xxx;
+} {2 2 evil {} {}}
+
+do_execsql_test 1.4 {
+ select * from t2 left join vt1 on vt1.id=t2.ctx where vt1.value = 3
+} {}
+
+finish_test
diff --git a/test/bestindex7.test b/test/bestindex7.test
new file mode 100644
index 0000000..a84b9ef
--- /dev/null
+++ b/test/bestindex7.test
@@ -0,0 +1,82 @@
+# 2020-01-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
+set testprefix bestindex7
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_tcl_module db
+
+proc vtab_command {src method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE xxx(a)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+ set mask [$hdl mask]
+
+ set iCons 0
+ set ret [list]
+ foreach cons $clist {
+ catch { array unset C }
+ array set C $cons
+ if {$C(usable)} {
+ lappend ret use $iCons
+ }
+ incr iCons
+ }
+ return $ret
+ }
+
+ xFilter {
+ return [list sql "SELECT rowid, x FROM $src"]
+ }
+
+ }
+
+ return {}
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(0), (2);
+ CREATE VIRTUAL TABLE vt1 USING tcl(vtab_command t1);
+}
+
+do_execsql_test 1.1 { select * from vt1 } {0 2}
+do_execsql_test 1.2 { select * from vt1 WHERE a=0 } {0}
+do_execsql_test 1.3 { select * from vt1 WHERE a=1 } {}
+do_execsql_test 1.4 { select * from vt1 WHERE a=1 OR a=0} {0}
+
+do_execsql_test 1.5 {
+ UPDATE t1 SET x=NULL WHERE x=2;
+}
+
+do_execsql_test 1.6 { select * from vt1 } {0 {}}
+do_execsql_test 1.7 { select * from vt1 WHERE a=0 } {0}
+do_execsql_test 1.8 { select * from vt1 WHERE a=1 } {}
+do_execsql_test 1.9 { select * from vt1 WHERE a=1 OR a=0} {0}
+do_execsql_test 1.10 { select * from vt1 WHERE a IN (2) } {}
+do_execsql_test 1.10 { select * from vt1 WHERE a IN (0,1,2,3) } {0}
+do_execsql_test 1.11 { select * from vt1 WHERE a IN (0, NULL) } {0}
+do_execsql_test 1.12 { select * from vt1 WHERE a IN (NULL) } {}
+
+finish_test
diff --git a/test/bestindex8.test b/test/bestindex8.test
new file mode 100644
index 0000000..e95c3c6
--- /dev/null
+++ b/test/bestindex8.test
@@ -0,0 +1,463 @@
+# 2020-01-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
+set testprefix bestindex8
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_tcl_module db
+
+proc vtab_command {src method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE xxx(a, b)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+ set orderby [$hdl orderby]
+ lappend ::lBestIndexDistinct [$hdl distinct]
+
+ #puts "ORDERBY: $orderby"
+ set iCons 0
+ set ret [list]
+ foreach cons $clist {
+ catch { array unset C }
+ array set C $cons
+ if {$C(usable)} {
+ lappend ret use $iCons
+ }
+ incr iCons
+ }
+ if {$orderby=="{column 0 desc 0} {column 1 desc 0}"
+ || $orderby=="{column 0 desc 0}"
+ } {
+ lappend ret orderby 1
+ lappend ret idxnum 1
+ set ::lOrderByConsumed 1
+ }
+ return $ret
+ }
+
+ xFilter {
+ set idxnum [lindex $args 0]
+ if {$idxnum} {
+ return [list sql "SELECT rowid, a, b FROM $src order by 2, 3"]
+ }
+ return [list sql "SELECT rowid, a, b FROM $src"]
+ }
+
+ }
+
+ return {}
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES('a', 'b'), ('c', 'd');
+ INSERT INTO t1 VALUES('a', 'b'), ('c', 'd');
+ CREATE VIRTUAL TABLE vt1 USING tcl(vtab_command t1);
+
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES (1), (0);
+}
+
+foreach {tn sql bDistinct idxinsert bConsumed res} {
+ 1 "SELECT a, b FROM vt1" 0 0 0 {a b c d a b c d}
+ 2 "SELECT DISTINCT a, b FROM vt1" 2 1 1 {a b c d}
+ 3 "SELECT DISTINCT a FROM vt1" 2 1 1 {a c}
+ 4 "SELECT DISTINCT b FROM vt1" 2 1 0 {b d}
+ 5 "SELECT DISTINCT b FROM vt1 ORDER BY a" 0 1 1 {b d}
+ 6 "SELECT DISTINCT t0.c0 FROM vt1, t0 ORDER BY vt1.a" 0 1 1 {1 0}
+ 7 "SELECT DISTINCT a, b FROM vt1 ORDER BY a, b" 3 0 1 {a b c d}
+ 8 "SELECT DISTINCT a, b FROM vt1 ORDER BY a" 0 1 1 {a b c d}
+ 9 "SELECT DISTINCT a FROM vt1 ORDER BY a, b" 0 1 1 {a c}
+
+ 10 "SELECT DISTINCT a, b FROM vt1 WHERE b='b'" 2 1 1 {a b}
+ 11 "SELECT DISTINCT a, b FROM vt1 WHERE +b='b'" 2 1 1 {a b}
+} {
+ set ::lBestIndexDistinct ""
+ set ::lOrderByConsumed 0
+ do_execsql_test 1.$tn.1 $sql $res
+ do_test 1.$tn.2 {
+ set ::lBestIndexDistinct
+ } $bDistinct
+ do_test 1.$tn.3 {
+ expr {[lsearch [execsql "explain $sql"] IdxInsert]>=0}
+ } $idxinsert
+ do_test 1.$tn.4 {
+ set ::lOrderByConsumed
+ } $bConsumed
+}
+
+#-------------------------------------------------------------------------
+reset_db
+register_tcl_module db
+
+proc vtab_command {src method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE xxx(a, b)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set ret [list]
+
+ set iCons 0
+ foreach cons [$hdl constraints] {
+ array set C $cons
+ if {($C(op)=="limit" || $C(op)=="offset") && $C(usable)} {
+ lappend ret use $iCons
+ }
+ incr iCons
+ }
+
+ return $ret
+ }
+
+ xFilter {
+ lappend ::lFilterArgs [lindex $args 2]
+ return [list sql "SELECT rowid, a, b FROM $src"]
+ }
+
+ }
+
+ return {}
+}
+
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ CREATE VIRTUAL TABLE vt1 USING tcl(vtab_command t1);
+}
+
+do_test 2.1 {
+ set ::lFilterArgs [list]
+ execsql { SELECT * FROM vt1 LIMIT 10 }
+ set ::lFilterArgs
+} {10}
+
+do_test 2.2 {
+ set ::lFilterArgs [list]
+ execsql { SELECT * FROM vt1 LIMIT 5 OFFSET 50 }
+ set ::lFilterArgs
+} {{5 50}}
+
+do_test 2.3 {
+ set ::lFilterArgs [list]
+ execsql { SELECT * FROM vt1 ORDER BY a, b LIMIT 1 OFFSET 1 }
+ set ::lFilterArgs
+} {{1 1}}
+
+do_test 2.4 {
+ set ::lFilterArgs [list]
+ execsql { SELECT * FROM vt1 ORDER BY a, +b LIMIT 1 OFFSET 1 }
+ set ::lFilterArgs
+} {{}}
+
+#-------------------------------------------------------------------------
+reset_db
+register_tcl_module db
+
+proc vtab_command {src method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE xxx(a, b)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set lCons [$hdl constraints]
+
+ set ret [list]
+ for {set i 0} {$i < [llength $lCons]} {incr i} {
+ array set C [lindex $lCons $i]
+ if {$C(usable)} {
+ lappend ret use $i
+ $hdl in $i 1
+ }
+ }
+ return $ret
+ }
+
+ xFilter {
+ set lArg [lindex $args 2]
+ lappend ::lFilterArg {*}$lArg
+ return [list sql "SELECT rowid, a, b FROM $src"]
+ }
+
+ }
+
+ return {}
+}
+
+do_execsql_test 3.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ CREATE VIRTUAL TABLE vt1 USING tcl(vtab_command t1);
+}
+
+foreach {tn sql lfa} {
+ 1 "SELECT * FROM vt1 WHERE b IN (10, 20, 30)" {{10 20 30}}
+ 2 "SELECT * FROM vt1 WHERE b IN ('abc', 'def')" {{abc def}}
+ 3 "SELECT * FROM vt1 WHERE a IS NULL AND b IN ('abc', 'def')" {{} {abc def}}
+ 4 "SELECT * FROM vt1 WHERE a IN (1,2,3) AND b IN ('abc', 'def')"
+ {{1 2 3} {abc def}}
+
+ 5 "SELECT * FROM vt1
+ WHERE a IN (SELECT 1 UNION SELECT 2) AND b IN ('abc', 'def')"
+ {{1 2} {abc def}}
+
+ 6 "SELECT * FROM vt1
+ WHERE b IN ('abc', 'def') AND a IN (SELECT 1 UNION SELECT 2)"
+ {{abc def} {1 2}}
+} {
+ do_test 3.$tn {
+ set ::lFilterArg [list]
+ execsql $sql
+ set ::lFilterArg
+ } $lfa
+}
+
+#explain_i { SELECT * FROM vt1 WHERE b IN (10, 20, 30) }
+
+#-------------------------------------------------------------------------
+reset_db
+register_tcl_module db
+
+proc vtab_command {src method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE xxx(a, b, c)"
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set lCons [$hdl constraints]
+
+ set ret [list]
+ for {set i 0} {$i < [llength $lCons]} {incr i} {
+ lappend ::lBestIndexRhs [$hdl rhs_value $i -]
+ }
+ return $ret
+ }
+
+ xFilter {
+ return [list sql "SELECT rowid, a, b, c FROM $src"]
+ }
+
+ }
+
+ return {}
+}
+
+do_execsql_test 4.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIRTUAL TABLE vt1 USING tcl(vtab_command t1);
+}
+
+foreach {tn sql lbir} {
+ 1 "SELECT * FROM vt1 WHERE b = 10" {10}
+ 2 "SELECT * FROM vt1 WHERE a = 'abc' AND b < 30" {abc 30}
+ 3 "SELECT * FROM vt1 WHERE a = 'abc' AND b < 30+2" {abc -}
+ 4 "SELECT * FROM vt1 WHERE a IN (1,2,3) AND b < 30+2" {- -}
+ 5 "SELECT * FROM vt1 WHERE a IS 111 AND b < 30+2" {111 -}
+} {
+ do_test 4.$tn {
+ set ::lBestIndexRhs [list]
+ execsql $sql
+ set ::lBestIndexRhs
+ } $lbir
+}
+
+#-------------------------------------------------------------------------
+reset_db
+db cache size 0
+register_tcl_module db
+
+set ::vtab_handle_in 1
+proc vtab_command {src method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE xxx(a, b, c)"
+ }
+
+ xBestIndex {
+ set lCols [list a b c]
+
+ set hdl [lindex $args 0]
+ set lCons [$hdl constraints]
+ set lOrder [$hdl order]
+
+ set L ""
+ set O ""
+ set W [list]
+ set a 0
+ for {set i 0} {$i < [llength $lCons]} {incr i} {
+ array set C [lindex $lCons $i]
+ if {$C(usable)} {
+ if { $C(op)=="eq" } {
+ set bIn 0
+ if {$::vtab_handle_in} { set bIn [$hdl in $i 1] }
+ if {$bIn} {
+ lappend W "[lindex $lCols $C(column)] IN (%I$a%)"
+ } else {
+ lappend W "[lindex $lCols $C(column)] = %$a%"
+ }
+ lappend ret omit $i
+ }
+ if { $C(op)=="limit" } { set L " LIMIT %$a%" ; lappend ret use $i }
+ if { $C(op)=="offset" } { set O " OFFSET %$a%" ; lappend ret use $i }
+ incr a
+ }
+ }
+
+ set order ""
+ set selectlist "rowid, a, b, c"
+ if {[llength $lOrder]} {
+ array set sl [list]
+ set lO [list]
+ foreach s $lOrder {
+ array set C $s
+ set ad ""
+ if {$C(desc)} { set ad " DESC" }
+ lappend lO "[lindex $lCols $C(column)]$ad"
+ set sl($C(column)) 1
+ }
+ if {[$hdl distinct]==2} {
+ set selectlist "DISTINCT 0"
+ foreach i {0 1 2} {
+ if {[info exists sl($i)]} {
+ append selectlist ", [lindex $lCols $i]"
+ } else {
+ append selectlist ", 0"
+ }
+ }
+ } else {
+ set order " ORDER BY [join $lO ,]"
+ }
+ }
+
+ set where ""
+ if {[llength $W]} { set where " WHERE [join $W { AND }]" }
+ set sql "SELECT $selectlist FROM $src$where$order$L$O"
+
+ lappend ret idxStr $sql
+ return $ret
+ }
+
+ xFilter {
+ foreach {idxnum idxstr lArg} $args {}
+ set ii 0
+ set sql $idxstr
+ foreach a $lArg {
+ set sql [string map [list %$ii% $a] $sql]
+ set sql [string map [list %I$ii% [join $a ,]] $sql]
+ incr ii
+ }
+ lappend ::lFilterSql $sql
+
+ if {[regexp {OFFSET (.*)$} $sql -> off]} {
+ set real_sql "
+ WITH c(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM c WHERE i<$off )
+ SELECT 0,0,0,0 FROM c
+ UNION ALL SELECT * FROM (
+ $sql
+ )
+ "
+ } else {
+ set real_sql $sql
+ }
+
+ return [list sql $real_sql]
+ }
+
+ }
+
+ return {}
+}
+
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIRTUAL TABLE vt1 USING tcl(vtab_command t1);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(2, 3, 4);
+ INSERT INTO t1 VALUES(3, 4, 5);
+ INSERT INTO t1 VALUES(1, 5, 6);
+ INSERT INTO t1 VALUES(2, 6, 7);
+ INSERT INTO t1 VALUES(3, 7, 8);
+ INSERT INTO t1 VALUES(1, 8, 9);
+ INSERT INTO t1 VALUES(2, 9, 0);
+}
+
+proc do_vtab_test {tn sql vtsql {res {}}} {
+ set ::lFilterSql [list]
+ uplevel [list do_execsql_test $tn.1 $sql $res]
+ uplevel [list do_test $tn.2 {set ::lFilterSql} [list {*}$vtsql]]
+}
+
+do_vtab_test 5.1.1 {
+ SELECT DISTINCT a FROM vt1
+} {
+ {SELECT DISTINCT 0, a, 0, 0 FROM t1}
+} {1 2 3}
+
+do_vtab_test 5.1.2 {
+ SELECT DISTINCT a FROM vt1 ORDER BY a
+} {
+ {SELECT rowid, a, b, c FROM t1 ORDER BY a}
+} {1 2 3}
+
+do_vtab_test 5.1.3 {
+ SELECT DISTINCT a FROM vt1 WHERE c IN (4,5,6,7,8)
+} {
+ {SELECT DISTINCT 0, a, 0, 0 FROM t1 WHERE c IN (4,5,6,7,8)}
+} {2 3 1}
+
+set ::vtab_handle_in 0
+do_vtab_test 5.1.4 {
+ SELECT DISTINCT a FROM vt1 WHERE c IN (4,5,6,7,8)
+} {
+ {SELECT DISTINCT 0, a, 0, 0 FROM t1 WHERE c = 4}
+ {SELECT DISTINCT 0, a, 0, 0 FROM t1 WHERE c = 5}
+ {SELECT DISTINCT 0, a, 0, 0 FROM t1 WHERE c = 6}
+ {SELECT DISTINCT 0, a, 0, 0 FROM t1 WHERE c = 7}
+ {SELECT DISTINCT 0, a, 0, 0 FROM t1 WHERE c = 8}
+} {2 3 1}
+
+set ::vtab_handle_in 1
+do_vtab_test 5.1.5a {
+ SELECT a, b, c FROM vt1 WHERE c IN (4,5,6,7,8) LIMIT 2 OFFSET 2
+} {
+ {SELECT rowid, a, b, c FROM t1 WHERE c IN (4,5,6,7,8) LIMIT 2 OFFSET 2}
+} {1 5 6 2 6 7}
+
+set ::vtab_handle_in 0
+do_vtab_test 5.1.5b {
+ SELECT a, b, c FROM vt1 WHERE c IN (4,5,6,7,8) LIMIT 2 OFFSET 2
+} {
+ {SELECT rowid, a, b, c FROM t1 WHERE c = 4}
+ {SELECT rowid, a, b, c FROM t1 WHERE c = 5}
+ {SELECT rowid, a, b, c FROM t1 WHERE c = 6}
+ {SELECT rowid, a, b, c FROM t1 WHERE c = 7}
+} {1 5 6 2 6 7}
+set ::vtab_handle_in 1
+
+finish_test
diff --git a/test/bestindex9.test b/test/bestindex9.test
new file mode 100644
index 0000000..94b9da0
--- /dev/null
+++ b/test/bestindex9.test
@@ -0,0 +1,108 @@
+# 2020-01-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
+set testprefix bestindex9
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+
+proc vtab_command {method args} {
+ switch -- $method {
+ xConnect {
+ return $::create_table
+ }
+
+ xBestIndex {
+ set hdl [lindex $args 0]
+ set ::vtab_orderby [$hdl orderby]
+ set ::vtab_distinct [$hdl distinct]
+
+ return [list orderby 1]
+ }
+
+ xFilter {
+ return ""
+ }
+ }
+
+ return {}
+}
+
+proc do_bestindex9_test {tn create select orderby distinct} {
+ forcedelete test.db2
+ sqlite3 dbtest test.db2
+ register_tcl_module dbtest
+
+ set ::create_table $create
+ dbtest eval { CREATE VIRTUAL TABLE t1 USING tcl(vtab_command); }
+ dbtest eval $select
+
+ do_test $tn.orderby [list set {} $::vtab_orderby] $orderby
+ do_test $tn.distinct [list set {} $::vtab_distinct] $distinct
+
+ dbtest close
+}
+
+#-------------------------------------------------------------------------
+#
+do_bestindex9_test 1.0 {
+ CREATE TABLE x(k1, k2, v1, PRIMARY KEY(k1, k2))
+} {
+ SELECT DISTINCT k1, k2 FROM t1
+} {{column 0 desc 0} {column 1 desc 0}} 2
+
+do_bestindex9_test 1.1 {
+ CREATE TABLE x(k1, k2, v1, PRIMARY KEY(k1, k2)) WITHOUT ROWID
+} {
+ SELECT DISTINCT k1, k2 FROM t1
+} {} 0
+
+do_bestindex9_test 1.2 {
+ CREATE TABLE x(k1 NOT NULL, k2 NOT NULL, v1, PRIMARY KEY(k1, k2))
+} {
+ SELECT DISTINCT k1, k2 FROM t1
+} {} 0
+
+#-------------------------------------------------------------------------
+#
+do_bestindex9_test 2 {
+ CREATE TABLE x(c1, c2, c3);
+} {
+ SELECT DISTINCT c1 FROM t1 ORDER BY c1
+} {{column 0 desc 0}} 3
+
+#-------------------------------------------------------------------------
+#
+do_bestindex9_test 3 {
+ CREATE TABLE x(c1, c2, c3);
+} {
+ SELECT DISTINCT c1 FROM t1 GROUP BY c1
+} {{column 0 desc 0}} 1
+
+do_bestindex9_test 4 {
+ CREATE TABLE x(c1, c2, c3);
+} {
+ CREATE TABLE t2(balls);
+ SELECT DISTINCT c1 FROM t1, t2
+} {{column 0 desc 0}} 2
+
+
+finish_test
+
+
+
+
diff --git a/test/between.test b/test/between.test
new file mode 100644
index 0000000..16c3913
--- /dev/null
+++ b/test/between.test
@@ -0,0 +1,143 @@
+# 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 names of the table and index used.
+#
+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
+ set eqp [execsql "EXPLAIN QUERY PLAN $sql"]
+ # puts eqp=$eqp
+ foreach {a b c x} $eqp {
+ if {[regexp {(SCAN|SEARCH) (\w+ AS )?(\w+) USING.* INDEX (\w+)\y} \
+ $x all ss as tab idx]} {
+ lappend data $tab $idx
+ } elseif {[regexp {(SCAN|SEARCH) (\w+ AS )?(\w+)\y} $x all ss as tab]} {
+ lappend data $tab *
+ }
+ }
+ return $data
+}
+
+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 *}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test between-2.0 {
+ CREATE TABLE t1(x TEXT, y TEXT COLLATE nocase);
+ INSERT INTO t1 VALUES('0', 'abc');
+}
+
+foreach {tn expr res} {
+ 1 "x BETWEEN 1 AND '5'" 0
+ 2 "x COLLATE binary BETWEEN 1 AND '5'" 0
+ 3 "x COLLATE nocase BETWEEN 1 AND '5'" 0
+
+ 4 "y BETWEEN 'A' AND 'B'" 1
+ 5 "y COLLATE nocase BETWEEN 'A' AND 'B'" 1
+ 6 "y COLLATE binary BETWEEN 'A' AND 'B'" 0
+ 7 "(y COLLATE binary) BETWEEN 'A' AND 'B'" 0
+} {
+ set sql "SELECT $expr FROM t1"
+ do_execsql_test between-2.1.$tn $sql $res
+}
+
+finish_test
diff --git a/test/bigfile.test b/test/bigfile.test
new file mode 100644
index 0000000..31c6323
--- /dev/null
+++ b/test/bigfile.test
@@ -0,0 +1,203 @@
+# 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 $
+#
+
+if {[file exists skip-big-file]} return
+if {$tcl_platform(os)=="Darwin"} return
+
+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 [get_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 [get_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 [get_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/bigfile2.test b/test/bigfile2.test
new file mode 100644
index 0000000..de3b14b
--- /dev/null
+++ b/test/bigfile2.test
@@ -0,0 +1,62 @@
+# 2011 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 implements regression tests for SQLite library. The
+# focus of this script testing the ability of SQLite to handle database
+# files larger than 4GB.
+#
+
+if {[file exists skip-big-file]} return
+if {$tcl_platform(os)=="Darwin"} return
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bigfile2
+
+# Create a small database.
+#
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+}
+
+# Pad the file out to 4GB in size. Then clear the file-size field in the
+# db header. This will cause SQLite to assume that the first 4GB of pages
+# are actually in use and new pages will be appended to the file.
+#
+db close
+if {[catch {fake_big_file 4096 [get_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 1.2 {
+ file size test.db
+} [expr 14 + 4096 * (1<<20)]
+
+# Now insert a large row. The overflow pages will be located past the 4GB
+# boundary. Then, after opening and closing the database, test that the row
+# can be read back in.
+#
+set str [string repeat k 30000]
+do_test 1.3 {
+ sqlite3 db test.db
+ execsql { INSERT INTO t1 VALUES(3, $str) }
+ db close
+ sqlite3 db test.db
+ db one { SELECT b FROM t1 WHERE a = 3 }
+} $str
+
+db close
+delete_file test.db
+
+finish_test
diff --git a/test/bigmmap.test b/test/bigmmap.test
new file mode 100644
index 0000000..ba9f842
--- /dev/null
+++ b/test/bigmmap.test
@@ -0,0 +1,108 @@
+# 2017 August 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 use mmap
+# to access files larger than 4GiB.
+#
+
+if {[file exists skip-big-file]} return
+if {$tcl_platform(os)=="Darwin"} return
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bigmmap
+
+ifcapable !mmap||!vtab {
+ finish_test
+ return
+}
+
+set mmap_limit 0
+db eval {
+ SELECT compile_options AS x FROM pragma_compile_options
+ WHERE x LIKE 'max_mmap_size=%'
+} {
+ regexp {MAX_MMAP_SIZE=([0-9]*)} $x -> mmap_limit
+}
+if {$mmap_limit < [expr 8 * 1<<30]} {
+ puts "Skipping bigmmap.test - requires SQLITE_MAX_MMAP_SIZE >= 8G"
+ finish_test
+ return
+}
+
+
+#-------------------------------------------------------------------------
+# Create the database file roughly 8GiB in size. Most pages are unused,
+# except that there is a table and index clustered around each 1GiB
+# boundary.
+#
+do_execsql_test 1.0 {
+ PRAGMA page_size = 4096;
+ CREATE TABLE t0(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 100 )
+ INSERT INTO t0 SELECT i, 't0', randomblob(800) FROM s;
+}
+
+for {set i 1} {$i < 8} {incr i} {
+ if {[catch {fake_big_file [expr $i*1024] [get_pwd]/test.db}]} {
+ puts "Cannot create ${i}MB sparse file"
+ finish_test
+ return
+ }
+ hexio_write test.db 28 [format %.8x [expr ($i*1024*1024*1024/4096) - 5]]
+
+ do_execsql_test 1.$i "
+ CREATE TABLE t$i (a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 100 )
+ INSERT INTO t$i SELECT i, 't$i', randomblob(800) FROM s;
+ "
+}
+
+#-------------------------------------------------------------------------
+# Check that data can be retrieved from the db with a variety of
+# configured mmap size limits.
+#
+for {set i 0} {$i < 9} {incr i} {
+
+ # Configure a memory mapping $i GB in size.
+ #
+ set val [expr $i*1024*1024*1024]
+ execsql "PRAGMA main.mmap_size = $val"
+ do_execsql_test 2.$i.0 {
+ PRAGMA main.mmap_size
+ } $val
+
+ for {set t 0} {$t < 8} {incr t} {
+ do_execsql_test 2.$i.$t.1 "
+ SELECT count(*) FROM t$t;
+ SELECT count(b || c) FROM t$t GROUP BY b;
+ " {100 100}
+
+ do_execsql_test 2.$i.$t.2 "
+ SELECT * FROM t$t AS o WHERE
+ NOT EXISTS( SELECT * FROM t$t AS i WHERE a=o.a AND +b=o.b AND +c=o.c )
+ ORDER BY b, c;
+ " {}
+
+ do_eqp_test 2.$i.$t.3 "
+ SELECT * FROM t$t AS o WHERE
+ NOT EXISTS( SELECT * FROM t$t AS i WHERE a=o.a AND +b=o.b AND +c=o.c )
+ ORDER BY b, c;
+ " [string map {"\n " "\n"} "
+ QUERY PLAN
+ |--SCAN o USING COVERING INDEX sqlite_autoindex_t${t}_1
+ `--CORRELATED SCALAR SUBQUERY xxxxxx
+ `--SEARCH i USING INTEGER PRIMARY KEY (rowid=?)
+ "]
+ }
+}
+
+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/bigsort.test b/test/bigsort.test
new file mode 100644
index 0000000..61c3344
--- /dev/null
+++ b/test/bigsort.test
@@ -0,0 +1,57 @@
+# 2014 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bigsort
+
+#--------------------------------------------------------------------
+# At one point there was an overflow problem if the product of the
+# cache-size and page-size was larger than 2^31. Causing an infinite
+# loop if the product was also an integer multiple of 2^32, or
+# inefficiency otherwise.
+#
+# This test causes thrashing on machines with smaller amounts of
+# memory. Make sure the host has at least 8GB available before running
+# this test.
+#
+# Update: https://sqlite.org/src/info/7c96a56 adds assert() statements
+# that make this test too slow to run with SQLITE_DEBUG builds.
+#
+if {[catch {exec free | grep Mem:} out] || [lindex $out 1]<8000000} {
+ finish_test
+ return
+}
+ifcapable debug {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ BEGIN;
+ WITH data(x,y) AS (
+ SELECT 1, zeroblob(10000)
+ UNION ALL
+ SELECT x+1, y FROM data WHERE x < 300000
+ )
+ INSERT INTO t1 SELECT * FROM data;
+ COMMIT;
+}
+do_execsql_test 1.1 {
+ PRAGMA cache_size = 4194304;
+ CREATE INDEX i1 ON t1(a, b);
+}
+
+
+finish_test
diff --git a/test/bind.test b/test/bind.test
new file mode 100644
index 0000000..8cafaab
--- /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
+} {column index out of range}
+ifcapable {utf16} {
+ do_test bind-8.3 {
+ encoding convertfrom unicode [sqlite3_errmsg16 $DB]
+ } {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
+} {column index out of range}
+ifcapable {utf16} {
+ do_test bind-8.7 {
+ encoding convertfrom unicode [sqlite3_errmsg16 $DB]
+ } {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/bind2.test b/test/bind2.test
new file mode 100644
index 0000000..1ebf35c
--- /dev/null
+++ b/test/bind2.test
@@ -0,0 +1,63 @@
+# 2022 Feb 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix bind2
+
+
+# Test that using bind_value() on a REAL sqlite3_value that was stored
+# as an INTEGER works properly.
+#
+# 1.1: An IntReal value read from a table,
+# 1.2: IntReal values obtained via the sqlite3_preupdate_old|new()
+# interfaces.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a REAL);
+ INSERT INTO t1 VALUES(42.0);
+ SELECT * FROM t1;
+} {42.0}
+
+do_test 1.1 {
+ set stmt [sqlite3_prepare db "SELECT ?" -1 tail]
+ sqlite3_bind_value_from_select $stmt 1 "SELECT a FROM t1"
+ sqlite3_step $stmt
+ sqlite3_column_text $stmt 0
+} {42.0}
+sqlite3_finalize $stmt
+
+ifcapable !preupdate {
+ finish_test
+ return
+}
+
+proc preup {args} {
+ set stmt [sqlite3_prepare db "SELECT ?" -1 tail]
+ sqlite3_bind_value_from_preupdate $stmt 1 old 0
+ sqlite3_step $stmt
+ lappend ::reslist [sqlite3_column_text $stmt 0]
+ sqlite3_reset $stmt
+ sqlite3_bind_value_from_preupdate $stmt 1 new 0
+ sqlite3_step $stmt
+ lappend ::reslist [sqlite3_column_text $stmt 0]
+ sqlite3_finalize $stmt
+}
+db preupdate hook preup
+
+do_test 1.2 {
+ set ::reslist [list]
+ execsql { UPDATE t1 SET a=43; }
+ set ::reslist
+} {42.0 43.0}
+
+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/bloom1.test b/test/bloom1.test
new file mode 100644
index 0000000..12b53dd
--- /dev/null
+++ b/test/bloom1.test
@@ -0,0 +1,70 @@
+# 2022 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.
+#
+#***********************************************************************
+#
+# Tests for queries that use bloom filters
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+set testprefix bloom1
+
+# Tests 1.* verify that the bloom filter code correctly handles the
+# case where the RHS of an (<ipk-column> = ?) expression must be coerced
+# to an integer before the comparison made.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c INTEGER PRIMARY KEY, d);
+}
+
+do_execsql_test 1.1 {
+ INSERT INTO t1 VALUES('hello', 'world');
+ INSERT INTO t2 VALUES(14, 'fourteen');
+}
+
+do_execsql_test 1.2 {
+ ANALYZE sqlite_schema;
+ INSERT INTO sqlite_stat1 VALUES('t2','idx1','6 6');
+ ANALYZE sqlite_schema;
+}
+
+do_execsql_test 1.3 {
+ SELECT 'affinity!' FROM t1 CROSS JOIN t2 WHERE t2.c = '14';
+} {affinity!}
+
+
+reset_db
+do_execsql_test 1.4 {
+ CREATE TABLE t1(a, b TEXT);
+ CREATE TABLE t2(c INTEGER PRIMARY KEY, d);
+ CREATE TABLE t3(e INTEGER PRIMARY KEY, f);
+
+ ANALYZE sqlite_schema;
+ INSERT INTO sqlite_stat1 VALUES('t1','idx1','600 6');
+ INSERT INTO sqlite_stat1 VALUES('t2','idx1','6 6');
+ INSERT INTO sqlite_stat1 VALUES('t3','idx2','6 6');
+ ANALYZE sqlite_schema;
+
+ INSERT INTO t1 VALUES(1, '123');
+ INSERT INTO t2 VALUES(123, 'one');
+ INSERT INTO t3 VALUES(123, 'two');
+}
+
+do_execsql_test 1.5 {
+ SELECT 'result' FROM t1, t2, t3
+ WHERE t2.c=t1.b AND t2.d!='silly'
+ AND t3.e=t1.b AND t3.f!='silly'
+} {result}
+
+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..5fc26d6
--- /dev/null
+++ b/test/boundary3.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.
+#
+
+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 {wide($x+1)}]) 1
+ set boundarynum([expr {wide(-($x+1))}]) 1
+ set boundarynum([expr {wide(-($x+2))}]) 1
+ set boundarynum([expr {wide($x+$x+1)}]) 1
+ set boundarynum([expr {wide($x+$x+2)}]) 1
+}
+set x [expr {wide(127)}]
+for {set i 1} {$i<=9} {incr i} {
+ set boundarynum($x) 1
+ set boundarynum([expr {wide($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 %016x [expr {wide($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)<0x7FFFFFFFFFFFFFFF || $r==-9223372036854775808} {
+ 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/btree01.test b/test/btree01.test
new file mode 100644
index 0000000..6e4717a
--- /dev/null
+++ b/test/btree01.test
@@ -0,0 +1,156 @@
+# 2014-11-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 contains test cases for b-tree logic.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix btree01
+
+# The refactoring on the b-tree balance() routine in check-in
+# http://www.sqlite.org/src/info/face33bea1ba3a (2014-10-27)
+# caused the integrity_check on the following SQL to fail.
+#
+do_execsql_test btree01-1.1 {
+ PRAGMA page_size=65536;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;
+ UPDATE t1 SET b=zeroblob(3000);
+ UPDATE t1 SET b=zeroblob(64000) WHERE a=2;
+ PRAGMA integrity_check;
+} {ok}
+
+# The previous test is sufficient to prevent a regression. But we
+# add a number of additional tests to stress the balancer in similar
+# ways, looking for related problems.
+#
+for {set i 1} {$i<=30} {incr i} {
+ do_test btree01-1.2.$i {
+ db eval {
+ DELETE FROM t1;
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;
+ UPDATE t1 SET b=zeroblob(3000);
+ UPDATE t1 SET b=zeroblob(64000) WHERE a=$::i;
+ PRAGMA integrity_check;
+ }
+ } {ok}
+}
+for {set i 1} {$i<=30} {incr i} {
+ do_test btree01-1.3.$i {
+ db eval {
+ DELETE FROM t1;
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;
+ UPDATE t1 SET b=zeroblob(2000);
+ UPDATE t1 SET b=zeroblob(64000) WHERE a=$::i;
+ PRAGMA integrity_check;
+ }
+ } {ok}
+}
+for {set i 1} {$i<=30} {incr i} {
+ do_test btree01-1.4.$i {
+ db eval {
+ DELETE FROM t1;
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;
+ UPDATE t1 SET b=zeroblob(6499) WHERE (a%3)==0;
+ UPDATE t1 SET b=zeroblob(6499) WHERE (a%3)==1;
+ UPDATE t1 SET b=zeroblob(6499) WHERE (a%3)==2;
+ UPDATE t1 SET b=zeroblob(64000) WHERE a=$::i;
+ PRAGMA integrity_check;
+ }
+ } {ok}
+}
+for {set i 1} {$i<=30} {incr i} {
+ do_test btree01-1.5.$i {
+ db eval {
+ DELETE FROM t1;
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(6542) FROM c;
+ UPDATE t1 SET b=zeroblob(2331);
+ UPDATE t1 SET b=zeroblob(65496) WHERE a=$::i;
+ PRAGMA integrity_check;
+ }
+ } {ok}
+}
+for {set i 1} {$i<=30} {incr i} {
+ do_test btree01-1.6.$i {
+ db eval {
+ DELETE FROM t1;
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(6542) FROM c;
+ UPDATE t1 SET b=zeroblob(2332);
+ UPDATE t1 SET b=zeroblob(65496) WHERE a=$::i;
+ PRAGMA integrity_check;
+ }
+ } {ok}
+}
+for {set i 1} {$i<=30} {incr i} {
+ do_test btree01-1.7.$i {
+ db eval {
+ DELETE FROM t1;
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;
+ UPDATE t1 SET b=zeroblob(1);
+ UPDATE t1 SET b=zeroblob(65000) WHERE a=$::i;
+ PRAGMA integrity_check;
+ }
+ } {ok}
+}
+for {set i 1} {$i<=31} {incr i} {
+ do_test btree01-1.8.$i {
+ db eval {
+ DELETE FROM t1;
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<31)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;
+ UPDATE t1 SET b=zeroblob(4000);
+ UPDATE t1 SET b=zeroblob(65000) WHERE a=$::i;
+ PRAGMA integrity_check;
+ }
+ } {ok}
+}
+
+# 2022-03-06 OSSFuzz issue 45329
+# An assertion fault due to the failure to clear a flag in an optimization
+# committed last night.
+#
+# When the stay-on-last page optimization of sqlite3BtreeIndexMoveto() is
+# invoked, it needs to clear the BTCF_ValidOvfl flag.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test btree01-2.1 {
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(a INT PRIMARY KEY, b BLOB, c INT) WITHOUT ROWID;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c) SELECT x*2, zeroblob(100), x FROM c;
+ UPDATE t1 SET b=zeroblob(1000) WHERE a=198;
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y INT);
+ INSERT INTO t2(y) VALUES(198),(187),(100);
+ SELECT y, c FROM t2 LEFT JOIN t1 ON y=a ORDER BY x;
+} {198 99 187 {} 100 50}
+do_execsql_test btree01-2.2 {
+ SELECT y, c FROM t1 RIGHT JOIN t2 ON y=a ORDER BY x;
+} {198 99 187 {} 100 50}
+
+
+finish_test
diff --git a/test/btree02.test b/test/btree02.test
new file mode 100644
index 0000000..c1fede5
--- /dev/null
+++ b/test/btree02.test
@@ -0,0 +1,62 @@
+# 2015-03-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 making multiple calls to saveCursorPosition()
+# and restoreCursorPosition() when cursors have eState==CURSOR_SKIPNEXT
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+load_static_extension db eval
+do_execsql_test btree02-100 {
+ CREATE TABLE t1(a TEXT, ax INTEGER, b INT, PRIMARY KEY(a,ax)) WITHOUT ROWID;
+ WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)
+ INSERT INTO t1(a,ax,b) SELECT printf('%02x',i+160), random(), i FROM c;
+ CREATE INDEX t1a ON t1(a);
+ CREATE TABLE t2(x,y);
+ CREATE TABLE t3(cnt);
+ WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<4)
+ INSERT INTO t3(cnt) SELECT i FROM c;
+ SELECT count(*) FROM t1;
+} {10}
+
+proc showt1 {} {
+ puts -nonewline "t1: "
+ puts [db eval {SELECT printf('(%s,%s)',quote(a),quote(b)) FROM t1}]
+}
+
+do_test btree02-110 {
+ db eval BEGIN
+ set i 0
+ # showt1
+ db eval {SELECT a, ax, b, cnt FROM t1 CROSS JOIN t3 WHERE b IS NOT NULL} {
+ if {$a==""} continue
+ db eval {INSERT INTO t2(x,y) VALUES($b,$cnt)}
+ # puts "a,b,cnt = ($a,$b,$cnt)"
+ incr i
+ if {$i%2==1} {
+ set bx [expr {$b+1000}]
+ # puts "INSERT ($a),$bx"
+ db eval {INSERT INTO t1(a,ax,b) VALUES(printf('(%s)',$a),random(),$bx)}
+ # showt1
+ } else {
+ # puts "DELETE a=$a"
+ db eval {DELETE FROM t1 WHERE a=$a}
+ # showt1
+ }
+ db eval {COMMIT; BEGIN}
+ }
+ db one {COMMIT; SELECT count(*) FROM t1;}
+} {10}
+
+finish_test
diff --git a/test/btreefault.test b/test/btreefault.test
new file mode 100644
index 0000000..d0ba059
--- /dev/null
+++ b/test/btreefault.test
@@ -0,0 +1,106 @@
+# 2013 April 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 contains fault injection tests designed to test the btree.c
+# module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix btreefault
+
+# This test will not work with an in-memory journal, as the database will
+# become corrupt if an error is injected into a transaction after it starts
+# writing data out to the db file.
+if {[permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+do_test 1-pre1 {
+ execsql {
+ PRAGMA auto_vacuum = incremental;
+ PRAGMA journal_mode = DELETE;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(randomblob(1000), randomblob(100));
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ DELETE FROM t1 WHERE rowid%2;
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+ set ::STMT [sqlite3_prepare db "SELECT * FROM t1 ORDER BY a" -1 DUMMY]
+ sqlite3_step $::STMT
+ sqlite3_step $::STMT
+} -body {
+ execsql { PRAGMA incremental_vacuum = 10 }
+} -test {
+ sqlite3_finalize $::STMT
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check
+}
+
+#-------------------------------------------------------------------------
+# dbsqlfuzz crash-6ef3cd3b18ccc5de86120950a0498641acd90a33.txt
+#
+reset_db
+
+do_execsql_test 2.0 {
+ CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b);
+ CREATE INDEX i1 ON t1(b);
+ CREATE TABLE t2(x, y);
+}
+
+do_execsql_test 2.1 {
+ INSERT INTO t1 VALUES(25, 25, 25);
+ INSERT INTO t2 VALUES(25, 'a'), (25, 'b'), (25, 'c');
+}
+
+faultsim_save
+do_test 2.2 {
+ set res [list]
+ db eval {
+ SELECT x, y FROM t1 CROSS JOIN t2 WHERE t2.x=t1.i AND +t1.i=25 ORDER BY b
+ } {
+ lappend res $x $y
+ if {$y=="b"} {
+ db eval { DELETE FROM t1 WHERE i=25 }
+ }
+ }
+ set res
+} {25 a 25 b}
+
+do_faultsim_test 2 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ set ::myres [list]
+ db eval {
+ SELECT x, y FROM t1 CROSS JOIN t2 WHERE t2.x=t1.i AND +t1.i=25 ORDER BY b
+ } {
+ lappend ::myres $x $y
+ if {$y=="b"} {
+ db eval { DELETE FROM t1 WHERE i=25 }
+ }
+ }
+ set ::myres
+} -test {
+ faultsim_test_result {0 {25 a 25 b}}
+}
+
+
+finish_test
diff --git a/test/busy.test b/test/busy.test
new file mode 100644
index 0000000..be0515b
--- /dev/null
+++ b/test/busy.test
@@ -0,0 +1,139 @@
+# 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
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix busy
+
+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
+
+#-------------------------------------------------------------------------
+# Test that the busy-handler is invoked correctly for "PRAGMA optimize"
+# and ANALYZE commnds.
+ifcapable pragma&&analyze&&!stat4 {
+
+reset_db
+
+do_execsql_test 3.1 {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(y);
+ CREATE TABLE t3(z);
+
+ CREATE INDEX i1 ON t1(x);
+ CREATE INDEX i2 ON t2(y);
+
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t2 VALUES(1);
+ ANALYZE;
+
+ SELECT * FROM t1 WHERE x=1;
+ SELECT * FROM t2 WHERE y=1;
+} {1 1}
+
+do_test 3.2 {
+ sqlite3 db2 test.db
+ execsql { BEGIN EXCLUSIVE } db2
+ catchsql { PRAGMA optimize }
+} {1 {database is locked}}
+
+proc busy_handler {n} {
+ if {$n>1000} { execsql { COMMIT } db2 }
+ return 0
+}
+db busy busy_handler
+
+do_test 3.3 {
+ catchsql { PRAGMA optimize }
+} {0 {}}
+
+do_test 3.4 {
+ execsql {
+ BEGIN;
+ SELECT count(*) FROM sqlite_master;
+ } db2
+} {6}
+
+proc busy_handler {n} { return 1 }
+do_test 3.5 {
+ catchsql { PRAGMA optimize }
+} {0 {}}
+
+do_test 3.6 {
+ execsql { COMMIT } db2
+ execsql {
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000
+ )
+ INSERT INTO t1 SELECT i FROM s;
+ }
+ execsql {
+ BEGIN;
+ SELECT count(*) FROM sqlite_master;
+ } db2
+} {6}
+
+do_test 3.7 {
+ catchsql { PRAGMA optimize }
+} {1 {database is locked}}
+
+proc busy_handler {n} {
+ if {$n>1000} { execsql { COMMIT } db2 }
+ return 0
+}
+do_test 3.8 {
+ catchsql { PRAGMA optimize }
+} {0 {}}
+
+}
+
+finish_test
diff --git a/test/busy2.test b/test/busy2.test
new file mode 100644
index 0000000..ec420c8
--- /dev/null
+++ b/test/busy2.test
@@ -0,0 +1,171 @@
+# 2020 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 test the busy handler
+#
+# TESTRUNNER: slow
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+set testprefix busy2
+
+do_multiclient_test tn {
+ do_test 1.$tn.0 {
+ sql2 {
+ CREATE TABLE t1(a, b);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES('A', 'B');
+ }
+ } {wal}
+
+ do_test 1.$tn.1 {
+ code1 { db timeout 1000 }
+ sql1 { SELECT * FROM t1 }
+ } {A B}
+
+ do_test 1.$tn.2 {
+ sql2 {
+ BEGIN;
+ INSERT INTO t1 VALUES('C', 'D');
+ }
+ } {}
+
+ do_test 1.$tn.3 {
+ set us [lindex [time { catch { sql1 { BEGIN EXCLUSIVE } } }] 0]
+ expr {$us>950000 && $us<1500000}
+ } {1}
+
+ do_test 1.$tn.4 {
+ sql2 {
+ COMMIT
+ }
+ } {}
+}
+
+#-------------------------------------------------------------------------
+
+do_multiclient_test tn {
+ # Make the db a WAL mode db. And add a table and a row to it. Then open
+ # a second connection within process 1. Process 1 now has connections
+ # [db] and [db1.2], process 2 has connection [db2] only.
+ #
+ # Configure all connections to use a 1000 ms timeout.
+ #
+ do_test 2.$tn.0 {
+ code1 {
+ sqlite3 db1.2 test.db
+ }
+ sql1 {
+ PRAGMA auto_vacuum = off;
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ code2 {
+ db2 timeout 1000
+ }
+ code1 {
+ db1.2 timeout 1000
+ db timeout 1000
+ db1.2 eval {SELECT * FROM t1}
+ }
+ } {1 2}
+
+ # Take a read lock with [db] in process 1.
+ #
+ do_test 2.$tn.1 {
+ sql1 {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {1 2}
+
+ # Insert a row using [db2] in process 2. Then try a passive checkpoint.
+ # It fails to checkpoint the final frame (due to the readlock taken by
+ # [db]), and returns in less than 250ms.
+ do_test 2.$tn.2 {
+ sql2 { INSERT INTO t1 VALUES(3, 4) }
+ set us [lindex [time {
+ set res [code2 { db2 eval { PRAGMA wal_checkpoint } }]
+ }] 0]
+ list [expr $us < 250000] $res
+ } {1 {0 4 3}}
+
+ # Now try a FULL checkpoint with [db2]. It returns SQLITE_BUSY. And takes
+ # over 950ms to do so.
+ do_test 2.$tn.3 {
+ set us [lindex [time {
+ set res [code2 { db2 eval { PRAGMA wal_checkpoint = FULL } }]
+ }] 0]
+ list [expr $us > 950000] $res
+ } {1 {1 4 3}}
+
+ # Passive checkpoint with [db1.2] (process 1). No SQLITE_BUSY, returns
+ # in under 250ms.
+ do_test 2.$tn.4 {
+ set us [lindex [time {
+ set res [code1 { db1.2 eval { PRAGMA wal_checkpoint } }]
+ }] 0]
+ list [expr $us < 250000] $res
+ } {1 {0 4 3}}
+
+ # Full checkpoint with [db1.2] (process 1). SQLITE_BUSY returned in
+ # a bit over 950ms.
+ do_test 2.$tn.5 {
+ set us [lindex [time {
+ set res [code1 { db1.2 eval { PRAGMA wal_checkpoint = FULL } }]
+ }] 0]
+ list [expr $us > 950000] $res
+ } {1 {1 4 3}}
+
+ code1 {
+ db1.2 close
+ }
+}
+
+#-------------------------------------------------------------------------
+# Check that even if the busy-handler fails (returns zero) within a
+# call to sqlite3_prepare() (or _v2(), or _v3()), it is still invoked
+# the next time an SQLITE_BUSY is encountered.
+#
+do_multiclient_test tn {
+ code1 {
+ set ::busy_called 0
+ proc busy {args} {
+ if {$::busy_called} { return 1 }
+ set ::busy_called 1
+ return 0
+ }
+ db busy busy
+ }
+
+ do_test 3.$tn.1 {
+ sql2 {
+ CREATE TABLE t1(x);
+ BEGIN EXCLUSIVE;
+ INSERT INTO t1 VALUES('x');
+ }
+ } {}
+
+ do_test 3.$tn.2 {
+ set ::busy_called 0
+ list [catch { sql1 { SELECT * FROM t1 } } msg] $::busy_called
+ } {1 1}
+
+ do_test 3.$tn.3 {
+ set ::busy_called 0
+ list [catch { sql1 { SELECT * FROM t1 } } msg] $::busy_called
+ } {1 1}
+
+}
+
+finish_test
diff --git a/test/cache.test b/test/cache.test
new file mode 100644
index 0000000..ffc25c4
--- /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||!compound {
+ 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 initialized, 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/cacheflush.test b/test/cacheflush.test
new file mode 100644
index 0000000..5046189
--- /dev/null
+++ b/test/cacheflush.test
@@ -0,0 +1,323 @@
+# 2011 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 contains test cases for sqlite3_db_cacheflush API.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix cacheflush
+test_set_config_pagecache 0 0
+
+# Run the supplied SQL on a copy of the database currently stored on
+# disk in file $dbfile.
+proc diskquery {dbfile sql} {
+ forcecopy $dbfile dq.db
+ sqlite3 dq dq.db
+ set res [execsql $sql dq]
+ dq close
+ set res
+}
+
+# Simplest possible test.
+#
+do_execsql_test 1.1.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+}
+do_test 1.1.1 {
+ diskquery test.db { SELECT * FROM t1 }
+} {1 2}
+do_test 1.1.2 {
+ sqlite3_db_cacheflush db
+ diskquery test.db { SELECT * FROM t1 }
+} {1 2 3 4}
+
+# Test that multiple pages may be flushed to disk.
+#
+do_execsql_test 1.2.0 {
+ COMMIT;
+ CREATE TABLE t2(a, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(5, 6);
+ INSERT INTO t2 VALUES('a', 'b');
+}
+do_test 1.2.1 {
+ diskquery test.db {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+} {1 2 3 4}
+do_test 1.2.2 {
+ sqlite3_db_cacheflush db
+ diskquery test.db {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+} {1 2 3 4 5 6 a b}
+
+# Test that pages with nRef!=0 are not flushed to disk.
+#
+do_execsql_test 1.3.0 {
+ COMMIT;
+ CREATE TABLE t3(a, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(7, 8);
+ INSERT INTO t2 VALUES('c', 'd');
+ INSERT INTO t3 VALUES('i', 'ii');
+}
+do_test 1.3.1 {
+ diskquery test.db {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ }
+} {1 2 3 4 5 6 a b}
+do_test 1.3.2 {
+ db eval { SELECT a FROM t1 } {
+ if {$a==3} {
+ sqlite3_db_cacheflush db
+ }
+ }
+ diskquery test.db {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ }
+} {1 2 3 4 5 6 a b c d i ii}
+do_test 1.3.2 {
+ sqlite3_db_cacheflush db
+ diskquery test.db {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ }
+} {1 2 3 4 5 6 7 8 a b c d i ii}
+
+# Check that SQLITE_BUSY is returned if pages cannot be flushed due to
+# conflicting read locks.
+#
+do_execsql_test 1.4.0 {
+ COMMIT;
+ BEGIN;
+ INSERT INTO t1 VALUES(9, 10);
+}
+do_test 1.4.1 {
+ sqlite3 db2 test.db
+ db2 eval {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ diskquery test.db {
+ SELECT * FROM t1;
+ }
+} {1 2 3 4 5 6 7 8}
+do_test 1.4.2 {
+ list [catch { sqlite3_db_cacheflush db } msg] $msg
+} {1 {database is locked}}
+do_test 1.4.3 {
+ diskquery test.db {
+ SELECT * FROM t1;
+ }
+} {1 2 3 4 5 6 7 8}
+do_test 1.4.4 {
+ db2 close
+ sqlite3_db_cacheflush db
+ diskquery test.db {
+ SELECT * FROM t1;
+ }
+} {1 2 3 4 5 6 7 8 9 10}
+do_execsql_test 1.4.5 { COMMIT }
+
+#-------------------------------------------------------------------------
+# Test that ATTACHed database caches are also flushed.
+#
+forcedelete test.db2
+do_execsql_test 2.1.0 {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t4(x, y);
+ INSERT INTO t4 VALUES('A', 'B');
+ BEGIN;
+ INSERT INTO t1 VALUES(11, 12);
+ INSERT INTO t4 VALUES('C', 'D');
+}
+do_test 2.1.1 {
+ diskquery test.db { SELECT * FROM t1; }
+} {1 2 3 4 5 6 7 8 9 10}
+do_test 2.1.2 {
+ diskquery test.db2 { SELECT * FROM t4; }
+} {A B}
+do_test 2.1.3 {
+ sqlite3_db_cacheflush db
+ diskquery test.db { SELECT * FROM t1; }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_test 2.1.4 {
+ sqlite3_db_cacheflush db
+ diskquery test.db2 { SELECT * FROM t4; }
+} {A B C D}
+do_execsql_test 2.1.5 { COMMIT }
+
+# And that hitting an SQLITE_BUSY when flushing "main" does not stop
+# SQLite from going on to flush "aux".
+#
+do_execsql_test 2.2.0 {
+ BEGIN;
+ INSERT INTO t1 VALUES(13, 14);
+ INSERT INTO t4 VALUES('E', 'F');
+}
+do_test 2.2.1 {
+ diskquery test.db { SELECT * FROM t1; }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_test 2.2.2 {
+ diskquery test.db2 { SELECT * FROM t4; }
+} {A B C D}
+do_test 2.2.3 {
+ sqlite3 db2 test.db
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ } db2
+ list [catch { sqlite3_db_cacheflush db } msg] $msg
+} {1 {database is locked}}
+do_test 2.2.4 {
+ diskquery test.db { SELECT * FROM t1; }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_test 2.2.5 {
+ diskquery test.db2 { SELECT * FROM t4; }
+} {A B C D E F}
+do_test 2.2.6 {
+ db2 close
+ sqlite3_db_cacheflush db
+ diskquery test.db { SELECT * FROM t1; }
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+do_execsql_test 2.2.7 { COMMIT }
+
+#-------------------------------------------------------------------------
+# Test that nothing terrible happens if sqlite3_db_cacheflush() is
+# called on an in-memory database.
+#
+do_test 3.0 {
+ db close
+ sqlite3 db :memory:
+ db eval {
+ CREATE TABLE t1(x PRIMARY KEY);
+ CREATE TABLE t2(y PRIMARY KEY);
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t2 VALUES(randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t2 VALUES(randomblob(100));
+ }
+ sqlite3_db_cacheflush db
+} {}
+
+do_execsql_test 3.1 { PRAGMA integrity_check } ok
+do_execsql_test 3.2 { COMMIT }
+do_execsql_test 3.3 { PRAGMA integrity_check } ok
+do_execsql_test 3.4 {
+ SELECT count(*) FROM t1;
+ SELECT count(*) FROM t2;
+} {2 2}
+
+#-------------------------------------------------------------------------
+# Test that calling sqlite3_db_cacheflush() does not interfere with
+# savepoint transactions.
+#
+do_test 4.0 {
+ reset_db
+ execsql {
+ CREATE TABLE ta(a, aa);
+ CREATE TABLE tb(b, bb);
+ INSERT INTO ta VALUES('a', randomblob(500));
+ INSERT INTO tb VALUES('b', randomblob(500));
+ BEGIN;
+ UPDATE ta SET a = 'A';
+ SAVEPOINT one;
+ UPDATE tb SET b = 'B';
+ }
+
+ sqlite3_db_cacheflush db
+ diskquery test.db {
+ SELECT a FROM ta;
+ SELECT b FROM tb;
+ }
+} {A B}
+
+do_test 4.1 {
+ execsql {
+ ROLLBACK TO one;
+ }
+ sqlite3_db_cacheflush db
+ diskquery test.db {
+ SELECT a FROM ta;
+ SELECT b FROM tb;
+ }
+} {A b}
+
+do_test 4.2 {
+ execsql {
+ INSERT INTO tb VALUES('c', randomblob(10));
+ INSERT INTO tb VALUES('d', randomblob(10));
+ INSERT INTO tb VALUES('e', randomblob(10));
+ }
+ sqlite3_db_cacheflush db
+ diskquery test.db {
+ SELECT a FROM ta;
+ SELECT b FROM tb;
+ }
+} {A b c d e}
+
+do_test 4.3 {
+ execsql {
+ SAVEPOINT two;
+ UPDATE tb SET b = upper(b);
+ }
+ sqlite3_db_cacheflush db
+ diskquery test.db {
+ SELECT a FROM ta;
+ SELECT b FROM tb;
+ }
+} {A B C D E}
+
+do_test 4.4 {
+ execsql {
+ ROLLBACK TO two;
+ }
+ sqlite3_db_cacheflush db
+ diskquery test.db {
+ SELECT a FROM ta;
+ SELECT b FROM tb;
+ }
+} {A b c d e}
+
+do_test 4.4 {
+ execsql {
+ ROLLBACK TO one;
+ }
+ sqlite3_db_cacheflush db
+ diskquery test.db {
+ SELECT a FROM ta;
+ SELECT b FROM tb;
+ }
+} {A b}
+
+do_test 4.5 {
+ execsql {
+ ROLLBACK;
+ SELECT a FROM ta;
+ SELECT b FROM tb;
+ }
+} {a b}
+
+test_restore_config_pagecache
+finish_test
diff --git a/test/cachespill.test b/test/cachespill.test
new file mode 100644
index 0000000..0692513
--- /dev/null
+++ b/test/cachespill.test
@@ -0,0 +1,77 @@
+# 2017 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix cachespill
+
+ifcapable !pager_pragmas {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Test that "PRAGMA cache_spill = 0" completely disables cache spilling.
+#
+do_execsql_test 1.1 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 100;
+ CREATE TABLE t1(a);
+}
+
+do_test 1.2 {
+ file size test.db
+} {2048}
+
+do_test 1.3 {
+ execsql {
+ BEGIN;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200
+ ) INSERT INTO t1 SELECT randomblob(900) FROM s;
+ }
+ expr {[file size test.db] > 50000}
+} {1}
+
+do_test 1.4 {
+ execsql ROLLBACK
+ file size test.db
+} {2048}
+
+do_test 1.5 {
+ execsql {
+ PRAGMA cache_spill = 0;
+ BEGIN;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200
+ ) INSERT INTO t1 SELECT randomblob(900) FROM s;
+ }
+ file size test.db
+} {2048}
+
+do_test 1.5 {
+ execsql {
+ ROLLBACK;
+ PRAGMA cache_spill = 1;
+ BEGIN;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200
+ ) INSERT INTO t1 SELECT randomblob(900) FROM s;
+ }
+ expr {[file size test.db] > 50000}
+} {1}
+
+do_execsql_test 1.6 { ROLLBACK }
+
+
+finish_test
diff --git a/test/capi2.test b/test/capi2.test
new file mode 100644
index 0000000..de47ab3
--- /dev/null
+++ b/test/capi2.test
@@ -0,0 +1,803 @@
+# 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) incomplete input} {}}
+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] \
+ [sqlite3_extended_errcode $DB]
+} {SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.a} SQLITE_CONSTRAINT_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] \
+ [sqlite3_extended_errcode $DB]
+} {SQLITE_CONSTRAINT {NOT NULL constraint failed: t2.a} SQLITE_CONSTRAINT_NOTNULL}
+
+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 {
+ list [sqlite3_errcode $DB] [sqlite3_extended_errcode $DB]
+} {SQLITE_CONSTRAINT SQLITE_CONSTRAINT_UNIQUE}
+
+# 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 {UNIQUE constraint failed: t1.a}}
+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..40d87ac
--- /dev/null
+++ b/test/capi3.test
@@ -0,0 +1,1276 @@
+# 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
+set ::testprefix capi3
+
+# 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 {}]
+ }
+ set ::capi3_errno [sqlite3_system_errno $db2]
+ list [sqlite3_extended_errcode $db2] [expr {$::capi3_errno!=0}]
+} {SQLITE_CANTOPEN 1}
+do_test capi3-3.4 {
+ sqlite3_errmsg $db2
+} {unable to open database file}
+do_test capi3-3.5 {
+ list [sqlite3_system_errno $db2] [sqlite3_close $db2]
+} [list $::capi3_errno SQLITE_OK]
+if {[clang_sanitize_address]==0} {
+ do_test capi3-3.6.1-misuse {
+ sqlite3_close $db2
+ } {SQLITE_MISUSE}
+ do_test capi3-3.6.2-misuse {
+ sqlite3_errmsg $db2
+ } {bad parameter or other API misuse}
+ ifcapable {utf16} {
+ do_test capi3-3.6.3-misuse {
+ utf8 [sqlite3_errmsg16 $db2]
+ } {bad parameter or other API misuse}
+ }
+}
+
+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 {
+ set x [sqlite3_column_type $STMT $i]
+ # EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
+ # fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
+ # point number string BLOB NULL
+ if {[lsearch {INTEGER FLOAT TEXT BLOB NULL} $x]<0} {
+ set types ERROR
+ break
+ } else {
+ lappend types $x
+ }
+ }
+ 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
+
+# 2018-01-09: If a column is the last token if a string, the column name
+# was not being set correctly, due to changes in check-in
+# https://sqlite.org/src/info/0fdf97efe5df7455
+#
+# This problem was detected by the community during beta-testing.
+#
+do_test capi3-5.34 {
+ set STMT [sqlite3_prepare $DB {SELECT :a, :b} -1 TAIL]
+ sqlite3_column_count $STMT
+} 2
+check_header $STMT capi-5.35 {:a :b} {{} {}}
+sqlite3_finalize $STMT
+
+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}
+
+# 6.2 and 6.3 used to return SQLITE_ERROR and SQLITE_SCHEMA, respectively.
+# But since attempting to close a connection no longer resets the internal
+# schema and expires all statements, this is no longer the case.
+do_test capi3-6.2 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+#check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1}
+do_test capi3-6.3 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+if {[clang_sanitize_address]==0} {
+ 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
+ sqlite3_db_config db DEFENSIVE 0
+ 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
+ sqlite3_db_config db DEFENSIVE 0
+ 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} \
+SQLITE_PERM {access permission denied} \
+SQLITE_ABORT {query aborted} \
+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_SCHEMA {database schema has changed} \
+SQLITE_CONSTRAINT {constraint failed} \
+SQLITE_MISMATCH {datatype mismatch} \
+SQLITE_MISUSE {bad parameter or other API misuse} \
+SQLITE_AUTH {authorization denied} \
+SQLITE_RANGE {column index out of range} \
+SQLITE_NOTADB {file 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.
+if { [permutation] != "nofaultsim" } {
+ 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;
+ }
+} {0 {}}
+do_test capi3-11.9.3 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3-11.10 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3-11.11 {
+ sqlite3_step $STMT
+} {SQLITE_DONE}
+ifcapable !autoreset {
+ do_test capi3-11.12armor {
+ sqlite3_step $STMT
+ sqlite3_step $STMT
+ } {SQLITE_MISUSE}
+} else {
+ do_test capi3-11.12 {
+ sqlite3_step $STMT
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+}
+do_test capi3-11.13 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+do_test capi3-11.14 {
+ execsql {
+ SELECT a FROM t2;
+ }
+} {1 2}
+do_test capi3-11.14.1 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3-11.15 {
+ catchsql {
+ ROLLBACK;
+ }
+} {1 {cannot rollback - no transaction is active}}
+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.
+#
+if {[clang_sanitize_address]==0} {
+ 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
+} {}
+
+# Test that calling sqlite3_column_blob() on a TEXT value does not change
+# the return type of subsequent calls to sqlite3_column_type().
+#
+do_execsql_test 20.1 {
+ CREATE TABLE t4(x);
+ INSERT INTO t4 VALUES('abcdefghij');
+}
+do_test 20.2 {
+ set stmt [sqlite3_prepare db "SELECT * FROM t4" -1 dummy]
+ sqlite3_step $stmt
+} {SQLITE_ROW}
+do_test 20.3 { sqlite3_column_type $stmt 0 } {TEXT}
+do_test 20.4 { sqlite3_column_blob $stmt 0 } {abcdefghij}
+do_test 20.5 { sqlite3_column_type $stmt 0 } {TEXT}
+do_test 20.6 { sqlite3_finalize $stmt } SQLITE_OK
+
+
+# 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..889ecbe
--- /dev/null
+++ b/test/capi3c.test
@@ -0,0 +1,1400 @@
+# 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
+set testprefix capi3c
+
+# 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}
+if {[clang_sanitize_address]==0} {
+ do_test capi3c-3.6.1-misuse {
+ sqlite3_close $db2
+ } {SQLITE_MISUSE}
+ do_test capi3c-3.6.2-misuse {
+ sqlite3_errmsg $db2
+ } {bad parameter or other API misuse}
+ ifcapable {utf16} {
+ do_test capi3c-3.6.3-misuse {
+ utf8 [sqlite3_errmsg16 $db2]
+ } {bad parameter or other API misuse}
+ }
+}
+
+# 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}
+if {[clang_sanitize_address]==0} {
+ do_test capi3c-6.4 {
+ db cache flush
+ sqlite3_close $DB
+ } {SQLITE_OK}
+ do_test capi3c-6.99-misuse {
+ db close
+ } {}
+} else {
+ 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
+ sqlite3_db_config db DEFENSIVE 0
+ 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
+ sqlite3_db_config db DEFENSIVE 0
+ 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} \
+SQLITE_PERM {access permission denied} \
+SQLITE_ABORT {query aborted} \
+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 {unknown error} \
+SQLITE_SCHEMA {database schema has changed} \
+SQLITE_CONSTRAINT {constraint failed} \
+SQLITE_MISMATCH {datatype mismatch} \
+SQLITE_MISUSE {bad parameter or other API misuse} \
+SQLITE_AUTH {authorization denied} \
+SQLITE_RANGE {column index out of range} \
+SQLITE_NOTADB {file 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.
+if { [permutation] != "nofaultsim" } {
+ 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;
+ }
+} {0 {}}
+do_test capi3c-11.9.3 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3c-11.10 {
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test capi3c-11.11 {
+ sqlite3_step $STMT
+} {SQLITE_DONE}
+ifcapable !autoreset {
+ do_test capi3c-11.12armor {
+ sqlite3_step $STMT
+ sqlite3_step $STMT
+ } {SQLITE_MISUSE}
+} else {
+ do_test capi3c-11.12 {
+ sqlite3_step $STMT
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+}
+do_test capi3c-11.13 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+do_test capi3c-11.14 {
+ execsql {
+ SELECT a FROM t2;
+ }
+} {1 2}
+do_test capi3c-11.14.1 {
+ sqlite3_get_autocommit $DB
+} 1
+do_test capi3c-11.15 {
+ catchsql {
+ ROLLBACK;
+ }
+} {1 {cannot rollback - no transaction is active}}
+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}
+
+
+# Further tests of sqlite3_column_decltype():
+#
+do_execsql_test 25.0 {
+ CREATE TABLE t11(a VARCHAR(10), b INTEGER);
+ CREATE TABLE t12(a VARCHAR(15), b FLOAT);
+}
+
+foreach {tn sql} {
+ 1 "SELECT * FROM t11 UNION ALL SELECT * FROM t12"
+ 2 "SELECT * FROM t11 UNION SELECT * FROM t12"
+ 3 "SELECT * FROM t11 EXCEPT SELECT * FROM t12"
+ 4 "SELECT * FROM t11 INTERSECT SELECT * FROM t12"
+
+ 5 "SELECT * FROM t11 UNION ALL SELECT * FROM t12 ORDER BY 1"
+ 6 "SELECT * FROM t11 UNION SELECT * FROM t12 ORDER BY 1"
+ 7 "SELECT * FROM t11 EXCEPT SELECT * FROM t12 ORDER BY 1"
+ 8 "SELECT * FROM t11 INTERSECT SELECT * FROM t12 ORDER BY 1"
+} {
+ do_test 25.$tn { decltype $sql } {VARCHAR(10) INTEGER}
+}
+
+finish_test
diff --git a/test/capi3d.test b/test/capi3d.test
new file mode 100644
index 0000000..7cad287
--- /dev/null
+++ b/test/capi3d.test
@@ -0,0 +1,289 @@
+# 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 and sqlite3_stmt_busy 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
+
+ # EVIDENCE-OF: R-61212-30018 If prepared statement X is an EXPLAIN or
+ # EXPLAIN QUERY PLAN statement, then sqlite3_stmt_readonly(X) returns
+ # the same value as if the EXPLAIN or EXPLAIN QUERY PLAN prefix were
+ # omitted.
+ #
+ do_test $testname.explain [format {
+ set DB [sqlite3_connection_pointer db]
+ set STMT [sqlite3_prepare $DB {EXPLAIN %s} -1 TAIL]
+ set rc [sqlite3_stmt_readonly $STMT]
+ sqlite3_finalize $STMT
+ set rc
+ } $sql] $truth
+ do_test $testname.eqp [format {
+ set DB [sqlite3_connection_pointer db]
+ set STMT [sqlite3_prepare $DB {EXPLAIN QUERY PLAN %s} -1 TAIL]
+ set rc [sqlite3_stmt_readonly $STMT]
+ sqlite3_finalize $STMT
+ set rc
+ } $sql] $truth
+}
+
+# EVIDENCE-OF: R-23332-64992 The sqlite3_stmt_readonly(X) interface
+# returns true (non-zero) if and only if the prepared statement X makes
+# no direct changes to the content of the database file.
+#
+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
+ifcapable wal {
+ test_is_readonly capi3d-2.6 {PRAGMA journal_mode=WAL} 0
+ test_is_readonly capi3d-2.7 {PRAGMA wal_checkpoint} 0
+}
+test_is_readonly capi3d-2.8 {PRAGMA application_id=1234} 0
+test_is_readonly capi3d-2.9 {VACUUM} 0
+test_is_readonly capi3d-2.10 {PRAGMA integrity_check} 1
+do_test capi3-2.49 {
+ sqlite3_stmt_readonly 0
+} 1
+
+
+# EVIDENCE-OF: R-04929-09147 This routine returns false if there is any
+# possibility that the statement might change the database file.
+#
+# EVIDENCE-OF: R-13288-53765 A false return does not guarantee that the
+# statement will change the database file.
+#
+# EVIDENCE-OF: R-22182-18548 For example, an UPDATE statement might have
+# a WHERE clause that makes it a no-op, but the sqlite3_stmt_readonly()
+# result would still be false.
+#
+# EVIDENCE-OF: R-50998-48593 Similarly, a CREATE TABLE IF NOT EXISTS
+# statement is a read-only no-op if the table already exists, but
+# sqlite3_stmt_readonly() still returns false for such a statement.
+#
+db eval {
+ CREATE TABLE t2(a,b,c);
+ INSERT INTO t2 VALUES(1,2,3);
+}
+test_is_readonly capi3d-2.11 {UPDATE t2 SET a=a+1 WHERE false} 0
+test_is_readonly capi3d-2.12 {CREATE TABLE IF NOT EXISTS t2(x,y)} 0
+
+
+# EVIDENCE-OF: R-37014-01401 The ATTACH and DETACH statements also cause
+# sqlite3_stmt_readonly() to return true since, while those statements
+# change the configuration of a database connection, they do not make
+# changes to the content of the database files on disk.
+#
+test_is_readonly capi3d-2.13 {ATTACH ':memory:' AS mem1} 1
+db eval {ATTACH ':memory:' AS mem1}
+test_is_readonly capi3d-2.14 {DETACH mem1} 1
+db eval {DETACH mem1}
+
+# EVIDENCE-OF: R-07474-04783 Transaction control statements such as
+# BEGIN, COMMIT, ROLLBACK, SAVEPOINT, and RELEASE cause
+# sqlite3_stmt_readonly() to return true, since the statements
+# themselves do not actually modify the database but rather they control
+# the timing of when other statements modify the database.
+#
+test_is_readonly capi3d-2.15 {BEGIN} 1
+test_is_readonly capi3d-2.16 {COMMIT} 1
+test_is_readonly capi3d-2.17 {SAVEPOINT one} 1
+test_is_readonly capi3d-2.18 {RELEASE one} 1
+
+# EVIDENCE-OF: R-36961-63052 The sqlite3_stmt_readonly() interface
+# returns true for BEGIN since BEGIN merely sets internal flags, but the
+# BEGIN IMMEDIATE and BEGIN EXCLUSIVE commands do touch the database and
+# so sqlite3_stmt_readonly() returns false for those commands.
+#
+test_is_readonly capi3d-2.19 {BEGIN IMMEDIATE} 0
+test_is_readonly capi3d-2.20 {BEGIN EXCLUSIVE} 0
+
+# EVIDENCE-OF: R-21769-42523 For example, if an application defines a
+# function "eval()" that calls sqlite3_exec(), then the following SQL
+# statement would change the database file through side-effects: SELECT
+# eval('DELETE FROM t1') FROM t2; But because the SELECT statement does
+# not change the database file directly, sqlite3_stmt_readonly() would
+# still return true.
+#
+proc evalsql {sql} {db eval $sql}
+db func eval evalsql
+test_is_readonly capi3d-2.21 {SELECT eval('DELETE FROM t1') FROM t2} 1
+
+# Tests for the is-explain interface.
+#
+proc test_is_explain {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_isexplain $STMT]
+ sqlite3_finalize $STMT
+ set rc
+ } $sql] $truth
+}
+
+test_is_explain capi3d-2.51 {SELECT * FROM sqlite_master} 0
+test_is_explain capi3d-2.52 { explain SELECT * FROM sqlite_master} 1
+test_is_explain capi3d-2.53 { Explain Query Plan select * FROM sqlite_master} 2
+do_test capi3-2.99 {
+ sqlite3_stmt_isexplain 0
+} 0
+
+# Tests for sqlite3_stmt_busy
+#
+do_test capi3d-3.1 {
+ db eval {INSERT INTO t1 VALUES(6); INSERT INTO t1 VALUES(7);}
+ set STMT [sqlite3_prepare db {SELECT * FROM t1} -1 TAIL]
+ sqlite3_stmt_busy $STMT
+} {0}
+do_test capi3d-3.2 {
+ sqlite3_step $STMT
+ sqlite3_stmt_busy $STMT
+} {1}
+do_test capi3d-3.3 {
+ sqlite3_step $STMT
+ sqlite3_stmt_busy $STMT
+} {1}
+do_test capi3d-3.4 {
+ sqlite3_reset $STMT
+ sqlite3_stmt_busy $STMT
+} {0}
+
+do_test capi3d-3.99 {
+ sqlite3_finalize $STMT
+ sqlite3_stmt_busy 0
+} {0}
+
+#--------------------------------------------------------------------------
+# Test the sqlite3_stmt_busy() function with ROLLBACK statements.
+#
+reset_db
+
+do_execsql_test capi3d-4.1 {
+ CREATE TABLE t4(x,y);
+ BEGIN;
+}
+
+do_test capi3d-4.2.1 {
+ set ::s1 [sqlite3_prepare_v2 db "ROLLBACK" -1 notused]
+ sqlite3_step $::s1
+} {SQLITE_DONE}
+
+do_test capi3d-4.2.2 {
+ sqlite3_stmt_busy $::s1
+} {0}
+
+do_catchsql_test capi3d-4.2.3 {
+ VACUUM
+} {0 {}}
+
+do_test capi3d-4.2.4 {
+ sqlite3_reset $::s1
+} {SQLITE_OK}
+
+do_catchsql_test capi3d-4.2.5 {
+ VACUUM
+} {0 {}}
+
+do_test capi3d-4.2.6 {
+ sqlite3_finalize $::s1
+} {SQLITE_OK}
+
+
+finish_test
diff --git a/test/capi3e.test b/test/capi3e.test
new file mode 100644
index 0000000..3e478e7
--- /dev/null
+++ b/test/capi3e.test
@@ -0,0 +1,126 @@
+# 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].
+#
+# This is no longer needed here because it should be done within the test
+# fixture executable itself, via Tcl_SetSystemEncoding.
+#
+# 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/carray01.test b/test/carray01.test
new file mode 100644
index 0000000..d6243eb
--- /dev/null
+++ b/test/carray01.test
@@ -0,0 +1,132 @@
+# 2020-11-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 tests for CARRAY extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix carray01
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+load_static_extension db carray
+
+# Parameter $stmt must be a prepared statement created using
+# the sqlite3_prepare_v2 command and with parameters fullly bound.
+# This routine simply runs the statement, gathers the result, and
+# returns a list containing the result.
+#
+# If the optional second argument is true, then the stmt is finalized
+# after it is run.
+#
+proc run_stmt {stmt {finalizeFlag 0}} {
+ set r {}
+ while {[sqlite3_step $stmt]=="SQLITE_ROW"} {
+ for {set i 0} {$i<[sqlite3_data_count $stmt]} {incr i} {
+ lappend r [sqlite3_column_text $stmt $i]
+ }
+ }
+ if {$finalizeFlag} {
+ sqlite3_finalize $stmt
+ } else {
+ sqlite3_reset $stmt
+ }
+ return $r
+}
+
+do_test 100 {
+ set STMT [sqlite3_prepare_v2 db {SELECT 5 IN carray(?3)} -1]
+ sqlite3_carray_bind $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 101 {
+ sqlite3_carray_bind -static $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 110 {
+ sqlite3_carray_bind $STMT 3 1 2 3 4 6 7
+ run_stmt $STMT 0
+} {0}
+do_test 120 {
+ sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 121 {
+ sqlite3_carray_bind -int64 -transient $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 122 {
+ sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 123 {
+ sqlite3_carray_bind -int32 -transient $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 124 {
+ sqlite3_carray_bind -int32 -static $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 125 {
+ sqlite3_carray_bind -int32 $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 130 {
+ sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 6 7
+ run_stmt $STMT 0
+} {0}
+do_test 131 {
+ sqlite3_carray_bind -int64 -transient $STMT 3 1 2 3 4 6 7
+ run_stmt $STMT 0
+} {0}
+do_test 131 {
+ sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 6 7
+ run_stmt $STMT 0
+} {0}
+do_test 140 {
+ sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 141 {
+ sqlite3_carray_bind -double -transient $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 142 {
+ sqlite3_carray_bind -double -static $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 150 {
+ sqlite3_carray_bind -double $STMT 3 1 2 3 4 6 7
+ run_stmt $STMT 0
+} {0}
+do_test 160 {
+ sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {1}
+do_test 170 {
+ sqlite3_carray_bind -text -static $STMT 3 1 2 3 4 6 7
+ run_stmt $STMT 0
+} {0}
+do_test 180 {
+ sqlite3_carray_bind -text -transient $STMT 3 1 2 3 4 5 6 7
+ run_stmt $STMT 0
+} {0}
+do_test 190 {
+ sqlite3_carray_bind $STMT 3
+ run_stmt $STMT 0
+} {0}
+
+sqlite3_finalize $STMT
+
+finish_test
diff --git a/test/cast.test b/test/cast.test
new file mode 100644
index 0000000..cbeec47
--- /dev/null
+++ b/test/cast.test
@@ -0,0 +1,487 @@
+# 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 cast-1.60 {
+ execsql {SELECT CAST(null AS REAL)}
+} {{}}
+do_test cast-1.61 {
+ execsql {SELECT typeof(CAST(null AS REAL))}
+} {null}
+do_test cast-1.62 {
+ execsql {SELECT CAST(1 AS REAL)}
+} {1.0}
+do_test cast-1.63 {
+ execsql {SELECT typeof(CAST(1 AS REAL))}
+} {real}
+do_test cast-1.64 {
+ execsql {SELECT CAST('1' AS REAL)}
+} {1.0}
+do_test cast-1.65 {
+ execsql {SELECT typeof(CAST('1' AS REAL))}
+} {real}
+do_test cast-1.66 {
+ execsql {SELECT CAST('abc' AS REAL)}
+} {0.0}
+do_test cast-1.67 {
+ execsql {SELECT typeof(CAST('abc' AS REAL))}
+} {real}
+do_test cast-1.68 {
+ execsql {SELECT CAST(x'31' AS REAL)}
+} {1.0}
+do_test cast-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 cast-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}
+
+# Added 2018-01-26
+#
+# EVIDENCE-OF: R-48741-32454 If the prefix integer is greater than
+# +9223372036854775807 then the result of the cast is exactly
+# +9223372036854775807.
+do_execsql_test cast-5.1 {
+ SELECT CAST('9223372036854775808' AS integer);
+ SELECT CAST(' +000009223372036854775808' AS integer);
+ SELECT CAST('12345678901234567890123' AS INTEGER);
+} {9223372036854775807 9223372036854775807 9223372036854775807}
+
+# EVIDENCE-OF: R-06028-16857 Similarly, if the prefix integer is less
+# than -9223372036854775808 then the result of the cast is exactly
+# -9223372036854775808.
+do_execsql_test cast-5.2 {
+ SELECT CAST('-9223372036854775808' AS integer);
+ SELECT CAST('-9223372036854775809' AS integer);
+ SELECT CAST('-12345678901234567890123' AS INTEGER);
+} {-9223372036854775808 -9223372036854775808 -9223372036854775808}
+
+# EVIDENCE-OF: R-33990-33527 When casting to INTEGER, if the text looks
+# like a floating point value with an exponent, the exponent will be
+# ignored because it is no part of the integer prefix.
+# EVIDENCE-OF: R-24225-46995 For example, "(CAST '123e+5' AS INTEGER)"
+# results in 123, not in 12300000.
+do_execsql_test cast-5.3 {
+ SELECT CAST('123e+5' AS INTEGER);
+ SELECT CAST('123e+5' AS NUMERIC);
+ SELECT CAST('123e+5' AS REAL);
+} {123 12300000 12300000.0}
+
+
+# The following does not have anything to do with the CAST operator,
+# but it does deal with affinity transformations.
+#
+do_execsql_test cast-6.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a NUMERIC);
+ INSERT INTO t1 VALUES
+ ('9000000000000000001'),
+ ('9000000000000000001 '),
+ (' 9000000000000000001'),
+ (' 9000000000000000001 ');
+ SELECT * FROM t1;
+} {9000000000000000001 9000000000000000001 9000000000000000001 9000000000000000001}
+
+# 2019-06-07
+# https://www.sqlite.org/src/info/4c2d7639f076aa7c
+do_execsql_test cast-7.1 {
+ SELECT CAST('-' AS NUMERIC);
+} {0}
+do_execsql_test cast-7.2 {
+ SELECT CAST('-0' AS NUMERIC);
+} {0}
+do_execsql_test cast-7.3 {
+ SELECT CAST('+' AS NUMERIC);
+} {0}
+do_execsql_test cast-7.4 {
+ SELECT CAST('/' AS NUMERIC);
+} {0}
+
+# 2019-06-07
+# https://www.sqlite.org/src/info/e8bedb2a184001bb
+do_execsql_test cast-7.10 {
+ SELECT '' - 2851427734582196970;
+} {-2851427734582196970}
+do_execsql_test cast-7.11 {
+ SELECT 0 - 2851427734582196970;
+} {-2851427734582196970}
+do_execsql_test cast-7.12 {
+ SELECT '' - 1;
+} {-1}
+
+# 2019-06-10
+# https://www.sqlite.org/src/info/dd6bffbfb6e61db9
+#
+# EVIDENCE-OF: R-55084-10555 Casting a TEXT or BLOB value into NUMERIC
+# yields either an INTEGER or a REAL result.
+#
+do_execsql_test cast-7.20 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0 (c0 TEXT);
+ INSERT INTO t0(c0) VALUES ('1.0');
+ SELECT CAST(c0 AS NUMERIC) FROM t0;
+} {1}
+
+# 2019-06-10
+# https://sqlite.org/src/info/27de823723a41df45af3
+#
+do_execsql_test cast-7.30 {
+ SELECT -'.';
+} 0
+do_execsql_test cast-7.31 {
+ SELECT '.'+0;
+} 0
+do_execsql_test cast-7.32 {
+ SELECT CAST('.' AS numeric);
+} 0
+do_execsql_test cast-7.33 {
+ SELECT -CAST('.' AS numeric);
+} 0
+
+# 2019-06-12
+# https://www.sqlite.org/src/info/674385aeba91c774
+#
+do_execsql_test cast-7.40 {
+ SELECT CAST('-0.0' AS numeric);
+} 0
+do_execsql_test cast-7.41 {
+ SELECT CAST('0.0' AS numeric);
+} 0
+do_execsql_test cast-7.42 {
+ SELECT CAST('+0.0' AS numeric);
+} 0
+do_execsql_test cast-7.43 {
+ SELECT CAST('-1.0' AS numeric);
+} -1
+
+ifcapable utf16 {
+ reset_db
+ execsql { PRAGMA encoding='utf16' }
+
+ do_execsql_test cast-8.1 {
+ SELECT quote(X'310032003300')==quote(substr(X'310032003300', 1))
+ } 1
+ do_execsql_test cast-8.2 {
+ SELECT CAST(X'310032003300' AS TEXT)
+ ==CAST(substr(X'310032003300', 1) AS TEXT)
+ } 1
+}
+
+reset_db
+do_execsql_test cast-9.0 {
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES (0);
+ CREATE VIEW v1(c0, c1) AS
+ SELECT CAST(0.0 AS NUMERIC), COUNT(*) OVER () FROM t0;
+ SELECT v1.c0 FROM v1, t0 WHERE v1.c0=0;
+} {0}
+
+
+finish_test
diff --git a/test/cffault.test b/test/cffault.test
new file mode 100644
index 0000000..0d029ec
--- /dev/null
+++ b/test/cffault.test
@@ -0,0 +1,158 @@
+# 2011 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 contains fault-injection test cases for the
+# sqlite3_db_cacheflush API.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix cffault
+source $testdir/malloc_common.tcl
+
+# Run the supplied SQL on a copy of the database currently stored on
+# disk in file $dbfile.
+proc diskquery {dbfile sql} {
+ forcecopy $dbfile dq.db
+ sqlite3 dq dq.db
+ set res [execsql $sql dq]
+ dq close
+ set res
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE INDEX i1 ON t1(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);
+}
+faultsim_save_and_close
+
+do_faultsim_test 1.1 -prep {
+ faultsim_restore_and_reopen
+ db eval {
+ BEGIN;
+ UPDATE t1 SET b=b+1;
+ }
+} -body {
+ sqlite3_db_cacheflush db
+} -test {
+ if {[sqlite3_get_autocommit db]} { error "Transaction rolled back!" }
+ faultsim_test_result {0 {}} {1 {disk I/O error}}
+ catch { db eval COMMIT }
+ faultsim_integrity_check
+}
+
+do_faultsim_test 1.2 -prep {
+ faultsim_restore_and_reopen
+ db eval {
+ BEGIN;
+ UPDATE t1 SET b=b+1;
+ }
+} -body {
+ set result [list]
+ db eval { SELECT * FROM t1 } {
+ if {$a==5} { catch { sqlite3_db_cacheflush db } }
+ lappend result $a $b
+ }
+ set result
+} -test {
+ faultsim_test_result {0 {1 3 3 5 5 7 7 9}} {1 {disk I/O error}}
+ catch { db eval COMMIT }
+ faultsim_integrity_check
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a PRIMARY KEY, b, c);
+ CREATE INDEX i1 ON t1(b);
+ CREATE INDEX i2 ON t1(c, b);
+ INSERT INTO t1 VALUES(1, 2, randomblob(600));
+ INSERT INTO t1 VALUES(3, 4, randomblob(600));
+ INSERT INTO t1 VALUES(5, 6, randomblob(600));
+ INSERT INTO t1 VALUES(7, 8, randomblob(600));
+ INSERT INTO t1 VALUES(9, 10, randomblob(600));
+}
+faultsim_save_and_close
+
+do_faultsim_test 2.1 -prep {
+ faultsim_restore_and_reopen
+ db eval {
+ BEGIN;
+ UPDATE t1 SET b=b+1;
+ }
+} -body {
+ set result [list]
+ db eval { SELECT * FROM t1 } {
+ if {$a==5} { catch { sqlite3_db_cacheflush db } }
+ lappend result $a $b
+ }
+ set result
+} -test {
+ faultsim_test_result {0 {1 3 3 5 5 7 7 9 9 11}} {1 {disk I/O error}}
+ catch { db eval { INSERT INTO t1 VALUES(11, 12, randomblob(600)) } }
+ catch { db eval COMMIT }
+ faultsim_integrity_check
+}
+
+do_faultsim_test 2.2 -prep {
+ faultsim_restore_and_reopen
+ db eval {
+ BEGIN;
+ UPDATE t1 SET b=b+1;
+ }
+} -body {
+ sqlite3_db_cacheflush db
+} -test {
+ if {[sqlite3_get_autocommit db]} { error "Transaction rolled back!" }
+ faultsim_test_result {0 {}} {1 {disk I/O error}}
+ catch { db eval { SELECT * FROM t1 } }
+ catch { db eval COMMIT }
+ faultsim_integrity_check
+}
+
+do_faultsim_test 2.3 -prep {
+ faultsim_restore_and_reopen
+ db eval {
+ BEGIN;
+ UPDATE t1 SET b=b-1;
+ }
+} -body {
+ sqlite3_db_cacheflush db
+} -test {
+ if {[sqlite3_get_autocommit db]} { error "Transaction rolled back!" }
+ faultsim_test_result {0 {}} {1 {disk I/O error}}
+ catch { db eval { INSERT INTO t1 VALUES(11, 12, randomblob(600)) } }
+ catch { db eval COMMIT }
+ faultsim_integrity_check
+}
+
+do_faultsim_test 2.4 -prep {
+ faultsim_restore_and_reopen
+ db eval {
+ BEGIN;
+ UPDATE t1 SET b=b-1;
+ }
+} -body {
+ catch { sqlite3_db_cacheflush db }
+ catch { sqlite3_db_release_memory db }
+ catch { sqlite3_db_cacheflush db }
+ execsql { SELECT a, b FROM t1 }
+} -test {
+ faultsim_test_result {0 {1 1 3 3 5 5 7 7 9 9}} {1 {disk I/O error}}
+ catchsql ROLLBACK
+ faultsim_integrity_check
+}
+
+finish_test
diff --git a/test/changes.test b/test/changes.test
new file mode 100644
index 0000000..21db075
--- /dev/null
+++ b/test/changes.test
@@ -0,0 +1,90 @@
+# 2021 June 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.
+#
+#***********************************************************************
+#
+# Tests for the sqlite3_changes() and sqlite3_total_changes() APIs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix changes
+
+# To test that the change-counters do not suffer from 32-bit signed integer
+# rollover, add the following line to the array of test cases below. The
+# test will take will over an hour to run.
+#
+# 7 (1<<31)+10 ""
+#
+
+foreach {tn nRow wor} {
+ 1 50 ""
+ 2 50 "WITHOUT ROWID"
+
+ 3 5000 ""
+ 4 5000 "WITHOUT ROWID"
+
+ 5 50000 ""
+ 6 50000 "WITHOUT ROWID"
+} {
+ reset_db
+ set nBig [expr $nRow]
+
+ do_execsql_test 1.$tn.0 "
+ PRAGMA journal_mode = off;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY) $wor;
+ " {off}
+
+ do_execsql_test 1.$tn.1 {
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i < $nBig
+ )
+ INSERT INTO t1 SELECT i FROM s;
+ }
+
+ do_test 1.$tn.2 {
+ db changes
+ } [expr $nBig]
+
+ do_test 1.$tn.3 {
+ db total_changes
+ } [expr $nBig]
+
+ do_execsql_test 1.$tn.4 {
+ INSERT INTO t1 VALUES(-1)
+ }
+
+ do_test 1.$tn.5 {
+ db changes
+ } [expr 1]
+
+ do_test 1.$tn.6 {
+ db total_changes
+ } [expr {$nBig+1}]
+
+ do_execsql_test 1.$tn.7a {
+ SELECT count(*) FROM t1
+ } [expr {$nBig+1}]
+
+ do_execsql_test 1.$tn.7 {
+ DELETE FROM t1
+ }
+
+ do_test 1.$tn.8 {
+ db changes
+ } [expr {$nBig+1}]
+
+ do_test 1.$tn.9 {
+ db total_changes
+ } [expr {2*($nBig+1)}]
+}
+
+finish_test
+
+
diff --git a/test/changes2.test b/test/changes2.test
new file mode 100644
index 0000000..46e25c0
--- /dev/null
+++ b/test/changes2.test
@@ -0,0 +1,95 @@
+# 2022 June 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 changes2
+
+do_execsql_test 1.0 {
+ CREATE TABLE some_table (
+ id INTEGER NOT NULL, value VARCHAR(40) NOT NULL, PRIMARY KEY (id)
+ );
+ INSERT INTO some_table (id, value) VALUES (1, 'v1');
+} {}
+
+set ::stmt [sqlite3_prepare_v2 db {
+ UPDATE some_table SET value='v2' WHERE id=1 RETURNING id
+} -1 dummy]
+
+do_test 1.1 {
+ list [sqlite3_step $::stmt] [db changes]
+} {SQLITE_ROW 1}
+
+do_test 1.2 {
+ list [sqlite3_step $::stmt] [db changes]
+} {SQLITE_DONE 1}
+
+sqlite3_reset $::stmt
+
+do_execsql_test 1.2 {
+ DROP TABLE some_table;
+ CREATE TABLE some_table (
+ id INTEGER NOT NULL, value VARCHAR(40) NOT NULL, PRIMARY KEY (id)
+ );
+ INSERT INTO some_table (id, value) VALUES (1, 'v1');
+} {}
+
+do_test 1.3 {
+ list [sqlite3_step $::stmt] [db changes]
+} {SQLITE_ROW 1}
+
+do_test 1.4 {
+ list [sqlite3_step $::stmt] [db changes]
+} {SQLITE_DONE 1}
+
+sqlite3_finalize $::stmt
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE log(t);
+} {}
+
+set ::stmt [sqlite3_prepare_v2 db {
+ INSERT INTO log VALUES(changes() || ' changes')
+} -1 dummy]
+
+do_execsql_test 2.1 {
+ INSERT INTO t1 VALUES (1, 'v1'), (2, 'v2');
+} {}
+
+do_test 2.2 {
+ list [sqlite3_step $::stmt] [sqlite3_reset $::stmt]
+} {SQLITE_DONE SQLITE_OK}
+
+do_execsql_test 2.3 {
+ CREATE TABLE t3(x);
+}
+
+do_execsql_test 2.2 {
+ INSERT INTO t1 VALUES (3, 'v1'), (4, 'v2');
+} {}
+
+do_test 2.3 {
+ list [sqlite3_step $::stmt] [sqlite3_reset $::stmt]
+} {SQLITE_DONE SQLITE_OK}
+
+sqlite3_finalize $::stmt
+
+do_execsql_test 2.4 {
+ SELECT * FROM log;
+} {{2 changes} {2 changes}}
+
+finish_test
+
diff --git a/test/check.test b/test/check.test
new file mode 100644
index 0000000..10d1cf4
--- /dev/null
+++ b/test/check.test
@@ -0,0 +1,615 @@
+# 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
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix check
+
+# Only run these tests if the build includes support for CHECK constraints
+ifcapable !check {
+ finish_test
+ return
+}
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+
+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 {CHECK constraint failed: x<5}}
+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 {CHECK constraint failed: y>x}}
+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 {CHECK constraint failed: x<5}}
+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 {CHECK constraint failed: x<5}}
+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 {
+ PRAGMA writable_schema = 1;
+ CREATE TABLE t2(
+ x INTEGER CONSTRAINT one CHECK( typeof(coalesce(x,0))=="integer" ),
+ y REAL CONSTRAINT two CHECK( typeof(coalesce(y,0.1))=='real' ),
+ z TEXT CONSTRAINT three CHECK( typeof(coalesce(z,''))=='text' )
+ );
+ CREATE TABLE t2n(
+ x INTEGER CONSTRAINT one CHECK( typeof(coalesce(x,0))=="integer" ),
+ y NUMERIC CONSTRAINT two CHECK( typeof(coalesce(y,0.1))=='real' ),
+ z TEXT CONSTRAINT three CHECK( typeof(coalesce(z,''))=='text' )
+ );
+ PRAGMA writable_schema = 0;
+ }
+} {}
+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
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+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 {CHECK constraint failed: one}}
+do_test check-2.5 {
+ # The 5 gets automatically promoted to 5.0 because the column type is REAL
+ catchsql {
+ INSERT INTO t2 VALUES(NULL, 5, NULL);
+ }
+} {0 {}}
+do_test check-2.5b {
+ # This time the column type is NUMERIC, so not automatic promption to REAL
+ # occurs and the constraint fails.
+ catchsql {
+ INSERT INTO t2n VALUES(NULL, 5, NULL);
+ }
+} {1 {CHECK constraint failed: two}}
+do_test check-2.6 {
+ catchsql {
+ INSERT INTO t2 VALUES(NULL, NULL, 3.14159);
+ }
+} {0 {}}
+
+# Undocumented behavior: The CONSTRAINT name clause can follow a constraint.
+# Such a clause is ignored. But the parser must accept it for backwards
+# compatibility.
+#
+do_test check-2.10 {
+ execsql {
+ CREATE TABLE t2b(
+ x INTEGER CHECK( typeof(coalesce(x,0))=='integer' ) CONSTRAINT one,
+ y TEXT PRIMARY KEY constraint two,
+ z INTEGER,
+ UNIQUE(x,z) constraint three
+ );
+ }
+} {}
+do_test check-2.11 {
+ catchsql {
+ INSERT INTO t2b VALUES('xyzzy','hi',5);
+ }
+} {1 {CHECK constraint failed: typeof(coalesce(x,0))=='integer'}}
+do_test check-2.12 {
+ execsql {
+ CREATE TABLE t2c(
+ x INTEGER CONSTRAINT x_one CONSTRAINT x_two
+ CHECK( typeof(coalesce(x,0))=='integer' )
+ CONSTRAINT x_two CONSTRAINT x_three,
+ y INTEGER, z INTEGER,
+ CONSTRAINT u_one UNIQUE(x,y,z) CONSTRAINT u_two
+ );
+ }
+} {}
+do_test check-2.13 {
+ catchsql {
+ INSERT INTO t2c VALUES('xyzzy',7,8);
+ }
+} {1 {CHECK constraint failed: x_two}}
+do_test check-2.cleanup {
+ execsql {
+ DROP TABLE IF EXISTS t2b;
+ DROP TABLE IF EXISTS t2c;
+ DROP TABLE IF EXISTS t2n;
+ }
+} {}
+
+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 {CHECK constraint failed: t3.x<25}}
+
+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 {CHECK constraint failed: x+y==11
+ OR x*y==12
+ OR x/y BETWEEN 5 AND 8
+ OR -x==y+10}}
+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;
+ PRAGMA integrity_check;
+ }
+} {0 1 ok}
+do_execsql_test check-4.8.1 {
+ PRAGMA ignore_check_constraints=OFF;
+ PRAGMA integrity_check;
+} {{CHECK constraint failed in t4}}
+do_test check-4.9 {
+ catchsql {
+ UPDATE t4 SET x=0, y=2;
+ }
+} {1 {CHECK constraint failed: x+y==11
+ OR x*y==12
+ OR x/y BETWEEN 5 AND 8
+ OR -x==y+10}}
+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 {CHECK constraint failed: x<5}}
+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 {CHECK constraint failed: x<5}}
+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 {CHECK constraint failed: x<5}}
+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}
+
+
+}
+
+#--------------------------------------------------------------------------
+# If a connection opens a database that contains a CHECK constraint that
+# uses an unknown UDF, the schema should not be considered malformed.
+# Attempting to modify the table should fail (since the CHECK constraint
+# cannot be tested).
+#
+reset_db
+proc myfunc {x} {expr $x < 10}
+db func myfunc -deterministic myfunc
+
+do_execsql_test 7.1 { CREATE TABLE t6(a CHECK (myfunc(a))) }
+do_execsql_test 7.2 { INSERT INTO t6 VALUES(9) }
+do_catchsql_test 7.3 { INSERT INTO t6 VALUES(11) } \
+ {1 {CHECK constraint failed: myfunc(a)}}
+
+do_test 7.4 {
+ sqlite3 db2 test.db
+ execsql { SELECT * FROM t6 } db2
+} {9}
+
+do_test 7.5 {
+ catchsql { INSERT INTO t6 VALUES(8) } db2
+} {1 {unknown function: myfunc()}}
+
+do_test 7.6 {
+ catchsql { CREATE TABLE t7(a CHECK (myfunc(a))) } db2
+} {1 {no such function: myfunc}}
+
+do_test 7.7 {
+ db2 func myfunc myfunc
+ execsql { INSERT INTO t6 VALUES(8) } db2
+} {}
+
+do_test 7.8 {
+ db2 func myfunc myfunc
+ catchsql { INSERT INTO t6 VALUES(12) } db2
+} {1 {CHECK constraint failed: myfunc(a)}}
+
+# 2013-08-02: Silently ignore database name qualifiers in CHECK constraints.
+#
+do_execsql_test 8.1 {
+ CREATE TABLE t810(a, CHECK( main.t810.a>0 ));
+ CREATE TABLE t811(b, CHECK( xyzzy.t811.b BETWEEN 5 AND 10 ));
+} {}
+
+# Make sure check constraints involving the ROWID are not ignored
+#
+do_execsql_test 9.1 {
+ CREATE TABLE t1(
+ a INTEGER PRIMARY KEY,
+ b INTEGER NOT NULL CONSTRAINT 'b-check' CHECK( b>a ),
+ c INTEGER NOT NULL CONSTRAINT 'c-check' CHECK( c>rowid*2 ),
+ d INTEGER NOT NULL CONSTRAINT 'd-check' CHECK( d BETWEEN b AND c )
+ );
+ INSERT INTO t1(a,b,c,d) VALUES(1,2,4,3),(2,4,6,5),(3,10,30,20);
+} {}
+do_catchsql_test 9.2 {
+ UPDATE t1 SET b=0 WHERE a=1;
+} {1 {CHECK constraint failed: b-check}}
+do_catchsql_test 9.3 {
+ UPDATE t1 SET c=a*2 WHERE a=1;
+} {1 {CHECK constraint failed: c-check}}
+
+# Integrity check on a VIEW with columns.
+#
+db close
+db2 close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 10.1 {
+ CREATE TABLE t1(x);
+ CREATE VIEW v1(y) AS SELECT x FROM t1;
+ PRAGMA integrity_check;
+} {ok}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 11.0 {
+ CREATE TABLE t1 (Col0 CHECK(1 COLLATE BINARY BETWEEN 1 AND 1) ) ;
+}
+do_execsql_test 11.1 {
+ INSERT INTO t1 VALUES (NULL);
+}
+do_execsql_test 11.2 {
+ INSERT INTO t1 VALUES (NULL);
+}
+
+do_execsql_test 11.3 {
+ CREATE TABLE t2(b, a CHECK(
+ CASE 'abc' COLLATE nocase WHEN a THEN 1 ELSE 0 END)
+ );
+}
+do_execsql_test 11.4 {
+ INSERT INTO t2(a) VALUES('abc');
+}
+do_execsql_test 11.5 {
+ INSERT INTO t2(b, a) VALUES(1, 'abc'||'');
+}
+do_execsql_test 11.6 {
+ INSERT INTO t2(b, a) VALUES(2, 'abc');
+}
+
+# 2019-12-24 ticket b383b90278186263
+#
+reset_db
+do_execsql_test 12.10 {
+ CREATE TABLE t1(a TEXT, CHECK(a=+a));
+ INSERT INTO t1(a) VALUES(NULL),('xyz'),(5),(x'303132'),(4.75);
+ SELECT quote(a) FROM t1 ORDER BY rowid;
+} {NULL 'xyz' '5' X'303132' '4.75'}
+do_execsql_test 12.20 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a TEXT, CHECK(a<>+a));
+ INSERT INTO t1(a) VALUES(NULL);
+} {}
+do_catchsql_test 12.21 {
+ INSERT INTO t1(a) VALUES('xyz');
+} {1 {CHECK constraint failed: a<>+a}}
+do_catchsql_test 12.22 {
+ INSERT INTO t1(a) VALUES(123);
+} {1 {CHECK constraint failed: a<>+a}}
+do_execsql_test 12.30 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a TEXT, CHECK(NOT(a=+a)));
+ INSERT INTO t1(a) VALUES(NULL);
+} {}
+do_catchsql_test 12.31 {
+ INSERT INTO t1(a) VALUES('xyz');
+} {1 {CHECK constraint failed: NOT(a=+a)}}
+do_catchsql_test 12.32 {
+ INSERT INTO t1(a) VALUES(123);
+} {1 {CHECK constraint failed: NOT(a=+a)}}
+do_execsql_test 12.40 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a TEXT, CHECK(NOT(a<>+a)));
+ INSERT INTO t1(a) VALUES(NULL),('xyz'),(5),(x'303132'),(4.75);
+ SELECT quote(a) FROM t1 ORDER BY rowid;
+} {NULL 'xyz' '5' X'303132' '4.75'}
+do_execsql_test 12.50 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a TEXT, CHECK(a BETWEEN 0 AND +a));
+ INSERT INTO t1(a) VALUES(NULL),('xyz'),(5),(x'303132'),(4.75);
+ SELECT quote(a) FROM t1 ORDER BY rowid;
+} {NULL 'xyz' '5' X'303132' '4.75'}
+do_execsql_test 12.60 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a TEXT, CHECK(a NOT BETWEEN 0 AND +a));
+ INSERT INTO t1(a) VALUES(NULL);
+ SELECT quote(a) FROM t1 ORDER BY rowid;
+} {NULL}
+do_catchsql_test 12.61 {
+ INSERT INTO t1(a) VALUES(456);
+} {1 {CHECK constraint failed: a NOT BETWEEN 0 AND +a}}
+do_execsql_test 12.70 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a TEXT, CHECK(a BETWEEN +a AND 999999));
+ INSERT INTO t1(a) VALUES(NULL),(5);
+ SELECT quote(a) FROM t1 ORDER BY rowid;
+} {NULL '5'}
+do_execsql_test 12.80 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a TEXT, CHECK(a NOT BETWEEN +a AND 999999));
+ INSERT INTO t1(a) VALUES(NULL);
+ SELECT quote(a) FROM t1 ORDER BY rowid;
+} {NULL}
+do_catchsql_test 12.81 {
+ INSERT INTO t1(a) VALUES(456);
+} {1 {CHECK constraint failed: a NOT BETWEEN +a AND 999999}}
+
+finish_test
diff --git a/test/checkfault.test b/test/checkfault.test
new file mode 100644
index 0000000..3b18a64
--- /dev/null
+++ b/test/checkfault.test
@@ -0,0 +1,41 @@
+# 2019 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 contains fault-injection test cases for the
+# sqlite3_db_cacheflush API.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix cffault
+source $testdir/malloc_common.tcl
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1 (Col0 CHECK(1 COLLATE BINARY BETWEEN 1 AND 1) ) ;
+ CREATE TABLE t2(b, a CHECK(
+ CASE 'abc' COLLATE nocase WHEN a THEN 1 ELSE 0 END)
+ );
+}
+
+do_faultsim_test 1.1 -faults oom* -body {
+ execsql { INSERT INTO t1 VALUES ('ABCDEFG') }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 1.2 -faults oom* -body {
+ execsql { INSERT INTO t2(a) VALUES('abc') }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+finish_test
diff --git a/test/chunksize.test b/test/chunksize.test
new file mode 100644
index 0000000..47d118d
--- /dev/null
+++ b/test/chunksize.test
@@ -0,0 +1,41 @@
+# 2019 June 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix chunksize
+
+if {$::tcl_platform(platform)!="unix"} {
+ finish_test
+ return
+}
+
+foreach {tn jrnlmode} {
+ 1 delete
+ 2 wal
+} {
+ reset_db
+ file_control_chunksize_test db main 32768
+ do_execsql_test $tn.0 " PRAGMA journal_mode = $jrnlmode " $jrnlmode
+ do_execsql_test $tn.1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+
+ execsql { PRAGMA wal_checkpoint }
+
+ do_test $tn.2 {
+ file size test.db
+ } 32768
+}
+
+finish_test
diff --git a/test/close.test b/test/close.test
new file mode 100644
index 0000000..107c7a7
--- /dev/null
+++ b/test/close.test
@@ -0,0 +1,89 @@
+# 2013 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.
+#
+#***********************************************************************
+#
+# Test some specific circumstances to do with shared cache mode.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix close
+
+# This module bypasses the "-key" logic in tester.tcl, so it cannot run
+# with the codec enabled.
+do_not_use_codec
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('one');
+ INSERT INTO t1 VALUES('two');
+ INSERT INTO t1 VALUES('three');
+}
+db close
+
+do_test 1.1 {
+ set DB [sqlite3_open test.db]
+ sqlite3_close_v2 $DB
+} {SQLITE_OK}
+
+do_test 1.2.1 {
+ set DB [sqlite3_open test.db]
+ set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
+ sqlite3_close_v2 $DB
+} {SQLITE_OK}
+do_test 1.2.2 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test 1.3.1 {
+ set DB [sqlite3_open test.db]
+ set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
+ sqlite3_step $STMT
+ sqlite3_close_v2 $DB
+} {SQLITE_OK}
+
+do_test 1.3.2 {
+ sqlite3_column_text $STMT 0
+} {one}
+
+do_test 1.3.3 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test 1.4.1 {
+ set DB [sqlite3_open test.db]
+ set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
+ sqlite3_step $STMT
+ sqlite3_close_v2 $DB
+} {SQLITE_OK}
+
+do_test 1.4.2 {
+ list [sqlite3_step $STMT] [sqlite3_column_text $STMT 0]
+} {SQLITE_ROW two}
+
+do_test 1.4.3 {
+ list [catch {
+ sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 dummy
+ } msg] $msg
+} {1 {(21) bad parameter or other API misuse}}
+
+do_test 1.4.4 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test 1.5 {
+ set DB [sqlite3_open test.db]
+ sqlite3_blob_open $DB main t1 x 2 0 BLOB
+ sqlite3_close_v2 $DB
+ sqlite3_blob_close $BLOB
+} {}
+
+finish_test
diff --git a/test/closure01.test b/test/closure01.test
new file mode 100644
index 0000000..ee3f2dd
--- /dev/null
+++ b/test/closure01.test
@@ -0,0 +1,295 @@
+# 2013-04-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.
+#
+#***********************************************************************
+#
+# Test cases for transitive_closure virtual table.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix closure01
+
+ifcapable !vtab||!cte { finish_test ; return }
+
+load_static_extension db closure
+
+do_execsql_test 1.0 {
+ BEGIN;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y INTEGER);
+ WITH RECURSIVE
+ cnt(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM cnt LIMIT 131072)
+ INSERT INTO t1(x, y) SELECT i, nullif(i,1)/2 FROM cnt;
+ CREATE INDEX t1y ON t1(y);
+ COMMIT;
+ CREATE VIRTUAL TABLE cx
+ USING transitive_closure(tablename=t1, idcolumn=x, parentcolumn=y);
+} {}
+
+# The entire table
+do_timed_execsql_test 1.1 {
+ SELECT count(*), depth FROM cx WHERE root=1 GROUP BY depth ORDER BY 1;
+} {/1 0 1 17 2 1 4 2 8 3 16 4 .* 65536 16/}
+do_timed_execsql_test 1.1-cte {
+ WITH RECURSIVE
+ below(id,depth) AS (
+ VALUES(1,0)
+ UNION ALL
+ SELECT t1.x, below.depth+1
+ FROM t1 JOIN below on t1.y=below.id
+ )
+ SELECT count(*), depth FROM below GROUP BY depth ORDER BY 1;
+} {/1 0 1 17 2 1 4 2 8 3 16 4 .* 65536 16/}
+
+# descendents of 32768
+do_timed_execsql_test 1.2 {
+ SELECT * FROM cx WHERE root=32768 ORDER BY id;
+} {32768 0 65536 1 65537 1 131072 2}
+do_timed_execsql_test 1.2-cte {
+ WITH RECURSIVE
+ below(id,depth) AS (
+ VALUES(32768,0)
+ UNION ALL
+ SELECT t1.x, below.depth+1
+ FROM t1 JOIN below on t1.y=below.id
+ WHERE below.depth<2
+ )
+ SELECT id, depth FROM below ORDER BY id;
+} {32768 0 65536 1 65537 1 131072 2}
+
+# descendents of 16384
+do_timed_execsql_test 1.3 {
+ SELECT * FROM cx WHERE root=16384 AND depth<=2 ORDER BY id;
+} {16384 0 32768 1 32769 1 65536 2 65537 2 65538 2 65539 2}
+do_timed_execsql_test 1.3-cte {
+ WITH RECURSIVE
+ below(id,depth) AS (
+ VALUES(16384,0)
+ UNION ALL
+ SELECT t1.x, below.depth+1
+ FROM t1 JOIN below on t1.y=below.id
+ WHERE below.depth<2
+ )
+ SELECT id, depth FROM below ORDER BY id;
+} {16384 0 32768 1 32769 1 65536 2 65537 2 65538 2 65539 2}
+
+# children of 16384
+do_execsql_test 1.4 {
+ SELECT id, depth, root, tablename, idcolumn, parentcolumn FROM cx
+ WHERE root=16384
+ AND depth=1
+ ORDER BY id;
+} {32768 1 {} t1 x y 32769 1 {} t1 x y}
+
+# great-grandparent of 16384
+do_timed_execsql_test 1.5 {
+ SELECT id, depth, root, tablename, idcolumn, parentcolumn FROM cx
+ WHERE root=16384
+ AND depth=3
+ AND idcolumn='Y'
+ AND parentcolumn='X';
+} {2048 3 {} t1 Y X}
+do_timed_execsql_test 1.5-cte {
+ WITH RECURSIVE
+ above(id,depth) AS (
+ VALUES(16384,0)
+ UNION ALL
+ SELECT t1.y, above.depth+1
+ FROM t1 JOIN above ON t1.x=above.id
+ WHERE above.depth<3
+ )
+ SELECT id FROM above WHERE depth=3;
+} {2048}
+
+# depth<5
+do_timed_execsql_test 1.6 {
+ SELECT count(*), depth FROM cx WHERE root=1 AND depth<5
+ GROUP BY depth ORDER BY 1;
+} {1 0 2 1 4 2 8 3 16 4}
+do_timed_execsql_test 1.6-cte {
+ WITH RECURSIVE
+ below(id,depth) AS (
+ VALUES(1,0)
+ UNION ALL
+ SELECT t1.x, below.depth+1
+ FROM t1 JOIN below ON t1.y=below.id
+ WHERE below.depth<4
+ )
+ SELECT count(*), depth FROM below GROUP BY depth ORDER BY 1;
+} {1 0 2 1 4 2 8 3 16 4}
+
+# depth<=5
+do_execsql_test 1.7 {
+ SELECT count(*), depth FROM cx WHERE root=1 AND depth<=5
+ GROUP BY depth ORDER BY 1;
+} {1 0 2 1 4 2 8 3 16 4 32 5}
+
+# depth==5
+do_execsql_test 1.8 {
+ SELECT count(*), depth FROM cx WHERE root=1 AND depth=5
+ GROUP BY depth ORDER BY 1;
+} {32 5}
+
+# depth BETWEEN 3 AND 5
+do_execsql_test 1.9 {
+ SELECT count(*), depth FROM cx WHERE root=1 AND depth BETWEEN 3 AND 5
+ GROUP BY depth ORDER BY 1;
+} {8 3 16 4 32 5}
+
+# depth==5 with min() and max()
+do_timed_execsql_test 1.10 {
+ SELECT count(*), min(id), max(id) FROM cx WHERE root=1 AND depth=5;
+} {32 32 63}
+do_timed_execsql_test 1.10-cte {
+ WITH RECURSIVE
+ below(id,depth) AS (
+ VALUES(1,0)
+ UNION ALL
+ SELECT t1.x, below.depth+1
+ FROM t1 JOIN below ON t1.y=below.id
+ WHERE below.depth<5
+ )
+ SELECT count(*), min(id), max(id) FROM below WHERE depth=5;
+} {32 32 63}
+
+# Create a much smaller table t2 with only 32 elements
+db eval {
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y INTEGER);
+ INSERT INTO t2 SELECT x, y FROM t1 WHERE x<32;
+ CREATE INDEX t2y ON t2(y);
+ CREATE VIRTUAL TABLE c2
+ USING transitive_closure(tablename=t2, idcolumn=x, parentcolumn=y);
+}
+
+# t2 full-table
+do_execsql_test 2.1 {
+ SELECT count(*), min(id), max(id) FROM c2 WHERE root=1;
+} {31 1 31}
+# t2 root=10
+do_execsql_test 2.2 {
+ SELECT id FROM c2 WHERE root=10;
+} {10 20 21}
+# t2 root=11
+do_execsql_test 2.3 {
+ SELECT id FROM c2 WHERE root=12;
+} {12 24 25}
+# t2 root IN [10,12]
+do_execsql_test 2.4 {
+ SELECT id FROM c2 WHERE root IN (10,12) ORDER BY id;
+} {10 12 20 21 24 25}
+# t2 root IN [10,12] (sorted)
+do_execsql_test 2.5 {
+ SELECT id FROM c2 WHERE root IN (10,12) ORDER BY +id;
+} {10 12 20 21 24 25}
+
+# t2 c2up from 20
+do_execsql_test 3.0 {
+ CREATE VIRTUAL TABLE c2up USING transitive_closure(
+ tablename = t2,
+ idcolumn = y,
+ parentcolumn = x
+ );
+ SELECT id FROM c2up WHERE root=20;
+} {1 2 5 10 20}
+
+# cx as c2up
+do_execsql_test 3.1 {
+ SELECT id FROM cx
+ WHERE root=20
+ AND tablename='t2'
+ AND idcolumn='y'
+ AND parentcolumn='x';
+} {1 2 5 10 20}
+
+# t2 first cousins of 20
+do_execsql_test 3.2 {
+ SELECT DISTINCT id FROM c2
+ WHERE root IN (SELECT id FROM c2up
+ WHERE root=20 AND depth<=2)
+ ORDER BY id;
+} {5 10 11 20 21 22 23}
+
+# t2 first cousins of 20
+do_execsql_test 3.3 {
+ SELECT id FROM c2
+ WHERE root=(SELECT id FROM c2up
+ WHERE root=20 AND depth=2)
+ AND depth=2
+ EXCEPT
+ SELECT id FROM c2
+ WHERE root=(SELECT id FROM c2up
+ WHERE root=20 AND depth=1)
+ AND depth<=1
+ ORDER BY id;
+} {22 23}
+
+# missing tablename.
+do_test 4.1 {
+ catchsql {
+ SELECT id FROM cx
+ WHERE root=20
+ AND tablename='t3'
+ AND idcolumn='y'
+ AND parentcolumn='x';
+ }
+} {1 {no such table: t3}}
+
+# missing idcolumn
+do_test 4.2 {
+ catchsql {
+ SELECT id FROM cx
+ WHERE root=20
+ AND tablename='t2'
+ AND idcolumn='xyz'
+ AND parentcolumn='x';
+ }
+} {1 {no such column: t2.xyz}}
+
+# missing parentcolumn
+do_test 4.3 {
+ catchsql {
+ SELECT id FROM cx
+ WHERE root=20
+ AND tablename='t2'
+ AND idcolumn='x'
+ AND parentcolumn='pqr';
+ }
+} {1 {no such column: t2.pqr}}
+
+# generic closure
+do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE temp.closure USING transitive_closure;
+ SELECT id FROM closure
+ WHERE root=1
+ AND depth=3
+ AND tablename='t1'
+ AND idcolumn='x'
+ AND parentcolumn='y'
+ ORDER BY id;
+} {8 9 10 11 12 13 14 15}
+
+#-------------------------------------------------------------------------
+# At one point the following join query was causing a malfunction in
+# xBestIndex.
+#
+do_execsql_test 6.0 {
+ CREATE TABLE t4 (
+ id INTEGER PRIMARY KEY,
+ name TEXT NOT NULL,
+ parent_id INTEGER
+ );
+ CREATE VIRTUAL TABLE vt4 USING transitive_closure (
+ idcolumn=id, parentcolumn=parent_id, tablename=t4
+ );
+}
+
+do_execsql_test 6.1 {
+ SELECT * FROM t4, vt4 WHERE t4.id = vt4.root AND vt4.id=4 AND vt4.depth=2;
+}
+
+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..b65b850
--- /dev/null
+++ b/test/collate1.test
@@ -0,0 +1,452 @@
+#
+# 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 testing collation sequences.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix collate1
+
+#
+# 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;
+ }
+} {}
+
+# A problem reported on the mailing list: A CREATE TABLE statement
+# is allowed to have two or more COLLATE clauses on the same column.
+# That probably ought to be an error, but we allow it for backwards
+# compatibility. Just make sure it works and doesn't leak memory.
+#
+do_test collate1-5.1 {
+ execsql {
+ CREATE TABLE c5(
+ id INTEGER PRIMARY KEY,
+ a TEXT COLLATE binary COLLATE nocase COLLATE rtrim,
+ b TEXT COLLATE nocase COLLATE binary,
+ c TEXT COLLATE rtrim COLLATE binary COLLATE rtrim COLLATE nocase
+ );
+ INSERT INTO c5 VALUES(1, 'abc','abc','abc');
+ INSERT INTO c5 VALUES(2, 'abc ','ABC','ABC');
+ SELECT id FROM c5 WHERE a='abc' ORDER BY id;
+ }
+} {1 2}
+do_test collate1-5.2 {
+ execsql {
+ SELECT id FROM c5 WHERE b='abc' ORDER BY id;
+ }
+} {1}
+do_test collate1-5.3 {
+ execsql {
+ SELECT id FROM c5 WHERE c='abc' ORDER BY id;
+ }
+} {1 2}
+
+
+
+#-------------------------------------------------------------------------
+# Fix problems with handling collation sequences named '"""'.
+#
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+do_execsql_test 6.1 {
+ SELECT """""""";
+} {\"\"\"}
+
+do_catchsql_test 6.2 {
+ CREATE TABLE x1(a);
+ SELECT a FROM x1 ORDER BY a COLLATE """""""";
+} {1 {no such collation sequence: """}}
+
+do_catchsql_test 6.3 {
+ SELECT a FROM x1 ORDER BY 1 COLLATE """""""";
+} {1 {no such collation sequence: """}}
+
+do_catchsql_test 6.4 {
+ SELECT 0 UNION SELECT 0 ORDER BY 1 COLLATE """""""";
+} {1 {no such collation sequence: """}}
+
+db collate {"""} [list string compare -nocase]
+
+do_execsql_test 6.5 {
+ PRAGMA foreign_keys = ON;
+ CREATE TABLE p1(a PRIMARY KEY COLLATE '"""');
+ CREATE TABLE c1(x, y REFERENCES p1);
+} {}
+
+do_execsql_test 6.6 {
+ INSERT INTO p1 VALUES('abc');
+ INSERT INTO c1 VALUES(1, 'ABC');
+}
+
+ifcapable foreignkey {
+ do_catchsql_test 6.7 {
+ DELETE FROM p1 WHERE rowid = 1
+ } {1 {FOREIGN KEY constraint failed}}
+}
+
+do_execsql_test 6.8 {
+ INSERT INTO p1 VALUES('abb');
+ INSERT INTO p1 VALUES('wxz');
+ INSERT INTO p1 VALUES('wxy');
+
+ INSERT INTO c1 VALUES(2, 'abb');
+ INSERT INTO c1 VALUES(3, 'wxz');
+ INSERT INTO c1 VALUES(4, 'WXY');
+ SELECT x, y FROM c1 ORDER BY y COLLATE """""""";
+} {2 abb 1 ABC 4 WXY 3 wxz}
+
+# 2015-04-15: Nested COLLATE operators
+#
+do_execsql_test 7.0 {
+ SELECT 'abc' UNION ALL SELECT 'DEF'
+ ORDER BY 1 COLLATE nocase COLLATE nocase COLLATE nocase COLLATE nocase;
+} {abc DEF}
+do_execsql_test 7.1 {
+ SELECT 'abc' UNION ALL SELECT 'DEF'
+ ORDER BY 1 COLLATE nocase COLLATE nocase COLLATE nocase COLLATE binary;
+} {DEF abc}
+do_execsql_test 7.2 {
+ SELECT 'abc' UNION ALL SELECT 'DEF'
+ ORDER BY 1 COLLATE binary COLLATE binary COLLATE binary COLLATE nocase;
+} {abc DEF}
+
+# 2019-06-14
+# https://sqlite.org/src/info/f1580ba1b574e9e9
+#
+do_execsql_test 8.0 {
+ SELECT ' ' > char(20) COLLATE rtrim;
+} 0
+do_execsql_test 8.1 {
+ SELECT '' < char(20) COLLATE rtrim;
+} 1
+do_execsql_test 8.2 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 COLLATE RTRIM, c1 BLOB UNIQUE,
+ PRIMARY KEY (c0, c1)) WITHOUT ROWID;
+ INSERT INTO t0 VALUES (123, 3), (' ', 1), (' ', 2), ('', 4);
+ SELECT * FROM t0 WHERE c1 = 1;
+} {{ } 1}
+
+# 2019-10-09
+# ALWAYS() macro fails following OOM
+# Problem detected by dbsqlfuzz.
+#
+do_execsql_test 9.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+}
+
+do_faultsim_test 9.1 -faults oom* -body {
+ execsql {
+ SELECT * FROM (
+ SELECT b COLLATE nocase IN (SELECT c FROM t2) FROM t1
+ );
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+# 2020-01-03 dbsqlfuzz find
+#
+reset_db
+do_catchsql_test 10.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b);
+ INSERT INTO t1 VALUES(0,NULL);
+ CREATE TABLE t2(x UNIQUE);
+ CREATE VIEW v1a(z,y) AS SELECT x COLLATE x FROM t2;
+ SELECT a,b,z,y,'' FROM t1 JOIN v1a ON b IS NOT FALSE;
+} {1 {no such collation sequence: x}}
+
+
+finish_test
diff --git a/test/collate2.test b/test/collate2.test
new file mode 100644
index 0000000..281aa35
--- /dev/null
+++ b/test/collate2.test
@@ -0,0 +1,742 @@
+#
+# 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
+
+set ::testprefix collate2
+
+#
+# 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||''
+ ORDER BY +collate2t1.a DESC;
+ }
+} {aa aA Aa AA}
+do_test collate2-4.4 {
+ execsql {
+ SELECT collate2t1.a FROM collate2t1, collate2t3
+ WHERE collate2t3.b||'' = collate2t1.b
+ ORDER BY +collate2t1.a DESC;
+ }
+} {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.1 {
+ execsql {
+ SELECT collate2t2.b FROM collate2t1 LEFT JOIN collate2t2 USING (b) order by collate2t1.oid;
+ }
+} {{} aa {} {} {} aa {} {} {} aa {} {} {} aa {} {} {}}
+do_test collate2-5.4.2 {
+ execsql {
+ SELECT collate2t2.b FROM collate2t2 RIGHT JOIN collate2t1 ON collate2t1.b=collate2t2.b
+ ORDER BY collate2t1.oid;
+ }
+} {{} aa {} {} {} aa {} {} {} aa {} {} {} aa {} {} {}}
+do_test collate2-5.4.3 {
+ execsql {
+ SELECT collate2t2.b FROM collate2t1 LEFT JOIN collate2t2 ON collate2t2.b=collate2t1.b
+ ORDER BY collate2t1.oid;
+ }
+} {{} aa {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}}
+do_test collate2-5.5.1 {
+ execsql {
+ SELECT collate2t1.b, collate2t2.b FROM collate2t2 LEFT OUTER JOIN collate2t1 USING (b);
+ }
+} {aa aa}
+do_test collate2-5.5.2 {
+ execsql {
+ SELECT collate2t1.b, collate2t2.b
+ FROM collate2t1 RIGHT JOIN collate2t2 ON collate2t2.b=collate2t1.b
+ }
+} {aa aa}
+
+do_execsql_test 6.1 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('b');
+ INSERT INTO t1 VALUES('B');
+}
+do_execsql_test 6.2 {
+ SELECT * FROM t1 WHERE x COLLATE nocase BETWEEN 'a' AND 'c';
+} {b B}
+do_execsql_test 6.3 {
+ SELECT * FROM t1 WHERE x BETWEEN 'a' COLLATE nocase AND 'c' COLLATE nocase;
+} {b B}
+do_execsql_test 6.4 {
+ SELECT * FROM t1
+ WHERE x COLLATE nocase BETWEEN 'a' COLLATE nocase AND 'c' COLLATE nocase;
+} {b B}
+do_execsql_test 6.5 {
+ SELECT * FROM t1 WHERE +x COLLATE nocase BETWEEN 'a' AND 'c';
+} {b B}
+do_execsql_test 6.6 {
+ SELECT * FROM t1 WHERE +x BETWEEN 'a' COLLATE nocase AND 'c' COLLATE nocase;
+} {b B}
+do_execsql_test 6.7 {
+ SELECT * FROM t1
+ WHERE +x COLLATE nocase BETWEEN 'a' COLLATE nocase AND 'c' COLLATE nocase;
+} {b B}
+
+finish_test
diff --git a/test/collate3.test b/test/collate3.test
new file mode 100644
index 0000000..99640d0
--- /dev/null
+++ b/test/collate3.test
@@ -0,0 +1,531 @@
+# 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 UNIQUE);
+ }
+} {}
+do_test collate3-1.1 {
+ catchsql {
+ SELECT * FROM collate3t1 ORDER BY 1 collate garbage;
+ }
+} {1 {no such collation sequence: garbage}}
+do_test collate3-1.1.2 {
+ catchsql {
+ SELECT DISTINCT c1 COLLATE garbage FROM collate3t1;
+ }
+} {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;
+}
+
+proc caseless {a b} { string compare -nocase $a $b }
+do_test collate3-1.4 {
+ db collate caseless caseless
+ execsql {
+ CREATE TABLE t1(a COLLATE caseless);
+ INSERT INTO t1 VALUES('Abc2');
+ INSERT INTO t1 VALUES('abc1');
+ INSERT INTO t1 VALUES('aBc3');
+ }
+ execsql { SELECT * FROM t1 ORDER BY a }
+} {abc1 Abc2 aBc3}
+
+do_test collate3-1.5 {
+ db close
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 ORDER BY a }
+} {1 {no such collation sequence: caseless}}
+
+do_test collate3-1.6.1 {
+ db collate caseless caseless
+ execsql { CREATE INDEX i1 ON t1(a) }
+ execsql { SELECT * FROM t1 ORDER BY a }
+} {abc1 Abc2 aBc3}
+
+do_test collate3-1.6.2 {
+ db close
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 ORDER BY a }
+} {1 {no such collation sequence: caseless}}
+
+do_test collate3-1.6.3 {
+ db close
+ sqlite3 db test.db
+ catchsql { PRAGMA integrity_check }
+} {1 {no such collation sequence: caseless}}
+
+do_test collate3-1.6.4 {
+ db close
+ sqlite3 db test.db
+ catchsql { REINDEX }
+} {1 {no such collation sequence: caseless}}
+
+do_test collate3-1.7.1 {
+ db collate caseless caseless
+ execsql {
+ DROP TABLE t1;
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a COLLATE caseless);
+ INSERT INTO t1 VALUES('Abc2');
+ INSERT INTO t1 VALUES('abc1');
+ INSERT INTO t1 VALUES('aBc3');
+ SELECT * FROM t1 ORDER BY a COLLATE caseless;
+ }
+} {abc1 Abc2 aBc3}
+
+do_test collate3-1.7.2 {
+ db close
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 ORDER BY a COLLATE caseless}
+} {1 {no such collation sequence: caseless}}
+
+do_test collate3-1.7.4 {
+ db close
+ sqlite3 db test.db
+ catchsql { REINDEX }
+} {1 {no such collation sequence: caseless}}
+
+do_test collate3-1.7.3 {
+ db close
+ sqlite3 db test.db
+ catchsql { PRAGMA integrity_check }
+} {1 {no such collation sequence: caseless}}
+
+do_test collate3-1.7.4 {
+ db close
+ sqlite3 db test.db
+ catchsql { REINDEX }
+} {1 {no such collation sequence: caseless}}
+
+do_test collate3-1.7.5 {
+ db close
+ sqlite3 db test.db
+ db collate caseless caseless
+ catchsql { PRAGMA integrity_check }
+} {0 ok}
+
+proc needed {nm} { db collate caseless caseless }
+do_test collate3-1.7.6 {
+ db close
+ sqlite3 db test.db
+ db collation_needed needed
+ catchsql { PRAGMA integrity_check }
+} {0 ok}
+
+do_test collate3-1.8 {
+ execsql { DROP TABLE t1 }
+} {}
+
+#
+# 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..b8c1c57
--- /dev/null
+++ b/test/collate4.test
@@ -0,0 +1,704 @@
+#
+# 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
+# initialized 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, rowid}
+} {{} 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, rowid}
+} {{} a A b B sort}
+do_test collate4-1.1.23 {
+ cksort {SELECT a FROM collate4t4 ORDER BY a COLLATE NOCASE, rowid}
+} {{} a A b B sort}
+do_test collate4-1.1.24 {
+ cksort {SELECT a FROM collate4t4 ORDER BY a COLLATE TEXT, rowid}
+} {{} 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, rowid}
+} {{} 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, rowid}
+} {{} a A b B sort}
+do_test collate4-1.2.16 {
+ cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE nocase, rowid}
+} {{} 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 4}
+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
+ ORDER BY collate4t2.rowid, collate4t1.rowid
+ }
+} {A a A A 19}
+do_test collate4-2.1.5 {
+ count {
+ SELECT * FROM collate4t2, collate4t1 WHERE b = a;
+ }
+} {A A 3}
+ifcapable subquery {
+ do_test collate4-2.1.6 {
+ count {
+ SELECT a FROM collate4t1 WHERE a IN (SELECT * FROM collate4t2)
+ ORDER BY rowid
+ }
+ } {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)
+ ORDER BY rowid
+ }
+ } {a A 5}
+ do_test collate4-2.1.8 {
+ count {
+ SELECT a FROM collate4t1 WHERE a IN ('z', 'a');
+ }
+ } {a A 4}
+ 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') ORDER BY rowid;
+ }
+ } {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 {UNIQUE constraint failed: collate4t1.a}}
+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 {UNIQUE constraint failed: collate4t1.a}}
+do_test collate4-3.4 {
+ catchsql {
+ INSERT INTO collate4t1 VALUES(1);
+ UPDATE collate4t1 SET a = 'abc';
+ }
+} {1 {UNIQUE constraint failed: collate4t1.a}}
+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 {UNIQUE constraint failed: collate4t1.a}}
+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 {UNIQUE constraint failed: collate4t1.a}}
+do_test collate4-3.9 {
+ catchsql {
+ INSERT INTO collate4t1 VALUES(1);
+ UPDATE collate4t1 SET a = 'abc';
+ }
+} {1 {UNIQUE constraint failed: collate4t1.a}}
+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 {UNIQUE constraint failed: collate4t1.a}}
+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 {UNIQUE constraint failed: collate4t1.a}}
+do_test collate4-3.14 {
+ catchsql {
+ INSERT INTO collate4t1 VALUES(1);
+ UPDATE collate4t1 SET a = 'abc';
+ }
+} {1 {UNIQUE constraint failed: collate4t1.a}}
+
+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..71d4efe
--- /dev/null
+++ b/test/collate5.test
@@ -0,0 +1,328 @@
+#
+# 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
+
+set testprefix collate5
+
+
+#
+# Tests are organised as follows:
+# collate5-1.* - DISTINCT
+# collate5-2.* - Compound SELECT
+# collate5-3.* - ORDER BY on compound SELECT
+# collate5-4.* - GROUP BY
+# collate5-5.* - Collation sequence cases
+
+# 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;
+ }
+} {/[aA] [aA] [aA] [aA] [bB] [bB] [bB] [bB] [nN] [nN]/}
+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;
+ }
+} {/[aA] 1(.0)? 2 [bB] 2 1 [bB] 3 1/}
+do_test collate5-4.3 {
+ execsql {
+ DROP TABLE collate5t1;
+ }
+} {}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a, b COLLATE nocase);
+ CREATE TABLE t2(c, d);
+ INSERT INTO t2 VALUES(1, 'bbb');
+}
+do_execsql_test 5.1 {
+ SELECT * FROM (
+ SELECT a, b FROM t1 UNION ALL SELECT c, d FROM t2
+ ) WHERE b='BbB';
+} {1 bbb}
+
+reset_db
+do_execsql_test 5.2 {
+ CREATE TABLE t1(a,b,c COLLATE NOCASE);
+ INSERT INTO t1 VALUES(NULL,'C','c');
+ CREATE VIEW v2 AS
+ SELECT a,b,c FROM t1 INTERSECT SELECT a,b,b FROM t1
+ WHERE 'eT"3qRkL+oJMJjQ9z0'>=b
+ ORDER BY a,b,c;
+}
+
+do_execsql_test 5.3 {
+ SELECT * FROM v2;
+} { {} C c }
+
+do_execsql_test 5.4 {
+ SELECT * FROM v2 WHERE c='c';
+} { {} C c }
+
+
+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..b06c87d
--- /dev/null
+++ b/test/collate8.test
@@ -0,0 +1,157 @@
+#
+# 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.
+#
+# 2015-02-09: Added tests to make sure COLLATE passes through function
+# calls. Ticket [ca0d20b6cdddec5e81b8d66f89c46a5583b5f6f6].
+#
+
+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}
+
+# Make sure the COLLATE operator perculates up through function calls
+# and other Expr structures that use the Expr.x.pList field.
+#
+do_execsql_test collate8-3.1 {
+ SELECT 'abc'==('ABC'||'') COLLATE nocase;
+ SELECT 'abc'==('ABC'||'' COLLATE nocase);
+ SELECT 'abc'==('ABC'||('' COLLATE nocase));
+ SELECT 'abc'==('ABC'||upper('' COLLATE nocase));
+} {1 1 1 1}
+do_execsql_test collate8-3.2 {
+ SELECT 'abc'==('ABC'||max('' COLLATE nocase,'' COLLATE binary));
+} {1}
+
+# The COLLATE binary is on the left and so takes precedence
+do_execsql_test collate8-3.3 {
+ SELECT 'abc'==('ABC'||max('' COLLATE binary,'' COLLATE nocase));
+} {0}
+
+do_execsql_test collate8-3.4 {
+ SELECT 'abc'==('ABC'||CASE WHEN 1-1=2 THEN '' COLLATE nocase
+ ELSE '' COLLATE binary END);
+ SELECT 'abc'==('ABC'||CASE WHEN 1+1=2 THEN '' COLLATE nocase
+ ELSE '' COLLATE binary END);
+} {1 1}
+do_execsql_test collate8-3.5 {
+ SELECT 'abc'==('ABC'||CASE WHEN 1=2 THEN '' COLLATE binary
+ ELSE '' COLLATE nocase END);
+} {0}
+
+
+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/collateB.test b/test/collateB.test
new file mode 100644
index 0000000..3c8d50d
--- /dev/null
+++ b/test/collateB.test
@@ -0,0 +1,77 @@
+# 2016-07-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.
+#
+#***********************************************************************
+# Test cases for a crash bug.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix collateB
+
+do_execsql_test collateB-1.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY);
+ CREATE TABLE t2(b INTEGER PRIMARY KEY, x1 INT COLLATE NOCASE);
+ CREATE TABLE t3(x2 INT);
+ SELECT * FROM t3, t2, t1 WHERE x2=b AND x1=a AND a=1;
+} {}
+do_execsql_test collateB-1.2 {
+ INSERT INTO t1(a) VALUES(1),(2),(3);
+ INSERT INTO t2(b,x1) VALUES(11,1),(22,2),(33,3);
+ INSERT INTO t3(x2) VALUES(11),(22),(33);
+ SELECT *,'|' FROM t3, t2, t1 WHERE x2=b AND x1=a AND a=1;
+} {11 11 1 1 |}
+do_execsql_test collateB-1.3 {
+ SELECT *,'|' FROM t3, t1, t2 WHERE x2=b AND x1=a AND a=1;
+} {11 1 11 1 |}
+do_execsql_test collateB-1.4 {
+ SELECT *,'|' FROM t2, t3, t1 WHERE x2=b AND x1=a AND a=1;
+} {11 1 11 1 |}
+do_execsql_test collateB-1.5 {
+ SELECT *,'|' FROM t2, t1, t3 WHERE x2=b AND x1=a AND a=1;
+} {11 1 1 11 |}
+do_execsql_test collateB-1.6 {
+ SELECT *,'|' FROM t1, t2, t3 WHERE x2=b AND x1=a AND a=1;
+} {1 11 1 11 |}
+do_execsql_test collateB-1.7 {
+ SELECT *,'|' FROM t1, t2, t3 WHERE x2=b AND x1=a AND a=1;
+} {1 11 1 11 |}
+do_execsql_test collateB-1.12 {
+ SELECT *,'|' FROM t3, t2, t1 WHERE b=x2 AND a=x1 AND 1=a;
+} {11 11 1 1 |}
+do_execsql_test collateB-1.13 {
+ SELECT *,'|' FROM t3, t1, t2 WHERE b=x2 AND a=x1 AND 1=a;
+} {11 1 11 1 |}
+do_execsql_test collateB-1.14 {
+ SELECT *,'|' FROM t2, t3, t1 WHERE b=x2 AND a=x1 AND 1=a;
+} {11 1 11 1 |}
+do_execsql_test collateB-1.15 {
+ SELECT *,'|' FROM t2, t1, t3 WHERE b=x2 AND a=x1 AND 1=a;
+} {11 1 1 11 |}
+do_execsql_test collateB-1.16 {
+ SELECT *,'|' FROM t1, t2, t3 WHERE b=x2 AND a=x1 AND 1=a;
+} {1 11 1 11 |}
+do_execsql_test collateB-1.17 {
+ SELECT *,'|' FROM t1, t2, t3 WHERE b=x2 AND a=x1 AND 1=a;
+} {1 11 1 11 |}
+
+#-------------------------------------------------------------------------
+# Test an assert() failure that was occuring if an index were created
+# on a column explicitly declared "COLLATE binary".
+reset_db
+do_execsql_test 2.1 {
+ CREATE TABLE t4(a COLLATE binary);
+ CREATE INDEX i4 ON t4(a);
+ INSERT INTO t4 VALUES('one'), ('two'), ('three');
+ VACUUM;
+}
+
+integrity_check 2.2
+
+finish_test
diff --git a/test/colmeta.test b/test/colmeta.test
new file mode 100644
index 0000000..21b0e0f
--- /dev/null
+++ b/test/colmeta.test
@@ -0,0 +1,110 @@
+#
+# 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
+
+# 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);
+ CREATE TABLE abc5(w,x,y,z,PRIMARY KEY(x,z)) WITHOUT ROWID;
+ CREATE TABLE abc6(rowid TEXT COLLATE rtrim, oid REAL, _rowid_ BLOB);
+ }
+ 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}}
+ 20 {main abc5 w} {0 {{} BINARY 0 0 0}}
+ 21 {main abc5 x} {0 {{} BINARY 1 1 0}}
+ 22 {main abc5 y} {0 {{} BINARY 0 0 0}}
+ 23 {main abc5 z} {0 {{} BINARY 1 1 0}}
+ 24 {main abc5 rowid} {1 {no such table column: abc5.rowid}}
+ 30 {main abc6 rowid} {0 {TEXT rtrim 0 0 0}}
+ 31 {main abc6 oid} {0 {REAL BINARY 0 0 0}}
+ 32 {main abc6 _rowid_} {0 {BLOB BINARY 0 0 0}}
+}
+ifcapable autoinc {
+ set tests [concat $tests {
+ 100 {{} abc4 b} {0 {INTEGER BINARY 0 1 1}}
+ 101 {main abc4 rowid} {0 {INTEGER BINARY 0 1 1}}
+ }]
+}
+ifcapable view {
+ set tests [concat $tests {
+ 200 {{} v1 a} {1 {no such table column: v1.a}}
+ 201 {main v1 b} {1 {no such table column: v1.b}}
+ 202 {main v1 badname} {1 {no such table column: v1.badname}}
+ 203 {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
+}
+
+# Calling sqlite3_table_column_metadata with a NULL column name merely
+# checks for the existance of the table.
+#
+do_test colmeta-300 {
+ catch {sqlite3_table_column_metadata $::DB main xyzzy} res
+} {1}
+do_test colmeta-301 {
+ catch {sqlite3_table_column_metadata $::DB main abc} res
+} {0}
+
+
+finish_test
diff --git a/test/colname.test b/test/colname.test
new file mode 100644
index 0000000..5fa0b60
--- /dev/null
+++ b/test/colname.test
@@ -0,0 +1,447 @@
+# 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.
+#
+
+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}
+
+# 2017-07-29: Interaction between column naming and query flattening.
+# For years now, the query flattener has inserted AS clauses on the
+# outer query that were the original SQL text of the column. This caused
+# column-name shifts when the query flattener was enhanced, breaking
+# legacy applications. See https://sqlite.org/src/info/41c27bc0ff1d3135
+# for details.
+#
+# To fix this, the column naming logic was moved ahead of the query
+# flattener so that column names are assigned before the query flattener
+# runs.
+#
+db close
+sqlite3 db :memory:
+do_test colname-9.100 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ CREATE VIEW v1(x,y) AS SELECT a,b FROM t1;
+ }
+ execsql2 {SELECT v1.x, (Y) FROM v1}
+ # Prior to the fix, this would return: "v1.x 1 (Y) 2"
+} {x 1 y 2}
+do_test colname-9.110 {
+ execsql2 {SELECT * FROM v1}
+} {x 1 y 2}
+do_test colname-9.120 {
+ db eval {
+ CREATE VIEW v2(x,y) AS SELECT a,b FROM t1 LIMIT 10;
+ }
+ execsql2 {SELECT * FROM v2 WHERE 1}
+} {x 1 y 2}
+do_test colname-9.130 {
+ execsql2 {SELECT v2.x, [v2].[y] FROM v2 WHERE 1}
+} {x 1 y 2}
+do_test colname-9.140 {
+ execsql2 {SELECT +x, +y FROM v2 WHERE 1}
+} {+x 1 +y 2}
+
+do_test colname-9.200 {
+ db eval {
+ CREATE TABLE t2(c,d);
+ INSERT INTO t2 VALUES(3,4);
+ CREATE VIEW v3 AS SELECT c AS a, d AS b FROM t2;
+ }
+ execsql2 {SELECT t1.a, v3.a AS n FROM t1 LEFT JOIN v3}
+} {a 1 n 3}
+do_test colname-9.211 {
+ execsql2 {SELECT t1.a AS n, v3.a FROM t1 JOIN v3}
+} {n 1 a 3}
+do_test colname-9.210 {
+ execsql2 {SELECT t1.a, v3.a AS n FROM t1 JOIN v3}
+} {a 1 n 3}
+
+# 2017-12-23: Ticket https://www.sqlite.org/src/info/3b4450072511e621
+# Inconsistent column names in CREATE TABLE AS
+#
+# Verify that the names of columns in the created table of a CREATE TABLE AS
+# are the same as the names of result columns in the SELECT statement.
+#
+do_execsql_test colname-9.300 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(aaa INT);
+ INSERT INTO t1(aaa) VALUES(123);
+}
+do_test colname-9.310 {
+ execsql2 {SELECT BBb FROM (SELECT aaa AS Bbb FROM t1)}
+} {Bbb 123}
+ifcapable vtab {
+ do_execsql_test colname-9.320 {
+ CREATE TABLE t2 AS SELECT BBb FROM (SELECT aaa AS Bbb FROM t1);
+ SELECT name FROM pragma_table_info('t2');
+ } {Bbb}
+}
+do_execsql_test colname-9.330 { -- added 2019-08-10 to invalidate
+ DROP TABLE IF EXISTS t1; -- a couple assert()s that were
+ CREATE TABLE t1(a); -- added by ticket 3b44500725
+ INSERT INTO t1 VALUES(17),(2),(99),(-3),(7);
+ SELECT (SELECT avg(a) UNION SELECT min(a) OVER()) FROM t1;
+} {17}
+
+# Issue detected by OSSFuzz on 2017-12-24 (Christmas Eve)
+# caused by check-in https://sqlite.org/src/info/6b2ff26c25
+#
+# Prior to being fixed, the following CREATE TABLE was dereferencing
+# a NULL pointer and segfaulting.
+#
+do_catchsql_test colname-9.400 {
+ CREATE TABLE t4 AS SELECT #0;
+} {1 {near "#0": syntax error}}
+
+# Issue detected by OSSFuzz on 2017-12-25 (Christmas Day)
+# also caused by check-in https://sqlite.org/src/info/6b2ff26c25
+#
+# Prior to being fixed, the following CREATE TABLE caused an
+# assertion fault.
+#
+do_catchsql_test colname-9.410 {
+ CREATE TABLE t5 AS SELECT RAISE(abort,a);
+} {1 {RAISE() may only be used within a trigger-program}}
+
+# Make sure the quotation marks get removed from the column names
+# when constructing a new table from an aggregate SELECT.
+# Email from Juergen Palm on 2017-07-11.
+#
+do_execsql_test colname-10.100 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1("with space" TEXT);
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2 AS SELECT "with space" FROM t1;
+ PRAGMA table_info(t2);
+} {0 {with space} TEXT 0 {} 0}
+do_execsql_test colname-10.110 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3 AS SELECT "with space" FROM t1 GROUP BY 1;
+ PRAGMA table_info(t3);
+} {0 {with space} TEXT 0 {} 0}
+
+
+finish_test
diff --git a/test/columncount.test b/test/columncount.test
new file mode 100644
index 0000000..d9956b4
--- /dev/null
+++ b/test/columncount.test
@@ -0,0 +1,62 @@
+# 2021 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 sqlite3_column_count() API.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix columncount
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+proc do_ccsql_test {tn sql res} {
+
+ uplevel [list do_test $tn [subst -nocommands {
+ set stmt [sqlite3_prepare_v2 db {$sql} -1 dummy]
+ set res [sqlite3_column_count [set stmt]]
+ while {[sqlite3_step [set stmt]]=="SQLITE_ROW"} {
+ for {set i 0} {[set i] < [sqlite3_data_count [set stmt]]} {incr i} {
+ lappend res [sqlite3_column_text [set stmt] [set i]]
+ }
+ }
+
+ set rc [sqlite3_finalize [set stmt]]
+ if {[set rc]!="SQLITE_OK"} {
+ error [sqlite3_errmsg db]
+ }
+
+ set res
+ }] [list {*}$res]]
+
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y, z);
+ INSERT INTO t1 VALUES('a', 'b', 'c');
+}
+
+do_ccsql_test 1.1 { SELECT * FROM t1 } {3 a b c}
+do_ccsql_test 1.2 { CREATE TABLE t2(a, b) } {0}
+
+do_ccsql_test 1.3 { ALTER TABLE t2 RENAME TO t3 } {0}
+do_ccsql_test 1.4 { ALTER TABLE t3 RENAME b TO ccc } {0}
+do_ccsql_test 1.5 { ALTER TABLE t3 ADD COLUMN d } {0}
+
+do_ccsql_test 1.6 { DROP TABLE t3 } {0}
+
+
+
+finish_test
diff --git a/test/conflict.test b/test/conflict.test
new file mode 100644
index 0000000..e0d0c87
--- /dev/null
+++ b/test/conflict.test
@@ -0,0 +1,860 @@
+# 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.
+#
+
+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 {NOT NULL constraint failed: t1.c}}
+ 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 (2007-08-21): Since temporary table files are now opened lazily,
+# and none of the following tests use large quantities of data, t3 is always 0.
+#
+# Update (2016-03-04): Subjournals now also open lazily, so t4 is also always 0.
+#
+foreach {i conf1 cmd t0 t1 t2 t3 t4} {
+ 1 {} UPDATE 1 {6 7 8 9} 1 0 0
+ 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 0
+ 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 0
+ 16 {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0 0 0
+} {
+ if {$t0} {set t1 {UNIQUE constraint failed: t1.a}}
+ 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 {UNIQUE constraint failed: t2.b}}
+do_test conflict-9.6 {
+ catchsql {
+ UPDATE t2 SET b=b+1 WHERE b=1;
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.b}}
+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 {UNIQUE constraint failed: t2.b}}
+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 {UNIQUE constraint failed: t2.b}}
+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 {UNIQUE constraint failed: t2.d}}
+do_test conflict-9.12 {
+ catchsql {
+ UPDATE t2 SET d=d+1 WHERE d=1;
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.d}}
+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 {UNIQUE constraint failed: t2.d}}
+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 {UNIQUE constraint failed: t2.d}}
+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 {UNIQUE constraint failed: t2.e}}
+do_test conflict-9.18 {
+ catchsql {
+ UPDATE t2 SET e=e+1 WHERE e=1;
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.e}}
+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 {UNIQUE constraint failed: t2.e}}
+verify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_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 {UNIQUE constraint failed: t2.e}}
+verify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_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 {UNIQUE constraint failed: t5.a}}
+verify_ex_errcode conflict-12.3b SQLITE_CONSTRAINT_PRIMARYKEY
+do_test conflict-12.4 {
+ execsql {
+ UPDATE OR REPLACE t5 SET a=a+1 WHERE a=1;
+ SELECT * FROM t5;
+ }
+} {2 one}
+do_test conflict-12.5 {
+ catchsql {
+ CREATE TABLE t5b(x);
+ INSERT INTO t5b(rowid, x) VALUES(1,10),(2,11);
+ UPDATE t5b SET rowid=rowid+1 WHERE x=10;
+ }
+} {1 {UNIQUE constraint failed: t5b.rowid}}
+verify_ex_errcode conflict-12.5b SQLITE_CONSTRAINT_ROWID
+
+
+# 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 {CHECK constraint failed: a!=2}}
+verify_ex_errcode conflict-13.1b SQLITE_CONSTRAINT_CHECK
+do_test conflict-13.2 {
+ execsql {
+ REPLACE INTO t13 VALUES(3);
+ COMMIT;
+ SELECT * FROM t13;
+ }
+} {1 3}
+
+
+# Ticket https://www.sqlite.org/src/tktview/e6f1f2e34dceeb1ed61531c7e9
+# Verify that it is not possible to sneak a NULL value into a NOT NULL
+# column using REPLACE.
+#
+do_catchsql_test conflict-14.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x NOT NULL DEFAULT NULL);
+ REPLACE INTO t1 DEFAULT VALUES;
+} {1 {NOT NULL constraint failed: t1.x}}
+
+# 2019-12-15 gramfuzz1 find
+# Three UNIQUE constraints, where the third would is a duplicate except
+# that it adds ON CONFLICT REPLACE. Verify that the indexes end up
+# sorted in the correct order (REPLACE last) so that constraint processing
+# works correctly.
+#
+reset_db
+do_execsql_test conflict-15.10 {
+ CREATE TABLE t1(
+ x PRIMARY KEY,
+ UNIQUE(x,x),
+ UNIQUE(x,x) ON CONFLICT REPLACE
+ );
+ INSERT INTO t1(x) VALUES(1);
+ SELECT * FROM t1;
+} {1}
+do_catchsql_test conflict-15.20 {
+ INSERT INTO t1(x) VALUES(1);
+} {1 {UNIQUE constraint failed: t1.x}}
+do_execsql_test conflict-15.30 {
+ SELECT * FROM t1;
+} {1}
+
+finish_test
diff --git a/test/conflict2.test b/test/conflict2.test
new file mode 100644
index 0000000..96289d3
--- /dev/null
+++ b/test/conflict2.test
@@ -0,0 +1,858 @@
+# 2013-11-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 the conflict resolution extension
+# in WITHOUT ROWID tables
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !conflict {
+ finish_test
+ return
+}
+
+# Create tables for the first group of tests.
+#
+do_test conflict2-1.0 {
+ execsql {
+ CREATE TABLE t1(a, b, c, PRIMARY KEY(a,b)) WITHOUT rowid;
+ 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 conflict2-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 conflict2-2.0 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(a,b)) WITHOUT rowid;
+ 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 conflict2-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 conflict2-3.0 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(a, b, c INTEGER, PRIMARY KEY(c), UNIQUE(a,b)) WITHOUT rowid;
+ 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 conflict2-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 conflict2-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 conflict2-4.$i {
+ if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
+ set r0 [catch {execsql [subst {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,PRIMARY KEY(a,b) $conf1) WITHOUT rowid;
+ 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 conflict2-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 {NOT NULL constraint failed: t1.c}}
+ do_test conflict2-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 conflict2-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.
+#
+# Update (2016-03-04): Subjournals now only open when their size
+# exceeds 64KB.
+#
+foreach {i conf1 cmd t0 t1 t2 t3 t4} {
+ 1 {} UPDATE 1 {6 7 8 9} 1 0 0
+ 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 0
+ 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 0
+ 16 {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0 0 0
+} {
+
+ # When using in-memory journals, no temporary files are required for
+ # statement journals.
+ if {[permutation] == "inmemory_journal"} { set t4 0 }
+
+ if {$t0} {set t1 {UNIQUE constraint failed: t1.a}}
+ if {[info exists TEMP_STORE] && $TEMP_STORE==3} {
+ set t3 0
+ } else {
+ set t3 [expr {$t3+$t4}]
+ }
+ do_test conflict2-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, PRIMARY KEY(a) $conf1) WITHOUT rowid;
+ 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 conflict2-7.1 {
+ execsql {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE t3;
+ CREATE TABLE t1(a PRIMARY KEY, b) without rowid;
+ }
+ 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 conflict2-7.2 {
+ execsql {
+ PRAGMA count_changes=on;
+ UPDATE OR IGNORE t1 SET a=1000;
+ }
+} {1}
+do_test conflict2-7.2.1 {
+ db changes
+} {1}
+do_test conflict2-7.3 {
+ execsql {
+ SELECT b FROM t1 WHERE a=1000;
+ }
+} {2}
+do_test conflict2-7.4 {
+ execsql {
+ SELECT count(*) FROM t1;
+ }
+} {50}
+do_test conflict2-7.5 {
+ execsql {
+ PRAGMA count_changes=on;
+ UPDATE OR REPLACE t1 SET a=1001;
+ }
+} {50}
+do_test conflict2-7.5.1 {
+ db changes
+} {50}
+do_test conflict2-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 conflict2-7.7.1 {
+ db changes
+} {50}
+
+# Make sure the row count is right for rows that are ignored on
+# an insert.
+#
+do_test conflict2-8.1 {
+ execsql {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1,2);
+ }
+ execsql {
+ INSERT OR IGNORE INTO t1 VALUES(2,3);
+ }
+} {1}
+do_test conflict2-8.1.1 {
+ db changes
+} {1}
+do_test conflict2-8.2 {
+ execsql {
+ INSERT OR IGNORE INTO t1 VALUES(2,4);
+ }
+} {0}
+do_test conflict2-8.2.1 {
+ db changes
+} {0}
+do_test conflict2-8.3 {
+ execsql {
+ INSERT OR REPLACE INTO t1 VALUES(2,4);
+ }
+} {1}
+do_test conflict2-8.3.1 {
+ db changes
+} {1}
+do_test conflict2-8.4 {
+ execsql {
+ INSERT OR IGNORE INTO t1 SELECT * FROM t1;
+ }
+} {0}
+do_test conflict2-8.4.1 {
+ db changes
+} {0}
+do_test conflict2-8.5 {
+ execsql {
+ INSERT OR IGNORE INTO t1 SELECT a+2,b+2 FROM t1;
+ }
+} {2}
+do_test conflict2-8.5.1 {
+ db changes
+} {2}
+do_test conflict2-8.6 {
+ execsql {
+ INSERT OR IGNORE INTO t1 SELECT a+3,b+3 FROM t1;
+ }
+} {3}
+do_test conflict2-8.6.1 {
+ db changes
+} {3}
+
+integrity_check conflict2-8.99
+
+do_test conflict2-9.1 {
+ execsql {
+ PRAGMA count_changes=0;
+ CREATE TABLE t2(
+ a INTEGER PRIMARY KEY 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
+ ) WITHOUT rowid;
+ CREATE TABLE t3(x);
+ INSERT INTO t3 VALUES(1);
+ SELECT * FROM t3;
+ }
+} {1}
+do_test conflict2-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 conflict2-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 conflict2-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 conflict2-9.5 {
+ catchsql {
+ INSERT INTO t2 VALUES(3,1,3,3,3);
+ }
+} {1 {UNIQUE constraint failed: t2.b}}
+do_test conflict2-9.5b {
+ db eval {SELECT * FROM t2;}
+} {1 1 1 1 1 2 2 2 2 2}
+do_test conflict2-9.6 {
+ catchsql {
+ UPDATE t2 SET b=b+1 WHERE b=1;
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.b}}
+do_test conflict2-9.6b {
+ db eval {SELECT * FROM t2;}
+} {1 1 1 1 1 2 2 2 2 2}
+do_test conflict2-9.7 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ INSERT INTO t2 VALUES(3,1,3,3,3);
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.b}}
+do_test conflict2-9.8 {
+ execsql {COMMIT}
+ execsql {SELECT * FROM t3}
+} {2}
+do_test conflict2-9.9 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ UPDATE t2 SET b=b+1 WHERE b=1;
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.b}}
+do_test conflict2-9.10 {
+ execsql {COMMIT}
+ execsql {SELECT * FROM t3}
+} {3}
+do_test conflict2-9.11 {
+ catchsql {
+ INSERT INTO t2 VALUES(3,3,3,1,3);
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.d}}
+do_test conflict2-9.12 {
+ catchsql {
+ UPDATE t2 SET d=d+1 WHERE d=1;
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.d}}
+do_test conflict2-9.13 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ INSERT INTO t2 VALUES(3,3,3,1,3);
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.d}}
+do_test conflict2-9.14 {
+ execsql {COMMIT}
+ execsql {SELECT * FROM t3}
+} {4}
+do_test conflict2-9.15 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ UPDATE t2 SET d=d+1 WHERE d=1;
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.d}}
+do_test conflict2-9.16 {
+ execsql {COMMIT}
+ execsql {SELECT * FROM t3}
+} {5}
+do_test conflict2-9.17 {
+ catchsql {
+ INSERT INTO t2 VALUES(3,3,3,3,1);
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.e}}
+do_test conflict2-9.18 {
+ catchsql {
+ UPDATE t2 SET e=e+1 WHERE e=1;
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.e}}
+do_test conflict2-9.19 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ INSERT INTO t2 VALUES(3,3,3,3,1);
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.e}}
+verify_ex_errcode conflict2-9.21b SQLITE_CONSTRAINT_UNIQUE
+do_test conflict2-9.20 {
+ catch {execsql {COMMIT}}
+ execsql {SELECT * FROM t3}
+} {5}
+do_test conflict2-9.21 {
+ catchsql {
+ BEGIN;
+ UPDATE t3 SET x=x+1;
+ UPDATE t2 SET e=e+1 WHERE e=1;
+ SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t2.e}}
+verify_ex_errcode conflict2-9.21b SQLITE_CONSTRAINT_UNIQUE
+do_test conflict2-9.22 {
+ catch {execsql {COMMIT}}
+ execsql {SELECT * FROM t3}
+} {5}
+do_test conflict2-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 conflict2-9.24 {
+ catchsql {
+ UPDATE t2 SET c=c-1 WHERE c=2;
+ SELECT * FROM t2;
+ }
+} {0 {2 2 1 2 2}}
+do_test conflict2-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 conflict2-9.26 {
+ catch {execsql {COMMIT}}
+ execsql {SELECT * FROM t3}
+} {6}
+
+do_test conflict2-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 conflict2-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 conflict2-11.1 {
+ execsql {
+ -- Create a database object (pages 2, 3 of the file)
+ BEGIN;
+ CREATE TABLE abc(a PRIMARY KEY, b, c) WITHOUT rowid;
+ 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 conflict2-11.2
+
+# Repeat test conflict2-11.1 but this time commit.
+#
+do_test conflict2-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 conflict2-11.1 but this time commit.
+#
+do_test conflict2-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 conflict2-11.6
+
+# Make sure UPDATE OR REPLACE works on tables that have only
+# an INTEGER PRIMARY KEY.
+#
+do_test conflict2-12.1 {
+ execsql {
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b text) WITHOUT rowid;
+ INSERT INTO t5 VALUES(1,'one');
+ INSERT INTO t5 VALUES(2,'two');
+ SELECT * FROM t5
+ }
+} {1 one 2 two}
+do_test conflict2-12.2 {
+ execsql {
+ UPDATE OR IGNORE t5 SET a=a+1 WHERE a=1;
+ SELECT * FROM t5;
+ }
+} {1 one 2 two}
+do_test conflict2-12.3 {
+ catchsql {
+ UPDATE t5 SET a=a+1 WHERE a=1;
+ }
+} {1 {UNIQUE constraint failed: t5.a}}
+verify_ex_errcode conflict2-12.3b SQLITE_CONSTRAINT_PRIMARYKEY
+do_test conflict2-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 conflict2-13.1 {
+ execsql {
+ CREATE TABLE t13(a PRIMARY KEY CHECK(a!=2)) WITHOUT rowid;
+ BEGIN;
+ REPLACE INTO t13 VALUES(1);
+ }
+ catchsql {
+ REPLACE INTO t13 VALUES(2);
+ }
+} {1 {CHECK constraint failed: a!=2}}
+verify_ex_errcode conflict2-13.1b SQLITE_CONSTRAINT_CHECK
+do_test conflict2-13.2 {
+ execsql {
+ REPLACE INTO t13 VALUES(3);
+ COMMIT;
+ SELECT * FROM t13;
+ }
+} {1 3}
+
+# Test for an unreleased bug in the REPLACE conflict resolution
+# discovered on 2013-11-09.
+#
+do_execsql_test conflict2-14.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(
+ x TEXT PRIMARY KEY NOT NULL,
+ y TEXT NOT NULL,
+ z INTEGER
+ );
+ INSERT INTO t1 VALUES('alpha','beta',1);
+ CREATE UNIQUE INDEX t1xy ON t1(x,y);
+ REPLACE INTO t1(x,y,z) VALUES('alpha','gamma',1);
+ PRAGMA integrity_check;
+ SELECT x,y FROM t1 INDEXED BY t1xy;
+ SELECT x,y,z FROM t1 NOT INDEXED;
+} {ok alpha gamma alpha gamma 1}
+do_execsql_test conflict2-14.2 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(
+ x TEXT PRIMARY KEY NOT NULL,
+ y TEXT NOT NULL,
+ z INTEGER
+ ) WITHOUT ROWID;
+ INSERT INTO t1 VALUES('alpha','beta',1);
+ CREATE UNIQUE INDEX t1xy ON t1(x,y);
+ REPLACE INTO t1(x,y,z) VALUES('alpha','gamma',1);
+ PRAGMA integrity_check;
+ SELECT x,y FROM t1 INDEXED BY t1xy;
+ SELECT x,y,z FROM t1 NOT INDEXED;
+} {ok alpha gamma alpha gamma 1}
+
+
+
+finish_test
diff --git a/test/conflict3.test b/test/conflict3.test
new file mode 100644
index 0000000..8eb4c1b
--- /dev/null
+++ b/test/conflict3.test
@@ -0,0 +1,437 @@
+# 2013-11-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 for the conflict resolution extension
+# to SQLite.
+#
+# This file focuses on making sure that combinations of REPLACE,
+# IGNORE, and FAIL conflict resolution play well together.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix conflict3
+
+ifcapable !conflict {
+ finish_test
+ return
+}
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(
+ a INTEGER PRIMARY KEY ON CONFLICT REPLACE,
+ b UNIQUE ON CONFLICT IGNORE,
+ c UNIQUE ON CONFLICT FAIL
+ );
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 1.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 1.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 1.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Replete the tests above, but this time on a table non-INTEGER primary key.
+#
+do_execsql_test 2.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ a INT PRIMARY KEY ON CONFLICT REPLACE,
+ b UNIQUE ON CONFLICT IGNORE,
+ c UNIQUE ON CONFLICT FAIL
+ );
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 2.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 2.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 2.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Replete again on a WITHOUT ROWID table.
+#
+do_execsql_test 3.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ a INT PRIMARY KEY ON CONFLICT REPLACE,
+ b UNIQUE ON CONFLICT IGNORE,
+ c UNIQUE ON CONFLICT FAIL
+ ) WITHOUT ROWID;
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 3.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 3.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 3.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Arrange the table rows in a different order and repeat.
+#
+do_execsql_test 4.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ b UNIQUE ON CONFLICT IGNORE,
+ c UNIQUE ON CONFLICT FAIL,
+ a INT PRIMARY KEY ON CONFLICT REPLACE
+ ) WITHOUT ROWID;
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 4.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 4.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 4.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Arrange the table rows in a different order and repeat.
+#
+do_execsql_test 5.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ b UNIQUE ON CONFLICT IGNORE,
+ a INT PRIMARY KEY ON CONFLICT REPLACE,
+ c UNIQUE ON CONFLICT FAIL
+ );
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 5.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 5.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 5.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Arrange the table rows in a different order and repeat.
+#
+do_execsql_test 6.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ c UNIQUE ON CONFLICT FAIL,
+ a INT PRIMARY KEY ON CONFLICT REPLACE,
+ b UNIQUE ON CONFLICT IGNORE
+ );
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 6.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 6.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 6.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Change which column is the PRIMARY KEY
+#
+do_execsql_test 7.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ a UNIQUE ON CONFLICT REPLACE,
+ b INTEGER PRIMARY KEY ON CONFLICT IGNORE,
+ c UNIQUE ON CONFLICT FAIL
+ );
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 7.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 7.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 7.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Change which column is the PRIMARY KEY
+#
+do_execsql_test 8.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ a UNIQUE ON CONFLICT REPLACE,
+ b INT PRIMARY KEY ON CONFLICT IGNORE,
+ c UNIQUE ON CONFLICT FAIL
+ );
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 8.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 8.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 8.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Change which column is the PRIMARY KEY
+#
+do_execsql_test 9.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ a UNIQUE ON CONFLICT REPLACE,
+ b INT PRIMARY KEY ON CONFLICT IGNORE,
+ c UNIQUE ON CONFLICT FAIL
+ ) WITHOUT ROWID;
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 9.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 9.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 9.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Change which column is the PRIMARY KEY
+#
+do_execsql_test 10.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ a UNIQUE ON CONFLICT REPLACE,
+ b UNIQUE ON CONFLICT IGNORE,
+ c INTEGER PRIMARY KEY ON CONFLICT FAIL
+ );
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 10.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 10.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 10.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Change which column is the PRIMARY KEY
+#
+do_execsql_test 11.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ a UNIQUE ON CONFLICT REPLACE,
+ b UNIQUE ON CONFLICT IGNORE,
+ c PRIMARY KEY ON CONFLICT FAIL
+ ) WITHOUT ROWID;
+ INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert a row that conflicts on column B. The insert should be ignored.
+#
+do_execsql_test 11.2 {
+ INSERT INTO t1(a,b,c) VALUES(3,2,5);
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4}
+
+# Insert two rows where the second conflicts on C. The first row show go
+# and and then there should be a constraint error.
+#
+do_test 11.3 {
+ catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}
+} {1 {UNIQUE constraint failed: t1.c}}
+do_execsql_test 11.4 {
+ SELECT a,b,c FROM t1 ORDER BY a;
+} {1 2 3 2 3 4 4 5 6}
+
+# Check that ticket [f68dc596c4] has been fixed.
+#
+do_execsql_test 12.1 {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t2 VALUES(111, '111');
+}
+do_execsql_test 12.2 {
+ REPLACE INTO t2 VALUES(NULL, '112'), (111, '111B');
+}
+do_execsql_test 12.3 {
+ SELECT * FROM t2;
+} {111 111B 112 112}
+
+#-------------------------------------------------------------------------
+ifcapable trigger {
+ reset_db
+ do_execsql_test 13.1.0 {
+ PRAGMA recursive_triggers = true;
+ CREATE TABLE t0 (c0 UNIQUE, c1 UNIQUE);
+ CREATE TRIGGER tr0 AFTER DELETE ON t0 BEGIN
+ DELETE FROM t0;
+ END;
+
+ INSERT INTO t0 VALUES(1, NULL);
+ INSERT INTO t0 VALUES(0, NULL);
+ }
+
+ do_catchsql_test 13.1.1 {
+ UPDATE OR REPLACE t0 SET c1 = 1;
+ } {1 {constraint failed}}
+
+ integrity_check 13.1.2
+
+ do_execsql_test 13.1.3 {
+ SELECT * FROM t0
+ } {1 {} 0 {}}
+
+ do_execsql_test 13.2.0 {
+ CREATE TABLE t2 (a PRIMARY KEY, b UNIQUE, c UNIQUE) WITHOUT ROWID;
+ CREATE TRIGGER tr3 AFTER DELETE ON t2 BEGIN
+ DELETE FROM t2;
+ END;
+
+ INSERT INTO t2 VALUES(1, 1, 1);
+ INSERT INTO t2 VALUES(2, 2, 2);
+ }
+
+ do_catchsql_test 13.2.1 {
+ UPDATE OR REPLACE t2 SET c = 0;
+ } {1 {constraint failed}}
+
+ integrity_check 13.2.2
+
+ do_execsql_test 13.2.3 {
+ SELECT * FROM t2
+ } {1 1 1 2 2 2}
+
+ do_execsql_test 13.3.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE log(x);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES(1, 2);
+
+ CREATE TRIGGER tb BEFORE UPDATE ON t1 BEGIN
+ DELETE FROM t1;
+ END;
+ CREATE TRIGGER ta AFTER UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES('fired!');
+ END;
+
+ UPDATE t1 SET b=3;
+ }
+
+ do_execsql_test 13.3.1 {
+ SELECT * FROM t1;
+ } {}
+ do_execsql_test 13.3.2 {
+ SELECT * FROM log;
+ } {}
+}
+
+finish_test
diff --git a/test/contrib01.test b/test/contrib01.test
new file mode 100644
index 0000000..43ea47c
--- /dev/null
+++ b/test/contrib01.test
@@ -0,0 +1,90 @@
+# 2013-06-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 contains test cases that were contributed on the sqlite-users
+# mailing list on 2013-06-05 by Mi Chen at mi.chen@echostar.com.
+#
+# At the time it was contributed, this test failed on trunk, but
+# worked on the NGQP.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+do_test contrib01-1.0 {
+ db eval {
+ CREATE TABLE T1 (B INTEGER NOT NULL,
+ C INTEGER NOT NULL,
+ D INTEGER NOT NULL,
+ E INTEGER NOT NULL,
+ F INTEGER NOT NULL,
+ G INTEGER NOT NULL,
+ H INTEGER NOT NULL,
+ PRIMARY KEY (B, C, D));
+
+ CREATE TABLE T2 (A INTEGER NOT NULL,
+ B INTEGER NOT NULL,
+ C INTEGER NOT NULL,
+ PRIMARY KEY (A, B, C));
+
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15527);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15560);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15561);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15563);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15564);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15566);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15567);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15569);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15612);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15613);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15638);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15681);
+ INSERT INTO T2(A, B, C) VALUES(702118,16183,15682);
+
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15527,6,0,5,5,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15560,6,0,5,2,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15561,6,0,5,2,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15563,6,0,5,2,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15564,6,0,5,2,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15566,6,0,5,2,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15567,6,0,5,2,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15569,6,0,5,2,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15612,6,0,5,5,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15613,6,0,5,2,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15638,6,0,5,2,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15681,6,0,5,5,0);
+ INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15682,6,0,5,2,0);
+ }
+} {}
+do_test contrib01-1.1 {
+ db eval {
+ SELECT T2.A, T2.B, T1.D, T1.E, T1.F, T1.G, T1.H, MAX(T1.C), '^'
+ FROM T1, T2
+ WHERE T1.B = T2.B
+ AND T1.C = T2.C
+ GROUP BY T2.A, T2.B, T1.D, T1.E, T1.F, T1.G, T1.H
+ ORDER BY +max(t1.c);
+ }
+} {702118 16183 6 0 5 5 0 15681 ^ 702118 16183 6 0 5 2 0 15682 ^}
+do_test contrib01-1.2 {
+ db eval {
+ SELECT T2.A, T2.B, T1.D, T1.E, T1.F, T1.G, T1.H, MAX(T1.C), '^'
+ FROM T1, T2
+ WHERE T1.B = T2.B
+ AND T1.C = T2.C
+ GROUP BY T2.A, T2.B, T1.F, T1.D, T1.E, T1.G, T1.H
+ ORDER BY +max(t1.c);
+ }
+} {702118 16183 6 0 5 5 0 15681 ^ 702118 16183 6 0 5 2 0 15682 ^}
+
+finish_test
diff --git a/test/corrupt.test b/test/corrupt.test
new file mode 100644
index 0000000..62ead4d
--- /dev/null
+++ b/test/corrupt.test
@@ -0,0 +1,349 @@
+# 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
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# 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]
+ sqlite3_db_config db DEFENSIVE 0
+ 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..f97a526
--- /dev/null
+++ b/test/corrupt2.test
@@ -0,0 +1,611 @@
+# 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
+set testprefix corrupt2
+
+# 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 deal with corrupt database files
+#
+database_may_be_corrupt
+
+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 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 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
+ # Note: This test is no longer meaningful due to the deferred computation
+ # of MemPage.nFree
+ catchsql {PRAGMA quick_check} db2
+} {0 {{*** in database main ***
+Page 1: free space corruption}}}
+
+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 {PRAGMA quick_check} db2
+} {0 {{*** in database main ***
+Page 1: free space corruption}}}
+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
+ sqlite3_db_config db2 DEFENSIVE 0
+ 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
+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
+ sqlite3_db_config db DEFENSIVE 0
+ 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}}
+ }
+
+ if {![nonzero_reserved_bytes]} {
+ 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}}
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that PRAGMA integrity_check detects cases where the freelist-count
+# header field is smaller than the actual number of pages on the freelist.
+#
+
+reset_db
+do_execsql_test 14.0 {
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(3500));
+ DELETE FROM t1;
+}
+
+do_execsql_test 14.1 {
+ PRAGMA integrity_check;
+ PRAGMA freelist_count;
+} {ok 3}
+
+# There are now 3 free pages. Modify the header-field so that it
+# (incorrectly) says that just 2 are free.
+do_test 14.2 {
+ db close
+ hexio_write test.db 36 [hexio_render_int32 2]
+ sqlite3 db test.db
+ execsql { PRAGMA freelist_count }
+} {2}
+
+do_execsql_test 14.3 {
+ PRAGMA integrity_check;
+} {{*** in database main ***
+Main freelist: size is 3 but should be 2}}
+
+# Use 2 of the free pages on the free-list.
+#
+do_execsql_test 14.4 {
+ INSERT INTO t1 VALUES(randomblob(2500));
+ PRAGMA freelist_count;
+} {0}
+
+do_execsql_test 14.5 {
+ PRAGMA integrity_check;
+} {{*** in database main ***
+Main freelist: size is 1 but should be 0}}
+
+
+finish_test
+
+finish_test
diff --git a/test/corrupt3.test b/test/corrupt3.test
new file mode 100644
index 0000000..7a2e174
--- /dev/null
+++ b/test/corrupt3.test
@@ -0,0 +1,121 @@
+# 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
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# 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.
+#
+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]
+do_test corrupt3-1.8 {
+ catchsql {
+ PRAGMA integrity_check
+ }
+} {0 {{*** in database main ***
+On tree page 2 cell 0: 2nd reference to page 3}}}
+
+# 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 1 {database disk image is malformed}]
+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: overflow list length is 0 but should be 1
+Page 3 is never used}}}
+
+finish_test
diff --git a/test/corrupt4.test b/test/corrupt4.test
new file mode 100644
index 0000000..5b0965a
--- /dev/null
+++ b/test/corrupt4.test
@@ -0,0 +1,149 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix corrupt4
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# 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}}
+
+#-------------------------------------------------------------------------
+
+reset_db
+do_execsql_test 2.0 {
+ PRAGMA page_size = 512;
+ CREATE TABLE t1(a, b, c);
+}
+
+# Create a database with a schema so large that the root of the
+# sqlite_schema table is the grandparent of its leaves.
+#
+set nView 1000
+do_test 2.1 {
+ execsql BEGIN
+ for {set ii 0} {$ii<$nView} {incr ii} {
+ execsql " CREATE VIEW v$ii AS SELECT a, b, c FROM t1 "
+ }
+ execsql COMMIT
+} {}
+db close
+
+proc get2byte {fd offset} {
+ seek $fd $offset
+ set bin [read $fd 2]
+ binary scan $bin S val
+ set val
+}
+proc get4byte {fd offset} {
+ seek $fd $offset
+ set bin [read $fd 4]
+ binary scan $bin I val
+ set val
+}
+proc put4byte {fd offset val} {
+ seek $fd $offset
+ set bin [binary format I $val]
+ puts -nonewline $fd $bin
+}
+
+# Page 1 is now the grandparent of its leaves. Corrupt the database by setting
+# the second rightmost child page number of page 1 to 1.
+#
+set fd [open test.db r+]
+fconfigure $fd -encoding binary -translation binary
+set nChild [get2byte $fd 103]
+set offChild [get2byte $fd [expr 100+12+($nChild-2)*2]]
+set pgnoChild [get4byte $fd $offChild]
+put4byte $fd $offChild 1
+close $fd
+
+if {![info exists ::G(perm:presql)]} {
+ sqlite3 db test.db
+
+ do_catchsql_test 2.2 {
+ PRAGMA writable_schema = 1;
+ SELECT * FROM sqlite_schema;
+ } {1 {database disk image is malformed}}
+
+ do_test 2.3 {
+ list [catch {
+ for {set ii $nView} {$ii<$nView*2} {incr ii} {
+ execsql "INSERT INTO sqlite_master VALUES(1, 2, 3, 4, 5)"
+ }
+ } msg] $msg
+ } {1 {database disk image is malformed}}
+}
+
+finish_test
diff --git a/test/corrupt5.test b/test/corrupt5.test
new file mode 100644
index 0000000..7509766
--- /dev/null
+++ b/test/corrupt5.test
@@ -0,0 +1,50 @@
+# 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
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# 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 {
+ sqlite3_db_config db DEFENSIVE 0
+ 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..dd773c9
--- /dev/null
+++ b/test/corrupt6.test
@@ -0,0 +1,259 @@
+# 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
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# 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..aa66cc7
--- /dev/null
+++ b/test/corrupt7.test
@@ -0,0 +1,112 @@
+# 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
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# 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.
+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 ***
+On tree page 2 cell 15: Offset 65457 out of range 945..1020}}
+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: Offset 1201 out of range 945..1020}}
+
+# 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..d7bceba
--- /dev/null
+++ b/test/corrupt8.test
@@ -0,0 +1,108 @@
+# 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
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# 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..bb37758
--- /dev/null
+++ b/test/corrupt9.test
@@ -0,0 +1,140 @@
+# 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
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# 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..12d9186
--- /dev/null
+++ b/test/corruptA.test
@@ -0,0 +1,83 @@
+# 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
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+
+# 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 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 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 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 not a database}}
+
+
+finish_test
diff --git a/test/corruptB.test b/test/corruptB.test
new file mode 100644
index 0000000..c51cb57
--- /dev/null
+++ b/test/corruptB.test
@@ -0,0 +1,193 @@
+# 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
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+
+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..a56abee
--- /dev/null
+++ b/test/corruptC.test
@@ -0,0 +1,428 @@
+# 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
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# Construct a compact, dense database for testing.
+#
+do_test corruptC-1.1 {
+ sqlite3_db_config db LEGACY_FILE_FORMAT 1
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ 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}
+} {0 {{*** in database main ***
+Page 3: free space corruption}}}
+
+# test that a corrupt content offset size is handled (seed 5649)
+#
+# Update 2016-12-27: As of check-in [0b86fbca66] "In sqlite3BtreeInsert() when
+# replacing a re-existing row, try to overwrite the cell directly rather than
+# deallocate and reallocate the cell" on 2016-12-09, this test case no longer
+# detects the offset size problem during the UPDATE. We have to run a subsequent
+# integrity_check to see it.
+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
+ db eval {UPDATE t1 SET y=1}
+ db eval {PRAGMA integrity_check}
+} {/Offset .* out of range/}
+
+# 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 ***
+On tree page 4 cell 19: Extends off end of page} {database disk image is malformed}}}
+
+# {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)
+# Obsolete. With single-pass DELETE the corruption in the
+# main database is not detected.
+if 0 {
+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)
+#
+# UPDATE: Prior to 3.8.2, this used to return SQLITE_CORRUPT. It no longer
+# does. That is Ok, the point of these tests is to verify that no buffer
+# overruns or overreads can be caused by corrupt databases.
+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;}
+} {0 {}}
+
+# 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 {database disk image is malformed}}
+
+#
+# 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..eb6ccb3
--- /dev/null
+++ b/test/corruptD.test
@@ -0,0 +1,145 @@
+# 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
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+#--------------------------------------------------------------------------
+# 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 { PRAGMA quick_check }
+} {0 {{*** in database main ***
+Page 2: free space corruption}}}
+do_test corruptD-1.1.2 {
+ incr_change_counter
+ hexio_write test.db [expr 1024+1] [hexio_render_int32 1021]
+ catchsql { SELECT * FROM t1 ORDER BY rowid }
+} {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..8c55623
--- /dev/null
+++ b/test/corruptE.test
@@ -0,0 +1,152 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# 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 {
+ sqlite3_db_config db LEGACY_FILE_FORMAT 1
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ 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 ORDER BY rowid;
+ 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
+
+ catchsql {PRAGMA integrity_check}
+} {/ out of order/}
+
+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
+
+ catchsql {PRAGMA integrity_check}
+} {/ Extends off end of page/}
+
+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
+
+ catchsql {PRAGMA integrity_check}
+} {/out of order/}
+
+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
+
+ catchsql {PRAGMA integrity_check}
+} {/out of order/}
+
+
+set tests [list {10233 0xd0} \
+ {941 0x42} \
+ {2041 0xd0} \
+ {2042 0x1f} \
+ {2274 0x75} \
+ {3267 0xf2} \
+ {5113 0x36} \
+ {10233 0x84} \
+ {10234 0x74} \
+ {10239 0x41} \
+ {11273 0x28} \
+ {11461 0xe6} \
+ {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
+
+ catchsql {PRAGMA integrity_check}
+ } {/out of order/}
+ incr tc 1
+}
+
+finish_test
diff --git a/test/corruptF.test b/test/corruptF.test
new file mode 100644
index 0000000..8c4fd84
--- /dev/null
+++ b/test/corruptF.test
@@ -0,0 +1,153 @@
+# 2012 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix corruptF
+
+# 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 deal with corrupt database files
+#
+database_may_be_corrupt
+
+proc str {i} { format %08d $i }
+
+# Create a 6 page database containing a single table - t1. Table t1
+# consists of page 2 (the root page) and pages 5 and 6 (leaf pages).
+# Database pages 3 and 4 are on the free list.
+#
+proc create_test_db {} {
+ catch { db close }
+ forcedelete test.db
+ sqlite3 db test.db
+ db func str str
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x); /* root page = 2 */
+ CREATE TABLE t2(x); /* root page = 3 */
+ CREATE TABLE t3(x); /* root page = 4 */
+
+ INSERT INTO t1 VALUES(str(1));
+ INSERT INTO t1 SELECT str(rowid+1) FROM t1;
+ INSERT INTO t1 SELECT str(rowid+2) FROM t1;
+ INSERT INTO t1 SELECT str(rowid+4) FROM t1;
+ INSERT INTO t1 SELECT str(rowid+8) FROM t1;
+ INSERT INTO t1 SELECT str(rowid+16) FROM t1;
+ INSERT INTO t1 SELECT str(rowid+32) FROM t1;
+ INSERT INTO t1 SELECT str(rowid+64) FROM t1;
+ DROP TABLE t2;
+ DROP TABLE t3;
+ }
+ db close
+}
+
+do_test 1.1 { create_test_db } {}
+
+# Check the db is as we expect. 6 pages in total, with 3 and 4 on the free
+# list. Page 3 is the free list trunk and page 4 is a leaf.
+#
+do_test 1.2 { file size test.db } [expr 6*1024]
+do_test 1.3 { hexio_read test.db 32 4 } 00000003
+do_test 1.4 { hexio_read test.db [expr 2*1024] 12 } 000000000000000100000004
+
+# Change the free-list entry to page 6 and reopen the db file.
+do_test 1.5 {
+ hexio_write test.db [expr 2*1024 + 8] 00000006
+ sqlite3 db test.db
+} {}
+
+# Now create a new table in the database file. The root of the new table
+# is page 6, which is also the right-most leaf page in table t1.
+#
+do_execsql_test 1.6 {
+ CREATE TABLE t4(x);
+ SELECT * FROM sqlite_master;
+} {
+ table t1 t1 2 {CREATE TABLE t1(x)}
+ table t4 t4 6 {CREATE TABLE t4(x)}
+}
+
+# At one point this was causing an assert to fail.
+#
+# This statement opens a cursor on table t1 and does a full table scan. As
+# each row is visited, it is copied into table t4. There is no temporary
+# table.
+#
+# When the t1 cursor reaches page 6 (which is both the right-most leaf of
+# t1 and the root of t4), it continues to iterate through the keys within
+# it (which at this point are keys that have been inserted into t4). And
+# for each row visited, another row is inserted into page 6 - it being the
+# root page of t4. Eventually, page 6 becomes full and the height of the
+# b-tree for table t4 increased. From the point of view of the t1 cursor,
+# this unexpectedly reduces the number of keys on page 6 in the middle of
+# its iteration, which causes an assert() to fail.
+#
+db_save_and_close
+if 1 {
+for {set i 0} {$i < 128} {incr i} {
+ db_restore_and_reopen
+ do_test 1.7.$i {
+ set res [
+ catchsql { INSERT INTO t4 SELECT x FROM t1 WHERE rowid>$i }
+ ]
+ if {$res == "0 {}" || $res == "1 {database disk image is malformed}"} {
+ set res ""
+ }
+ set res
+ } {}
+}
+}
+
+do_test 2.1 { create_test_db } {}
+do_test 2.2 { file size test.db } [expr 6*1024]
+do_test 2.3 { hexio_read test.db 32 4 } 00000003
+do_test 2.4 { hexio_read test.db [expr 2*1024] 12 } 000000000000000100000004
+
+# Change the free-list entry to page 5 and reopen the db file.
+do_test 2.5 {
+ hexio_write test.db [expr 2*1024 + 8] 00000005
+ sqlite3 db test.db
+} {}
+
+# Now create a new table in the database file. The root of the new table
+# is page 5, which is also the right-most leaf page in table t1.
+#
+do_execsql_test 2.6 {
+ CREATE TABLE t4(x);
+ SELECT * FROM sqlite_master;
+} {
+ table t1 t1 2 {CREATE TABLE t1(x)}
+ table t4 t4 5 {CREATE TABLE t4(x)}
+}
+
+db_save_and_close
+for {set i 127} {$i >= 0} {incr i -1} {
+ db_restore_and_reopen
+ do_test 2.7.$i {
+ set res [
+ catchsql {
+ INSERT INTO t4 SELECT x FROM t1 WHERE rowid<$i ORDER BY rowid DESC
+ }
+ ]
+ if {$res == "0 {}" || $res == "1 {database disk image is malformed}"} {
+ set res ""
+ }
+ set res
+ } {}
+}
+
+finish_test
diff --git a/test/corruptG.test b/test/corruptG.test
new file mode 100644
index 0000000..9448034
--- /dev/null
+++ b/test/corruptG.test
@@ -0,0 +1,75 @@
+# 2013-08-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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix corruptG
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# Create a simple database with a single entry. Then corrupt the
+# header-size varint on the index payload so that it maps into a
+# negative number. Try to use the database.
+#
+
+do_execsql_test 1.1 {
+ PRAGMA page_size=512;
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1(rowid,a,b,c) VALUES(52,'abc','xyz','123');
+ CREATE INDEX t1abc ON t1(a,b,c);
+}
+
+set idxroot [db one {SELECT rootpage FROM sqlite_master WHERE name = 't1abc'}]
+
+# Corrupt the file
+db close
+hexio_write test.db [expr {$idxroot*512 - 15}] 888080807f
+sqlite3 db test.db
+
+# Try to use the file.
+do_test 1.2 {
+ catchsql {
+ SELECT c FROM t1 WHERE a>'abc';
+ }
+} {1 {database disk image is malformed}}
+do_test 1.3 {
+ catchsql {
+ PRAGMA integrity_check
+ }
+} {1 {database disk image is malformed}}
+do_test 1.4 {
+ catchsql {
+ SELECT c FROM t1 ORDER BY a;
+ }
+} {1 {database disk image is malformed}}
+
+# Corrupt the same file in a slightly different way. Make the record header
+# sane, but corrupt one of the serial_type value to indicate a huge payload
+# such that the payload begins in allocated space but overflows the buffer.
+#
+db close
+hexio_write test.db [expr {$idxroot*512-15}] 0513ff7f01
+sqlite3 db test.db
+
+do_test 2.1 {
+ catchsql {
+ SELECT rowid FROM t1 WHERE a='abc' and b='xyz123456789XYZ';
+ }
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/corruptH.test b/test/corruptH.test
new file mode 100644
index 0000000..9ba7522
--- /dev/null
+++ b/test/corruptH.test
@@ -0,0 +1,176 @@
+# 2014-01-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
+set testprefix corruptH
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+database_may_be_corrupt
+
+# The corruption migrations tested by the code in this file are not detected
+# mmap mode.
+#
+# The reason is that in mmap mode, the different queries may use different
+# PgHdr objects for the same page (same data, but different PgHdr container
+# objects). And so the corruption is not detected.
+#
+if {[permutation]=="mmap"} {
+ finish_test
+ return
+}
+
+# Initialize the database.
+#
+do_execsql_test 1.1 {
+ PRAGMA page_size=1024;
+
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES(randomblob(200));
+ INSERT INTO t2 SELECT randomblob(200) FROM t2;
+ INSERT INTO t2 SELECT randomblob(200) FROM t2;
+ INSERT INTO t2 SELECT randomblob(200) FROM t2;
+ INSERT INTO t2 SELECT randomblob(200) FROM t2;
+ INSERT INTO t2 SELECT randomblob(200) FROM t2;
+ INSERT INTO t2 SELECT randomblob(200) FROM t2;
+} {}
+
+# Corrupt the file so that the root page of t1 is also linked into t2 as
+# a leaf page.
+#
+do_test 1.2 {
+ db eval { SELECT name, rootpage FROM sqlite_master } {
+ set r($name) $rootpage
+ }
+ db close
+ hexio_write test.db [expr {($r(t2)-1)*1024 + 11}] [format %.2X $r(t1)]
+ sqlite3 db test.db
+} {}
+
+do_test 1.3 {
+ db eval { PRAGMA secure_delete=1 }
+ list [catch {
+ db eval { SELECT * FROM t1 WHERE a IN (1, 2) } {
+ db eval { DELETE FROM t2 }
+ }
+ } msg] $msg
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+
+# Initialize the database.
+#
+do_execsql_test 2.1 {
+ PRAGMA auto_vacuum=0;
+ PRAGMA page_size=1024;
+
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+
+ CREATE TABLE t3(x);
+
+ CREATE TABLE t2(x PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t2 VALUES(randomblob(100));
+
+ DROP TABLE t3;
+} {}
+
+do_test 2.2 {
+ db eval { SELECT name, rootpage FROM sqlite_master } {
+ set r($name) $rootpage
+ }
+ db close
+ set fl [hexio_get_int [hexio_read test.db 32 4]]
+
+ hexio_write test.db [expr {($fl-1) * 1024 + 0}] 00000000
+ hexio_write test.db [expr {($fl-1) * 1024 + 4}] 00000001
+ hexio_write test.db [expr {($fl-1) * 1024 + 8}] [format %.8X $r(t1)]
+ hexio_write test.db 36 00000002
+
+ sqlite3 db test.db
+} {}
+
+
+# The trick here is that the root page of the tree scanned by the outer
+# query is also currently on the free-list. So while the first seek on
+# the table (for a==1) works, by the time the second is attempted The
+# "INSERT INTO t2..." statements have recycled the root page of t1 and
+# used it as an index leaf. Normally, BtreeMovetoUnpacked() detects
+# that the PgHdr object associated with said root page does not match
+# the cursor (as it is now marked with PgHdr.intKey==0) and returns
+# SQLITE_CORRUPT.
+#
+set res23 {1 {database disk image is malformed}}
+do_test 2.3 {
+ list [catch {
+ set res [list]
+ db eval { SELECT * FROM t1 WHERE a IN (1, 2) } {
+ db eval {
+ INSERT INTO t2 SELECT randomblob(100) FROM t2;
+ INSERT INTO t2 SELECT randomblob(100) FROM t2;
+ INSERT INTO t2 SELECT randomblob(100) FROM t2;
+ INSERT INTO t2 SELECT randomblob(100) FROM t2;
+ INSERT INTO t2 SELECT randomblob(100) FROM t2;
+ }
+ lappend res $b
+ }
+ set res
+ } msg] $msg
+} $res23
+
+#-------------------------------------------------------------------------
+reset_db
+
+# Initialize the database.
+#
+do_execsql_test 3.1 {
+ PRAGMA page_size=1024;
+
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+
+ CREATE TABLE t2(c INTEGER PRAGMA KEY, d);
+ INSERT INTO t2 VALUES(1, randomblob(1100));
+} {}
+
+do_test 3.2 {
+ db eval { SELECT name, rootpage FROM sqlite_master } {
+ set r($name) $rootpage
+ }
+ db close
+
+ hexio_write test.db [expr {($r(t2)-1) * 1024 + 1020}] 00000002
+
+ sqlite3 db test.db
+} {}
+
+do_test 3.3 {
+ list [catch {
+ db eval { SELECT * FROM t1 WHERE a IN (1, 2) } {
+ db eval {
+ DELETE FROM t2 WHERE c=1;
+ }
+ }
+ } msg] $msg
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/corruptI.test b/test/corruptI.test
new file mode 100644
index 0000000..12ce446
--- /dev/null
+++ b/test/corruptI.test
@@ -0,0 +1,263 @@
+# 2014-01-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
+set testprefix corruptI
+
+if {[permutation]=="mmap"} {
+ finish_test
+ return
+}
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+database_may_be_corrupt
+
+# Initialize the database.
+#
+do_execsql_test 1.1 {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES('abcdefghijklmnop');
+} {}
+db close
+
+do_test 1.2 {
+ set offset [hexio_get_int [hexio_read test.db [expr 2*1024 + 8] 2]]
+ set off [expr 2*1024 + $offset + 1]
+ hexio_write test.db $off 7f06
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 WHERE a = 10 }
+} {0 {}}
+
+do_test 1.3 {
+ db close
+ set offset [hexio_get_int [hexio_read test.db [expr 2*1024 + 8] 2]]
+ set off [expr 2*1024 + $offset + 1]
+ hexio_write test.db $off FFFF7f02
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 WHERE a = 10 }
+} {1 {database disk image is malformed}}
+
+do_test 2.0 {
+ execsql {
+ CREATE TABLE r(x);
+ INSERT INTO r VALUES('ABCDEFGHIJK');
+ CREATE INDEX r1 ON r(x);
+ }
+ set pg [db one {SELECT rootpage FROM sqlite_master WHERE name = 'r1'}]
+} {5}
+
+do_test 2.1 {
+ db close
+ set offset [hexio_get_int [hexio_read test.db [expr (5-1)*1024 + 8] 2]]
+ set off [expr (5-1)*1024 + $offset + 1]
+ hexio_write test.db $off FFFF0004
+ sqlite3 db test.db
+ catchsql { SELECT * FROM r WHERE x >= 10.0 }
+} {1 {database disk image is malformed}}
+
+do_test 2.2 {
+ catchsql { SELECT * FROM r WHERE x >= 10 }
+} {1 {database disk image is malformed}}
+
+if {[db one {SELECT sqlite_compileoption_used('ENABLE_OVERSIZE_CELL_CHECK')}]} {
+ # The following tests only work if OVERSIZE_CELL_CHECK is disabled
+} else {
+ reset_db
+ do_execsql_test 3.1 {
+ PRAGMA auto_vacuum=0;
+ PRAGMA page_size = 512;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ WITH s(a, b) AS (
+ SELECT 2, 'abcdefghij'
+ UNION ALL
+ SELECT a+2, b FROM s WHERe a < 40
+ )
+ INSERT INTO t1 SELECT * FROM s;
+ } {}
+
+ do_test 3.2 {
+ hexio_write test.db [expr 512+3] 0054
+ db close
+ sqlite3 db test.db
+ execsql { INSERT INTO t1 VALUES(5, 'klmnopqrst') }
+ execsql { INSERT INTO t1 VALUES(7, 'klmnopqrst') }
+ } {}
+
+ db close
+ sqlite3 db test.db
+ do_catchsql_test 3.3 {
+ INSERT INTO t1 VALUES(9, 'klmnopqrst');
+ } {1 {database disk image is malformed}}
+} ;# end-if !defined(ENABLE_OVERSIZE_CELL_CHECK)
+
+
+#-------------------------------------------------------------------------
+# Test that an assert() failure discovered by AFL corrupt database file
+# testing has been fixed.
+#
+reset_db
+do_execsql_test 4.0 {
+ PRAGMA page_size = 65536;
+ PRAGMA autovacuum = 0;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(-1, 'abcdefghij');
+ INSERT INTO t1 VALUES(0, 'abcdefghij');
+}
+
+set root [db one {SELECT rootpage FROM sqlite_master}]
+set offset [expr ($root-1) * 65536]
+
+ifcapable oversize_cell_check {
+ set res {1 {database disk image is malformed}}
+} else {
+ set res {0 {}}
+}
+do_test 4.1 {
+ db close
+ hexio_write test.db [expr $offset + 8 + 2] 0000
+ hexio_write test.db [expr $offset + 5] 0000
+ sqlite3 db test.db
+ catchsql { DELETE FROM t1 WHERE a=0 }
+} $res
+
+
+#-------------------------------------------------------------------------
+# Database properties:
+#
+# * Incremental vacuum mode.
+# * Database root table has a single leaf page.
+# * Free list consists of a single trunk page.
+#
+# The db is then corrupted by adding the root table leaf page as a free-list
+# leaf page (so that it is referenced twice).
+#
+# Then, a new table is created. The new root page is the current free-list
+# trunk. This means that the root table leaf page is made into the new
+# free list trunk, which corrupts its header. Then, when the new entry is
+# inserted into the root table, things would get chaotic.
+#
+reset_db
+do_test 5.0 {
+ execsql {
+ PRAGMA page_size = 512;
+ PRAGMA auto_vacuum = 2;
+ }
+ for {set i 3} {1} {incr i} {
+ execsql "CREATE TABLE t${i}(x)"
+ if {[db one {PRAGMA page_count}]>$i} break
+ }
+ set nPage [db one {PRAGMA page_count}]
+ execsql {
+ CREATE TABLE t100(x);
+ DROP TABLE t100;
+ }
+} {}
+
+do_execsql_test 5.1 {
+ PRAGMA page_count
+} [expr $nPage+1]
+
+do_test 5.2 {
+ # The last page of the db is now the only leaf of the sqlite_master table.
+ # Corrupt the db by adding it to the free-list as well (the second last
+ # page of the db is the free-list trunk).
+ db close
+ hexio_write test.db [expr 512*($nPage-1)] [
+ format "%.8X%.8X%.8X" 0 1 [expr $nPage+1]
+ ]
+} {12}
+
+do_test 5.3 {
+ sqlite3 db test.db
+ catchsql { CREATE TABLE tx(x); }
+} {1 {database disk image is malformed}}
+
+
+#-------------------------------------------------------------------------
+# Set the payload size of a cell to just less than 2^32 bytes (not
+# possible in an uncorrupted db). Then try to delete the cell. At one
+# point this led to an integer overflow that caused an assert() to fail.
+#
+reset_db
+do_execsql_test 6.0 {
+ PRAGMA page_size = 512;
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(300));
+ INSERT INTO t1 VALUES(zeroblob(600));
+} {}
+do_test 6.1 {
+ db close
+ hexio_write test.db 616 8FFFFFFF7F02
+ sqlite3 db test.db
+ execsql { DELETE FROM t1 WHERE rowid=2 }
+} {}
+
+#-------------------------------------------------------------------------
+# See what happens if the sqlite_master entry associated with a PRIMARY
+# KEY or UNIQUE index is removed.
+#
+reset_db
+do_execsql_test 7.0 {
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE t1(x PRIMARY KEY, y);
+ INSERT INTO t1 VALUES('a', 'A');
+ INSERT INTO t1 VALUES('b', 'A');
+ INSERT INTO t1 VALUES('c', 'A');
+ SELECT name FROM sqlite_master;
+} {t1 sqlite_autoindex_t1_1}
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 7.1 {
+ PRAGMA writable_schema = 1;
+ DELETE FROM sqlite_master WHERE name = 'sqlite_autoindex_t1_1';
+}
+do_test 7.2 {
+ db close
+ sqlite3 db test.db
+ catchsql { UPDATE t1 SET x='d' AND y='D' WHERE rowid = 2 }
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+# At one point an assert() would fail if attempt was made to free page 1.
+#
+reset_db
+do_execsql_test 8.0 {
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(zeroblob(300));
+ INSERT INTO t1 VALUES(zeroblob(300));
+ INSERT INTO t1 VALUES(zeroblob(300));
+ INSERT INTO t1 VALUES(zeroblob(300));
+} {}
+
+do_test 8.1 {
+ db close
+ hexio_write test.db [expr 1024 + 8] 00000001
+ sqlite3 db test.db
+ catchsql { DELETE FROM t1 }
+} {1 {database disk image is malformed}}
+
+do_test 8.2 {
+ db close
+ sqlite3 db test.db
+ execsql { PRAGMA integrity_check }
+} {/.*in database main.*/}
+
+
+finish_test
diff --git a/test/corruptJ.test b/test/corruptJ.test
new file mode 100644
index 0000000..732adb0
--- /dev/null
+++ b/test/corruptJ.test
@@ -0,0 +1,80 @@
+# 2015-03-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.
+#
+#***********************************************************************
+#
+# Corruption consisting of a database page that thinks it is a child
+# of itself.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix corruptJ
+
+if {[permutation]=="mmap"} {
+ finish_test
+ return
+}
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+database_may_be_corrupt
+
+# Initialize the database.
+#
+do_execsql_test 1.1 {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE t1(a,b);
+ WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(700) FROM c;
+} {}
+db close
+
+# Corrupt the root page of the t1 table such that the left-child pointer
+# for the very first cell points back to the root. Then try to DROP the
+# table. The clearDatabasePage() routine should not loop.
+#
+do_test 1.2 {
+ hexio_write test.db [expr {2*1024-2}] 02
+ sqlite3 db test.db
+ catchsql { DROP TABLE t1 }
+} {1 {database disk image is malformed}}
+
+# Similar test using a WITHOUT ROWID table
+#
+do_test 2.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE t1(a,b,PRIMARY KEY(a,b)) WITHOUT ROWID;
+ WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)
+ INSERT INTO t1(a,b) SELECT i, zeroblob(200) FROM c;
+ }
+} {}
+
+# The table is three levels deep. Corrupt the left child of an intermediate
+# page so that it points back to the root page.
+#
+do_test 2.2 {
+ db close
+ hexio_read test.db [expr {9*1024+391}] 8
+} {00000008814D0401}
+do_test 2.2b {
+ hexio_write test.db [expr {9*1024+391}] 00000002
+ sqlite3 db test.db
+ catchsql { PRAGMA secure_delete=ON; DROP TABLE t1; }
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/corruptK.test b/test/corruptK.test
new file mode 100644
index 0000000..1569afe
--- /dev/null
+++ b/test/corruptK.test
@@ -0,0 +1,234 @@
+# 2017-03-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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix corruptK
+
+if {[permutation]=="mmap"} {
+ finish_test
+ return
+}
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+database_may_be_corrupt
+
+# Initialize the database.
+#
+do_execsql_test 1.1 {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE t1(x);
+
+ INSERT INTO t1 VALUES(randomblob(20));
+ INSERT INTO t1 VALUES(randomblob(100)); -- make this into a free slot
+ INSERT INTO t1 VALUES(randomblob(27)); -- this one will be corrupt
+ INSERT INTO t1 VALUES(randomblob(800));
+
+ DELETE FROM t1 WHERE rowid=2; -- free the 100 byte slot
+ PRAGMA page_count
+} {2}
+
+
+# Corrupt the database so that the blob stored immediately before
+# the free slot (rowid==3) has an overlarge length field. So that
+# we can use sqlite3_blob_write() to manipulate the size field of
+# the free slot.
+#
+# Then use sqlite3_blob_write() to set the size of said free slot
+# to 24 bytes (instead of the actual 100).
+#
+# Then use the new 24 byte slot. Leaving the in-memory version of
+# the page with zero free slots and a large nFree value. Then try
+# to allocate another slot to get to defragmentPage().
+#
+do_test 1.2 {
+ db close
+ hexio_write test.db [expr 1024 + 0x360] 21
+ hexio_write test.db [expr 1024 + 0x363] [format %x [expr 31*2 + 12]]
+ sqlite3 db test.db
+
+ set fd [db incrblob t1 x 3]
+ fconfigure $fd -translation binary -encoding binary
+ seek $fd 30
+ puts -nonewline $fd "\x18"
+ close $fd
+} {}
+do_execsql_test 1.3 {
+ INSERT INTO t1 VALUES(randomblob(20));
+}
+
+# This test no longer functions due to the deferred computation of
+# MemPage.nFree.
+#
+if 0 {
+do_catchsql_test 1.4 {
+ INSERT INTO t1 VALUES(randomblob(90));
+} {1 {database disk image is malformed}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.1 {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum=0;
+ CREATE TABLE t1(x);
+
+ INSERT INTO t1 VALUES(randomblob(20));
+ INSERT INTO t1 VALUES(randomblob(20)); -- free this one
+ INSERT INTO t1 VALUES(randomblob(20));
+ INSERT INTO t1 VALUES(randomblob(20)); -- and this one
+ INSERT INTO t1 VALUES(randomblob(20)); -- corrupt this one.
+
+ DELETE FROM t1 WHERE rowid IN(2, 4);
+ PRAGMA page_count
+} {2}
+
+do_test 2.2 {
+ db close
+ hexio_write test.db [expr 1024 + 0x388] 53
+ hexio_write test.db [expr 1024 + 0x38A] 03812C
+
+ sqlite3 db test.db
+ set fd [db incrblob t1 x 5]
+ fconfigure $fd -translation binary -encoding binary
+
+ seek $fd 22
+ puts -nonewline $fd "\x5d"
+ close $fd
+} {}
+
+do_catchsql_test 2.3 {
+ INSERT INTO t1 VALUES(randomblob(900));
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+
+ifcapable vtab {
+if {[permutation]!="inmemory_journal"} {
+
+ proc hex2blob {hex} {
+ # Split on newlines:
+ set bytes [list]
+ foreach l [split $hex "\n"] {
+ if {[string is space $l]} continue
+ set L [list]
+ foreach b [split $l] {
+ if {[string is xdigit $b] && [string length $b]==2} {
+ lappend L [expr "0x$b"]
+ }
+ }
+ if {[llength $L]!=16} {
+ error "Badly formed hex (1)"
+ }
+ set bytes [concat $bytes $L]
+ }
+
+ binary format c* $bytes
+ }
+
+ reset_db
+ db func hex2blob hex2blob
+
+ do_execsql_test 3.1 {
+ PRAGMA page_size=1024;
+ 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);
+ }
+ sqlite3_db_config db DEFENSIVE 0
+ do_execsql_test 3.2 {
+ UPDATE sqlite_dbpage SET data = hex2blob('
+ 000: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+ 010: 04 00 01 01 20 40 20 20 00 00 3e d9 00 00 00 06 .... @ ..>.....
+ 020: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................
+ 030: 0f 00 00 00 00 00 00 00 00 00 00 01 00 00 83 00 ................
+ 040: 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 .............8..
+ 050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e d9 ..............>.
+ 060: 00 2d e6 07 0d 00 00 00 01 03 a0 00 03 e0 00 00 .-..............
+ 070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0d0: 00 00 00 00 00 c1 00 00 00 00 00 00 00 00 00 00 ................
+ 0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 160: 00 83 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 180: 00 00 00 00 00 00 00 00 00 00 07 00 30 00 00 00 ............0...
+ 190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 1c0: 02 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 ................
+ 1d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 1e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 1f0: 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 220: 00 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 230: 0c 00 00 00 00 00 00 60 00 00 00 06 00 00 c3 00 .......`........
+ 240: 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 270: 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 290: 04 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 2a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 2b0: 00 00 00 00 83 00 8c 00 00 00 00 00 00 00 00 00 ................
+ 2c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 2d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 2e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 310: 00 78 00 00 00 00 00 00 00 00 00 00 00 00 70 00 .x............p.
+ 320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 340: 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 350: 00 00 00 00 00 68 00 00 00 00 00 00 00 00 00 00 .....h..........
+ 360: 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 ................
+ 370: 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 ................
+ 380: 00 00 00 00 70 00 00 00 00 00 00 00 00 00 00 00 ....p...........
+ 390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 3a0: 5e 01 07 17 1b 1b 01 81 13 74 61 62 6c 65 73 65 ^........tablese
+ 3b0: 6e 73 6f 32 73 73 65 6e 73 6f 72 73 02 43 52 45 nso2ssensors.CRE
+ 3c0: 41 54 45 20 54 41 42 4c 45 20 73 65 6e 73 6f 72 ATE TABLE sensor
+ 3d0: 73 20 0a 20 20 24 20 20 20 20 20 20 20 20 20 20 s . $
+ 3e0: b8 6e 61 6d 65 21 74 65 78 74 2c 20 79 61 6c 20 .name!text, yal
+ 3f0: 72 65 61 6c 2c 20 74 69 6d 65 20 74 65 78 74 29 real, time text)
+ ') WHERE pgno=1
+ }
+
+ db close
+ sqlite3 db test.db
+
+ do_catchsql_test 3.3 {
+ PRAGMA integrity_check;
+ } {1 {database disk image is malformed}}
+
+} ;# [permutation]!="inmemory_journal"
+} ;# ifcapable vtab
+
+
+
+finish_test
diff --git a/test/corruptL.test b/test/corruptL.test
new file mode 100644
index 0000000..3a841a8
--- /dev/null
+++ b/test/corruptL.test
@@ -0,0 +1,1504 @@
+# 2019-01-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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix corruptL
+
+database_may_be_corrupt
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 1.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 356352 pagesize 4096 filename crash-acaae0347204ae.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 d0 00 00 00 .....@ ........
+| 32: 40 00 ea 00 00 00 00 00 00 40 00 00 00 40 00 00 @........@...@..
+| 96: 00 00 00 00 0d 00 00 00 04 0e 9c 00 0f ad 0f 4f ...............O
+| 112: 0e fc 0e 9c 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3728: 00 00 00 00 00 00 00 00 00 00 00 00 5e 04 07 17 ............^...
+| 3744: 1f 1f 01 81 0b 74 61 62 6c 65 74 31 5f 70 61 72 .....tablet1_par
+| 3760: 65 6e 74 74 31 5f 70 61 72 65 6e 74 04 43 52 45 entt1_parent.CRE
+| 3776: 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 70 61 ATE TABLE .t1_pa
+| 3792: 72 65 6e 74 22 28 6e 6f 64 65 6e 6f 20 49 4e 54 rent.(nodeno INT
+| 3808: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY
+| 3824: 2c 70 61 72 65 6e 74 6e 6f 64 65 29 51 03 06 17 ,parentnode)Q...
+| 3840: 1b 1b 01 7b 74 61 62 6c 65 74 31 5f 6e 6f 64 65 ....tablet1_node
+| 3856: 74 31 5f 6e 6f 64 65 03 43 52 45 41 54 45 20 54 t1_node.CREATE T
+| 3872: 41 42 4c 45 20 22 74 31 5f 6e 6f 64 65 22 28 6e ABLE .t1_node.(n
+| 3888: 6f 64 65 6e 6f 20 49 4e 54 45 47 45 52 20 50 52 odeno INTEGER PR
+| 3904: 49 4d 41 52 59 20 4b 45 59 2c 64 61 74 61 29 5c IMARY KEY,data).
+| 3920: 02 07 17 1d 1d 01 81 0b 74 61 62 6c 65 74 31 5f ........tablet1_
+| 3936: 72 6f 77 69 64 74 31 5f 72 6f 77 69 64 02 43 52 rowidt1_rowid.CR
+| 3952: 45 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 72 EATE TABLE .t1_r
+| 3968: 6f 77 69 64 22 28 72 6f 77 69 64 20 49 4e 54 45 owid.(rowid INTE
+| 3984: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
+| 4000: 6e 6f 64 65 6e 6f 2c 61 30 2c 61 31 29 51 01 07 nodeno,a0,a1)Q..
+| 4016: 17 11 11 08 81 0f 74 61 62 6c 65 74 31 74 31 43 ......tablet1t1C
+| 4032: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA
+| 4048: 42 4c 45 20 74 31 20 55 53 49 4e 47 20 72 74 72 BLE t1 USING rtr
+| 4064: 65 65 28 69 64 2c 78 30 20 50 52 49 4d 41 52 59 ee(id,x0 PRIMARY
+| 4080: 20 4b 45 59 2c 70 61 72 65 6e 74 6e 6f 64 65 29 KEY,parentnode)
+| page 2 offset 4096
+| 0: 51 03 06 17 1b 1b 01 7b 74 61 62 6c 65 74 31 5f Q.......tablet1_
+| 16: 6e 6f 64 65 74 31 5f 6e 6f 64 65 03 43 52 45 41 nodet1_node.CREA
+| 32: 54 45 20 54 41 42 4c 45 20 22 74 31 5f 6e 6f 64 TE TABLE .t1_nod
+| 48: 65 22 28 6e 6f 64 65 6e 6f 20 49 4e 54 45 47 45 e.(nodeno INTEGE
+| 64: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 64 61 R PRIMARY KEY,da
+| 80: 74 61 29 5c 02 07 17 1d 1d 01 81 0b 74 61 62 6c ta).........tabl
+| 96: 65 74 31 5f 72 6f 77 69 64 74 31 5f 72 6f 77 69 et1_rowidt1_rowi
+| 112: 64 02 43 52 45 41 54 45 20 54 41 42 4c 45 00 00 d.CREATE TABLE..
+| 128: 01 0a 02 00 00 00 01 0e 0d 00 00 00 00 24 0e 0d .............$..
+| 144: 0c 1a 06 85 50 46 60 27 70 08 00 00 00 00 00 00 ....PF`'p.......
+| 3824: 00 00 00 00 00 00 00 0d 0e 05 00 09 1d 00 74 6f ..............to
+| 3840: 79 20 68 61 6c 66 10 0d 05 00 09 23 00 62 6f 74 y half.....#.bot
+| 3856: 74 6f 6d 20 68 61 6c 66 0f 0c 05 00 09 21 00 72 tom half.....!.r
+| 3872: 69 67 68 74 20 68 61 6c 66 0e 0b 05 00 09 1f 00 ight half.......
+| 3888: 6c 65 66 74 20 43 15 f6 e6 f6 46 50 34 35 24 54 left C....FP45$T
+| 3904: 15 44 52 05 44 14 24 c4 52 02 27 43 15 f6 e6 f6 .DR.D.$.R.'C....
+| 3920: 46 52 22 8e 6f 64 65 6e 6f 20 49 4e 54 45 47 45 FR..odeno INTEGE
+| 3936: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 64 61 R PRIMARY KEY,da
+| 3952: 74 61 29 5c 02 07 17 1d 1d 01 81 0b 74 61 62 6c ta).........tabl
+| 3968: 65 74 31 5f 72 6f 74 74 6f 6d 20 65 64 67 65 0f et1_rottom edge.
+| 3984: 07 05 00 09 21 00 72 69 67 68 74 20 65 64 67 65 ....!.right edge
+| 4000: 0e 06 05 00 09 1f 00 6c 65 66 74 20 65 64 67 65 .......left edge
+| 4016: 0b 05 05 00 09 19 00 63 65 6e 74 65 72 17 04 05 .......center...
+| 4032: 00 09 31 00 75 70 70 65 72 2d 72 69 67 68 74 20 ..1.upper-right
+| 4048: 63 6f 72 6e 65 72 17 03 05 00 09 31 00 6c 6f 77 corner.....1.low
+| 4064: 65 72 2d 72 69 67 68 74 20 63 6f 72 6e 65 72 16 er-right corner.
+| 4080: 02 05 00 09 2f 00 75 70 70 65 72 2d 6c 65 66 74 ..../.upper-left
+| page 3 offset 8192
+| 0: 20 63 6f 72 6e 65 72 16 01 05 00 09 2f 01 8c 6f corner...../..o
+| 16: 77 65 72 2d 6c 53 51 4c 69 74 65 20 66 6f 72 6d wer-lSQLite form
+| 32: 61 74 20 33 00 10 00 01 01 00 40 20 20 00 00 00 at 3......@ ...
+| 48: 00 00 00 00 2f 00 00 0d eb 13 00 00 00 03 00 00 ..../...........
+| 64: 00 04 00 00 00 00 00 00 00 06 00 00 00 01 00 00 ................
+| 80: 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 ................
+| page 6 offset 20480
+| 128: 00 00 00 00 00 00 00 00 97 3d 04 ae 7c 01 00 00 .........=..|...
+| 624: 00 00 00 00 00 00 21 97 3d 04 ae 7c 01 00 00 00 ......!.=..|....
+| 1120: 00 00 00 00 00 20 97 3d 04 ae 7c 01 00 00 00 00 ..... .=..|.....
+| 1616: 00 00 00 00 1f 97 3d 04 ae 7c 01 00 00 00 00 00 ......=..|......
+| 2112: 00 00 00 1e 97 3d 04 ae 7c 01 00 00 00 00 00 00 .....=..|.......
+| 2608: 00 00 1d 97 d3 d0 4a e7 c0 00 00 00 00 00 00 00 ......J.........
+| 3088: 00 00 00 00 00 00 00 00 00 00 00 00 01 f3 00 00 ................
+| 3600: 23 97 3d 04 ae 7c 01 00 00 00 00 00 00 00 00 00 #.=..|..........
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26 ...............&
+| page 8 offset 28672
+| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| 1072: 97 4d 1e 14 00 ae 7c 00 00 00 00 00 00 00 00 00 .M....|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 ................
+| page 10 offset 36864
+| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| 1072: 9a ee c1 80 fd 78 1f ce 1b ae eb b4 00 00 00 00 .....x..........
+| 1088: 13 20 ff 20 00 70 00 00 00 60 50 00 00 00 11 e0 . . .p...`P.....
+| 1104: 00 00 00 70 00 00 00 60 50 05 35 14 c6 97 46 52 ...p...`P.5...FR
+| 1120: 06 66 f7 26 d6 17 42 03 30 01 00 00 10 10 04 02 .f.&..B.0.......
+| 1136: 02 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 .........@......
+| 1152: 00 00 00 00 00 40 00 00 00 40 00 00 00 00 00 00 .....@...@......
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................
+| page 12 offset 45056
+| 0: 0d 00 00 00 01 04 30 00 04 30 e1 b4 30 97 4d 46 ......0..0..0.MF
+| 16: 14 00 ae 7c 00 00 00 00 00 00 00 03 00 00 43 00 ...|..........C.
+| page 47 offset 188416
+| 2512: 00 00 00 00 00 00 00 00 be 00 00 00 00 00 00 00 ................
+| page 87 offset 352256
+| 2512: 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00 ................
+| end crash-acaae0347204ae.db
+}]} {}
+
+do_catchsql_test 1.1 {
+ PRAGMA cell_size_check = off;
+ DROP INDEX t1x1;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 1.2 {
+ SELECT sum(s+length(b)) FROM t1 WHERE a IN (110,10,150) AND q IS NULL;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 1.3 {
+ REINDEX t1;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 1.4 {
+ PRAGMA integrity_check
+} {1 {database disk image is malformed}}
+
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 2.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 20480 pagesize 4096 filename crash.txt.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 05 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 00 00 00 05 0e 55 00 0f 74 0f 3c ..........U..t.<
+| 112: 0e f9 0e d1 0e 55 00 00 00 00 00 00 00 00 00 00 .....U..........
+| 3664: 00 00 00 00 00 7a 05 07 15 11 11 08 81 63 76 69 .....z.......cvi
+| 3680: 65 77 76 31 76 31 43 52 45 41 54 45 20 56 49 45 ewv1v1CREATE VIE
+| 3696: 57 20 76 31 28 78 2c 79 29 20 41 53 0a 53 45 4c W v1(x,y) AS.SEL
+| 3712: 45 43 54 20 74 31 2e 62 2c 74 32 2e 62 20 46 52 ECT t1.b,t2.b FR
+| 3728: 4f 4d 20 74 31 2c 74 32 20 57 48 45 52 45 20 74 OM t1,t2 WHERE t
+| 3744: 31 2e 61 3d 74 32 2e 61 20 47 52 4f 55 50 20 42 1.a=t2.a GROUP B
+| 3760: 59 20 31 20 48 41 56 49 4e 47 20 74 32 2e 63 20 Y 1 HAVING t2.c
+| 3776: 4e 4f 54 20 4e 55 4c 4c 0a 4c 49 4d 49 54 20 31 NOT NULL.LIMIT 1
+| 3792: 30 26 04 06 17 11 11 01 39 74 61 62 6c 65 74 32 0&......9tablet2
+| 3808: 74 32 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 t2.CREATE TABLE
+| 3824: 74 32 28 61 2c 62 2c 63 29 41 03 06 17 15 11 01 t2(a,b,c)A......
+| 3840: 6b 69 6e 64 65 78 74 31 78 31 74 31 04 43 52 45 kindext1x1t1.CRE
+| 3856: 41 54 45 20 49 4e 44 45 58 20 73 31 78 31 20 4f ATE INDEX s1x1 O
+| 3872: 4e 20 74 31 28 64 29 20 57 48 45 52 45 20 65 65 N t1(d) WHERE ee
+| 3888: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 36 02 06 17 IS NOT NULL6...
+| 3904: 17 11 01 53 69 6e 64 65 78 74 31 61 62 63 74 31 ...Sindext1abct1
+| 3920: 03 43 52 45 41 54 45 20 49 4e 44 45 58 20 74 31 .CREATE INDEX t1
+| 3936: 61 62 63 20 4f 4e 20 74 31 28 61 2c 62 2c 63 2b abc ON t1(a,b,c+
+| 3952: 64 2b 65 29 81 09 01 07 17 11 11 01 81 7d 74 61 d+e)..........ta
+| 3968: 62 6c 65 74 31 74 31 02 43 52 45 41 54 45 20 54 blet1t1.CREATE T
+| 3984: 41 42 4c 45 20 74 31 28 61 2c 62 2c 63 2c 64 2c ABLE t1(a,b,c,d,
+| 4000: 65 2c 66 2c 67 2c 68 2c 6a 2c 6a 6a 2c 6a 6a 6a e,f,g,h,j,jj,jjj
+| 4016: 2c 6b 2c 61 61 2c 62 62 2c 63 63 2c 64 64 2c 65 ,k,aa,bb,cc,dd,e
+| 4032: 65 20 44 45 46 41 55 4c 54 20 33 2e 31 34 2c 0a e DEFAULT 3.14,.
+| 4048: 66 66 20 44 45 46 41 55 4c 54 28 27 68 69 63 63 ff DEFAULT('hicc
+| 4064: 75 70 27 29 2c 67 67 20 4e 4f 54 20 4e 55 4c 4c up'),gg NOT NULL
+| 4080: 20 44 45 46 41 55 4c 54 28 66 61 6c 73 65 29 29 DEFAULT(false))
+| page 2 offset 4096
+| 0: 0d 00 00 00 0a 0e 7b 00 0f dc 0f b6 0f 8f 0f 68 ...............h
+| 16: 0f 41 0f 1a 0e f3 0e cb 0e a3 0e 7b 00 00 00 00 .A..............
+| 3696: 00 00 00 00 00 00 00 00 00 00 00 26 0a 14 01 01 ...........&....
+| 3712: 02 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19 ................
+| 3728: 08 09 5a 00 b4 40 09 1e b8 51 eb 85 1f 68 69 63 ..Z..@...Q...hic
+| 3744: 63 75 70 26 09 14 01 01 02 08 00 00 00 00 00 00 cup&............
+| 3760: 00 00 00 00 00 00 07 19 08 08 50 00 a0 40 09 1e ..........P..@..
+| 3776: b8 51 eb 85 1f 68 69 63 63 75 70 26 08 14 01 01 .Q...hiccup&....
+| 3792: 02 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19 ................
+| 3808: 08 07 46 00 8c 40 09 1e b8 51 eb 85 1f 68 69 63 ..F..@...Q...hic
+| 3824: 63 75 70 25 07 14 01 01 01 08 00 00 00 00 00 00 cup%............
+| 3840: 00 00 00 00 00 00 07 b9 08 06 3c 78 40 09 1e b8 ..........<x@...
+| 3856: 51 eb 85 1f 68 69 63 63 75 70 25 06 14 01 00 01 Q...hiccup%.....
+| 3872: 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19 08 ................
+| 3888: 05 32 64 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 .2d@...Q...hiccu
+| 3904: 70 25 05 14 01 01 01 08 00 00 00 00 00 00 00 00 p%..............
+| 3920: 00 00 00 00 07 19 08 04 28 50 40 09 1e b8 51 eb ........(P@...Q.
+| 3936: 85 1f 68 69 63 63 75 70 25 04 14 01 01 01 08 00 ..hiccup%.......
+| 3952: 00 00 00 00 00 00 00 00 00 00 00 07 19 08 03 1e ................
+| 3968: 3c 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 70 25 <@...Q...hiccup%
+| 3984: 03 14 01 01 01 08 00 00 00 00 00 00 00 00 00 00 ................
+| 4000: 00 00 07 19 08 02 14 28 40 09 1e b8 51 eb 85 1f .......(@...Q...
+| 4016: 68 69 63 63 75 70 24 02 14 09 01 01 08 00 00 00 hiccup$.........
+| 4032: 00 00 00 00 00 00 00 00 00 07 19 08 0a 14 40 09 ..............@.
+| 4048: 1e b8 51 eb 85 1f 68 69 63 63 75 70 22 01 14 08 ..Q...hiccup....
+| 4064: 08 08 07 ff ff ff ff ff ff 00 00 00 00 00 00 07 ................
+| 4080: 19 08 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 70 ..@...Q...hiccup
+| page 3 offset 8192
+| 0: 0a 00 00 00 0a 0f aa 00 0f fa 0f f2 0f e9 0f e0 ................
+| 16: 0f d7 0f ce 0f c5 0f bc 0e b3 0f aa 00 00 00 00 ................
+| 4000: 00 00 00 00 00 00 00 00 00 00 08 05 01 01 00 01 ................
+| 4016: 09 5a 0a 08 05 01 01 00 01 08 50 09 08 05 01 01 .Z........P.....
+| 4032: 00 01 07 46 08 08 05 01 01 00 01 06 3c 07 08 05 ...F........<...
+| 4048: 01 01 00 01 05 32 06 08 05 01 01 00 01 04 28 05 .....2........(.
+| 4064: 08 05 01 01 00 01 03 1e 04 08 05 01 01 00 01 02 ................
+| 4080: 14 03 07 05 09 01 00 01 0a 02 05 05 08 08 00 09 ................
+| page 4 offset 12288
+| 0: 0a 00 00 00 0a 0f cf 00 0f fc 0f f7 0f f2 0f ed ................
+| 16: 0f e8 0f e3 0f de 0f d9 0f d4 0f cf 00 00 00 00 ................
+| 4032: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 ................
+| 4048: 03 08 01 0a 04 03 08 01 09 04 03 08 01 08 04 03 ................
+| 4064: 08 01 07 04 03 08 01 06 04 03 08 01 05 04 03 08 ................
+| 4080: 01 04 04 03 08 01 13 04 03 08 01 02 03 03 08 09 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| end crash.txt.db
+}]} {}
+
+do_execsql_test 2.1 {
+ PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
+ INSERT INTO t1(b) VALUES(X'a0fee3669f9fddefc5cba913e4225d4b6ce2b04f26b87fad3ee6f9b7d90a1ea62a169bf41e5d32707a6ca5c3d05e4bde05c9d89eaaa8c50e74333d2e9fcd7dfe95528a3a016aac1102d825c5cd70cf99d8a88e0ea7f798d4334386518b7ad359beb168b93aba059a2a3bd93112d65b44c12b9904ea786b204d80531cdf0504bf9b203dbe927061974caf7b9f30cbc3397b61f802e732012a6663d41c3607d6f1c0dbcfd489adac05ca500c0b04439d894cd93a840159225ef73b627e178b9f84b3ffe66cf22a963a8368813ff7961fc47f573211ccec95e0220dcbb3bf429f4a50ba54d7a53784ac51bfef346e6ac8ae0d0e7c3175946e62ba2b');
+}
+
+do_catchsql_test 2.2 {
+ SELECT b,c FROM t1 ORDER BY a;
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(a, b, c, d INTEGER PRIMARY KEY);
+ CREATE TABLE t2(a, b, c, d INTEGER PRIMARY KEY);
+
+ INSERT INTO t1(a, b, c, d) VALUES (1, 2, 3, 100), (4, 5, 6, 101);
+ INSERT INTO t2(a, b, c, d) VALUES (1, 100, 3, 1000), (4, 101, 6, 1001);
+
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t2a ON t2(a, b, c);
+
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET sql = 'CREATE INDEX t2a ON t2(a)' WHERE name='t2a';
+}
+
+db close
+sqlite3 db test.db
+
+do_catchsql_test 3.1 {
+ INSERT INTO t1 SELECT * FROM t2;
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 4.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 4096 pagesize 512 filename crash-6b48ba69806134.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 02 00 01 01 00 40 20 20 00 ff ff ff ff 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 05 00 eb 00 01 00 00 00 00 ................
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c ................
+| 96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0 ..,P............
+| 112: 05 56 01 86 01 2a 01 06 00 00 00 00 00 00 00 00 .V...*..........
+| 128: 00 ff 00 00 ff ff ff e1 00 00 00 00 00 00 00 00 ................
+| 144: 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 ................
+| 160: 00 00 00 00 00 00 00 00 f2 00 00 00 00 00 00 00 ................
+| 176: 00 00 f9 ff ff ff ff ff ff ff 00 00 00 00 00 fb ................
+| 208: 00 00 00 00 00 00 00 00 1e 00 00 00 fe 00 00 00 ................
+| 224: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ca 00 ................
+| 256: 00 00 00 00 ef ff 22 07 06 17 11 11 01 31 74 61 .............1ta
+| 272: 62 6c 65 74 38 38 74 04 43 52 45 41 54 45 20 54 blet88t.CREATE T
+| 288: 41 42 4c 45 20 74 34 28 87 29 2a 06 06 17 13 11 ABLE t4(.)*.....
+| 304: 01 3f 69 4f 64 65 78 74 33 78 74 33 05 43 52 45 .?iOdext3xt3.CRE
+| 320: 41 54 45 20 49 6e 44 45 58 20 74 33 78 20 4f 4e ATE InDEX t3x ON
+| 336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e t3(x).......Ein
+| 352: 64 65 2e 74 32 63 64 74 3d 05 43 52 45 41 54 45 de.t2cdt=.CREATE
+| 368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74 INDEX t2cd ON t
+| 384: 32 28 0a 0c 44 29 28 05 06 17 11 11 01 3d 74 61 2(..D)(......=ta
+| 400: 62 6c 65 d4 33 74 33 04 43 52 45 41 54 45 20 54 ble.3t3.CREATE T
+| 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f)
+| 432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (......=tablet2t
+| 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t
+| 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$.....
+| 480: 01 35 74 60 62 6c 65 74 31 74 31 02 43 52 45 41 .5t`blet1t1.CREA
+| 496: 54 45 20 54 41 42 4c 45 20 74 30 28 61 2c 62 29 TE TABLE t0(a,b)
+| page 2 offset 512
+| 0: 0d 00 ff 11 04 01 cf 00 01 fa 01 f3 01 de 01 cf ................
+| 32: 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 13 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 20 00 00 ............. ..
+| 64: 00 00 00 00 00 00 f8 ff ff ff 00 00 00 00 00 00 ................
+| 160: 01 64 00 00 00 00 00 80 ff ff ff 00 00 00 00 00 .d..............
+| 176: 00 00 00 00 00 00 00 00 1f 00 00 00 00 00 00 03 ................
+| 192: 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 ..@.............
+| 288: 00 00 00 00 00 00 ff ff ff e9 00 00 00 00 00 00 ................
+| 336: 01 00 00 ff ff 00 00 00 00 00 00 00 00 00 00 00 ................
+| 368: 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...............
+| 384: 00 de ff 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 464: 00 00 00 00 00 13 76 65 6e 65 69 67 68 74 13 03 ......veneight..
+| 480: 03 40 07 07 14 00 54 45 20 49 4e 44 45 58 20 74 .@....TE INDEX t
+| 496: 32 63 64 20 4f 4e 20 74 32 28 0a 0c 44 09 01 02 2cd ON t2(..D...
+| page 3 offset 1024
+| 0: 0d 00 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 aa ....H.T.........
+| 16: 30 34 28 87 29 2a 06 06 17 13 11 01 3f 69 4f 64 04(.)*......?iOd
+| 32: 65 79 74 33 78 74 33 6d 6d 6d 6d 6d 6d 7d 6d 6d eyt3xt3mmmmmm.mm
+| 48: 6d 41 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d mAmmmmmmmmmmmmmm
+| 64: 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 66 6d 6d 6d 6d mmmmmmmmmmmfmmmm
+| 80: 6d 4e 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d mNmmmmmmmmmmmmmm
+| 96: 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d mmmmmmmmmmmmmmmm
+| 112: 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d mmmmmmmmmmmmmmmm
+| 128: 6d 6d 6d 6d 6d 00 00 00 00 00 00 00 00 00 00 00 mmmmm...........
+| 160: 80 00 00 00 00 00 00 03 00 00 00 ff e4 00 00 00 ................
+| 208: 00 00 00 00 00 00 00 00 00 00 00 00 00 c5 00 00 ................
+| 240: 14 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 ................
+| 256: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0f ec ................
+| 304: 00 00 00 00 19 08 05 17 17 17 17 65 69 67 68 74 ...........eight
+| 320: 65 69 67 68 74 73 65 00 00 00 00 00 00 00 00 00 eightse.........
+| 336: 00 00 00 00 19 08 05 17 17 17 17 65 69 67 68 74 ...........eight
+| 352: 65 69 67 68 74 73 65 01 65 6e 00 00 00 10 25 07 eightse.en....%.
+| 368: 07 6e 25 07 07 07 40 18 00 00 00 00 00 00 40 18 .n%...@.......@.
+| 384: 00 00 00 00 00 00 40 14 00 00 00 00 00 00 40 14 ......@.......@.
+| 400: 00 00 00 00 00 00 09 06 05 01 01 01 01 04 04 03 ................
+| 416: 03 07 05 05 01 01 09 09 02 02 19 04 05 17 17 17 ................
+| 432: 17 10 65 76 65 6e 65 69 67 68 74 65 69 67 68 74 ..eveneighteight
+| 448: 73 65 76 65 6e 25 03 05 07 07 07 07 40 14 00 00 seven%......@...
+| 464: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00 ....@.......@...
+| 480: 00 00 00 00 40 14 00 00 00 00 e8 f6 09 02 00 00 ....@...........
+| 496: 00 00 00 00 00 00 00 00 00 00 64 00 00 00 00 02 ..........d.....
+| page 4 offset 1536
+| 0: 0d 00 00 00 00 02 00 00 00 00 00 00 00 00 00 fa ................
+| 16: 1f a1 07 00 00 00 00 00 01 00 00 00 00 00 00 00 ................
+| 32: 00 00 00 00 00 00 00 00 00 00 00 00 00 73 69 6d .............sim
+| 48: 70 6c 65 00 00 00 00 00 00 00 00 00 00 00 00 00 ple.............
+| 80: 00 00 00 00 00 10 00 00 00 00 00 00 01 00 00 00 ................
+| 96: 00 00 00 00 00 00 00 00 00 00 00 00 00 fe ff ff ................
+| 112: ff 00 00 00 00 00 00 00 00 00 00 00 4a 00 00 00 ............J...
+| 144: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 176: e5 ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 208: 00 00 00 00 00 00 00 00 00 00 36 36 00 00 00 00 ..........66....
+| 240: 00 00 00 6c 00 00 00 00 00 00 00 00 00 00 00 00 ...l............
+| 256: 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 320: 00 00 00 00 00 00 00 00 01 00 00 02 00 80 00 00 ................
+| 336: 00 00 00 00 00 19 08 05 17 17 17 17 65 69 67 68 ............eigh
+| 352: 74 65 69 67 68 74 73 65 76 65 6e 73 65 76 65 6e teightsevenseven
+| 368: 25 07 05 07 07 07 07 40 18 00 00 00 00 00 00 40 %......@.......@
+| 384: 18 00 20 00 00 00 40 00 14 00 00 00 00 00 00 40 .. ...@........@
+| 400: 14 00 00 00 00 00 1c 09 06 05 01 01 01 01 04 04 ................
+| 416: 03 03 07 05 05 01 01 00 00 00 00 00 00 00 00 00 ................
+| 448: 74 73 65 76 65 6e 00 80 ff ff 00 00 00 00 00 aa tseven..........
+| 464: 00 9e 00 00 00 00 00 00 00 00 00 00 00 70 6f 72 .............por
+| 480: 74 65 72 00 00 00 00 00 00 00 00 00 00 00 00 00 ter.............
+| 496: 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 00 ......).........
+| page 5 offset 2048
+| 0: 0a 00 00 00 08 01 96 00 01 fa 01 c5 01 f2 01 bc ................
+| 16: 01 dc 01 a6 01 96 01 cc 00 00 00 00 00 00 00 00 ................
+| 112: 00 00 00 09 00 00 00 00 01 00 00 00 00 00 00 00 ................
+| 160: 74 72 69 67 62 ff ff ff ff fc 00 00 00 00 00 00 trigb...........
+| 240: 00 00 00 00 00 00 00 00 00 00 ff 00 00 00 00 00 ................
+| 256: e5 ff ff ff 00 00 54 00 00 00 00 00 00 00 00 00 ......T.........
+| 304: 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 ................
+| 400: 00 00 00 00 00 09 00 00 00 00 01 00 00 00 00 00 ................
+| 448: 00 00 74 72 69 67 62 ff ff ff ff fc 00 00 07 05 ..trigb.........
+| 464: 05 01 01 09 09 02 02 19 04 05 17 17 17 17 10 65 ...............e
+| 480: 76 65 6e 65 69 67 68 74 65 40 18 00 00 00 00 01 veneighte@......
+| 496: 02 03 07 04 01 01 01 03 04 02 05 04 09 01 ff fd ................
+| end crash-6b48ba69806134.db
+}]} {}
+
+set res {1 {database disk image is malformed}}
+ifcapable oversize_cell_check {
+ set res {1 {no such table: t3}}
+}
+do_catchsql_test 4.1 {
+ PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
+ INSERT INTO t3 SELECT * FROM t2;
+} $res
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 5.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 192512 pagesize 4096 filename crash-9ae5502296c949.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 2f .....@ ......./
+| 32: 00 00 00 1b 00 00 00 13 00 00 00 03 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 06 00 00 00 01 00 00 00 00 ................
+| 64: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 96: 00 00 00 00 0d 00 00 00 04 0e e2 00 0f 96 0f 44 ...............D
+| 112: 0f 10 0e e2 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3808: 00 00 2c 04 06 17 15 11 01 41 69 6e 64 65 78 74 ..,......Aindext
+| 3824: 31 78 32 74 31 06 43 52 45 41 54 45 20 49 4e 44 1x2t1.CREATE IND
+| 3840: 45 58 20 74 31 78 32 20 4f 4e 20 74 31 28 62 29 EX t1x2 ON t1(b)
+| 3856: 32 03 06 17 15 11 01 4d 69 6e 64 65 78 74 31 78 2......Mindext1x
+| 3872: 31 74 31 05 43 52 45 41 54 45 20 49 4e 44 45 58 1t1.CREATE INDEX
+| 3888: 20 74 31 78 31 20 4f 4e 20 74 31 28 67 2b 68 2c t1x1 ON t1(g+h,
+| 3904: 6a 2c 6b 29 50 02 06 17 2b 2b 01 59 74 61 62 6c j,k)P...++.Ytabl
+| 3920: 65 73 71 6c 69 74 65 5f 73 65 71 75 65 6e 63 65 esqlite_sequence
+| 3936: 73 71 6c 69 74 65 5f 73 65 71 75 65 6e 63 65 04 sqlite_sequence.
+| 3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 73 71 6c CREATE TABLE sql
+| 3968: 69 74 65 5f 73 65 71 75 65 6e 63 65 28 6e 61 6d ite_sequence(nam
+| 3984: 65 2c 73 65 71 29 68 01 07 17 11 11 01 81 3b 74 e,seq)h.......;t
+| 4000: 61 62 6c 65 74 31 74 31 03 43 52 45 41 54 45 20 ablet1t1.CREATE
+| 4016: 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 TABLE t1(a INTEG
+| 4032: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41 ER PRIMARY KEY A
+| 4048: 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 62 2c UTOINCREMENT,.b,
+| 4064: 63 2c 64 2c 65 2c 66 2c 67 2c 68 2c 6a 2c 6b 2c c,d,e,f,g,h,j,k,
+| 4080: 6c 2c 6d 2c 6e 2c 6f 2c 70 2c 71 2c 72 2c 73 29 l,m,n,o,p,q,r,s)
+| page 2 offset 4096
+| 0: 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 ................
+| 16: 00 00 00 00 02 10 00 00 00 05 00 00 00 03 02 00 ................
+| 32: 00 00 00 05 00 00 00 03 02 00 00 00 00 05 00 00 ................
+| 48: 00 03 02 00 00 00 00 05 00 00 00 03 02 00 00 00 ................
+| 64: 00 05 00 00 00 03 02 00 00 00 00 05 00 00 00 03 ................
+| 80: 02 00 00 00 00 05 00 00 00 03 02 00 00 00 00 05 ................
+| 96: 00 00 00 03 02 00 00 00 00 05 00 00 00 03 05 00 ................
+| 112: 00 00 03 03 00 00 00 23 02 00 00 00 00 03 00 00 .......#........
+| 128: 00 23 02 00 00 00 00 03 00 00 00 23 02 00 00 00 .#.........#....
+| 144: 00 03 00 00 00 23 02 00 00 00 00 03 00 00 00 23 .....#.........#
+| 160: 05 00 00 00 06 05 00 00 00 06 02 00 00 00 00 03 ................
+| 176: 00 00 00 06 02 00 00 00 00 03 00 00 00 24 02 00 .............$..
+| 192: 00 00 00 03 00 00 00 24 02 00 00 00 00 03 00 00 .......$........
+| 208: 00 24 02 00 00 00 00 02 00 00 00 00 03 00 00 00 .$..............
+| 224: 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 $...............
+| page 3 offset 8192
+| 0: 05 00 00 00 09 0f d0 00 00 00 00 19 0f fb 0f f6 ................
+| 16: 0f f1 0f ec 0f e7 0f e2 0f dc 0f d6 0f d0 0f a0 ................
+| 32: 0f a0 0f a0 0f a0 0f a0 0f a0 0f a0 0f a0 0f a0 ................
+| 1072: 00 97 4c 0a 14 00 ae 7c 00 00 00 00 00 00 00 00 ..L....|........
+| 1088: 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 ................
+| 4000: 0f ac 00 06 00 00 00 00 00 30 00 00 00 00 00 00 .........0......
+| 4048: 00 00 00 16 81 2a 00 00 00 14 81 16 00 00 00 12 .....*..........
+| 4064: 81 02 00 00 00 10 6e 00 00 00 0e 5a 00 00 00 0c ......n....Z....
+| 4080: 46 00 00 00 0a 32 00 00 00 08 1e 00 00 00 18 0a F....2..........
+| page 4 offset 12288
+| 0: 0d 00 00 00 01 0f f7 00 0f f7 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 07 01 03 11 02 74 31 00 be ............t1..
+| page 5 offset 16384
+| 0: 0a 0f 7c 00 0a 0f 74 00 0f f9 0f eb 0f dd 0f cf ..|...t.........
+| 16: 0f c1 0f b3 0f a4 0f 94 0f 84 0f 74 0f 74 0f 74 ...........t.t.t
+| 32: 0f 74 0f 74 0f 74 0f 74 0f 74 0f 74 0f 74 00 00 .t.t.t.t.t.t.t..
+| 3952: 00 00 00 00 07 05 00 00 00 02 00 be 0f 8c 00 08 ................
+| 3968: 00 00 00 00 07 05 00 00 00 02 00 aa 0f 9c 00 08 ................
+| 3984: 00 00 00 00 07 05 00 00 00 02 00 96 0f ac 00 08 ................
+| 4000: 00 00 00 00 07 05 00 00 00 02 00 82 0f ba 00 07 ................
+| 4016: 00 00 00 06 05 00 00 00 01 6e 0f c8 00 07 00 00 .........n......
+| 4032: 00 06 05 00 00 00 01 5a 0f d6 00 07 00 00 00 06 .......Z........
+| 4048: 05 00 00 00 01 46 0f e4 00 07 00 00 00 06 05 00 .....F..........
+| 4064: 00 00 01 32 0f f2 00 07 00 00 00 06 05 00 00 00 ...2............
+| 4080: 01 1e 00 00 00 07 00 00 00 06 05 00 00 00 01 0a ................
+| page 6 offset 20480
+| 0: 02 00 00 00 01 0e 0d 00 00 00 00 24 0e 0d 0c 1a ...........$....
+| 16: 06 55 04 66 02 77 00 88 00 00 00 00 00 00 00 00 .U.f.w..........
+| 128: 00 00 00 00 00 00 00 00 97 3d 04 ae 7c 01 00 00 .........=..|...
+| 624: 00 00 00 00 00 00 21 97 3d 04 ae 7c 01 00 00 00 ......!.=..|....
+| 1120: 00 00 00 00 00 20 97 3d 04 ae 7c 01 00 00 00 00 ..... .=..|.....
+| 1616: 00 00 00 00 1f 97 3d 04 ae 7c 01 00 00 00 00 00 ......=..|......
+| 2112: 00 00 00 1e 97 3d 04 ae 7c 01 00 00 00 00 00 00 .....=..|.......
+| 2608: 00 00 1d 97 3d 04 ae 7c 01 00 00 00 00 00 00 00 ....=..|........
+| 3088: 00 00 00 00 00 00 00 00 00 00 00 00 01 f3 00 00 ................
+| 3600: 23 97 3d 04 ae 7c 01 00 00 00 00 00 00 00 00 00 #.=..|..........
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26 ...............&
+| page 8 offset 28672
+| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| 1072: 97 4d 1e 14 00 ae 7c 00 00 00 00 00 00 00 00 00 .M....|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 ................
+| page 10 offset 36864
+| 256: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| 1072: 97 4d 32 14 00 ae 7c 00 00 00 00 00 00 00 00 00 .M2...|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................
+| page 12 offset 45056
+| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| 1072: 97 4d 46 14 00 ae 7c 00 00 00 00 00 00 00 00 00 .MF...|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 ................
+| page 14 offset 53248
+| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| 1072: 97 4d 5a 14 00 ae 7c 00 00 00 00 00 00 00 00 00 .MZ...|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 ................
+| page 16 offset 61440
+| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| 1072: 97 4d 6e 14 00 ae 7c 00 00 00 00 00 00 00 00 00 .Mn...|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0b ................
+| page 18 offset 69632
+| 0: 0d 00 00 00 01 04 2f 00 04 2f 00 00 00 00 00 00 ....../../......
+| 1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 ................
+| 1072: 4d 81 02 14 00 ae 7c 00 00 00 00 00 00 00 00 00 M.....|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d ................
+| page 20 offset 77824
+| 0: 0d 00 00 00 01 04 2f 00 04 2f 00 00 00 00 00 00 ....../../......
+| 1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 ................
+| 1072: 4d 81 16 14 00 ae 7c 00 00 00 00 00 00 00 00 00 M.....|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0f ................
+| page 22 offset 86016
+| 0: 0d 00 00 00 01 04 2f 00 04 2f 00 00 00 00 00 00 ....../../......
+| 1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 ................
+| 1072: 4d 81 2a 14 00 ae 7c 00 00 00 00 00 00 00 00 00 M.*...|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 ................
+| page 24 offset 94208
+| 0: 0d 00 00 00 01 04 31 00 04 31 00 00 00 00 00 00 ......1..1......
+| 1072: 00 97 4c 0a 14 00 ae 7c 00 00 00 00 00 00 00 00 ..L....|........
+| 1088: 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 ................
+| page 25 offset 98304
+| 0: 0d 00 00 00 01 04 2f 00 04 2f 00 00 00 00 00 00 ....../../......
+| 1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 ................
+| 1072: 4d 81 3e 14 00 ae 7c 00 00 00 00 00 00 00 00 00 M.>...|.........
+| 1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 ................
+| page 26 offset 102400
+| 2512: 00 00 00 00 00 00 00 0a 00 00 00 00 00 00 00 00 ................
+| page 27 offset 106496
+| 0: 00 00 00 00 00 00 00 12 00 00 00 07 00 00 00 1d ................
+| 16: 00 00 00 09 00 00 00 1f 00 00 00 0b 00 00 00 21 ...............!
+| 32: 00 00 00 0d 00 00 00 25 00 00 00 0f 00 00 00 19 .......%........
+| 48: 00 00 00 11 00 00 00 29 00 00 00 13 00 00 00 2b .......).......+
+| 64: 00 00 00 15 00 00 00 2d 00 00 00 2e 00 00 00 17 .......-........
+| page 28 offset 110592
+| 2512: 00 00 00 00 00 00 00 1e 00 00 00 00 00 00 00 00 ................
+| page 30 offset 118784
+| 2512: 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 .......2........
+| page 32 offset 126976
+| 2512: 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 .......F........
+| page 34 offset 135168
+| 2512: 00 00 00 00 00 00 00 5a 00 00 00 00 00 00 00 00 .......Z........
+| page 35 offset 139264
+| 0: 0a 08 44 00 05 02 77 00 0e 11 0a 33 06 55 02 77 ..D...w....3.U.w
+| 16: 04 66 00 88 00 88 00 88 00 00 00 00 00 00 00 00 .f..............
+| 128: 00 00 00 00 00 00 00 00 04 66 01 ef 00 00 00 00 .........f......
+| 624: 00 00 00 00 00 00 00 97 3d 04 ae 7c 01 00 00 00 ........=..|....
+| 1120: 00 00 00 00 00 20 97 3d 04 ae 7c 01 00 00 00 00 ..... .=..|.....
+| 1616: 00 00 00 00 22 97 3d 04 ae 7c 01 00 00 00 00 00 ......=..|......
+| 2112: 00 00 00 1e 0c 22 01 ef 00 00 00 00 00 00 00 00 ................
+| 2608: 00 00 00 97 3d 04 ae 7c 01 00 00 00 00 00 00 00 ....=..|........
+| 3104: 00 1c 00 00 01 ef 00 00 00 00 00 00 00 00 00 00 ................
+| 3600: 00 97 3d 04 ae 7c 01 00 00 00 00 00 00 00 00 00 ..=..|..........
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a ................
+| page 36 offset 143360
+| 0: 0a 08 44 00 04 02 77 00 06 55 02 77 04 66 0e 11 ..D...w..U.w.f..
+| 16: 00 88 00 88 00 88 0e 11 00 00 00 00 00 00 00 00 ................
+| 128: 00 00 00 00 00 00 00 00 04 76 01 ef 00 00 00 00 .........v......
+| 624: 00 00 00 00 00 00 00 97 3e 04 ae 7c 02 00 00 00 ........>..|....
+| 1120: 00 00 00 00 00 2a 97 3e 04 ae 7c 02 00 00 00 00 .....*.>..|.....
+| 1616: 00 00 00 00 2c 97 3e 04 ae 7c 02 00 00 00 00 00 ....,.>..|......
+| 2112: 00 00 00 28 00 00 05 cd 00 00 00 00 00 00 00 00 ...(............
+| 3600: 00 97 3e 04 ae 7c 02 00 00 00 00 00 00 00 00 00 ..>..|..........
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2f .............../
+| page 38 offset 151552
+| 2512: 00 00 00 00 00 00 00 6e 00 00 00 00 00 00 00 00 .......n........
+| page 40 offset 159744
+| 2512: 00 00 00 00 00 00 00 00 82 00 00 00 00 00 00 00 ................
+| page 42 offset 167936
+| 2512: 00 00 00 00 00 00 00 00 96 00 00 00 00 00 00 00 ................
+| page 44 offset 176128
+| 2512: 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00 ................
+| page 47 offset 188416
+| 2512: 00 00 00 00 00 00 00 00 be 00 00 00 00 00 00 00 ................
+| end crash-9ae5502296c949.db
+}]} {}
+
+do_catchsql_test 5.1 {
+ INSERT INTO t1(b) VALUES(zeroblob(40000));
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 5.2 {
+ DROP INDEX t1x2;
+} {0 {}}
+
+do_catchsql_test 5.3 {
+ INSERT INTO t1(b) VALUES(zeroblob(40000));
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 6.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 20480 pagesize 4096 filename crash-d260f001fa015c.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 05 .....@ ........
+| 32: 00 00 00 00 00 ff ff f0 00 00 00 02 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 64 00 00 00 01 00 00 00 00 .......d........
+| 96: 00 00 00 00 0d 0f f8 00 04 0e ce 00 0f 4c 0f d3 .............L..
+| 112: 0e fa 0e ce 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3776: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2a 04 ..............*.
+| 3792: 06 17 13 11 01 3f 69 6e 64 65 78 74 31 62 74 31 .....?indext1bt1
+| 3808: 05 43 52 45 41 54 45 20 49 4e 44 45 58 20 74 31 .CREATE INDEX t1
+| 3824: 62 20 4f 4e 20 74 31 28 62 29 50 03 06 17 2b 2b b ON t1(b)P...++
+| 3840: 01 59 74 61 62 6c 65 73 71 6c 69 74 65 5f 73 65 .Ytablesqlite_se
+| 3856: 71 75 65 6e 63 65 73 71 6c 69 74 65 5f 73 65 71 quencesqlite_seq
+| 3872: 75 65 6e 63 65 04 43 52 45 41 54 45 20 54 41 42 uence.CREATE TAB
+| 3888: 4c 45 20 73 71 6c 69 74 65 5f 73 65 71 75 65 6e LE sqlite_sequen
+| 3904: 63 65 28 6e 61 6d 65 2c 73 65 71 29 81 04 01 07 ce(name,seq)....
+| 3920: 17 11 11 01 81 73 74 61 62 6c 65 74 31 74 31 02 .....stablet1t1.
+| 3936: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 CREATE TABLE t1(
+| 3952: 61 20 52 45 41 4c 20 4e 4f 54 20 4e 55 4c 4c 20 a REAL NOT NULL
+| 3968: 44 45 46 41 55 4c 54 28 32 35 2b 33 32 29 2c 62 DEFAULT(25+32),b
+| 3984: 20 46 4c 4f 41 54 2c 63 20 44 4f 55 42 4c 45 20 FLOAT,c DOUBLE
+| 4000: 55 4e 49 51 55 45 2c 0a 64 20 43 4c 4f 42 2c 65 UNIQUE,.d CLOB,e
+| 4016: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 4032: 20 4b 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45 KEY AUTOINCREME
+| 4048: 4e 54 29 23 02 06 17 37 11 01 00 69 6e 64 65 78 NT)#...7...index
+| 4064: 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 sqlite_autoindex
+| 4080: 5f 74 31 5f 31 74 31 05 00 00 00 08 00 00 00 00 _t1_1t1.........
+| page 2 offset 4096
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 3 offset 8192
+| 0: 0a 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0a 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| end crash-d260f001fa015c.db
+}]} {}
+
+do_catchsql_test 6.1 {
+ BEGIN;
+ INSERT INTO t1(b) VALUES(1);
+ INSERT INTO t1(b) VALUES(2);
+ COMMIT;
+} {1 {malformed database schema (t1b) - invalid rootpage}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 7.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 20480 pagesize 4096 filename crash-8391315d75edff.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 05 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 00 00 00 05 0e 55 00 0f 74 0f 3c ..........U..t.<
+| 112: 0e f9 0e d1 0e 55 00 00 00 00 00 00 00 00 00 00 .....U..........
+| 3664: 00 00 00 00 00 7a 05 07 15 11 11 08 81 63 76 69 .....z.......cvi
+| 3680: 65 77 76 31 76 31 43 52 45 41 54 45 20 56 49 45 ewv1v1CREATE VIE
+| 3696: 57 20 76 31 28 78 2c 69 29 20 41 53 0a 53 45 4c W v1(x,i) AS.SEL
+| 3712: 45 43 54 20 74 31 2e 62 2c 74 32 2e 62 20 46 52 ECT t1.b,t2.b FR
+| 3728: 4f 4d 20 74 31 2c 74 32 20 57 48 45 52 45 20 74 OM t1,t2 WHERE t
+| 3744: 31 2e 61 3d 74 32 2e 61 20 47 52 4f 55 50 20 42 1.a=t2.a GROUP B
+| 3760: 59 20 31 20 48 41 56 49 4e 47 20 74 32 2e 63 20 Y 1 HAVING t2.c
+| 3776: 4e 4f 54 20 4e 55 4c 4c 0a 4c 49 4d 49 54 20 31 NOT NULL.LIMIT 1
+| 3792: 30 26 04 06 17 11 11 01 39 74 61 62 6c 65 74 32 0&......9tablet2
+| 3808: 74 32 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 t2.CREATE TABLE
+| 3824: 74 32 28 61 2c 62 2c 63 29 41 03 06 17 15 11 01 t2(a,b,c)A......
+| 3840: 6b 69 6e 64 65 78 74 31 78 31 74 31 03 43 52 45 kindext1x1t1.CRE
+| 3856: 41 54 45 20 49 4e 44 45 58 20 74 31 78 31 20 4f ATE INDEX t1x1 O
+| 3872: 4e 20 74 31 28 64 29 20 57 48 45 52 45 20 65 65 N t1(d) WHERE ee
+| 3888: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 36 02 06 17 IS NOT NULL6...
+| 3904: 17 11 01 53 69 6e 64 65 78 74 31 61 62 63 74 31 ...Sindext1abct1
+| 3920: 03 43 52 45 41 54 45 20 49 4e 44 45 58 20 74 31 .CREATE INDEX t1
+| 3936: 61 62 63 20 4f 4e 20 74 31 28 61 2c 62 2c 63 2b abc ON t1(a,b,c+
+| 3952: 64 2b 65 29 81 09 01 07 17 11 11 01 81 7d 74 61 d+e)..........ta
+| 3968: 62 6c 65 74 31 74 31 02 43 52 45 41 54 45 20 54 blet1t1.CREATE T
+| 3984: 41 42 4c 45 20 74 31 28 61 2c 62 2c 63 2c 64 2c ABLE t1(a,b,c,d,
+| 4000: 65 2c 66 2c 67 2c 68 2c 6a 2c 6a 6a 2c 6a 6a 6a e,f,g,h,j,jj,jjj
+| 4016: 2c 6b 2c 61 61 2c 62 69 8c 63 63 2c 64 64 2c 65 ,k,aa,bi.cc,dd,e
+| 4032: 65 20 44 45 46 41 55 4c 54 20 33 2e 31 34 2c 0a e DEFAULT 3.14,.
+| 4048: 66 66 20 44 45 46 41 55 4c 54 28 27 68 69 63 63 ff DEFAULT('hicc
+| 4064: 75 70 27 29 2c 67 67 20 4e 4f 54 20 4e 55 4c 4c up'),gg NOT NULL
+| 4080: 20 44 45 46 41 55 4c 54 28 66 61 6c 73 65 29 29 DEFAULT(false))
+| page 2 offset 4096
+| 0: 0d 00 00 00 0a 0e 7b 00 0f dc 0f b6 0f 8f 0f 68 ...............h
+| 16: 0f 41 0f 1a 0e f3 0e cb 0e a3 0e 22 00 00 00 00 .A..............
+| 3696: 00 00 00 00 00 00 00 00 00 00 00 26 0a 14 01 01 ...........&....
+| 3712: 02 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19 ................
+| 3728: 08 09 5a 00 b4 40 09 1e b8 51 eb 95 1f 68 69 63 ..Z..@...Q...hic
+| 3744: 63 75 70 26 09 14 01 01 02 08 00 00 00 00 00 00 cup&............
+| 3760: 00 00 00 00 00 00 07 19 08 08 50 00 a0 40 09 1e ..........P..@..
+| 3776: b8 51 eb 85 1f 68 69 63 63 74 70 26 08 14 01 01 .Q...hicctp&....
+| 3792: 03 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19 ................
+| 3808: 08 07 46 00 8c 40 09 1e b8 51 eb 85 1f 68 69 63 ..F..@...Q...hic
+| 3824: 63 75 70 25 07 14 01 01 01 08 00 00 00 00 00 00 cup%............
+| 3840: 00 00 00 00 00 10 07 19 08 06 3c 78 40 09 1e b8 ..........<x@...
+| 3856: 51 eb 85 1f 68 69 63 63 75 70 25 06 14 01 01 01 Q...hiccup%.....
+| 3872: 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19 08 ................
+| 3888: 05 32 64 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 .2d@...Q...hiccu
+| 3904: 70 25 05 14 01 01 01 08 00 00 00 00 00 00 00 00 p%..............
+| 3920: 00 00 00 00 07 19 08 04 28 50 40 09 1e b8 51 eb ........(P@...Q.
+| 3936: 85 1f 68 69 63 63 75 70 25 04 14 01 00 f1 08 00 ..hiccup%.......
+| 3952: 00 00 00 00 00 00 00 00 00 00 00 07 19 08 03 1e ................
+| 3968: 3c 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 70 25 <@...Q...hiccup%
+| 3984: 03 14 01 01 01 08 00 00 00 00 00 00 00 00 00 00 ................
+| 4000: 00 00 07 19 08 02 14 28 40 09 1e b8 51 eb 85 1f .......(@...Q...
+| 4016: 68 69 63 63 75 70 24 02 14 09 01 01 08 00 00 00 hiccup$.........
+| 4032: 00 00 00 00 00 00 00 00 00 07 19 08 0a 14 40 09 ..............@.
+| 4048: 1e b8 51 eb 85 1f 68 69 63 63 75 70 22 01 14 08 ..Q...hiccup....
+| 4064: 08 08 08 00 00 00 00 00 00 00 00 00 00 00 00 07 ................
+| 4080: 19 08 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 70 ..@...Q...hiccup
+| page 3 offset 8192
+| 0: 0a 00 00 00 0a 0f aa 00 0f fa 0f f2 0f e9 0f e0 ................
+| 16: 0f d7 0f ce 0f c5 0f bc 0f b3 0f aa 00 00 00 00 ................
+| 4000: 00 00 00 00 00 00 00 00 00 00 08 05 01 01 00 01 ................
+| 4016: 09 5a 0a d8 05 01 01 00 01 08 50 09 08 05 01 01 .Z........P.....
+| 4032: 00 01 07 46 08 08 05 01 01 00 01 06 3c 07 08 05 ...F........<...
+| 4048: 01 01 00 01 05 32 06 08 05 01 01 00 01 04 28 05 .....2........(.
+| 4064: 08 05 01 02 60 01 03 1e 04 08 05 01 01 00 01 02 ....`...........
+| 4080: 14 03 07 05 09 01 00 01 0a 02 05 05 08 08 00 09 ................
+| page 4 offset 12288
+| 0: 0a 00 00 00 0a 0f cf 00 0f fc 0f f7 0f f2 0f ed ................
+| 16: 0f e8 0f e3 0f de 0f d9 0f d4 0f cf 00 00 00 00 ................
+| 4032: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 ................
+| 4048: 03 08 01 0a 04 03 08 01 09 04 03 08 01 08 04 03 ................
+| 4064: 08 01 07 04 03 08 01 06 04 03 08 01 05 04 03 08 ................
+| 4080: 01 04 04 03 08 01 03 04 03 08 01 02 03 03 08 09 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| end crash-8391315d75edff.db
+}]} {}
+
+do_catchsql_test 7.1 {
+ SELECT * FROM sqlite_master;
+} {1 {malformed database schema (t1x1) - invalid rootpage}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 8.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 2048 pagesize 512 filename a.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 02 00 01 01 00 40 20 20 ff ff 00 0c 00 00 00 07 .....@ ........
+| 32: 0b 00 00 00 00 00 00 00 00 00 00 08 9c 00 00 04 ................
+| 48: 00 00 00 e0 09 00 00 01 00 00 00 01 00 00 00 00 ................
+| 64: 00 00 00 00 f2 ff 00 00 00 00 00 00 00 00 00 00 ................
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c ................
+| 96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0 ..,P............
+| 112: 05 56 01 86 01 2a 01 06 00 00 00 00 00 06 00 00 .V...*..........
+| 128: 00 ff 00 00 ff ff ff e1 00 00 00 00 00 00 00 00 ................
+| 144: 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 ................
+| 160: 00 00 00 00 00 00 00 00 f2 00 00 00 00 00 00 00 ................
+| 176: 00 00 f9 ff ff ff ff ff ff ff 00 00 00 5f 00 fb ............._..
+| 192: 00 00 00 00 00 00 00 00 00 e1 ff 00 00 00 00 00 ................
+| 208: 00 00 10 00 00 00 00 00 1e 00 00 00 fe 00 00 00 ................
+| 224: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ca 00 ................
+| 240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 ...............5
+| 256: 00 00 00 00 ef ff 22 07 06 17 11 11 01 30 39 38 .............098
+| 272: 62 6c 65 74 38 38 74 04 43 52 45 41 54 45 20 54 blet88t.CREATE T
+| 288: 41 42 4c 45 20 74 34 28 87 29 2a 06 06 17 13 11 ABLE t4(.)*.....
+| 304: 01 3f 69 4f 64 65 78 74 33 78 74 40 05 43 52 45 .?iOdext3xt@.CRE
+| 320: 41 54 45 20 49 6e 44 45 58 20 74 33 78 20 4f 4e ATE InDEX t3x ON
+| 336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e t3(x).......Ein
+| 352: 00 04 00 00 34 63 64 74 3d 05 43 52 45 41 54 45 ....4cdt=.CREATE
+| 368: 20 49 4e 44 45 58 20 63 74 64 32 20 4f 4e 20 74 INDEX ctd2 ON t
+| 384: 32 28 0a 0c 44 29 28 05 06 17 11 11 01 3d 74 6c 2(..D)(......=tl
+| 400: 62 61 d4 65 33 74 33 04 43 52 45 41 54 45 20 54 ba.e3t3.CREATE T
+| 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f)
+| 432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (......=tablet2t
+| 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t
+| 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$.....
+| 480: 01 35 74 60 62 6c 65 74 31 74 31 02 43 52 45 41 .5t`blet1t1.CREA
+| 496: 54 45 20 54 41 42 4c 45 20 74 30 28 61 2c 62 29 TE TABLE t0(a,b)
+| page 2 offset 512
+| 0: 0d 00 ff 11 04 01 cf 80 01 fa 01 09 00 de 01 cf ................
+| 16: 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 ................
+| 32: 00 00 08 00 00 00 00 00 00 11 00 00 00 00 00 13 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 e0 ff ff ................
+| 64: ff d2 ff ff ff 00 f8 ff ff ff 00 00 00 00 00 00 ................
+| 80: 00 ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 96: 00 00 00 00 ff de 00 00 00 00 00 00 00 00 00 00 ................
+| 112: 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 .............@..
+| 128: 2a 00 00 00 00 00 00 00 00 f7 00 00 00 00 00 00 *...............
+| 144: 00 00 00 00 00 21 00 00 00 00 00 00 00 00 00 00 .....!..........
+| 160: 01 64 00 00 00 00 04 80 ff ff ff 00 00 00 00 00 .d..............
+| 176: 00 00 00 00 00 00 00 00 1f 00 00 00 00 00 00 00 ................
+| 192: 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 ..@.............
+| 208: b5 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 .......@........
+| 224: 00 00 00 f6 00 ee ff ff ff 00 00 00 00 00 00 00 ................
+| 272: f2 00 00 00 00 00 00 00 00 00 f9 ff ff ff ff ff ................
+| 288: ff ff 00 00 00 5f 00 fb 00 00 00 00 00 00 00 00 ....._..........
+| 320: 1e 00 00 00 fe 00 00 00 00 00 00 00 00 00 00 00 ................
+| 336: 00 00 00 00 00 00 ca 00 00 00 00 00 00 00 ff ec ................
+| 352: 00 00 00 00 00 00 00 32 00 00 00 00 ef ff 22 07 .......2........
+| 368: 06 17 11 11 01 30 74 61 62 6c 65 74 38 38 74 04 .....0tablet88t.
+| 384: 43 52 45 41 54 45 20 54 41 42 4c 45 20 8c cb d7 CREATE TABLE ...
+| 400: 78 d6 d5 f9 f9 17 13 11 01 3f 69 4f 64 65 78 74 x........?iOdext
+| 416: 33 78 74 33 05 43 52 45 41 54 45 26 49 6e 44 45 3xt3.CREATE&InDE
+| 432: 58 20 74 33 78 00 00 00 00 00 00 00 00 00 00 00 X t3x...........
+| 464: 00 00 00 00 00 13 76 65 6e 65 69 67 68 74 13 03 ......veneight..
+| 480: 03 40 07 07 15 00 54 45 20 49 4e 44 45 58 20 74 .@....TE INDEX t
+| 496: 31 63 64 20 4f 4e 20 74 ce d7 f5 f0 44 09 01 02 1cd ON t....D...
+| page 3 offset 1024
+| 0: 0d 00 00 00 48 01 54 00 01 f6 e2 ec 01 c5 01 aa ....H.T.........
+| 16: 30 34 28 87 29 32 06 f5 16 13 11 01 8e 61 24 64 04(.)2.......a$d
+| 32: 65 78 74 37 78 1f 33 6d 6d 6d 6d 6d 00 00 04 06 ext7x.3mmmmm....
+| 48: 6d 41 6d 6d 6e 6d 6d 00 00 02 00 6d 6d 6d 6d 6d mAmmnmm....mmmmm
+| 64: 15 11 01 45 45 45 45 45 45 45 45 45 45 45 45 45 ...EEEEEEEEEEEEE
+| 80: 45 45 45 45 45 45 45 45 45 45 45 00 45 63 74 64 EEEEEEEEEEE.Ectd
+| 96: 34 20 4f 4e 20 61 62 6c 5d 74 38 38 74 04 43 52 4 ON abl]t88t.CR
+| 112: 45 41 54 45 20 54 41 42 4c 45 20 74 34 28 87 29 EATE TABLE t4(.)
+| 128: 2a 06 06 13 13 01 00 00 00 4f 64 6e 78 74 33 44 *........Odnxt3D
+| 144: 74 13 05 43 52 45 41 54 45 20 49 6e 44 45 00 00 t..CREATE InDE..
+| 160: 00 00 00 00 00 00 00 f9 ff ff ff ff ff ff ff 00 ................
+| 176: 00 00 5f 00 fb 00 00 2d 00 00 00 00 00 00 00 00 .._....-........
+| 192: 00 00 00 00 00 00 00 00 00 00 00 00 00 1e 00 00 ................
+| 208: 00 fe 00 00 00 00 17 15 11 01 45 69 6e 64 65 2e ..........Einde.
+| 224: 5b 38 63 64 74 3d 05 43 52 45 41 54 45 20 49 4e [8cdt=.CREATE IN
+| 240: 44 45 58 20 63 20 64 32 20 4f 4e 20 74 32 28 0a DEX c d2 ON t2(.
+| 256: 0c 44 32 05 00 10 00 00 11 11 3d 74 6c 62 61 d4 .D2.......=tlba.
+| 272: 65 33 74 33 04 43 52 45 41 54 45 20 54 41 42 4c e3t3.CREATE TABL
+| 288: 45 20 74 36 ff ff 7f ff 43 52 45 41 54 45 20 49 E t6....CREATE I
+| 304: 73 71 6c 69 74 65 5f 73 65 71 75 65 6e 63 65 28 sqlite_sequence(
+| 320: 0a 0c 44 29 28 05 06 17 11 11 01 3d 74 6c 62 61 ..D)(......=tlba
+| 336: 20 00 00 00 33 04 43 52 45 41 54 45 20 54 41 42 ...3.CREATE TAB
+| 352: 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 28 02 LE t3(c,x,e,f)(.
+| 368: 06 00 00 7f ff 40 41 54 45 20 49 6e 44 45 58 20 .....@ATE InDEX
+| 384: 74 33 78 20 4f 4e 20 74 31 28 78 29 2e 04 06 17 t3x ON t1(x)....
+| 400: 15 11 01 45 69 6e 64 65 2e 74 34 63 64 74 3d 05 ...Einde.t4cdt=.
+| 416: 00 00 00 00 00 00 00 00 00 00 00 4d 00 00 00 00 ...........M....
+| 432: 01 00 00 00 00 00 00 05 00 00 10 00 00 00 00 00 ................
+| 448: 00 01 00 00 00 00 01 00 00 00 00 07 40 14 00 00 ............@...
+| 464: 00 00 21 00 40 18 00 00 00 00 00 00 40 1c 00 00 ..!.@.......@...
+| 480: 00 00 ff ff ff 00 00 00 5f 00 fb 00 00 2d 00 00 ........_....-..
+| 496: 00 00 00 1e 00 00 00 fe 00 00 64 00 00 ff fb 02 ..........d.....
+| page 4 offset 1536
+| 0: 0d 00 39 00 00 02 00 00 00 00 00 00 00 00 00 00 ..9.............
+| end a.db
+}]} {}
+
+set res {1 {database disk image is malformed}}
+ifcapable oversize_cell_check {
+ set res {1 {no such table: t3}}
+}
+do_catchsql_test 8.1 {
+ PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
+ INSERT INTO t3 SELECT * FROM t2;
+} $res
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 9.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 8192 pagesize 4096 filename crash-ab10597e4e1c32.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 00 00 00 01 0f d6 00 0f d6 00 00 ................
+| 4048: 00 00 00 00 00 00 28 01 06 17 11 11 01 3d 74 61 ......(......=ta
+| 4064: 62 6c 65 74 31 74 31 02 43 52 45 41 54 45 20 54 blet1t1.CREATE T
+| 4080: 41 42 4c 45 20 74 31 28 61 2c 62 2c 63 2c 64 29 ABLE t1(a,b,c,d)
+| page 2 offset 4096
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| end crash-ab10597e4e1c32.db
+}]} {}
+
+do_execsql_test 9.1 {
+ SAVEPOINT one;
+}
+do_catchsql_test 9.3 {
+ INSERT INTO t1(b,c) VALUES(5,6);
+} {1 {database disk image is malformed}}
+do_execsql_test 9.3 {
+ ROLLBACK TO one;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 10.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 180224 pagesize 4096 filename crash-41390d95d613b6.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 00 00 00 04 0e e2 00 0f 96 0f 44 ...............D
+| 112: 0f 10 0e e2 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3808: 00 00 2c 14 06 17 15 11 01 41 69 6e 64 65 78 74 ..,......Aindext
+| 3824: 41 78 33 74 31 06 43 52 45 41 54 45 20 49 4e 44 Ax3t1.CREATE IND
+| 3840: 45 58 20 74 31 78 32 20 4f 4e 20 74 31 28 62 29 EX t1x2 ON t1(b)
+| 3856: 32 03 06 17 15 11 01 4d 69 6e 64 65 78 74 31 88 2......Mindext1.
+| 3872: 31 74 31 05 43 52 45 41 54 45 20 49 4e 44 45 58 1t1.CREATE INDEX
+| 3888: 20 74 31 78 31 20 4f 4e 20 74 31 28 67 2b 68 2c t1x1 ON t1(g+h,
+| 3904: 6a 2d 6b 29 50 02 06 17 2b 2b 01 59 74 61 62 6c j-k)P...++.Ytabl
+| 3920: 65 73 71 6c 69 74 65 5e 73 65 71 74 65 6e 63 65 esqlite^seqtence
+| 3936: 73 71 6c 69 74 65 5f 73 65 71 75 65 6e 63 65 04 sqlite_sequence.
+| 3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 73 71 6c CREATE TABLE sql
+| 3968: 69 74 65 5f 73 65 71 75 65 6e 63 65 28 6e 61 6d ite_sequence(nam
+| 3984: 65 2c 73 65 71 29 68 00 07 17 11 11 01 81 3b 74 e,seq)h.......;t
+| 4000: 61 62 6c 65 74 31 74 31 03 43 52 45 41 54 45 20 ablet1t1.CREATE
+| 4016: 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 TABLE t1(a INTEG
+| 4032: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41 ER PRIMARY KEY A
+| 4048: 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 62 2c UTOINCREMENT,.b,
+| 4064: 63 2c 64 2c 65 2c 66 2c 67 2c 68 2c 6a 2c 6b 2c c,d,e,f,g,h,j,k,
+| 4080: 6c 2c 6d 2c 6e 2c 6f 2c 70 2c 71 2c 72 2c 73 29 l,m,n,o,p,q,r,s)
+| page 2 offset 4096
+| 0: 01 00 00 00 00 01 00 00 10 00 01 00 00 00 00 01 ................
+| 16: 00 00 00 00 02 00 0f f0 00 15 00 00 00 03 02 00 ................
+| 32: 00 00 d9 05 00 00 00 03 02 00 00 00 00 05 00 00 ................
+| 48: 10 03 02 00 00 00 00 05 00 00 00 03 02 00 00 00 ................
+| 64: 00 05 00 00 00 02 62 00 00 00 00 05 00 00 00 03 ......b.........
+| 80: 02 00 00 00 00 05 00 00 00 03 02 00 00 00 00 05 ................
+| 96: 00 00 00 03 02 00 00 00 00 05 00 00 00 03 05 00 ................
+| 112: 00 00 03 03 01 00 00 23 02 00 00 4f 00 02 00 00 .......#...O....
+| 128: 10 25 02 00 00 00 00 03 00 00 00 23 02 00 00 00 .%.........#....
+| 144: 00 03 00 00 00 23 02 00 00 00 00 03 00 00 00 23 .....#.........#
+| 160: 05 00 08 90 06 05 00 00 00 06 01 ff 00 00 00 03 ................
+| 176: 00 00 00 06 02 00 00 00 00 02 ff 00 00 00 00 00 ................
+| page 3 offset 8192
+| 0: 05 00 00 00 09 0f d0 00 00 00 00 19 0f fb 0f f6 ................
+| 16: 0f f1 10 ec ec e7 0f e2 0f dc 0f d6 0f 00 00 00 ................
+| 1072: 00 97 4c 0a 24 00 ae 00 00 00 00 00 00 00 00 00 ..L.$...........
+| 4048: 00 00 00 16 83 39 ff ff ff 14 81 16 00 00 00 12 .....9..........
+| 4064: 81 02 00 00 00 10 6e 00 00 00 0e 5a 00 00 00 0c ......n....Z....
+| 4080: 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F...............
+| page 4 offset 12288
+| 1072: 97 4d 32 14 00 ae 00 00 00 00 00 00 00 00 00 00 .M2.............
+| 4080: 00 00 00 00 00 00 00 07 01 03 11 02 74 31 00 bd ............t1..
+| page 5 offset 16384
+| 0: fa 0f 7c 00 0a 0f 74 00 0f f9 0f eb 0f dd 0f cf ..|...t.........
+| 16: 0f c1 0f b3 0f a4 0e 94 0f 84 0f 74 0f 74 0f 74 ...........t.t.t
+| 32: 0f 74 0f 64 0f 00 00 00 00 00 00 00 00 00 00 00 .t.d............
+| 3952: 00 00 00 00 07 05 00 00 00 02 00 be 0f 8c 10 07 ................
+| 3968: ff ff 00 00 07 05 00 00 00 02 00 aa 0f 9b f0 08 ................
+| 3984: c8 00 00 00 37 06 00 00 00 01 00 96 0f ac 00 08 ....7...........
+| 4000: 00 00 00 b3 07 15 00 10 00 02 00 82 0f ba 00 07 ................
+| 4016: 00 00 00 06 05 00 00 00 01 6e 0f c8 00 07 00 00 .........n......
+| 4032: 00 06 05 00 00 00 01 5a 03 f6 00 07 00 00 00 06 .......Z........
+| 4048: 05 00 00 00 01 46 0f e4 00 07 00 00 10 06 05 00 .....F..........
+| 4064: 00 00 01 32 10 02 00 07 00 00 00 07 05 00 00 00 ...2............
+| 4080: 01 1d ff ff ff 07 10 00 00 06 05 00 00 00 01 0a ................
+| page 6 offset 20480
+| 624: 00 00 00 00 00 21 97 00 00 00 00 00 00 00 00 00 .....!..........
+| 1120: 00 00 00 00 00 24 57 3e 00 00 00 00 00 00 00 00 .....$W>........
+| 1616: 00 00 00 00 1f 97 00 00 00 00 00 00 00 00 00 00 ................
+| 2112: 00 00 00 1e 97 3d 00 00 00 00 00 00 00 00 00 00 .....=..........
+| 2608: 00 1d 97 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| page 8 offset 28672
+| 1184: 00 00 00 00 00 00 00 00 00 97 4d 1e 13 ff ae 7c ..........M....|
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 ................
+| page 9 offset 32768
+| 256: 0d 01 c0 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| page 10 offset 36864
+| 0: 0d 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................
+| page 12 offset 45056
+| 0: 0d 00 00 00 01 04 30 00 00 00 00 00 00 00 00 00 ......0.........
+| page 14 offset 53248
+| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| 1072: 96 4d 5a 14 00 00 00 00 00 00 00 00 00 00 00 00 .MZ.............
+| page 16 offset 61440
+| 0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00 ......0..0......
+| 1072: 97 4d 6e 14 00 ae 7b ff ff ff ff 00 00 00 00 00 .Mn.............
+| page 18 offset 69632
+| 1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 ................
+| 1072: 4d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 M...............
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d ................
+| page 20 offset 77824
+| 1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 ................
+| 1072: 4d 81 16 14 00 ae 00 00 00 00 00 00 00 00 00 00 M...............
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0f ................
+| page 22 offset 86016
+| 0: 0d 00 00 00 01 04 2f 00 04 2f 01 00 00 00 00 00 ....../../......
+| 1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 ................
+| 1072: 4d 81 2a 14 00 00 00 00 00 00 00 00 00 00 00 00 M.*.............
+| page 24 offset 94208
+| 1072: 00 97 4c 0a 14 00 ae 7c 00 00 00 00 00 00 00 00 ..L....|........
+| page 25 offset 98304
+| 1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 ................
+| 1072: 4d 81 3e 14 00 ae 7c 00 00 18 ff 00 00 00 00 00 M.>...|.........
+| page 27 offset 106496
+| 0: 00 00 00 00 00 00 00 12 00 00 00 07 00 00 00 1d ................
+| 16: 00 00 00 09 00 00 00 1f 00 00 00 0b 00 00 00 21 ...............!
+| 32: 00 00 00 0d 00 10 00 25 00 00 00 0f 00 00 00 27 .......%.......'
+| 48: 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| page 32 offset 126976
+| 2512: 00 00 00 00 00 00 00 45 21 00 00 00 00 00 00 00 .......E!.......
+| page 35 offset 139264
+| 0: 00 0a 08 44 00 05 02 77 00 0e 11 0a 92 00 00 00 ...D...w........
+| 1120: 00 00 00 00 00 20 97 00 00 00 00 00 00 00 00 00 ..... ..........
+| 1616: 00 00 00 00 22 00 00 00 00 00 00 00 00 00 00 00 ................
+| 2608: 00 00 00 97 3d 04 00 00 00 00 00 00 00 00 00 00 ....=...........
+| 3104: 00 1c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3600: 00 97 3d 04 ae 7c 00 00 00 00 00 00 00 00 00 00 ..=..|..........
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a ................
+| page 36 offset 143360
+| 0: 0a 08 44 00 04 02 00 00 00 00 00 00 00 00 00 00 ..D.............
+| 1120: 00 00 00 00 00 2a 97 3e 04 00 00 00 00 00 00 00 .....*.>........
+| 1616: 00 00 00 00 2c 97 3e 00 00 00 00 00 00 00 00 00 ....,.>.........
+| 2112: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 ...............8
+| 2128: 00 00 05 cd 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3600: 00 97 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| page 38 offset 151552
+| 2464: 00 00 00 00 00 00 00 00 00 6e 00 00 00 00 00 00 .........n......
+| page 40 offset 159744
+| 2512: 00 00 00 00 00 00 00 00 82 00 00 00 00 00 00 00 ................
+| page 42 offset 167936
+| 2512: 00 00 00 00 00 00 00 96 00 00 00 00 00 00 00 00 ................
+| page 44 offset 176128
+| 2512: 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00 ................
+| end crash-41390d95d613b6.db
+}]} {}
+
+do_catchsql_test 10.1 {
+ PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
+ SELECT * FROM t1 WHERE a<='2019-05-09' ORDER BY a DESC;
+} {1 {database disk image is malformed}}
+
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 11.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 595 pagesize 512 filename x.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 02 00 00 01 00 40 20 20 00 01 00 0c 00 00 00 07 .....@ ........
+| 32: 00 00 00 05 07 a1 1f fa 00 00 00 08 00 00 00 04 ................
+| 48: 00 00 01 00 00 49 00 00 00 00 00 05 00 00 00 00 .....I..........
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c ................
+| 96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0 ..,P............
+| 112: 01 56 01 86 01 2a 01 06 00 00 62 00 00 00 00 00 .V...*....b.....
+| 128: 00 ed e2 78 74 64 33 ff 43 52 45 41 54 45 20 49 ...xtd3.CREATE I
+| 144: 4e 44 45 58 20 74 33 78 20 4f 4e 20 74 33 28 38 NDEX t3x ON t3(8
+| 160: 29 2e 04 06 17 15 11 01 45 69 6e 64 65 68 74 32 ).......Eindeht2
+| 176: 63 64 74 31 e5 43 52 45 41 54 45 20 49 4e 44 45 cdt1.CREATE INDE
+| 192: 58 20 74 32 63 c4 20 4f 4e 20 74 32 28 63 2c 64 X t2c. ON t2(c,d
+| 208: 29 28 05 06 17 01 11 11 3d 74 61 6c 36 74 62 74 )(......=tal6tbt
+| 224: 65 32 04 43 52 45 41 54 45 20 54 41 42 4c 45 20 e2.CREATE TABLE
+| 240: 74 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 t...............
+| 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 30 e8 03 .............0..
+| 272: 62 6c 65 74 34 74 35 02 43 52 45 41 54 45 20 54 blet4t5.CREATE T
+| 288: 41 42 4c 45 20 74 34 28 94 29 2a 06 06 17 13 11 ABLE t4(.)*.....
+| 304: 01 3f 69 33 74 6e 65 78 78 74 64 33 ff 43 52 45 .?i3tnexxtd3.CRE
+| 320: 41 54 45 20 49 4e 44 45 58 20 74 33 78 20 4f 4e ATE INDEX t3x ON
+| 336: 20 74 31 28 38 29 2e 04 06 17 15 11 01 45 69 6e t1(8).......Ein
+| 352: 64 65 68 74 32 63 64 74 31 e5 43 52 45 41 54 45 deht2cdt1.CREATE
+| 368: 20 49 4e 44 45 58 20 74 32 63 c4 20 4f 4e 20 74 INDEX t2c. ON t
+| 384: 32 28 63 2c 64 29 28 05 06 17 01 11 11 3d 74 61 2(c,d)(......=ta
+| 400: 6c 32 74 62 74 65 32 04 43 52 45 41 54 45 20 54 l2tbte2.CREATE T
+| 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f)
+| 432: 28 02 06 17 11 11 01 3d 74 61 9e 93 65 74 32 74 (......=ta..et2t
+| 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t
+| 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$.....
+| 480: 01 35 55 61 62 6c 88 74 31 74 31 02 43 52 45 41 .5Uabl.t1t1.CREA
+| 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29 TE TABLE t1(a,b)
+| page 2 offset 512
+| 0: 0d 00 00 00 0d 25 00 01 cf 00 01 fa 01 f3 01 de .....%..........
+| 16: 01 00 00 00 fd 00 00 0d 00 00 00 00 45 20 54 41 ............E TA
+| 32: 42 4c 45 20 74 34 28 94 29 2a 06 06 17 13 11 01 BLE t4(.)*......
+| 48: 3f 69 33 74 6e 65 78 78 74 64 33 ff 43 52 45 a0 ?i3tnexxtd3.CRE.
+| 64: a0 a0 a0 a0 a0 a0 a0 a0 a0 a0 a0 a0 74 13 11 01 ............t...
+| 80: 49 45 74 00 00 00 00 00 00 00 00 00 00 00 00 00 IEt.............
+| end x.db
+}]} {}
+
+do_catchsql_test 11.1 {
+ PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
+ DELETE FROM t3 WHERE x IN (SELECT x FROM t4);
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 12.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 12288 pagesize 4096 filename crash-e6d070858a3a85.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 00 00 00 02 0f 8f 00 0f bf 0f 8f ................
+| 3968: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2e ................
+| 3984: 02 06 17 15 11 01 45 69 6e 64 65 78 74 31 63 62 ......Eindext1cb
+| 4000: 74 31 03 43 52 45 41 54 45 20 49 4e 44 45 58 20 t1.CREATE INDEX
+| 4016: 74 31 63 62 20 4f 4e 20 74 31 28 63 2c 62 29 3f t1cb ON t1(c,b)?
+| 4032: 01 06 17 11 11 01 6b 74 61 62 6c 65 74 31 74 31 ......ktablet1t1
+| 4048: 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 .CREATE TABLE t1
+| 4064: 28 61 20 49 4e 54 2c 20 62 20 49 4e 54 2c 20 43 (a INT, b INT, C
+| 4080: 20 49 4e 54 20 44 45 46 41 55 4c 54 20 31 36 29 INT DEFAULT 16)
+| page 2 offset 4096
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4000: 00 00 00 00 00 00 00 00 07 0b 04 01 01 01 63 63 ..............cc
+| 4016: 11 05 0a 04 00 00 01 11 05 09 04 08 08 01 0f 05 ................
+| 4032: 08 04 00 00 01 01 56 07 04 01 08 01 07 10 07 06 ......V.........
+| 4048: 14 01 01 01 06 08 10 06 05 04 f5 00 01 05 10 07 ................
+| 4064: 04 04 01 01 01 04 03 10 06 03 04 01 09 01 03 10 ................
+| 4080: 06 02 04 01 00 01 02 10 06 01 04 09 01 01 02 10 ................
+| page 3 offset 8192
+| 0: 0a 00 00 00 0b 0f b0 00 0f f9 0f f2 0f eb 0f e4 ................
+| 16: 0f dd 0f d6 0f 9f 0f c7 0f be 00 00 00 00 00 00 ................
+| 4016: 07 04 01 01 01 11 e2 0b 06 04 91 00 01 11 0a 07 ................
+| 4032: 04 01 01 01 10 08 06 07 04 01 01 01 10 04 04 06 ................
+| 4048: 04 01 01 09 10 02 06 04 01 0a 01 10 00 00 00 00 ................
+| end crash-e6d070858a3a85.db
+}]} {}
+
+do_catchsql_test 12.1 {
+ SELECT CAST((SELECT b FROM t1 WHERE 16=c) AS int) FROM t1 WHERE 16=c;
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 13.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 8192 pagesize 4096 filename crash-81dd2952aef34f.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 02 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 00 00 00 01 0f c4 00 0f c4 00 00 ................
+| 4032: 00 00 00 00 3a 11 06 17 11 11 01 61 74 61 62 6c ....:......atabl
+| 4048: 65 74 31 74 31 02 43 52 45 41 54 45 20 54 41 42 et1t1.CREATE TAB
+| 4064: 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 LE t1(a INTEGER
+| 4080: 50 52 49 4d 41 52 59 20 4b 45 59 2c 62 2c 63 29 PRIMARY KEY,b,c)
+| page 2 offset 4096
+| 0: 0d 07 70 00 02 0f eb 00 0f fa 00 00 00 00 00 00 ..p.............
+| 4064: 00 00 00 00 00 00 00 00 00 00 00 05 bf ff ff ff ................
+| 4080: ff ff ff ff ff 04 00 01 00 02 04 01 00 00 00 00 ................
+| end crash-81dd2952aef34f.db
+}]} {}
+
+do_catchsql_test 13.1 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x-2019 FROM c WHERE x<2)
+ INSERT INTO t1(b,c) SELECT last_insert_rowid(), x FROM c;
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 14.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 512 pagesize 65536 filename clusterfuzz-testcase-minimized-sqlite3_dbfuzz2_fuzzer-4806406219825152
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 00 01 02 01 00 40 20 20 00 63 2e 78 00 00 00 07 .....@ .c.x....
+| 32: 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 01 00 35 05 43 00 04 00 00 00 ........5.C.....
+| 80: 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 0c ................
+| 96: 00 2e 2c 50 0d 00 00 00 03 00 00 00 01 da 01 b0 ..,P............
+| 112: 01 56 01 86 01 2a 01 02 00 00 00 00 00 00 00 1c .V...*..........
+| 128: 00 38 80 b2 e6 0e 00 00 00 00 00 00 00 00 00 10 .8..............
+| 144: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ................
+| 160: 00 00 00 00 00 00 00 00 00 00 00 00 45 20 54 41 ............E TA
+| 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 35 74 61 .............5ta
+| 272: 62 6c 00 10 00 00 34 07 43 52 54 45 20 54 41 42 bl....4.CRTE TAB
+| 288: 4c 45 20 74 33 28 63 2e 78 2c 65 2c 66 15 28 3a LE t3(c.x,e,f.(:
+| 304: 06 17 11 11 01 65 78 8c cc 87 85 35 05 43 72 45 .....ex....5.CrE
+| 320: 41 54 48 20 49 4e 44 45 58 20 74 33 78 20 4f 4e ATH INDEX t3x ON
+| 336: 20 74 33 28 78 39 2e 04 06 17 15 11 01 45 69 6e t3(x9.......Ein
+| 352: 64 65 78 74 32 63 64 74 32 05 43 52 45 41 54 45 dext2cdt2.CREATE
+| 368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74 INDEX t2cd ON t
+| 384: 32 28 63 2a 44 29 28 05 fa e8 ee ed 01 3d 74 63 2(c*D)(......=tc
+| 400: 62 6c 65 74 33 74 33 07 43 52 45 41 54 45 20 54 blet3t3.CREATE T
+| 416: 41 42 4c 45 20 74 33 28 63 2e 78 2c 65 2c 66 15 ABLE t3(c.x,e,f.
+| 432: 28 3a 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (:.....=tablet2t
+| 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t
+| 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$.....
+| 480: 01 35 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .5tablet1t1.CREA
+| 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 63 29 TE TABLE t1(a,c)
+| end clusterfuzz-testcase-minimized-sqlite3_dbfuzz2_fuzzer-4806406219825152
+}]} {}
+
+extra_schema_checks 0
+do_catchsql_test 14.1 {
+ PRAGMA integrity_check;
+} {1 {database disk image is malformed}}
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable altertable {
+ do_catchsql_test 14.2 {
+ ALTER TABLE t1 RENAME TO alkjalkjdfiiiwuer987lkjwer82mx97sf98788s9789s;
+ } {1 {database disk image is malformed}}
+}
+extra_schema_checks 1
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 15.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-3afa1ca9e9c1bd.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 00 00 00 06 0e 88 00 0f b8 0f 6d ...............m
+| 112: 0f 3a 0f 0b 0e d5 0e 88 01 00 00 00 00 00 00 00 .:..............
+| 3712: 00 00 00 00 00 00 00 00 4b 06 06 17 25 25 01 5b ........K...%%.[
+| 3728: 74 61 62 6c 65 73 71 6c 69 74 65 5f 73 74 61 74 tablesqlite_stat
+| 3744: 31 73 71 6c 69 74 65 5f 73 74 61 74 31 07 43 52 1sqlite_stat1.CR
+| 3760: 45 41 54 45 20 54 41 42 4c 45 20 73 71 6c 69 74 EATE TABLE sqlit
+| 3776: 65 5f 73 74 61 74 31 28 74 62 6c 2c 69 64 78 2c e_stat1(tbl,idx,
+| 3792: 73 74 61 74 29 34 05 06 17 13 11 01 53 69 6e 64 stat)4......Sind
+| 3808: 65 78 63 31 63 63 31 06 43 52 45 41 54 45 20 55 exc1cc1.CREATE U
+| 3824: 4e 49 51 55 45 20 49 4e 44 45 58 20 63 31 63 20 NIQUE INDEX c1c
+| 3840: 4f 4e 20 63 31 28 63 2c 20 62 29 2d 04 06 17 13 ON c1(c, b)-....
+| 3856: 11 01 45 69 6e 64 65 78 63 31 64 63 31 05 43 52 ..Eindexc1dc1.CR
+| 3872: 45 41 54 45 20 49 4e 44 45 58 20 63 31 64 20 4f EATE INDEX c1d O
+| 3888: 4e 20 63 31 28 64 2c 20 62 29 31 03 06 17 13 11 N c1(d, b)1.....
+| 3904: 01 4d 69 6e 64 65 78 62 31 63 62 31 05 43 52 45 .Mindexb1cb1.CRE
+| 3920: 41 54 45 20 55 4e 49 51 55 45 20 49 4e 44 45 58 ATE UNIQUE INDEX
+| 3936: 20 62 31 63 20 4f 4e 20 62 31 28 63 29 49 02 06 b1c ON b1(c)I..
+| 3952: 17 11 11 0f 7f 74 61 62 6c 65 63 31 63 31 03 43 .....tablec1c1.C
+| 3968: 52 45 41 54 45 20 54 41 42 4c 45 20 63 31 28 61 REATE TABLE c1(a
+| 3984: 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59 INT PRIMARY KEY
+| 4000: 2c 20 62 2c 20 63 2c 20 64 29 20 57 49 54 48 4f , b, c, d) WITHO
+| 4016: 55 54 20 52 4f 57 49 44 46 01 06 17 11 11 01 79 UT ROWIDF......y
+| 4032: 74 61 62 6c 65 62 31 62 31 02 43 52 45 41 54 45 tableb1b1.CREATE
+| 4048: 20 54 41 42 4c 45 20 62 31 28 61 20 49 4e 54 20 TABLE b1(a INT
+| 4064: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 20 PRIMARY KEY, b,
+| 4080: 63 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 c) WITHOUT ROWID
+| page 2 offset 4096
+| 0: 0a 00 00 00 07 0f ca 00 0f fa 0f f2 0f ea 0f e2 ................
+| 16: 0f da 00 00 00 01 00 00 00 00 00 00 00 00 00 00 ................
+| 4032: 00 00 00 00 00 00 00 00 00 00 07 04 01 0f 01 06 ................
+| 4048: 67 07 07 04 01 0f 01 06 66 06 07 04 01 0f 01 05 g.......f.......
+| 4064: 65 05 07 04 01 0f 01 04 64 04 07 04 01 0f 01 03 e.......d.......
+| 4080: 63 03 07 04 01 0f 01 02 62 0f 05 04 09 0f 09 61 c.......b......a
+| page 3 offset 8192
+| 0: 0a 00 00 00 07 0f bd 00 0f f9 0f ef 0f e5 0f db ................
+| 16: 0f d1 0f c7 0f bd 00 00 00 00 01 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 09 05 01 ................
+| 4032: 0f 01 01 07 61 07 07 09 05 01 0f 01 01 06 61 06 ....a.........a.
+| 4048: 06 09 05 01 0f 01 01 05 61 05 05 09 05 01 0f 01 ........a.......
+| 4064: 01 04 61 04 04 09 05 01 0f 01 01 03 61 03 03 09 ..a.........a...
+| 4080: 05 01 0f 01 01 02 61 0f 02 06 05 09 0f 09 09 61 ......a........a
+| page 4 offset 12288
+| 0: 0a 00 00 00 07 0f d8 00 0f fc 0f f0 0f ea 0f e4 ................
+| 16: 0f de 0f d8 0f f6 00 00 00 00 00 00 00 00 00 00 ................
+| 4048: 00 00 00 00 00 00 00 00 05 03 01 01 07 07 05 03 ................
+| 4064: 01 01 06 06 05 03 01 01 05 05 05 03 01 01 04 04 ................
+| 4080: 05 03 01 01 03 03 05 03 01 01 0f 02 03 03 09 09 ................
+| page 5 offset 16384
+| 0: 0a 00 00 00 07 0f ca 00 0f fa 0f f2 0f ea 0f 00 ................
+| 4032: 00 00 00 00 00 00 00 00 00 00 07 04 01 0f 01 07 ................
+| 4048: 61 07 07 04 01 0f 01 06 61 06 07 04 01 0f 01 05 a.......a.......
+| 4064: 61 05 07 04 01 1f 01 04 61 04 07 04 01 0f 01 03 a.......a.......
+| 4080: 61 03 07 04 01 0f 01 02 61 02 05 04 09 0f 09 61 a.......a......a
+| page 6 offset 20480
+| 0: 0a 00 00 00 07 0f ca 00 0f fa 0f ea 0f e2 00 00 ................
+| 4032: 00 00 00 00 00 00 00 00 00 00 07 04 01 0f 01 07 ................
+| 4048: 61 07 07 04 01 0f 01 06 61 06 07 04 01 0f 01 05 a.......a.......
+| 4064: 61 05 07 04 01 0f 01 04 61 04 07 04 01 0f 01 03 a.......a.......
+| 4080: 61 03 07 04 01 0f 01 0f 61 02 05 04 09 0f 09 61 a.......a......a
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f 1c 00 0f f0 0f e0 0f d3 0f c5 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0b 05 04 11 11 13 62 31 ..............b1
+| 4032: 62 31 37 20 31 0c 04 04 11 13 13 62 31 62 31 63 b17 1......b1b1c
+| 4048: 37 20 31 0b 03 04 11 11 13 63 31 63 31 37 20 31 7 1......c1c17 1
+| 4064: 0e 02 04 11 13 07 63 31 63 31 64 37 20 31 20 31 ......c1c1d7 1 1
+| 4080: 0e 01 04 11 13 17 63 31 63 31 63 37 20 31 00 00 ......c1c1c7 1..
+| end crash-3afa1ca9e9c1bd.db
+}]} {}
+
+extra_schema_checks 0
+do_execsql_test 15.1 {
+ PRAGMA cell_size_check = 0;
+ UPDATE c1 SET c= NOT EXISTS(SELECT 1 FROM c1 ORDER BY (SELECT 1 FROM c1 ORDER BY a)) +10 WHERE d BETWEEN 4 AND 7;
+} {}
+extra_schema_checks 1
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 16.0 {
+ CREATE TABLE t1(w, x, y, z, UNIQUE(w, x), UNIQUE(y, z));
+ INSERT INTO t1 VALUES(1, 1, 1, 1);
+
+ CREATE TABLE t1idx(x, y, i INTEGER, PRIMARY KEY(x)) WITHOUT ROWID;
+ INSERT INTO t1idx VALUES(10, NULL, 5);
+
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET rootpage = (
+ SELECT rootpage FROM sqlite_master WHERE name='t1idx'
+ ) WHERE type = 'index';
+}
+
+extra_schema_checks 0
+db close
+sqlite3 db test.db
+extra_schema_checks 1
+
+do_catchsql_test 16.1 {
+ PRAGMA writable_schema = ON;
+ INSERT INTO t1(rowid, w, x, y, z) VALUES(5, 10, 11, 10, NULL);
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+# Test that corruption is reported from within a checkpoint if the
+# expected final size of the database (according to the last commit
+# frame in the wal file) is greater than the combined initial sizes
+# of the database and wal file.
+#
+if {[wal_is_capable]} {
+ reset_db
+ do_execsql_test 17.0 {
+ CREATE TABLE t1(o INTEGER PRIMARY KEY, t UNIQUE);
+ INSERT INTO t1(t) VALUES(randomblob(123));
+ INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
+ INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
+ INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
+ INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
+ INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
+ INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
+ INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
+ INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
+ INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
+
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(-1, 'b');
+ } {wal}
+
+ do_test 17.1 {
+ set fd [open test.db r+]
+ chan truncate $fd 2048
+ file size test.db
+ } {2048}
+
+ do_catchsql_test 17.2 {
+ PRAGMA wal_checkpoint
+ } {1 {database disk image is malformed}}
+
+ do_test 17.3 {
+ close $fd
+ } {}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 18.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 12288 pagesize 4096 filename crash-40d5739835cbdb.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 00 00 00 02 0f 4e 00 0f a2 0f 4e ..........N....N
+| 3904: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 02 ..............R.
+| 3920: 07 17 11 11 01 81 0f 74 61 62 6c 65 74 32 74 32 .......tablet2t2
+| 3936: 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 32 .CREATE TABLE t2
+| 3952: 28 61 20 49 4e 54 2c 20 62 20 49 4e 54 45 47 45 (a INT, b INTEGE
+| 3968: 52 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28 61 R, PRIMARY KEY(a
+| 3984: 2c 62 29 29 20 57 49 54 48 4f 55 54 20 52 4f 57 ,b)) WITHOUT ROW
+| 4000: 49 44 5c 01 07 16 11 11 01 81 23 74 61 62 6c 65 ID........#table
+| 4016: 74 31 74 31 02 43 52 45 41 54 45 20 54 41 42 4c t1t1.CREATE TABL
+| 4032: 45 20 74 31 28 61 20 49 4e 54 20 50 52 49 4d 41 E t1(a INT PRIMA
+| 4048: 52 59 20 4b 45 59 2c 20 62 20 54 45 58 54 2c 20 RY KEY, b TEXT,
+| 4064: 63 20 54 45 58 54 2c 20 64 20 49 4e 54 45 47 45 c TEXT, d INTEGE
+| 4080: 52 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 R) WITHOUT ROWID
+| page 2 offset 4096
+| 0: 0a 00 00 00 06 0f a7 00 0f f4 0f e5 0f d5 0f c5 ................
+| 16: 0f b6 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4000: 00 00 00 00 00 00 00 0f 05 01 15 13 01 06 65 7f ..............e.
+| 4016: 25 6e 73 69 78 06 0e 05 01 13 15 03 b5 6f 64 64 %nsix........odd
+| 4032: 66 69 76 65 05 0f 05 01 15 15 01 04 65 76 65 61 five........evea
+| 4048: e6 6f 75 82 04 0f 05 01 13 17 01 03 6f 64 64 74 .ou.........oddt
+| 4064: 68 72 61 15 03 0e 05 01 15 12 01 02 64 76 64 6e hra.........dvdn
+| 4080: 74 77 6f 02 00 00 00 00 00 00 00 00 00 00 00 00 two.............
+| page 3 offset 8192
+| 2816: 00 00 00 00 00 00 00 00 00 00 00 06 03 02 01 00 ................
+| 2832: c8 07 06 03 02 01 00 c7 11 06 03 02 01 02 a6 52 ...............R
+| 2848: 06 d5 02 01 10 c5 1b 06 03 02 00 ef c4 53 06 03 .............S..
+| 2864: 02 01 00 c3 22 06 04 02 01 00 c2 26 06 03 02 01 ...........&....
+| 2880: 00 c2 1e 02 b3 02 01 00 c0 3a 06 03 3c 01 00 bf .........:..<...
+| 2896: 2c 06 03 02 01 00 be 27 00 83 02 01 01 bd 15 06 ,......'........
+| 2912: 03 02 01 00 bc 21 06 03 02 01 00 bb 54 16 13 02 .....!......T...
+| 2928: 01 09 9a 0a 06 03 02 01 00 b9 53 06 03 02 01 00 ..........S.....
+| 2944: b8 52 06 13 02 01 00 b7 1e 06 03 02 01 00 b6 34 .R.............4
+| 2960: 06 13 02 01 00 b5 3a 05 f3 12 01 00 b4 45 05 03 ......:......E..
+| 2976: 02 00 00 b4 6f 06 03 02 01 00 b2 03 06 03 02 01 ....o...........
+| 2992: 00 b1 63 06 03 02 01 00 b0 24 06 03 02 01 00 9f ..c......$......
+| 3008: ac 06 03 02 01 00 a2 2f 07 03 02 01 01 ad 21 06 ......./......!.
+| 3024: 03 02 01 fb cd 5b 06 c0 01 f1 00 ab 23 06 03 02 .....[......#...
+| 3040: 01 00 aa 5b 06 03 02 01 00 a3 ce 06 02 03 01 00 ...[............
+| 3056: a8 0e 06 03 02 01 00 a7 0c 06 02 f1 01 00 a6 0d ................
+| 3072: 06 03 02 01 00 95 25 06 03 02 01 00 a4 17 06 03 ......%.........
+| 3088: 02 01 00 a3 09 06 03 02 01 00 a2 51 06 03 02 02 ...........Q....
+| 3104: 00 a1 40 06 01 e2 00 00 a0 4b 06 13 02 00 00 9e ..@......K......
+| 3120: 5d 06 03 02 01 10 9e 81 06 03 02 01 00 9d 42 06 ].............B.
+| 3136: 03 69 01 00 9c 48 06 03 02 01 00 9b 48 06 03 01 .i...H......H...
+| 3152: 01 00 9a 09 06 03 02 01 00 99 2f 06 03 02 01 00 ........../.....
+| 3168: 98 3a 06 03 02 01 00 97 24 06 03 02 01 00 96 4a .:......$......J
+| 3184: 06 03 02 11 00 f9 50 02 93 02 01 00 94 2f 06 03 ......P....../..
+| 3200: 02 11 04 93 1a 06 03 01 04 e0 92 1a 06 03 02 01 ................
+| 3216: 00 91 27 06 03 02 01 00 90 23 06 03 02 01 00 8f ..'......#......
+| 3232: 3b 06 03 02 01 00 8e 46 06 16 02 01 00 8d 1d 07 ;......F........
+| 3248: 23 12 01 00 8c 5a 06 03 02 01 00 8a 39 06 03 02 #....Z......9...
+| 3264: 00 ff 84 b5 06 03 02 01 00 89 07 06 03 02 11 00 ................
+| 3280: 88 02 06 03 02 01 00 87 19 06 03 02 01 00 86 4d ...............M
+| 3296: 06 13 12 00 00 85 4b 06 03 02 01 00 84 37 06 13 ......K......7..
+| 3312: 02 01 00 83 2c 06 03 02 01 00 81 60 06 13 02 11 ....,......`....
+| 3328: 00 81 3b 06 03 02 01 0a b0 5a 06 03 01 01 7f 22 ..;......Z......
+| 3344: 05 03 01 01 7e 21 05 03 01 01 7d 0b 15 03 01 02 ....~!..........
+| 3360: 7b 08 05 03 06 91 7b 22 05 03 01 01 7a 58 05 03 ............zX..
+| 3376: 01 01 7a 4f 05 03 01 01 78 49 05 03 01 01 77 16 ..zO....xI....w.
+| 3392: 05 03 01 01 76 5f 05 03 01 01 75 0f 05 03 01 01 ....v_....u.....
+| 3408: 74 2f 05 03 01 01 3f 1f 05 03 01 02 72 14 05 03 t/....?.....r...
+| 3424: 00 f1 71 08 05 03 01 01 70 0c 05 03 01 47 7f 29 ..q.....p....G.)
+| 3440: 05 03 01 01 6e 57 05 03 01 01 6d 33 05 13 00 f1 ....nW....m3....
+| 3456: 6c 0b 05 03 01 01 6b 49 05 03 01 01 69 05 05 03 l.....kI....i...
+| 3472: 01 02 ed 23 00 00 01 00 00 00 00 00 00 00 00 00 ...#............
+| end crash-40d5739835cbdb.db
+}]} {}
+
+ifcapable json1 {
+do_catchsql_test 18.1 {
+ SELECT
+ json_group_array(c) OVER win4
+ FROM t1
+ WINDOW win4 AS (
+ ORDER BY a COLLATE nocase RANGE BETWEEN 1.0 PRECEDING AND CURRENT ROW
+ )
+} {1 {JSON cannot hold BLOB values}}
+} ;# ifcapable json1
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 19.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 20480 pagesize 4096 filename crash-f022eb0ce64d27.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 05 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0f f8 00 04 0e d2 00 0f 08 0f d3 ................
+| 112: 0f ae 0e d2 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3792: 00 00 34 04 06 17 0f 11 01 57 69 6e 64 65 78 61 ..4......Windexa
+| 3808: 74 31 05 43 52 45 41 54 45 20 55 4e 49 51 55 45 t1.CREATE UNIQUE
+| 3824: 20 49 4e 44 45 58 20 61 20 4f 4e 20 74 31 28 61 INDEX a ON t1(a
+| 3840: 2c 20 30 20 7c 20 61 29 81 23 01 07 17 11 11 01 , 0 | a).#......
+| 3856: 82 31 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .1tablet1t1.CREA
+| 3872: 54 45 20 54 41 42 4c 45 20 74 31 28 0a 20 20 20 TE TABLE t1(.
+| 3888: 20 67 63 62 20 41 53 20 28 62 2a 31 29 2c 0a 20 gcb AS (b*1),.
+| 3904: 20 20 20 61 20 49 34 54 45 47 45 52 20 50 52 49 a I4TEGER PRI
+| 3920: 4d 41 52 59 20 4b 45 59 2c 0a 20 20 20 20 67 63 MARY KEY,. gc
+| 3936: 63 20 41 53 20 28 74 32 2b 30 29 2c 0a 20 20 20 c AS (t2+0),.
+| 3952: 20 62 20 55 4e 49 51 55 45 2c 0a 20 20 20 20 67 b UNIQUE,. g
+| 3968: 63 61 20 41 53 20 28 31 2a 61 2b 30 29 2c 0a 20 ca AS (1*a+0),.
+| 3984: 20 20 20 74 32 20 55 4e 49 51 55 45 0a 20 20 29 t2 UNIQUE. )
+| 4000: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 23 03 WITHOUT ROWID#.
+| 4016: 06 17 37 11 01 00 69 6e 64 65 78 73 71 6c 69 74 ..7...indexsqlit
+| 4032: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 33 e_autoindex_t1_3
+| 4048: 74 31 02 23 02 06 17 37 11 01 00 69 6e 64 65 78 t1.#...7...index
+| 4064: 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 sqlite_autoindex
+| 4080: 5f 74 31 5f 32 74 31 02 00 00 00 08 00 00 00 00 _t1_2t1.........
+| page 2 offset 4096
+| 0: 0a 00 00 00 05 0f d8 00 0f f8 0f f8 9f e8 0f e0 ................
+| 16: 0f d8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4048: 00 00 00 00 00 00 00 00 07 04 01 02 00 0f 13 88 ................
+| 4064: 07 04 01 02 00 0e 0f a0 07 04 01 02 00 0d 0b b8 ................
+| 4080: 07 04 01 02 00 0c 07 d0 07 04 01 02 00 0b 03 e8 ................
+| page 5 offset 16384
+| 0: 0a 00 00 00 05 0f e2 00 0f fa 0f f4 0f ee 0f e8 ................
+| 16: 0f e2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4064: 00 00 05 03 01 01 0f 0f 05 03 01 01 0e 0e 05 03 ................
+| 4080: 01 01 0d 0d 05 03 01 01 0c 0c 05 03 01 01 0b 0b ................
+| end crash-f022eb0ce64d27.db
+}]} {}
+
+do_execsql_test 19.1 {
+ PRAGMA writable_schema=ON;
+}
+do_catchsql_test 19.2 {
+ UPDATE t1 SET a=1;
+} {1 {database disk image is malformed}}
+
+reset_db
+do_execsql_test 19.3 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INTEGER, d TEXT);
+ CREATE INDEX i1 ON t1((NULL));
+ INSERT INTO t1 VALUES(1, NULL, 1, 'text value');
+ PRAGMA writable_schema = on;
+ UPDATE sqlite_schema SET
+ sql = 'CREATE INDEX i1 ON t1(b, c, d)',
+ tbl_name = 't1',
+ type='index'
+ WHERE name='i1';
+}
+db close
+sqlite3 db test.db
+do_catchsql_test 19.4 {
+ PRAGMA integrity_check;
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/corruptM.test b/test/corruptM.test
new file mode 100644
index 0000000..15fc8d6
--- /dev/null
+++ b/test/corruptM.test
@@ -0,0 +1,186 @@
+# 2019-08-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.
+#
+#***********************************************************************
+#
+# Check to ensure that the type, name, and tbl_name fields of the
+# sqlite_master table are validated and errors are reported if they
+# are inconsistent with the sql.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix corruptM
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+proc open_db2_and_catchsql {sql} {
+ set rc [catch { sqlite3 db2 test.db } msg]
+ if {$rc} {
+ return [list $rc $msg]
+ }
+ set res [catchsql $sql db2]
+ db2 close
+ set res
+}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test corruptM-100 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(111,222,333);
+ CREATE INDEX i1 ON t1(b);
+ CREATE VIEW v2 AS SELECT 15,22;
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN SELECT 5; END;
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 t1 | index i1 t1 | view v2 v2 | trigger r1 t1 |}
+do_execsql_test corruptM-101 {
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET tbl_name=NULL WHERE name='t1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 {} | index i1 t1 | view v2 v2 | trigger r1 t1 |}
+do_test corruptM-102 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ }
+} {1 {malformed database schema (t1)}}
+
+do_execsql_test corruptM-110 {
+ UPDATE sqlite_master SET tbl_name='tx' WHERE name='t1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 tx | index i1 t1 | view v2 v2 | trigger r1 t1 |}
+do_test corruptM-111 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ }
+} {1 {malformed database schema (t1)}}
+do_execsql_test corruptM-112 {
+ UPDATE sqlite_master SET tbl_name='t1', type='tabl' WHERE name='t1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {tabl t1 t1 | index i1 t1 | view v2 v2 | trigger r1 t1 |}
+do_test corruptM-113 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ }
+} {1 {malformed database schema (t1)}}
+do_execsql_test corruptM-114 {
+ UPDATE sqlite_master SET tbl_name='t9',type='table',name='t9'WHERE name='t1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t9 t9 | index i1 t1 | view v2 v2 | trigger r1 t1 |}
+do_test corruptM-114 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ }
+} {1 {malformed database schema (t9)}}
+
+do_execsql_test corruptM-120 {
+ UPDATE sqlite_master SET name='t1',tbl_name='T1' WHERE name='t9';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 T1 | index i1 t1 | view v2 v2 | trigger r1 t1 |}
+do_test corruptM-121 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ SELECT * FROM t1, v2;
+ }
+} {0 {ok 111 222 333 15 22}}
+
+do_execsql_test corruptM-130 {
+ UPDATE sqlite_master SET type='view' WHERE name='t1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {view t1 T1 | index i1 t1 | view v2 v2 | trigger r1 t1 |}
+do_test corruptM-131 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ SELECT * FROM t1, v2;
+ }
+} {1 {malformed database schema (t1)}}
+
+do_execsql_test corruptM-140 {
+ UPDATE sqlite_master SET type='table', tbl_name='t1' WHERE name='t1';
+ UPDATE sqlite_master SET tbl_name='tx' WHERE name='i1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 t1 | index i1 tx | view v2 v2 | trigger r1 t1 |}
+do_test corruptM-141 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ SELECT * FROM t1, v2;
+ }
+} {1 {malformed database schema (i1)}}
+
+do_execsql_test corruptM-150 {
+ UPDATE sqlite_master SET type='table', tbl_name='t1' WHERE name='i1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 t1 | table i1 t1 | view v2 v2 | trigger r1 t1 |}
+do_test corruptM-151 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ SELECT * FROM t1, v2;
+ }
+} {1 {malformed database schema (i1)}}
+
+do_execsql_test corruptM-160 {
+ UPDATE sqlite_master SET type='view', tbl_name='t1' WHERE name='i1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 t1 | view i1 t1 | view v2 v2 | trigger r1 t1 |}
+do_test corruptM-161 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ SELECT * FROM t1, v2;
+ }
+} {1 {malformed database schema (i1)}}
+
+do_execsql_test corruptM-170 {
+ UPDATE sqlite_master SET type='index', tbl_name='t1' WHERE name='i1';
+ UPDATE sqlite_master SET type='table', tbl_name='v2' WHERE name='v2';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 t1 | index i1 t1 | table v2 v2 | trigger r1 t1 |}
+do_test corruptM-171 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ SELECT * FROM t1, v2;
+ }
+} {1 {malformed database schema (v2)}}
+
+do_execsql_test corruptM-180 {
+ UPDATE sqlite_master SET type='view',name='v3',tbl_name='v3' WHERE name='v2';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 t1 | index i1 t1 | view v3 v3 | trigger r1 t1 |}
+do_test corruptM-181 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ SELECT * FROM t1, v2;
+ }
+} {1 {malformed database schema (v3)}}
+
+do_execsql_test corruptM-190 {
+ UPDATE sqlite_master SET type='view',name='v2',tbl_name='v2' WHERE name='v3';
+ UPDATE sqlite_master SET type='view' WHERE name='r1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 t1 | index i1 t1 | view v2 v2 | view r1 t1 |}
+do_test corruptM-191 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ SELECT * FROM t1, v2;
+ }
+} {1 {malformed database schema (r1)}}
+do_execsql_test corruptM-192 {
+ UPDATE sqlite_master SET type='trigger',tbl_name='v2' WHERE name='r1';
+ SELECT type, name, tbl_name, '|' FROM sqlite_master;
+} {table t1 t1 | index i1 t1 | view v2 v2 | trigger r1 v2 |}
+do_test corruptM-193 {
+ open_db2_and_catchsql {
+ PRAGMA quick_check;
+ SELECT * FROM t1, v2;
+ }
+} {1 {malformed database schema (r1)}}
+
+finish_test
diff --git a/test/corruptN.test b/test/corruptN.test
new file mode 100644
index 0000000..376325f
--- /dev/null
+++ b/test/corruptN.test
@@ -0,0 +1,279 @@
+# 2020-12-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.
+#
+#***********************************************************************
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix corruptN
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+reset_db
+do_test 1.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 4096 pagesize 512 filename sql024239.txt.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 02 00 01 01 00 40 20 20 00 00 00 0c 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 04 ................
+| 48: 00 00 00 00 89 00 00 04 00 10 00 01 0a 00 00 01 ................
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c ................
+| 96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0 ..,P............
+| 112: 01 56 01 86 01 2a 01 06 00 00 00 00 00 00 00 00 .V...*..........
+| 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 31 74 61 .............1ta
+| 272: 62 6c 65 74 34 74 34 07 43 52 45 41 54 45 20 54 blet4t4.CREATE T
+| 288: 41 42 4c 45 20 74 34 28 78 29 2a 06 06 17 13 11 ABLE t4(x)*.....
+| 304: 01 3f 69 6e 64 65 78 74 33 78 74 33 05 43 52 45 .?indext3xt3.CRE
+| 320: 41 54 45 20 49 4e 44 45 58 20 74 33 78 20 4f 4e ATE INDEX t3x ON
+| 336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e t3(x).......Ein
+| 352: 64 65 78 74 32 63 64 74 32 05 43 52 45 41 54 45 dext2cdt2.CREATE
+| 368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74 INDEX t2cd ON t
+| 384: 32 28 63 2c 64 29 28 05 06 17 11 11 01 3d 74 61 2(c,d)(......=ta
+| 400: 62 6c 65 74 33 74 33 07 43 52 45 41 54 45 20 54 blet3t3.CREATE T
+| 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f)
+| 432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (......=tablet2t
+| 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t
+| 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$.....
+| 480: 01 35 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .5tablet1t1.CREA
+| 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29 TE TABLE t1(a,b)
+| page 2 offset 512
+| 0: 0d 00 00 00 04 01 41 00 01 fa 01 f3 01 de 01 cf ......A.........
+| 160: 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 .. .............
+| 448: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d ................
+| 464: 04 03 17 17 73 65 76 65 6e 65 69 67 68 74 13 03 ....seveneight..
+| 480: 03 07 07 40 14 00 00 00 00 00 00 40 18 00 00 00 ...@.......@....
+| 496: 00 00 00 05 02 03 01 01 03 04 04 01 03 09 01 02 ................
+| page 3 offset 1024
+| 0: 0d 00 00 00 08 01 54 00 01 f7 01 ec 01 c5 01 aa ......T.........
+| 16: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 112: 00 00 dd 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 336: 00 00 00 00 19 08 05 17 17 17 17 65 69 67 68 74 ...........eight
+| 352: 65 69 67 68 74 73 65 76 65 6e 73 65 76 65 6e 25 eightsevenseven%
+| 368: 07 05 07 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 432: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 ................
+| 480: 00 00 0f 04 17 17 01 65 69 67 68 74 65 69 67 68 .......eighteigh
+| 496: 74 08 15 04 07 07 01 40 18 00 00 00 00 00 00 40 t......@.......@
+| page 4 offset 1536
+| 0: 18 00 00 00 00 00 00 07 07 04 01 01 01 04 04 06 ................
+| 16: 07 04 01 01 01 02 02 05 0f 04 17 17 01 73 6d 76 .............smv
+| 32: 65 6e 65 69 67 68 74 04 15 04 07 07 01 40 14 00 eneight......@..
+| page 5 offset 2048
+| 0: 0a 00 00 00 08 01 96 00 01 fa 01 c4 01 f2 01 bc ................
+| 16: 01 dc 01 e1 01 96 01 cc 00 00 00 00 00 00 00 00 ................
+| 160: 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 ......2.........
+| 368: 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 400: 00 00 00 00 00 00 0f 04 17 17 01 85 69 67 68 74 ............ight
+| 416: 65 69 67 68 74 08 15 04 07 07 01 40 18 00 00 00 eight......@....
+| 432: 00 00 00 40 18 00 00 00 00 00 00 07 07 04 01 01 ...@............
+| 448: 01 04 04 06 07 04 01 01 01 02 02 05 0f 04 17 17 ................
+| 464: 01 73 6d 76 65 6e 65 69 67 68 74 04 15 04 07 07 .smveneight.....
+| 480: 01 40 14 00 00 00 00 00 00 40 18 00 00 00 00 00 .@.......@......
+| 496: 00 03 07 04 01 01 01 03 04 02 05 04 03 01 09 02 ................
+| page 6 offset 2560
+| 0: 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 16: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 ................
+| 304: 00 00 00 26 00 00 00 00 00 00 00 00 00 00 00 00 ...&............
+| page 7 offset 3072
+| 0: 0d 00 00 00 08 01 c2 00 01 fb 01 f6 01 f1 01 ec ................
+| 16: 01 e0 01 d4 01 cb 01 c2 00 00 00 00 00 00 00 00 ................
+| 128: 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 04 ............. ..
+| 384: 00 00 00 00 00 00 00 00 00 07 08 02 17 65 69 fc .............ei.
+| 400: 68 74 07 07 02 17 65 69 67 68 74 0a fb fd f8 bf ht....eight.....
+| 416: e7 ff ff ff 00 00 00 0a 05 02 07 40 18 00 00 00 ...........@....
+| 432: 00 00 00 03 04 02 01 04 03 03 02 01 04 03 02 01 ................
+| 448: ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 ................
+| end sql024239.txt.db
+}]} {}
+
+do_catchsql_test 1.1 {
+ VACUUM;
+} {1 {database disk image is malformed}}
+
+# 2021-04-05 dbsqlfuzz b92b72e4de80b5140c30ab71372ca719b8feb618
+do_test 2.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 16384 pagesize 4096 filename c-b92b.txt.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 04 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0f f8 00 04 0f 12 00 0f 91 0f d3 ................
+| 112: 0f 67 0f 12 00 00 00 00 00 00 00 00 00 00 00 00 .g..............
+| 3856: 00 00 53 04 07 1b 13 11 08 81 0d 74 72 69 67 67 ..S........trigg
+| 3872: 65 72 74 72 30 74 31 43 52 45 41 54 45 20 54 52 ertr0t1CREATE TR
+| 3888: 49 47 47 45 52 20 74 72 30 20 44 45 4c 45 54 45 IGGER tr0 DELETE
+| 3904: 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 55 ON t1 BEGIN. U
+| 3920: 50 44 41 54 45 20 74 31 20 53 45 54 20 62 20 3d PDATE t1 SET b =
+| 3936: 20 61 3b 0a 45 4e 44 28 03 06 17 11 11 01 3d 69 a;.END(......=i
+| 3952: 6e 64 65 78 69 30 74 31 04 43 52 45 41 54 45 20 ndexi0t1.CREATE
+| 3968: 49 4e 44 45 58 20 69 30 20 4f 4e 20 74 31 28 62 INDEX i0 ON t1(b
+| 3984: 29 40 01 06 17 11 11 01 6d 74 61 62 6c 65 74 31 )@......mtablet1
+| 4000: 74 31 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 t1.CREATE TABLE
+| 4016: 74 31 28 61 20 55 4e 49 51 55 45 20 4f 4e 20 43 t1(a UNIQUE ON C
+| 4032: 4f 4e 46 4c 49 43 54 20 52 45 50 4c 41 43 45 2c ONFLICT REPLACE,
+| 4048: 20 62 29 23 02 06 17 37 11 01 00 69 6e 64 65 78 b)#...7...index
+| 4064: 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 sqlite_autoindex
+| 4080: 5f 74 31 5f 31 74 31 03 00 00 00 08 00 00 00 00 _t1_1t1.........
+| page 2 offset 4096
+| 0: 0d 00 00 00 02 0f 00 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 05 02 03 01 01 09 0d 05 01 03 01 01 04 0c ................
+| page 3 offset 8192
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 03 01 01 09 02 04 03 01 09 04 ................
+| page 4 offset 12288
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 03 01 01 0d 02 04 03 00 00 00 ................
+| end c-b92b.txt.db
+}]} {}
+
+# This test only works with the legacy RC4 PRNG
+if 0 {
+ prng_seed 0 db
+ do_catchsql_test 2.1 {
+ SELECT count(*) FROM sqlite_schema;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t1(a) SELECT randomblob(null) FROM c;
+ } {1 {database disk image is malformed}}
+}
+
+reset_db
+if {![info exists ::G(perm:presql)]} {
+ do_execsql_test 3.0 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_schema
+ SET sql = 'CREATE TABLE sqlite_sequence(name-seq)'
+ WHERE name = 'sqlite_sequence';
+ }
+ db close
+ sqlite3 db test.db
+ do_catchsql_test 3.1 {
+ PRAGMA writable_schema = 1;
+ INSERT INTO t1(y) VALUES('abc');
+ } {1 {database disk image is malformed}}
+ reset_db
+
+ do_execsql_test 4.1 {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b UNIQUE, c UNIQUE);
+ INSERT INTO x1 VALUES(1, 1, 2);
+ INSERT INTO x1 VALUES(2, 2, 3);
+ INSERT INTO x1 VALUES(3, 3, 4);
+ INSERT INTO x1 VALUES(4, 5, 6);
+ PRAGMA writable_schema = 1;
+
+ UPDATE sqlite_schema SET rootpage = (
+ SELECT rootpage FROM sqlite_schema WHERE name = 'sqlite_autoindex_x1_2'
+ ) WHERE name = 'sqlite_autoindex_x1_1';
+ }
+
+ db close
+ sqlite3 db test.db
+ breakpoint
+ do_catchsql_test 4.2 {
+ PRAGMA writable_schema = 1;
+ REPLACE INTO x1 VALUES(5, 2, 3);
+ } {0 {}}
+
+}
+
+#-------------------------------------------------------------------------
+
+reset_db
+
+ifcapable json1&&vtab {
+ db func strreplace strreplace
+ proc strreplace {orig a b} {
+ string map [list $a $b] $orig
+ }
+
+ do_execsql_test 5.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_schema
+ SET sql = strreplace(sql, 't1', 'json_each')
+ WHERE type='index';
+ }
+
+ # Do not run this tests if there is any presql (SQL run from within
+ # the [sqlite3] command) configured. In this case the schema is parsed
+ # before the "PRAGMA writable_schema" command is executed and the
+ # script throws and exception.
+ if {[info exists ::G(perm:presql)]==0 || $::G(perm:presql)==""} {
+ db close
+ sqlite3 db test.db
+
+ do_execsql_test 5.1 {
+ PRAGMA writable_schema = 1;
+ SELECT * FROM t1
+ }
+ }
+}; # ifcapable json1&&vtab
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 6.0 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1(b) VALUES(zeroblob(300)),(zeroblob(300)),(zeroblob(300)),(zeroblob(300));
+ CREATE TABLE t2(a);
+ CREATE TRIGGER t1tr BEFORE UPDATE ON t1 BEGIN DELETE FROM t2; END;
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_schema SET rootpage=3 WHERE rowid=2;
+ PRAGMA writable_schema=RESET;
+ INSERT INTO t2 VALUES('active'),('boomer'),('atom'),('atomic'),
+ ('alpha channel backup abandon test aback boomer atom alpha active');
+}
+do_catchsql_test 6.1 {
+ UPDATE t1 SET b=zeroblob(299);
+} {1 {database disk image is malformed}}
+
+reset_db
+do_execsql_test 6.2 {
+ -- Make "t1" a large table. Large enough that the children of the root
+ -- node are interior nodes.
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(x);
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500
+ )
+ INSERT INTO t1 SELECT zeroblob(300) FROM s;
+
+ CREATE TABLE t2(y);
+ CREATE TRIGGER tr BEFORE UPDATE ON t1 BEGIN
+ DELETE FROM t2;
+ END;
+
+ -- Set the root of table t2 to 137 - the leftmost child of the root of t1.
+ PRAGMA writable_schema = ON;
+ UPDATE sqlite_schema SET rootpage = 137 WHERE name='t2';
+ PRAGMA writable_schema = RESET;
+}
+
+do_catchsql_test 6.3 {
+ -- Run an UPDATE on t1 that will hit a child of page 136. Have the trigger
+ -- clear page 136 and its children. Assert fails.
+ UPDATE t1 SET x='hello world' WHERE rowid=1;
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/cost.test b/test/cost.test
new file mode 100644
index 0000000..5684177
--- /dev/null
+++ b/test/cost.test
@@ -0,0 +1,289 @@
+# 2014-04-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 cost
+
+
+do_execsql_test 1.1 {
+ CREATE TABLE t3(id INTEGER PRIMARY KEY, b NOT NULL);
+ CREATE TABLE t4(c, d, e);
+ CREATE UNIQUE INDEX i3 ON t3(b);
+ CREATE UNIQUE INDEX i4 ON t4(c, d);
+}
+do_eqp_test 1.2 {
+ SELECT e FROM t3, t4 WHERE b=c ORDER BY b, d;
+} {
+ QUERY PLAN
+ |--SCAN t3 USING COVERING INDEX i3
+ `--SEARCH t4 USING INDEX i4 (c=?)
+}
+
+
+do_execsql_test 2.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+}
+
+# It is better to use an index for ORDER BY than sort externally, even
+# if the index is a non-covering index.
+do_eqp_test 2.2 {
+ SELECT * FROM t1 ORDER BY a;
+} {SCAN t1 USING INDEX i1}
+
+do_execsql_test 3.1 {
+ CREATE TABLE t5(a INTEGER PRIMARY KEY,b,c,d,e,f,g);
+ CREATE INDEX t5b ON t5(b);
+ CREATE INDEX t5c ON t5(c);
+ CREATE INDEX t5d ON t5(d);
+ CREATE INDEX t5e ON t5(e);
+ CREATE INDEX t5f ON t5(f);
+ CREATE INDEX t5g ON t5(g);
+}
+
+do_eqp_test 3.2 {
+ SELECT a FROM t5
+ WHERE b IS NULL OR c IS NULL OR d IS NULL
+ ORDER BY a;
+} {
+ QUERY PLAN
+ |--MULTI-INDEX OR
+ | |--INDEX 1
+ | | `--SEARCH t5 USING INDEX t5b (b=?)
+ | |--INDEX 2
+ | | `--SEARCH t5 USING INDEX t5c (c=?)
+ | `--INDEX 3
+ | `--SEARCH t5 USING INDEX t5d (d=?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+#-------------------------------------------------------------------------
+# If there is no likelihood() or stat3 data, SQLite assumes that a closed
+# range scan (e.g. one constrained by "col BETWEEN ? AND ?" constraint)
+# visits 1/64 of the rows in a table.
+#
+# Note: 1/63 =~ 0.016
+# Note: 1/65 =~ 0.015
+#
+reset_db
+do_execsql_test 4.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+}
+do_eqp_test 4.2 {
+ SELECT * FROM t1 WHERE likelihood(a=?, 0.014) AND b BETWEEN ? AND ?;
+} {SEARCH t1 USING INDEX i1 (a=?)}
+
+do_eqp_test 4.3 {
+ SELECT * FROM t1 WHERE likelihood(a=?, 0.016) AND b BETWEEN ? AND ?;
+} {SEARCH t1 USING INDEX i2 (b>? AND b<?)}
+
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 5.1 {
+ CREATE TABLE t2(x, y);
+ CREATE INDEX t2i1 ON t2(x);
+}
+
+do_eqp_test 5.2 {
+ SELECT * FROM t2 ORDER BY x, y;
+} {
+ QUERY PLAN
+ |--SCAN t2 USING INDEX t2i1
+ `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY
+}
+
+do_eqp_test 5.3 {
+ SELECT * FROM t2 WHERE x BETWEEN ? AND ? ORDER BY rowid;
+} {
+ QUERY PLAN
+ |--SEARCH t2 USING INDEX t2i1 (x>? AND x<?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+# where7.test, where8.test:
+#
+do_execsql_test 6.1 {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b, c);
+ CREATE INDEX t3i1 ON t3(b);
+ CREATE INDEX t3i2 ON t3(c);
+}
+
+do_eqp_test 6.2 {
+ SELECT a FROM t3 WHERE (b BETWEEN 2 AND 4) OR c=100 ORDER BY a
+} {
+ QUERY PLAN
+ |--MULTI-INDEX OR
+ | |--INDEX 1
+ | | `--SEARCH t3 USING INDEX t3i1 (b>? AND b<?)
+ | `--INDEX 2
+ | `--SEARCH t3 USING INDEX t3i2 (c=?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 7.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d,e,f,g);
+ 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);
+}
+
+do_eqp_test 7.2 {
+ SELECT a FROM t1
+ WHERE (b>=950 AND b<=1010) OR (b IS NULL AND c NOT NULL)
+ ORDER BY a
+} {
+ QUERY PLAN
+ |--MULTI-INDEX OR
+ | |--INDEX 1
+ | | `--SEARCH t1 USING INDEX t1b (b>? AND b<?)
+ | `--INDEX 2
+ | `--SEARCH t1 USING INDEX t1b (b=?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+do_eqp_test 7.3 {
+ SELECT rowid 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 t1}
+
+do_eqp_test 7.4 {
+ SELECT rowid FROM t1 WHERE (+b IS NULL AND c NOT NULL) OR c IS NULL
+} {SCAN t1}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 8.1 {
+ CREATE TABLE composer(
+ cid INTEGER PRIMARY KEY,
+ cname TEXT
+ );
+ CREATE TABLE album(
+ aid INTEGER PRIMARY KEY,
+ aname TEXT
+ );
+ CREATE TABLE track(
+ tid INTEGER PRIMARY KEY,
+ cid INTEGER REFERENCES composer,
+ aid INTEGER REFERENCES album,
+ title TEXT
+ );
+ CREATE INDEX track_i1 ON track(cid);
+ CREATE INDEX track_i2 ON track(aid);
+}
+
+do_eqp_test 8.2 {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE cname LIKE '%bach%'
+ AND unlikely(composer.cid=track.cid)
+ AND unlikely(album.aid=track.aid);
+} {
+ QUERY PLAN
+ |--SCAN track
+ |--SEARCH album USING INTEGER PRIMARY KEY (rowid=?)
+ |--SEARCH composer USING INTEGER PRIMARY KEY (rowid=?)
+ `--USE TEMP B-TREE FOR DISTINCT
+}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 9.1 {
+ CREATE TABLE t1(
+ a,b,c,d,e, f,g,h,i,j,
+ k,l,m,n,o, p,q,r,s,t
+ );
+ CREATE INDEX i1 ON t1(k,l,m,n,o,p,q,r,s,t);
+}
+do_test 9.2 {
+ for {set i 0} {$i < 100} {incr i} {
+ execsql { INSERT INTO t1 DEFAULT VALUES }
+ }
+ execsql {
+ ANALYZE;
+ CREATE INDEX i2 ON t1(a,b,c,d,e,f,g,h,i,j);
+ }
+} {}
+
+set L [list a=? b=? c=? d=? e=? f=? g=? h=? i=? j=?]
+foreach {tn nTerm nRow} {
+ 1 1 10
+ 2 2 10
+ 3 3 8
+ 4 4 7
+ 5 5 7
+ 6 6 5
+ 7 7 5
+ 8 8 5
+ 9 9 5
+ 10 10 5
+} {
+ set w [join [lrange $L 0 [expr $nTerm-1]] " AND "]
+ set p1 [expr ($nRow-1) / 100.0]
+ set p2 [expr ($nRow+1) / 100.0]
+
+ set sql1 "SELECT * FROM t1 WHERE likelihood(k=?, $p1) AND $w"
+ set sql2 "SELECT * FROM t1 WHERE likelihood(k=?, $p2) AND $w"
+
+ do_eqp_test 9.3.$tn.1 $sql1 {/INDEX i1/}
+ do_eqp_test 9.3.$tn.2 $sql2 {/INDEX i2/}
+}
+
+
+#-------------------------------------------------------------------------
+#
+
+ifcapable stat4 {
+ do_execsql_test 10.1 {
+ CREATE TABLE t6(a, b, c);
+ CREATE INDEX t6i1 ON t6(a, b);
+ CREATE INDEX t6i2 ON t6(c);
+ }
+
+ do_test 10.2 {
+ for {set i 0} {$i < 16} {incr i} {
+ execsql { INSERT INTO t6 VALUES($i%4, 'xyz', $i%8) }
+ }
+ execsql ANALYZE
+ } {}
+
+ do_eqp_test 10.3 {
+ SELECT rowid FROM t6 WHERE a=0 AND c=0
+ } {SEARCH t6 USING INDEX t6i2 (c=?)}
+
+ do_eqp_test 10.4 {
+ SELECT rowid FROM t6 WHERE a=0 AND b='xyz' AND c=0
+ } {SEARCH t6 USING INDEX t6i2 (c=?)}
+
+ do_eqp_test 10.5 {
+ SELECT rowid FROM t6 WHERE likelihood(a=0, 0.1) AND c=0
+ } {SEARCH t6 USING INDEX t6i1 (a=?)}
+
+ do_eqp_test 10.6 {
+ SELECT rowid FROM t6 WHERE likelihood(a=0, 0.1) AND b='xyz' AND c=0
+ } {SEARCH t6 USING INDEX t6i1 (a=? AND b=?)}
+}
+
+finish_test
diff --git a/test/count.test b/test/count.test
new file mode 100644
index 0000000..6f02074
--- /dev/null
+++ b/test/count.test
@@ -0,0 +1,251 @@
+# 2009-02-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.
+#
+
+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.
+#
+#
+
+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_execsql_test count-2.9a {
+ SELECT count(*) FROM t2 HAVING count(*)>1;
+} {}
+do_execsql_test count-2.9b {
+ SELECT count(*) FROM t2 HAVING count(*)<10;
+} {0}
+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}
+
+do_execsql_test count-5.1 {
+ CREATE TABLE t5(a TEXT PRIMARY KEY, b VARCHAR(50)) WITHOUT ROWID;
+ INSERT INTO t5 VALUES('bison','jazz');
+ SELECT count(*) FROM t5;
+} {1}
+
+do_catchsql_test count-6.1 {
+ CREATE TABLE t6(x);
+ SELECT count(DISTINCT) FROM t6 GROUP BY x;
+} {1 {DISTINCT aggregates must have exactly one argument}}
+
+# 2020-05-08.
+# The count() optimization should honor the NOT INDEXED clause
+#
+reset_db
+do_execsql_test count-7.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c VARCHAR(1000));
+ CREATE INDEX t1b ON t1(b);
+ INSERT INTO t1(a,b,c) values(1,2,'count.test cases for NOT INDEXED');
+ ANALYZE;
+ UPDATE sqlite_stat1 SET stat='1000000 10' WHERE idx='t1b';
+ ANALYZE sqlite_master;
+}
+do_eqp_test count-7.2 {
+ SELECT count(1) FROM t1;
+} {
+ QUERY PLAN
+ `--SCAN t1 USING COVERING INDEX t1b
+}
+do_eqp_test count-7.3 {
+ SELECT count(1) FROM t1 NOT INDEXED
+} {
+ QUERY PLAN
+ `--SCAN t1
+}
+do_eqp_test count-7.3 {
+ SELECT count(*) FROM t1;
+} {
+ QUERY PLAN
+ `--SCAN t1 USING COVERING INDEX t1b
+}
+do_eqp_test count-7.4 {
+ SELECT count(*) FROM t1 NOT INDEXED
+} {
+ QUERY PLAN
+ `--SCAN t1
+}
+
+do_execsql_test count-8.0 {
+ CREATE TABLE t7(a INT,b TEXT,c BLOB,d REAL);
+ CREATE TABLE t8(a INT,b TEXT,c BLOB,d REAL);
+ CREATE INDEX t8a ON t8(a);
+}
+do_catchsql_test count-8.1 {
+ SELECT * FROM t8 WHERE (a, b) IN (
+ SELECT count(t8.b), count(*) FROM t7 AS ra0 ORDER BY count(*)
+ ) AND t8.b=0;
+} {1 {misuse of aggregate: count()}}
+
+
+finish_test
diff --git a/test/countofview.test b/test/countofview.test
new file mode 100644
index 0000000..0ee511f
--- /dev/null
+++ b/test/countofview.test
@@ -0,0 +1,56 @@
+# 2018-08-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.
+#
+#***********************************************************************
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix countofview
+
+do_execsql_test 1.0 {
+ CREATE TABLE t2(c);
+ CREATE TABLE t3(f);
+
+ INSERT INTO t2 VALUES(1), (2);
+ INSERT INTO t3 VALUES(3);
+}
+
+do_execsql_test 1.1 {
+ select c from t2 union all select f from t3 limit 1 offset 1
+} {2}
+
+do_execsql_test 1.2 {
+ select count(*) from (
+ select c from t2 union all select f from t3 limit 1 offset 1
+ )
+} {1}
+
+do_execsql_test 1.3 {
+ select count(*) from (
+ select c from t2 union all select f from t3
+ )
+} {3}
+
+# 2019-05-15
+do_execsql_test 2.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1),(99),('abc');
+ CREATE VIEW v1(x,y) AS SELECT x,1 FROM t1 UNION ALL SELECT x,2 FROM t1;
+ SELECT count(*) FROM v1 WHERE x<>1;
+} {4}
+do_execsql_test 2.1 {
+ SELECT count(*) FROM v1 GROUP BY y;
+} {3 3}
+
+
+
+finish_test
diff --git a/test/coveridxscan.test b/test/coveridxscan.test
new file mode 100644
index 0000000..c87227c
--- /dev/null
+++ b/test/coveridxscan.test
@@ -0,0 +1,119 @@
+# 2012 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.
+#
+#***********************************************************************
+#
+# Tests for the optimization which attempts to use a covering index
+# for a full-table scan (under the theory that the index will be smaller
+# and require less I/O and hence will run faster.)
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix coveridxscan
+
+do_test 1.1 {
+ db eval {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(5,4,3), (4,8,2), (3,2,1);
+ CREATE INDEX t1ab ON t1(a,b);
+ CREATE INDEX t1b ON t1(b);
+ SELECT a FROM t1;
+ }
+ # covering index used for the scan, hence values are increasing
+} {3 4 5}
+
+do_test 1.2 {
+ db eval {
+ SELECT a, c FROM t1;
+ }
+ # There is no covering index, hence the values are in rowid order
+} {5 3 4 2 3 1}
+
+do_test 1.3 {
+ db eval {
+ SELECT b FROM t1;
+ }
+ # Choice of two indices: use the one with fewest columns
+} {2 4 8}
+
+do_test 2.1 {
+ optimization_control db cover-idx-scan 0
+ db eval {SELECT a FROM t1}
+ # With the optimization turned off, output in rowid order
+} {5 4 3}
+do_test 2.2 {
+ db eval {SELECT a, c FROM t1}
+} {5 3 4 2 3 1}
+do_test 2.3 {
+ db eval {SELECT b FROM t1}
+} {4 8 2}
+
+db close
+sqlite3_shutdown
+sqlite3_config_cis 0
+sqlite3 db test.db
+
+do_test 3.1 {
+ db eval {SELECT a FROM t1}
+ # With the optimization configured off, output in rowid order
+} {5 4 3}
+do_test 3.2 {
+ db eval {SELECT a, c FROM t1}
+} {5 3 4 2 3 1}
+do_test 3.3 {
+ db eval {SELECT b FROM t1}
+} {4 8 2}
+
+db close
+sqlite3_shutdown
+sqlite3_config_cis 1
+sqlite3 db test.db
+
+# The CIS optimization is enabled again. Covering indices are once again
+# used for all table scans.
+do_test 4.1 {
+ db eval {SELECT a FROM t1}
+} {3 4 5}
+do_test 4.2 {
+ db eval {SELECT a, c FROM t1}
+} {5 3 4 2 3 1}
+do_test 4.3 {
+ db eval {SELECT b FROM t1}
+} {2 4 8}
+
+#-------------------------------------------------------------------------
+# Test that indexes with large numbers of columns can be correctly
+# identified as covering indexes.
+reset_db
+set L [list]
+for {set i 1} {$i<120} {incr i} {
+ lappend L "c$i"
+}
+set cols [join $L ,]
+
+do_execsql_test 5.1.0 "
+ CREATE TABLE t1(a, b, c, $cols, PRIMARY KEY(a, b, c)) WITHOUT ROWID;
+ CREATE INDEX i1 ON t1($cols);
+
+ CREATE TABLE t2(i INTEGER PRIMARY KEY, $cols);
+ CREATE INDEX i2 ON t2($cols);
+"
+
+do_eqp_test 5.1.1 {
+ SELECT * FROM t1 ORDER BY c1, c2;
+} {SCAN t1 USING COVERING INDEX i1}
+
+do_eqp_test 5.1.2 {
+ SELECT * FROM t2 ORDER BY c1, c2;
+} {SCAN t2 USING COVERING INDEX i2}
+
+
+finish_test
diff --git a/test/crash.test b/test/crash.test
new file mode 100644
index 0000000..c1901da
--- /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
+# 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..fc078b3
--- /dev/null
+++ b/test/crash5.test
@@ -0,0 +1,127 @@
+
+# 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 !crashtest||!memorymanage {
+ puts "Skipping crash5 tests: not compiled with -DSQLITE_ENABLE_MEMORY_MANAGEMENT..."
+ finish_test
+ return
+}
+
+db close
+
+for {set ii 0} {$ii < 10} {incr ii} {
+ for {set jj 1} {$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] {
+ proc get_pwd {} {
+ if {$::tcl_platform(platform) eq "windows"} {
+ if {[info exists ::env(ComSpec)]} {
+ set comSpec $::env(ComSpec)
+ } else {
+ # NOTE: Hard-code the typical default value.
+ set comSpec {C:\Windows\system32\cmd.exe}
+ }
+ return [string map [list \\ /] \
+ [string trim [exec -- $comSpec /c echo %CD%]]]
+ } else {
+ return [pwd]
+ }
+ }
+ sqlite3_crashparams 0 [file join [get_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
+ set rc [catch {db eval { CREATE UNIQUE INDEX i1 ON t1(a); }} msg]
+# puts "$msg ac=[sqlite3_get_autocommit db] iFail=$iFail"
+# puts "fail=[sqlite3_memdebug_fail -1]"
+
+ if {$rc} {
+ # If the transaction is still active (it may not be if the malloc()
+ # failure occurred 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 [get_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..482999c
--- /dev/null
+++ b/test/crash7.test
@@ -0,0 +1,116 @@
+# 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
+set testprefix crash7
+
+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
+ }
+}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;
+ DELETE FROM t1 WHERE rowid%2;
+}
+db_save_and_close
+
+for {set i 0} {$i < 20} {incr i} {
+ db_restore_and_reopen
+ do_test 2.[expr $i+1].1 {
+ crashsql -file test.db -seed $i {VACUUM}
+ } {1 {child process exited abnormally}}
+ do_execsql_test 2.[expr $i+1].2 { PRAGMA integrity_check } {ok}
+}
+
+
+finish_test
diff --git a/test/crash8.test b/test/crash8.test
new file mode 100644
index 0000000..c078299
--- /dev/null
+++ b/test/crash8.test
@@ -0,0 +1,419 @@
+# 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_not_use_codec
+
+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
+#
+if {[atomic_batch_write test.db]==0} {
+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;
+ }
+ } {persist persist}
+ if {[atomic_batch_write test.db]==0} {
+ do_test crash8.4.1.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}
+}
+
+#
+# Since the following tests (crash8-5.*) rely upon being able
+# to copy a file while open, they will not work on Windows.
+#
+# They also depend on being able to copy the journal file, which
+# is not created on F2FS file-systems that support atomic
+# write. So do not run these tests in that case either.
+#
+if {$::tcl_platform(platform)=="unix" && [atomic_batch_write test.db]==0 } {
+ 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/crashM.test b/test/crashM.test
new file mode 100644
index 0000000..de10c45
--- /dev/null
+++ b/test/crashM.test
@@ -0,0 +1,80 @@
+# 2015 Mar 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.
+#
+#***********************************************************************
+#
+# Crash tests for the multiplex module with 8.3 filenames enabled.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix crashM
+
+ifcapable !crashtest||!8_3_names {
+ finish_test
+ return
+}
+
+db close
+sqlite3_shutdown
+sqlite3_config_uri 1
+
+foreach f [glob -nocomplain test1.* test2.*] { forcedelete $f }
+sqlite3_multiplex_initialize "" 1
+sqlite3 db file:test1.db?8_3_names=1
+sqlite3_multiplex_control db main chunk_size [expr 64*1024]
+
+do_execsql_test 1.0 {
+ ATTACH 'file:test2.db?8_3_names=1' AS aux;
+
+ CREATE TABLE t1(x, y);
+ CREATE INDEX t1x ON t1(x);
+ CREATE INDEX t1y ON t1(y);
+
+ CREATE TABLE aux.t2(x, y);
+ CREATE INDEX aux.t2x ON t2(x);
+ CREATE INDEX aux.t2y ON t2(y);
+
+ WITH s(a) AS (
+ SELECT 1 UNION ALL SELECT a+1 FROM s WHERE a<1000
+ )
+ INSERT INTO t1 SELECT a, randomblob(500) FROM s;
+
+ WITH s(a) AS (
+ SELECT 1 UNION ALL SELECT a+1 FROM s WHERE a<1000
+ )
+ INSERT INTO t2 SELECT a, randomblob(500) FROM s;
+} {}
+
+for {set i 0} {$i < 20} {incr i} {
+ do_test 2.$i.1 {
+ crashsql -delay 1 -file test1.db -opendb {
+ sqlite3_shutdown
+ sqlite3_config_uri 1
+ sqlite3_multiplex_initialize crash 1
+ sqlite3 db file:test1.db?8_3_names=1
+ sqlite3_multiplex_control db main chunk_size [expr 64*1024]
+ } {
+ ATTACH 'file:test2.db?8_3_names=1' AS aux;
+ BEGIN;
+ UPDATE t1 SET y = randomblob(500) WHERE (x%10)==0;
+ UPDATE t2 SET y = randomblob(500) WHERE (x%10)==0;
+ COMMIT;
+ }
+ } {1 {child process exited abnormally}}
+
+ do_execsql_test 2.$i.2 {
+ PRAGMA main.integrity_check;
+ PRAGMA aux.integrity_check;
+ } {ok ok}
+}
+
+catch { db close }
+sqlite3_multiplex_shutdown
+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..5773fbf
--- /dev/null
+++ b/test/createtab.test
@@ -0,0 +1,154 @@
+# 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.
+#
+
+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
+
+}
+
+# 2019-03-31 Ensure that a proper error is returned for an index
+# with too many columns.
+#
+do_test createtab-3.1 {
+ db eval {DROP TABLE IF EXISTS t1;}
+ set sql "CREATE TABLE t1(x,UNIQUE(x[string repeat ,x 100000]))"
+ catchsql $sql
+} {1 {too many columns in index}}
+
+finish_test
diff --git a/test/cse.test b/test/cse.test
new file mode 100644
index 0000000..3912bc3
--- /dev/null
+++ b/test/cse.test
@@ -0,0 +1,200 @@
+# 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
+set testprefix cse
+
+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
+}
+
+#-------------------------------------------------------------------------
+# Ticket fd1bda016d1a
+#
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(a TEXT, b);
+ INSERT INTO t1 VALUES('hello', 0);
+ INSERT INTO t1 VALUES('world', 0);
+
+ CREATE TABLE t2(x TEXT);
+ INSERT INTO t2 VALUES('hello');
+ INSERT INTO t2 VALUES('world');
+
+ CREATE TABLE t3(y);
+ INSERT INTO t3 VALUES(1000);
+} {}
+
+do_execsql_test 3.1 {
+ SELECT 1000 = y FROM t3
+} {1}
+
+do_execsql_test 3.2 {
+ SELECT 1000 IN (SELECT x FROM t2), 1000 = y FROM t3
+} {0 1}
+
+do_execsql_test 3.3 {
+ SELECT 0 IN (SELECT a), (SELECT a LIMIT 0) FROM t1
+} {0 {} 0 {}}
+
+do_execsql_test 3.4 {
+ SELECT 0 IN (SELECT a) FROM t1 WHERE a = 'hello' OR (SELECT a LIMIT 0);
+} {0}
+
+do_execsql_test 3.5 {
+ CREATE TABLE v0(v1 VARCHAR0);
+ INSERT INTO v0 VALUES(2), (3);
+ SELECT 0 IN(SELECT v1) FROM v0 WHERE v1 = 2 OR(SELECT v1 LIMIT 0);
+} {0}
+
+finish_test
diff --git a/test/csv01.test b/test/csv01.test
new file mode 100644
index 0000000..ecb1a96
--- /dev/null
+++ b/test/csv01.test
@@ -0,0 +1,279 @@
+# 2016-06-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.
+#
+#***********************************************************************
+#
+# Test cases for CSV virtual table.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix csv01
+
+ifcapable !vtab||!cte { finish_test ; return }
+
+load_static_extension db csv
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE temp.t1 USING csv(
+ data=
+'1,2,3,4
+5,6,7,8
+9,10,11,12
+13,14,15,16
+',
+ columns=4
+ );
+ SELECT * FROM t1 WHERE c1=10;
+} {9 10 11 12}
+do_execsql_test 1.1 {
+ SELECT * FROM t1 WHERE c1='10';
+} {9 10 11 12}
+do_execsql_test 1.2 {
+ SELECT rowid FROM t1;
+} {1 2 3 4}
+
+do_execsql_test 1.3 {
+ DROP TABLE temp.t1;
+ CREATE VIRTUAL TABLE temp.t1 USING csv(
+ data=
+'a,b,"mix-bloom-eel","soft opinion"
+1,2,3,4
+5,6,7,8
+9,10,11,12
+13,14,15,16
+',
+ header=1
+ );
+ SELECT * FROM t1 WHERE "soft opinion"=12;
+} {9 10 11 12}
+do_execsql_test 1.4 {
+ SELECT name FROM pragma_table_xinfo('t1');
+} {a b mix-bloom-eel {soft opinion}}
+
+do_execsql_test 1.5 {
+ DROP TABLE temp.t1;
+ CREATE VIRTUAL TABLE temp.t1 USING csv(
+ data=
+'a,b,"mix-bloom-eel","soft opinion"
+1,2,3,4
+5,6,7,8
+9,10,11,12
+13,14,15,16
+',
+ header=false
+ );
+ SELECT * FROM t1 WHERE c1='b';
+} {a b mix-bloom-eel {soft opinion}}
+do_execsql_test 1.6 {
+ SELECT name FROM pragma_table_xinfo('t1');
+} {c0 c1 c2 c3}
+
+do_execsql_test 1.7 {
+ DROP TABLE temp.t1;
+ CREATE VIRTUAL TABLE temp.t1 USING csv(
+ data=
+'a,b,"mix-bloom-eel","soft opinion"
+1,2,3,4
+5,6,7,8
+9,10,11,12
+13,14,15,16
+',
+ header,
+ schema='CREATE TABLE x(x0,x1,x2,x3,x4)',
+ columns=5
+ );
+ SELECT * FROM t1 WHERE x1='6';
+} {5 6 7 8 {}}
+do_execsql_test 1.8 {
+ SELECT name FROM pragma_table_xinfo('t1');
+} {x0 x1 x2 x3 x4}
+
+
+do_execsql_test 2.0 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE temp.t2 USING csv(
+ data=
+'1,2,3,4
+5,6,7,8
+9,10,11,12
+13,14,15,16
+',
+ columns=4,
+ schema='CREATE TABLE t2(a INT, b TEXT, c REAL, d BLOB)'
+ );
+ SELECT * FROM t2 WHERE a=9;
+} {9 10 11 12}
+do_execsql_test 2.1 {
+ SELECT * FROM t2 WHERE b=10;
+} {9 10 11 12}
+do_execsql_test 2.2 {
+ SELECT * FROM t2 WHERE c=11;
+} {9 10 11 12}
+do_execsql_test 2.3 {
+ SELECT * FROM t2 WHERE d=12;
+} {}
+do_execsql_test 2.4 {
+ SELECT * FROM t2 WHERE d='12';
+} {9 10 11 12}
+do_execsql_test 2.5 {
+ SELECT * FROM t2 WHERE a='9';
+} {9 10 11 12}
+
+do_execsql_test 3.0 {
+ DROP TABLE t2;
+ CREATE VIRTUAL TABLE temp.t3 USING csv(
+ data=
+'1,2,3,4
+5,6,7,8
+9,10,11,12
+13,14,15,16
+',
+ columns=4,
+ schema=
+ 'CREATE TABLE t3(a PRIMARY KEY,b TEXT,c TEXT,d TEXT) WITHOUT ROWID',
+ testflags=1
+ );
+ SELECT a FROM t3 WHERE b=6 OR c=7 OR d=12 ORDER BY +a;
+} {5 9}
+do_execsql_test 3.1 {
+ SELECT a FROM t3 WHERE +b=6 OR c=7 OR d=12 ORDER BY +a;
+} {5 9}
+
+# The rowid column is not visible on a WITHOUT ROWID virtual table
+do_catchsql_test 3.2 {
+ SELECT rowid, a FROM t3;
+} {1 {no such column: rowid}}
+
+# Multi-column WITHOUT ROWID virtual tables may not be writable.
+do_catchsql_test 4.0 {
+ DROP TABLE t3;
+ CREATE VIRTUAL TABLE temp.t4 USING csv_wr(
+ data=
+'1,2,3,4
+5,6,7,8
+9,10,11,12
+13,14,15,16',
+ columns=4,
+ schema=
+ 'CREATE TABLE t3(a,b,c,d,PRIMARY KEY(a,b)) WITHOUT ROWID',
+ testflags=1
+ );
+} {1 {bad schema: 'CREATE TABLE t3(a,b,c,d,PRIMARY KEY(a,b)) WITHOUT ROWID' - not an error}}
+
+# WITHOUT ROWID tables with a single-column PRIMARY KEY may be writable.
+do_catchsql_test 4.1 {
+ DROP TABLE IF EXISTS t4;
+ CREATE VIRTUAL TABLE temp.t4 USING csv_wr(
+ data=
+'1,2,3,4
+5,6,7,8
+9,10,11,12
+13,14,15,16',
+ columns=4,
+ schema=
+ 'CREATE TABLE t3(a,b,c,d,PRIMARY KEY(b)) WITHOUT ROWID',
+ testflags=1
+ );
+} {0 {}}
+
+do_catchsql_test 4.2 {
+ DROP TABLE IF EXISTS t5;
+ CREATE VIRTUAL TABLE temp.t5 USING csv_wr(
+ data=
+ '1,2,3,4
+ 5,6,7,8
+ 9,10,11,12
+ 13,14,15,16',
+ columns=4,
+ schema=
+ 'CREATE TABLE t3(a,b,c,d) WITHOUT ROWID',
+ testflags=1
+ );
+} {1 {bad schema: 'CREATE TABLE t3(a,b,c,d) WITHOUT ROWID' - PRIMARY KEY missing on table t3}}
+
+# 2018-04-24
+# Memory leak reported on the sqlite-users mailing list by Ralf Junker.
+#
+do_catchsql_test 4.3 {
+ CREATE VIRTUAL TABLE IF NOT EXISTS temp.t1
+ USING csv(filename='FileDoesNotExist.csv');
+} {1 {cannot open 'FileDoesNotExist.csv' for reading}}
+
+# 2018-06-02
+# Problem with single-column CSV support reported on the mailing list
+# by Trent W. Buck.
+#
+do_execsql_test 4.4 {
+ CREATE VIRTUAL TABLE temp.trent USING csv(data='1');
+ SELECT * FROM trent;
+} {1}
+
+# 2018-12-26
+# Bug report on the mailing list
+#
+forcedelete csv01.csv
+set fd [open csv01.csv wb]
+puts $fd "a,b,c,d\r\n1,2,3,4\r\none,two,three,four\r\n5,6,7,8"
+close $fd
+do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE t5_1 USING csv(filename='csv01.csv');
+ SELECT name FROM temp.pragma_table_info('t5_1');
+} {c0 c1 c2 c3}
+do_execsql_test 5.2 {
+ SELECT *, '|' FROM t5_1;
+} {a b c d | 1 2 3 4 | one two three four | 5 6 7 8 |}
+do_execsql_test 5.3 {
+ DROP TABLE t5_1;
+ CREATE VIRTUAL TABLE t5_1 USING csv(filename='csv01.csv', header);
+ SELECT name FROM temp.pragma_table_info('t5_1');
+} {a b c d}
+do_execsql_test 5.4 {
+ SELECT *, '|' FROM t5_1;
+} {1 2 3 4 | one two three four | 5 6 7 8 |}
+
+#-------------------------------------------------------------------------
+
+proc randomtext {n} {
+ string range [db one {SELECT hex(randomblob($n))}] 1 $n
+}
+
+for {set ii 0} {$ii < 200} {incr ii} {
+ reset_db
+ load_static_extension db csv
+ set fd [open csv.data w]
+ puts $fd "a,b"
+ puts $fd "[randomtext $ii],abcd"
+ close $fd
+ do_execsql_test 6.$ii.1 {
+ CREATE VIRTUAL TABLE abc USING csv(filename='csv.data', header=true);
+ }
+ do_execsql_test 6.$ii.2 {
+ SELECT count(*) FROM abc
+ } 1
+}
+
+for {set ii 0} {$ii < 20} {incr ii} {
+ reset_db
+ load_static_extension db csv
+ set T [randomtext $ii]
+ set fd [open csv.data w]
+ puts $fd "a,b"
+ puts -nonewline $fd "abcd,$T"
+ close $fd
+ do_execsql_test 7.$ii.1 {
+ CREATE VIRTUAL TABLE abc USING csv(filename='csv.data', header=true);
+ }
+ breakpoint
+ do_execsql_test 7.$ii.2 {
+ SELECT * FROM abc
+ } [list abcd $T]
+}
+
+
+finish_test
diff --git a/test/ctime.test b/test/ctime.test
new file mode 100644
index 0000000..26b2fa2
--- /dev/null
+++ b/test/ctime.test
@@ -0,0 +1,259 @@
+# 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}
+
+# Check the THREADSAFE option for SQLITE_THREADSAFE=2 builds (there are
+# a couple of these configurations in releasetest.tcl).
+#
+ifcapable threadsafe2 {
+ foreach {tn opt res} {
+ 1 SQLITE_THREADSAFE 1
+ 2 THREADSAFE 1
+ 3 THREADSAFE=0 0
+ 4 THREADSAFE=1 0
+ 5 THREADSAFE=2 1
+ 6 THREADSAFE= 0
+ } {
+ do_execsql_test ctime-1.3.$tn {
+ SELECT sqlite_compileoption_used($opt)
+ } $res
+ }
+}
+
+# SQLITE_THREADSAFE should pretty much always be defined
+# one way or the other, and it must have a value of 0 or 1.
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 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 [catch {db one {
+ SELECT sqlite_compileoption_get($N);
+ }} msg]
+ lappend ans1 $msg
+ 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 {{}}}
+
+#--------------------------------------------------------------------------
+# Test that SQLITE_DIRECT_OVERFLOW_READ is reflected in the output of
+# "PRAGMA compile_options".
+#
+ifcapable direct_read {
+ set res 1
+} else {
+ set res 0
+}
+do_test ctime-3.0.1 {
+ expr [lsearch [db eval {PRAGMA compile_options}] DIRECT_OVERFLOW_READ]>=0
+} $res
+
+finish_test
diff --git a/test/cursorhint.test b/test/cursorhint.test
new file mode 100644
index 0000000..a3397b8
--- /dev/null
+++ b/test/cursorhint.test
@@ -0,0 +1,162 @@
+# 2014 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
+set testprefix cursorhint
+
+ifcapable !cursorhints {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE TABLE t2(x,y,z);
+ INSERT INTO t1(a,b) VALUES(10, 15);
+ INSERT INTO t1(a,b) VALUES(20, 25);
+ INSERT INTO t2(x,y) VALUES('ten', 'fifteen');
+ INSERT INTO t2(x,y) VALUES('twenty', 'twentyfive');
+ CREATE TABLE t3(id TEXT PRIMARY KEY, a, b, c, d) WITHOUT ROWID;
+ INSERT INTO t3(id,a,b,c,d) SELECT rowid, a, b, c, d FROM t1;
+ PRAGMA automatic_index = 0;
+}
+
+# Run EXPLAIN on $sql. Return a list of P4 values for all $opcode
+# opcodes.
+#
+proc p4_of_opcode {db opcode sql} {
+ set res {}
+ $db eval "EXPLAIN $sql" x {
+ if {$x(opcode)==$opcode} {lappend res $x(p4)}
+ }
+ return $res
+}
+
+# Run EXPLAIN on $sql. Return a list of P5 values for all $opcode
+# opcodes that contain regexp $comment in their comment
+#
+proc p5_of_opcode {db opcode sql} {
+ set res {}
+ $db eval "EXPLAIN $sql" x {
+ if {$x(opcode)==$opcode} {
+ lappend res $x(p5)
+ }
+ }
+ return $res
+}
+
+# Verify that when t1 is in the outer loop and t2 is in the inner loop,
+# no cursor hints occur for t1 (since it is a full table scan) but that
+# each t2 access has a cursor hint based on the current t1.a value.
+#
+do_test 1.1 {
+ p4_of_opcode db CursorHint {
+ SELECT * FROM t1 CROSS JOIN t2 WHERE a=x
+ }
+} {{EQ(r[1],c0)}}
+do_test 1.2 {
+ p5_of_opcode db OpenRead {
+ SELECT * FROM t1 CROSS JOIN t2 WHERE a=x
+ }
+} {0 0}
+
+# Do the same test the other way around.
+#
+do_test 2.1 {
+ p4_of_opcode db CursorHint {
+ SELECT * FROM t2 CROSS JOIN t1 WHERE a=x
+ }
+} {{EQ(c0,r[1])}}
+do_test 2.2 {
+ p5_of_opcode db OpenRead {
+ SELECT * FROM t2 CROSS JOIN t1 WHERE a=x
+ }
+} {0 0}
+
+# Various expressions captured by CursorHint
+#
+do_test 3.1 {
+ p4_of_opcode db CursorHint {
+ SELECT * FROM t1 WHERE a=15 AND c=22 AND rowid!=98
+ }
+} {AND(AND(EQ(c0,15),EQ(c2,22)),NE(rowid,98))}
+do_test 3.2 {
+ p4_of_opcode db CursorHint {
+ SELECT * FROM t3 WHERE a<15 AND b>22 AND id!=98
+ }
+} {AND(AND(LT(c1,15),GT(c2,22)),NE(c0,98))}
+
+# Indexed queries
+#
+do_test 4.1asc {
+ db eval {
+ CREATE INDEX t1bc ON t1(b,c);
+ CREATE INDEX t2yz ON t2(y,z);
+ }
+ p4_of_opcode db CursorHint {
+ SELECT * FROM t1 WHERE b>11 ORDER BY b ASC;
+ }
+} {}
+do_test 4.1desc {
+ p4_of_opcode db CursorHint {
+ SELECT * FROM t1 WHERE b>11 ORDER BY b DESC;
+ }
+} {GT(c0,11)}
+do_test 4.2 {
+ p5_of_opcode db OpenRead {
+ SELECT * FROM t1 WHERE b>11;
+ }
+} {2 0}
+do_test 4.3asc {
+ p4_of_opcode db CursorHint {
+ SELECT c FROM t1 WHERE b<11 ORDER BY b ASC;
+ }
+} {LT(c0,11)}
+do_test 4.3desc {
+ p4_of_opcode db CursorHint {
+ SELECT c FROM t1 WHERE b<11 ORDER BY b DESC;
+ }
+} {}
+do_test 4.4 {
+ p5_of_opcode db OpenRead {
+ SELECT c FROM t1 WHERE b<11;
+ }
+} {0}
+
+do_test 4.5asc {
+ p4_of_opcode db CursorHint {
+ SELECT c FROM t1 WHERE b>=10 AND b<=20 ORDER BY b ASC;
+ }
+} {LE(c0,20)}
+do_test 4.5desc {
+ p4_of_opcode db CursorHint {
+ SELECT c FROM t1 WHERE b>=10 AND b<=20 ORDER BY b DESC;
+ }
+} {GE(c0,10)}
+
+# If there are any equality terms used in the constraint, then all terms
+# should be hinted.
+#
+do_test 4.6asc {
+ p4_of_opcode db CursorHint {
+ SELECT rowid FROM t1 WHERE b=22 AND c>=10 AND c<=20 ORDER BY b,c ASC;
+ }
+} {AND(AND(EQ(c0,22),GE(c1,10)),LE(c1,20))}
+do_test 4.6desc {
+ p4_of_opcode db CursorHint {
+ SELECT rowid FROM t1 WHERE b=22 AND c>=10 AND c<=20 ORDER BY b,c DESC;
+ }
+} {AND(AND(EQ(c0,22),GE(c1,10)),LE(c1,20))}
+
+finish_test
diff --git a/test/cursorhint2.test b/test/cursorhint2.test
new file mode 100644
index 0000000..a78d151
--- /dev/null
+++ b/test/cursorhint2.test
@@ -0,0 +1,204 @@
+# 2016 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus is on testing that cursor-hints are correct for queries
+# involving LEFT JOIN.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix cursorhint2
+
+ifcapable !cursorhints {
+ finish_test
+ return
+}
+
+proc extract_hints {sql} {
+
+ db eval "SELECT tbl_name, rootpage FROM sqlite_master where rootpage" {
+ set lookup($rootpage) $tbl_name
+ }
+
+ set ret [list]
+ db eval "EXPLAIN $sql" a {
+ switch -- $a(opcode) {
+ OpenRead {
+ set csr($a(p1)) $lookup($a(p2))
+ }
+ CursorHint {
+ lappend ret $csr($a(p1)) $a(p4)
+ }
+ }
+ }
+
+ set ret
+}
+
+proc do_extract_hints_test {tn sql ret} {
+ uplevel [list do_test $tn [list extract_hints $sql] [list {*}$ret]]
+}
+
+do_execsql_test 1.0 {
+ PRAGMA automatic_index = 0;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ CREATE TABLE t3(e, f);
+}
+
+do_extract_hints_test 1.1 {
+ SELECT * FROM t1 WHERE a=1;
+} {
+ t1 EQ(c0,1)
+}
+
+do_extract_hints_test 1.2 {
+ SELECT * FROM t1 CROSS JOIN t2 ON (a=c) WHERE d IS NULL;
+} {
+ t2 {AND(ISNULL(c1),EQ(r[1],c0))}
+}
+
+do_extract_hints_test 1.3 {
+ SELECT * FROM t1 LEFT JOIN t2 ON (a=c) WHERE d IS NULL;
+} {
+ t2 {EQ(r[2],c0)}
+}
+
+do_extract_hints_test 1.4 {
+ SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND a=10) WHERE d IS NULL;
+} {
+ t2 {AND(EQ(r[2],c0),EQ(r[3],10))}
+}
+
+do_extract_hints_test 1.5 {
+ SELECT * FROM t1 CROSS JOIN t2 ON (a=c AND a=10) WHERE d IS NULL;
+} {
+ t1 EQ(c0,10) t2 {AND(ISNULL(c1),EQ(r[3],c0))}
+}
+
+do_extract_hints_test 1.6 {
+ SELECT * FROM t1 LEFT JOIN t2 ON (a=c) LEFT JOIN t3 ON (d=f);
+} {
+ t2 {EQ(r[2],c0)} t3 {EQ(r[6],c1)}
+}
+
+if 0 {
+ do_extract_hints_test 1.7 {
+ SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND d=e) LEFT JOIN t3 ON (d=f);
+ } {
+ t2 {EQ(r[2],c0)} t3 {AND(EQ(r[6],c0),EQ(r[7],c1))}
+ }
+}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 2.0 {
+ CREATE TABLE x1(x, y);
+ CREATE TABLE x2(a, b);
+}
+
+do_extract_hints_test 2.1 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE b IS NULL;
+} {
+ x2 {EQ(c0,r[2])}
+}
+
+do_extract_hints_test 2.2 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE b IS +NULL;
+} {
+ x2 {EQ(c0,r[2])}
+}
+
+do_extract_hints_test 2.3 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 1 = (b IS NULL)
+} {
+ x2 {EQ(c0,r[2])}
+}
+
+do_extract_hints_test 2.4 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 1 = coalesce(b, 1)
+} {
+ x2 {EQ(c0,r[2])}
+}
+
+do_extract_hints_test 2.5 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 1 = coalesce(b, 1)
+} {
+ x2 {EQ(c0,r[2])}
+}
+
+if {0} {
+ # These tests no longer work due to the LEFT-JOIN strength reduction
+ # optimization
+ do_extract_hints_test 2.6 {
+ SELECT * FROM x1 CROSS JOIN x2 ON (a=x) WHERE 0 = (b IS NOT NULL)
+ } {
+ x2 {EQ(c0,r[2])}
+ }
+
+ do_extract_hints_test 2.7 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 0 = (b IS NOT +NULL)
+ } {
+ x2 {EQ(c0,r[2])}
+ }
+
+ do_extract_hints_test 2.8 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE b IS NOT +NULL
+ } {
+ x2 {EQ(c0,r[2])}
+ }
+
+ do_extract_hints_test 2.9 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x)
+ WHERE CASE b WHEN 0 THEN 0 ELSE 1 END;
+ } {
+ x2 {EQ(c0,r[2])}
+ }
+
+ do_extract_hints_test 2.10 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE x2.b = 32+32
+ } {
+ x2 {AND(EQ(c1,ADD(32,32)),EQ(c0,r[2]))}
+ }
+
+ ifcapable !icu {
+ # This test only works using the built-in LIKE, not the ICU LIKE extension.
+ do_extract_hints_test 2.11 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE x2.b LIKE 'abc%'
+ } {
+ x2 {AND(expr,EQ(c0,r[2]))}
+ }
+ }
+}
+
+do_extract_hints_test 2.12 {
+ SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE coalesce(x2.b, 1)
+} {
+ x2 {EQ(c0,r[2])}
+}
+
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1 (i1 TEXT);
+ CREATE TABLE t2 (i2 TEXT UNIQUE);
+ INSERT INTO t1 VALUES('0');
+ INSERT INTO t2 VALUES('0');
+}
+
+do_extract_hints_test 3.1 {
+ SELECT * FROM t1 CROSS JOIN t2 WHERE (t1.i1 = t2.i2) AND t2.i2 = 1;
+} {
+ t1 {EQ(c0,r[1])} t2 EQ(c0,1)
+}
+
+
+finish_test
diff --git a/test/dataversion1.test b/test/dataversion1.test
new file mode 100644
index 0000000..55f7aad
--- /dev/null
+++ b/test/dataversion1.test
@@ -0,0 +1,87 @@
+# 2018-07-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.
+#
+#***********************************************************************
+#
+# Test case for SQLITE_FCNTL_DATA_VERSION
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Construct a database and get its initial data version
+sqlite3 db test.db
+do_test dataversion1-100 {
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(99);
+ SELECT * FROM t1;
+ }
+} {99}
+set dv1 [file_control_data_version db main]
+
+# The data version does not change by ATTACH or by changes to
+# other schemas within the same connection.
+#
+do_test dataversion1-101 {
+ db eval {
+ ATTACH ':memory:' AS aux1;
+ CREATE TABLE aux1.t2(y);
+ CREATE TEMP TABLE t3(z);
+ }
+ file_control_data_version db main
+} $dv1
+
+# The data version does change when SQL modifies the table
+do_test dataversion1-110 {
+ db eval {
+ UPDATE t1 SET x=x+1;
+ }
+ set dv2 [file_control_data_version db]
+ expr {$::dv1==$dv2}
+} {0}
+
+# But the data version is constant if there are changes to other
+# schemas
+set dv1 [file_control_data_version db main]
+do_test dataversion1-120 {
+ db eval {
+ UPDATE t2 SET y=y+1;
+ }
+ file_control_data_version db
+} $dv1
+
+# Changes to the database via another connection are not detected
+# until there is a read transaction.
+#
+sqlite3 db2 test.db
+do_test dataversion1-130 {
+ db2 eval {
+ SELECT * FROM t1
+ }
+} {100}
+do_test dataversion1-131 {
+ file_control_data_version db
+} $dv1
+do_test dataversion1-132 {
+ db2 eval {
+ UPDATE t1 SET x=x+1;
+ }
+ set dv2 [file_control_data_version db]
+ expr {$::dv1==$dv2}
+} {1}
+do_test dataversion1-133 {
+ db eval {SELECT * FROM t1}
+ set dv2 [file_control_data_version db]
+ expr {$::dv1==$dv2}
+} {0}
+
+
+
+finish_test
diff --git a/test/date.test b/test/date.test
new file mode 100644
index 0000000..62233ad
--- /dev/null
+++ b/test/date.test
@@ -0,0 +1,547 @@
+# 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(1721059.5) 1721059.5
+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.024264259
+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.
+#
+# Use SQLITE_TESTCTRL_LOCALTIME_FAULT=2 to set an alternative localtime_r()
+# implementation that is not locale-dependent. This testing localtime_r()
+# operates as follows:
+#
+# (1) Localtime is 30 minutes earlier than (west of) UTC on
+# even days (counting from 1970-01-01)
+#
+# (2) Localtime is 30 minutes later than (east of) UTC on odd days.
+#
+# (3) The function fails for the specific date/time value
+# of 2000-05-29 14:16:00 in order to test the ability of
+# SQLite to deal with localtime_r() failures.
+#
+proc local_to_utc {tn utc local} {
+ do_execsql_test date-$tn "SELECT datetime('$utc','localtime')" [list $local]
+}
+proc utc_to_local {tn local utc} {
+ do_execsql_test date-$tn "SELECT datetime('$local','utc')" [list $utc]
+}
+
+sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 2
+local_to_utc 6.1 {2000-10-29 12:00:00} {2000-10-29 12:30:00}
+utc_to_local 6.2 {2000-10-29 12:30:00} {2000-10-29 12:00:00}
+local_to_utc 6.3 {2000-10-30 12:00:00} {2000-10-30 11:30:00}
+utc_to_local 6.4 {2000-10-30 11:30:00} {2000-10-30 12:00:00}
+
+local_to_utc 6.5 {2000-10-28 23:59:59} {2000-10-28 23:29:59}
+local_to_utc 6.6 {2000-10-29 00:00:00} {2000-10-29 00:30:00}
+
+# The previous two cases establish that no such localtime as
+# 2000-10-29 00:10:00 exists. Verify that we get a reasonable
+# answer if we try to convert this non-existant localtime to utc?
+#
+utc_to_local 6.7 {2000-10-29 00:10:00} {2000-10-28 23:40:00}
+
+local_to_utc 6.8 {2022-02-10 23:59:59} {2022-02-11 00:29:59}
+local_to_utc 6.9 {2022-02-11 00:00:00} {2022-02-10 23:30:00}
+local_to_utc 6.10 {2022-02-10 23:45:00} {2022-02-11 00:15:00}
+local_to_utc 6.11 {2022-02-11 00:45:00} {2022-02-11 00:15:00}
+
+# The previous two cases show that two different UTC values give
+# the same localtime of 2022-02-11 00:15:00. When converting from
+# that localtime back to UTC, we should get one or the other of
+# the two UTC values.
+#
+utc_to_local 6.12 {2022-02-11 00:15:00} {2022-02-11 00:45:00}
+
+# If localtime_r() fails, the datetime() SQL function should raise an error
+#
+do_catchsql_test date-6.20 {
+ SELECT datetime('2000-05-29 14:16:00','localtime');
+} {1 {local time unavailable}}
+
+# Modifiers work for dates that are way out of band for localtime_r()
+#
+local_to_utc 6.21 {1800-10-29 12:00:00} {1800-10-29 12:30:00}
+utc_to_local 6.22 {1800-10-29 12:30:00} {1800-10-29 12:00:00}
+local_to_utc 6.23 {3000-10-30 12:00:00} {3000-10-30 11:30:00}
+utc_to_local 6.24 {3000-10-30 11:30:00} {3000-10-30 12:00:00}
+
+# Restore the use of the OS localtime_r() before going on...
+sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 0
+
+# 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}
+ }
+}
+
+# Verify that multiple calls to date functions with 'now' return the
+# same answer.
+#
+# EVIDENCE-OF: R-34818-13664 The 'now' argument to date and time
+# functions always returns exactly the same value for multiple
+# invocations within the same sqlite3_step() call.
+#
+proc sleeper {} {after 100}
+do_test date-15.1 {
+ db func sleeper sleeper
+ db eval {
+ SELECT c - a FROM (SELECT julianday('now') AS a,
+ sleeper(), julianday('now') AS c);
+ }
+} {0.0}
+do_test date-15.2 {
+ db eval {
+ SELECT a==b FROM (SELECT current_timestamp AS a,
+ sleeper(), current_timestamp AS b);
+ }
+} {1}
+
+# Tests of extreme values in date/time functions. Run with UBSan or the
+# equivalent to verify no signed interger overflow warnings.
+#
+datetest 16.1 {date(147483649)} NULL
+datetest 16.2 {datetime(0)} {-4713-11-24 12:00:00}
+datetest 16.3 {datetime(5373484.49999999)} {9999-12-31 23:59:59}
+datetest 16.4 {julianday('-4713-11-24 12:00:00')} 0.0
+datetest 16.5 {julianday('9999-12-31 23:59:59.999')} 5373484.49999999
+datetest 16.6 {datetime(0,'+464269060799 seconds')} {9999-12-31 23:59:59}
+datetest 16.7 {datetime(0,'+464269060800 seconds')} NULL
+datetest 16.8 {datetime(0,'+7737817679 minutes')} {9999-12-31 23:59:00}
+datetest 16.9 {datetime(0,'+7737817680 minutes')} NULL
+datetest 16.10 {datetime(0,'+128963627 hours')} {9999-12-31 23:00:00}
+datetest 16.11 {datetime(0,'+128963628 hours')} NULL
+datetest 16.12 {datetime(0,'+5373484 days')} {9999-12-31 12:00:00}
+datetest 16.13 {datetime(0,'+5373485 days')} NULL
+datetest 16.14 {datetime(0,'+176545 months')} {9999-12-24 12:00:00}
+datetest 16.15 {datetime(0,'+176546 months')} NULL
+datetest 16.16 {datetime(0,'+14712 years')} {9999-11-24 12:00:00}
+datetest 16.17 {datetime(0,'+14713 years')} NULL
+datetest 16.20 {datetime(5373484.4999999,'-464269060799 seconds')} \
+ {-4713-11-24 12:00:00}
+datetest 16.21 {datetime(5373484,'-464269060800 seconds')} NULL
+datetest 16.22 {datetime(5373484.4999999,'-7737817679 minutes')} \
+ {-4713-11-24 12:00:59}
+datetest 16.23 {datetime(5373484,'-7737817680 minutes')} NULL
+datetest 16.24 {datetime(5373484.4999999,'-128963627 hours')} \
+ {-4713-11-24 12:59:59}
+datetest 16.25 {datetime(5373484,'-128963628 hours')} NULL
+datetest 16.26 {datetime(5373484,'-5373484 days')} {-4713-11-24 12:00:00}
+datetest 16.27 {datetime(5373484,'-5373485 days')} NULL
+datetest 16.28 {datetime(5373484,'-176545 months')} {-4713-12-01 12:00:00}
+datetest 16.29 {datetime(5373484,'-176546 months')} NULL
+datetest 16.30 {datetime(5373484,'-14712 years')} {-4713-12-31 12:00:00}
+datetest 16.31 {datetime(5373484,'-14713 years')} NULL
+
+# 2017-03-02: Wrong 'start of day' computation.
+# https://www.sqlite.org/src/info/6097cb92745327a1
+#
+datetest 17.1 {datetime(2457754, 'start of day')} {2016-12-31 00:00:00}
+datetest 17.2 {datetime(2457828)} {2017-03-15 12:00:00}
+datetest 17.3 {datetime(2457828,'start of day')} {2017-03-15 00:00:00}
+datetest 17.4 {datetime(2457828,'start of month')} {2017-03-01 00:00:00}
+datetest 17.5 {datetime(2457828,'start of year')} {2017-01-01 00:00:00}
+datetest 17.6 {datetime(37,'start of year')} NULL
+datetest 17.7 {datetime(38,'start of year')} {-4712-01-01 00:00:00}
+
+# 2022-03-04 https://sqlite.org/forum/forumpost/2ffbaa2c3fd7fb82
+# The 'localtime' modifier should preserve fractional seconds.
+#
+datetest 18.1 {strftime('%f',1.234,'unixepoch','localtime')} {01.234}
+
+finish_test
diff --git a/test/date2.test b/test/date2.test
new file mode 100644
index 0000000..a16e25c
--- /dev/null
+++ b/test/date2.test
@@ -0,0 +1,176 @@
+# 2017-07-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 file is testing date and time functions used in
+# check constraints and index expressions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Skip this whole file if date and time functions are omitted
+# at compile-time
+#
+ifcapable {!datetime} {
+ finish_test
+ return
+}
+
+do_execsql_test date2-100 {
+ CREATE TABLE t1(x, y, CHECK( date(x) BETWEEN '2017-07-01' AND '2017-07-31' ));
+ INSERT INTO t1(x,y) VALUES('2017-07-20','one');
+} {}
+do_catchsql_test date2-110 {
+ INSERT INTO t1(x,y) VALUES('now','two');
+} {1 {non-deterministic use of date() in a CHECK constraint}}
+do_execsql_test date2-120 {
+ SELECT * FROM t1;
+} {2017-07-20 one}
+do_catchsql_test date2-130 {
+ INSERT INTO t1(x,y) VALUES('2017-08-01','two');
+} {1 {CHECK constraint failed: date(x) BETWEEN '2017-07-01' AND '2017-07-31'}}
+
+# 2021-03-16 Forum post https://sqlite.org/forum/forumpost/464afd4086
+do_catchsql_test date2-140 {
+ DROP TABLE t1;
+ CREATE TABLE t1(x, y, z AS (date()));
+ INSERT INTO t1(x,y) VALUES(1,2);
+} {1 {non-deterministic use of date() in a generated column}}
+
+do_execsql_test date2-200 {
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2(x,y) VALUES(1, '2017-07-20'), (2, 'xyzzy');
+ CREATE INDEX t2y ON t2(date(y));
+}
+do_catchsql_test date2-210 {
+ INSERT INTO t2(x,y) VALUES(3, 'now');
+} {1 {non-deterministic use of date() in an index}}
+do_execsql_test date2-220 {
+ SELECT x, y FROM t2 ORDER BY x;
+} {1 2017-07-20 2 xyzzy}
+
+do_execsql_test date2-300 {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t3(a,b) SELECT x, julianday('2017-07-01')+x FROM c;
+ UPDATE t3 SET b='now' WHERE a=500;
+}
+do_catchsql_test date2-310 {
+ CREATE INDEX t3b1 ON t3(datetime(b));
+} {1 {non-deterministic use of datetime() in an index}}
+do_catchsql_test date2-320 {
+ CREATE INDEX t3b1 ON t3(datetime(b)) WHERE typeof(b)='real';
+} {0 {}}
+do_execsql_test date2-330 {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t3
+ WHERE typeof(b)='real'
+ AND datetime(b) BETWEEN '2017-07-04' AND '2017-07-08';
+} {/USING INDEX t3b/}
+do_execsql_test date2-331 {
+ SELECT a FROM t3
+ WHERE typeof(b)='real'
+ AND datetime(b) BETWEEN '2017-07-04' AND '2017-07-08'
+ ORDER BY a;
+} {3 4 5 6}
+
+do_execsql_test date2-400 {
+ CREATE TABLE t4(a INTEGER PRIMARY KEY,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t4(a,b) SELECT x, julianday('2017-07-01')+x FROM c;
+ UPDATE t4 SET b='now' WHERE a=500;
+}
+do_catchsql_test date2-410 {
+ CREATE INDEX t4b1 ON t4(b)
+ WHERE date(b) BETWEEN '2017-06-01' AND '2017-08-31';
+} {1 {non-deterministic use of date() in an index}}
+do_execsql_test date2-420 {
+ DELETE FROM t4 WHERE a=500;
+ CREATE INDEX t4b1 ON t4(b)
+ WHERE date(b) BETWEEN '2017-06-01' AND '2017-08-31';
+}
+do_catchsql_test date2-430 {
+ INSERT INTO t4(a,b) VALUES(9999,'now');
+} {1 {non-deterministic use of date() in an index}}
+
+do_execsql_test date2-500 {
+ CREATE TABLE mods(x);
+ INSERT INTO mods(x) VALUES
+ ('+10 days'),
+ ('-10 days'),
+ ('+10 hours'),
+ ('-10 hours'),
+ ('+10 minutes'),
+ ('-10 minutes'),
+ ('+10 seconds'),
+ ('-10 seconds'),
+ ('+10 months'),
+ ('-10 months'),
+ ('+10 years'),
+ ('-10 years'),
+ ('start of month'),
+ ('start of year'),
+ ('start of day'),
+ ('weekday 1'),
+ ('unixepoch');
+ CREATE TABLE t5(y,m);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ INSERT INTO t5(y,m) SELECT julianday('2017-07-01')+c.x, mods.x FROM c, mods;
+ CREATE INDEX t5x1 on t5(y) WHERE datetime(y,m) IS NOT NULL;
+}
+do_catchsql_test date2-510 {
+ INSERT INTO t5(y,m) VALUES('2017-07-20','localtime');
+} {1 {non-deterministic use of datetime() in an index}}
+do_catchsql_test date2-520 {
+ INSERT INTO t5(y,m) VALUES('2017-07-20','utc');
+} {1 {non-deterministic use of datetime() in an index}}
+
+# 2019-10-30 Ticket 830277d9db6c3ba1
+#
+do_catchsql_test date2-600 {
+ CREATE TABLE t600(a REAL CHECK( a<julianday('now') ));
+ INSERT INTO t600(a) VALUES(1.0);
+} {1 {non-deterministic use of julianday() in a CHECK constraint}}
+do_catchsql_test date2-601 {
+ CREATE TABLE t601(a REAL, b TEXT, CHECK( a<julianday(b) ));
+ INSERT INTO t601(a,b) VALUES(1.0, '1970-01-01');
+} {0 {}}
+do_catchsql_test date2-602 {
+ INSERT INTO t601(a,b) VALUES(1e100, '1970-01-01');
+} {1 {CHECK constraint failed: a<julianday(b)}}
+do_catchsql_test date2-603 {
+ INSERT INTO t601(a,b) VALUES(10, 'now');
+} {1 {non-deterministic use of julianday() in a CHECK constraint}}
+do_catchsql_test date2-604 {
+ INSERT INTO t600(a) VALUES(julianday('now')+10);
+} {1 {non-deterministic use of julianday() in a CHECK constraint}}
+
+
+do_catchsql_test date2-610 {
+ CREATE TABLE t610(a,b);
+ CREATE INDEX t610x1 ON t610(julianday('now')+b);
+ INSERT INTO t610(a,b) VALUES(123,456);
+} {1 {non-deterministic use of julianday() in an index}}
+do_catchsql_test date2-611 {
+ CREATE TABLE t611(a,b);
+ CREATE INDEX t611x1 ON t611(julianday(a)+b);
+ INSERT INTO t611(a,b) VALUES('1970-01-01',10.0);
+} {0 {}}
+do_catchsql_test date2-612 {
+ INSERT INTO t611(a,b) VALUES('now',10.0);
+} {1 {non-deterministic use of julianday() in an index}}
+
+do_catchsql_test date3-620 {
+ CREATE TABLE t620(a, b AS (a+julianday('now')));
+ INSERT INTO t620 VALUES(10);
+} {1 {non-deterministic use of julianday() in a generated column}}
+
+finish_test
diff --git a/test/date3.test b/test/date3.test
new file mode 100644
index 0000000..1798a34
--- /dev/null
+++ b/test/date3.test
@@ -0,0 +1,149 @@
+# 2022-01-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 date and time functions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# 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 date3-$tnum [subst {
+ execsql "SELECT coalesce($expr,'NULL')"
+ }] [list $result]
+}
+set tcl_precision 15
+
+# EVIDENCE-OF: R-45708-63005 unixepoch(time-value, modifier, modifier,
+# ...)
+#
+datetest 1.1 {unixepoch('1970-01-01')} {0}
+datetest 1.2 {unixepoch('1969-12-31 23:59:59')} {-1}
+datetest 1.3 {unixepoch('2106-02-07 06:28:15')} {4294967295}
+datetest 1.4 {unixepoch('2106-02-07 06:28:16')} {4294967296}
+datetest 1.5 {unixepoch('9999-12-31 23:59:59')} {253402300799}
+datetest 1.6 {unixepoch('0000-01-01 00:00:00')} {-62167219200}
+
+# EVIDENCE-OF: R-30877-63179 The unixepoch() function returns a unix
+# timestamp - the number of seconds since 1970-01-01 00:00:00 UTC.
+#
+for {set i 1} {$i<=100} {incr i} {
+ set x [expr {int(rand()*0xfffffffff)-0xffffffff}]
+ datetest 1.7.$i "unixepoch($x,'unixepoch')==$x" {1}
+}
+
+# EVIDENCE-OF: R-62992-54137 The unixepoch() always returns an integer,
+# even if the input time-value has millisecond precision.
+#
+datetest 1.8 {unixepoch('2022-01-27 12:59:28.052')} {1643288368}
+
+# EVIDENCE-OF: R-05412-24332 If the time-value is numeric (the
+# DDDDDDDDDD format) then the 'auto' modifier causes the time-value to
+# interpreted as either a julian day number or a unix timestamp,
+# depending on its magnitude.
+#
+# EVIDENCE-OF: R-56763-40111 If the value is between 0.0 and
+# 5373484.499999, then it is interpreted as a julian day number
+# (corresponding to dates between -4713-11-24 12:00:00 and 9999-12-31
+# 23:59:59, inclusive).
+#
+# EVIDENCE-OF: R-07289-49223 For numeric values outside of the range of
+# valid julian day numbers, but within the range of -210866760000 to
+# 253402300799, the 'auto' modifier causes the value to be interpreted
+# as a unix timestamp.
+#
+# EVIDENCE-OF: R-20795-34947 Other numeric values are out of range and
+# cause a NULL return.
+#
+foreach {tn jd date} {
+ 2.1 0.0 {-4713-11-24 12:00:00}
+ 2.2 5373484.4999999 {9999-12-31 23:59:59}
+ 2.3 2440587.5 {1970-01-01 00:00:00}
+ 2.4 2440587.49998843 {1969-12-31 23:59:59}
+ 2.5 2440615.7475463 {1970-01-29 05:56:28}
+
+ 2.10 -1 {1969-12-31 23:59:59}
+ 2.11 5373485 {1970-03-04 04:38:05}
+ 2.12 -210866760000 {-4713-11-24 12:00:00}
+ 2.13 253402300799 {9999-12-31 23:59:59}
+
+ 2.20 -210866760001 {NULL}
+ 2.21 253402300800 {NULL}
+} {
+ datetest $tn "datetime($jd,'auto')" $date
+}
+
+# EVIDENCE-OF: R-38886-35357 The 'auto' modifier is a no-op for text
+# time-values.
+#
+datetest 2.30 {date('2022-01-29','auto')==date('2022-01-29')} {1}
+
+# EVIDENCE-OF: R-53132-26856 The 'auto' modifier can be used to work
+# with date/time values even in cases where it is not known if the
+# julian day number or unix timestamp formats are in use.
+#
+do_execsql_test date3-2.40 {
+ WITH tx(timeval,datetime) AS (
+ VALUES('2022-01-27 13:15:44','2022-01-27 13:15:44'),
+ (2459607.05260275,'2022-01-27 13:15:44'),
+ (1643289344,'2022-01-27 13:15:44')
+ )
+ SELECT datetime(timeval,'auto') == datetime FROM tx;
+} {1 1 1}
+
+# EVIDENCE-OF: R-49255-55373 The "unixepoch" modifier (11) only works if
+# it immediately follows a time value in the DDDDDDDDDD format.
+#
+# EVIDENCE-OF: R-23075-39245 This modifier causes the DDDDDDDDDD to be
+# interpreted not as a Julian day number as it normally would be, but as
+# Unix Time - the number of seconds since 1970.
+#
+datetest 3.1 {datetime(2459607.05,'+1 hour','unixepoch')} {NULL}
+datetest 3.2 {datetime(2459607.05,'unixepoch','+1 hour')} {1970-01-29 12:13:27}
+
+# EVIDENCE-OF: R-21150-52363 The "julianday" modifier must immediately
+# follow the initial time-value which must be of the form DDDDDDDDD.
+#
+# EVIDENCE-OF: R-31176-64601 Any other use of the 'julianday' modifier
+# is an error and causes the function to return NULL.
+#
+# EVIDENCE-OF: R-32483-36353 The 'julianday' modifier forces the
+# time-value number to be interpreted as a julian-day number.
+#
+# EVIDENCE-OF: R-25859-20124 The only difference is that adding
+# 'julianday' forces the DDDDDDDDD time-value format, and causes a NULL
+# to be returned if any other time-value format is used.
+#
+datetest 4.1 {datetime(2459607,'julianday')} {2022-01-27 12:00:00}
+datetest 4.2 {datetime(2459607,'+1 hour','julianday')} {NULL}
+datetest 4.3 {datetime('2022-01-27','julianday')} {NULL}
+
+
+
+# EVIDENCE-OF: R-33431-18865 Unix timestamps for the first 63 days of
+# 1970 will be interpreted as julian day numbers.
+#
+do_execsql_test date3-5.0 {
+ WITH inc(x) AS (VALUES(-10) UNION ALL SELECT x+1 FROM inc WHERE x<100)
+ SELECT count(*) FROM inc
+ WHERE datetime('1970-01-01',format('%+d days',x))
+ <> datetime(unixepoch('1970-01-01',format('%+d days',x)),'auto');
+} {63}
+
+finish_test
diff --git a/test/dbdata.test b/test/dbdata.test
new file mode 100644
index 0000000..5b1150c
--- /dev/null
+++ b/test/dbdata.test
@@ -0,0 +1,115 @@
+# 2019-04-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 sqlite_dbpage virtual table.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix dbdata
+
+ifcapable !vtab||!compound {
+ finish_test
+ return
+}
+if { [catch { db enable_load_extension 1 }]
+ || [catch { db eval { SELECT load_extension('../dbdata') } }]
+} {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE T1(a, b);
+ INSERT INTO t1(rowid, a ,b) VALUES(5, 'v', 'five');
+ INSERT INTO t1(rowid, a, b) VALUES(10, 'x', 'ten');
+}
+
+do_execsql_test 1.1 {
+ SELECT pgno, cell, field, quote(value) FROM sqlite_dbdata WHERE pgno=2;
+} {
+ 2 0 -1 5
+ 2 0 0 'v'
+ 2 0 1 'five'
+ 2 1 -1 10
+ 2 1 0 'x'
+ 2 1 1 'ten'
+}
+
+breakpoint
+do_execsql_test 1.2 {
+ SELECT pgno, cell, field, quote(value) FROM sqlite_dbdata;
+} {
+ 1 0 -1 1
+ 1 0 0 'table'
+ 1 0 1 'T1'
+ 1 0 2 'T1'
+ 1 0 3 2
+ 1 0 4 {'CREATE TABLE T1(a, b)'}
+ 2 0 -1 5
+ 2 0 0 'v'
+ 2 0 1 'five'
+ 2 1 -1 10
+ 2 1 0 'x'
+ 2 1 1 'ten'
+}
+
+set big [string repeat big 2000]
+do_execsql_test 1.3 {
+ INSERT INTO t1 VALUES(NULL, $big);
+ SELECT value FROM sqlite_dbdata WHERE pgno=2 AND cell=2 AND field=1;
+} $big
+
+do_execsql_test 1.4 {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(NULL, randomblob(5050));
+}
+do_test 1.5 {
+ execsql {
+ SELECT quote(value) FROM sqlite_dbdata WHERE pgno=2 AND cell=0 AND field=1;
+ }
+} [db one {SELECT quote(b) FROM t1}]
+
+#-------------------------------------------------------------------------
+reset_db
+db enable_load_extension 1
+db eval { SELECT load_extension('../dbdata') }
+
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10
+ )
+ INSERT INTO t1 SELECT randomblob(900) FROM s;
+}
+
+do_execsql_test 2.1 {
+ SELECT * FROM sqlite_dbptr WHERE pgno=2;
+} {
+ 2 25 2 6 2 7 2 9 2 11 2 13 2 15 2 17 2 19 2 21
+}
+
+do_execsql_test 2.2 {
+ SELECT * FROM sqlite_dbptr WHERE pgno=3;
+} {
+ 3 24 3 23
+}
+
+do_execsql_test 2.3 {
+ SELECT * FROM sqlite_dbptr
+} {
+ 2 25 2 6 2 7 2 9 2 11 2 13 2 15 2 17 2 19 2 21
+ 3 24 3 23
+}
+
+
+finish_test
diff --git a/test/dbfuzz.c b/test/dbfuzz.c
new file mode 100644
index 0000000..ca1c6ea
--- /dev/null
+++ b/test/dbfuzz.c
@@ -0,0 +1,754 @@
+/*
+** 2016-12-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 program is designed for fuzz-testing SQLite database files.
+**
+** This program reads fuzzed database files from the disk files named
+** on the command-line. Each database is loaded into an in-memory
+** filesystem so that the original database file is unmolested.
+**
+** The fuzzed database is then opened, and series of SQL statements
+** are run against the database to ensure that SQLite can safely handle
+** the fuzzed database.
+*/
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ctype.h>
+#define ISSPACE(X) isspace((unsigned char)(X))
+#define ISDIGIT(X) isdigit((unsigned char)(X))
+#include "sqlite3.h"
+#ifdef __unix__
+# include <signal.h>
+# include <unistd.h>
+#endif
+
+/*
+** Print sketchy documentation for this utility program
+*/
+static void showHelp(const char *zArgv0){
+ printf("Usage: %s [options] DATABASE ...\n", zArgv0);
+ printf(
+"Read databases into an in-memory filesystem. Run test SQL as specified\n"
+"by command-line arguments or from\n"
+"\n"
+" SELECT group_concat(sql) FROM autoexec;\n"
+"\n"
+"Options:\n"
+" --help Show this help text\n"
+" -q|--quiet Reduced output\n"
+" --limit-mem N Limit memory used by test SQLite instances to N bytes\n"
+" --limit-vdbe Panic if any test runs for more than 100,000 cycles\n"
+" --no-lookaside Disable the lookaside memory allocator\n"
+" --timeout N Timeout after N seconds.\n"
+" --trace Show the results of each SQL command\n"
+" -v|--verbose Increased output. Repeat for more output.\n"
+ );
+ exit(0);
+}
+
+/*
+** Print an error message and quit.
+*/
+static void fatalError(const char *zFormat, ...){
+ va_list ap;
+ va_start(ap, zFormat);
+ vfprintf(stderr, zFormat, ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+ exit(1);
+}
+
+/*
+** Files in the virtual file system.
+*/
+typedef struct VFile VFile;
+typedef struct VHandle VHandle;
+struct VFile {
+ char *zFilename; /* Filename. NULL for delete-on-close. From malloc() */
+ int sz; /* Size of the file in bytes */
+ int nRef; /* Number of references to this file */
+ unsigned char *a; /* Content of the file. From malloc() */
+};
+struct VHandle {
+ sqlite3_file base; /* Base class. Must be first */
+ VFile *pVFile; /* The underlying file */
+};
+
+/*
+** Maximum number of files in the in-memory virtual filesystem.
+*/
+#define MX_FILE 10
+
+/*
+** Maximum allowed file size
+*/
+#define MX_FILE_SZ 1000000
+
+/*
+** All global variables are gathered into the "g" singleton.
+*/
+static struct GlobalVars {
+ VFile aFile[MX_FILE]; /* The virtual filesystem */
+} g;
+
+
+/*
+** Initialize the virtual file system.
+*/
+static void formatVfs(void){
+ int i;
+ for(i=0; i<MX_FILE; i++){
+ g.aFile[i].sz = -1;
+ g.aFile[i].zFilename = 0;
+ g.aFile[i].a = 0;
+ g.aFile[i].nRef = 0;
+ }
+}
+
+
+/*
+** Erase all information in the virtual file system.
+*/
+static void reformatVfs(void){
+ int i;
+ for(i=0; i<MX_FILE; i++){
+ if( g.aFile[i].sz<0 ) continue;
+ if( g.aFile[i].zFilename ){
+ free(g.aFile[i].zFilename);
+ g.aFile[i].zFilename = 0;
+ }
+ if( g.aFile[i].nRef>0 ){
+ fatalError("file %d still open. nRef=%d", i, g.aFile[i].nRef);
+ }
+ g.aFile[i].sz = -1;
+ free(g.aFile[i].a);
+ g.aFile[i].a = 0;
+ g.aFile[i].nRef = 0;
+ }
+}
+
+/*
+** Find a VFile by name
+*/
+static VFile *findVFile(const char *zName){
+ int i;
+ if( zName==0 ) return 0;
+ for(i=0; i<MX_FILE; i++){
+ if( g.aFile[i].zFilename==0 ) continue;
+ if( strcmp(g.aFile[i].zFilename, zName)==0 ) return &g.aFile[i];
+ }
+ return 0;
+}
+
+/*
+** Find a VFile called zName. Initialize it to the content of
+** disk file zDiskFile.
+**
+** Return NULL if the filesystem is full.
+*/
+static VFile *createVFile(const char *zName, const char *zDiskFile){
+ VFile *pNew = findVFile(zName);
+ int i;
+ FILE *in = 0;
+ long sz = 0;
+
+ if( pNew ) return pNew;
+ for(i=0; i<MX_FILE && g.aFile[i].sz>=0; i++){}
+ if( i>=MX_FILE ) return 0;
+ if( zDiskFile ){
+ in = fopen(zDiskFile, "rb");
+ if( in==0 ) fatalError("no such file: \"%s\"", zDiskFile);
+ fseek(in, 0, SEEK_END);
+ sz = ftell(in);
+ rewind(in);
+ }
+ pNew = &g.aFile[i];
+ if( zName ){
+ int nName = (int)strlen(zName)+1;
+ pNew->zFilename = malloc(nName);
+ if( pNew->zFilename==0 ){
+ if( in ) fclose(in);
+ return 0;
+ }
+ memcpy(pNew->zFilename, zName, nName);
+ }else{
+ pNew->zFilename = 0;
+ }
+ pNew->nRef = 0;
+ pNew->sz = sz;
+ pNew->a = malloc(sz);
+ if( sz>0 ){
+ if( pNew->a==0 || fread(pNew->a, sz, 1, in)<1 ){
+ free(pNew->zFilename);
+ free(pNew->a);
+ pNew->a = 0;
+ pNew->zFilename = 0;
+ pNew->sz = -1;
+ pNew = 0;
+ }
+ }
+ if( in ) fclose(in);
+ return pNew;
+}
+
+/* Methods for the VHandle object
+*/
+static int inmemClose(sqlite3_file *pFile){
+ VHandle *p = (VHandle*)pFile;
+ VFile *pVFile = p->pVFile;
+ pVFile->nRef--;
+ if( pVFile->nRef==0 && pVFile->zFilename==0 ){
+ pVFile->sz = -1;
+ free(pVFile->a);
+ pVFile->a = 0;
+ }
+ return SQLITE_OK;
+}
+static int inmemRead(
+ sqlite3_file *pFile, /* Read from this open file */
+ void *pData, /* Store content in this buffer */
+ int iAmt, /* Bytes of content */
+ sqlite3_int64 iOfst /* Start reading here */
+){
+ VHandle *pHandle = (VHandle*)pFile;
+ VFile *pVFile = pHandle->pVFile;
+ if( iOfst<0 || iOfst>=pVFile->sz ){
+ memset(pData, 0, iAmt);
+ return SQLITE_IOERR_SHORT_READ;
+ }
+ if( iOfst+iAmt>pVFile->sz ){
+ memset(pData, 0, iAmt);
+ iAmt = (int)(pVFile->sz - iOfst);
+ memcpy(pData, pVFile->a, iAmt);
+ return SQLITE_IOERR_SHORT_READ;
+ }
+ memcpy(pData, pVFile->a + iOfst, iAmt);
+ return SQLITE_OK;
+}
+static int inmemWrite(
+ sqlite3_file *pFile, /* Write to this file */
+ const void *pData, /* Content to write */
+ int iAmt, /* bytes to write */
+ sqlite3_int64 iOfst /* Start writing here */
+){
+ VHandle *pHandle = (VHandle*)pFile;
+ VFile *pVFile = pHandle->pVFile;
+ if( iOfst+iAmt > pVFile->sz ){
+ unsigned char *aNew;
+ if( iOfst+iAmt >= MX_FILE_SZ ){
+ return SQLITE_FULL;
+ }
+ aNew = realloc(pVFile->a, (int)(iOfst+iAmt));
+ if( aNew==0 ){
+ return SQLITE_FULL;
+ }
+ pVFile->a = aNew;
+ if( iOfst > pVFile->sz ){
+ memset(pVFile->a + pVFile->sz, 0, (int)(iOfst - pVFile->sz));
+ }
+ pVFile->sz = (int)(iOfst + iAmt);
+ }
+ memcpy(pVFile->a + iOfst, pData, iAmt);
+ return SQLITE_OK;
+}
+static int inmemTruncate(sqlite3_file *pFile, sqlite3_int64 iSize){
+ VHandle *pHandle = (VHandle*)pFile;
+ VFile *pVFile = pHandle->pVFile;
+ if( pVFile->sz>iSize && iSize>=0 ) pVFile->sz = (int)iSize;
+ return SQLITE_OK;
+}
+static int inmemSync(sqlite3_file *pFile, int flags){
+ return SQLITE_OK;
+}
+static int inmemFileSize(sqlite3_file *pFile, sqlite3_int64 *pSize){
+ *pSize = ((VHandle*)pFile)->pVFile->sz;
+ return SQLITE_OK;
+}
+static int inmemLock(sqlite3_file *pFile, int type){
+ return SQLITE_OK;
+}
+static int inmemUnlock(sqlite3_file *pFile, int type){
+ return SQLITE_OK;
+}
+static int inmemCheckReservedLock(sqlite3_file *pFile, int *pOut){
+ *pOut = 0;
+ return SQLITE_OK;
+}
+static int inmemFileControl(sqlite3_file *pFile, int op, void *pArg){
+ return SQLITE_NOTFOUND;
+}
+static int inmemSectorSize(sqlite3_file *pFile){
+ return 512;
+}
+static int inmemDeviceCharacteristics(sqlite3_file *pFile){
+ return
+ SQLITE_IOCAP_SAFE_APPEND |
+ SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
+ SQLITE_IOCAP_POWERSAFE_OVERWRITE;
+}
+
+
+/* Method table for VHandle
+*/
+static sqlite3_io_methods VHandleMethods = {
+ /* iVersion */ 1,
+ /* xClose */ inmemClose,
+ /* xRead */ inmemRead,
+ /* xWrite */ inmemWrite,
+ /* xTruncate */ inmemTruncate,
+ /* xSync */ inmemSync,
+ /* xFileSize */ inmemFileSize,
+ /* xLock */ inmemLock,
+ /* xUnlock */ inmemUnlock,
+ /* xCheck... */ inmemCheckReservedLock,
+ /* xFileCtrl */ inmemFileControl,
+ /* xSectorSz */ inmemSectorSize,
+ /* xDevchar */ inmemDeviceCharacteristics,
+ /* xShmMap */ 0,
+ /* xShmLock */ 0,
+ /* xShmBarrier */ 0,
+ /* xShmUnmap */ 0,
+ /* xFetch */ 0,
+ /* xUnfetch */ 0
+};
+
+/*
+** Open a new file in the inmem VFS. All files are anonymous and are
+** delete-on-close.
+*/
+static int inmemOpen(
+ sqlite3_vfs *pVfs,
+ const char *zFilename,
+ sqlite3_file *pFile,
+ int openFlags,
+ int *pOutFlags
+){
+ VFile *pVFile = createVFile(zFilename, 0);
+ VHandle *pHandle = (VHandle*)pFile;
+ if( pVFile==0 ){
+ return SQLITE_FULL;
+ }
+ pHandle->pVFile = pVFile;
+ pVFile->nRef++;
+ pFile->pMethods = &VHandleMethods;
+ if( pOutFlags ) *pOutFlags = openFlags;
+ return SQLITE_OK;
+}
+
+/*
+** Delete a file by name
+*/
+static int inmemDelete(
+ sqlite3_vfs *pVfs,
+ const char *zFilename,
+ int syncdir
+){
+ VFile *pVFile = findVFile(zFilename);
+ if( pVFile==0 ) return SQLITE_OK;
+ if( pVFile->nRef==0 ){
+ free(pVFile->zFilename);
+ pVFile->zFilename = 0;
+ pVFile->sz = -1;
+ free(pVFile->a);
+ pVFile->a = 0;
+ return SQLITE_OK;
+ }
+ return SQLITE_IOERR_DELETE;
+}
+
+/* Check for the existance of a file
+*/
+static int inmemAccess(
+ sqlite3_vfs *pVfs,
+ const char *zFilename,
+ int flags,
+ int *pResOut
+){
+ VFile *pVFile = findVFile(zFilename);
+ *pResOut = pVFile!=0;
+ return SQLITE_OK;
+}
+
+/* Get the canonical pathname for a file
+*/
+static int inmemFullPathname(
+ sqlite3_vfs *pVfs,
+ const char *zFilename,
+ int nOut,
+ char *zOut
+){
+ sqlite3_snprintf(nOut, zOut, "%s", zFilename);
+ return SQLITE_OK;
+}
+
+/*
+** Register the VFS that reads from the g.aFile[] set of files.
+*/
+static void inmemVfsRegister(void){
+ static sqlite3_vfs inmemVfs;
+ sqlite3_vfs *pDefault = sqlite3_vfs_find(0);
+ inmemVfs.iVersion = 3;
+ inmemVfs.szOsFile = sizeof(VHandle);
+ inmemVfs.mxPathname = 200;
+ inmemVfs.zName = "inmem";
+ inmemVfs.xOpen = inmemOpen;
+ inmemVfs.xDelete = inmemDelete;
+ inmemVfs.xAccess = inmemAccess;
+ inmemVfs.xFullPathname = inmemFullPathname;
+ inmemVfs.xRandomness = pDefault->xRandomness;
+ inmemVfs.xSleep = pDefault->xSleep;
+ inmemVfs.xCurrentTimeInt64 = pDefault->xCurrentTimeInt64;
+ sqlite3_vfs_register(&inmemVfs, 0);
+};
+
+/*
+** Timeout handler
+*/
+#ifdef __unix__
+static void timeoutHandler(int NotUsed){
+ (void)NotUsed;
+ fatalError("timeout\n");
+}
+#endif
+
+/*
+** Set the an alarm to go off after N seconds. Disable the alarm
+** if N==0
+*/
+static void setAlarm(int N){
+#ifdef __unix__
+ alarm(N);
+#else
+ (void)N;
+#endif
+}
+/***************************************************************************
+** String accumulator object
+*/
+typedef struct Str Str;
+struct Str {
+ char *z; /* The string. Memory from malloc() */
+ sqlite3_uint64 n; /* Bytes of input used */
+ sqlite3_uint64 nAlloc; /* Bytes allocated to z[] */
+ int oomErr; /* OOM error has been seen */
+};
+
+/* Initialize a Str object */
+static void StrInit(Str *p){
+ memset(p, 0, sizeof(*p));
+}
+
+/* Append text to the end of a Str object */
+static void StrAppend(Str *p, const char *z){
+ sqlite3_uint64 n = strlen(z);
+ if( p->n + n >= p->nAlloc ){
+ char *zNew;
+ sqlite3_uint64 nNew;
+ if( p->oomErr ) return;
+ nNew = p->nAlloc*2 + 100 + n;
+ zNew = sqlite3_realloc64(p->z, nNew);
+ if( zNew==0 ){
+ sqlite3_free(p->z);
+ memset(p, 0, sizeof(*p));
+ p->oomErr = 1;
+ return;
+ }
+ p->z = zNew;
+ p->nAlloc = nNew;
+ }
+ memcpy(p->z + p->n, z, (int)n);
+ p->n += n;
+ p->z[p->n] = 0;
+}
+
+/* Return the current string content */
+static char *StrStr(Str *p){
+ return p->z;
+}
+
+/* Free the string */
+static void StrFree(Str *p){
+ sqlite3_free(p->z);
+ StrInit(p);
+}
+
+/*
+** Return the value of a hexadecimal digit. Return -1 if the input
+** is not a hex digit.
+*/
+static int hexDigitValue(char c){
+ if( c>='0' && c<='9' ) return c - '0';
+ if( c>='a' && c<='f' ) return c - 'a' + 10;
+ if( c>='A' && c<='F' ) return c - 'A' + 10;
+ return -1;
+}
+
+/*
+** Interpret zArg as an integer value, possibly with suffixes.
+*/
+static int integerValue(const char *zArg){
+ sqlite3_int64 v = 0;
+ static const struct { char *zSuffix; int iMult; } aMult[] = {
+ { "KiB", 1024 },
+ { "MiB", 1024*1024 },
+ { "GiB", 1024*1024*1024 },
+ { "KB", 1000 },
+ { "MB", 1000000 },
+ { "GB", 1000000000 },
+ { "K", 1000 },
+ { "M", 1000000 },
+ { "G", 1000000000 },
+ };
+ int i;
+ int isNeg = 0;
+ if( zArg[0]=='-' ){
+ isNeg = 1;
+ zArg++;
+ }else if( zArg[0]=='+' ){
+ zArg++;
+ }
+ if( zArg[0]=='0' && zArg[1]=='x' ){
+ int x;
+ zArg += 2;
+ while( (x = hexDigitValue(zArg[0]))>=0 ){
+ v = (v<<4) + x;
+ zArg++;
+ }
+ }else{
+ while( ISDIGIT(zArg[0]) ){
+ v = v*10 + zArg[0] - '0';
+ zArg++;
+ }
+ }
+ for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
+ if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
+ v *= aMult[i].iMult;
+ break;
+ }
+ }
+ if( v>0x7fffffff ) fatalError("parameter too large - max 2147483648");
+ return (int)(isNeg? -v : v);
+}
+
+/*
+** This callback is invoked by sqlite3_log().
+*/
+static void sqlLog(void *pNotUsed, int iErrCode, const char *zMsg){
+ printf("LOG: (%d) %s\n", iErrCode, zMsg);
+ fflush(stdout);
+}
+
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+/*
+** This an SQL progress handler. After an SQL statement has run for
+** many steps, we want to interrupt it. This guards against infinite
+** loops from recursive common table expressions.
+**
+** *pVdbeLimitFlag is true if the --limit-vdbe command-line option is used.
+** In that case, hitting the progress handler is a fatal error.
+*/
+static int progressHandler(void *pVdbeLimitFlag){
+ if( *(int*)pVdbeLimitFlag ) fatalError("too many VDBE cycles");
+ return 1;
+}
+#endif
+
+/*
+** Allowed values for the runFlags parameter to runSql()
+*/
+#define SQL_TRACE 0x0001 /* Print each SQL statement as it is prepared */
+#define SQL_OUTPUT 0x0002 /* Show the SQL output */
+
+/*
+** Run multiple commands of SQL. Similar to sqlite3_exec(), but does not
+** stop if an error is encountered.
+*/
+static void runSql(sqlite3 *db, const char *zSql, unsigned runFlags){
+ const char *zMore;
+ const char *zEnd = &zSql[strlen(zSql)];
+ sqlite3_stmt *pStmt;
+
+ while( zSql && zSql[0] ){
+ zMore = 0;
+ pStmt = 0;
+ sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore);
+ assert( zMore<=zEnd );
+ if( zMore==zSql ) break;
+ if( runFlags & SQL_TRACE ){
+ const char *z = zSql;
+ int n;
+ while( z<zMore && ISSPACE(z[0]) ) z++;
+ n = (int)(zMore - z);
+ while( n>0 && ISSPACE(z[n-1]) ) n--;
+ if( n==0 ) break;
+ if( pStmt==0 ){
+ printf("TRACE: %.*s (error: %s)\n", n, z, sqlite3_errmsg(db));
+ }else{
+ printf("TRACE: %.*s\n", n, z);
+ }
+ }
+ zSql = zMore;
+ if( pStmt ){
+ if( (runFlags & SQL_OUTPUT)==0 ){
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){}
+ }else{
+ int nCol = -1;
+ int nRow;
+ for(nRow=0; SQLITE_ROW==sqlite3_step(pStmt); nRow++){
+ int i;
+ if( nCol<0 ){
+ nCol = sqlite3_column_count(pStmt);
+ }
+ for(i=0; i<nCol; i++){
+ int eType = sqlite3_column_type(pStmt,i);
+ printf("ROW[%d].%s = ", nRow, sqlite3_column_name(pStmt,i));
+ switch( eType ){
+ case SQLITE_NULL: {
+ printf("NULL\n");
+ break;
+ }
+ case SQLITE_INTEGER: {
+ printf("INT %s\n", sqlite3_column_text(pStmt,i));
+ break;
+ }
+ case SQLITE_FLOAT: {
+ printf("FLOAT %s\n", sqlite3_column_text(pStmt,i));
+ break;
+ }
+ case SQLITE_TEXT: {
+ printf("TEXT [%s]\n", sqlite3_column_text(pStmt,i));
+ break;
+ }
+ case SQLITE_BLOB: {
+ printf("BLOB (%d bytes)\n", sqlite3_column_bytes(pStmt,i));
+ break;
+ }
+ }
+ }
+ }
+ }
+ sqlite3_finalize(pStmt);
+ }
+ }
+}
+
+int main(int argc, char **argv){
+ int i; /* Loop counter */
+ int nDb = 0; /* Number of databases to fuzz */
+ char **azDb = 0; /* Names of the databases (limit: 20) */
+ int verboseFlag = 0; /* True for extra output */
+ int noLookaside = 0; /* Disable lookaside if true */
+ int vdbeLimitFlag = 0; /* Stop after 100,000 VDBE ops */
+ int nHeap = 0; /* True for fixed heap size */
+ int iTimeout = 0; /* Timeout delay in seconds */
+ int rc; /* Result code from SQLite3 API calls */
+ sqlite3 *db; /* The database connection */
+ sqlite3_stmt *pStmt; /* A single SQL statement */
+ Str sql; /* SQL to run */
+ unsigned runFlags = 0; /* Flags passed to runSql */
+
+ for(i=1; i<argc; i++){
+ char *z = argv[i];
+ if( z[0]!='-' ){
+ azDb = realloc(azDb, sizeof(azDb[0])*(nDb+1));
+ if( azDb==0 ) fatalError("out of memory");
+ azDb[nDb++] = z;
+ continue;
+ }
+ z++;
+ if( z[0]=='-' ) z++;
+ if( strcmp(z, "help")==0 ){
+ showHelp(argv[0]);
+ }else if( strcmp(z, "limit-mem")==0 ){
+ if( i==argc-1 ) fatalError("missing argument to %s", argv[i]);
+ nHeap = integerValue(argv[++i]);
+ }else if( strcmp(z, "no-lookaside")==0 ){
+ noLookaside = 1;
+ }else if( strcmp(z, "timeout")==0 ){
+ if( i==argc-1 ) fatalError("missing argument to %s", argv[i]);
+ iTimeout = integerValue(argv[++i]);
+ }else if( strcmp(z, "trace")==0 ){
+ runFlags |= SQL_OUTPUT|SQL_TRACE;
+ }else if( strcmp(z, "limit-vdbe")==0 ){
+ vdbeLimitFlag = 1;
+ }else if( strcmp(z, "v")==0 || strcmp(z, "verbose")==0 ){
+ verboseFlag = 1;
+ runFlags |= SQL_TRACE;
+ }else{
+ fatalError("unknown command-line option: \"%s\"\n", argv[i]);
+ }
+ }
+ if( nDb==0 ){
+ showHelp(argv[0]);
+ }
+ if( verboseFlag ){
+ sqlite3_config(SQLITE_CONFIG_LOG, sqlLog);
+ }
+ if( nHeap>0 ){
+ void *pHeap = malloc( nHeap );
+ if( pHeap==0 ) fatalError("cannot allocate %d-byte heap\n", nHeap);
+ rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, 32);
+ if( rc ) fatalError("heap configuration failed: %d\n", rc);
+ }
+ if( noLookaside ){
+ sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0);
+ }
+ inmemVfsRegister();
+ formatVfs();
+ StrInit(&sql);
+#ifdef __unix__
+ signal(SIGALRM, timeoutHandler);
+#endif
+ for(i=0; i<nDb; i++){
+ if( verboseFlag && nDb>1 ){
+ printf("DATABASE-FILE: %s\n", azDb[i]);
+ fflush(stdout);
+ }
+ if( iTimeout ) setAlarm(iTimeout);
+ createVFile("test.db", azDb[i]);
+ rc = sqlite3_open_v2("test.db", &db, SQLITE_OPEN_READWRITE, "inmem");
+ if( rc ){
+ printf("cannot open test.db for \"%s\"\n", azDb[i]);
+ reformatVfs();
+ continue;
+ }
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ if( vdbeLimitFlag ){
+ sqlite3_progress_handler(db, 100000, progressHandler, &vdbeLimitFlag);
+ }
+#endif
+ rc = sqlite3_prepare_v2(db, "SELECT sql FROM autoexec", -1, &pStmt, 0);
+ if( rc==SQLITE_OK ){
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){
+ StrAppend(&sql, (const char*)sqlite3_column_text(pStmt, 0));
+ StrAppend(&sql, "\n");
+ }
+ }
+ sqlite3_finalize(pStmt);
+ StrAppend(&sql, "PRAGMA integrity_check;\n");
+ runSql(db, StrStr(&sql), runFlags);
+ sqlite3_close(db);
+ reformatVfs();
+ StrFree(&sql);
+ if( sqlite3_memory_used()>0 ){
+ free(azDb);
+ reformatVfs();
+ fatalError("memory leak of %lld bytes", sqlite3_memory_used());
+ }
+ }
+ StrFree(&sql);
+ reformatVfs();
+ return 0;
+}
diff --git a/test/dbfuzz001.test b/test/dbfuzz001.test
new file mode 100644
index 0000000..2a430de
--- /dev/null
+++ b/test/dbfuzz001.test
@@ -0,0 +1,374 @@
+# 2012-12-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.
+#
+#***********************************************************************
+#
+# Test cases for corrupt database files.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !deserialize {
+ finish_test
+ return
+}
+database_may_be_corrupt
+
+# In the following database file, there is 384 bytes of free space
+# on page 8 that does not appear on the freeblock list.
+#
+do_test dbfuzz001-100 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+ | size 5632 pagesize 512 filename c4.db
+ | page 1 offset 0
+ | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+ | 16: 02 00 01 01 00 40 20 20 00 00 00 02 00 00 00 0b .....@ ........
+ | 32: 00 00 00 06 00 00 00 01 00 00 00 28 00 00 00 04 ...........(....
+ | 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+ | 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 ................
+ | 96: 00 2e 30 38 0d 00 00 00 06 01 06 00 01 da 01 b0 ..08............
+ | 112: 01 56 01 86 01 2a 01 06 00 00 00 00 00 00 00 00 .V...*..........
+ | 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 31 74 61 ......"......1ta
+ | 272: 62 6c 65 74 34 74 34 07 43 52 45 41 54 45 20 54 blet4t4.CREATE T
+ | 288: 41 42 4c 45 20 74 34 28 78 29 2a 06 06 17 13 11 ABLE t4(x)*.....
+ | 304: 01 3f 69 6e 64 65 78 00 00 00 00 00 00 00 00 00 .?index.........
+ | 336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e t3(x).......Ein
+ | 352: 64 65 78 74 32 63 64 74 32 05 43 52 45 41 54 45 dext2cdt2.CREATE
+ | 368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74 INDEX t2cd ON t
+ | 384: 32 28 63 2c 64 29 28 05 06 17 11 11 01 3d 74 61 2(c,d)(......=ta
+ | 400: 62 6c 65 74 33 74 33 04 43 52 45 41 54 45 20 54 blet3t3.CREATE T
+ | 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f)
+ | 432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (......=tablet2t
+ | 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t
+ | 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$.....
+ | 480: 01 35 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .5tablet1t1.CREA
+ | 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29 TE TABLE t1(a,b)
+ | page 2 offset 512
+ | 0: 0d 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................
+ | page 3 offset 1024
+ | 0: 0d 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................
+ | page 4 offset 1536
+ | 0: 05 00 00 00 03 01 f1 00 00 00 00 0b 01 fb 01 f6 ................
+ | 16: 01 f1 00 16 00 00 09 06 05 01 01 01 01 04 04 03 ................
+ | 32: 03 07 05 05 01 01 09 09 02 02 19 04 05 17 17 17 ................
+ | 48: 17 73 65 76 65 6e 65 69 67 68 74 65 69 67 68 74 .seveneighteight
+ | 64: 73 65 76 65 6e 25 03 05 07 07 07 07 40 14 00 00 seven%......@...
+ | 80: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00 ....@.......@...
+ | 96: 00 00 00 00 40 14 00 00 00 00 00 00 09 02 05 01 ....@...........
+ | 112: 01 01 01 03 04 04 03 07 01 05 09 01 01 09 02 02 ................
+ | 352: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a ................
+ | 496: 00 00 00 00 0a 3e 00 00 00 09 21 00 00 00 08 06 .....>....!.....
+ | page 5 offset 2048
+ | 0: 0a 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................
+ | page 7 offset 3072
+ | 0: 0d 00 00 00 08 01 c2 00 01 fb 01 f6 01 f1 01 ec ................
+ | 16: 01 e0 01 d4 01 cb 01 c2 00 00 00 00 00 00 00 00 ................
+ | 96: 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 ................
+ | 224: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 ................
+ | 288: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 ................
+ | 448: 00 00 07 08 02 17 65 69 67 68 74 07 07 02 17 65 ......eight....e
+ | 464: 69 67 68 74 0a 06 02 07 40 18 00 00 00 00 00 00 ight....@.......
+ | 480: 0a 05 02 07 40 18 00 00 00 00 00 00 03 04 02 01 ....@...........
+ | 496: 04 03 03 02 01 04 03 02 02 01 02 03 01 02 01 02 ................
+ | page 8 offset 3584
+ | 0: 0d 00 21 00 01 00 16 00 00 16 00 16 00 16 00 16 ..!.............
+ | 16: 00 16 00 16 00 00 09 06 05 01 01 01 01 04 04 03 ................
+ | 32: 03 00 00 00 5f 01 09 09 02 02 00 00 00 56 17 17 ...._........V..
+ | 48: 17 73 65 76 65 6e 65 69 67 68 74 65 69 67 68 74 .seveneighteight
+ | 64: 73 65 76 65 6e 00 00 00 3b 07 07 07 40 14 00 00 seven...;...@...
+ | 80: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00 ....@.......@...
+ | 96: 00 00 00 00 40 14 00 00 00 00 00 00 00 00 00 14 ....@...........
+ | 112: 01 01 01 03 04 04 03 00 00 00 09 01 01 09 02 02 ................
+ | 352: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a ................
+ | page 9 offset 4096
+ | 0: 0d 00 00 00 1b 00 47 00 01 d9 01 be 01 af 01 a0 ......G.........
+ | 16: 01 91 01 82 01 73 01 64 01 55 01 46 01 37 01 28 .....s.d.U.F.7.(
+ | 32: 01 19 01 0a 00 fb 00 ec 00 dd 00 ce 00 bf 00 b0 ................
+ | 48: 00 a1 00 92 00 83 00 74 00 65 00 56 00 47 00 00 .......t.e.V.G..
+ | 64: 00 00 00 00 00 00 00 0d 21 00 00 48 01 54 00 01 ........!..H.T..
+ | 80: f7 01 ec 01 c5 01 0d 20 00 00 48 01 54 00 01 f7 ....... ..H.T...
+ | 96: 01 ec 01 c5 01 0d 1f 00 00 48 01 54 00 01 f7 01 .........H.T....
+ | 112: ec 01 c5 01 0d 1e 00 00 48 01 54 00 01 f7 01 ec ........H.T.....
+ | 128: 01 c5 01 0d 1d 00 00 48 01 54 00 01 f7 01 ec 01 .......H.T......
+ | 144: c5 01 0d 1c 00 00 48 01 54 00 01 f7 01 ec 01 c5 ......H.T.......
+ | 160: 01 0d 1b 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 .....H.T........
+ | 176: 0d 1a 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d ....H.T.........
+ | 192: 19 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 18 ...H.T..........
+ | 208: 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 17 00 ..H.T...........
+ | 224: 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 16 00 00 .H.T............
+ | 240: 48 01 54 00 01 f7 01 ec 01 c5 01 0d 15 00 00 48 H.T............H
+ | 256: 01 54 00 01 f7 01 ec 01 c5 01 0d 14 00 00 48 01 .T............H.
+ | 272: 54 00 01 f7 01 ec 01 c5 01 0d 13 00 00 48 01 54 T............H.T
+ | 288: 00 01 f7 01 ec 01 c5 01 0d 12 00 00 48 01 54 00 ............H.T.
+ | 304: 01 f7 01 ec 01 c5 01 0d 11 00 00 48 01 54 00 01 ...........H.T..
+ | 320: f7 01 ec 01 c5 01 0d 10 00 00 48 01 54 00 01 f7 ..........H.T...
+ | 336: 01 ec 01 c5 01 0d 0f 00 00 48 01 54 00 01 f7 01 .........H.T....
+ | 352: ec 01 c5 01 0d 0e 00 00 48 01 54 00 01 f7 01 ec ........H.T.....
+ | 368: 01 c5 01 0d 0d 00 00 48 01 54 00 01 f7 01 ec 01 .......H.T......
+ | 384: c5 01 0d 0c 00 00 48 01 54 00 01 f7 01 ec 01 c5 ......H.T.......
+ | 400: 01 0d 0b 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 .....H.T........
+ | 416: 0d 0a 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d ....H.T.........
+ | 432: 09 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 19 08 ...H.T..........
+ | 448: 05 17 17 17 17 65 69 67 68 74 65 69 67 68 74 73 .....eighteights
+ | 464: 65 76 65 6e 73 65 76 65 6e 25 07 05 07 07 07 07 evenseven%......
+ | 480: 40 18 00 00 00 00 00 00 40 18 00 00 00 00 00 00 @.......@.......
+ | 496: 40 14 00 00 00 00 00 00 40 14 00 00 00 00 00 00 @.......@.......
+ | page 10 offset 4608
+ | 0: 0d 00 00 00 1d 00 4d 00 01 f1 01 e2 01 d3 01 c4 ......M.........
+ | 16: 01 b5 01 a6 01 97 01 88 01 79 01 6a 01 5b 01 4c .........y.j.[.L
+ | 32: 01 3d 01 2e 01 1f 01 10 01 01 00 f2 00 e3 00 d4 .=..............
+ | 48: 00 c5 00 b6 00 a7 00 98 00 89 00 7a 00 6b 00 5c ...........z.k.\
+ | 64: 00 4d 00 00 00 00 00 00 00 00 00 00 00 0d 3e 00 .M............>.
+ | 80: 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 3d 00 00 .H.T.........=..
+ | 96: 48 01 54 00 01 f7 01 ec 01 c5 01 0d 3c 00 00 48 H.T.........<..H
+ | 112: 01 54 00 01 f7 01 ec 01 c5 01 0d 3b 00 00 48 01 .T.........;..H.
+ | 128: 54 00 01 f7 01 ec 01 c5 01 0d 3a 00 00 48 01 54 T.........:..H.T
+ | 144: 00 01 f7 01 ec 01 c5 01 0d 39 00 00 48 01 54 00 .........9..H.T.
+ | 160: 01 f7 01 ec 01 c5 01 0d 38 00 00 48 01 54 00 01 ........8..H.T..
+ | 176: f7 01 ec 01 c5 01 0d 37 00 00 48 01 54 00 01 f7 .......7..H.T...
+ | 192: 01 ec 01 c5 01 0d 36 00 00 48 01 54 00 01 f7 01 ......6..H.T....
+ | 208: ec 01 c5 01 0d 35 00 00 48 01 54 00 01 f7 01 ec .....5..H.T.....
+ | 224: 01 c5 01 0d 34 00 00 48 01 54 00 01 f7 01 ec 01 ....4..H.T......
+ | 240: c5 01 0d 33 00 00 48 01 54 00 01 f7 01 ec 01 c5 ...3..H.T.......
+ | 256: 01 0d 32 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 ..2..H.T........
+ | 272: 0d 31 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d .1..H.T.........
+ | 288: 30 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 2f 0..H.T........./
+ | 304: 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 2e 00 ..H.T...........
+ | 320: 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 2d 00 00 .H.T.........-..
+ | 336: 48 01 54 00 01 f7 01 ec 01 c5 01 0d 2c 00 00 48 H.T.........,..H
+ | 352: 01 54 00 01 f7 01 ec 01 c5 01 0d 2b 00 00 48 01 .T.........+..H.
+ | 368: 54 00 01 f7 01 ec 01 c5 01 0d 2a 00 00 48 01 54 T.........*..H.T
+ | 384: 00 01 f7 01 ec 01 c5 01 0d 29 00 00 48 01 54 00 .........)..H.T.
+ | 400: 01 f7 01 ec 01 c5 01 0d 28 00 00 48 01 54 00 01 ........(..H.T..
+ | 416: f7 01 ec 01 c5 01 0d 27 00 00 48 01 54 00 01 f7 .......'..H.T...
+ | 432: 01 ec 01 c5 01 0d 26 00 00 48 01 54 00 01 f7 01 ......&..H.T....
+ | 448: ec 01 c5 01 0d 25 00 00 48 01 54 00 01 f7 01 ec .....%..H.T.....
+ | 464: 01 c5 01 0d 24 00 00 48 01 54 00 01 f7 01 ec 01 ....$..H.T......
+ | 480: c5 01 0d 23 00 00 48 01 54 00 01 f7 01 ec 01 c5 ...#..H.T.......
+ | 496: 01 0d 22 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 .."..H.T........
+ | page 11 offset 5120
+ | 0: 0d 00 00 00 0a 01 6a 00 01 f1 01 e2 01 d3 01 c4 ......j.........
+ | 16: 01 b5 01 a6 01 97 01 88 01 79 01 6a 00 00 00 00 .........y.j....
+ | 352: 00 00 00 00 00 00 00 00 00 00 0d 48 00 00 48 01 ...........H..H.
+ | 368: 54 00 01 f7 01 ec 01 c5 01 0d 47 00 00 48 01 54 T.........G..H.T
+ | 384: 00 01 f7 01 ec 01 c5 01 0d 46 00 00 48 01 54 00 .........F..H.T.
+ | 400: 01 f7 01 ec 01 c5 01 0d 45 00 00 48 01 54 00 01 ........E..H.T..
+ | 416: f7 01 ec 01 c5 01 0d 44 00 00 48 01 54 00 01 f7 .......D..H.T...
+ | 432: 01 ec 01 c5 01 0d 43 00 00 48 01 54 00 01 f7 01 ......C..H.T....
+ | 448: ec 01 c5 01 0d 42 00 00 48 01 54 00 01 f7 01 ec .....B..H.T.....
+ | 464: 01 c5 01 0d 41 00 00 48 01 54 00 01 f7 01 ec 01 ....A..H.T......
+ | 480: c5 01 0d 40 00 00 48 01 54 00 01 f7 01 ec 01 c5 ...@..H.T.......
+ | 496: 01 0d 3f 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 ..?..H.T........
+ | end c4.db
+ }]
+} {}
+
+ifcapable !oversize_cell_check {
+ # Non SQLITE_ENABLE_OVERSIZE_CELL_CHECK builds:
+ do_test dbfuzz001-101a {
+ db eval {PRAGMA writable_schema=on; PRAGMA integrity_check}
+ } {/Fragmentation of 384 bytes reported as 0 on page 8/}
+} else {
+ # SQLITE_ENABLE_OVERSIZE_CELL_CHECK builds:
+ do_catchsql_test dbfuzz001-101b {
+ PRAGMA writable_schema=on;
+ PRAGMA integrity_check;
+ } {1 {database disk image is malformed}}
+}
+
+# The DELETE query below deletes the very last cell from page 8.
+# Prior to a certain fix to sqlite3BtreeDelete() and because of the
+# corruption to the freeblock list on page 8, this would fail to
+# cause a rebalance operation, which would leave the btree in a weird
+# state that would lead to segfaults and or assertion faults.
+#
+do_execsql_test dbfuzz001-110 {
+ DELETE FROM t3 WHERE x IS NOT NULL AND +rowid=6;
+} {}
+
+# This is a dbfuzz2-generate test case that can cause a page with
+# pPage->nCell==0 to enter the balancer.
+#
+do_test dbfuzz001-200 {
+ db deserialize [decode_hexdb {
+ | size 3076 pagesize 512 filename c03.db
+ | page 1 offset 0
+ | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+ | 16: 02 00 01 01 00 40 20 20 00 00 00 0c 00 00 00 07 .....@ ........
+ | 32: 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 04 ................
+ | 48: 00 00 00 00 00 00 00 03 e8 00 00 01 00 00 00 00 ................
+ | 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c ................
+ | 96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0 ..,P............
+ | 112: 01 56 01 86 01 2a 01 06 00 00 00 00 00 00 00 00 .V...*..........
+ | 128: 00 00 00 00 00 00 00 00 ef 00 00 00 00 00 00 00 ................
+ | 192: 00 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ | 224: 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e9 00 ................
+ | 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 31 74 61 ......"......1ta
+ | 272: 62 6c 65 74 34 74 34 07 43 52 45 41 54 45 20 54 blet4t4.CREATE T
+ | 288: 41 42 4c 45 20 74 34 28 78 29 2a 06 06 17 13 11 ABLE t4(x)*.....
+ | 304: 01 3f 69 6e 64 65 78 74 33 78 74 33 06 43 52 45 .?indext3xt3.CRE
+ | 320: 41 54 45 20 49 4e 44 45 58 20 74 33 64 20 4f 4e ATE INDEX t3d ON
+ | 336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e t3(x).......Ein
+ | 352: 64 65 78 74 32 63 64 74 32 05 43 52 45 41 54 45 dext2cdt2.CREATE
+ | 368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74 INDEX t2cd ON t
+ | 384: 32 28 63 2c 64 29 28 05 06 17 11 11 01 3d 74 61 2(c,d)(......=ta
+ | 400: 62 6c 65 74 33 74 33 04 43 52 45 41 54 45 20 54 blet3t3.CREATE T
+ | 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f)
+ | 432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (......=tablet2t
+ | 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t
+ | 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$.....
+ | 480: 01 35 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .5tablet1t1.CREA
+ | 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29 TE TABLE t1(a,b)
+ | page 2 offset 512
+ | 0: 0d 00 00 00 04 01 cf 00 01 fa 01 f3 01 de 01 cf ................
+ | 176: 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ | 256: 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ | 368: 00 00 00 00 00 00 00 00 00 00 00 00 1e 00 00 00 ................
+ | 416: 00 00 00 1b 00 00 00 00 04 00 00 00 00 00 00 00 ................
+ | 448: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d ................
+ | 464: 04 03 17 17 73 65 76 65 6e 65 69 67 68 74 13 03 ....seveneight..
+ | 480: 03 07 07 40 14 00 00 00 00 00 00 40 18 00 00 00 ...@.......@....
+ | 496: 00 00 00 05 02 03 01 01 03 04 04 01 03 09 01 02 ................
+ | page 3 offset 1024
+ | 0: 0d 00 00 00 08 01 54 00 01 f7 01 ec 01 c5 01 aa ......T.........
+ | 16: 01 a1 01 96 01 6f 01 54 00 00 00 00 00 00 00 00 .....o.T........
+ | 32: 00 00 00 00 00 00 00 03 e8 00 00 00 00 00 00 00 ................
+ | 336: 00 00 00 00 19 08 05 16 17 17 17 65 69 67 68 74 ...........eight
+ | 352: 65 69 67 68 74 73 65 76 65 6e 73 65 76 ff ff ff eightsevensev...
+ | 368: 0e 05 07 07 07 07 40 18 00 00 00 00 00 00 40 18 ......@.......@.
+ | 384: 00 00 00 00 00 00 40 14 00 00 00 00 00 00 40 14 ......@.......@.
+ | 400: 00 00 00 00 00 00 09 06 05 01 01 01 01 04 04 03 ................
+ | 416: 03 07 05 05 01 01 09 09 02 02 19 04 05 17 17 17 ................
+ | 432: 17 73 65 6f 65 6e 65 69 67 68 74 65 69 67 68 74 .seoeneighteight
+ | 448: 73 65 76 65 6e 25 03 05 07 07 07 07 40 14 00 00 seven%......@...
+ | 464: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00 ....@.......@...
+ | 480: 00 00 00 00 40 14 00 00 00 00 00 00 09 02 05 01 ....@...........
+ | 496: 01 01 01 03 04 04 03 07 01 05 09 01 01 09 02 02 ................
+ | page 4 offset 1536
+ | 0: 0d 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 ................
+ | 160: 00 00 00 ea 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ | 336: 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 ............ ...
+ | page 5 offset 2048
+ | 0: 0a 00 00 00 08 01 96 00 01 fa 01 c4 01 f2 01 bc ................
+ | 16: 01 dc 01 a6 01 96 01 cc 00 00 00 00 00 00 00 00 ................
+ | 48: 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 ................
+ | 288: 00 00 00 00 00 00 00 00 00 64 00 00 00 2b 00 00 .........d...+..
+ | 400: 00 00 00 00 00 00 0f 04 17 17 01 65 69 67 68 74 ...........eight
+ | 416: 65 69 6f 68 74 08 15 04 07 07 01 40 18 00 00 00 eioht......@....
+ | 432: 00 00 00 40 18 00 00 00 00 00 00 07 07 04 01 01 ...@............
+ | 448: 01 04 04 06 07 04 01 01 01 02 02 05 0f 04 17 17 ................
+ | 464: 01 73 65 76 65 6e 65 69 67 68 74 04 15 04 07 07 .seveneight.....
+ | 480: 01 40 14 00 00 00 00 00 00 40 18 00 00 00 00 00 .@.......@......
+ | 496: 00 03 07 04 01 01 01 03 04 02 05 04 09 01 09 02 ................
+ | page 6 offset 2560
+ | 0: 0a 00 00 00 00 02 00 00 00 00 00 00 00 0d 00 00 ................
+ | 16: 00 08 01 c2 00 01 fb 01 f6 01 f1 01 ec 01 e0 01 ................
+ | 32: d4 01 cb 01 c2 00 00 00 00 00 00 00 00 00 00 00 ................
+ | 160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 ................
+ | 448: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 ................
+ | 464: 08 02 17 65 69 67 68 74 07 07 02 17 65 69 67 68 ...eight....eigh
+ | 480: 74 0a 06 02 07 40 18 00 00 00 00 00 00 0a 05 02 t....@..........
+ | 496: 07 40 18 00 04 02 01 04 03 03 02 01 04 03 02 02 .@..............
+ | end x/c03.db
+ }]
+ catchsql {INSERT INTO t3 SELECT * FROM t2;}
+} {1 {database disk image is malformed}}
+
+
+do_test dbfuzz001-310 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 3584 pagesize 512 filename x/c02.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 02 00 01 01 00 40 20 20 00 00 00 0c 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 04 00 00 00 01 00 00 00 00 ................
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c ................
+| 96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0 ..,P............
+| 112: 01 56 01 86 01 2a 01 06 00 00 00 00 00 00 00 00 .V...*..........
+| 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 31 74 61 ......"......1ta
+| 272: 62 6c 65 74 34 74 34 07 43 52 45 41 54 45 20 54 blet4t4.CREATE T
+| 288: 41 42 4c 45 20 74 34 28 78 29 2a 06 06 17 13 11 ABLE t4(x)*.....
+| 304: 01 3f 69 6e 64 65 78 74 33 78 74 33 05 43 52 45 .?indext3xt3.CRE
+| 320: 41 54 45 20 49 4e 44 45 58 20 74 33 78 20 4f 4e ATE INDEX t3x ON
+| 336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e t3(x).......Ein
+| 352: 64 65 78 74 32 63 64 74 32 05 43 52 45 41 54 45 dext2cdt2.CREATE
+| 368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74 INDEX t2cd ON t
+| 384: 32 28 63 2c 64 29 28 05 06 17 11 11 01 3d 74 61 2(c,d)(......=ta
+| 400: 62 6c 65 74 33 74 33 07 43 52 45 41 54 45 20 54 blet3t3.CREATE T
+| 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f)
+| 432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (......=tablet2t
+| 448: 32 32 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 22CREATE TABLE t
+| 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$.....
+| 480: 01 35 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .5tablet1t1.CREA
+| 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29 TE TABLE t1(a,b)
+| page 2 offset 512
+| 0: 0d 00 00 00 04 01 cf 00 01 fa 01 f3 01 de 01 cf ................
+| 160: 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 .. .............
+| 448: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d ................
+| 464: 04 03 17 17 73 65 76 65 6e 65 69 67 68 74 13 03 ....seveneight..
+| 480: 03 07 07 40 14 00 00 00 00 00 00 40 18 00 00 00 ...@.......@....
+| 496: 00 00 00 05 02 03 01 01 03 04 04 01 03 09 01 02 ................
+| page 3 offset 1024
+| 0: 0d 00 00 00 08 01 54 00 01 f7 01 ec 01 c5 01 aa ......T.........
+| 16: 01 a1 01 96 01 6f 01 54 00 00 00 00 00 00 00 00 .....o.T........
+| 112: 00 00 dd 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 336: 00 00 00 00 19 08 05 17 17 17 17 65 69 67 68 74 ...........eight
+| 352: 65 69 67 68 74 73 65 76 65 6e 73 65 76 65 6e 25 eightsevenseven%
+| 368: 07 05 07 07 07 07 40 18 00 00 00 00 00 00 40 18 ......@.......@.
+| 384: 00 00 00 00 00 00 40 14 00 00 00 00 00 00 40 14 ......@.......@.
+| 400: 00 00 00 00 00 00 09 06 05 01 01 01 01 04 04 03 ................
+| 416: 03 07 05 05 01 01 09 09 02 02 19 04 05 17 17 17 ................
+| 432: 17 73 65 76 65 6e 65 69 67 68 74 65 69 67 68 74 .seveneighteight
+| 448: 73 65 76 65 6e 25 03 05 07 07 07 07 40 14 00 00 seven%......@...
+| 464: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00 ....@.......@...
+| 480: 00 00 00 00 40 14 00 00 00 00 00 00 09 02 05 01 ....@...........
+| 496: 01 01 01 03 04 04 03 07 01 05 09 01 01 09 02 02 ................
+| page 4 offset 1536
+| 0: 0d 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................
+| 192: 00 00 00 00 00 00 7f 00 00 00 00 00 00 00 00 00 ................
+| 208: 00 e5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 2048
+| 0: 0a 00 00 00 08 01 96 00 01 fa 01 c4 01 f2 01 bc ................
+| 16: 01 dc 01 a6 01 96 01 cc 00 00 00 00 00 00 00 00 ................
+| 240: 00 00 00 00 00 00 00 00 00 00 00 00 00 0e 00 00 ................
+| 400: 00 00 00 00 00 00 0f 04 17 07 01 65 69 67 68 74 ...........eight
+| 416: 65 69 67 68 74 08 15 04 07 07 01 40 18 00 00 00 eight......@....
+| 432: 00 00 00 40 18 00 00 00 00 00 00 07 07 04 01 01 ...@............
+| 448: 01 04 04 06 07 04 01 01 01 02 02 05 0f 04 17 17 ................
+| 464: 01 73 65 76 65 6e 65 69 67 68 74 04 15 04 07 07 .seveneight.....
+| 480: 01 40 14 00 00 00 00 00 00 40 18 00 00 00 00 00 .@.......@......
+| 496: 00 03 07 04 01 01 01 03 04 02 05 04 09 01 09 02 ................
+| page 6 offset 2560
+| 0: 0a 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................
+| 464: 00 00 00 00 00 00 00 00 00 00 7f 00 00 00 00 00 ................
+| page 7 offset 3072
+| 0: 0d 00 00 00 08 01 c2 00 01 fb 01 f6 01 f1 01 ec ................
+| 16: 01 e0 01 d4 01 cb 01 c2 00 00 00 00 00 00 00 00 ................
+| 448: 00 00 07 08 02 17 65 69 67 68 74 07 07 02 17 65 ......eight....e
+| 464: 69 67 68 74 0a 06 02 07 40 18 00 00 00 00 00 00 ight....@.......
+| 480: 0a 05 02 07 40 18 00 00 00 00 00 00 03 04 02 01 ....@...........
+| 496: 04 03 03 02 01 04 03 02 02 01 02 03 01 02 01 02 ................
+| end x/c02.db
+ }]
+} {}
+
+extra_schema_checks 0
+do_catchsql_test dbfuzz001-320 {
+ PRAGMA integrity_check;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test dbfuzz001-330 {
+ DELETE FROM t3 WHERE x IN (SELECT x FROM t4);
+} {1 {database disk image is malformed}}
+extra_schema_checks 1
+
+finish_test
diff --git a/test/dbfuzz2-seed1.db b/test/dbfuzz2-seed1.db
new file mode 100644
index 0000000..17f0550
--- /dev/null
+++ b/test/dbfuzz2-seed1.db
Binary files differ
diff --git a/test/dbfuzz2.c b/test/dbfuzz2.c
new file mode 100644
index 0000000..f006291
--- /dev/null
+++ b/test/dbfuzz2.c
@@ -0,0 +1,402 @@
+/*
+** 2018-10-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 program is designed for fuzz-testing SQLite database files using
+** the -fsanitize=fuzzer option of clang.
+**
+** The -fsanitize=fuzzer option causes a main() to be inserted automatically.
+** That main() invokes LLVMFuzzerTestOneInput(D,S) to be invoked repeatedly.
+** Each D is a fuzzed database file. The code in this file runs various
+** SQL statements against that database, trying to provoke a failure.
+**
+** For best results the seed database files should have these tables:
+**
+** Table "t1" with columns "a" and "b"
+** Tables "t2" and "t3 with the same number of compatible columns
+** "t3" should have a column names "x"
+** Table "t4" with a column "x" that is compatible with t3.x.
+**
+** Any of these tables can be virtual tables, for example FTS or RTree tables.
+**
+** To run this test:
+**
+** mkdir dir
+** cp dbfuzz2-seed*.db dir
+** clang-6.0 -I. -g -O1 -fsanitize=fuzzer -DTHREADSAFE=0 \
+** -DSQLITE_ENABLE_DBSTAT_VTAB dbfuzz2.c sqlite3.c -ldl
+** ./a.out dir
+*/
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <stdint.h>
+#ifndef _WIN32
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+#include "sqlite3.h"
+
+/*
+** This is the is the SQL that is run against the database.
+*/
+static const char *azSql[] = {
+ "PRAGMA integrity_check;",
+ "SELECT * FROM sqlite_schema;",
+ "SELECT sum(length(name)) FROM dbstat;",
+ "UPDATE t1 SET b=a, a=b WHERE a<b;",
+ "ALTER TABLE t1 RENAME TO alkjalkjdfiiiwuer987lkjwer82mx97sf98788s9789s;",
+ "INSERT INTO t3 SELECT * FROM t2;",
+ "DELETE FROM t3 WHERE x IN (SELECT x FROM t4);",
+ "REINDEX;",
+ "DROP TABLE t3;",
+ "VACUUM;",
+};
+
+/* Output verbosity level. 0 means complete silence */
+int eVerbosity = 0;
+
+/* True to activate PRAGMA vdbe_debug=on */
+static int bVdbeDebug = 0;
+
+/* Maximum size of the in-memory database file */
+static sqlite3_int64 szMax = 104857600;
+
+/* Progress handler callback data */
+static int nCb = 0; /* Number of callbacks seen so far */
+static int mxCb = 250000; /* Maximum allowed callbacks */
+
+/***** Copy/paste from ext/misc/memtrace.c ***************************/
+/* The original memory allocation routines */
+static sqlite3_mem_methods memtraceBase;
+static FILE *memtraceOut;
+
+/* Methods that trace memory allocations */
+static void *memtraceMalloc(int n){
+ if( memtraceOut ){
+ fprintf(memtraceOut, "MEMTRACE: allocate %d bytes\n",
+ memtraceBase.xRoundup(n));
+ }
+ return memtraceBase.xMalloc(n);
+}
+static void memtraceFree(void *p){
+ if( p==0 ) return;
+ if( memtraceOut ){
+ fprintf(memtraceOut, "MEMTRACE: free %d bytes\n", memtraceBase.xSize(p));
+ }
+ memtraceBase.xFree(p);
+}
+static void *memtraceRealloc(void *p, int n){
+ if( p==0 ) return memtraceMalloc(n);
+ if( n==0 ){
+ memtraceFree(p);
+ return 0;
+ }
+ if( memtraceOut ){
+ fprintf(memtraceOut, "MEMTRACE: resize %d -> %d bytes\n",
+ memtraceBase.xSize(p), memtraceBase.xRoundup(n));
+ }
+ return memtraceBase.xRealloc(p, n);
+}
+static int memtraceSize(void *p){
+ return memtraceBase.xSize(p);
+}
+static int memtraceRoundup(int n){
+ return memtraceBase.xRoundup(n);
+}
+static int memtraceInit(void *p){
+ return memtraceBase.xInit(p);
+}
+static void memtraceShutdown(void *p){
+ memtraceBase.xShutdown(p);
+}
+
+/* The substitute memory allocator */
+static sqlite3_mem_methods ersaztMethods = {
+ memtraceMalloc,
+ memtraceFree,
+ memtraceRealloc,
+ memtraceSize,
+ memtraceRoundup,
+ memtraceInit,
+ memtraceShutdown
+};
+
+/* Begin tracing memory allocations to out. */
+int sqlite3MemTraceActivate(FILE *out){
+ int rc = SQLITE_OK;
+ if( memtraceBase.xMalloc==0 ){
+ rc = sqlite3_config(SQLITE_CONFIG_GETMALLOC, &memtraceBase);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &ersaztMethods);
+ }
+ }
+ memtraceOut = out;
+ return rc;
+}
+
+/* Deactivate memory tracing */
+int sqlite3MemTraceDeactivate(void){
+ int rc = SQLITE_OK;
+ if( memtraceBase.xMalloc!=0 ){
+ rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memtraceBase);
+ if( rc==SQLITE_OK ){
+ memset(&memtraceBase, 0, sizeof(memtraceBase));
+ }
+ }
+ memtraceOut = 0;
+ return rc;
+}
+/***** End copy/paste from ext/misc/memtrace.c ***************************/
+
+/*
+** Progress handler callback
+**
+** Count the number of callbacks and cause an abort once the limit is
+** reached.
+*/
+static int progress_handler(void *pNotUsed){
+ nCb++;
+ if( nCb<mxCb ) return 0;
+ if( eVerbosity>=1 ){
+ printf("-- Progress limit of %d reached\n", mxCb);
+ }
+ return 1;
+}
+
+/* libFuzzer invokes this routine with fuzzed database files (in aData).
+** This routine run SQLite against the malformed database to see if it
+** can provoke a failure or malfunction.
+*/
+int LLVMFuzzerTestOneInput(const uint8_t *aData, size_t nByte){
+ unsigned char *a;
+ sqlite3 *db;
+ int rc;
+ int i;
+ sqlite3_int64 x;
+ char *zErr = 0;
+
+ if( eVerbosity>=1 ){
+ printf("************** nByte=%d ***************\n", (int)nByte);
+ fflush(stdout);
+ }
+ if( sqlite3_initialize() ) return 0;
+ rc = sqlite3_open(0, &db);
+ if( rc ) return 1;
+ a = sqlite3_malloc64(nByte+1);
+ if( a==0 ) return 1;
+ memcpy(a, aData, nByte);
+ sqlite3_deserialize(db, "main", a, nByte, nByte,
+ SQLITE_DESERIALIZE_RESIZEABLE |
+ SQLITE_DESERIALIZE_FREEONCLOSE);
+ x = szMax;
+#ifdef SQLITE_FCNTL_SIZE_LIMIT
+ sqlite3_file_control(db, "main", SQLITE_FCNTL_SIZE_LIMIT, &x);
+#endif
+ if( bVdbeDebug ){
+ sqlite3_exec(db, "PRAGMA vdbe_debug=ON", 0, 0, 0);
+ }
+ if( mxCb>0 ){
+ sqlite3_progress_handler(db, 10, progress_handler, 0);
+ }
+#ifdef SQLITE_TESTCTRL_PRNG_SEED
+ sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SEED, 1, db);
+#endif
+ for(i=0; i<sizeof(azSql)/sizeof(azSql[0]); i++){
+ if( eVerbosity>=1 ){
+ printf("%s\n", azSql[i]);
+ fflush(stdout);
+ }
+ zErr = 0;
+ nCb = 0;
+ rc = sqlite3_exec(db, azSql[i], 0, 0, &zErr);
+ if( rc && eVerbosity>=1 ){
+ printf("-- rc=%d zErr=%s\n", rc, zErr);
+ }
+ sqlite3_free(zErr);
+ }
+ rc = sqlite3_close(db);
+ if( rc!=SQLITE_OK ){
+ fprintf(stdout, "sqlite3_close() returns %d\n", rc);
+ }
+ if( sqlite3_memory_used()!=0 ){
+ int nAlloc = 0;
+ int nNotUsed = 0;
+ sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &nAlloc, &nNotUsed, 0);
+ fprintf(stderr,"Memory leak: %lld bytes in %d allocations\n",
+ sqlite3_memory_used(), nAlloc);
+ exit(1);
+ }
+ return 0;
+}
+
+/*
+** Return the number of "v" characters in a string. Return 0 if there
+** are any characters in the string other than "v".
+*/
+static int numberOfVChar(const char *z){
+ int N = 0;
+ while( z[0] && z[0]=='v' ){
+ z++;
+ N++;
+ }
+ return z[0]==0 ? N : 0;
+}
+
+/* libFuzzer invokes this routine once when the executable starts, to
+** process the command-line arguments.
+*/
+int LLVMFuzzerInitialize(int *pArgc, char ***pArgv){
+ int i, j, n;
+ int argc = *pArgc;
+ char **argv = *pArgv;
+ for(i=j=1; i<argc; i++){
+ char *z = argv[i];
+ if( z[0]=='-' ){
+ z++;
+ if( z[0]=='-' ) z++;
+ if( z[0]=='v' && (n = numberOfVChar(z))>0 ){
+ eVerbosity += n;
+ continue;
+ }
+ if( strcmp(z,"vdbe-debug")==0 ){
+ bVdbeDebug = 1;
+ continue;
+ }
+ if( strcmp(z,"limit")==0 ){
+ if( i+1==argc ){
+ fprintf(stderr, "missing argument to %s\n", argv[i]);
+ exit(1);
+ }
+ mxCb = strtol(argv[++i], 0, 0);
+ continue;
+ }
+ if( strcmp(z,"memtrace")==0 ){
+ sqlite3MemTraceActivate(stdout);
+ continue;
+ }
+ if( strcmp(z,"max-db-size")==0 ){
+ if( i+1==argc ){
+ fprintf(stderr, "missing argument to %s\n", argv[i]);
+ exit(1);
+ }
+ szMax = strtol(argv[++i], 0, 0);
+ continue;
+ }
+ if( strcmp(z, "lookaside")==0 ){
+ int sz, nSlot;
+ if( i+2>=argc ){
+ fprintf(stderr,
+ "--lookaside requires two arguments: slot-size num-slots\n");
+ exit(1);
+ }
+ sz = atoi(argv[++i]);
+ nSlot = atoi(argv[++i]);
+ sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, nSlot);
+ continue;
+ }
+#ifndef _WIN32
+ if( strcmp(z,"max-stack")==0
+ || strcmp(z,"max-data")==0
+ || strcmp(z,"max-as")==0
+ ){
+ struct rlimit x,y;
+ int resource = RLIMIT_STACK;
+ char *zType = "RLIMIT_STACK";
+ if( i+1==argc ){
+ fprintf(stderr, "missing argument to %s\n", argv[i]);
+ exit(1);
+ }
+ if( z[4]=='d' ){
+ resource = RLIMIT_DATA;
+ zType = "RLIMIT_DATA";
+ }
+ if( z[4]=='a' ){
+ resource = RLIMIT_AS;
+ zType = "RLIMIT_AS";
+ }
+ memset(&x,0,sizeof(x));
+ getrlimit(resource, &x);
+ y.rlim_cur = atoi(argv[++i]);
+ y.rlim_max = x.rlim_cur;
+ setrlimit(resource, &y);
+ memset(&y,0,sizeof(y));
+ getrlimit(resource, &y);
+ printf("%s changed from %d to %d\n",
+ zType, (int)x.rlim_cur, (int)y.rlim_cur);
+ continue;
+ }
+#endif /* _WIN32 */
+ }
+ argv[j++] = argv[i];
+ }
+ argv[j] = 0;
+ *pArgc = j;
+ return 0;
+}
+
+#ifdef STANDALONE
+/*
+** Read an entire file into memory. Space to hold the file comes
+** from malloc().
+*/
+static unsigned char *readFile(const char *zName, int *pnByte){
+ FILE *in = fopen(zName, "rb");
+ long nIn;
+ size_t nRead;
+ unsigned char *pBuf;
+ if( in==0 ) return 0;
+ fseek(in, 0, SEEK_END);
+ nIn = ftell(in);
+ rewind(in);
+ pBuf = malloc( nIn+1 );
+ if( pBuf==0 ){ fclose(in); return 0; }
+ nRead = fread(pBuf, nIn, 1, in);
+ fclose(in);
+ if( nRead!=1 ){
+ free(pBuf);
+ return 0;
+ }
+ pBuf[nIn] = 0;
+ if( pnByte ) *pnByte = nIn;
+ return pBuf;
+}
+#endif /* STANDALONE */
+
+#ifdef STANDALONE
+int main(int argc, char **argv){
+ int i;
+ LLVMFuzzerInitialize(&argc, &argv);
+ for(i=1; i<argc; i++){
+ unsigned char *pIn;
+ int nIn;
+ pIn = readFile(argv[i], &nIn);
+ if( pIn ){
+ LLVMFuzzerTestOneInput((const uint8_t*)pIn, (size_t)nIn);
+ free(pIn);
+ }
+ }
+#ifdef RUSAGE_SELF
+ if( eVerbosity>0 ){
+ struct rusage x;
+ printf("SQLite %s\n", sqlite3_sourceid());
+ memset(&x, 0, sizeof(x));
+ if( getrusage(RUSAGE_SELF, &x)==0 ){
+ printf("Maximum RSS = %ld KB\n", x.ru_maxrss);
+ }
+ }
+#endif
+ return 0;
+}
+#endif /*STANDALONE*/
diff --git a/test/dbpage.test b/test/dbpage.test
new file mode 100644
index 0000000..0646a70
--- /dev/null
+++ b/test/dbpage.test
@@ -0,0 +1,111 @@
+# 2017-10-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 sqlite_dbpage virtual table.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix dbpage
+
+ifcapable !vtab||!compound {
+ finish_test
+ return
+}
+
+sqlite3_db_config db DEFENSIVE 0
+do_test 100 {
+ execsql {
+ PRAGMA auto_vacuum=0;
+ PRAGMA page_size=4096;
+ PRAGMA journal_mode=WAL;
+ }
+ execsql {
+ CREATE TABLE t1(a,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b) SELECT x, printf('%d-x%.*c',x,x,'x') FROM c;
+ PRAGMA integrity_check;
+ }
+} {ok}
+do_execsql_test 110 {
+ SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage('main') ORDER BY pgno;
+} {1 X'53514C6974' 2 X'0500000001' 3 X'0D0000004E' 4 X'0D00000016'}
+do_execsql_test 120 {
+ SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage WHERE pgno=2;
+} {2 X'0500000001'}
+do_execsql_test 130 {
+ SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage WHERE pgno=4;
+} {4 X'0D00000016'}
+do_execsql_test 140 {
+ SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage WHERE pgno=5;
+} {}
+do_execsql_test 150 {
+ SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage WHERE pgno=0;
+} {}
+do_execsql_test 160 {
+ ATTACH ':memory:' AS aux1;
+ PRAGMA aux1.page_size=4096;
+ CREATE TABLE aux1.t2(a,b,c);
+ INSERT INTO t2 VALUES(11,12,13);
+ SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage('aux1');
+} {1 X'53514C6974' 2 X'0D00000001'}
+do_execsql_test 170 {
+ CREATE TABLE aux1.x3(x,y,z);
+ INSERT INTO x3(x,y,z) VALUES(1,'main',1),(2,'aux1',1);
+ SELECT pgno, schema, substr(data,1,6)
+ FROM sqlite_dbpage, x3
+ WHERE sqlite_dbpage.schema=x3.y AND sqlite_dbpage.pgno=x3.z
+ ORDER BY x3.x;
+} {1 main SQLite 1 aux1 SQLite}
+
+do_execsql_test 200 {
+ CREATE TEMP TABLE saved_content(x);
+ INSERT INTO saved_content(x) SELECT data FROM sqlite_dbpage WHERE pgno=4;
+ UPDATE sqlite_dbpage SET data=zeroblob(4096) WHERE pgno=4;
+} {}
+do_catchsql_test 210 {
+ PRAGMA integrity_check;
+} {1 {database disk image is malformed}}
+do_execsql_test 220 {
+ SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage('main') ORDER BY pgno;
+} {1 X'53514C6974' 2 X'0500000001' 3 X'0D0000004E' 4 X'0000000000'}
+do_execsql_test 230 {
+ UPDATE sqlite_dbpage SET data=(SELECT x FROM saved_content) WHERE pgno=4;
+} {}
+do_catchsql_test 230 {
+ PRAGMA integrity_check;
+} {0 ok}
+do_execsql_test 240 {
+ DELETE FROM saved_content;
+ INSERT INTO saved_content(x)
+ SELECT data FROM sqlite_dbpage WHERE schema='aux1' AND pgno=2;
+} {}
+do_execsql_test 241 {
+ UPDATE sqlite_dbpage SET data=zeroblob(4096) WHERE pgno=2 AND schema='aux1';
+} {}
+do_catchsql_test 250 {
+ PRAGMA aux1.integrity_check;
+} {1 {database disk image is malformed}}
+do_execsql_test 260 {
+ UPDATE sqlite_dbpage SET data=(SELECT x FROM saved_content)
+ WHERE pgno=2 AND schema='aux1';
+} {}
+do_catchsql_test 270 {
+ PRAGMA aux1.integrity_check;
+} {0 ok}
+
+db close
+sqlite3 db :memory:
+do_execsql_test 300 {
+ SELECT * FROM sqlite_temp_schema, sqlite_dbpage;
+} {}
+
+finish_test
diff --git a/test/dbpagefault.test b/test/dbpagefault.test
new file mode 100644
index 0000000..b41ac66
--- /dev/null
+++ b/test/dbpagefault.test
@@ -0,0 +1,88 @@
+# 2022 July 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
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+if {[permutation] == "inmemory_journal"} {
+ finish_test
+ return
+}
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+set testprefix dbpagefault
+
+faultsim_save_and_close
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+ execsql { ATTACH 'test.db2' AS aux; }
+} -body {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING sqlite_dbpage();
+ }
+} -test {
+ execsql { PRAGMA journal_mode = off }
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 2 -prep {
+ sqlite3 db "xyz.db" -vfs memdb
+ execsql { ATTACH 'test.db2' AS aux; }
+} -body {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING sqlite_dbpage();
+ INSERT INTO t1 DEFAULT VALUES;
+ }
+} -test {
+ execsql { PRAGMA journal_mode = off }
+ faultsim_test_result {1 {no such schema}} {1 {SQL logic error}}
+}
+
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE x1(z, b);
+ CREATE TRIGGER BEFORE INSERT ON x1 BEGIN
+ DELETE FROM sqlite_dbpage WHERE pgno=100;
+ UPDATE sqlite_dbpage SET data=null WHERE pgno=100;
+ END;
+}
+
+# This test case no longer works, as it is no longer possible to use
+# virtual table sqlite_dbpage from within a trigger.
+#
+do_execsql_test 3.1 {
+ PRAGMA trusted_schema = 1;
+}
+do_catchsql_test 3.2 {
+ PRAGMA trusted_schema = 1;
+ INSERT INTO x1 DEFAULT VALUES;
+} {1 {unsafe use of virtual table "sqlite_dbpage"}}
+#do_faultsim_test 3 -prep {
+# catch { db close }
+# sqlite3 db test.db
+# execsql { PRAGMA trusted_schema = 1 }
+#} -body {
+# execsql { INSERT INTO x1 DEFAULT VALUES; }
+#} -test {
+# faultsim_test_result {0 {}}
+#}
+
+
+finish_test
+
+
diff --git a/test/dbstatus.test b/test/dbstatus.test
new file mode 100644
index 0000000..8d5d834
--- /dev/null
+++ b/test/dbstatus.test
@@ -0,0 +1,457 @@
+# 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
+set testprefix dbstatus
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+# Memory statistics must be enabled for this test.
+db close
+sqlite3_shutdown
+sqlite3_config_memstatus 1
+sqlite3_config_uri 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 stat4 {
+ 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} {
+ ifcapable malloc_usable_size break
+
+ # 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;
+ }
+ 6k {
+ 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 "k" report slightly less
+ # memory than is actually freed when all schema items are finalized.
+ # This is because memory allocated by KeyInfo objects is no longer
+ # counted as "schema memory".
+ #
+ # 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_stat4 is unaccounted for by
+ # dbstatus.
+ #
+ # Finally, on osx the estimate of memory used by the schema may be
+ # slightly low.
+ #
+ if {[string match *k $tn]
+ || [string match *x $tn] || $AUTOVACUUM
+ || ([string match *y $tn] && $STAT3)
+ || ($::tcl_platform(os) == "Darwin")
+ } {
+ 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]
+ }
+}
+
+#-------------------------------------------------------------------------
+# The following tests focus on DBSTATUS_CACHE_USED_SHARED
+#
+ifcapable shared_cache {
+ if {([permutation]=="memsys3"
+ || [permutation]=="memsys5"
+ || $::tcl_platform(os)=="Linux") && ![sqlite3 -has-codec]} {
+ proc do_cacheused_test {tn db res} {
+ set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0]
+ set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0]
+ set cu [lindex $cu 1]
+ set pcu [lindex $pcu 1]
+ uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"]
+ }
+ reset_db
+ sqlite3 db file:test.db?cache=shared
+
+ do_execsql_test 4.0 {
+ PRAGMA auto_vacuum=NONE;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ }
+ do_cacheused_test 4.0.1 db { 4568 4568 }
+ do_execsql_test 4.1 {
+ CREATE TEMP TABLE tt(a, b, c);
+ INSERT INTO tt VALUES(1, 2, 3);
+ }
+ do_cacheused_test 4.1.1 db { 9000 9000 }
+
+ sqlite3 db2 file:test.db?cache=shared
+ do_cacheused_test 4.2.1 db2 { 4568 2284 }
+ do_cacheused_test 4.2.2 db { 9000 6716 }
+ db close
+ do_cacheused_test 4.2.3 db2 { 4568 4568 }
+ sqlite3 db file:test.db?cache=shared
+ do_cacheused_test 4.2.4 db2 { 4568 2284 }
+ db2 close
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that passing an out-of-range value to sqlite3_stmt_status does
+# not cause a crash.
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+}
+
+do_test 5.1 {
+ set ::stmt [sqlite3_prepare db "SELECT * FROM t1" -1 dummy]
+ sqlite3_step $::stmt
+ sqlite3_step $::stmt
+ sqlite3_step $::stmt
+ sqlite3_reset $::stmt
+} {SQLITE_OK}
+
+ifcapable api_armor {
+ do_test 5.2 { sqlite3_stmt_status $::stmt -1 0 } 0
+}
+do_test 5.3 { sqlite3_stmt_status $::stmt 0 0 } 0
+do_test 5.4 {
+ expr [sqlite3_stmt_status $::stmt 99 0]>0
+} 1
+foreach {tn id res} {
+ 1 SQLITE_STMTSTATUS_MEMUSED 1
+ 2 SQLITE_STMTSTATUS_FULLSCAN_STEP 1
+ 3 SQLITE_STMTSTATUS_SORT 0
+ 4 SQLITE_STMTSTATUS_AUTOINDEX 0
+ 5 SQLITE_STMTSTATUS_VM_STEP 1
+ 6 SQLITE_STMTSTATUS_REPREPARE 0
+ 7 SQLITE_STMTSTATUS_RUN 1
+} {
+if {$tn==2} breakpoint
+ do_test 5.5.$tn { expr [sqlite3_stmt_status $::stmt $id 0]>0 } $res
+}
+
+sqlite3_finalize $::stmt
+finish_test
diff --git a/test/dbstatus2.test b/test/dbstatus2.test
new file mode 100644
index 0000000..5e9ea88
--- /dev/null
+++ b/test/dbstatus2.test
@@ -0,0 +1,115 @@
+# 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_db_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
+}
+
+proc db_write {db {reset 0}} {
+ sqlite3_db_status $db CACHE_WRITE $reset
+}
+
+proc db_spill {db {reset 0}} {
+ sqlite3_db_status $db CACHE_SPILL $reset
+}
+
+do_test 1.1 {
+ db close
+ sqlite3 db test.db
+ execsql { PRAGMA mmap_size = 0 }
+ 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}
+
+do_test 2.1 { db_write db } {0 0 0}
+do_test 2.2 {
+ execsql { INSERT INTO t1 VALUES(4, randomblob(600)) }
+ db_write db
+} {0 4 0}
+do_test 2.3 { db_write db 1 } {0 4 0}
+do_test 2.4 { db_write db 0 } {0 0 0}
+do_test 2.5 { db_write db 1 } {0 0 0}
+
+if {[wal_is_capable]} {
+ do_test 2.6 {
+ execsql { PRAGMA journal_mode = WAL }
+ db_write db 1
+ } {0 1 0}
+}
+do_test 2.7 {
+ execsql { INSERT INTO t1 VALUES(5, randomblob(600)) }
+ db_write db
+} {0 4 0}
+do_test 2.8 { db_write db 1 } {0 4 0}
+do_test 2.9 { db_write db 0 } {0 0 0}
+
+do_test 3.0 { db_spill db 1 } {0 0 0}
+do_test 3.1 { db_spill db 0 } {0 0 0}
+do_execsql_test 3.2 {
+ PRAGMA journal_mode=DELETE;
+ PRAGMA cache_size=3;
+ UPDATE t1 SET b=randomblob(1000);
+} {delete}
+do_test 3.3 { db_spill db 0 } {0 8 0}
+
+finish_test
diff --git a/test/decimal.test b/test/decimal.test
new file mode 100644
index 0000000..a2e5799
--- /dev/null
+++ b/test/decimal.test
@@ -0,0 +1,186 @@
+# 2017 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix decimal
+
+if {[catch {load_static_extension db decimal} error]} {
+ puts "Skipping decimal tests, hit load error: $error"
+ finish_test; return
+}
+
+do_execsql_test 1000 {
+ SELECT decimal(1);
+} {1}
+do_execsql_test 1010 {
+ SELECT decimal(1.0);
+} {1.0}
+do_execsql_test 1020 {
+ SELECT decimal(0001.0);
+} {1.0}
+do_execsql_test 1030 {
+ SELECT decimal(+0001.0);
+} {1.0}
+do_execsql_test 1040 {
+ SELECT decimal(-0001.0);
+} {-1.0}
+do_execsql_test 1050 {
+ SELECT decimal(1.0e72);
+} {1000000000000000000000000000000000000000000000000000000000000000000000000}
+# 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123
+do_execsql_test 1060 {
+ SELECT decimal(1.0e-72);
+} {0.0000000000000000000000000000000000000000000000000000000000000000000000010}
+# 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123
+do_execsql_test 1070 {
+ SELECT decimal(-123e-4);
+} {-0.0123}
+do_execsql_test 1080 {
+ SELECT decimal(+123e+4);
+} {1230000.0}
+
+
+do_execsql_test 2000 {
+ CREATE TABLE t1(seq INTEGER PRIMARY KEY, val TEXT);
+ INSERT INTO t1 VALUES
+ (1, '-9999e99'),
+ (2, '-9998.000e+99'),
+ (3, '-9999.0'),
+ (4, '-1'),
+ (5, '-9999e-20'),
+ (6, '0'),
+ (7, '1e-30'),
+ (8, '1e-29'),
+ (9, '1'),
+ (10,'1.00000000000000001'),
+ (11,'+1.00001'),
+ (12,'99e+99');
+ SELECT *, '|'
+ FROM t1 AS a, t1 AS b
+ WHERE a.seq<b.seq
+ AND decimal_cmp(a.val,b.val)>=0;
+} {}
+do_execsql_test 2010 {
+ SELECT *, '|'
+ FROM t1 AS a, t1 AS b
+ WHERE a.seq<>b.seq
+ AND decimal_cmp(a.val,b.val)==0;
+} {}
+do_execsql_test 2020 {
+ SELECT *, '|'
+ FROM t1 AS a, t1 AS b
+ WHERE a.seq>b.seq
+ AND decimal_cmp(a.val,b.val)<=0;
+} {}
+do_execsql_test 2030 {
+ SELECT seq FROM t1 ORDER BY val COLLATE decimal;
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+do_execsql_test 2040 {
+ SELECT seq FROM t1 ORDER BY val COLLATE decimal DESC;
+} {12 11 10 9 8 7 6 5 4 3 2 1}
+
+do_execsql_test 3000 {
+ CREATE TABLE t3(seq INTEGER PRIMARY KEY, val TEXT);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<10)
+ INSERT INTO t3(seq, val) SELECT x, x FROM c;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<5)
+ INSERT INTO t3(seq, val) SELECT x+10, x*1000 FROM c;
+ SELECT decimal(val) FROM t3 ORDER BY seq;
+} {1 2 3 4 5 6 7 8 9 10 1000 2000 3000 4000 5000}
+do_execsql_test 3020 {
+ SELECT decimal_add(val,'0.5') FROM t3 WHERE seq>5 ORDER BY seq
+} {6.5 7.5 8.5 9.5 10.5 1000.5 2000.5 3000.5 4000.5 5000.5}
+do_execsql_test 3030 {
+ SELECT decimal_add(val,'-10') FROM t3 ORDER BY seq;
+} {-9 -8 -7 -6 -5 -4 -3 -2 -1 0 990 1990 2990 3990 4990}
+
+do_execsql_test 4000 {
+ SELECT decimal_sum(val) FROM t3;
+} {15055}
+do_execsql_test 4010 {
+ SELECT decimal_sum(decimal_add(val,val||'e+10')) FROM t3;
+} {150550000015055}
+do_execsql_test 4010 {
+ SELECT decimal_sum(decimal_add(val||'e+20',decimal_add(val,val||'e-20')))
+ FROM t3;
+} {1505500000000000000015055.00000000000000015055}
+
+do_execsql_test 5000 {
+ WITH RECURSIVE c(x,y,z) AS (
+ VALUES(0,'1','1')
+ UNION ALL
+ SELECT x+1, decimal_mul(y,'2'), decimal_mul(z,'0.5')
+ FROM c WHERE x<32
+ )
+ SELECT count(*) FROM c WHERE decimal_mul(y,z)='1';
+} {33}
+
+do_execsql_test 5100 {
+ SELECT decimal_mul('1234.00','2.00');
+} {2468.00}
+do_execsql_test 5101 {
+ SELECT decimal_mul('1234.00','2.0000');
+} {2468.00}
+do_execsql_test 5102 {
+ SELECT decimal_mul('1234.0000','2.000');
+} {2468.000}
+do_execsql_test 5103 {
+ SELECT decimal_mul('1234.0000','2');
+} {2468}
+
+if {[catch {load_static_extension db ieee754} error]} {
+ puts "Skipping ieee754 tests, hit load error: $error"
+ finish_test; return
+}
+
+do_execsql_test 6000 {
+ CREATE TABLE pow2(x INTEGER PRIMARY KEY, v TEXT);
+ WITH RECURSIVE c(x,v) AS (
+ VALUES(0,'1')
+ UNION ALL
+ SELECT x+1, decimal_mul(v,'2') FROM c WHERE x+1<=971
+ ) INSERT INTO pow2(x,v) SELECT x, v FROM c;
+ WITH RECURSIVE c(x,v) AS (
+ VALUES(-1,'0.5')
+ UNION ALL
+ SELECT x-1, decimal_mul(v,'0.5') FROM c WHERE x-1>=-1075
+ ) INSERT INTO pow2(x,v) SELECT x, v FROM c;
+} {}
+do_execsql_test 6010 {
+ WITH c(n) AS (SELECT ieee754_from_blob(x'0000000000000001'))
+SELECT decimal_mul(ieee754_mantissa(c.n),pow2.v)
+ FROM pow2, c WHERE pow2.x=ieee754_exponent(c.n);
+} {0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625}
+do_execsql_test 6020 {
+ WITH c(n) AS (SELECT ieee754_from_blob(x'7fefffffffffffff'))
+SELECT decimal_mul(ieee754_mantissa(c.n),pow2.v)
+ FROM pow2, c WHERE pow2.x=ieee754_exponent(c.n);
+} {179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368}
+
+do_execsql_test 6100 {
+ SELECT ieee754(ieee754_from_blob(x'0000000000000001'));
+} {ieee754(1,-1074)}
+do_execsql_test 6110 {
+ SELECT ieee754(ieee754_from_blob(x'7fefffffffffffff'));
+} {ieee754(9007199254740991,971)}
+do_execsql_test 6120 {
+ SELECT printf('%.8e',ieee754_from_blob(x'0000000000000001'));
+} {4.94065646e-324}
+do_execsql_test 6130 {
+ SELECT printf('%.8e',ieee754_from_blob(x'ffefffffffffffff'));
+} {-1.79769313e+308}
+
+
+
+
+finish_test
diff --git a/test/default.test b/test/default.test
new file mode 100644
index 0000000..06a180c
--- /dev/null
+++ b/test/default.test
@@ -0,0 +1,140 @@
+# 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}
+}
+
+do_execsql_test default-3.1 {
+ CREATE TABLE t3(
+ a INTEGER PRIMARY KEY AUTOINCREMENT,
+ b INT DEFAULT 12345 UNIQUE NOT NULL CHECK( b>=0 AND b<99999 ),
+ c VARCHAR(123,456) DEFAULT 'hello' NOT NULL ON CONFLICT REPLACE,
+ d REAL,
+ e FLOATING POINT(5,10) DEFAULT 4.36,
+ f NATIONAL CHARACTER(15) COLLATE RTRIM,
+ g LONG INTEGER DEFAULT( 3600*12 )
+ );
+ INSERT INTO t3 VALUES(null, 5, 'row1', '5.25', 'xyz', 321, '432');
+ SELECT a, typeof(a), b, typeof(b), c, typeof(c),
+ d, typeof(d), e, typeof(e), f, typeof(f),
+ g, typeof(g) FROM t3;
+} {1 integer 5 integer row1 text 5.25 real xyz text 321 text 432 integer}
+do_execsql_test default-3.2 {
+ DELETE FROM t3;
+ INSERT INTO t3 DEFAULT VALUES;
+ SELECT * FROM t3;
+} {2 12345 hello {} 4.36 {} 43200}
+do_execsql_test default-3.3 {
+ CREATE TABLE t300(
+ a INT DEFAULT 2147483647,
+ b INT DEFAULT 2147483648,
+ c INT DEFAULT +9223372036854775807,
+ d INT DEFAULT -2147483647,
+ e INT DEFAULT -2147483648,
+ f INT DEFAULT -9223372036854775808,
+ g INT DEFAULT (-(-9223372036854775808)),
+ h INT DEFAULT (-(-9223372036854775807))
+ );
+ INSERT INTO t300 DEFAULT VALUES;
+ SELECT * FROM t300;
+} {2147483647 2147483648 9223372036854775807 -2147483647 -2147483648 -9223372036854775808 9.22337203685478e+18 9223372036854775807}
+
+# Do now allow bound parameters in new DEFAULT values.
+# Silently convert bound parameters to NULL in DEFAULT causes
+# in the sqlite_master table, for backwards compatibility.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test default-4.0 {
+ CREATE TABLE t1(a TEXT, b TEXT DEFAULT(99));
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_master SET sql='CREATE TABLE t1(a TEXT, b TEXT DEFAULT(:xyz))';
+} {}
+db close
+sqlite3 db test.db
+do_execsql_test default-4.1 {
+ INSERT INTO t1(a) VALUES('xyzzy');
+ SELECT a, quote(b) FROM t1;
+} {xyzzy NULL}
+do_catchsql_test default-4.2 {
+ CREATE TABLE t2(a TEXT, b TEXT DEFAULT(:xyz));
+} {1 {default value of column [b] is not constant}}
+do_catchsql_test default-4.3 {
+ CREATE TABLE t2(a TEXT, b TEXT DEFAULT(abs(:xyz)));
+} {1 {default value of column [b] is not constant}}
+do_catchsql_test default-4.4 {
+ CREATE TABLE t2(a TEXT, b TEXT DEFAULT(98+coalesce(5,:xyz)));
+} {1 {default value of column [b] is not constant}}
+
+# 2020-03-09 out-of-bounds memory access discovered by "Eternal Sakura"
+# and reported to chromium.
+#
+reset_db
+do_catchsql_test default-5.1 {
+ CREATE TABLE t1 (a,b DEFAULT(random() NOTNULL IN (RAISE(IGNORE),2,3)));
+ INSERT INTO t1(a) VALUES(1);
+} {1 {RAISE() may only be used within a trigger-program}}
+
+finish_test
diff --git a/test/delete.test b/test/delete.test
new file mode 100644
index 0000000..a448e52
--- /dev/null
+++ b/test/delete.test
@@ -0,0 +1,419 @@
+# 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}
+
+do_execsql_test delete-10.0 {
+ CREATE TABLE t1(a INT UNIQUE, b INT);
+ INSERT INTO t1(a,b) VALUES('1','2');
+ SELECT * FROM t1 WHERE a='1' AND b='2';
+} {1 2}
+
+do_execsql_test delete-10.1 {
+ DELETE FROM t1 WHERE a='1' AND b='2';
+}
+
+do_execsql_test delete-10.2 {
+ SELECT * FROM t1 WHERE a='1' AND b='2';
+}
+
+do_execsql_test delete-11.0 {
+ CREATE TABLE t11(a INTEGER PRIMARY KEY, b INT);
+ WITH RECURSIVE cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<20)
+ INSERT INTO t11(a,b) SELECT x, (x*17)%100 FROM cnt;
+ SELECT * FROM t11;
+} {1 17 2 34 3 51 4 68 5 85 6 2 7 19 8 36 9 53 10 70 11 87 12 4 13 21 14 38 15 55 16 72 17 89 18 6 19 23 20 40}
+do_execsql_test delete-11.1 {
+ DELETE FROM t11 AS xyz
+ WHERE EXISTS(SELECT 1 FROM t11 WHERE t11.a>xyz.a AND t11.b<=xyz.b);
+ SELECT * FROM t11;
+} {6 2 12 4 18 6 19 23 20 40}
+
+
+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/delete4.test b/test/delete4.test
new file mode 100644
index 0000000..8d6a1b8
--- /dev/null
+++ b/test/delete4.test
@@ -0,0 +1,272 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix delete4
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(1, 0);
+ INSERT INTO t1 VALUES(2, 1);
+ INSERT INTO t1 VALUES(3, 0);
+ INSERT INTO t1 VALUES(4, 1);
+ INSERT INTO t1 VALUES(5, 0);
+ INSERT INTO t1 VALUES(6, 1);
+ INSERT INTO t1 VALUES(7, 0);
+ INSERT INTO t1 VALUES(8, 1);
+}
+do_execsql_test 1.2 {
+ DELETE FROM t1 WHERE y=1;
+}
+do_execsql_test 1.3 {
+ SELECT x FROM t1;
+} {1 3 5 7}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 2.1 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);
+ INSERT INTO t1 VALUES(1, 0, randomblob(200));
+ INSERT INTO t1 VALUES(2, 1, randomblob(200));
+ INSERT INTO t1 VALUES(3, 0, randomblob(200));
+ INSERT INTO t1 VALUES(4, 1, randomblob(200));
+ INSERT INTO t1 VALUES(5, 0, randomblob(200));
+ INSERT INTO t1 VALUES(6, 1, randomblob(200));
+ INSERT INTO t1 VALUES(7, 0, randomblob(200));
+ INSERT INTO t1 VALUES(8, 1, randomblob(200));
+}
+do_execsql_test 2.2 {
+ DELETE FROM t1 WHERE y=1;
+}
+do_execsql_test 2.3 {
+ SELECT x FROM t1;
+} {1 3 5 7}
+
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 3.0.1 {
+ CREATE TABLE t1(a, b, PRIMARY KEY(a, b)) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(2, 4);
+ INSERT INTO t1 VALUES(1, 5);
+ DELETE FROM t1 WHERE a=1;
+ SELECT printf('(%d)',changes());
+ SELECT * FROM t1;
+} {(2) 2 4}
+do_execsql_test 3.0.2 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b) SELECT x, x+1 FROM c;
+ SELECT printf('(%d)',changes());
+ DELETE FROM t1;
+ SELECT printf('(%d)',changes());
+} {(100) (101)}
+
+#-------------------------------------------------------------------------
+# DELETE statement that uses the OR optimization
+#
+reset_db
+do_execsql_test 3.1 {
+ CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b);
+ CREATE INDEX i1a ON t1(a);
+ CREATE INDEX i1b 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, 'one', 'i');
+ INSERT INTO t1 VALUES(6, 'two', 'ii');
+ INSERT INTO t1 VALUES(7, 'three', 'iii');
+ INSERT INTO t1 VALUES(8, 'four', 'iv');
+} {}
+
+do_execsql_test 3.2 {
+ DELETE FROM t1 WHERE a='two' OR b='iv';
+}
+
+do_execsql_test 3.3 {
+ SELECT i FROM t1 ORDER BY i;
+} {1 3 5 7}
+
+do_execsql_test 3.4 {
+ PRAGMA integrity_check;
+} {ok}
+
+# Between 2015-09-14 and 2015-09-28, the following test cases would result
+# in corruption (wrong # of entries in index) due to a bug in the ONEPASS
+# optimization.
+#
+do_execsql_test 4.1 {
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(col0, col1);
+ INSERT INTO "t4" VALUES(14, 'abcde');
+ CREATE INDEX idx_t4_0 ON t4 (col1, col0);
+ CREATE INDEX idx_t4_3 ON t4 (col0);
+ DELETE FROM t4 WHERE col0=69 OR col0>7;
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test 4.2 {
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(col0, col1);
+ INSERT INTO "t4" VALUES(14, 'abcde');
+ CREATE INDEX idx_t4_3 ON t4 (col0);
+ CREATE INDEX idx_t4_0 ON t4 (col1, col0);
+ DELETE FROM t4 WHERE col0=69 OR col0>7;
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test 4.11 {
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(col0, col1, pk PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t4 VALUES(14, 'abcde','xyzzy');
+ CREATE INDEX idx_t4_0 ON t4 (col1, col0);
+ CREATE INDEX idx_t4_3 ON t4 (col0);
+ DELETE FROM t4 WHERE col0=69 OR col0>7;
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test 4.12 {
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(col0, col1, pk PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t4 VALUES(14, 'abcde','xyzzy');
+ CREATE INDEX idx_t4_3 ON t4 (col0);
+ CREATE INDEX idx_t4_0 ON t4 (col1, col0);
+ DELETE FROM t4 WHERE col0=69 OR col0>7;
+ PRAGMA integrity_check;
+} {ok}
+
+# 2016-04-09
+# Ticket https://sqlite.org/src/info/a306e56ff68b8fa5
+# Failure to completely delete when reverse_unordered_selects is
+# engaged.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 5.0 {
+ PRAGMA page_size=1024;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ CREATE INDEX x1 ON t1(b, c);
+ INSERT INTO t1(a,b,c) VALUES(1, 1, zeroblob(80));
+ INSERT INTO t1(a,b,c) SELECT a+1, 1, c FROM t1;
+ INSERT INTO t1(a,b,c) SELECT a+2, 1, c FROM t1;
+ INSERT INTO t1(a,b,c) SELECT a+10, 2, c FROM t1 WHERE b=1;
+ INSERT INTO t1(a,b,c) SELECT a+20, 3, c FROM t1 WHERE b=1;
+ PRAGMA reverse_unordered_selects = ON;
+ DELETE FROM t1 WHERE b=2;
+ SELECT a FROM t1 WHERE b=2;
+} {}
+
+# 2016-05-02
+# Ticket https://www.sqlite.org/src/tktview/dc6ebeda93960877
+# A subquery in the WHERE clause of a one-pass DELETE can cause an
+# incorrect answer.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 6.0 {
+ CREATE TABLE t2(x INT);
+ INSERT INTO t2(x) VALUES(1),(2),(3),(4),(5);
+ DELETE FROM t2 WHERE EXISTS(SELECT 1 FROM t2 AS v WHERE v.x=t2.x-1);
+ SELECT x FROM t2;
+} {1}
+do_execsql_test 6.1 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x INT);
+ INSERT INTO t2(x) VALUES(1),(2),(3),(4),(5);
+ DELETE FROM t2 WHERE EXISTS(SELECT 1 FROM t2 AS v WHERE v.x=t2.x+1);
+ SELECT x FROM t2;
+} {5}
+
+#-------------------------------------------------------------------------
+# Test the effect of failing to find a table row based on an index key
+# within a DELETE. Either because the db is corrupt, or a trigger on another
+# row already deleted the entry, or because a BEFORE trigger on the current
+# row has already deleted it.
+#
+do_execsql_test 7.1.0 {
+ CREATE TABLE t3(id INT PRIMARY KEY, a, b) WITHOUT ROWID;
+ CREATE INDEX t3a ON t3(a);
+ CREATE INDEX t3b ON t3(b);
+
+ INSERT INTO t3 VALUES(1, 1, 1);
+ INSERT INTO t3 VALUES(2, 2, 2);
+ INSERT INTO t3 VALUES(3, 3, 3);
+ INSERT INTO t3 VALUES(4, 4, 1);
+}
+do_execsql_test 7.1.1 {
+ DELETE FROM t3 WHERE a=4 OR b=1;
+}
+do_execsql_test 7.1.2 {
+ SELECT * FROM t3;
+} { 2 2 2 3 3 3 }
+
+do_execsql_test 7.2.0 {
+ CREATE TABLE t4(a PRIMARY KEY, b) WITHOUT ROWID;
+ CREATE INDEX t4i ON t4(b);
+ INSERT INTO t4 VALUES(1, 'hello');
+ INSERT INTO t4 VALUES(2, 'world');
+
+ CREATE TABLE t5(a PRIMARY KEY, b) WITHOUT ROWID;
+ CREATE INDEX t5i ON t5(b);
+ INSERT INTO t5 VALUES(1, 'hello');
+ INSERT INTO t5 VALUES(3, 'world');
+
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master SET rootpage = (
+ SELECT rootpage FROM sqlite_master WHERE name = 't5'
+ ) WHERE name = 't4';
+}
+
+db close
+sqlite3 db test.db
+do_execsql_test 7.2.1 {
+ DELETE FROM t4 WHERE b='world'
+}
+reset_db
+
+do_execsql_test 7.3.0 {
+ CREATE TABLE t3(id INT PRIMARY KEY, a, b) WITHOUT ROWID;
+ INSERT INTO t3 VALUES(1, 2, 3);
+ INSERT INTO t3 VALUES(4, 5, 6);
+ INSERT INTO t3 VALUES(7, 8, 9);
+ CREATE TRIGGER t3t BEFORE DELETE ON t3 BEGIN
+ DELETE FROM t3 WHERE id=old.id+3;
+ END;
+}
+
+do_execsql_test 7.3.1 {
+ DELETE FROM t3 WHERE a IN(2, 5, 8);
+ SELECT * FROM t3;
+} {}
+
+do_execsql_test 7.3.2 {
+ DROP TRIGGER t3t;
+ INSERT INTO t3 VALUES(1, 2, 3);
+ INSERT INTO t3 VALUES(4, 5, 6);
+ INSERT INTO t3 VALUES(7, 8, 9);
+ CREATE TRIGGER t3t BEFORE DELETE ON t3 BEGIN
+ DELETE FROM t3 WHERE id=old.id;
+ END;
+}
+
+do_execsql_test 7.3.3 {
+ DELETE FROM t3 WHERE a IN(2, 5, 8);
+ SELECT * FROM t3;
+} {}
+
+
+finish_test
diff --git a/test/delete_db.test b/test/delete_db.test
new file mode 100644
index 0000000..6edd9c2
--- /dev/null
+++ b/test/delete_db.test
@@ -0,0 +1,222 @@
+# 2016 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 implements regression tests for SQLite library. The
+# focus of this file is testing the code in test_delete.c (the
+# sqlite3_delete_database() API).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix delete_db
+
+if {[atomic_batch_write test.db]} {
+ finish_test
+ return
+}
+
+proc delete_all {} {
+ foreach f [glob -nocomplain test2*] { file delete $f }
+ foreach f [glob -nocomplain test3*] { file delete $f }
+}
+
+proc copydb {} {
+ foreach f [glob -nocomplain test3*] { file delete $f }
+ foreach f [glob -nocomplain test2*] {
+ set p [string range $f 5 end]
+ file copy "test2$p" "test3$p"
+ }
+}
+
+proc files {} {
+ lsort [glob -nocomplain test3*]
+}
+
+db close
+delete_all
+sqlite3 db test2.database
+
+#-------------------------------------------------------------------------
+#
+# 1.1: Journal files.
+# 1.2: Wal files.
+# 1.3: Multiplexor with journal file.
+# 1.4: Multiplexor with wal file.
+#
+# 2.* are a copy of 1.* with the multiplexor enabled.
+#
+# 3.* tests errors.
+#
+
+do_test 1.1.0 {
+ execsql {
+ CREATE TABLE t1(x, y);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ copydb
+ files
+} {test3.database test3.database-journal}
+
+do_test 1.1.1 {
+ sqlite3_delete_database test3.database
+ files
+} {}
+
+do_test 1.2.0 {
+ execsql {
+ COMMIT;
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ copydb
+ files
+} {test3.database test3.database-shm test3.database-wal}
+do_test 1.2.1 {
+ sqlite3_delete_database test3.database
+ files
+} {}
+
+db close
+delete_all
+sqlite3_multiplex_initialize "" 0
+sqlite3 db test2.database -vfs multiplex
+sqlite3_multiplex_control db "main" chunk_size 32768
+
+do_test 1.3.0 {
+ execsql { PRAGMA auto_vacuum = 0; }
+ execsql {
+ CREATE TABLE x1(a, b);
+ WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000 )
+ INSERT INTO x1 SELECT randomblob(100), randomblob(100) FROM s;
+ BEGIN;
+ UPDATE x1 SET a=randomblob(101)
+ }
+ copydb
+ files
+} [list {*}{
+ test3.database test3.database-journal test3.database001
+ test3.database002 test3.database003
+}]
+do_test 1.3.1 {
+ sqlite3_delete_database test3.database
+ files
+} {}
+
+
+do_test 1.4.0 {
+ execsql {
+ COMMIT;
+ PRAGMA journal_mode = wal;
+ UPDATE x1 SET a=randomblob(102)
+ }
+ copydb
+ files
+} [list {*}{
+ test3.database test3.database-shm test3.database-wal test3.database001
+ test3.database002 test3.database003
+}]
+do_test 1.4.1 {
+ sqlite3_delete_database test3.database
+ files
+} {}
+
+
+ifcapable 8_3_names {
+ db close
+ delete_all
+ sqlite3 db file:test2.db?8_3_names=1 -uri 1
+
+ do_test 2.1.0 {
+ execsql {
+ CREATE TABLE t1(x, y);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ copydb
+ files
+ } {test3.db test3.nal}
+
+ do_test 2.1.1 {
+ sqlite3_delete_database test3.db
+ files
+ } {}
+
+ do_test 2.2.0 {
+ execsql {
+ COMMIT;
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ copydb
+ files
+ } {test3.db test3.shm test3.wal}
+ do_test 2.2.1 {
+ sqlite3_delete_database test3.db
+ files
+ } {}
+
+
+ db close
+ delete_all
+ sqlite3_multiplex_initialize "" 0
+ sqlite3 db file:test2.db?8_3_names=1 -uri 1 -vfs multiplex
+ sqlite3_multiplex_control db "main" chunk_size 32768
+
+ do_test 2.3.0 {
+ execsql { PRAGMA auto_vacuum = 0; }
+ execsql {
+ CREATE TABLE x1(a, b);
+ WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000 )
+ INSERT INTO x1 SELECT randomblob(100), randomblob(100) FROM s;
+ BEGIN;
+ UPDATE x1 SET a=randomblob(101)
+ }
+ copydb
+ files
+ } [list {*}{
+ test3.001 test3.002 test3.003 test3.db test3.nal
+ }]
+ do_test 2.3.1 {
+ sqlite3_delete_database test3.db
+ files
+ } {}
+
+
+ do_test 2.4.0 {
+ execsql {
+ COMMIT;
+ PRAGMA journal_mode = wal;
+ UPDATE x1 SET a=randomblob(102)
+ }
+ copydb
+ files
+ } [list {*}{
+ test3.001 test3.002 test3.003 test3.db test3.db-shm test3.wal
+ }]
+ do_test 2.4.1 {
+ sqlite3_delete_database test3.db
+ files
+ } {}
+}
+
+db close
+delete_all
+sqlite3_multiplex_shutdown
+
+do_test 3.0 {
+ file mkdir dir2.db
+ sqlite3_delete_database dir2.db
+} {SQLITE_ERROR}
+do_test 3.1 {
+ sqlite3_delete_database dir2.db/test.db
+} {SQLITE_OK}
+
+finish_test
diff --git a/test/descidx1.test b/test/descidx1.test
new file mode 100644
index 0000000..14be6f8
--- /dev/null
+++ b/test/descidx1.test
@@ -0,0 +1,365 @@
+# 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}
+sqlite3_db_config db LEGACY_FILE_FORMAT 0
+
+# 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 ORDER BY a;
+ }
+ } {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 ORDER BY a;
+ }
+ } {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
+ sqlite3_db_config db LEGACY_FILE_FORMAT
+ } {1}
+} else {
+ do_test descidx1-6.1 {
+ db close
+ forcedelete test.db test.db-journal
+ sqlite3 db test.db
+ sqlite3_db_config db LEGACY_FILE_FORMAT
+ } {0}
+}
+do_test descidx1-6.2 {
+ sqlite3_db_config db LEGACY_FILE_FORMAT 1
+ sqlite3_db_config db 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
+ sqlite3_db_config db LEGACY_FILE_FORMAT 0
+ sqlite3_db_config db 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 {
+ sqlite3_db_config db LEGACY_FILE_FORMAT 1
+ execsql {
+ VACUUM;
+ }
+ get_file_format
+ } {4}
+}
+
+
+
+finish_test
diff --git a/test/descidx2.test b/test/descidx2.test
new file mode 100644
index 0000000..5aefc59
--- /dev/null
+++ b/test/descidx2.test
@@ -0,0 +1,186 @@
+# 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}
+sqlite3_db_config db LEGACY_FILE_FORMAT 0
+
+# 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..30dd8f8
--- /dev/null
+++ b/test/descidx3.test
@@ -0,0 +1,155 @@
+# 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}
+sqlite3_db_config db LEGACY_FILE_FORMAT 0
+
+# 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 {
+ lsort [execsql {
+ UPDATE t1 SET a=2 WHERE i<6;
+ SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';
+ }]
+ } {2 3 4 6 8}
+ 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..446f85b
--- /dev/null
+++ b/test/distinct.test
@@ -0,0 +1,352 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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" && $opcode != "Explain"} { lappend program1 $opcode }
+ }
+ db eval "EXPLAIN $sql2" {
+ if {$opcode != "Noop" && $opcode != "Explain"} { 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!=8 && $p5!=0} { error "p5 = $p5" }
+ if {$p5==8} {
+ 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 NOT NULL, c2 NOT NULL);
+ CREATE INDEX i3 ON t3(c2);
+
+ CREATE TABLE t4(a, b NOT NULL, c NOT NULL, d NOT NULL);
+ CREATE UNIQUE INDEX t4i1 ON t4(b, c);
+ CREATE UNIQUE INDEX t4i2 ON t4(d COLLATE nocase);
+}
+foreach {tn noop sql} {
+
+ 1.1 0 "SELECT DISTINCT b, c FROM t1"
+ 1.2 1 "SELECT DISTINCT b, c FROM t4"
+ 2.1 0 "SELECT DISTINCT c FROM t1 WHERE b = ?"
+ 2.2 1 "SELECT DISTINCT c FROM t4 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 0 "SELECT DISTINCT * FROM t1"
+ 8.2 1 "SELECT DISTINCT * FROM t4"
+
+ 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.1 0 "SELECT DISTINCT a, d FROM t1"
+ 12.2 0 "SELECT DISTINCT a, d FROM t4"
+ 13.1 0 "SELECT DISTINCT a, b, c COLLATE nocase FROM t1"
+ 13.2 0 "SELECT DISTINCT a, b, c COLLATE nocase FROM t4"
+ 14.1 0 "SELECT DISTINCT a, d COLLATE nocase FROM t1"
+ 14.2 1 "SELECT DISTINCT a, d COLLATE nocase FROM t4"
+
+ 15 0 "SELECT DISTINCT a, d COLLATE binary FROM t1"
+ 16.1 0 "SELECT DISTINCT a, b, c COLLATE binary FROM t1"
+ 16.2 1 "SELECT DISTINCT a, b, c COLLATE binary FROM t4"
+
+ 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)"
+
+ 24 0 "SELECT DISTINCT rowid/2 FROM t1"
+ 25 1 "SELECT DISTINCT rowid/2, rowid FROM t1"
+ 26.1 0 "SELECT DISTINCT rowid/2, b FROM t1 WHERE c = ?"
+ 26.2 1 "SELECT DISTINCT rowid/2, b FROM t4 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 ORDER BY +b COLLATE binary" {btree 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 ORDER BY rowid;
+} {a A a A}
+
+do_test 3.0 {
+ db eval {
+ CREATE TABLE t3(a INTEGER, b INTEGER, c, UNIQUE(a,b));
+ INSERT INTO t3 VALUES
+ (null, null, 1),
+ (null, null, 2),
+ (null, 3, 4),
+ (null, 3, 5),
+ (6, null, 7),
+ (6, null, 8);
+ SELECT DISTINCT a, b FROM t3 ORDER BY +a, +b;
+ }
+} {{} {} {} 3 6 {}}
+do_test 3.1 {
+ regexp {OpenEphemeral} [db eval {
+ EXPLAIN SELECT DISTINCT a, b FROM t3 ORDER BY +a, +b;
+ }]
+} {0}
+
+#-------------------------------------------------------------------------
+# Ticket [fccbde530a6583bf2748400919f1603d5425995c] (2014-01-08)
+# The logic that computes DISTINCT sometimes thinks that a zeroblob()
+# and a blob of all zeros are different when they should be the same.
+#
+do_execsql_test 4.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(1);
+ CREATE TABLE t2(x);
+ INSERT INTO t2
+ SELECT DISTINCT
+ CASE a WHEN 1 THEN x'0000000000'
+ WHEN 2 THEN zeroblob(5)
+ ELSE 'xyzzy' END
+ FROM t1;
+ SELECT quote(x) FROM t2 ORDER BY 1;
+} {'xyzzy' X'0000000000'}
+
+#----------------------------------------------------------------------------
+# Ticket [c5ea805691bfc4204b1cb9e9aa0103bd48bc7d34] (2014-12-04)
+# Make sure that DISTINCT works together with ORDER BY and descending
+# indexes.
+#
+do_execsql_test 5.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(3),(1),(5),(2),(6),(4),(5),(1),(3);
+ CREATE INDEX t1x ON t1(x DESC);
+ SELECT DISTINCT x FROM t1 ORDER BY x ASC;
+} {1 2 3 4 5 6}
+do_execsql_test 5.2 {
+ SELECT DISTINCT x FROM t1 ORDER BY x DESC;
+} {6 5 4 3 2 1}
+do_execsql_test 5.3 {
+ SELECT DISTINCT x FROM t1 ORDER BY x;
+} {1 2 3 4 5 6}
+do_execsql_test 5.4 {
+ DROP INDEX t1x;
+ CREATE INDEX t1x ON t1(x ASC);
+ SELECT DISTINCT x FROM t1 ORDER BY x ASC;
+} {1 2 3 4 5 6}
+do_execsql_test 5.5 {
+ SELECT DISTINCT x FROM t1 ORDER BY x DESC;
+} {6 5 4 3 2 1}
+do_execsql_test 5.6 {
+ SELECT DISTINCT x FROM t1 ORDER BY x;
+} {1 2 3 4 5 6}
+
+#-------------------------------------------------------------------------
+# 2015-11-23. Problem discovered by Kostya Serebryany using libFuzzer
+#
+db close
+sqlite3 db :memory:
+do_execsql_test 6.1 {
+ CREATE TABLE jjj(x);
+ SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1)
+ FROM sqlite_master;
+} {jjj}
+do_execsql_test 6.2 {
+ CREATE TABLE nnn(x);
+ SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1)
+ FROM sqlite_master;
+} {mmm}
+
+#-------------------------------------------------------------------------
+# Ticket [9c944882]
+#
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY);
+ CREATE TABLE t3(a INTEGER PRIMARY KEY);
+
+ CREATE TABLE t4(x);
+ CREATE TABLE t5(y);
+
+ INSERT INTO t5 VALUES(1), (2), (2);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t3 VALUES(2);
+ INSERT INTO t4 VALUES(2);
+}
+
+do_execsql_test 7.1 {
+ WITH t2(b) AS (
+ SELECT DISTINCT y FROM t5 ORDER BY y
+ )
+ SELECT * FROM
+ t4 CROSS JOIN t3 CROSS JOIN t1
+ WHERE (t1.a=t3.a) AND (SELECT count(*) FROM t2 AS y WHERE t4.x!='abc')=t1.a
+} {2 2 2}
+
+# 2021-04-06 forum post https://sqlite.org/forum/forumpost/66954e9ece
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE person ( pid INT) ;
+ CREATE UNIQUE INDEX idx ON person ( pid ) WHERE pid == 1;
+ INSERT INTO person VALUES (1), (10), (10);
+ SELECT DISTINCT pid FROM person where pid = 10;
+} {10}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 9.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('a', 'a');
+ INSERT INTO t1 VALUES('a', 'b');
+ INSERT INTO t1 VALUES('a', 'c');
+
+ INSERT INTO t1 VALUES('b', 'a');
+ INSERT INTO t1 VALUES('b', 'b');
+ INSERT INTO t1 VALUES('b', 'c');
+
+ INSERT INTO t1 VALUES('a', 'a');
+ INSERT INTO t1 VALUES('b', 'b');
+
+ INSERT INTO t1 VALUES('A', 'A');
+ INSERT INTO t1 VALUES('B', 'B');
+}
+
+foreach {tn idx} {
+ 1 { }
+ 2 { CREATE INDEX i1 ON t1(a, b); }
+ 3 { CREATE INDEX i1 ON t1(b, a); }
+ 4 { CREATE INDEX i1 ON t1(a COLLATE nocase, b COLLATE nocase); }
+ 5 { CREATE INDEX i1 ON t1(b COLLATE nocase, a COLLATE nocase); }
+} {
+
+ execsql { DROP INDEX IF EXISTS i1 }
+ execsql $idx
+
+ do_execsql_test 9.$tn.1 {
+ SELECT DISTINCT a, b FROM t1 ORDER BY a, b
+ } {
+ A A B B
+ a a a b a c
+ b a b b b c
+ }
+
+ do_execsql_test 9.$tn.1 {
+ SELECT DISTINCT a COLLATE nocase, b COLLATE nocase FROM t1
+ ORDER BY a COLLATE nocase, b COLLATE nocase
+ } {
+ a a a b a c
+ b a b b b c
+ }
+}
+
+
+finish_test
diff --git a/test/distinct2.test b/test/distinct2.test
new file mode 100644
index 0000000..46eace6
--- /dev/null
+++ b/test/distinct2.test
@@ -0,0 +1,304 @@
+# 2016-04-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 DISTINCT queries using the skip-ahead
+# optimization.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix distinct2
+
+do_execsql_test 100 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(0),(1),(2);
+ CREATE TABLE t2 AS
+ SELECT DISTINCT a.x AS aa, b.x AS bb
+ FROM t1 a, t1 b;
+ SELECT *, '|' FROM t2 ORDER BY aa, bb;
+} {0 0 | 0 1 | 0 2 | 1 0 | 1 1 | 1 2 | 2 0 | 2 1 | 2 2 |}
+do_execsql_test 110 {
+ DROP TABLE t2;
+ CREATE TABLE t2 AS
+ SELECT DISTINCT a.x AS aa, b.x AS bb
+ FROM t1 a, t1 b
+ WHERE a.x IN t1 AND b.x IN t1;
+ SELECT *, '|' FROM t2 ORDER BY aa, bb;
+} {0 0 | 0 1 | 0 2 | 1 0 | 1 1 | 1 2 | 2 0 | 2 1 | 2 2 |}
+do_execsql_test 120 {
+ CREATE TABLE t102 (i0 TEXT UNIQUE NOT NULL);
+ INSERT INTO t102 VALUES ('0'),('1'),('2');
+ DROP TABLE t2;
+ CREATE TABLE t2 AS
+ SELECT DISTINCT *
+ FROM t102 AS t0
+ JOIN t102 AS t4 ON (t2.i0 IN t102)
+ NATURAL JOIN t102 AS t3
+ JOIN t102 AS t1 ON (t0.i0 IN t102)
+ JOIN t102 AS t2 ON (t2.i0=+t0.i0 OR (t0.i0<>500 AND t2.i0=t1.i0));
+ SELECT *, '|' FROM t2 ORDER BY 1, 2, 3, 4, 5;
+} {0 0 0 0 | 0 0 1 0 | 0 0 1 1 | 0 0 2 0 | 0 0 2 2 | 0 1 0 0 | 0 1 1 0 | 0 1 1 1 | 0 1 2 0 | 0 1 2 2 | 0 2 0 0 | 0 2 1 0 | 0 2 1 1 | 0 2 2 0 | 0 2 2 2 | 1 0 0 0 | 1 0 0 1 | 1 0 1 1 | 1 0 2 1 | 1 0 2 2 | 1 1 0 0 | 1 1 0 1 | 1 1 1 1 | 1 1 2 1 | 1 1 2 2 | 1 2 0 0 | 1 2 0 1 | 1 2 1 1 | 1 2 2 1 | 1 2 2 2 | 2 0 0 0 | 2 0 0 2 | 2 0 1 1 | 2 0 1 2 | 2 0 2 2 | 2 1 0 0 | 2 1 0 2 | 2 1 1 1 | 2 1 1 2 | 2 1 2 2 | 2 2 0 0 | 2 2 0 2 | 2 2 1 1 | 2 2 1 2 | 2 2 2 2 |}
+
+do_execsql_test 400 {
+ CREATE TABLE t4(a,b,c,d,e,f,g,h,i,j);
+ INSERT INTO t4 VALUES(0,1,2,3,4,5,6,7,8,9);
+ INSERT INTO t4 SELECT * FROM t4;
+ INSERT INTO t4 SELECT * FROM t4;
+ CREATE INDEX t4x ON t4(c,d,e);
+ SELECT DISTINCT a,b,c FROM t4 WHERE a=0 AND b=1;
+} {0 1 2}
+do_execsql_test 410 {
+ SELECT DISTINCT a,b,c,d FROM t4 WHERE a=0 AND b=1;
+} {0 1 2 3}
+do_execsql_test 411 {
+ SELECT DISTINCT d,a,b,c FROM t4 WHERE a=0 AND b=1;
+} {3 0 1 2}
+do_execsql_test 420 {
+ SELECT DISTINCT a,b,c,d,e FROM t4 WHERE a=0 AND b=1;
+} {0 1 2 3 4}
+do_execsql_test 430 {
+ SELECT DISTINCT a,b,c,d,e,f FROM t4 WHERE a=0 AND b=1;
+} {0 1 2 3 4 5}
+
+do_execsql_test 500 {
+ CREATE TABLE t5(a INT, b INT);
+ CREATE UNIQUE INDEX t5x ON t5(a+b);
+ INSERT INTO t5(a,b) VALUES(0,0),(1,0),(1,1),(0,3);
+ CREATE TEMP TABLE out AS SELECT DISTINCT a+b FROM t5;
+ SELECT * FROM out ORDER BY 1;
+} {0 1 2 3}
+
+do_execsql_test 600 {
+ CREATE TABLE t6a(x INTEGER PRIMARY KEY);
+ INSERT INTO t6a VALUES(1);
+ CREATE TABLE t6b(y INTEGER PRIMARY KEY);
+ INSERT INTO t6b VALUES(2),(3);
+ SELECT DISTINCT x, x FROM t6a, t6b;
+} {1 1}
+
+do_execsql_test 700 {
+ CREATE TABLE t7(a, b, c);
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE (i+1)<200
+ )
+ INSERT INTO t7 SELECT i/100, i/50, i FROM s;
+}
+do_execsql_test 710 {
+ SELECT DISTINCT a, b FROM t7;
+} {
+ 0 0 0 1
+ 1 2 1 3
+}
+do_execsql_test 720 {
+ SELECT DISTINCT a, b+1 FROM t7;
+} {
+ 0 1 0 2
+ 1 3 1 4
+}
+do_execsql_test 730 {
+ CREATE INDEX i7 ON t7(a, b+1);
+ ANALYZE;
+ SELECT DISTINCT a, b+1 FROM t7;
+} {
+ 0 1 0 2
+ 1 3 1 4
+}
+
+do_execsql_test 800 {
+ CREATE TABLE t8(a, b, c);
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE (i+1)<100
+ )
+ INSERT INTO t8 SELECT i/40, i/20, i/40 FROM s;
+}
+
+do_execsql_test 820 {
+ SELECT DISTINCT a, b, c FROM t8;
+} {
+ 0 0 0 0 1 0
+ 1 2 1 1 3 1
+ 2 4 2
+}
+
+do_execsql_test 820 {
+ SELECT DISTINCT a, b, c FROM t8 WHERE b=3;
+} {1 3 1}
+
+do_execsql_test 830 {
+ CREATE INDEX i8 ON t8(a, c);
+ ANALYZE;
+ SELECT DISTINCT a, b, c FROM t8 WHERE b=3;
+} {1 3 1}
+
+do_execsql_test 900 {
+ CREATE TABLE t9(v);
+ INSERT INTO t9 VALUES
+ ('abcd'), ('Abcd'), ('aBcd'), ('ABcd'), ('abCd'), ('AbCd'), ('aBCd'),
+ ('ABCd'), ('abcD'), ('AbcD'), ('aBcD'), ('ABcD'), ('abCD'), ('AbCD'),
+ ('aBCD'), ('ABCD'),
+ ('wxyz'), ('Wxyz'), ('wXyz'), ('WXyz'), ('wxYz'), ('WxYz'), ('wXYz'),
+ ('WXYz'), ('wxyZ'), ('WxyZ'), ('wXyZ'), ('WXyZ'), ('wxYZ'), ('WxYZ'),
+ ('wXYZ'), ('WXYZ');
+}
+
+do_execsql_test 910 {
+ SELECT DISTINCT v COLLATE NOCASE, v FROM t9 ORDER BY +v;
+} {
+ ABCD ABCD ABCd ABCd ABcD ABcD ABcd ABcd AbCD
+ AbCD AbCd AbCd AbcD AbcD Abcd Abcd
+ WXYZ WXYZ WXYz WXYz WXyZ WXyZ WXyz WXyz WxYZ
+ WxYZ WxYz WxYz WxyZ WxyZ Wxyz Wxyz
+ aBCD aBCD aBCd aBCd aBcD aBcD aBcd aBcd abCD
+ abCD abCd abCd abcD abcD abcd abcd
+ wXYZ wXYZ wXYz wXYz wXyZ wXyZ wXyz wXyz wxYZ
+ wxYZ wxYz wxYz wxyZ wxyZ wxyz wxyz
+}
+
+do_execsql_test 920 {
+ CREATE INDEX i9 ON t9(v COLLATE NOCASE, v);
+ ANALYZE;
+
+ SELECT DISTINCT v COLLATE NOCASE, v FROM t9 ORDER BY +v;
+} {
+ ABCD ABCD ABCd ABCd ABcD ABcD ABcd ABcd AbCD
+ AbCD AbCd AbCd AbcD AbcD Abcd Abcd
+ WXYZ WXYZ WXYz WXYz WXyZ WXyZ WXyz WXyz WxYZ
+ WxYZ WxYz WxYz WxyZ WxyZ Wxyz Wxyz
+ aBCD aBCD aBCd aBCd aBcD aBcD aBcd aBcd abCD
+ abCD abCd abCd abcD abcD abcd abcd
+ wXYZ wXYZ wXYz wXYz wXyZ wXyZ wXyz wXyz wxYZ
+ wxYZ wxYz wxYz wxyZ wxyZ wxyz wxyz
+}
+
+# Ticket https://sqlite.org/src/info/ef9318757b152e3a on 2017-11-21
+# Incorrect result due to a skip-ahead-distinct optimization on a
+# join where no rows of the inner loop appear in the result set.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test 1000 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER);
+ CREATE INDEX t1b ON t1(b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y INTEGER);
+ CREATE INDEX t2y ON t2(y);
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<49)
+ INSERT INTO t1(b) SELECT x/10 - 1 FROM c;
+ WITH RECURSIVE c(x) AS (VALUES(-1) UNION ALL SELECT x+1 FROM c WHERE x<19)
+ INSERT INTO t2(x,y) SELECT x, 1 FROM c;
+ SELECT DISTINCT y FROM t1, t2 WHERE b=x AND b<>-1;
+ ANALYZE;
+ SELECT DISTINCT y FROM t1, t2 WHERE b=x AND b<>-1;
+} {1 1}
+db close
+sqlite3 db :memory:
+do_execsql_test 1010 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER);
+ CREATE INDEX t1b ON t1(b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y INTEGER);
+ CREATE INDEX t2y ON t2(y);
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<49)
+ INSERT INTO t1(b) SELECT -(x/10 - 1) FROM c;
+ WITH RECURSIVE c(x) AS (VALUES(-1) UNION ALL SELECT x+1 FROM c WHERE x<19)
+ INSERT INTO t2(x,y) SELECT -x, 1 FROM c;
+ SELECT DISTINCT y FROM t1, t2 WHERE b=x AND b<>1 ORDER BY y DESC;
+ ANALYZE;
+ SELECT DISTINCT y FROM t1, t2 WHERE b=x AND b<>1 ORDER BY y DESC;
+} {1 1}
+db close
+sqlite3 db :memory:
+do_execsql_test 1020 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX t1a ON t1(a, b);
+ -- Lots of rows of (1, 'no'), followed by a single (1, 'yes').
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a, b) SELECT 1, 'no' FROM c;
+ INSERT INTO t1(a, b) VALUES(1, 'yes');
+ CREATE TABLE t2(x PRIMARY KEY);
+ INSERT INTO t2 VALUES('yes');
+ SELECT DISTINCT a FROM t1, t2 WHERE x=b;
+ ANALYZE;
+ SELECT DISTINCT a FROM t1, t2 WHERE x=b;
+} {1 1}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 2000 {
+ CREATE TABLE t0 (c0, c1, c2, PRIMARY KEY (c0, c1));
+ CREATE TABLE t1 (c2);
+ INSERT INTO t0(c2) VALUES (0),(1),(3),(4),(5),(6),(7),(8),(9),(10),(11);
+ INSERT INTO t0(c1) VALUES ('a');
+ INSERT INTO t1(c2) VALUES (0);
+}
+do_execsql_test 2010 {
+ SELECT DISTINCT t0.c0, t1._rowid_, t0.c1 FROM t1 CROSS JOIN t0 ORDER BY t0.c0;
+} {{} 1 {} {} 1 a}
+do_execsql_test 1.2 {
+ ANALYZE;
+}
+do_execsql_test 2020 {
+ SELECT DISTINCT t0.c0, t1._rowid_, t0.c1 FROM t1 CROSS JOIN t0 ORDER BY t0.c0;
+} {{} 1 {} {} 1 a}
+
+
+do_execsql_test 2030 {
+ CREATE TABLE t2(a, b, c);
+ CREATE INDEX t2ab ON t2(a, b);
+
+ WITH c(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM c WHERE i<64)
+ INSERT INTO t2 SELECT 'one', i%2, 'one' FROM c;
+
+ WITH c(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM c WHERE i<64)
+ INSERT INTO t2 SELECT 'two', i%2, 'two' FROM c;
+
+ CREATE TABLE t3(x INTEGER PRIMARY KEY);
+ INSERT INTO t3 VALUES(1);
+
+ ANALYZE;
+}
+do_execsql_test 2040 {
+ SELECT DISTINCT a, b, x FROM t3 CROSS JOIN t2 ORDER BY a, +b;
+} {
+ one 0 1
+ one 1 1
+ two 0 1
+ two 1 1
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 3000 {
+ CREATE TABLE t0 (c0, c1 NOT NULL DEFAULT 1, c2, PRIMARY KEY (c0, c1));
+ INSERT INTO t0(c2) VALUES (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL);
+ INSERT INTO t0(c2) VALUES('a');
+}
+
+do_execsql_test 3010 {
+ SELECT DISTINCT * FROM t0 WHERE NULL IS t0.c0;
+} {
+ {} 1 {}
+ {} 1 a
+}
+
+do_execsql_test 3020 {
+ ANALYZE;
+}
+
+do_execsql_test 3030 {
+ SELECT DISTINCT * FROM t0 WHERE NULL IS c0;
+} {
+ {} 1 {}
+ {} 1 a
+}
+
+finish_test
diff --git a/test/distinctagg.test b/test/distinctagg.test
new file mode 100644
index 0000000..a34312e
--- /dev/null
+++ b/test/distinctagg.test
@@ -0,0 +1,217 @@
+# 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
+set testprefix distinctagg
+
+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
+ }
+} {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}}
+
+#--------------------------------------------------------------------------
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+
+ INSERT INTO t1 VALUES (1, 1, 1);
+ INSERT INTO t1 VALUES (2, 2, 2);
+ INSERT INTO t1 VALUES (3, 3, 3);
+ INSERT INTO t1 VALUES (4, 1, 4);
+ INSERT INTO t1 VALUES (5, 2, 1);
+ INSERT INTO t1 VALUES (5, 3, 2);
+ INSERT INTO t1 VALUES (4, 1, 3);
+ INSERT INTO t1 VALUES (3, 2, 4);
+ INSERT INTO t1 VALUES (2, 3, 1);
+ INSERT INTO t1 VALUES (1, 1, 2);
+
+ INSERT INTO t2 VALUES('a', 'a', 'a');
+ INSERT INTO t2 VALUES('b', 'b', 'b');
+ INSERT INTO t2 VALUES('c', 'c', 'c');
+
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1bc ON t1(b, c);
+}
+
+foreach {tn use_eph sql res} {
+ 1 0 "SELECT count(DISTINCT a) FROM t1" 5
+ 2 0 "SELECT count(DISTINCT b) FROM t1" 3
+ 3 1 "SELECT count(DISTINCT c) FROM t1" 4
+ 4 0 "SELECT count(DISTINCT c) FROM t1 WHERE b=3" 3
+ 5 0 "SELECT count(DISTINCT rowid) FROM t1" 10
+ 6 0 "SELECT count(DISTINCT a) FROM t1, t2" 5
+ 7 0 "SELECT count(DISTINCT a) FROM t2, t1" 5
+ 8 1 "SELECT count(DISTINCT a+b) FROM t1, t2, t2, t2" 6
+ 9 0 "SELECT count(DISTINCT c) FROM t1 WHERE c=2" 1
+ 10 1 "SELECT count(DISTINCT t1.rowid) FROM t1, t2" 10
+} {
+ do_test 3.$tn.1 {
+ set prg [db eval "EXPLAIN $sql"]
+ set idx [lsearch $prg OpenEphemeral]
+ expr {$idx>=0}
+ } $use_eph
+
+ do_execsql_test 3.$tn.2 $sql $res
+}
+
+do_execsql_test 3.10 {
+ SELECT a, count(DISTINCT b) FROM t1 GROUP BY a;
+} {
+ 1 1 2 2 3 2 4 1 5 2
+}
+
+#--------------------------------------------------------------------------
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1bc ON t1(b, c);
+
+ INSERT INTO t1 VALUES(1, 'A', 1);
+ INSERT INTO t1 VALUES(1, 'A', 1);
+ INSERT INTO t1 VALUES(2, 'A', 2);
+ INSERT INTO t1 VALUES(2, 'A', 2);
+ INSERT INTO t1 VALUES(1, 'B', 1);
+ INSERT INTO t1 VALUES(2, 'B', 2);
+ INSERT INTO t1 VALUES(3, 'B', 3);
+ INSERT INTO t1 VALUES(NULL, 'B', NULL);
+ INSERT INTO t1 VALUES(NULL, 'C', NULL);
+ INSERT INTO t1 VALUES('d', 'D', 'd');
+
+ CREATE TABLE t2(d, e, f);
+ CREATE INDEX t2def ON t2(d, e, f);
+
+ INSERT INTO t2 VALUES(1, 1, 'a');
+ INSERT INTO t2 VALUES(1, 1, 'a');
+ INSERT INTO t2 VALUES(1, 2, 'a');
+ INSERT INTO t2 VALUES(1, 2, 'a');
+ INSERT INTO t2 VALUES(1, 2, 'b');
+ INSERT INTO t2 VALUES(1, 3, 'b');
+ INSERT INTO t2 VALUES(1, 3, 'a');
+ INSERT INTO t2 VALUES(1, 3, 'b');
+ INSERT INTO t2 VALUES(2, 3, 'x');
+ INSERT INTO t2 VALUES(2, 3, 'y');
+ INSERT INTO t2 VALUES(2, 3, 'z');
+
+ CREATE TABLE t3(x, y, z);
+ INSERT INTO t3 VALUES(1,1,1);
+ INSERT INTO t3 VALUES(2,2,2);
+}
+
+foreach {tn use_eph sql res} {
+ 1 0 "SELECT count(DISTINCT c) FROM t1 GROUP BY b" {2 3 0 1}
+ 2 1 "SELECT count(DISTINCT a) FROM t1 GROUP BY b" {2 3 0 1}
+ 3 1 "SELECT count(DISTINCT a) FROM t1 GROUP BY b+c" {0 1 1 1 1}
+
+ 4 0 "SELECT count(DISTINCT f) FROM t2 GROUP BY d, e" {1 2 2 3}
+ 5 1 "SELECT count(DISTINCT f) FROM t2 GROUP BY d" {2 3}
+ 6 0 "SELECT count(DISTINCT f) FROM t2 WHERE d IS 1 GROUP BY e" {1 2 2}
+} {
+ do_test 4.$tn.1 {
+ set prg [db eval "EXPLAIN $sql"]
+ set idx [lsearch $prg OpenEphemeral]
+ expr {$idx>=0}
+ } $use_eph
+
+ do_execsql_test 4.$tn.2 $sql $res
+}
+
+
+set t3root [db one {SELECT rootpage FROM sqlite_schema WHERE name='t3'}]
+foreach {tn use_t3 sql res} {
+ 1 1 "SELECT count(*) FROM t3" 2
+ 2 0 "SELECT count(*) FROM t1" 10
+ 2 1 "SELECT count(DISTINCT a) FROM t1, t3" 4
+ 3 1 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3" 4
+ 4 1 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3 WHERE t3.x=1" 4
+ 5 1 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3 WHERE t3.x=0" 0
+ 6 1 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3 ON (t3.x=0)" 4
+ 7 1 "SELECT count(DISTINCT x) FROM t1 LEFT JOIN t3" 2
+ 8 1 "SELECT count(DISTINCT x) FROM t1 LEFT JOIN t3 WHERE t3.x=1" 1
+ 9 1 "SELECT count(DISTINCT x) FROM t1 LEFT JOIN t3 WHERE t3.x=0" 0
+ 10 1 "SELECT count(DISTINCT x) FROM t1 LEFT JOIN t3 ON (t3.x=0)" 0
+
+} {
+ do_test 5.$tn.1 {
+ set bUse 0
+ db eval "EXPLAIN $sql" a {
+ if {$a(opcode)=="OpenRead" && $a(p2)==$t3root} {set bUse 1}
+ }
+ set bUse
+ } $use_t3
+
+ do_execsql_test 5.$tn.2 $sql $res
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 6.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ INSERT INTO t1 VALUES(123,456);
+ INSERT INTO t2 VALUES(123,456);
+}
+do_execsql_test 6.1 {
+ SELECT count(DISTINCT c) FROM t1 LEFT JOIN t2;
+} {1}
+
+do_execsql_test 7.0 {
+ CREATE TABLE v1 ( v2 UNIQUE, v3 AS( TYPEOF ( NULL ) ) UNIQUE );
+ SELECT COUNT ( DISTINCT TRUE ) FROM v1 GROUP BY likelihood ( v3 , 0.100000 );
+}
+
+
+finish_test
+
diff --git a/test/e_blobbytes.test b/test/e_blobbytes.test
new file mode 100644
index 0000000..c24318c
--- /dev/null
+++ b/test/e_blobbytes.test
@@ -0,0 +1,79 @@
+# 2014 October 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix e_blobbytes
+
+ifcapable !incrblob {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE q1(r INTEGER PRIMARY KEY, s TEXT);
+ WITH d(a, b) AS (
+ SELECT 0, ''
+ UNION ALL
+ SELECT a+1, b||'.' FROM d WHERE a<10000
+ )
+ INSERT INTO q1 SELECT * FROM d;
+}
+
+
+# EVIDENCE-OF: R-07796-55423 Returns the size in bytes of the BLOB
+# accessible via the successfully opened BLOB handle in its only
+# argument.
+#
+proc check_blob_size {tn rowid bytes} {
+ uplevel [list do_test $tn [subst -nocommands {
+ sqlite3_blob_open db main q1 s $rowid 0 B
+ set res [sqlite3_blob_bytes [set B]]
+ sqlite3_blob_close [set B]
+ set res
+ }] $bytes]
+}
+check_blob_size 1.1 43 43
+check_blob_size 1.2 391 391
+check_blob_size 1.3 6349 6349
+check_blob_size 1.4 2621 2621
+check_blob_size 1.5 7771 7771
+check_blob_size 1.6 7949 7949
+check_blob_size 1.7 4374 4374
+check_blob_size 1.8 2578 2578
+check_blob_size 1.9 7004 7004
+check_blob_size 1.10 2180 2180
+check_blob_size 1.11 3796 3796
+check_blob_size 1.12 7101 7101
+check_blob_size 1.13 7449 7449
+check_blob_size 1.14 7224 7224
+check_blob_size 1.15 3038 3038
+check_blob_size 1.16 1083 1083
+check_blob_size 1.17 5157 5157
+check_blob_size 1.18 6686 6686
+check_blob_size 1.19 6592 6592
+check_blob_size 1.20 0 0
+
+
+# EVIDENCE-OF: R-53088-19343 The incremental blob I/O routines can only
+# read or overwriting existing blob content; they cannot change the size
+# of a blob.
+#
+# Also demonstrated in other e_blobXXX.test files.
+#
+do_test 2.1 {
+ sqlite3_blob_open db main q1 s 86 1 B
+ list [catch { sqlite3_blob_write $B 86 "1" 1 } msg] $msg
+} {1 SQLITE_ERROR}
+sqlite3_blob_close $B
+
+finish_test
diff --git a/test/e_blobclose.test b/test/e_blobclose.test
new file mode 100644
index 0000000..40291cf
--- /dev/null
+++ b/test/e_blobclose.test
@@ -0,0 +1,175 @@
+# 2014 October 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix e_blobclose
+
+ifcapable !incrblob {
+ finish_test
+ return
+}
+
+set dots [string repeat . 40]
+do_execsql_test 1.0 {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b DOTS);
+ INSERT INTO x1 VALUES(-1, $dots);
+ INSERT INTO x1 VALUES(-10, $dots);
+ INSERT INTO x1 VALUES(-100, $dots);
+ INSERT INTO x1 VALUES(-1000, $dots);
+ INSERT INTO x1 VALUES(-10000, $dots);
+}
+
+# EVIDENCE-OF: R-03145-46390 This function closes an open BLOB handle.
+#
+# It's not clear how to test that a blob handle really is closed.
+# Attempting to use a closed blob handle will likely crash the process.
+# Assume here that if the SHARED lock on the db file is released,
+# the blob handle has been closed.
+#
+do_execsql_test 1.1 { PRAGMA lock_status } {main unlocked temp closed}
+sqlite3_blob_open db main x1 b -1 0 B
+do_execsql_test 1.2 { PRAGMA lock_status } {main shared temp closed}
+sqlite3_blob_close $B
+do_execsql_test 1.3 { PRAGMA lock_status } {main unlocked temp closed}
+
+
+# EVIDENCE-OF: R-34027-00617 If the blob handle being closed was opened
+# for read-write access, and if the database is in auto-commit mode and
+# there are no other open read-write blob handles or active write
+# statements, the current transaction is committed.
+#
+# 2.1.*: Transaction is not committed if there are other open
+# read-write blob handles.
+#
+# 2.2.*: Transaction is not committed if not in auto-commit mode.
+#
+# 2.3.*: Active write statements.
+#
+do_test 2.1.1 {
+ sqlite3_blob_open db main x1 b -100 1 B1
+ sqlite3_blob_open db main x1 b -1000 1 B2
+ sqlite3_blob_open db main x1 b -10000 1 B3
+ sqlite3_blob_open db main x1 b -10000 0 B4 ;# B4 is read-only!
+ execsql { PRAGMA lock_status }
+} {main reserved temp closed}
+do_test 2.1.2 {
+ sqlite3_blob_close $B1
+ execsql { PRAGMA lock_status }
+} {main reserved temp closed}
+do_test 2.1.3 {
+ sqlite3_blob_close $B2
+ execsql { PRAGMA lock_status }
+} {main reserved temp closed}
+do_test 2.1.4 {
+ sqlite3_blob_close $B3
+ execsql { PRAGMA lock_status }
+} {main shared temp closed}
+do_test 2.1.5 {
+ sqlite3_blob_close $B4
+ execsql { PRAGMA lock_status }
+} {main unlocked temp closed}
+
+do_test 2.2.1 {
+ sqlite3_blob_open db main x1 b -100 1 B1
+ execsql { PRAGMA lock_status }
+} {main reserved temp closed}
+do_test 2.2.2 {
+ execsql { BEGIN }
+ sqlite3_blob_close $B1
+ execsql { PRAGMA lock_status }
+} {main reserved temp closed}
+do_test 2.2.3 {
+ execsql { COMMIT }
+ execsql { PRAGMA lock_status }
+} {main unlocked temp closed}
+
+proc val {} {
+ sqlite3_blob_close $::B
+ db eval { PRAGMA lock_status }
+}
+db func val val
+do_test 2.3.1 {
+ sqlite3_blob_open db main x1 b -100 1 B
+ execsql { PRAGMA lock_status }
+} {main reserved temp closed}
+do_test 2.3.2 {
+ execsql { INSERT INTO x1 VALUES(15, val()) }
+ execsql { PRAGMA lock_status }
+} {main unlocked temp closed}
+do_test 2.3.3 {
+ execsql { SELECT * FROM x1 WHERE a = 15 }
+} {15 {main reserved temp closed}}
+
+# A reader does not inhibit commit.
+do_test 2.3.4 {
+ sqlite3_blob_open db main x1 b -100 1 B
+ execsql { PRAGMA lock_status }
+} {main reserved temp closed}
+do_test 2.3.5 {
+ execsql { SELECT a, val() FROM x1 LIMIT 1 }
+} {-10000 {main shared temp closed}}
+
+
+do_test 3.1 {
+ sqlite3_blob_open db main x1 b -10 1 B
+ execsql {
+ INSERT INTO x1 VALUES(1, 'abc');
+ SELECT * FROM x1 WHERE a=1;
+ }
+} {1 abc}
+do_test 3.2 {
+ sqlite3_blob_write $B 0 "abcdefghij" 10
+ execsql { SELECT * FROM x1 WHERE a=-10 }
+} {-10 abcdefghij..............................}
+
+do_test 3.3 {
+ sqlite3 db2 test.db
+ execsql { BEGIN ; SELECT * FROM x1 } db2
+ sqlite3_blob_close $B
+} {SQLITE_BUSY}
+
+# EVIDENCE-OF: R-41959-38737 Otherwise, if this function is passed a
+# valid open blob handle, the values returned by the sqlite3_errcode()
+# and sqlite3_errmsg() functions are set before returning.
+#
+do_test 3.4 {
+ list [sqlite3_errcode db] [sqlite3_errmsg db]
+} {SQLITE_BUSY {database is locked}}
+
+# EVIDENCE-OF: R-37801-37633 The BLOB handle is closed unconditionally.
+# Even if this routine returns an error code, the handle is still
+# closed.
+#
+# Test that the lock has been released. Assume this means the handle
+# is closed, even though blob_close() returned SQLITE_BUSY.
+#
+do_execsql_test 3.4 { PRAGMA lock_status } {main unlocked temp closed}
+
+# EVIDENCE-OF: R-35111-05628 If an error occurs while committing the
+# transaction, an error code is returned and the transaction rolled
+# back.
+#
+# Row 1 is removed (it was inserted this transaction) and row -10
+# is restored to its original state. Transaction has been rolled back.
+#
+do_execsql_test 3.5 {
+ SELECT * FROM x1 WHERE a IN (1, -10);
+} {-10 ........................................}
+
+# EVIDENCE-OF: R-25894-51060 Calling this routine with a null pointer
+# (such as would be returned by a failed call to sqlite3_blob_open()) is
+# a harmless no-op.
+#
+do_test 4.0 { sqlite3_blob_close 0 } {}
+
+finish_test
diff --git a/test/e_blobopen.test b/test/e_blobopen.test
new file mode 100644
index 0000000..41fd13c
--- /dev/null
+++ b/test/e_blobopen.test
@@ -0,0 +1,553 @@
+# 2014 October 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix e_blobopen
+
+ifcapable !incrblob {
+ finish_test
+ return
+}
+
+forcedelete test.db2
+
+do_execsql_test 1.0 {
+ ATTACH 'test.db2' AS aux;
+
+ CREATE TABLE main.t1(a INTEGER PRIMARY KEY, b TEXT, c BLOB);
+ CREATE TEMP TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c BLOB);
+ CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b TEXT, c BLOB);
+
+ CREATE TABLE main.x1(a INTEGER PRIMARY KEY, b TEXT, c BLOB);
+ CREATE TEMP TABLE x2(a INTEGER PRIMARY KEY, b TEXT, c BLOB);
+ CREATE TABLE aux.x3(a INTEGER PRIMARY KEY, b TEXT, c BLOB);
+
+ INSERT INTO main.t1 VALUES(1, 'main one', X'0101');
+ INSERT INTO main.t1 VALUES(2, 'main two', X'0102');
+ INSERT INTO main.t1 VALUES(3, 'main three', X'0103');
+ INSERT INTO main.t1 VALUES(4, 'main four', X'0104');
+ INSERT INTO main.t1 VALUES(5, 'main five', X'0105');
+
+ INSERT INTO main.x1 VALUES(1, 'x main one', X'000101');
+ INSERT INTO main.x1 VALUES(2, 'x main two', X'000102');
+ INSERT INTO main.x1 VALUES(3, 'x main three', X'000103');
+ INSERT INTO main.x1 VALUES(4, 'x main four', X'000104');
+ INSERT INTO main.x1 VALUES(5, 'x main five', X'000105');
+
+ INSERT INTO temp.t1 VALUES(1, 'temp one', X'0201');
+ INSERT INTO temp.t1 VALUES(2, 'temp two', X'0202');
+ INSERT INTO temp.t1 VALUES(3, 'temp three', X'0203');
+ INSERT INTO temp.t1 VALUES(4, 'temp four', X'0204');
+ INSERT INTO temp.t1 VALUES(5, 'temp five', X'0205');
+
+ INSERT INTO temp.x2 VALUES(1, 'x temp one', X'000201');
+ INSERT INTO temp.x2 VALUES(2, 'x temp two', X'000202');
+ INSERT INTO temp.x2 VALUES(3, 'x temp three', X'000203');
+ INSERT INTO temp.x2 VALUES(4, 'x temp four', X'000204');
+ INSERT INTO temp.x2 VALUES(5, 'x temp five', X'000205');
+
+ INSERT INTO aux.t1 VALUES(1, 'aux one', X'0301');
+ INSERT INTO aux.t1 VALUES(2, 'aux two', X'0302');
+ INSERT INTO aux.t1 VALUES(3, 'aux three', X'0303');
+ INSERT INTO aux.t1 VALUES(4, 'aux four', X'0304');
+ INSERT INTO aux.t1 VALUES(5, 'aux five', X'0305');
+
+ INSERT INTO aux.x3 VALUES(1, 'x aux one', X'000301');
+ INSERT INTO aux.x3 VALUES(2, 'x aux two', X'000302');
+ INSERT INTO aux.x3 VALUES(3, 'x aux three', X'000303');
+ INSERT INTO aux.x3 VALUES(4, 'x aux four', X'000304');
+ INSERT INTO aux.x3 VALUES(5, 'x aux five', X'000305');
+}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-37639-55938 This interfaces opens a handle to the BLOB
+# located in row iRow, column zColumn, table zTable in database zDb; in
+# other words, the same BLOB that would be selected by: SELECT zColumn
+# FROM zDb.zTable WHERE rowid = iRow;
+#
+proc read_blob {zDb zTab zCol iRow} {
+ sqlite3_blob_open db $zDb $zTab $zCol $iRow 0 B
+ set nByte [sqlite3_blob_bytes $B]
+ set data [sqlite3_blob_read $B 0 $nByte]
+ sqlite3_blob_close $B
+ return $data
+}
+
+do_test 1.1.1 { read_blob main t1 b 1 } "main one"
+do_test 1.1.2 { read_blob main t1 c 1 } "\01\01"
+do_test 1.1.3 { read_blob temp t1 b 1 } "temp one"
+do_test 1.1.4 { read_blob temp t1 c 1 } "\02\01"
+do_test 1.1.6 { read_blob aux t1 b 1 } "aux one"
+do_test 1.1.7 { read_blob aux t1 c 1 } "\03\01"
+
+do_test 1.2.1 { read_blob main t1 b 4 } "main four"
+do_test 1.2.2 { read_blob main t1 c 4 } "\01\04"
+do_test 1.2.3 { read_blob temp t1 b 4 } "temp four"
+do_test 1.2.4 { read_blob temp t1 c 4 } "\02\04"
+do_test 1.2.6 { read_blob aux t1 b 4 } "aux four"
+do_test 1.2.7 { read_blob aux t1 c 4 } "\03\04"
+
+do_test 1.3.1 { read_blob main x1 b 2 } "x main two"
+do_test 1.3.2 { read_blob main x1 c 2 } "\00\01\02"
+do_test 1.3.3 { read_blob temp x2 b 2 } "x temp two"
+do_test 1.3.4 { read_blob temp x2 c 2 } "\00\02\02"
+do_test 1.3.6 { read_blob aux x3 b 2 } "x aux two"
+do_test 1.3.7 { read_blob aux x3 c 2 } "\00\03\02"
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-27234-05761 Parameter zDb is not the filename that
+# contains the database, but rather the symbolic name of the database.
+# For attached databases, this is the name that appears after the AS
+# keyword in the ATTACH statement. For the main database file, the
+# database name is "main". For TEMP tables, the database name is "temp".
+#
+# The test cases immediately above demonstrate that the database name
+# for the main db, for TEMP tables and for those in attached databases
+# is correct. The following tests check that filenames cannot be
+# used as well.
+#
+do_test 2.1 {
+ list [catch { sqlite3_blob_open db "test.db" t1 b 1 0 B } msg] $msg
+} {1 SQLITE_ERROR}
+do_test 2.2 {
+ list [catch { sqlite3_blob_open db "test.db2" t1 b 1 0 B } msg] $msg
+} {1 SQLITE_ERROR}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-50854-53979 If the flags parameter is non-zero, then
+# the BLOB is opened for read and write access.
+#
+# EVIDENCE-OF: R-03922-41160 If the flags parameter is zero, the BLOB is
+# opened for read-only access.
+#
+foreach {tn iRow flags} {
+ 1 1 0
+ 2 2 1
+ 3 3 -1
+ 4 4 2147483647
+ 5 5 -2147483648
+} {
+ do_test 3.$tn.1 {
+ sqlite3_blob_open db main x1 c $iRow $flags B
+ set n [sqlite3_blob_bytes $B]
+ sqlite3_blob_read $B 0 $n
+ } [binary format ccc 0 1 $iRow]
+
+ if {$flags==0} {
+ # Blob was opened for read-only access - writing returns an error.
+ do_test 3.$tn.2 {
+ list [catch { sqlite3_blob_write $B 0 xxx 3 } msg] $msg
+ } {1 SQLITE_READONLY}
+
+ do_execsql_test 3.$tn.3 {
+ SELECT c FROM x1 WHERE a=$iRow;
+ } [binary format ccc 0 1 $iRow]
+ } else {
+ # Blob was opened for read/write access - writing succeeds
+ do_test 3.$tn.4 {
+ list [catch { sqlite3_blob_write $B 0 xxx 3 } msg] $msg
+ } {0 {}}
+
+ do_execsql_test 3.$tn.5 {
+ SELECT c FROM x1 WHERE a=$iRow;
+ } {xxx}
+ }
+
+ sqlite3_blob_close $B
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('abcd', 152);
+ INSERT INTO t1 VALUES(NULL, X'00010203');
+ INSERT INTO t1 VALUES('', 154.2);
+
+ CREATE TABLE t2(x PRIMARY KEY, y) WITHOUT ROWID;
+ INSERT INTO t2 VALUES(1, 'blob');
+
+ CREATE TABLE t3(a PRIMARY KEY, b, c, d, e, f, UNIQUE(e, f));
+ INSERT INTO t3 VALUES('aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff');
+ CREATE INDEX t3b ON t3(b);
+
+ CREATE TABLE p1(x PRIMARY KEY);
+ INSERT INTO p1 VALUES('abc');
+
+ CREATE TABLE c1(a INTEGER PRIMARY KEY, b REFERENCES p1);
+ INSERT INTO c1 VALUES(45, 'abc');
+}
+
+proc test_blob_open {tn zDb zTab zCol iRow flags errcode errmsg} {
+ global B
+ set B "0x1234"
+
+ if {$errcode=="SQLITE_OK"} {
+ set expected "0 {}"
+ } else {
+ set expected "1 $errcode"
+ }
+
+ set ::res [list [
+ catch { sqlite3_blob_open db $zDb $zTab $zCol $iRow $flags B } msg
+ ] $msg]
+ do_test 4.$tn.1 { set ::res } $expected
+
+ # EVIDENCE-OF: R-08940-21305 Unless it returns SQLITE_MISUSE, this
+ # function sets the database connection error code and message
+ # accessible via sqlite3_errcode() and sqlite3_errmsg() and related
+ # functions.
+ #
+ # This proc (test_blob_open) is used below to test various error and
+ # non-error conditions. But never SQLITE_MISUSE conditions. So these
+ # test cases are considered as partly verifying the requirement above.
+ # See below for a test of the SQLITE_MISUSE case.
+ #
+ do_test 4.$tn.2 {
+ sqlite3_errcode db
+ } $errcode
+ do_test 4.$tn.3 {
+ sqlite3_errmsg db
+ } $errmsg
+
+ # EVIDENCE-OF: R-31086-35521 On success, SQLITE_OK is returned and the
+ # new BLOB handle is stored in *ppBlob. Otherwise an error code is
+ # returned and, unless the error code is SQLITE_MISUSE, *ppBlob is set
+ # to NULL.
+ #
+ do_test 4.$tn.4 {
+ expr {$B == "0"}
+ } [expr {$errcode != "SQLITE_OK"}]
+
+ # EVIDENCE-OF: R-63421-15521 This means that, provided the API is not
+ # misused, it is always safe to call sqlite3_blob_close() on *ppBlob
+ # after this function it returns.
+ do_test 4.$tn.5 {
+ sqlite3_blob_close $B
+ } {}
+}
+
+# EVIDENCE-OF: R-31204-44780 Database zDb does not exist
+test_blob_open 1 nosuchdb t1 x 1 0 SQLITE_ERROR "no such table: nosuchdb.t1"
+
+# EVIDENCE-OF: R-28676-08005 Table zTable does not exist within database zDb
+test_blob_open 2 main tt1 x 1 0 SQLITE_ERROR "no such table: main.tt1"
+
+# EVIDENCE-OF: R-40134-30296 Table zTable is a WITHOUT ROWID table
+test_blob_open 3 main t2 y 1 0 SQLITE_ERROR \
+ "cannot open table without rowid: t2"
+
+# EVIDENCE-OF: R-56376-21261 Column zColumn does not exist
+test_blob_open 4 main t1 z 2 0 SQLITE_ERROR "no such column: \"z\""
+
+# EVIDENCE-OF: R-28258-23166 Row iRow is not present in the table
+test_blob_open 5 main t1 y 6 0 SQLITE_ERROR "no such rowid: 6"
+
+# EVIDENCE-OF: R-11683-62380 The specified column of row iRow contains a
+# value that is not a TEXT or BLOB value
+test_blob_open 6 main t1 x 2 0 SQLITE_ERROR "cannot open value of type null"
+test_blob_open 7 main t1 y 1 0 SQLITE_ERROR "cannot open value of type integer"
+test_blob_open 8 main t1 y 3 0 SQLITE_ERROR "cannot open value of type real"
+
+# EVIDENCE-OF: R-34146-30782 Column zColumn is part of an index, PRIMARY
+# KEY or UNIQUE constraint and the blob is being opened for read/write
+# access
+#
+# Test cases 8.1.* show that such columns can be opened for read-access.
+# Tests 8.2.* show that read-write access is different. Columns "c" and "c"
+# are not part of an index, PK or UNIQUE constraint, so they work in both
+# cases.
+#
+test_blob_open 8.1.1 main t3 a 1 0 SQLITE_OK "not an error"
+test_blob_open 8.1.2 main t3 b 1 0 SQLITE_OK "not an error"
+test_blob_open 8.1.3 main t3 c 1 0 SQLITE_OK "not an error"
+test_blob_open 8.1.4 main t3 d 1 0 SQLITE_OK "not an error"
+test_blob_open 8.1.5 main t3 e 1 0 SQLITE_OK "not an error"
+test_blob_open 8.1.6 main t3 f 1 0 SQLITE_OK "not an error"
+
+set cannot "cannot open indexed column for writing"
+test_blob_open 8.2.1 main t3 a 1 8 SQLITE_ERROR $cannot
+test_blob_open 8.2.2 main t3 b 1 8 SQLITE_ERROR $cannot
+test_blob_open 8.2.3 main t3 c 1 8 SQLITE_OK "not an error"
+test_blob_open 8.2.4 main t3 d 1 8 SQLITE_OK "not an error"
+test_blob_open 8.2.5 main t3 e 1 8 SQLITE_ERROR $cannot
+test_blob_open 8.2.6 main t3 f 1 8 SQLITE_ERROR $cannot
+
+# EVIDENCE-OF: R-50117-55204 Foreign key constraints are enabled, column
+# zColumn is part of a child key definition and the blob is being opened
+# for read/write access
+#
+# 9.1: FK disabled, read-only access.
+# 9.2: FK disabled, read-only access.
+# 9.3: FK enabled, read/write access.
+# 9.4: FK enabled, read/write access.
+#
+test_blob_open 9.1 main c1 b 45 0 SQLITE_OK "not an error"
+test_blob_open 9.2 main c1 b 45 1 SQLITE_OK "not an error"
+execsql { PRAGMA foreign_keys = ON }
+test_blob_open 9.3 main c1 b 45 0 SQLITE_OK "not an error"
+test_blob_open 9.4 main c1 b 45 1 SQLITE_ERROR \
+ "cannot open foreign key column for writing"
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-08940-21305 Unless it returns SQLITE_MISUSE, this
+# function sets the database connection error code and message
+# accessible via sqlite3_errcode() and sqlite3_errmsg() and related
+# functions.
+#
+# This requirement is partially verified by the many uses of test
+# command [test_blob_open] above. All that is left is to verify the
+# SQLITE_MISUSE case.
+#
+# SQLITE_MISUSE is only returned if SQLITE_ENABLE_API_ARMOR is defined
+# during compilation.
+#
+ifcapable api_armor {
+ sqlite3_blob_open db main t1 x 1 0 B
+
+ do_test 10.1.1 {
+ list [catch {sqlite3_blob_open $B main t1 x 1 0 B2} msg] $msg
+ } {1 SQLITE_MISUSE}
+ do_test 10.1.2 {
+ list [sqlite3_errcode db] [sqlite3_errmsg db]
+ } {SQLITE_OK {not an error}}
+ sqlite3_blob_close $B
+
+ do_test 10.2.1 {
+ list [catch {sqlite3_blob_open db main {} x 1 0 B} msg] $msg
+ } {1 SQLITE_MISUSE}
+ do_test 10.2.2 {
+ list [sqlite3_errcode db] [sqlite3_errmsg db]
+ } {SQLITE_OK {not an error}}
+}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-50542-62589 If the row that a BLOB handle points to is
+# modified by an UPDATE, DELETE, or by ON CONFLICT side-effects then the
+# BLOB handle is marked as "expired". This is true if any column of the
+# row is changed, even a column other than the one the BLOB handle is
+# open on.
+#
+# EVIDENCE-OF: R-48367-20048 Calls to sqlite3_blob_read() and
+# sqlite3_blob_write() for an expired BLOB handle fail with a return
+# code of SQLITE_ABORT.
+#
+# 11.2: read-only handle, DELETE.
+# 11.3: read-only handle, UPDATE.
+# 11.4: read-only handle, REPLACE.
+# 11.5: read/write handle, DELETE.
+# 11.6: read/write handle, UPDATE.
+# 11.7: read/write handle, REPLACE.
+#
+do_execsql_test 11.1 {
+ CREATE TABLE b1(a INTEGER PRIMARY KEY, b, c UNIQUE);
+ INSERT INTO b1 VALUES(1, '1234567890', 1);
+ INSERT INTO b1 VALUES(2, '1234567890', 2);
+ INSERT INTO b1 VALUES(3, '1234567890', 3);
+ INSERT INTO b1 VALUES(4, '1234567890', 4);
+ INSERT INTO b1 VALUES(5, '1234567890', 5);
+ INSERT INTO b1 VALUES(6, '1234567890', 6);
+
+ CREATE TABLE b2(a INTEGER PRIMARY KEY, b, c UNIQUE);
+ INSERT INTO b2 VALUES(1, '1234567890', 1);
+ INSERT INTO b2 VALUES(2, '1234567890', 2);
+ INSERT INTO b2 VALUES(3, '1234567890', 3);
+ INSERT INTO b2 VALUES(4, '1234567890', 4);
+ INSERT INTO b2 VALUES(5, '1234567890', 5);
+ INSERT INTO b2 VALUES(6, '1234567890', 6);
+}
+
+do_test 11.2.1 {
+ sqlite3_blob_open db main b1 b 2 0 B
+ sqlite3_blob_read $B 0 10
+} {1234567890}
+do_test 11.2.2 {
+ # Deleting a different row does not invalidate the blob handle.
+ execsql { DELETE FROM b1 WHERE a = 1 }
+ sqlite3_blob_read $B 0 10
+} {1234567890}
+do_test 11.2.3 {
+ execsql { DELETE FROM b1 WHERE a = 2 }
+ list [catch { sqlite3_blob_read $B 0 10 } msg] $msg
+} {1 SQLITE_ABORT}
+do_test 11.2.4 {
+ sqlite3_blob_close $B
+} {}
+
+do_test 11.3.1 {
+ sqlite3_blob_open db main b1 b 3 0 B
+ sqlite3_blob_read $B 0 10
+} {1234567890}
+do_test 11.3.2 {
+ # Updating a different row
+ execsql { UPDATE b1 SET c = 42 WHERE a=4 }
+ sqlite3_blob_read $B 0 10
+} {1234567890}
+do_test 11.3.3 {
+ execsql { UPDATE b1 SET c = 43 WHERE a=3 }
+ list [catch { sqlite3_blob_read $B 0 10 } msg] $msg
+} {1 SQLITE_ABORT}
+do_test 11.3.4 {
+ sqlite3_blob_close $B
+} {}
+
+do_test 11.4.1 {
+ sqlite3_blob_open db main b1 b 6 0 B
+ sqlite3_blob_read $B 0 10
+} {1234567890}
+do_test 11.4.2 {
+ # Replace a different row
+ execsql { INSERT OR REPLACE INTO b1 VALUES(10, 'abcdefghij', 5) }
+ sqlite3_blob_read $B 0 10
+} {1234567890}
+do_test 11.4.3 {
+ execsql { INSERT OR REPLACE INTO b1 VALUES(11, 'abcdefghij', 6) }
+ list [catch { sqlite3_blob_read $B 0 10 } msg] $msg
+} {1 SQLITE_ABORT}
+do_test 11.4.4 {
+ sqlite3_blob_close $B
+} {}
+
+do_test 11.4.1 {
+ sqlite3_blob_open db main b2 b 2 1 B
+ sqlite3_blob_write $B 0 "abcdefghij"
+} {}
+do_test 11.4.2 {
+ # Deleting a different row does not invalidate the blob handle.
+ execsql { DELETE FROM b2 WHERE a = 1 }
+ sqlite3_blob_write $B 0 "ABCDEFGHIJ"
+} {}
+do_test 11.4.3 {
+ execsql { DELETE FROM b2 WHERE a = 2 }
+ list [catch { sqlite3_blob_write $B 0 "0987654321" } msg] $msg
+} {1 SQLITE_ABORT}
+do_test 11.4.4 {
+ sqlite3_blob_close $B
+} {}
+
+do_test 11.5.1 {
+ sqlite3_blob_open db main b2 b 3 1 B
+ sqlite3_blob_write $B 0 "abcdefghij"
+} {}
+do_test 11.5.2 {
+ # Updating a different row
+ execsql { UPDATE b2 SET c = 42 WHERE a=4 }
+ sqlite3_blob_write $B 0 "ABCDEFGHIJ"
+} {}
+do_test 11.5.3 {
+ execsql { UPDATE b2 SET c = 43 WHERE a=3 }
+ list [catch { sqlite3_blob_write $B 0 "0987654321" } msg] $msg
+} {1 SQLITE_ABORT}
+do_test 11.5.4 {
+ sqlite3_blob_close $B
+} {}
+
+do_test 11.6.1 {
+ sqlite3_blob_open db main b2 b 6 1 B
+ sqlite3_blob_write $B 0 "abcdefghij"
+} {}
+do_test 11.6.2 {
+ # Replace a different row
+ execsql { INSERT OR REPLACE INTO b2 VALUES(10, 'abcdefghij', 5) }
+ sqlite3_blob_write $B 0 "ABCDEFGHIJ"
+} {}
+do_test 11.6.3 {
+ execsql { INSERT OR REPLACE INTO b2 VALUES(11, 'abcdefghij', 6) }
+ list [catch { sqlite3_blob_write $B 0 "0987654321" } msg] $msg
+} {1 SQLITE_ABORT}
+do_test 11.6.4 {
+ sqlite3_blob_close $B
+} {}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-45408-40694 Changes written into a BLOB prior to the
+# BLOB expiring are not rolled back by the expiration of the BLOB. Such
+# changes will eventually commit if the transaction continues to
+# completion.
+#
+do_execsql_test 12.1 {
+ CREATE TABLE b3(x INTEGER PRIMARY KEY, y TEXT, z INTEGER);
+ INSERT INTO b3 VALUES(22, '..........', NULL);
+}
+do_test 12.2 {
+ sqlite3_blob_open db main b3 y 22 1 B
+ sqlite3_blob_write $B 0 "xxxxx" 5
+} {}
+do_execsql_test 12.3 {
+ UPDATE b3 SET z = 'not null';
+}
+do_test 12.4 {
+ list [catch {sqlite3_blob_write $B 5 "xxxxx" 5} msg] $msg
+} {1 SQLITE_ABORT}
+do_execsql_test 12.5 {
+ SELECT * FROM b3;
+} {22 xxxxx..... {not null}}
+do_test 12.5 {
+ sqlite3_blob_close $B
+} {}
+do_execsql_test 12.6 {
+ SELECT * FROM b3;
+} {22 xxxxx..... {not null}}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-58813-55036 The sqlite3_bind_zeroblob() and
+# sqlite3_result_zeroblob() interfaces and the built-in zeroblob SQL
+# function may be used to create a zero-filled blob to read or write
+# using the incremental-blob interface.
+#
+do_execsql_test 13.1 {
+ CREATE TABLE c2(i INTEGER PRIMARY KEY, j);
+ INSERT INTO c2 VALUES(10, zeroblob(24));
+}
+
+do_test 13.2 {
+ set stmt [sqlite3_prepare_v2 db "INSERT INTO c2 VALUES(11, ?)" -1]
+ sqlite3_bind_zeroblob $stmt 1 45
+ sqlite3_step $stmt
+ sqlite3_finalize $stmt
+} {SQLITE_OK}
+
+# The blobs can be read:
+#
+do_test 13.3.1 {
+ sqlite3_blob_open db main c2 j 10 1 B
+ sqlite3_blob_open db main c2 j 11 1 B2
+ list [sqlite3_blob_bytes $B] [sqlite3_blob_bytes $B2]
+} {24 45}
+do_test 13.3.2 {
+ sqlite3_blob_read $B 0 24
+} [string repeat [binary format c 0] 24]
+do_test 13.3.3 {
+ sqlite3_blob_read $B2 0 45
+} [string repeat [binary format c 0] 45]
+
+# And also written:
+#
+do_test 13.4.1 {
+ sqlite3_blob_write $B 0 [string repeat [binary format c 1] 24]
+} {}
+do_test 13.4.2 {
+ sqlite3_blob_write $B2 0 [string repeat [binary format c 1] 45]
+} {}
+do_test 13.5 {
+ sqlite3_blob_close $B
+ sqlite3_blob_close $B2
+ execsql { SELECT j FROM c2 }
+} [list \
+ [string repeat [binary format c 1] 24] \
+ [string repeat [binary format c 1] 45] \
+]
+
+
+finish_test
diff --git a/test/e_blobwrite.test b/test/e_blobwrite.test
new file mode 100644
index 0000000..8d8588e
--- /dev/null
+++ b/test/e_blobwrite.test
@@ -0,0 +1,208 @@
+# 2014 October 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix e_blobwrite
+
+ifcapable !incrblob {
+ finish_test
+ return
+}
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-62898-22698 This function is used to write data into an
+# open BLOB handle from a caller-supplied buffer. N bytes of data are
+# copied from the buffer Z into the open BLOB, starting at offset
+# iOffset.
+#
+set dots [string repeat . 40]
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, t TEXT);
+ INSERT INTO t1 VALUES(-1, $dots);
+ INSERT INTO t1 VALUES(-2, $dots);
+ INSERT INTO t1 VALUES(-3, $dots);
+ INSERT INTO t1 VALUES(-4, $dots);
+ INSERT INTO t1 VALUES(-5, $dots);
+ INSERT INTO t1 VALUES(-6, $dots);
+}
+
+proc blob_write_test {tn id iOffset blob nData final} {
+ sqlite3_blob_open db main t1 t $id 1 B
+
+ # EVIDENCE-OF: R-45864-01884 On success, sqlite3_blob_write() returns
+ # SQLITE_OK. Otherwise, an error code or an extended error code is
+ # returned.
+ #
+ # This block tests the SQLITE_OK case in the requirement above (the
+ # Tcl sqlite3_blob_write() wrapper uses an empty string in place of
+ # "SQLITE_OK"). The error cases are tested by the "blob_write_error_test"
+ # tests below.
+ #
+ set res [sqlite3_blob_write $B $iOffset $blob $nData]
+ uplevel [list do_test $tn.1 [list set {} $res] {}]
+
+ sqlite3_blob_close $B
+ uplevel [list do_execsql_test $tn.3 "SELECT t FROM t1 WHERE a=$id" $final]
+}
+
+set blob "0123456789012345678901234567890123456789"
+blob_write_test 1.1 -1 0 $blob 10 { 0123456789.............................. }
+blob_write_test 1.2 -2 8 $blob 10 { ........0123456789...................... }
+blob_write_test 1.3 -3 8 $blob 1 { ........0............................... }
+blob_write_test 1.4 -4 18 $blob 22 { ..................0123456789012345678901 }
+blob_write_test 1.5 -5 18 $blob 0 { ........................................ }
+blob_write_test 1.6 -6 0 $blob 40 { 0123456789012345678901234567890123456789 }
+
+
+proc blob_write_error_test {tn B iOffset blob nData errcode errmsg} {
+
+ # In cases where the underlying sqlite3_blob_write() function returns
+ # SQLITE_OK, the Tcl wrapper returns an empty string. If the underlying
+ # function returns an error, the Tcl wrapper throws an exception with
+ # the error code as the Tcl exception message.
+ #
+ if {$errcode=="SQLITE_OK"} {
+ set ret ""
+ set isError 0
+ } else {
+ set ret $errcode
+ set isError 1
+ }
+
+ set cmd [list sqlite3_blob_write $B $iOffset $blob $nData]
+ uplevel [list do_test $tn.1 [subst -nocommands {
+ list [catch {$cmd} msg] [set msg]
+ }] [list $isError $ret]]
+
+ # EVIDENCE-OF: R-34782-18311 Unless SQLITE_MISUSE is returned, this
+ # function sets the database connection error code and message
+ # accessible via sqlite3_errcode() and sqlite3_errmsg() and related
+ # functions.
+ #
+ if {$errcode == "SQLITE_MISUSE"} { error "test proc misuse!" }
+ uplevel [list do_test $tn.2 [list sqlite3_errcode db] $errcode]
+ uplevel [list do_test $tn.3 [list sqlite3_errmsg db] $errmsg]
+}
+
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a TEXT, b INTEGER PRIMARY KEY);
+ INSERT INTO t2 VALUES($dots, 43);
+ INSERT INTO t2 VALUES($dots, 44);
+ INSERT INTO t2 VALUES($dots, 45);
+}
+
+# EVIDENCE-OF: R-63341-57517 If the BLOB handle passed as the first
+# argument was not opened for writing (the flags parameter to
+# sqlite3_blob_open() was zero), this function returns SQLITE_READONLY.
+#
+sqlite3_blob_open db main t2 a 43 0 B
+blob_write_error_test 2.1 $B 0 $blob 10 \
+ SQLITE_READONLY {attempt to write a readonly database}
+sqlite3_blob_close $B
+
+# EVIDENCE-OF: R-29804-27366 If offset iOffset is less than N bytes from
+# the end of the BLOB, SQLITE_ERROR is returned and no data is written.
+#
+sqlite3_blob_open db main t2 a 44 3 B
+blob_write_error_test 2.2.1 $B 31 $blob 10 \
+ SQLITE_ERROR {SQL logic error}
+
+# Make a successful write to the blob handle. This shows that the
+# sqlite3_errcode() and sqlite3_errmsg() values are set even if the
+# blob_write() call succeeds (see requirement in the [blob_write_error_test]
+# proc).
+blob_write_error_test 2.2.1 $B 30 $blob 10 SQLITE_OK {not an error}
+
+# EVIDENCE-OF: R-58570-38916 If N or iOffset are less than zero
+# SQLITE_ERROR is returned and no data is written.
+#
+blob_write_error_test 2.2.2 $B 31 $blob -1 \
+ SQLITE_ERROR {SQL logic error}
+blob_write_error_test 2.2.3 $B 20 $blob 10 SQLITE_OK {not an error}
+blob_write_error_test 2.2.4 $B -1 $blob 10 \
+ SQLITE_ERROR {SQL logic error}
+sqlite3_blob_close $B
+
+# EVIDENCE-OF: R-20958-54138 An attempt to write to an expired BLOB
+# handle fails with an error code of SQLITE_ABORT.
+#
+do_test 2.3 {
+ sqlite3_blob_open db main t2 a 43 0 B
+ execsql { DELETE FROM t2 WHERE b=43 }
+} {}
+blob_write_error_test 2.3.1 $B 5 $blob 5 \
+ SQLITE_ABORT {query aborted}
+do_test 2.3.2 {
+ execsql { SELECT 1, 2, 3 }
+ sqlite3_errcode db
+} {SQLITE_OK}
+blob_write_error_test 2.3.3 $B 5 $blob 5 \
+ SQLITE_ABORT {query aborted}
+sqlite3_blob_close $B
+
+# EVIDENCE-OF: R-08382-59936 Writes to the BLOB that occurred before the
+# BLOB handle expired are not rolled back by the expiration of the
+# handle, though of course those changes might have been overwritten by
+# the statement that expired the BLOB handle or by other independent
+# statements.
+#
+# 3.1.*: not rolled back,
+# 3.2.*: overwritten.
+#
+do_execsql_test 3.0 {
+ CREATE TABLE t3(i INTEGER PRIMARY KEY, j TEXT, k TEXT);
+ INSERT INTO t3 VALUES(1, $dots, $dots);
+ INSERT INTO t3 VALUES(2, $dots, $dots);
+ SELECT * FROM t3 WHERE i=1;
+} {
+ 1
+ ........................................
+ ........................................
+}
+sqlite3_blob_open db main t3 j 1 1 B
+blob_write_error_test 3.1.1 $B 5 $blob 10 SQLITE_OK {not an error}
+do_execsql_test 3.1.2 {
+ UPDATE t3 SET k = 'xyz' WHERE i=1;
+ SELECT * FROM t3 WHERE i=1;
+} {
+ 1 .....0123456789......................... xyz
+}
+blob_write_error_test 3.1.3 $B 15 $blob 10 \
+ SQLITE_ABORT {query aborted}
+sqlite3_blob_close $B
+do_execsql_test 3.1.4 {
+ SELECT * FROM t3 WHERE i=1;
+} {
+ 1 .....0123456789......................... xyz
+}
+
+sqlite3_blob_open db main t3 j 2 1 B
+blob_write_error_test 3.2.1 $B 5 $blob 10 SQLITE_OK {not an error}
+do_execsql_test 3.2.2 {
+ UPDATE t3 SET j = 'xyz' WHERE i=2;
+ SELECT * FROM t3 WHERE i=2;
+} {
+ 2 xyz ........................................
+}
+blob_write_error_test 3.2.3 $B 15 $blob 10 \
+ SQLITE_ABORT {query aborted}
+sqlite3_blob_close $B
+do_execsql_test 3.2.4 {
+ SELECT * FROM t3 WHERE i=2;
+} {
+ 2 xyz ........................................
+}
+
+
+
+finish_test
diff --git a/test/e_changes.test b/test/e_changes.test
new file mode 100644
index 0000000..2eb77d3
--- /dev/null
+++ b/test/e_changes.test
@@ -0,0 +1,443 @@
+# 2011 October 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
+set testprefix e_changes
+
+# Like [do_execsql_test], except it appends the value returned by
+# [db changes] to the result of executing the SQL script.
+#
+proc do_changes_test {tn sql res} {
+ uplevel [list \
+ do_test $tn "concat \[execsql {$sql}\] \[db changes\]" $res
+ ]
+}
+
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-58361-29089 The changes() function returns the number
+# of database rows that were changed or inserted or deleted by the most
+# recently completed INSERT, DELETE, or UPDATE statement, exclusive of
+# statements in lower-level triggers.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(x, y, PRIMARY KEY(x, y)) WITHOUT ROWID;
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t2(y);
+}
+foreach {tn schema} {
+ 1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b);
+ }
+ 2 {
+ CREATE TABLE t1(a, b, PRIMARY KEY(a, b)) WITHOUT ROWID;
+ CREATE INDEX i1 ON t1(b);
+ }
+} {
+ reset_db
+ execsql $schema
+
+ # Insert 1 row.
+ do_changes_test 1.$tn.1 { INSERT INTO t1 VALUES(0, 0) } 1
+
+ # Insert 10 rows.
+ do_changes_test 1.$tn.2 {
+ WITH rows(i, j) AS (
+ SELECT 1, 1 UNION ALL SELECT i+1, j+i FROM rows WHERE i<10
+ )
+ INSERT INTO t1 SELECT * FROM rows
+ } 10
+
+ # Modify 5 rows.
+ do_changes_test 1.$tn.3 {
+ UPDATE t1 SET b=b+1 WHERE a<5;
+ } 5
+
+ # Delete 4 rows
+ do_changes_test 1.$tn.4 {
+ DELETE FROM t1 WHERE a>6
+ } 4
+
+ # Check the "on the database connecton specified" part of hte
+ # requirement - changes made by other connections do not show up in
+ # the return value of sqlite3_changes().
+ do_test 1.$tn.5 {
+ sqlite3 db2 test.db
+ execsql { INSERT INTO t1 VALUES(-1, -1) } db2
+ db2 changes
+ } 1
+ do_test 1.$tn.6 {
+ db changes
+ } 4
+ db2 close
+
+ # Test that statements that modify no rows because they hit UNIQUE
+ # constraints set the sqlite3_changes() value to 0. Regardless of
+ # whether or not they are executed inside an explicit transaction.
+ #
+ # 1.$tn.8-9: outside of a transaction
+ # 1.$tn.10-12: inside a transaction
+ #
+ do_changes_test 1.$tn.7 {
+ CREATE UNIQUE INDEX i2 ON t1(a);
+ } 4
+ do_catchsql_test 1.$tn.8 {
+ INSERT INTO t1 VALUES('a', 0), ('b', 0), ('c', 0), (0, 11);
+ } {1 {UNIQUE constraint failed: t1.a}}
+ do_test 1.$tn.9 { db changes } 0
+ do_catchsql_test 1.$tn.10 {
+ BEGIN;
+ INSERT INTO t1 VALUES('a', 0), ('b', 0), ('c', 0), (0, 11);
+ } {1 {UNIQUE constraint failed: t1.a}}
+ do_test 1.$tn.11 { db changes } 0
+ do_changes_test 1.$tn.12 COMMIT 0
+
+}
+
+
+#--------------------------------------------------------------------------
+# X-EVIDENCE-OF: R-44877-05564 Executing any other type of SQL statement
+# does not modify the value returned by this function.
+#
+reset_db
+do_changes_test 2.1 { CREATE TABLE t1(x) } 0
+do_changes_test 2.2 {
+ WITH d(y) AS (SELECT 1 UNION ALL SELECT y+1 FROM d WHERE y<47)
+ INSERT INTO t1 SELECT y FROM d;
+} 47
+
+# The statement above set changes() to 47. Check that none of the following
+# modify this.
+do_changes_test 2.3 { SELECT count(x) FROM t1 } {47 47}
+do_changes_test 2.4 { DROP TABLE t1 } 47
+do_changes_test 2.5 { CREATE TABLE t1(x) } 47
+ifcapable altertable {
+ do_changes_test 2.6 { ALTER TABLE t1 ADD COLUMN b } 47
+}
+
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-53938-27527 Only changes made directly by the INSERT,
+# UPDATE or DELETE statement are considered - auxiliary changes caused
+# by triggers, foreign key actions or REPLACE constraint resolution are
+# not counted.
+#
+# 3.1.*: triggers
+# 3.2.*: foreign key actions
+# 3.3.*: replace constraints
+#
+reset_db
+do_execsql_test 3.1.0 {
+ CREATE TABLE log(x);
+ CREATE TABLE p1(one PRIMARY KEY, two);
+
+ CREATE TRIGGER tr_ai AFTER INSERT ON p1 BEGIN
+ INSERT INTO log VALUES('insert');
+ END;
+ CREATE TRIGGER tr_bd BEFORE DELETE ON p1 BEGIN
+ INSERT INTO log VALUES('delete');
+ END;
+ CREATE TRIGGER tr_au AFTER UPDATE ON p1 BEGIN
+ INSERT INTO log VALUES('update');
+ END;
+
+}
+
+do_changes_test 3.1.1 {
+ INSERT INTO p1 VALUES('a', 'A'), ('b', 'B'), ('c', 'C');
+} 3
+do_changes_test 3.1.2 {
+ UPDATE p1 SET two = two||two;
+} 3
+do_changes_test 3.1.3 {
+ DELETE FROM p1 WHERE one IN ('a', 'c');
+} 2
+do_execsql_test 3.1.4 {
+ -- None of the inserts on table log were counted.
+ SELECT count(*) FROM log
+} 8
+
+do_execsql_test 3.2.0 {
+ DELETE FROM p1;
+ INSERT INTO p1 VALUES('a', 'A'), ('b', 'B'), ('c', 'C');
+
+ CREATE TABLE c1(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE SET NULL);
+ CREATE TABLE c2(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE SET DEFAULT);
+ CREATE TABLE c3(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE CASCADE);
+ INSERT INTO c1 VALUES('a', 'aaa');
+ INSERT INTO c2 VALUES('b', 'bbb');
+ INSERT INTO c3 VALUES('c', 'ccc');
+
+ INSERT INTO p1 VALUES('d', 'D'), ('e', 'E'), ('f', 'F');
+ CREATE TABLE c4(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE SET NULL);
+ CREATE TABLE c5(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE SET DEFAULT);
+ CREATE TABLE c6(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE CASCADE);
+ INSERT INTO c4 VALUES('d', 'aaa');
+ INSERT INTO c5 VALUES('e', 'bbb');
+ INSERT INTO c6 VALUES('f', 'ccc');
+
+ PRAGMA foreign_keys = ON;
+}
+
+do_changes_test 3.2.1 { DELETE FROM p1 WHERE one = 'a' } 1
+do_changes_test 3.2.2 { DELETE FROM p1 WHERE one = 'b' } 1
+do_changes_test 3.2.3 { DELETE FROM p1 WHERE one = 'c' } 1
+do_execsql_test 3.2.4 {
+ SELECT * FROM c1;
+ SELECT * FROM c2;
+ SELECT * FROM c3;
+} {{} aaa {} bbb}
+
+do_changes_test 3.2.5 { UPDATE p1 SET one = 'g' WHERE one = 'd' } 1
+do_changes_test 3.2.6 { UPDATE p1 SET one = 'h' WHERE one = 'e' } 1
+do_changes_test 3.2.7 { UPDATE p1 SET one = 'i' WHERE one = 'f' } 1
+do_execsql_test 3.2.8 {
+ SELECT * FROM c4;
+ SELECT * FROM c5;
+ SELECT * FROM c6;
+} {{} aaa {} bbb i ccc}
+
+do_execsql_test 3.3.0 {
+ CREATE TABLE r1(a UNIQUE, b UNIQUE);
+ INSERT INTO r1 VALUES('i', 'i');
+ INSERT INTO r1 VALUES('ii', 'ii');
+ INSERT INTO r1 VALUES('iii', 'iii');
+ INSERT INTO r1 VALUES('iv', 'iv');
+ INSERT INTO r1 VALUES('v', 'v');
+ INSERT INTO r1 VALUES('vi', 'vi');
+ INSERT INTO r1 VALUES('vii', 'vii');
+}
+
+do_changes_test 3.3.1 { INSERT OR REPLACE INTO r1 VALUES('i', 1) } 1
+do_changes_test 3.3.2 { INSERT OR REPLACE INTO r1 VALUES('iv', 'v') } 1
+do_changes_test 3.3.3 { UPDATE OR REPLACE r1 SET b='v' WHERE a='iii' } 1
+do_changes_test 3.3.4 { UPDATE OR REPLACE r1 SET b='vi',a='vii' WHERE a='ii' } 1
+do_execsql_test 3.3.5 {
+ SELECT * FROM r1 ORDER BY a;
+} {i 1 iii v vii vi}
+
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-09813-48563 The value returned by sqlite3_changes()
+# immediately after an INSERT, UPDATE or DELETE statement run on a view
+# is always zero.
+#
+reset_db
+do_execsql_test 4.1 {
+ CREATE TABLE log(log);
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE TRIGGER v1_i INSTEAD OF INSERT ON v1 BEGIN
+ INSERT INTO log VALUES('insert');
+ END;
+ CREATE TRIGGER v1_u INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO log VALUES('update'), ('update');
+ END;
+ CREATE TRIGGER v1_d INSTEAD OF DELETE ON v1 BEGIN
+ INSERT INTO log VALUES('delete'), ('delete'), ('delete');
+ END;
+}
+
+do_changes_test 4.2.1 { INSERT INTO t1 SELECT * FROM t1 } 3
+do_changes_test 4.2.2 { INSERT INTO v1 VALUES(1, 2) } 0
+
+do_changes_test 4.3.1 { INSERT INTO t1 SELECT * FROM t1 } 6
+do_changes_test 4.3.2 { UPDATE v1 SET y='xyz' WHERE x=1 } 0
+
+do_changes_test 4.4.1 { INSERT INTO t1 SELECT * FROM t1 } 12
+do_changes_test 4.4.2 { DELETE FROM v1 WHERE x=5 } 0
+
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-32918-61474 Before entering a trigger program the value
+# returned by sqlite3_changes() function is saved. After the trigger
+# program has finished, the original value is restored.
+#
+reset_db
+db func my_changes my_changes
+set ::changes [list]
+proc my_changes {x} {
+ set res [db changes]
+ lappend ::changes $x $res
+ return $res
+}
+
+do_execsql_test 5.1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(x);
+ INSERT INTO t1 VALUES(1, NULL);
+ INSERT INTO t1 VALUES(2, NULL);
+ INSERT INTO t1 VALUES(3, NULL);
+ CREATE TRIGGER AFTER UPDATE ON t1 BEGIN
+ INSERT INTO t2 VALUES('a'), ('b'), ('c');
+ SELECT my_changes('trigger');
+ END;
+}
+
+do_execsql_test 5.1.1 {
+ INSERT INTO t2 VALUES('a'), ('b');
+ UPDATE t1 SET b = my_changes('update');
+ SELECT * FROM t1;
+} {1 2 2 2 3 2}
+
+# Value is being restored to "2" when the trigger program exits.
+do_test 5.1.2 {
+ set ::changes
+} {update 2 trigger 3 update 2 trigger 3 update 2 trigger 3}
+
+
+reset_db
+do_execsql_test 5.2.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE log(x);
+ INSERT INTO t1 VALUES(1, 0);
+ INSERT INTO t1 VALUES(2, 0);
+ INSERT INTO t1 VALUES(3, 0);
+ CREATE TRIGGER t1_a_u AFTER UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES(old.b || ' -> ' || new.b || ' c = ' || changes() );
+ END;
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES(1), (2), (3);
+ UPDATE t1 SET b = changes();
+}
+do_execsql_test 5.2.1 {
+ SELECT * FROM t1;
+} {1 3 2 3 3 3}
+do_execsql_test 5.2.2 {
+ SELECT * FROM log;
+} {{0 -> 3 c = 3} {0 -> 3 c = 3} {0 -> 3 c = 3}}
+
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-17146-37073 Within a trigger program each INSERT,
+# UPDATE and DELETE statement sets the value returned by
+# sqlite3_changes() upon completion as normal. Of course, this value
+# will not include any changes performed by sub-triggers, as the
+# sqlite3_changes() value will be saved and restored after each
+# sub-trigger has run.
+reset_db
+do_execsql_test 6.0 {
+
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(a, b);
+ CREATE TABLE log(x);
+
+ CREATE TRIGGER t1_i BEFORE INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.a, new.b), (new.a, new.b);
+ INSERT INTO log VALUES('t2->' || changes());
+ END;
+
+ CREATE TRIGGER t2_i AFTER INSERT ON t2 BEGIN
+ INSERT INTO t3 VALUES(new.a, new.b), (new.a, new.b), (new.a, new.b);
+ INSERT INTO log VALUES('t3->' || changes());
+ END;
+
+ CREATE TRIGGER t1_u AFTER UPDATE ON t1 BEGIN
+ UPDATE t2 SET b=new.b WHERE a=old.a;
+ INSERT INTO log VALUES('t2->' || changes());
+ END;
+
+ CREATE TRIGGER t2_u BEFORE UPDATE ON t2 BEGIN
+ UPDATE t3 SET b=new.b WHERE a=old.a;
+ INSERT INTO log VALUES('t3->' || changes());
+ END;
+
+ CREATE TRIGGER t1_d AFTER DELETE ON t1 BEGIN
+ DELETE FROM t2 WHERE a=old.a AND b=old.b;
+ INSERT INTO log VALUES('t2->' || changes());
+ END;
+
+ CREATE TRIGGER t2_d BEFORE DELETE ON t2 BEGIN
+ DELETE FROM t3 WHERE a=old.a AND b=old.b;
+ INSERT INTO log VALUES('t3->' || changes());
+ END;
+}
+
+do_changes_test 6.1 {
+ INSERT INTO t1 VALUES('+', 'o');
+ SELECT * FROM log;
+} {t3->3 t3->3 t2->2 1}
+
+do_changes_test 6.2 {
+ DELETE FROM log;
+ UPDATE t1 SET b='*';
+ SELECT * FROM log;
+} {t3->6 t3->6 t2->2 1}
+
+do_changes_test 6.3 {
+ DELETE FROM log;
+ DELETE FROM t1;
+ SELECT * FROM log;
+} {t3->6 t3->0 t2->2 1}
+
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-43399-09409 This means that if the changes() SQL
+# function (or similar) is used by the first INSERT, UPDATE or DELETE
+# statement within a trigger, it returns the value as set when the
+# calling statement began executing.
+#
+# EVIDENCE-OF: R-53215-27584 If it is used by the second or subsequent
+# such statement within a trigger program, the value returned reflects
+# the number of rows modified by the previous INSERT, UPDATE or DELETE
+# statement within the same trigger.
+#
+reset_db
+do_execsql_test 7.1 {
+ CREATE TABLE q1(t);
+ CREATE TABLE q2(u, v);
+ CREATE TABLE q3(w);
+
+ CREATE TRIGGER q2_insert BEFORE INSERT ON q2 BEGIN
+
+ /* changes() returns value from previous I/U/D in callers context */
+ INSERT INTO q1 VALUES('1:' || changes());
+
+ /* changes() returns value of previous I/U/D in this context */
+ INSERT INTO q3 VALUES(changes()), (2), (3);
+ INSERT INTO q1 VALUES('2:' || changes());
+ INSERT INTO q3 VALUES(changes() + 3), (changes()+4);
+ SELECT 'this does not affect things!';
+ INSERT INTO q1 VALUES('3:' || changes());
+ UPDATE q3 SET w = w+10 WHERE w%2;
+ INSERT INTO q1 VALUES('4:' || changes());
+ DELETE FROM q3;
+ INSERT INTO q1 VALUES('5:' || changes());
+ END;
+}
+
+do_execsql_test 7.2 {
+ INSERT INTO q2 VALUES('x', 'y');
+ SELECT * FROM q1;
+} {
+ 1:0 2:3 3:2 4:3 5:5
+}
+
+do_execsql_test 7.3 {
+ DELETE FROM q1;
+ INSERT INTO q2 VALUES('x', 'y');
+ SELECT * FROM q1;
+} {
+ 1:5 2:3 3:2 4:3 5:5
+}
+
+
+
+finish_test
diff --git a/test/e_createtable.test b/test/e_createtable.test
new file mode 100644
index 0000000..3ecffae
--- /dev/null
+++ b/test/e_createtable.test
@@ -0,0 +1,1969 @@
+# 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
+}
+
+
+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}
+}
+
+
+# syntax diagram column-constraint
+#
+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
+ );
+ } {}
+}
+
+# -- 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)" {}
+}
+
+# -- 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
+ );
+ } {}
+}
+
+# -- 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" {}
+}
+
+#
+# 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-18448-33677 If a schema-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
+if {[permutation]!="maindbname"} {
+ 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
+if {[permutation]!="maindbname"} {
+ 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-23976-43329 It is an error to specify both a
+# schema-name and the TEMP or TEMPORARY keyword, unless the schema-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
+if {[permutation]!="maindbname"} {
+ 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-31997-24564 If no schema name is specified and the TEMP
+# keyword is not present then the table is created in the main database.
+#
+drop_all_tables
+if {[permutation]!="maindbname"} {
+ 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)" {{view 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)" {{view 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-55407-45319 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" BLOB (a.k.a "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-07343-35026 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. A
+# 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-33440-07331 For the purposes of the DEFAULT clause, an
+# expression is considered constant if it contains no sub-queries,
+# column or table references, bound parameters, or string literals
+# enclosed in double-quotes instead of single-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) ))} {}
+ 5 {CREATE TABLE t5(x DEFAULT ( x!=?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-31826-01813 An error is raised if more than one PRIMARY
+# KEY clause appears in a CREATE TABLE statement.
+#
+# 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))" {}
+}
+
+# EVIDENCE-OF: R-54755-39291 The PRIMARY KEY is optional for ordinary
+# tables but is required for WITHOUT ROWID tables.
+#
+do_catchsql_test 4.1.3 {
+ CREATE TABLE t6(a, b); --ok
+} {0 {}}
+do_catchsql_test 4.1.4 {
+ CREATE TABLE t7(a, b) WITHOUT ROWID; --Error, no PRIMARY KEY
+} {1 {PRIMARY KEY missing on table t7}}
+
+
+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-59124-61339 Each row in a table with a primary key must
+# have a unique combination of values in its primary key columns.
+#
+# EVIDENCE-OF: R-06471-16287 If an INSERT or UPDATE statement attempts
+# to modify the table content so that two or more rows have identical
+# primary key values, that 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 {UNIQUE constraint failed: t1.x} {
+ 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"}
+}
+do_createtable_tests 4.3.1 -error {UNIQUE constraint failed: t2.x, t2.y} {
+ 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 {UNIQUE constraint failed: t1.x} {
+ 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"}
+}
+do_createtable_tests 4.3.3 -error {UNIQUE constraint failed: t2.x, t2.y} {
+ 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-40010-16873 Unless the column is an INTEGER PRIMARY KEY
+# or the table is a WITHOUT ROWID table or a STRICT table or the column
+# is declared NOT NULL, 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 behavior. 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}}
+do_catchsql_test 4.5.4 {
+ CREATE TABLE t4(s, u INT PRIMARY KEY, v) WITHOUT ROWID;
+ INSERT INTO t4 VALUES(1, NULL, 2);
+} {1 {NOT NULL constraint failed: t4.u}}
+do_catchsql_test 4.5.5 {
+ CREATE TABLE t5(s, u INT PRIMARY KEY NOT NULL, v);
+ INSERT INTO t5 VALUES(1, NULL, 2);
+} {1 {NOT NULL constraint failed: t5.u}}
+do_catchsql_test 4.5.6 {
+ CREATE TABLE t6(s INT, u INT PRIMARY KEY, v INT) STRICT;
+ INSERT INTO t6 VALUES(1, NULL, 2);
+} {1 {NOT NULL constraint failed: t6.u}}
+do_catchsql_test 4.5.7 {
+ CREATE TABLE t7(s INT, u INT PRIMARY KEY NOT NULL, v INT) STRICT;
+ INSERT INTO t7 VALUES(1, NULL, 2);
+} {1 {NOT NULL constraint failed: t7.u}}
+
+# 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-30981-64168 For each UNIQUE constraint on the table,
+# each row must contain a unique combination of values in the columns
+# identified by the UNIQUE constraint.
+#
+# EVIDENCE-OF: R-59124-61339 Each row in a table with a primary key must
+# have a unique combination of values in its primary key columns.
+#
+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 {UNIQUE constraint failed: %s} {
+ 1 "INSERT INTO t1 VALUES(1, 'one')" {{t1.a}}
+ 2 "INSERT INTO t1 VALUES(4.3, 'two')" {{t1.a}}
+ 3 "INSERT INTO t1 VALUES('reveal', 'three')" {{t1.a}}
+ 4 "INSERT INTO t1 VALUES(X'123456', 'four')" {{t1.a}}
+
+ 5 "UPDATE t1 SET a = 1 WHERE rowid=2" {{t1.a}}
+ 6 "UPDATE t1 SET a = 4.3 WHERE rowid=3" {{t1.a}}
+ 7 "UPDATE t1 SET a = 'reveal' WHERE rowid=4" {{t1.a}}
+ 8 "UPDATE t1 SET a = X'123456' WHERE rowid=1" {{t1.a}}
+
+ 9 "INSERT INTO t4 VALUES('xyx', 1, 1)" {{t4.a, t4.b, t4.c}}
+ 10 "INSERT INTO t4 VALUES('xyx', 2, 1)" {{t4.a, t4.b, t4.c}}
+ 11 "INSERT INTO t4 VALUES('uvw', 1, 1)" {{t4.a, t4.b, t4.c}}
+
+ 12 "UPDATE t4 SET a='xyx' WHERE rowid=3" {{t4.a, t4.b, t4.c}}
+ 13 "UPDATE t4 SET b=1 WHERE rowid=2" {{t4.a, t4.b, t4.c}}
+ 14 "UPDATE t4 SET a=0, b=0, c=0" {{t4.a, t4.b, t4.c}}
+}
+
+# EVIDENCE-OF: R-00404-17670 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-55820-29984 In most cases, UNIQUE and PRIMARY KEY
+# constraints are implemented by creating a unique index in the
+# database.
+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
+}
+
+# Obsolete: 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"
+ {/*SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (b=?)*/}
+
+ 2 "EXPLAIN QUERY PLAN SELECT * FROM t2 ORDER BY b, c"
+ {/*SCAN t2 USING INDEX sqlite_autoindex_t2_1*/}
+
+ 3 "EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE b=10 AND c>10"
+ {/*SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (b=? AND c>?)*/}
+}
+
+# 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 {CHECK constraint failed: %s} {
+ 1a "INSERT INTO x1 VALUES('one', 0)" {b>0}
+ 1b "INSERT INTO t1 VALUES('one', -4.0)" {b>0}
+
+ 2a "INSERT INTO x2 VALUES('abc', 1)" {a||b}
+ 2b "INSERT INTO t2 VALUES('abc', 1)" {a||b}
+
+ 3a "INSERT INTO x2 VALUES(0, 'abc')" {a||b}
+ 3b "INSERT INTO t2 VALUES(0, 'abc')" {a||b}
+
+ 4a "UPDATE t1 SET b=-1 WHERE rowid=1" {b>0}
+ 4b "UPDATE x1 SET b=-1 WHERE rowid=1" {b>0}
+
+ 4a "UPDATE x2 SET a='' WHERE rowid=1" {a||b}
+ 4b "UPDATE t2 SET a='' WHERE rowid=1" {a||b}
+}
+
+# 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 {NOT NULL constraint failed: %s} {
+ 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 {UNIQUE constraint failed: t1_ab.a}} 0 {1 one 2 two 3 three}
+ 2 t1_ro {1 {UNIQUE constraint failed: t1_ro.a}} 1 {1 one 2 two}
+ 3 t1_fa {1 {UNIQUE constraint failed: t1_fa.a}} 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 {UNIQUE constraint failed: t1_xx.a}} 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 {NOT NULL constraint failed: t2_ab.b}} 0 {1 one 2 two 3 three}
+ 2 t2_ro {1 {NOT NULL constraint failed: t2_ro.b}} 1 {1 one 2 two}
+ 3 t2_fa {1 {NOT NULL constraint failed: t2_fa.b}} 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 {NOT NULL constraint failed: t2_re.b}} 0 {1 one 2 two 3 three}
+ 6 t2_xx {1 {NOT NULL constraint failed: t2_xx.b}} 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 {UNIQUE constraint failed: t3_ab.a, t3_ab.b}}
+ 0 {1 one 2 two 3 three}
+ 2 t3_ro {1 {UNIQUE constraint failed: t3_ro.a, t3_ro.b}}
+ 1 {1 one 2 two}
+ 3 t3_fa {1 {UNIQUE constraint failed: t3_fa.a, t3_fa.b}}
+ 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 {UNIQUE constraint failed: t3_xx.a, t3_xx.b}}
+ 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 ORDER BY rowid" $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 {CHECK constraint failed: b!=10}}
+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 {NOT NULL constraint failed: t5.b}}
+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.
+#
+# EVIDENCE-OF: R-06726-07466 A column name can be any of the names
+# defined in the CREATE TABLE statement or one of the following special
+# identifiers: "ROWID", "OID", or "_ROWID_".
+#
+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.
+#
+# EVIDENCE-OF: R-44615-33286 The special identifiers only refer to the
+# row key if the CREATE TABLE statement does not define a real column
+# with the same name.
+#
+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-47901-33947 With one exception noted below, if a rowid
+# 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 {UNIQUE constraint failed: t6.pk}}
+do_catchsql_test 5.4.4.2 {
+ INSERT INTO t7 VALUES(2)
+} {1 {UNIQUE constraint failed: t7.pk}}
+do_catchsql_test 5.4.4.3 {
+ INSERT INTO t8 VALUES(2)
+} {1 {UNIQUE constraint failed: t8.pk}}
+do_catchsql_test 5.4.4.4 {
+ INSERT INTO t9 VALUES(2)
+} {1 {UNIQUE constraint failed: t9.pk}}
+
+# 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..9bd9322
--- /dev/null
+++ b/test/e_delete.test
@@ -0,0 +1,477 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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);
+} {}
+
+# -- syntax diagram delete-stmt
+# -- 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-26300-50198 If a WHERE clause is supplied, then only
+# those rows for which the WHERE clause boolean expression is true are
+# deleted.
+#
+# EVIDENCE-OF: R-23360-48280 Rows for which the expression is false or
+# NULL are retained.
+#
+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-12275-20298 In other words, the schema-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:
+#
+# -- 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..5cd5d0a
--- /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;
+ "
+}
+
+
+# -- 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-04950-25529 Once removed, the trigger definition is no
+# longer present in the sqlite_schema (or sqlite_temp_schema) 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..00f59dd
--- /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 temp.sqlite_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
+}
+
+# -- 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 { string compare [list_all_data] $databasedata } 0
+
+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 { string compare [list_all_data] $databasedata } 0
+
+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 { string compare [list_all_data] $databasedata } 0
+
+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 { string compare [list_all_data] $databasedata } 0
+
+do_execsql_test 3.5.0 { SELECT * FROM aux.v2 } {{a aux} {b aux}}
+do_execsql_test 3.5.1 { DROP VIEW aux.v2 } {}
+do_catchsql_test 3.5.2 { SELECT * FROM aux.v2 } {1 {no such table: aux.v2}}
+do_test 3.5.3 { list_all_views } {aux.v3}
+do_test 3.5.4 { string compare [list_all_data] $databasedata } 0
+
+do_execsql_test 3.6.0 { SELECT * FROM v3 } {{a aux} {b aux}}
+do_execsql_test 3.6.1 { DROP VIEW v3 } {}
+do_catchsql_test 3.6.2 { SELECT * FROM v3 } {1 {no such table: v3}}
+do_test 3.6.3 { list_all_views } {}
+do_test 3.6.4 { string compare [list_all_data] $databasedata } 0
+
+# 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" "main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3"
+ 2 "DROP VIEW IF EXISTS main.xx" "main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3"
+ 3 "DROP VIEW IF EXISTS temp.v2" "main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3"
+}
+
+
+
+
+finish_test
diff --git a/test/e_expr.test b/test/e_expr.test
new file mode 100644
index 0000000..3f8d5ad
--- /dev/null
+++ b/test/e_expr.test
@@ -0,0 +1,1988 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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.
+#
+# X-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
+#
+# X-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.
+#
+# X-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-53431-59159 The % operator casts both of its operands
+# to type INTEGER and then computes the remainder after dividing the
+# left integer by the right integer.
+#
+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}
+do_execsql_test e_expr-6.5 {SELECT 72.35%5} {2.0}
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-15904-00746 The result of any binary operator is either
+# a numeric value or NULL, except for the || concatenation operator, and
+# the -> and ->> extract operators which evaluate 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.
+#
+# X-EVIDENCE-OF: R-36231-30731 The COLLATE operator has a higher
+# precedence (binds more tightly) than any binary operator and any unary
+# prefix operator except "~".
+#
+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-19836-11244 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.
+#
+# -- 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}
+
+# -- 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
+
+# -- 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}
+ }
+}
+
+# -- 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
+
+ 5 9 "(x(),8) >= (9,7) AND (x(),8)<=(9,10)" 1 2
+ 6 9 "(x(),8) BETWEEN (9,7) AND (9,10)" 1 1
+} {
+ do_test e_expr-13.1.$tn {
+ set ::xcount 0
+ set a [execsql "SELECT $expr"]
+ list $::xcount $a
+ } [list $nEval $res]
+}
+
+# X-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.1b { SELECT 'abc%xyz' LIKE 'ABC\%x%' ESCAPE '\' } 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.3b { SELECT 'abc%xyz' LIKE 'ABC\%X%' ESCAPE '\' } 0
+do_execsql_test e_expr-16.1.4 { SELECT 'ABCxyz' LIKE 'ABC%' } 1
+do_execsql_test e_expr-16.1.4b { SELECT 'ABC%xyz' LIKE 'ABC\%x%' ESCAPE '\' } 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.6b { SELECT 'abc%xyz' LIKE 'ABC\%X%' ESCAPE '\' } 1
+do_execsql_test e_expr-16.1.7 { SELECT 'ABCxyz' LIKE 'ABC%' } 1
+do_execsql_test e_expr-16.1.7b { SELECT 'ABC%xyz' LIKE 'ABC\%X%' ESCAPE '\' } 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-65524-61849 If an application-defined SQL function
+# named "regexp" is added at run-time, then the "X REGEXP Y" operator
+# will be implemented as a call to "regexp(Y,X)".
+#
+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-57495-24088 There are two fundamental 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, iif(NULL,8,99);
+} {B 99}
+do_execsql_test e_expr-21.4.2 {
+ SELECT CASE WHEN 0 THEN 'A' WHEN NULL THEN 'B' ELSE 'C' END, iif(0,8,99);
+} {C 99}
+
+# 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] [rev $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
+} {B}
+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-20854-17109 A CAST conversion is similar to the
+# conversion that takes place when a column affinity is applied to a
+# value except that with the CAST operator the conversion always takes
+# place even if the conversion lossy and irreversible, whereas column
+# affinity only changes the data type of a value if the change is
+# lossless and reversible.
+#
+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-32434-09092 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-29283-15561 Otherwise, the storage class of the result
+# is determined by applying the rules for determining column affinity to
+# the type-name.
+#
+# The R-29283-15561 requirement above is demonstrated by all of the
+# subsequent e_expr-26 tests.
+#
+# EVIDENCE-OF: R-43522-35548 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-08980-53124 The CAST operator understands decimal
+# integers only &mdash; conversion of hexadecimal integers stops at
+# the "x" in the "0x" prefix of the hexadecimal integer string and thus
+# result of the CAST is always zero.
+do_expr_test e_expr-30.5.1 { CAST('0x1234' AS INTEGER) } integer 0
+do_expr_test e_expr-30.5.2 { CAST('0X1234' AS INTEGER) } integer 0
+
+# EVIDENCE-OF: R-02752-50091 A cast of a REAL value into an INTEGER
+# results in the integer between the REAL value and zero that is closest
+# to the REAL value.
+#
+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-51517-40824 If a REAL is greater than the greatest
+# possible signed integer (+9223372036854775807) then the result is the
+# greatest possible signed integer and if the REAL is less than the
+# least possible signed integer (-9223372036854775808) then the result
+# is the least possible signed integer.
+#
+do_expr_test e_expr-31.2.1 { CAST(2e+50 AS INT) } integer 9223372036854775807
+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 9223372036854775807
+
+
+# EVIDENCE-OF: R-55084-10555 Casting a TEXT or BLOB value into NUMERIC
+# yields either an INTEGER or a REAL result.
+#
+# EVIDENCE-OF: R-48945-04866 If the input text looks like an integer
+# (there is no decimal point nor exponent) and the value is small enough
+# to fit in a 64-bit signed integer, then the result will be INTEGER.
+#
+# EVIDENCE-OF: R-47045-23194 Input text that looks like floating point
+# (there is a decimal point and/or an exponent) and the text describes a
+# value that can be losslessly converted back and forth between IEEE 754
+# 64-bit float and a 51-bit signed integer, then the result is INTEGER.
+#
+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
+do_expr_test e_expr-32.1.6 {CAST( '9.223372036e14' AS NUMERIC)} integer 922337203600000
+do_expr_test e_expr-32.1.7 {CAST('-9.223372036e14' AS NUMERIC)} integer -922337203600000
+do_test e_expr-32.1.8 {
+ set expr {CAST( '9.223372036e15' AS NUMERIC)}
+ db eval "SELECT typeof($expr) AS type, printf('%.5e',$expr) AS value" break;
+ list $type $value
+} {real 9.22337e+15}
+do_test e_expr-32.1.9 {
+ set expr {CAST('-9.223372036e15' AS NUMERIC)}
+ db eval "SELECT typeof($expr) AS type, printf('%.5e',$expr) AS value" break;
+ list $type $value
+} {real -9.22337e+15}
+
+# EVIDENCE-OF: R-50300-26941 Any text input that describes a value
+# outside the range of a 64-bit signed integer yields a REAL result.
+#
+do_expr_test e_expr-32.1.20 { CAST('9223372036854775807' AS numeric) } \
+ integer 9223372036854775807
+do_expr_test e_expr-32.1.21 { CAST('9223372036854775808' AS numeric) } \
+ real 9.22337203685478e+18
+do_expr_test e_expr-32.1.22 { CAST('-9223372036854775808' AS numeric) } \
+ integer -9223372036854775808
+do_expr_test e_expr-32.1.23 { CAST('-9223372036854775809' AS numeric) } \
+ real -9.22337203685478e+18
+
+# 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
+do_expr_test e_expr-32.2.5 {
+ CAST('9223372036854775807 ' AS NUMERIC)
+} integer 9223372036854775807
+do_expr_test e_expr-32.2.6 {
+ CAST(' 9223372036854775807 ' AS NUMERIC)
+} integer 9223372036854775807
+do_expr_test e_expr-32.2.7 {
+ CAST(' ' AS NUMERIC)
+} integer 0
+do_execsql_test e_expr-32.2.8 {
+ WITH t1(x) AS (VALUES
+ ('9000000000000000001'),
+ ('9000000000000000001x'),
+ ('9000000000000000001 '),
+ (' 9000000000000000001 '),
+ (' 9000000000000000001'),
+ (' 9000000000000000001.'),
+ ('9223372036854775807'),
+ ('9223372036854775807 '),
+ (' 9223372036854775807 '),
+ ('9223372036854775808'),
+ (' 9223372036854775808 '),
+ ('9223372036854775807.0'),
+ ('9223372036854775807e+0'),
+ ('-5.0'),
+ ('-5e+0'))
+ SELECT typeof(CAST(x AS NUMERIC)), CAST(x AS NUMERIC)||'' FROM t1;
+} [list \
+ integer 9000000000000000001 \
+ integer 9000000000000000001 \
+ integer 9000000000000000001 \
+ integer 9000000000000000001 \
+ integer 9000000000000000001 \
+ real 9.0e+18 \
+ integer 9223372036854775807 \
+ integer 9223372036854775807 \
+ integer 9223372036854775807 \
+ real 9.22337203685478e+18 \
+ real 9.22337203685478e+18 \
+ real 9.22337203685478e+18 \
+ real 9.22337203685478e+18 \
+ integer -5 \
+ integer -5 \
+]
+
+# 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-43573-23448 A SELECT statement enclosed in parentheses
+# is a subquery.
+#
+# 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-22239-33740 A subquery that returns two or more columns
+# is a row value subquery and can only be used as the operand of a
+# comparison operator.
+#
+# The following block tests that errors are returned in a bunch of cases
+# where a subquery returns more than one column.
+#
+set M {/1 {sub-select returns [23] columns - expected 1}/}
+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 $M
+}
+
+# EVIDENCE-OF: R-18318-14995 The value of a subquery expression is the
+# first row of the result from the enclosed SELECT statement.
+#
+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-52325-25449 The value of a subquery expression is NULL
+# if the enclosed SELECT statement returns no rows.
+#
+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 {}
+}
+
+# EVIDENCE-OF: R-62477-06476 For example, the values NULL, 0.0, 0,
+# 'english' and '0' are all considered to be false.
+#
+do_execsql_test e_expr-37.1 {
+ SELECT CASE WHEN NULL THEN 'true' ELSE 'false' END, iif(NULL,'true','false');
+} {false false}
+do_execsql_test e_expr-37.2 {
+ SELECT CASE WHEN 0.0 THEN 'true' ELSE 'false' END, iif(0.0,'true','false');
+} {false false}
+do_execsql_test e_expr-37.3 {
+ SELECT CASE WHEN 0 THEN 'true' ELSE 'false' END, iif(0,'true','false');
+} {false false}
+do_execsql_test e_expr-37.4 {
+ SELECT CASE WHEN 'engligh' THEN 'true' ELSE 'false' END, iif('engligh','true','false');
+} {false false}
+do_execsql_test e_expr-37.5 {
+ SELECT CASE WHEN '0' THEN 'true' ELSE 'false' END, iif('0','true','false');
+} {false false}
+
+# EVIDENCE-OF: R-55532-10108 Values 1, 1.0, 0.1, -0.1 and '1english' are
+# considered to be true.
+#
+do_execsql_test e_expr-37.6 {
+ SELECT CASE WHEN 1 THEN 'true' ELSE 'false' END, iif(1,'true','false');
+} {true true}
+do_execsql_test e_expr-37.7 {
+ SELECT CASE WHEN 1.0 THEN 'true' ELSE 'false' END, iif(1.0,'true','false');
+} {true true}
+do_execsql_test e_expr-37.8 {
+ SELECT CASE WHEN 0.1 THEN 'true' ELSE 'false' END, iif(0.1,'true','false');
+} {true true}
+do_execsql_test e_expr-37.9 {
+ SELECT CASE WHEN -0.1 THEN 'true' ELSE 'false' END, iif(-0.1,'true','false');
+} {true true}
+do_execsql_test e_expr-37.10 {
+ SELECT CASE WHEN '1english' THEN 'true' ELSE 'false' END, iif('1engl','true','false');
+} {true true}
+
+
+finish_test
diff --git a/test/e_fkey.test b/test/e_fkey.test
new file mode 100644
index 0000000..3662a39
--- /dev/null
+++ b/test/e_fkey.test
@@ -0,0 +1,3047 @@
+# 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 [subst -nocommands {
+ set eqpres [list]
+ $db eval "$sql" {
+ lappend eqpres [set detail]
+ }
+ set eqpres
+ }]
+}
+
+proc do_detail_test {tn sql res} {
+ set normalres [list {*}$res]
+ uplevel [subst -nocommands {
+ do_test $tn {
+ eqp { $sql }
+ } {$normalres}
+ }]
+}
+
+###########################################################################
+### SECTION 2: Enabling Foreign Key Support
+###########################################################################
+
+#-------------------------------------------------------------------------
+# EVIDENCE-OF: R-37672-59189 In order to use foreign key constraints in
+# SQLite, the library must be compiled with neither
+# SQLITE_OMIT_FOREIGN_KEY nor 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-10109-20452 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 (2009-10-14) - 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-44261-39702 Foreign key constraints are disabled by
+# default (for backwards compatibility), so must be enabled separately
+# for each database connection.
+#
+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-08013-37737 The application 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 {UNIQUE constraint failed: artist.artistid}}
+ {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 {NOT NULL constraint failed: track.trackartist}}
+
+#-------------------------------------------------------------------------
+# 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 - ".*" referencing ".*"}/}} \
+ $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 - "child4" referencing "parent"}}
+do_test e_fkey-19.3 {
+ catchsql { INSERT INTO child5 VALUES('xxx', 6) }
+} {1 {foreign key mismatch - "child5" referencing "parent"}}
+do_test e_fkey-19.4 {
+ catchsql { INSERT INTO child6 VALUES(2, 3) }
+} {1 {foreign key mismatch - "child6" referencing "parent"}}
+do_test e_fkey-19.5 {
+ catchsql { INSERT INTO child7 VALUES(3) }
+} {1 {foreign key mismatch - "child7" referencing "parent"}}
+
+#-------------------------------------------------------------------------
+# 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-35763-48267 Foreign key DML errors are 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 - \"c2\" referencing \"p2\""
+ 4 c3 p3 "foreign key mismatch - \"c3\" referencing \"p3\""
+ 5 c4 p4 "foreign key mismatch - \"c4\" referencing \"p4\""
+ 6 c5 p5 "foreign key mismatch - \"c5\" referencing \"p5\""
+ 7 c6 p6 "foreign key mismatch - \"c6\" referencing \"p6\""
+ 8 c7 p7 "foreign key mismatch - \"c7\" referencing \"p7\""
+} {
+ 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 - "child9" referencing "parent2"}}
+do_test e_fkey-21.4 {
+ catchsql { INSERT INTO child9 VALUES('II') }
+} {1 {foreign key mismatch - "child9" referencing "parent2"}}
+do_test e_fkey-21.5 {
+ catchsql { INSERT INTO child9 VALUES(NULL) }
+} {1 {foreign key mismatch - "child9" referencing "parent2"}}
+do_test e_fkey-21.6 {
+ catchsql { INSERT INTO child10 VALUES('I', 'II', 'III') }
+} {1 {foreign key mismatch - "child10" referencing "parent2"}}
+do_test e_fkey-21.7 {
+ catchsql { INSERT INTO child10 VALUES(1, 2, 3) }
+} {1 {foreign key mismatch - "child10" referencing "parent2"}}
+do_test e_fkey-21.8 {
+ catchsql { INSERT INTO child10 VALUES(NULL, NULL, NULL) }
+} {1 {foreign key mismatch - "child10" referencing "parent2"}}
+
+#-------------------------------------------------------------------------
+# 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_detail_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 = ?;
+} {
+ {SCAN artist}
+ {SCAN track}
+}
+do_detail_test e_fkey-25.3 {
+ PRAGMA foreign_keys = ON;
+ EXPLAIN QUERY PLAN DELETE FROM artist WHERE 1;
+} {
+ {SCAN artist}
+ {SCAN track}
+}
+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_detail_test e_fkey-27.3 {
+ EXPLAIN QUERY PLAN UPDATE artist SET artistid = ?, artistname = ?
+} {
+ {SCAN artist}
+ {SEARCH track USING COVERING INDEX trackindex (trackartist=?)}
+ {SEARCH track USING COVERING INDEX trackindex (trackartist=?)}
+}
+do_detail_test e_fkey-27.4 {
+ EXPLAIN QUERY PLAN DELETE FROM artist
+} {
+ {SCAN artist}
+ {SEARCH track USING COVERING INDEX trackindex (trackartist=?)}
+}
+
+###########################################################################
+### 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 - "c" referencing "p"}}
+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 - "c" referencing "p"}}
+
+
+#-------------------------------------------------------------------------
+# 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-55814-22637 The "SET DEFAULT" actions are similar to
+# "SET NULL", except that each of the child key columns is set to
+# contain the column's 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 ORDER BY rowid;
+ }
+} {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 ORDER BY rowid;
+ }
+} {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 ORDER BY rowid; SELECT 'xxx' ; 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 ORDER BY rowid; SELECT 'xxx' ; 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); INSERT INTO tbl VALUES(1, 2); }
+ [list catchsql $zAlter]
+ " [lindex {{0 {}} {1 {Cannot add a REFERENCES column with non-NULL default value}}} $isError]
+
+}
+
+ifcapable altertable {
+ 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-43040-62530 The text of the child CREATE TABLE
+# statement or statements stored in the sqlite_schema table are modified
+# to reflect the new parent table name.
+#
+ifcapable altertable {
+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 - "c2" referencing "p"}}
+do_test e_fkey-60.5 {
+ execsql { DROP TABLE c1 }
+ catchsql { DELETE FROM p }
+} {1 {foreign key mismatch - "c2" referencing "p"}}
+do_test e_fkey-60.6 {
+ execsql { DROP TABLE c2 }
+ execsql { DELETE FROM p }
+} {}
+
+#-------------------------------------------------------------------------
+# Test that the special behaviors of ALTER and DROP TABLE are only
+# activated when foreign keys are enabled. Special behaviors 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.
+#
+ifcapable altertable {
+do_test e_fkey-61.1.1 {
+ drop_all_tables
+ execsql { CREATE TABLE t1(a, b) ; INSERT INTO t1 VALUES(1, 2) }
+ 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;
+ PRAGMA legacy_alter_table = ON;
+ 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 }
+ execsql { PRAGMA legacy_alter_table = OFF }
+} {}
+
+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 behavior: 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;
+ "
+}
+
+# If the current build was created using clang with the -fsanitize=address
+# switch, then the library uses considerably more stack space than usual.
+# So much more, that some of the following tests cause stack overflows
+# if they are run under this configuration.
+#
+if {[clang_sanitize_address]==0} {
+ 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-44355-00270 The PRAGMA recursive_triggers setting does
+# 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..c06feab
--- /dev/null
+++ b/test/e_fts3.test
@@ -0,0 +1,707 @@
+# 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}
+
+# 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') }
+sqlite3_db_config db DEFENSIVE 0
+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..7561e58
--- /dev/null
+++ b/test/e_insert.test
@@ -0,0 +1,431 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+# 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
+}
+
+# -- 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" {}
+ 71 "INSERT INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 72 "INSERT INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 73 "INSERT OR ROLLBACK INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 74 "INSERT OR ROLLBACK INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 75 "INSERT OR ABORT INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 76 "INSERT OR ABORT INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 77 "INSERT OR REPLACE INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 78 "INSERT OR REPLACE INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 79 "INSERT OR FAIL INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 80 "INSERT OR FAIL INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 81 "INSERT OR FAIL INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 82 "INSERT OR IGNORE INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 83 "REPLACE INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
+ 84 "REPLACE INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
+}
+
+delete_all_data
+
+# EVIDENCE-OF: R-21490-41092 The first form (with the "VALUES" keyword)
+# creates one or more new rows 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}
+
+ 3a "INSERT INTO a2(a) VALUES(3),(4)" {}
+ 3b "SELECT count(*) FROM a2" {4}
+}
+
+# EVIDENCE-OF: R-19218-01018 If the column-name list after table-name is
+# omitted then the number of values inserted into each row 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-29730-42609 In this case the result of evaluating the
+# left-most expression from each term of the VALUES list is inserted
+# into the left-most column of each new row, and so forth for each
+# subsequent expression.
+#
+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-21115-58321 If a column-name list is specified, then
+# the number of values in each term of the VALUE list 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-00267-47727 The initial "INSERT" keyword can be
+# replaced by "REPLACE" or "INSERT OR action" to specify an alternative
+# constraint conflict resolution algorithm to use during that 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')" {UNIQUE constraint failed: a4.c} 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')" {UNIQUE constraint failed: a4.c} 0 {1 a 3 a 2 b}
+ 1.6 "INSERT OR ABORT INTO a4 VALUES(1, 'd')"
+ {UNIQUE constraint failed: a4.c} 0 {1 a 3 a 2 b}
+ 1.7 "INSERT OR ROLLBACK INTO a4 VALUES(1, 'd')"
+ {UNIQUE constraint failed: a4.c} 1 {1 a 3 a 2 b}
+ 1.8 "INSERT INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'"
+ {UNIQUE constraint failed: a4.c} 1 {1 a 3 a 2 b}
+ 1.9 "INSERT OR FAIL INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'"
+ {UNIQUE constraint failed: a4.c} 1 {1 a 3 a 2 b 4 e}
+
+ 2.1 "INSERT INTO a4 VALUES(2,'f')"
+ {UNIQUE constraint failed: a4.c} 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-59829-49719 The optional "schema-name." prefix on the
+# table-name is supported 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..00291b7
--- /dev/null
+++ b/test/e_reindex.test
@@ -0,0 +1,299 @@
+# 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);
+} {}
+
+# -- 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" {}
+ 6 "REINDEX i1" {}
+ 7 "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.
+#
+sqlite3_db_config db DEFENSIVE 0
+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);
+
+ CREATE TABLE saved(a,b,c,d,e);
+ INSERT INTO saved SELECT * FROM sqlite_master WHERE type = 'index';
+ PRAGMA writable_schema = 1;
+ DELETE FROM sqlite_master WHERE type = 'index';
+} {}
+
+db close
+sqlite3 db test.db
+sqlite3_db_config db DEFENSIVE 0
+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;
+ INSERT INTO sqlite_master SELECT * FROM saved;
+ DROP TABLE saved;
+} {}
+
+db close
+sqlite3 db test.db
+do_execsql_test e_reindex-1.3 {
+ PRAGMA integrity_check;
+} [list \
+ {row 3 missing from index i2} \
+ {row 3 missing from index i1} \
+ {row 4 missing from index i2} \
+ {row 4 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-35892-30289 For a command of the form "REINDEX name", a
+# match against collation-name takes precedence over a match against
+# index-name or table-name.
+#
+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..f4bb1a4
--- /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-00634-08585 If a schema name is specified as part of an
+# object reference, it must be either "main", or "temp" or the
+# schema-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-17446-42210 Like other SQL identifiers, schema 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-14755-58619 If a schema name is specified, then only
+# that one schema 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..5a3f0d3
--- /dev/null
+++ b/test/e_select.test
@@ -0,0 +1,2174 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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.
+#
+# -- 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 {near "USING": syntax error}}
+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}}
+
+# -- 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" {}
+}
+
+
+# -- 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}
+}
+
+# -- syntax diagram join-source
+#
+# -- 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}
+}
+
+# -- 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}
+}
+
+# -- 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}
+}
+
+# -- 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-45424-07352 If there is only a single table or subquery
+# in 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-28355-09804 If there is more than one table or subquery
+# in FROM clause then the contents of all tables and/or subqueries 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-49872-03192 If the join-operator 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-25071-21202 The "CROSS JOIN" join operator produces the
+# same result 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 ORDER BY +c, +f
+} [list -60.06 {} {} -39.24 {} encompass -1 \
+ -60.06 {} {} alerting {} -93.79 {} \
+ -60.06 {} {} coldest -96 dramatists 82.3 \
+ -60.06 {} {} conducting -87.24 37.56 {} \
+ -60.06 {} {} presenting 51 reformation dignified \
+ -58 {} 1.21 -39.24 {} encompass -1 \
+ -58 {} 1.21 alerting {} -93.79 {} \
+ -58 {} 1.21 coldest -96 dramatists 82.3 \
+ -58 {} 1.21 conducting -87.24 37.56 {} \
+ -58 {} 1.21 presenting 51 reformation dignified \
+]
+# TODO: Come back and add a few more like the above.
+
+# EVIDENCE-OF: R-18439-38548 In other words, if the left-hand dataset
+# consists of Nleft rows of Mleft columns, and the right-hand dataset of
+# Nright rows of Mright columns, then the cartesian product is a dataset
+# of Nleft&times;Nright rows, each containing Mleft+Mright 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-38465-03616 If there is an ON clause then the ON
+# expression is evaluated for each row of the cartesian product as a
+# boolean expression. Only rows for which the expression evaluates to
+# true are included 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-49933-05137 If there is a USING clause then each of the
+# column names specified must exist in the datasets to both the left and
+# right of the join-operator.
+#
+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-22776-52830 For each pair of named columns, the
+# expression "lhs.X = rhs.X" is evaluated for each row of the cartesian
+# product as a boolean expression. Only rows for which all such
+# expressions evaluates to true are included 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-38422-04402 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-24610-05866 If the join-operator 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 does not match any row in the
+# right-hand dataset.
+#
+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-04932-55942 If the NATURAL keyword is in the
+# join-operator 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-60775-64916 If a WHERE clause is specified, the WHERE
+# expression is evaluated for each row in the input data as a boolean
+# expression. Only rows for which the WHERE clause expression evaluates
+# to true are included 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 ORDER BY +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 51.65 -59.58 belfries}
+ 7 "SELECT max(a), * FROM z1" {63 63 born -26}
+ 8 "SELECT *, min(a) FROM z1" {-5 {} 75 -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-38023-18396 It is an error to use a "*" or "alias.*"
+# expression in any context other 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" {1 1 4}
+ 2 "SELECT one, two, count(*) FROM a1 WHERE one<3" {1 1 2}
+ 3 "SELECT one, two, count(*) FROM a1 WHERE one>3" {4 10 1}
+ 4 "SELECT *, count(*) FROM a1 JOIN a2" {1 1 1 1 16}
+ 5 "SELECT *, sum(three) FROM a1 NATURAL JOIN a2" {1 1 1 3}
+ 6 "SELECT *, sum(three) FROM a1 NATURAL JOIN a2" {1 1 1 3}
+ 7 "SELECT group_concat(three, ''), a1.* FROM a1 NATURAL JOIN a2" {12 1 1}
+}
+
+# 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-40855-36147 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 according to the processing rules stated below for ORDER BY
+# expressions. 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 get 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" {
+ /#,# f 1 o #,# s #,# t/
+ }
+ 2 "SELECT group_concat(one), sum(one) FROM b1 GROUP BY (one>4)" {
+ 1,2,3,4 10 5,6,7 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" {/#,# 3 #,#/}
+ 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 j>6" {5 10}
+}
+
+# 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" {2 1 1 0}
+ 2 "SELECT i, j FROM c2 GROUP BY i%2 HAVING j<30" {2 1 1 0}
+ 3 "SELECT i, j FROM c2 GROUP BY i%2 HAVING j>30" {}
+ 4 "SELECT i, j FROM c2 GROUP BY i%2 HAVING j>30" {}
+ 5 "SELECT count(*), i, k FROM c2 NATURAL JOIN c3 GROUP BY substr(k, 1, 1)"
+ {2 4 beryllium 2 1 hydrogen 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-01256-01950 If neither ALL or DISTINCT are present,
+# then the behavior 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-47709-27231 The usual rules apply for selecting a
+# collation sequence to compare text values.
+#
+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-45440-25633 ORDER BY and LIMIT clauses may only occur
+# at the end of the entire compound SELECT, and then only if the final
+# element of the compound is not a VALUES clause.
+#
+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"
+ 8b "VALUES('8b') 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
+}
+foreach {tn select} {
+ 50 "SELECT * FROM j1 ORDER BY 1 UNION ALL SELECT * FROM j2,j3"
+ 51 "SELECT * FROM j1 LIMIT 1 UNION ALL SELECT * FROM j2,j3"
+ 52 "SELECT count(*) FROM j1 UNION ALL VALUES(11) ORDER BY 1"
+ 53 "SELECT count(*) FROM j1 UNION ALL VALUES(11) LIMIT 1"
+} {
+ do_test e_select-7.3.$tn { catch {execsql $select} msg } 1
+}
+
+# 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" {
+ /# 1 # 1 # 1 # 1
+ # 1 # 1 # 2 # 2/
+ }
+ 9 "SELECT z, x FROM d1 ORDER BY 1" {
+ /-20 1 -1 # -1 # 3 1
+ 7 1 8 1 93 # 93 #/
+ }
+}
+
+# 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" {
+ /# 1 # 1 # 1 # 1 # 1 # 1 # 2 # 2/
+ }
+ 4 "SELECT z AS x, x AS z FROM d1 ORDER BY x" {
+ /-20 1 -1 # -1 # 3 1 7 1 8 1 93 # 93 #/
+ }
+}
+
+# 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..8330894
--- /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-49872-03192 If the join-operator 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-25071-21202 The "CROSS JOIN" join operator produces the
+ # same result 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-38465-03616 If there is an ON clause then the ON
+ # expression is evaluated for each row of the cartesian product as a
+ # boolean expression. Only rows for which the expression evaluates to
+ # true are included 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-59237-46742 A subquery specified in the
+# table-or-subquery following the FROM clause in a simple SELECT
+# statement is handled as if it was a table containing the data returned
+# by executing the subquery statement.
+#
+# EVIDENCE-OF: R-27438-53558 Each column of the subquery has the
+# collation sequence and affinity of the corresponding expression in the
+# subquery 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_totalchanges.test b/test/e_totalchanges.test
new file mode 100644
index 0000000..bb5cfba
--- /dev/null
+++ b/test/e_totalchanges.test
@@ -0,0 +1,214 @@
+# 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_totalchanges
+
+# Like [do_execsql_test], except it appends the value returned by
+# [db total_changes] to the result of executing the SQL script.
+#
+proc do_tc_test {tn sql res} {
+ uplevel [list \
+ do_test $tn "concat \[execsql {$sql}\] \[db total_changes\]" $res
+ ]
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX t1_b ON t1(b);
+ CREATE TABLE t2(x, y, PRIMARY KEY(x, y)) WITHOUT ROWID;
+ CREATE INDEX t2_y ON t2(y);
+}
+
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-38914-26427 The total_changes() function returns the
+# number of row changes caused by INSERT, UPDATE or DELETE statements
+# since the current database connection was opened.
+#
+# 1.1.*: different types of I/U/D statements,
+# 1.2.*: trigger programs.
+#
+do_tc_test 1.1.1 {
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ UPDATE t1 SET a = a+1;
+ DELETE FROM t1;
+} {6}
+do_tc_test 1.1.2 {
+ DELETE FROM t1
+} {6}
+
+do_tc_test 1.1.3 {
+ WITH data(a,b) AS (
+ SELECT 0, 0 UNION ALL SELECT a+1, b+1 FROM data WHERE a<99
+ )
+ INSERT INTO t1 SELECT * FROM data;
+} {106}
+
+do_tc_test 1.1.4 {
+ INSERT INTO t2 SELECT * FROM t1 WHERE a<50;
+ UPDATE t2 SET y=y+1;
+} {206}
+
+do_tc_test 1.1.5 {
+ DELETE FROM t2 WHERE y<=25
+} {231}
+
+do_execsql_test 1.2.1 {
+ DELETE FROM t1;
+ DELETE FROM t2;
+}
+sqlite3 db test.db ; # To reset total_changes
+do_tc_test 1.2.2 {
+ CREATE TABLE log(detail);
+ CREATE TRIGGER t1_after_insert AFTER INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('inserted into t1');
+ END;
+
+ CREATE TRIGGER t1_before_delete BEFORE DELETE ON t1 BEGIN
+ INSERT INTO log VALUES('deleting from t1');
+ INSERT INTO log VALUES('here we go!');
+ END;
+
+ CREATE TRIGGER t1_after_update AFTER UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES('update');
+ DELETE FROM log;
+ END;
+
+ INSERT INTO t1 VALUES('a', 'b'); -- 1 + 1
+ UPDATE t1 SET b='c'; -- 1 + 1 + 2
+ DELETE FROM t1; -- 1 + 1 + 1
+} {9}
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-61766-15253 Executing any other type of SQL statement
+# does not affect the value returned by sqlite3_total_changes().
+ifcapable altertable {
+ do_tc_test 2.1 {
+ INSERT INTO t1 VALUES(1, 2), (3, 4);
+ INSERT INTO t2 VALUES(1, 2), (3, 4);
+ } {15}
+ do_tc_test 2.2 {
+ SELECT count(*) FROM t1;
+ } {2 15}
+ do_tc_test 2.3 {
+ CREATE TABLE t4(a, b);
+ ALTER TABLE t4 ADD COLUMN c;
+ CREATE INDEX i4 ON t4(c);
+ ALTER TABLE t4 RENAME TO t5;
+ ANALYZE;
+ BEGIN;
+ DROP TABLE t2;
+ ROLLBACK;
+ VACUUM;
+ } {15}
+}
+
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-36043-10590 Changes made as part of foreign key
+# actions are included in the count, but those made as part of REPLACE
+# constraint resolution are not.
+#
+# 3.1.*: foreign key actions
+# 3.2.*: REPLACE constraints.
+#
+sqlite3 db test.db ; # To reset total_changes
+do_tc_test 3.1.1 {
+ CREATE TABLE p1(c PRIMARY KEY, d);
+ CREATE TABLE c1(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE SET NULL);
+ CREATE TABLE c2(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE CASCADE);
+ CREATE TABLE c3(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE SET DEFAULT);
+
+ INSERT INTO p1 VALUES(1, 'one');
+ INSERT INTO p1 VALUES(2, 'two');
+ INSERT INTO p1 VALUES(3, 'three');
+ INSERT INTO p1 VALUES(4, 'four');
+
+ INSERT INTO c1 VALUES(1, 'i');
+ INSERT INTO c2 VALUES(2, 'ii');
+ INSERT INTO c3 VALUES(3, 'iii');
+ PRAGMA foreign_keys = ON;
+} {7}
+
+do_tc_test 3.1.2 { DELETE FROM p1 WHERE c=1; } {9}
+do_tc_test 3.1.3 { DELETE FROM p1 WHERE c=2; } {11}
+do_tc_test 3.1.4 { DELETE FROM p1 WHERE c=3; } {13}
+do_tc_test 3.1.5 { DELETE FROM p1 WHERE c=4; } {14} ; # only 1 this time.
+
+sqlite3 db test.db ; # To reset total_changes
+do_tc_test 3.1.6 {
+ DROP TABLE c1;
+ DROP TABLE c2;
+ DROP TABLE c3;
+ CREATE TABLE c1(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE SET NULL);
+ CREATE TABLE c2(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE CASCADE);
+ CREATE TABLE c3(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE SET DEFAULT);
+
+ INSERT INTO p1 VALUES(1, 'one');
+ INSERT INTO p1 VALUES(2, 'two');
+ INSERT INTO p1 VALUES(3, 'three');
+ INSERT INTO p1 VALUES(4, 'four');
+
+ INSERT INTO c1 VALUES(1, 'i');
+ INSERT INTO c2 VALUES(2, 'ii');
+ INSERT INTO c3 VALUES(3, 'iii');
+ PRAGMA foreign_keys = ON;
+} {7}
+
+do_tc_test 3.1.7 { UPDATE p1 SET c=c+4 WHERE c=1; } {9}
+do_tc_test 3.1.8 { UPDATE p1 SET c=c+4 WHERE c=2; } {11}
+do_tc_test 3.1.9 { UPDATE p1 SET c=c+4 WHERE c=3; } {13}
+do_tc_test 3.1.10 { UPDATE p1 SET c=c+4 WHERE c=4; } {14} ; # only 1 this time.
+
+sqlite3 db test.db ; # To reset total_changes
+do_tc_test 3.2.1 {
+ CREATE TABLE t3(a UNIQUE, b UNIQUE);
+ INSERT INTO t3 VALUES('one', 'one');
+ INSERT INTO t3 VALUES('two', 'two');
+ INSERT OR REPLACE INTO t3 VALUES('one', 'two');
+} {3}
+
+do_tc_test 3.2.2 {
+ INSERT INTO t3 VALUES('three', 'one');
+ UPDATE OR REPLACE t3 SET b='two' WHERE b='one';
+ SELECT * FROM t3;
+} {three two 5}
+
+#--------------------------------------------------------------------------
+# EVIDENCE-OF: R-54872-08741 Changes to a view that are intercepted by
+# INSTEAD OF triggers are not counted.
+#
+sqlite3 db test.db ; # To reset total_changes
+do_tc_test 4.1 {
+ CREATE TABLE t6(x);
+ CREATE VIEW v1 AS SELECT * FROM t6;
+ CREATE TRIGGER v1_tr1 INSTEAD OF INSERT ON v1 BEGIN
+ SELECT 'no-op';
+ END;
+
+ INSERT INTO v1 VALUES('a');
+ INSERT INTO v1 VALUES('b');
+} {0}
+do_tc_test 4.2 {
+ CREATE TRIGGER v1_tr2 INSTEAD OF INSERT ON v1 BEGIN
+ INSERT INTO t6 VALUES(new.x);
+ END;
+
+ INSERT INTO v1 VALUES('c');
+ INSERT INTO v1 VALUES('d');
+} {2}
+
+
+finish_test
diff --git a/test/e_update.test b/test/e_update.test
new file mode 100644
index 0000000..a13b059
--- /dev/null
+++ b/test/e_update.test
@@ -0,0 +1,605 @@
+# 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
+}
+
+# -- 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-58095-46013 Otherwise, the UPDATE affects only those
+# rows for which the WHERE clause 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-28518-13457 The optional "OR action" conflict clause
+# that follows the UPDATE keyword 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"
+ {UNIQUE constraint failed: t3.b} 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'"
+ {UNIQUE constraint failed: t3.b} 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"
+ {UNIQUE constraint failed: t3.b} 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"
+ {UNIQUE constraint failed: t3.b} 0 {2 three 3 one 4 four}
+
+ 8 "UPDATE OR ABORT t3 SET b='three' WHERE a=3"
+ {UNIQUE constraint failed: t3.b} 0 {2 three 3 one 4 four}
+
+ 9 "UPDATE OR FAIL t3 SET b='two'"
+ {UNIQUE constraint failed: t3.b} 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'"
+ {UNIQUE constraint failed: t3.b} 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-43190-62442 In other words, the schema-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';
+ SELECT 'temp', tbl_name FROM sqlite_temp_master WHERE type = 'table';
+ 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
+#
+# -- 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..b1fb479
--- /dev/null
+++ b/test/e_uri.test
@@ -0,0 +1,465 @@
+# 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
+do_not_use_codec
+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
+ SQLITE_OPEN_EXRESCODE
+ } tvfs]
+ set fileName [sqlite3_db_filename $DB main]
+ sqlite3_close $DB
+ forcedelete $fileName
+ 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-27632-24205 URI filename interpretation is enabled if
+# the SQLITE_OPEN_URI flag is set in the third 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-06842-00595 If the URI contains an authority, then it
+# must be either an empty string or the string "localhost".
+#
+# 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[test_pwd /]test.db} {not an error}
+ 2 {file://[test_pwd /]test.db} {not an error}
+ 3 {file://x[test_pwd /]test.db} {invalid uri authority: x}
+ 4 {file://invalid[test_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} {[test_pwd / {}]test.db {}}
+ 2 {file:test.db?a=b#abc} {[test_pwd / {}]test.db {a b}}
+ 3 {file:test.db?a=b#?c=d} {[test_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} {[test_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-44013-13102 The mode parameter may be set to either
+# "ro", "rw", "rwc", or "memory". 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}
+ 7 {file:test.db?mode=memory} {not an error}
+ 8 {file:test.db?mode=MEMORY} {no such access mode: MEMORY}
+" {
+ do_test 7.$tn { open_uri_error $uri } $error
+}
+
+
+# EVIDENCE-OF: R-43036-46756 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_open_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-20590-08726 It is an error to specify a value for the
+# mode parameter that is less restrictive than that specified by the
+# flags passed in the third parameter to sqlite3_open_v2().
+#
+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
+}
+
+ifcapable shared_cache {
+# 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-31773-41793 If sqlite3_open_v2() is used and the
+# "cache" parameter is present in a URI filename, its value overrides
+# any behavior 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
+} ;# End ifcapable shared_chache
+
+# 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..63bf7c1
--- /dev/null
+++ b/test/e_vacuum.test
@@ -0,0 +1,347 @@
+# 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
+}
+
+
+# -- 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&&compound {
+ 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}
+
+if {![nonzero_reserved_bytes]} {
+ # 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.
+ #
+ if {[wal_is_capable]} {
+ 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-40347-36128 By default, VACUUM operates on the main
+# database.
+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]
+
+# Vacuuming the main database does not affect aux
+do_execsql_test e_vacuum-2.1.3 { VACUUM } {}
+do_test e_vacuum-2.1.6 { expr {[file size test.db2]==$::original_size} } 1
+
+# EVIDENCE-OF: R-36598-60500 Attached databases can be vacuumed by
+# appending the appropriate schema-name to the VACUUM statement.
+do_execsql_test e_vacuum-2.1.7 { VACUUM aux; } {}
+do_test e_vacuum-2.1.8 { 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.
+#
+# Update 2019-01-07: Rowids are now preserved by VACUUM.
+#
+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}
+
+# Rowids are preserved if an INTEGER PRIMARY KEY is used
+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}
+
+# Rowid is preserved for VACUUM INTO
+do_execsql_test e_vacuum-3.1.5 {
+ DROP TABLE t5;
+ CREATE TABLE t5(x);
+ 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}
+forcedelete test2.db
+do_execsql_test e_vacuum-3.1.6 {
+ VACUUM INTO 'test2.db';
+ ATTACH 'test2.db' AS aux1;
+ SELECT rowid, x FROM aux1.t5;
+ DETACH aux1;
+} {1 x 3 z}
+
+# Rowids are not renumbered if the table being vacuumed
+# has indexes.
+do_execsql_test e_vacuum-3.1.7 {
+ DROP TABLE t5;
+ CREATE TABLE t5(x,y,z);
+ INSERT INTO t5(x) VALUES('x');
+ INSERT INTO t5(x) VALUES('y');
+ INSERT INTO t5(x) VALUES('z');
+ UPDATE t5 SET y=x, z=random();
+ DELETE FROM t5 WHERE x = 'y';
+ CREATE INDEX t5x ON t5(x);
+ CREATE UNIQUE INDEX t5y ON t5(y);
+ CREATE INDEX t5zxy ON t5(z,x,y);
+ SELECT rowid, x FROM t5;
+} {1 x 3 z}
+do_execsql_test e_vacuum-3.1.8 {
+ VACUUM;
+ SELECT rowid, x FROM t5;
+} {1 x 3 z}
+
+# EVIDENCE-OF: R-12218-18073 A VACUUM will fail if there is an open
+# transaction on the database connection that is attempting to run the
+# VACUUM.
+#
+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-55138-13241 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/e_wal.test b/test/e_wal.test
new file mode 100644
index 0000000..c9c5e96
--- /dev/null
+++ b/test/e_wal.test
@@ -0,0 +1,231 @@
+# 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_wal
+
+db close
+forcedelete test.db-shm
+testvfs oldvfs -iversion 1
+
+
+# EVIDENCE-OF: R-58297-14483 WAL databases can be created, read, and
+# written even if shared memory is unavailable as long as the
+# locking_mode is set to EXCLUSIVE before the first attempted access.
+#
+# EVIDENCE-OF: R-00449-33772 This feature allows WAL databases to be
+# created, read, and written by legacy VFSes that lack the "version 2"
+# shared-memory methods xShmMap, xShmLock, xShmBarrier, and xShmUnmap on
+# the sqlite3_io_methods object.
+#
+# 1.1: "create" tests.
+# 1.2: "read" tests.
+# 1.3: "write" tests.
+#
+# All three done with VFS "oldvfs", which has iVersion==1 and so does
+# not support shared memory.
+#
+sqlite3 db test.db -vfs oldvfs
+do_execsql_test 1.1.1 {
+ PRAGMA journal_mode = WAL;
+} {delete}
+do_execsql_test 1.1.2 {
+ PRAGMA locking_mode = EXCLUSIVE;
+ PRAGMA journal_mode = WAL;
+} {exclusive wal}
+do_execsql_test 1.1.3 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+} {}
+do_test 1.1.4 {
+ list [file exists test.db-shm] [file exists test.db-wal]
+} {0 1}
+
+do_test 1.2.1 {
+ db close
+ sqlite3 db test.db -vfs oldvfs
+ catchsql { SELECT * FROM t1 }
+} {1 {unable to open database file}}
+do_test 1.2.2 {
+ execsql { PRAGMA locking_mode = EXCLUSIVE }
+ execsql { SELECT * FROM t1 }
+} {1 2}
+do_test 1.2.3 {
+ list [file exists test.db-shm] [file exists test.db-wal]
+} {0 1}
+
+do_test 1.3.1 {
+ db close
+ sqlite3 db test.db -vfs oldvfs
+ catchsql { INSERT INTO t1 VALUES(3, 4) }
+} {1 {unable to open database file}}
+do_test 1.3.2 {
+ execsql { PRAGMA locking_mode = EXCLUSIVE }
+ execsql { INSERT INTO t1 VALUES(3, 4) }
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+do_test 1.3.3 {
+ list [file exists test.db-shm] [file exists test.db-wal]
+} {0 1}
+
+# EVIDENCE-OF: R-31969-57825 If EXCLUSIVE locking mode is set prior to
+# the first WAL-mode database access, then SQLite never attempts to call
+# any of the shared-memory methods and hence no shared-memory wal-index
+# is ever created.
+#
+db close
+sqlite3 db test.db
+do_execsql_test 2.1.1 {
+ PRAGMA locking_mode = EXCLUSIVE;
+ SELECT * FROM t1;
+} {exclusive 1 2 3 4}
+do_test 2.1.2 {
+ list [file exists test.db-shm] [file exists test.db-wal]
+} {0 1}
+
+# EVIDENCE-OF: R-36328-16367 In that case, the database connection
+# remains in EXCLUSIVE mode as long as the journal mode is WAL; attempts
+# to change the locking mode using "PRAGMA locking_mode=NORMAL;" are
+# no-ops.
+#
+do_execsql_test 2.2.1 {
+ PRAGMA locking_mode = NORMAL;
+ SELECT * FROM t1;
+} {exclusive 1 2 3 4}
+do_test 2.2.2 {
+ sqlite3 db2 test.db
+ catchsql {SELECT * FROM t1} db2
+} {1 {database is locked}}
+db2 close
+
+# EVIDENCE-OF: R-63522-46088 The only way to change out of EXCLUSIVE
+# locking mode is to first change out of WAL journal mode.
+#
+do_execsql_test 2.3.1 {
+ PRAGMA journal_mode = DELETE;
+ SELECT * FROM t1;
+} {delete 1 2 3 4}
+do_test 2.3.2 {
+ sqlite3 db2 test.db
+ catchsql {SELECT * FROM t1} db2
+} {1 {database is locked}}
+do_execsql_test 2.3.3 {
+ PRAGMA locking_mode = NORMAL;
+ SELECT * FROM t1;
+} {normal 1 2 3 4}
+do_test 2.3.4 {
+ sqlite3 db2 test.db
+ catchsql {SELECT * FROM t1} db2
+} {0 {1 2 3 4}}
+db2 close
+db close
+
+
+# EVIDENCE-OF: R-57239-11845 If NORMAL locking mode is in effect for the
+# first WAL-mode database access, then the shared-memory wal-index is
+# created.
+#
+do_test 3.0 {
+ sqlite3 db test.db
+ execsql { PRAGMA journal_mode = WAL }
+ db close
+} {}
+do_test 3.1 {
+ sqlite3 db test.db
+ execsql { SELECT * FROM t1 }
+ list [file exists test.db-shm] [file exists test.db-wal]
+} {1 1}
+
+# EVIDENCE-OF: R-13779-07711 As long as exactly one connection is using
+# a shared-memory wal-index, the locking mode can be changed freely
+# between NORMAL and EXCLUSIVE.
+#
+do_execsql_test 3.2.1 {
+ PRAGMA locking_mode = EXCLUSIVE;
+ PRAGMA locking_mode = NORMAL;
+ PRAGMA locking_mode = EXCLUSIVE;
+ INSERT INTO t1 VALUES(5, 6);
+} {exclusive normal exclusive}
+do_test 3.2.2 {
+ sqlite3 db2 test.db
+ catchsql { SELECT * FROM t1 } db2
+} {1 {database is locked}}
+
+# EVIDENCE-OF: R-10993-11647 It is only when the shared-memory wal-index
+# is omitted, when the locking mode is EXCLUSIVE prior to the first
+# WAL-mode database access, that the locking mode is stuck in EXCLUSIVE.
+#
+do_execsql_test 3.2.3 {
+ PRAGMA locking_mode = NORMAL;
+ SELECT * FROM t1;
+} {normal 1 2 3 4 5 6}
+do_test 3.2.4 {
+ catchsql { SELECT * FROM t1 } db2
+} {0 {1 2 3 4 5 6}}
+
+do_catchsql_test 3.2.5 {
+ PRAGMA locking_mode = EXCLUSIVE;
+ INSERT INTO t1 VALUES(7, 8);
+} {1 {database is locked}}
+
+db2 close
+
+# EVIDENCE-OF: R-46197-42811 This means that the underlying VFS must
+# support the "version 2" shared-memory.
+#
+# EVIDENCE-OF: R-55316-21772 If the VFS does not support shared-memory
+# methods, then the attempt to open a database that is already in WAL
+# mode, or the attempt convert a database into WAL mode, will fail.
+#
+db close
+do_test 3.4.1 {
+ sqlite3 db test.db -vfs oldvfs
+ catchsql { SELECT * FROM t1 }
+} {1 {unable to open database file}}
+db close
+do_test 3.4.2 {
+ forcedelete test.db2
+ sqlite3 db test.db2 -vfs oldvfs
+ catchsql { PRAGMA journal_mode = WAL }
+} {0 delete}
+db close
+
+
+# EVIDENCE-OF: R-45540-25505 To prevent older versions of SQLite (prior
+# to version 3.7.0, 2010-07-22) from trying to recover a WAL-mode
+# database (and making matters worse) the database file format version
+# numbers (bytes 18 and 19 in the database header) are increased from 1
+# to 2 in WAL mode.
+#
+reset_db
+do_execsql_test 4.1.1 { CREATE TABLE t1(x, y) }
+do_test 4.1.2 { hexio_read test.db 18 2 } {0101}
+do_execsql_test 4.1.3 { PRAGMA journal_mode = wAL } {wal}
+do_test 4.1.4 { hexio_read test.db 18 2 } {0202}
+
+
+# EVIDENCE-OF: R-02535-05811 One can explicitly change out of WAL mode
+# using a pragma such as this: PRAGMA journal_mode=DELETE;
+#
+do_execsql_test 4.2.1 { INSERT INTO t1 VALUES(1, 1); } {}
+do_test 4.2.2 { file exists test.db-wal } {1}
+do_execsql_test 4.2.3 { PRAGMA journal_mode = delete } {delete}
+do_test 4.2.4 { file exists test.db-wal } {0}
+
+# EVIDENCE-OF: R-60175-02388 Deliberately changing out of WAL mode
+# changes the database file format version numbers back to 1 so that
+# older versions of SQLite can once again access the database file.
+#
+do_test 4.3 { hexio_read test.db 18 2 } {0101}
+
+finish_test
diff --git a/test/e_walauto.test b/test/e_walauto.test
new file mode 100644
index 0000000..7665b1b
--- /dev/null
+++ b/test/e_walauto.test
@@ -0,0 +1,214 @@
+# 2014 December 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/wal_common.tcl
+set testprefix e_walauto
+
+# Do not run this test on OpenBSD, as it depends on read() and mmap both
+# accessing the same coherent view of the "test.db-shm" file. This doesn't
+# work on OpenBSD.
+#
+if {$tcl_platform(os) == "OpenBSD"} {
+ finish_test
+ return
+}
+
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+
+proc read_nbackfill {} {
+ seek $::shmfd 96
+ binary scan [read $::shmfd 4] n nBackfill
+ set nBackfill
+}
+proc read_mxframe {} {
+ seek $::shmfd 16
+ binary scan [read $::shmfd 4] n mxFrame
+ set mxFrame
+}
+
+# Assuming that the main db for database handle
+#
+proc do_autocommit_threshold_test {tn value} {
+
+ set nBackfillSaved [read_nbackfill]
+ while {1} {
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ if {[read_mxframe] >= $value} break
+ }
+
+ set nBackfillNew [read_nbackfill]
+ uplevel [list do_test $tn "expr $nBackfillNew > $nBackfillSaved" 1]
+}
+
+# EVIDENCE-OF: R-30135-06439 The wal_autocheckpoint pragma can be used
+# to invoke this interface from SQL.
+#
+# All tests in this file are run twice - once using the
+# sqlite3_wal_autocheckpoint() API, and once using "PRAGMA
+# wal_autocheckpoint".
+#
+foreach {tn code} {
+ 1 {
+ proc autocheckpoint {db value} {
+ uplevel [list $db eval "PRAGMA wal_autocheckpoint = $value"]
+ }
+ }
+
+ 2 {
+ proc autocheckpoint {db value} {
+ uplevel [list sqlite3_wal_autocheckpoint $db $value]
+ return $value
+ }
+ }
+} {
+
+ eval $code
+
+ reset_db
+ execsql { PRAGMA auto_vacuum = 0 }
+ do_execsql_test 1.$tn.0 { PRAGMA journal_mode = WAL } {wal}
+ do_execsql_test 1.$tn.1 { CREATE TABLE t1(a, b) }
+ set shmfd [open "test.db-shm" rb]
+
+ # EVIDENCE-OF: R-41531-51083 Every new database connection defaults to
+ # having the auto-checkpoint enabled with a threshold of 1000 or
+ # SQLITE_DEFAULT_WAL_AUTOCHECKPOINT pages.
+ #
+ do_autocommit_threshold_test 1.$tn.2 1000
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ do_autocommit_threshold_test 1.$tn.3 1000
+
+ # EVIDENCE-OF: R-38128-34102 The sqlite3_wal_autocheckpoint(D,N) is a
+ # wrapper around sqlite3_wal_hook() that causes any database on database
+ # connection D to automatically checkpoint after committing a
+ # transaction if there are N or more frames in the write-ahead log file.
+ #
+ do_test 1.$tn.4 {
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ autocheckpoint db 100
+ } {100}
+ do_autocommit_threshold_test 1.$tn.5 100
+
+ do_test 1.$tn.6 {
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ autocheckpoint db 500
+ } {500}
+ do_autocommit_threshold_test 1.$tn.7 500
+
+ # EVIDENCE-OF: R-26993-43540 Passing zero or a negative value as the
+ # nFrame parameter disables automatic checkpoints entirely.
+ #
+ do_test 1.$tn.7 {
+ autocheckpoint db 0 ;# Set to zero
+ for {set i 0} {$i < 10000} {incr i} {
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ }
+ expr {[file size test.db-wal] > (5 * 1024 * 1024)}
+ } 1
+ do_test 1.$tn.8 {
+ sqlite3_wal_checkpoint_v2 db truncate
+ file size test.db-wal
+ } 0
+ do_test 1.$tn.9 {
+ autocheckpoint db -4 ;# Set to a negative value
+ for {set i 0} {$i < 10000} {incr i} {
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ }
+ expr {[file size test.db-wal] > (5 * 1024 * 1024)}
+ } 1
+
+ # EVIDENCE-OF: R-10203-42688 The callback registered by this function
+ # replaces any existing callback registered using sqlite3_wal_hook().
+ #
+ set ::wal_hook_callback 0
+ proc wal_hook_callback {args} { incr ::wal_hook_callback ; return 0 }
+ do_test 1.$tn.10.1 {
+ db wal_hook wal_hook_callback
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ set ::wal_hook_callback
+ } 2
+ do_test 1.$tn.10.2 {
+ autocheckpoint db 100
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ set ::wal_hook_callback
+ } 2
+
+ # EVIDENCE-OF: R-17497-43474 Likewise, registering a callback using
+ # sqlite3_wal_hook() disables the automatic checkpoint mechanism
+ # configured by this function.
+ do_test 1.$tn.11.1 {
+ sqlite3_wal_checkpoint_v2 db truncate
+ file size test.db-wal
+ } 0
+ do_test 1.$tn.11.2 {
+ autocheckpoint db 100
+ for {set i 0} {$i < 1000} {incr i} {
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ }
+ expr {[file size test.db-wal] < (1 * 1024 * 1024)}
+ } 1
+ do_test 1.$tn.11.3 {
+ db wal_hook wal_hook_callback
+ for {set i 0} {$i < 1000} {incr i} {
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ }
+ expr {[file size test.db-wal] < (1 * 1024 * 1024)}
+ } 0
+
+ # EVIDENCE-OF: R-33080-59193 Checkpoints initiated by this mechanism
+ # are PASSIVE.
+ #
+ set ::busy_callback_count 0
+ proc busy_callback {args} {
+ incr ::busy_callback_count
+ return 0
+ }
+ do_test 1.$tn.12.1 {
+ sqlite3_wal_checkpoint_v2 db truncate
+ autocheckpoint db 100
+ db busy busy_callback
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ } {}
+ do_test 1.$tn.12.2 {
+ sqlite3 db2 test.db
+ db2 eval { BEGIN; SELECT * FROM t1 LIMIT 10; }
+ read_nbackfill
+ } {0}
+ do_test 1.$tn.12.3 {
+ for {set i 0} {$i < 1000} {incr i} {
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ }
+ read_nbackfill
+ } {2}
+ do_test 1.$tn.12.4 {
+ set ::busy_callback_count
+ } {0}
+ db2 close
+
+ do_test 1.$tn.12.5 {
+ db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }
+ read_nbackfill
+ } {1559}
+
+ db close
+ close $shmfd
+}
+
+finish_test
diff --git a/test/e_walckpt.test b/test/e_walckpt.test
new file mode 100644
index 0000000..3b1f3b0
--- /dev/null
+++ b/test/e_walckpt.test
@@ -0,0 +1,753 @@
+# 2014 December 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/wal_common.tcl
+set testprefix e_walckpt
+
+# The following two commands are used to determine if any of the files
+# "test.db", "test.db2" and "test.db3" are modified by a test case.
+#
+# The [save_db_hashes] command saves a hash of the current contents of
+# all three files in global variables. The [compare_db_hashes] compares
+# the current contents with the saved hashes and returns a list of the
+# files that have changed.
+#
+proc save_db_hashes {} {
+ global H
+ foreach f {test.db test.db2 test.db3} {
+ set H($f) 0
+ catch { set H($f) [md5file $f] }
+ }
+}
+proc compare_db_hashes {} {
+ global H
+ set ret [list]
+ foreach f {test.db test.db2 test.db3} {
+ set expect 0
+ catch { set expect [md5file $f] }
+ if {$H($f) != $expect} { lappend ret $f }
+ }
+ set ret
+}
+
+#-------------------------------------------------------------------------
+# All calls to the [sqlite3_wal_checkpoint_v2] command made within this
+# file use this wrapper. It's sole purpose is to throw an error if the
+# following requirement is violated:
+#
+# EVIDENCE-OF: R-60567-47780 Unless it returns SQLITE_MISUSE, the
+# sqlite3_wal_checkpoint_v2() interface sets the error information that
+# is queried by sqlite3_errcode() and sqlite3_errmsg().
+#
+proc wal_checkpoint_v2 {db args} {
+ set rc [catch {
+ uplevel sqlite3_wal_checkpoint_v2 $db $args
+ } msg]
+
+ set errcode "SQLITE_OK"
+ if {$rc} {
+ set errcode [lindex [split $msg " "] 0]
+ } elseif { [lindex $msg 0] } {
+ set errcode "SQLITE_BUSY"
+ }
+
+ if {$errcode != "SQLITE_MISUSE" && [sqlite3_errcode $db] != $errcode} {
+ error "sqlite3_errcode mismatch! (1) $errcode!=[sqlite3_errcode $db]"
+ }
+
+ if {$rc==0} {
+ return $msg
+ } else {
+ error $msg
+ }
+}
+
+
+# The following tests are run 3 times, each using a different method of
+# invoking a checkpoint:
+#
+# 1) Using sqlite3_wal_checkpoint_v2()
+# 2) Using "PRAGMA wal_checkpoint"
+# 3) Using sqlite3_wal_checkpoint() in place of checkpoint_v2(PASSIVE)
+#
+# Cases (2) and (3) are to show that the following statements are
+# correct, respectively:
+#
+# EVIDENCE-OF: R-36706-10507 The PRAGMA wal_checkpoint command can be
+# used to invoke this interface from SQL.
+#
+# EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is
+# equivalent to
+# sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0).
+#
+foreach {tn script} {
+ 1 {
+ proc checkpoint {db mode args} {
+ eval wal_checkpoint_v2 [list $db] [list $mode] $args
+ }
+ }
+
+ 2 {
+ proc checkpoint {db mode args} {
+ set sql "PRAGMA wal_checkpoint = $mode"
+ if {[llength $args] && [lindex $args 0]!=""} {
+ set sql "PRAGMA [lindex $args 0].wal_checkpoint = $mode"
+ }
+ set rc [catch { $db eval $sql } msg]
+ if {$rc} {
+ regsub {database} $msg {database:} msg
+ error "[sqlite3_errcode $db] - $msg"
+ }
+ set msg
+ }
+ }
+
+ 3 {
+ proc checkpoint {db mode args} {
+ if {$mode == "passive"} {
+ set rc [eval sqlite3_wal_checkpoint [list $db] $args]
+ if {$rc != "SQLITE_OK"} {
+ error "$rc - [sqlite3_errmsg $db]"
+ }
+ } else {
+ eval wal_checkpoint_v2 [list $db] [list $mode] $args
+ }
+ }
+ }
+
+} {
+
+ eval $script
+
+ reset_db
+ forcedelete test.db2 test.db3 test.db4
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ ATTACH 'test.db3' AS aux2;
+ ATTACH 'test.db4' AS aux3;
+ CREATE TABLE t1(x);
+ CREATE TABLE aux.t2(x);
+ CREATE TABLE aux2.t3(x);
+ CREATE TABLE aux3.t4(x);
+ PRAGMA main.journal_mode = WAL;
+ PRAGMA aux.journal_mode = WAL;
+ PRAGMA aux2.journal_mode = WAL;
+ /* Leave aux4 in rollback mode */
+ }
+
+ # EVIDENCE-OF: R-49787-09095 The sqlite3_wal_checkpoint_v2(D,X,M,L,C)
+ # interface runs a checkpoint operation on database X of database
+ # connection D in mode M. Status information is written back into
+ # integers pointed to by L and C.
+ #
+ # Tests 1, 2 and 3 below verify the "on database X" part of the
+ # above. Other parts of this requirement are tested below.
+ #
+ # EVIDENCE-OF: R-00653-06026 If parameter zDb is NULL or points to a
+ # zero length string, then the specified operation is attempted on all
+ # WAL databases attached to database connection db.
+ #
+ # Tests 4 and 5 below test this.
+ #
+ foreach {tn2 zDb dblist} {
+ 1 main test.db
+ 2 aux test.db2
+ 3 aux2 test.db3
+ 4 "" {test.db test.db2 test.db3}
+ 5 - {test.db test.db2 test.db3}
+ 6 temp {}
+ } {
+ do_test $tn.1.$tn2 {
+ execsql {
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ INSERT INTO t3 VALUES(3);
+ }
+ save_db_hashes
+
+ if {$zDb == "-"} {
+ checkpoint db passive
+ } else {
+ checkpoint db passive $zDb
+ }
+
+ compare_db_hashes
+ } $dblist
+ }
+
+ # EVIDENCE-OF: R-38207-48996 If zDb is not NULL (or a zero length
+ # string) and is not the name of any attached database, SQLITE_ERROR is
+ # returned to the caller.
+ do_test $tn.2.1 {
+ list [catch { checkpoint db passive notadb } msg] $msg
+ } {1 {SQLITE_ERROR - unknown database: notadb}}
+
+ # EVIDENCE-OF: R-14303-42483 If database zDb is the name of an attached
+ # database that is not in WAL mode, SQLITE_OK is returned and both
+ # *pnLog and *pnCkpt set to -1.
+ #
+ if {$tn==3} {
+ # With sqlite3_wal_checkpoint() the two output variables cannot be
+ # tested. So just test that no error is returned when attempting to
+ # checkpoint a db in rollback mode.
+ do_test $tn.2.2.a { checkpoint db passive aux3 } {}
+ } else {
+ do_test $tn.2.2.b { checkpoint db passive aux3 } {0 -1 -1}
+ }
+
+ # EVIDENCE-OF: R-62028-47212 All calls obtain an exclusive "checkpoint"
+ # lock on the database file.
+ db close
+ testvfs tvfs
+ tvfs filter xShmLock
+ tvfs script filelock
+ proc filelock {method file handle details} {
+ # Test for an exclusive checkpoint lock. A checkpoint lock locks a
+ # single byte starting at offset 1.
+ if {$details == "1 1 lock exclusive"} { set ::seen_checkpoint_lock 1 }
+ }
+ sqlite3 db test.db -vfs tvfs
+ do_test $tn.3.1 {
+ execsql { INSERT INTO t1 VALUES('xyz') }
+ unset -nocomplain ::seen_checkpoint_lock
+ checkpoint db passive
+ set ::seen_checkpoint_lock
+ } {1}
+ db close
+ tvfs delete
+ reset_db
+
+
+
+
+ #-----------------------------------------------------------------------
+ # EVIDENCE-OF: R-10421-19736 If any other process is running a
+ # checkpoint operation at the same time, the lock cannot be obtained and
+ # SQLITE_BUSY is returned.
+ #
+ # EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,
+ # it will not be invoked in this case.
+ #
+ testvfs tvfs
+ tvfs filter xWrite
+ sqlite3 db test.db -vfs tvfs
+ sqlite3 db2 test.db -vfs tvfs
+
+ do_test $tn.3.2.1 {
+ db2 eval {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ INSERT INTO t1 VALUES(5,6);
+ }
+ file size test.db-wal
+ } [wal_file_size 5 1024]
+
+
+ # Connection [db] runs a checkpoint. During this checkpoint, each
+ # time it calls xWrite() to write a page into the database file, we
+ # attempt to start a checkpoint using [db2]. According to the
+ # first requirement being tested, this should return SQLITE_BUSY. According
+ # to the second, the busy-handler belonging to [db2] should not be
+ # invoked.
+ #
+ set ::write_count 0
+ set ::write_errors [list]
+ proc busy_callback {args} {
+ lappend ::write_errors "busy handler called!"
+ }
+ proc write_callback {args} {
+ set rc [catch {checkpoint db2 passive} msg]
+ if {0==[regexp "database is locked" $msg] && $msg!="1 -1 -1"} {
+ lappend ::write_errors "$rc $msg"
+ }
+ incr ::write_count
+ }
+ db2 busy busy_callback
+ tvfs script write_callback
+
+ do_test $tn.3.2.2 {
+ db eval {SELECT * FROM sqlite_master}
+ checkpoint db full
+ set ::write_count
+ } {2}
+
+ do_test $tn.3.2.3 {
+ set ::write_errors
+ } {}
+
+ db close
+ db2 close
+ tvfs delete
+
+ proc busy_handler {mode busy_handler_mode n} {
+ incr ::busy_handler_counter
+ switch -- $busy_handler_mode {
+ 1 {
+ # Do nothing. Do not block.
+ return 1
+ }
+
+ 2 {
+ # Close first the reader, then later the writer. Give up before
+ # closing the [db6] reader.
+ if {$n==5} { catch {db2 eval commit} }
+ if {$n==10} { catch {db3 eval commit} }
+ if {$n==15} { return 1 }
+ return 0
+ }
+
+ 3 {
+ # Close first the writer, then later the reader. And finally the
+ # [db6] reader.
+ if {$n==5} { catch {db2 eval commit} }
+ if {$n==10} { catch {db3 eval commit} }
+ if {$n==15} { catch {db6 eval commit} }
+ return 0
+ }
+ }
+ }
+
+ foreach {mode busy_handler_mode} {
+ passive 1
+ full 1 full 2 full 3
+ restart 1 restart 2 restart 3
+ truncate 1 truncate 2 truncate 3
+ } {
+ set tp "$tn.$mode.$busy_handler_mode"
+
+ set ::sync_counter 0
+
+ # Set up a callback function for xSync and xWrite calls made during
+ # the checkpoint.
+ #
+ set ::checkpoint_ongoing 0
+ proc tvfs_callback {method args} {
+ if {$::checkpoint_ongoing==0} return
+
+ set tail [file tail [lindex $args 0]]
+ if {$method == "xSync" && $tail == "test.db"} {
+ incr ::sync_counter
+ }
+ if {$method == "xWrite" && $tail=="test.db"} {
+ if {$::write_ok < 0} {
+ set ::write_ok [expr ![catch {db5 eval { BEGIN IMMEDIATE }}]]
+ catch { db5 eval ROLLBACK }
+ }
+ if {$::read_ok < 0} {
+ set ::read_ok [expr ![catch {db5 eval { SELECT * FROM t1 }}]]
+ }
+
+ # If one has not already been opened, open a read-transaction using
+ # connection [db6]
+ catch { db6 eval { BEGIN ; SELECT * FROM sqlite_master } } msg
+ }
+ if {$method == "xShmLock" } {
+ set details [lindex $args 2]
+ if {$details == "0 1 lock exclusive"} { set ::seen_writer_lock 1 }
+ }
+ }
+
+ catch { db close }
+ forcedelete test.db
+ testvfs tvfs
+ sqlite3 db test.db -vfs tvfs
+ #tvfs filter xSync
+ tvfs script tvfs_callback
+
+ do_execsql_test $tp.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ } {wal}
+
+ # Open a reader on the current database snapshot.
+ do_test $tp.1 {
+ sqlite3 db2 test.db -vfs tvfs
+ execsql {
+ BEGIN;
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2;
+ } db2
+ } {1 2 3 4 5 6}
+
+ # Open a writer. Write a transaction. Then begin, but do not commit,
+ # a second transaction.
+ do_test $tp.2 {
+ sqlite3 db3 test.db -vfs tvfs
+ execsql {
+ INSERT INTO t2 VALUES(7, 8);
+ BEGIN;
+ INSERT INTO t2 VALUES(9, 10);
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2;
+ } db3
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ sqlite3 db5 test.db -vfs tvfs
+ sqlite3 db6 test.db -vfs tvfs
+
+ # Register a busy-handler with connection [db].
+ #
+ db busy [list busy_handler $mode $busy_handler_mode]
+ set ::sync_counter 0
+ set ::busy_handler_counter 0
+ set ::read_ok -1
+ set ::write_ok -1
+ set ::seen_writer_lock 0
+
+ set ::checkpoint_ongoing 1
+ do_test $tp.3 {
+ checkpoint db $mode main
+ set {} {}
+ } {}
+ set ::checkpoint_ongoing 0
+ set ::did_restart_blocking [expr {[catch {db6 eval commit}]}]
+
+ if { $mode=="passive" } {
+ # EVIDENCE-OF: R-16333-64433 Checkpoint as many frames as possible
+ # without waiting for any database readers or writers to finish, then
+ # sync the database file if all frames in the log were checkpointed.
+ #
+ # "As many frames as possible" means all but the last two transactions
+ # (the two that write to table t2, of which the scond is unfinished).
+ # So copying the db file only we see the t1 change, but not the t2
+ # modifications.
+ #
+ # The busy handler is not invoked (see below) and the db reader and
+ # writer are still active - so the checkpointer did not wait for either
+ # readers or writers. As a result the checkpoint was not finished and
+ # so the db file is not synced.
+ #
+ # EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
+ # in the SQLITE_CHECKPOINT_PASSIVE mode.
+ #
+ # It's not. Test case "$tp.6".
+ #
+ do_test $tp.4 {
+ forcecopy test.db abc.db
+ sqlite3 db4 abc.db
+ db4 eval { SELECT * FROM t1 UNION ALL SELECT * FROM t2 }
+ } {1 2 3 4 5 6}
+ do_test $tp.5 { set ::sync_counter } 0
+ do_test $tp.6 { set ::busy_handler_counter } 0
+ db4 close
+
+ db2 eval COMMIT
+ db3 eval COMMIT
+
+ # EVIDENCE-OF: R-65499-53765 On the other hand, passive mode might leave
+ # the checkpoint unfinished if there are concurrent readers or writers.
+ #
+ # The reader and writer have now dropped their locks. And so a
+ # checkpoint now is able to checkpoint more frames. Showing that the
+ # attempt above was left "unfinished".
+ #
+ # Also, because the checkpoint finishes this time, the db is synced.
+ # Which is part of R-16333-64433 above.
+ #
+ set ::checkpoint_ongoing 1
+ do_test $tp.7 {
+ checkpoint db $mode main
+ forcecopy test.db abc.db
+ sqlite3 db4 abc.db
+ db4 eval { SELECT * FROM t1 UNION ALL SELECT * FROM t2 }
+ } {1 2 3 4 5 6 7 8 9 10}
+ set ::checkpoint_ongoing 0
+ do_test $tp.7 { set ::sync_counter } 1
+ do_test $tp.8 { set ::busy_handler_counter } 0
+ db4 close
+ }
+
+ if { $mode=="full" || $mode=="restart" || $mode=="truncate" } {
+
+ # EVIDENCE-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and
+ # TRUNCATE modes also obtain the exclusive "writer" lock on the
+ # database file.
+ #
+ # Or at least attempts to obtain.
+ #
+ do_test $tp.9 {
+ set ::seen_writer_lock
+ } {1}
+
+ if {$busy_handler_mode==2 || $busy_handler_mode==3} {
+ # EVIDENCE-OF: R-59171-47567 This mode blocks (it invokes the
+ # busy-handler callback) until there is no database writer and all
+ # readers are reading from the most recent database snapshot.
+ #
+ # The test below shows that both the reader and writer have
+ # finished:
+ #
+ # Also restated by the following two. That both busy_handler_mode
+ # values 2 and 3 work show that both of the following are true - as
+ # they release the reader and writer transactions in different
+ # orders.
+ #
+ # EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained
+ # immediately, and a busy-handler is configured, it is invoked and the
+ # writer lock retried until either the busy-handler returns 0 or the
+ # lock is successfully obtained.
+ #
+ # EVIDENCE-OF: R-48107-00250 The busy-handler is also invoked while
+ # waiting for database readers as described above.
+ #
+ do_test $tp.7 {
+ list [catchsql COMMIT db2] [catchsql COMMIT db3]
+ } [list \
+ {1 {cannot commit - no transaction is active}} \
+ {1 {cannot commit - no transaction is active}} \
+ ]
+
+ # EVIDENCE-OF: R-29177-48281 It then checkpoints all frames in the log
+ # file and syncs the database file.
+ #
+ do_test $tp.8 {
+ forcecopy test.db abc.db
+ sqlite3 db4 abc.db
+ db4 eval { SELECT * FROM t1 UNION ALL SELECT * FROM t2 }
+ } {1 2 3 4 5 6 7 8 9 10}
+ do_test $tp.9 { set ::sync_counter } 1
+ db4 close
+
+ # EVIDENCE-OF: R-51867-44713 This mode blocks new database writers
+ # while it is pending, but new database readers are allowed to continue
+ # unimpeded.
+ #
+ # EVIDENCE-OF: R-47276-58266 Like SQLITE_CHECKPOINT_FULL, this mode
+ # blocks new database writer attempts while it is pending, but does not
+ # impede readers.
+ #
+ # The first of the above two refers to "full" mode. The second
+ # to "restart".
+ #
+ do_test $tp.10.1 {
+ list $::write_ok $::read_ok
+ } {0 1}
+
+ # EVIDENCE-OF: R-12410-31217 This mode works the same way as
+ # SQLITE_CHECKPOINT_FULL with the addition that after checkpointing the
+ # log file it blocks (calls the busy-handler callback) until all
+ # readers are reading from the database file only.
+ #
+ # The stuff above passed, so the first part of this requirement
+ # is met. The second part is tested below. If the checkpoint mode
+ # was "restart" or "truncate", then the busy-handler will have
+ # been called to block on wal-file readers.
+ #
+ do_test $tp.11 {
+ set ::did_restart_blocking
+ } [expr {($mode=="restart"||$mode=="truncate")&&$busy_handler_mode==3}]
+
+ # EVIDENCE-OF: R-44699-57140 This mode works the same way as
+ # SQLITE_CHECKPOINT_RESTART with the addition that it also truncates
+ # the log file to zero bytes just prior to a successful return.
+ if {$mode=="truncate" && $busy_handler_mode==3} {
+ do_test $tp.12 {
+ file size test.db-wal
+ } 0
+ }
+ } elseif {$busy_handler_mode==1} {
+
+ # EVIDENCE-OF: R-34519-06271 SQLITE_BUSY is returned in this case.
+ if {$tn!=2} {
+ # ($tn==2) is the loop that uses "PRAGMA wal_checkpoint"
+ do_test $tp.13 { sqlite3_errcode db } {SQLITE_BUSY}
+ }
+
+ # EVIDENCE-OF: R-49155-63541 If the busy-handler returns 0 before the
+ # writer lock is obtained or while waiting for database readers, the
+ # checkpoint operation proceeds from that point in the same way as
+ # SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible
+ # without blocking any further.
+ do_test $tp.14 {
+ forcecopy test.db abc.db
+ sqlite3 db4 abc.db
+ db4 eval { SELECT * FROM t1 UNION ALL SELECT * FROM t2 }
+ } {1 2 3 4 5 6}
+ do_test $tp.15 { set ::sync_counter } 0
+ do_test $tp.16 { set ::busy_handler_counter } 1
+ db4 close
+ }
+ }
+
+ db2 close
+ db3 close
+ db5 close
+ db6 close
+ }
+
+ db close
+ tvfs delete
+}
+
+#-----------------------------------------------------------------------
+# EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint
+# mode:
+#
+# Valid checkpoint modes are 0, 1, 2 and 3.
+#
+sqlite3 db test.db
+foreach {tn mode res} {
+ 0 -1001 {1 {SQLITE_MISUSE - not an error}}
+ 1 -1 {1 {SQLITE_MISUSE - not an error}}
+ 2 0 {0 {0 -1 -1}}
+ 3 1 {0 {0 -1 -1}}
+ 4 2 {0 {0 -1 -1}}
+ 5 3 {0 {0 -1 -1}}
+ 6 4 {1 {SQLITE_MISUSE - not an error}}
+ 7 114 {1 {SQLITE_MISUSE - not an error}}
+ 8 1000000 {1 {SQLITE_MISUSE - not an error}}
+} {
+ do_test 4.$tn {
+ list [catch "wal_checkpoint_v2 db $mode" msg] $msg
+ } $res
+}
+db close
+
+foreach tn {1 2 3} {
+ forcedelete test.db test.db2 test.db3
+ testvfs tvfs
+
+ sqlite3 db test.db -vfs tvfs
+ execsql {
+ ATTACH 'test.db2' AS aux2;
+ ATTACH 'test.db3' AS aux3;
+ PRAGMA main.journal_mode = WAL;
+ PRAGMA aux2.journal_mode = WAL;
+ PRAGMA aux3.journal_mode = WAL;
+
+ CREATE TABLE main.t1(x,y);
+ CREATE TABLE aux2.t2(x,y);
+ CREATE TABLE aux3.t3(x,y);
+
+ INSERT INTO t1 VALUES('a', 'b');
+ INSERT INTO t2 VALUES('a', 'b');
+ INSERT INTO t3 VALUES('a', 'b');
+ }
+ sqlite3 db2 test.db2 -vfs tvfs
+
+ switch -- $tn {
+ 1 {
+ # EVIDENCE-OF: R-41299-52117 If no error (SQLITE_BUSY or otherwise) is
+ # encountered while processing the attached databases, SQLITE_OK is
+ # returned.
+ do_test 5.$tn.1 {
+ lindex [wal_checkpoint_v2 db truncate] 0
+ } {0} ;# 0 -> SQLITE_OK
+ do_test 5.$tn.2 {
+ list [expr [file size test.db-wal]==0] \
+ [expr [file size test.db2-wal]==0] \
+ [expr [file size test.db3-wal]==0]
+ } {1 1 1}
+ }
+
+ 2 {
+ # EVIDENCE-OF: R-38578-34175 If an SQLITE_BUSY error is encountered when
+ # processing one or more of the attached WAL databases, the operation is
+ # still attempted on any remaining attached databases and SQLITE_BUSY is
+ # returned at the end.
+ db2 eval { BEGIN; INSERT INTO t2 VALUES('d', 'e'); }
+ do_test 5.$tn.1 {
+ lindex [wal_checkpoint_v2 db truncate] 0
+ } {1} ;# 1 -> SQLITE_BUSY
+ do_test 5.$tn.2 {
+ list [expr [file size test.db-wal]==0] \
+ [expr [file size test.db2-wal]==0] \
+ [expr [file size test.db3-wal]==0]
+ } {1 0 1}
+ db2 eval ROLLBACK
+ }
+
+ 3 {
+ # EVIDENCE-OF: R-38049-07913 If any other error occurs while processing
+ # an attached database, processing is abandoned and the error code is
+ # returned to the caller immediately.
+ tvfs filter xWrite
+ tvfs script inject_ioerr
+ proc inject_ioerr {method file args} {
+ if {[file tail $file]=="test.db2"} {
+ return "SQLITE_IOERR"
+ }
+ return 0
+ }
+ do_test 5.$tn.1 {
+ list [catch { wal_checkpoint_v2 db truncate } msg] $msg
+ } {1 {SQLITE_IOERR - disk I/O error}}
+ do_test 5.$tn.2 {
+ list [expr [file size test.db-wal]==0] \
+ [expr [file size test.db2-wal]==0] \
+ [expr [file size test.db3-wal]==0]
+ } {1 0 0}
+ tvfs script ""
+ }
+ }
+
+ db close
+ db2 close
+}
+
+reset_db
+sqlite3 db2 test.db
+
+do_test 6.1 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ file size test.db-wal
+} [wal_file_size 3 1024]
+
+do_test 6.2 {
+ db2 eval { BEGIN; SELECT * FROM t1; }
+ db eval { INSERT INTO t1 VALUES(3, 4) }
+ file size test.db-wal
+} [wal_file_size 4 1024]
+
+# At this point the log file contains 4 frames. 3 of which it should
+# be possible to checkpoint.
+#
+# EVIDENCE-OF: R-16642-42503 If pnLog is not NULL, then *pnLog is set to
+# the total number of frames in the log file or to -1 if the checkpoint
+# could not run because of an error or because the database is not in
+# WAL mode.
+#
+# EVIDENCE-OF: R-10514-25250 If pnCkpt is not NULL,then *pnCkpt is set
+# to the total number of checkpointed frames in the log file (including
+# any that were already checkpointed before the function was called) or
+# to -1 if the checkpoint could not run due to an error or because the
+# database is not in WAL mode.
+#
+do_test 6.4 {
+ lrange [wal_checkpoint_v2 db passive] 1 2
+} {4 3}
+
+# EVIDENCE-OF: R-37257-17813 Note that upon successful completion of an
+# SQLITE_CHECKPOINT_TRUNCATE, the log file will have been truncated to
+# zero bytes and so both *pnLog and *pnCkpt will be set to zero.
+#
+do_test 6.5 {
+ db2 eval COMMIT
+ wal_checkpoint_v2 db truncate
+} {0 0 0}
+
+
+
+finish_test
diff --git a/test/e_walhook.test b/test/e_walhook.test
new file mode 100644
index 0000000..b4a3156
--- /dev/null
+++ b/test/e_walhook.test
@@ -0,0 +1,200 @@
+# 2014 December 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/wal_common.tcl
+set testprefix e_walhook
+
+
+# EVIDENCE-OF: R-00752-43975 The sqlite3_wal_hook() function is used to
+# register a callback that is invoked each time data is committed to a
+# database in wal mode.
+#
+# 1.1: shows that the wal-hook is not invoked in rollback mode.
+# 1.2: but is invoked in wal mode.
+#
+set ::wal_hook_count 0
+proc my_wal_hook {args} {
+ incr ::wal_hook_count
+ return 0
+}
+
+do_test 1.1.1 {
+ db wal_hook my_wal_hook
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ }
+ set ::wal_hook_count
+} 0
+do_test 1.1.2 {
+ execsql { PRAGMA journal_mode = wal }
+ set ::wal_hook_count
+} 0
+
+do_test 1.3 {
+ execsql { INSERT INTO t1 VALUES(2) }
+ set wal_hook_count
+} 1
+
+do_test 1.4 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ COMMIT;
+ }
+ set wal_hook_count
+} 2
+
+# EVIDENCE-OF: R-65366-15139 The callback is invoked by SQLite after the
+# commit has taken place and the associated write-lock on the database
+# released
+#
+set ::read_ok 0
+proc my_wal_hook {args} {
+ sqlite3 db2 test.db
+ if {[db2 eval { SELECT * FROM t1 }] == "1 2 3 4 5"} {
+ set ::read_ok 1
+ }
+ db2 close
+}
+do_test 2.1 {
+ execsql { INSERT INTO t1 VALUES(5) }
+ set ::read_ok
+} 1
+
+# EVIDENCE-OF: R-44294-52863 The third parameter is the name of the
+# database that was written to - either "main" or the name of an
+# ATTACH-ed database.
+#
+# EVIDENCE-OF: R-18913-19355 The fourth parameter is the number of pages
+# currently in the write-ahead log file, including those that were just
+# committed.
+#
+set ::wal_hook_args [list]
+proc my_wal_hook {dbname nEntry} {
+ set ::wal_hook_args [list $dbname $nEntry]
+}
+forcedelete test.db2
+do_test 3.0 {
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t2(x);
+ PRAGMA aux.journal_mode = wal;
+ }
+} {wal}
+
+# Database "aux"
+do_test 3.1.1 {
+ set wal_hook_args [list]
+ execsql { INSERT INTO t2 VALUES('a') }
+} {}
+do_test 3.1.2 {
+ set wal_hook_args
+} [list aux [wal_frame_count test.db2-wal 1024]]
+
+# Database "main"
+do_test 3.2.1 {
+ set wal_hook_args [list]
+ execsql { INSERT INTO t1 VALUES(6) }
+} {}
+do_test 3.1.2 {
+ set wal_hook_args
+} [list main [wal_frame_count test.db-wal 1024]]
+
+# EVIDENCE-OF: R-14034-00929 If an error code is returned, that error
+# will propagate back up through the SQLite code base to cause the
+# statement that provoked the callback to report an error, though the
+# commit will have still occurred.
+#
+proc my_wal_hook {args} { return 1 ;# SQLITE_ERROR }
+do_catchsql_test 4.1 {
+ INSERT INTO t1 VALUES(7)
+} {1 {SQL logic error}}
+
+proc my_wal_hook {args} { return 5 ;# SQLITE_BUSY }
+do_catchsql_test 4.2 {
+ INSERT INTO t1 VALUES(8)
+} {1 {database is locked}}
+
+proc my_wal_hook {args} { return 14 ;# SQLITE_CANTOPEN }
+do_catchsql_test 4.3 {
+ INSERT INTO t1 VALUES(9)
+} {1 {unable to open database file}}
+
+do_execsql_test 4.4 {
+ SELECT * FROM t1
+} {1 2 3 4 5 6 7 8 9}
+
+# EVIDENCE-OF: R-10466-53920 Calling sqlite3_wal_hook() replaces any
+# previously registered write-ahead log callback.
+set ::old_wal_hook 0
+proc my_old_wal_hook {args} {
+ incr ::old_wal_hook
+ return 0
+}
+db wal_hook my_old_wal_hook
+do_test 5.1 {
+ execsql { INSERT INTO t1 VALUES(10) }
+ set ::old_wal_hook
+} {1}
+
+# Replace old_wal_hook. Observe that it is not invoked after it has
+# been replaced.
+proc my_new_wal_hook {args} { return 0 }
+db wal_hook my_new_wal_hook
+do_test 5.2 {
+ execsql { INSERT INTO t1 VALUES(11) }
+ set ::old_wal_hook
+} {1}
+
+
+
+# EVIDENCE-OF: R-57445-43425 Note that the sqlite3_wal_autocheckpoint()
+# interface and the wal_autocheckpoint pragma both invoke
+# sqlite3_wal_hook() and will overwrite any prior sqlite3_wal_hook()
+# settings.
+#
+set ::old_wal_hook 0
+proc my_old_wal_hook {args} { incr ::old_wal_hook ; return 0 }
+db wal_hook my_old_wal_hook
+do_test 6.1.1 {
+ execsql { INSERT INTO t1 VALUES(12) }
+ set ::old_wal_hook
+} {1}
+do_test 6.1.2 {
+ execsql { PRAGMA wal_autocheckpoint = 1000 }
+ execsql { INSERT INTO t1 VALUES(12) }
+ set ::old_wal_hook
+} {1}
+
+# EVIDENCE-OF: R-52629-38967 The first parameter passed to the callback
+# function when it is invoked is a copy of the third parameter passed to
+# sqlite3_wal_hook() when registering the callback.
+#
+# This is tricky to test using the tcl interface. However, the
+# mechanism used to invoke the tcl script registered as a wal-hook
+# depends on the context pointer being correctly passed through. And
+# since multiple different wal-hook scripts have been successfully
+# invoked by this test script, consider this tested.
+#
+# EVIDENCE-OF: R-23378-42536 The second is a copy of the database
+# handle.
+#
+# There is an assert() in the C wal-hook used by tclsqlite.c to
+# prove this. And that hook has been invoked multiple times when
+# running this script. So consider this requirement tested as well.
+#
+
+finish_test
diff --git a/test/emptytable.test b/test/emptytable.test
new file mode 100644
index 0000000..79cd16e
--- /dev/null
+++ b/test/emptytable.test
@@ -0,0 +1,50 @@
+# 2017-02-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 cases to show that a join involving an empty table is very fast.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+do_execsql_test emptytable-100 {
+ CREATE TABLE t1(a);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a) SELECT x FROM c;
+ CREATE TABLE empty(x);
+ SELECT count(*) FROM t1;
+} {100}
+
+# Interrupt queries after 1M cycles to prevent burning excess CPU
+proc stopDb {args} {
+ db interrupt
+}
+db progress 1000000 {stopDb}
+
+# Prior to the query planner optimization on 2017-02-15, this query would
+# take a ridiculous amount of time. If that optimization stops working,
+# the result here will be in interrupt for running too long.
+#
+do_catchsql_test emptytable-110 {
+ SELECT count(*) FROM t1, t1, t1, t1, t1, t1, empty;
+} {0 0}
+
+do_catchsql_test emptytable-120 {
+ SELECT count(*) FROM t1, t1 LEFT JOIN empty;
+} {0 10000}
+do_catchsql_test emptytable-121 {
+ SELECT count(*) FROM t1, t1 LEFT JOIN t1, empty;
+} {0 0}
+
+
+finish_test
diff --git a/test/enc.test b/test/enc.test
new file mode 100644
index 0000000..ffe2416
--- /dev/null
+++ b/test/enc.test
@@ -0,0 +1,252 @@
+# 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}
+
+#-------------------------------------------------------------------------
+reset_db
+forcedelete test.db2
+forcedelete test.db3
+
+do_execsql_test enc-12.0 {
+ PRAGMA encoding = 'utf-8';
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('a', 'b', 'c');
+ ATTACH 'test.db3' AS aux;
+ CREATE TABLE aux.t3(x, y, z);
+ INSERT INTO t3 VALUES('xxx', 'yyy', 'zzz');
+ PRAGMA encoding;
+} {UTF-8}
+
+do_test enc-12.1 {
+ sqlite3 db2 test.db2
+ db2 eval {
+ PRAGMA encoding = 'UTF-16le';
+ CREATE TABLE t2(d, e, f);
+ INSERT INTO t2 VALUES('d', 'e', 'f');
+ PRAGMA encoding;
+ }
+} {UTF-16le}
+
+do_test enc-12.2 {
+ db2 backup test.db
+ db2 close
+} {}
+
+do_catchsql_test enc-12.3 {
+ SELECT * FROM t2;
+} {1 {attached databases must use the same text encoding as main database}}
+
+db close
+sqlite3 db test.db3
+do_execsql_test enc-12.4 {
+ SELECT * FROM t3;
+ PRAGMA encoding = 'UTF-16le';
+ SELECT * FROM t3;
+} {xxx yyy zzz xxx yyy zzz}
+
+db close
+sqlite3 db test.db3
+breakpoint
+do_execsql_test enc-12.5 {
+ PRAGMA encoding = 'UTF-16le';
+ PRAGMA encoding;
+} {UTF-8}
+
+reset_db
+do_execsql_test enc-12.6 {
+ PRAGMA encoding = 'UTF-8';
+ CREATE TEMP TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('xxx', 'yyy', 'zzz');
+}
+do_test enc-12.7 {
+ sqlite3 db2 test.db2
+ db2 backup test.db
+ db2 close
+ db eval {
+ SELECT * FROM t1;
+ }
+} {xxx yyy zzz}
+do_catchsql_test enc-12.8 {
+ SELECT * FROM t2;
+ SELECT * FROM t1;
+} {1 {attached databases must use the same text encoding as main database}}
+
+db close
+sqlite3 db test.db
+do_execsql_test enc-12.9 {
+ CREATE TEMP TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('xxx', 'yyy', 'zzz');
+}
+do_execsql_test enc-12.10 {
+ SELECT * FROM t2;
+ SELECT * FROM t1;
+} {d e f xxx yyy zzz}
+
+finish_test
diff --git a/test/enc2.test b/test/enc2.test
new file mode 100644
index 0000000..81e7bfd
--- /dev/null
+++ b/test/enc2.test
@@ -0,0 +1,567 @@
+# 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).
+#
+
+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 behavior 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}
+
+# 2020-01-15 ticket a08879a4a476eea9
+# Do not allow a database connection encoding change unless *all*
+# attached databases are empty.
+#
+reset_db
+do_execsql_test enc2-11.10 {
+ PRAGMA encoding=UTF8;
+ CREATE TEMP TABLE t1(x);
+ INSERT INTO t1 VALUES('this is a test');
+ PRAGMA encoding=UTF16;
+ SELECT * FROM t1;
+} {{this is a test}}
+
+finish_test
diff --git a/test/enc3.test b/test/enc3.test
new file mode 100644
index 0000000..c9d39cb
--- /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.
+#
+
+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 CAST(a AS text) 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 CAST(a AS text) LIKE CAST(x'610062002500' AS text);
+ }
+ } {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..eda9577
--- /dev/null
+++ b/test/eqp.test
@@ -0,0 +1,850 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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 INT, b INT, ex TEXT);
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+ CREATE TABLE t2(a INT, b INT, ex TEXT);
+ CREATE TABLE t3(a INT, b INT, ex TEXT);
+}
+
+do_eqp_test 1.2 {
+ SELECT * FROM t2, t1 WHERE t1.a=1 OR t1.b=2;
+} {
+ QUERY PLAN
+ |--MULTI-INDEX OR
+ | |--INDEX 1
+ | | `--SEARCH t1 USING INDEX i1 (a=?)
+ | `--INDEX 2
+ | `--SEARCH t1 USING INDEX i2 (b=?)
+ `--SCAN t2
+}
+do_eqp_test 1.3 {
+ SELECT * FROM t2 CROSS JOIN t1 WHERE t1.a=1 OR t1.b=2;
+} {
+ QUERY PLAN
+ |--SCAN t2
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SEARCH t1 USING INDEX i1 (a=?)
+ `--INDEX 2
+ `--SEARCH t1 USING INDEX i2 (b=?)
+}
+do_eqp_test 1.3 {
+ SELECT a FROM t1 ORDER BY a
+} {
+ QUERY PLAN
+ `--SCAN t1 USING COVERING INDEX i1
+}
+do_eqp_test 1.4 {
+ SELECT a FROM t1 ORDER BY +a
+} {
+ QUERY PLAN
+ |--SCAN t1 USING COVERING INDEX i1
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_eqp_test 1.5 {
+ SELECT a FROM t1 WHERE a=4
+} {
+ QUERY PLAN
+ `--SEARCH t1 USING COVERING INDEX i1 (a=?)
+}
+do_eqp_test 1.6 {
+ SELECT DISTINCT count(*) FROM t3 GROUP BY a;
+} {
+ QUERY PLAN
+ |--SCAN t3
+ |--USE TEMP B-TREE FOR GROUP BY
+ `--USE TEMP B-TREE FOR DISTINCT
+}
+
+do_eqp_test 1.7.1 {
+ SELECT * FROM t3 JOIN (SELECT 1)
+} {
+ QUERY PLAN
+ |--MATERIALIZE (subquery-xxxxxx)
+ | `--SCAN CONSTANT ROW
+ |--SCAN (subquery-xxxxxx)
+ `--SCAN t3
+}
+do_eqp_test 1.7.2 {
+ SELECT * FROM t3 JOIN (SELECT 1) AS v1
+} {
+ QUERY PLAN
+ |--MATERIALIZE v1
+ | `--SCAN CONSTANT ROW
+ |--SCAN v1
+ `--SCAN t3
+}
+do_eqp_test 1.7.3 {
+ SELECT * FROM t3 AS xx JOIN (SELECT 1) AS yy
+} {
+ QUERY PLAN
+ |--MATERIALIZE yy
+ | `--SCAN CONSTANT ROW
+ |--SCAN yy
+ `--SCAN xx
+}
+
+
+do_eqp_test 1.8 {
+ SELECT * FROM t3 JOIN (SELECT 1 UNION SELECT 2)
+} {
+ QUERY PLAN
+ |--MATERIALIZE (subquery-xxxxxx)
+ | `--COMPOUND QUERY
+ | |--LEFT-MOST SUBQUERY
+ | | `--SCAN CONSTANT ROW
+ | `--UNION USING TEMP B-TREE
+ | `--SCAN CONSTANT ROW
+ |--SCAN (subquery-xxxxxx)
+ `--SCAN t3
+}
+do_eqp_test 1.9 {
+ SELECT * FROM t3 JOIN (SELECT 1 EXCEPT SELECT a FROM t3 LIMIT 17) AS abc
+} {
+ QUERY PLAN
+ |--MATERIALIZE abc
+ | `--COMPOUND QUERY
+ | |--LEFT-MOST SUBQUERY
+ | | `--SCAN CONSTANT ROW
+ | `--EXCEPT USING TEMP B-TREE
+ | `--SCAN t3
+ |--SCAN abc
+ `--SCAN t3
+}
+do_eqp_test 1.10 {
+ SELECT * FROM t3 JOIN (SELECT 1 INTERSECT SELECT a FROM t3 LIMIT 17) AS abc
+} {
+ QUERY PLAN
+ |--MATERIALIZE abc
+ | `--COMPOUND QUERY
+ | |--LEFT-MOST SUBQUERY
+ | | `--SCAN CONSTANT ROW
+ | `--INTERSECT USING TEMP B-TREE
+ | `--SCAN t3
+ |--SCAN abc
+ `--SCAN t3
+}
+
+do_eqp_test 1.11 {
+ SELECT * FROM t3 JOIN (SELECT 1 UNION ALL SELECT a FROM t3 LIMIT 17) abc
+} {
+ QUERY PLAN
+ |--MATERIALIZE abc
+ | `--COMPOUND QUERY
+ | |--LEFT-MOST SUBQUERY
+ | | `--SCAN CONSTANT ROW
+ | `--UNION ALL
+ | `--SCAN t3
+ |--SCAN abc
+ `--SCAN t3
+}
+
+#-------------------------------------------------------------------------
+# Test cases eqp-2.* - tests for single select statements.
+#
+drop_all_tables
+do_execsql_test 2.1 {
+ CREATE TABLE t1(x INT, y INT, ex TEXT);
+
+ CREATE TABLE t2(x INT, y INT, ex TEXT);
+ CREATE INDEX t2i1 ON t2(x);
+}
+
+det 2.2.1 "SELECT DISTINCT min(x), max(x) FROM t1 GROUP BY x ORDER BY 1" {
+ QUERY PLAN
+ |--SCAN t1
+ |--USE TEMP B-TREE FOR GROUP BY
+ |--USE TEMP B-TREE FOR DISTINCT
+ `--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" {
+ QUERY PLAN
+ |--SCAN t2 USING COVERING INDEX t2i1
+ |--USE TEMP B-TREE FOR DISTINCT
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+det 2.2.3 "SELECT DISTINCT * FROM t1" {
+ QUERY PLAN
+ |--SCAN t1
+ `--USE TEMP B-TREE FOR DISTINCT
+}
+det 2.2.4 "SELECT DISTINCT * FROM t1, t2" {
+ QUERY PLAN
+ |--SCAN t1
+ |--SCAN t2
+ `--USE TEMP B-TREE FOR DISTINCT
+}
+det 2.2.5 "SELECT DISTINCT * FROM t1, t2 ORDER BY t1.x" {
+ QUERY PLAN
+ |--SCAN t1
+ |--SCAN t2
+ |--USE TEMP B-TREE FOR DISTINCT
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+det 2.2.6 "SELECT DISTINCT t2.x FROM t1, t2 ORDER BY t2.x" {
+ QUERY PLAN
+ |--SCAN t2 USING COVERING INDEX t2i1
+ `--SCAN t1
+}
+
+det 2.3.1 "SELECT max(x) FROM t2" {
+ QUERY PLAN
+ `--SEARCH t2 USING COVERING INDEX t2i1
+}
+det 2.3.2 "SELECT min(x) FROM t2" {
+ QUERY PLAN
+ `--SEARCH t2 USING COVERING INDEX t2i1
+}
+det 2.3.3 "SELECT min(x), max(x) FROM t2" {
+ QUERY PLAN
+ `--SCAN t2 USING COVERING INDEX t2i1
+}
+
+det 2.4.1 "SELECT * FROM t1 WHERE rowid=?" {
+ QUERY PLAN
+ `--SEARCH t1 USING INTEGER PRIMARY KEY (rowid=?)
+}
+
+
+
+#-------------------------------------------------------------------------
+# 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;
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SCALAR SUBQUERY xxxxxx
+ `--SCAN sub
+}
+do_eqp_test 3.1.2 {
+ SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub);
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SCALAR SUBQUERY xxxxxx
+ `--SCAN sub
+}
+do_eqp_test 3.1.3 {
+ SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub ORDER BY y);
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SCALAR SUBQUERY xxxxxx
+ |--SCAN sub
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_eqp_test 3.1.4 {
+ SELECT * FROM t1 WHERE (SELECT x FROM t2 ORDER BY x);
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SCALAR SUBQUERY xxxxxx
+ `--SCAN t2 USING COVERING INDEX t2i1
+}
+
+det 3.2.1 {
+ SELECT * FROM (SELECT * FROM t1 ORDER BY x LIMIT 10) ORDER BY y LIMIT 5
+} {
+ QUERY PLAN
+ |--CO-ROUTINE (subquery-xxxxxx)
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ |--SCAN (subquery-xxxxxx)
+ `--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
+} {
+ QUERY PLAN
+ |--MATERIALIZE x1
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ |--MATERIALIZE x2
+ | `--SCAN t2 USING INDEX t2i1
+ |--SCAN x1
+ |--SCAN x2
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+det 3.3.1 {
+ SELECT * FROM t1 WHERE y IN (SELECT y FROM t2)
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--LIST SUBQUERY xxxxxx
+ `--SCAN t2
+}
+det 3.3.2 {
+ SELECT * FROM t1 WHERE y IN (SELECT y FROM t2 WHERE t1.x!=t2.x)
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--CORRELATED LIST SUBQUERY xxxxxx
+ `--SCAN t2
+}
+det 3.3.3 {
+ SELECT * FROM t1 WHERE EXISTS (SELECT y FROM t2 WHERE t1.x!=t2.x)
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--CORRELATED SCALAR SUBQUERY xxxxxx
+ `--SCAN t2
+}
+
+#-------------------------------------------------------------------------
+# Test cases eqp-4.* - tests for composite select statements.
+#
+do_eqp_test 4.1.1 {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2
+} {
+ QUERY PLAN
+ `--COMPOUND QUERY
+ |--LEFT-MOST SUBQUERY
+ | `--SCAN t1
+ `--UNION ALL
+ `--SCAN t2
+}
+do_eqp_test 4.1.2 {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 2
+} {
+ QUERY PLAN
+ `--MERGE (UNION ALL)
+ |--LEFT
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ `--RIGHT
+ |--SCAN t2
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_eqp_test 4.1.3 {
+ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 2
+} {
+ QUERY PLAN
+ `--MERGE (UNION)
+ |--LEFT
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ `--RIGHT
+ |--SCAN t2
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_eqp_test 4.1.4 {
+ SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 2
+} {
+ QUERY PLAN
+ `--MERGE (INTERSECT)
+ |--LEFT
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ `--RIGHT
+ |--SCAN t2
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_eqp_test 4.1.5 {
+ SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 2
+} {
+ QUERY PLAN
+ `--MERGE (EXCEPT)
+ |--LEFT
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ `--RIGHT
+ |--SCAN t2
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+do_eqp_test 4.2.2 {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 1
+} {
+ QUERY PLAN
+ `--MERGE (UNION ALL)
+ |--LEFT
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ `--RIGHT
+ `--SCAN t2 USING INDEX t2i1
+}
+do_eqp_test 4.2.3 {
+ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 1
+} {
+ QUERY PLAN
+ `--MERGE (UNION)
+ |--LEFT
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ `--RIGHT
+ |--SCAN t2 USING INDEX t2i1
+ `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY
+}
+do_eqp_test 4.2.4 {
+ SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 1
+} {
+ QUERY PLAN
+ `--MERGE (INTERSECT)
+ |--LEFT
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ `--RIGHT
+ |--SCAN t2 USING INDEX t2i1
+ `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY
+}
+do_eqp_test 4.2.5 {
+ SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 1
+} {
+ QUERY PLAN
+ `--MERGE (EXCEPT)
+ |--LEFT
+ | |--SCAN t1
+ | `--USE TEMP B-TREE FOR ORDER BY
+ `--RIGHT
+ |--SCAN t2 USING INDEX t2i1
+ `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY
+}
+
+do_eqp_test 4.3.1 {
+ SELECT x FROM t1 UNION SELECT x FROM t2
+} {
+ QUERY PLAN
+ `--COMPOUND QUERY
+ |--LEFT-MOST SUBQUERY
+ | `--SCAN t1
+ `--UNION USING TEMP B-TREE
+ `--SCAN t2 USING COVERING INDEX t2i1
+}
+
+do_eqp_test 4.3.2 {
+ SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1
+} {
+ QUERY PLAN
+ `--COMPOUND QUERY
+ |--LEFT-MOST SUBQUERY
+ | `--SCAN t1
+ |--UNION USING TEMP B-TREE
+ | `--SCAN t2 USING COVERING INDEX t2i1
+ `--UNION USING TEMP B-TREE
+ `--SCAN t1
+}
+do_eqp_test 4.3.3 {
+ SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1 ORDER BY 1
+} {
+ QUERY PLAN
+ `--MERGE (UNION)
+ |--LEFT
+ | `--MERGE (UNION)
+ | |--LEFT
+ | | |--SCAN t1
+ | | `--USE TEMP B-TREE FOR ORDER BY
+ | `--RIGHT
+ | `--SCAN t2 USING COVERING INDEX t2i1
+ `--RIGHT
+ |--SCAN t1
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+if 0 {
+#-------------------------------------------------------------------------
+# This next block of tests verifies that the examples on the
+# lang_explain.html page are correct.
+#
+drop_all_tables
+
+# XVIDENCE-OF: R-47779-47605 sqlite> EXPLAIN QUERY PLAN SELECT a, b
+# FROM t1 WHERE a=1;
+# 0|0|0|SCAN t1
+#
+do_execsql_test 5.1.0 { CREATE TABLE t1(a INT, b INT, ex TEXT) }
+det 5.1.1 "SELECT a, b FROM t1 WHERE a=1" {
+ 0 0 0 {SCAN t1}
+}
+
+# XVIDENCE-OF: R-55852-17599 sqlite> CREATE INDEX i1 ON t1(a);
+# sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1;
+# 0|0|0|SEARCH t1 USING INDEX i1
+#
+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 t1 USING INDEX i1 (a=?)}
+}
+
+# XVIDENCE-OF: R-21179-11011 sqlite> CREATE INDEX i2 ON t1(a, b);
+# sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1;
+# 0|0|0|SEARCH t1 USING COVERING INDEX i2 (a=?)
+#
+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 t1 USING COVERING INDEX i2 (a=?)}
+}
+
+# XVIDENCE-OF: R-09991-48941 sqlite> EXPLAIN QUERY PLAN
+# SELECT t1.*, t2.* FROM t1, t2 WHERE t1.a=1 AND t1.b>2;
+# 0|0|0|SEARCH t1 USING COVERING INDEX i2 (a=? AND b>?)
+# 0|1|1|SCAN t2
+#
+do_execsql_test 5.4.0 {CREATE TABLE t2(c INT, d INT, ex TEXT)}
+det 5.4.1 "SELECT t1.a, t2.c FROM t1, t2 WHERE t1.a=1 AND t1.b>2" {
+ 0 0 0 {SEARCH t1 USING COVERING INDEX i2 (a=? AND b>?)}
+ 0 1 1 {SCAN t2}
+}
+
+# XVIDENCE-OF: R-33626-61085 sqlite> EXPLAIN QUERY PLAN
+# SELECT t1.*, t2.* FROM t2, t1 WHERE t1.a=1 AND t1.b>2;
+# 0|0|1|SEARCH t1 USING COVERING INDEX i2 (a=? AND b>?)
+# 0|1|0|SCAN t2
+#
+det 5.5 "SELECT t1.a, t2.c FROM t2, t1 WHERE t1.a=1 AND t1.b>2" {
+ 0 0 1 {SEARCH t1 USING COVERING INDEX i2 (a=? AND b>?)}
+ 0 1 0 {SCAN t2}
+}
+
+# XVIDENCE-OF: R-04002-25654 sqlite> CREATE INDEX i3 ON t1(b);
+# sqlite> EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=1 OR b=2;
+# 0|0|0|SEARCH t1 USING COVERING INDEX i2 (a=?)
+# 0|0|0|SEARCH t1 USING INDEX i3 (b=?)
+#
+do_execsql_test 5.5.0 {CREATE INDEX i3 ON t1(b)}
+det 5.6.1 "SELECT a, b FROM t1 WHERE a=1 OR b=2" {
+ 0 0 0 {SEARCH t1 USING COVERING INDEX i2 (a=?)}
+ 0 0 0 {SEARCH t1 USING INDEX i3 (b=?)}
+}
+
+# XVIDENCE-OF: R-24577-38891 sqlite> EXPLAIN QUERY PLAN
+# SELECT c, d FROM t2 ORDER BY c;
+# 0|0|0|SCAN t2
+# 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 t2}
+ 0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+
+# XVIDENCE-OF: R-58157-12355 sqlite> CREATE INDEX i4 ON t2(c);
+# sqlite> EXPLAIN QUERY PLAN SELECT c, d FROM t2 ORDER BY c;
+# 0|0|0|SCAN t2 USING INDEX i4
+#
+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 t2 USING INDEX i4}
+}
+
+# XVIDENCE-OF: R-13931-10421 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 t2
+# 0|0|0|EXECUTE SCALAR SUBQUERY 1
+# 1|0|0|SEARCH t1 USING COVERING INDEX i2 (a=?)
+# 0|0|0|EXECUTE CORRELATED SCALAR SUBQUERY 2
+# 2|0|0|SEARCH t1 USING INDEX i3 (b=?)
+#
+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 t2 USING COVERING INDEX i4}
+ 0 0 0 {EXECUTE SCALAR SUBQUERY 1}
+ 1 0 0 {SEARCH t1 USING COVERING INDEX i2 (a=?)}
+ 0 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 2}
+ 2 0 0 {SEARCH t1 USING INDEX i3 (b=?)}
+}
+
+# XVIDENCE-OF: R-50892-45943 sqlite> EXPLAIN QUERY PLAN
+# SELECT count(*) FROM (SELECT max(b) AS x FROM t1 GROUP BY a) GROUP BY x;
+# 1|0|0|SCAN t1 USING COVERING INDEX i2
+# 0|0|0|SCAN SUBQUERY 1
+# 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 t1 USING COVERING INDEX i2}
+ 0 0 0 {SCAN SUBQUERY 1}
+ 0 0 0 {USE TEMP B-TREE FOR GROUP BY}
+}
+
+# XVIDENCE-OF: R-46219-33846 sqlite> EXPLAIN QUERY PLAN
+# SELECT * FROM (SELECT * FROM t2 WHERE c=1), t1;
+# 0|0|0|SEARCH t2 USING INDEX i4 (c=?)
+# 0|1|1|SCAN t1
+#
+det 5.11 "SELECT a, b FROM (SELECT * FROM t2 WHERE c=1), t1" {
+ 0 0 0 {SEARCH t2 USING INDEX i4 (c=?)}
+ 0 1 1 {SCAN t1 USING COVERING INDEX i2}
+}
+
+# XVIDENCE-OF: R-37879-39987 sqlite> EXPLAIN QUERY PLAN
+# SELECT a FROM t1 UNION SELECT c FROM t2;
+# 1|0|0|SCAN t1
+# 2|0|0|SCAN t2
+# 0|0|0|COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)
+#
+det 5.12 "SELECT a,b FROM t1 UNION SELECT c, 99 FROM t2" {
+ 1 0 0 {SCAN t1 USING COVERING INDEX i2}
+ 2 0 0 {SCAN t2 USING COVERING INDEX i4}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)}
+}
+
+# XVIDENCE-OF: R-44864-63011 sqlite> EXPLAIN QUERY PLAN
+# SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1;
+# 1|0|0|SCAN t1 USING COVERING INDEX i2
+# 2|0|0|SCAN t2 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 t1 USING COVERING INDEX i1}
+ 2 0 0 {SCAN t2}
+ 2 0 0 {USE TEMP B-TREE FOR ORDER BY}
+ 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)}
+}
+
+if {![nonzero_reserved_bytes]} {
+ #-------------------------------------------------------------------------
+ # 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, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1
+ } [string trimleft {
+1 0 0 SCAN t1 USING COVERING INDEX i2
+2 0 0 SCAN t2
+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 INT, b INT, ex CHAR(100));
+ CREATE TABLE t2(a INT, b INT, ex CHAR(100));
+ CREATE INDEX i1 ON t2(a);
+}
+
+det 7.1 "SELECT count(*) FROM t1" {
+ QUERY PLAN
+ `--SCAN t1
+}
+
+det 7.2 "SELECT count(*) FROM t2" {
+ QUERY PLAN
+ `--SCAN t2 USING COVERING INDEX i1
+}
+
+do_execsql_test 7.3 {
+ INSERT INTO t1(a,b) VALUES(1, 2);
+ INSERT INTO t1(a,b) VALUES(3, 4);
+
+ INSERT INTO t2(a,b) VALUES(1, 2);
+ INSERT INTO t2(a,b) VALUES(3, 4);
+ INSERT INTO t2(a,b) VALUES(5, 6);
+
+ ANALYZE;
+}
+
+db close
+sqlite3 db test.db
+
+det 7.4 "SELECT count(*) FROM t1" {
+ QUERY PLAN
+ `--SCAN t1
+}
+
+det 7.5 "SELECT count(*) FROM t2" {
+ QUERY PLAN
+ `--SCAN t2 USING COVERING INDEX i1
+}
+
+#-------------------------------------------------------------------------
+# The following tests - eqp-8.* - test that queries that use the OP_Count
+# optimization return something sensible with EQP.
+#
+drop_all_tables
+
+do_execsql_test 8.0 {
+ CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID;
+ CREATE TABLE t2(a, b, c);
+}
+
+det 8.1.1 "SELECT * FROM t2" {
+ QUERY PLAN
+ `--SCAN t2
+}
+
+det 8.1.2 "SELECT * FROM t2 WHERE rowid=?" {
+ QUERY PLAN
+ `--SEARCH t2 USING INTEGER PRIMARY KEY (rowid=?)
+}
+
+det 8.1.3 "SELECT count(*) FROM t2" {
+ QUERY PLAN
+ `--SCAN t2
+}
+
+det 8.2.1 "SELECT * FROM t1" {
+ QUERY PLAN
+ `--SCAN t1
+}
+
+det 8.2.2 "SELECT * FROM t1 WHERE b=?" {
+ QUERY PLAN
+ `--SEARCH t1 USING PRIMARY KEY (b=?)
+}
+
+det 8.2.3 "SELECT * FROM t1 WHERE b=? AND c=?" {
+ QUERY PLAN
+ `--SEARCH t1 USING PRIMARY KEY (b=? AND c=?)
+}
+
+det 8.2.4 "SELECT count(*) FROM t1" {
+ QUERY PLAN
+ `--SCAN t1
+}
+
+# 2018-08-16: While working on Fossil I discovered that EXPLAIN QUERY PLAN
+# did not describe IN operators implemented using a ROWID lookup. These
+# test cases ensure that problem as been fixed.
+#
+do_execsql_test 9.0 {
+ -- Schema from Fossil 2018-08-16
+ CREATE TABLE forumpost(
+ fpid INTEGER PRIMARY KEY,
+ froot INT,
+ fprev INT,
+ firt INT,
+ fmtime REAL
+ );
+ CREATE INDEX forumthread ON forumpost(froot,fmtime);
+ CREATE TABLE blob(
+ rid INTEGER PRIMARY KEY,
+ rcvid INTEGER,
+ size INTEGER,
+ uuid TEXT UNIQUE NOT NULL,
+ content BLOB,
+ CHECK( length(uuid)>=40 AND rid>0 )
+ );
+ CREATE TABLE event(
+ type TEXT,
+ mtime DATETIME,
+ objid INTEGER PRIMARY KEY,
+ tagid INTEGER,
+ uid INTEGER REFERENCES user,
+ bgcolor TEXT,
+ euser TEXT,
+ user TEXT,
+ ecomment TEXT,
+ comment TEXT,
+ brief TEXT,
+ omtime DATETIME
+ );
+ CREATE INDEX event_i1 ON event(mtime);
+ CREATE TABLE private(rid INTEGER PRIMARY KEY);
+}
+do_eqp_test 9.1 {
+ WITH thread(age,duration,cnt,root,last) AS (
+ SELECT
+ julianday('now') - max(fmtime) AS age,
+ max(fmtime) - min(fmtime) AS duration,
+ sum(fprev IS NULL) AS msg_count,
+ froot,
+ (SELECT fpid FROM forumpost
+ WHERE froot=x.froot
+ AND fpid NOT IN private
+ ORDER BY fmtime DESC LIMIT 1)
+ FROM forumpost AS x
+ WHERE fpid NOT IN private --- Ensure this table mentioned in EQP output!
+ GROUP BY froot
+ ORDER BY 1 LIMIT 26 OFFSET 5
+ )
+ SELECT
+ thread.age,
+ thread.duration,
+ thread.cnt,
+ blob.uuid,
+ substr(event.comment,instr(event.comment,':')+1)
+ FROM thread, blob, event
+ WHERE blob.rid=thread.last
+ AND event.objid=thread.last
+ ORDER BY 1;
+} {
+ QUERY PLAN
+ |--MATERIALIZE thread
+ | |--SCAN x USING INDEX forumthread
+ | |--USING ROWID SEARCH ON TABLE private FOR IN-OPERATOR
+ | |--CORRELATED SCALAR SUBQUERY xxxxxx
+ | | |--SEARCH forumpost USING COVERING INDEX forumthread (froot=?)
+ | | `--USING ROWID SEARCH ON TABLE private FOR IN-OPERATOR
+ | `--USE TEMP B-TREE FOR ORDER BY
+ |--SCAN thread
+ |--SEARCH blob USING INTEGER PRIMARY KEY (rowid=?)
+ |--SEARCH event USING INTEGER PRIMARY KEY (rowid=?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+finish_test
diff --git a/test/errmsg.test b/test/errmsg.test
new file mode 100644
index 0000000..f32da59
--- /dev/null
+++ b/test/errmsg.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.
+#
+#***********************************************************************
+# 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}
+ 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}
+ SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.b}
+}]
+verify_ex_errcode 2.2b SQLITE_CONSTRAINT_UNIQUE
+do_test 2.3 {
+ error_messages_v2 "INSERT INTO t1 VALUES('ghi', 'def')"
+} [list {*}{
+ SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.b}
+ SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.b}
+}]
+verify_ex_errcode 2.3b SQLITE_CONSTRAINT_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}
+ 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..159e875
--- /dev/null
+++ b/test/eval.test
@@ -0,0 +1,87 @@
+# 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
+ }
+} {}
+do_test eval-2.3 {
+ execsql {
+ 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
+ ORDER BY rowid DESC;
+ }
+} {4 {} {} 3 {} {} 2 {} {} 1 {} {}}
+do_test eval-2.4 {
+ 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..494ede7
--- /dev/null
+++ b/test/exclusive.test
@@ -0,0 +1,540 @@
+# 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"
+ && [atomic_batch_write test.db]==0
+} {
+
+ # 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.
+#
+if {[atomic_batch_write test.db]==0} {
+
+# 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.
+ # (2016-03-04) The statement-journal is now opened lazily
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds
+} {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.
+ # 2016-03-04: The statement-journal open is deferred
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds
+} {2}
+do_test exclusive-5.5 {
+ execsql {
+ COMMIT;
+ }
+ # Three files are still open: The db, journal and statement-journal.
+ # 2016-03-04: The statement-journal open is deferred
+ set sqlite_open_file_count
+ expr $sqlite_open_file_count-$extrafds
+} {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}
+
+# 2019-12-26 ticket fb3b3024ea238d5c
+if {[permutation]!="journaltest"} {
+ # The custom VFS used by the "journaltest" permutation cannot open the
+ # shared-memory file. So, while it is able to switch the db file to
+ # journal_mode=WAL when locking_mode=EXCLUSIVE, it can no longer access
+ # it once the locking_mode is changed back to NORMAL.
+ do_test exclusive-7.1 {
+ db close
+ forcedelete test.db test.db-journal test.db-wal
+ sqlite3 db test.db
+ # The following sequence of pragmas would trigger an assert()
+ # associated with Pager.changeCountDone inside of assert_pager_state(),
+ # prior to the fix.
+ db eval {
+ PRAGMA locking_mode = EXCLUSIVE;
+ PRAGMA journal_mode = WAL;
+ PRAGMA locking_mode = NORMAL;
+ PRAGMA user_version;
+ PRAGMA journal_mode = DELETE;
+ }
+ } {exclusive wal normal 0 delete}
+}
+
+
+} ;# atomic_batch_write==0
+
+finish_test
diff --git a/test/exclusive2.test b/test/exclusive2.test
new file mode 100644
index 0000000..92fcd76
--- /dev/null
+++ b/test/exclusive2.test
@@ -0,0 +1,324 @@
+# 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
+}
+
+# Tests in this file verify that locking_mode=exclusive causes SQLite to
+# use cached pages even if the database is changed on disk. This doesn't
+# work with mmap.
+if {[permutation]=="mmap"} {
+ 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, b) VALUES(randstr(10, 400), 0);
+ INSERT INTO t1(a, b) VALUES(randstr(10, 400), 0);
+ INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 FROM t1;
+ INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 FROM t1;
+ INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 FROM t1;
+ INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 FROM t1;
+ INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 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=0;
+ } 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 {
+ 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..5f9e36e
--- /dev/null
+++ b/test/exists.test
@@ -0,0 +1,199 @@
+# 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} {
+ if {![wal_is_capable] && $jm=="wal"} continue
+
+ 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..55b1dc9
--- /dev/null
+++ b/test/expr.test
@@ -0,0 +1,1084 @@
+# 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.111b {i1=NULL, i2=8} {i1 IS NOT DISTINCT FROM i2} 0
+test_expr expr-1.112 {i1=NULL, i2=NULL} {i1 IS i2} 1
+test_expr expr-1.112b {i1=NULL, i2=NULL} {i1 IS NOT DISTINCT FROM i2} 1
+test_expr expr-1.113 {i1=6, i2=NULL} {i1 IS i2} 0
+test_expr expr-1.113b {i1=6, i2=NULL} {i1 IS NOT DISTINCT FROM i2} 0
+test_expr expr-1.114 {i1=6, i2=6} {i1 IS i2} 1
+test_expr expr-1.114b {i1=6, i2=6} {i1 IS NOT DISTINCT FROM 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.115b {i1=NULL, i2=8} \
+ {CASE WHEN i1 IS NOT DISTINCT FROM 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.116b {i1=NULL, i2=NULL} \
+ {CASE WHEN i1 IS NOT DISTINCT FROM 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.117b {i1=6, i2=NULL} \
+ {CASE WHEN i1 IS NOT DISTINCT FROM 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.118b {i1=8, i2=8} \
+ {CASE WHEN i1 IS NOT DISTINCT FROM 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.119b {i1=NULL, i2=8} {i1 IS DISTINCT FROM i2} 1
+test_expr expr-1.120 {i1=NULL, i2=NULL} {i1 IS NOT i2} 0
+test_expr expr-1.120b {i1=NULL, i2=NULL} {i1 IS DISTINCT FROM i2} 0
+test_expr expr-1.121 {i1=6, i2=NULL} {i1 IS NOT i2} 1
+test_expr expr-1.121b {i1=6, i2=NULL} {i1 IS DISTINCT FROM i2} 1
+test_expr expr-1.122 {i1=6, i2=6} {i1 IS NOT i2} 0
+test_expr expr-1.122b {i1=6, i2=6} {i1 IS DISTINCT FROM 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.123b {i1=NULL, i2=8} \
+ {CASE WHEN i1 IS DISTINCT FROM 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.124b {i1=NULL, i2=NULL} \
+ {CASE WHEN i1 IS DISTINCT FROM 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.125b {i1=6, i2=NULL} \
+ {CASE WHEN i1 IS DISTINCT FROM 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
+test_expr expr-1.126b {i1=8, i2=8} \
+ {CASE WHEN i1 IS DISTINCT FROM i2 THEN 'yes' ELSE 'no' END} no
+
+do_catchsql_test expr-1.127 {
+ SELECT 1 IS #1;
+} {1 {near "#1": syntax error}}
+
+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
+
+ test_realnum_expr expr-1.260\
+ {i1=3037000500, i2=3037000500} {i1*i2} 9.22337203700025e+18
+ test_realnum_expr expr-1.261\
+ {i1=3037000500, i2=-3037000500} {i1*i2} -9.22337203700025e+18
+ test_realnum_expr expr-1.262\
+ {i1=-3037000500, i2=3037000500} {i1*i2} -9.22337203700025e+18
+ test_realnum_expr expr-1.263\
+ {i1=-3037000500, i2=-3037000500} {i1*i2} 9.22337203700025e+18
+
+ test_realnum_expr expr-1.264\
+ {i1=3037000500, i2=3037000499} {i1*i2} 9223372033963249500
+ test_realnum_expr expr-1.265\
+ {i1=3037000500, i2=-3037000499} {i1*i2} -9223372033963249500
+ test_realnum_expr expr-1.266\
+ {i1=-3037000500, i2=3037000499} {i1*i2} -9223372033963249500
+ test_realnum_expr expr-1.267\
+ {i1=-3037000500, i2=-3037000499} {i1*i2} 9223372033963249500
+
+ test_realnum_expr expr-1.268\
+ {i1=3037000499, i2=3037000500} {i1*i2} 9223372033963249500
+ test_realnum_expr expr-1.269\
+ {i1=3037000499, i2=-3037000500} {i1*i2} -9223372033963249500
+ test_realnum_expr expr-1.270\
+ {i1=-3037000499, i2=3037000500} {i1*i2} -9223372033963249500
+ test_realnum_expr expr-1.271\
+ {i1=-3037000499, i2=-3037000500} {i1*i2} 9223372033963249500
+
+}}
+
+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}
+
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+do_execsql_test expr-13.8 {
+ SELECT "" <= '';
+} {1}
+do_execsql_test expr-13.9 {
+ SELECT '' <= "";
+} {1}
+
+# 2018-02-26. Ticket https://www.sqlite.org/src/tktview/36fae083b450e3af85
+#
+do_execsql_test expr-14.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(0),(1),(NULL),(0.5),('1x'),('0x');
+ SELECT count(*) FROM t1
+ WHERE (x OR (8==9)) != (CASE WHEN x THEN 1 ELSE 0 END);
+} {0}
+do_execsql_test expr-14.2 {
+ SELECT count(*) FROM t1
+ WHERE (x OR (8==9)) != (NOT NOT x);
+} {0}
+do_execsql_test expr-14.3 {
+ SELECT sum(NOT x) FROM t1
+ WHERE x
+} {0}
+do_execsql_test expr-14.4 {
+ SELECT sum(CASE WHEN x THEN 0 ELSE 1 END) FROM t1
+ WHERE x
+} {0}
+
+
+foreach {tn val} [list 1 NaN 2 -NaN 3 NaN0 4 -NaN0 5 Inf 6 -Inf] {
+ do_execsql_test expr-15.$tn.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(0),(1),(NULL),(0.5),('1x'),('0x');
+ }
+
+ do_test expr-15.$tn.2 {
+ set ::STMT [sqlite3_prepare db "INSERT INTO t1 VALUES(?)" -1 TAIL]
+ sqlite3_bind_double $::STMT 1 $val
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+
+ do_execsql_test expr-15.$tn.3 {
+ SELECT count(*) FROM t1
+ WHERE (x OR (8==9)) != (CASE WHEN x THEN 1 ELSE 0 END);
+ } {0}
+
+ do_execsql_test expr-15.$tn.4 {
+ SELECT count(*) FROM t1
+ WHERE (x OR (8==9)) != (NOT NOT x);
+ } {0}
+
+ do_execsql_test expr-15.$tn.5 {
+ SELECT sum(NOT x) FROM t1
+ WHERE x
+ } {0}
+
+ do_execsql_test expr-15.$tn.6 {
+ SELECT sum(CASE WHEN x THEN 0 ELSE 1 END) FROM t1
+ WHERE x
+ } {0}
+}
+
+reset_db
+sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+do_execsql_test expr-16.1 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE dual(dummy);
+ INSERT INTO dual VALUES('X');
+} {}
+do_execsql_test expr-16.100 {
+ SELECT implies_nonnull_row( (b=1 AND 0)>(b=3 AND 0),a)
+ FROM dual LEFT JOIN t1;
+} {0}
+do_execsql_test expr-16.101 {
+ SELECT implies_nonnull_row( (b=1 AND 0)>(b=3 AND a=4),a)
+ FROM dual LEFT JOIN t1;
+} {1}
+do_execsql_test expr-16.102 {
+ SELECT implies_nonnull_row( (b=1 AND a=2)>(b=3 AND a=4),a)
+ FROM dual LEFT JOIN t1;
+} {1}
+
+finish_test
diff --git a/test/expr2.test b/test/expr2.test
new file mode 100644
index 0000000..3dfbadc
--- /dev/null
+++ b/test/expr2.test
@@ -0,0 +1,54 @@
+# 2019 May 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 file is testing expressions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix expr2
+
+do_execsql_test 1.0 {
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES ('val');
+}
+
+do_execsql_test 1.1 {
+ SELECT * FROM t0 WHERE (
+ ( (0 IS NOT FALSE) OR NOT (0 IS FALSE OR (t0.c0 = 1)) ) IS 0
+ )
+} {val}
+
+do_execsql_test 1.2.1 {
+ SELECT
+ ( (0 IS NOT FALSE) OR NOT (0 IS FALSE OR (t0.c0 = 1)) ) IS 0
+ FROM t0
+} {1}
+
+do_execsql_test 1.2.2 {
+ SELECT
+ ( (0 IS NOT FALSE) OR NOT (0 IS 0 OR (t0.c0 = 1)) ) IS 0
+ FROM t0
+} {1}
+
+do_execsql_test 1.3 {
+ SELECT ( (0 IS NOT FALSE) OR NOT (0 IS FALSE OR (t0.c0 = 1)) ) FROM t0
+} {0}
+
+do_execsql_test 1.4.1 {
+ SELECT (0 IS NOT FALSE) FROM t0
+} {0}
+do_execsql_test 1.4.2 {
+ SELECT NOT (0 IS FALSE OR (t0.c0 = 1)) FROM t0
+} {0}
+
+
+finish_test
diff --git a/test/exprfault.test b/test/exprfault.test
new file mode 100644
index 0000000..9e5977e
--- /dev/null
+++ b/test/exprfault.test
@@ -0,0 +1,35 @@
+# 2021 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix exprfault
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(d);
+}
+faultsim_save_and_close
+
+do_faultsim_test 1.1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT a = ( SELECT d FROM (SELECT d FROM t2) ) FROM t1
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+finish_test
diff --git a/test/extension01.test b/test/extension01.test
new file mode 100644
index 0000000..97b7726
--- /dev/null
+++ b/test/extension01.test
@@ -0,0 +1,83 @@
+# 2014-06-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 for various small extensions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix extension01
+
+load_static_extension db fileio
+do_test 1.0 {
+ forcedelete file1.txt
+ set out [open ./file1.txt wb]
+ puts -nonewline $out "This is a text file without a line ending"
+ close $out
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t1 VALUES(1, readfile('./file1.txt'));
+ SELECT * FROM t1;
+ }
+} {1 {This is a text file without a line ending}}
+do_test 1.1 {
+ forcedelete file2.txt
+ db nullvalue nil
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(2, readfile(NULL)),(3, readfile('file2.txt'));
+ SELECT a, b, typeof(b) FROM t1;
+ }
+} {2 nil null 3 nil null}
+
+do_test 1.2 {
+ db eval {
+ SELECT writefile('./file2.txt', 'A second test line');
+ }
+} {18}
+do_test 1.3 {
+ set in [open ./file2.txt rb]
+ set x [read $in]
+ close $in
+ list $x [file size file2.txt]
+} {{A second test line} 18}
+
+do_test 1.4 {
+ db eval {
+ SELECT writefile('./file2.txt', NULL);
+ }
+} {0}
+do_test 1.5 {
+ file size ./file2.txt
+} {0}
+
+do_test 1.6 {
+ if {$::tcl_platform(platform)=="unix"} {
+ file attributes ./file2.txt -permissions r--r--r--
+ } else {
+ file attributes ./file2.txt -readonly 1
+ }
+ db eval {
+ SELECT writefile('./file2.txt', 'Another test');
+ }
+} {nil}
+do_test 1.7 {
+ if {$::tcl_platform(platform)=="unix"} {
+ file attributes ./file2.txt -permissions rw-r--r--
+ } else {
+ file attributes ./file2.txt -readonly 0
+ }
+ db eval {
+ SELECT writefile(NULL, 'Another test');
+ }
+} {nil}
+
+finish_test
diff --git a/test/external_reader.test b/test/external_reader.test
new file mode 100644
index 0000000..5d29398
--- /dev/null
+++ b/test/external_reader.test
@@ -0,0 +1,74 @@
+# 2021 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+set testprefix external_reader
+
+ifcapable !wal {
+ finish_test
+ return
+}
+if {$::tcl_platform(platform)!="unix"} {
+ finish_test
+ return
+}
+
+do_multiclient_test tn {
+
+ set bExternal 1
+ if {[info commands db3]!=""} { set bExternal 0 }
+
+ do_test 1.$tn.0 {
+ sql1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ } {wal}
+
+ do_test 1.$tn.1 {
+ sql2 { SELECT * FROM t1 }
+ } {1 2}
+
+ do_test 1.$tn.2 {
+ code1 {
+ file_control_external_reader db
+ }
+ } {0}
+
+ do_test 1.$tn.3 {
+ sql2 {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {1 2}
+
+ do_test 1.$tn.4 {
+ code1 {
+ file_control_external_reader db
+ }
+ } $bExternal
+
+ do_test 1.$tn.5 {
+ sql2 { COMMIT }
+ } {}
+
+ do_test 1.$tn.6 {
+ code1 { file_control_external_reader db }
+ } 0
+
+}
+
+
+finish_test
diff --git a/test/extraquick.test b/test/extraquick.test
new file mode 100644
index 0000000..f453564
--- /dev/null
+++ b/test/extraquick.test
@@ -0,0 +1,16 @@
+#
+# May you do good 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 most of the tests run by veryquick.test except for those
+# that take a long time.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/permutations.test
+
+run_test_suite extraquick
+
+finish_test
diff --git a/test/fallocate.test b/test/fallocate.test
new file mode 100644
index 0000000..3e15448
--- /dev/null
+++ b/test/fallocate.test
@@ -0,0 +1,157 @@
+# 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"
+ && [permutation] != "atomic-batch-write"
+ && [atomic_batch_write test.db]==0
+ } {
+ hexio_get_int [hexio_read test.db-journal 16 4]
+ } else {
+ set {} 1024
+ }
+} {1024}
+do_test fallocate-1.8 { execsql { COMMIT } } {}
+
+do_test fallocate-1.8 {
+ set nPg [db one {PRAGMA page_count}]
+ set nFile [expr [file size test.db] / 1024]
+ list [expr $nPg<100] [expr $nFile>100]
+} {1 1}
+
+do_execsql_test fallocate-1.9 {
+ PRAGMA max_page_count = 100;
+} {100}
+
+#-------------------------------------------------------------------------
+# 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..460b71e
--- /dev/null
+++ b/test/filectrl.test
@@ -0,0 +1,72 @@
+# 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 [get_pwd]
+} {}
+do_test filectrl-1.6 {
+ sqlite3 db test.db
+ set fn [file_control_tempfilename db]
+ set fn
+} {/etilqs_/}
+db close
+forcedelete .test_control_lockproxy.db-conch test.proxy
+forcedelete test.db test2.db
+
+if {$tcl_platform(platform)=="windows"} {
+ do_test filectrl-2.1 {
+ sqlite3 db test2.db
+ set size [file size test2.db]
+ set handle [file_control_win32_get_handle db]
+ db close
+ forcedelete test2.db
+ list $size $handle [expr {$handle != 0}]
+ } {/^0 \{0 [0-9A-Fa-f]+\} 1$/}
+
+ do_test filectrl-2.2 {
+ sqlite3 db test2.db
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 (x) VALUES(RANDOMBLOB(1048576));
+ }
+ set size [file size test2.db]
+ set handle [file_control_win32_get_handle db]
+ db close
+ forcedelete test2.db
+ list $size $handle [expr {$handle != 0}]
+ } {/^1\d+ \{0 [0-9A-Fa-f]+\} 1$/}
+}
+
+finish_test
diff --git a/test/filefmt.test b/test/filefmt.test
new file mode 100644
index 0000000..b44ef8e
--- /dev/null
+++ b/test/filefmt.test
@@ -0,0 +1,254 @@
+# 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 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 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 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 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);
+} {}
+if {![nonzero_reserved_bytes]} {
+ 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);
+} {}
+if {![nonzero_reserved_bytes]} {
+ 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}
+
+reset_db
+do_execsql_test filefmt-4.1 {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(x, y);
+ CREATE TABLE t2(x, y);
+
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
+
+ INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
+ INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
+}
+
+do_test filefmt-4.2 {
+ sql36231 { INSERT INTO t2 SELECT * FROM t1 }
+} {}
+
+do_test filefmt-4.3 {
+ forcedelete bak.db
+ db backup bak.db
+} {}
+
+do_test filefmt-4.4 {
+ sqlite3 db2 bak.db
+ db2 eval { PRAGMA integrity_check }
+} {ok}
+db2 close
+
+finish_test
diff --git a/test/filter1.test b/test/filter1.test
new file mode 100644
index 0000000..7b2cf9c
--- /dev/null
+++ b/test/filter1.test
@@ -0,0 +1,225 @@
+# 2018 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 implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix filter1
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES(1), (2), (3), (4), (5), (6), (7), (8), (9);
+}
+
+do_execsql_test 1.1 { SELECT sum(a) FROM t1; } 45
+do_execsql_test 1.2 { SELECT sum(a) FILTER( WHERE a<5 ) FROM t1; } 10
+
+do_execsql_test 1.3 {
+ SELECT sum(a) FILTER( WHERE a>9 ),
+ sum(a) FILTER( WHERE a>8 ),
+ sum(a) FILTER( WHERE a>7 ),
+ sum(a) FILTER( WHERE a>6 ),
+ sum(a) FILTER( WHERE a>5 ),
+ sum(a) FILTER( WHERE a>4 ),
+ sum(a) FILTER( WHERE a>3 ),
+ sum(a) FILTER( WHERE a>2 ),
+ sum(a) FILTER( WHERE a>1 ),
+ sum(a) FILTER( WHERE a>0 )
+ FROM t1;
+} {{} 9 17 24 30 35 39 42 44 45}
+
+do_execsql_test 1.4 {
+ SELECT max(a) FILTER (WHERE (a % 2)==0) FROM t1
+} {8}
+
+do_execsql_test 1.5 {
+ SELECT min(a) FILTER (WHERE a>4) FROM t1
+} {5}
+
+do_execsql_test 1.6 {
+ SELECT count(*) FILTER (WHERE a!=5) FROM t1
+} {8}
+
+do_execsql_test 1.7 {
+ SELECT min(a) FILTER (WHERE a>3) FROM t1 GROUP BY (a%2) ORDER BY 1;
+} {4 5}
+
+do_execsql_test 1.8 {
+ CREATE VIEW vv AS
+ SELECT sum(a) FILTER( WHERE a>9 ),
+ sum(a) FILTER( WHERE a>8 ),
+ sum(a) FILTER( WHERE a>7 ),
+ sum(a) FILTER( WHERE a>6 ),
+ sum(a) FILTER( WHERE a>5 ),
+ sum(a) FILTER( WHERE a>4 ),
+ sum(a) FILTER( WHERE a>3 ),
+ sum(a) FILTER( WHERE a>2 ),
+ sum(a) FILTER( WHERE a>1 ),
+ sum(a) FILTER( WHERE a>0 )
+ FROM t1;
+ SELECT * FROM vv;
+} {{} 9 17 24 30 35 39 42 44 45}
+
+
+#-------------------------------------------------------------------------
+# Test some errors:
+#
+# .1 FILTER on a non-aggregate function,
+# .2 Window function in FILTER clause,
+# .3 Aggregate function in FILTER clause,
+#
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1), (2), (3), (4), (5), (6), (7), (8), (9);
+}
+
+do_catchsql_test 2.1 {
+ SELECT upper(a) FILTER (WHERE a=1) FROM t1
+} {1 {FILTER may not be used with non-aggregate upper()}}
+
+do_catchsql_test 2.2 {
+ SELECT sum(a) FILTER (WHERE 1 - max(a) OVER () > 0) FROM t1
+} {1 {misuse of window function max()}}
+
+do_catchsql_test 2.3 {
+ SELECT sum(a) FILTER (WHERE 1 - count(a)) FROM t1
+} {1 {misuse of aggregate function count()}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1, 1);
+}
+do_execsql_test 3.1 {
+ SELECT b, max(a) FILTER (WHERE b='x') FROM t1;
+} {1 {}}
+
+do_execsql_test 3.2 {
+ CREATE TABLE t2(a, b, c);
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(1, 3, 4);
+ INSERT INTO t2 VALUES(2, 5, 6);
+ INSERT INTO t2 VALUES(2, 7, 8);
+}
+do_execsql_test 3.3 {
+ SELECT a, c, max(b) FILTER (WHERE c='x') FROM t2 GROUP BY a;
+} {1 3 {} 2 6 {}}
+
+do_execsql_test 3.4 {
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(1, 5, 'x');
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(1, 4, 'x');
+ INSERT INTO t2 VALUES(2, 5, 6);
+ INSERT INTO t2 VALUES(2, 7, 8);
+}
+do_execsql_test 3.5 {
+ SELECT a, c, max(b) FILTER (WHERE c='x') FROM t2 GROUP BY a;
+} {1 x 5 2 6 {}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('a', 0, 5);
+ INSERT INTO t1 VALUES('a', 1, 10);
+ INSERT INTO t1 VALUES('a', 0, 15);
+
+ INSERT INTO t1 VALUES('b', 0, 5);
+ INSERT INTO t1 VALUES('b', 1, 1000);
+ INSERT INTO t1 VALUES('b', 0, 5);
+
+ INSERT INTO t1 VALUES('c', 0, 1);
+ INSERT INTO t1 VALUES('c', 1, 2);
+ INSERT INTO t1 VALUES('c', 0, 3);
+}
+
+do_execsql_test 4.1 {
+ SELECT avg(c) FILTER (WHERE b!=1) AS h FROM t1 GROUP BY a ORDER BY h;
+} {2.0 5.0 10.0}
+do_execsql_test 4.2 {
+ SELECT avg(c) FILTER (WHERE b!=1) AS h FROM t1 GROUP BY a ORDER BY (h+1.0);
+} {2.0 5.0 10.0}
+do_execsql_test 4.3 {
+ SELECT a, avg(c) FILTER (WHERE b!=1) AS h FROM t1 GROUP BY a ORDER BY avg(c);
+} {c 2.0 a 10.0 b 5.0}
+do_execsql_test 4.4 {
+ SELECT a, avg(c) FILTER (WHERE b!=1) FROM t1 GROUP BY a ORDER BY 2
+} {c 2.0 b 5.0 a 10.0}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(1, 3);
+}
+
+do_execsql_test 5.1 {
+ SELECT count(*) FILTER (WHERE b>2) FROM (SELECT * FROM t1)
+} {1}
+
+do_execsql_test 5.2 {
+ SELECT count(*) FILTER (WHERE b>2) OVER () FROM (SELECT * FROM t1)
+} {1 1}
+
+do_execsql_test 5.3 {
+ SELECT count(*) FILTER (WHERE b>2) OVER (ORDER BY b) FROM (SELECT * FROM t1)
+} {0 1}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 6.0 {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,1);
+ INSERT INTO t1 VALUES(2,2);
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(1,1);
+}
+
+do_execsql_test 6.1 {
+ SELECT (SELECT COUNT(a) FILTER(WHERE x) FROM t2) FROM t1;
+} {1 1}
+do_execsql_test 6.2 {
+ SELECT (SELECT COUNT(a+x) FROM t2) FROM t1;
+} {1 1}
+do_execsql_test 6.3 {
+ SELECT (SELECT COUNT(a) FROM t2) FROM t1;
+} {2}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(321, 100000);
+ INSERT INTO t1 VALUES(111, 110000);
+ INSERT INTO t1 VALUES(444, 120000);
+ INSERT INTO t1 VALUES(222, 130000);
+}
+
+do_execsql_test 7.1 {
+ SELECT max(a), max(a) FILTER (WHERE b<12345), b FROM t1;
+} {
+ 444 {} 120000
+}
+
+
+
+finish_test
diff --git a/test/filter2.tcl b/test/filter2.tcl
new file mode 100644
index 0000000..f3871f8
--- /dev/null
+++ b/test/filter2.tcl
@@ -0,0 +1,132 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+source [file join [file dirname $argv0] pg_common.tcl]
+
+#=========================================================================
+
+
+start_test filter2 "2019 July 2"
+
+ifcapable !windowfunc
+
+execsql_test 1.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER);
+ INSERT INTO t1 VALUES
+ (1, 7), (2, 3), (3, 5), (4, 30), (5, 26), (6, 23), (7, 27),
+ (8, 3), (9, 17), (10, 26), (11, 33), (12, 25), (13, NULL), (14, 47),
+ (15, 36), (16, 13), (17, 45), (18, 31), (19, 11), (20, 36), (21, 37),
+ (22, 21), (23, 22), (24, 14), (25, 16), (26, 3), (27, 7), (28, 29),
+ (29, 50), (30, 38), (31, 3), (32, 36), (33, 12), (34, 4), (35, 46),
+ (36, 3), (37, 48), (38, 23), (39, NULL), (40, 24), (41, 5), (42, 46),
+ (43, 11), (44, NULL), (45, 18), (46, 25), (47, 15), (48, 18), (49, 23);
+}
+
+execsql_test 1.1 { SELECT sum(b) FROM t1 }
+
+execsql_test 1.2 { SELECT sum(b) FILTER (WHERE a<10) FROM t1 }
+
+execsql_test 1.3 { SELECT count(DISTINCT b) FROM t1 }
+
+execsql_test 1.4 { SELECT count(DISTINCT b) FILTER (WHERE a!=19) FROM t1 }
+
+execsql_test 1.5 {
+ SELECT min(b) FILTER (WHERE a>19),
+ min(b) FILTER (WHERE a>0),
+ max(a+b) FILTER (WHERE a>19),
+ max(b+a) FILTER (WHERE a BETWEEN 10 AND 40)
+ FROM t1;
+}
+
+execsql_test 1.6 {
+ SELECT min(b),
+ min(b),
+ max(a+b),
+ max(b+a)
+ FROM t1
+ GROUP BY (a%10)
+ ORDER BY 1, 2, 3, 4;
+}
+
+execsql_test 1.7 {
+ SELECT min(b) FILTER (WHERE a>19),
+ min(b) FILTER (WHERE a>0),
+ max(a+b) FILTER (WHERE a>19),
+ max(b+a) FILTER (WHERE a BETWEEN 10 AND 40)
+ FROM t1
+ GROUP BY (a%10)
+ ORDER BY 1, 2, 3, 4;
+}
+
+execsql_test 1.8 {
+ SELECT sum(a+b) FILTER (WHERE a=NULL) FROM t1
+}
+
+execsql_test 1.9 {
+ SELECT (a%5) FROM t1 GROUP BY (a%5)
+ HAVING sum(b) FILTER (WHERE b<20) > 34
+ ORDER BY 1
+}
+
+execsql_test 1.10 {
+ SELECT (a%5), sum(b) FILTER (WHERE b<20) AS bbb
+ FROM t1
+ GROUP BY (a%5) HAVING sum(b) FILTER (WHERE b<20) >34
+ ORDER BY 1
+}
+
+execsql_test 1.11 {
+ SELECT (a%5), sum(b) FILTER (WHERE b<20) AS bbb
+ FROM t1
+ GROUP BY (a%5) HAVING sum(b) FILTER (WHERE b<20) >34
+ ORDER BY 2
+}
+
+execsql_test 1.12 {
+ SELECT (a%5),
+ sum(b) FILTER (WHERE b<20) AS bbb,
+ count(distinct b) FILTER (WHERE b<20 OR a=13) AS ccc
+ FROM t1 GROUP BY (a%5)
+ ORDER BY 2
+}
+
+execsql_test 1.13 {
+ SELECT
+ string_agg(CAST(b AS TEXT), '_') FILTER (WHERE b%2!=0),
+ string_agg(CAST(b AS TEXT), '_') FILTER (WHERE b%2!=1),
+ count(*) FILTER (WHERE b%2!=0),
+ count(*) FILTER (WHERE b%2!=1)
+ FROM t1;
+}
+
+execsql_float_test 1.14 {
+ SELECT
+ avg(b) FILTER (WHERE b>a),
+ avg(b) FILTER (WHERE b<a)
+ FROM t1 GROUP BY (a%2) ORDER BY 1,2;
+}
+
+execsql_test 1.15 {
+ SELECT
+ a/5,
+ sum(b) FILTER (WHERE a%5=0),
+ sum(b) FILTER (WHERE a%5=1),
+ sum(b) FILTER (WHERE a%5=2),
+ sum(b) FILTER (WHERE a%5=3),
+ sum(b) FILTER (WHERE a%5=4)
+ FROM t1 GROUP BY (a/5) ORDER BY 1;
+}
+
+finish_test
+
+
diff --git a/test/filter2.test b/test/filter2.test
new file mode 100644
index 0000000..21ee665
--- /dev/null
+++ b/test/filter2.test
@@ -0,0 +1,156 @@
+# 2019 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix filter2
+
+ifcapable !windowfunc { finish_test ; return }
+do_execsql_test 1.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER);
+ INSERT INTO t1 VALUES
+ (1, 7), (2, 3), (3, 5), (4, 30), (5, 26), (6, 23), (7, 27),
+ (8, 3), (9, 17), (10, 26), (11, 33), (12, 25), (13, NULL), (14, 47),
+ (15, 36), (16, 13), (17, 45), (18, 31), (19, 11), (20, 36), (21, 37),
+ (22, 21), (23, 22), (24, 14), (25, 16), (26, 3), (27, 7), (28, 29),
+ (29, 50), (30, 38), (31, 3), (32, 36), (33, 12), (34, 4), (35, 46),
+ (36, 3), (37, 48), (38, 23), (39, NULL), (40, 24), (41, 5), (42, 46),
+ (43, 11), (44, NULL), (45, 18), (46, 25), (47, 15), (48, 18), (49, 23);
+} {}
+
+do_execsql_test 1.1 {
+ SELECT sum(b) FROM t1
+} {1041}
+
+do_execsql_test 1.2 {
+ SELECT sum(b) FILTER (WHERE a<10) FROM t1
+} {141}
+
+do_execsql_test 1.3 {
+ SELECT count(DISTINCT b) FROM t1
+} {31}
+
+do_execsql_test 1.4 {
+ SELECT count(DISTINCT b) FILTER (WHERE a!=19) FROM t1
+} {31}
+
+do_execsql_test 1.5 {
+ SELECT min(b) FILTER (WHERE a>19),
+ min(b) FILTER (WHERE a>0),
+ max(a+b) FILTER (WHERE a>19),
+ max(b+a) FILTER (WHERE a BETWEEN 10 AND 40)
+ FROM t1;
+} {3 3 88 85}
+
+do_execsql_test 1.6 {
+ SELECT min(b),
+ min(b),
+ max(a+b),
+ max(b+a)
+ FROM t1
+ GROUP BY (a%10)
+ ORDER BY 1, 2, 3, 4;
+} {3 3 58 58 3 3 66 66 3 3 71 71 3 3 88 88 4 4 61 61 5 5 54 54
+ 7 7 85 85 11 11 79 79 16 16 81 81 24 24 68 68}
+
+do_execsql_test 1.7 {
+ SELECT min(b) FILTER (WHERE a>19),
+ min(b) FILTER (WHERE a>0),
+ max(a+b) FILTER (WHERE a>19),
+ max(b+a) FILTER (WHERE a BETWEEN 10 AND 40)
+ FROM t1
+ GROUP BY (a%10)
+ ORDER BY 1, 2, 3, 4;
+} {3 3 58 58 3 3 71 39 4 4 38 61 7 7 85 85 11 5 54 45 16 16 81 81
+ 18 3 66 61 21 3 88 68 23 11 79 79 24 24 68 68}
+
+do_execsql_test 1.8 {
+ SELECT sum(a+b) FILTER (WHERE a=NULL) FROM t1
+} {{}}
+
+do_execsql_test 1.9 {
+ SELECT (a%5) FROM t1 GROUP BY (a%5)
+ HAVING sum(b) FILTER (WHERE b<20) > 34
+ ORDER BY 1
+} {3 4}
+
+do_execsql_test 1.10 {
+ SELECT (a%5), sum(b) FILTER (WHERE b<20) AS bbb
+ FROM t1
+ GROUP BY (a%5) HAVING sum(b) FILTER (WHERE b<20) >34
+ ORDER BY 1
+} {3 49 4 46}
+
+do_execsql_test 1.11 {
+ SELECT (a%5), sum(b) FILTER (WHERE b<20) AS bbb
+ FROM t1
+ GROUP BY (a%5) HAVING sum(b) FILTER (WHERE b<20) >34
+ ORDER BY 2
+} {4 46 3 49}
+
+do_execsql_test 1.12 {
+ SELECT (a%5),
+ sum(b) FILTER (WHERE b<20) AS bbb,
+ count(distinct b) FILTER (WHERE b<20 OR a=13) AS ccc
+ FROM t1 GROUP BY (a%5)
+ ORDER BY 2
+} {2 25 3 0 34 2 1 34 4 4 46 4 3 49 5}
+
+do_execsql_test 1.13 {
+ SELECT
+ group_concat(CAST(b AS TEXT), '_') FILTER (WHERE b%2!=0),
+ group_concat(CAST(b AS TEXT), '_') FILTER (WHERE b%2!=1),
+ count(*) FILTER (WHERE b%2!=0),
+ count(*) FILTER (WHERE b%2!=1)
+ FROM t1;
+} {7_3_5_23_27_3_17_33_25_47_13_45_31_11_37_21_3_7_29_3_3_23_5_11_25_15_23 30_26_26_36_36_22_14_16_50_38_36_12_4_46_48_24_46_18_18 27 19}
+
+
+do_test 1.14 {
+ set myres {}
+ foreach r [db eval {SELECT
+ avg(b) FILTER (WHERE b>a),
+ avg(b) FILTER (WHERE b<a)
+ FROM t1 GROUP BY (a%2) ORDER BY 1,2;}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {30.8333 13.7273 31.4167 13.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.15 {
+ SELECT
+ a/5,
+ sum(b) FILTER (WHERE a%5=0),
+ sum(b) FILTER (WHERE a%5=1),
+ sum(b) FILTER (WHERE a%5=2),
+ sum(b) FILTER (WHERE a%5=3),
+ sum(b) FILTER (WHERE a%5=4)
+ FROM t1 GROUP BY (a/5) ORDER BY 1;
+} {0 {} 7 3 5 30 1 26 23 27 3 17 2 26 33 25 {} 47 3 36 13 45 31 11
+ 4 36 37 21 22 14 5 16 3 7 29 50 6 38 3 36 12 4 7 46 3 48 23 {}
+ 8 24 5 46 11 {} 9 18 25 15 18 23}
+
+finish_test
diff --git a/test/filterfault.test b/test/filterfault.test
new file mode 100644
index 0000000..a8cde1f
--- /dev/null
+++ b/test/filterfault.test
@@ -0,0 +1,44 @@
+# 2018 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 implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix filterfault
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c, d);
+ INSERT INTO t1 VALUES(1, 2, 3, 4);
+ INSERT INTO t1 VALUES(5, 6, 7, 8);
+ INSERT INTO t1 VALUES(9, 10, 11, 12);
+}
+faultsim_save_and_close
+
+do_faultsim_test 1 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT sum(a) FILTER (WHERE b<5),
+ count() FILTER (WHERE d!=c)
+ FROM t1 GROUP BY c ORDER BY 1;
+ }
+} -test {
+ faultsim_test_result {0 {{} 1 {} 1 1 1}}
+}
+
+
+finish_test
diff --git a/test/fkey1.test b/test/fkey1.test
new file mode 100644
index 0000000..db93be5
--- /dev/null
+++ b/test/fkey1.test
@@ -0,0 +1,275 @@
+# 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
+set testprefix fkey1
+
+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} \
+]
+do_test fkey1-3.5 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 0 0}
+
+# Stress the dequoting logic. The first test is not so bad.
+do_execsql_test fkey1-4.0 {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE "xx1"("xx2" TEXT PRIMARY KEY, "xx3" TEXT);
+ INSERT INTO "xx1"("xx2","xx3") VALUES('abc','def');
+ CREATE TABLE "xx4"("xx5" TEXT REFERENCES "xx1" ON DELETE CASCADE);
+ INSERT INTO "xx4"("xx5") VALUES('abc');
+ INSERT INTO "xx1"("xx2","xx3") VALUES('uvw','xyz');
+ SELECT 1, "xx5" FROM "xx4";
+ DELETE FROM "xx1";
+ SELECT 2, "xx5" FROM "xx4";
+} {1 abc}
+
+# This case is identical to the previous except the "xx" in each name
+# is changed to a single escaped double-quote character.
+do_execsql_test fkey1-4.1 {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE """1"("""2" TEXT PRIMARY KEY, """3" TEXT);
+ INSERT INTO """1"("""2","""3") VALUES('abc','def');
+ CREATE TABLE """4"("""5" TEXT REFERENCES """1" ON DELETE CASCADE);
+ INSERT INTO """4"("""5") VALUES('abc');
+ INSERT INTO """1"("""2","""3") VALUES('uvw','xyz');
+ SELECT 1, """5" FROM """4";
+ DELETE FROM """1";
+ SELECT 2, """5" FROM """4";
+} {1 abc}
+do_execsql_test fkey1-4.2 {
+ PRAGMA table_info="""1";
+} {0 {"2} TEXT 0 {} 1 1 {"3} TEXT 0 {} 0}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test fkey1-5.1 {
+ CREATE TABLE t11(
+ x INTEGER PRIMARY KEY,
+ parent REFERENCES t11 ON DELETE CASCADE
+ );
+ INSERT INTO t11 VALUES (1, NULL), (2, 1), (3, 2);
+} {}
+
+# The REPLACE part of this statement deletes the row (2, 1). Then the
+# DELETE CASCADE caused by deleting that row removes the (3, 2) row. Which
+# would have been the parent of the new row being inserted. Causing an
+# FK violation.
+#
+do_catchsql_test fkey1-5.2 {
+ INSERT OR REPLACE INTO t11 VALUES (2, 3);
+} {1 {FOREIGN KEY constraint failed}}
+
+# Make sure sqlite3_trace() output works with triggers used to implement
+# FK constraints
+#
+ifcapable trace {
+ proc sqltrace {txt} {
+ global traceoutput
+ lappend traceoutput $txt
+ }
+ do_test fkey1-5.2.1 {
+ unset -nocomplain traceoutput
+ db trace sqltrace
+ catch {db eval {INSERT OR REPLACE INTO t11 VALUES(2,3);}}
+ set traceoutput
+ } {{INSERT OR REPLACE INTO t11 VALUES(2,3);} {INSERT OR REPLACE INTO t11 VALUES(2,3);} {INSERT OR REPLACE INTO t11 VALUES(2,3);}}
+}
+
+# A similar test to the above.
+do_execsql_test fkey1-5.3 {
+ CREATE TABLE Foo (
+ Id INTEGER PRIMARY KEY,
+ ParentId INTEGER REFERENCES Foo(Id) ON DELETE CASCADE, C1
+ );
+ INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (1, null, 'A');
+ INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (2, 1, 'A-2-1');
+ INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (3, 2, 'A-3-2');
+ INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (4, 3, 'A-4-3');
+}
+do_catchsql_test fkey1-5.4 {
+ INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (2, 3, 'A-2-3');
+} {1 {FOREIGN KEY constraint failed}}
+
+#-------------------------------------------------------------------------
+# Check that foreign key processing is not fooled by partial indexes
+# on the parent table.
+#
+do_execsql_test 6.0 {
+ CREATE TABLE p1(x, y);
+ CREATE UNIQUE INDEX p1x ON p1(x) WHERE y<2;
+ INSERT INTO p1 VALUES(1, 1);
+ CREATE TABLE c1(a REFERENCES p1(x));
+}
+
+do_catchsql_test 6.1 {
+ INSERT INTO c1 VALUES(1);
+} {1 {foreign key mismatch - "c1" referencing "p1"}}
+
+do_execsql_test 6.2 {
+ CREATE UNIQUE INDEX p1x2 ON p1(x);
+ INSERT INTO c1 VALUES(1);
+} {}
+
+# 2021-07-03 https://sqlite.org/forum/forumpost/a6b0c05277
+# 2021-07-07 https://sqlite.org/forum/forumpost/79c9e4797d
+# Failure to allocate enough registers in the VDBE for a
+# PRAGMA foreign_key_check when the foreign key has more
+# columns than the table.
+#
+reset_db
+do_execsql_test 7.1 {
+ PRAGMA foreign_keys=OFF;
+ CREATE TABLE t1(a,b,c,FOREIGN KEY(a,a,a,a,a,a,a,a,a,a,a,a,a,a) REFERENCES t0);
+ INSERT INTO t1 VALUES(1,2,3);
+ PRAGMA foreign_key_check;
+} {t1 1 t0 0}
+do_execsql_test 7.2 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c AS(1),d, FOREIGN KEY(c,d,b,a,b,d,b,c) REFERENCES t0);
+ PRAGMA foreign_key_check;
+} {}
+
+# 2021-12-31 forum https://sqlite.org/forum/forumpost/24bd1fef7e9323ef
+# Memory leak caused by sqlite3NestedParse() running on a corrupt system
+# table. Discovered by Jingzhou Fu.
+#
+reset_db
+do_execsql_test 8.1 {
+ PRAGMA writable_schema=ON;
+ PRAGMA foreign_keys = ON;
+ CREATE TABLE sqlite_stat1 (tbl INTEGER PRIMARY KEY DESC, idx UNIQUE DEFAULT NULL) WITHOUT ROWID;
+ PRAGMA writable_schema=OFF;
+ CREATE TABLE sqlsim4(stat PRIMARY KEY);;
+ CREATE TABLE t1(sqlsim7 REFERENCES sqlite_stat1 ON DELETE CASCADE);
+ DROP table "sqlsim4";
+} {}
+# 2022-01-01 dbsqlfuzz 1c57440219f6f0aedf5e8f72a8ddd75f15aea381
+# Follow-up case to the above. Assertion is not true if the schema
+# is corrupt.
+reset_db
+database_may_be_corrupt
+do_execsql_test 8.2 {
+ CREATE TABLE t1(a REFERENCES sqlite_stat1 ON DELETE CASCADE);
+ CREATE TABLE t2(a TEXT PRIMARY KEY);
+ PRAGMA writable_schema=ON;
+ CREATE TABLE sqlite_stat1(tbl INTEGER PRIMARY KEY DESC, idx UNIQUE DEFAULT NULL) WITHOUT ROWID;
+ UPDATE sqlite_schema SET name='sqlite_autoindex_sqlite_stat1_1' WHERE name='sqlite_autoindex_sqlite_stat1_2';
+ PRAGMA writable_schema=RESET;
+} {}
+do_catchsql_test 8.3 {
+ REINDEX;
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/fkey2.test b/test/fkey2.test
new file mode 100644
index 0000000..6f9bdc2
--- /dev/null
+++ b/test/fkey2.test
@@ -0,0 +1,2047 @@
+# 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 - "t10" referencing "t9"}}
+}
+
+do_test fkey2-1.1.0 {
+ execsql [string map {/D/ {}} $FkeySimpleSchema]
+} {}
+foreach {tn zSql res} $FkeySimpleTests {
+ do_test fkey2-1.1.$tn.1 { catchsql $zSql } $res
+ do_test fkey2-1.1.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}
+ do_test fkey2-1.1.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}
+ do_test fkey2-1.1.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}
+ do_test fkey2-1.1.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}
+ do_test fkey2-1.1.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}
+ do_test fkey2-1.1.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}
+}
+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
+ do_test fkey2-1.2.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}
+ do_test fkey2-1.2.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}
+ do_test fkey2-1.2.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}
+ do_test fkey2-1.2.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}
+ do_test fkey2-1.2.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}
+ do_test fkey2-1.2.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}
+}
+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
+ do_test fkey2-1.3.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}
+ do_test fkey2-1.3.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}
+ do_test fkey2-1.3.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}
+ do_test fkey2-1.3.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}
+ do_test fkey2-1.3.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}
+ do_test fkey2-1.3.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}
+}
+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 {UNIQUE constraint failed: node.nodeid}}
+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 {CHECK constraint failed: e!=5}}
+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 {CHECK constraint failed: e!=5}}
+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}
+do_execsql_test fkey2-9.3.0 {
+ CREATE TABLE t3(x PRIMARY KEY REFERENCES t3 ON DELETE SET NULL);
+ INSERT INTO t3(x) VALUES(12345);
+ DROP TABLE t3;
+} {}
+
+#-------------------------------------------------------------------------
+# 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 - "c" referencing "."}/}
+}
+
+# "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 - "t2" referencing "t1"}}
+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, rowid, _rowid_, oid);
+ CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(a) ON UPDATE CASCADE);
+
+ INSERT INTO t1 VALUES(10, 100, 'abc', 'def', 'ghi');
+ 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);
+ INSERT INTO t2 VALUES(1,2);
+ }
+ 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_table(
+ 'main', 'table', 't1', $zCreate, $zOld, $zNew, 0
+ )}
+ }
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+ 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")}}
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+
+ # 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);
+ INSERT INTO temp.t2 VALUES(1,2);
+ }
+ 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 temp.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)}}
+
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+ 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")}}
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+
+ # 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 temp.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.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);
+ INSERT INTO aux.t2(a,b) VALUES(1,2);
+ }
+ 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)}}
+
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+ 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")}}
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+
+ # 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 - "cc" referencing "pp"}}
+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}
+verify_ex_errcode fkey2-17.1.2b SQLITE_CONSTRAINT_FOREIGNKEY
+ifcapable autoreset {
+ do_test fkey2-17.1.3 {
+ sqlite3_step $STMT
+ } {SQLITE_CONSTRAINT}
+ verify_ex_errcode fkey2-17.1.3b SQLITE_CONSTRAINT_FOREIGNKEY
+} else {
+ do_test fkey2-17.1.3 {
+ sqlite3_step $STMT
+ } {SQLITE_MISUSE}
+}
+do_test fkey2-17.1.4 {
+ sqlite3_finalize $STMT
+} {SQLITE_CONSTRAINT}
+verify_ex_errcode fkey2-17.1.4b SQLITE_CONSTRAINT_FOREIGNKEY
+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}
+verify_ex_errcode fkey2-17.1.13b SQLITE_CONSTRAINT_FOREIGNKEY
+do_test fkey2-17.1.14 {
+ sqlite3_finalize $STMT
+} {SQLITE_CONSTRAINT}
+verify_ex_errcode fkey2-17.1.14b SQLITE_CONSTRAINT_FOREIGNKEY
+
+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 [lrange $args 0 4]; 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}
+verify_ex_errcode fkey2-19.2b SQLITE_CONSTRAINT_FOREIGNKEY
+do_test fkey2-19.3 {
+ sqlite3_reset $S
+} {SQLITE_CONSTRAINT}
+verify_ex_errcode fkey2-19.3b SQLITE_CONSTRAINT_FOREIGNKEY
+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}}
+
+# 2015-04-16: Foreign key errors propagate back up to the parser.
+#
+do_test fkey2-20150416-100 {
+ db close
+ sqlite3 db :memory:
+ catchsql {
+ PRAGMA foreign_keys=1;
+ CREATE TABLE t1(x PRIMARY KEY);
+ CREATE TABLE t(y REFERENCES t0(x)ON DELETE SET DEFAULT);
+ CREATE TABLE t0(y REFERENCES t1 ON DELETE SET NULL);
+ REPLACE INTO t1 SELECT(0);CREATE TABLE t2(x);CREATE TABLE t3;
+ }
+} {1 {foreign key mismatch - "t" referencing "t0"}}
+
+finish_test
diff --git a/test/fkey3.test b/test/fkey3.test
new file mode 100644
index 0000000..a8d0382
--- /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..79cf663
--- /dev/null
+++ b/test/fkey4.test
@@ -0,0 +1,57 @@
+# 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}
+verify_ex_errcode fkey4-1.2b SQLITE_CONSTRAINT_FOREIGNKEY
+do_test fkey4-1.3 {
+ set ::STMT2 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL]
+ sqlite3_step $::STMT2
+} {SQLITE_CONSTRAINT}
+verify_ex_errcode fkey4-1.3b SQLITE_CONSTRAINT_FOREIGNKEY
+do_test fkey4-1.4 {
+ db eval {SELECT * FROM t2}
+} {1 3}
+sqlite3_finalize $::STMT1
+sqlite3_finalize $::STMT2
+
+finish_test
diff --git a/test/fkey5.test b/test/fkey5.test
new file mode 100644
index 0000000..d467a64
--- /dev/null
+++ b/test/fkey5.test
@@ -0,0 +1,492 @@
+# 2012 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 tests the PRAGMA foreign_key_check command.
+#
+# EVIDENCE-OF: R-15402-03103 PRAGMA schema.foreign_key_check; PRAGMA
+# schema.foreign_key_check(table-name);
+#
+# EVIDENCE-OF: R-41653-15278 The foreign_key_check pragma checks the
+# database, or the table called "table-name", for foreign key
+# constraints that are violated. The foreign_key_check pragma returns
+# one row output for each foreign key violation.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fkey5
+
+ifcapable {!foreignkey} {
+ finish_test
+ return
+}
+
+do_test fkey5-1.1 {
+ db eval {
+ CREATE TABLE p1(a INTEGER PRIMARY KEY); INSERT INTO p1 VALUES(88),(89);
+ CREATE TABLE p2(a INT PRIMARY KEY); INSERT INTO p2 VALUES(77),(78);
+ CREATE TABLE p3(a TEXT PRIMARY KEY);
+ INSERT INTO p3 VALUES(66),(67),('alpha'),('BRAVO');
+ CREATE TABLE p4(a TEXT PRIMARY KEY COLLATE nocase);
+ INSERT INTO p4 VALUES('alpha'),('BRAVO'),('55'),('Delta'),('ECHO');
+ CREATE TABLE p5(a INTEGER PRIMARY KEY, b, c, UNIQUE(b,c));
+ INSERT INTO p5 VALUES(1,'Alpha','abc'),(2,'beta','def');
+ CREATE TABLE p6(a INTEGER PRIMARY KEY, b TEXT COLLATE nocase,
+ c TEXT COLLATE rtrim, UNIQUE(b,c));
+ INSERT INTO p6 VALUES(1,'Alpha','abc '),(2,'bETA','def ');
+
+ CREATE TABLE c1(x INTEGER PRIMARY KEY references p1);
+ CREATE TABLE c2(x INTEGER PRIMARY KEY references p2);
+ CREATE TABLE c3(x INTEGER PRIMARY KEY references p3);
+ CREATE TABLE c4(x INTEGER PRIMARY KEY references p4);
+ CREATE TABLE c5(x INT references p1);
+ CREATE TABLE c6(x INT references p2);
+ CREATE TABLE c7(x INT references p3);
+ CREATE TABLE c8(x INT references p4);
+ CREATE TABLE c9(x TEXT UNIQUE references p1);
+ CREATE TABLE c10(x TEXT UNIQUE references p2);
+ CREATE TABLE c11(x TEXT UNIQUE references p3);
+ CREATE TABLE c12(x TEXT UNIQUE references p4);
+ CREATE TABLE c13(x TEXT COLLATE nocase references p3);
+ CREATE TABLE c14(x TEXT COLLATE nocase references p4);
+ CREATE TABLE c15(x, y, FOREIGN KEY(x,y) REFERENCES p5(b,c));
+ CREATE TABLE c16(x, y, FOREIGN KEY(x,y) REFERENCES p5(c,b));
+ CREATE TABLE c17(x, y, FOREIGN KEY(x,y) REFERENCES p6(b,c));
+ CREATE TABLE c18(x, y, FOREIGN KEY(x,y) REFERENCES p6(c,b));
+ CREATE TABLE c19(x TEXT COLLATE nocase, y TEXT COLLATE rtrim,
+ FOREIGN KEY(x,y) REFERENCES p5(b,c));
+ CREATE TABLE c20(x TEXT COLLATE nocase, y TEXT COLLATE rtrim,
+ FOREIGN KEY(x,y) REFERENCES p5(c,b));
+ CREATE TABLE c21(x TEXT COLLATE nocase, y TEXT COLLATE rtrim,
+ FOREIGN KEY(x,y) REFERENCES p6(b,c));
+ CREATE TABLE c22(x TEXT COLLATE nocase, y TEXT COLLATE rtrim,
+ FOREIGN KEY(x,y) REFERENCES p6(c,b));
+
+ PRAGMA foreign_key_check;
+ }
+} {}
+do_test fkey5-1.2 {
+ db eval {
+ INSERT INTO c1 VALUES(90),(87),(88);
+ PRAGMA foreign_key_check;
+ }
+} {c1 87 p1 0 c1 90 p1 0}
+do_test fkey5-1.2b {
+ db eval {
+ PRAGMA main.foreign_key_check;
+ }
+} {c1 87 p1 0 c1 90 p1 0}
+do_test fkey5-1.2c {
+ db eval {
+ PRAGMA temp.foreign_key_check;
+ }
+} {}
+do_test fkey5-1.3 {
+ db eval {
+ PRAGMA foreign_key_check(c1);
+ }
+} {c1 87 p1 0 c1 90 p1 0}
+do_test fkey5-1.4 {
+ db eval {
+ PRAGMA foreign_key_check(c2);
+ }
+} {}
+do_test fkey5-1.5 {
+ db eval {
+ PRAGMA main.foreign_key_check(c2);
+ }
+} {}
+do_test fkey5-1.6 {
+ catchsql {
+ PRAGMA temp.foreign_key_check(c2);
+ }
+} {1 {no such table: temp.c2}}
+
+# EVIDENCE-OF: R-45728-08709 There are four columns in each result row.
+#
+# EVIDENCE-OF: R-55672-01620 The first column is the name of the table
+# that contains the REFERENCES clause.
+#
+# EVIDENCE-OF: R-00471-55166 The second column is the rowid of the row
+# that contains the invalid REFERENCES clause, or NULL if the child
+# table is a WITHOUT ROWID table.
+#
+# The second clause in the previous is tested by fkey5-10.3.
+#
+# EVIDENCE-OF: R-40482-20265 The third column is the name of the table
+# that is referred to.
+#
+# EVIDENCE-OF: R-62839-07969 The fourth column is the index of the
+# specific foreign key constraint that failed.
+#
+do_test fkey5-2.0 {
+ db eval {
+ INSERT INTO c5 SELECT x FROM c1;
+ DELETE FROM c1;
+ PRAGMA foreign_key_check;
+ }
+} {c5 1 p1 0 c5 3 p1 0}
+do_test fkey5-2.1 {
+ db eval {
+ PRAGMA foreign_key_check(c5);
+ }
+} {c5 1 p1 0 c5 3 p1 0}
+do_test fkey5-2.2 {
+ db eval {
+ PRAGMA foreign_key_check(c1);
+ }
+} {}
+do_execsql_test fkey5-2.3 {
+ PRAGMA foreign_key_list(c5);
+} {0 0 p1 x {} {NO ACTION} {NO ACTION} NONE}
+
+do_test fkey5-3.0 {
+ db eval {
+ INSERT INTO c9 SELECT x FROM c5;
+ DELETE FROM c5;
+ PRAGMA foreign_key_check;
+ }
+} {c9 1 p1 0 c9 3 p1 0}
+do_test fkey5-3.1 {
+ db eval {
+ PRAGMA foreign_key_check(c9);
+ }
+} {c9 1 p1 0 c9 3 p1 0}
+do_test fkey5-3.2 {
+ db eval {
+ PRAGMA foreign_key_check(c5);
+ }
+} {}
+
+do_test fkey5-4.0 {
+ db eval {
+ DELETE FROM c9;
+ INSERT INTO c2 VALUES(79),(77),(76);
+ PRAGMA foreign_key_check;
+ }
+} {c2 76 p2 0 c2 79 p2 0}
+do_test fkey5-4.1 {
+ db eval {
+ PRAGMA foreign_key_check(c2);
+ }
+} {c2 76 p2 0 c2 79 p2 0}
+do_test fkey5-4.2 {
+ db eval {
+ INSERT INTO c6 SELECT x FROM c2;
+ DELETE FROM c2;
+ PRAGMA foreign_key_check;
+ }
+} {c6 1 p2 0 c6 3 p2 0}
+do_test fkey5-4.3 {
+ db eval {
+ PRAGMA foreign_key_check(c6);
+ }
+} {c6 1 p2 0 c6 3 p2 0}
+do_test fkey5-4.4 {
+ db eval {
+ INSERT INTO c10 SELECT x FROM c6;
+ DELETE FROM c6;
+ PRAGMA foreign_key_check;
+ }
+} {c10 1 p2 0 c10 3 p2 0}
+do_test fkey5-4.5 {
+ db eval {
+ PRAGMA foreign_key_check(c10);
+ }
+} {c10 1 p2 0 c10 3 p2 0}
+
+do_test fkey5-5.0 {
+ db eval {
+ DELETE FROM c10;
+ INSERT INTO c3 VALUES(68),(67),(65);
+ PRAGMA foreign_key_check;
+ }
+} {c3 65 p3 0 c3 68 p3 0}
+do_test fkey5-5.1 {
+ db eval {
+ PRAGMA foreign_key_check(c3);
+ }
+} {c3 65 p3 0 c3 68 p3 0}
+do_test fkey5-5.2 {
+ db eval {
+ INSERT INTO c7 SELECT x FROM c3;
+ INSERT INTO c7 VALUES('Alpha'),('alpha'),('foxtrot');
+ DELETE FROM c3;
+ PRAGMA foreign_key_check;
+ }
+} {c7 1 p3 0 c7 3 p3 0 c7 4 p3 0 c7 6 p3 0}
+do_test fkey5-5.3 {
+ db eval {
+ PRAGMA foreign_key_check(c7);
+ }
+} {c7 1 p3 0 c7 3 p3 0 c7 4 p3 0 c7 6 p3 0}
+do_test fkey5-5.4 {
+ db eval {
+ INSERT INTO c11 SELECT x FROM c7;
+ DELETE FROM c7;
+ PRAGMA foreign_key_check;
+ }
+} {c11 1 p3 0 c11 3 p3 0 c11 4 p3 0 c11 6 p3 0}
+do_test fkey5-5.5 {
+ db eval {
+ PRAGMA foreign_key_check(c11);
+ }
+} {c11 1 p3 0 c11 3 p3 0 c11 4 p3 0 c11 6 p3 0}
+
+do_test fkey5-6.0 {
+ db eval {
+ DELETE FROM c11;
+ INSERT INTO c4 VALUES(54),(55),(56);
+ PRAGMA foreign_key_check;
+ }
+} {c4 54 p4 0 c4 56 p4 0}
+do_test fkey5-6.1 {
+ db eval {
+ PRAGMA foreign_key_check(c4);
+ }
+} {c4 54 p4 0 c4 56 p4 0}
+do_test fkey5-6.2 {
+ db eval {
+ INSERT INTO c8 SELECT x FROM c4;
+ INSERT INTO c8 VALUES('Alpha'),('ALPHA'),('foxtrot');
+ DELETE FROM c4;
+ PRAGMA foreign_key_check;
+ }
+} {c8 1 p4 0 c8 3 p4 0 c8 6 p4 0}
+do_test fkey5-6.3 {
+ db eval {
+ PRAGMA foreign_key_check(c8);
+ }
+} {c8 1 p4 0 c8 3 p4 0 c8 6 p4 0}
+do_test fkey5-6.4 {
+ db eval {
+ INSERT INTO c12 SELECT x FROM c8;
+ DELETE FROM c8;
+ PRAGMA foreign_key_check;
+ }
+} {c12 1 p4 0 c12 3 p4 0 c12 6 p4 0}
+do_test fkey5-6.5 {
+ db eval {
+ PRAGMA foreign_key_check(c12);
+ }
+} {c12 1 p4 0 c12 3 p4 0 c12 6 p4 0}
+
+do_test fkey5-7.1 {
+ set res {}
+ db eval {
+ INSERT OR IGNORE INTO c13 SELECT * FROM c12;
+ INSERT OR IGNORE INTO C14 SELECT * FROM c12;
+ DELETE FROM c12;
+ PRAGMA foreign_key_check;
+ } {
+ lappend res [list $table $rowid $fkid $parent]
+ }
+ lsort $res
+} {{c13 1 0 p3} {c13 2 0 p3} {c13 3 0 p3} {c13 4 0 p3} {c13 5 0 p3} {c13 6 0 p3} {c14 1 0 p4} {c14 3 0 p4} {c14 6 0 p4}}
+do_test fkey5-7.2 {
+ db eval {
+ PRAGMA foreign_key_check(c14);
+ }
+} {c14 1 p4 0 c14 3 p4 0 c14 6 p4 0}
+do_test fkey5-7.3 {
+ db eval {
+ PRAGMA foreign_key_check(c13);
+ }
+} {c13 1 p3 0 c13 2 p3 0 c13 3 p3 0 c13 4 p3 0 c13 5 p3 0 c13 6 p3 0}
+
+do_test fkey5-8.0 {
+ db eval {
+ DELETE FROM c13;
+ DELETE FROM c14;
+ INSERT INTO c19 VALUES('alpha','abc');
+ PRAGMA foreign_key_check(c19);
+ }
+} {c19 1 p5 0}
+do_test fkey5-8.1 {
+ db eval {
+ DELETE FROM c19;
+ INSERT INTO c19 VALUES('Alpha','abc');
+ PRAGMA foreign_key_check(c19);
+ }
+} {}
+do_test fkey5-8.2 {
+ db eval {
+ INSERT INTO c20 VALUES('Alpha','abc');
+ PRAGMA foreign_key_check(c20);
+ }
+} {c20 1 p5 0}
+do_test fkey5-8.3 {
+ db eval {
+ DELETE FROM c20;
+ INSERT INTO c20 VALUES('abc','Alpha');
+ PRAGMA foreign_key_check(c20);
+ }
+} {}
+do_test fkey5-8.4 {
+ db eval {
+ INSERT INTO c21 VALUES('alpha','abc ');
+ PRAGMA foreign_key_check(c21);
+ }
+} {}
+do_test fkey5-8.5 {
+ db eval {
+ DELETE FROM c21;
+ INSERT INTO c19 VALUES('Alpha','abc');
+ PRAGMA foreign_key_check(c21);
+ }
+} {}
+do_test fkey5-8.6 {
+ db eval {
+ INSERT INTO c22 VALUES('Alpha','abc');
+ PRAGMA foreign_key_check(c22);
+ }
+} {c22 1 p6 0}
+do_test fkey5-8.7 {
+ db eval {
+ DELETE FROM c22;
+ INSERT INTO c22 VALUES('abc ','ALPHA');
+ PRAGMA foreign_key_check(c22);
+ }
+} {}
+
+
+#-------------------------------------------------------------------------
+# Tests 9.* verify that missing parent tables are handled correctly.
+#
+do_execsql_test 9.1.1 {
+ CREATE TABLE k1(x REFERENCES s1);
+ PRAGMA foreign_key_check(k1);
+} {}
+do_execsql_test 9.1.2 {
+ INSERT INTO k1 VALUES(NULL);
+ PRAGMA foreign_key_check(k1);
+} {}
+do_execsql_test 9.1.3 {
+ INSERT INTO k1 VALUES(1);
+ PRAGMA foreign_key_check(k1);
+} {k1 2 s1 0}
+
+do_execsql_test 9.2.1 {
+ CREATE TABLE k2(x, y, FOREIGN KEY(x, y) REFERENCES s1(a, b));
+ PRAGMA foreign_key_check(k2);
+} {}
+do_execsql_test 9.2 {
+ INSERT INTO k2 VALUES(NULL, 'five');
+ PRAGMA foreign_key_check(k2);
+} {}
+do_execsql_test 9.3 {
+ INSERT INTO k2 VALUES('one', NULL);
+ PRAGMA foreign_key_check(k2);
+} {}
+do_execsql_test 9.4 {
+ INSERT INTO k2 VALUES('six', 'seven');
+ PRAGMA foreign_key_check(k2);
+} {k2 3 s1 0}
+
+#-------------------------------------------------------------------------
+# Test using a WITHOUT ROWID table as the child table with an INTEGER
+# PRIMARY KEY as the parent key.
+#
+reset_db
+do_execsql_test 10.1 {
+ CREATE TABLE p30 (id INTEGER PRIMARY KEY);
+ CREATE TABLE IF NOT EXISTS c30 (
+ line INTEGER,
+ master REFERENCES p30(id),
+ PRIMARY KEY(master)
+ ) WITHOUT ROWID;
+
+ INSERT INTO p30 (id) VALUES (1);
+ INSERT INTO c30 (master, line) VALUES (1, 999);
+}
+do_execsql_test 10.2 {
+ PRAGMA foreign_key_check;
+}
+# EVIDENCE-OF: R-00471-55166 The second column is the rowid of the row
+# that contains the invalid REFERENCES clause, or NULL if the child
+# table is a WITHOUT ROWID table.
+do_execsql_test 10.3 {
+ INSERT INTO c30 VALUES(45, 45);
+ PRAGMA foreign_key_check;
+} {c30 {} p30 0}
+
+#-------------------------------------------------------------------------
+# Test "foreign key mismatch" errors.
+#
+reset_db
+do_execsql_test 11.0 {
+ CREATE TABLE tt(y);
+ CREATE TABLE c11(x REFERENCES tt(y));
+}
+do_catchsql_test 11.1 {
+ PRAGMA foreign_key_check;
+} {1 {foreign key mismatch - "c11" referencing "tt"}}
+
+# 2020-07-03 Bug in foreign_key_check discovered while working on the
+# forum reports that pragma_foreign_key_check does not accept an argument:
+# If two separate schemas seem to reference one another, that causes
+# problems for foreign_key_check.
+#
+reset_db
+do_execsql_test 12.0 {
+ ATTACH ':memory:' as aux;
+ CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b TEXT REFERENCES t2);
+ CREATE TABLE main.t2(x TEXT PRIMARY KEY, y INT);
+ INSERT INTO main.t2 VALUES('abc',11),('def',22),('xyz',99);
+ INSERT INTO aux.t1 VALUES(5,'abc'),(7,'xyz'),(9,'oops');
+ PRAGMA foreign_key_check=t1;
+} {t1 5 t2 0 t1 7 t2 0 t1 9 t2 0}
+do_execsql_test 12.1 {
+ CREATE TABLE aux.t2(x TEXT PRIMARY KEY, y INT);
+ INSERT INTO aux.t2 VALUES('abc',11),('def',22),('xyz',99);
+ PRAGMA foreign_key_check=t1;
+} {t1 9 t2 0}
+
+# 2020-07-03: the pragma_foreign_key_check virtual table should
+# accept arguments for the table name and/or schema name.
+#
+ifcapable vtab {
+ do_execsql_test 13.0 {
+ SELECT *, 'x' FROM pragma_foreign_key_check('t1');
+ } {t1 9 t2 0 x}
+ do_catchsql_test 13.1 {
+ SELECT *, 'x' FROM pragma_foreign_key_check('t1','main');
+ } {1 {no such table: main.t1}}
+ do_execsql_test 13.2 {
+ SELECT *, 'x' FROM pragma_foreign_key_check('t1','aux');
+ } {t1 9 t2 0 x}
+}
+
+ifcapable vtab {
+ reset_db
+ do_execsql_test 13.10 {
+ PRAGMA foreign_keys=OFF;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT REFERENCES t2);
+ CREATE TABLE t2(x TEXT PRIMARY KEY, y INT);
+ CREATE TABLE t3(w TEXT, z INT REFERENCES t1);
+ INSERT INTO t2 VALUES('abc',11),('def',22),('xyz',99);
+ INSERT INTO t1 VALUES(5,'abc'),(7,'xyz'),(9,'oops');
+ INSERT INTO t3 VALUES(11,7),(22,19);
+ } {}
+ do_execsql_test 13.11 {
+ SELECT x.*, '|'
+ FROM sqlite_schema, pragma_foreign_key_check(name) AS x
+ WHERE type='table'
+ ORDER BY x."table";
+ } {t1 9 t2 0 | t3 2 t1 0 |}
+ do_execsql_test 13.12 {
+ SELECT *, '|'
+ FROM pragma_foreign_key_check AS x
+ ORDER BY x."table";
+ } {t1 9 t2 0 | t3 2 t1 0 |}
+}
+
+finish_test
diff --git a/test/fkey6.test b/test/fkey6.test
new file mode 100644
index 0000000..b658f20
--- /dev/null
+++ b/test/fkey6.test
@@ -0,0 +1,229 @@
+# 2012 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 tests the PRAGMA defer_foreign_keys and
+# SQLITE_DBSTATUS_DEFERRED_FKS
+#
+# EVIDENCE-OF: R-18981-16292 When the defer_foreign_keys PRAGMA is on,
+# enforcement of all foreign key constraints is delayed until the
+# outermost transaction is committed.
+#
+# EVIDENCE-OF: R-28911-57501 The defer_foreign_keys pragma defaults to
+# OFF so that foreign key constraints are only deferred if they are
+# created as "DEFERRABLE INITIALLY DEFERRED".
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fkey6
+
+ifcapable {!foreignkey} {
+ finish_test
+ return
+}
+
+do_execsql_test fkey6-1.0 {
+ PRAGMA defer_foreign_keys;
+} {0}
+
+do_execsql_test fkey6-1.1 {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ CREATE TABLE t2(y INTEGER PRIMARY KEY,
+ z INTEGER REFERENCES t1(x) DEFERRABLE INITIALLY DEFERRED);
+ CREATE INDEX t2z ON t2(z);
+ CREATE TABLE t3(u INTEGER PRIMARY KEY, v INTEGER REFERENCES t1(x));
+ CREATE INDEX t3v ON t3(v);
+ INSERT INTO t1 VALUES(1),(2),(3),(4),(5);
+ INSERT INTO t2 VALUES(1,1),(2,2);
+ INSERT INTO t3 VALUES(3,3),(4,4);
+} {}
+do_test fkey6-1.2 {
+ catchsql {DELETE FROM t1 WHERE x=2;}
+} {1 {FOREIGN KEY constraint failed}}
+do_test fkey6-1.3 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 0 0}
+do_test fkey6-1.4 {
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE x=1;
+ }
+} {}
+do_test fkey6-1.5.1 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 1
+} {0 1 0}
+do_test fkey6-1.5.2 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 1 0}
+do_test fkey6-1.6 {
+ execsql {
+ ROLLBACK;
+ }
+} {}
+do_test fkey6-1.7 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 0 0}
+do_test fkey6-1.8 {
+ execsql {
+ PRAGMA defer_foreign_keys=ON;
+ BEGIN;
+ DELETE FROM t1 WHERE x=3;
+ }
+} {}
+do_test fkey6-1.9 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 1 0}
+
+# EVIDENCE-OF: R-21752-26913 The defer_foreign_keys pragma is
+# automatically switched off at each COMMIT or ROLLBACK. Hence, the
+# defer_foreign_keys pragma must be separately enabled for each
+# transaction.
+do_execsql_test fkey6-1.10.1 {
+ PRAGMA defer_foreign_keys;
+ ROLLBACK;
+ PRAGMA defer_foreign_keys;
+ BEGIN;
+ PRAGMA defer_foreign_keys=ON;
+ PRAGMA defer_foreign_keys;
+ COMMIT;
+ PRAGMA defer_foreign_keys;
+ BEGIN;
+} {1 0 1 0}
+do_test fkey6-1.10.2 {
+ catchsql {DELETE FROM t1 WHERE x=3}
+} {1 {FOREIGN KEY constraint failed}}
+db eval {ROLLBACK}
+
+do_test fkey6-1.20 {
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE x=1;
+ }
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 1 0}
+do_test fkey6-1.21 {
+ execsql {
+ DELETE FROM t2 WHERE y=1;
+ }
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 0 0}
+do_test fkey6-1.22 {
+ execsql {
+ COMMIT;
+ }
+} {}
+
+do_execsql_test fkey6-2.1 {
+ CREATE TABLE p1(a PRIMARY KEY);
+ INSERT INTO p1 VALUES('one'), ('two');
+ CREATE TABLE c1(x REFERENCES p1);
+ INSERT INTO c1 VALUES('two'), ('one');
+}
+
+do_execsql_test fkey6-2.2 {
+ BEGIN;
+ PRAGMA defer_foreign_keys = 1;
+ DELETE FROM p1;
+ ROLLBACK;
+ PRAGMA defer_foreign_keys;
+} {0}
+
+do_execsql_test fkey6-2.3 {
+ BEGIN;
+ PRAGMA defer_foreign_keys = 1;
+ DROP TABLE p1;
+ PRAGMA vdbe_trace = 0;
+ ROLLBACK;
+ PRAGMA defer_foreign_keys;
+} {0}
+
+do_execsql_test fkey6-2.4 {
+ BEGIN;
+ PRAGMA defer_foreign_keys = 1;
+ DELETE FROM p1;
+ DROP TABLE c1;
+ COMMIT;
+ PRAGMA defer_foreign_keys;
+} {0}
+
+do_execsql_test fkey6-2.5 {
+ DROP TABLE p1;
+ CREATE TABLE p1(a PRIMARY KEY);
+ INSERT INTO p1 VALUES('one'), ('two');
+ CREATE TABLE c1(x REFERENCES p1);
+ INSERT INTO c1 VALUES('two'), ('one');
+}
+
+do_execsql_test fkey6-2.6 {
+ BEGIN;
+ PRAGMA defer_foreign_keys = 1;
+ INSERT INTO c1 VALUES('three');
+ DROP TABLE c1;
+ COMMIT;
+ PRAGMA defer_foreign_keys;
+} {0}
+
+#--------------------------------------------------------------------------
+# Test that defer_foreign_keys disables RESTRICT.
+#
+do_execsql_test 3.1 {
+ CREATE TABLE p2(a PRIMARY KEY, b);
+ CREATE TABLE c2(x, y REFERENCES p2 ON DELETE RESTRICT ON UPDATE RESTRICT);
+ INSERT INTO p2 VALUES(1, 'one');
+ INSERT INTO p2 VALUES(2, 'two');
+ INSERT INTO c2 VALUES('i', 1);
+}
+
+do_catchsql_test 3.2.1 {
+ BEGIN;
+ UPDATE p2 SET a=a-1;
+} {1 {FOREIGN KEY constraint failed}}
+do_execsql_test 3.2.2 { COMMIT }
+
+do_execsql_test 3.2.3 {
+ BEGIN;
+ PRAGMA defer_foreign_keys = 1;
+ UPDATE p2 SET a=a-1;
+ COMMIT;
+}
+
+do_execsql_test 3.2.4 {
+ BEGIN;
+ PRAGMA defer_foreign_keys = 1;
+ UPDATE p2 SET a=a-1;
+}
+do_catchsql_test 3.2.5 {
+ COMMIT;
+} {1 {FOREIGN KEY constraint failed}}
+do_execsql_test 3.2.6 { ROLLBACK }
+
+do_execsql_test 3.3.1 {
+ CREATE TRIGGER p2t AFTER DELETE ON p2 BEGIN
+ INSERT INTO p2 VALUES(old.a, 'deleted!');
+ END;
+}
+do_catchsql_test 3.3.2 {
+ BEGIN;
+ DELETE FROM p2 WHERE a=1;
+} {1 {FOREIGN KEY constraint failed}}
+do_execsql_test 3.3.3 { COMMIT }
+
+do_execsql_test 3.3.4 {
+ BEGIN;
+ PRAGMA defer_foreign_keys = 1;
+ DELETE FROM p2 WHERE a=1;
+ COMMIT;
+ SELECT * FROM p2;
+} {0 one 1 deleted!}
+
+
+finish_test
diff --git a/test/fkey7.test b/test/fkey7.test
new file mode 100644
index 0000000..77870a7
--- /dev/null
+++ b/test/fkey7.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
+set testprefix fkey7
+
+ifcapable {!foreignkey} {
+ finish_test
+ return
+}
+
+do_execsql_test 1.1 {
+ PRAGMA foreign_keys = 1;
+
+ CREATE TABLE s1(a PRIMARY KEY, b);
+ CREATE TABLE par(a, b REFERENCES s1, c UNIQUE, PRIMARY KEY(a));
+
+ CREATE TABLE c1(a, b REFERENCES par);
+ CREATE TABLE c2(a, b REFERENCES par);
+ CREATE TABLE c3(a, b REFERENCES par(c));
+}
+
+proc auth {op tbl args} {
+ if {$op == "SQLITE_READ"} { set ::tbls($tbl) 1 }
+ return "SQLITE_OK"
+}
+db auth auth
+db cache size 0
+proc do_tblsread_test {tn sql tbllist} {
+ array unset ::tbls
+ uplevel [list execsql $sql]
+ uplevel [list do_test $tn {lsort [array names ::tbls]} $tbllist]
+}
+
+do_tblsread_test 1.2 { UPDATE par SET b=? WHERE a=? } {par s1}
+do_tblsread_test 1.3 { UPDATE par SET a=? WHERE b=? } {c1 c2 par}
+do_tblsread_test 1.4 { UPDATE par SET c=? WHERE b=? } {c3 par}
+do_tblsread_test 1.5 { UPDATE par SET a=?,b=?,c=? WHERE b=? } {c1 c2 c3 par s1}
+
+ifcapable incrblob {
+ do_execsql_test 2.0 {
+ CREATE TABLE pX(x PRIMARY KEY);
+ CREATE TABLE cX(a INTEGER PRIMARY KEY, b REFERENCES pX);
+ }
+
+ do_catchsql_test 2.1 {
+ INSERT INTO cX VALUES(11, zeroblob(40));
+ } {1 {FOREIGN KEY constraint failed}}
+
+ do_test 2.2 {
+ set stmt [sqlite3_prepare_v2 db "INSERT INTO cX VALUES(11, ?)" -1]
+ sqlite3_bind_zeroblob $stmt 1 45
+ sqlite3_step $stmt
+ sqlite3_finalize $stmt
+ } {SQLITE_CONSTRAINT}
+}
+
+ifcapable stat4 {
+ do_execsql_test 3.0 {
+ CREATE TABLE p4 (id INTEGER NOT NULL PRIMARY KEY);
+ INSERT INTO p4 VALUES(1), (2), (3);
+
+ CREATE TABLE c4(x INTEGER REFERENCES p4(id) DEFERRABLE INITIALLY DEFERRED);
+ CREATE INDEX c4_x ON c4(x);
+ INSERT INTO c4 VALUES(1), (2), (3);
+
+ ANALYZE;
+ INSERT INTO p4(id) VALUES(4);
+ }
+}
+
+
+do_execsql_test 4.0 {
+ PRAGMA foreign_keys = true;
+ CREATE TABLE parent(
+ p PRIMARY KEY
+ );
+ CREATE TABLE child(
+ c UNIQUE REFERENCES parent(p)
+ );
+}
+
+do_catchsql_test 4.1 {
+ INSERT OR FAIL INTO child VALUES(123), (123);
+} {1 {FOREIGN KEY constraint failed}}
+
+do_execsql_test 4.2 {
+ SELECT * FROM child;
+} {}
+
+do_execsql_test 4.3 {
+ PRAGMA foreign_key_check;
+} {}
+
+do_catchsql_test 4.4 {
+ INSERT INTO parent VALUES(123);
+ INSERT OR FAIL INTO child VALUES(123), (123);
+} {1 {UNIQUE constraint failed: child.c}}
+
+do_execsql_test 4.5 {
+ SELECT * FROM child;
+} {123}
+
+do_execsql_test 4.6 {
+ PRAGMA foreign_key_check;
+} {}
+
+finish_test
diff --git a/test/fkey8.test b/test/fkey8.test
new file mode 100644
index 0000000..2d72f6f
--- /dev/null
+++ b/test/fkey8.test
@@ -0,0 +1,253 @@
+# 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
+set testprefix fkey8
+
+ifcapable {!foreignkey} {
+ finish_test
+ return
+}
+do_execsql_test 1.0 { PRAGMA foreign_keys = 1; }
+
+
+foreach {tn use_stmt sql schema} {
+ 1 1 "DELETE FROM p1" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1);
+ }
+
+ 2.1 0 "DELETE FROM p1" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE);
+ }
+ 2.2 0 "DELETE FROM p1" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON DELETE SET NULL);
+ }
+ 2.3 1 "DELETE FROM p1" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON DELETE SET DEFAULT);
+ }
+
+ 3 1 "DELETE FROM p1" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE);
+ CREATE TRIGGER ct1 AFTER DELETE ON c1 BEGIN
+ INSERT INTO p1 VALUES('x');
+ END;
+ }
+
+ 4 1 "DELETE FROM p1" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE, c PRIMARY KEY);
+ CREATE TABLE cc1(d REFERENCES c1);
+ }
+
+ 5.1 0 "DELETE FROM p1" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE, c PRIMARY KEY);
+ CREATE TABLE cc1(d REFERENCES c1 ON DELETE CASCADE);
+ }
+ 5.2 0 "DELETE FROM p1" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE, c PRIMARY KEY);
+ CREATE TABLE cc1(d REFERENCES c1 ON DELETE SET NULL);
+ }
+ 5.3 1 "DELETE FROM p1" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE, c PRIMARY KEY);
+ CREATE TABLE cc1(d REFERENCES c1 ON DELETE SET DEFAULT);
+ }
+
+ 6.1 1 "UPDATE p1 SET a = ?" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON UPDATE SET NULL, c);
+ }
+ 6.2 0 "UPDATE OR IGNORE p1 SET a = ?" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON UPDATE SET NULL, c);
+ }
+ 6.3 1 "UPDATE OR IGNORE p1 SET a = ?" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b REFERENCES p1 ON UPDATE CASCADE, c);
+ }
+ 6.4 1 "UPDATE OR IGNORE p1 SET a = ?" {
+ CREATE TABLE p1(a PRIMARY KEY);
+ CREATE TABLE c1(b NOT NULL REFERENCES p1 ON UPDATE SET NULL, c);
+ }
+
+} {
+ drop_all_tables
+ do_test 1.$tn {
+ execsql $schema
+ set stmt [sqlite3_prepare_v2 db $sql -1 dummy]
+ set ret [uses_stmt_journal $stmt]
+ sqlite3_finalize $stmt
+ set ret
+ } $use_stmt
+}
+
+#-------------------------------------------------------------------------
+# The following tests check that foreign key constaint counters are
+# correctly updated for any implicit DELETE operations that occur
+# when a REPLACE command is executed against a WITHOUT ROWID table
+# that has no triggers or auxiliary indexes.
+#
+reset_db
+do_execsql_test 2.1.0 {
+ PRAGMA foreign_keys = on;
+ CREATE TABLE p1(a PRIMARY KEY, b) WITHOUT ROWID;
+ CREATE TABLE c1(x REFERENCES p1 DEFERRABLE INITIALLY DEFERRED);
+
+ INSERT INTO p1 VALUES(1, 'one');
+ INSERT INTO p1 VALUES(2, 'two');
+ INSERT INTO c1 VALUES(1);
+ INSERT INTO c1 VALUES(2);
+}
+
+do_catchsql_test 2.1.2 {
+ BEGIN;
+ DELETE FROM p1 WHERE a=1;
+ INSERT OR REPLACE INTO p1 VALUES(2, 'two');
+ COMMIT;
+} {1 {FOREIGN KEY constraint failed}}
+
+reset_db
+do_execsql_test 2.2.0 {
+ PRAGMA foreign_keys = on;
+ CREATE TABLE p2(a PRIMARY KEY, b);
+ CREATE TABLE c2(
+ x PRIMARY KEY,
+ y REFERENCES p2 DEFERRABLE INITIALLY DEFERRED
+ ) WITHOUT ROWID;
+}
+
+do_catchsql_test 2.2.1 {
+ BEGIN;
+ INSERT INTO c2 VALUES(13, 13);
+ INSERT OR REPLACE INTO c2 VALUES(13, 13);
+ DELETE FROM c2;
+ COMMIT;
+} {0 {}}
+
+reset_db
+do_execsql_test 2.3.0 {
+ PRAGMA foreign_keys = on;
+ CREATE TABLE p3(a PRIMARY KEY, b) WITHOUT ROWID;
+ CREATE TABLE c3(x REFERENCES p3);
+
+ INSERT INTO p3 VALUES(1, 'one');
+ INSERT INTO p3 VALUES(2, 'two');
+ INSERT INTO c3 VALUES(1);
+ INSERT INTO c3 VALUES(2);
+
+ CREATE TRIGGER p3d AFTER DELETE ON p3 WHEN old.a=1 BEGIN
+ INSERT OR REPLACE INTO p3 VALUES(2, 'three');
+ END;
+}
+
+do_catchsql_test 2.3.1 {
+ DELETE FROM p3 WHERE a=1
+} {1 {FOREIGN KEY constraint failed}}
+
+
+do_execsql_test 3.0 {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE t2(
+ a PRIMARY KEY, b, c, d, e,
+ FOREIGN KEY(b, c) REFERENCES t2(d, e)
+ ) WITHOUT ROWID;
+ CREATE UNIQUE INDEX idx ON t2(d, e);
+
+ INSERT INTO t2 VALUES(1, 'one', 'one', 'one', 'one'); -- row is parent of self
+ INSERT INTO t2 VALUES(2, 'one', 'one', 'one', NULL); -- parent is row 1
+}
+
+do_catchsql_test 3.1 {
+ DELETE FROM t2 WHERE a=1;
+} {1 {FOREIGN KEY constraint failed}}
+
+do_execsql_test 4.0 {
+ CREATE TABLE t1 (
+ c1 PRIMARY KEY,
+ c2 NUMERIC,
+ FOREIGN KEY(c1) REFERENCES t1(c2)
+ ) WITHOUT ROWID ;
+ CREATE INDEX t1c1 ON t1(c1);
+ CREATE UNIQUE INDEX t1c1unique ON t1(c2);
+}
+do_catchsql_test 4.1 {
+ INSERT OR REPLACE INTO t1 VALUES(10000, 20000);
+} {1 {FOREIGN KEY constraint failed}}
+do_execsql_test 4.2 {
+ INSERT OR REPLACE INTO t1 VALUES(20000, 20000);
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ PRAGMA foreign_keys = true;
+ CREATE TABLE parent(
+ p TEXT PRIMARY KEY
+ );
+ CREATE TABLE child(
+ c INTEGER UNIQUE,
+ FOREIGN KEY(c) REFERENCES parent(p) DEFERRABLE INITIALLY DEFERRED
+ );
+ BEGIN;
+ INSERT INTO child VALUES(123);
+ INSERT INTO parent VALUES('123');
+ COMMIT;
+}
+do_execsql_test 5.1 {
+ PRAGMA integrity_check;
+} {ok}
+
+do_execsql_test 5.2 {
+ INSERT INTO parent VALUES(1200);
+ BEGIN;
+ INSERT INTO child VALUES(456);
+ UPDATE parent SET p = '456' WHERE p=1200;
+ COMMIT;
+}
+do_execsql_test 5.3 {
+ PRAGMA integrity_check;
+} {ok}
+
+#-------------------------------------------------------------------------
+reset_db
+forcedelete test.db2
+do_execsql_test 6.1 {
+ PRAGMA foreign_keys = on;
+ CREATE TABLE c1(b);
+ INSERT INTO c1 VALUES(123);
+}
+
+do_execsql_test 6.2 {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.p1(a INTEGER PRIMARY KEY);
+ CREATE TABLE aux.c1(b REFERENCES p1(a) ON DELETE RESTRICT);
+
+ INSERT INTO aux.p1 VALUES(123);
+}
+
+do_execsql_test 6.3 {
+ DELETE FROM aux.p1 WHERE a=123;
+}
+
+
+finish_test
diff --git a/test/fkey_malloc.test b/test/fkey_malloc.test
new file mode 100644
index 0000000..382e6f6
--- /dev/null
+++ b/test/fkey_malloc.test
@@ -0,0 +1,134 @@
+# 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;
+ PRAGMA foreign_key_check;
+}
+
+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 "FOREIGN KEY constraint failed"
+ || $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/fordelete.test b/test/fordelete.test
new file mode 100644
index 0000000..39c0c35
--- /dev/null
+++ b/test/fordelete.test
@@ -0,0 +1,209 @@
+# 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
+set ::testprefix fordelete
+
+# This function returns a list of the tables or indexes opened with
+# OP_OpenWrite instructions when the SQL statement passed as the only
+# argument is executed. If the OPFLAG_FORDELETE flag is specified on
+# the OP_OpenWrite, an asterix is appended to the object name. The list
+# is sorted in [lsort] order before it is returned.
+#
+proc analyze_delete_program {sql} {
+ # Build a map from root page to table/index name.
+ db eval {
+ SELECT name, rootpage FROM sqlite_master
+ } {
+ set T($rootpage) $name
+ }
+
+ # For each OpenWrite instruction generated for the proposed DELETE
+ # statement, add the following array entries:
+ #
+ # $M(<cursor number>) -> <object name>
+ # $O(<object name>) -> "*" | ""
+ #
+ # The O() entry is set to "*" if the BTREE_FORDELETE flag is specified,
+ # or "" otherwise.
+ #
+ db eval "EXPLAIN $sql" R {
+ if {$R(opcode)=="OpenWrite"} {
+ set root $R(p2)
+ set csr $R(p1)
+ if {[info exists T($root)]} { set M($csr) $T($root) }
+
+ set obj $T($root)
+ set O($obj) ""
+ if {$R(p5) & 0x08} {
+ set O($obj) *
+ } else {
+ set O($obj) ""
+ }
+ }
+ }
+
+ db eval "EXPLAIN $sql" R {
+ if {$R(opcode) == "Delete"} {
+ set csr $R(p1)
+ if {[info exists M($csr)]} {
+ set idxdelete [expr {("0x$R(p5)" & 0x04) ? 1 : 0}]
+ if {$idxdelete} {
+ append O($M($csr)) "+"
+ }
+ }
+ }
+ }
+
+ set res [list]
+ foreach {k v} [array get O] {
+ lappend res "${k}${v}"
+ }
+
+ lsort $res
+}
+
+proc do_adp_test {tn sql res} {
+ uplevel [list do_test $tn [list analyze_delete_program $sql] [list {*}$res]]
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+}
+
+foreach {tn sql res} {
+ 1 { DELETE FROM t1 WHERE a=?} { sqlite_autoindex_t1_1 t1*+ }
+ 2 { DELETE FROM t1 WHERE a=? AND b=? } { sqlite_autoindex_t1_1 t1+ }
+ 3 { DELETE FROM t1 WHERE a>? } { sqlite_autoindex_t1_1 t1*+ }
+ 4 { DELETE FROM t1 WHERE rowid=? } { sqlite_autoindex_t1_1* t1 }
+} {
+ do_adp_test 1.$tn $sql $res
+}
+
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a, b, c);
+ CREATE INDEX t2a ON t2(a);
+ CREATE INDEX t2b ON t2(b);
+ CREATE INDEX t2c ON t2(c);
+}
+foreach {tn sql res} {
+ 1 { DELETE FROM t2 WHERE a=?} { t2*+ t2a t2b* t2c* }
+ 2 { DELETE FROM t2 WHERE a=? AND +b=?} { t2+ t2a t2b* t2c* }
+ 3 { DELETE FROM t2 WHERE a=? OR b=?} { t2 t2a* t2b* t2c* }
+ 4 { DELETE FROM t2 WHERE +a=? } { t2 t2a* t2b* t2c* }
+ 5 { DELETE FROM t2 WHERE rowid=? } { t2 t2a* t2b* t2c* }
+} {
+ do_adp_test 2.$tn $sql $res
+}
+
+#-------------------------------------------------------------------------
+# Test that a record that consists of the bytes:
+#
+# 0x01 0x00
+#
+# is interpreted by OP_Column as a vector of NULL values (assuming the
+# default column values are NULL). Also test that:
+#
+# 0x00
+#
+# is handled in the same way.
+#
+do_execsql_test 3.0 {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c, d);
+ CREATE TABLE x2(a INTEGER PRIMARY KEY, b, c, d);
+}
+
+do_test 3.1 {
+ set root [db one { SELECT rootpage FROM sqlite_master WHERE name = 'x1' }]
+ db eval {
+ BEGIN IMMEDIATE;
+ }
+ set bt [btree_from_db db]
+ set csr [btree_cursor $bt $root 1]
+ btree_insert $csr 5 "\000"
+ btree_close_cursor $csr
+ db eval { COMMIT }
+
+ db eval {
+ SELECT * FROM x1;
+ }
+} {5 {} {} {}}
+
+do_test 3.2 {
+ set root [db one { SELECT rootpage FROM sqlite_master WHERE name = 'x2' }]
+ db eval {
+ BEGIN IMMEDIATE;
+ }
+ set bt [btree_from_db db]
+ set csr [btree_cursor $bt $root 1]
+ btree_insert $csr 6 "\000"
+ btree_close_cursor $csr
+ db eval { COMMIT }
+
+ db eval {
+ SELECT * FROM x2;
+ }
+} {6 {} {} {}}
+
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE log(x);
+ CREATE TABLE p1(one PRIMARY KEY, two);
+
+ CREATE TRIGGER tr_bd BEFORE DELETE ON p1 BEGIN
+ INSERT INTO log VALUES('delete');
+ END;
+ INSERT INTO p1 VALUES('a', 'A'), ('b', 'B'), ('c', 'C');
+ DELETE FROM p1 WHERE one = 'a';
+}
+
+reset_db
+do_execsql_test 4.1 {
+ BEGIN TRANSACTION;
+ CREATE TABLE tbl(a PRIMARY KEY, b, c);
+ CREATE TABLE log(a, b, c);
+ INSERT INTO "tbl" VALUES(1,2,3);
+ CREATE TRIGGER the_trigger BEFORE DELETE ON tbl BEGIN
+ INSERT INTO log VALUES(1, 2,3);
+ END;
+ COMMIT;
+ DELETE FROM tbl WHERE a=1;
+}
+
+reset_db
+do_execsql_test 5.1 {
+ PRAGMA foreign_keys = 1;
+ 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
+ );
+} {}
+do_execsql_test 5.2 {
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t2 VALUES(1, 2);
+ SELECT * FROM t2;
+} {1 2}
+do_execsql_test 5.3 {
+ DELETE FROM t1 WHERE a = 2;
+} {}
+
+
+finish_test
diff --git a/test/format4.test b/test/format4.test
new file mode 100644
index 0000000..a850ce2
--- /dev/null
+++ b/test/format4.test
@@ -0,0 +1,66 @@
+# 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}
+sqlite3_db_config db LEGACY_FILE_FORMAT 0
+
+# 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..3ed0952
--- /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}}
+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}}
+# 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..176c619
--- /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}}
+
+# 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..de319ea
--- /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}}
+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}}
+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..fcd3ca3
--- /dev/null
+++ b/test/fts3_common.tcl
@@ -0,0 +1,420 @@
+# 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.
+#
+
+#-------------------------------------------------------------------------
+# INSTRUCTIONS
+#
+# The following commands are available:
+#
+# fts3_build_db_1 N
+# Using database handle [db] create an FTS4 table named t1 and populate
+# it with N rows of data. N must be less than 10,000. Refer to the
+# header comments above the proc implementation below for details.
+#
+# fts3_build_db_2 N
+# Using database handle [db] create an FTS4 table named t2 and populate
+# it with N rows of data. N must be less than 100,000. Refer to the
+# header comments above the proc implementation below for details.
+#
+# fts3_integrity_check TBL
+# TBL must be an FTS table in the database currently opened by handle
+# [db]. This proc loads and tokenizes all documents within the table,
+# then checks that the current contents of the FTS index matches the
+# results.
+#
+# fts3_terms TBL WHERE
+# Todo.
+#
+# fts3_doclist TBL TERM WHERE
+# Todo.
+#
+#
+#
+
+ifcapable fts3 {
+ sqlite3_fts3_may_be_corrupt 0
+}
+
+#-------------------------------------------------------------------------
+# USAGE: fts3_build_db_1 SWITCHES N
+#
+# Build a sample FTS table in the database opened by database connection
+# [db]. The name of the new table is "t1".
+#
+proc fts3_build_db_1 {args} {
+
+ set default(-module) fts4
+
+ set nArg [llength $args]
+ if {($nArg%2)==0} {
+ error "wrong # args: should be \"fts3_build_db_1 ?switches? n\""
+ }
+
+ set n [lindex $args [expr $nArg-1]]
+ array set opts [array get default]
+ array set opts [lrange $args 0 [expr $nArg-2]]
+ foreach k [array names opts] {
+ if {0==[info exists default($k)]} { error "unknown option: $k" }
+ }
+
+ if {$n > 10000} {error "n must be <= 10000"}
+ db eval "CREATE VIRTUAL TABLE t1 USING $opts(-module) (x, y)"
+
+ set xwords [list zero one two three four five six seven eight nine ten]
+ set ywords [list alpha beta gamma delta epsilon zeta eta theta iota kappa]
+
+ for {set i 0} {$i < $n} {incr i} {
+ set x ""
+ set y ""
+
+ set x [list]
+ lappend x [lindex $xwords [expr ($i / 1000) % 10]]
+ lappend x [lindex $xwords [expr ($i / 100) % 10]]
+ lappend x [lindex $xwords [expr ($i / 10) % 10]]
+ lappend x [lindex $xwords [expr ($i / 1) % 10]]
+
+ set y [list]
+ lappend y [lindex $ywords [expr ($i / 1000) % 10]]
+ lappend y [lindex $ywords [expr ($i / 100) % 10]]
+ lappend y [lindex $ywords [expr ($i / 10) % 10]]
+ lappend y [lindex $ywords [expr ($i / 1) % 10]]
+
+ db eval { INSERT INTO t1(docid, x, y) VALUES($i, $x, $y) }
+ }
+}
+
+#-------------------------------------------------------------------------
+# USAGE: fts3_build_db_2 N ARGS
+#
+# Build a sample FTS table in the database opened by database connection
+# [db]. The name of the new table is "t2".
+#
+proc fts3_build_db_2 {args} {
+
+ set default(-module) fts4
+ set default(-extra) ""
+
+ set nArg [llength $args]
+ if {($nArg%2)==0} {
+ error "wrong # args: should be \"fts3_build_db_1 ?switches? n\""
+ }
+
+ set n [lindex $args [expr $nArg-1]]
+ array set opts [array get default]
+ array set opts [lrange $args 0 [expr $nArg-2]]
+ foreach k [array names opts] {
+ if {0==[info exists default($k)]} { error "unknown option: $k" }
+ }
+
+ if {$n > 100000} {error "n must be <= 100000"}
+
+ set sql "CREATE VIRTUAL TABLE t2 USING $opts(-module) (content"
+ if {$opts(-extra) != ""} {
+ append sql ", " $opts(-extra)
+ }
+ append sql ")"
+ db eval $sql
+
+ set chars [list 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 < $n} {incr i} {
+ set word ""
+ set nChar [llength $chars]
+ append word [lindex $chars [expr {($i / 1) % $nChar}]]
+ append word [lindex $chars [expr {($i / $nChar) % $nChar}]]
+ append word [lindex $chars [expr {($i / ($nChar*$nChar)) % $nChar}]]
+
+ db eval { INSERT INTO t2(docid, content) VALUES($i, $word) }
+ }
+}
+
+#-------------------------------------------------------------------------
+# 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] {
+ #puts $zTerm
+ 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 {[string compare $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 nDoclist [gobble_varint blob]
+ set doclist [gobble_string blob $nDoclist]
+
+ 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
+ " {
+ set c 0
+ binary scan $root c c
+ if {$c==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..cb1bde7
--- /dev/null
+++ b/test/fts3aa.test
@@ -0,0 +1,265 @@
+# 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
+set testprefix fts3aa
+
+# 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}
+
+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}}
+
+do_execsql_test 8.0 {
+ CREATE VIRTUAL TABLE t0 USING fts4(order=desc);
+ BEGIN;
+ INSERT INTO t0(rowid, content) VALUES(1, 'abc');
+ UPDATE t0 SET docid=5 WHERE docid=1;
+ INSERT INTO t0(rowid, content) VALUES(6, 'abc');
+}
+do_execsql_test 8.1 {
+ SELECT docid FROM t0 WHERE t0 MATCH 'abc';
+} {6 5}
+do_execsql_test 8.2 {
+ SELECT docid FROM t0 WHERE t0 MATCH '"abc abc"';
+} {}
+do_execsql_test 8.3 { COMMIT }
+do_execsql_test 8.4 {
+ SELECT docid FROM t0 WHERE t0 MATCH 'abc';
+} {6 5}
+do_execsql_test 8.5 {
+ SELECT docid FROM t0 WHERE t0 MATCH '"abc abc"';
+} {}
+
+do_execsql_test 9.1 {
+ CREATE VIRTUAL TABLE t9 USING fts4(a, "", '---');
+}
+do_execsql_test 9.2 {
+ CREATE VIRTUAL TABLE t10 USING fts3(<, b, c);
+}
+
+do_execsql_test 10.0 {
+ CREATE VIRTUAL TABLE z1 USING fts3;
+ INSERT INTO z1 VALUES('one two three'),('four one five'),('six two five');
+ CREATE TRIGGER z1r1 AFTER DELETE ON z1_content BEGIN
+ DELETE FROM z1;
+ END;
+}
+do_catchsql_test 10.1 {
+ DELETE FROM z1;
+} {1 {SQL logic error}}
+
+expand_all_sql db
+finish_test
diff --git a/test/fts3ab.test b/test/fts3ab.test
new file mode 100644
index 0000000..86124f7
--- /dev/null
+++ b/test/fts3ab.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 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 ,]);"
+}
+
+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..9b658d1
--- /dev/null
+++ b/test/fts3ag.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 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 {
+ 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..b17b5bd
--- /dev/null
+++ b/test/fts3ai.test
@@ -0,0 +1,92 @@
+# 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
+}
+
+ifcapable !utf16 {
+ 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..0c89691
--- /dev/null
+++ b/test/fts3aj.test
@@ -0,0 +1,87 @@
+# 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.
+#
+
+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..080efe5
--- /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..d9b2233
--- /dev/null
+++ b/test/fts3ao.test
@@ -0,0 +1,250 @@
+# 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}}
+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}}
+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}
+
+# At one point this was causing a memory leak.
+#
+foreach {tn sql} {
+ 1 {}
+ 2 { INSERT INTO ft(ft) VALUES('merge=2,2'); }
+} {
+ reset_db
+ do_execsql_test 6.$tn.1 "
+ CREATE TABLE t1(x);
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft VALUES('hello world');
+ $sql
+ "
+
+ db close
+ sqlite3 db test.db
+ do_execsql_test 6.$tn.2 { SELECT * FROM t1 } {}
+
+ do_test 6.$tn.3 {
+ sqlite3 db2 test.db
+ db2 eval { DROP TABLE t1 }
+ db2 close
+ set stmt [sqlite3_prepare db { SELECT * FROM ft } -1 dummy]
+ sqlite3_finalize $stmt
+ } {SQLITE_OK}
+ db close
+}
+
+finish_test
diff --git a/test/fts3atoken.test b/test/fts3atoken.test
new file mode 100644
index 0000000..4981480
--- /dev/null
+++ b/test/fts3atoken.test
@@ -0,0 +1,287 @@
+# 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 fts3atoken
+
+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 fts3atoken-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.
+#
+sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1
+do_test fts3atoken-1.1 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
+ }
+} {1 {unknown tokenizer: blah}}
+do_test fts3atoken-1.2 {
+ execsql {
+ SELECT fts3_tokenizer('blah', fts3_tokenizer('simple')) IS NULL;
+ }
+} {0}
+do_test fts3atoken-1.3 {
+ execsql {
+ SELECT fts3_tokenizer('blah') == fts3_tokenizer('simple');
+ }
+} {1}
+do_test fts3atoken-1.4 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
+ }
+} {0 {}}
+do_test fts3atoken-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');
+ SELECT content FROM t1 WHERE content MATCH 'movement'
+ }
+} {{There was movement at the station}}
+
+unset -nocomplain simple blah2name simplename
+set simplename "simple"
+set blah2name "blah2"
+set simple [db one {SELECT fts3_tokenizer('simple')}]
+sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 0
+do_catchsql_test 1.6 {
+ SELECT fts3_tokenizer('blah', fts3_tokenizer('simple')) IS NULL;
+} {1 {fts3tokenize disabled}}
+do_test fts3atoken-1.7 {
+ execsql {
+ SELECT fts3_tokenizer('blah2', $simple) IS NULL;
+ }
+} {1}
+
+# With ENABLE_FTS3_TOKENIZER off, the fts3_tokenzer(1) function
+# returns NULL unless the first parameter is a bound parameter.
+# If the first parameter is a bound parameter, then fts3_tokenizer(1)
+# returns the actual pointer value as a BLOB.
+#
+do_test fts3atoken-1.8 {
+ execsql {
+ SELECT fts3_tokenizer($blah2name) == fts3_tokenizer($simplename),
+ typeof(fts3_tokenizer($blah2name)),
+ typeof(fts3_tokenizer('blah2')),
+ typeof(fts3_tokenizer($simplename)),
+ typeof(fts3_tokenizer('simple'));
+ }
+} {1 blob null blob null}
+
+# With ENABLE_FTS3_TOKENIZER on, fts3_tokenizer() always returns
+# the BLOB pointer, regardless the parameter
+#
+sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1
+do_test fts3atoken-1.9 {
+ execsql {
+ SELECT fts3_tokenizer('blah2') == fts3_tokenizer('simple'),
+ typeof(fts3_tokenizer($blah2name)),
+ typeof(fts3_tokenizer('blah2')),
+ typeof(fts3_tokenizer($simplename)),
+ typeof(fts3_tokenizer('simple'));
+ }
+} {1 blob blob blob blob}
+
+# 2019-12-31: The fts3_tokenizer() function can never be invoked from
+# within a trigger or view.
+#
+do_catchsql_test fts3atoken-1.10 {
+ CREATE VIEW v110(x) AS
+ SELECT fts3_tokenizer('tok110', fts3_tokenizer('simple')) IS NULL;
+} {0 {}}
+do_catchsql_test fts3atoken-1.11 {
+ SELECT * FROM v110;
+} {1 {unsafe use of fts3_tokenizer()}}
+do_catchsql_test fts3atoken-1.12 {
+ CREATE TABLE t110(a,b);
+ CREATE TRIGGER r110 AFTER INSERT ON t110 BEGIN
+ SELECT fts3_tokenizer('tok110', fts3_tokenizer('simple')) IS NULL;
+ END;
+} {0 {}}
+do_catchsql_test fts3atoken-1.13 {
+ INSERT INTO t110(a,b) VALUES(1,2);
+} {1 {unsafe use of fts3_tokenizer()}}
+do_catchsql_test fts3atoken-1.14 {
+ SELECT * FROM t110;
+} {0 {}}
+
+#--------------------------------------------------------------------------
+# Test cases fts3atoken-2.* test error cases in the scalar function based
+# API for getting and setting tokenizers.
+#
+do_test fts3atoken-2.1 {
+ catchsql {
+ SELECT fts3_tokenizer('nosuchtokenizer');
+ }
+} {1 {unknown tokenizer: nosuchtokenizer}}
+
+#--------------------------------------------------------------------------
+# Test cases fts3atoken-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.
+#
+sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1
+do_test fts3atoken-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 fts3atoken-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 fts3atoken-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 fts3atoken-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 fts3atoken-4.1 en_US {} {}
+ do_icu_test fts3atoken-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 fts3atoken-4.3 th_TH $input $output
+ do_icu_test fts3atoken-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 fts3atoken-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 fts3atoken-4.6 MiddleOfTheOcean $input $output
+ do_icu_test fts3atoken-4.7 th_TH $input $output
+ do_icu_test fts3atoken-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;
+ }
+
+ proc cp_to_str {codepoint_list} {
+ set fmt [string repeat %c [llength $codepoint_list]]
+ eval [list format $fmt] $codepoint_list
+ }
+
+ do_test 5.2 {
+ set str [cp_to_str {19968 26085 32822 32645 27874 23433 20986}]
+ execsql { INSERT INTO x1 VALUES($str) }
+ } {}
+}
+
+do_test fts3atoken-internal {
+ execsql { SELECT fts3_tokenizer_internal_test() }
+} {ok}
+
+#-------------------------------------------------------------------------
+# Test empty tokenizer names.
+#
+do_catchsql_test 6.1.1 {
+ CREATE VIRTUAL TABLE t3 USING fts4(tokenize="");
+} {1 {unknown tokenizer: }}
+do_catchsql_test 6.1.2 {
+ CREATE VIRTUAL TABLE t3 USING fts4(tokenize=);
+} {1 {unknown tokenizer: }}
+do_catchsql_test 6.1.3 {
+ CREATE VIRTUAL TABLE t3 USING fts4(tokenize=" ");
+} {1 {unknown tokenizer: }}
+
+do_catchsql_test 6.2.1 {
+ SELECT fts3_tokenizer(NULL);
+} {1 {unknown tokenizer: }}
+
+sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1
+do_catchsql_test 6.2.2 {
+ SELECT fts3_tokenizer(NULL, X'1234567812345678');
+} {1 {argument type mismatch}}
+do_catchsql_test 6.2.3 {
+ SELECT fts3_tokenizer(NULL, X'12345678');
+} {1 {argument type mismatch}}
+
+
+finish_test
diff --git a/test/fts3auto.test b/test/fts3auto.test
new file mode 100644
index 0000000..1919397
--- /dev/null
+++ b/test/fts3auto.test
@@ -0,0 +1,717 @@
+# 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 {
+ ifcapable fts4_deferred { set deferred $v }
+ }
+ default {
+ error "bad option \"$k\": must be -deferred"
+ }
+ }
+ }
+
+ get_near_results $tbl $match $deferred aHit
+ get_near_results $tbl [string map {AND OR} $match] $deferred aMatchinfo
+
+ set matchinfo_asc [list]
+ foreach docid [lsort -integer -incr [array names aHit]] {
+ lappend matchinfo_asc $docid $aMatchinfo($docid)
+ }
+ set matchinfo_desc [list]
+ foreach docid [lsort -integer -decr [array names aHit]] {
+ lappend matchinfo_desc $docid $aMatchinfo($docid)
+ }
+
+ set title "(\"$match\" -> [llength [array names aHit]] rows)"
+
+ do_execsql_test $tn$title.1 "
+ SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid ASC
+ " [lsort -integer -incr [array names aHit]]
+
+ do_execsql_test $tn$title.2 "
+ SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid DESC
+ " [lsort -integer -decr [array names aHit]]
+
+ 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} {
+ sqlite3_db_config db DEFENSIVE 0
+ 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}
+
+ ifcapable fts4_deferred {
+ 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') }
+ ifcapable fts4_deferred {
+ expr {[fts3_zero_long_segments t1 $limit]>0}
+ } else {
+ expr 1
+ }
+ } {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*}
+
+ ifcapable fts4_deferred {
+ db eval {UPDATE t1_stat SET value=x'' WHERE id=0}
+ do_catchsql_test 4.$tn.4.6 {
+ SELECT docid FROM t1 WHERE t1 MATCH 'on* NEAR/3 fi*'
+ } {1 {database disk image is malformed}}
+ }
+}
+
+#--------------------------------------------------------------------------
+# 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..1524d6d
--- /dev/null
+++ b/test/fts3aux1.test
@@ -0,0 +1,531 @@
+# 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'
+} {/*SCAN terms VIRTUAL TABLE INDEX 1:*/}
+do_execsql_test 2.1.1.2 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term='braid'
+} {/*SCAN terms VIRTUAL TABLE INDEX 0:*/}
+
+# 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
+} {1}
+do_test 2.1.2.2 {
+ set cnt 0
+ execsql { SELECT * FROM terms_v WHERE rec('cnt', term) AND +term='braid' }
+ set cnt
+} {19}
+
+# 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
+} {19}
+
+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'
+} {/*SCAN terms VIRTUAL TABLE INDEX 2:*/}
+do_execsql_test 2.2.1.2 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term>'brain'
+} {/*SCAN terms VIRTUAL TABLE INDEX 0:*/}
+
+do_execsql_test 2.2.1.3 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term<'brain'
+} {/*SCAN terms VIRTUAL TABLE INDEX 4:*/}
+do_execsql_test 2.2.1.4 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term<'brain'
+} {/*SCAN terms VIRTUAL TABLE INDEX 0:*/}
+
+do_execsql_test 2.2.1.5 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term BETWEEN 'brags' AND 'brain'
+} {/*SCAN terms VIRTUAL TABLE INDEX 6:*/}
+do_execsql_test 2.2.1.6 {
+ EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term BETWEEN 'brags' AND 'brain'
+} {/*SCAN terms VIRTUAL TABLE INDEX 0:*/}
+
+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 {SCAN terms VIRTUAL TABLE INDEX 0:}
+ if {$sort} { append res {*USE TEMP B-TREE FOR ORDER BY} }
+ set res "/*$res*/"
+
+ 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 {invalid arguments to fts4aux constructor}}
+do_catchsql_test 3.1.3 {
+ CREATE VIRTUAL TABLE terms2 USING fts4aux(t2, t2);
+} {1 {invalid 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}}
+do_catchsql_test 3.2.3 {
+ SELECT * FROM terms3 WHERE term = 'abc'
+} {1 {SQL logic error}}
+
+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 r1 r2} {
+ do_eqp_test $tn.eqp $sql $r1
+ do_execsql_test $tn $sql $r2
+}
+
+do_plansql_test 4.2 {
+ SELECT y FROM x2, terms WHERE y = term AND col = '*'
+} {
+ QUERY PLAN
+ |--SCAN x2
+ `--SCAN terms VIRTUAL TABLE INDEX 1:
+} {
+ 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 = '*'
+} {
+ QUERY PLAN
+ |--SCAN x2
+ `--SCAN terms VIRTUAL TABLE INDEX 1:
+} {
+ 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 = '*'
+} {
+ QUERY PLAN
+ |--SCAN terms VIRTUAL TABLE INDEX 0:
+ `--SEARCH x3 USING COVERING INDEX i1 (y=?)
+} {
+ 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 = '*'
+} {
+ QUERY PLAN
+ |--SCAN terms VIRTUAL TABLE INDEX 0:
+ `--SEARCH x3 USING COVERING INDEX i1 (y=?)
+} {
+ 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}
+
+#-------------------------------------------------------------------------
+# Test that we can create an fts4aux table in the temp database.
+#
+forcedelete test.db2
+do_execsql_test 6.1 {
+ CREATE VIRTUAL TABLE ft1 USING fts4(x, y);
+ INSERT INTO ft1 VALUES('a b', 'c d');
+ INSERT INTO ft1 VALUES('e e', 'c d');
+ INSERT INTO ft1 VALUES('a a', 'b b');
+ CREATE VIRTUAL TABLE temp.aux1 USING fts4aux(main, ft1);
+ SELECT * FROM aux1;
+} {
+ a * 2 3 a 0 2 3
+ b * 2 3 b 0 1 1 b 1 1 2
+ c * 2 2 c 1 2 2
+ d * 2 2 d 1 2 2
+ e * 1 2 e 0 1 2
+}
+
+do_execsql_test 6.2 {
+ ATTACH 'test.db2' AS att;
+ CREATE VIRTUAL TABLE att.ft1 USING fts4(x, y);
+ INSERT INTO att.ft1 VALUES('v w', 'x y');
+ INSERT INTO att.ft1 VALUES('z z', 'x y');
+ INSERT INTO att.ft1 VALUES('v v', 'w w');
+ CREATE VIRTUAL TABLE temp.aux2 USING fts4aux(att, ft1);
+ SELECT * FROM aux2;
+} {
+ v * 2 3 v 0 2 3
+ w * 2 3 w 0 1 1 w 1 1 2
+ x * 2 2 x 1 2 2
+ y * 2 2 y 1 2 2
+ z * 1 2 z 0 1 2
+}
+
+foreach {tn q res1 res2} {
+ 1 { SELECT * FROM %%% WHERE term = 'a' } {a * 2 3 a 0 2 3} {}
+ 2 { SELECT * FROM %%% WHERE term = 'x' } {} {x * 2 2 x 1 2 2}
+
+ 3 { SELECT * FROM %%% WHERE term >= 'y' }
+ {} {y * 2 2 y 1 2 2 z * 1 2 z 0 1 2}
+
+ 4 { SELECT * FROM %%% WHERE term <= 'c' }
+ {a * 2 3 a 0 2 3 b * 2 3 b 0 1 1 b 1 1 2 c * 2 2 c 1 2 2} {}
+} {
+ set sql1 [string map {%%% aux1} $q]
+ set sql2 [string map {%%% aux2} $q]
+
+ do_execsql_test 7.$tn.1 $sql1 $res1
+ do_execsql_test 7.$tn.2 $sql2 $res2
+}
+
+do_test 8.1 {
+ catchsql { CREATE VIRTUAL TABLE att.aux3 USING fts4aux(main, ft1) }
+} {1 {invalid arguments to fts4aux constructor}}
+
+do_test 8.2 {
+ execsql {DETACH att}
+ catchsql { SELECT * FROM aux2 }
+} {1 {SQL logic error}}
+
+finish_test
diff --git a/test/fts3aux2.test b/test/fts3aux2.test
new file mode 100644
index 0000000..9554022
--- /dev/null
+++ b/test/fts3aux2.test
@@ -0,0 +1,168 @@
+# 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 fts3aux2
+
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(a, b, languageid=l);
+ INSERT INTO t1(a, b, l) VALUES
+ ('zero zero', 'zero zero', 0),
+ ('one two', 'three four', 1),
+ ('five six', 'seven eight', 2)
+ ;
+ CREATE VIRTUAL TABLE terms USING fts4aux(t1);
+} {}
+
+do_execsql_test 1.2.1 {
+ SELECT term, documents, occurrences, languageid FROM terms WHERE col = '*';
+} {zero 1 4 0}
+
+do_execsql_test 1.2.2 {
+ SELECT * FROM terms;
+} {zero * 1 4 zero 0 1 2 zero 1 1 2}
+
+do_execsql_test 1.2.3 {
+ SELECT * FROM terms WHERE languageid='';
+} {}
+
+do_execsql_test 1.2.4 {
+ SELECT * FROM terms WHERE languageid=-1;
+} {}
+
+do_execsql_test 1.2.5 {
+ SELECT * FROM terms WHERE languageid=9223372036854775807;
+} {}
+
+do_execsql_test 1.2.6 {
+ SELECT * FROM terms WHERE languageid=-9223372036854775808;
+} {}
+
+do_execsql_test 1.2.7 {
+ SELECT * FROM terms WHERE languageid=NULL;
+} {}
+
+do_execsql_test 1.3.1 {
+ SELECT term, documents, occurrences, languageid
+ FROM terms WHERE col = '*' AND languageid=1;
+} {
+ four 1 1 1 one 1 1 1 three 1 1 1 two 1 1 1
+}
+
+do_execsql_test 1.3.2 {
+ SELECT term, col, documents, occurrences, languageid
+ FROM terms WHERE languageid=1;
+} {
+ four * 1 1 1 four 1 1 1 1
+ one * 1 1 1 one 0 1 1 1
+ three * 1 1 1 three 1 1 1 1
+ two * 1 1 1 two 0 1 1 1
+}
+
+do_execsql_test 1.3.3 {
+ SELECT term, col, documents, occurrences, languageid
+ FROM terms WHERE languageid=1 AND term='zero'
+} {
+}
+
+do_execsql_test 1.3.4 {
+ SELECT term, col, documents, occurrences, languageid
+ FROM terms WHERE languageid='1' AND term='two'
+} {
+ two * 1 1 1 two 0 1 1 1
+}
+
+do_execsql_test 1.3.5 {
+ SELECT term, col, documents, occurrences, languageid
+ FROM terms WHERE languageid='+1' AND term>'four'
+} {
+ one * 1 1 1 one 0 1 1 1
+ three * 1 1 1 three 1 1 1 1
+ two * 1 1 1 two 0 1 1 1
+}
+
+do_execsql_test 1.4.1 {
+ SELECT term, documents, occurrences, languageid
+ FROM terms WHERE col = '*' AND languageid=2;
+} {
+ eight 1 1 2 five 1 1 2 seven 1 1 2 six 1 1 2
+}
+
+do_execsql_test 1.4.2 {
+ SELECT term, col, documents, occurrences, languageid
+ FROM terms WHERE languageid=2;
+} {
+ eight * 1 1 2 eight 1 1 1 2
+ five * 1 1 2 five 0 1 1 2
+ seven * 1 1 2 seven 1 1 1 2
+ six * 1 1 2 six 0 1 1 2
+}
+
+do_execsql_test 1.4.3 {
+ SELECT term, col, documents, occurrences, languageid
+ FROM terms WHERE languageid=2 AND term='five';
+} {
+ five * 1 1 2 five 0 1 1 2
+}
+
+do_execsql_test 1.4.4 {
+ SELECT term, col, documents, occurrences, languageid
+ FROM terms WHERE term='five' AND languageid=2
+} {
+ five * 1 1 2 five 0 1 1 2
+}
+
+do_execsql_test 1.4.5 {
+ SELECT term, col, documents, occurrences, languageid
+ FROM terms WHERE term>='seven' AND languageid=2
+} {
+ seven * 1 1 2 seven 1 1 1 2
+ six * 1 1 2 six 0 1 1 2
+}
+
+do_execsql_test 1.4.6 {
+ SELECT term, col, documents, occurrences, languageid
+ FROM terms WHERE term>='e' AND term<'seven' AND languageid=2
+} {
+ eight * 1 1 2 eight 1 1 1 2
+ five * 1 1 2 five 0 1 1 2
+}
+
+#-------------------------------------------------------------------------
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE ft USING fts3();
+ INSERT INTO ft VALUES('a_234567890123456789');
+ INSERT INTO ft VALUES('b_234567890123456789');
+ INSERT INTO ft VALUES('c_234567890123456789');
+ CREATE VIRTUAL TABLE t2 USING fts4aux(ft);
+}
+
+do_execsql_test 2.1 {
+ SELECT term FROM t2 WHERE term=X'625f323334353637383930313233343536373839';
+}
+
+do_execsql_test 2.2 {
+ SELECT term FROM t2 WHERE term<X'625f003334353637383930313233343536373839';
+} {
+ 234567890123456789 234567890123456789 a a b b
+}
+
+do_execsql_test 2.3 {
+ SELECT term FROM t2 WHERE term=X'625f003334353637383930313233343536373839';
+}
+
+
+finish_test
diff --git a/test/fts3b.test b/test/fts3b.test
new file mode 100644
index 0000000..ee0a1ce
--- /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}}
+
+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..6ceef2c
--- /dev/null
+++ b/test/fts3conf.test
@@ -0,0 +1,254 @@
+# 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" 0 1 {{a b c d} {e f g h}}
+ 12 "UPDATE OR ABORT $T3" 0 1 {{a b c d} {e f g h} {i j k l}}
+ 13 "UPDATE OR FAIL $T3" 0 1 {{a b c d} {e f g h} {i j k l}}
+ 14 "UPDATE OR IGNORE $T3" 0 0 {{a b c d} {e f g h} {i j k l}}
+ 15 "UPDATE OR REPLACE $T3" 0 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
+
+if {$tcl_platform(byteOrder)=="littleEndian"} {
+ do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE t3 USING fts4;
+ REPLACE INTO t3(docid, content) VALUES (1, 'one two');
+ SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'one'
+ } {X'0100000002000000'}
+
+ do_execsql_test 3.2 {
+ REPLACE INTO t3(docid, content) VALUES (2, 'one two three four');
+ SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'four'
+ } {X'0200000003000000'}
+
+ do_execsql_test 3.3 {
+ REPLACE INTO t3(docid, content) VALUES (1, 'one two three four five six');
+ SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'six'
+ } {X'0200000005000000'}
+
+ do_execsql_test 3.4 {
+ UPDATE OR REPLACE t3 SET docid = 2 WHERE docid=1;
+ SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'six'
+ } {X'0100000006000000'}
+
+ do_execsql_test 3.5 {
+ UPDATE OR REPLACE t3 SET docid = 3 WHERE docid=2;
+ SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'six'
+ } {X'0100000006000000'}
+
+ do_execsql_test 3.6 {
+ REPLACE INTO t3(docid, content) VALUES (3, 'one two');
+ SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'one'
+ } {X'0100000002000000'}
+
+ do_execsql_test 3.7 {
+ REPLACE INTO t3(docid, content) VALUES(NULL,'one two three four');
+ REPLACE INTO t3(docid, content) VALUES(NULL,'one two three four five six');
+ SELECT docid FROM t3;
+ } {3 4 5}
+
+ do_execsql_test 3.8 {
+ UPDATE OR REPLACE t3 SET docid = 5, content='three four' WHERE docid = 4;
+ SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'one'
+ } {X'0200000002000000'}
+}
+
+#-------------------------------------------------------------------------
+# Test that the xSavepoint is invoked correctly if the first write
+# operation within a transaction is to a virtual table.
+#
+do_catchsql_test 4.1.1 {
+ CREATE VIRTUAL TABLE t0 USING fts4;
+ BEGIN;
+ INSERT INTO t0(rowid, content) SELECT
+ 1, 'abc' UNION ALL SELECT
+ 2, 'def' UNION ALL SELECT
+ 1, 'ghi';
+} {1 {constraint failed}}
+do_execsql_test 4.1.2 {
+ COMMIT;
+}
+do_execsql_test 4.1.3 {
+ SELECT * FROM t0 WHERE t0 MATCH 'abc';
+ INSERT INTO t0(t0) VALUES('integrity-check');
+} {}
+
+do_execsql_test 4.2.1 {
+ CREATE VIRTUAL TABLE t01 USING fts4;
+ BEGIN;
+ SAVEPOINT abc;
+ INSERT INTO t01 VALUES('a b c');
+ ROLLBACK TO abc;
+ COMMIT;
+}
+do_execsql_test 4.2.2 {
+ SELECT * FROM t01 WHERE t01 MATCH 'b';
+ INSERT INTO t01(t01) VALUES('integrity-check');
+} {}
+
+do_execsql_test 4.3.1 {
+ CREATE VIRTUAL TABLE t02 USING fts4;
+ INSERT INTO t01 VALUES('1 1 1');
+ INSERT INTO t02 VALUES('2 2 2');
+ BEGIN;
+ SAVEPOINT abc;
+ INSERT INTO t01 VALUES('a b c');
+ INSERT INTO t02 VALUES('a b c');
+ ROLLBACK TO abc;
+ COMMIT;
+}
+do_execsql_test 4.3.2 {
+ SELECT * FROM t01 WHERE t01 MATCH 'b';
+ INSERT INTO t01(t01) VALUES('integrity-check');
+} {}
+
+do_execsql_test 4.4.1 {
+ CREATE TABLE A(ID INTEGER PRIMARY KEY, AnotherID INTEGER, Notes TEXT);
+ CREATE VIRTUAL TABLE AFTS USING FTS4 (Notes);
+ CREATE TRIGGER A_DeleteTrigger AFTER DELETE ON A FOR EACH ROW BEGIN
+ DELETE FROM AFTS WHERE rowid=OLD.ID;
+ END;
+ CREATE TABLE B(ID INTEGER PRIMARY KEY,Notes TEXT);
+ CREATE VIRTUAL TABLE BFTS USING FTS3 (Notes);
+ CREATE TRIGGER B_DeleteTrigger AFTER DELETE ON B FOR EACH ROW BEGIN
+ DELETE FROM BFTS WHERE rowid=OLD.ID;
+ END;
+}
+
+do_execsql_test 4.4.2 {
+ BEGIN TRANSACTION;
+ DELETE FROM A WHERE AnotherID=1;
+ DELETE FROM B WHERE ID=1;
+ COMMIT;
+}
+
+
+
+finish_test
diff --git a/test/fts3corrupt.test b/test/fts3corrupt.test
new file mode 100644
index 0000000..69d5030
--- /dev/null
+++ b/test/fts3corrupt.test
@@ -0,0 +1,234 @@
+# 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.
+#
+sqlite3_db_config db DEFENSIVE 0
+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
+
+# 2019-11-18 https://bugs.chromium.org/p/chromium/issues/detail?id=1025467
+# bug1
+db close
+sqlite3 db :memory:
+do_catchsql_test 6.10 {
+ CREATE VIRTUAL TABLE f using fts3(a,b);
+ CREATE TABLE f_stat(id INTEGER PRIMARY KEY, value BLOB);
+ INSERT INTO f_segdir VALUES (2000, 0,0,0, '16', '');
+ INSERT INTO f_segdir VALUES (1999, 0,0,0, '0 18',
+ x'000131030102000103323334050101010200');
+ INSERT INTO f_segments (blockid) values (16);
+ INSERT INTO f_segments values (0, x'');
+ INSERT INTO f_stat VALUES (1,x'cf0f01');
+ INSERT INTO f(f) VALUES ('merge=1');
+} {1 {database disk image is malformed}}
+
+# 2020-03-02 https://bugs.chromium.org/p/chromium/issues/detail?id=1057441
+# The ticket complains of use of an uninitialized value. That part is harmless.
+# The only reason to fix this is the failure to detect a subtly corrupt
+# inverted index.
+#
+reset_db
+do_catchsql_test 7.10 {
+ CREATE VIRTUAL TABLE f USING fts3(a,b);
+ INSERT INTO f_segdir VALUES (0,0,1,0,'0 0',x'01010101020101');
+ SELECT matchinfo( f , 'pcx') FROM f WHERE b MATCH x'c533';
+} {1 {database disk image is malformed}}
+
+reset_db
+sqlite3_fts3_may_be_corrupt 1
+do_execsql_test 8.1 {
+ CREATE VIRTUAL TABLE f USING fts3(a);
+ INSERT INTO f(f) VALUES('nodesize=24');
+ BEGIN;
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz0123456789');
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz0123456789');
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz0123456789');
+
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz012345678X');
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz012345678X');
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz012345678X');
+ COMMIT;
+ BEGIN;
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz0123456789');
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz0123456789');
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz0123456789');
+
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz012345678X');
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz012345678X');
+ INSERT INTO f VALUES('abcdefghijklmnopqrstuvwxyz012345678X');
+ COMMIT;
+
+ SELECT count(*) FROM f_segments;
+} {4}
+
+do_execsql_test 8.2 {
+ UPDATE f_segments SET block = (
+ SELECT block FROM f_segments WHERE blockid=1
+ ) WHERE blockid=2
+}
+
+do_catchsql_test 8.3 {
+ INSERT INTO f(f) VALUES('merge=2,2');
+} {1 {database disk image is malformed}}
+sqlite3_fts3_may_be_corrupt 0
+
+finish_test
diff --git a/test/fts3corrupt2.test b/test/fts3corrupt2.test
new file mode 100644
index 0000000..5864353
--- /dev/null
+++ b/test/fts3corrupt2.test
@@ -0,0 +1,111 @@
+# 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
+sqlite3_fts3_may_be_corrupt 1
+
+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"
+}
+
+sqlite3_db_config db DEFENSIVE 0
+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/fts3corrupt3.test b/test/fts3corrupt3.test
new file mode 100644
index 0000000..eae13f2
--- /dev/null
+++ b/test/fts3corrupt3.test
@@ -0,0 +1,66 @@
+# 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 fts3corrupt3
+
+#-------------------------------------------------------------------------
+# Test that fts3 does not choke on an oversized varint.
+#
+do_execsql_test 1.0 {
+ PRAGMA page_size = 512;
+ CREATE VIRTUAL TABLE t1 USING fts3;
+ BEGIN;
+ INSERT INTO t1 VALUES('one');
+ INSERT INTO t1 VALUES('one');
+ INSERT INTO t1 VALUES('one');
+ COMMIT;
+}
+do_execsql_test 1.1 {
+ SELECT quote(root) from t1_segdir;
+} {X'00036F6E6509010200010200010200'}
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 1.2 {
+ UPDATE t1_segdir SET root = X'00036F6E650EFFFFFFFFFFFFFFFFFFFFFFFF0200';
+}
+do_catchsql_test 1.3 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'one'
+} {0 -1}
+
+#-------------------------------------------------------------------------
+# Interior node with the prefix or suffix count of an entry set to a
+# negative value.
+#
+set doc1 [string repeat "x " 600]
+set doc2 [string repeat "y " 600]
+set doc3 [string repeat "z " 600]
+
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE t2 USING fts3;
+ BEGIN;
+ INSERT INTO t2 VALUES($doc1);
+ INSERT INTO t2 VALUES($doc2);
+ INSERT INTO t2 VALUES($doc3);
+ COMMIT;
+}
+do_execsql_test 2.1 {
+ SELECT quote(root) from t2_segdir;
+} {X'0101017900017A'}
+
+
+
+finish_test
diff --git a/test/fts3corrupt4.test b/test/fts3corrupt4.test
new file mode 100644
index 0000000..f8e89b3
--- /dev/null
+++ b/test/fts3corrupt4.test
@@ -0,0 +1,7667 @@
+# 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
+source $testdir/fts3_common.tcl
+set testprefix fts3corrupt4
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+sqlite3_fts3_may_be_corrupt 1
+database_may_be_corrupt
+extra_schema_checks 0
+
+do_execsql_test 1.0 {
+ BEGIN;
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft VALUES('aback');
+ INSERT INTO ft VALUES('abaft');
+ INSERT INTO ft VALUES('abandon');
+ COMMIT;
+}
+
+proc blob {a} { binary decode hex $a }
+db func blob blob
+
+do_execsql_test 1.1 {
+ SELECT quote(root) FROM ft_segdir;
+} {X'0005616261636B03010200030266740302020003046E646F6E03030200'}
+
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 1.2 {
+ UPDATE ft_segdir SET root = blob(
+ '0005616261636B03010200 FFFFFFFF0702 66740302020003046E646F6E03030200'
+ );
+}
+
+do_catchsql_test 1.3 {
+ SELECT * FROM ft WHERE ft MATCH 'abandon';
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0.0 {
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft(ft) VALUES('nodesize=32');
+}
+do_test 2.0.1 {
+ for {set i 0} {$i < 12} {incr i} {
+ execsql {
+ BEGIN;
+ INSERT INTO ft VALUES('abc' || $i);
+ INSERT INTO ft VALUES('abc' || $i || 'x' );
+ INSERT INTO ft VALUES('abc' || $i || 'xx' );
+ COMMIT
+ }
+ }
+ execsql {
+ SELECT count(*) FROM ft_segdir;
+ SELECT count(*) FROM ft_segments;
+ }
+} {12 0}
+
+do_execsql_test 2.1 {
+ INSERT INTO ft(ft) VALUES('merge=1,4');
+ SELECT count(*) FROM ft_segdir;
+ SELECT count(*) FROM ft_segments;
+} {12 3}
+
+do_execsql_test 2.2 {
+ SELECT quote(block) FROM ft_segments WHERE blockid=2
+} {X'00056162633130031F0200'}
+
+db func blob blob
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 2.3.1 {
+ UPDATE ft_segments SET block =
+ blob('00056162633130031F0200 FFFFFFFF07FF55 66740302020003046E646F6E03030200')
+ WHERE blockid=2;
+} {}
+do_catchsql_test 2.3.2 {
+ INSERT INTO ft(ft) VALUES('merge=1,4');
+} {1 {database disk image is malformed}}
+
+do_execsql_test 2.4.1 {
+ UPDATE ft_segments SET block =
+ blob('00056162633130031F0200 02FFFFFFFF07 66740302020003046E646F6E03030200')
+ WHERE blockid=2;
+} {}
+do_catchsql_test 2.4.2 {
+ INSERT INTO ft(ft) VALUES('merge=1,4');
+} {1 {database disk image is malformed}}
+
+do_execsql_test 2.5.1 {
+ UPDATE ft_segments SET block =
+ blob('00056162633130031F0200 0202 6674 FFFFFF070302020003046E646F6E030200')
+ WHERE blockid=2;
+} {}
+do_catchsql_test 2.5.2 {
+ INSERT INTO ft(ft) VALUES('merge=1,4');
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 3.0.0 {
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft(ft) VALUES('nodesize=32');
+}
+do_test 3.0.1 {
+ execsql BEGIN
+ for {set i 0} {$i < 20} {incr i} {
+ execsql { INSERT INTO ft VALUES('abc' || $i) }
+ }
+ execsql {
+ COMMIT;
+ SELECT count(*) FROM ft_segdir;
+ SELECT count(*) FROM ft_segments;
+ }
+} {1 5}
+
+do_execsql_test 3.1 {
+ SELECT quote(root) FROM ft_segdir
+} {X'0101056162633132040136030132030136'}
+
+db func blob blob
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 3.2 {
+ UPDATE ft_segdir
+ SET root = blob('0101056162633132FFFFFFFF070236030132030136');
+}
+
+do_catchsql_test 3.1 {
+ SELECT * FROM ft WHERE ft MATCH 'abc20'
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3();
+ INSERT INTO t1 VALUES('one two three');
+ UPDATE t1_segdir SET start_block = 1;
+}
+
+do_catchsql_test 4.1 {
+ SELECT * FROM t1 WHERE t1 MATCH 'one';
+} {1 {database disk image is malformed}}
+do_catchsql_test 4.2 {
+ SELECT * FROM t1 WHERE t1 MATCH 'two';
+} {1 {database disk image is malformed}}
+do_catchsql_test 4.3 {
+ SELECT * FROM t1 WHERE t1 MATCH 'three';
+} {1 {database disk image is malformed}}
+do_execsql_test 4.4 {
+ INSERT INTO t1(t1) VALUES('optimize');
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 5.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 24576 pagesize 4096 filename c15.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 04 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e f9 00 06 0d ec 00 0f cd 0f 69 ...............i
+| 112: 0f 01 0e 10 0e c6 0d ec 00 00 00 00 00 00 00 00 ................
+| 3552: 00 00 00 00 00 00 00 00 00 00 00 00 22 06 06 17 ................
+| 3568: 11 11 01 31 74 61 62 6c 65 74 32 74 32 06 43 52 ...1tablet2t2.CR
+| 3584: 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 78 29 EATE TABLE t2(x)
+| 3600: 81 33 04 07 17 1f 1f 01 82 35 74 61 62 6c 65 74 .3.......5tablet
+| 3616: 31 5f 73 65 67 64 69 72 74 31 5f 73 65 67 64 69 1_segdirt1_segdi
+| 3632: 72 04 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 r.CREATE TABLE '
+| 3648: 74 31 5f 73 65 67 64 69 72 27 28 6c 65 76 65 6c t1_segdir'(level
+| 3664: 20 49 4e 54 45 47 45 52 2c 69 64 78 20 49 4e 54 INTEGER,idx INT
+| 3680: 45 47 45 52 2c 73 74 61 72 74 5f 62 6c 6f 63 6b EGER,start_block
+| 3696: 20 49 4e 54 45 47 45 52 2c 6c 65 61 76 65 73 5f INTEGER,leaves_
+| 3712: 65 6e 64 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 end_block INTEGE
+| 3728: 52 2c 65 6e 64 5f 62 6c 6f 63 6b 20 49 4e 54 45 R,end_block INTE
+| 3744: 47 45 52 2c 72 6f 6f 74 20 42 4c 4f 42 2c 50 52 GER,root BLOB,PR
+| 3760: 49 4d 41 52 59 20 4b 45 59 28 6c 65 76 65 6c 2c IMARY KEY(level,
+| 3776: 20 69 64 78 29 29 31 05 06 17 45 1f 01 00 69 6e idx))1...E...in
+| 3792: 64 65 78 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e dexsqlite_autoin
+| 3808: 64 65 79 5f 74 31 5f 73 65 67 64 69 72 5f 31 74 dey_t1_segdir_1t
+| 3824: 31 5f 73 65 67 64 69 72 05 00 00 00 08 00 00 00 1_segdir........
+| 3840: 00 66 03 07 17 23 23 01 81 13 74 61 62 6c 65 74 .f...##...tablet
+| 3856: 31 5f 73 65 67 6d 65 6e 74 73 74 31 5f 73 65 67 1_segmentst1_seg
+| 3872: 6d 65 6e 74 73 03 43 52 45 41 54 45 20 54 41 42 ments.CREATE TAB
+| 3888: 4c 45 20 27 74 31 5f 73 65 67 6d 65 6e 74 73 27 LE 't1_segments'
+| 3904: 28 62 6c 6f 63 6b 69 64 20 49 4e 54 45 47 45 52 (blockid INTEGER
+| 3920: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 6c PRIMARY KEY, bl
+| 3936: 6f 63 6b 20 42 4c 4f 42 29 62 02 07 17 21 21 01 ock BLOB)b...!!.
+| 3952: 81 0f 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65 6e ..tablet1_conten
+| 3968: 74 74 31 5f 63 6f 6e 74 65 6e 74 02 43 52 45 41 tt1_content.CREA
+| 3984: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e TE TABLE 't1_con
+| 4000: 74 65 6e 74 27 28 64 6f 63 69 64 20 49 4e 54 45 tent'(docid INTE
+| 4016: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
+| 4032: 20 27 63 30 63 6f 6e 74 65 6e 74 27 29 31 01 06 'c0content')1..
+| 4048: 17 11 11 08 51 74 61 62 6c 65 74 31 74 31 43 52 ....Qtablet1t1CR
+| 4064: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4080: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| page 2 offset 4096
+| 0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00 ................
+| 4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00 .....abandon....
+| 4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b .abaft.....aback
+| page 3 offset 8192
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 4 offset 12288
+| 0: 0d 00 00 00 01 0f d6 00 0f d6 00 00 00 00 00 00 ................
+| 4048: 00 00 00 00 00 00 28 01 07 08 08 08 08 15 46 30 ......(.......F0
+| 4064: 20 32 39 00 05 61 62 61 63 6b 03 01 02 00 03 02 29..aback......
+| 4080: 66 74 03 02 02 00 03 04 6e 64 6f 60 30 30 20 00 ft......ndo`00 .
+| page 5 offset 16384
+| 0: a0 00 00 00 10 ff b0 00 ff fb 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 04 04 08 08 09 ................
+| page 6 offset 20480
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7 ................
+| 16: 0f b8 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 ..'t1_content'(d
+| 32: 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 ocid INTEGER PRI
+| 48: 4d 41 52 59 20 4b 45 59 2c 20 27 63 30 63 6f 6e MARY KEY, 'c0con
+| 64: 74 65 6e 74 27 29 31 01 06 17 11 11 08 51 74 61 tent')1......Qta
+| 80: 62 6c 65 74 31 74 31 43 52 45 41 54 45 20 56 49 blet1t1CREATE VI
+| 96: 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 RTUAL TABLE t1 U
+| 112: 53 49 4e 47 20 66 74 73 33 0d 00 00 00 03 0f e0 SING fts3.......
+| 128: 00 0f f6 0f ec 0f e0 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end c15.db
+}]} {}
+
+do_catchsql_test 5.1 {
+ SELECT * FROM t1 WHERE t1 MATCH 'abandon';
+} {1 {malformed database schema (sqlite_autoindey_t1_segdir_1) - orphan index}}
+
+
+#-------------------------------------------------------------------------
+reset_db
+database_may_be_corrupt
+do_execsql_test 6.0 {
+ CREATE VIRTUAL TABLE Table0 USING fts3();
+ INSERT INTO Table0_segdir VALUES(1,NULL,1,NULL,NULL,NULL);
+}
+
+do_catchsql_test 6.1 {
+ SELECT * FROM Table0 WHERE Table0 MATCH 'a';
+} {0 {}}
+
+do_catchsql_test 6.2 {
+ INSERT INTO Table0(Table0) VALUES('optimize');
+} {0 {}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 7.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 32768 pagesize 4096 filename crash-04bb6e7c811ce9.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e ef 00 07 0d 4d 00 0f bd 0f 5f ..........M...._
+| 112: 0e f7 0e 06 0e bc 0d a4 0d 4d 00 00 00 00 00 00 .........M......
+| 3392: 00 00 00 00 00 00 00 00 00 00 00 00 00 55 07 07 .............U..
+| 3408: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 73 74 ......tablet1_st
+| 3424: 61 74 74 31 5f 73 74 61 74 07 43 52 45 41 54 45 att1_stat.CREATE
+| 3440: 20 54 41 42 4c 45 20 27 74 31 5f 73 74 61 74 27 TABLE 't1_stat'
+| 3456: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (id INTEGER PRIM
+| 3472: 41 52 59 20 4b 45 59 2c 20 76 61 6c 75 65 20 42 ARY KEY, value B
+| 3488: 4c 4f 42 29 60 06 07 17 21 21 01 81 0b 74 61 62 LOB)`...!!...tab
+| 3504: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64 let1_docsizet1_d
+| 3520: 6f 63 73 69 7a 65 06 43 52 45 41 54 45 20 54 41 ocsize.CREATE TA
+| 3536: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27 BLE 't1_docsize'
+| 3552: 28 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 (docid INTEGER P
+| 3568: 52 49 4d 41 52 59 20 4b 45 59 2c 20 73 69 7a 65 RIMARY KEY, size
+| 3584: 20 42 4c 4f 42 29 81 33 04 07 17 1f 1f 01 82 35 BLOB).3.......5
+| 3600: 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 74 31 tablet1_segdirt1
+| 3616: 5f 73 65 67 64 69 72 04 43 52 45 41 54 45 20 54 _segdir.CREATE T
+| 3632: 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 72 27 ABLE 't1_segdir'
+| 3648: 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 2c 69 (level INTEGER,i
+| 3664: 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 72 74 dx INTEGER,start
+| 3680: 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 6c _block INTEGER,l
+| 3696: 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 6b 20 eaves_end_block
+| 3712: 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c 6f 63 INTEGER,end_bloc
+| 3728: 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 20 42 k INTEGER,root B
+| 3744: 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 59 28 LOB,PRIMARY KEY(
+| 3760: 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 05 06 17 level, idx))1...
+| 3776: 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 65 5f E...indexsqlite_
+| 3792: 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 65 67 autoindex_t1_seg
+| 3808: 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 05 00 dir_1t1_segdir..
+| 3824: 00 00 08 00 00 00 00 66 03 07 17 23 23 01 81 13 .......f...##...
+| 3840: 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e 74 73 tablet1_segments
+| 3856: 74 31 5f 73 65 67 6d 65 6e 74 73 03 43 52 45 41 t1_segments.CREA
+| 3872: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
+| 3888: 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 20 49 ments'(blockid I
+| 3904: 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b NTEGER PRIMARY K
+| 3920: 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 5c EY, block BLOB).
+| 3936: 02 07 17 21 21 01 81 03 74 61 62 6c 65 74 31 5f ...!!...tablet1_
+| 3952: 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 65 6e contentt1_conten
+| 3968: 74 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 t.CREATE TABLE '
+| 3984: 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 63 69 t1_content'(doci
+| 4000: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR
+| 4016: 59 20 4b 45 59 2c 20 27 63 30 61 27 29 41 01 06 Y KEY, 'c0a')A..
+| 4032: 17 11 11 08 71 74 61 62 6c 65 74 31 74 31 43 52 ....qtablet1t1CR
+| 4048: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4064: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 34 LE t1 USING fts4
+| 4080: 28 61 2c 70 72 65 66 69 78 3d 27 31 2c 32 27 29 (a,prefix='1,2')
+| page 2 offset 4096
+| 0: 0d 00 00 00 08 0e 1f 00 0f c4 0f 7c 0f 34 0f 07 ...........|.4..
+| 16: 0e c3 0e 97 0e 63 0e 1f 00 00 00 00 00 00 00 00 .....c..........
+| 3600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ...............B
+| 3616: 08 04 00 81 09 73 75 6e 74 20 69 6e 20 63 75 6c .....sunt in cul
+| 3632: 70 61 20 71 75 69 20 6f 66 66 69 63 69 61 20 64 pa qui officia d
+| 3648: 65 73 65 72 75 6e 74 20 6d 6f 6c 6c 69 74 20 61 eserunt mollit a
+| 3664: 6e 69 6d 20 69 64 20 65 73 74 20 6c 61 62 6f 72 nim id est labor
+| 3680: 75 6d 2e 32 07 03 00 6b 45 78 63 65 70 74 65 75 um.2...kExcepteu
+| 3696: 72 20 73 69 6e 74 20 6f 63 63 61 65 63 67 42 06 r sint occaecgB.
+| 3712: 37 57 06 96 46 17 46 17 42 06 e6 f6 e2 07 07 26 7W..F.F.B......&
+| 3728: f6 96 46 56 e7 42 c2 a0 60 30 05 b6 36 96 c6 c7 ..FV.B..`0..6...
+| 3744: 56 d2 06 46 f6 c6 f7 26 52 06 57 52 06 67 56 7c V..F...&R.WR.gV|
+| 3760: 65 3f 04 20 6e 75 6c 6c 61 20 70 61 72 69 61 74 e?. nulla pariat
+| 3776: 75 72 2e 42 05 04 00 81 09 44 75 69 73 20 61 75 ur.B.....Duis au
+| 3792: 74 65 20 69 72 75 72 65 20 64 6f 6c 6f 72 20 69 te irure dolor i
+| 3808: 6e 20 72 65 70 72 65 68 65 6e 64 65 72 69 74 20 n reprehenderit
+| 3824: 69 6e 20 76 6f 6c 75 70 74 61 74 65 20 76 65 6c in voluptate vel
+| 3840: 69 74 20 65 73 73 65 2b 04 03 00 5d 6e 69 73 69 it esse+...]nisi
+| 3856: 20 75 74 20 61 6c 69 71 75 69 70 20 65 78 20 65 ut aliquip ex e
+| 3872: 61 20 63 6f 6d 6d 6f 64 6f 20 63 6f 6e 73 65 71 a commodo conseq
+| 3888: 75 61 74 2e 46 03 04 00 81 11 55 74 20 65 6e 69 uat.F.....Ut eni
+| 3904: 6d 20 61 64 20 6d 69 6e 69 6d 20 76 65 6e 69 61 m ad minim venia
+| 3920: 6d 2c 20 71 75 69 73 20 6e 6f 73 74 72 75 64 20 m, quis nostrud
+| 3936: 65 78 65 72 63 69 74 61 74 69 6f 6e 20 75 6c 6c exercitation ull
+| 3952: 61 6d 63 6f 20 6c 61 62 6f 72 69 73 46 02 04 00 amco laborisF...
+| 3968: 81 11 73 65 64 20 64 6f 20 65 69 75 73 6d 6f 64 ..sed do eiusmod
+| 3984: 20 74 65 6d 70 6f 72 20 69 6e 63 69 64 69 64 75 tempor incididu
+| 4000: 6e 74 20 75 74 20 6c 61 62 6f 72 65 20 65 74 20 nt ut labore et
+| 4016: 64 6f 6c 6f 72 65 20 6d 61 67 6e 61 20 61 6c 69 dolore magna ali
+| 4032: 71 75 61 2e 3a 01 03 00 7b 4c 6f 72 65 6d 20 69 qua.:....Lorem i
+| 4048: 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 72 12 29 psum dolor sir.)
+| 4064: 0d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 .et, consectetur
+| 4080: 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 adipiscing elit
+| page 3 offset 8192
+| 0: 0d 00 00 00 00 10 30 00 10 17 50 30 80 20 00 00 ......0...P0. ..
+| 16: 27 46 50 30 20 50 00 00 27 56 c0 30 30 a0 00 10 'FP0 P..'V.00...
+| 32: 17 40 90 20 70 00 10 20 00 10 30 00 00 27 66 50 .@. p.. ..0..'fP
+| 48: 60 30 60 00 20 a0 00 10 16 f0 30 50 90 08 20 a0 `0`. .....0P.. .
+| 64: 20 80 20 80 80 81 78 40 20 40 03 02 03 23 53 10 . ...x@ @...#S.
+| 80: 00 16 11 30 10 60 40 00 10 c0 00 10 40 00 00 00 ...0.`@.....@...
+| 96: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 78 24 ..............x$
+| 112: 41 71 83 37 10 27 97 60 10 40 00 00 16 41 10 10 Aq.7.'.`.@...A..
+| 128: 40 00 10 30 90 00 30 20 50 00 10 30 00 20 70 00 @..0..0 P..0. p.
+| 144: 00 16 51 b0 10 90 00 10 40 70 00 10 30 80 00 10 ..Q.....@p..0...
+| 160: 50 30 00 10 b0 00 10 40 00 10 20 00 10 b0 00 00 P0.....@.. .....
+| 176: 16 60 30 60 50 00 00 16 90 f0 10 30 00 10 60 00 .`0`P......0..`.
+| 192: 30 40 40 40 00 30 30 90 00 00 16 c0 c0 10 20 00 0@@@.00....... .
+| 208: 10 80 00 10 b0 00 50 c0 00 00 16 d0 90 20 b0 00 ......P...... ..
+| 224: 10 50 00 50 80 00 00 16 e0 c0 30 80 00 10 20 00 .P.P......0... .
+| 240: 20 60 00 10 60 00 00 16 f0 60 70 40 00 10 60 00 `..`....`p@..`.
+| 256: 00 17 00 60 60 70 00 10 70 00 00 17 10 60 30 70 ...``p..p....`0p
+| 272: 00 50 50 00 00 17 20 30 50 70 00 00 17 30 c0 10 .PP... 0Pp...0..
+| 288: 50 00 10 20 00 50 30 00 10 20 00 00 17 40 30 20 P.. .P0.. ...@0
+| 304: 50 00 00 17 50 a0 20 70 00 10 20 a0 00 10 30 00 P...P. p.. ...0.
+| 320: 00 17 60 70 30 60 00 20 90 30 08 52 60 10 80 80 ..`p0`. .0.R`...
+| 336: 80 80 81 78 a3 e3 02 03 63 63 50 00 26 16 40 30 ...x....ccP.&.@0
+| 352: 30 40 00 20 86 97 06 97 36 36 96 e6 70 30 10 80 0@. ....66..p0..
+| 368: 00 10 56 c6 97 17 56 10 30 20 c0 00 50 26 97 00 ..V...V.0 ..P&..
+| 384: 30 40 40 00 10 36 d6 57 40 30 10 60 00 10 36 e6 0@@..6.W@0.`..6.
+| 400: 96 d0 30 80 90 00 10 37 57 46 50 30 50 30 00 00 ..0....7WFP0P0..
+| 416: 66 36 96 c6 c7 56 d0 30 60 20 00 10 66 f6 d6 d6 f6...V.0` ..f...
+| 432: f6 46 f0 30 40 70 00 20 96 e7 36 56 37 46 57 47 .F.0@p. ..6V7FWG
+| 448: 57 20 30 10 70 00 50 47 17 56 17 40 30 40 80 00 W 0.p.PG.V.@0@..
+| 464: 10 47 56 c7 06 10 30 80 40 00 20 77 06 96 46 17 .GV...0.@. w..F.
+| 480: 46 17 40 30 70 50 00 00 86 46 57 36 57 27 56 e7 F.@0pP...FW6W'V.
+| 496: 40 30 80 70 00 10 16 f0 30 20 30 00 20 36 c6 f7 @0.p....0 0. 6..
+| 512: 20 60 10 40 00 40 50 00 50 16 50 60 20 a0 00 40 `.@.@P.P.P` ..@
+| 528: 30 00 10 37 56 97 30 30 50 20 00 00 26 56 10 30 0..7V.00P ..&V.0
+| 544: 40 60 00 10 66 97 57 36 d6 f6 40 30 20 40 00 10 @`..f.W6..@0 @..
+| 560: 36 c6 97 40 30 10 90 00 15 35 14 c6 97 46 52 06 6..@0....5...FR.
+| 576: 66 f7 26 d6 17 42 03 30 01 00 00 10 10 04 02 02 f.&..B.0........
+| 592: 00 00 00 00 00 00 00 00 70 00 00 00 00 00 00 00 ........p.......
+| 608: 00 00 00 00 60 00 00 00 40 00 00 00 00 00 00 00 ....`...@.......
+| page 4 offset 12288
+| 0: 0d 00 00 00 03 0a a6 00 0d 57 0c 4a 0a a6 00 00 .........W.J....
+| 2720: 00 00 00 00 00 00 83 21 03 08 02 08 08 08 17 86 .......!........
+| 2736: 30 08 00 30 20 34 30 32 00 02 61 64 06 01 08 00 0..0 402..ad....
+| 2752: 02 04 00 01 01 6c 06 02 0c 00 02 04 00 01 01 6d .....l.........m
+| 2768: 03 01 06 00 01 01 6e 03 08 00 00 91 01 75 03 05 ......n......u..
+| 2784: 03 00 00 02 63 69 03 06 02 00 01 01 6f 07 01 07 ....ci......o...
+| 2800: 00 03 07 03 00 01 01 75 06 07 05 00 01 04 00 00 .......u........
+| 2816: 02 64 65 03 08 07 00 01 01 6f 0d 01 04 00 01 03 .de......o......
+| 2832: 09 00 03 05 00 01 03 00 01 01 75 03 05 02 00 00 ..........u.....
+| 2848: 02 65 61 03 04 06 00 01 01 69 03 02 04 00 01 01 .ea......i......
+| 2864: 6c 03 01 09 00 01 01 6e 30 03 03 00 01 01 73 06 l......n0.....s.
+| 2880: 05 0b 00 03 0b 00 01 01 74 03 02 09 00 01 01 75 ........t......u
+| 2896: 03 06 04 00 01 01 78 09 03 09 00 01 05 00 03 02 ......x.........
+| 2912: 00 00 02 66 75 03 06 05 00 00 02 69 64 03 08 0a ...fu......id...
+| 2928: 00 01 01 6e 0a 02 06 00 03 06 04 00 03 03 00 01 ...n............
+| 2944: 01 70 03 01 03 00 01 01 72 03 05 04 00 00 02 6c .p......r......l
+| 2960: 61 09 02 08 00 01 0b 00 05 0c 00 01 01 6f 03 01 a............o..
+| 2976: 02 00 00 02 6d 61 03 02 0b 00 01 01 69 03 03 05 ....ma......i...
+| 2992: 00 01 01 6f 03 08 08 00 00 02 6e 69 03 04 02 00 ...o......ni....
+| 3008: 01 01 6f 06 03 08 00 04 06 00 01 01 75 03 06 06 ..o.........u...
+| 3024: 00 00 02 6f 63 03 07 04 00 01 01 66 03 08 06 00 ...oc......f....
+| 3040: 00 02 70 61 03 06 07 00 01 01 72 03 07 07 00 00 ..pa......r.....
+| 3056: 02 71 75 06 03 07 00 05 05 00 00 02 72 65 03 05 .qu.........re..
+| 3072: 07 00 00 02 73 65 03 02 02 00 01 01 69 06 01 05 ....se......i...
+| 3088: 00 06 03 00 01 01 75 03 08 02 00 00 02 74 65 03 ......u......te.
+| 3104: 02 05 00 00 02 75 6c 03 03 0a 00 01 01 74 09 02 .....ul......t..
+| 3120: 07 00 01 02 00 01 03 00 00 02 76 65 06 03 06 00 ..........ve....
+| 3136: 02 0a 00 01 01 6f 03 05 09 00 82 0a 02 08 02 08 .....o..........
+| 3152: 08 08 17 84 02 04 00 30 20 32 35 31 00 01 61 13 .......0 251..a.
+| 3168: 01 06 04 00 01 0c 00 01 04 00 01 04 00 01 03 00 ................
+| 3184: 03 09 00 00 01 63 10 01 07 00 03 07 03 00 02 02 .....c..........
+| 3200: 00 01 05 00 01 04 00 00 01 64 11 01 04 00 01 03 .........d......
+| 3216: 09 00 03 02 05 00 01 03 00 02 07 00 00 01 65 1b ..............e.
+| 3232: 01 09 00 01 04 01 70 00 03 01 80 00 05 03 00 01 ......p.........
+| 3248: 0b 00 01 04 00 01 02 00 01 0b 00 00 01 66 03 06 .............f..
+| 3264: 05 00 00 01 69 0f 01 03 00 01 06 00 03 04 04 04 ....i...........
+| 3280: 00 03 03 09 00 00 01 6c 0c 01 02 00 01 08 00 01 .......l........
+| 3296: 0b 00 05 0c 00 00 01 6d 09 02 0b 00 01 05 00 05 .......m........
+| 3312: 08 00 00 01 6e 0c 03 08 00 01 02 00 02 06 00 01 ....n...........
+| 3328: 06 00 00 01 6f 06 07 04 00 01 06 00 00 01 70 06 ....o.........p.
+| 3344: 06 07 00 01 07 00 00 01 71 06 03 07 00 05 05 00 ........q.......
+| 3360: 00 01 72 03 05 07 00 00 01 73 0c 01 05 00 01 02 ..r......s......
+| 3376: 00 05 03 00 01 02 00 00 01 74 03 02 05 00 00 01 .........t......
+| 3392: 75 0a 02 07 00 01 02 0a 00 01 03 00 00 01 76 07 u.............v.
+| 3408: 03 06 00 02 09 03 00 85 26 01 08 08 08 08 08 17 ........&.......
+| 3424: 8a 3e 30 20 36 36 35 00 02 61 64 03 03 04 00 02 .>0 665..ad.....
+| 3440: 08 69 70 69 73 63 69 6e 67 03 01 08 00 01 05 6c .ipiscing......l
+| 3456: 69 71 75 61 03 02 0c 00 05 02 69 70 03 04 04 00 iqua......ip....
+| 3472: 01 03 6d 65 74 03 01 06 00 01 03 6e 69 6d 03 08 ..met......nim..
+| 3488: 09 00 01 03 75 74 65 03 05 03 00 00 06 63 69 6c ....ute......cil
+| 3504: 6c 75 6d 03 06 02 00 01 06 6f 6d 6d 6f 64 6f 03 lum......ommodo.
+| 3520: 04 07 00 02 09 6e 73 65 63 74 65 74 75 72 03 01 .....nsectetur..
+| 3536: 07 00 05 04 71 75 61 74 03 04 08 00 01 04 75 6c ....quat......ul
+| 3552: 70 61 03 08 04 00 02 07 70 69 64 61 74 61 74 03 pa......pidatat.
+| 3568: 07 05 00 00 08 64 65 73 65 72 75 6e 74 03 08 07 .....deserunt...
+| 3584: 00 01 01 6f 03 02 03 00 02 03 6c 6f 72 06 01 04 ...o......lor...
+| 3600: 00 04 05 00 05 01 65 06 02 0a 00 04 03 00 01 03 ......e.........
+| 3616: 75 69 73 03 05 02 00 00 02 65 61 03 04 06 00 01 uis......ea.....
+| 3632: 06 69 75 73 6d 6f 64 03 02 04 00 01 03 6c 69 74 .iusmod......lit
+| 3648: 03 01 09 00 01 03 6e 69 6d 03 03 03 00 01 03 73 ......nim......s
+| 3664: 73 65 03 05 0b 00 02 01 74 03 08 0b 00 01 01 74 se......t......t
+| 3680: 03 02 09 00 01 01 75 03 06 04 00 01 01 78 03 04 ......u......x..
+| 3696: 05 00 02 07 63 65 70 74 65 75 72 03 07 02 00 02 ....cepteur.....
+| 3712: 0a 65 72 63 69 74 61 74 69 6f 6e 03 03 09 00 00 .ercitation.....
+| 3728: 06 66 75 67 69 61 74 03 06 05 00 00 02 69 64 03 .fugiat......id.
+| 3744: 08 0a 00 01 01 6e 07 05 06 04 00 03 03 00 02 08 .....n..........
+| 3760: 63 69 64 69 64 75 6e 74 03 02 06 00 01 04 70 73 cididunt......ps
+| 3776: 75 6d 03 01 03 00 01 04 72 75 72 65 03 05 04 00 um......rure....
+| 3792: 00 06 6c 61 62 6f 72 65 03 02 08 00 05 02 69 73 ..labore......is
+| 3808: 03 03 0b 00 05 02 75 6d 03 08 0c 00 01 04 6f 72 ......um......or
+| 3824: 65 6d 03 01 02 00 00 05 6d 61 67 6e 61 03 02 0b em......magna...
+| 3840: 00 01 04 69 6e 69 6d 03 03 05 00 01 05 6f 6c 6c ...inim......oll
+| 3856: 69 74 03 08 08 00 00 04 6e 69 73 69 03 04 02 00 it......nisi....
+| 3872: 01 02 6f 6e 03 07 06 00 02 05 73 74 72 75 64 03 ..on......strud.
+| 3888: 03 08 00 01 04 75 6c 6c 61 03 06 06 00 00 08 6f .....ulla......o
+| 3904: 63 63 61 65 63 61 74 03 07 04 00 01 06 66 66 69 ccaecat......ffi
+| 3920: 63 69 61 03 08 06 00 00 08 70 61 72 69 61 74 75 cia......pariatu
+| 3936: 72 03 06 07 00 01 07 72 6f 69 64 65 6e 74 03 07 r......roident..
+| 3952: 07 00 00 03 71 75 69 03 08 05 00 03 01 73 03 03 ....qui......s..
+| 3968: 07 00 00 0d 72 65 70 72 65 68 65 6e 64 65 72 69 ....reprehenderi
+| 3984: 74 03 05 07 00 00 03 73 65 64 03 02 02 00 01 03 t......sed......
+| 4000: 69 6e 74 03 07 03 00 02 01 74 03 01 05 00 01 03 int......t......
+| 4016: 75 6e 74 03 08 02 00 00 06 74 65 6d 70 6f 72 03 unt......tempor.
+| 4032: 02 05 00 00 07 75 6c 6c 61 6d 63 6f 03 03 0a 00 .....ullamco....
+| 4048: 01 01 74 09 02 07 00 01 02 00 01 03 00 00 05 76 ..t............v
+| 4064: 65 6c 69 74 03 05 0a 00 02 04 6e 69 61 6d 03 03 elit......niam..
+| 4080: 06 00 01 08 6f 6c 75 70 74 61 74 65 03 05 09 00 ....oluptate....
+| page 5 offset 16384
+| 0: 0a 00 00 00 03 0f eb 00 0f fb 0f f3 0f eb 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 00 00 07 04 02 08 01 ................
+| 4080: 08 00 03 07 04 02 08 01 04 00 02 04 04 08 08 09 ................
+| page 6 offset 20480
+| 0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8 ................
+| 16: 0f e2 0f dc 0f d6 0f d0 00 00 00 00 00 00 00 00 ................
+| 4048: 04 08 03 00 0e 0b 04 07 03 00 0e 06 04 06 03 00 ................
+| 4064: 0e 06 04 05 03 00 0e 0a 04 04 03 00 0e 07 04 03 ................
+| 4080: 03 00 0e 0a 04 02 03 00 0e 0b 04 01 03 00 0e 08 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 01 0f f7 00 0f f7 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 07 00 03 00 14 08 45 b5 03 .............E..
+| page 8 offset 28672
+| 0: 6f ee cd e1 f1 ee 1a ca be ed ee ec de ac f1 cb o...............
+| 16: f1 ee 1a ce de ee f1 ee 0a cc de ed ae 90 87 88 ................
+| 32: ec 5e dc ec fc 11 72 32 75 0a da be ec ed eb de .^....r2u.......
+| 48: ce c1 aa e0 ae ec 1f c1 ee 99 c2 aa e0 a9 ad 15 ................
+| 64: 0e ec ab ef 1e e0 48 ad 15 04 24 80 00 00 00 00 ......H...$.....
+| 80: 00 00 00 00 e0 00 00 00 04 2c 80 00 10 42 4e c1 .........,...BN.
+| 96: 20 4b 45 59 2c 6e 6f 64 65 6e 6f 2c 61 30 29 46 KEY,nodeno,a0)F
+| 112: 02 06 17 11 11 08 7b 74 61 62 6c 65 74 31 74 31 .......tablet1t1
+| 128: 43 52 45 41 54 e1 ec eb ea eb eb ac ee ce be de CREAT...........
+| 144: ee f1 ee 1a ca ba de 47 80 30 00 14 90 47 70 30 .......G.0...Gp0
+| 160: 00 11 60 47 60 30 00 15 f0 47 50 30 00 10 f0 47 ..`G`0...GP0...G
+| 176: 40 30 00 11 f0 47 45 20 30 00 11 d0 45 10 30 00 @0...GE 0...E.0.
+| 192: 12 10 45 00 30 00 14 e0 44 f0 30 00 11 e0 44 e0 ..E.0...D.0...D.
+| 208: 30 00 12 a0 44 d0 30 00 15 e0 44 c0 30 00 10 40 0...D.0...D.0..@
+| 224: 44 b0 30 00 15 10 44 a0 30 00 14 c0 44 90 30 00 D.0...D.0...D.0.
+| 240: 16 20 44 80 30 00 52 45 41 54 45 20 54 41 42 4c . D.0.REATE TABL
+| 256: 45 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 69 E 't1_content'(i
+| 272: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR
+| 288: 59 20 4b 45 59 2c 20 63 30 29 69 03 07 17 19 19 Y KEY, c0)i.....
+| 304: 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74 31 ..-tablet1_idxt1
+| 320: 5f 69 64 78 03 43 52 45 41 54 45 20 54 41 42 4c _idx.CREATE TABL
+| 336: 45 20 27 70 31 5f 69 64 78 03 6e 69 6d 03 03 03 E 'p1_idx.nim...
+| 352: 00 01 03 73 73 65 03 05 0b 00 02 01 74 03 08 0b ...sse......t...
+| 368: 00 01 01 74 03 02 09 00 01 01 75 03 06 04 00 01 ...t......u.....
+| 384: 01 78 03 04 05 00 02 07 63 65 70 74 65 75 72 03 .x......cepteur.
+| 400: 07 02 00 02 0a 65 72 63 69 74 61 74 69 6f 6e 03 .....ercitation.
+| 416: 03 09 00 00 06 66 75 67 69 61 74 03 06 05 00 00 .....fugiat.....
+| 432: 02 69 64 03 08 0a 00 01 01 6e 07 05 06 04 00 03 .id......n......
+| 448: 03 00 02 08 63 69 64 69 64 75 6e 74 03 02 06 00 ....cididunt....
+| 464: 01 04 70 73 75 6d 03 01 03 00 01 04 72 75 72 65 ..psum......rure
+| 480: 03 05 04 00 00 06 6c 61 62 6f 72 65 03 02 08 00 ......labore....
+| 496: 05 02 69 73 03 03 0b 00 05 02 75 6d 03 08 0c 00 ..is......um....
+| 512: 01 04 6f 72 65 6d 03 01 02 00 00 05 6d 61 67 6e ..orem......magn
+| 528: 61 03 02 0b 00 01 04 69 6e 69 6d 03 03 05 00 01 a......inim.....
+| 544: 05 6f 6c 6c 69 74 03 08 08 00 00 04 6e 69 73 69 .ollit......nisi
+| 560: 03 04 02 00 01 02 6f 6e 03 07 06 00 02 05 73 74 ......on......st
+| 576: 72 75 64 03 03 08 00 01 04 75 6c 6c 61 03 06 06 rud......ulla...
+| 592: 00 00 08 6f 63 63 61 65 63 61 74 03 07 04 00 01 ...occaecat.....
+| 608: 06 66 66 69 63 69 61 03 08 06 00 00 08 70 61 72 .fficia......par
+| 624: 69 61 74 75 72 03 06 07 00 01 07 72 6f ed ce de iatur......ro...
+| 640: 69 64 65 6e 74 03 07 07 00 00 03 71 75 69 03 08 ident......qui..
+| 656: 05 00 03 01 73 03 03 07 00 00 0d 72 65 70 72 65 ....s......repre
+| 672: 68 65 6e 64 65 72 69 74 03 05 07 00 00 03 73 65 henderit......se
+| 688: 64 03 02 02 00 01 03 69 6e 74 03 07 03 00 02 01 d......int......
+| 704: 74 03 01 05 00 01 03 75 6e 74 03 08 02 00 00 06 t......unt......
+| 720: 74 65 6d 70 6f 72 03 02 05 00 00 07 75 6c 6c 61 tempor......ulla
+| 736: 6d 63 6f 03 03 0a 00 01 01 74 09 02 07 00 01 02 mco......t......
+| 752: 00 01 03 00 00 05 76 65 6c 69 74 03 05 0a 00 02 ......velit.....
+| 768: 04 6e 69 61 6d 03 03 06 00 01 08 6f 6c 75 70 74 .niam......olupt
+| 784: 61 74 65 03 05 09 00 0a 00 00 00 03 0f eb 00 0f ate.............
+| 800: fb 0f f3 0f eb 00 00 00 00 00 00 00 00 00 00 00 ................
+| end crash-04bb6e7c811ce9.db
+}]} {}
+
+do_catchsql_test 7.1 {
+ SELECT matchinfo(t1,'y') FROM t1 WHERE t1 MATCH 'e*';
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 8.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-7948058d822acb.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e ef 00 07 0d 4d 00 0f bd 0f 5f ..........M...._
+| 112: 0e f7 0e 06 0e bc 0d a4 0d 4d 00 00 00 00 00 00 .........M......
+| 3392: 00 00 00 00 00 00 00 00 00 00 00 00 00 55 07 07 .............U..
+| 3408: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 73 74 ......tablet1_st
+| 3424: 61 74 74 31 5f 73 74 61 74 07 43 52 45 41 54 45 att1_stat.CREATE
+| 3440: 20 54 41 42 4c 45 20 27 74 31 5f 73 74 61 74 27 TABLE 't1_stat'
+| 3456: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (id INTEGER PRIM
+| 3472: 41 52 59 20 4b 45 59 2c 20 76 61 6c 75 65 20 42 ARY KEY, value B
+| 3488: 4c 4f 42 29 60 06 07 17 21 21 01 81 0b 74 61 62 LOB)`...!!...tab
+| 3504: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64 let1_docsizet1_d
+| 3520: 6f 63 73 69 7a 65 06 43 52 45 41 54 45 20 54 41 ocsize.CREATE TA
+| 3536: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27 BLE 't1_docsize'
+| 3552: 28 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 (docid INTEGER P
+| 3568: 52 49 4d 41 52 59 20 4b 45 59 2c 20 73 69 7a 65 RIMARY KEY, size
+| 3584: 20 42 4c 4f 42 29 81 33 04 07 17 1f 1f 01 82 35 BLOB).3.......5
+| 3600: 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 74 31 tablet1_segdirt1
+| 3616: 5f 73 65 67 64 69 72 04 43 52 45 41 54 45 20 54 _segdir.CREATE T
+| 3632: 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 72 27 ABLE 't1_segdir'
+| 3648: 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 2c 69 (level INTEGER,i
+| 3664: 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 72 74 dx INTEGER,start
+| 3680: 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 6c _block INTEGER,l
+| 3696: 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 6b 20 eaves_end_block
+| 3712: 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c 6f 63 INTEGER,end_bloc
+| 3728: 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 20 42 k INTEGER,root B
+| 3744: 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 59 28 LOB,PRIMARY KEY(
+| 3760: 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 05 06 17 level, idx))1...
+| 3776: 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 65 5f E...indexsqlite_
+| 3792: 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 65 67 autoindex_t1_seg
+| 3808: 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 05 00 dir_1t1_segdir..
+| 3824: 00 00 08 00 00 00 00 66 03 07 17 23 23 01 81 13 .......f...##...
+| 3840: 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e 74 73 tablet1_segments
+| 3856: 74 31 5f 73 65 67 6d 65 6e 74 73 03 43 52 45 41 t1_segments.CREA
+| 3872: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
+| 3888: 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 20 49 ments'(blockid I
+| 3904: 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b NTEGER PRIMARY K
+| 3920: 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 5c EY, block BLOB).
+| 3936: 02 07 17 21 21 01 81 03 74 61 62 6c 65 74 31 5f ...!!...tablet1_
+| 3952: 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 65 6e contentt1_conten
+| 3968: 74 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 t.CREATE TABLE '
+| 3984: 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 63 69 t1_content'(doci
+| 4000: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR
+| 4016: 59 20 4b 45 59 2c 20 27 63 30 61 27 29 41 01 06 Y KEY, 'c0a')A..
+| 4032: 17 11 11 08 71 74 61 62 6c 65 74 31 74 31 43 52 ....qtablet1t1CR
+| 4048: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4064: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 34 LE t1 USING fts4
+| 4080: 28 61 2c 70 72 65 66 69 78 3d 27 31 2c 32 27 29 (a,prefix='1,2')
+| page 2 offset 4096
+| 0: 0d 00 00 00 08 0e 1f 00 0f c4 0f 7c 0f 34 0f 07 ...........|.4..
+| 16: 0e c3 0e 97 0e 63 0e 1f 00 00 00 00 00 00 00 00 .....c..........
+| 3600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ...............B
+| 3616: 08 04 00 81 09 73 75 6e 74 20 69 6e 20 63 75 6c .....sunt in cul
+| 3632: 70 61 20 71 75 69 20 6f 66 66 69 63 69 61 20 64 pa qui officia d
+| 3648: 65 73 65 72 75 6e 74 20 6d 6f 6c 6c 69 74 20 61 eserunt mollit a
+| 3664: 6e 69 6d 20 69 64 20 65 73 74 20 6c 61 62 6f 72 nim id est labor
+| 3680: 75 6d 2e 32 07 03 00 6b 45 78 63 65 70 74 65 75 um.2...kExcepteu
+| 3696: 72 20 73 69 6e 74 20 6f 63 63 61 65 63 67 42 06 r sint occaecgB.
+| 3712: 37 57 06 96 46 17 46 17 42 06 e6 f6 e2 07 07 26 7W..F.F.B......&
+| 3728: f6 96 46 56 e7 42 c2 a0 60 30 05 b6 36 96 c6 c7 ..FV.B..`0..6...
+| 3744: 56 d2 06 46 f6 c6 f7 26 52 06 57 52 06 67 56 7c V..F...&R.WR.gV|
+| 3760: 65 3f 04 20 6e 75 6c 6c 61 20 70 61 72 69 61 74 e?. nulla pariat
+| 3776: 75 72 2e 42 05 04 00 81 09 44 75 69 73 20 61 75 ur.B.....Duis au
+| 3792: 74 65 20 69 72 75 72 65 20 64 6f 6c 6f 72 20 69 te irure dolor i
+| 3808: 6e 20 72 65 70 72 65 68 65 6e 64 65 72 69 74 20 n reprehenderit
+| 3824: 69 6e 20 76 6f 6c 75 70 74 61 74 65 20 76 65 6c in voluptate vel
+| 3840: 69 74 20 65 73 73 65 2b 04 03 00 5d 6e 69 73 69 it esse+...]nisi
+| 3856: 20 75 74 20 61 7c 69 71 75 69 70 20 65 78 20 65 ut a|iquip ex e
+| 3872: 61 20 63 6f 6d 6d 6f 64 6f 20 63 6f 6e 73 65 71 a commodo conseq
+| 3888: 75 61 74 2e 46 03 04 00 81 11 55 74 20 65 6e 69 uat.F.....Ut eni
+| 3904: 6d 20 61 64 20 6d 69 6e 69 6d 20 76 65 6e 69 61 m ad minim venia
+| 3920: 6d 2c 20 71 75 69 73 20 6e 6f 73 74 72 75 64 20 m, quis nostrud
+| 3936: 65 78 65 72 63 69 74 61 74 69 6f 6e 20 75 6c 6c exercitation ull
+| 3952: 61 6d 63 6f 20 6c 61 62 6f 72 69 73 46 02 04 00 amco laborisF...
+| 3968: 81 11 73 65 64 20 64 6f 20 65 69 75 73 6d 6f 64 ..sed do eiusmod
+| 3984: 20 74 65 6d 70 6f 72 20 69 6e 63 69 64 69 64 75 tempor incididu
+| 4000: 6e 74 20 75 74 20 6c 61 62 6f 72 65 20 65 74 20 nt ut labore et
+| 4016: 64 6f 6c 6f 72 65 20 6d 61 67 6e 61 20 61 6c 69 dolore magna ali
+| 4032: 71 75 61 2e 3a 01 03 00 7b 4c 6f 72 65 6d 20 69 qua.:....Lorem i
+| 4048: 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 psum dolor sit a
+| 4064: 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 met, consectetur
+| 4080: 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 adipiscing elit
+| page 3 offset 8192
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 4 offset 12288
+| 0: 0d 00 00 00 03 0a a6 00 0d 57 0c 4a 0a a6 00 00 .........W.J....
+| 2720: 00 00 00 00 00 00 83 21 03 08 02 08 08 08 17 86 .......!........
+| 2736: 30 08 00 30 20 34 30 32 00 02 61 64 06 01 08 00 0..0 402..ad....
+| 2752: 02 04 00 01 01 6c 06 02 0c 00 02 04 00 01 01 6d .....l.........m
+| 2768: 03 01 06 00 01 01 6e 03 08 00 00 91 01 75 03 05 ......n......u..
+| 2784: 03 00 00 02 63 69 03 06 02 00 01 01 6f 07 01 07 ....ci......o...
+| 2800: 00 03 07 03 00 01 01 75 06 07 05 00 01 04 00 00 .......u........
+| 2816: 02 64 65 03 08 07 00 01 01 6f 0d 01 04 00 01 03 .de......o......
+| 2832: 09 00 03 05 00 01 03 00 01 01 75 03 05 02 00 00 ..........u.....
+| 2848: 02 65 61 03 04 06 00 01 01 69 03 02 04 00 01 01 .ea......i......
+| 2864: 6c 03 01 09 00 01 01 6e 30 03 03 00 01 01 73 06 l......n0.....s.
+| 2880: 05 0b 00 03 0b 00 01 01 74 03 02 09 00 01 01 75 ........t......u
+| 2896: 03 06 04 00 01 01 78 09 03 09 00 01 05 00 03 02 ......x.........
+| 2912: 00 00 02 66 75 03 06 05 00 00 02 69 64 03 08 0a ...fu......id...
+| 2928: 00 01 01 6e 0a 02 06 00 03 06 04 00 03 03 00 01 ...n............
+| 2944: 01 70 03 01 03 00 01 01 72 03 05 04 00 00 02 6c .p......r......l
+| 2960: 61 09 02 08 00 01 0b 00 05 0c 00 01 01 6f 03 01 a............o..
+| 2976: 02 00 00 02 6d 61 03 02 0b 00 01 01 69 03 03 05 ....ma......i...
+| 2992: 00 01 01 6f 03 08 08 00 00 02 6e 69 03 04 02 00 ...o......ni....
+| 3008: 01 01 6f 06 03 08 00 04 06 00 01 01 75 03 06 06 ..o.........u...
+| 3024: 00 00 02 6f 63 03 07 04 00 01 01 66 03 08 06 00 ...oc......f....
+| 3040: 00 02 70 61 03 06 07 00 01 01 72 03 07 07 00 00 ..pa......r.....
+| 3056: 02 71 75 06 03 07 00 05 05 00 00 02 72 65 03 05 .qu.........re..
+| 3072: 07 00 00 02 73 65 03 02 02 00 01 01 69 06 01 05 ....se......i...
+| 3088: 00 06 03 00 01 01 75 03 08 02 00 00 02 74 65 03 ......u......te.
+| 3104: 02 05 00 00 02 75 6c 03 03 0a 00 01 01 74 09 02 .....ul......t..
+| 3120: 07 00 01 02 00 01 03 00 00 02 76 65 06 03 06 00 ..........ve....
+| 3136: 02 0a 00 01 01 6f 03 05 09 00 82 0a 02 08 02 08 .....o..........
+| 3152: 08 08 17 84 02 04 00 30 20 32 35 31 00 01 61 13 .......0 251..a.
+| 3168: 01 06 04 00 01 0c 00 01 04 00 01 04 00 01 03 00 ................
+| 3184: 03 09 00 00 01 63 10 01 07 00 03 07 03 00 02 02 .....c..........
+| 3200: 00 01 05 00 01 04 00 00 01 64 11 01 04 00 01 03 .........d......
+| 3216: 09 00 03 02 05 00 01 03 00 02 07 00 00 01 65 1b ..............e.
+| 3232: 01 09 00 01 04 07 00 01 03 00 80 00 15 03 00 01 ................
+| 3248: 0b 00 01 04 00 01 02 00 01 0b 00 00 01 66 03 06 .............f..
+| 3264: 05 00 00 01 69 0f 01 03 00 01 06 00 03 04 04 04 ....i...........
+| 3280: 00 03 03 09 00 00 01 6c 0c 01 02 00 01 08 00 01 .......l........
+| 3296: 0b 00 05 0c 00 00 01 6d 09 02 0b 00 01 05 00 05 .......m........
+| 3312: 08 00 00 01 6e 0c 03 08 00 01 02 00 02 06 00 01 ....n...........
+| 3328: 06 00 00 01 6f 06 07 04 00 01 06 00 00 01 70 06 ....o.........p.
+| 3344: 06 07 00 01 07 00 00 01 71 06 03 07 00 05 05 00 ........q.......
+| 3360: 00 01 72 03 05 07 00 00 01 73 0c 01 05 00 01 02 ..r......s......
+| 3376: 00 05 03 00 01 02 00 00 01 74 03 02 05 00 00 01 .........t......
+| 3392: 75 0a 02 07 00 01 02 0a 00 01 03 00 00 01 76 07 u.............v.
+| 3408: 03 06 00 02 09 03 00 85 26 01 08 08 08 08 08 17 ........&.......
+| 3424: 8a 3e 30 20 36 36 35 00 02 61 64 03 03 04 00 02 .>0 665..ad.....
+| 3440: 08 69 70 69 73 63 69 6e 67 03 01 08 00 01 05 6c .ipiscing......l
+| 3456: 69 71 75 61 03 02 0c 00 05 02 69 70 03 04 04 00 iqua......ip....
+| 3472: 01 03 6d 65 74 03 01 06 00 01 03 6e 69 6d 03 08 ..met......nim..
+| 3488: 09 00 01 03 75 74 65 03 05 03 00 00 06 63 69 6c ....ute......cil
+| 3504: 6c 75 6d 03 06 02 00 01 06 6f 6d 6d 6f 64 6f 03 lum......ommodo.
+| 3520: 04 07 00 02 09 6e 73 65 63 74 65 74 75 72 03 01 .....nsectetur..
+| 3536: 07 00 05 04 71 75 61 74 03 04 08 00 01 04 75 6c ....quat......ul
+| 3552: 70 61 03 08 04 00 02 07 70 69 64 61 74 61 74 03 pa......pidatat.
+| 3568: 07 05 00 00 08 64 65 73 65 72 75 6e 74 03 08 07 .....deserunt...
+| 3584: 00 01 01 6f 03 02 03 00 02 03 6c 6f 72 06 01 04 ...o......lor...
+| 3600: 00 40 05 00 05 01 65 06 02 0a 00 04 03 00 01 03 .@....e.........
+| 3616: 75 69 73 03 05 02 00 00 02 65 61 03 04 06 00 01 uis......ea.....
+| 3632: 06 69 75 73 6d 6f 64 03 02 04 00 01 03 6c 69 74 .iusmod......lit
+| 3648: 03 01 09 00 01 03 6e 69 6d 03 03 03 00 01 03 73 ......nim......s
+| 3664: 73 65 03 05 0b 00 02 01 74 03 08 0b 00 01 01 74 se......t......t
+| 3680: 03 02 09 00 01 01 75 03 06 04 00 01 01 78 03 04 ......u......x..
+| 3696: 05 00 02 07 63 65 70 74 65 75 72 03 07 02 00 02 ....cepteur.....
+| 3712: 0a 65 72 63 69 74 61 74 69 6f 6e 03 03 09 00 00 .ercitation.....
+| 3728: 06 66 75 67 69 61 74 03 06 05 00 00 02 69 64 03 .fugiat......id.
+| 3744: 08 0a 00 01 01 6e 07 05 06 04 00 03 03 00 02 08 .....n..........
+| 3760: 63 69 64 69 64 75 6e 74 03 02 06 00 01 04 70 73 cididunt......ps
+| 3776: 75 6d 03 01 03 00 01 04 72 75 72 65 03 05 04 00 um......rure....
+| 3792: 00 06 6c 61 62 6f 72 65 03 02 08 00 05 02 69 73 ..labore......is
+| 3808: 03 03 0b 00 05 02 75 6d 03 08 0c 00 01 04 6f 72 ......um......or
+| 3824: 65 6d 03 01 02 00 00 05 6d 61 67 6e 61 03 02 0b em......magna...
+| 3840: 00 01 04 69 6e 69 6d 03 03 05 00 01 05 6f 6c 6c ...inim......oll
+| 3856: 69 74 03 08 08 00 00 04 6e 69 73 69 03 04 02 00 it......nisi....
+| 3872: 01 02 6f 6e 03 07 06 00 02 05 73 74 72 75 64 03 ..on......strud.
+| 3888: 03 08 00 01 04 75 6c 6c 61 03 06 06 00 00 08 6f .....ulla......o
+| 3904: 63 63 61 65 63 61 74 03 07 04 00 01 06 66 66 69 ccaecat......ffi
+| 3920: 63 69 61 03 08 06 00 00 08 70 61 72 69 61 74 75 cia......pariatu
+| 3936: 72 03 06 07 00 01 07 72 6f 69 64 65 6e 74 03 07 r......roident..
+| 3952: 07 00 00 03 71 75 69 03 08 05 00 03 01 73 03 03 ....qui......s..
+| 3968: 07 00 00 0d 72 65 70 72 65 68 65 6e 64 65 72 69 ....reprehenderi
+| 3984: 74 03 05 07 00 00 03 73 65 64 03 02 02 00 01 03 t......sed......
+| 4000: 69 6e 74 03 07 03 00 02 01 74 03 01 05 00 01 03 int......t......
+| 4016: 75 6e 74 03 08 02 00 00 06 74 65 6d 70 6f 72 03 unt......tempor.
+| 4032: 02 05 00 00 07 75 6c 6c 61 6d 63 6f 03 03 0a 00 .....ullamco....
+| 4048: 01 01 74 09 02 07 00 01 02 00 01 03 00 00 05 76 ..t............v
+| 4064: 65 6c 69 74 03 05 0a 00 02 04 6e 69 61 6d 03 03 elit......niam..
+| 4080: 06 00 01 08 6f 6c 75 70 74 61 74 65 03 05 09 00 ....oluptate....
+| page 5 offset 16384
+| 0: 0a 00 00 00 03 0f eb 00 0f fb 0f f3 0f eb 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 00 00 07 04 02 08 01 ................
+| 4080: 08 00 03 07 04 02 08 01 04 00 02 04 04 08 08 09 ................
+| page 6 offset 20480
+| 0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8 ................
+| 16: 0f e2 0f dc 0f d6 0f d0 00 00 00 00 00 00 00 00 ................
+| 4048: 04 08 03 00 0e 0b 04 07 03 00 0e 06 04 06 03 00 ................
+| 4064: 0e 06 04 05 03 00 0e 0a 04 04 03 00 0e 07 04 03 ................
+| 4080: 03 00 0e 0a 04 02 03 00 0e 0b 04 01 03 00 0e 08 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 01 0f f7 00 0f f7 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 07 00 03 00 14 08 45 b5 03 .............E..
+| end crash-7948058d822acb.db
+}]} {}
+
+do_catchsql_test 8.1 {
+ SELECT matchinfo(t1,'x') FROM t1 WHERE t1 MATCH 'e*';
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 9.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-e1c6cbfdf643e9.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 0d a4 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00 (a,b,c)...9.....
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 35 58 54 45 4e 53 49 4f IT LOAD 5XTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 1f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 44 4e 41 42 4c 45 20 46 54 53 35 58 .#..DNABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 01 00 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 0a 12 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end crash-e1c6cbfdf643e9.db
+}]} {}
+
+do_execsql_test 9.1 {
+ SELECT count(*) FROM t1 WHERE t1 MATCH '"json1 enable"';
+} {1}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 10.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-c3a971f0061039.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 0d a4 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 30 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY0KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00 (a,b,c)...9.....
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 1f MEMSYS5 ENABLE.
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 43 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXCINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 09 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 46 20 47 45 ....)..ENABLF GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 09 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 02 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 10 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 02 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end crash-c3a971f0061039.db
+}]} {}
+
+do_catchsql_test 10.1 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT OR IGNORE INTO t1(a,c) SELECT x,null FROM c
+ UNION ALL SELECT 180-x,printf('[%,d]',x*-5844627) FROM c;
+} {0 {}}
+
+do_catchsql_test 10.3 {
+ INSERT INTO t1(t1) VALUES('optimize');
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 11.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-843cb8447eaf14.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 0d a4 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00 (a,b,c)...9.....
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d4 ...t.[.@.$......
+| 48: dd bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 35 99 0c 78 0c 57 0c 3e 0c 24 0c 0a ....5..x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 01 00 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 a2 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end crash-843cb8447eaf14.db
+}]} {}
+
+do_catchsql_test 11.1 {
+ SELECT rowid, quote(matchinfo(t1,'pcxybs')) FROM t1 WHERE t1 MATCH 'e*'
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 12.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename c81b.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 01 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ................
+| 96: 00 2e 30 38 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ..08...........!
+| 112: 0e b9 0d c8 0e 7e 0d a4 0d a4 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 62 2c 72 6f 6f 74 ock INTEGEb,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00 (a,b,c)...9.....
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 46 4e 41 ABLE GEOPOLY FNA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 0f 25 READSAFE=0.$...%
+| 3088: 19 58 54 48 52 45 41 44 53 41 46 45 3d 30 42 49 .XTHREADSAFE=0BI
+| 3104: 4e 41 52 59 18 23 05 00 0f 25 19 58 54 48 52 45 NARY.#...%.XTHRE
+| 3120: 41 44 53 41 46 45 3d 30 4e 4f 43 41 53 45 17 22 ADSAFE=0NOCASE..
+| 3136: 05 00 0f 25 17 58 54 48 52 45 41 44 53 41 46 45 ...%.XTHREADSAFE
+| 3152: 3d 30 52 54 52 49 4d 1f 21 05 00 0f 33 19 58 4f =0RTRIM.!...3.XO
+| 3168: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3184: 4f 4e 42 49 4e 41 52 59 1f 20 05 00 0f 33 19 58 ONBINARY. ...3.X
+| 3200: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3216: 49 4f 4e 4e 4f 43 41 53 45 1e 1f 05 00 0f 33 17 IONNOCASE.....3.
+| 3232: 58 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e XOMIT LOAD EXTEN
+| 3248: 53 49 4f 4e 52 54 52 49 4d 1f 1e 05 00 0f 33 19 SIONRTRIM.....3.
+| 3264: 58 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 XMAX MEMORY=5000
+| 3280: 30 30 30 30 42 49 4e 41 52 59 1f 1d 05 00 0f 33 0000BINARY.....3
+| 3296: 19 58 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 .XMAX MEMORY=500
+| 3312: 30 30 30 30 30 4e 4f 43 41 53 45 1e 1c 05 00 0f 00000NOCASE.....
+| 3328: 33 17 58 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 3.XMAX MEMORY=50
+| 3344: 30 30 30 30 30 30 52 54 52 49 4d 18 1b 05 00 0f 000000RTRIM.....
+| 3360: 25 19 58 45 4e 41 42 4c 45 20 52 54 52 45 45 42 %.XENABLE RTREEB
+| 3376: 49 4e 41 52 59 18 1a 05 00 0f 25 19 58 45 4e 41 INARY.....%.XENA
+| 3392: 42 4c 45 20 52 54 52 45 45 4e 4f 43 41 53 45 17 BLE RTREENOCASE.
+| 3408: 19 05 00 0f 25 17 58 45 4e 41 42 4c 45 20 52 54 ....%.XENABLE RT
+| 3424: 52 45 45 52 54 52 49 4d 1a 18 05 00 0f 29 19 58 REERTRIM.....).X
+| 3440: 45 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 42 49 ENABLE MEMSYS5BI
+| 3456: 4e 41 52 59 1a 17 05 00 0f 29 19 58 45 4e 41 42 NARY.....).XENAB
+| 3472: 4c 45 20 4d 45 4d 53 59 53 35 4e 4f 43 41 53 45 LE MEMSYS5NOCASE
+| 3488: 19 16 05 00 0f 29 17 58 45 4e 41 42 4c 45 20 4d .....).XENABLE M
+| 3504: 45 4d 53 59 53 35 52 54 52 49 4d 18 15 05 00 0f EMSYS5RTRIM.....
+| 3520: 25 19 58 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 42 %.XENABLE JSON1B
+| 3536: 49 4e 41 52 59 18 14 05 00 0f 25 19 58 45 4e 41 INARY.....%.XENA
+| 3552: 42 4c 45 20 4a 53 4f 4e 31 4e 4f 43 41 53 45 17 BLE JSON1NOCASE.
+| 3568: 13 05 00 0f 25 17 58 45 4e 41 42 4c 45 20 4a 53 ....%.XENABLE JS
+| 3584: 4f 4e 31 52 54 52 49 4d 1a 12 05 00 0f 29 19 58 ON1RTRIM.....).X
+| 3600: 45 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 42 49 ENABLE GEOPOLYBI
+| 3616: 4e 41 52 59 1a 11 05 00 0f 29 19 58 45 4e 41 1e NARY.....).XENA.
+| 3632: 4c 45 20 47 45 4f 50 4f 4c 59 4e 4f 43 41 53 45 LE GEOPOLYNOCASE
+| 3648: 19 10 05 00 0f 29 17 58 45 4e 41 42 4c 45 20 47 .....).XENABLE G
+| 3664: 45 4f 50 4f 4c 59 52 54 52 49 4d 17 0f 05 00 0f EOPOLYRTRIM.....
+| 3680: 23 19 58 45 4e 41 42 4c 45 20 46 54 53 35 42 49 #.XENABLE FTS5BI
+| 3696: 4e 41 52 59 17 0e 05 00 0f 23 19 58 55 4e 41 42 NARY.....#.XUNAB
+| 3712: 4c 45 20 46 54 53 35 4e 4f 43 41 53 45 16 0d 05 LE FTS5NOCASE...
+| 3728: 00 0f 23 17 58 45 4e 41 42 4c 45 20 46 54 53 35 ..#.XENABLE FTS5
+| 3744: 52 54 52 49 4d 17 0c 05 00 0f 23 19 58 45 4e 41 RTRIM.....#.XENA
+| 3760: 42 4c 45 20 46 54 53 34 42 49 4e 41 52 59 17 0b BLE FTS4BINARY..
+| 3776: 05 00 0f 23 19 58 45 4e 41 42 4c 45 20 46 54 53 ...#.XENABLE FTS
+| 3792: 35 4e 4f 43 40 53 45 16 0a 05 00 0f 23 17 58 45 5NOC@SE.....#.XE
+| 3808: 4e 41 42 4c 45 20 46 54 53 34 52 54 52 49 4d 1e NABLE FTS4RTRIM.
+| 3824: 09 05 00 0f 31 19 58 45 4e 41 42 4c 35 20 44 42 ....1.XENABL5 DB
+| 3840: 53 54 41 54 20 56 54 41 42 42 49 4e 41 52 59 1e STAT VTABBINARY.
+| 3856: 08 05 00 0f 31 19 58 45 4e 41 42 4c 45 20 44 42 ....1.XENABLE DB
+| 3872: 53 54 41 54 20 56 54 41 42 4e 4f 43 41 53 45 1d STAT VTABNOCASE.
+| 3888: 07 05 00 0f 31 17 58 45 4e 41 42 4c 45 20 44 42 ....1.XENABLE DB
+| 3904: 53 54 41 54 20 56 54 41 42 52 54 52 49 4d 11 06 STAT VTABRTRIM..
+| 3920: 05 00 0f 17 19 58 44 45 42 55 47 42 49 4e 41 52 .....XDEBUGBINAR
+| 3936: 59 11 05 05 00 0f 17 19 58 44 45 42 55 47 4e 4f Y.......XDEBUGNO
+| 3952: 43 41 53 45 10 04 05 00 0f 17 17 58 44 45 42 55 CASE.......XDEBU
+| 3968: 47 52 54 52 49 4d 27 03 05 00 0f 43 19 58 43 4f GRTRIM'....C.XCO
+| 3984: 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 MPILER=gcc-5.4.0
+| 4000: 20 32 30 31 36 30 36 30 39 42 49 4e 41 52 59 27 20160609BINARY'
+| 4016: 02 05 00 0f 43 19 58 43 4f 4d 50 49 4c 45 52 3d ....C.XCOMPILER=
+| 4032: 67 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 gcc-5.4.0 201606
+| 4048: 30 39 4e 4f 43 41 53 45 26 01 05 00 0f 43 17 58 09NOCASE&....C.X
+| 4064: 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 COMPILER=gcc-5.4
+| 4080: 2e 30 20 32 30 31 36 30 36 30 39 52 54 52 49 4d .0 20160609RTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 03 07 bb 00 0c ad 0b a0 07 bb 00 00 ................
+| 1968: 00 00 00 00 00 00 00 00 00 00 00 87 62 03 08 08 ............b...
+| 1984: 01 08 08 17 8f 34 02 30 20 39 38 30 00 01 30 1e .....4.0 980..0.
+| 2000: 01 01 01 06 00 01 01 01 06 00 01 01 01 06 00 1f ................
+| 2016: 01 01 03 00 01 01 01 03 00 01 01 01 03 00 00 08 ................
+| 2032: 32 30 31 36 30 36 30 39 0f 01 01 01 07 00 01 01 20160609........
+| 2048: 01 07 00 01 01 01 07 00 00 01 34 0f 01 01 01 05 ..........4.....
+| 2064: 00 01 01 01 05 00 01 01 01 05 00 00 01 35 0f 01 .............5..
+| 2080: 01 01 04 00 01 01 01 04 00 01 01 01 04 00 01 07 ................
+| 2096: 30 30 30 30 30 30 30 0f 1c 01 01 04 00 01 01 01 0000000.........
+| 2112: 04 00 01 01 01 04 00 00 06 62 69 6e 61 72 79 3c .........binary<
+| 2128: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 2144: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 2160: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 2176: 02 00 03 01 02 02 00 03 01 02 02 00 00 08 63 6f ..............co
+| 2192: 6d 70 69 6c 65 72 0f 01 01 01 02 00 01 01 01 02 mpiler..........
+| 2208: 00 01 01 01 02 00 00 06 64 62 73 74 61 74 0f 07 ........dbstat..
+| 2224: 01 01 03 00 01 01 01 03 00 01 01 01 03 00 01 04 ................
+| 2240: 65 62 75 67 0f 04 01 01 02 00 01 01 01 02 00 01 ebug............
+| 2256: 01 01 02 00 00 03 65 6e 61 05 11 01 01 02 00 03 ......ena.......
+| 2272: 03 62 6c 35 05 09 01 01 02 00 05 01 65 5a 07 01 .bl5........eZ..
+| 2288: 01 02 00 01 01 01 02 00 02 01 01 02 00 01 01 01 ................
+| 2304: 02 00 01 01 01 02 00 01 01 01 02 00 02 01 01 02 ................
+| 2320: 00 01 01 01 02 00 02 01 01 02 00 01 01 01 02 00 ................
+| 2336: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 2352: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 2368: 01 02 00 01 01 01 02 00 01 08 78 74 65 6e 73 69 ..........xtensi
+| 2384: 6f 6e 0f 1f 01 01 04 00 01 01 01 04 00 01 01 01 on..............
+| 2400: 04 00 00 04 66 74 73 34 0a 0a 01 01 03 00 02 01 ....fts4........
+| 2416: 01 03 00 03 01 35 14 0b 01 01 03 00 02 01 01 03 .....5..........
+| 2432: 00 01 01 01 03 00 01 01 01 03 00 00 03 67 63 63 .............gcc
+| 2448: 0f 01 01 01 03 00 01 01 01 03 00 01 01 01 03 00 ................
+| 2464: 01 06 65 6f 70 6f 6c 79 0f 10 01 01 03 00 01 01 ..eopoly........
+| 2480: 01 04 00 01 01 01 03 00 00 05 6a 73 6f 6e 31 0f ..........json1.
+| 2496: 13 01 01 03 00 01 01 01 03 00 01 01 01 03 00 00 ................
+| 2512: 02 6c 65 05 11 01 01 03 00 01 03 6f 61 64 0f 1f .le........oad..
+| 2528: 01 01 03 00 01 01 01 03 00 01 01 01 03 00 00 03 ................
+| 2544: 6d 61 78 0f 1c 01 01 02 00 01 01 01 02 00 01 01 max.............
+| 2560: 01 02 00 01 05 65 6d 6f 72 79 0f 1c 01 01 03 00 .....emory......
+| 2576: 01 01 01 03 00 01 01 01 03 00 03 04 73 79 73 35 ............sys5
+| 2592: 0f 16 01 01 03 00 01 01 01 03 00 01 01 01 03 00 ................
+| 2608: 00 03 6e 6f 63 05 0b 01 02 02 00 03 03 61 73 65 ..noc........ase
+| 2624: 37 02 01 02 02 00 03 01 02 02 00 03 01 02 02 00 7...............
+| 2640: 06 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 2656: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 2672: 02 02 00 03 01 02 02 00 00 04 6f 6d 69 74 0f 1f ..........omit..
+| 2688: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 00 05 ................
+| 2704: 72 74 72 65 65 0f 19 01 01 03 00 01 01 01 03 00 rtree...........
+| 2720: 01 01 01 03 00 03 02 69 6d 3c 01 01 02 02 00 03 .......im<......
+| 2736: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 2752: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 2768: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 2784: 00 03 01 02 02 00 00 02 73 65 05 0b 01 02 03 00 ........se......
+| 2800: 00 0a 74 68 72 65 61 64 73 61 66 65 0f 22 01 01 ..threadsafe....
+| 2816: 02 00 01 01 01 02 00 01 01 01 02 00 00 06 75 6e ..............un
+| 2832: 61 62 6c 65 05 0e 01 01 02 00 00 04 76 74 61 62 able........vtab
+| 2848: 0f 07 01 01 04 00 01 01 01 04 00 01 01 01 04 00 ................
+| 2864: 00 01 78 6c 01 02 00 01 02 00 01 02 00 01 02 00 ..xl............
+| 2880: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 ................
+| 2896: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 2912: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 2928: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 ................
+| 2944: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 2960: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 11 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 00 f6 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 01 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 10 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 02 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 03 0f ee 00 0f fb 0f f5 0f ee 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 04 ................
+| 4080: 08 01 01 02 03 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0c f4 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end c81b.db
+}]} {}
+
+do_catchsql_test 12.1 {
+ SELECT rowid, quote(matchinfo(t1,'pcxybspcxybs'))
+ FROM t1 WHERE t1 MATCH 'e*e*'
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 13.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-c666cfde112dee.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 07 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 0d a4 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 62 2c 72 6f 6f 74 ock INTEGEb,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00 (a,b,c)...9.....
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 23 00 20 32 30 31 36 30 36 30 39 20 44 45 42 4#. 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 53 49 4d 18 1b 05 00 25 00000XRTSIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 52 4c 45 20 4a 53 4f ...%..ENARLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 1e 4c NARY....)..ENA.L
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 59 e5 58 .#..ENABLE FTY.X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 ..#..ENABLE FTS5
+| 3792: 58 4e 4f 43 40 53 45 16 0a 05 00 23 0f 17 45 4e XNOC@SE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2f 30 20 32 30 31 36 30 36 30 cc-5.4/0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 41 00 04 6c 6f 61 64 03 25 1c 00 n1.%.A..load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 02 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 f2 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 57 02 00 .............W..
+| 3504: 01 02 00 01 01 00 01 02 00 01 02 00 01 02 10 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 64 6e 73 69 6f .........xtdnsio
+| 3552: 6e 09 1f 04 00 01 04 00 01 03 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 57 63 63 09 01 03 ..........Wcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 02 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end crash-c666cfde112dee.db
+}]} {}
+
+do_catchsql_test 13.1 {
+ SELECT quote(matchinfo(t1,'pcxybs'))==0 FROM t1 WHERE b MATCH 'e*';
+} {0 {}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 14.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-f7b636a855e1d2.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e ef 00 07 0d 4d 00 0f bd 0f 5f ..........M...._
+| 112: 0e f7 0e 06 0e bc 0d a4 0d 4d 00 00 00 00 00 00 .........M......
+| 3392: 00 00 00 00 00 00 00 00 00 00 00 00 00 55 07 07 .............U..
+| 3408: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 73 74 ......tablet1_st
+| 3424: 61 74 74 31 5f 73 74 61 74 07 43 52 45 41 54 45 att1_stat.CREATE
+| 3440: 20 54 41 42 4c 45 20 27 74 31 5f 73 74 61 74 27 TABLE 't1_stat'
+| 3456: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (id INTEGER PRIM
+| 3472: 41 52 59 20 4b 45 59 2c 20 76 61 6c 75 65 20 42 ARY KEY, value B
+| 3488: 4c 4f 42 29 60 06 07 17 21 21 01 81 0b 74 61 62 LOB)`...!!...tab
+| 3504: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64 let1_docsizet1_d
+| 3520: 6f 63 73 69 7a 65 06 43 52 45 41 54 45 20 54 41 ocsize.CREATE TA
+| 3536: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27 BLE 't1_docsize'
+| 3552: 28 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 (docid INTEGER P
+| 3568: 52 49 4d 41 52 59 20 4b 45 59 2c 20 73 69 7a 65 RIMARY KEY, size
+| 3584: 20 42 4c 4f 42 29 81 33 04 07 17 1f 1f 01 82 35 BLOB).3.......5
+| 3600: 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 74 31 tablet1_segdirt1
+| 3616: 5f 73 65 67 64 69 25 04 43 52 45 41 54 45 20 54 _segdi%.CREATE T
+| 3632: 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 72 27 ABLE 't1_segdir'
+| 3648: 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 2c 69 (level INTEGER,i
+| 3664: 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 72 74 dx INTEGER,start
+| 3680: 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 6c _block INTEGER,l
+| 3696: 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 6b 20 eaves_end_block
+| 3712: 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c 6f 63 INTEGER,end_bloc
+| 3728: 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 20 42 k INTEGER,root B
+| 3744: 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 59 28 LOB,PRIMARY KEY(
+| 3760: 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 05 06 17 level, idx))1...
+| 3776: 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 65 5f E...indexsqlite_
+| 3792: 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 65 67 autoindex_t1_seg
+| 3808: 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 05 00 dir_1t1_segdir..
+| 3824: 00 00 08 00 00 00 00 66 03 07 17 23 23 01 81 13 .......f...##...
+| 3840: 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e 74 73 tablet1_segments
+| 3856: 74 31 5f 73 65 67 6d 65 6e 74 73 03 43 52 45 41 t1_segments.CREA
+| 3872: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
+| 3888: 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 20 49 ments'(blockid I
+| 3904: 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b NTEGER PRIMARY K
+| 3920: 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 5c EY, block BLOB).
+| 3936: 02 07 17 21 21 01 81 03 74 61 62 6c 65 74 31 5f ...!!...tablet1_
+| 3952: 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 65 6e contentt1_conten
+| 3968: 74 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 t.CREATE TABLE '
+| 3984: 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 63 69 t1_content'(doci
+| 4000: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR
+| 4016: 59 20 4b 45 59 2c 20 27 63 30 61 27 29 41 01 06 Y KEY, 'c0a')A..
+| 4032: 17 11 11 08 71 74 61 62 6c 65 74 31 74 31 43 52 ....qtablet1t1CR
+| 4048: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4064: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 34 LE t1 USING fts4
+| 4080: 28 61 2c 70 72 65 66 69 78 3d 27 31 2c 32 27 29 (a,prefix='1,2')
+| page 2 offset 4096
+| 0: 0d 00 00 00 08 0e 1f 00 0f c4 0f 7c 0f 34 0f 07 ...........|.4..
+| 16: 0e c3 0e 97 0e 63 0e 1f 00 00 00 00 00 00 00 00 .....c..........
+| 3600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ...............B
+| 3616: 08 04 00 81 09 73 75 6e 74 20 69 6e 20 63 75 6c .....sunt in cul
+| 3632: 70 61 20 71 75 69 20 6f 66 66 69 63 69 61 20 64 pa qui officia d
+| 3648: 65 73 65 72 75 6e 74 20 6d 6f 6c 6c 69 74 20 61 eserunt mollit a
+| 3664: 6e 69 6d 20 69 64 20 65 73 74 20 6c 61 62 6f 72 nim id est labor
+| 3680: 75 6d 2e 32 07 03 01 6b 45 78 63 65 70 74 65 75 um.2...kExcepteu
+| 3696: 72 20 73 69 6e 74 20 6f 63 63 61 65 63 61 74 20 r sint occaecat
+| 3712: 63 75 70 69 64 61 74 61 74 20 6e 6f 6e 20 70 72 cupidatat non pr
+| 3728: 6f 69 64 65 6e 74 2c 2a 06 03 00 5b 63 69 6c 6c oident,*...[cill
+| 3744: 75 6d 20 64 6f 6c 6f 72 65 20 65 75 20 66 75 67 um dolore eu fug
+| 3760: 69 61 74 20 6e 75 6c 6c 61 20 70 61 72 69 61 74 iat nulla pariat
+| 3776: 75 72 2e 43 05 04 00 81 09 44 75 69 73 20 61 75 ur.C.....Duis au
+| 3792: 74 65 20 69 72 75 72 65 20 64 6f 6c 6f 72 20 69 te irure dolor i
+| 3808: 6e 20 72 65 70 72 65 68 65 6e 64 65 72 69 74 20 n reprehenderit
+| 3824: 69 6e 20 76 6f 6c 75 70 74 61 74 65 20 76 65 6c in voluptate vel
+| 3840: 69 74 20 65 73 73 65 2b 14 03 00 5d 6e 69 73 69 it esse+...]nisi
+| 3856: 20 75 74 20 61 6c 69 71 75 69 70 20 65 78 20 65 ut aliquip ex e
+| 3872: 61 20 63 6f 6d 6d 6f 64 6f 20 63 6f 6e 73 65 71 a commodo conseq
+| 3888: 75 61 74 2e 46 03 04 00 81 11 55 74 20 65 6e 69 uat.F.....Ut eni
+| 3904: 6d 20 61 64 20 6d 69 6e 69 6d 20 76 65 6e 69 61 m ad minim venia
+| 3920: 6d 2c 20 71 75 69 73 20 6e 6f 73 74 72 75 64 20 m, quis nostrud
+| 3936: 65 78 65 72 63 69 74 61 74 69 6f 6e 20 75 6c 6c exercitation ull
+| 3952: 61 6d 63 6f 20 6c 61 62 6f 72 69 73 46 02 04 00 amco laborisF...
+| 3968: 81 11 73 65 64 20 64 6f 20 65 69 75 73 6d 6f 64 ..sed do eiusmod
+| 3984: 20 74 65 6d 70 6f 72 20 69 6e 63 69 64 69 64 75 tempor incididu
+| 4000: 6e 74 20 75 74 20 6c 61 62 6f 72 65 20 65 74 20 nt ut labore et
+| 4016: 64 6f 6c 6f 72 65 20 6d 61 67 6e 61 20 61 6c 69 dolore magna ali
+| 4032: 71 75 61 2e 3a 01 03 00 7b 4c 6f 72 65 6d 20 69 qua.:....Lorem i
+| 4048: 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 psum dolor sit a
+| 4064: 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 met, consectetur
+| 4080: 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 adipiscing elit
+| page 3 offset 8192
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 4 offset 12288
+| 0: 0d 00 00 00 03 0a a6 00 0d 57 0c 4a 0a a6 00 00 .........W.J....
+| 2720: 00 00 00 00 00 00 83 21 03 08 02 08 08 08 17 86 .......!........
+| 2736: 30 08 00 30 20 34 30 32 00 02 61 64 06 01 08 00 0..0 402..ad....
+| 2752: 02 04 00 01 01 6c 06 02 0c 00 02 04 00 01 01 6d .....l.........m
+| 2768: 03 01 06 00 01 01 6e 03 08 09 00 01 01 75 03 05 ......n......u..
+| 2784: 03 00 00 02 63 69 03 06 01 00 01 01 6f 07 01 07 ....ci......o...
+| 2800: 00 03 07 03 00 01 01 75 06 07 05 00 01 04 00 00 .......u........
+| 2816: 02 64 65 03 08 07 00 01 01 6f 0d 01 04 00 01 03 .de......o......
+| 2832: 09 00 03 05 00 01 03 00 01 01 75 03 05 02 00 00 ..........u.....
+| 2848: 02 65 61 03 04 06 00 01 01 69 03 02 04 00 01 01 .ea......i......
+| 2864: 6c 03 01 09 00 01 01 6e 03 03 03 00 01 01 73 06 l......n......s.
+| 2880: 05 0b 00 03 0b 00 01 01 74 03 02 09 00 01 01 75 ........t......u
+| 2896: 03 06 04 00 01 01 78 09 03 09 00 01 05 00 03 02 ......x.........
+| 2912: 00 00 02 66 75 03 06 05 00 00 02 69 64 03 08 0a ...fu......id...
+| 2928: 00 01 01 6e 0a 02 06 00 03 06 04 00 03 03 00 01 ...n............
+| 2944: 01 70 03 01 13 00 01 01 72 03 05 04 00 00 02 6c .p......r......l
+| 2960: 61 09 02 08 00 01 0b 00 05 0c 00 01 01 6f 03 01 a............o..
+| 2976: 02 00 00 02 6d 61 03 02 0b 00 01 01 69 03 04 05 ....ma......i...
+| 2992: 00 01 01 6f 03 08 08 00 00 02 6e 69 03 04 02 00 ...o......ni....
+| 3008: 01 01 6f 06 03 08 00 04 06 00 01 01 75 03 06 06 ..o.........u...
+| 3024: 00 00 02 6f 63 03 07 04 00 01 01 66 03 08 06 00 ...oc......f....
+| 3040: 00 02 70 61 03 06 07 00 01 01 72 03 07 07 00 00 ..pa......r.....
+| 3056: 02 71 75 06 03 07 00 05 05 00 00 02 72 65 03 05 .qu.........re..
+| 3072: 07 00 00 02 73 65 03 02 02 00 01 01 69 06 01 05 ....se......i...
+| 3088: 00 06 03 00 01 01 75 03 08 02 00 00 02 74 65 03 ......u......te.
+| 3104: 03 05 00 00 02 75 6c 03 03 0a 00 01 01 74 09 02 .....ul......t..
+| 3120: 07 00 01 02 00 01 03 00 00 02 76 65 06 03 06 00 ..........ve....
+| 3136: 02 0a 00 01 01 6f 03 05 09 00 82 0a 02 08 02 08 .....o..........
+| 3152: 08 08 17 84 02 04 00 30 20 32 35 31 00 01 61 13 .......0 251..a.
+| 3168: 01 06 04 00 01 0c 00 01 04 00 01 04 00 01 03 00 ................
+| 3184: 03 09 00 00 01 63 10 01 07 00 03 07 03 00 02 02 .....c..........
+| 3200: 00 01 05 00 01 04 00 00 01 64 11 01 04 00 01 03 .........d......
+| 3216: 09 00 03 02 05 00 01 03 00 02 07 00 00 01 65 1b ..............e.
+| 3232: 01 09 00 01 04 07 00 01 03 08 00 01 05 03 00 01 ................
+| 3248: 0b 00 01 04 00 01 02 00 01 0b 00 00 01 66 03 06 .............f..
+| 3264: 05 00 00 01 69 0f 01 03 00 01 06 00 03 04 04 04 ....i...........
+| 3280: 00 03 03 09 00 00 01 6c 0c 01 02 00 01 08 00 01 .......l........
+| 3296: 0b 00 05 0c 00 00 01 6d 09 02 0b 00 01 05 00 05 .......m........
+| 3312: 08 00 00 01 6e 0c 03 08 00 01 02 00 02 06 00 01 ....n...........
+| 3328: 06 00 00 01 6f 06 07 04 00 01 06 00 00 01 70 06 ....o.........p.
+| 3344: 06 07 00 01 07 00 00 01 71 06 03 07 00 05 05 00 ........q.......
+| 3360: 00 01 72 03 05 08 00 00 01 73 0c 01 05 00 01 02 ..r......s......
+| 3376: 00 05 03 00 01 02 00 00 01 74 03 02 05 00 00 01 .........t......
+| 3392: 75 0a 02 07 00 01 02 0a 00 01 03 00 00 01 76 07 u.............v.
+| 3408: 03 06 00 02 09 03 00 85 26 01 08 08 08 08 08 17 ........&.......
+| 3424: 8a 3e 30 20 36 36 35 00 02 61 64 03 03 04 00 02 .>0 665..ad.....
+| 3440: 08 69 70 69 73 63 69 6e 67 03 01 08 00 01 05 6c .ipiscing......l
+| 3456: 69 71 75 61 03 02 0c 00 05 02 69 70 03 04 04 00 iqua......ip....
+| 3472: 01 03 6d 65 74 03 01 06 00 01 03 6e 69 6d 03 08 ..met......nim..
+| 3488: 09 00 01 03 75 74 65 03 05 03 00 00 06 63 69 6c ....ute......cil
+| 3504: 6c 75 6d 03 06 02 00 01 06 6f 6d 6d 6f 64 6f 03 lum......ommodo.
+| 3520: 04 07 00 02 09 6e 73 65 63 74 65 74 75 72 03 01 .....nsectetur..
+| 3536: 07 00 05 04 71 75 61 74 03 04 08 00 01 04 75 6c ....quat......ul
+| 3552: 70 61 03 08 04 00 02 07 70 69 64 61 74 61 74 03 pa......pidatat.
+| 3568: 07 05 00 00 08 64 65 73 65 72 75 6e 74 03 08 07 .....deserunt...
+| 3584: 00 01 01 6f 03 02 03 00 02 03 6c 6f 72 06 01 04 ...o......lor...
+| 3600: 00 04 05 00 05 01 65 06 02 0a 00 04 03 00 01 03 ......e.........
+| 3616: 75 69 73 03 05 02 00 00 02 65 61 03 04 06 00 01 uis......ea.....
+| 3632: 06 69 75 73 6d 6f 64 03 02 04 00 01 03 6c 69 74 .iusmod......lit
+| 3648: 03 01 09 00 01 03 6e 69 6d 03 03 03 00 01 03 73 ......nim......s
+| 3664: 73 65 03 05 0b 00 02 01 73 03 08 0b 00 01 01 74 se......s......t
+| 3680: 03 02 09 00 01 01 75 03 06 04 00 01 01 78 03 04 ......u......x..
+| 3696: 05 00 02 07 63 65 70 74 65 75 72 03 07 02 00 02 ....cepteur.....
+| 3712: 0a 65 72 63 69 74 61 74 69 6f 6e 03 03 09 00 00 .ercitation.....
+| 3728: 06 66 75 67 69 61 74 03 06 05 00 00 02 69 64 03 .fugiat......id.
+| 3744: 08 0a 00 01 01 6e 07 05 06 04 00 03 03 00 02 08 .....n..........
+| 3760: 63 69 64 69 64 75 6e 74 03 02 06 00 01 04 70 73 cididunt......ps
+| 3776: 75 6d 03 01 03 00 01 04 72 75 72 65 03 05 04 00 um......rure....
+| 3792: 00 06 6c 61 62 6f 72 65 03 02 08 00 05 02 69 73 ..labore......is
+| 3808: 03 03 0b 00 05 02 75 6d 03 08 0c 00 01 04 6f 72 ......um......or
+| 3824: 65 6d 03 01 02 00 00 05 6d 61 67 6e 61 03 02 0b em......magna...
+| 3840: 00 01 04 69 6e 69 6d 03 03 05 00 01 05 6f 6c 6c ...inim......oll
+| 3856: 69 74 03 08 08 00 00 04 6e 69 73 69 03 04 02 00 it......nisi....
+| 3872: 01 02 6f 6e 03 07 06 00 02 05 73 74 72 75 64 03 ..on......strud.
+| 3888: 03 08 00 01 04 75 6c 6c 61 03 06 06 00 00 08 6f .....ulla......o
+| 3904: 63 63 61 65 63 61 74 03 07 04 00 01 06 66 66 69 ccaecat......ffi
+| 3920: 63 69 61 03 08 06 00 00 08 70 61 72 69 61 74 75 cia......pariatu
+| 3936: 72 03 06 07 00 01 07 72 6f 69 64 65 6e 74 03 07 r......roident..
+| 3952: 07 00 00 03 71 75 69 03 08 05 00 03 01 73 03 03 ....qui......s..
+| 3968: 07 00 00 0d 72 65 70 72 65 68 65 6e 64 65 72 69 ....reprehenderi
+| 3984: 74 03 05 07 00 00 03 73 65 64 03 02 02 00 01 03 t......sed......
+| 4000: 69 6e 74 03 07 03 00 02 01 74 03 01 05 00 01 03 int......t......
+| 4016: 75 6e 74 03 08 02 00 00 06 74 65 6d 70 6f 72 03 unt......tempor.
+| 4032: 02 05 00 00 07 75 6c 6c 61 6d 63 6f 03 03 0a 00 .....ullamco....
+| 4048: 01 01 74 09 02 07 00 01 02 00 01 03 00 00 05 76 ..t............v
+| 4064: 65 6c 69 74 03 05 0a 00 02 04 6e 69 61 6d 03 03 elit......niam..
+| 4080: 06 00 01 08 6f 6c 75 70 74 61 74 65 03 05 09 00 ....oluptate....
+| page 5 offset 16384
+| 0: 0a 00 00 00 03 0f eb 00 0f fb 0f f3 0f eb 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 00 00 07 04 02 08 01 ................
+| 4080: 08 00 03 07 04 02 08 01 04 00 02 04 04 08 08 09 ................
+| page 6 offset 20480
+| 0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8 ................
+| 16: 0f e2 0f dc 0f d6 0f d0 00 00 00 00 00 00 00 00 ................
+| 4048: 04 08 03 00 0e 0b 04 07 03 00 0e 06 04 06 03 00 ................
+| 4064: 0e 06 04 05 03 00 0e 0a 04 04 03 00 0e 07 04 03 ................
+| 4080: 03 00 0e 0a 04 02 03 00 0e 0b 04 01 03 00 0e 08 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 01 0f f7 00 0f f7 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 07 00 03 00 14 08 45 b5 03 .............E..
+| end crash-f7b636a855e1d2.db
+}]} {}
+
+do_execsql_test 14.1 {
+ PRAGMA writable_schema = 1;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10)
+ INSERT INTO t1(a) SELECT randomblob(3000) FROM c;
+}
+
+do_catchsql_test 14.2 {
+ INSERT INTO t1(t1) VALUES('optimize');
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 15.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3(a, content="");
+ INSERT INTO t1_segdir VALUES(0,0,0,0,'0 665',X'000261640303040002086970697363696e670301080001056c6971756103020c00050269700304040001036d65740301060001036e6a6d03080900010375746503050300000663696c6c756d0306020001066f6d6d6f646f0304070002096e736563746574757203010700050471756174030408000104756c7061030804000207706964617461740307050000086465736572756e740308070001016f0302030002036c6f720601040004050005016506020a00040300010375697303050200000265610304060001066975736d6f640302040001036c69740301090001036e696d13030300010373736503050b0002017403080b0001017403020900010175030604000101780304050002076365707465757203070100020a65726369746174696f6e030309000006667567696174030605000002696403080a0001016e070506040003030002086369646964756e740302060001047073756d030103000104727572650305040000066c61626f7265030208000502697303030b000502756d03080c0001046f72656d0301020000056d61676e6103020b000104696e696d0303050001056f6c6c69740308080000046e6973690304020001026f6e0307060002057374727564030308000104756c6c610306060000086f636361656361740307040001066666696369610308060000087061726961747572030607000107726f6964656e740307070000037175690308050003017303030700000d726570726568656e6465726974030507000003736564030202000103696e7403070300020174030105000103756e7403080200000674656d706f72030205000007756c6c616d636f03030a0001017409020700010200010300000576656c697403050a0002046e69616d0303060001086f6c75707461746503050900');
+}
+
+do_execsql_test 15.1 {
+ SELECT quote(matchinfo(t1, t1 ))==0 FROM t1 WHERE t1 MATCH 'e*';
+} {0 0 0 0 0 0}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 16.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-de7e8cb026385a.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e ef 00 07 0d 4d 00 0f bd 0f 5f ..........M...._
+| 112: 0e f7 0e 06 0e bc 0d a4 0d 4d 00 00 00 00 00 00 .........M......
+| 3392: 00 00 00 00 00 00 00 00 00 00 00 00 00 55 07 07 .............U..
+| 3408: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 73 74 ......tablet1_st
+| 3424: 61 74 74 31 5f 73 74 61 74 07 43 52 45 41 54 45 att1_stat.CREATE
+| 3440: 20 54 41 42 4c 45 20 27 74 31 5f 73 74 61 74 27 TABLE 't1_stat'
+| 3456: 28 69 64 20 49 af 54 45 47 45 52 20 50 52 49 4d (id I.TEGER PRIM
+| 3472: 41 52 59 20 4b 45 59 2c 20 76 61 6c 75 65 20 42 ARY KEY, value B
+| 3488: 4c 4f 42 29 60 06 07 17 21 21 01 81 0b 74 61 62 LOB)`...!!...tab
+| 3504: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64 let1_docsizet1_d
+| 3520: 6f 63 73 69 7a 65 06 43 52 45 41 54 45 20 54 41 ocsize.CREATE TA
+| 3536: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27 BLE 't1_docsize'
+| 3552: 28 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 (docid INTEGER P
+| 3568: 52 49 4d 41 52 59 20 4b 45 59 2c 20 73 69 7a 65 RIMARY KEY, size
+| 3584: 20 42 4c 4f 42 29 81 33 04 07 17 1f 1f 01 82 35 BLOB).3.......5
+| 3600: 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 74 31 tablet1_segdirt1
+| 3616: 5f 73 65 67 64 69 72 04 43 52 45 41 54 45 20 54 _segdir.CREATE T
+| 3632: 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 72 27 ABLE 't1_segdir'
+| 3648: 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 2c 69 (level INTEGER,i
+| 3664: 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 72 74 dx INTEGER,start
+| 3680: 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 6c _block INTEGER,l
+| 3696: 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 6b 20 eaves_end_block
+| 3712: 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c 6f 63 INTEGER,end_bloc
+| 3728: 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 20 42 k INTEGER,root B
+| 3744: 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 59 28 LOB,PRIMARY KEY(
+| 3760: 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 05 06 17 level, idx))1...
+| 3776: 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 65 5f E...indexsqlite_
+| 3792: 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 65 67 autoindex_t1_seg
+| 3808: 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 05 00 dir_1t1_segdir..
+| 3824: 00 00 08 00 00 00 00 66 03 07 17 23 23 01 81 13 .......f...##...
+| 3840: 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e 74 73 tablet1_segments
+| 3856: 74 31 5f 73 65 67 6d 65 6e 74 73 03 43 52 45 41 t1_segments.CREA
+| 3872: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
+| 3888: 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 20 49 ments'(blockid I
+| 3904: 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b NTEGER PRIMARY K
+| 3920: 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 5c EY, block BLOB).
+| 3936: 02 07 17 21 21 01 81 03 74 61 62 6c 65 74 31 5f ...!!...tablet1_
+| 3952: 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 65 6e contentt1_conten
+| 3968: 74 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 t.CREATE TABLE '
+| 3984: 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 63 69 t1_content'(doci
+| 4000: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR
+| 4016: 59 20 4b 45 59 2c 20 27 63 30 61 27 29 41 01 06 Y KEY, 'c0a')A..
+| 4032: 17 11 11 08 71 74 61 62 6c 65 74 31 74 31 43 52 ....qtablet1t1CR
+| 4048: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4064: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 34 LE t1 USING fts4
+| 4080: 28 61 2c 70 72 65 66 69 78 3d 27 31 2c 32 27 29 (a,prefix='1,2')
+| page 2 offset 4096
+| 0: 0d 00 00 00 08 0e 1f 00 0f c4 0f 7c 0f 34 0f 07 ...........|.4..
+| 16: 0e c3 0e 97 0e 63 0e 1f 00 00 00 00 00 00 00 00 .....c..........
+| 3600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ...............B
+| 3616: 08 04 00 81 09 73 75 6e 74 20 69 6e 20 63 75 6c .....sunt in cul
+| 3632: 70 61 20 71 75 69 20 6f 66 66 69 63 69 61 20 64 pa qui officia d
+| 3648: 65 73 65 72 75 6e 74 20 6d 6f 6c 6c 69 74 20 61 eserunt mollit a
+| 3664: 6e 69 6d 20 69 64 20 65 73 74 20 6c 61 62 6f 72 nim id est labor
+| 3680: 75 6d 2e 32 07 03 00 6b 45 78 63 65 70 74 65 75 um.2...kExcepteu
+| 3696: 72 20 73 69 6e 74 20 6f 63 63 61 65 63 61 74 20 r sint occaecat
+| 3712: 63 75 70 69 64 61 74 61 74 20 6e 6f 6e 20 70 72 cupidatat non pr
+| 3728: 6f 69 64 65 6e 74 2c 2a 06 03 00 5b 63 69 6c 6c oident,*...[cill
+| 3744: 75 6d 20 64 6f 6c 6f 72 65 20 65 75 20 66 75 67 um dolore eu fug
+| 3760: 69 61 74 20 6e 75 6c 6c 61 20 70 61 72 69 61 74 iat nulla pariat
+| 3776: 75 72 2e 42 05 04 00 81 09 44 75 69 73 20 61 75 ur.B.....Duis au
+| 3792: 74 65 20 69 72 75 72 65 21 64 6f 6c 6f 72 20 69 te irure!dolor i
+| 3808: 6e 20 72 65 70 72 65 68 65 6e 64 65 72 69 74 20 n reprehenderit
+| 3824: 69 6e 20 76 6f 6c 75 70 74 61 74 65 20 76 65 6c in voluptate vel
+| 3840: 69 74 20 65 73 74 65 2b 04 03 00 5d 6e 69 73 69 it este+...]nisi
+| 3856: 20 75 74 20 61 6c 69 71 75 69 70 20 65 78 20 65 ut aliquip ex e
+| 3872: 61 20 63 6f 6d 6d 6f 64 6f 20 63 6f 6e 73 65 71 a commodo conseq
+| 3888: 75 61 74 2e 46 03 04 00 81 11 55 74 20 65 6e 69 uat.F.....Ut eni
+| 3904: 6d 20 61 64 20 6d 69 6e 69 6d 20 76 65 6e 69 61 m ad minim venia
+| 3920: 6d 2c 20 71 75 69 73 20 6e 6f 73 74 72 75 64 20 m, quis nostrud
+| 3936: 65 78 65 72 63 69 74 61 74 69 6f 6e 20 75 6c 6c exercitation ull
+| 3952: 61 6d 63 6f 20 6c 61 62 6f 72 69 73 46 02 04 00 amco laborisF...
+| 3968: 81 11 73 65 64 20 64 6f 20 65 69 75 73 6d 6f 64 ..sed do eiusmod
+| 3984: 20 74 65 6d 70 6f 72 20 69 6e 63 69 64 69 64 75 tempor incididu
+| 4000: 6e 74 20 75 74 20 6c 61 62 6f 72 65 20 65 74 20 nt ut labore et
+| 4016: 64 6f 6c 6f 72 65 20 6d 61 67 6e 61 20 51 6c 69 dolore magna Qli
+| 4032: 71 75 61 2e 3a 01 03 00 7b 4c 6f 72 65 6d 20 69 qua.:....Lorem i
+| 4048: 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 e5 61 psum dolor sit.a
+| 4064: 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 met, consectetur
+| 4080: 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 adipiscing elit
+| page 3 offset 8192
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 4 offset 12288
+| 0: 0d 00 00 00 03 0a a6 00 0d 57 0c 4a 0a a6 00 00 .........W.J....
+| 2720: 00 00 00 00 00 00 83 21 03 08 02 08 08 08 17 86 .......!........
+| 2736: 30 08 00 30 20 34 30 32 00 02 61 64 06 01 08 00 0..0 402..ad....
+| 2752: 02 04 00 01 01 6c 06 02 0c 00 02 04 00 01 01 6d .....l.........m
+| 2768: 03 01 06 00 01 01 6e 03 08 09 00 01 01 75 03 05 ......n......u..
+| 2784: 03 00 00 02 63 69 03 06 02 00 01 01 6f 07 01 07 ....ci......o...
+| 2800: 00 03 07 03 00 01 01 75 06 07 05 00 01 04 00 00 .......u........
+| 2816: 02 64 65 03 08 07 00 01 01 6f 0d 01 04 00 01 03 .de......o......
+| 2832: 09 00 03 05 00 01 03 00 01 01 75 03 05 02 00 00 ..........u.....
+| 2848: 02 65 61 03 04 06 00 01 01 69 03 02 04 00 01 01 .ea......i......
+| 2864: 6c 03 01 09 00 01 01 6e 03 03 03 00 01 01 73 06 l......n......s.
+| 2880: 05 0b 00 03 0b 00 01 01 74 03 02 09 00 01 01 75 ........t......u
+| 2896: 03 06 04 00 01 01 78 09 03 09 00 01 05 00 03 02 ......x.........
+| 2912: 00 00 02 66 75 03 06 05 00 00 02 69 64 03 08 0a ...fu......id...
+| 2928: 00 01 01 6e 0a 02 06 00 03 06 04 00 03 03 00 01 ...n............
+| 2944: 01 70 03 01 03 00 01 01 72 03 05 04 00 00 02 6c .p......r......l
+| 2960: 61 09 02 08 00 01 0b 00 05 0c 00 01 01 6f 03 01 a............o..
+| 2976: 02 00 00 02 6d 61 03 02 0b 00 01 01 69 03 03 05 ....ma......i...
+| 2992: 00 01 01 6f 03 08 08 00 00 02 6e 69 03 04 02 00 ...o......ni....
+| 3008: 01 01 6f 06 03 08 00 04 06 00 01 01 75 03 06 06 ..o.........u...
+| 3024: 00 00 02 6f 63 03 07 04 00 01 01 66 03 08 06 00 ...oc......f....
+| 3040: 00 02 70 61 03 06 07 00 01 01 72 03 07 07 00 00 ..pa......r.....
+| 3056: 02 71 75 06 03 07 00 05 05 00 00 02 72 65 03 05 .qu.........re..
+| 3072: 07 00 00 02 73 65 03 02 02 00 01 01 69 06 01 05 ....se......i...
+| 3088: 00 06 03 00 01 01 75 03 08 02 00 00 02 74 65 03 ......u......te.
+| 3104: 02 05 00 00 02 75 6c 03 03 0a 00 01 01 74 09 02 .....ul......t..
+| 3120: 07 00 01 02 00 01 03 00 00 02 76 65 06 03 06 00 ..........ve....
+| 3136: 02 0a 00 01 01 6f 03 05 09 00 82 0a 02 08 12 08 .....o..........
+| 3152: 08 08 17 84 02 04 00 30 20 32 35 31 00 01 61 23 .......0 251..a#
+| 3168: 01 06 04 00 01 0c 00 01 04 00 01 04 00 01 03 00 ................
+| 3184: 03 09 00 00 01 63 10 01 07 00 03 07 03 00 02 02 .....c..........
+| 3200: 00 01 05 00 01 04 00 00 01 64 11 01 04 00 01 03 .........d......
+| 3216: 09 00 03 02 05 00 01 13 00 02 07 00 00 01 65 1b ..............e.
+| 3232: 01 09 00 01 04 07 00 01 03 08 00 01 05 03 00 01 ................
+| 3248: 0b 00 01 04 00 01 02 00 01 0b 00 00 01 66 03 06 .............f..
+| 3264: 05 00 00 01 69 0f 01 03 00 01 06 00 03 04 04 04 ....i...........
+| 3280: 00 03 03 09 00 00 01 6c 0c 01 02 00 01 08 00 01 .......l........
+| 3296: 0b 00 05 0c 00 10 01 6d 09 02 0b 00 01 05 00 05 .......m........
+| 3312: 08 00 00 01 6e 0c 03 08 00 01 02 00 02 06 00 01 ....n...........
+| 3328: 06 00 00 01 6f 06 07 04 00 01 06 00 00 01 70 06 ....o.........p.
+| 3344: 06 07 00 01 07 00 00 01 71 06 03 07 00 05 05 00 ........q.......
+| 3360: 00 01 72 03 05 07 00 00 01 73 0c 01 05 00 01 02 ..r......s......
+| 3376: 00 05 03 00 01 02 00 00 01 74 03 02 05 00 00 01 .........t......
+| 3392: 75 0a 02 07 00 01 02 0a 00 01 03 00 00 01 76 07 u.............v.
+| 3408: 03 06 00 02 09 03 00 85 26 01 08 08 08 08 08 17 ........&.......
+| 3424: 8a 3e 30 20 36 36 35 00 02 61 64 03 03 04 00 02 .>0 665..ad.....
+| 3440: 08 69 70 69 73 63 69 6e 67 03 01 08 00 01 05 6c .ipiscing......l
+| 3456: 69 71 75 61 03 02 0c 00 05 02 69 70 03 04 04 00 iqua......ip....
+| 3472: 01 03 6d 65 74 03 01 06 00 01 03 6e 69 6d 03 08 ..met......nim..
+| 3488: 09 00 01 03 75 74 65 03 05 03 00 00 06 63 69 6c ....ute......cil
+| 3504: 6c 75 6d 03 06 02 00 01 06 6f 6d 6d 6f 64 6f 03 lum......ommodo.
+| 3520: 04 07 00 02 09 6e 73 65 63 74 65 74 75 72 03 01 .....nsectetur..
+| 3536: 07 00 05 04 71 75 61 74 03 04 08 00 01 04 75 6c ....quat......ul
+| 3552: 70 61 03 08 04 00 02 07 70 69 64 61 74 61 74 03 pa......pidatat.
+| 3568: 07 05 00 00 08 64 65 73 65 72 75 6e 74 03 08 07 .....deserunt...
+| 3584: 00 01 01 6f 03 02 03 00 02 03 6c 6f 72 06 01 04 ...o......lor...
+| 3600: 00 04 05 00 05 01 65 06 02 0a 00 04 03 00 01 03 ......e.........
+| 3616: 75 69 73 03 05 02 00 00 02 65 61 03 04 06 00 01 uis......ea.....
+| 3632: 06 69 75 73 6d 6f 64 03 02 04 00 01 03 6c 69 74 .iusmod......lit
+| 3648: 03 01 09 00 01 03 6e 69 6d 03 03 03 00 01 03 73 ......nim......s
+| 3664: 73 65 03 05 0b 00 02 01 74 03 08 0b 00 01 01 74 se......t......t
+| 3680: 03 02 09 00 01 01 75 03 06 04 00 01 01 78 03 04 ......u......x..
+| 3696: 05 00 02 07 63 65 70 74 65 75 72 03 07 02 00 02 ....cepteur.....
+| 3712: 0a 65 72 63 69 74 61 74 69 6f 6e 03 03 09 00 00 .ercitation.....
+| 3728: 06 66 75 67 69 61 74 03 06 05 00 00 02 69 64 03 .fugiat......id.
+| 3744: 08 0a 00 01 01 6e 07 05 06 04 00 03 03 00 02 08 .....n..........
+| 3760: 63 69 64 69 64 75 7e 74 03 02 06 00 01 04 70 73 cididu~t......ps
+| 3776: 75 6d 03 01 03 00 01 03 72 75 72 65 03 05 04 00 um......rure....
+| 3792: 00 06 6c 61 62 6f 72 65 03 02 08 00 05 02 69 73 ..labore......is
+| 3808: 03 03 0b 00 05 02 75 6d 03 08 0c 00 01 04 6f 72 ......um......or
+| 3824: 65 6d 03 01 02 00 00 05 6d 61 67 6e 61 03 02 0b em......magna...
+| 3840: 00 01 04 69 6e 69 6d 03 03 05 00 01 05 6f 6c 6c ...inim......oll
+| 3856: 69 74 03 08 08 00 00 04 6e 69 73 69 03 04 02 00 it......nisi....
+| 3872: 01 02 6f 6e 03 07 06 00 02 05 73 74 72 75 64 03 ..on......strud.
+| 3888: 03 08 00 01 04 75 6c 6c 61 03 06 06 00 00 08 6f .....ulla......o
+| 3904: 63 63 61 65 63 61 74 03 07 04 00 01 06 66 66 69 ccaecat......ffi
+| 3920: 63 69 61 03 08 06 00 00 08 70 61 72 69 61 74 75 cia......pariatu
+| 3936: 72 03 06 07 00 01 07 72 6f 69 64 65 6e 74 03 07 r......roident..
+| 3952: 07 00 00 03 71 75 69 03 08 05 00 03 01 73 03 03 ....qui......s..
+| 3968: 07 00 00 0d 72 65 70 72 65 68 65 6e 64 65 72 69 ....reprehenderi
+| 3984: 74 03 05 07 00 00 03 73 65 64 03 02 02 00 01 03 t......sed......
+| 4000: 69 6e 74 03 07 03 00 02 01 74 03 01 05 00 01 03 int......t......
+| 4016: 75 6e 74 03 08 02 00 00 06 74 65 6d 70 6f 72 03 unt......tempor.
+| 4032: 02 05 00 00 07 75 6c 6c 61 6d 63 6f 03 03 0a 00 .....ullamco....
+| 4048: 01 01 74 09 02 07 00 01 02 00 01 03 00 00 05 76 ..t............v
+| 4064: 65 6c 69 74 03 05 0a 00 02 04 6e 69 61 6d 03 03 elit......niam..
+| 4080: 06 00 01 08 6f 6c 75 70 74 61 74 65 03 05 09 00 ....oluptate....
+| page 5 offset 16384
+| 0: 0a 00 00 00 03 0f eb 00 0f fb 0f f3 0f eb 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 00 00 07 04 02 08 01 ................
+| 4080: 08 00 03 07 04 02 08 03 a4 00 02 04 04 08 08 09 ................
+| page 6 offset 20480
+| 0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8 ................
+| 16: 0f e2 0f dc 0f d6 0f d0 00 00 00 00 00 00 00 00 ................
+| 4048: 04 08 03 00 0e 0b 04 07 03 00 0e 06 04 06 03 00 ................
+| 4064: 0e 06 04 05 03 00 0e 0a 04 04 03 00 0e 07 04 03 ................
+| 4080: 03 00 0e 0a 04 02 03 00 0e 0b 04 01 03 00 0e 08 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 01 0f f7 00 0f f7 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 07 00 03 00 14 08 45 b5 03 .............E..
+| end crash-de7e8cb026385a.db
+}]} {}
+
+do_catchsql_test 16.1 {
+ INSERT INTO t1(t1) VALUES('optimize');
+} {0 {}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 17.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-f15972acf5bc1c.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 0d a4 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00 (a,b,c)...9.....
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 03 28 0d 4f 0d 35 0d 1b 0c fb .......(.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 72 7f 00 .........?%..r..
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 43 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAC EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 14 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0e 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 4d 03 25 15 00 00 04 .%....sysM.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 0e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 10 d6 0f c7 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end crash-f15972acf5bc1c.db
+}]} {}
+
+do_execsql_test 17.1 {
+ BEGIN;
+ INSERT INTO t1(t1) SELECT x FROM t2;
+ UPDATE t1 SET b=quote(zeroblob(200)) WHERE a MATCH 'thread*';
+}
+
+do_catchsql_test 17.2 {
+ DROP TABLE IF EXISTS t1;
+} {1 {SQL logic error}}
+
+do_execsql_test 17.3 {
+ INSERT INTO t1(t1) VALUES('optimize');
+}
+
+do_catchsql_test 17.4 {
+ DROP TABLE IF EXISTS t1;
+} {1 {SQL logic error}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 18.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 32768 pagesize 4096 filename crash-4ce32d0608aff1.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 07 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 0d a4 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 62 2c 72 6f 6f 74 ock INTEGEb,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00 (a,b,c)...9.....
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 23 00 20 32 30 31 36 30 36 30 39 20 44 45 42 4#. 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 53 49 4d 18 1b 05 00 25 00000XRTSIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 52 4c 45 20 4a 53 4f ...%..ENARLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 1e 4c NARY....)..ENA.L
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 55 ....)..ENABLE GU
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 59 e5 58 .#..ENABLE FTY.X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 ..#..ENABLE FTS5
+| 3792: 58 4e 4f 43 40 53 45 16 0a 05 00 23 0f 17 45 4e XNOC@SE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 25 75 2e 34 2f 30 20 32 30 31 36 30 36 30 cc%u.4/0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 41 00 04 6c 6f 61 64 03 25 1c 00 n1.%.A..load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 56 65 03 %....threadsaVe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 02 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 f2 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 57 02 00 .............W..
+| 3504: 01 02 00 01 01 00 01 02 00 11 02 00 01 02 10 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 64 6e 73 69 6f .........xtdnsio
+| 3552: 6e 09 1f 04 00 01 04 00 01 03 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 57 63 63 09 01 03 ..........Wcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 02 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4064: 00 00 00 00 00 0d 05 02 23 61 75 74 6f 6d 65 72 ........#automer
+| 4080: 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 3d 31 30 ge=5...#merge=10
+| page 8 offset 28672
+| 0: 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 69 74 79 0,8...+integrity
+| 16: 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 75 69 6c -check....rebuil
+| 32: 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 00 00 00 d....optimize...
+| end crash-4ce32d0608aff1.db
+}]} {}
+
+do_catchsql_test 18.1 {
+ SELECT quote(matchinfo(t1,'pcxybs'))==0 FROM t1 WHERE b MATCH 'e*';
+} {0 {}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 19.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-526ea445f41c02.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 41 43 52 ...._tablet1tACR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00 (a,b,c)...9.....
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2f .COMPILER=gcc-5/
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4f 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c OARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4d f5 20 46 54 53 34 ..#..ENABM. FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 52 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ARLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 04 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 13 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 12 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 81 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end crash-526ea445f41c02.db
+}]} {}
+
+do_catchsql_test 19.1 {
+ PRAGMA writable_schema = 1;
+ SELECT rowid,a,c,snippet(t1,85101090932165,-1,10) FROM t1 WHERE a MATCH 'rtree';
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 20.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-afecd03c862e58.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
+| 96: 00 00 00 00 0d 0e ef 00 07 0d 4d 00 0f bd 0f 5f ..........M...._
+| 112: 0e f7 0e 06 0e bc 0d a4 0d 4d 00 00 01 00 00 00 .........M......
+| 3392: 00 00 00 00 00 00 00 00 00 00 00 00 00 55 07 07 .............U..
+| 3408: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 73 74 ......tablet1_st
+| 3424: 61 74 74 31 5f 73 74 61 74 07 43 52 45 41 54 45 att1_stat.CREATE
+| 3440: 20 54 41 42 4c 45 20 27 74 31 5f 73 74 61 74 27 TABLE 't1_stat'
+| 3456: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (id INTEGER PRIM
+| 3472: 41 52 59 20 4b 45 59 2c 20 76 61 6c 75 65 20 42 ARY KEY, value B
+| 3488: 4c 4f 42 29 60 06 07 17 21 21 01 81 0b 74 61 62 LOB)`...!!...tab
+| 3504: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64 let1_docsizet1_d
+| 3520: 6f 63 73 69 7a 65 06 43 52 45 41 54 45 20 54 41 ocsize.CREATE TA
+| 3536: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27 BLE 't1_docsize'
+| 3552: 28 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 (docid INTEGER P
+| 3568: 52 49 4d 41 52 59 30 4b 45 59 2c 20 73 69 7a 65 RIMARY0KEY, size
+| 3584: 20 42 4c 4f 42 29 81 33 04 07 17 1f 1f 01 82 35 BLOB).3.......5
+| 3600: 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 74 31 tablet1_segdirt1
+| 3616: 5f 73 65 67 64 69 25 04 43 52 45 41 54 45 20 54 _segdi%.CREATE T
+| 3632: 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 72 27 ABLE 't1_segdir'
+| 3648: 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 2c 69 (level INTEGER,i
+| 3664: 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 72 74 dx INTEGER,start
+| 3680: 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 6c _block INTEGER,l
+| 3696: 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 6b 20 eaves_end_block
+| 3712: 49 4d 54 45 47 45 52 2c 65 6e 64 5f 62 6c 6f 63 IMTEGER,end_bloc
+| 3728: 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 20 42 k INTEGER,root B
+| 3744: 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 59 28 LOB,PRIMARY KEY(
+| 3760: 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 05 06 17 level, idx))1...
+| 3776: 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 65 5f E...indexsqlite_
+| 3792: 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 65 67 autoindex_t1_seg
+| 3808: 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 05 00 dir_1t1_segdir..
+| 3824: 00 00 08 00 00 00 00 66 03 07 17 23 23 01 81 13 .......f...##...
+| 3840: 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e 74 73 tablet1_segments
+| 3856: 74 31 5f 73 65 67 6d 65 6e 74 73 03 43 52 45 41 t1_segments.CREA
+| 3872: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
+| 3888: 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 20 49 ments'(blockid I
+| 3904: 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b NTEGER PRIMARY K
+| 3920: 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 5c EY, block BLOB).
+| 3936: 02 07 17 21 21 01 81 03 74 61 62 6c 65 74 31 5f ...!!...tablet1_
+| 3952: 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 65 6e contentt1_conten
+| 3968: 74 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 t.CREATE TABLE '
+| 3984: 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 63 69 t1_content'(doci
+| 4000: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR
+| 4016: 59 20 4b 45 59 2c 20 27 63 30 61 27 29 41 01 06 Y KEY, 'c0a')A..
+| 4032: 17 11 11 08 71 74 61 62 6c 65 74 31 74 31 43 52 ....qtablet1t1CR
+| 4048: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4064: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 34 LE t1 USING fts4
+| 4080: 28 61 2c 70 72 65 66 69 78 3d 27 31 2c 32 27 29 (a,prefix='1,2')
+| page 2 offset 4096
+| 0: 0d 00 00 00 08 0e 1f 00 0f c4 0f 7c 0f 34 0f 07 ...........|.4..
+| 16: 0e c3 0e 97 0e 63 0e 1f 00 00 00 00 00 00 00 00 .....c..........
+| 3600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ...............B
+| 3616: 08 04 00 81 09 73 75 6e 74 20 69 6e 20 63 75 6c .....sunt in cul
+| 3632: 70 61 20 71 75 68 20 6f 66 66 69 63 69 61 20 64 pa quh officia d
+| 3648: 65 73 65 72 75 6e 74 20 6d 6f 6c 6c 69 74 20 61 eserunt mollit a
+| 3664: 6e 69 6d 20 69 64 20 65 73 74 20 6c 61 62 6f 72 nim id est labor
+| 3680: 75 6d 2e 32 07 03 01 6b 45 78 63 65 70 74 65 75 um.2...kExcepteu
+| 3696: 72 20 73 69 6e 74 20 6f 63 63 61 65 63 61 74 20 r sint occaecat
+| 3712: 63 75 70 69 64 61 74 61 74 20 6e 6f 6e 20 70 72 cupidatat non pr
+| 3728: 6f 69 64 65 6e 74 2c 2a 06 03 00 5b 63 69 6c 6c oident,*...[cill
+| 3744: 75 6d 20 64 6f 6c 6f 72 65 20 65 75 20 66 75 67 um dolore eu fug
+| 3760: 69 61 74 20 6e 75 6c 6c 61 20 70 61 72 69 61 74 iat nulla pariat
+| 3776: 75 72 2e 43 05 04 00 81 09 44 75 69 73 20 61 75 ur.C.....Duis au
+| 3792: 74 65 20 69 72 75 72 65 20 64 6f 6c 6f 72 20 69 te irure dolor i
+| 3808: 6e 20 72 65 70 72 65 68 65 6e 64 65 72 69 74 20 n reprehenderit
+| 3824: 69 6e 20 76 6f 6c 75 70 74 61 74 65 20 76 65 6c in voluptate vel
+| 3840: 69 74 20 65 73 73 65 2b 14 03 00 5d 6e 69 73 69 it esse+...]nisi
+| 3856: 20 75 74 20 61 6c 69 71 75 69 70 20 65 78 20 65 ut aliquip ex e
+| 3872: 61 20 63 6f 6d 6d 6f 64 6f 20 63 6f 6e 73 65 71 a commodo conseq
+| 3888: 75 61 74 2e 46 03 04 00 81 11 55 74 20 65 6e 69 uat.F.....Ut eni
+| 3904: 6d 20 61 63 20 6d 69 6e 69 6d 20 76 65 6e 69 61 m ac minim venia
+| 3920: 6d 2c 20 71 75 69 73 20 6e 6f 73 74 72 75 64 20 m, quis nostrud
+| 3936: 65 78 65 72 63 69 74 61 74 69 6f 6e 20 75 6c 6c exercitation ull
+| 3952: 61 6d 63 6f 20 6c 61 62 6f 72 69 73 46 02 04 00 amco laborisF...
+| 3968: 81 11 73 65 64 20 64 6f 20 65 69 75 73 6d 6f 64 ..sed do eiusmod
+| 3984: 20 74 65 6d 70 6f 72 20 69 6e 63 69 64 69 64 75 tempor incididu
+| 4000: 6e 74 20 75 74 20 6c 61 62 6f 72 65 20 65 74 20 nt ut labore et
+| 4016: 64 6f 6c 6f 72 65 20 6d 61 67 6e 61 20 61 6c 69 dolore magna ali
+| 4032: 71 75 61 2e 3a 01 03 00 7b 4c 6f 72 65 6d 20 69 qua.:....Lorem i
+| 4048: 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 psum dolor sit a
+| 4064: 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 met, consectetur
+| 4080: 20 61 64 69 70 69 73 63 69 6e 67 20 65 6c 69 74 adipiscing elit
+| page 3 offset 8192
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 4 offset 12288
+| 0: 0d 00 00 00 03 0a a6 00 0d 57 0c 4a 0a a6 00 00 .........W.J....
+| 2720: 00 00 00 00 00 00 83 21 03 08 02 08 08 08 17 86 .......!........
+| 2736: 30 08 00 30 20 34 30 32 00 02 61 64 06 01 08 00 0..0 402..ad....
+| 2752: 02 04 00 01 01 6c 06 02 0c 00 02 04 00 01 01 6d .....l.........m
+| 2768: 03 01 06 00 01 01 6e 03 08 09 00 01 01 75 03 05 ......n......u..
+| 2784: 03 00 00 02 63 69 03 06 01 00 01 01 6f 07 01 07 ....ci......o...
+| 2800: 00 03 07 03 00 01 01 75 06 07 05 00 01 04 00 00 .......u........
+| 2816: 02 64 65 03 08 07 00 01 01 6f 0d 01 04 00 01 03 .de......o......
+| 2832: 09 00 03 05 00 01 03 00 01 01 75 03 05 02 00 00 ..........u.....
+| 2848: 02 65 61 03 04 06 00 01 01 69 03 02 04 00 01 01 .ea......i......
+| 2864: 6c 03 01 09 00 01 01 6e 03 03 03 00 01 01 73 06 l......n......s.
+| 2880: 05 0b 00 03 0b 00 01 01 74 03 02 09 00 01 01 75 ........t......u
+| 2896: 03 06 04 00 01 01 78 09 03 09 00 01 05 00 03 02 ......x.........
+| 2912: 00 00 02 66 75 03 06 05 00 00 02 69 64 03 08 0a ...fu......id...
+| 2928: 00 01 01 6e 0a 02 06 00 03 06 04 00 03 03 00 01 ...n............
+| 2944: 01 70 03 01 13 00 01 01 72 03 05 04 00 00 02 6c .p......r......l
+| 2960: 61 09 02 08 00 01 0b 00 05 0c 00 01 01 6f 03 01 a............o..
+| 2976: 02 00 00 02 6d 61 03 02 0b 00 01 01 69 03 03 05 ....ma......i...
+| 2992: 00 01 01 6f 03 08 08 00 00 02 6e 69 03 04 02 00 ...o......ni....
+| 3008: 01 01 6f 06 03 08 00 04 06 00 01 01 75 03 06 06 ..o.........u...
+| 3024: 00 00 02 6f 63 03 07 04 00 01 01 66 03 08 06 00 ...oc......f....
+| 3040: 00 02 70 61 03 06 07 00 01 01 72 03 07 07 00 00 ..pa......r.....
+| 3056: 02 71 75 06 03 07 00 05 05 00 00 02 72 65 03 05 .qu.........re..
+| 3072: 07 00 00 02 73 65 03 02 02 00 01 01 69 06 01 05 ....se......i...
+| 3088: 00 06 03 00 01 01 75 03 08 02 00 00 02 74 65 03 ......u......te.
+| 3104: 03 05 00 00 02 72 bc 03 03 0a 00 01 01 74 09 02 .....r.......t..
+| 3120: 07 00 01 02 00 01 03 00 00 02 76 65 06 03 06 00 ..........ve....
+| 3136: 02 0a 00 01 01 6f 03 05 09 00 82 0a 02 08 02 08 .....o..........
+| 3152: 08 08 17 84 02 04 00 30 20 32 35 31 00 01 61 13 .......0 251..a.
+| 3168: 01 06 04 00 01 0c 00 01 04 00 01 04 00 01 03 00 ................
+| 3184: 03 09 00 00 01 63 10 01 07 00 03 07 03 00 02 02 .....c..........
+| 3200: 00 01 05 00 01 04 00 00 01 64 11 01 04 00 01 03 .........d......
+| 3216: 09 00 03 02 05 00 01 03 00 02 07 00 00 01 65 1b ..............e.
+| 3232: 01 09 00 01 04 07 00 01 03 08 00 01 05 03 00 01 ................
+| 3248: 0b 00 01 04 00 01 02 00 01 0b 00 00 01 66 03 06 .............f..
+| 3264: 05 00 00 01 69 0f 01 03 00 01 06 00 02 04 04 04 ....i...........
+| 3280: 00 03 03 09 00 00 01 6c 0c 01 02 00 01 08 00 01 .......l........
+| 3296: 0b 00 05 0c 00 00 01 6d 09 02 0b 00 01 05 00 05 .......m........
+| 3312: 08 00 00 01 6e 0c 03 08 00 01 02 00 02 06 00 01 ....n...........
+| 3328: 06 00 f0 01 6f 06 07 04 00 01 06 00 00 01 70 06 ....o.........p.
+| 3344: 06 07 00 01 07 00 00 01 71 06 03 07 00 05 05 00 ........q.......
+| 3360: 00 01 72 03 05 08 00 00 01 73 0c 01 05 00 01 02 ..r......s......
+| 3376: 00 05 03 00 01 02 00 00 01 74 03 02 05 00 00 01 .........t......
+| 3392: 75 0a 02 07 00 01 02 0a 00 01 03 00 00 01 76 07 u.............v.
+| 3408: 03 06 00 02 09 03 00 85 26 01 08 08 08 08 08 17 ........&.......
+| 3424: 8a 3e 30 21 36 36 35 00 02 61 64 03 03 04 00 02 .>0!665..ad.....
+| 3440: 08 69 70 69 73 63 69 6e 67 03 01 08 00 01 05 6c .ipiscing......l
+| 3456: 69 71 75 61 03 02 0c 00 05 02 69 70 03 04 04 00 iqua......ip....
+| 3472: 01 03 6d 65 74 03 01 06 00 01 03 6e 69 6d 03 08 ..met......nim..
+| 3488: 09 00 01 03 75 74 65 03 05 03 00 00 06 63 69 6c ....ute......cil
+| 3504: 6c 75 6d 03 06 02 00 01 06 6f 6d 6d 6f 64 6f 03 lum......ommodo.
+| 3520: 04 07 00 02 09 6e 73 65 63 74 65 74 75 72 03 01 .....nsectetur..
+| 3536: 07 00 05 04 71 75 61 74 03 04 08 00 01 04 75 6c ....quat......ul
+| 3552: 70 61 03 08 04 00 02 07 70 69 64 61 74 61 74 03 pa......pidatat.
+| 3568: 07 05 00 00 08 64 65 73 65 72 75 6e 74 03 08 07 .....deserunt...
+| 3584: 00 01 01 6f 03 02 03 00 02 03 6c 6f 72 06 01 04 ...o......lor...
+| 3600: 00 04 05 00 05 01 65 06 02 0a 00 04 03 00 01 03 ......e.........
+| 3616: 75 69 73 03 05 02 00 00 02 65 61 03 04 06 00 01 uis......ea.....
+| 3632: 06 69 75 73 6d 6f 64 03 02 04 00 01 03 6c 69 74 .iusmod......lit
+| 3648: 03 01 09 00 01 03 6e 69 6d 03 03 03 00 01 03 73 ......nim......s
+| 3664: 73 65 03 05 0b 00 02 01 74 03 08 0b 00 01 01 74 se......t......t
+| 3680: 03 02 09 00 01 01 75 03 06 04 00 01 01 78 03 04 ......u......x..
+| 3696: 05 00 02 07 63 65 70 74 65 75 72 03 07 02 00 02 ....cepteur.....
+| 3712: 0a 65 72 63 69 74 61 74 69 6f 6e 03 03 09 00 00 .ercitation.....
+| 3728: 06 66 75 67 69 61 74 03 06 05 00 00 02 69 64 03 .fugiat......id.
+| 3744: 08 0a 00 01 01 6e 07 05 06 04 00 03 03 00 02 08 .....n..........
+| 3760: 63 69 64 69 64 75 6e 74 03 02 06 00 01 04 70 73 cididunt......ps
+| 3776: 75 6d 03 01 03 00 01 04 72 75 72 65 03 05 04 00 um......rure....
+| 3792: 00 06 6c 61 62 6f 72 65 03 02 08 00 05 02 69 73 ..labore......is
+| 3808: 03 03 0b 00 05 02 75 6d 03 08 0c 00 01 04 6f 72 ......um......or
+| 3824: 65 6d 03 01 02 00 00 05 6d 61 67 6e 61 03 02 0b em......magna...
+| 3840: 00 01 04 69 6e 69 6d 03 03 05 00 01 05 6f 6c 6c ...inim......oll
+| 3856: 69 74 03 08 08 00 00 04 6e 69 73 69 03 04 02 00 it......nisi....
+| 3872: 01 02 6f 6e 03 07 06 00 02 05 73 74 72 75 64 03 ..on......strud.
+| 3888: 03 08 00 01 04 75 6c 6c 61 03 06 06 00 00 08 6f .....ulla......o
+| 3904: 63 63 61 65 63 61 74 03 07 04 00 01 06 66 66 69 ccaecat......ffi
+| 3920: 63 69 61 03 08 06 00 00 08 70 61 72 69 61 74 75 cia......pariatu
+| 3936: 72 03 06 07 00 01 07 72 6f 69 64 65 6e 74 03 07 r......roident..
+| 3952: 07 00 00 03 71 75 69 03 08 05 00 03 01 73 03 03 ....qui......s..
+| 3968: 07 00 00 0d 72 65 41 72 65 68 65 6e 64 65 72 69 ....reArehenderi
+| 3984: 74 03 05 07 00 00 03 73 65 64 03 02 02 00 01 03 t......sed......
+| 4000: 69 6e 74 03 07 03 00 02 01 74 03 01 05 00 01 03 int......t......
+| 4016: 75 6e 74 03 08 02 00 00 06 74 65 6d 70 6f 72 03 unt......tempor.
+| 4032: 02 05 00 00 07 75 6c 6c 61 6d 63 6f 03 03 0a 00 .....ullamco....
+| 4048: 01 01 74 09 02 07 00 01 02 00 01 03 00 00 05 76 ..t............v
+| 4064: 65 6c 69 74 03 05 0a 00 02 04 6e 69 61 6d 03 03 elit......niam..
+| 4080: 06 00 01 08 70 6c 75 70 74 61 74 65 03 05 09 00 ....pluptate....
+| page 5 offset 16384
+| 0: 0a 00 00 00 03 0f eb 00 0f fb 0f f3 0f eb 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 00 00 07 04 02 08 01 ................
+| 4080: 08 00 03 07 04 0a 98 01 04 00 02 04 04 08 08 09 ................
+| page 6 offset 20480
+| 0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8 ................
+| 16: 0f e2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4048: 04 08 03 00 0e 0b 04 07 03 00 0e 06 04 06 03 00 ................
+| 4064: 0e 06 04 05 03 00 0e 0a 04 04 03 00 0e 07 04 03 ................
+| 4080: 03 00 0e 0a 04 02 03 00 0e 0b 04 01 03 00 0e 08 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 01 0f f7 00 0f f7 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 07 00 03 00 14 08 45 b5 03 .............E..
+| end crash-afecd03c862e58.db
+}]} {}
+
+do_execsql_test 20.1 {
+ PRAGMA writable_schema = 1;
+ BEGIN;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10)
+ INSERT INTO t1(a) SELECT randomblob(3000) FROM c;
+}
+
+do_execsql_test 20.2 {
+ INSERT INTO t1(t1) VALUES('optimize');
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 21.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-18cc014e42e828.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 04 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 66 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 ft2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 75 67 64 69 72 .5tablet1_sugdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 46 47 45 52 rt_block INTFGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 62 2c 72 6f 6f 74 ock INTEGEb,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4e 0d 35 0d 1b 0c fb .......h.N.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 00 00 .......x.W.>.$..
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 23 00 20 32 30 31 36 30 36 30 39 20 44 45 42 4#. 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 43 53 VTAB ENABLE FCS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 20 21 05 00 33 0f 19 4f 4d 0XRTRIM !..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 39 NABLE GEOPOLYXB9
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 1e 4c NARY....)..ENA.L
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 16 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 48 4e 41 52 59 17 0b LE FTS4XBHNARY..
+| 3776: 05 00 23 0e 19 45 4e 41 42 4c 45 20 46 54 53 35 ..#..ENABLE FTS5
+| 3792: 58 4e 4f 43 40 53 45 16 0a 05 00 23 0f 17 45 4e XNOC@SE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 2e 52 49 4d 1e ABLE FTS4XR.RIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 da 41 52 59 27 20160609XBI.ARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 00 00 00 00 OMPILER=gcc-....
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 3a 03 25 07 00 00 01 34 03 25 05 00 00 01 35 0:.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 57 63 63 03 25 03 00 01 .5.%....Wcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 64 64 73 61 66 65 03 %....threddsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 12 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 0e 97 02 00 ................
+| 3504: 01 02 00 01 cb 00 01 02 00 01 02 00 01 02 10 01 ................
+| 3520: 02 00 01 02 00 01 02 01 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 ab 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 12 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 01 f0 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 02 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 08 a2 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 02 01 01 02 00 ................
+| 3936: 01 01 01 01 ff f1 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 01 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 03 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 02 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 00 00 00 00 00 00 00 00 uild............
+| end crash-18cc014e42e828.db
+}]} {}
+
+do_catchsql_test 21.1 {
+ PRAGMA writable_schema = 1;
+ SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'R*';
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 22.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-b794c89d922ac9.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 61 6c 65 74 31 5f 73 65 67 64 69 72 .5taalet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 84 65 6e 74 74 31 5f 63 6f 6e 74 1_con.entt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 49 53 35 20 45 4e 41 42 4c 45 20 MEMSIS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 26 0f READSAFE=0.$..&.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 55 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LU RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 19 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE.FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4e f5 20 46 54 53 34 ..#..ENABN. FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 41 53 ...1..ENABLE DAS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 ab 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 48 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d HRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 43 49 4e 41 52 59 27 20160609XCINARY'
+| 4016: 02 04 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 d4 01 02 ff 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 64 d3 09 01 03 ..........gd....
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 19 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 12 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 07 80 00 f3 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| end crash-b794c89d922ac9.db
+}]} {}
+
+do_catchsql_test 22.1 {
+ PRAGMA writable_schema = 1;
+ SELECT snippet(t1,'', '', '--',-1,01)==0
+ FROM t1 WHERE a MATCH 'rtree OR json1rtree OR json1';
+} {0 {0 0 0 0 0 0 0}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 23.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-670b15f2955a36.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 10 00 00 01 00 00 00 07 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 75 74 31 5f 73 65 67 6d 65 6e ..tablut1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 42 20 50 52 49 4d 41 52 59 INTEGEB PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 01 0f d8 00 2f 0f 86 0f 74 ....%.H..../...t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5a fe 40 0e 24 0e 08 0d ef 0d d5 ...t.Z.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4f 81 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 00 00 00 00 .......x.W.>....
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 10 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 35 0f READSAFE=0.$..5.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 55 00 25 0f 19 54 48 52 45 41 NARY.#U.%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 44 20 52 54 52 45 45 58 42 ..ENABLD RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 24 0f 17 45 4e 40 42 4c 45 20 52 54 52 ...$..EN@BLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4d 41 42 4c NARY....)..EMABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 4c 45 E MEMSYS5XNOCALE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4e 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 NSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 5f b9 4d 1a 12 05 00 29 0f 19 45 N1XRT_.M....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 31 4c 59 58 42 49 NABLE GEOP1LYXBI
+| 3616: 4e 41 52 58 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARX....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 57 45 ....)..ENABLE WE
+| 3664: 4f 50 4f 4c 59 48 52 54 52 49 4d 17 0f 05 00 23 OPOLYHRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 53 59 17 0e 05 00 23 0f 19 45 4e 40 42 4b NASY....#..EN@BK
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 94 34 58 42 49 4e 41 52 59 17 0b LE FT.4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 43 70 46 54 53 34 ..#..ENABLCpFTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 32 53 ...1..ENABLE D2S
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 0b 27 0f 19 44 45 42 55 47 58 42 49 4e 41 52 ..'..DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 03 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 35 52 3d 67 ...C..COMPIL5R=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 02 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 00 00 00 00 00 0 20160609X.....
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 08 55 1a .%....0000000.U.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 61 75 .dbstat.%....eau
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 0c 97 63 63 03 25 03 00 01 .5.%.....cc.%...
+| 3136: 06 65 6f 70 6f 6c 7a 03 25 11 00 00 05 6a 73 6f .eopolz.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 3d f0 03 04 73 79 73 35 03 25 15 00 00 04 .%=...sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 09 08 17 8d 12 30 20 38 33 37 e3 aa e0 ........0 837...
+| 3264: 12 d1 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 49 09 01 07 .....2016060I...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 01 f0 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 f3 01 03 00 01 03 00 19 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 00 f3 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 46 01 02 02 00 00 ..........F.....
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 64 65 09 19 03 00 01 03 00 01 03 00 .rtrde..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 01 ff 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 02 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 09 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 71 97 65 3d 35 0d 04 02 23 6d 65 72 67 65 meq.e=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 00 00 00 00 00 00 00 00 00 00 00 00 00 ity.............
+| end crash-670b15f2955a36.db
+}]} {}
+
+do_catchsql_test 23.1 {
+ PRAGMA writable_schema = 1;
+ SELECT 'FyzLy'FROM t1 WHERE t1 MATCH 'j';
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 24.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-369d042958c29b.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 03 10 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 10 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 64 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 dst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 4f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1Ocontentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 39 4d cid INTEGER PR9M
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 26 0b 48 0e 0f d8 0f af 0f 86 0f 74 ....&.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0e 94 03 28 0d 4f 0d 35 0d 1b 05 0b .......(.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 72 7f 00 .........?%..r..
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 55 42 4.0 20160609 DUB
+| 2928: 55 47 20 45 4e 41 e4 7c 45 20 44 42 53 54 41 54 UG ENA.|E DBSTAT
+| 2944: e4 d1 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 ..TAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 42 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 BTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4c 49 54 20 4c =50000000 OLIT L
+| 3056: 4f 41 43 20 45 58 54 45 4e 53 49 4f 4e 21 54 48 OAC EXTENSION!TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 4b 75 3d 30 58 4d 4f 43 41 53 45 17 22 DSAKu=0XMOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 46 3d ..%..THREADSAFF=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 52 49 4f IT LOAD EXTENRIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 42 b8 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MB. MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 0d a5 0f 19 45 4e 41 42 INARY.......ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 1c 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 14 05 01 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 12 42 4c 45 20 4a 53 4f 4e 31 58 42 ..EN.BLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 09 d9 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 3e 31 58 4e 4f 43 41 53 45 17 LE JSO>1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 40 42 4c 45 20 4a 53 4f ...%..EN@BLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 82 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 c9 29 e8 19 46 4e 41 42 4c NARY....)..FNABL
+| 3632: 48 c0 47 45 4f 50 4f 4c 59 58 4e 74 43 41 53 45 H.GEOPOLYXNtCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 30 46 54 53 35 58 42 49 ..ENABLE0FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0e 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 42 42 4c 45 20 44 42 53 ...1..ENBBLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 4a 4d 11 06 TAT VTABXRTRJM..
+| 3920: 05 f0 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0e 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 16 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 06 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4b 45 52 3d 67 63 63 2d 35 2e 34 2e OMPIKER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 40 39 58 29 54 52 49 4d 0 201606@9X)TRIM
+| page 4 offset 12288
+| 0: 0d 00 10 00 00 10 00 00 00 00 00 00 00 01 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6e 6f 72 79 ..max.%....enory
+| 3184: 03 25 19 00 03 04 ce 79 73 4d 03 25 15 00 00 04 .%.....ysM.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 0e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 09 ................
+| 3280: 51 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 Q....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 02 f1 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 67 ler............g
+| 3440: d2 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 .stat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 6f 82 6c 65 3f 07 02 00 01 02 00 01 02 .eno.le?........
+| 3488: b0 01 02 00 01 02 00 11 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 a6 00 01 02 00 01 ................
+| 3520: 02 05 51 02 00 01 02 00 01 02 00 01 02 00 01 02 ..Q.............
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 00 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 73 6c 79 09 .........eopsly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 12 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 03 ff ff 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 07 30 01 01 01 02 00 01 01 ........0.......
+| 3968: 01 02 00 11 01 01 02 00 01 01 01 02 00 11 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 01 ff 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 09 c2 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0e f4 0f e9 10 d6 0f c7 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =1..............
+| end crash-369d042958c29b.db
+}]} {}
+
+do_catchsql_test 24.1 {
+ PRAGMA writable_schema = 1;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT '4hE'+x FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 24.2 {
+ UPDATE t1 SET b=quote((true) ) WHERE t1 MATCH 'h';
+} {0 {}}
+
+do_catchsql_test 24.3 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT 3+x FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 24.4 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT null<<x FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {0 {}}
+
+do_catchsql_test 24.5 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT 3+x FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 24.7 {
+ INSERT INTO t1(t1) SELECT x FROM t2;
+} {0 {}}
+
+#-------------------------------------------------------------------------
+#-------------------------------------------------------------------------
+reset_db
+do_test 25.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-dde9e76ed8ab2d.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 03 10 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 64 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 dst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 39 4d cid INTEGER PR9M
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 26 0b 48 0e 0f d8 0f af 0f 86 0f 74 ....&.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0e 94 03 28 0d 4f 0d 35 0d 1b 05 0b .......(.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 72 7f 00 .........?%..r..
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 55 42 4.0 20160609 DUB
+| 2928: 55 47 20 45 4e 41 e4 7c 45 20 44 42 53 54 41 54 UG ENA.|E DBSTAT
+| 2944: e4 46 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 .FTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 42 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 BTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4c 49 54 20 4c =50000000 OLIT L
+| 3056: 4f 41 43 20 45 58 54 45 4e 53 49 4f 4e 21 54 48 OAC EXTENSION!TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 4b 75 3d 30 58 4d 4f 43 41 53 45 17 22 DSAKu=0XMOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 46 3d ..%..THREADSAFF=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 52 49 4f IT LOAD EXTENRIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 42 b8 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MB. MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 0d a5 0f 19 45 4e 41 42 INARY.......ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 1c 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 14 05 01 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 12 42 4c 45 20 4a 53 4f 4e 31 58 42 ..EN.BLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 09 d9 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 3e 31 58 4e 4f 43 41 53 45 17 LE JSO>1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 40 42 4c 45 20 4a 53 4f ...%..EN@BLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 82 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 c9 29 e8 19 46 4e 41 42 4c NARY....)..FNABL
+| 3632: 48 c0 47 45 4f 50 4f 4c 59 58 4e 74 43 41 53 45 H.GEOPOLYXNtCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 30 46 54 53 35 58 42 49 ..ENABLE0FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0e 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 42 42 4c 45 20 44 42 53 ...1..ENBBLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 4a 4d 11 06 TAT VTABXRTRJM..
+| 3920: 05 f0 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0e 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 16 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 06 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4b 45 52 3d 67 63 63 2d 35 2e 34 2e OMPIKER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 40 39 58 29 54 52 49 4d 0 201606@9X)TRIM
+| page 4 offset 12288
+| 0: 0d 00 10 00 00 10 00 00 00 00 00 00 00 01 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6e 6f 72 79 ..max.%....enory
+| 3184: 03 25 19 00 03 04 ce 79 73 4d 03 25 15 00 00 04 .%.....ysM.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 0e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 09 ................
+| 3280: 51 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 Q....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 02 f1 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 67 ler............g
+| 3440: d2 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 .stat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 6f 82 6c 65 3f 07 02 00 01 02 00 01 02 .eno.le?........
+| 3488: b0 01 02 00 01 02 00 11 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 a6 00 01 02 00 01 ................
+| 3520: 02 05 51 02 00 01 02 00 01 02 00 01 02 00 01 02 ..Q.............
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 00 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 73 6c 79 09 .........eopsly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 12 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 0e 9f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 ..mit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 07 30 01 01 01 02 00 01 01 ........0.......
+| 3968: 01 02 00 11 01 01 02 00 01 01 01 02 00 11 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 01 ff 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0e f4 0f e9 10 d6 0f c7 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =1..............
+| end crash-dde9e76ed8ab2d.db
+}]} {}
+
+do_catchsql_test 25.1 {
+ PRAGMA writable_schema = 1;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x%1 FROM c WHERE x<599237)
+ INSERT INTO t1( a ) SELECT randomblob(3000) FROM t2 ;
+} {0 {}}
+
+do_catchsql_test 25.2 {
+ UPDATE t1 SET b=quote((true) ) WHERE t1 MATCH 'h*';
+} {0 {}}
+
+do_catchsql_test 25.3 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x +x FROM c WHERE 72<x)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {0 {}}
+
+do_catchsql_test 25.4 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x%1 FROM c WHERE 599237<x)
+ INSERT INTO t1(a) SELECT randomblob(3000) FROM t2 ;
+} {0 {}}
+
+do_catchsql_test 25.5 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x%1 FROM c WHERE x<599237)
+ INSERT INTO t1( a ) SELECT randomblob(3000) FROM t2 ;
+} {0 {}}
+
+do_catchsql_test 25.6 {
+ INSERT INTO t1(t1) SELECT x FROM t2;
+ INSERT INTO t1(t1) SELECT x FROM t2;
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 26.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-26682721375870.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 51 r'(level INTEGEQ
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 62 2c 72 6f 6f 74 ock INTEGEb,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 66 6d 65 6e ..tablet1_sefmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 00 00 ...t.[.@.$......
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 23 00 20 32 2f 31 36 30 36 30 39 20 44 45 42 4#. 2/160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 59 4f 4e 20 54 48 OAD EXTENSYON TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 38 52 45 41 44 53 41 46 45 3d ..%..T8READSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 fc 53 49 4f IT LOAD EXTE.SIO
+| 3184: 4e 68 42 49 4e 4a c2 59 1f 20 05 00 33 0f 19 4f NhBINJ.Y. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 2f 30 30 MAX MEMORY=50/00
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 48 4e 4f 43 41 53 45 1e 1c 05 00 33 0000HNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 53 41 53 45 17 LE RTREEXNOSASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 42 42 INARY....%..ENBB
+| 3552: 4d 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 ME JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 1e 4c NARY....)..ENA.L
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 62 54 52 49 4d 17 0f 05 00 23 OPOLYXbTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 fc 35 58 4e 4f 43 41 53 45 16 0d 05 E FT.5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 ..#..ENABLE FTS5
+| 3792: 58 4e 4f 43 40 53 45 16 0a 05 00 23 0f 17 45 4e XNOC@SE....#..EN
+| 3808: 41 42 4c 45 20 56 54 53 34 58 52 54 52 49 4d 1e ABLE VTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 b3 58 1e TAT VTABXBINA.X.
+| 3856: 08 05 00 31 0f 19 45 4e 40 42 4c 45 20 44 42 53 ...1..EN@BLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 45 42 53 ...1..ENABLE EBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 4b 19 4e 41 52 59 27 20160609XK.NARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 34 33 ...........0 243
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 51 74 03 25 0a 00 01 04 65 62 75 .dbstQt.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1e f3 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 2f 30 30 09 1c 04 00 01 04 ...0000/00......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 01 f0 01 02 00 57 02 00 .............W..
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 10 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 00 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 a9 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 0b 31 02 00 01 02 00 01 05 65 6d 6f 72 79 ...1.......emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 f3 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 63 61 66 65 09 22 02 ...threadcafe...
+| 3888: 00 01 02 00 02 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 00 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 00 e2 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 00 00 00 ...........#a...
+| end crash-26682721375870.db
+}]} {}
+
+do_execsql_test 26.1 {
+ PRAGMA writable_schema = 1;
+ SELECT count(*) FROM (
+ SELECT t1, (t1) FROM t1 WHERE b MATCH 'x'
+ )
+} 34
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 27.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-23ddd777a03bfd.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 64 73 74 31 5f 73 65 67 6d 65 6e 73 73 04 43 52 dst1_segmenss.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 4e 72 59 INTEGER PRIMNrY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 04 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 39 4d cid INTEGER PR9M
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 26 0b 48 0e 0f d8 0f af 0f 86 0f 74 ....&.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e 00 00 00 00 00 .a.N./..........
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 72 7f 00 .........?%..r..
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 55 42 4.0 20160609 DUB
+| 2928: 55 47 20 45 4e 41 e4 7c 45 20 44 42 53 54 41 54 UG ENA.|E DBSTAT
+| 2944: e4 46 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 .FTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 42 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 BTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4c 49 54 20 4c =50000000 OLIT L
+| 3056: 4f 41 43 20 45 58 54 45 4e 53 49 4f 4e 21 54 48 OAC EXTENSION!TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 4b 75 3d 30 58 4d 4f 43 41 53 45 17 22 DSAKu=0XMOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 46 3d ..%..THREADSAFF=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 52 49 4f IT LOAD EXTENRIO
+| 3184: 4e 58 42 49 4e 41 52 59 0f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 43 49 MIT LOAD EXTENCI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 5d 12 49 4d 1f 1e 05 00 33 0f 19 IONXR].IM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4f 4f 43 41 53 45 1e 1c 05 00 33 0000XOOCASE....3
+| 3328: 0f 17 4d 41 b8 20 4d 45 4d 4f 52 59 3d 35 30 3c ..MA. MEMORY=50<
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 0d a5 0f 19 45 4e 41 42 INARY.......ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 1c 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 53 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NASY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 14 05 01 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 12 42 4c 45 20 4a 53 4f 4e 31 58 42 ..EN.BLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 09 d9 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 3e 31 58 4e 4f 43 41 53 45 17 LE JSO>1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 40 42 4c 45 20 4a 53 4f ...%..EN@BLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 82 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4d 59 58 42 49 NABLE GEOPOMYXBI
+| 3616: 4e 41 52 59 1a 11 05 c9 29 e8 19 46 4e 41 42 4c NARY....)..FNABL
+| 3632: 48 c0 47 45 4f 50 4f 4c 59 58 4e 74 43 41 53 45 H.GEOPOLYXNtCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 30 46 54 53 35 58 42 49 ..ENABLE0FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 4a e1 53 45 16 0e 05 E FTS5XNOJ.SE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 55 4e XNOCASE....#..UN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 42 42 4c 45 20 44 42 53 ...1..ENBBLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 4a 4d 11 06 TAT VTABXRTRJM..
+| 3920: 05 f0 17 0f 29 44 45 42 55 47 58 42 49 4e 41 52 ....)DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0e 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 16 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 06 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4b 45 52 3d 67 63 63 2d 35 2e 34 2e OMPIKER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 40 39 58 29 54 52 49 4d 0 201606@9X)TRIM
+| page 4 offset 12288
+| 0: 0d 00 10 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| 16: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 7c 65 09 25 09 g.%....enab|e.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6e 6f 72 79 ..max.%....enory
+| 3184: 03 25 19 00 03 04 ce 79 73 4d 03 25 15 00 00 04 .%.....ysM.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 0e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 02 f1 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 01 f2 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 67 ler............g
+| 3440: d2 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 .stat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 6f 82 6c 65 3f 07 02 00 01 02 00 01 02 .eno.le?........
+| 3488: b0 01 02 00 01 02 00 11 0a f0 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 a6 00 01 02 00 02 ................
+| 3520: 02 05 51 02 00 01 02 00 01 02 00 01 02 00 01 02 ..Q.............
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 00 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 73 6c 79 09 .........eopsly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 12 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 01 e3 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 01 f0 01 01 01 07 30 01 01 01 02 00 01 01 ........0.......
+| 3968: 01 02 00 ea 01 01 02 00 01 01 01 02 00 11 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 01 ff 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 11 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 01 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0e f4 0f e9 10 d6 0f c7 ................
+| 4016: 00 00 00 00 00 00 00 00 0f 85 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =1..............
+| end crash-23ddd777a03bfd.db
+}]} {}
+
+do_catchsql_test 27.2 {
+ PRAGMA writable_schema = 1;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x GLOB 2.16770 FROM x)
+ INSERT INTO t1(a) SELECT randomblob(3000) FROM t2 ;
+} {1 {database disk image is malformed}}
+do_catchsql_test 27.3 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT 3+x FROM c WHERE x<2.653)
+ INSERT INTO t1(a) SELECT randomblob(-current_time) FROM c;
+} {1 {database disk image is malformed}}
+do_catchsql_test 27.4 {
+ UPDATE t1 SET b=quote((true) ) WHERE t1 MATCH 'h*h*';
+} {0 {}}
+do_catchsql_test 27.5 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT 3+x FROM c WHERE x<2.653)
+ INSERT INTO t1(a) SELECT randomblob(-current_time) FROM c;
+} {1 {database disk image is malformed}}
+do_catchsql_test 27.5 {
+ INSERT INTO t1(t1) SELECT x FROM t2;
+} {1 {database disk image is malformed}}
+do_catchsql_test 27.6 {
+ INSERT INTO t1(t1) SELECT x FROM t2;
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 28.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-159ac1ca51ed55.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 10 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 64 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 dst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 4f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1Ocontentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 43 a5 52 20 50 52 39 4d cid INTEC.R PR9M
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 26 0b 48 00 00 00 00 00 00 00 00 00 ....&.H.........
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 72 7f 00 .........?%..r..
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 55 42 4.0 20160609 DUB
+| 2928: 55 47 20 45 4e 41 e4 7c 45 20 44 42 53 54 41 54 UG ENA.|E DBSTAT
+| 2944: e4 46 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 .FTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 1f 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 AB.E GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 42 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 BTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4c 49 54 20 4c =50000000 OLIT L
+| 3056: 4f 41 43 20 45 58 54 45 4e 53 49 4f 4e 21 54 48 OAC EXTENSION!TH
+| 3072: 52 45 41 44 53 41 46 45 3d 2f 18 24 05 00 25 0f READSAFE=/.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 4b 75 3d 30 58 4d 4f 43 41 53 45 17 22 DSAKu=0XMOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 46 3d ..%..THREADSAFF=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 52 49 4f IT LOAD EXTENRIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 42 b8 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MB. MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 4a 4d 18 1b 05 00 25 00000XRTRJM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 0d a5 0f 19 45 4e 41 42 INARY.......ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 1c 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 14 05 01 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 12 42 4c 45 20 4a 53 4f 4e 31 58 42 ..EN.BLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 09 d9 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 3e 31 58 4e 4f 43 41 53 45 17 LE JSO>1XNOCASE.
+| 3568: 13 05 00 25 0f 17 44 4e 40 42 4c 45 20 4a 53 4f ...%..DN@BLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 82 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 c9 29 e8 19 46 4e 41 42 4c NARY....)..FNABL
+| 3632: 48 c0 47 45 4f 50 4f 4c 59 58 4e 74 43 41 53 45 H.GEOPOLYXNtCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 30 46 54 53 35 58 42 49 ..ENABLE0FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0e 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 04 ff 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 42 42 4c 45 20 44 42 53 ...1..ENBBLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 4a 4d 11 06 TAT VTABXRTRJM..
+| 3920: 05 f0 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 09 b0 17 0e 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 16 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 4d 67 ...C..COMPILERMg
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 06 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4b 45 52 3d 67 63 63 2d 35 2e 34 2e OMPIKER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 40 39 58 29 54 52 49 4d 0 201606@9X)TRIM
+| page 4 offset 12288
+| 0: 0d 00 10 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 00 00 00 00 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 4d 07 30 30 30 30 30 30 30 03 25 1a .%..M.0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 10 ff ff f5 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 71 78 03 25 18 00 01 05 65 6e 6f 72 79 ..mqx.%....enory
+| 3184: 03 25 19 00 03 04 ce 79 73 4d 03 25 15 00 00 04 .%.....ysM.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 7f 08 72 65 61 64 73 61 66 65 03 %......readsafe.
+| 3232: 25 0e 00 00 04 76 75 61 62 03 25 0b 00 86 50 01 %....vuab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 09 ................
+| 3280: 51 03 00 00 09 32 30 31 36 30 36 30 39 09 01 07 Q....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 03 ff 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 02 f1 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 67 ler............g
+| 3440: d2 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 .stat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 6f 82 6c 65 3f 07 02 00 01 02 00 01 02 .eno.le?........
+| 3488: b0 01 02 00 00 f2 00 11 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 a6 00 01 02 00 01 ................
+| 3520: 02 05 51 02 00 01 02 00 01 02 00 01 02 00 01 02 ..Q.............
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 00 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 73 6c 79 09 .........eopsly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 12 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 0f 71 02 02 00 03 01 02 02 00 03 6f 02 02 00 00 .q.........o....
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 07 30 01 01 01 02 00 01 01 ........0.......
+| 3968: 01 02 00 11 01 01 02 00 01 01 01 02 00 11 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 01 ff 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 00 00 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0e f4 0f e9 10 d6 0f c7 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =1..............
+| end crash-159ac1ca51ed55.db
+}]} {}
+
+do_catchsql_test 28.1 {
+ PRAGMA writable_schema = 1;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT 3+x FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 28.2 {
+ UPDATE t1 SET b=quote((true) ) WHERE t1 MATCH 'h';
+} {0 {}}
+
+do_catchsql_test 28.3 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT 3+x FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 28.4 {
+ WITH c(x) AS (VALUES(1) UNION ALL SELECT 3<<x FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {0 {}}
+
+do_catchsql_test 28.5 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT 3+x FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 28.6 {
+ WITH c(x) AS (VALUES(1) UNION ALL SELECT 3<<x FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {0 {}}
+
+do_catchsql_test 28.7 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+3 FROM c WHERE x<72)
+ INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 28.8 {
+ INSERT INTO t1(t1) SELECT x FROM t2;
+} {0 {}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 29.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-53f41622dd3bf6.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 54 69 72 .5tablet1_segTir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4d 54 45 47 45 52 2c 73 74 61 ,idx IMTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 39 4d cid INTEGER PR9M
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 12 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 6b 3c 65 74 31 74 31 43 52 ...._tak<et1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 03 28 0d 4f 0d 35 0d 1b 0c fb .......(.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 72 7f 00 .........?%..r..
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 21 44 45 42 4.0 20160609!DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 46 20 46 54 53 VTAB ENABLF FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 55 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLU JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 56 4d 41 58 20 4d 45 4d 4f 52 59 RTREEVMAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 42 43 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OBC EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 40 18 24 05 00 25 0f READSAFE=@.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 31 58 4e 4f 43 41 53 45 17 22 DSAFE=1XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 43 41 46 45 3d ..%..THREADCAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 48 MIT LOAD EXTENSH
+| 3216: cf 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 .NXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 2d 35 30 30 30 30 MAX MEMORY-50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 49 18 1a 05 0d a5 0f 19 45 4e 41 42 INARI.......ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f be 31 53 45 17 LE RTREEXNO.1SE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 51 ...%..ENABLE RTQ
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 37 f8 52 54 52 49 4d 18 14 05 00 25 MSYS7.RTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 3e 31 58 4e 4f 43 41 53 45 17 LE JSO>1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 48 c0 47 45 4f 50 4f 4c 40 58 4e 4f 43 41 53 45 H.GEOPOL@XNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 51 49 4d 17 0f 05 00 23 OPOLYXRTQIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4d 41 52 59 17 0b LE FTS4XBIMARY..
+| 3776: 05 00 23 0f 19 45 4e 31 42 4c 45 20 46 1a 53 34 ..#..EN1BLE F.S4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 96 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 T.T VTABXRTRIM..
+| 3920: 05 00 17 0f 1e e4 45 42 55 47 58 42 49 4e 41 52 ......EBUGXBINAR
+| 3936: 59 11 05 05 00 17 0e 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 01 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 40 32 30 31 36 30 36 30 cc-5.4.0@2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 4f 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMOILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 01 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 4d 03 25 15 00 00 04 .%....sysM.%....
+| 3200: 6e 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 nmit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 0e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 bd .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 06 00 00 01 35 09 01 04 00 01 04 00 02 04 ......5.........
+| 3328: 00 01 07 30 30 e6 30 30 30 30 09 1c 04 00 01 04 ...00.0000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 04 01 02 02 10 03 01 02 02 ................
+| 3376: 00 0f 71 02 12 00 03 01 02 02 00 03 01 65 02 00 ..q..........e..
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 0d a2 00 03 01 02 02 00 00 08 63 3b 6d 70 69 ...........c;mpi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 01 f0 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 01 f0 ................
+| 3760: 03 01 02 02 05 93 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 8a 72 65 65 09 19 03 00 01 03 00 11 03 00 .r.ree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 75 61 62 09 07 04 .........vuab...
+| 3904: 00 01 04 00 01 04 00 00 61 78 b4 01 01 01 01 02 ........ax......
+| 3920: 00 01 01 01 02 00 00 f1 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 01 ff 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 09 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 02 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 11 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 1f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 10 d6 0f c7 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =1..............
+| end crash-53f41622dd3bf6.db
+}]} {}
+
+do_catchsql_test 29.1 {
+ PRAGMA writable_schema = 1;
+ INSERT INTO t1(a) SELECT X'819192E578DE3F';
+ UPDATE t1 SET b=quote(zeroblob(current_date)) WHERE t1 MATCH 't*';
+ INSERT INTO t1(b) VALUES(x'78');
+ INSERT INTO t1(t1) SELECT x FROM t2;
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 30.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 28672 pagesize 4096 filename crash-e6e3857edf9b26.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 62 2c 72 6f 6f 74 ock INTEGEb,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 00 00 ...t.[.@.$......
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7e f0 .........?%...~.
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 23 00 20 32 30 31 36 30 36 30 39 20 44 45 42 4#. 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 42 92 4c 45 20 46 54 53 VTAB ENB.LE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 1f 4a 53 4f 4e 31 20 45 4e 41 42 4c 49 BLE.JSON1 ENABLI
+| 3008: 00 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 .MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 88 4e 4f 43 41 53 45 17 22 DSAFE=0.NOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 20 05 00 33 0f 17 ONXNOCASE. ..3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 54 20 45 58 54 45 4e 53 OMIT LOAT EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 04 00 33 0f 19 IONXRTRIM....3..
+| 3264: 82 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 .AX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d fa 52 59 3d 35 30 20 ..MAX MEM.RY=50
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 53 52 45 45 58 42 ..ENABLE RSREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 53 41 53 45 17 LE RTREEXNOSASE.
+| 3408: 19 05 00 25 0f 17 45 4e 42 42 4c 45 20 52 54 52 ...%..ENBBLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 5a 53 35 58 42 49 NABLE MEMSZS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 3c NARY....)..ENAB<
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 31 42 4c 45 20 47 45 4e 50 4f 4c 59 58 42 49 N1BLE GENPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e f2 1e 4c NARY....)..EN..L
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 3c NARY....#..ENAB<
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 43 4c 45 20 46 54 53 35 ..#..ENACLE FTS5
+| 3792: 58 4e 4f 43 40 53 45 16 0a 05 00 23 0f 17 45 4e XNOC@SE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 55 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAU VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 62 49 4d 11 06 TAT VTABXRTbIM..
+| 3920: 05 00 17 0f 19 44 45 42 54 47 58 42 49 4e 41 52 .....DEBTGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 54 45 42 55 47 58 4e 4f Y.......TEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 68 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d hRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4f 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XOOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 14 00 e8 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 f2 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 60 62 6c 65 3f 07 02 00 01 02 00 01 01 .en`ble?........
+| 3488: ff f1 b1 00 00 02 3f 01 01 f0 f1 02 00 57 02 00 ......?......W..
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 10 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 01 01 02 00 01 02 ................
+| 3536: 00 01 02 00 00 f2 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 b3 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 cc 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 62 65 65 09 19 03 00 01 03 00 01 03 00 .rtbee..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 01 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 02 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 03 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 01 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 da 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 01 ff ff 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 01 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 01 6f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .o..............
+| end crash-e6e3857edf9b26.db
+}]} {}
+
+do_execsql_test 30.1 {
+ UPDATE t1 SET b=a;
+}
+
+do_catchsql_test 30.2 {
+ SELECT (matchinfo(null)) FROM t1 WHERE t1 MATCH 'ee*e*e*e*e*e*e*Re*e*e*e**'
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 31.0 {
+CREATE VIRTUAL TABLE t1 USING fts3(a,b,c);
+INSERT INTO t1_segdir VALUES(0,0,0,0,'0 592',X'00016dcb048ce6fbd3b2d68bfebf0101020200808080808080808020010202008080808080808080100102020080808080808080800801020200808080808080808004010202008080808080808080020102020080808080808080800101020200808080808080804001020200808080808080802001020200808080808080801001020200808080808080800801020200808080808080800401020200808080808080800201020200808080808080800101020200808080808080400102020080808080808020010202008080808080801001020200808080808080080102020080808080808004010202008080808080800201020200808080808080010102020080808080804001020200808080808020010202008080808080100102020080808080800801020200808080808004010202008080808080020102020080808080800101020200808080804001020200808080802001020200808080801001020200808080800801020200808080800401020200808080800201020200808080800101020200808080400102020080808020010202008080801001020200808080080102020080808004010202008080800201020200808080010102020080804001020200808020010202008080100102020080800801020200808004010202008080020102020080800101020200804001020200802001020200801001020200800801020200800401020200800201020200800101020200400102020020010202001001020200080102020004010202000201020200010102020001010202008080808080808080800101020200');
+INSERT INTO t1_segdir VALUES(0,1,0,0,'0 18',X'00026d6d0d8ee6fbd3b2d68bfe7f01020200');
+}
+
+do_catchsql_test 31.1 {
+ SELECT (matchinfo(t1, c ) ) FROM t1 WHERE t1 MATCH 'M*M*M*M*';
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 32.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 24576 pagesize 4096 filename crash-74fdbc96edbc04.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 44 52 2c 73 74 61 ,idx INTEGDR,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 6a 6e 64 65 78 73 71 6c 69 74 ..E...jndexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 03 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 5a INTEGER PRIMARZ
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 50 0d 35 0d 1b 0c fb .......h.P.5....
+| 64: 0c da 0c b8 fc 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 7e 54 UG ENABLE DBST~T
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 44 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e D ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 54 41 46 45 3d 30 58 42 49 .THREADTAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 bd 4e 4f 43 41 53 45 17 22 DSAFE=0.NOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4e IT LOAD EXTENSIN
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 1f 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX.MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 44 4d 4f 52 59 3d 35 30 30 ..MAX MDMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 55 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LU RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 3f 43 41 53 45 E MEMSYS5XN?CASE
+| 3488: 19 16 05 00 29 0f 17 45 4e a1 42 4c 45 20 4d 45 ....)..EN.BLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 5f 4c 59 58 42 49 NABLE GEOP_LYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4b bf 43 41 53 45 E GEOPOLYXK.CASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 55 20 46 54 53 35 58 42 49 ..ENABLU FTS5XBI
+| 3696: 4e 4b a2 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NK.Y....#..ENABL
+| 3712: 45 20 46 54 52 35 58 4e 4f 43 41 53 45 16 0d 05 E FTR5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0b 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 07 e1 0f 19 45 4e 41 42 4c 45 20 44 42 53 ......ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 18 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 41 18 4e 4f 43 41 53 45 1d TAT VTAA.NOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 32 53 ...1..ENABLE D2S
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 00 00 00 00 00 00 Y.......DE......
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 01 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 38 03 25 07 00 00 01 34 03 25 05 00 00 01 35 08.%....4.%....5
+| 3024: 03 25 13 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 62 78 03 25 18 00 01 05 65 6d 6f 72 79 ..mbx.%....emory
+| 3184: 03 25 19 00 03 04 73 c8 73 35 03 25 15 00 00 04 .%....s.s5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 02 04 ......5.........
+| 3328: 00 01 07 30 2f 30 30 30 30 30 09 1c 04 00 01 04 ...0/00000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 6c 2c 65 3f 07 02 00 01 02 00 01 02 .enal,e?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 01 ff f1 02 00 01 ................
+| 3520: 02 00 01 02 00 01 02 00 f1 02 00 01 02 00 01 4f ...............O
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 00 f3 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 04 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 02 ff 01 03 00 00 04 6c 6f 61 63 ............loac
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 64 6d 6f 72 79 ...........dmory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 02 f0 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 4b 01 02 02 00 ...........K....
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 f4 01 02 00 01 02 01 02 00 01 01 01 02 ff ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 ae 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 12 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 12 00 01 01 01 02 01 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 76 01 02 00 01 01 01 .........v......
+| 4064: 02 00 01 01 01 02 01 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| end crash-74fdbc96edbc04.db
+}]} {}
+
+do_catchsql_test 32.1 {
+ UPDATE t1 SET b=quote(zeroblob(6.51158946e+5)) WHERE a MATCH '*t*';
+} {1 {database disk image is malformed}}
+
+#do_catchsql_test 32.2 {
+# UPDATE t1 SET b=((- '' )) WHERE a MATCH '0*t';
+#} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+ifcapable icu {
+ reset_db
+ do_catchsql_test 33.0 {
+ CREATE VIRTUAL TABLE f USING fts3(a,b,tokenize=icu);
+ CREATE TABLE 'f_docsize'(docid INTEGER PRIMARY KEY, size BLOB);
+ CREATE TABLE 'f_stat'(id INTEGER PRIMARY KEY, value BLOB);
+ INSERT INTO f VALUES (1, '1234');
+ INSERT INTO f_stat VALUES (1,x'0000000165656565db6569746565c5c52bc5c5c53e3a003bc502ffffffffc5c5c53e3a003bc502fffffffffb8b2afbfb6565f0740100650000000165656565db6569746565c5c52bc5c5c53e3a003bc502ffffffffc5c5c53e3a003b8b00c5c5c5c5c5bfc5');
+ INSERT INTO f(f) VALUES ('merge=198,49');
+ } {1 {database disk image is malformed}}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 34.0 {
+ CREATE VIRTUAL TABLE f USING fts3(a,b);
+ INSERT INTO f VALUES (1, '1234');
+ INSERT INTO f_segdir VALUES (1,255,0,0,'1 255',x'00');
+ UPDATE f_segdir SET level = 0 WHERE level IN (
+ SELECT level FROM f_segdir LIMIT 1 OFFSET 1
+ );
+ INSERT INTO f_segdir VALUES (255,249,0,121,'0 0',x'00');
+ INSERT INTO f_content VALUES (255,0,x'ff');
+ INSERT INTO f_segdir VALUES (1,255,16,0,'1 255',x'00');
+}
+
+do_catchsql_test 34.1 {
+ UPDATE f SET b = x'00' WHERE b IN (SELECT b FROM f LIMIT 1 OFFSET 0);
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 35.0 {
+ CREATE VIRTUAL TABLE f USING fts3(a,b);
+ INSERT INTO f_segdir VALUES (1,255,0,0,'1 255',x'0001ff000001ff000001ff000001ff000001ff00c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5bec5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5');
+}
+
+do_catchsql_test 35.1 {
+ INSERT INTO f(f) VALUES ('integrity-check');
+} {1 {database disk image is malformed}}
+
+reset_db
+do_catchsql_test 36.0 {
+ CREATE VIRTUAL TABLE f USING fts3(a,tokenize=porter);
+ CREATE TABLE 'f_stat'(id INTEGER PRIMARY KEY, value BLOB);
+ INSERT INTO f VALUES (1);
+ INSERT INTO f_stat VALUES (1,x'00000000000101010119013d00ffff0400fa83717b71a69297979701f63d010101010101010101010101190000000000000000fa83717b71a601f63d01010101010101010101010119013d00ffffff0400fa83717b71a69297979701f63d010101010101010101010101190000000000000000fa83717b71a69201f63d010101f63d01010101010101010101010119013d00ffffff0400fa83717b71a6929797010101010101010101010119013d00ffff01f63d01010101010101010101010119013d00ffffff0400fa83717b71a69297979701f63d00fa03ffffffa69297979701f63d010101000000000101010101197e9797976567656565ffa63535354e');
+ INSERT INTO f(f) VALUES ('merge=53,216');
+} {0 {}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 36.0 {
+ CREATE VIRTUAL TABLE f USING fts3(a,b);
+ CREATE TABLE 'f_stat'(id INTEGER PRIMARY KEY, value BLOB);
+ INSERT INTO f_stat VALUES (1,x'11014101000101c5c5014b010164c5014b010101c50101c5c5010201010101014101000101c5c5014b010101c5014b010101c50101c5c501010100c50101c5c5010101010101e40201010101014101000201010101014101000101010201010101014101000101c5c503b5fefefe3afeffffc5c5c5c50101010101010201010101014101adadadadadadadadadadadad91adadadadadadadad0101c50101c5c501f9ffffffffffffffff0001010102010101010140f5000101c5c5014b010101c50101c5c501010101e6010201010101014101000101c5c5014b010101c50101c5c5010101114b0101c5c50101010a0101020101e60101');
+}
+
+do_catchsql_test 36.1 {
+ INSERT INTO f(f) VALUES ('merge=59,59');
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 37.0 {
+ CREATE VIRTUAL TABLE f USING fts3(a,b);
+ INSERT INTO f_segdir VALUES (28,0,0,0,'0 0',x'00');
+ INSERT INTO f_segdir VALUES (0,241,0,0,'0 0',x'0001000030310000f1');
+}
+
+do_catchsql_test 37.1 {
+ INSERT INTO f VALUES (0,x'00');
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 38.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 24576 pagesize 4096 filename crash-1cc4f8a70485ce.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 62 2c 72 6f 6f 74 ock INTEGEb,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 00 00 ...t.[.@.$......
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7e f0 .........?%...~.
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 23 00 20 42 30 31 36 2f 36 30 39 20 44 45 42 4#. B016/609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 42 92 4c 45 20 46 54 53 VTAB ENB.LE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 5c 45 1f 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 B.E.JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4c =50000000 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 88 4e 4f 43 41 53 45 17 22 DSAFE=0.NOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 54 20 45 58 54 45 4e 53 OMIT LOAT EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 04 00 33 0f 19 IONXRTRIM....3..
+| 3264: 82 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 .AX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d fa 52 59 3d 35 30 20 ..MAX MEM.RY=50
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 42 42 4c 45 20 52 54 52 ...%..ENBBLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 3c NARY....)..ENAB<
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 95 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 31 42 4c 45 20 47 45 4e 50 4f 4c 59 58 42 49 N1BLE GENPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 3e f2 1e 4c NARY....)..E>..L
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 3c NARY....#..ENAB<
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 5d 24 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 ]$RIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 ..#..ENABLE FTS5
+| 3792: 58 4e 4f 43 40 53 45 16 0a 05 00 23 0f 17 45 4e XNOC@SE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4b 45 20 44 42 53 ...1..ENABKE DBS
+| 3904: 54 41 54 20 56 53 41 42 58 52 54 62 49 4d 11 06 TAT VSABXRTbIM..
+| 3920: 05 00 17 0f 19 44 45 42 54 47 58 42 49 4e 41 52 .....DEBTGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 68 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d hRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4f 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XOOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 8c 36 ..0.%.....2016.6
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 5d 70 69 6c 65 72 03 25 02 00 00 ...co]piler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 7e 73 69 6f .........xte~sio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 7f 6c 79 03 25 11 00 00 05 6a 73 6f .eop.ly.%....jso
+| 3152: 6e 31 03 25 14 00 e8 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 c2 00 03 01 02 02 00 03 01 04 82 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 60 62 6c 65 3f 07 02 00 01 02 92 e1 a4 .en`ble?........
+| 3488: ff fc a2 8c 95 b2 3f 01 01 f0 f1 02 00 57 02 00 ......?......W..
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 10 01 ................
+| 3520: 02 00 01 02 00 01 02 00 01 02 01 01 02 00 01 02 ................
+| 3536: 00 01 02 00 00 f2 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 5f 70 6f 6c 79 09 .........e_poly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 b3 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 cc 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 62 65 65 09 19 03 00 01 03 00 01 03 00 .rtbee..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 01 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 02 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 03 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 01 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 da 00 00 f1 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 01 ff ff 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 01 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| end crash-1cc4f8a70485ce.db
+}]} {}
+
+do_execsql_test 38.1 {
+ UPDATE t1 SET b=a;
+}
+
+do_catchsql_test 38.2 {
+ SELECT b FROM t1 WHERE a MATCH 'e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*'
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+set saved $sqlite_fts3_enable_parentheses
+set sqlite_fts3_enable_parentheses 1
+do_execsql_test 39.0 {
+ CREATE VIRTUAL TABLE t0 USING fts3(
+ col0 INTEGER PRIMARY KEY,
+ col1 VARCHAR(8),
+ col2 BINARY,
+ col3 BINARY
+ );
+ INSERT INTO t0_content VALUES(1,1,'1234','aaaa','bbbb');
+ INSERT INTO t0_segdir VALUES(0,0,0,0,'0 42',X'000131030782000103323334050101010200000461616161050101020200000462626262050101030200');
+}
+
+do_test 39.1 {
+ catch {
+ db eval { SELECT rowid FROM t0 WHERE t0 MATCH '1 NEAR 1' }
+ }
+} 0
+
+do_test 39.2 {
+ catch {
+ db eval {
+ SELECT matchinfo(t0,'yxy') FROM t0 WHERE t0 MATCH x'2b0a312b0a312a312a2a0b5d0a0b0b0a312a0a0b0b0a312a0b310a392a0b0a27312a2a0b5d0a312a0b310a31315d0b310a312a316d2a0b313b15bceaa50a312a0b0a27312a2a0b5d0a312a0b310a312b0b2a310a312a0b2a0b2a0b2e5d0a0bff313336e34a2a312a0b0a3c310b0a0b4b4b0b4b2a4bec40322b2a0b310a0a312a0a0a0a0a0a0a0a0a0b310a312a2a2a0b5d0a0b0b0a312a0b310a312a0b0a4e4541530b310a5df5ced70a0a0a0a0a4f520a0a0a0a0a0a0a312a0b0a4e4541520b310a5d616161610a0a0a0a4f520a0a0a0a0a0a312b0a312a312a0a0a0a0a0a0a004a0b0a310b220a0b0a310a4a22310a0b0a7e6fe0e0e030e0e0e0e0e01176e02000e0e0e0e0e01131320226310a0b0a310a4a22310a0b0a310a766f8b8b4ee0e0300ae0090909090909090909090909090909090909090909090909090909090909090947aaaa540b09090909090909090909090909090909090909090909090909090909090909fae0e0f2f22164e0e0f273e07fefefef7d6dfafafafa6d6d6d6d';
+ }
+ }
+} 0
+set sqlite_fts3_enable_parentheses $saved
+
+#-------------------------------------------------------------------------
+reset_db
+set saved $sqlite_fts3_enable_parentheses
+set sqlite_fts3_enable_parentheses 1
+
+do_execsql_test 40.1 {
+
+ CREATE VIRTUAL TABLE t0 USING fts3(col0 INTEGER PRIMARY KEY, col1, col2 ,col3 );
+ INSERT INTO t0_segdir VALUES(0,0,0,0,'0 42',
+ X'0001310301020001033233340500010102000004616161bc050101020200000462626262050101030200'
+ );
+}
+
+do_execsql_test 40.2 {
+ SELECT 0==matchinfo(t0,'sx') FROM t0 WHERE t0 MATCH '1* 2 3 4 5 6 OR 1';
+} 0
+
+set sqlite_fts3_enable_parentheses $saved
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 41.1 {
+ CREATE VIRTUAL TABLE t1 USING fts3(a,b,c);
+ INSERT INTO t1_segdir VALUES(0,0,0,0,'0 835',X'000130120106000106000106001f030001030001030000083230313630363039090107000107000107000001340901050001050001050000013509010400010400010400010730303030303030091c0400010400010400000662696e6172793c0301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000008636f3870696c657209010200010200010200000664627374617409070300010300010300010465627567090402000102000102000006656e61626c653f07020001020001020001020001020001020001020001020001020001030001010002020001020001020001020001120001020001020001020001020001020001087874656e73696f6e091f0400010400010400000466747334090a0300010300010400030135090d03000103000103000003676363090103000103000103000106656f706f6c790910030001030001030000056a736f6e310913030001030001030000046c6f6164091f030001030001030000036d6178091c02000102000102000105656d6f7279091c03000103000103000304737973350916030001030001030000066e6f636173653c02010202000301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000301020200030102020000046f6d6974091f020001020001020000057274726565091903000103000103000302696d3c010102020003010202000301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000301020200000a746872656164736166650922020001020001020000047674616209070400010400010400000178b401010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200');
+}
+
+do_execsql_test 41.2 {
+ SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'rtree ner "json1^enable"';
+}
+
+#-------------------------------------------------------------------------
+do_execsql_test 42.1 {
+ CREATE VIRTUAL TABLE f USING fts3(a, b);
+}
+do_execsql_test 42.2 {
+ INSERT INTO f_segdir VALUES(0,2,1111,0,0,X'00');
+ INSERT INTO f_segdir VALUES(0,3,0 ,0,0,X'00013003010200');
+}
+do_execsql_test 42.3 {
+ INSERT INTO f(f) VALUES ('merge=107,2');
+}
+
+#-------------------------------------------------------------------------
+reset_db
+set saved $sqlite_fts3_enable_parentheses
+set sqlite_fts3_enable_parentheses 1
+do_execsql_test 43.1 {
+ CREATE VIRTUAL TABLE def USING fts3(xyz);
+ INSERT INTO def_segdir VALUES(0,0,0,0,0, X'0001310301c9000103323334050d81');
+} {}
+
+do_execsql_test 43.2 {
+ SELECT rowid FROM def WHERE def MATCH '1 NEAR 1'
+} {1}
+
+set sqlite_fts3_enable_parentheses $saved
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 44.1 {
+ CREATE VIRTUAL TABLE t0 USING fts3(col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY);
+ INSERT INTO t0_content VALUES(0,NULL,NULL,NULL,NULL);
+ INSERT INTO t0_segdir VALUES(0,0,0,0,'0 42',X'00013103010200010332333405010201ba00000461616161050101020200000462626262050101030200');
+}
+
+do_execsql_test 44.2 {
+ SELECT matchinfo(t0, t0) IS NULL FROM t0 WHERE t0 MATCH '1*'
+} {0}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 45.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 24576 pagesize 4096 filename crash-65c98512cc9e49.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06 .....@ ........
+| 96: 00 00 00 00 0d 0e fc 00 06 0d bc 00 0f ca 0f 6c ...............l
+| 112: 0f 04 0e 13 0e c9 0d bc 00 00 00 00 00 00 00 00 ................
+| 3504: 00 00 00 00 00 00 00 00 00 00 00 00 55 06 07 17 ............U...
+| 3520: 1b 1b 01 81 01 74 61 62 6c 65 78 31 5f 73 74 61 .....tablex1_sta
+| 3536: 74 78 31 5f 73 74 61 74 06 43 52 45 41 54 45 20 tx1_stat.CREATE
+| 3552: 54 41 42 4c 45 20 27 78 31 5f 73 74 61 74 27 28 TABLE 'x1_stat'(
+| 3568: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 id INTEGER PRIMA
+| 3584: 52 59 20 4b 45 59 2c 20 76 61 6c 75 65 20 42 4c RY KEY, value BL
+| 3600: 41 82 29 81 33 04 07 17 1f 1f 01 82 35 74 61 62 A.).3.......5tab
+| 3616: 6c 65 78 31 5f 73 65 67 64 69 72 78 31 5f 73 65 lex1_segdirx1_se
+| 3632: 67 64 69 72 04 43 52 45 41 54 45 20 54 41 42 4c gdir.CREATE TABL
+| 3648: 45 20 27 78 31 5f 73 65 67 64 69 72 27 28 6c 65 E 'x1_segdir'(le
+| 3664: 76 65 6c 20 49 4e 54 45 47 45 52 2c 69 64 78 20 vel INTEGER,idx
+| 3680: 49 4e 54 45 47 45 52 2c 73 74 61 72 74 5f 62 6c INTEGER,start_bl
+| 3696: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 6c 65 61 76 ock INTEGER,leav
+| 3712: 65 73 5f 65 6e 64 5f 62 6c 6f 63 6b 20 49 4e 54 es_end_block INT
+| 3728: 45 47 45 52 2c 65 6e 64 5f 62 6c 6f 63 6b 20 49 EGER,end_block I
+| 3744: 4e 54 45 47 45 52 2c 72 6f 6f 74 20 42 4c 4f 42 NTEGER,root BLOB
+| 3760: 2c 50 52 49 4d 41 52 59 20 4b 45 59 28 6c 65 76 ,PRIMARY KEY(lev
+| 3776: 65 6c 2c 20 69 64 78 29 29 31 05 06 17 45 1f 01 el, idx))1...E..
+| 3792: 00 69 6e 64 65 78 73 71 6c 69 74 65 5f 61 75 74 .indexsqlite_aut
+| 3808: 6f 69 6e 64 65 78 5f 78 31 5f 73 65 67 64 69 72 oindex_x1_segdir
+| 3824: 5f 31 78 31 5f 73 65 67 64 69 72 05 00 00 00 08 _1x1_segdir.....
+| 3840: 60 00 00 00 66 03 07 17 23 23 01 81 13 74 61 62 `...f...##...tab
+| 3856: 6c 65 78 31 5f 73 65 67 6d 65 6e 74 73 78 31 5f lex1_segmentsx1_
+| 3872: 73 65 67 6d 65 6e 74 73 03 43 52 45 41 54 45 20 segments.CREATE
+| 3888: 54 41 42 4c 45 20 27 78 31 5f 73 65 67 6d 65 6e TABLE 'x1_segmen
+| 3904: 74 73 27 28 62 6c 6f 63 6b 69 64 20 49 4e 54 45 ts'(blockid INTE
+| 3920: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
+| 3936: 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 5c 02 07 17 block BLOB)....
+| 3952: 21 21 01 81 03 74 61 62 6c 65 78 31 5f 63 6f 6e !!...tablex1_con
+| 3968: 74 65 6e 74 78 31 5f 63 6f 6e 74 65 6e 74 02 43 tentx1_content.C
+| 3984: 52 45 41 54 45 20 54 41 42 4c 45 20 27 78 31 5f REATE TABLE 'x1_
+| 4000: 63 6f 6e 74 65 6e 74 27 28 64 6f 63 69 64 20 49 content'(docid I
+| 4016: 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b NTEGER PRIMARY K
+| 4032: 45 59 2c 20 27 63 30 78 27 29 34 01 06 17 11 11 EY, 'c0x')4.....
+| 4048: 08 57 74 61 62 6c 65 78 31 78 31 43 52 45 41 54 .Wtablex1x1CREAT
+| 4064: 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 E VIRTUAL TABLE
+| 4080: 78 31 20 55 53 49 4e 47 20 66 74 73 33 28 78 29 x1 USING fts3(x)
+| page 2 offset 4096
+| 0: 0d 00 00 00 11 0f 77 f0 0f f8 0f f0 0f e8 0f e0 ......w.........
+| 16: 0f d8 0f d0 0f c8 0f c0 00 00 00 00 00 00 00 00 ................
+| 3952: 00 00 00 00 00 00 00 00 06 11 03 00 13 77 78 79 .............wxy
+| 3968: 06 10 03 00 13 74 75 76 06 0f 03 00 13 71 33 73 .....tuv.....q3s
+| 3984: 06 0e 03 00 13 6e 6f 70 06 0d 03 00 13 6b 6c 6d .....nop.....klm
+| 4000: 06 0c 03 04 c3 68 69 6a 06 0b 03 00 13 65 66 67 .....hij.....efg
+| 4016: 06 0a 03 00 13 62 63 64 06 09 03 00 13 79 7a 61 .....bcd.....yza
+| 4032: 06 08 03 00 13 76 77 78 06 07 03 00 13 73 74 75 .....vwx.....stu
+| 4048: 06 06 03 00 13 70 71 72 06 05 03 00 13 6d 6e 6f .....pqr.....mno
+| 4064: 06 03 03 00 13 6a 6b 6c 06 03 03 00 13 67 68 69 .....jkl.....ghi
+| 4080: 06 02 02 00 03 64 65 66 06 01 03 00 13 61 52 63 .....def.....aRc
+| page 3 offset 8192
+| 0: 0d 00 00 00 03 0f a7 00 0f b5 0f a7 0f fa 01 00 ................
+| 4000: 00 00 00 00 00 00 00 0c 02 03 00 1e 00 03 6b 6c ..............kl
+| 4016: 6d 03 0d 02 00 43 01 04 00 81 0a 00 03 61 62 63 m....C.......abc
+| 4032: 03 0b 32 00 00 03 62 63 64 03 0a 02 00 00 03 64 ..2...bcd......d
+| 4048: 69 26 03 02 02 00 00 03 65 66 67 03 0b 02 00 00 i&......efg.....
+| 4064: 03 67 68 69 03 03 02 00 00 03 68 69 6a 03 0c 02 .ghi......hij...
+| 4080: 00 00 03 6a 6a 2c 03 04 02 00 03 81 00 03 00 00 ...jj,..........
+| page 4 offset 12288
+| 0: 0d 0f 3a 00 05 0f 25 00 0f 9e 0f 88 0f 43 0f 25 ..:...%......C.%
+| 16: 0f 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .r..............
+| 3856: 00 00 00 00 00 00 00 00 00 56 01 08 08 13 1e 03 .........V......
+| 3872: 30 20 39 00 03 13 05 07 08 08 18 08 13 1e 30 20 0 9...........0
+| 3888: 39 00 03 77 78 79 03 11 02 00 0f 6c 00 09 01 08 9..wxy.....l....
+| 3904: 08 15 54 27 04 07 09 01 08 08 15 42 02 30 20 33 ..T'.......B.0 3
+| 3920: 36 00 03 6e 6f 70 03 0e 02 00 00 03 71 72 73 03 6..nop......qrs.
+| 3936: 0f 02 00 00 03 74 75 76 03 10 02 00 0f cf b1 06 .....tuv........
+| 3952: 01 08 14 06 07 01 08 09 01 1b 14 02 02 31 32 38 .............128
+| 3968: 20 2d 37 32 10 01 01 6b 14 03 07 09 09 08 08 15 -72...k........
+| 3984: 1e 30 20 33 36 00 03 79 7a 61 03 09 02 00 2f 02 .0 36..yza..../.
+| 4000: 07 09 08 08 08 15 54 30 20 33 36 00 03 6d 6e 6f ......T0 36..mno
+| 4016: 03 05 02 00 00 03 70 71 72 03 06 02 00 00 03 73 ......pqr......s
+| 4032: 74 75 03 07 02 00 00 03 76 77 78 03 08 02 00 00 tu......vwx.....
+| 4048: 00 00 4a 08 08 08 15 54 30 20 33 36 00 03 61 62 ..J....T0 36..ab
+| 4064: 63 03 01 02 00 00 03 64 65 66 03 02 02 00 00 03 c......def......
+| 4080: 67 68 69 03 03 67 00 00 03 6a 6b 6c 03 04 02 00 ghi..g...jkl....
+| page 5 offset 16384
+| 0: 0a 0f e7 00 05 0f da 00 0f e1 0f fa 0f f4 0f ed ................
+| 16: 0f da 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4048: 00 00 00 00 00 00 00 1a 01 03 06 04 01 08 01 02 ................
+| 4064: 06 05 04 08 08 01 05 00 00 00 06 01 03 06 04 09 ................
+| 4080: 02 01 02 04 05 04 09 09 01 03 05 04 09 08 01 02 ................
+| page 6 offset 20480
+| 0: 0d 00 10 00 01 0f f9 00 0f f9 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 05 01 03 00 10 01 03 ................
+| end crash-65c98512cc9e49.db
+}]} {}
+
+do_catchsql_test 45.2 {
+ INSERT INTO x1(x1) VALUES( 'merge=1' )
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+set saved $sqlite_fts3_enable_parentheses
+set sqlite_fts3_enable_parentheses 1
+do_execsql_test 46.1 {
+ CREATE VIRTUAL TABLE t0 USING fts3(a INTEGER PRIMARY KEY,b,c,d);
+ INSERT INTO t0_segdir VALUES(0,0,0,0,'0 42',X'0001310301c9000103323334050d8000f200000461616161050101020200000462626262050101030200');
+} {}
+
+do_catchsql_test 46.2 {
+ SELECT * FROM t0
+ WHERE t0 MATCH x'2b0a312b0a312a312a2a0b5d0a0b0b0a312a0a0b0b0a312a0b310a392a0b0a27312a2a0b5d0a312a0b310a31315d0b310a312a316d2a0b313b15bceaa50a312a0b0a27312a2a0b5d0a312a0b310a312b0b2a310a312a0b2a0b2a0b2e5d0a0bff313336e34a2a312a0b0a3c310b0a0b4b4b0b4b2a4bec40322b2a0b310a0a312a0a0a0a0a0a0a0a0a0b310a312a2a2a0b5d0a0b0b0a312a0b310a312a0b0a4e4541530b310a5df5ced70a0a0a0a0a4f520a0a0a0a0a0a0a312a0b0a4e4541520b310a5d616161610a0a0a0a4f520a0a0a0a0a0a312b0a312a312a0a0a0a0a0a0a004a0b0a310b220a0b0a310a4a22310a0b0a7e6fe0e0e030e0e0e0e0e01176e02000e0e0e0e0e01131320226310a0b0a310a4a22310a0b0a310a766f8b8b4ee0e0300ae0090909090909090909090909090909090909090909090909090909090909090947aaaa540b09090909090909090909090909090909090909090909090909090909090909fae0e0f2f22164e0e0f273e07fefefef7d6dfafafafa6d6d6d6d';
+} {1 {database disk image is malformed}}
+
+set sqlite_fts3_enable_parentheses $saved
+extra_schema_checks 1
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 47.1 {
+ CREATE VIRTUAL TABLE t1 USING fts3(a,b,c);
+}
+do_execsql_test 47.2 {
+ INSERT INTO t1_segdir VALUES(0,0,0,0,0,X'000130120106000106000106001f030001030001030000083230313630363039090107000107000107000001340901050001050001050000013509010400010400010400010730303030303030091c0400010400010400000662696e6172793c0301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000008636f6d70696c657209010200010200010200000664627374617409070300010300010300010465627567090402000102000102000006656e61626c653f07020001020001020001020001020001020001020001020001020001020001020001020001010001020001020001020001020001020001020001020001020001087874656e73696f6e091f0400010400010400000466747334090a0300010300010300030135090d03000103000103000003676363090103000103000103000106656f706f6c790910030001030001030000056a736f6e310913030001030001030000046c6f6164091f030001030001030000036d6178091c02000102000102000105656d6f7279091c03000103000103000304737973350916030001030001030000066e6f636173653c02010202000301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000301020200030102020000046f6d6974091f020001020001020000057274726565091903000103000103000302696d3c01010202000301020200030102020003010202000301020200030102020003010202000301a202000301020200030102020003010202000301020200000a746872656164736166650922020001020001020000047674616209070400010400010400000178b401010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200');
+ INSERT INTO t1_segdir VALUES(0,1,0,0,0,X'0001300425061b000008323031363036303903250700000134032505000001350325040001073030303030303003251a000008636f6d70696c657203250200000664627374617403250a00010465627567032508000006656e61626c650925090504040404040001087874656e73696f6e03251d0000046674733403250d0003013503250f000003676363032503000106656f706f6c790325110000056a736f6e310325130000046c6f616403251c0000036d6178032518000105656d6f7279032519000304737973350325150000046f6d697403251b000005727472656503251700000a7468726561647361666503251e0000047674616333250b00');
+}
+
+do_catchsql_test 47.3 {
+ SELECT matchinfo(t1) FROM t1 WHERE t1 MATCH '"json1 enable"';
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 48.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 20480 pagesize 4096 filename sql038051.txt.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........
+| 96: 00 00 00 00 0d 0e fc 00 05 0e 13 00 0f ca 0f 6c ...............l
+| 112: 0f 04 0e 13 0e c9 00 00 00 00 00 00 00 00 00 00 ................
+| 3600: 00 00 00 81 33 04 07 17 1f 1f 01 82 35 74 61 62 ....3.......5tab
+| 3616: 6c 65 78 31 5f 73 65 67 64 69 72 78 31 5f 73 65 lex1_segdirx1_se
+| 3632: 67 64 69 72 04 43 52 45 41 54 45 20 54 41 42 4c gdir.CREATE TABL
+| 3648: 45 20 27 78 31 5f 73 65 67 64 69 72 27 28 6c 65 E 'x1_segdir'(le
+| 3664: 76 65 6c 20 49 4e 54 45 47 45 52 2c 69 64 78 20 vel INTEGER,idx
+| 3680: 49 4e 54 45 47 45 52 2c 73 74 61 72 74 5f 62 6c INTEGER,start_bl
+| 3696: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 6c 65 61 76 ock INTEGER,leav
+| 3712: 65 73 5f 65 6e 64 5f 62 6c 6f 63 6b 20 49 4e 54 es_end_block INT
+| 3728: 45 47 45 52 2c 65 6e 64 5f 62 6c 6f 63 6b 20 49 EGER,end_block I
+| 3744: 4e 54 45 47 45 52 2c 72 6f 6f 74 20 42 4c 4f 42 NTEGER,root BLOB
+| 3760: 2c 50 52 49 4d 41 52 59 20 4b 45 59 28 6c 65 76 ,PRIMARY KEY(lev
+| 3776: 65 6c 2c 20 69 64 78 29 29 31 05 06 17 45 1f 01 el, idx))1...E..
+| 3792: 00 69 6e 64 65 78 73 71 6c 69 74 65 5f 61 75 74 .indexsqlite_aut
+| 3808: 6f 69 6e 64 65 78 5f 78 31 5f 73 65 67 64 69 72 oindex_x1_segdir
+| 3824: 5f 31 78 31 5f 73 65 67 64 69 72 05 00 00 00 08 _1x1_segdir.....
+| 3840: 00 00 00 00 66 03 07 17 23 23 01 81 13 74 61 62 ....f...##...tab
+| 3856: 6c 65 78 31 5f 73 65 67 6d 65 6e 74 73 78 31 5f lex1_segmentsx1_
+| 3872: 73 65 67 6d 65 6e 74 73 03 43 52 45 41 54 45 20 segments.CREATE
+| 3888: 54 41 42 4c 45 20 27 78 31 5f 73 65 67 6d 65 6e TABLE 'x1_segmen
+| 3904: 74 73 27 28 62 6c 6f 63 6b 69 64 20 49 4e 54 45 ts'(blockid INTE
+| 3920: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
+| 3936: 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 5c 02 07 17 block BLOB)....
+| 3952: 21 21 01 81 03 74 61 62 6c 65 78 31 5f 63 6f 6e !!...tablex1_con
+| 3968: 74 65 6e 74 78 31 5f 63 6f 6e 74 65 6e 74 02 43 tentx1_content.C
+| 3984: 52 45 41 54 45 20 54 41 42 4c 45 20 27 78 31 5f REATE TABLE 'x1_
+| 4000: 63 6f 6e 74 65 6e 74 27 28 64 6f 63 69 64 20 49 content'(docid I
+| 4016: 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b NTEGER PRIMARY K
+| 4032: 45 59 2c 20 27 63 30 78 27 29 34 01 06 17 11 11 EY, 'c0x')4.....
+| 4048: 08 57 74 61 62 6c 65 78 31 78 31 43 52 45 41 54 .Wtablex1x1CREAT
+| 4064: 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 E VIRTUAL TABLE
+| 4080: 78 31 20 55 53 49 4e 47 20 66 74 73 33 28 78 29 x1 USING fts3(x)
+| page 2 offset 4096
+| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3920: 00 00 00 2e 04 03 00 63 62 72 61 69 6e 73 74 65 .......cbrainste
+| 3936: 6d 20 62 72 61 69 6e 73 74 65 6d 73 20 62 72 61 m brainstems bra
+| 3952: 69 6e 73 74 6f 72 6d 20 62 72 61 69 6e 73 74 6f instorm brainsto
+| 3968: 72 6d 73 2b 03 03 00 5d 62 72 61 69 6e 20 62 72 rms+...]brain br
+| 3984: 61 69 6e 63 68 69 6c 64 20 62 72 61 69 6e 65 64 ainchild brained
+| 4000: 20 62 72 61 69 6e 69 6e 67 20 62 72 61 69 6e 73 braining brains
+| 4016: 26 02 03 00 53 62 72 61 67 73 20 62 72 61 69 64 &...Sbrags braid
+| 4032: 20 62 72 61 69 64 65 64 20 62 72 61 69 64 69 6e braided braidin
+| 4048: 67 20 62 72 61 69 64 73 26 01 03 00 53 62 72 61 g braids&...Sbra
+| 4064: 65 73 20 62 72 61 67 20 62 72 61 67 67 65 64 20 es brag bragged
+| 4080: 62 72 61 c3 67 65 72 20 62 72 61 67 67 69 6e 67 bra.ger bragging
+| page 3 offset 8192
+| 0: 0d 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 ................
+| page 4 offset 12288
+| 0: 0d 00 00 00 04 0f 20 00 0f c8 0f 90 0f 54 0f 20 ...... ......T.
+| 3872: 32 04 07 08 01 08 08 15 58 03 30 20 33 38 00 09 2.......X.0 38..
+| 3888: 62 72 61 69 6e 73 74 65 6d 03 04 02 00 09 01 73 brainstem......s
+| 3904: 03 04 03 00 07 03 6f 72 6d 03 04 04 00 0a 01 73 ......orm......s
+| 3920: 03 04 05 00 3a 03 07 08 01 08 08 15 68 02 30 20 ....:.......h.0
+| 3936: 34 36 00 05 62 72 61 69 6e 03 03 02 00 05 05 63 46..brain......c
+| 3952: 68 69 6c 64 03 03 03 00 05 02 65 64 03 03 04 00 hild......ed....
+| 3968: 05 03 69 6e 67 03 03 05 00 05 01 73 03 03 06 00 ..ing......s....
+| 3984: 36 02 07 08 09 08 08 15 62 30 20 34 33 00 05 62 6.......b0 43..b
+| 4000: 72 61 67 73 03 02 02 00 03 02 69 64 03 02 03 00 rags......id....
+| 4016: 05 02 65 64 03 02 04 00 05 03 69 6e 67 03 02 05 ..ed......ing...
+| 4032: 00 05 01 73 03 02 06 00 36 01 07 08 08 08 08 15 ...s....6.......
+| 4048: 62 30 20 34 33 00 05 62 72 61 65 73 03 01 02 00 b0 43..braes....
+| 4064: 03 01 68 03 01 03 00 04 03 67 65 74 03 01 04 00 ..h......get....
+| 4080: 06 01 72 03 01 05 00 05 03 69 6e 67 03 01 06 00 ..r......ing....
+| page 5 offset 16384
+| 0: 0a 00 00 00 04 0f e7 00 0f fb 0f f5 0f ee 0f e7 ................
+| 4064: 00 00 00 00 00 00 00 06 04 08 01 01 03 04 06 04 ................
+| 4080: 08 01 01 02 03 05 04 08 09 01 02 04 04 08 08 09 ................
+| end sql038051.txt.db
+}]} {}
+
+do_catchsql_test 48.1 {
+ INSERT INTO x1(x1) VALUES('nodesize=24'),('merge=3,4');
+ INSERT INTO x1(x1) VALUES( 'merge=3,4' ),('merge=3,4');
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 49.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-58821b8eae6883.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
+| 96: 00 00 00 00 0d 0e ef 00 07 0d 4d 00 0f bd 0f 5f ..........M...._
+| 112: 0e f7 0e 06 0e bc 0d a4 0d 4d 00 00 00 00 00 00 .........M......
+| 3392: 00 00 00 00 00 00 00 00 00 00 00 00 00 55 07 07 .............U..
+| 3408: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 73 74 ......tablet1_st
+| 3424: 61 74 74 31 5f 73 74 61 74 07 43 52 45 41 54 45 att1_stat.CREATE
+| 3440: 20 54 41 42 4c 45 20 27 74 31 5f 73 74 61 74 27 TABLE 't1_stat'
+| 3456: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (id INTEGER PRIM
+| 3472: 41 52 59 20 4b 45 59 2c 20 76 61 6c 75 65 20 42 ARY KEY, value B
+| 3488: 4c 4f 42 29 60 06 07 17 21 21 01 81 0b 74 61 62 LOB)`...!!...tab
+| 3504: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64 let1_docsizet1_d
+| 3520: 6f 63 73 69 7a 65 06 43 52 45 41 54 45 20 54 41 ocsize.CREATE TA
+| 3536: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27 BLE 't1_docsize'
+| 3552: 28 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 (docid INTEGER P
+| 3568: 52 49 4d 41 52 59 20 4b 45 59 2c 20 73 69 7a 65 RIMARY KEY, size
+| 3584: 20 42 4c 4f 42 29 81 33 04 07 17 1f 1f 01 82 35 BLOB).3.......5
+| 3600: 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 74 31 tablet1_segdirt1
+| 3616: 5f 73 65 67 64 69 72 04 43 52 45 41 54 45 20 54 _segdir.CREATE T
+| 3632: 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 72 27 ABLE 't1_segdir'
+| 3648: 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 2c 69 (level INTEGER,i
+| 3664: 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 72 74 dx INTEGER,start
+| 3680: 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 6c _block INTEGER,l
+| 3696: 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 6b 20 eaves_end_block
+| 3712: 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c 6f 63 INTEGER,end_bloc
+| 3728: 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 20 42 k INTEGER,root B
+| 3744: 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 59 28 LOB,PRIMARY KEY(
+| 3760: 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 05 06 17 level, idx))1...
+| 3776: 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 65 5f E...indexsqlite_
+| 3792: 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 65 67 autoindex_t1_seg
+| 3808: 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 05 00 dir_1t1_segdir..
+| 3824: 00 00 08 00 00 00 00 66 03 07 17 23 23 01 81 13 .......f...##...
+| 3840: 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e 74 73 tablet1_segments
+| 3856: 74 31 5f 73 65 67 6d 65 6e 74 73 03 43 52 45 41 t1_segments.CREA
+| 3872: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
+| 3888: 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 20 49 ments'(blockid I
+| 3904: 4e 54 45 47 45 52 20 f9 52 49 4d 41 52 59 20 4b NTEGER .RIMARY K
+| 3920: 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 5c EY, block BLOB).
+| 3936: 02 07 17 21 21 01 81 03 74 61 62 6c 65 74 31 5f ...!!...tablet1_
+| 3952: 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 65 6e contentt1_conten
+| 3968: 74 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 t.CREATE TABLE '
+| 3984: 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 63 69 t1_content'(doci
+| 4000: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 d INTEGER PRIMAR
+| 4016: 59 20 4b 45 59 2c 20 27 63 30 61 27 29 41 01 06 Y KEY, 'c0a')A..
+| 4032: 17 11 11 08 71 74 61 62 6c 65 74 31 74 31 43 52 ....qtablet1t1CR
+| 4048: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4064: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 34 LE t1 USING fts4
+| 4080: 28 61 2c 70 72 65 66 69 78 3d 27 32 2c 32 27 29 (a,prefix='2,2')
+| page 2 offset 4096
+| 0: 0d 00 00 00 08 0e 1f 00 0f c4 0f 7c 0f 34 0f 07 ...........|.4..
+| 16: 0e c3 0e 97 0e 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ...............B
+| 3616: 08 04 00 81 09 73 75 6e 74 20 69 6e 20 63 75 6c .....sunt in cul
+| 3632: 70 61 20 71 75 69 20 6f 66 66 69 63 69 61 20 64 pa qui officia d
+| 3648: 65 73 65 72 75 6e 74 20 6d 6f 6c 6c 69 74 20 61 eserunt mollit a
+| 3664: 6e 69 6d 20 69 64 20 65 73 74 20 6c 61 62 6f 72 nim id est labor
+| 3680: 75 6d 2e 32 07 03 00 6b 45 78 63 65 70 74 65 75 um.2...kExcepteu
+| 3696: 72 20 73 69 6e 74 20 6f 63 63 61 65 63 61 74 20 r sint occaecat
+| 3712: 63 75 70 69 64 61 74 61 74 20 6e 6f 6e 20 70 72 cupidatat non pr
+| 3728: 6f 69 64 65 6e 74 2c 2a 06 03 00 5b 63 69 6c 6c oident,*...[cill
+| 3744: 75 6d 20 64 6f 6c 6f 72 65 20 65 75 20 66 75 67 um dolore eu fug
+| 3760: 69 61 74 20 6e 75 6c 6c 61 20 70 61 72 69 61 74 iat nulla pariat
+| 3776: 75 72 2e 42 05 04 00 81 09 44 75 69 73 20 61 75 ur.B.....Duis au
+| 3792: 74 65 20 69 72 75 72 65 20 64 6f 6c 6f 72 20 69 te irure dolor i
+| 3808: 6e 20 72 65 70 72 65 68 65 6e 64 65 72 69 74 20 n reprehenderit
+| 3824: 69 6e 20 76 6f 6c 75 70 74 61 74 65 20 76 65 6c in voluptate vel
+| 3840: 69 74 20 65 73 73 65 2b 04 03 00 5d 6e 69 73 69 it esse+...]nisi
+| 3856: 20 75 74 20 61 6c 69 71 75 69 70 20 65 78 20 65 ut aliquip ex e
+| 3872: 61 20 63 6f 6d 6d 6f 64 6f 20 63 6f 6e 73 65 71 a commodo conseq
+| 3888: 75 61 74 2e 46 03 04 00 81 11 55 74 20 65 6e 69 uat.F.....Ut eni
+| 3904: 6d 20 61 64 20 6d 69 6e 69 6d 20 76 65 6e 69 61 m ad minim venia
+| 3920: 6d 2c 20 71 75 69 73 20 6e 6f 73 74 72 75 64 20 m, quis nostrud
+| 3936: 65 78 65 72 63 69 74 61 74 69 6f 6e 20 75 6c 6c exercitation ull
+| 3952: 61 6d 63 6f 20 6c 61 62 6f 72 69 73 46 02 04 00 amco laborisF...
+| 3968: 81 11 73 65 64 20 64 6f 20 65 69 75 73 6d 6f 64 ..sed do eiusmod
+| 3984: 20 74 65 6d 70 6f 72 20 69 6e 63 69 64 69 64 75 tempor incididu
+| 4000: 6e 74 20 75 74 20 6c 61 62 6f 72 65 20 65 74 20 nt ut labore et
+| 4016: 64 6f 6c 6f 72 65 20 6d 61 67 6e 61 20 61 6c 69 dolore magna ali
+| 4032: 71 75 61 2e 3a 01 03 00 7b 4c 6f 72 65 6d 20 69 qua.:....Lorem i
+| 4048: 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 psum dolor sit a
+| 4064: 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 met, consectetur
+| 4080: 20 61 64 69 70 69 73 63 69 6e 67 20 65 00 01 00 adipiscing e...
+| page 4 offset 12288
+| 0: 0d 00 00 00 03 0a a6 00 0d 57 0c 4a 0a a6 00 00 .........W.J....
+| 2720: 00 00 00 00 00 00 83 21 03 08 02 08 08 08 17 86 .......!........
+| 2736: 30 08 00 30 20 34 30 32 00 02 61 64 06 01 08 00 0..0 402..ad....
+| 2752: 02 04 00 01 01 6c 06 02 0c 00 02 04 00 01 01 6d .....l.........m
+| 2768: 03 01 06 00 01 01 6e 03 08 09 00 01 01 75 03 05 ......n......u..
+| 2784: 03 00 00 02 63 69 03 06 02 00 01 01 6f 07 01 07 ....ci......o...
+| 2800: 00 03 07 03 00 01 01 75 06 07 05 00 01 04 00 00 .......u........
+| 2816: 02 64 65 03 08 07 00 01 01 6f 0d 01 04 00 01 03 .de......o......
+| 2832: 09 00 03 05 00 01 03 00 01 01 75 03 05 02 00 00 ..........u.....
+| 2848: 02 65 61 03 04 06 00 01 01 69 03 02 04 00 01 01 .ea......i......
+| 2864: 6c 03 01 09 00 01 01 6e 03 03 03 00 01 01 73 06 l......n......s.
+| 2880: 05 0b 00 03 0b 00 01 01 74 03 02 09 00 01 01 75 ........t......u
+| 2896: 03 06 04 00 01 01 78 09 03 09 00 01 05 00 03 02 ......x.........
+| 2912: 00 00 02 66 75 03 06 05 00 00 02 69 64 03 08 0a ...fu......id...
+| 2928: 00 01 01 6e 0a 02 06 00 03 06 04 00 03 03 00 01 ...n............
+| 2944: 01 70 03 01 03 00 01 01 72 03 05 04 00 00 02 6c .p......r......l
+| 2960: 61 09 02 08 00 01 0b 00 05 0c 00 01 01 6f 03 01 a............o..
+| 2976: 02 00 00 02 6d 61 03 02 0b 00 01 01 69 03 03 05 ....ma......i...
+| 2992: 00 01 01 6f 03 08 08 00 00 02 6e 69 03 04 02 00 ...o......ni....
+| 3008: 01 01 6f 06 03 08 00 04 06 00 01 01 75 03 06 06 ..o.........u...
+| 3024: 00 00 02 6f 63 03 07 04 00 01 01 66 03 08 06 00 ...oc......f....
+| 3040: 00 02 70 61 03 06 07 00 01 01 72 03 07 07 00 00 ..pa......r.....
+| 3056: 02 71 75 06 03 07 00 05 05 00 00 02 72 65 03 05 .qu.........re..
+| 3072: 07 00 00 02 73 65 03 02 02 00 01 01 69 06 01 05 ....se......i...
+| 3088: 00 06 03 00 01 01 75 03 08 02 00 00 02 74 65 03 ......u......te.
+| 3104: 02 05 00 00 02 75 6c 03 03 0a 00 01 01 74 09 02 .....ul......t..
+| 3120: 07 00 01 02 00 01 03 00 00 02 76 65 06 03 06 00 ..........ve....
+| 3136: 02 0a 00 01 01 6f 03 05 09 00 82 0a 02 08 02 08 .....o..........
+| 3152: 08 08 17 84 02 04 00 30 20 32 35 31 00 01 61 13 .......0 251..a.
+| 3168: 01 06 04 00 01 0c 00 01 04 00 01 04 00 01 03 00 ................
+| 3184: 03 09 00 00 01 63 10 01 07 00 03 07 03 00 02 02 .....c..........
+| 3200: 00 01 05 00 01 04 00 00 01 64 11 01 04 00 01 03 .........d......
+| 3216: 09 00 03 02 05 00 01 03 00 02 07 00 00 01 65 1b ..............e.
+| 3232: 01 09 00 01 04 07 00 01 03 08 00 01 05 03 00 01 ................
+| 3248: 0b 00 01 04 00 01 02 00 01 0b 00 00 01 66 03 06 .............f..
+| 3264: 05 00 00 01 69 0f 01 03 00 01 06 00 03 04 04 04 ....i...........
+| 3280: 00 03 03 09 00 00 01 6c 0c 01 02 00 01 08 00 01 .......l........
+| 3296: 0b 00 05 0c 00 00 01 6d 09 02 0b 00 01 05 00 05 .......m........
+| 3312: 08 00 00 01 6e 0c 03 08 00 01 02 00 02 06 00 01 ....n...........
+| 3328: 06 00 00 01 6f 06 07 04 00 01 06 00 00 01 70 06 ....o.........p.
+| 3344: 06 07 00 01 07 00 00 01 71 06 03 07 00 05 05 00 ........q.......
+| 3360: 00 01 72 03 05 07 00 00 01 73 0c 01 05 00 01 02 ..r......s......
+| 3376: 00 05 03 00 01 02 00 00 01 74 03 02 05 00 00 01 .........t......
+| 3392: 75 0a 02 07 00 01 02 0a 00 01 03 00 00 01 76 07 u.............v.
+| 3408: 03 06 00 02 09 03 00 85 26 01 08 08 08 08 08 17 ........&.......
+| 3424: 8a 3e 30 20 36 36 35 00 02 61 65 03 03 04 00 02 .>0 665..ae.....
+| 3440: 08 69 70 69 73 63 69 6e 67 03 01 08 00 01 05 6c .ipiscing......l
+| 3456: 69 71 75 61 03 02 0c 00 05 02 69 70 03 04 04 00 iqua......ip....
+| 3472: 01 03 6d 65 74 03 01 06 00 01 03 6e 69 6d 03 08 ..met......nim..
+| 3488: 09 00 01 03 75 74 65 03 05 03 00 00 06 63 69 6c ....ute......cil
+| 3504: 6c 75 6d 03 06 02 00 01 06 6f 6d 6d 6f 64 6f 03 lum......ommodo.
+| 3520: 04 07 00 02 09 6e 73 65 63 74 65 74 b5 72 03 01 .....nsectet.r..
+| 3536: 07 00 05 04 71 75 61 74 03 04 08 00 01 04 75 6c ....quat......ul
+| 3552: 70 61 03 08 04 00 02 07 70 69 64 61 74 61 74 03 pa......pidatat.
+| 3568: 07 05 00 00 08 64 65 73 65 72 75 6e 74 03 08 07 .....deserunt...
+| 3584: 00 01 01 6f 03 02 03 00 02 03 6c 6f 72 06 01 04 ...o......lor...
+| 3600: 00 04 05 00 05 01 65 06 02 0a 00 04 03 00 01 03 ......e.........
+| 3616: 75 69 73 03 05 02 00 00 02 65 61 03 04 06 00 01 uis......ea.....
+| 3632: 06 69 75 73 6d 6f 64 03 02 04 00 01 03 6c 69 74 .iusmod......lit
+| 3648: 03 01 09 00 01 03 6e 69 6d 03 03 03 00 01 03 73 ......nim......s
+| 3664: 73 65 03 05 0b 00 02 01 74 03 08 0b 00 01 01 74 se......t......t
+| 3680: 03 02 09 00 01 01 75 03 06 04 00 01 01 78 03 04 ......u......x..
+| 3696: 05 00 02 07 63 65 70 74 65 75 72 03 07 02 00 02 ....cepteur.....
+| 3712: 0a 65 72 63 69 74 61 74 69 6f 6e 03 03 09 00 00 .ercitation.....
+| 3728: 06 66 75 67 69 61 74 03 06 05 00 00 02 69 64 03 .fugiat......id.
+| 3744: 08 0a 00 01 01 6e 07 05 06 04 00 03 03 00 02 08 .....n..........
+| 3760: 63 69 64 69 64 75 6e 74 03 02 06 00 01 04 70 73 cididunt......ps
+| 3776: 75 6d 03 01 03 00 01 04 72 75 72 65 03 05 04 00 um......rure....
+| 3792: 00 06 6c 61 62 6f 72 65 03 02 08 00 05 02 69 73 ..labore......is
+| 3808: 03 03 0b 00 05 02 75 6d 03 08 0c 00 01 04 6f 72 ......um......or
+| 3824: 65 6d 03 01 02 00 00 05 6d 61 67 6e 61 03 02 0b em......magna...
+| 3840: 00 01 04 69 6e 69 6d 03 03 05 00 01 05 6f 6c 6c ...inim......oll
+| 3856: 69 74 03 08 08 00 00 04 6e 69 73 69 03 04 02 00 it......nisi....
+| 3872: 01 02 6f 6e 03 07 06 00 02 05 73 74 72 75 64 03 ..on......strud.
+| 3888: 03 08 00 01 04 75 6c 6c 61 03 06 06 00 00 08 6f .....ulla......o
+| 3904: 63 63 61 65 63 61 74 03 07 04 00 01 06 66 66 69 ccaecat......ffi
+| 3920: 63 69 61 03 08 06 00 00 08 70 61 72 69 61 74 75 cia......pariatu
+| 3936: 72 03 06 07 00 01 07 72 6f 69 64 65 6e 74 03 07 r......roident..
+| 3952: 07 00 00 03 71 75 69 03 08 05 00 03 01 73 03 03 ....qui......s..
+| 3968: 07 00 00 0d 72 65 70 72 65 68 65 6e 64 65 72 69 ....reprehenderi
+| 3984: 74 03 05 07 00 00 03 73 65 64 03 02 02 00 01 03 t......sed......
+| 4000: 69 6e 74 03 07 03 00 02 01 74 03 01 05 00 01 03 int......t......
+| 4016: 75 6e 74 03 08 02 00 00 06 74 65 6d 70 6f 72 03 unt......tempor.
+| 4032: 02 05 00 00 07 75 6c 6c 61 6d 63 6f 03 03 0a 00 .....ullamco....
+| 4048: 01 01 74 09 02 07 00 01 02 00 01 03 00 00 05 76 ..t............v
+| 4064: 65 6c 69 74 03 05 0a 00 02 04 6e 69 61 6d 03 03 elit......niam..
+| 4080: 06 00 01 08 6f 6c 75 70 74 61 74 65 03 05 09 00 ....oluptate....
+| page 5 offset 16384
+| 0: 0a 00 00 00 03 0f eb 00 0f fb 0f f3 0f eb 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 00 00 07 04 02 08 01 ................
+| 4080: 08 00 03 07 04 02 08 01 04 00 02 04 04 08 08 09 ................
+| page 6 offset 20480
+| 0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8 ................
+| 16: 0f e2 0f dc 0f d6 0f d0 00 00 00 00 00 00 00 00 ................
+| 4048: 04 08 03 00 0e 0b 04 07 03 00 0e 06 04 06 03 00 ................
+| 4064: 0e 06 04 05 03 00 0e 0a 04 04 03 00 0e 07 04 03 ................
+| 4080: 03 00 0e 0a 04 02 03 00 0e 0b 04 01 03 00 0e 08 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 01 0f f7 00 0f f7 00 00 00 00 01 00 ................
+| 4080: 00 00 00 00 00 00 00 07 00 03 00 14 08 45 b5 03 .............E..
+| end crash-58821b8eae6883.db
+}]} {}
+
+do_catchsql_test 49.1 {
+ SAVEPOINT one;
+ DELETE FROM t1 WHERE t1 MATCH 'c*';
+ SELECT matchinfo(t1,'pcx') IS NULL FROM t1 WHERE t1 MATCH 'f*e*';
+} {0 0}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 50.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-14ab65782c9c45.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 00 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 00 00 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 68 64 69 72 egdir_1t1_sehdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 INTEGER PRIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 62 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'b1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 00 00 00 00 00 00 00 00 00 ................
+| 2880: 00 00 00 00 00 00 00 00 81 f9 25 06 00 82 7f 00 ..........%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 50 4f 4c 59 20 45 4e 41 ABLE GEOPOLY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 37 a0 30 30 30 30 f2 30 20 4f 4d 49 54 20 4c =7.0000.0 OMIT L
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 54 53 41 46 45 3d ..%..THREATSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 5c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT .OAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 46 1e 1f 05 00 33 0f 17 ONXNOCASF....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 44 52 49 4d 1f 1e 05 00 33 0f 19 IONXRDRIM....3..
+| 3264: 4d 41 68 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAh MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 16 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 43 53 59 53 35 58 42 49 NABLE MECSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 46 20 46 54 53 34 58 52 54 52 49 4d 1e ABLF FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 55 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d UAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 00 00 00 00 00 00 00 00 9XNOCASE........
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 38 70 69 ...........co8pi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 52 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 Rstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 01 .enable?........
+| 3488: ff f1 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 03 00 01 01 00 02 02 00 01 02 00 01 ................
+| 3520: 02 00 01 02 00 01 12 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 04 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 0b 01 13 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 83 6f 6e 31 ...........j.on1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 00 00 00 00 ity-check.......
+| end crash-14ab65782c9c45.db
+}]} {}
+
+do_execsql_test 50.1 {
+ SELECT NULL FROM t1 WHERE t1 MATCH '"^enable"'
+} {
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 51.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-11cf359576eb28.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........
+| 32: 00 00 00 02 00 00 00 01 00 00 00 07 00 00 00 04 ................
+| 96: 00 00 00 00 0d 0e b1 00 06 0d a4 00 0f 8d 0f 21 ...............!
+| 112: 0e b9 0d c8 0e 7e 0d a4 0d a4 00 00 00 00 00 00 .....~..........
+| 3488: 00 00 00 00 22 07 06 17 11 11 01 31 74 61 62 6c ...........1tabl
+| 3504: 65 74 32 74 32 07 43 52 45 41 54 45 20 54 41 42 et2t2.CREATE TAB
+| 3520: 4c 45 20 74 32 28 78 29 81 33 05 07 17 1f 1f 01 LE t2(x).3......
+| 3536: 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 .5tablet1_segdir
+| 3552: 74 31 5f 73 65 67 64 69 72 05 43 52 45 41 54 45 t1_segdir.CREATE
+| 3568: 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 TABLE 't1_segdi
+| 3584: 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 r'(level INTEGER
+| 3600: 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 74 61 ,idx INTEGER,sta
+| 3616: 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 rt_block INTEGER
+| 3632: 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 ,leaves_end_bloc
+| 3648: 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c k INTEGER,end_bl
+| 3664: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 ock INTEGER,root
+| 3680: 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 BLOB,PRIMARY KE
+| 3696: 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 06 Y(level, idx))1.
+| 3712: 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 ..E...indexsqlit
+| 3728: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 e_autoindex_t1_s
+| 3744: 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 egdir_1t1_segdir
+| 3760: 06 0f c7 00 08 00 00 00 00 66 04 07 17 23 23 01 .........f...##.
+| 3776: 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e ..tablet1_segmen
+| 3792: 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 04 43 52 tst1_segments.CR
+| 3808: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 3824: 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 egments'(blockid
+| 3840: 20 49 4e 54 45 47 45 52 20 50 51 49 4d 41 52 59 INTEGER PQIMARY
+| 3856: 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 KEY, block BLOB
+| 3872: 29 6a 03 07 17 21 21 01 81 1f 74 61 62 6c 65 74 )j...!!...tablet
+| 3888: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 1_contentt1_cont
+| 3904: 65 6e 74 03 43 52 45 41 54 45 20 54 41 42 4c 45 ent.CREATE TABLE
+| 3920: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 't1_content'(do
+| 3936: 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d cid INTEGER PRIM
+| 3952: 41 52 59 20 4b 45 59 2c 20 27 63 30 61 27 2c 20 ARY KEY, 'c0a',
+| 3968: 27 63 31 62 27 2c 20 27 63 32 63 27 29 38 02 06 'c1b', 'c2c')8..
+| 3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52 ...._tablet1t1CR
+| 4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| 4032: 28 61 2c 62 2c 63 29 00 00 00 00 00 00 00 00 00 (a,b,c).........
+| page 3 offset 8192
+| 0: 0d 00 00 00 25 0b 48 00 0f d8 0f af 0f 86 0f 74 ....%.H........t
+| 16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5 .a.N./..........
+| 32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5 ...t.[.@.$......
+| 48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb .......h.O.5....
+| 64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a .......x.W.>.$..
+| 80: 0b 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .H..............
+| 2880: 00 00 00 00 00 00 00 00 81 3f 25 06 00 82 7f 00 .........?%.....
+| 2896: 00 43 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e .COMPILER=gcc-5.
+| 2912: 34 2e 30 20 32 30 31 36 30 36 30 39 20 44 45 42 4.0 20160609 DEB
+| 2928: 55 47 20 45 4e 41 42 4c 45 20 44 42 53 54 41 54 UG ENABLE DBSTAT
+| 2944: 20 56 54 41 42 20 45 4e 41 42 4c 45 20 46 54 53 VTAB ENABLE FTS
+| 2960: 34 20 45 4e 41 42 4c 45 20 46 54 53 35 20 45 4e 4 ENABLE FTS5 EN
+| 2976: 41 42 4c 45 20 47 45 4f 59 0f 4c 59 20 45 4e 41 ABLE GEOY.LY ENA
+| 2992: 42 4c 45 20 4a 53 4f 4e 31 20 45 4e 41 42 4c 45 BLE JSON1 ENABLE
+| 3008: 20 4d 45 4d 53 59 53 35 20 45 4e 41 42 4c 45 20 MEMSYS5 ENABLE
+| 3024: 52 54 52 45 45 20 4d 41 58 20 4d 45 4d 4f 52 59 RTREE MAX MEMORY
+| 3040: 3d 35 30 30 30 30 30 30 30 20 4f 4d 49 54 20 4d =50000000 OMIT M
+| 3056: 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 20 54 48 OAD EXTENSION TH
+| 3072: 52 45 41 44 53 41 46 45 3d 30 18 24 05 00 25 0f READSAFE=0.$..%.
+| 3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49 .THREADSAFE=0XBI
+| 3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41 NARY.#..%..THREA
+| 3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22 DSAFE=0XNOCASE..
+| 3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d ..%..THREADSAFE=
+| 3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d 0XRTRIM.!..3..OM
+| 3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f IT LOAD EXTENSIO
+| 3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f NXBINARY. ..3..O
+| 3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 MIT LOAD EXTENSI
+| 3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 ONXNOCASE....3..
+| 3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 OMIT LOAD EXTENS
+| 3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19 IONXRTRIM....3..
+| 3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30 MAX MEMORY=50000
+| 3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f 000XBINARY....3.
+| 3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 .MAX MEMORY=5000
+| 3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33 0000XNOCASE....3
+| 3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 ..MAX MEMORY=500
+| 3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25 00000XRTRIM....%
+| 3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42 ..ENABLE RTREEXB
+| 3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17 LE RTREEXNOCASE.
+| 3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52 ...%..ENABLE RTR
+| 3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45 EEXRTRIM....)..E
+| 3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49 NABLE MEMSYS5XBI
+| 3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45 E MEMSYS5XNOCASE
+| 3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45 ....)..ENABLE ME
+| 3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25 MSYS5XRTRIM....%
+| 3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42 ..ENABLE JSON1XB
+| 3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42 INARY....%..ENAB
+| 3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17 LE JSON1XNOCASE.
+| 3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f ...%..ENABLE JSO
+| 3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45 N1XRTRIM....)..E
+| 3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49 NABLE GEOPOLYXBI
+| 3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c NARY....)..ENABL
+| 3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45 E GEOPOLYXNOCASE
+| 3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45 ....)..ENABLE GE
+| 3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23 OPOLYXRTRIM....#
+| 3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49 ..ENABLE FTS5XBI
+| 3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c NARY....#..ENABL
+| 3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05 E FTS5XNOCASE...
+| 3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58 .#..ENABLE FTS5X
+| 3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42 RTRIM....#..ENAB
+| 3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b LE FTS4XBINARY..
+| 3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34 ..#..ENABLE FTS4
+| 3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e XNOCASE....#..EN
+| 3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e ABLE FTS4XRTRIM.
+| 3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e TAT VTABXBINARY.
+| 3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d TAT VTABXNOCASE.
+| 3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53 ...1..ENABLE DBS
+| 3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06 TAT VTABXRTRIM..
+| 3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52 .....DEBUGXBINAR
+| 3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f Y.......DEBUGXNO
+| 3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47 CASE.......DEBUG
+| 3968: 58 52 54 52 49 4d 27 03 05 00 43 10 19 43 4f 4d XRTRIM'...C..COM
+| 3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20 PILER=gcc-5.4.0
+| 4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27 20160609XBINARY'
+| 4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67 ...C..COMPILER=g
+| 4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30 cc-5.4.0 2016060
+| 4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43 9XNOCASE&...C..C
+| 4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e OMPILER=gcc-5.4.
+| 4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d 0 20160609XRTRIM
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 02 0b a0 00 0c ad 0b a0 00 00 00 00 ................
+| 2976: 82 0a 02 08 08 09 08 08 17 84 06 30 20 32 35 33 ...........0 253
+| 2992: 00 01 30 04 25 06 1b 00 00 08 32 30 31 36 30 36 ..0.%.....201606
+| 3008: 30 39 03 25 07 00 00 01 34 03 25 05 00 00 01 35 09.%....4.%....5
+| 3024: 03 25 04 00 01 07 30 30 30 30 30 30 30 03 25 1a .%....0000000.%.
+| 3040: 00 00 08 63 6f 6d 70 69 6c 65 72 03 25 02 00 00 ...compiler.%...
+| 3056: 06 64 62 73 74 61 74 03 25 0a 00 01 04 65 62 75 .dbstat.%....ebu
+| 3072: 67 03 25 08 00 00 06 65 6e 61 62 6c 65 09 25 09 g.%....enable.%.
+| 3088: 05 04 04 04 04 04 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3104: 6e 03 25 1d 00 00 04 66 74 73 34 03 25 0d 00 03 n.%....fts4.%...
+| 3120: 01 35 03 25 0f 00 00 03 67 63 63 03 25 03 00 01 .5.%....gcc.%...
+| 3136: 06 65 6f 70 6f 6c 79 03 25 11 00 00 05 6a 73 6f .eopoly.%....jso
+| 3152: 6e 31 03 25 13 00 00 04 6c 6f 61 64 03 25 1c 00 n1.%....load.%..
+| 3168: 00 03 6d 61 78 03 25 18 00 01 05 65 6d 6f 72 79 ..max.%....emory
+| 3184: 03 25 19 00 03 04 73 79 73 35 03 25 15 00 00 04 .%....sys5.%....
+| 3200: 6f 6d 69 74 03 25 1b 00 00 05 72 74 72 65 65 03 omit.%....rtree.
+| 3216: 25 17 00 00 0a 74 68 72 65 61 64 73 61 66 65 03 %....threadsafe.
+| 3232: 25 1e 00 00 04 76 74 61 62 03 25 0b 00 86 50 01 %....vtab.%...P.
+| 3248: 08 08 08 08 08 17 8d 12 30 20 38 33 35 00 01 30 ........0 835..0
+| 3264: 12 01 06 00 01 06 00 01 06 00 1f 03 00 01 03 00 ................
+| 3280: 01 03 00 00 08 32 30 31 36 30 36 30 39 09 01 07 .....20160609...
+| 3296: 00 01 07 00 01 07 00 00 01 34 09 01 05 00 01 05 .........4......
+| 3312: 00 01 05 00 00 01 35 09 01 04 00 01 04 00 01 04 ......5.........
+| 3328: 00 01 07 30 30 30 30 30 30 30 09 1c 04 00 01 04 ...0000000......
+| 3344: 00 01 04 00 00 06 62 69 6e 61 72 79 3c 03 01 02 ......binary<...
+| 3360: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3376: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 5f ..............._
+| 3392: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 ................
+| 3408: 01 02 02 00 03 01 02 02 00 00 08 63 6f 6d 70 69 ...........compi
+| 3424: 6c 65 72 09 01 02 00 01 02 00 01 02 00 00 06 64 ler............d
+| 3440: 62 73 74 61 74 09 07 03 00 01 03 00 01 03 00 01 bstat...........
+| 3456: 04 65 62 75 67 09 04 02 00 01 02 00 01 02 00 00 .ebug...........
+| 3472: 06 65 6e 61 62 6c 65 3f 07 02 00 01 02 00 01 02 .enable?........
+| 3488: 00 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 ................
+| 3504: 01 02 00 01 02 00 01 02 00 01 02 00 01 02 00 01 ................
+| 3520: 02 00 01 01 00 01 02 00 01 02 00 01 02 00 01 02 ................
+| 3536: 00 01 02 00 01 02 00 01 08 78 74 65 6e 73 69 6f .........xtensio
+| 3552: 6e 09 1f 04 00 01 04 00 01 04 00 00 04 66 74 73 n............fts
+| 3568: 34 09 0a 03 00 01 03 00 01 03 00 03 01 35 09 0d 4............5..
+| 3584: 03 00 01 03 00 01 03 00 00 03 67 63 63 09 01 03 ..........gcc...
+| 3600: 00 01 03 00 01 03 00 01 06 65 6f 70 6f 6c 79 09 .........eopoly.
+| 3616: 10 03 00 01 03 00 01 03 00 00 05 6a 73 6f 6e 31 ...........json1
+| 3632: 09 13 03 00 01 03 00 01 03 00 00 04 6c 6f 61 64 ............load
+| 3648: 09 1f 03 00 01 03 00 01 03 00 00 03 6d 61 78 09 ............max.
+| 3664: 1c 02 00 01 02 00 01 02 00 01 05 65 6d 6f 72 79 ...........emory
+| 3680: 09 1c 03 00 01 03 00 01 03 00 03 04 73 79 73 35 ............sys5
+| 3696: 09 16 03 00 01 03 00 01 03 00 00 06 6e 6f 63 61 ............noca
+| 3712: 73 65 3c 02 01 02 02 00 03 01 02 02 00 03 01 02 se<.............
+| 3728: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3744: 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 ................
+| 3760: 03 01 02 02 00 03 01 02 02 00 03 01 02 02 00 00 ................
+| 3776: 04 6f 6d 69 74 09 1f 02 00 01 02 00 01 02 00 00 .omit...........
+| 3792: 05 72 74 72 65 65 09 19 03 00 01 03 00 01 03 00 .rtree..........
+| 3808: 03 02 69 6d 3c 01 01 02 02 00 03 01 02 02 00 03 ..im<...........
+| 3824: 01 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 ................
+| 3840: 02 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 ................
+| 3856: 02 00 03 01 02 02 00 03 01 02 02 00 03 01 02 02 ................
+| 3872: 00 00 0a 74 68 72 65 61 64 73 61 66 65 09 22 02 ...threadsafe...
+| 3888: 00 01 02 00 01 02 00 00 04 76 74 61 62 09 07 04 .........vtab...
+| 3904: 00 01 04 00 01 04 00 00 01 78 b4 01 01 01 01 02 .........x......
+| 3920: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 3936: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 3952: 01 01 03 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 3968: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 3984: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4000: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| 4016: 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 ................
+| 4032: 01 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 ................
+| 4048: 01 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 ................
+| 4064: 02 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 ................
+| 4080: 00 01 01 01 02 00 01 01 01 02 00 01 01 01 02 00 ................
+| page 6 offset 20480
+| 0: 0a 00 00 00 02 0f f5 00 0f fb 0f f5 00 00 00 00 ................
+| 4080: 00 00 00 00 00 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 7 offset 24576
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity-check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end crash-11cf359576eb28.db
+}]} {}
+
+set saved $sqlite_fts3_enable_parentheses
+set sqlite_fts3_enable_parentheses 1
+do_catchsql_test 51.1 {
+ SELECT 'xyzzy',offsets(t1) FROM t1 WHERE t1 MATCH 'rtree OR json1''rtree NEAR "json1 enable"';
+} {1 {database disk image is malformed}}
+set sqlite_fts3_enable_parentheses $saved
+
+#-------------------------------------------------------------------------
+#
+set saved $sqlite_fts3_enable_parentheses
+set sqlite_fts3_enable_parentheses 1
+reset_db
+do_test 52.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 28672 pagesize 4096 filename crash-fd33f4b1c8348b.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 92 00 00 00 07 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 04 ................
+| 96: 00 00 00 00 0d 0e ef 00 08 0d 13 00 0f bd 0f 5f ..............._
+| 112: 0e f7 0e 06 0e bc 0d a4 0d 4d 0d 13 00 00 00 00 .........M......
+| 3344: 00 00 00 38 08 06 17 11 11 08 5f 74 61 62 6c 65 ...8......_table
+| 3360: 74 32 74 32 43 52 45 41 54 45 20 56 49 52 54 55 t2t2CREATE VIRTU
+| 3376: 41 4c 20 54 41 42 4c 45 20 74 32 20 55 53 49 4e AL TABLE t2 USIN
+| 3392: 47 20 66 74 73 34 61 75 78 28 74 31 29 55 07 07 G fts4aux(t1)U..
+| 3408: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 73 74 ......tablet1_st
+| 3424: 61 74 74 31 5f 73 74 61 74 07 43 52 45 41 54 45 att1_stat.CREATE
+| 3440: 20 54 41 42 4c 45 20 27 74 31 5f 73 74 61 74 27 TABLE 't1_stat'
+| 3456: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (id INTEGER PRIM
+| 3472: 41 52 59 20 4b 45 59 2c 20 76 61 6c 75 65 20 42 ARY KEY, value B
+| 3488: 4c 4f 42 29 60 06 07 17 21 21 01 81 0b 74 61 62 LOB)`...!!...tab
+| 3504: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64 let1_docsizet1_d
+| 3520: 6f 63 73 69 7a 65 06 43 52 45 41 54 45 20 54 41 ocsize.CREATE TA
+| 3536: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27 BLE 't1_docsize'
+| 3552: 28 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 (docid INTEGER P
+| 3568: 52 49 4d 41 52 59 20 4b 45 59 2c 20 73 69 7a 65 RIMARY KEY, size
+| 3584: 20 42 4c 4f 42 29 81 33 04 07 17 1f 1f 01 82 35 BLOB).3.......5
+| 3600: 74 61 62 6c 65 74 31 5f 73 65 67 64 69 72 74 31 tablet1_segdirt1
+| 3616: 5f 73 65 67 64 69 72 04 43 52 45 41 54 45 20 54 _segdir.CREATE T
+| 3632: 41 42 4c 45 20 27 74 31 5f 73 65 67 64 69 72 27 ABLE 't1_segdir'
+| 3648: 28 6c 65 76 65 6c 20 49 4e 54 45 47 45 52 2c 69 (level INTEGER,i
+| 3664: 64 78 20 49 4e 64 45 47 45 52 2c 73 74 61 72 74 dx INdEGER,start
+| 3680: 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 6c _block INTEGER,l
+| 3696: 65 61 76 65 73 5f 65 6e 64 5f 62 6c 6f 63 6b 20 eaves_end_block
+| 3712: 49 4e 54 45 47 45 52 2c 65 6e 64 5f 62 6c 6f 63 INTEGER,end_bloc
+| 3728: 6b 20 49 4e 54 45 47 45 52 2c 72 6f 6f 74 20 42 k INTEGER,root B
+| 3744: 4c 4f 42 2c 50 52 49 4d 41 52 59 20 4b 45 59 28 LOB,PRIMARY KEY(
+| 3760: 6c 65 76 65 6c 2c 20 69 64 78 29 29 31 05 06 17 level, idx))1...
+| 3776: 45 1f 01 00 69 6e 64 65 78 73 71 6c 69 74 65 5f E...indexsqlite_
+| 3792: 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 73 65 67 autoindex_t1_seg
+| 3808: 64 69 72 5f 31 74 31 5f 73 65 67 64 69 72 05 00 dir_1t1_segdir..
+| 3824: 00 00 08 00 00 00 00 66 03 07 17 23 23 01 81 13 .......f...##...
+| 3840: 74 61 62 6c 65 74 31 5f 73 65 67 6d 65 6e 74 73 tablet1_segments
+| 3856: 74 31 5f 73 65 67 6d 65 6e 74 73 03 43 52 45 41 t1_segments.CREA
+| 3872: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
+| 3888: 6d 65 6e 74 73 27 28 62 6c 6f 63 6b 69 64 20 49 ments'(blockid I
+| 3904: 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b NTEGER PRIMARY K
+| 3920: 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 5c EY, block BLOB).
+| 3936: 02 07 17 21 21 01 81 03 74 61 62 6c 65 74 31 5f ...!!...tablet1_
+| 3952: 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74 65 6e contentt1_conten
+| 3968: 74 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 t.CREATE TABLE '
+| 3984: 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64 6f 63 69 t1_content'(doci
+| 4000: 64 20 49 4e 54 45 47 45 52 e6 50 52 49 4d 41 52 d INTEGER.PRIMAR
+| 4016: 59 20 4b 45 59 2c 20 27 63 30 61 27 29 41 01 06 Y KEY, 'c0a')A..
+| 4032: 17 11 11 08 71 74 61 62 6c 65 74 31 74 31 43 52 ....qtablet1t1CR
+| 4048: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4064: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 34 LE t1 USING fts4
+| 4080: 28 61 2c 70 72 65 66 69 78 3d 27 31 2c 32 27 29 (a,prefix='1,2')
+| page 2 offset 4096
+| 0: 0d 00 00 00 08 0e 22 00 0f c4 0f 00 00 00 00 00 ................
+| 3616: 00 00 42 08 04 00 81 09 73 75 6e 74 20 69 6e 20 ..B.....sunt in
+| 3632: 63 75 6c 70 61 20 71 75 69 20 6f 66 66 69 63 69 culpa qui offici
+| 3648: 61 20 64 65 73 65 72 75 6e 74 20 6d 6f 6c 6c 69 a deserunt molli
+| 3664: 74 20 61 6e 69 6d 20 69 64 20 65 73 74 20 7c 61 t anim id est |a
+| 3680: 62 6f 72 75 6d 2e 32 07 03 00 6b 45 78 63 65 70 borum.2...kExcep
+| 3696: 74 65 75 72 20 73 69 6e 74 20 6f 63 63 61 65 63 teur sint occaec
+| 3712: 61 74 20 63 75 70 69 64 61 74 61 74 20 6e 6f 6e at cupidatat non
+| 3728: 20 70 72 6f 69 64 65 6e 74 2c 29 06 03 00 59 63 proident,)...Yc
+| 3744: 69 6c 6c 75 6d 20 64 6f 6c 6f 72 65 20 65 20 66 illum dolore e f
+| 3760: 75 67 69 61 74 20 6e 75 6c 6c 61 20 70 61 72 69 ugiat nulla pari
+| 3776: 61 74 75 72 2e 42 05 04 00 81 09 44 75 69 73 20 atur.B.....Duis
+| 3792: 61 75 74 65 20 69 72 75 72 65 20 64 6f 6c 6f 72 aute irure dolor
+| 3808: 20 69 6e 20 72 65 60 72 65 68 65 6e 64 65 72 69 in re`rehenderi
+| 3824: 74 20 69 6e 20 76 70 6c 75 70 74 61 74 65 20 76 t in vpluptate v
+| 3840: 65 6c 69 72 c0 65 73 73 65 29 04 03 00 59 6e 69 elir.esse)...Yni
+| 3856: 73 6a 20 75 74 20 61 6c 69 71 75 69 70 20 65 20 sj ut aliquip e
+| 3872: 65 20 63 6f 6d 6d 6f 64 6f 20 63 6f 6e 73 65 71 e commodo conseq
+| 3888: 75 61 74 2e 46 03 04 00 29 11 55 74 20 65 6e 69 uat.F...).Ut eni
+| 3904: 6d 20 61 64 20 6d 69 6e 69 6d 20 76 65 6e 69 61 m ad minim venia
+| 3920: 6d 2c 20 71 75 69 73 20 6e 6f 73 74 72 75 64 20 m, quis nostrud
+| 3936: 65 78 65 72 63 69 7a 71 74 69 6f 6e 20 75 6c 6c exercizqtion ull
+| 3952: 61 6d 63 6f 20 6c 61 62 6f 72 69 73 46 02 04 00 amco laborisF...
+| 3968: 81 11 73 65 64 20 64 6f 20 65 69 75 73 6d 6f 64 ..sed do eiusmod
+| 3984: 20 74 65 6d 70 6f 72 20 69 6e 63 69 64 69 64 75 tempor incididu
+| 4000: 6e 74 20 75 74 20 6c 61 62 6f 72 65 20 65 74 20 nt ut labore et
+| 4016: 64 6f 6c 6f 72 65 20 6d 61 67 6e 61 20 61 6c 69 dolore magna ali
+| 4032: 71 75 61 2e 3a 01 03 00 7b 4c 6f 72 65 6d 20 69 qua.:....Lorem i
+| 4048: 72 63 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 rcum dolor sit a
+| 4064: 6d 65 74 2c 20 63 6f 6e 78 65 63 74 65 64 75 72 met, conxectedur
+| 4080: 20 61 64 69 70 69 73 00 00 00 00 00 00 00 00 00 adipis.........
+| page 4 offset 12288
+| 0: 0d 00 00 00 03 0a c1 00 0d 61 0c 54 0a c1 00 00 .........a.T....
+| 2752: 00 83 10 03 08 02 08 08 08 17 86 0e 08 00 30 20 ..............0
+| 2768: 33 38 35 00 02 61 64 06 01 08 00 02 04 00 01 01 385..ad.........
+| 2784: 6c 06 02 0c 00 02 04 00 01 01 6d 03 01 06 10 01 l.........m.....
+| 2800: 01 6e 03 08 09 00 01 01 75 03 05 03 00 00 02 63 .n......u......c
+| 2816: 69 03 06 02 00 01 01 6f 07 01 07 00 03 07 03 00 i......o........
+| 2832: 01 01 75 06 75 05 00 01 04 00 00 02 64 65 03 08 ..u.u.......de..
+| 2848: 07 00 01 01 6f 0d 01 04 00 01 03 09 00 03 05 00 ....o...........
+| 2864: 01 03 00 01 01 75 03 05 02 00 00 02 65 69 03 02 .....u......ei..
+| 2880: 04 00 01 01 6c 03 01 44 00 01 01 6e 03 03 03 00 ....l..D...n....
+| 2896: 01 01 73 06 05 0b 00 03 0b 00 01 01 74 03 02 09 ..s.........t...
+| 2912: 00 01 01 78 06 03 09 00 04 02 00 00 02 66 75 03 ...x.........fu.
+| 2928: 06 05 00 00 02 69 64 03 08 0a 00 01 01 6e 0a 02 .....id......n..
+| 2944: 06 00 03 06 04 00 03 03 00 01 01 70 03 01 03 00 ...........p....
+| 2960: 01 01 72 03 05 04 00 00 02 6c 61 09 02 08 00 01 ..r......la.....
+| 2976: 0b 00 05 0c 00 01 01 6f 03 01 02 00 00 02 6d 61 .......o......ma
+| 2992: 03 02 0b 00 01 01 69 03 03 05 00 01 01 6f 03 08 ......i......o..
+| 3008: 08 00 00 02 6e 69 03 04 02 00 01 01 6f 06 03 08 ....ni......o...
+| 3024: 00 04 06 00 01 01 75 03 06 06 00 00 02 6f 63 03 ......u......oc.
+| 3040: 07 04 00 01 01 66 03 08 06 00 00 02 70 61 03 06 .....f......pa..
+| 3056: 07 00 01 11 72 03 07 07 00 00 02 71 75 06 03 07 ....r......qu...
+| 3072: 00 05 05 00 00 02 72 65 03 05 07 00 00 02 73 65 ......re......se
+| 3088: 03 02 02 00 01 01 69 06 01 05 00 06 03 00 01 01 ......i.........
+| 3104: 75 03 08 02 00 00 02 74 65 03 02 05 00 00 02 75 u......te......u
+| 3120: 6c 13 03 0a 00 01 01 74 09 02 07 00 01 02 00 01 l......t........
+| 3136: 02 ff ff 02 76 65 06 03 06 00 02 0a 00 01 01 6f ....ve.........o
+| 3152: 03 05 09 00 82 0a 02 08 02 08 08 08 17 84 02 04 ................
+| 3168: 00 30 20 32 35 31 00 01 61 13 01 06 04 00 01 0c .0 251..a.......
+| 3184: 00 01 04 00 01 04 00 01 03 00 03 09 00 00 01 63 ...............c
+| 3200: 10 01 07 00 03 07 03 00 02 02 00 01 05 00 01 04 ................
+| 3216: 00 00 01 64 11 01 04 00 01 03 09 00 03 02 05 00 ...d............
+| 3232: 01 03 00 02 07 00 00 01 65 1b 01 09 00 01 04 07 ........e.......
+| 3248: 00 01 03 08 00 01 05 03 00 01 1c eb 01 04 00 01 ................
+| 3264: 0e 80 01 0b 00 00 01 66 03 06 05 00 00 01 69 0f .......f......i.
+| 3280: 01 03 00 01 06 0b 23 04 04 04 00 03 03 09 00 00 ......#.........
+| 3296: 01 6c 0c 01 02 00 01 08 00 01 0b 00 05 0c 00 00 .l..............
+| 3312: 01 6d 09 02 0b 00 01 05 00 05 08 00 00 01 6e 0c .m............n.
+| 3328: 03 08 00 01 02 00 02 06 00 01 06 00 00 01 6f 06 ..............o.
+| 3344: 07 04 00 01 06 00 00 01 70 06 06 07 00 01 07 00 ........p.......
+| 3360: 00 01 71 06 03 07 00 05 05 00 00 01 72 03 05 07 ..q.........r...
+| 3376: 00 00 02 73 0c 01 05 00 01 02 00 05 03 00 01 02 ...s............
+| 3392: 00 00 01 74 03 02 05 00 00 01 75 0a 02 07 00 01 ...t......u.....
+| 3408: 02 0a 00 01 03 00 00 01 76 07 03 06 00 02 09 03 ........v.......
+| 3424: 00 85 1c 01 08 08 08 08 08 17 8a 2a 30 20 36 35 ...........*0 65
+| 3440: 35 00 02 61 64 03 03 04 00 02 08 69 70 69 73 63 5..ad......ipisc
+| 3456: 69 6e 67 03 01 08 00 01 05 6c 69 71 75 61 03 02 ing......liqua..
+| 3472: 0c 00 05 02 69 70 03 04 04 00 01 03 6d 65 74 03 ....ip......met.
+| 3488: 01 06 00 01 03 6e 69 6d 03 08 09 00 01 03 75 74 .....nim......ut
+| 3504: 65 03 05 03 00 00 06 63 69 6c 6c 75 6d 03 06 02 e......cillum...
+| 3520: 00 01 06 6f 6d 6d 6f 64 6f 03 04 07 00 02 09 6e ...ommodo......n
+| 3536: 73 65 63 74 65 74 75 72 03 01 07 00 05 04 71 75 sectetur......qu
+| 3552: 61 73 03 04 08 00 01 04 75 6c 70 61 03 08 04 00 as......ulpa....
+| 3568: 02 07 70 69 64 61 74 61 74 03 07 05 00 00 08 64 ..pidatat......d
+| 3584: 65 73 65 72 75 6e 74 03 08 07 00 01 01 6f 03 09 eserunt......o..
+| 3600: b3 00 02 03 6c 6f 72 06 01 04 00 04 05 00 05 01 ....lor.........
+| 3616: 65 06 02 0a 00 04 03 00 01 03 75 69 73 03 05 02 e.........uis...
+| 3632: 00 00 01 65 07 04 05 03 00 02 04 00 01 06 69 75 ...e..........iu
+| 3648: 73 6d 6f 64 03 02 04 00 01 03 6c 69 74 03 01 09 smod......lit...
+| 3664: 00 01 03 6e 69 6d 03 03 03 00 01 03 73 73 65 03 ...nim......sse.
+| 3680: 05 0b 00 02 01 74 03 08 0b 00 01 01 74 03 02 09 .....t......t...
+| 3696: 00 01 08 78 63 65 70 64 65 75 72 03 07 02 00 02 ...xcepdeur.....
+| 3712: 0a 65 72 63 69 74 61 74 69 6f 6e 03 03 09 00 00 .ercitation.....
+| 3728: 06 66 75 67 69 61 74 03 06 05 00 00 02 69 64 03 .fugiat......id.
+| 3744: 08 0a 00 01 01 6e 07 05 06 04 00 03 03 00 02 08 .....n..........
+| 3760: 63 69 64 69 64 75 6e 74 03 02 06 00 01 04 70 73 cididunt......ps
+| 3776: 75 6c f3 01 03 00 01 04 72 75 72 65 03 05 04 00 ul......rure....
+| 3792: 00 06 6c 61 62 6f 72 65 03 02 08 00 05 02 69 73 ..labore......is
+| 3808: 03 03 0b 00 05 02 75 6d 03 08 0c 00 01 04 6f 72 ......um......or
+| 3824: 65 6d 03 01 02 00 00 05 6d 61 67 6e 61 03 02 0b em......magna...
+| 3840: 00 01 04 69 6e 69 6d 03 03 05 00 01 05 6f 6c 6c ...inim......oll
+| 3856: 69 74 03 08 08 00 00 04 6e 69 73 69 03 04 02 00 it......nisi....
+| 3872: 01 02 6f 6e 03 07 06 00 02 05 73 74 72 75 64 03 ..on......strud.
+| 3888: 03 08 00 01 04 75 6c 6c 61 03 06 06 00 00 08 6f .....ulla......o
+| 3904: 63 63 61 65 63 61 74 03 07 04 00 01 06 66 66 69 ccaecat......ffi
+| 3920: 63 69 61 03 08 06 00 00 08 70 61 72 69 61 74 75 cia......pariatu
+| 3936: 72 03 06 07 00 01 07 72 6f 69 64 65 6e 74 03 07 r......roident..
+| 3952: 07 00 00 03 71 75 69 03 08 15 00 03 01 73 03 03 ....qui......s..
+| 3968: 07 00 00 0d 72 65 70 72 65 68 65 6e 64 65 72 69 ....reprehenderi
+| 3984: 74 03 05 07 00 00 03 73 65 64 03 02 01 ff ff f0 t......sed......
+| 4000: b9 6e 74 03 07 03 00 02 01 74 03 01 05 00 01 03 .nt......t......
+| 4016: 75 6e 74 03 08 02 00 00 06 74 65 6d 70 6f 72 03 unt......tempor.
+| 4032: 02 05 00 00 07 75 6c 6c 61 6d 63 6f 03 03 0a 00 .....ullamco....
+| 4048: 01 01 74 09 02 07 00 01 02 00 01 03 00 00 05 76 ..t............v
+| 4064: 65 6c 69 74 03 05 0a 00 02 04 6e 69 61 6d 03 03 elit......niam..
+| 4080: 06 00 01 08 6f 6c 75 70 74 61 74 65 03 05 09 00 ....oluptate....
+| page 5 offset 16384
+| 0: 0a 00 00 00 03 0f eb 00 0f fb 0f f3 00 00 00 00 ................
+| 4064: 00 00 00 00 00 00 00 00 00 00 00 07 04 02 08 01 ................
+| 4080: 08 00 03 07 04 02 08 01 04 00 02 04 04 08 08 09 ................
+| page 6 offset 20480
+| 0: 0d 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................
+| 4048: 04 08 03 00 0e 0b 04 07 03 00 0e 06 04 06 03 00 ................
+| 4064: 0e 06 04 05 03 00 0e 0a 04 04 03 00 0e 07 04 03 ................
+| 4080: 03 00 0d fa 04 02 03 00 0e 0b 04 00 00 00 00 00 ................
+| page 7 offset 24576
+| 4080: 00 00 00 00 00 00 00 07 00 03 00 00 00 00 00 00 ................
+| end crash-fd33f4b1c8348b.db
+}]} {}
+
+do_catchsql_test 52.1 {
+ SELECT * FROM t1, t2;
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 53.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 8192 pagesize 1024 filename crash-7bc.txt.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 04 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 02 f3 00 07 01 51 00 03 c8 03 63 ..........Q....c
+| 112: 02 fb 02 0a 02 c0 01 a8 01 51 00 00 00 00 00 00 .........Q......
+| 336: 00 55 07 07 17 1b 1b 01 81 01 74 61 62 6c 65 74 .U........tablet
+| 352: 31 5f 73 74 61 74 74 31 5f 73 74 61 74 07 43 52 1_statt1_stat.CR
+| 368: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 384: 74 61 74 27 28 69 64 20 49 4e 54 45 47 45 52 20 tat'(id INTEGER
+| 400: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 61 6c PRIMARY KEY, val
+| 416: 75 65 20 42 4c 4f 42 29 60 06 07 17 21 21 01 81 ue BLOB)`...!!..
+| 432: 0b 74 61 62 6c 65 74 31 5f 64 6f 63 73 69 7a 65 .tablet1_docsize
+| 448: 74 31 5f 64 6f 63 73 69 7a 65 06 43 52 45 41 54 t1_docsize.CREAT
+| 464: 45 20 54 41 42 4c 45 20 27 74 31 5f 64 6f 63 73 E TABLE 't1_docs
+| 480: 69 7a 65 27 28 64 6f 63 69 64 20 49 4e 54 45 47 ize'(docid INTEG
+| 496: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 ER PRIMARY KEY,
+| 512: 73 69 7a 65 20 42 4c 4f 42 29 81 33 04 07 17 1f size BLOB).3....
+| 528: 1f 01 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 ...5tablet1_segd
+| 544: 69 72 74 31 5f 73 65 67 64 69 72 04 43 52 45 41 irt1_segdir.CREA
+| 560: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
+| 576: 64 69 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 dir'(level INTEG
+| 592: 45 52 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 ER,idx INTEGER,s
+| 608: 74 61 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 tart_block INTEG
+| 624: 45 52 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c ER,leaves_end_bl
+| 640: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f ock INTEGER,end_
+| 656: 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f block INTEGER,ro
+| 672: 6f 74 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 ot BLOB,PRIMARY
+| 688: 4b 45 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 KEY(level, idx))
+| 704: 31 05 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 1...E...indexsql
+| 720: 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 ite_autoindex_t1
+| 736: 5f 73 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 _segdir_1t1_segd
+| 752: 69 72 05 00 00 00 08 00 00 00 00 66 03 07 17 23 ir.........f...#
+| 768: 23 01 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d #...tablet1_segm
+| 784: 65 6e 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 03 entst1_segments.
+| 800: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 CREATE TABLE 't1
+| 816: 5f 73 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b _segments'(block
+| 832: 69 64 20 49 4e 53 45 47 45 52 20 50 52 49 4d 41 id INSEGER PRIMA
+| 848: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c RY KEY, block BL
+| 864: 4f 42 29 63 02 07 17 21 21 01 81 11 74 61 62 6c OB)c...!!...tabl
+| 880: 65 74 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f et1_contentt1_co
+| 896: 6e 74 65 6e 74 02 43 52 45 41 54 45 20 54 41 42 ntent.CREATE TAB
+| 912: 4c 45 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 LE 't1_content'(
+| 928: 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 docid INTEGER PR
+| 944: 49 4d 41 52 59 20 4b 45 59 2c 20 27 63 30 30 27 IMARY KEY, 'c00'
+| 960: 2c 20 27 63 31 62 27 29 36 01 06 17 11 11 08 5b , 'c1b')6......[
+| 976: 74 61 62 6c 65 74 31 74 31 43 52 45 41 54 45 20 tablet1t1CREATE
+| 992: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31 VIRTUAL TABLE t1
+| 1008: 20 55 53 49 4e 47 20 66 74 73 34 28 30 2c 62 29 USING fts4(0,b)
+| page 2 offset 1024
+| 0: 0d 00 00 00 03 00 0f 00 00 23 00 16 00 0f 00 05 .........#......
+| 16: 03 04 00 08 0f 61 0b 02 04 00 08 1b 41 54 45 20 .....a......ATE
+| 32: 32 3a 50 87 5a 01 05 00 08 8f 37 66 30 30 30 30 2:P.Z.....7f0000
+| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 256: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 496: 30 40 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0@00000000000000
+| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 880: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 896: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 912: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 1008: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| page 3 offset 2048
+| 0: 0d 00 00 00 02 03 86 00 03 f4 03 86 00 00 00 00 ................
+| 896: 00 00 00 00 00 00 87 62 02 04 00 8f 48 00 d5 07 .......b....H...
+| 912: 66 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 f000000000000000
+| 928: 30 30 30 30 3a 30 30 30 30 30 30 30 30 30 30 30 0000:00000000000
+| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 1008: 00 00 00 08 0a 01 03 00 1a 00 01 30 03 01 02 00 ...........0....
+| page 4 offset 3072
+| 0: 0d 00 00 00 03 03 9e 00 03 ed 03 bc 03 9e 00 00 ................
+| 912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c 03 ................
+| 928: 07 08 01 08 08 15 2c 02 30 20 31 36 00 01 30 03 ......,.0 16..0.
+| 944: 03 02 00 00 01 61 05 03 01 01 02 00 2f 02 07 08 .....a....../...
+| 960: 09 08 08 15 54 30 20 33 36 00 01 30 03 02 02 00 ....T0 36..0....
+| 976: 00 01 32 05 02 01 01 03 00 00 03 61 74 65 05 02 ..2........ate..
+| 992: 01 01 02 00 00 01 70 05 02 01 01 04 00 11 01 07 ......p.........
+| 1008: 08 08 09 01 17 14 02 32 20 39 39 37 01 01 01 66 .......2 997...f
+| page 5 offset 4096
+| 0: 0a 00 00 00 03 03 ee 00 03 fb 03 f5 03 ee 00 00 ................
+| 992: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 04 ................
+| 1008: 08 01 01 02 03 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 6 offset 5120
+| 0: 0d 00 00 00 03 03 eb 00 00 00 00 00 00 00 00 00 ................
+| 992: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10 ................
+| 1008: 01 01 05 02 03 00 10 01 03 05 01 03 00 10 01 01 ................
+| page 7 offset 6144
+| 0: 0d 00 00 00 01 03 f6 00 03 f6 00 00 00 00 00 00 ................
+| 1008: 00 00 00 00 00 00 08 00 03 00 16 03 08 c5 e0 07 ................
+| page 8 offset 7168
+| 0: 00 00 00 00 30 30 30 30 30 30 30 30 30 30 30 30 ....000000000000
+| 16: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 32: 30 30 30 30 30 30 30 30 30 30 30 30 30 bc 30 30 0000000000000.00
+| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 c0 30 00000000000000.0
+| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 256: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 496: 30 30 30 30 30 30 30 30 30 30 30 40 30 30 30 30 00000000000@0000
+| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 880: 30 30 30 30 30 30 30 30 30 05 01 00 00 00 00 00 000000000.......
+| end crash-7bc.txt.db
+}]} {}
+
+do_execsql_test 53.1 {
+ SELECT*FROM t1 WHERE t1 MATCH'ATE"0"OR"2D:P"""ATE"0"OR"2:P"""';
+} {0 {ATE 2:P}}
+set sqlite_fts3_enable_parentheses $saved
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 54.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+.open --hexdb
+| size 8192 pagesize 1024 filename crash-365.txt.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 04 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
+| 96: 00 00 00 00 0d 02 f3 00 07 01 51 00 03 c8 03 63 ..........Q....c
+| 112: 02 fb 02 0a 02 c0 01 a8 01 51 00 00 00 00 00 00 .........Q......
+| 336: 00 55 07 07 17 1b 1b 01 81 01 74 61 62 6c 65 74 .U........tablet
+| 352: 31 5f 73 74 61 74 74 31 5f 73 74 61 74 07 43 52 1_statt1_stat.CR
+| 368: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
+| 384: 74 61 74 27 28 69 64 20 49 4e 54 45 47 45 52 20 tat'(id INTEGER
+| 400: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 61 6c PRIMARY KEY, val
+| 416: 75 65 20 42 4c 4f 42 29 60 06 07 17 21 21 01 81 ue BLOB)`...!!..
+| 432: 0b 74 61 62 6c 65 74 31 5f 64 6f 63 73 69 7a 65 .tablet1_docsize
+| 448: 74 31 5f 64 6f 63 73 69 7a 65 06 43 52 45 41 54 t1_docsize.CREAT
+| 464: 45 20 54 41 42 4c 45 20 27 74 31 5f 64 6f 63 73 E TABLE 't1_docs
+| 480: 69 7a 65 27 28 64 6f 63 69 64 20 49 4e 54 45 47 ize'(docid INTEG
+| 496: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 ER PRIMARY KEY,
+| 512: 73 69 7a 65 20 42 4c 4f 42 29 81 33 04 07 17 1f size BLOB).3....
+| 528: 1f 01 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 ...5tablet1_segd
+| 544: 69 72 74 31 5f 73 65 67 64 69 72 04 43 52 45 41 irt1_segdir.CREA
+| 560: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
+| 576: 64 69 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 dir'(level INTEG
+| 592: 45 52 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 ER,idx INTEGER,s
+| 608: 74 61 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 tart_block INTEG
+| 624: 45 52 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c ER,leaves_end_bl
+| 640: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f ock INTEGER,end_
+| 656: 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f block INTEGER,ro
+| 672: 6f 74 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 ot BLOB,PRIMARY
+| 688: 4b 45 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 KEY(level, idx))
+| 704: 31 05 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 1...E...indexsql
+| 720: 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 ite_autoindex_t1
+| 736: 5f 73 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 _segdir_1t1_segd
+| 752: 69 72 05 00 00 00 08 00 00 00 00 66 03 07 17 23 ir.........f...#
+| 768: 23 01 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d #...tablet1_segm
+| 784: 65 6e 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 03 entst1_segments.
+| 800: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 CREATE TABLE 't1
+| 816: 5f 73 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b _segments'(block
+| 832: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 id INTEGER PRIMA
+| 848: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c RY KEY, block BL
+| 864: 4f 42 29 63 02 07 17 21 21 01 81 11 74 61 62 6c OB)c...!!...tabl
+| 880: 65 74 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f et1_contentt1_co
+| 896: 6e 74 65 6e 74 02 43 52 45 41 54 45 20 54 41 42 ntent.CREATE TAB
+| 912: 4c 45 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 LE 't1_content'(
+| 928: 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 docid INTEGER PR
+| 944: 49 4d 41 52 59 20 4b 45 59 2c 20 27 63 30 30 27 IMARY KEY, 'c00'
+| 960: 2c 20 27 63 31 62 27 29 36 01 06 17 11 11 08 5b , 'c1b')6......[
+| 976: 74 61 62 6c 65 74 31 74 31 43 52 45 41 54 45 20 tablet1t1CREATE
+| 992: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31 VIRTUAL TABLE t1
+| 1008: 20 55 53 49 4e 47 20 66 74 73 34 28 30 2c 62 29 USING fts4(0,b)
+| page 2 offset 1024
+| 0: 0d 00 00 00 03 00 0f 00 00 23 00 16 00 0f 00 05 .........#......
+| 16: 03 04 00 08 0f 61 0b 02 04 00 08 1b 41 54 45 20 .....a......ATE
+| 32: 32 3a 50 87 5a 01 05 00 08 8f 37 66 30 30 30 30 2:P.Z.....7f0000
+| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 256: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 496: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 624: 30 30 30 30 30 30 30 30 30 30 1b 30 30 30 30 30 0000000000.00000
+| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 688: 30 30 30 30 30 30 30 30 2f 30 30 30 30 30 30 30 00000000/0000000
+| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 880: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 896: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 912: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 1008: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| page 3 offset 2048
+| 0: 0d 00 00 00 02 03 86 00 03 f4 03 86 00 00 00 00 ................
+| 896: 00 00 00 00 00 00 87 62 02 04 00 8f 48 00 d5 07 .......b....H...
+| 912: 66 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 f000000000000000
+| 928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 1008: 00 00 00 08 0a 01 03 00 1a 00 01 30 03 01 02 00 ...........0....
+| page 4 offset 3072
+| 0: 0d 00 00 00 03 03 9e 00 03 ed 03 bc 03 9e 00 01 ................
+| 912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c 03 ................
+| 928: 07 08 01 08 08 15 2c 02 30 20 31 36 00 01 30 03 ......,.0 16..0.
+| 944: 03 02 00 00 01 61 05 03 01 01 02 00 2f 02 07 08 .....a....../...
+| 960: 09 08 08 15 54 30 20 33 36 00 01 30 03 02 02 00 ....T0 36..0....
+| 976: 00 01 32 05 02 01 01 03 00 00 03 61 74 65 05 02 ..2........ate..
+| 992: 01 01 02 00 00 01 70 05 02 01 01 04 00 11 01 07 ......p.........
+| 1008: 08 08 09 01 17 14 02 32 20 39 39 37 01 01 01 66 .......2 997...f
+| page 5 offset 4096
+| 0: 0a 00 00 00 03 03 ee 00 03 fb 03 f5 03 ee 00 00 ................
+| 992: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 04 ................
+| 1008: 08 01 01 02 03 05 04 08 09 01 02 04 04 08 08 09 ................
+| page 6 offset 5120
+| 0: 0d 00 00 00 03 03 eb 00 03 f9 03 f2 00 00 00 00 ................
+| 992: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10 ................
+| 1008: 01 01 05 02 03 00 10 01 03 05 01 03 00 10 01 01 ................
+| page 7 offset 6144
+| 0: 0d 00 00 00 01 03 f6 00 03 f6 00 00 00 00 00 00 ................
+| 1008: 00 00 00 00 00 00 08 00 03 00 16 03 03 05 e0 07 ................
+| page 8 offset 7168
+| 0: 00 00 00 00 30 30 30 30 30 30 30 30 30 30 30 30 ....000000000000
+| 16: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 32: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 256: 30 30 30 30 30 2f 30 30 30 30 30 30 30 30 30 30 00000/0000000000
+| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 496: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
+| 880: 30 30 30 30 30 30 30 30 30 05 01 01 01 02 00 00 000000000.......
+| end crash-365.txt.db
+}]} {}
+
+do_execsql_test 54.1 {
+ SELECT rowid, quote(matchinfo(t1,'pcxybspcxybs')) FROM t1 WHERE t1 MATCH'ATE"0"OR"2:P"""';
+}
+
+finish_test
diff --git a/test/fts3corrupt5.test b/test/fts3corrupt5.test
new file mode 100644
index 0000000..a8a3b01
--- /dev/null
+++ b/test/fts3corrupt5.test
@@ -0,0 +1,59 @@
+# 2019 May 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
+source $testdir/fts3_common.tcl
+set testprefix fts3corrupt5
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+sqlite3_fts3_may_be_corrupt 1
+
+do_execsql_test 1.0 {
+ BEGIN;
+ CREATE VIRTUAL TABLE ft USING fts3(a, b, c);
+ INSERT INTO ft VALUES('one', 'one', 'one');
+ COMMIT;
+}
+
+do_execsql_test 1.1 {
+ SELECT * FROM ft WHERE ft MATCH 'b:one'
+} {one one one}
+
+do_execsql_test 1.2 {
+ SELECT quote(root) FROM ft_segdir;
+} {X'00036F6E6509010201010201020200'}
+
+breakpoint
+foreach {tn val q bCorrupt} {
+ 1 X'00036F6E650901' 'b:one' 1
+ 2 X'00036F6E6509010201010201FFFFFF' 'c:one' 1
+ 3 X'00036F6E6501' 'b:one' 1
+ 4 X'00036F6E650101' 'b:one' 1
+ 5 X'00036F6E650100' 'b:one' 0
+} {
+ do_execsql_test 1.3.$tn.1 "UPDATE ft_segdir SET root = $val"
+
+ set res {0 {}}
+ if {$bCorrupt} { set res {1 {database disk image is malformed}}}
+ do_catchsql_test 1.3.$tn.2 {
+ SELECT * FROM ft WHERE ft MATCH $q
+ } $res
+}
+
+finish_test
diff --git a/test/fts3corrupt6.test b/test/fts3corrupt6.test
new file mode 100644
index 0000000..a3c5fd8
--- /dev/null
+++ b/test/fts3corrupt6.test
@@ -0,0 +1,79 @@
+# 2020 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 script is testing the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+set testprefix fts3corrupt6
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+set ::saved_sqlite_fts3_enable_parentheses $::sqlite_fts3_enable_parentheses
+set sqlite_fts3_enable_parentheses 1
+sqlite3_fts3_may_be_corrupt 1
+database_may_be_corrupt
+
+do_execsql_test 1.0 {
+ BEGIN TRANSACTION;
+ CREATE TABLE t_content(col0 INTEGER);
+ PRAGMA writable_schema=ON;
+ CREATE VIRTUAL TABLE t0 USING fts3(col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY);
+ INSERT INTO t0_content VALUES(0,NULL,NULL,NULL,NULL);
+ INSERT INTO t0_segdir VALUES(0,0,0,0,'0 42',X'000131030102000103323334050101010200000461616161050101020200000462626262050101030200');
+ COMMIT;
+}
+
+do_execsql_test 1.1 {
+ SELECT 0+matchinfo(t0,'yxyyxy') FROM t0 WHERE t0 MATCH CAST( x'2b0a312b0a312a312a2a0b5d0a0b0b0a312a0a0b0b0a312a0b310a392a0b0a27312a2a0b5d0a312a0b310a31315d0b310a312a316d2a0b313b15bceaa50a312a0b0a27312a2a0b5d0a312a0b310a312b0b2a310a312a0b2a0b2a0b2e5d0a0bff313336e34a2a312a0b0a3c310b0a0b4b4b0b4b2a4bec40322b2a0b310a0a312a0a0a0a0a0a0a0a0a0b310a312a2a2a0b5d0a0b0b0a312a0b310a312a0b0a4e4541530b310a5df5ced70a0a0a0a0a4f520a0a0a0a0a0a0a312a0b0a4e4541520b310a5d616161610a0a0a0a4f520a0a0a0a0a0a312b0a312a312a0a0a0a0a0a0a004a0b0a310b220a0b0a310a4a22310a0b0a7e6fe0e0e030e0e0e0e0e01176e02000e0e0e0e0e01131320226310a0b0a310a4a22310a0b0a310a766f8b8b4ee0e0300ae0090909090909090909090909090909090909090909090909090909090909090947aaaa540b09090909090909090909090909090909090909090909090909090909090909fae0e0f2f22164e0e0f273e07fefefef7d6dfafafafa6d6d6d6d' AS TEXT);
+} {0}
+
+do_execsql_test 1.2 {
+ CREATE VIRTUAL TABLE t1 USING fts3(col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY);
+ INSERT INTO t1_content VALUES(0,NULL,NULL,NULL,NULL);
+ INSERT INTO t1_segdir VALUES(0,0,0,0,'0 42',X'000131030102000103323334050101010200000461616161050101020200000462626262050101030200');
+}
+
+do_execsql_test 1.3 {
+ SELECT 42+matchinfo(t1,'yxyyxy') FROM t1 WHERE t1 MATCH x'2b0a312b0a312a312a2a0b5d0a0b0b0a312a0a0b0b0a312a0b310a392a0b0a27312a2a0b5d0a312a0b310a31315d0b310a312a316d2a0b313b15bceaa50a312a0b0a27312a2a0b5d0a312a0b310a312b0b2a310a312a0b2a0b2a0b2e5d0a0bff313336e34a2a312a0b0a3c310b0a0b4b4b0b4b2a4bec40322b2a0b310a0a312a0a0a0a0a0a0a0a0a0b310a312a2a2a0b5d0a0b0b0a312a0b310a312a0b0a4e4541530b310a5df5ced70a0a0a0a0a4f520a0a0a0a0a0a0a312a0b0a4e4541520b310a5d616161610a0a0a0a4f520a0a0a0a0a0a312b0a312a312a0a0a0a0a0a0a004a0b0a310b220a0b0a310a4a22310a0b0a7e6fe0e0e030e0e0e0e0e01176e02000e0e0e0e0e01131320226310a0b0a310a4a22310a0b0a310a766f8b8b4ee0e0300ae0090909090909090909090909090909090909090909090909090909090909090947aaaa540b09090909090909090909090909090909090909090909090909090909090909fae0e0f2f22164e0e0f273e07fefefef7d6dfafafafa6d6d6d6d';
+} {42}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE t0 USING fts3(a);
+ INSERT INTO t0_segdir VALUES(0,0,0,0,'0 42',X'000131030782000103323334050100fff200010461616161050101020200000462626262050101030200');
+}
+do_execsql_test 2.1 {
+ SELECT count(*) FROM t0 WHERE t0 MATCH '(1 NEAR 1) AND (aaaa OR 1)';
+} 1
+
+#-------------------------------------------------------------------------
+reset_db
+breakpoint
+do_catchsql_test 3.0 {
+ CREATE VIRTUAL TABLE main.Table0 USING fts3();
+ INSERT INTO Table0 VALUES (1), (printf('%8.1280000X') ), (1), (printf('%8.1280000X') ), (1) ;
+ INSERT INTO Table0 VALUES (0), (printf('%8.1280000X%8.1280000X') ), (1), (printf('%1280000.1280000X%#1280000.1280000E%8.1280000X') ), (1) ;
+ INSERT INTO Table0 VALUES (1) ;
+ UPDATE Table0_segdir SET start_block = 1;
+ INSERT INTO Table0 VALUES (1) ;
+ INSERT INTO Table0(Table0) VALUES('merge=6,8');
+} {1 {database disk image is malformed}}
+
+set sqlite_fts3_enable_parentheses $saved_sqlite_fts3_enable_parentheses
+finish_test
diff --git a/test/fts3cov.test b/test/fts3cov.test
new file mode 100644
index 0000000..5d83836
--- /dev/null
+++ b/test/fts3cov.test
@@ -0,0 +1,434 @@
+# 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:
+sqlite3_db_config db DEFENSIVE 0
+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*'
+} {database disk image is malformed}
+
+# 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'
+} {database disk image is malformed}
+
+#--------------------------------------------------------------------------
+# 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}
+do_error_test fts3cov-9.3 {
+ INSERT INTO xx(xx) VALUES('short');
+} {SQL logic error}
+do_error_test fts3cov-9.4 {
+ INSERT INTO xx(xx) VALUES('waytoolongtobecorrect');
+} {SQL logic error}
+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.
+#
+sqlite3_db_config db DEFENSIVE 0
+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..b0547ce
--- /dev/null
+++ b/test/fts3d.test
@@ -0,0 +1,372 @@
+# 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}]
+
+db eval {SELECT c FROM t1 }
+check_terms_all fts3d-4.1 {a four is test that this 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 test that this 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 {[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.
+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.
+sqlite3_db_config db DEFENSIVE 0
+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}
+
+# ALTER TABLE RENAME on an FTS3 table following an incr-merge op.
+#
+do_test fts3d-6.6 {
+ execsql { INSERT INTO xyz(xyz) VALUES('merge=2,2') }
+ sqlite3 db test.db
+ execsql {
+ ALTER TABLE xyz RENAME TO ott;
+ SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
+ }
+} {ott_content ott_segdir ott_segments ott_stat}
+
+
+finish_test
diff --git a/test/fts3defer.test b/test/fts3defer.test
new file mode 100644
index 0000000..5d8395a
--- /dev/null
+++ b/test/fts3defer.test
@@ -0,0 +1,531 @@
+# 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||!fts4_deferred {
+ 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
+
+sqlite3_db_config db DEFENSIVE 0
+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
+ sqlite3_db_config db DEFENSIVE 0
+ 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')"
+ sqlite3_db_config db DEFENSIVE 0
+ 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
+ sqlite3_db_config db DEFENSIVE 0
+ 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}}
+
+set tokenizers {1 simple}
+ifcapable icu { lappend tokenizers 2 {icu en_US} }
+foreach {tn tokenizer} $tokenizers {
+ do_execsql_test 5.$tn.1 "
+ CREATE VIRTUAL TABLE x3 USING FTS4(a, b, TOKENIZE $tokenizer)
+ "
+ do_execsql_test 5.$tn.2 {
+ BEGIN;
+ INSERT INTO x3 VALUES('b b b b b b b b b b b', 'b b b b b b b b b b b b b');
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 SELECT * FROM x3;
+ INSERT INTO x3 VALUES('a b c', NULL);
+ INSERT INTO x3 VALUES('a x c', NULL);
+ COMMIT;
+
+ SELECT * FROM x3 WHERE x3 MATCH 'a b';
+ } {{a b c} {}}
+
+ do_execsql_test 5.$tn.3 { DROP TABLE x3 }
+}
+
+finish_test
diff --git a/test/fts3defer2.test b/test/fts3defer2.test
new file mode 100644
index 0000000..46b62b9
--- /dev/null
+++ b/test/fts3defer2.test
@@ -0,0 +1,165 @@
+# 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||!fts4_deferred {
+ 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');
+}
+sqlite3_db_config db DEFENSIVE 0
+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;
+ }
+} {
+ sqlite3_db_config db DEFENSIVE 0
+ 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.2.$tn.4 {
+ SELECT mit(matchinfo(t2, 'x')) FROM t2 WHERE t2 MATCH 'e "g z"';
+ } [list \
+ [list 1 2 2 1 2 2] \
+ ]
+}
+
+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;
+ }
+} {
+ sqlite3_db_config db DEFENSIVE 0
+ 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/fts3defer3.test b/test/fts3defer3.test
new file mode 100644
index 0000000..a795e92
--- /dev/null
+++ b/test/fts3defer3.test
@@ -0,0 +1,84 @@
+# 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.
+#
+#***********************************************************************
+#
+# This file contains a very simple test to show that the deferred tokens
+# optimization is doing something.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+ifcapable !fts3||!fts4_deferred {
+ finish_test
+ return
+}
+set testprefix fts3defer3
+
+set nDoclist 3204
+set nDoc 800
+
+# Set up a database that contains 800 rows. Each row contains the document
+# "b b", except for the row with docid=200, which contains "a b". Hence
+# token "b" is extremely common and token "a" is not.
+#
+do_test 1.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts4;
+ BEGIN;
+ }
+ for {set i 1} {$i <= $nDoc} {incr i} {
+ set document "b b"
+ if {$i==200} { set document "a b" }
+ execsql { INSERT INTO t1 (docid, content) VALUES($i, $document) }
+ }
+ execsql COMMIT
+} {}
+
+# Check that the db contains two doclists. A small one for "a" and a
+# larger one for "b".
+#
+do_execsql_test 1.2 {
+ SELECT blockid, length(block) FROM t1_segments;
+} [list 1 8 2 $nDoclist]
+
+# Query for 'a b'. Although this test doesn't prove so, token "b" will
+# be deferred because of the very large associated doclist.
+#
+do_execsql_test 1.3 {
+ SELECT docid, content FROM t1 WHERE t1 MATCH 'a b';
+} {200 {a b}}
+
+# Zero out the doclist for token "b" within the database file. Now the
+# only queries that use token "b" that will work are those that defer
+# it. Any query that tries to use the doclist belonging to token "b"
+# will fail.
+#
+do_test 1.4 {
+ set fd [db incrblob t1_segments block 2]
+ puts -nonewline $fd [string repeat "\00" $nDoclist]
+ close $fd
+} {}
+
+# The first two queries succeed, as they defer token "b". The last one
+# fails, as it tries to load the corrupt doclist.
+#
+do_execsql_test 1.5 {
+ SELECT docid, content FROM t1 WHERE t1 MATCH 'a b';
+} {200 {a b}}
+do_execsql_test 1.6 {
+ SELECT count(*) FROM t1 WHERE t1 MATCH 'a b';
+} {1}
+do_catchsql_test 1.7 {
+ SELECT count(*) FROM t1 WHERE t1 MATCH 'b';
+} {1 {database disk image is malformed}}
+
+
+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/fts3dropmod.test b/test/fts3dropmod.test
new file mode 100644
index 0000000..d6b1677
--- /dev/null
+++ b/test/fts3dropmod.test
@@ -0,0 +1,44 @@
+# 2021 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. 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
+set testprefix fts3dropmod
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+sqlite3_drop_modules db fts3
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3(x);
+}
+do_catchsql_test 1.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4(x);
+} {1 {no such module: fts4}}
+
+reset_db
+sqlite3_drop_modules db fts4
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE t1 USING fts4(x);
+}
+do_catchsql_test 2.1 {
+ CREATE VIRTUAL TABLE t2 USING fts3(x);
+} {1 {no such module: fts3}}
+
+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..2fd1920
--- /dev/null
+++ b/test/fts3expr.test
@@ -0,0 +1,521 @@
+# 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 {unknown tokenizer: doesnotexist}}
+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 '""';
+ }
+} {}
+
+
+do_test fts3expr-8.0 { test_fts3expr "(blah)" } {PHRASE 3 0 blah}
+do_test fts3expr-8.1 { test_fts3expr "(blah.)" } {PHRASE 3 0 blah}
+do_test fts3expr-8.2 { test_fts3expr "(blah,)" } {PHRASE 3 0 blah}
+do_test fts3expr-8.3 { test_fts3expr "(blah!)" } {PHRASE 3 0 blah}
+do_test fts3expr-8.4 { test_fts3expr "(blah-)" } {PHRASE 3 0 blah}
+
+do_test fts3expr-8.5 { test_fts3expr "((blah.))" } {PHRASE 3 0 blah}
+do_test fts3expr-8.6 { test_fts3expr "(((blah,)))" } {PHRASE 3 0 blah}
+do_test fts3expr-8.7 { test_fts3expr "((((blah!))))" } {PHRASE 3 0 blah}
+
+do_test fts3expr-8.8 { test_fts3expr "(,(blah-),)" } {PHRASE 3 0 blah}
+
+set sqlite_fts3_enable_parentheses 0
+
+do_test fts3expr-9.1 {
+ test_fts3expr "f (e NEAR/2 a)"
+} {AND {PHRASE 3 0 f} {NEAR/2 {PHRASE 3 0 e} {PHRASE 3 0 a}}}
+
+do_test fts3expr-10.1 { test_fts3expr "abc *" } {PHRASE 3 0 abc}
+do_test fts3expr-10.2 { test_fts3expr "*" } {}
+do_test fts3expr-10.3 { test_fts3expr "abc*" } {PHRASE 3 0 abc+}
+
+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/fts3expr3.test b/test/fts3expr3.test
new file mode 100644
index 0000000..83c1532
--- /dev/null
+++ b/test/fts3expr3.test
@@ -0,0 +1,238 @@
+# 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 part of the FTS3 expression
+# parser that rebalances large expressions.
+#
+# $Id: fts3expr2.test,v 1.2 2009/06/05 17:09:12 drh Exp $
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set ::testprefix fts3expr3
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+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_rebalance('simple', $expr, 'a', 'b', 'c')}
+ ]
+}
+
+proc balanced_exprtree_structure {nEntry} {
+ set L [list]
+ for {set i 1} {$i <= $nEntry} {incr i} {
+ lappend L xxx
+ }
+ while {[llength $L] > 1} {
+ set N [list]
+ if {[llength $L] % 2} {
+ foreach {a b} [lrange $L 0 end-1] { lappend N [list AND $a $b] }
+ lappend N [lindex $L end]
+ } else {
+ foreach {a b} $L { lappend N [list AND $a $b] }
+ }
+ set L $N
+ }
+ return [lindex $L 0]
+}
+
+proc balanced_and_tree {nEntry} {
+ set query [balanced_exprtree_structure $nEntry]
+ if {$query == "xxx"} {
+ return "P 1"
+ }
+ for {set i 1} {$i <= $nEntry} {incr i} {
+ regsub xxx $query "{P $i}" query
+ }
+ return $query
+}
+
+proc random_tree_structure {nEntry bParen op} {
+ set query xxx
+ for {set i 1} {$i < $nEntry} {incr i} {
+ set x1 [expr int(rand()*4.0)]
+ set x2 [expr int(rand()*2.0)]
+ if {$x1==0 && $bParen} {
+ set query "($query)"
+ }
+ if {$x2} {
+ set query "xxx $op $query"
+ } else {
+ set query "$query $op xxx"
+ }
+ }
+ return $query
+}
+
+proc random_and_query {nEntry {bParen 0}} {
+ set query [random_tree_structure $nEntry $bParen AND]
+ for {set i 1} {$i <= $nEntry} {incr i} {
+ regsub xxx $query $i query
+ }
+ return $query
+}
+
+proc random_or_query {nEntry} {
+ set query [random_tree_structure $nEntry 1 OR]
+ for {set i 1} {$i <= $nEntry} {incr i} {
+ regsub xxx $query $i query
+ }
+ return $query
+}
+
+proc random_andor_query {nEntry} {
+ set query [random_tree_structure $nEntry 1 AND]
+ for {set i 1} {$i <= $nEntry} {incr i} {
+ regsub xxx $query "([random_or_query $nEntry])" query
+ }
+ return $query
+}
+
+proc balanced_andor_tree {nEntry} {
+ set tree [balanced_exprtree_structure $nEntry]
+ set node "{[balanced_and_tree $nEntry]}"
+ regsub -all AND $node OR node
+ regsub -all xxx $tree $node tree
+ return $tree
+}
+
+if 1 {
+
+# Test that queries like "1 AND 2 AND 3 AND 4..." are transformed to
+# balanced trees by FTS.
+#
+for {set i 1} {$i < 100} {incr i} {
+ do_test 1.$i {
+ test_fts3expr2 [random_and_query $i]
+ } [balanced_and_tree $i]
+}
+
+# Same again, except with parenthesis inserted at arbitrary points.
+#
+for {set i 1} {$i < 100} {incr i} {
+ do_test 2.$i {
+ test_fts3expr2 [random_and_query $i 1]
+ } [balanced_and_tree $i]
+}
+
+# Now attempt to balance two AND trees joined by an OR.
+#
+for {set i 1} {$i < 100} {incr i} {
+ do_test 3.$i {
+ test_fts3expr2 "[random_and_query $i 1] OR [random_and_query $i 1]"
+ } [list OR [balanced_and_tree $i] [balanced_and_tree $i]]
+}
+
+# Try trees of AND nodes with leaves that are themselves trees of OR nodes.
+#
+for {set i 2} {$i < 64} {incr i 4} {
+ do_test 3.$i {
+ test_fts3expr2 [random_andor_query $i]
+ } [balanced_andor_tree $i]
+}
+
+# These exceed the depth limit.
+#
+for {set i 65} {$i < 70} {incr i} {
+ do_test 3.$i {
+ list [catch {test_fts3expr2 [random_andor_query $i]} msg] $msg
+ } {1 {Error parsing expression}}
+}
+
+# This also exceeds the depth limit.
+#
+
+do_test 4.1.1 {
+ set q "1"
+ for {set i 2} {$i < 5000} {incr i} {
+ append q " AND $i"
+ }
+ list [catch {test_fts3expr2 $q} msg] $msg
+} {1 {Error parsing expression}}
+do_test 4.1.2 {
+ set q "1"
+ for {set i 2} {$i < 4000} {incr i} {
+ append q " AND $i"
+ }
+ catch {test_fts3expr2 $q}
+} {0}
+
+proc create_toggle_tree {nDepth} {
+ if {$nDepth == 0} { return xxx }
+ set nNew [expr $nDepth-1]
+ if {$nDepth % 2} {
+ return "([create_toggle_tree $nNew]) OR ([create_toggle_tree $nNew])"
+ }
+ return "([create_toggle_tree $nNew]) AND ([create_toggle_tree $nNew])"
+}
+
+do_test 4.2 {
+ list [catch {test_fts3expr2 [create_toggle_tree 17]} msg] $msg
+} {1 {Error parsing expression}}
+
+set query [random_andor_query 12]
+set result [balanced_andor_tree 12]
+do_faultsim_test fts3expr3-fault-1 -faults oom-* -body {
+ test_fts3expr2 $::query
+} -test {
+ faultsim_test_result [list 0 $::result]
+}
+
+}
+
+#-------------------------------------------------------------------
+
+foreach {tn expr res} {
+ 1 {1 OR 2 OR 3 OR 4} {OR {OR {P 1} {P 2}} {OR {P 3} {P 4}}}
+ 2 {1 OR (2 AND 3 AND 4 AND 5)}
+ {OR {P 1} {AND {AND {P 2} {P 3}} {AND {P 4} {P 5}}}}
+ 3 {(2 AND 3 AND 4 AND 5) OR 1}
+ {OR {AND {AND {P 2} {P 3}} {AND {P 4} {P 5}}} {P 1}}
+
+ 4 {1 AND (2 OR 3 OR 4 OR 5)}
+ {AND {P 1} {OR {OR {P 2} {P 3}} {OR {P 4} {P 5}}}}
+ 5 {(2 OR 3 OR 4 OR 5) AND 1}
+ {AND {OR {OR {P 2} {P 3}} {OR {P 4} {P 5}}} {P 1}}
+
+ 6 {(2 OR 3 OR 4 OR 5) NOT 1}
+ {NOT {OR {OR {P 2} {P 3}} {OR {P 4} {P 5}}} {P 1}}
+
+ 7 {1 NOT (2 OR 3 OR 4 OR 5)}
+ {NOT {P 1} {OR {OR {P 2} {P 3}} {OR {P 4} {P 5}}}}
+
+ 8 {(1 OR 2 OR 3 OR 4) NOT (5 AND 6 AND 7 AND 8)}
+ {NOT {OR {OR {P 1} {P 2}} {OR {P 3} {P 4}}} {AND {AND {P 5} {P 6}} {AND {P 7} {P 8}}}}
+} {
+ do_test 5.1.$tn {
+ test_fts3expr2 $expr
+ } $res
+}
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/fts3expr4.test b/test/fts3expr4.test
new file mode 100644
index 0000000..4a6bd29
--- /dev/null
+++ b/test/fts3expr4.test
@@ -0,0 +1,82 @@
+# 2014 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 testing the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts3expr4
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3||!icu {
+ finish_test
+ return
+}
+
+set sqlite_fts3_enable_parentheses 1
+
+proc test_fts3expr {tokenizer expr} {
+ db one {SELECT fts3_exprtest($tokenizer, $expr, 'a', 'b', 'c')}
+}
+
+proc do_icu_expr_test {tn expr res} {
+ set res2 [list {*}$res]
+ uplevel [list do_test $tn [list test_fts3expr "icu en_US" $expr] $res2]
+}
+
+proc do_simple_expr_test {tn expr res} {
+ uplevel [list do_test $tn [list test_fts3expr simple $expr] [list {*}$res]]
+}
+
+#-------------------------------------------------------------------------
+#
+do_icu_expr_test 1.1 "abcd" {PHRASE 3 0 abcd}
+do_icu_expr_test 1.2 " tag " {PHRASE 3 0 tag}
+do_icu_expr_test 1.3 {"x y z"} {PHRASE 3 0 x y z}
+do_icu_expr_test 1.4 {x OR y} {OR {PHRASE 3 0 x} {PHRASE 3 0 y}}
+do_icu_expr_test 1.5 {(x OR y)} {OR {PHRASE 3 0 x} {PHRASE 3 0 y}}
+do_icu_expr_test 1.6 { "(x OR y)" } {PHRASE 3 0 ( x or y )}
+
+# In "col:word", if "col" is not the name of a column, the entire thing
+# is passed to the tokenizer.
+#
+do_icu_expr_test 1.7 {a:word} {PHRASE 0 0 word}
+do_icu_expr_test 1.8 {d:word} {PHRASE 3 0 d:word}
+
+set sqlite_fts3_enable_parentheses 0
+
+do_icu_expr_test 2.1 {
+ f (e NEAR/2 a)
+} {AND {AND {AND {PHRASE 3 0 f} {PHRASE 3 0 (}} {NEAR/2 {PHRASE 3 0 e} {PHRASE 3 0 a}}} {PHRASE 3 0 )}}
+
+#-------------------------------------------------------------------------
+#
+do_simple_expr_test 3.1 {*lOl* *h4h*} {
+ AND {PHRASE 3 0 lol+} {PHRASE 3 0 h4h+}
+}
+
+do_icu_expr_test 3.2 {*lOl* *h4h*} {
+ AND {AND {AND {PHRASE 3 0 *} {PHRASE 3 0 lol+}} {PHRASE 3 0 *}} {PHRASE 3 0 h4h+}
+}
+
+do_simple_expr_test 3.3 { * } {}
+do_simple_expr_test 3.4 { *a } { PHRASE 3 0 a }
+do_simple_expr_test 3.5 { a*b } { AND {PHRASE 3 0 a+} {PHRASE 3 0 b} }
+do_simple_expr_test 3.6 { *a*b } { AND {PHRASE 3 0 a+} {PHRASE 3 0 b} }
+do_simple_expr_test 3.7 { *"abc" } { PHRASE 3 0 abc }
+do_simple_expr_test 3.8 { "abc"* } { PHRASE 3 0 abc }
+do_simple_expr_test 3.8 { "ab*c" } { PHRASE 3 0 ab+ c }
+
+do_icu_expr_test 3.9 { "ab*c" } { PHRASE 3 0 ab+ * c }
+do_icu_expr_test 3.10 { ab*c } { AND {PHRASE 3 0 ab+} {PHRASE 3 0 c}}
+
+finish_test
diff --git a/test/fts3expr5.test b/test/fts3expr5.test
new file mode 100644
index 0000000..1317bef
--- /dev/null
+++ b/test/fts3expr5.test
@@ -0,0 +1,66 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts3expr5
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+proc test_fts3expr {expr} {
+ db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}
+}
+
+#-------------------------------------------------------------------------
+# Various forms of empty phrase expressions.
+#
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t0 USING fts3(x);
+ SELECT rowid FROM t0 WHERE x MATCH '';
+} {}
+do_execsql_test 1.1 {
+ SELECT rowid FROM t0 WHERE x MATCH '""';
+} {}
+do_execsql_test 1.2 {
+ SELECT rowid FROM t0 WHERE x MATCH '"" ""';
+} {}
+do_execsql_test 1.3 {
+ SELECT rowid FROM t0 WHERE x MATCH '"" OR ""';
+} {}
+do_execsql_test 1.4 {
+ SELECT rowid FROM t0 WHERE x MATCH '"" NOT ""';
+} {}
+do_execsql_test 1.5 {
+ SELECT rowid FROM t0 WHERE x MATCH '""""';
+} {}
+
+#-------------------------------------------------------------------------
+# Various forms of empty phrase expressions.
+#
+set sqlite_fts3_enable_parentheses 1
+do_test 2.0 {
+ test_fts3expr {(a:123)(b:234)()(c:456)}
+} {AND {AND {PHRASE 0 0 123} {PHRASE 1 0 234}} {PHRASE 2 0 456}}
+do_test 2.1 {
+ test_fts3expr {(a:123)(b:234)(c:456)}
+} {AND {AND {PHRASE 0 0 123} {PHRASE 1 0 234}} {PHRASE 2 0 456}}
+do_test 2.2 {
+ list [catch { test_fts3expr {"123" AND ( )} } msg] $msg
+} {1 {Error parsing expression}}
+
+finish_test
diff --git a/test/fts3f.test b/test/fts3f.test
new file mode 100644
index 0000000..d9a57cb
--- /dev/null
+++ b/test/fts3f.test
@@ -0,0 +1,57 @@
+# 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
+set testprefix fts3f
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE ft USING fts3(x);
+ BEGIN;
+ INSERT INTO ft VALUES('a one'), ('b one'), ('c one');
+}
+
+do_test 1.1 {
+ set ret [list]
+ db eval { SELECT docid FROM ft WHERE ft MATCH 'one' } {
+ if { $docid==2 } {
+ db eval COMMIT
+ }
+ lappend ret $docid
+ }
+ set ret
+} {1 2 3}
+
+do_execsql_test 1.2 {
+ BEGIN;
+ INSERT INTO ft VALUES('a one'), ('b one'), ('c one');
+}
+
+do_execsql_test 1.3 {
+ SELECT docid, optimize(ft) FROM ft WHERE ft MATCH 'one'
+} {
+ 1 {Index optimized} 2 {Index already optimal} 3 {Index already optimal}
+ 4 {Index already optimal}
+ 5 {Index already optimal} 6 {Index already optimal}
+}
+
+finish_test
diff --git a/test/fts3fault.test b/test/fts3fault.test
new file mode 100644
index 0000000..21defd2
--- /dev/null
+++ b/test/fts3fault.test
@@ -0,0 +1,263 @@
+# 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 }
+
+set ::TMPDBERROR [list 1 \
+ {unable to open a temporary database file for storing temporary tables}
+]
+
+# 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 {}} $::TMPDBERROR
+}
+
+# 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}}
+}
+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}}
+}
+
+
+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
+} {}
+
+ifcapable fts4_deferred {
+ do_faultsim_test 8.1 -faults oom-t* -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} $::TMPDBERROR
+}
+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}}}
+}
+
+do_faultsim_test 10.1 -prep {
+ faultsim_delete_and_reopen
+} -body {
+ execsql { CREATE VIRTUAL TABLE t1 USING fts4(a, b, languageid=d) }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 11.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3(a, b);
+}
+faultsim_save_and_close
+
+do_faultsim_test 11 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { DROP TABLE t1 }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+finish_test
diff --git a/test/fts3fault2.test b/test/fts3fault2.test
new file mode 100644
index 0000000..913f9ba
--- /dev/null
+++ b/test/fts3fault2.test
@@ -0,0 +1,250 @@
+# 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 {}}
+}
+
+ifcapable fts3_unicode {
+ do_test 5.0 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE VIRTUAL TABLE ft USING fts4(a, tokenize=unicode61);
+ }
+ faultsim_save_and_close
+ } {}
+
+ do_faultsim_test 5.1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+ } -body {
+ execsql { INSERT INTO ft VALUES('the quick brown fox'); }
+ execsql { INSERT INTO ft VALUES(
+ 'theunusuallylongtokenthatjustdragsonandonandonandthendragsonsomemoreeof'
+ );
+ }
+ execsql { SELECT docid FROM ft WHERE ft MATCH 'th*' }
+ } -test {
+ faultsim_test_result {0 {1 2}}
+ }
+}
+
+reset_db
+do_test 6.0 {
+ execsql {
+ CREATE VIRTUAL TABLE t6 USING fts4(x,order=DESC);
+ INSERT INTO t6(docid, x) VALUES(-1,'a b');
+ INSERT INTO t6(docid, x) VALUES(1, 'b');
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test 6.1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql { SELECT docid FROM t6 WHERE t6 MATCH '"a* b"' }
+} -test {
+ faultsim_test_result {0 -1}
+}
+
+#-------------------------------------------------------------------------
+# Inject faults into a query for an N-byte prefix that uses a prefix=N+1
+# index.
+reset_db
+do_execsql_test 7.0 {
+ CREATE VIRTUAL TABLE t7 USING fts4(x,prefix=2);
+ INSERT INTO t7 VALUES('the quick brown fox');
+ INSERT INTO t7 VALUES('jumped over the');
+ INSERT INTO t7 VALUES('lazy dog');
+}
+do_faultsim_test 7.1 -faults oom* -body {
+ execsql { SELECT docid FROM t7 WHERE t7 MATCH 't*' }
+} -test {
+ faultsim_test_result {0 {1 2}}
+}
+
+#-------------------------------------------------------------------------
+# Inject faults into a opening an existing fts3 table that has been
+# upgraded to add an %_stat table.
+#
+reset_db
+do_execsql_test 8.0 {
+ CREATE VIRTUAL TABLE t8 USING fts3;
+ INSERT INTO t8 VALUES('the quick brown fox');
+ INSERT INTO t8 VALUES('jumped over the');
+ INSERT INTO t8 VALUES('lazy dog');
+ INSERT INTO t8(t8) VALUES('automerge=8');
+ SELECT name FROM sqlite_master WHERE name LIKE 't8%';
+} {
+ t8 t8_content t8_segments t8_segdir t8_stat
+}
+faultsim_save_and_close
+
+do_faultsim_test 8.1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { INSERT INTO t8 VALUES('one two three') }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+set ::TMPDBERROR [list 1 \
+ {unable to open a temporary database file for storing temporary tables}
+]
+do_faultsim_test 8.2 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { ALTER TABLE t8 RENAME TO t8ii }
+} -test {
+ faultsim_test_result {0 {}} $::TMPDBERROR
+}
+
+#-------------------------------------------------------------------------
+reset_db
+set chunkconfig [fts3_configure_incr_load 1 1]
+do_execsql_test 9.0 {
+ PRAGMA page_size = 512;
+ CREATE VIRTUAL TABLE t9 USING fts3;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50
+ )
+ INSERT INTO t9 SELECT 'one two three' FROM s;
+}
+
+do_faultsim_test 8.2 -faults io* -body {
+ execsql { SELECT count(*) FROM t9 WHERE t9 MATCH '"one two three"' }
+} -test {
+ faultsim_test_result {0 50}
+}
+
+eval fts3_configure_incr_load $chunkconfig
+
+
+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/fts3fuzz001.test b/test/fts3fuzz001.test
new file mode 100644
index 0000000..41b22d3
--- /dev/null
+++ b/test/fts3fuzz001.test
@@ -0,0 +1,114 @@
+# 2012-12-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.
+#
+#***********************************************************************
+#
+# Test cases for corrupt database files.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !deserialize||!fts3 {
+ finish_test
+ return
+}
+database_may_be_corrupt
+
+do_test fts3fuzz001-100 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 24576 pagesize 4096 filename c6.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 0e f9 00 06 0d ec 00 0f cd 0f 69 ...............i
+| 112: 0f 01 0e 10 0e c6 0d ec 00 00 00 00 00 00 00 00 ................
+| 3552: 00 00 00 00 00 00 00 00 00 00 00 00 22 06 06 17 ............"...
+| 3568: 11 11 01 31 74 61 62 6c 65 74 32 74 32 06 43 52 ...1tablet2t2.CR
+| 3584: 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 78 29 EATE TABLE t2(x)
+| 3600: 81 33 04 07 17 1f 1f 01 82 35 74 61 62 6c 65 74 .3.......5tablet
+| 3616: 31 5f 73 65 67 64 69 72 74 31 5f 73 65 67 64 69 1_segdirt1_segdi
+| 3632: 72 04 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 r.CREATE TABLE '
+| 3648: 74 31 5f 73 65 67 64 69 72 27 28 6c 65 76 65 6c t1_segdir'(level
+| 3664: 20 49 4e 54 45 47 45 52 2c 69 64 78 20 49 4e 54 INTEGER,idx INT
+| 3680: 45 47 45 52 2c 73 74 61 72 74 5f 62 6c 6f 63 6b EGER,start_block
+| 3696: 20 49 4e 54 45 47 45 52 2c 6c 65 61 76 65 73 5f INTEGER,leaves_
+| 3712: 65 6e 64 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45 end_block INTEGE
+| 3728: 52 2c 65 6e 64 5f 62 6c 6f 63 6b 20 49 4e 54 45 R,end_block INTE
+| 3744: 47 45 52 2c 72 6f 6f 74 20 42 4c 4f 42 2c 50 52 GER,root BLOB,PR
+| 3760: 49 4d 41 52 59 20 4b 45 59 28 6c 65 76 65 6c 2c IMARY KEY(level,
+| 3776: 20 69 64 78 29 29 31 05 06 17 45 1f 01 00 69 6e idx))1...E...in
+| 3792: 64 65 78 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e dexsqlite_autoin
+| 3808: 64 65 78 5f 74 15 f7 36 56 76 46 97 25 f3 17 43 dex_t..6VvF.%..C
+| 3824: 15 5f 73 65 67 64 69 72 05 00 00 00 08 00 00 00 ._segdir........
+| 3840: 00 66 03 07 17 23 23 01 81 13 74 61 62 6c 65 74 .f...##...tablet
+| 3856: 31 5f 73 65 67 6d 65 6e 74 73 74 31 5f 73 65 67 1_segmentst1_seg
+| 3872: 6d 65 6e 74 73 03 43 52 45 41 54 45 20 54 41 42 ments.CREATE TAB
+| 3888: 4c 45 20 27 74 31 5f 73 65 67 6d 65 6e 74 73 27 LE 't1_segments'
+| 3904: 28 62 6c 6f 63 6b 69 64 20 49 4e 54 45 47 45 52 (blockid INTEGER
+| 3920: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 6c PRIMARY KEY, bl
+| 3936: 6f 63 6b 20 42 4c 4f 42 29 62 02 07 17 21 21 01 ock BLOB)b...!!.
+| 3952: 81 0f 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65 6e ..tablet1_conten
+| 3968: 74 74 31 5f 63 6f 6e 74 65 6e 74 02 43 52 45 41 tt1_content.CREA
+| 3984: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e TE TABLE 't1_con
+| 4000: 74 65 6e 74 27 28 64 6f 63 69 64 20 49 4e 54 45 tent'(docid INTE
+| 4016: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
+| 4032: 20 27 63 30 63 6f 6e 74 65 6e 74 27 29 31 01 06 'c0content')1..
+| 4048: 17 11 11 08 51 74 61 62 6c 65 74 31 74 31 43 52 ....Qtablet1t1CR
+| 4064: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 EATE VIRTUAL TAB
+| 4080: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33 LE t1 USING fts3
+| page 2 offset 4096
+| 0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00 ................
+| 4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00 .....abandon....
+| 4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b .abaft.....aback
+| page 3 offset 8192
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 4 offset 12288
+| 0: 0d 00 00 00 01 0f d6 00 0f 00 00 00 00 00 00 00 ................
+| 4048: 00 00 00 00 00 00 28 01 07 08 08 08 08 15 46 30 ......(.......F0
+| 4064: 20 32 39 00 05 61 62 61 63 6b 03 01 02 00 03 02 29..aback......
+| 4080: 66 74 03 02 02 00 03 04 6e 64 6f 6e 03 03 02 00 ft......ndon....
+| page 5 offset 16384
+| 0: 0a 00 00 00 01 0f fb 00 0f fb 00 00 00 00 00 00 ................
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 04 04 08 08 09 ................
+| page 6 offset 20480
+| 0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7 ................
+| 16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f ...........#auto
+| 4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65 merge=5...#merge
+| 4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72 =100,8...+integr
+| 4064: 69 74 79 3d 63 68 65 63 6b 09 02 02 1b 72 65 62 ity=check....reb
+| 4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 uild....optimize
+| end c6.db
+ }]
+ catchsql {
+ PRAGMA writable_schema=on; -- disable schema corruption detection
+ INSERT INTO t1(t1) SELECT x FROM t2;
+ }
+} {1 {database disk image is malformed}}
+do_test fts3fuzz001-110 {
+ catchsql {
+ INSERT INTO t1(t1) VALUES('integrity-check');
+ }
+} {1 {database disk image is malformed}}
+do_test fts3fuzz001-120 {
+ catchsql {
+ INSERT INTO t1(t1) VALUES('optimize');
+ }
+} {1 {database disk image is malformed}}
+do_test fts3fuzz001-121 {
+ catchsql {
+ INSERT INTO t1(t1) VALUES('integrity-check');
+ }
+} {1 {database disk image is malformed}}
+
+
+finish_test
diff --git a/test/fts3join.test b/test/fts3join.test
new file mode 100644
index 0000000..3333b1a
--- /dev/null
+++ b/test/fts3join.test
@@ -0,0 +1,106 @@
+# 2014 January 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 FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix fts3join
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE ft1 USING fts4(x);
+ INSERT INTO ft1 VALUES('aaa aaa');
+ INSERT INTO ft1 VALUES('aaa bbb');
+ INSERT INTO ft1 VALUES('bbb aaa');
+ INSERT INTO ft1 VALUES('bbb bbb');
+
+ CREATE TABLE t1(id, y);
+ INSERT INTO t1 VALUES(1, 'aaa');
+ INSERT INTO t1 VALUES(2, 'bbb');
+}
+
+do_execsql_test 1.1 {
+ SELECT docid FROM ft1, t1 WHERE ft1 MATCH y AND id=1;
+} {1 2 3}
+
+do_execsql_test 1.2 {
+ SELECT docid FROM ft1, t1 WHERE ft1 MATCH y AND id=1 ORDER BY docid;
+} {1 2 3}
+
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE ft2 USING fts4(x);
+ CREATE VIRTUAL TABLE ft3 USING fts4(y);
+
+ INSERT INTO ft2 VALUES('abc');
+ INSERT INTO ft2 VALUES('def');
+ INSERT INTO ft3 VALUES('ghi');
+ INSERT INTO ft3 VALUES('abc');
+}
+
+do_execsql_test 2.1 { SELECT * FROM ft2, ft3 WHERE x MATCH y; } {abc abc}
+do_execsql_test 2.2 { SELECT * FROM ft2, ft3 WHERE y MATCH x; } {abc abc}
+do_execsql_test 2.3 { SELECT * FROM ft3, ft2 WHERE x MATCH y; } {abc abc}
+do_execsql_test 2.4 { SELECT * FROM ft3, ft2 WHERE y MATCH x; } {abc abc}
+
+do_catchsql_test 2.5 {
+ SELECT * FROM ft3, ft2 WHERE y MATCH x AND x MATCH y;
+} {1 {unable to use function MATCH in the requested context}}
+
+do_execsql_test 3.0 {
+ CREATE VIRTUAL TABLE vt USING fts3(x);
+ INSERT INTO vt VALUES('abc');
+ INSERT INTO vt VALUES('xyz');
+
+ CREATE TABLE tt(a INTEGER PRIMARY KEY);
+ INSERT INTO tt VALUES(1), (2);
+}
+
+do_execsql_test 3.1 {
+ SELECT * FROM tt LEFT JOIN (
+ SELECT rowid AS rrr, * FROM vt WHERE vt MATCH 'abc'
+ ) ON tt.a = rrr
+} {1 1 abc 2 {} {}}
+
+do_execsql_test 3.2 {
+ SELECT * FROM tt LEFT JOIN vt ON (vt MATCH 'abc')
+} {1 abc 2 abc}
+
+#-------------------------------------------------------------------------
+# Test that queries of the form found in test case 4.2 use an automatic
+# index to avoid running multiple fts queries.
+#
+do_execsql_test 4.1 {
+ CREATE VIRTUAL TABLE ft4 USING fts3(x);
+ CREATE TABLE t4(y, z);
+ CREATE INDEX t4y ON t1(y);
+}
+
+do_eqp_test 4.2 {
+ SELECT * FROM t4 LEFT JOIN (
+ SELECT docid, * FROM ft4 WHERE ft4 MATCH ?
+ ) AS rr ON t4.rowid=rr.docid
+ WHERE t4.y = ?;
+} {
+ QUERY PLAN
+ |--MATERIALIZE rr
+ | `--SCAN ft4 VIRTUAL TABLE INDEX 3:
+ |--SCAN t4
+ `--SEARCH rr USING AUTOMATIC COVERING INDEX (docid=?) LEFT-JOIN
+}
+
+finish_test
diff --git a/test/fts3malloc.test b/test/fts3malloc.test
new file mode 100644
index 0000000..ed30fe2
--- /dev/null
+++ b/test/fts3malloc.test
@@ -0,0 +1,307 @@
+# 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)
+}
+do_write_test fts3_malloc-1.7 sqlite_master {
+ CREATE VIRTUAL TABLE ft7 USING fts4(a, b, notindexed=b)
+}
+
+# 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;
+ DROP TABLE ft7;
+ }
+ 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..af0b1cd
--- /dev/null
+++ b/test/fts3matchinfo.test
@@ -0,0 +1,556 @@
+# 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.1 { INSERT INTO t5(t5) VALUES('optimize') }
+
+ifcapable fts4_deferred {
+ sqlite3_db_config db DEFENSIVE 0
+ do_execsql_test 4.4.0.2 {
+ 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}}
+
+sqlite3_db_config db DEFENSIVE 0
+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.
+sqlite3_db_config db DEFENSIVE 0
+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}}
+
+#-------------------------------------------------------------------------
+do_execsql_test 8.1 {
+ CREATE VIRTUAL TABLE t12 USING fts4;
+ INSERT INTO t12 VALUES('a b c d');
+ SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a';
+} {{0 0 0 0 0 0 1 1 1}}
+do_execsql_test 8.2 {
+ INSERT INTO t12 VALUES('a d c d');
+ SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a';
+} {
+ {0 1 1 0 1 1 1 2 2} {1 1 1 1 1 1 1 2 2}
+}
+do_execsql_test 8.3 {
+ INSERT INTO t12 VALUES('a d d a');
+ SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a';
+} {
+ {0 3 2 0 3 2 1 4 3} {1 3 2 1 3 2 1 4 3} {2 3 2 2 3 2 2 4 3}
+}
+
+do_execsql_test 9.1 {
+ CREATE VIRTUAL TABLE ft2 USING fts4;
+ INSERT INTO ft2 VALUES('a b c d e');
+ INSERT INTO ft2 VALUES('f a b c d');
+ SELECT snippet(ft2, '[', ']', '', -1, 1) FROM ft2 WHERE ft2 MATCH 'c';
+} {{[c]} {[c]}}
+
+#---------------------------------------------------------------------------
+# Test for a memory leak
+#
+do_execsql_test 10.1 {
+ DROP TABLE t10;
+ CREATE VIRTUAL TABLE t10 USING fts4(idx, value);
+ INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three');
+ SELECT docId, t10.*
+ FROM t10
+ JOIN (SELECT 1 AS idx UNION SELECT 2 UNION SELECT 3) AS x
+ WHERE t10 MATCH x.idx
+ AND matchinfo(t10) not null
+ GROUP BY docId
+ ORDER BY 1;
+} {1 1 one 2 2 two 3 3 three}
+
+#---------------------------------------------------------------------------
+# Test the 'y' matchinfo flag
+#
+set sqlite_fts3_enable_parentheses 1
+reset_db
+do_execsql_test 11.0 {
+ CREATE VIRTUAL TABLE tt USING fts3(x, y);
+ INSERT INTO tt VALUES('c d a c d d', 'e a g b d a'); -- 1
+ INSERT INTO tt VALUES('c c g a e b', 'c g d g e c'); -- 2
+ INSERT INTO tt VALUES('b e f d e g', 'b a c b c g'); -- 3
+ INSERT INTO tt VALUES('a c f f g d', 'd b f d e g'); -- 4
+ INSERT INTO tt VALUES('g a c f c f', 'd g g b c c'); -- 5
+ INSERT INTO tt VALUES('g a c e b b', 'd b f b g g'); -- 6
+ INSERT INTO tt VALUES('f d a a f c', 'e e a d c f'); -- 7
+ INSERT INTO tt VALUES('a c b b g f', 'a b a e d f'); -- 8
+ INSERT INTO tt VALUES('b a f e c c', 'f d b b a b'); -- 9
+ INSERT INTO tt VALUES('f d c e a c', 'f a f a a f'); -- 10
+}
+
+db func mit mit
+foreach {tn expr res} {
+ 1 "a" {
+ 1 {1 2} 2 {1 0} 3 {0 1} 4 {1 0} 5 {1 0}
+ 6 {1 0} 7 {2 1} 8 {1 2} 9 {1 1} 10 {1 3}
+ }
+
+ 2 "b" {
+ 1 {0 1} 2 {1 0} 3 {1 2} 4 {0 1} 5 {0 1}
+ 6 {2 2} 8 {2 1} 9 {1 3}
+ }
+
+ 3 "y:a" {
+ 1 {0 2} 3 {0 1}
+ 7 {0 1} 8 {0 2} 9 {0 1} 10 {0 3}
+ }
+
+ 4 "x:a" {
+ 1 {1 0} 2 {1 0} 4 {1 0} 5 {1 0}
+ 6 {1 0} 7 {2 0} 8 {1 0} 9 {1 0} 10 {1 0}
+ }
+
+ 5 "a OR b" {
+ 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
+ 6 {1 0 2 2} 7 {2 1 0 0} 8 {1 2 2 1} 9 {1 1 1 3} 10 {1 3 0 0}
+ }
+
+ 6 "a AND b" {
+ 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
+ 6 {1 0 2 2} 8 {1 2 2 1} 9 {1 1 1 3}
+ }
+
+ 7 "a OR (a AND b)" {
+ 1 {1 2 1 2 0 1} 2 {1 0 1 0 1 0} 3 {0 1 0 1 1 2} 4 {1 0 1 0 0 1}
+ 5 {1 0 1 0 0 1} 6 {1 0 1 0 2 2} 7 {2 1 0 0 0 0} 8 {1 2 1 2 2 1}
+ 9 {1 1 1 1 1 3} 10 {1 3 0 0 0 0}
+ }
+
+} {
+ do_execsql_test 11.1.$tn.1 {
+ SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr
+ } $res
+
+ set r2 [list]
+ foreach {rowid L} $res {
+ lappend r2 $rowid
+ set M [list]
+ foreach {a b} $L {
+ lappend M [expr ($a ? 1 : 0) + ($b ? 2 : 0)]
+ }
+ lappend r2 $M
+ }
+
+ do_execsql_test 11.1.$tn.2 {
+ SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr
+ } $r2
+
+ do_execsql_test 11.1.$tn.2 {
+ SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr
+ } $r2
+}
+set sqlite_fts3_enable_parentheses 0
+
+#---------------------------------------------------------------------------
+# Test the 'b' matchinfo flag
+#
+set sqlite_fts3_enable_parentheses 1
+reset_db
+db func mit mit
+
+do_test 12.0 {
+ set cols [list]
+ for {set i 0} {$i < 50} {incr i} { lappend cols "c$i" }
+ execsql "CREATE VIRTUAL TABLE tt USING fts3([join $cols ,])"
+} {}
+
+do_execsql_test 12.1 {
+ INSERT INTO tt (rowid, c4, c45) VALUES(1, 'abc', 'abc');
+ SELECT mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH 'abc';
+} [list [list [expr 1<<4] [expr 1<<(45-32)]]]
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/fts3matchinfo2.test b/test/fts3matchinfo2.test
new file mode 100644
index 0000000..670e107
--- /dev/null
+++ b/test/fts3matchinfo2.test
@@ -0,0 +1,35 @@
+# 2020-05-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 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 sqlite_fts3_enable_parentheses 1
+
+# Crash case found by cyg0810 at gmail.com 2020-05-14. Reported to
+# chromium (which is not vulnerable) who kindly referred it to us.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t_content(col0 INTEGER);
+ CREATE VIRTUAL TABLE t0 USING fts3(col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY);
+ INSERT INTO t0 VALUES (1, '1234','aaaa','bbbb');
+ SELECT hex(matchinfo(t0,'yxy')) FROM t0 WHERE t0 MATCH x'2b0a312b0a312a312a2a0b5d0a0b0b0a312a0a0b0b0a312a0b310a392a0b0a27312a2a0b5d0a312a0b310a31315d0b310a312a316d2a0b313b15bceaa50a312a0b0a27312a2a0b5d0a312a0b310a312b0b2a310a312a0b2a0b2a0b2e5d0a0bff313336e34a2a312a0b0a3c310b0a0b4b4b0b4b2a4bec40322b2a0b310a0a312a0a0a0a0a0a0a0a0a0b310a312a2a2a0b5d0a0b0b0a312a0b310a312a0b0a4e4541530b310a5df5ced70a0a0a0a0a4f520a0a0a0a0a0a0a312a0b0a4e4541520b310a5d616161610a0a0a0a4f520a0a0a0a0a0a312b0a312a312a0a0a0a0a0a0a004a0b0a310b220a0b0a310a4a22310a0b0a7e6fe0e0e030e0e0e0e0e01176e02000e0e0e0e0e01131320226310a0b0a310a4a22310a0b0a310a766f8b8b4ee0e0300ae0090909090909090909090909090909090909090909090909090909090909090947aaaa540b09090909090909090909090909090909090909090909090909090909090909fae0e0f2f22164e0e0f273e07fefefef7d6dfafafafa6d6d6d6d';
+} {/000000.*0000000/}
+
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/fts3misc.test b/test/fts3misc.test
new file mode 100644
index 0000000..a1bec42
--- /dev/null
+++ b/test/fts3misc.test
@@ -0,0 +1,326 @@
+# 2017 March 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 script is testing the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts3misc
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# A self-join.
+#
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3(a, b);
+ INSERT INTO t1 VALUES('one', 'i');
+ INSERT INTO t1 VALUES('one', 'ii');
+ INSERT INTO t1 VALUES('two', 'i');
+ INSERT INTO t1 VALUES('two', 'ii');
+}
+
+do_execsql_test 1.1 {
+ SELECT a.a, b.b FROM t1 a, t1 b WHERE a.t1 MATCH 'two' AND b.t1 MATCH 'i'
+} {two i two i two i two i}
+
+#-------------------------------------------------------------------------
+# FTS tables with 128 or more columns.
+#
+proc v1 {v} {
+ set vector [list a b c d e f g h]
+ set res [list]
+ for {set i 0} {$i<8} {incr i} {
+ if {$v & (1 << $i)} { lappend res [lindex $vector $i] }
+ }
+ set res
+}
+proc v2 {v} {
+ set vector [list d e f g h i j k]
+ set res [list]
+ for {set i 0} {$i<8} {incr i} {
+ if {$v & (1 << $i)} { lappend res [lindex $vector $i] }
+ }
+ set res
+}
+db func v1 v1
+db func v2 v2
+
+do_test 2.0 {
+ set cols [list]
+ for {set i 0} {$i<200} {incr i} {
+ lappend cols "c$i"
+ }
+ execsql "CREATE VIRTUAL TABLE t2 USING fts3([join $cols ,])"
+ execsql {
+ WITH data(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM data WHERE i<200
+ )
+ INSERT INTO t2(c198, c199) SELECT v1(i), v2(i) FROM data;
+ }
+} {}
+do_execsql_test 2.1 {
+ SELECT rowid FROM t2 WHERE t2 MATCH '"a b c"'
+} {
+ 7 15 23 31 39 47 55 63 71 79 87 95 103 111
+ 119 127 135 143 151 159 167 175 183 191 199
+}
+do_execsql_test 2.2 {
+ SELECT rowid FROM t2 WHERE t2 MATCH '"g h i"'
+} {
+ 56 57 58 59 60 61 62 63 120 121 122 123 124
+ 125 126 127 184 185 186 187 188 189 190 191
+}
+do_execsql_test 2.3 {
+ SELECT rowid FROM t2 WHERE t2 MATCH '"i h"'
+} {
+}
+do_execsql_test 2.4 {
+ SELECT rowid FROM t2 WHERE t2 MATCH '"f e"'
+} {
+}
+do_execsql_test 2.5 {
+ SELECT rowid FROM t2 WHERE t2 MATCH '"e f"'
+} {
+ 6 7 14 15 22 23 30 31 38 39 46 47 48 49 50 51 52 53 54 55 56
+ 57 58 59 60 61 62 63 70 71 78 79 86 87 94 95 102 103 110
+ 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
+ 134 135 142 143 150 151 158 159 166 167 174 175 176 177 178 179 180
+ 181 182 183 184 185 186 187 188 189 190 191 198 199
+}
+
+#-------------------------------------------------------------------------
+# Range constraints on the docid using non-integer values.
+#
+do_execsql_test 2.6 {
+ SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN NULL AND 45;
+} {}
+do_execsql_test 2.7 {
+ SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN 11.5 AND 48.2;
+} {
+ 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
+ 29 30 31 34 35 38 39 42 43 46 47 48
+}
+do_execsql_test 2.8 {
+ SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN '11.5' AND '48.2';
+} {
+ 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
+ 29 30 31 34 35 38 39 42 43 46 47 48
+}
+
+#-------------------------------------------------------------------------
+# Phrase query tests.
+#
+do_execsql_test 3.1.1 {
+ CREATE VIRTUAL TABLE t3 USING fts3;
+ INSERT INTO t3 VALUES('a b c');
+ INSERT INTO t3 VALUES('d e f');
+ INSERT INTO t3 VALUES('a b d');
+ INSERT INTO t3 VALUES('1 2 3 4 5 6 7 8 9 10 11');
+}
+do_execsql_test 3.1.2 {
+ SELECT * FROM t3 WHERE t3 MATCH '"a b x y"' ORDER BY docid DESC
+}
+do_execsql_test 3.1.3 {
+ SELECT * FROM t3 WHERE t3 MATCH '"a b c" OR "a b x y"' ORDER BY docid DESC
+} {{a b c}}
+do_execsql_test 3.1.4 {
+ SELECT * FROM t3 WHERE t3 MATCH '"a* b* x* a*"'
+}
+do_execsql_test 3.1.5 {
+ SELECT rowid FROM t3 WHERE t3 MATCH '"2 3 4 5 6 7 8 9"'
+} {4}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+ifcapable fts4_deferred {
+ do_execsql_test 4.0 {
+ PRAGMA page_size = 512;
+ CREATE VIRTUAL TABLE t4 USING fts4;
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<8000 )
+ INSERT INTO t4 SELECT 'a b c a b c a b c' FROM s;
+ }
+ do_execsql_test 4.1 {
+ SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"'
+ } {8000}
+ do_execsql_test 4.2 {
+ SELECT quote(value) from t4_stat where id=0
+ } {X'C03EC0B204C0A608'}
+ sqlite3_db_config db DEFENSIVE 0
+ do_execsql_test 4.3 {
+ UPDATE t4_stat SET value = X'C03EC0B204C0A60800' WHERE id=0;
+ }
+ do_catchsql_test 4.4 {
+ SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"'
+ } {1 {database disk image is malformed}}
+ do_execsql_test 4.5 {
+ UPDATE t4_stat SET value = X'00C03EC0B204C0A608' WHERE id=0;
+ }
+ do_catchsql_test 4.6 {
+ SELECT count(*) FROM t4 WHERE t4 MATCH '"a b c" OR "c a b"'
+ } {1 {database disk image is malformed}}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 5.0 {
+ CREATE VIRTUAL TABLE t5 USING fts4;
+ INSERT INTO t5 VALUES('a x x x x b x x x x c');
+ INSERT INTO t5 VALUES('a x x x x b x x x x c');
+ INSERT INTO t5 VALUES('a x x x x b x x x x c');
+}
+do_execsql_test 5.1 {
+ SELECT rowid FROM t5 WHERE t5 MATCH 'a NEAR/4 b NEAR/4 c'
+} {1 2 3}
+do_execsql_test 5.2 {
+ SELECT rowid FROM t5 WHERE t5 MATCH 'a NEAR/3 b NEAR/4 c'
+} {}
+do_execsql_test 5.3 {
+ SELECT rowid FROM t5 WHERE t5 MATCH 'a NEAR/4 b NEAR/3 c'
+} {}
+do_execsql_test 5.4 {
+ SELECT rowid FROM t5 WHERE t5 MATCH 'y NEAR/4 b NEAR/4 c'
+} {}
+do_execsql_test 5.5 {
+ SELECT rowid FROM t5 WHERE t5 MATCH 'x OR a NEAR/3 b NEAR/3 c'
+} {1 2 3}
+do_execsql_test 5.5 {
+ SELECT rowid FROM t5 WHERE t5 MATCH 'x OR y NEAR/3 b NEAR/3 c'
+} {1 2 3}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 6.0 {
+ CREATE VIRTUAL TABLE t6 USING fts4;
+
+ BEGIN;
+ WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50000)
+ INSERT INTO t6 SELECT 'x x x x x x x x x x x' FROM s;
+
+ INSERT INTO t6 VALUES('x x x x x x x x x x x A');
+ INSERT INTO t6 VALUES('x x x x x x x x x x x B');
+ INSERT INTO t6 VALUES('x x x x x x x x x x x A');
+ INSERT INTO t6 VALUES('x x x x x x x x x x x B');
+
+ WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50000)
+ INSERT INTO t6 SELECT 'x x x x x x x x x x x' FROM s;
+ COMMIT;
+}
+do_execsql_test 6.1 {
+ SELECT rowid FROM t6 WHERE t6 MATCH 'b OR "x a"'
+} {50001 50002 50003 50004}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 7.0 {
+ CREATE VIRTUAL TABLE vt0 USING fts3(c0);
+ INSERT INTO vt0 VALUES (x'00');
+}
+do_execsql_test 7.1 {
+ INSERT INTO vt0(vt0) VALUES('integrity-check');
+}
+
+#-------------------------------------------------------------------------
+# Ticket [8a6fa2bb].
+#
+reset_db
+do_execsql_test 7.0.1 {
+ CREATE VIRTUAL TABLE vt0 USING fts4(c0, order=DESC);
+ INSERT INTO vt0(c0) VALUES (0), (0);
+}
+do_execsql_test 7.0.2 {
+ INSERT INTO vt0(vt0) VALUES('integrity-check');
+}
+reset_db
+do_execsql_test 7.1.1 {
+ CREATE VIRTUAL TABLE vt0 USING fts4(c0, order=ASC);
+ INSERT INTO vt0(c0) VALUES (0), (0);
+}
+do_execsql_test 7.1.2 {
+ INSERT INTO vt0(vt0) VALUES('integrity-check');
+}
+do_execsql_test 7.2.1 {
+ CREATE VIRTUAL TABLE ft USING fts4(c0, c1, order=DESC, prefix=1);
+ INSERT INTO ft VALUES('a b c d', 'hello world');
+ INSERT INTO ft VALUES('negative', 'positive');
+ INSERT INTO ft VALUES('hello world', 'a b c d');
+}
+do_execsql_test 7.2.2 {
+ INSERT INTO vt0(vt0) VALUES('integrity-check');
+}
+
+#-------------------------------------------------------------------------
+# Ticket [745f1abc].
+#
+reset_db
+do_execsql_test 8.1 {
+ CREATE VIRTUAL TABLE vt0 USING fts4(c0, prefix=1);
+}
+do_execsql_test 8.2 {
+ BEGIN;
+ INSERT INTO vt0 VALUES (0);
+ INSERT INTO vt0(vt0) VALUES('optimize');
+ COMMIT;
+}
+do_execsql_test 8.3 {
+ INSERT INTO vt0(vt0) VALUES('integrity-check');
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 9.0 {
+ CREATE VIRTUAL TABLE t1 using fts4(mailcontent);
+ insert into t1(rowid, mailcontent) values
+ (-4764623217061966105, 'we are going to upgrade'),
+ (8324454597464624651, 'we are going to upgrade');
+}
+
+do_execsql_test 9.1 {
+ INSERT INTO t1(t1) VALUES('integrity-check');
+}
+
+do_execsql_test 9.2 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'upgrade';
+} {
+ -4764623217061966105 8324454597464624651
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 10.0 {
+ CREATE VIRTUAL TABLE f USING fts3(a,b);
+ CREATE TABLE 'f_stat'(id INTEGER PRIMARY KEY, value BLOB);
+ INSERT INTO f_stat VALUES (1,x'3b3b3b3b3b3b3b28ffffffffffffffffff1807f9073481f1d43bc93b3b3b3b3b3b3b3b3b3b18073b3b3b3b3b3b3b9b003b');
+} {}
+
+do_catchsql_test 10.1 {
+ INSERT INTO f(f) VALUES ('merge=69,59');
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+do_execsql_test 11.0 {
+ CREATE VIRTUAL TABLE xyz USING fts3();
+}
+do_execsql_test 11.1 {
+ SELECT * FROM xyz WHERE xyz MATCH 'a NEAR/4294836224 a';
+}
+
+finish_test
diff --git a/test/fts3near.test b/test/fts3near.test
new file mode 100644
index 0000000..2d9981e
--- /dev/null
+++ b/test/fts3near.test
@@ -0,0 +1,597 @@
+
+# 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}}
+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}
+
+# Ticket 38b1ae018f.
+#
+do_execsql_test fts3near-7.1 {
+ CREATE VIRTUAL TABLE x USING fts4(y,z);
+ INSERT INTO x VALUES('aaa bbb ccc ddd', 'bbb ddd aaa ccc');
+ SELECT * FROM x where y MATCH 'bbb NEAR/6 aaa';
+} {{aaa bbb ccc ddd} {bbb ddd aaa ccc}}
+
+do_execsql_test fts3near-7.2 {
+ CREATE VIRTUAL TABLE t2 USING fts4(a, b);
+ INSERT INTO t2 VALUES('A B C', 'A D E');
+ SELECT * FROM t2 where t2 MATCH 'a:A NEAR E'
+} {}
+
+
+finish_test
diff --git a/test/fts3offsets.test b/test/fts3offsets.test
new file mode 100644
index 0000000..24c339d
--- /dev/null
+++ b/test/fts3offsets.test
@@ -0,0 +1,135 @@
+# 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.
+#
+#***********************************************************************
+#
+
+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 fts3offsets
+set sqlite_fts3_enable_parentheses 1
+
+proc extract {offsets text} {
+ set res ""
+
+ set off [list]
+ foreach {t i s n} $offsets {
+ lappend off [list $s $n]
+ }
+ set off [lsort -integer -index 0 $off]
+
+ set iOff 0
+ foreach e $off {
+ foreach {s n} $e {}
+ append res [string range $text $iOff $s-1]
+ append res "("
+ append res [string range $text $s [expr $s+$n-1]]
+ append res ")"
+ set iOff [expr $s+$n]
+ }
+ append res [string range $text $iOff end]
+
+ set res
+}
+db func extract extract
+
+
+do_execsql_test 1.1.0 {
+ CREATE VIRTUAL TABLE xx USING fts3(x);
+ INSERT INTO xx VALUES('A x x x B C x x');
+ INSERT INTO xx VALUES('A B C x B x x C');
+ INSERT INTO xx VALUES('A x x B C x x x');
+}
+do_execsql_test 1.1.1 {
+ SELECT oid,extract(offsets(xx), x) FROM xx WHERE xx MATCH 'a OR (b NEAR/1 c)';
+} {
+ 1 {(A) x x x (B) (C) x x}
+ 2 {(A) (B) (C) x (B) x x C}
+ 3 {(A) x x (B) (C) x x x}
+}
+
+do_execsql_test 1.2 {
+ DELETE FROM xx;
+ INSERT INTO xx VALUES('A x x x B C x x');
+ INSERT INTO xx VALUES('A x x C x x x C');
+ INSERT INTO xx VALUES('A x x B C x x x');
+}
+do_execsql_test 1.2.1 {
+ SELECT oid,extract(offsets(xx), x) FROM xx WHERE xx MATCH 'a OR (b NEAR/1 c)';
+} {
+ 1 {(A) x x x (B) (C) x x}
+ 2 {(A) x x C x x x C}
+ 3 {(A) x x (B) (C) x x x}
+}
+
+do_execsql_test 1.3 {
+ DELETE FROM xx;
+ INSERT INTO xx(rowid, x) VALUES(1, 'A B C');
+ INSERT INTO xx(rowid, x) VALUES(2, 'A x');
+ INSERT INTO xx(rowid, x) VALUES(3, 'A B C');
+ INSERT INTO xx(rowid, x) VALUES(4, 'A B C x x x x x x x B');
+ INSERT INTO xx(rowid, x) VALUES(5, 'A x x x x x x x x x C');
+ INSERT INTO xx(rowid, x) VALUES(6, 'A x x x x x x x x x x x B');
+ INSERT INTO xx(rowid, x) VALUES(7, 'A B C');
+}
+do_execsql_test 1.3.1 {
+ SELECT oid,extract(offsets(xx), x) FROM xx WHERE xx MATCH 'a OR (b NEAR/1 c)';
+} {
+ 1 {(A) (B) (C)}
+ 2 {(A) x}
+ 3 {(A) (B) (C)}
+ 4 {(A) (B) (C) x x x x x x x B}
+ 5 {(A) x x x x x x x x x C}
+ 6 {(A) x x x x x x x x x x x B}
+ 7 {(A) (B) (C)}
+}
+
+
+do_execsql_test 1.4 {
+ DELETE FROM xx;
+ INSERT INTO xx(rowid, x) VALUES(7, 'A B C');
+ INSERT INTO xx(rowid, x) VALUES(6, 'A x');
+ INSERT INTO xx(rowid, x) VALUES(5, 'A B C');
+ INSERT INTO xx(rowid, x) VALUES(4, 'A B C x x x x x x x B');
+ INSERT INTO xx(rowid, x) VALUES(3, 'A x x x x x x x x x C');
+ INSERT INTO xx(rowid, x) VALUES(2, 'A x x x x x x x x x x x B');
+ INSERT INTO xx(rowid, x) VALUES(1, 'A B C');
+}
+do_execsql_test 1.4.1 {
+ SELECT oid,extract(offsets(xx), x) FROM xx WHERE xx MATCH 'a OR (b NEAR/1 c)'
+ ORDER BY docid DESC;
+} {
+ 7 {(A) (B) (C)}
+ 6 {(A) x}
+ 5 {(A) (B) (C)}
+ 4 {(A) (B) (C) x x x x x x x B}
+ 3 {(A) x x x x x x x x x C}
+ 2 {(A) x x x x x x x x x x x B}
+ 1 {(A) (B) (C)}
+}
+
+do_execsql_test 1.5.0 {
+ CREATE VIRTUAL TABLE x1 USING fts3(x);
+ INSERT INTO x1 VALUES('A A A');
+ INSERT INTO x1 VALUES('A A A');
+}
+do_execsql_test 1.5.1 {
+ SELECT offsets(x1) FROM x1 WHERE x1 MATCH 'a OR b AND c NEAR d'
+} {
+ {0 0 0 1 0 0 2 1 0 0 4 1}
+ {0 0 0 1 0 0 2 1 0 0 4 1}
+}
+
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/fts3prefix.test b/test/fts3prefix.test
new file mode 100644
index 0000000..e8d2b2b
--- /dev/null
+++ b/test/fts3prefix.test
@@ -0,0 +1,295 @@
+# 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 {}}
+do_catchsql_test 5.3 {
+ CREATE VIRTUAL TABLE t5 USING fts4(prefix="-1");
+} {1 {error parsing prefix parameter: -1}}
+
+#-------------------------------------------------------------------------
+# Prefix indexes of size 0 are ignored. Demonstrate this by showing that
+# adding prefix=0 does not change the contents of the %_segdir table.
+#
+reset_db
+do_execsql_test 6.1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(prefix=0);
+ CREATE VIRTUAL TABLE t2 USING fts4;
+ INSERT INTO t1 VALUES('Twas Mulga Bill, from Eaglehawk, ');
+ INSERT INTO t2 VALUES('Twas Mulga Bill, from Eaglehawk, ');
+} {}
+do_execsql_test 6.1.2 {
+ SELECT md5sum(quote(root)) FROM t1_segdir;
+} [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]
+
+reset_db
+do_execsql_test 6.2.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(prefix="1,0,2");
+ CREATE VIRTUAL TABLE t2 USING fts4(prefix="1,2");
+ INSERT INTO t1 VALUES('that caught the cycling craze;');
+ INSERT INTO t2 VALUES('that caught the cycling craze;');
+} {}
+do_execsql_test 6.2.2 {
+ SELECT md5sum(quote(root)) FROM t1_segdir;
+} [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]
+
+reset_db
+do_execsql_test 6.3.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(prefix="1,3,2");
+ CREATE VIRTUAL TABLE t2 USING fts4(prefix="1,2");
+ INSERT INTO t1 VALUES('He turned away the good old horse');
+ INSERT INTO t2 VALUES('He turned away the good old horse');
+} {}
+do_test 6.3.2 {
+ set one [db eval {SELECT md5sum(quote(root)) FROM t1_segdir}]
+ set two [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]
+ expr {$one == $two}
+} 0
+
+reset_db
+do_execsql_test 6.4.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(prefix="1,600,2");
+ CREATE VIRTUAL TABLE t2 USING fts4(prefix="1,2");
+ INSERT INTO t1 VALUES('that served him many days;');
+ INSERT INTO t2 VALUES('that served him many days;');
+} {}
+do_execsql_test 6.4.2 {
+ SELECT md5sum(quote(root)) FROM t1_segdir;
+} [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]
+
+reset_db
+do_execsql_test 6.5.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(prefix="2147483647,2147483648,2147483649");
+ CREATE VIRTUAL TABLE t2 USING fts4(prefix=);
+ INSERT INTO t1 VALUES('He dressed himself in cycling clothes');
+ INSERT INTO t2 VALUES('He dressed himself in cycling clothes');
+} {}
+do_execsql_test 6.5.2 {
+ SELECT md5sum(quote(root)) FROM t1_segdir;
+} [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]
+
+
+do_execsql_test 7.0 {
+ CREATE VIRTUAL TABLE t6 USING fts4(x,order=DESC);
+ INSERT INTO t6(docid, x) VALUES(-1,'a b');
+ INSERT INTO t6(docid, x) VALUES(1, 'b');
+}
+do_execsql_test 7.1 {
+ SELECT docid FROM t6 WHERE t6 MATCH '"a* b"';
+} {-1}
+do_execsql_test 7.2 {
+ SELECT docid FROM t6 WHERE t6 MATCH 'a*';
+} {-1}
+do_execsql_test 7.3 {
+ SELECT docid FROM t6 WHERE t6 MATCH 'a* b';
+} {-1}
+
+
+
+finish_test
diff --git a/test/fts3prefix2.test b/test/fts3prefix2.test
new file mode 100644
index 0000000..e033fb6
--- /dev/null
+++ b/test/fts3prefix2.test
@@ -0,0 +1,61 @@
+# 2012 January 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 fts3prefix2
+
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 { PRAGMA page_size = 512 }
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(x, prefix="2,3");
+
+ BEGIN;
+ INSERT INTO t1 VALUES('T TX T TX T TX T TX T TX');
+ 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; -- 64
+ 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
+ COMMIT;
+}
+
+do_execsql_test 1.2 {
+ INSERT INTO t1 SELECT * FROM t1 LIMIT 10;
+ INSERT INTO t1 SELECT * FROM t1 LIMIT 10;
+ INSERT INTO t1 SELECT * FROM t1 LIMIT 10;
+ DELETE FROM t1 WHERE docid > 5;
+}
+
+do_execsql_test 1.3 {
+ SELECT * FROM t1 WHERE t1 MATCH 'T*';
+} {
+ {T TX T TX T TX T TX T TX}
+ {T TX T TX T TX T TX T TX}
+ {T TX T TX T TX T TX T TX}
+ {T TX T TX T TX T TX T TX}
+ {T TX T TX T TX T TX T TX}
+}
+
+finish_test
diff --git a/test/fts3query.test b/test/fts3query.test
new file mode 100644
index 0000000..70ee005
--- /dev/null
+++ b/test/fts3query.test
@@ -0,0 +1,293 @@
+# 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
+} {
+ QUERY PLAN
+ |--SCAN t1 USING COVERING INDEX i1
+ `--SCAN ft VIRTUAL TABLE INDEX 1:
+}
+do_eqp_test fts3query-4.3 {
+ SELECT t1.number FROM ft, t1 WHERE t1.number=ft.rowid ORDER BY t1.date
+} {
+ QUERY PLAN
+ |--SCAN t1 USING COVERING INDEX i1
+ `--SCAN ft VIRTUAL TABLE INDEX 1:
+}
+do_eqp_test fts3query-4.4 {
+ SELECT t1.number FROM t1, bt WHERE t1.number=bt.rowid ORDER BY t1.date
+} {
+ QUERY PLAN
+ |--SCAN t1 USING COVERING INDEX i1
+ `--SEARCH bt USING INTEGER PRIMARY KEY (rowid=?)
+}
+do_eqp_test fts3query-4.5 {
+ SELECT t1.number FROM bt, t1 WHERE t1.number=bt.rowid ORDER BY t1.date
+} {
+ QUERY PLAN
+ |--SCAN t1 USING COVERING INDEX i1
+ `--SEARCH bt USING INTEGER PRIMARY KEY (rowid=?)
+}
+
+
+# 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
+}
+sqlite3_db_config db DEFENSIVE 0
+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, 'abcd') FROM t2 WHERE t2 MATCH 'history'
+} {1 {unrecognized matchinfo request: d}}
+
+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}}
+}
+
+# Test some range queries on the rowid field.
+#
+do_execsql_test 7.1 {
+ CREATE VIRTUAL TABLE ft4 USING fts4(x);
+ CREATE TABLE t4(x);
+}
+
+set SMALLINT -9223372036854775808
+set LARGEINT 9223372036854775807
+do_test 7.2 {
+ db transaction {
+ foreach {iFirst nEntry} [subst {
+ 0 100
+ $SMALLINT 100
+ [expr $LARGEINT - 99] 100
+ }] {
+ for {set i 0} {$i < $nEntry} {incr i} {
+ set iRowid [expr $i + $iFirst]
+ execsql {
+ INSERT INTO ft4(rowid, x) VALUES($iRowid, 'x y z');
+ INSERT INTO t4(rowid, x) VALUES($iRowid, 'x y z');
+ }
+ }
+ }
+ }
+} {}
+
+foreach {tn iFirst iLast} [subst {
+ 1 5 10
+ 2 $SMALLINT [expr $SMALLINT+5]
+ 3 $SMALLINT [expr $SMALLINT+50]
+ 4 [expr $LARGEINT-5] $LARGEINT
+ 5 $LARGEINT $LARGEINT
+ 6 $SMALLINT $LARGEINT
+ 7 $SMALLINT $SMALLINT
+ 8 $LARGEINT $SMALLINT
+}] {
+ set res [db eval {
+ SELECT rowid FROM t4 WHERE rowid BETWEEN $iFirst AND $iLast
+ } ]
+
+ do_execsql_test 7.2.$tn.1.[llength $res] {
+ SELECT rowid FROM ft4 WHERE rowid BETWEEN $iFirst AND $iLast
+ } $res
+ set res [db eval {
+ SELECT rowid FROM t4 WHERE rowid BETWEEN $iFirst AND $iLast
+ ORDER BY +rowid DESC
+ } ]
+ do_execsql_test 7.2.$tn.2.[llength $res] {
+ SELECT rowid FROM ft4 WHERE rowid BETWEEN $iFirst AND $iLast
+ ORDER BY rowid DESC
+ } $res
+}
+
+foreach ii [db eval {SELECT rowid FROM t4}] {
+ set res1 [db eval {SELECT rowid FROM t4 WHERE rowid > $ii}]
+ set res2 [db eval {SELECT rowid FROM t4 WHERE rowid < $ii}]
+ set res1s [db eval {SELECT rowid FROM t4 WHERE rowid > $ii ORDER BY +rowid DESC}]
+ set res2s [db eval {SELECT rowid FROM t4 WHERE rowid < $ii ORDER BY +rowid DESC}]
+
+ do_execsql_test 7.3.$ii.1 {
+ SELECT rowid FROM ft4 WHERE rowid > $ii
+ } $res1
+
+ do_execsql_test 7.3.$ii.2 {
+ SELECT rowid FROM ft4 WHERE rowid < $ii
+ } $res2
+
+ do_execsql_test 7.3.$ii.3 {
+ SELECT rowid FROM ft4 WHERE rowid > $ii ORDER BY rowid DESC
+ } $res1s
+
+ do_execsql_test 7.3.$ii.4 {
+ SELECT rowid FROM ft4 WHERE rowid < $ii ORDER BY rowid DESC
+ } $res2s
+}
+
+finish_test
diff --git a/test/fts3rank.test b/test/fts3rank.test
new file mode 100644
index 0000000..fd1a1c8
--- /dev/null
+++ b/test/fts3rank.test
@@ -0,0 +1,69 @@
+# 2017 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. The
+# focus of this script is testing the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts3rank
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+install_fts3_rank_function db
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3(a, b);
+ INSERT INTO t1 VALUES('one two', 'one');
+ INSERT INTO t1 VALUES('one two', 'three');
+ INSERT INTO t1 VALUES('one two', 'two');
+}
+
+do_execsql_test 1.1 {
+ SELECT * FROM t1 WHERE t1 MATCH 'one'
+ ORDER BY rank(matchinfo(t1), 1.0, 1.0) DESC, rowid
+} {
+ {one two} one
+ {one two} three
+ {one two} two
+}
+
+do_execsql_test 1.2 {
+ SELECT * FROM t1 WHERE t1 MATCH 'two'
+ ORDER BY rank(matchinfo(t1), 1.0, 1.0) DESC, rowid
+} {
+ {one two} two
+ {one two} one
+ {one two} three
+}
+
+do_catchsql_test 1.3 {
+ SELECT * FROM t1 ORDER BY rank(matchinfo(t1), 1.0, 1.0) DESC, rowid
+} {1 {invalid matchinfo blob passed to function rank()}}
+
+do_catchsql_test 1.4 {
+ SELECT * FROM t1 ORDER BY rank(x'0000000000000000') DESC, rowid
+} {0 {{one two} one {one two} three {one two} two}}
+
+if {$tcl_platform(byteOrder)=="littleEndian"} {
+ do_catchsql_test 1.5le {
+ SELECT * FROM t1 ORDER BY rank(x'0100000001000000') DESC, rowid
+ } {1 {invalid matchinfo blob passed to function rank()}}
+} else {
+ do_catchsql_test 1.5be {
+ SELECT * FROM t1 ORDER BY rank(x'0000000100000001') DESC, rowid
+ } {1 {invalid matchinfo blob passed to function rank()}}
+}
+
+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..0943c05
--- /dev/null
+++ b/test/fts3shared.test
@@ -0,0 +1,176 @@
+#
+# 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is the interactions between the FTS3/4 module
+# and shared-cache mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !fts3||!shared_cache {
+ finish_test
+ return
+}
+set ::testprefix fts3shared
+
+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
+
+#-------------------------------------------------------------------------
+# The following tests - fts3shared-2.* - test that unless FTS is bypassed
+# and the underlying tables accessed directly, it is not possible for an
+# SQLITE_LOCKED error to be enountered when committing an FTS transaction.
+#
+# Any SQLITE_LOCKED error should be returned when the fts4 (or fts4aux)
+# table is first read/written within a transaction, not later on.
+#
+set LOCKED {1 {database table is locked}}
+forcedelete test.db
+sqlite3 dbR test.db
+sqlite3 dbW test.db
+do_test 2.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts4;
+ CREATE TABLE t2ext(a, b);
+ CREATE VIRTUAL TABLE t2 USING fts4(content=t2ext);
+ CREATE VIRTUAL TABLE t1aux USING fts4aux(t1);
+ CREATE VIRTUAL TABLE t2aux USING fts4aux(t2);
+
+ INSERT INTO t1 VALUES('a b c');
+ INSERT INTO t2(rowid, a, b) VALUES(1, 'd e f', 'g h i');
+ } dbW
+} {}
+
+# Test that once [dbW] has written to the FTS table, no client may read
+# from the FTS or fts4aux table.
+do_test 2.2.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES('j k l');
+ } dbW
+ execsql BEGIN dbR
+} {}
+do_test 2.2.2 { catchsql "SELECT * FROM t1 WHERE rowid=1" dbR } $LOCKED
+do_test 2.2.3 { catchsql "SELECT * FROM t1 WHERE t1 MATCH 'a'" dbR } $LOCKED
+do_test 2.2.4 { catchsql "SELECT rowid FROM t1 WHERE t1 MATCH 'a'" dbR } $LOCKED
+do_test 2.2.5 { catchsql "SELECT * FROM t1" dbR } $LOCKED
+do_test 2.2.6 { catchsql "SELECT * FROM t1aux" dbR } $LOCKED
+do_test 2.2.7 { execsql COMMIT dbW } {}
+do_test 2.2.8 { execsql COMMIT dbR } {}
+
+# Same test as 2.2.*, except with a content= table.
+#
+do_test 2.3.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t2(rowid, a, b) VALUES(2, 'j k l', 'm n o');
+ } dbW
+ execsql BEGIN dbR
+} {}
+do_test 2.3.3 { catchsql "SELECT * FROM t2 WHERE t2 MATCH 'a'" dbR } $LOCKED
+do_test 2.3.4 { catchsql "SELECT rowid FROM t2 WHERE t2 MATCH 'a'" dbR } $LOCKED
+do_test 2.3.6 { catchsql "SELECT * FROM t2aux" dbR } $LOCKED
+do_test 2.3.7 { execsql COMMIT dbW } {}
+do_test 2.3.8 { execsql COMMIT dbR } {}
+
+# Test that once a connection has read from the FTS or fts4aux table,
+# another connection may not write to the FTS table.
+#
+foreach {tn sql} {
+ 1 "SELECT * FROM t1 WHERE rowid=1"
+ 2 "SELECT * FROM t1 WHERE t1 MATCH 'a'"
+ 3 "SELECT rowid FROM t1 WHERE t1 MATCH 'a'"
+ 4 "SELECT * FROM t1"
+ 5 "SELECT * FROM t1aux"
+} {
+
+ do_test 2.4.$tn {
+ execsql BEGIN dbR
+ execsql $::sql dbR
+ execsql BEGIN dbW
+ catchsql "INSERT INTO t1 VALUES('p q r')" dbW
+ } $LOCKED
+
+ execsql ROLLBACK dbR
+ execsql ROLLBACK dbW
+}
+
+# Same test as 2.4.*, except with a content= table.
+#
+foreach {tn sql} {
+ 2 "SELECT * FROM t2 WHERE t2 MATCH 'a'"
+ 3 "SELECT rowid FROM t2 WHERE t2 MATCH 'a'"
+ 5 "SELECT * FROM t2aux"
+} {
+
+ do_test 2.5.$tn {
+ execsql BEGIN dbR
+ execsql $::sql dbR
+ execsql BEGIN dbW
+ catchsql "INSERT INTO t2(rowid, a, b) VALUES(3, 's t u', 'v w x')" dbW
+ } $LOCKED
+
+ execsql ROLLBACK dbR
+ execsql ROLLBACK dbW
+}
+
+dbW close
+dbR 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..ae022b6
--- /dev/null
+++ b/test/fts3snippet.test
@@ -0,0 +1,592 @@
+# 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
+set testprefix fts3snippet
+
+# 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-1.$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:
+ sqlite3_db_config db DEFENSIVE 0
+ 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}
+}
+
+#-------------------------------------------------------------------------
+# Test an interaction between the snippet() function and OR clauses.
+#
+do_execsql_test 2.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4;
+ INSERT INTO t2 VALUES('one two three four five');
+ INSERT INTO t2 VALUES('two three four five one');
+ INSERT INTO t2 VALUES('three four five one two');
+ INSERT INTO t2 VALUES('four five one two three');
+ INSERT INTO t2 VALUES('five one two three four');
+}
+
+do_execsql_test 2.2 {
+ SELECT snippet(t2, '[', ']') FROM t2 WHERE t2 MATCH 'one OR (four AND six)'
+} {
+ {[one] two three [four] five}
+ {two three [four] five [one]}
+ {three [four] five [one] two}
+ {[four] five [one] two three}
+ {five [one] two three [four]}
+}
+
+do_execsql_test 2.3 {
+ SELECT snippet(t2, '[', ']') FROM t2
+ WHERE t2 MATCH 'one OR (four AND six)'
+ ORDER BY docid DESC
+} {
+ {five [one] two three [four]}
+ {[four] five [one] two three}
+ {three [four] five [one] two}
+ {two three [four] five [one]}
+ {[one] two three [four] five}
+}
+
+do_execsql_test 2.4 {
+ INSERT INTO t2 VALUES('six');
+}
+
+do_execsql_test 2.5 {
+ SELECT snippet(t2, '[', ']') FROM t2 WHERE t2 MATCH 'one OR (four AND six)'
+} {
+ {[one] two three [four] five}
+ {two three [four] five [one]}
+ {three [four] five [one] two}
+ {[four] five [one] two three}
+ {five [one] two three [four]}
+}
+
+do_execsql_test 2.6 {
+ SELECT snippet(t2, '[', ']') FROM t2
+ WHERE t2 MATCH 'one OR (four AND six)'
+ ORDER BY docid DESC
+} {
+ {five [one] two three [four]}
+ {[four] five [one] two three}
+ {three [four] five [one] two}
+ {two three [four] five [one]}
+ {[one] two three [four] five}
+}
+
+#-------------------------------------------------------------------------
+do_execsql_test 3 {
+ CREATE VIRTUAL TABLE t3 USING fts4;
+ INSERT INTO t3 VALUES('[one two three]');
+}
+do_execsql_test 3.1 {
+ SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one';
+} {{[<b>one</b> two three]}}
+do_execsql_test 3.2 {
+ SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'two';
+} {{[one <b>two</b> three]}}
+do_execsql_test 3.3 {
+ SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'three';
+} {{[one two <b>three</b>]}}
+do_execsql_test 3.4 {
+ SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one OR two OR three';
+} {{[<b>one</b> <b>two</b> <b>three</b>]}}
+
+#-------------------------------------------------------------------------
+# Request a snippet 0 tokens in size. This is always an empty string.
+do_execsql_test 4.1 {
+ CREATE VIRTUAL TABLE t4 USING fts4;
+ INSERT INTO t4 VALUES('a b c d');
+ SELECT snippet(t4, '[', ']', '...', 0, 0) FROM t4 WHERE t4 MATCH 'b';
+} {{}}
+
+do_test 4.2 {
+ set x35 [string trim [string repeat "x " 35]]
+ execsql "INSERT INTO t4 VALUES('$x35 E $x35 F $x35 G $x35');"
+ llength [db one {
+ SELECT snippet(t4, '', '', '', 0, 64) FROM t4 WHERE t4 MATCH 'E'
+ }]
+} {64}
+
+do_test 4.3 {
+ llength [db one {
+ SELECT snippet(t4, '', '', '', 0, 150) FROM t4 WHERE t4 MATCH 'E'
+ }]
+} {64}
+
+
+#-------------------------------------------------------------------------
+# Request a snippet from a query with more than 64 phrases.
+#
+do_execsql_test 5.0 {
+ CREATE VIRTUAL TABLE t5 USING fts3(x);
+ INSERT INTO t5 VALUES('a1 a2 a3');
+ INSERT INTO t5 VALUES('a4 a5 a6');
+ INSERT INTO t5 VALUES('a70 a71 a72');
+}
+
+do_execsql_test 5.1 {
+ SELECT snippet(t5, '[', ']') FROM t5 WHERE t5 MATCH
+ 'a1 OR a2 OR a3 OR a4 OR a5 OR a6 OR a7 OR a8 OR a9 OR a10 OR ' ||
+ 'a11 OR a12 OR a13 OR a14 OR a15 OR a16 OR a17 OR a18 OR a19 OR a10 OR ' ||
+ 'a21 OR a22 OR a23 OR a24 OR a25 OR a26 OR a27 OR a28 OR a29 OR a20 OR ' ||
+ 'a31 OR a32 OR a33 OR a34 OR a35 OR a36 OR a37 OR a38 OR a39 OR a30 OR ' ||
+ 'a41 OR a42 OR a43 OR a44 OR a45 OR a46 OR a47 OR a48 OR a49 OR a40 OR ' ||
+ 'a51 OR a52 OR a53 OR a54 OR a55 OR a56 OR a57 OR a58 OR a59 OR a50 OR ' ||
+ 'a61 OR a62 OR a63 OR a64 OR a65 OR a66 OR a67 OR a68 OR a69 OR a60 OR ' ||
+ 'a71 OR a72 OR a73 OR a74 OR a75 OR a76 OR a77 OR a78 OR a79 OR a70'
+} {
+ {[a1] [a2] [a3]}
+ {[a4] [a5] [a6]}
+ {[a70] [a71] [a72]}
+}
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/fts3snippet2.test b/test/fts3snippet2.test
new file mode 100644
index 0000000..607b01e
--- /dev/null
+++ b/test/fts3snippet2.test
@@ -0,0 +1,59 @@
+# 2020-05-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.
+#
+#*************************************************************************
+#
+# 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
+set testprefix fts3snippet
+
+# 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
+#-------------------------------------------------------------------------
+# Request a snippet from a query with more than 64 phrases.
+#
+reset_db
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE f USING fts3(b);
+ INSERT INTO f VALUES ( x'746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218');
+}
+
+do_execsql_test 1.1 {
+ SELECT length(snippet(f))>0 FROM f WHERE b MATCH x'1065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a010f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c2a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e0f42';
+} {1}
+
+reset_db
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE t0 USING fts3(col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY);
+ INSERT INTO t0 VALUES (1, '1234','aaaa','bbbb');
+ SELECT snippet(t0) FROM t0 WHERE t0 MATCH x'0a4d4d4d4d320a4f52d70a310a310a4e4541520a0a31f6ce0a4f520a0a310a310a310a4f520a75fc2a242424' ;
+} {<b>1</b>}
+
+reset_db
+do_execsql_test 2.1 {
+ CREATE VIRTUAL TABLE t0 USING fts3(
+ col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY
+ );
+ INSERT INTO t0 VALUES ('one', '1234','aaaa','bbbb');
+}
+do_execsql_test 2.2 {
+ SELECT snippet(t0) FROM t0 WHERE t0 MATCH
+ '(def AND (one NEAR abc)) OR one'
+} {<b>one</b>}
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/fts3sort.test b/test/fts3sort.test
new file mode 100644
index 0000000..218bf3e
--- /dev/null
+++ b/test/fts3sort.test
@@ -0,0 +1,184 @@
+# 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/fts3tok1.test b/test/fts3tok1.test
new file mode 100644
index 0000000..139fae8
--- /dev/null
+++ b/test/fts3tok1.test
@@ -0,0 +1,124 @@
+# 2013 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 script is testing the "fts3tokenize" virtual table
+# that is part of the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !fts3 { finish_test ; return }
+set ::testprefix fts3tok1
+
+#-------------------------------------------------------------------------
+# Simple test cases. Using the default (simple) tokenizer.
+#
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING fts3tokenize(simple);
+ CREATE VIRTUAL TABLE t2 USING fts3tokenize();
+ CREATE VIRTUAL TABLE t3 USING fts3tokenize(simple, '', 'xyz ');
+}
+
+foreach {tn tbl} {1 t1 2 t2 3 t3} {
+ do_execsql_test 1.$tn.1 "SELECT * FROM $tbl WHERE input = 'one two three'" {
+ {one two three} one 0 3 0
+ {one two three} two 4 7 1
+ {one two three} three 8 13 2
+ }
+
+ do_execsql_test 1.$tn.2 "
+ SELECT token FROM $tbl WHERE input = 'OnE tWo tHrEe'
+ " {
+ one two three
+ }
+}
+
+do_execsql_test 1.4 {
+ SELECT token FROM t3 WHERE input = '1x2x3x'
+} {1 2 3}
+
+do_execsql_test 1.5 {
+ SELECT token FROM t1 WHERE input = '1x2x3x'
+} {1x2x3x}
+
+do_execsql_test 1.6 {
+ SELECT token FROM t3 WHERE input = '1''2x3x'
+} {1'2 3}
+
+do_execsql_test 1.7 {
+ SELECT token FROM t3 WHERE input = ''
+} {}
+
+do_execsql_test 1.8 {
+ SELECT token FROM t3 WHERE input = NULL
+} {}
+
+do_execsql_test 1.9 {
+ SELECT * FROM t3 WHERE input = 123
+} {123 123 0 3 0}
+
+do_execsql_test 1.10 {
+ SELECT * FROM t1 WHERE input = 'a b c' AND token = 'b';
+} {
+ {a b c} b 2 3 1
+}
+
+do_execsql_test 1.11 {
+ SELECT * FROM t1 WHERE token = 'b' AND input = 'a b c';
+} {
+ {a b c} b 2 3 1
+}
+
+do_execsql_test 1.12 {
+ SELECT * FROM t1 WHERE input < 'b' AND input = 'a b c';
+} {
+ {a b c} a 0 1 0
+ {a b c} b 2 3 1
+ {a b c} c 4 5 2
+}
+
+do_execsql_test 1.13.1 {
+ CREATE TABLE c1(x);
+ INSERT INTO c1(x) VALUES('a b c');
+ INSERT INTO c1(x) VALUES('d e f');
+}
+do_execsql_test 1.13.2 {
+ SELECT * FROM c1, t1 WHERE input = x AND c1.rowid=t1.rowid;
+} {
+ {a b c} {a b c} a 0 1 0
+ {d e f} {d e f} e 2 3 1
+}
+
+
+#-------------------------------------------------------------------------
+# Error cases.
+#
+do_catchsql_test 2.0 {
+ CREATE VIRTUAL TABLE tX USING fts3tokenize(nosuchtokenizer);
+} {1 {unknown tokenizer: nosuchtokenizer}}
+
+do_catchsql_test 2.1 {
+ CREATE VIRTUAL TABLE t4 USING fts3tokenize;
+ SELECT * FROM t4;
+} {1 {SQL logic error}}
+
+do_catchsql_test 2.2 {
+ CREATE VIRTUAL TABLE t USING fts4(tokenize=simple"");
+} {0 {}}
+
+ifcapable fts3_unicode {
+ do_catchsql_test 2.3 {
+ CREATE VIRTUAL TABLE u USING fts4(tokenize=unicode61"");
+ } {1 {unknown tokenizer}}
+}
+
+
+finish_test
diff --git a/test/fts3tok_err.test b/test/fts3tok_err.test
new file mode 100644
index 0000000..df0d4be
--- /dev/null
+++ b/test/fts3tok_err.test
@@ -0,0 +1,47 @@
+# 2013 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 script is testing the "fts3tokenize" virtual table
+# that is part of the FTS3 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+ifcapable !fts3 { finish_test ; return }
+set ::testprefix fts3tok_err
+
+
+faultsim_save_and_close
+do_faultsim_test fts3tok_err-1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { CREATE VIRTUAL TABLE t1 USING fts3tokenize("simple"); }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_test fts3tok_err-2.prep {
+ faultsim_delete_and_reopen
+ execsql { CREATE VIRTUAL TABLE t1 USING fts3tokenize("simple"); }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test fts3tok_err-2 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { SELECT token FROM t1 WHERE input = 'A galaxy far, far away' }
+} -test {
+ faultsim_test_result {0 {a galaxy far far away}}
+}
+
+
+finish_test
diff --git a/test/fts3varint.test b/test/fts3varint.test
new file mode 100644
index 0000000..9f797ed
--- /dev/null
+++ b/test/fts3varint.test
@@ -0,0 +1,121 @@
+# 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/tester.tcl
+set testprefix fts3varint
+
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+proc test_list {list} {
+ foreach n $list { fts3_test_varint $n }
+}
+
+proc do_fts3_varint_test {tn list} {
+ uplevel [list do_test $tn [list test_list $list] {}]
+}
+
+do_fts3_varint_test 1.0 {
+ 1 10 100 1000 10000 100000 1000000
+ 10000000 100000000 1000000000 10000000000
+ 100000000000 1000000000000 10000000000000
+}
+
+do_fts3_varint_test 1.1 {
+ -1 -10 -100 -1000 -10000 -100000 -1000000
+ -10000000 -100000000 -1000000000 -10000000000
+ -100000000000 -1000000000000 -10000000000000
+}
+
+do_fts3_varint_test 2.0 { 0 1 2 }
+do_fts3_varint_test 2.1 { 1 2 3 }
+do_fts3_varint_test 2.2 { 3 4 5 }
+do_fts3_varint_test 2.3 { 7 8 9 }
+do_fts3_varint_test 2.4 { 15 16 17 }
+do_fts3_varint_test 2.5 { 31 32 33 }
+do_fts3_varint_test 2.6 { 63 64 65 }
+do_fts3_varint_test 2.7 { 127 128 129 }
+do_fts3_varint_test 2.8 { 255 256 257 }
+do_fts3_varint_test 2.9 { 511 512 513 }
+do_fts3_varint_test 2.10 { 1023 1024 1025 }
+do_fts3_varint_test 2.11 { 2047 2048 2049 }
+do_fts3_varint_test 2.12 { 4095 4096 4097 }
+do_fts3_varint_test 2.13 { 8191 8192 8193 }
+do_fts3_varint_test 2.14 { 16383 16384 16385 }
+do_fts3_varint_test 2.15 { 32767 32768 32769 }
+do_fts3_varint_test 2.16 { 65535 65536 65537 }
+do_fts3_varint_test 2.17 { 131071 131072 131073 }
+do_fts3_varint_test 2.18 { 262143 262144 262145 }
+do_fts3_varint_test 2.19 { 524287 524288 524289 }
+do_fts3_varint_test 2.20 { 1048575 1048576 1048577 }
+do_fts3_varint_test 2.21 { 2097151 2097152 2097153 }
+do_fts3_varint_test 2.22 { 4194303 4194304 4194305 }
+do_fts3_varint_test 2.23 { 8388607 8388608 8388609 }
+do_fts3_varint_test 2.24 { 16777215 16777216 16777217 }
+do_fts3_varint_test 2.25 { 33554431 33554432 33554433 }
+do_fts3_varint_test 2.26 { 67108863 67108864 67108865 }
+do_fts3_varint_test 2.27 { 134217727 134217728 134217729 }
+do_fts3_varint_test 2.28 { 268435455 268435456 268435457 }
+do_fts3_varint_test 2.29 { 536870911 536870912 536870913 }
+do_fts3_varint_test 2.30 { 1073741823 1073741824 1073741825 }
+do_fts3_varint_test 2.31 { 2147483647 2147483648 2147483649 }
+do_fts3_varint_test 2.32 { 4294967295 4294967296 4294967297 }
+do_fts3_varint_test 2.33 { 8589934591 8589934592 8589934593 }
+do_fts3_varint_test 2.34 { 17179869183 17179869184 17179869185 }
+do_fts3_varint_test 2.35 { 34359738367 34359738368 34359738369 }
+do_fts3_varint_test 2.36 { 68719476735 68719476736 68719476737 }
+do_fts3_varint_test 2.37 { 137438953471 137438953472 137438953473 }
+do_fts3_varint_test 2.38 { 274877906943 274877906944 274877906945 }
+do_fts3_varint_test 2.39 { 549755813887 549755813888 549755813889 }
+do_fts3_varint_test 2.40 { 1099511627775 1099511627776 1099511627777 }
+do_fts3_varint_test 2.41 { 2199023255551 2199023255552 2199023255553 }
+do_fts3_varint_test 2.42 { 4398046511103 4398046511104 4398046511105 }
+do_fts3_varint_test 2.43 { 8796093022207 8796093022208 8796093022209 }
+do_fts3_varint_test 2.44 { 17592186044415 17592186044416 17592186044417 }
+do_fts3_varint_test 2.45 { 35184372088831 35184372088832 35184372088833 }
+do_fts3_varint_test 2.46 { 70368744177663 70368744177664 70368744177665 }
+do_fts3_varint_test 2.47 { 140737488355327 140737488355328 140737488355329 }
+do_fts3_varint_test 2.48 { 281474976710655 281474976710656 281474976710657 }
+do_fts3_varint_test 2.49 { 562949953421311 562949953421312 562949953421313 }
+do_fts3_varint_test 2.50 { 1125899906842623 1125899906842624 1125899906842625 }
+do_fts3_varint_test 2.51 { 2251799813685247 2251799813685248 2251799813685249 }
+do_fts3_varint_test 2.52 { 4503599627370495 4503599627370496 4503599627370497 }
+do_fts3_varint_test 2.53 { 9007199254740991 9007199254740992 9007199254740993 }
+do_fts3_varint_test 2.54 {
+ 18014398509481983 18014398509481984 18014398509481985 }
+do_fts3_varint_test 2.55 {
+ 36028797018963967 36028797018963968 36028797018963969 }
+do_fts3_varint_test 2.56 {
+ 72057594037927935 72057594037927936 72057594037927937 }
+do_fts3_varint_test 2.57 {
+ 144115188075855871 144115188075855872 144115188075855873 }
+do_fts3_varint_test 2.58 {
+ 288230376151711743 288230376151711744 288230376151711745 }
+do_fts3_varint_test 2.59 {
+ 576460752303423487 576460752303423488 576460752303423489 }
+do_fts3_varint_test 2.60 {
+ 1152921504606846975 1152921504606846976 1152921504606846977 }
+do_fts3_varint_test 2.61 {
+ 2305843009213693951 2305843009213693952 2305843009213693953 }
+do_fts3_varint_test 2.62 {
+ 4611686018427387903 4611686018427387904 4611686018427387905 }
+
+if {![catch {fts3_test_varint 18446744073709551615}]} {
+ do_fts3_varint_test 2.63 {
+ 9223372036854775807 9223372036854775808 9223372036854775809 }
+
+ do_fts3_varint_test 3.0 { 18446744073709551615 -18446744073709551615 }
+}
+
+finish_test
diff --git a/test/fts4aa.test b/test/fts4aa.test
new file mode 100644
index 0000000..0c6c0b9
--- /dev/null
+++ b/test/fts4aa.test
@@ -0,0 +1,256 @@
+# 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
+}
+
+# Create the fts_kjv_genesis procedure which fills and FTS3/4 table with
+# the complete text of the Book of Genesis.
+#
+source $testdir/genesis.tcl
+
+# 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);
+ }
+ fts_kjv_genesis
+ 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
+ }
+} {}
+ifcapable fts4_deferred {
+ 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);
+ }
+ fts_kjv_genesis
+} {}
+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);
+ }
+ fts_kjv_genesis
+} {}
+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 args} {
+ 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);
+ }
+ fts_kjv_genesis
+} {}
+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
+}
+
+# 2019-11-16 https://bugs.chromium.org/p/chromium/issues/detail?id=1025472
+#
+db close
+sqlite3 db :memory:
+do_execsql_test fts4aa-5.10 {
+ CREATE VIRTUAL TABLE t1 USING fts4(a, b, c, d, e,f,g,h,i,j,k,l,m,n,o,p,q,r);
+ INSERT INTO t1 VALUES('X Y', '2', '3', '4', '5', '6', '7', '8', '9', '0',
+ 'a','b','c','d','e','f','g','h');
+ UPDATE t1_docsize SET size=x'88' WHERE docid=1;
+} {}
+do_catchsql_test fts4aa-5.20 {
+ SELECT quote(matchinfo(t1, 'l')) FROM t1 WHERE t1 MATCH 'X Y';
+} {1 {database disk image is malformed}}
+do_execsql_test fts4aa-5.30 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts4(a,b,c,d);
+ INSERT INTO t1 VALUES('one two','three four','five six','seven eight');
+} {}
+do_catchsql_test fts4aa-5.40 {
+ UPDATE t1_stat SET value=x'01010101' WHERE id=0;
+ SELECT quote(matchinfo(t1,'a')) FROM t1 WHERE t1 MATCH 'one two';
+} {1 {database disk image is malformed}}
+do_catchsql_test fts4aa-5.50 {
+ UPDATE t1_stat SET value=x'010101' WHERE id=0;
+ SELECT quote(matchinfo(t1,'a')) FROM t1 WHERE t1 MATCH 'one two';
+} {1 {database disk image is malformed}}
+do_catchsql_test fts4aa-5.60 {
+ UPDATE t1_stat SET value=x'01' WHERE id=0;
+ SELECT quote(matchinfo(t1,'a')) FROM t1 WHERE t1 MATCH 'one two';
+} {1 {database disk image is malformed}}
+do_catchsql_test fts4aa-5.70 {
+ UPDATE t1_stat SET value=x'' WHERE id=0;
+ SELECT quote(matchinfo(t1,'a')) FROM t1 WHERE t1 MATCH 'one two';
+} {1 {database disk image is malformed}}
+
+# 2019-11-18 https://bugs.chromium.org/p/chromium/issues/detail?id=1025467
+db close
+sqlite3 db :memory:
+if {$tcl_platform(byteOrder)=="littleEndian"} {
+ set res {X'0200000000000000000000000E0000000E00000001000000010000000100000001000000'}
+} else {
+ set res {X'0000000200000000000000000000000E0000000E00000001000000010000000100000001'}
+}
+do_catchsql_test fts4aa-6.10 {
+ CREATE VIRTUAL TABLE f USING fts4();
+ INSERT INTO f_segdir VALUES (77,91,0,0,'255 77',x'0001308000004d5c4ddddddd4d4d7b4d4d4d614d8019ff4d05000001204d4d2e4d6e4d4d4d4b4d6c4d004d4d4d4d4d4d3d000000004d5d4d4d645d4d004d4d4d4d4d4d4d4d4d454d6910004d05ffff054d646c4d004d5d4d4d4d4d3d000000004d4d4d4d4d4d4d4d4d4d4d69624d4d4d04004d4d4d4d4d604d4ce1404d554d45');
+ INSERT INTO f_segdir VALUES (77,108,0,0,'255 77',x'0001310000fa64004d4d4d3c5d4d654d4d4d614d8000ff4d05000001204d4d2e4d6e4d4d4dff4d4d4d4d4d4d00104d4d4d4d000000004d4d4d0400311d4d4d4d4d4d4d4d4d4d684d6910004d05ffff054d4d6c4d004d4d4d4d4d4d3d000000004d4d4d4d644d4d4d4d4d4d69624d4d4d03ed4d4d4d4d4d604d4ce1404d550080');
+ INSERT INTO f_stat VALUES (0,x'80808080100000000064004d4d4d3c4d4d654d4d4d614d8000ff4df6ff1a00204d4d2e4d6e4d4d4d104d4d4d4d4d4d00104d4d4d4d4d4d69574d4d4d000031044d4d4d3e4d4d4c4d05004d6910');
+ SELECT quote(matchinfo(f,'pnax')) from f where f match '0 1';
+} {1 {database disk image is malformed}}
+
+# 2019-11-18 Detect infinite loop in fts3SelectLeaf()
+db close
+sqlite3 db :memory:
+do_catchsql_test fts4aa-7.10 {
+ CREATE VIRTUAL TABLE f USING fts4();
+ INSERT INTO f_segdir VALUES (63,60,60,60,'60 60',x'3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c483c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c20003c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c283c3c3c3c3c3c3c3c3c3c3c223c3c3c3c3c3c3c3c3c');
+ INSERT INTO f_segments VALUES (60,x'3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c5a3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c2a3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c5e3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c803c3c3c3c3c3c233c3c3c3c1c3c3c3c3c3c3c3c3c3c3c3c1b3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c273c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c1a3c3c3c3c3c3c000200003c3c3c3c3c3c3c3c3c3c3c3c3c383c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d898d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d3c3c3c3c3c3c3c3c3c3cba3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c1c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c00023c3c3c3c3c3c383c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3cbc3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c2c3c3c3c403c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c16161616161616163c3c3c3c3c3c3c3c3c3c3c3c3c583c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c2b3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c1c013c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c20003c3c3c3c3c3c3c3c3c3c3c800000003c3c3c3c3c3c3c2c3c3c3c3c3c3c353c08080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808f4080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808083c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c323c3c3c3c3c3c3c3c3c3c3c4f3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3cfcfcfcfcfcfcfcfcfcfcfc10fcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfd02fcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfcfc03e8fcfcfcfc3c3c3c3c3c3c8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c553c3c3c3c3c3c3c3c3c3c3c3c3c573c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c000000803c3c4dd5d5a6d52cf3d5d5d5d5d5d5d5d5d5d5d5d5d5d53c3c3c3c3f3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c2d3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c013c3c3c3c00643c3c3c3ce93c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c263c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c363c3c3c3c3c3c3c3c3c3c3c3c3c3c543c3c3c3c3c3c3c3c3c3c273c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c330000003c3c3c3c3c3c3c3c3c3c3c3c3c3c4d3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c000010003c3c3c3c3c3c413c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c1c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c403c3c3c3c3c3c3c3c3c3c3c3cec0000fa3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c2d3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c4c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c5e3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c1b3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c593c3c3c3c3c3c243c3c373c3c3c3c3cff3c3c3c3c3c3c3c3c3c3c3c3c3c000080003c3c3c3c3c3c3c3c3c3c353c3c3c3c3c3d3c3c3c3c3c3c3c3c3c3c3c3c4d3c3c3c3c3c3c3c3c3c3c3c3c3c40003c3c3c3c3c293c3c3c3c3c3c3c3c3c3d3c3c3c3c3c3c3c3c353c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c4f3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3f3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3cff7f3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c2d3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3ca43c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3cbf3c3c3c3c3c3c3c3c3c008000003c3c3c3c3c3c3c3c343c3c373c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c593c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c');
+ SELECT * from f where f match '0';
+} {1 {database disk image is malformed}}
+
+
+finish_test
diff --git a/test/fts4check.test b/test/fts4check.test
new file mode 100644
index 0000000..c94c359
--- /dev/null
+++ b/test/fts4check.test
@@ -0,0 +1,217 @@
+# 2012 March 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 FTS 'integrity-check' function,
+# used to check if the current FTS index accurately reflects the content
+# of the table.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+set ::testprefix fts4check
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Run the integrity-check on FTS table $tbl using database handle $db. If
+# the integrity-check passes, return "ok". Otherwise, throw an exception.
+#
+proc fts_integrity {db tbl} {
+ $db eval "INSERT INTO $tbl ($tbl) VALUES('integrity-check')"
+ return "ok"
+}
+
+#-------------------------------------------------------------------------
+# Test cases 1.*
+#
+# 1.0: Build a reasonably sized FTS table (5000 rows).
+#
+# 1.1: Run the integrity check code to check it passes.
+#
+# 1.2: Make a series of minor changes to the underlying FTS data structures
+# (e.g. delete or insert a row from the %_content table). Check that
+# this causes the integrity-check code to fail.
+#
+
+# Build an FTS table and check the integrity-check passes.
+#
+do_test 1.0 { fts3_build_db_1 5000 } {}
+do_test 1.1 { fts_integrity db t1 } {ok}
+
+# Mess around with the underlying tables. Check that this causes the
+# integrity-check test to fail.
+#
+foreach {tn disruption} {
+ 1 {
+ INSERT INTO t1_content(docid, c0x, c1y) VALUES(NULL, 'a', 'b');
+ }
+ 2 {
+ DELETE FROM t1_content WHERE docid = (SELECT max(docid) FROM t1_content);
+ }
+ 3 {
+ DELETE FROM t1_segdir WHERE level=0 AND idx=(
+ SELECT max(idx) FROM t1_segdir WHERE level=0
+ );
+ }
+} {
+ sqlite3_db_config db DEFENSIVE 0
+ do_execsql_test 1.2.1.$tn "BEGIN; $disruption"
+ do_catchsql_test 1.2.2.$tn {
+ INSERT INTO t1 (t1) VALUES('integrity-check')
+ } {1 {database disk image is malformed}}
+ do_execsql_test 1.2.3.$tn "ROLLBACK"
+}
+
+do_test 1.3 { fts_integrity db t1 } {ok}
+
+#-------------------------------------------------------------------------
+# Test cases 2.*
+#
+# 2.0: Build a reasonably sized FTS table (20000 rows) that includes
+# prefix indexes.
+#
+# 2.1: Run the integrity check code to check it passes.
+#
+# 2.2: Make a series of minor changes to the underlying FTS data structures
+# (e.g. delete or insert a row from the %_content table). Check that
+# this causes the integrity-check code to fail.
+#
+
+do_test 2.0 { fts3_build_db_2 -extra {prefix="3,1"} 20000 } {}
+do_test 2.1 { fts_integrity db t2 } {ok}
+foreach {tn disruption} {
+ 1 {
+ INSERT INTO t2_content VALUES(NULL, 'xyz')
+ }
+ 3 {
+ DELETE FROM t2_segdir WHERE level=0 AND idx=(
+ SELECT max(idx) FROM t2_segdir WHERE level=1024
+ );
+ }
+} {
+ sqlite3_db_config db DEFENSIVE 0
+ do_execsql_test 2.2.1.$tn "BEGIN; $disruption"
+ do_catchsql_test 2.2.2.$tn {
+ INSERT INTO t2 (t2) VALUES('integrity-check')
+ } {1 {database disk image is malformed}}
+ do_execsql_test 2.2.3.$tn "ROLLBACK"
+}
+
+
+#-------------------------------------------------------------------------
+# Test cases 3.*
+#
+# 3.0: Build a reasonably sized FTS table (5000 rows) that includes
+# prefix indexes and uses the languageid= feature.
+#
+# 3.1: Run the integrity check code to check it passes.
+#
+# 3.2: Make a series of minor changes to the underlying FTS data structures
+# (e.g. delete or insert a row from the %_content table). Check that
+# this causes the integrity-check code to fail.
+#
+do_test 3.0 {
+ reset_db
+ fts3_build_db_1 5000
+ execsql {
+ CREATE VIRTUAL TABLE t3 USING fts4(x, y, prefix="2,3", languageid=langid);
+ }
+ foreach docid [execsql {SELECT docid FROM t1 ORDER BY 1 ASC}] {
+ execsql {
+ INSERT INTO t3(x, y, langid)
+ SELECT x, y, (docid%9)*4 FROM t1 WHERE docid=$docid;
+ }
+ }
+} {}
+do_test 3.1 { fts_integrity db t3 } {ok}
+
+foreach {tn disruption} {
+ 1 {
+ INSERT INTO t3_content(c0x, c1y, langid) VALUES(NULL, 'a', 0);
+ }
+ 2 {
+ UPDATE t3_content SET langid=langid+1 WHERE rowid = (
+ SELECT max(rowid) FROM t3_content
+ )
+ }
+} {
+ sqlite3_db_config db DEFENSIVE 0
+ do_execsql_test 3.2.1.$tn "BEGIN; $disruption"
+ do_catchsql_test 3.2.2.$tn {
+ INSERT INTO t3 (t3) VALUES('integrity-check')
+ } {1 {database disk image is malformed}}
+ do_execsql_test 3.2.3.$tn "ROLLBACK"
+}
+
+#--------------------------------------------------------------------------
+# Test case 4.*
+#
+# Test that the integrity-check works if there are "notindexed" columns.
+#
+do_execsql_test 4.0 {
+ CREATE VIRTUAL TABLE t4 USING fts4(a, b, c, notindexed=b);
+ INSERT INTO t4 VALUES('text one', 'text two', 'text three');
+ INSERT INTO t4(t4) VALUES('integrity-check');
+}
+
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 4.1 {
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_master
+ SET sql = 'CREATE VIRTUAL TABLE t4 USING fts4(a, b, c)'
+ WHERE name = 't4';
+}
+
+do_test 4.2 {
+ db close
+ sqlite3 db test.db
+ catchsql {
+ INSERT INTO t4(t4) VALUES('integrity-check');
+ }
+} {1 {database disk image is malformed}}
+reset_db
+
+#--------------------------------------------------------------------------
+# Test case 5.*
+#
+# Test that the integrity-check works if there is uncommitted data.
+#
+do_execsql_test 5.0 {
+ BEGIN;
+ CREATE VIRTUAL TABLE t5 USING fts4(a, prefix="1,2,3");
+ INSERT INTO t5 VALUES('And down by Kosiosko, where the reed-banks sweep');
+ INSERT INTO t5 VALUES('and sway, and the rolling plains are wide, the');
+ INSERT INTO t5 VALUES('man from snowy river is a household name today,');
+ INSERT INTO t5 VALUES('and the stockmen tell the story of his ride');
+}
+
+do_execsql_test 5.1 {
+ INSERT INTO t5(t5) VALUES('integrity-check');
+} {}
+
+sqlite3_db_config db DEFENSIVE 0
+do_catchsql_test 5.2 {
+ INSERT INTO t5_content VALUES(5, 'his hardy mountain pony');
+ INSERT INTO t5(t5) VALUES('integrity-check');
+} {1 {database disk image is malformed}}
+
+do_execsql_test 5.3 ROLLBACK
+
+do_execsql_test 5.4 {
+ CREATE VIRTUAL TABLE t5 USING fts4(a, prefix="1,2,3");
+ INSERT INTO t5(t5) VALUES('integrity-check');
+} {}
+
+finish_test
diff --git a/test/fts4content.test b/test/fts4content.test
new file mode 100644
index 0000000..980586e
--- /dev/null
+++ b/test/fts4content.test
@@ -0,0 +1,674 @@
+# 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.
+#
+# 8.* - Test that if the content=xxx and prefix options are used together,
+# the 'rebuild' command still works.
+#
+# 9.* - Test using content=xxx where xxx is a virtual table.
+#
+# 11.* - Test that circular references (e.g. "t1(content=t1)") are
+# detected.
+#
+
+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 {no such table: main.t7}}
+
+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}}
+
+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 {no such table: main.t7}}
+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}}
+do_catchsql_test 6.2.9 {
+ SELECT * FROM ft7 WHERE ft7 MATCH '"A A"';
+} {1 {SQL logic error}}
+
+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}}
+
+#-------------------------------------------------------------------------
+# Test cases 8.*
+#
+do_execsql_test 8.1 {
+ CREATE TABLE t10(a, b);
+ INSERT INTO t10 VALUES(
+ 'abasia abasic abask', 'Abassin abastardize abatable');
+ INSERT INTO t10 VALUES(
+ 'abate abatement abater', 'abatis abatised abaton');
+ INSERT INTO t10 VALUES(
+ 'abator abattoir Abatua', 'abature abave abaxial');
+
+ CREATE VIRTUAL TABLE ft10 USING fts4(content=t10, prefix="2,4", a, b);
+}
+
+do_execsql_test 8.2 { SELECT * FROM ft10 WHERE a MATCH 'ab*'; }
+do_execsql_test 8.3 { INSERT INTO ft10(ft10) VALUES('rebuild'); }
+do_execsql_test 8.4 { SELECT rowid FROM ft10 WHERE a MATCH 'ab*'; } {1 2 3}
+do_execsql_test 8.5 { SELECT rowid FROM ft10 WHERE b MATCH 'abav*'; } {3}
+do_execsql_test 8.6 { SELECT rowid FROM ft10 WHERE ft10 MATCH 'abas*'; } {1}
+
+#-------------------------------------------------------------------------
+# Test cases 9.*
+#
+reset_db
+register_echo_module [sqlite3_connection_pointer db]
+
+do_execsql_test 9.1 {
+ CREATE TABLE tbl1(a, b);
+ INSERT INTO tbl1 VALUES('a b', 'c d');
+ INSERT INTO tbl1 VALUES('e f', 'a b');
+ CREATE VIRTUAL TABLE e1 USING echo(tbl1);
+ CREATE VIRTUAL TABLE ft1 USING fts4(content=e1);
+ INSERT INTO ft1(ft1) VALUES('rebuild');
+}
+
+do_execsql_test 9.2 {
+ SELECT rowid, * FROM ft1 WHERE ft1 MATCH 'e'
+} {2 {e f} {a b}}
+
+do_execsql_test 9.3 {
+ SELECT rowid, * FROM ft1 WHERE ft1 MATCH 'a'
+} {1 {a b} {c d} 2 {e f} {a b}}
+
+do_execsql_test 9.4 {
+ DELETE FROM ft1 WHERE docid=1;
+}
+
+do_execsql_test 9.5 {
+ SELECT rowid, * FROM ft1 WHERE ft1 MATCH 'a'
+} {2 {e f} {a b}}
+
+do_execsql_test 9.6 {
+ INSERT INTO ft1(ft1) VALUES('rebuild');
+ SELECT rowid, * FROM ft1 WHERE ft1 MATCH 'a'
+} {1 {a b} {c d} 2 {e f} {a b}}
+
+
+#-------------------------------------------------------------------------
+# Test cases 10.*
+#
+reset_db
+register_fs_module [sqlite3_connection_pointer db]
+
+proc write_file {path text} {
+ set fd [open $path w]
+ puts -nonewline $fd $text
+ close $fd
+}
+
+write_file t1.txt {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}
+write_file t2.txt {a b c d e f g h i j k l m a b c d e f g h i j k l m}
+write_file t3.txt {n o p q r s t u v w x y z n o p q r s t u v w x y z}
+
+do_execsql_test 10.1 {
+ CREATE TABLE idx(id INTEGER PRIMARY KEY, path TEXT);
+ INSERT INTO idx VALUES (1, 't1.txt');
+ INSERT INTO idx VALUES (2, 't2.txt');
+ INSERT INTO idx VALUES (3, 't3.txt');
+
+ CREATE VIRTUAL TABLE vt USING fs(idx);
+ SELECT path, data FROM vt;
+} {
+ 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 {a b c d e f g h i j k l m a b c d e f g h i j k l m}
+ 3 {n o p q r s t u v w x y z n o p q r s t u v w x y z}
+}
+
+do_execsql_test 10.2 {
+ SELECT path, data FROM vt WHERE rowid = 2;
+} {
+ 2 {a b c d e f g h i j k l m a b c d e f g h i j k l m}
+}
+
+do_execsql_test 10.3 {
+ CREATE VIRTUAL TABLE ft USING fts4(content=vt);
+ INSERT INTO ft(ft) VALUES('rebuild');
+}
+
+do_execsql_test 10.4 {
+ SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 'e'
+} {
+ {...c d [e] f g...} {...c d [e] f g...}
+}
+
+do_execsql_test 10.5 {
+ SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 't'
+} {
+ {...r s [t] u v...} {...r s [t] u v...}
+}
+
+do_execsql_test 10.6 { DELETE FROM ft WHERE docid=2 }
+
+do_execsql_test 10.7 {
+ SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 'e'
+} {
+ {...c d [e] f g...}
+}
+
+#-------------------------------------------------------------------------
+# Test cases 11.*
+#
+reset_db
+
+do_catchsql_test 11.1 {
+ CREATE VIRTUAL TABLE x1 USING fts4(content=x1);
+} {1 {vtable constructor called recursively: x1}}
+
+#---------------------------------------------------------------------------
+# Check that an fts4 table cannot be its own content table.
+#
+reset_db
+breakpoint
+do_execsql_test 12.1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(a, content=t1 );
+ INSERT INTO t1(rowid, a) VALUES(1, 'abc');
+}
+do_catchsql_test 12.1.2 {
+ SELECT * FROM t1;
+} {1 {SQL logic error}}
+do_catchsql_test 12.1.3 {
+ SELECT * FROM t1('abc');
+} {1 {SQL logic error}}
+do_catchsql_test 12.1.4 {
+ SELECT count(*) FROM t1;
+} {1 {SQL logic error}}
+
+reset_db
+do_execsql_test 12.2.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(a, content=t2 );
+ CREATE VIRTUAL TABLE t2 USING fts4(a, content=t1 );
+ INSERT INTO t1(rowid, a) VALUES(1, 'abc');
+}
+do_catchsql_test 12.2.2 {
+ SELECT * FROM t1;
+} {1 {SQL logic error}}
+do_catchsql_test 12.2.3 {
+ SELECT * FROM t1('abc');
+} {1 {SQL logic error}}
+do_catchsql_test 12.2.4 {
+ SELECT count(*) FROM t1;
+} {1 {SQL logic error}}
+
+
+
+finish_test
diff --git a/test/fts4docid.test b/test/fts4docid.test
new file mode 100644
index 0000000..2328b6e
--- /dev/null
+++ b/test/fts4docid.test
@@ -0,0 +1,116 @@
+# 2012 March 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
+source $testdir/fts3_common.tcl
+set ::testprefix fts4docid
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Initialize a table with pseudo-randomly generated data.
+#
+do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts4; }
+do_test 1.1 {
+ foreach {docid content} {
+ 0 {F N K B T I K V B A} 1 {D M J E S P H E L O}
+ 2 {W U T Q T Q T L H G} 3 {D W H M B R S Z B K}
+ 4 {F Q I N P Q J L Z D} 5 {J O Q E Y A O E L B}
+ 6 {O V R A C R K C Y H} 7 {Z J H T Q Q O R A G}
+ 8 {L K J W G D Y W B M} 9 {K E Y I A Q R Q T S}
+ 10 {N P H Y Z M R T I C} 11 {E X H O I S E S Z F}
+ 12 {B Y Q T J X C L L J} 13 {Q D C U U A Q E Z U}
+ 14 {S I T C J R X S J M} 15 {M X M K E X L H Q Y}
+ 16 {O W E I C H U Y S Y} 17 {P V V E M T H C C S}
+ 18 {L Y A M I E N M X O} 19 {S Y R U L S Q Y F P}
+ 20 {U J S T T J J S V X} 21 {T E I W P O V A A P}
+ 22 {W D K H D H F G O J} 23 {T X Y P G M J U I L}
+ 24 {F V X E B C N B K W} 25 {E B A Y N N T Z I C}
+ 26 {G E E B C P U D H G} 27 {J D J K N S B Q T M}
+ 28 {Q T G M D O D Y V G} 29 {P X W I W V P W Z G}
+ } {
+ execsql { INSERT INTO t1(docid, content) VALUES($docid, $content) }
+ }
+} {}
+
+# Quick test regarding affinites and the docid/rowid column.
+do_execsql_test 2.1.1 { SELECT docid FROM t1 WHERE docid = 5 } {5}
+do_execsql_test 2.1.2 { SELECT docid FROM t1 WHERE docid = '5' } {5}
+do_execsql_test 2.1.3 { SELECT docid FROM t1 WHERE docid = +5 } {5}
+do_execsql_test 2.1.4 { SELECT docid FROM t1 WHERE docid = +'5' } {5}
+do_execsql_test 2.1.5 { SELECT docid FROM t1 WHERE docid < 5 } {0 1 2 3 4}
+do_execsql_test 2.1.6 { SELECT docid FROM t1 WHERE docid < '5' } {0 1 2 3 4}
+
+do_execsql_test 2.2.1 { SELECT rowid FROM t1 WHERE rowid = 5 } {5}
+do_execsql_test 2.2.2 { SELECT rowid FROM t1 WHERE rowid = '5' } {5}
+do_execsql_test 2.2.3 { SELECT rowid FROM t1 WHERE rowid = +5 } {5}
+do_execsql_test 2.2.4 { SELECT rowid FROM t1 WHERE rowid = +'5' } {5}
+do_execsql_test 2.2.5 { SELECT rowid FROM t1 WHERE rowid < 5 } {0 1 2 3 4}
+do_execsql_test 2.2.6 { SELECT rowid FROM t1 WHERE rowid < '5' } {0 1 2 3 4}
+
+#-------------------------------------------------------------------------
+# Now test a bunch of full-text queries featuring range constraints on
+# the docid field. Each query is run so that the range constraint:
+#
+# * is on the docid field,
+# * is on the docid field with a unary +,
+# * is on the rowid field,
+# * is on the rowid field with a unary +.
+#
+# Queries are run with both "ORDER BY docid DESC" and "ORDER BY docid ASC"
+# clauses.
+#
+foreach {tn where result} {
+ 1 {WHERE t1 MATCH 'O' AND xxx < 17} {1 5 6 7 11 16}
+ 2 {WHERE t1 MATCH 'O' AND xxx < 4123456789123456} {1 5 6 7 11 16 18 21 22 28}
+ 3 {WHERE t1 MATCH 'O' AND xxx < 1} {}
+ 4 {WHERE t1 MATCH 'O' AND xxx < -4123456789123456} {}
+
+ 5 {WHERE t1 MATCH 'O' AND xxx > 17} {18 21 22 28}
+ 6 {WHERE t1 MATCH 'O' AND xxx > 4123456789123456} {}
+ 7 {WHERE t1 MATCH 'O' AND xxx > 1} {5 6 7 11 16 18 21 22 28}
+ 8 {WHERE t1 MATCH 'O' AND xxx > -4123456789123456} {1 5 6 7 11 16 18 21 22 28}
+
+ 9 {WHERE t1 MATCH '"Q T"' AND xxx < 27} {2 9 12}
+ 10 {WHERE t1 MATCH '"Q T"' AND xxx <= 27} {2 9 12 27}
+ 11 {WHERE t1 MATCH '"Q T"' AND xxx > 27} {28}
+ 12 {WHERE t1 MATCH '"Q T"' AND xxx >= 27} {27 28}
+} {
+ foreach {tn2 ref order} {
+ 1 docid "ORDER BY docid ASC"
+ 2 +docid "ORDER BY docid ASC"
+ 3 rowid "ORDER BY docid ASC"
+ 4 +rowid "ORDER BY docid ASC"
+
+ 5 docid "ORDER BY docid DESC"
+ 6 +docid "ORDER BY docid DESC"
+ 7 rowid "ORDER BY docid DESC"
+ 8 +rowid "ORDER BY docid DESC"
+ } {
+ set w [string map "xxx $ref" $where]
+ set q "SELECT docid FROM t1 $w $order"
+
+ if {$tn2<5} {
+ set r [lsort -integer -increasing $result]
+ } else {
+ set r [lsort -integer -decreasing $result]
+ }
+
+ do_execsql_test 3.$tn.$tn2 $q $r
+ }
+}
+
+finish_test
diff --git a/test/fts4growth.test b/test/fts4growth.test
new file mode 100644
index 0000000..5cf8777
--- /dev/null
+++ b/test/fts4growth.test
@@ -0,0 +1,441 @@
+# 2014 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 is testing the FTS4 module.
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts4growth
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+source $testdir/genesis.tcl
+
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 1.1 { CREATE VIRTUAL TABLE x1 USING fts3; }
+
+do_test 1.2 {
+ foreach L {
+ {"See here, young man," said Mulga Bill, "from Walgett to the sea,}
+ {From Conroy's Gap to Castlereagh, there's none can ride like me.}
+ {I'm good all round at everything as everybody knows,}
+ {Although I'm not the one to talk -- I hate a man that blows.}
+ } {
+ execsql { INSERT INTO x1 VALUES($L) }
+ }
+ execsql { SELECT end_block, length(root) FROM x1_segdir }
+} {{0 114} 114 {0 118} 118 {0 95} 95 {0 115} 115}
+
+do_execsql_test 1.3 {
+ INSERT INTO x1(x1) VALUES('optimize');
+ SELECT level, end_block, length(root) FROM x1_segdir;
+} {0 {0 394} 394}
+
+do_test 1.4 {
+ foreach L {
+ {But riding is my special gift, my chiefest, sole delight;}
+ {Just ask a wild duck can it swim, a wildcat can it fight.}
+ {There's nothing clothed in hair or hide, or built of flesh or steel,}
+ {There's nothing walks or jumps, or runs, on axle, hoof, or wheel,}
+ {But what I'll sit, while hide will hold and girths and straps are tight:}
+ {I'll ride this here two-wheeled concern right straight away at sight."}
+ } {
+ execsql { INSERT INTO x1 VALUES($L) }
+ }
+ execsql {
+ INSERT INTO x1(x1) VALUES('merge=4,4');
+ SELECT level, end_block, length(root) FROM x1_segdir;
+ }
+} {1 {224 921} 2}
+
+do_execsql_test 1.5 {
+ SELECT length(block) FROM x1_segments;
+} {921 {}}
+
+do_test 1.6 {
+ foreach L {
+ {'Twas Mulga Bill, from Eaglehawk, that sought his own abode,}
+ {That perched above Dead Man's Creek, beside the mountain road.}
+ {He turned the cycle down the hill and mounted for the fray,}
+ {But 'ere he'd gone a dozen yards it bolted clean away.}
+
+ {It left the track, and through the trees, just like a silver steak,}
+ {It whistled down the awful slope towards the Dead Man's Creek.}
+ {It shaved a stump by half an inch, it dodged a big white-box:}
+ {The very wallaroos in fright went scrambling up the rocks,}
+
+ {The wombats hiding in their caves dug deeper underground,}
+ {As Mulga Bill, as white as chalk, sat tight to every bound.}
+ {It struck a stone and gave a spring that cleared a fallen tree,}
+ {It raced beside a precipice as close as close could be;}
+
+ {And then as Mulga Bill let out one last despairing shriek}
+ {It made a leap of twenty feet into the Dead Man's Creek.}
+ {It shaved a stump by half an inch, it dodged a big white-box:}
+ {The very wallaroos in fright went scrambling up the rocks,}
+ {The wombats hiding in their caves dug deeper underground,}
+ } {
+ execsql { INSERT INTO x1 VALUES($L) }
+ }
+ execsql {
+ SELECT level, end_block, length(root) FROM x1_segdir;
+ }
+} {1 {224 921} 2 1 {226 1230} 7 0 {0 98} 98}
+
+do_execsql_test 1.7 {
+ SELECT sum(length(block)) FROM x1_segments WHERE blockid IN (224,225,226)
+} {1230}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 2.1 {
+ CREATE TABLE t1(docid, words);
+ CREATE VIRTUAL TABLE x2 USING fts4;
+}
+fts_kjv_genesis
+do_test 2.2 {
+ foreach id [db eval {SELECT docid FROM t1}] {
+ execsql {
+ INSERT INTO x2(docid, content) SELECT $id, words FROM t1 WHERE docid=$id
+ }
+ }
+ foreach id [db eval {SELECT docid FROM t1}] {
+ execsql {
+ INSERT INTO x2(docid, content) SELECT NULL, words FROM t1 WHERE docid=$id
+ }
+ if {[db one {SELECT count(*) FROM x2_segdir WHERE level<2}]==2} break
+ }
+} {}
+
+do_execsql_test 2.3 {
+ SELECT count(*) FROM x2_segdir WHERE level=2;
+ SELECT count(*) FROM x2_segdir WHERE level=3;
+} {6 0}
+
+do_execsql_test 2.4 {
+ INSERT INTO x2(x2) VALUES('merge=4,4');
+ SELECT count(*) FROM x2_segdir WHERE level=2;
+ SELECT count(*) FROM x2_segdir WHERE level=3;
+} {6 1}
+
+do_execsql_test 2.5 {
+ SELECT end_block FROM x2_segdir WHERE level=3;
+ INSERT INTO x2(x2) VALUES('merge=4,4');
+ SELECT end_block FROM x2_segdir WHERE level=3;
+ INSERT INTO x2(x2) VALUES('merge=4,4');
+ SELECT end_block FROM x2_segdir WHERE level=3;
+} {{5588 -3950} {5588 -11766} {5588 -15541}}
+
+do_execsql_test 2.6 {
+ SELECT sum(length(block)) FROM x2_segdir, x2_segments WHERE
+ blockid BETWEEN start_block AND leaves_end_block
+ AND level=3
+} {15541}
+
+do_execsql_test 2.7 {
+ INSERT INTO x2(x2) VALUES('merge=1000,4');
+ SELECT end_block FROM x2_segdir WHERE level=3;
+} {{5588 127563}}
+
+do_execsql_test 2.8 {
+ SELECT sum(length(block)) FROM x2_segdir, x2_segments WHERE
+ blockid BETWEEN start_block AND leaves_end_block
+ AND level=3
+} {127563}
+
+#--------------------------------------------------------------------------
+# Test that delete markers are removed from FTS segments when possible.
+# It is only possible to remove delete markers when the output of the
+# merge operation will become the oldest segment in the index.
+#
+# 3.1 - when the oldest segment is created by an 'optimize'.
+# 3.2 - when the oldest segment is created by an incremental merge.
+# 3.3 - by a crisis merge.
+#
+
+proc insert_doc {args} {
+ foreach iDoc $args {
+ set L [lindex {
+ {In your eagerness to engage the Trojans,}
+ {don’t any of you charge ahead of others,}
+ {trusting in your strength and horsemanship.}
+ {And don’t lag behind. That will hurt our charge.}
+ {Any man whose chariot confronts an enemy’s}
+ {should thrust with his spear at him from there.}
+ {That’s the most effective tactic, the way}
+ {men wiped out city strongholds long ago —}
+ {their chests full of that style and spirit.}
+ } [expr $iDoc%9]]
+ execsql { REPLACE INTO x3(docid, content) VALUES($iDoc, $L) }
+ }
+}
+
+proc delete_doc {args} {
+ foreach iDoc $args {
+ execsql { DELETE FROM x3 WHERE docid = $iDoc }
+ }
+}
+
+proc second {x} { lindex $x 1 }
+db func second second
+
+do_execsql_test 3.0 { CREATE VIRTUAL TABLE x3 USING fts4 }
+
+do_test 3.1.1 {
+ db transaction { insert_doc 1 2 3 4 5 6 }
+ execsql { SELECT level, idx, second(end_block) FROM x3_segdir }
+} {0 0 412}
+do_test 3.1.2 {
+ delete_doc 1 2 3 4 5 6
+ execsql { SELECT count(*) FROM x3_segdir }
+} {0}
+do_test 3.1.3 {
+ db transaction {
+ insert_doc 1 2 3 4 5 6 7 8 9
+ delete_doc 9 8 7
+ }
+ execsql { SELECT level, idx, second(end_block) FROM x3_segdir }
+} {0 0 591 0 1 65 0 2 72 0 3 76}
+do_test 3.1.4 {
+ execsql { INSERT INTO x3(x3) VALUES('optimize') }
+ execsql { SELECT level, idx, second(end_block) FROM x3_segdir }
+} {0 0 412}
+
+do_test 3.2.1 {
+ execsql { DELETE FROM x3 }
+ insert_doc 8 7 6 5 4 3 2 1
+ delete_doc 7 8
+ execsql { SELECT count(*) FROM x3_segdir }
+} {10}
+do_test 3.2.2 {
+ execsql { INSERT INTO x3(x3) VALUES('merge=500,10') }
+ execsql { SELECT level, idx, second(end_block) FROM x3_segdir }
+} {1 0 412}
+
+# This assumes the crisis merge happens when there are already 16
+# segments and one more is added.
+#
+do_test 3.3.1 {
+ execsql { DELETE FROM x3 }
+ insert_doc 1 2 3 4 5 6 7 8 9 10 11
+ delete_doc 11 10 9 8 7
+ execsql { SELECT count(*) FROM x3_segdir }
+} {16}
+
+do_test 3.3.2 {
+ insert_doc 12
+ execsql { SELECT level, idx, second(end_block) FROM x3_segdir WHERE level=1 }
+} {1 0 412}
+
+#--------------------------------------------------------------------------
+# Check a theory on a bug in fts4 - that segments with idx==0 were not
+# being incrementally merged correctly. Theory turned out to be false.
+#
+do_execsql_test 4.1 {
+ DROP TABLE IF EXISTS x4;
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(docid, words);
+ CREATE VIRTUAL TABLE x4 USING fts4(words);
+}
+do_test 4.2 {
+ fts_kjv_genesis
+ execsql { INSERT INTO x4 SELECT words FROM t1 }
+ execsql { INSERT INTO x4 SELECT words FROM t1 }
+} {}
+
+do_execsql_test 4.3 {
+ SELECT level, idx, second(end_block) FROM x4_segdir
+} {0 0 117483 0 1 118006}
+
+do_execsql_test 4.4 {
+ INSERT INTO x4(x4) VALUES('merge=10,2');
+ SELECT count(*) FROM x4_segdir;
+} {3}
+
+do_execsql_test 4.5 {
+ INSERT INTO x4(x4) VALUES('merge=10,2');
+ SELECT count(*) FROM x4_segdir;
+} {3}
+
+do_execsql_test 4.6 {
+ INSERT INTO x4(x4) VALUES('merge=1000,2');
+ SELECT count(*) FROM x4_segdir;
+} {1}
+
+
+
+#--------------------------------------------------------------------------
+# Check that segments are not promoted if the "end_block" field does not
+# contain a size.
+#
+do_execsql_test 5.1 {
+ DROP TABLE IF EXISTS x2;
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(docid, words);
+ CREATE VIRTUAL TABLE x2 USING fts4;
+}
+fts_kjv_genesis
+
+proc first {L} {lindex $L 0}
+db func first first
+
+do_test 5.2 {
+ foreach r [db eval { SELECT rowid FROM t1 }] {
+ execsql {
+ INSERT INTO x2(docid, content) SELECT docid, words FROM t1 WHERE rowid=$r
+ }
+ }
+ foreach d [db eval { SELECT docid FROM t1 LIMIT -1 OFFSET 20 }] {
+ execsql { DELETE FROM x2 WHERE docid = $d }
+ }
+
+ execsql {
+ INSERT INTO x2(x2) VALUES('optimize');
+ SELECT level, idx, end_block FROM x2_segdir
+ }
+} {2 0 {752 1926}}
+
+do_execsql_test 5.3 {
+ UPDATE x2_segdir SET end_block = CAST( first(end_block) AS INTEGER );
+ SELECT end_block, typeof(end_block) FROM x2_segdir;
+} {752 integer}
+
+do_execsql_test 5.4 {
+ INSERT INTO x2 SELECT words FROM t1 LIMIT 50;
+ SELECT level, idx, end_block FROM x2_segdir
+} {2 0 752 0 0 {758 5174}}
+
+do_execsql_test 5.5 {
+ UPDATE x2_segdir SET end_block = end_block || ' 1926' WHERE level=2;
+ INSERT INTO x2 SELECT words FROM t1 LIMIT 40;
+ SELECT level, idx, end_block FROM x2_segdir
+} {0 0 {752 1926} 0 1 {758 5174} 0 2 {763 4170}}
+
+proc t1_to_x2 {} {
+ foreach id [db eval {SELECT docid FROM t1 LIMIT 2}] {
+ execsql {
+ DELETE FROM x2 WHERE docid=$id;
+ INSERT INTO x2(docid, content) SELECT $id, words FROM t1 WHERE docid=$id;
+ }
+ }
+}
+
+#--------------------------------------------------------------------------
+# Check that segments created by auto-merge are not promoted until they
+# are completed.
+#
+
+do_execsql_test 6.1 {
+ CREATE VIRTUAL TABLE x5 USING fts4;
+ INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 0;
+ INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 25;
+ INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 50;
+ INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 75;
+ SELECT count(*) FROM x5_segdir
+} {4}
+
+do_execsql_test 6.2 {
+ INSERT INTO x5(x5) VALUES('merge=2,4');
+ SELECT level, idx, end_block FROM x5_segdir;
+} {0 0 {10 9216} 0 1 {21 9330} 0 2 {31 8850} 0 3 {40 8689} 1 0 {1320 -3117}}
+
+do_execsql_test 6.3 {
+ INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 100;
+ SELECT level, idx, end_block FROM x5_segdir;
+} {
+ 0 0 {10 9216} 0 1 {21 9330} 0 2 {31 8850}
+ 0 3 {40 8689} 1 0 {1320 -3117} 0 4 {1329 8297}
+}
+
+do_execsql_test 6.4 {
+ INSERT INTO x5(x5) VALUES('merge=200,4');
+ SELECT level, idx, end_block FROM x5_segdir;
+} {0 0 {1329 8297} 1 0 {1320 28009}}
+
+do_execsql_test 6.5 {
+ INSERT INTO x5 SELECT words FROM t1;
+ SELECT level, idx, end_block FROM x5_segdir;
+} {
+ 0 1 {1329 8297} 0 0 {1320 28009} 0 2 {1449 118006}
+}
+
+#--------------------------------------------------------------------------
+# Ensure that if part of an incremental merge is performed by an old
+# version that does not support storing segment sizes in the end_block
+# field, no size is stored in the final segment (as it would be incorrect).
+#
+do_execsql_test 7.1 {
+ CREATE VIRTUAL TABLE x6 USING fts4;
+ INSERT INTO x6 SELECT words FROM t1;
+ INSERT INTO x6 SELECT words FROM t1;
+ INSERT INTO x6 SELECT words FROM t1;
+ INSERT INTO x6 SELECT words FROM t1;
+ INSERT INTO x6 SELECT words FROM t1;
+ INSERT INTO x6 SELECT words FROM t1;
+ SELECT level, idx, end_block FROM x6_segdir;
+} {
+ 0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006}
+ 0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}
+}
+
+do_execsql_test 7.2 {
+ INSERT INTO x6(x6) VALUES('merge=25,4');
+ SELECT level, idx, end_block FROM x6_segdir;
+} {
+ 0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006}
+ 0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}
+ 1 0 {23694 -69477}
+}
+
+do_execsql_test 7.3 {
+ UPDATE x6_segdir SET end_block = first(end_block) WHERE level=1;
+ SELECT level, idx, end_block FROM x6_segdir;
+} {
+ 0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006}
+ 0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}
+ 1 0 23694
+}
+
+do_execsql_test 7.4 {
+ INSERT INTO x6(x6) VALUES('merge=25,4');
+ SELECT level, idx, end_block FROM x6_segdir;
+} {
+ 0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006}
+ 0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}
+ 1 0 23694
+}
+
+do_execsql_test 7.5 {
+ INSERT INTO x6(x6) VALUES('merge=2500,4');
+ SELECT level, idx, start_block, leaves_end_block, end_block FROM x6_segdir;
+} {
+ 1 0 719 1171 23694
+}
+
+do_execsql_test 7.6 {
+ INSERT INTO x6(x6) VALUES('merge=2500,2');
+ SELECT level, idx, start_block, leaves_end_block, end_block FROM x6_segdir;
+} {
+ 1 0 719 1171 23694
+}
+
+do_execsql_test 7.7 {
+ SELECT sum(length(block)) FROM x6_segments
+} {635247}
+
+
+finish_test
diff --git a/test/fts4growth2.test b/test/fts4growth2.test
new file mode 100644
index 0000000..bcccf89
--- /dev/null
+++ b/test/fts4growth2.test
@@ -0,0 +1,92 @@
+# 2014 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 is testing the FTS4 module.
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts4growth2
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+source $testdir/genesis.tcl
+
+do_execsql_test 1.0 { CREATE TABLE t1(docid, words); }
+fts_kjv_genesis
+
+proc structure {} {
+ puts [ db eval {SELECT level, count(*) FROM x1_segdir GROUP BY level} ]
+}
+
+proc tt {val} {
+ execsql {
+ DELETE FROM x1
+ WHERE docid IN (SELECT docid FROM t1 WHERE (rowid-1)%4==$val+0);
+ }
+ execsql {
+ INSERT INTO x1(docid, content)
+ SELECT docid, words FROM t1 WHERE (rowid%4)==$val+0;
+ }
+}
+
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE x1 USING fts4;
+ INSERT INTO x1(x1) VALUES('automerge=2');
+}
+
+do_test 1.2 {
+ for {set i 0} {$i < 40} {incr i} {
+ tt 0 ; tt 1 ; tt 2 ; tt 3
+ }
+ execsql {
+ SELECT max(level) FROM x1_segdir;
+ SELECT count(*) FROM x1_segdir WHERE level=2;
+ }
+} {2 1}
+
+do_test 1.3 {
+ for {set i 0} {$i < 40} {incr i} {
+ tt 0 ; tt 1 ; tt 2 ; tt 3
+ }
+ execsql {
+ SELECT max(level) FROM x1_segdir;
+ SELECT count(*) FROM x1_segdir WHERE level=2;
+ }
+} {2 1}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 2.1 {
+ DELETE FROM t1 WHERE rowid>16;
+ DROP TABLE IF EXISTS x1;
+ CREATE VIRTUAL TABLE x1 USING fts4;
+}
+
+db func second second
+proc second {L} {lindex $L 1}
+
+for {set tn 0} {$tn < 40} {incr tn} {
+ do_test 2.2.$tn {
+ for {set i 0} {$i < 100} {incr i} {
+ tt 0 ; tt 1 ; tt 2 ; tt 3
+ }
+ execsql { SELECT max(level) FROM x1_segdir }
+ } {1}
+}
+
+
+finish_test
diff --git a/test/fts4incr.test b/test/fts4incr.test
new file mode 100644
index 0000000..9210488
--- /dev/null
+++ b/test/fts4incr.test
@@ -0,0 +1,77 @@
+# 2012 March 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
+source $testdir/fts3_common.tcl
+set ::testprefix fts4incr
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Create the fts_kjv_genesis procedure which fills and FTS3/4 table
+# with the complete text of the Book of Genesis.
+#
+source $testdir/genesis.tcl
+
+do_test 1.0 {
+ execsql { CREATE VIRTUAL TABLE t1 USING fts4(words) }
+ fts_kjv_genesis
+} {}
+
+do_execsql_test 1.1 {
+ SELECT min(docid), max(docid) FROM t1;
+} {1001001 1050026}
+
+foreach {tn q res} {
+ 1 { SELECT count(*) FROM t1 WHERE t1 MATCH 'and' AND docid < 1010000} 224
+ 2 { SELECT count(*) FROM t1 WHERE t1 MATCH '"in the"' AND docid < 1010000} 47
+ 3 { SELECT count(*) FROM t1 WHERE t1 MATCH '"And God"' AND docid < 1010000} 33
+ 4 { SELECT count(*) FROM t1 WHERE t1
+ MATCH '"land of canaan"' AND docid < 1030000 } 7
+} {
+ foreach s {0 1} {
+ execsql "INSERT INTO t1(t1) VALUES('test-no-incr-doclist=$s')"
+ do_execsql_test 2.$tn.$s $q $res
+ set t($s) [lindex [time [list execsql $q] 100] 0]
+ }
+ if {0} {
+ puts "with optimization: $t(0) without: $t(1)"
+ }
+}
+
+do_test 2.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t2 USING fts4(order=DESC);
+ }
+ set num [list one two three four five six seven eight nine ten]
+ execsql BEGIN
+ for {set i 0} {$i < 10000} {incr i} {
+ set x "[lindex $num [expr $i%10]] zero"
+ execsql { INSERT INTO t2(docid, content) VALUES($i, $x) }
+ }
+ execsql COMMIT
+ execsql { INSERT INTO t2(t2) VALUES('optimize') }
+} {}
+
+do_execsql_test 2.2 {
+ SELECT count(*) FROM t2 WHERE t2 MATCH '"never zero"'
+} {0}
+
+do_execsql_test 2.3 {
+ SELECT count(*) FROM t2 WHERE t2 MATCH '"two zero"'
+} {1000}
+
+finish_test
diff --git a/test/fts4langid.test b/test/fts4langid.test
new file mode 100644
index 0000000..45e851f
--- /dev/null
+++ b/test/fts4langid.test
@@ -0,0 +1,507 @@
+# 2012 March 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 file implements regression tests for SQLite library. The
+# focus of this script is testing the languageid=xxx FTS4 option.
+#
+
+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 fts4langid
+
+#---------------------------------------------------------------------------
+# Test plan:
+#
+# 1.* - Warm-body tests created for specific purposes during development.
+# Passing these doesn't really prove much.
+#
+# 2.1.* - Test that FTS queries only ever return rows associated with
+# the requested language.
+#
+# 2.2.* - Same as 2.1.*, after an 'optimize' command.
+#
+# 2.3.* - Same as 2.1.*, after a 'rebuild' command.
+#
+# 3.* - Tests with content= tables. Both where there is a real
+# underlying content table and where there is not.
+#
+# 4.* - Test that if one is provided, the tokenizer xLanguage method
+# is called to configure the tokenizer before tokenizing query
+# or document text.
+#
+# 5.* - Test the fts4aux table when the associated FTS4 table contains
+# multiple languages.
+#
+
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(a, b, languageid=lang_id);
+}
+
+do_execsql_test 1.2 {
+ SELECT sql FROM sqlite_master WHERE name = 't1_content';
+} {{CREATE TABLE 't1_content'(docid INTEGER PRIMARY KEY, 'c0a', 'c1b', langid)}}
+
+do_execsql_test 1.3 {SELECT docid FROM t1} {}
+do_execsql_test 1.4 {SELECT lang_id FROM t1} {}
+
+do_execsql_test 1.5 {INSERT INTO t1(a, b) VALUES('aaa', 'bbb')}
+do_execsql_test 1.6 {SELECT lang_id FROM t1 } {0}
+
+do_execsql_test 1.7 {INSERT INTO t1(a, b, lang_id) VALUES('aaa', 'bbb', 4)}
+do_execsql_test 1.8 {SELECT lang_id FROM t1 } {0 4}
+
+do_execsql_test 1.9 {INSERT INTO t1(a, b, lang_id) VALUES('aaa', 'bbb', 'xyz')}
+do_execsql_test 1.10 {SELECT lang_id FROM t1} {0 4 0}
+
+do_execsql_test 1.11 {
+ CREATE VIRTUAL TABLE t2 USING fts4;
+ INSERT INTO t2 VALUES('abc');
+}
+do_execsql_test 1.12 { SELECT rowid FROM t2 WHERE content MATCH 'abc' } 1
+
+do_execsql_test 1.13 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts4(languageid=lang_id);
+ INSERT INTO t1(content) VALUES('a b c');
+ INSERT INTO t1(content, lang_id) VALUES('a b c', 1);
+}
+
+do_execsql_test 1.14 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'b';
+} {1}
+do_execsql_test 1.15 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'b' AND lang_id = 0;
+} {1}
+
+do_execsql_test 1.16 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'b' AND lang_id = 1;
+} {2}
+
+do_catchsql_test 1.17 {
+ INSERT INTO t1(content, lang_id) VALUES('123', -1);
+} {1 {constraint failed}}
+
+do_execsql_test 1.18 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts4(languageid=lang_id);
+ INSERT INTO t1(content, lang_id) VALUES('A', 13);
+ INSERT INTO t1(content, lang_id) VALUES('B', 13);
+ INSERT INTO t1(content, lang_id) VALUES('C', 13);
+ INSERT INTO t1(content, lang_id) VALUES('D', 13);
+ INSERT INTO t1(content, lang_id) VALUES('E', 13);
+ INSERT INTO t1(content, lang_id) VALUES('F', 13);
+ INSERT INTO t1(content, lang_id) VALUES('G', 13);
+ INSERT INTO t1(content, lang_id) VALUES('H', 13);
+ INSERT INTO t1(content, lang_id) VALUES('I', 13);
+ INSERT INTO t1(content, lang_id) VALUES('J', 13);
+ INSERT INTO t1(content, lang_id) VALUES('K', 13);
+ INSERT INTO t1(content, lang_id) VALUES('L', 13);
+ INSERT INTO t1(content, lang_id) VALUES('M', 13);
+ INSERT INTO t1(content, lang_id) VALUES('N', 13);
+ INSERT INTO t1(content, lang_id) VALUES('O', 13);
+ INSERT INTO t1(content, lang_id) VALUES('P', 13);
+ INSERT INTO t1(content, lang_id) VALUES('Q', 13);
+ INSERT INTO t1(content, lang_id) VALUES('R', 13);
+ INSERT INTO t1(content, lang_id) VALUES('S', 13);
+ SELECT rowid FROM t1 WHERE t1 MATCH 'A';
+} {}
+
+
+#-------------------------------------------------------------------------
+# Test cases 2.*
+#
+proc build_multilingual_db_1 {db} {
+ $db eval { CREATE VIRTUAL TABLE t2 USING fts4(x, y, languageid=l) }
+
+ set xwords [list zero one two three four five six seven eight nine ten]
+ set ywords [list alpha beta gamma delta epsilon zeta eta theta iota kappa]
+
+ for {set i 0} {$i < 1000} {incr i} {
+ set iLangid [expr $i%9]
+ set x ""
+ set y ""
+
+ set x [list]
+ lappend x [lindex $xwords [expr ($i / 1000) % 10]]
+ lappend x [lindex $xwords [expr ($i / 100) % 10]]
+ lappend x [lindex $xwords [expr ($i / 10) % 10]]
+ lappend x [lindex $xwords [expr ($i / 1) % 10]]
+
+ set y [list]
+ lappend y [lindex $ywords [expr ($i / 1000) % 10]]
+ lappend y [lindex $ywords [expr ($i / 100) % 10]]
+ lappend y [lindex $ywords [expr ($i / 10) % 10]]
+ lappend y [lindex $ywords [expr ($i / 1) % 10]]
+
+ $db eval { INSERT INTO t2(docid, x, y, l) VALUES($i, $x, $y, $iLangid) }
+ }
+
+ $db eval {
+ CREATE TABLE data(x, y, l);
+ INSERT INTO data(rowid, x, y, l) SELECT docid, x, y, l FROM t2;
+ }
+}
+
+proc rowid_list_set_langid {langid} {
+ set ::rowid_list_langid $langid
+}
+proc rowid_list {pattern} {
+ set langid $::rowid_list_langid
+ set res [list]
+ db eval {SELECT rowid, x, y FROM data WHERE l = $langid ORDER BY rowid ASC} {
+ if {[string match "*$pattern*" $x] || [string match "*$pattern*" $y]} {
+ lappend res $rowid
+ }
+ }
+ return $res
+}
+
+proc or_merge_list {list1 list2} {
+ set res [list]
+
+ set i1 0
+ set i2 0
+
+ set n1 [llength $list1]
+ set n2 [llength $list2]
+
+ while {$i1 < $n1 && $i2 < $n2} {
+ set e1 [lindex $list1 $i1]
+ set e2 [lindex $list2 $i2]
+
+ if {$e1==$e2} {
+ lappend res $e1
+ incr i1
+ incr i2
+ } elseif {$e1 < $e2} {
+ lappend res $e1
+ incr i1
+ } else {
+ lappend res $e2
+ incr i2
+ }
+ }
+
+ concat $res [lrange $list1 $i1 end] [lrange $list2 $i2 end]
+}
+
+proc or_merge_lists {args} {
+ set res [lindex $args 0]
+ for {set i 1} {$i < [llength $args]} {incr i} {
+ set res [or_merge_list $res [lindex $args $i]]
+ }
+ set res
+}
+
+proc and_merge_list {list1 list2} {
+ foreach i $list2 { set a($i) 1 }
+ set res [list]
+ foreach i $list1 {
+ if {[info exists a($i)]} {lappend res $i}
+ }
+ set res
+}
+
+
+proc and_merge_lists {args} {
+ set res [lindex $args 0]
+ for {set i 1} {$i < [llength $args]} {incr i} {
+ set res [and_merge_list $res [lindex $args $i]]
+ }
+ set res
+}
+
+proc filter_list {list langid} {
+ set res [list]
+ foreach i $list {
+ if {($i % 9) == $langid} {lappend res $i}
+ }
+ set res
+}
+
+do_test 2.0 {
+ reset_db
+ build_multilingual_db_1 db
+} {}
+
+proc do_test_query1 {tn query res_script} {
+ for {set langid 0} {$langid < 10} {incr langid} {
+ rowid_list_set_langid $langid
+ set res [eval $res_script]
+
+ set actual [
+ execsql {SELECT docid FROM t2 WHERE t2 MATCH $query AND l = $langid}
+ ]
+ do_test $tn.$langid [list set {} $actual] $res
+ }
+}
+
+# Run some queries.
+do_test_query1 2.1.1 {delta} { rowid_list delta }
+do_test_query1 2.1.2 {"zero one two"} { rowid_list "zero one two" }
+do_test_query1 2.1.3 {zero one two} {
+ and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]
+}
+do_test_query1 2.1.4 {"zero one" OR "one two"} {
+ or_merge_lists [rowid_list "zero one"] [rowid_list "one two"]
+}
+
+# Now try the same tests as above, but after running the 'optimize'
+# command on the FTS table.
+#
+do_execsql_test 2.2 {
+ INSERT INTO t2(t2) VALUES('optimize');
+ SELECT count(*) FROM t2_segdir;
+} {9}
+do_test_query1 2.2.1 {delta} { rowid_list delta }
+do_test_query1 2.2.2 {"zero one two"} { rowid_list "zero one two" }
+do_test_query1 2.2.3 {zero one two} {
+ and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]
+}
+do_test_query1 2.2.4 {"zero one" OR "one two"} {
+ or_merge_lists [rowid_list "zero one"] [rowid_list "one two"]
+}
+
+# And rebuild.
+#
+do_test 2.3 {
+ reset_db
+ build_multilingual_db_1 db
+ execsql { INSERT INTO t2(t2) VALUES('rebuild') }
+} {}
+do_test_query1 2.3.1 {delta} { rowid_list delta }
+do_test_query1 2.3.2 {"zero one two"} { rowid_list "zero one two" }
+do_test_query1 2.3.3 {zero one two} {
+ and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]
+}
+do_test_query1 2.3.4 {"zero one" OR "one two"} {
+ or_merge_lists [rowid_list "zero one"] [rowid_list "one two"]
+}
+
+#-------------------------------------------------------------------------
+# Test cases 3.*
+#
+do_test 3.0 {
+ reset_db
+ build_multilingual_db_1 db
+ execsql {
+ CREATE TABLE t3_data(l, x, y);
+ INSERT INTO t3_data(rowid, l, x, y) SELECT docid, l, x, y FROM t2;
+ DROP TABLE t2;
+ }
+} {}
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4(content=t3_data, languageid=l);
+ INSERT INTO t2(t2) VALUES('rebuild');
+}
+
+do_test_query1 3.1.1 {delta} { rowid_list delta }
+do_test_query1 3.1.2 {"zero one two"} { rowid_list "zero one two" }
+do_test_query1 3.1.3 {zero one two} {
+ and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]
+}
+do_test_query1 3.1.4 {"zero one" OR "one two"} {
+ or_merge_lists [rowid_list "zero one"] [rowid_list "one two"]
+}
+
+do_execsql_test 3.2.1 {
+ DROP TABLE t2;
+ CREATE VIRTUAL TABLE t2 USING fts4(x, y, languageid=l, content=nosuchtable);
+}
+
+do_execsql_test 3.2.2 {
+ INSERT INTO t2(docid, x, y, l) SELECT rowid, x, y, l FROM t3_data;
+}
+
+do_execsql_test 3.2.3 {
+ DROP TABLE t3_data;
+}
+
+do_test_query1 3.3.1 {delta} { rowid_list delta }
+do_test_query1 3.3.2 {"zero one two"} { rowid_list "zero one two" }
+do_test_query1 3.3.3 {zero one two} {
+ and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]
+}
+do_test_query1 3.3.4 {"zero one" OR "one two"} {
+ or_merge_lists [rowid_list "zero one"] [rowid_list "one two"]
+}
+
+do_execsql_test 3.4 {
+ CREATE TABLE t8c(a, b);
+ CREATE VIRTUAL TABLE t8 USING fts4(content=t8c, languageid=langid);
+ INSERT INTO t8(docid, a, b) VALUES(-1, 'one two three', 'x y z');
+ SELECT docid FROM t8 WHERE t8 MATCH 'one x' AND langid=0
+} {-1}
+
+#-------------------------------------------------------------------------
+# Test cases 4.*
+#
+proc build_multilingual_db_2 {db} {
+ $db eval {
+ CREATE VIRTUAL TABLE t4 USING fts4(
+ tokenize=testtokenizer,
+ languageid=lid
+ );
+ }
+ for {set i 0} {$i < 50} {incr i} {
+ execsql {
+ INSERT INTO t4(docid, content, lid) VALUES($i, 'The Quick Brown Fox', $i)
+ }
+ }
+}
+
+do_test 4.1.0 {
+ reset_db
+ set ptr [fts3_test_tokenizer]
+ sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1
+ execsql { SELECT fts3_tokenizer('testtokenizer', $ptr) }
+ build_multilingual_db_2 db
+} {}
+do_execsql_test 4.1.1 {
+ SELECT docid FROM t4 WHERE t4 MATCH 'quick';
+} {0}
+do_execsql_test 4.1.2 {
+ SELECT docid FROM t4 WHERE t4 MATCH 'quick' AND lid=1;
+} {}
+do_execsql_test 4.1.3 {
+ SELECT docid FROM t4 WHERE t4 MATCH 'Quick' AND lid=1;
+} {1}
+for {set i 0} {$i < 50} {incr i} {
+ do_execsql_test 4.1.4.$i {
+ SELECT count(*) FROM t4 WHERE t4 MATCH 'fox' AND lid=$i;
+ } [expr 0==($i%2)]
+}
+do_catchsql_test 4.1.5 {
+ INSERT INTO t4(content, lid) VALUES('hello world', 101)
+} {1 {SQL logic error}}
+
+#-------------------------------------------------------------------------
+# Test cases 5.*
+#
+# The following test cases are designed to detect a 32-bit overflow bug
+# that existed at one point.
+#
+proc build_multilingual_db_3 {db} {
+ $db eval {
+ CREATE VIRTUAL TABLE t5 USING fts4(languageid=lid);
+ }
+ set languages [list 0 1 2 [expr 1<<30]]
+
+ foreach lid $languages {
+ execsql {
+ INSERT INTO t5(docid, content, lid) VALUES(
+ $lid, 'My language is ' || $lid, $lid
+ )
+ }
+ }
+}
+
+do_test 5.1.0 {
+ reset_db
+ build_multilingual_db_3 db
+} {}
+
+do_execsql_test 5.1.1 {
+ SELECT level FROM t5_segdir;
+} [list 0 1024 2048 [expr 1<<40]]
+
+do_execsql_test 5.1.2 {SELECT docid FROM t5 WHERE t5 MATCH 'language'} 0
+foreach langid [list 0 1 2 [expr 1<<30]] {
+ do_execsql_test 5.2.$langid {
+ SELECT docid FROM t5 WHERE t5 MATCH 'language' AND lid = $langid
+ } $langid
+}
+
+set lid [expr 1<<30]
+do_execsql_test 5.3.1 {
+ CREATE VIRTUAL TABLE t6 USING fts4(languageid=lid);
+ INSERT INTO t6 VALUES('I belong to language 0!');
+}
+do_test 5.3.2 {
+ for {set i 0} {$i < 20} {incr i} {
+ execsql {
+ INSERT INTO t6(content, lid) VALUES(
+ 'I (row '||$i||') belong to langauge N!', $lid
+ );
+ }
+ }
+ execsql { SELECT docid FROM t6 WHERE t6 MATCH 'belong' }
+} {1}
+
+do_test 5.3.3 {
+ execsql { SELECT docid FROM t6 WHERE t6 MATCH 'belong' AND lid=$lid}
+} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21}
+
+do_execsql_test 5.3.4 { INSERT INTO t6(t6) VALUES('optimize') } {}
+do_execsql_test 5.3.5 { SELECT docid FROM t6 WHERE t6 MATCH 'belong' } {1}
+do_execsql_test 5.3.6 {
+ SELECT docid FROM t6 WHERE t6 MATCH 'belong' AND lid=$lid
+} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21}
+
+
+set lid [expr 1<<30]
+foreach lid [list 4 [expr 1<<30]] {
+ do_execsql_test 5.4.$lid.1 {
+ DELETE FROM t6;
+ SELECT count(*) FROM t6_segdir;
+ SELECT count(*) FROM t6_segments;
+ } {0 0}
+ do_execsql_test 5.4.$lid.2 {
+ INSERT INTO t6(content, lid) VALUES('zero zero zero', $lid);
+ INSERT INTO t6(content, lid) VALUES('zero zero one', $lid);
+ INSERT INTO t6(content, lid) VALUES('zero one zero', $lid);
+ INSERT INTO t6(content, lid) VALUES('zero one one', $lid);
+ INSERT INTO t6(content, lid) VALUES('one zero zero', $lid);
+ INSERT INTO t6(content, lid) VALUES('one zero one', $lid);
+ INSERT INTO t6(content, lid) VALUES('one one zero', $lid);
+ INSERT INTO t6(content, lid) VALUES('one one one', $lid);
+
+ SELECT docid FROM t6 WHERE t6 MATCH '"zero zero"' AND lid=$lid;
+ } {1 2 5}
+
+ do_execsql_test 5.4.$lid.3 {
+ SELECT count(*) FROM t6_segdir;
+ SELECT count(*) FROM t6_segments;
+ } {8 0}
+
+ do_execsql_test 5.4.$lid.4 {
+ INSERT INTO t6(t6) VALUES('merge=100,3');
+ INSERT INTO t6(t6) VALUES('merge=100,3');
+ SELECT docid FROM t6 WHERE t6 MATCH '"zero zero"' AND lid=$lid;
+ } {1 2 5}
+
+ do_execsql_test 5.4.$lid.5 {
+ SELECT count(*) FROM t6_segdir;
+ SELECT count(*) FROM t6_segments;
+ } {1 2}
+}
+
+reset_db
+do_execsql_test 6.0 {
+ CREATE VIRTUAL TABLE vt0 USING fts4(c0, languageid="lid");
+ INSERT INTO vt0 VALUES ('a'), ('b');
+ BEGIN;
+ UPDATE vt0 SET lid = 1 WHERE lid=0;
+}
+do_execsql_test 6.1 {
+ INSERT INTO vt0(vt0) VALUES('integrity-check');
+}
+do_execsql_test 6.2 {
+ COMMIT;
+ INSERT INTO vt0(vt0) VALUES('integrity-check');
+}
+finish_test
diff --git a/test/fts4lastrowid.test b/test/fts4lastrowid.test
new file mode 100644
index 0000000..7b35e3c
--- /dev/null
+++ b/test/fts4lastrowid.test
@@ -0,0 +1,72 @@
+# 2017 Feb 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.
+#
+#***********************************************************************
+#
+# Tests of the last_insert_rowid functionality with fts4.
+#
+
+set testdir [file dirname $argv0]
+source [file join [file dirname [info script]] tester.tcl]
+set testprefix fts4lastrowid
+
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING fts4(str);
+}
+
+do_execsql_test 1.1 {
+ INSERT INTO t1 VALUES('one string');
+ INSERT INTO t1 VALUES('two string');
+ INSERT INTO t1 VALUES('three string');
+ SELECT last_insert_rowid();
+} {3}
+
+do_execsql_test 1.2 {
+ BEGIN;
+ INSERT INTO t1 VALUES('one string');
+ INSERT INTO t1 VALUES('two string');
+ INSERT INTO t1 VALUES('three string');
+ COMMIT;
+ SELECT last_insert_rowid();
+} {6}
+
+do_execsql_test 1.3 {
+ INSERT INTO t1(rowid, str) VALUES(-22, 'some more text');
+ SELECT last_insert_rowid();
+} {-22}
+
+do_execsql_test 1.4 {
+ BEGIN;
+ INSERT INTO t1(rowid, str) VALUES(45, 'some more text');
+ INSERT INTO t1(rowid, str) VALUES(46, 'some more text');
+ INSERT INTO t1(rowid, str) VALUES(222, 'some more text');
+ SELECT last_insert_rowid();
+ COMMIT;
+ SELECT last_insert_rowid();
+} {222 222}
+
+do_execsql_test 1.5 {
+ CREATE TABLE x1(x);
+ INSERT INTO x1 VALUES('john'), ('paul'), ('george'), ('ringo');
+ INSERT INTO t1 SELECT x FROM x1;
+ SELECT last_insert_rowid();
+} {226}
+
+do_execsql_test 1.6 {
+ INSERT INTO t1(rowid, str) SELECT rowid+10, x FROM x1;
+ SELECT last_insert_rowid();
+} {14}
+
+
+finish_test
diff --git a/test/fts4merge.test b/test/fts4merge.test
new file mode 100644
index 0000000..3cd6932
--- /dev/null
+++ b/test/fts4merge.test
@@ -0,0 +1,347 @@
+# 2012 March 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 script is testing the incremental merge function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+proc fts3_integrity_check {tbl} {
+ db eval "INSERT INTO $tbl ($tbl) VALUES('integrity-check')"
+ return "ok"
+}
+
+foreach mod {fts3 fts4} {
+ set ::testprefix fts4merge-$mod
+ reset_db
+
+ #-------------------------------------------------------------------------
+ # Test cases 1.*
+ #
+ do_test 1.0 { fts3_build_db_1 -module $mod 1004 } {}
+ do_test 1.1 { fts3_integrity_check t1 } {ok}
+ do_execsql_test 1.1 {
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level
+ } {
+ 0 {0 1 2 3 4 5 6 7 8 9 10 11}
+ 1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13}
+ 2 {0 1 2}
+ }
+
+ for {set i 0} {$i<20} {incr i} {
+ do_execsql_test 1.2.$i.1 { INSERT INTO t1(t1) VALUES('merge=1') }
+ do_test 1.2.$i.2 { fts3_integrity_check t1 } ok
+ do_execsql_test 1.2.$i.3 {
+ SELECT docid FROM t1 WHERE t1 MATCH 'zero one two three'
+ } {123 132 213 231 312 321}
+ }
+
+ do_execsql_test 1.3 {
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level
+ } {
+ 2 {0 1 2 3}
+ }
+
+ for {set i 0} {$i<100} {incr i} {
+ do_execsql_test 1.4.$i { INSERT INTO t1(t1) VALUES('merge=1,4') }
+ do_test 1.4.$i.2 { fts3_integrity_check t1 } ok
+ do_execsql_test 1.4.$i.3 {
+ SELECT docid FROM t1 WHERE t1 MATCH 'zero one two three'
+ } {123 132 213 231 312 321}
+ }
+
+ do_execsql_test 1.5 {
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level
+ } {
+ 3 0
+ }
+
+ #-------------------------------------------------------------------------
+ # Test cases 2.* test that errors in the xxx part of the 'merge=xxx' are
+ # handled correctly.
+ #
+ do_execsql_test 2.0 "CREATE VIRTUAL TABLE t2 USING $mod"
+
+ foreach {tn arg} {
+ 1 {merge=abc}
+ 2 {merge=%%%}
+ 3 {merge=,}
+ 4 {merge=5,}
+ 5 {merge=6,%}
+ 6 {merge=6,six}
+ 7 {merge=6,1}
+ } {
+ do_catchsql_test 2.$tn {
+ INSERT INTO t2(t2) VALUES($arg);
+ } {1 {SQL logic error}}
+ }
+
+ #-------------------------------------------------------------------------
+ # Test cases 3.*
+ #
+ do_test 3.0 {
+ reset_db
+ execsql { PRAGMA page_size = 512 }
+ fts3_build_db_2 -module $mod 30040
+ } {}
+ do_test 3.1 { fts3_integrity_check t2 } {ok}
+
+ do_execsql_test 3.2 {
+ SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level
+ } {
+ 0 {0 1 2 3 4 5 6}
+ 1 {0 1 2 3 4}
+ 2 {0 1 2 3 4}
+ 3 {0 1 2 3 4 5 6}
+ }
+
+ do_execsql_test 3.3 {
+ INSERT INTO t2(t2) VALUES('merge=1000000,2');
+ SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level
+ } {
+ 4 0
+ }
+
+ #-------------------------------------------------------------------------
+ # Test cases 4.*
+ #
+ reset_db
+ do_execsql_test 4.1 "
+ PRAGMA page_size = 512;
+ CREATE VIRTUAL TABLE t4 USING $mod;
+ PRAGMA main.page_size;
+ " {512}
+
+ do_test 4.2 {
+ foreach x {a c b d e f g h i j k l m n o p} {
+ execsql "INSERT INTO t4 VALUES('[string repeat $x 600]')"
+ }
+ execsql {SELECT level, group_concat(idx, ' ') FROM t4_segdir GROUP BY level}
+ } {0 {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}}
+
+ foreach {tn expect} {
+ 1 "0 {0 1 2 3 4 5 6 7 8 9 10 11 12 13} 1 0"
+ 2 "0 {0 1 2 3 4 5 6 7 8 9 10 11 12} 1 0"
+ 3 "0 {0 1 2 3 4 5 6 7 8 9 10 11} 1 0"
+ 4 "0 {0 1 2 3 4 5 6 7 8 9 10} 1 0"
+ 5 "0 {0 1 2 3 4 5 6 7 8 9} 1 0"
+ 6 "0 {0 1 2 3 4 5 6 7 8} 1 0"
+ 7 "0 {0 1 2 3 4 5 6 7} 1 0"
+ 8 "0 {0 1 2 3 4 5 6} 1 0"
+ 9 "0 {0 1 2 3 4 5} 1 0"
+ } {
+ do_execsql_test 4.3.$tn {
+ INSERT INTO t4(t4) VALUES('merge=1,16');
+ SELECT level, group_concat(idx, ' ') FROM t4_segdir GROUP BY level;
+ } $expect
+ }
+
+ do_execsql_test 4.4.1 {
+ SELECT quote(value) FROM t4_stat WHERE rowid=1
+ } {X'0006'}
+
+ sqlite3_db_config db DEFENSIVE 0
+ do_execsql_test 4.4.2 {
+ DELETE FROM t4_stat WHERE rowid=1;
+ INSERT INTO t4(t4) VALUES('merge=1,12');
+ SELECT level, group_concat(idx, ' ') FROM t4_segdir GROUP BY level;
+ } "0 {0 1 2 3 4 5} 1 0"
+
+
+ #-------------------------------------------------------------------------
+ # Test cases 5.*
+ #
+ # Test that if a crisis-merge occurs that disrupts an ongoing incremental
+ # merge, the next call to "merge=A,B" identifies this and starts a new
+ # incremental merge. There are two scenarios:
+ #
+ # * There are less segments on the input level that the disrupted
+ # incremental merge operated on, or
+ #
+ # * Sufficient segments exist on the input level but the segments
+ # contain keys smaller than the largest key in the potential output
+ # segment.
+ #
+ do_test 5.1 {
+ reset_db
+ fts3_build_db_1 -module $mod 1000
+ } {}
+
+ do_execsql_test 5.2 {
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
+ } {
+ 0 {0 1 2 3 4 5 6 7}
+ 1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13}
+ 2 {0 1 2}
+ }
+
+ do_execsql_test 5.3 {
+ INSERT INTO t1(t1) VALUES('merge=1,5');
+ INSERT INTO t1(t1) VALUES('merge=1,5');
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
+ } {
+ 1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+ 2 {0 1 2 3}
+ }
+
+ do_execsql_test 5.4 {SELECT quote(value) from t1_stat WHERE rowid=1} {X'010F'}
+ do_test 5.5 {
+ foreach docid [execsql {SELECT docid FROM t1}] {
+ execsql {INSERT INTO t1 SELECT * FROM t1 WHERE docid=$docid}
+ }
+ } {}
+
+ do_execsql_test 5.6 {SELECT quote(value) from t1_stat WHERE rowid=1} {X'010F'}
+
+ do_execsql_test 5.7 {
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
+ SELECT quote(value) from t1_stat WHERE rowid=1;
+ } {
+ 0 {0 1 2 3 4 5 6 7}
+ 1 {0 1 2 3 4 5 6 7 8 9 10 11 12}
+ 2 {0 1 2 3 4 5 6 7}
+ X'010F'
+ }
+
+ do_execsql_test 5.8 {
+ INSERT INTO t1(t1) VALUES('merge=1,6');
+ INSERT INTO t1(t1) VALUES('merge=1,6');
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
+ SELECT quote(value) from t1_stat WHERE rowid=1;
+ } {
+ 1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13}
+ 2 {0 1 2 3 4 5 6 7 8} X'010E'
+ }
+
+ do_test 5.8.1 { fts3_integrity_check t1 } ok
+
+ do_test 5.9 {
+ set L [expr 16*16*7 + 16*3 + 12]
+ foreach docid [execsql {
+ SELECT docid FROM t1 UNION ALL SELECT docid FROM t1 LIMIT $L
+ }] {
+ execsql {INSERT INTO t1 SELECT * FROM t1 WHERE docid=$docid}
+ }
+ } {}
+
+ do_execsql_test 5.10 {
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
+ SELECT quote(value) from t1_stat WHERE rowid=1;
+ } {
+ 0 {0 1 2 3 4 5 6 7 8 9 10 11} 1 0 2 0 3 0 X'010E'
+ }
+
+ do_execsql_test 5.11 {
+ INSERT INTO t1(t1) VALUES('merge=1,6');
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
+ SELECT quote(value) from t1_stat WHERE rowid=1;
+ } {
+ 1 {0 1} 2 0 3 0 X'010E'
+ }
+
+ #-------------------------------------------------------------------------
+ # Test cases 6.*
+ #
+ # At one point the following test caused an assert() to fail (because the
+ # second 'merge=1,2' operation below actually "merges" a single input
+ # segment, which was unexpected).
+ #
+ do_test 6.1 {
+ reset_db
+ set a [string repeat a 900]
+ set b [string repeat b 900]
+ set c [string repeat c 900]
+ set d [string repeat d 900]
+
+ execsql "CREATE VIRTUAL TABLE t1 USING $mod"
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES($a);
+ INSERT INTO t1 VALUES($b);
+ COMMIT;
+ BEGIN;
+ INSERT INTO t1 VALUES($c);
+ INSERT INTO t1 VALUES($d);
+ COMMIT;
+ }
+
+ execsql {
+ INSERT INTO t1(t1) VALUES('merge=1,2');
+ INSERT INTO t1(t1) VALUES('merge=1,2');
+ }
+ } {}
+
+ #-------------------------------------------------------------------------
+ # Test cases 7.*
+ #
+ # Test that the value returned by sqlite3_total_changes() increases by
+ # 1 following a no-op "merge=A,B", or by more than 1 if actual work is
+ # performed.
+ #
+ do_test 7.0 {
+ reset_db
+ fts3_build_db_1 -module $mod 1000
+ } {}
+
+ do_execsql_test 7.1 {
+ SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level
+ } {
+ 0 {0 1 2 3 4 5 6 7}
+ 1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13}
+ 2 {0 1 2}
+ }
+ do_test 7.2 {
+ set x [db total_changes]
+ execsql { INSERT INTO t1(t1) VALUES('merge=2,10') }
+ expr { ([db total_changes] - $x)>1 }
+ } {1}
+ do_test 7.3 {
+ set x [db total_changes]
+ execsql { INSERT INTO t1(t1) VALUES('merge=200,10') }
+ expr { ([db total_changes] - $x)>1 }
+ } {1}
+ do_test 7.4 {
+ set x [db total_changes]
+ execsql { INSERT INTO t1(t1) VALUES('merge=200,10') }
+ expr { ([db total_changes] - $x)>1 }
+ } {0}
+ do_test 7.5 {
+ set x [db total_changes]
+ execsql { INSERT INTO t1(t1) VALUES('merge=200,10') }
+ expr { ([db total_changes] - $x)>1 }
+ } {0}
+}
+
+#-------------------------------------------------------------------------
+# Test cases 8.* - ticket [bf1aab89].
+#
+set testprefix fts4merge
+reset_db
+do_execsql_test 8.0 {
+ CREATE VIRTUAL TABLE t1 USING fts4(a, order=DESC);
+ INSERT INTO t1(a) VALUES (0);
+ INSERT INTO t1(a) VALUES (0);
+ UPDATE t1 SET a = NULL;
+}
+
+do_execsql_test 8.1 {
+ INSERT INTO t1(t1) VALUES('merge=1,4');
+}
+
+finish_test
diff --git a/test/fts4merge2.test b/test/fts4merge2.test
new file mode 100644
index 0000000..308b692
--- /dev/null
+++ b/test/fts4merge2.test
@@ -0,0 +1,38 @@
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+source $testdir/malloc_common.tcl
+set ::testprefix fts4merge2
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_test 1.0 {
+ fts3_build_db_1 1000
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test 1.1 -faults oom-* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { INSERT INTO t1(t1) VALUES('merge=32,4') }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 1.2 -faults oom-t* -prep {
+ if {$iFail<100} {set iFail 803}
+ faultsim_restore_and_reopen
+} -body {
+ execsql { INSERT INTO t1(t1) VALUES('merge=1,2') }
+ execsql { INSERT INTO t1(t1) VALUES('merge=1,2') }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/fts4merge3.test b/test/fts4merge3.test
new file mode 100644
index 0000000..08b68b9
--- /dev/null
+++ b/test/fts4merge3.test
@@ -0,0 +1,105 @@
+# 2012 March 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 script is testing the incremental merge function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+source $testdir/lock_common.tcl
+source $testdir/bc_common.tcl
+
+set ::testprefix fts4merge3
+
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+if {"" == [bc_find_binaries backcompat.test]} {
+ finish_test
+ return
+}
+
+db close
+do_all_bc_test {
+
+ sql2 { PRAGMA page_size = 512 }
+ if { 0==[catch { sql2 { CREATE VIRTUAL TABLE x USING fts4 } } ] } {
+
+ # Build a large database.
+ set msg "this takes around 12 seconds"
+ do_test "1.1 ($msg)" { fts3_build_db_2 20000 } {}
+
+ # Run some queries on it, using the old and new versions.
+ do_test 1.2 { sql1 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'" } {1485}
+ do_test 1.3 { sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'" } {1485}
+
+ do_test 1.4 {
+ set x [sql2 "PRAGMA page_count"]
+ expr {$x>=1284 && $x<=1286}
+ } {1}
+ do_test 1.5 { sql2 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
+ } } [list 0 15 1 1 2 14 3 4]
+
+ # Run some incr-merge operations on the db.
+ for {set i 0} {$i<10} {incr i} {
+ do_test 1.6.$i.1 { sql1 { INSERT INTO t2(t2) VALUES('merge=2,2') } } {}
+ do_test 1.6.$i.2 {
+ sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'"
+ } {1485}
+ }
+
+ do_test 1.7 { sql2 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
+ } } {2 15 3 5}
+
+ # Using the old connection, insert many rows.
+ do_test 1.8 {
+ for {set i 0} {$i < 1500} {incr i} {
+ sql2 "INSERT INTO t2 SELECT content FROM t2 WHERE docid = $i"
+ }
+ } {}
+
+ do_test 1.9 { sql2 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
+ } } [list 0 12 1 13 2 4 3 6]
+
+ # Run a big incr-merge operation on the db.
+ do_test 1.10 { sql1 { INSERT INTO t2(t2) VALUES('merge=2000,2') } } {}
+ do_test 1.11 {
+ sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'"
+ } {1485 21485}
+
+ do_test 1.12 {
+ for {set i 0} {$i < 1500} {incr i} {
+ sql2 "INSERT INTO t2 SELECT content FROM t2 WHERE docid = $i"
+ }
+ } {}
+ do_test 1.13 {
+ sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'"
+ } {1485 21485 22985}
+
+ do_test 1.14 {
+ sql2 "INSERT INTO t2(t2) VALUES('optimize')"
+ sql2 "SELECT docid FROM t2 WHERE t2 MATCH 'abc'"
+ } {1485 21485 22985}
+
+ do_test 1.15 { sql2 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
+ } } {4 1}
+ }
+}
+
+
+finish_test
diff --git a/test/fts4merge4.test b/test/fts4merge4.test
new file mode 100644
index 0000000..12328c2
--- /dev/null
+++ b/test/fts4merge4.test
@@ -0,0 +1,102 @@
+# 2013 May 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+set ::testprefix fts4merge4
+
+ifcapable !fts3||!shared_cache {
+ finish_test
+ return
+}
+
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+do_execsql_test 1.1 { CREATE VIRTUAL TABLE t1 USING fts4 }
+
+do_test 1.2 {
+ for {set i 0} {$i < 2000} {incr i} {
+ execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
+ }
+} {}
+
+do_test 1.3 {
+ execsql BEGIN
+ for {set i 0} {$i < 2000} {incr i} {
+ execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
+ }
+ execsql {
+ INSERT INTO t1(t1) VALUES('merge=8,50');
+ COMMIT
+ }
+} {}
+
+reset_db
+do_execsql_test 2.0 { CREATE VIRTUAL TABLE t1 USING fts4 }
+do_test 2.1 {
+ for {set i 0} {$i < 2000} {incr i} {
+ execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
+ }
+} {}
+do_execsql_test 2.2 { SELECT count(*) FROM t1_segdir; } 35
+do_execsql_test 2.3 { INSERT INTO t1(t1) VALUES('optimize') } {}
+do_execsql_test 2.4 { SELECT count(*) FROM t1_segdir; } 1
+
+#-------------------------------------------------------------------------
+# Now test that the automerge=? option appears to work.
+#
+do_execsql_test 2.1 { CREATE VIRTUAL TABLE t2 USING fts4; }
+
+set doc ""
+foreach c1 "a b c d e f g h i j" {
+ foreach c2 "a b c d e f g h i j" {
+ foreach c3 "a b c d e f g h i j" {
+ lappend doc "$c1$c2$c3"
+ }
+ }
+}
+set doc [string repeat $doc 10]
+
+foreach {tn am expected} {
+ 1 {automerge=2} {1 1 2 1 4 1 6 1}
+ 2 {automerge=4} {1 2 2 1 3 1}
+ 3 {automerge=8} {0 4 1 3 2 1}
+ 4 {automerge=1} {0 4 1 3 2 1}
+} {
+ foreach {tn2 openclose} {1 {} 2 { db close ; sqlite3 db test.db }} {
+ do_test 2.2.$tn.$tn2 {
+ execsql { DELETE FROM t2 }
+ execsql { INSERT INTO t2(t2) VALUES($am) };
+
+ eval $openclose
+
+ for {set i 0} {$i < 100} {incr i} {
+ execsql {
+ BEGIN;
+ INSERT INTO t2 VALUES($doc);
+ INSERT INTO t2 VALUES($doc);
+ INSERT INTO t2 VALUES($doc);
+ INSERT INTO t2 VALUES($doc);
+ INSERT INTO t2 VALUES($doc);
+ COMMIT;
+ }
+ }
+
+ execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }
+ } [list {*}$expected]
+ }
+}
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/fts4merge5.test b/test/fts4merge5.test
new file mode 100644
index 0000000..1fad778
--- /dev/null
+++ b/test/fts4merge5.test
@@ -0,0 +1,58 @@
+# 2019 October 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
+set testprefix fts4merge5
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+source $testdir/genesis.tcl
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(docid, words);
+}
+fts_kjv_genesis
+
+do_execsql_test 1.2 {
+ CREATE VIRTUAL TABLE x1 USING fts3;
+ INSERT INTO x1(x1) VALUES('nodesize=64');
+ INSERT INTO x1(x1) VALUES('maxpending=64');
+}
+
+do_execsql_test 1.3 {
+ INSERT INTO x1(docid, content) SELECT * FROM t1;
+}
+
+for {set tn 1} {1} {incr tn} {
+ set tc1 [db total_changes]
+ do_execsql_test 1.4.$tn.1 {
+ INSERT INTO x1(x1) VALUES('merge=1,2');
+ }
+ set tc2 [db total_changes]
+
+ if {($tc2 - $tc1)<2} break
+
+ do_execsql_test 1.4.$tn.1 {
+ INSERT INTO x1(x1) VALUES('integrity-check');
+ }
+}
+
+
+
+finish_test
diff --git a/test/fts4min.test b/test/fts4min.test
new file mode 100644
index 0000000..ca63b39
--- /dev/null
+++ b/test/fts4min.test
@@ -0,0 +1,53 @@
+# 2020 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+set ::testprefix fts4min
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+#------------------------------------------------------------------
+do_execsql_test 0.0 {
+ CREATE TABLE t1(a NOT NULL, b);
+ CREATE INDEX i1 ON t1(a);
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE ft USING fts3(c);
+ INSERT INTO ft(docid, c) VALUES(22, 'hello world');
+ INSERT INTO ft(docid, c) VALUES(44, 'hello world');
+ INSERT INTO ft(docid, c) VALUES(11, 'hello world');
+}
+
+do_eqp_test 1.1.1 {
+ SELECT max(rowid) FROM ft
+} {VIRTUAL TABLE INDEX 0:DESC}
+
+do_eqp_test 1.1.2 {
+ SELECT min(rowid) FROM ft
+} {VIRTUAL TABLE INDEX 0:ASC}
+
+do_execsql_test 1.2.1 {
+ SELECT max(rowid) FROM ft
+} {44}
+
+do_execsql_test 1.2.2 {
+ SELECT min(rowid) FROM ft
+} {11}
+
+finish_test
diff --git a/test/fts4noti.test b/test/fts4noti.test
new file mode 100644
index 0000000..87a0571
--- /dev/null
+++ b/test/fts4noti.test
@@ -0,0 +1,230 @@
+# 2013 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 notindexed=xxx FTS4 option.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix fts4noti
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+
+#-------------------------------------------------------------------------
+# Test that typos in "notindexed=" column names are detected.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE cc(a, b, c);
+}
+foreach {tn arg res} {
+ 1 "(b, c, notindexed=a)" {1 {no such column: a}}
+ 2 "(a, b, notindexed=a)" {0 {}}
+ 3 "(a, b, notindexed=a, notindexed=a)" {0 {}}
+ 4 "(notindexed=a, a, b)" {0 {}}
+ 5 "(notindexed=a, notindexed=b, notindexed=c, a, b, c, d)" {0 {}}
+ 6 "(notindexed=a, notindexed=B, notindexed=c, a, b, c, d)" {0 {}}
+ 7 "(notindexed=a, notindexed=b, notindexed=c, a, B, c, d)" {0 {}}
+ 8 "(notindexed=d, content=cc)" {1 {no such column: d}}
+ 9 "(notindexed=a, content=cc)" {0 {}}
+ 10 "(notindexed=a, notindexed=b, a)" {1 {no such column: b}}
+ 11 "(notindexed=a, notindexed=b, b)" {1 {no such column: a}}
+} {
+ do_catchsql_test 1.$tn "CREATE VIRTUAL TABLE t1 USING fts4 $arg" $res
+ if {[lindex $res 0]==0} { execsql "DROP TABLE t1" }
+}
+
+do_execsql_test 1.x { SELECT name FROM sqlite_master } {cc}
+
+
+#-------------------------------------------------------------------------
+# Test that notindexed columns are not indexed.
+#
+foreach {tn schema} {
+ 1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(a, b, c, notindexed=b);
+ }
+ 2 {
+ CREATE TABLE c1(a, b, c);
+ INSERT INTO c1 VALUES('one two', 'three four', 'five six');
+ INSERT INTO c1 VALUES('three four', 'five six', 'one two');
+ CREATE VIRTUAL TABLE t1 USING fts4(content=c1, notindexed=b);
+ }
+ 3 {
+ CREATE VIRTUAL TABLE t1 USING fts4(content="", a, b, c, notindexed=b);
+ }
+} {
+ execsql $schema
+
+ do_execsql_test 2.$tn.1 {
+ INSERT INTO t1(docid,a,b,c) VALUES(1, 'one two', 'three four', 'five six');
+ INSERT INTO t1(docid,a,b,c) VALUES(2, 'three four', 'five six', 'one two');
+ }
+
+ do_execsql_test 2.$tn.2 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
+ do_execsql_test 2.$tn.3 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
+ do_execsql_test 2.$tn.4 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
+
+ do_execsql_test 2.$tn.5 { INSERT INTO t1(t1) VALUES('optimize') }
+
+ do_execsql_test 2.$tn.6 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
+ do_execsql_test 2.$tn.7 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
+ do_execsql_test 2.$tn.8 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
+
+ if {$tn!=3} {
+ do_execsql_test 2.$tn.9 { INSERT INTO t1(t1) VALUES('rebuild') }
+
+ do_execsql_test 2.$tn.10 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
+ do_execsql_test 2.$tn.11 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
+ do_execsql_test 2.$tn.12 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
+
+ do_execsql_test 2.$tn.13 {
+ SELECT a,b,c FROM t1 WHERE docid=1
+ } {{one two} {three four} {five six}}
+ do_execsql_test 2.$tn.14 {
+ SELECT a,b,c FROM t1 WHERE docid=2
+ } {{three four} {five six} {one two}}
+ }
+
+ do_execsql_test 2.x { DROP TABLE t1 }
+}
+
+#-------------------------------------------------------------------------
+# Test that notindexed columns are not scanned for deferred tokens.
+#
+
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4(x, y, notindexed=x);
+}
+do_test 3.2 {
+ set v [string repeat " 1" 50000]
+ set v1 "x $v"
+ set v2 "y $v"
+ execsql {
+ INSERT INTO t2 VALUES(1, 'x y z');
+ INSERT INTO t2 VALUES(2, $v1);
+ INSERT INTO t2 VALUES(3, $v2);
+ INSERT INTO t2 VALUES(4, $v2);
+ INSERT INTO t2 VALUES(5, $v2);
+ INSERT INTO t2 VALUES(6, $v2);
+ }
+} {}
+
+do_execsql_test 3.3 { SELECT x FROM t2 WHERE t2 MATCH '2' } {}
+do_execsql_test 3.4 { SELECT x FROM t2 WHERE t2 MATCH '1' } {2 3 4 5 6}
+do_execsql_test 3.5 { SELECT x FROM t2 WHERE t2 MATCH 'x' } {1 2}
+do_execsql_test 3.6 { SELECT x FROM t2 WHERE t2 MATCH 'x 1' } {2}
+
+do_execsql_test 3.x { DROP TABLE t2 }
+
+#-------------------------------------------------------------------------
+# Test that the types of notindexed columns are not modified.
+#
+do_execsql_test 4.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4(poi, addr, notindexed=poi);
+ INSERT INTO t2 VALUES(114, 'x x x');
+ INSERT INTO t2 VALUES(X'1234', 'y y y');
+ INSERT INTO t2 VALUES(NULL, 'z z z');
+ INSERT INTO t2 VALUES(113.2, 'w w w');
+ INSERT INTO t2 VALUES('poi', 'v v v');
+}
+do_execsql_test 4.2 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'x' } {integer}
+do_execsql_test 4.3 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'y' } {blob}
+do_execsql_test 4.4 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'z' } {null}
+do_execsql_test 4.5 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'w' } {real}
+do_execsql_test 4.6 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'v' } {text}
+
+do_execsql_test 4.x { DROP TABLE t2 }
+
+#-------------------------------------------------------------------------
+# Test that multiple notindexed options on a single table work as expected.
+#
+do_execsql_test 5.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4(
+ notindexed="three", one, two, three, notindexed="one",
+ );
+ INSERT INTO t2 VALUES('a', 'b', 'c');
+ INSERT INTO t2 VALUES('c', 'a', 'b');
+ INSERT INTO t2 VALUES('b', 'c', 'a');
+}
+do_execsql_test 5.2 { SELECT docid FROM t2 WHERE t2 MATCH 'a' } {2}
+do_execsql_test 5.3 { SELECT docid FROM t2 WHERE t2 MATCH 'b' } {1}
+do_execsql_test 5.4 { SELECT docid FROM t2 WHERE t2 MATCH 'c' } {3}
+
+do_execsql_test 5.x { DROP TABLE t2 }
+
+#-------------------------------------------------------------------------
+# Check that if an indexed column name is a prefix of a notindexed column
+# name, the column is still correctly tokenized. This was a problem at one
+# point.
+do_execsql_test 6.1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(
+ poiCategory, poiCategoryId, notindexed=poiCategoryId
+ );
+ INSERT INTO t1(poiCategory, poiCategoryId) values ('Restaurant', 6021);
+}
+
+do_execsql_test 6.1.2 {
+ SELECT * FROM t1 WHERE t1 MATCH 'restaurant';
+} { Restaurant 6021 }
+do_execsql_test 6.1.3 {
+ SELECT * FROM t1 WHERE t1 MATCH 're*';
+} { Restaurant 6021 }
+do_execsql_test 6.1.4 {
+ SELECT * FROM t1 WHERE t1 MATCH '6021';
+} {}
+do_execsql_test 6.1.5 {
+ SELECT * FROM t1 WHERE t1 MATCH '60*';
+} {}
+
+do_execsql_test 6.2.1 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts4(
+ poiCategory, poiCategoryId, notindexed=poiCategory
+ );
+ INSERT INTO t1(poiCategory, poiCategoryId) values ('Restaurant', 6021);
+}
+
+do_execsql_test 6.2.2 {
+ SELECT * FROM t1 WHERE t1 MATCH 'restaurant';
+} {}
+do_execsql_test 6.2.3 {
+ SELECT * FROM t1 WHERE t1 MATCH 're*';
+} {}
+do_execsql_test 6.2.4 {
+ SELECT * FROM t1 WHERE t1 MATCH '6021';
+} { Restaurant 6021 }
+do_execsql_test 6.2.5 {
+ SELECT * FROM t1 WHERE t1 MATCH '60*';
+} { Restaurant 6021 }
+
+do_execsql_test 6.3.1 {
+ DROP TABLE t1;
+ CREATE VIRTUAL TABLE t1 USING fts4(abc, ab, a, notindexed=abc);
+ CREATE VIRTUAL TABLE t2 USING fts4(a, ab, abc, notindexed=abc);
+
+ INSERT INTO t1 VALUES('no', 'yes', 'yep');
+ INSERT INTO t2 VALUES('yep', 'yes', 'no');
+
+ SELECT count(*) FROM t1 WHERE t1 MATCH 'no';
+ SELECT count(*) FROM t1 WHERE t1 MATCH 'yes';
+ SELECT count(*) FROM t1 WHERE t1 MATCH 'yep';
+
+ SELECT count(*) FROM t2 WHERE t2 MATCH 'no';
+ SELECT count(*) FROM t2 WHERE t2 MATCH 'yes';
+ SELECT count(*) FROM t2 WHERE t2 MATCH 'yep';
+} {0 1 1 0 1 1}
+
+finish_test
diff --git a/test/fts4onepass.test b/test/fts4onepass.test
new file mode 100644
index 0000000..344be4b
--- /dev/null
+++ b/test/fts4onepass.test
@@ -0,0 +1,160 @@
+# 2015 Sep 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+set ::testprefix fts4onepass
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft(rowid, content) VALUES(1, '1 2 3');
+ INSERT INTO ft(rowid, content) VALUES(2, '4 5 6');
+ INSERT INTO ft(rowid, content) VALUES(3, '7 8 9');
+}
+
+#-------------------------------------------------------------------------
+# Check that UPDATE and DELETE statements that feature "WHERE rowid=?" or
+# or "WHERE docid=?" clauses do not use statement journals. But that other
+# DELETE and UPDATE statements do.
+#
+# Note: "MATCH ? AND docid=?" does use a statement journal.
+#
+foreach {tn sql uses} {
+ 1.1 { DELETE FROM ft } 1
+ 1.2 { DELETE FROM ft WHERE docid=? } 0
+ 1.3 { DELETE FROM ft WHERE rowid=? } 0
+ 1.4 { DELETE FROM ft WHERE ft MATCH '1' } 1
+ 1.5 { DELETE FROM ft WHERE ft MATCH '1' AND docid=? } 1
+ 1.6 { DELETE FROM ft WHERE ft MATCH '1' AND rowid=? } 1
+
+ 2.1 { UPDATE ft SET content='a b c' } 1
+ 2.2 { UPDATE ft SET content='a b c' WHERE docid=? } 0
+ 2.3 { UPDATE ft SET content='a b c' WHERE rowid=? } 0
+ 2.4 { UPDATE ft SET content='a b c' WHERE ft MATCH '1' } 1
+ 2.5 { UPDATE ft SET content='a b c' WHERE ft MATCH '1' AND docid=? } 1
+ 2.6 { UPDATE ft SET content='a b c' WHERE ft MATCH '1' AND rowid=? } 1
+} {
+ do_test 1.$tn { sql_uses_stmt db $sql } $uses
+}
+
+#-------------------------------------------------------------------------
+# Check that putting a "DELETE/UPDATE ... WHERE rowid=?" statement in a
+# trigger program does not prevent the VM from using a statement
+# transaction. Even if the calling statement cannot hit a constraint.
+#
+do_execsql_test 2.0 {
+ CREATE TABLE t1(x);
+
+ CREATE TRIGGER t1_ai AFTER INSERT ON t1 BEGIN
+ DELETE FROM ft WHERE rowid=new.x;
+ END;
+
+ CREATE TRIGGER t1_ad AFTER DELETE ON t1 BEGIN
+ UPDATE ft SET content = 'a b c' WHERE rowid=old.x;
+ END;
+
+ CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 BEGIN
+ DELETE FROM ft WHERE rowid=old.x;
+ END;
+}
+
+foreach {tn sql uses} {
+ 1 { INSERT INTO t1 VALUES(1) } 1
+ 2 { DELETE FROM t1 WHERE x=4 } 1
+ 3 { UPDATE t1 SET x=10 WHERE x=11 } 1
+} {
+ do_test 2.$tn { sql_uses_stmt db $sql } $uses
+}
+
+#-------------------------------------------------------------------------
+# Test that an "UPDATE ... WHERE rowid=?" works and does not corrupt the
+# index when it strikes a constraint. Both inside and outside a
+# transaction.
+#
+foreach {tn tcl1 tcl2} {
+ 1 {} {}
+
+ 2 {
+ execsql BEGIN
+ } {
+ if {[sqlite3_get_autocommit db]==1} { error "transaction rolled back!" }
+ execsql COMMIT
+ }
+} {
+
+ do_execsql_test 3.$tn.0 {
+ DROP TABLE IF EXISTS ft2;
+ CREATE VIRTUAL TABLE ft2 USING fts4;
+ INSERT INTO ft2(rowid, content) VALUES(1, 'a b c');
+ INSERT INTO ft2(rowid, content) VALUES(2, 'a b d');
+ INSERT INTO ft2(rowid, content) VALUES(3, 'a b e');
+ }
+
+ eval $tcl1
+ foreach {tn2 sql content} {
+ 1 { UPDATE ft2 SET docid=2 WHERE docid=1 }
+ { 1 {a b c} 2 {a b d} 3 {a b e} }
+
+ 2 {
+ INSERT INTO ft2(rowid, content) VALUES(4, 'a b f');
+ UPDATE ft2 SET docid=5 WHERE docid=4;
+ UPDATE ft2 SET docid=3 WHERE docid=5;
+ } { 1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }
+
+ 3 {
+ UPDATE ft2 SET docid=3 WHERE docid=4; -- matches 0 rows
+ UPDATE ft2 SET docid=2 WHERE docid=3;
+ } { 1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }
+
+ 4 {
+ INSERT INTO ft2(rowid, content) VALUES(4, 'a b g');
+ UPDATE ft2 SET docid=-1 WHERE docid=4;
+ UPDATE ft2 SET docid=3 WHERE docid=-1;
+ } {-1 {a b g} 1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }
+
+ 5 {
+ DELETE FROM ft2 WHERE rowid=451;
+ DELETE FROM ft2 WHERE rowid=-1;
+ UPDATE ft2 SET docid = 2 WHERE docid = 1;
+ } {1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }
+ } {
+ do_catchsql_test 3.$tn.$tn2.a $sql {1 {constraint failed}}
+ do_execsql_test 3.$tn.$tn2.b { SELECT rowid, content FROM ft2 } $content
+ do_execsql_test 3.$tn.$tn2.c {
+ INSERT INTO ft2(ft2) VALUES('integrity-check');
+ }
+ }
+ eval $tcl2
+}
+
+do_execsql_test 4.0 {
+ CREATE VIRTUAL TABLE zt USING fts4(a, b);
+ INSERT INTO zt(rowid, a, b) VALUES(1, 'unus duo', NULL);
+ INSERT INTO zt(rowid, a, b) VALUES(2, NULL, NULL);
+
+ BEGIN;
+ UPDATE zt SET b='septum' WHERE rowid = 1;
+ UPDATE zt SET b='octo' WHERE rowid = 1;
+ COMMIT;
+
+ SELECT count(*) FROM zt_segdir;
+} {3}
+
+
+finish_test
diff --git a/test/fts4opt.test b/test/fts4opt.test
new file mode 100644
index 0000000..4b3d003
--- /dev/null
+++ b/test/fts4opt.test
@@ -0,0 +1,214 @@
+# 2016 March 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+set ::testprefix fts4opt
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Create the fts_kjv_genesis procedure which fills and FTS3/4 table
+# with the complete text of the Book of Genesis.
+#
+source $testdir/genesis.tcl
+
+do_execsql_test 1.0 { CREATE TABLE t1(docid, words) }
+fts_kjv_genesis
+
+#-------------------------------------------------------------------------
+# Argument $db is an open database handle. $tbl is the name of an FTS3/4
+# table with the database. This command rearranges the contents of the
+# %_segdir table so that all segments within each index are on the same
+# level. This means that the 'merge' command can then be used for an
+# incremental optimize routine.
+#
+proc prepare_for_optimize {db tbl} {
+ sqlite3_db_config $db DEFENSIVE 0
+ $db eval [string map [list % $tbl] {
+ BEGIN;
+ CREATE TEMP TABLE tmp_segdir(
+ level, idx, start_block, leaves_end_block, end_block, root
+ );
+
+ INSERT INTO temp.tmp_segdir
+ SELECT
+ 1024*(o.level / 1024) + 32, -- level
+ sum(o.level<i.level OR (o.level=i.level AND o.idx>i.idx)), -- idx
+ o.start_block, o.leaves_end_block, o.end_block, o.root -- other
+ FROM %_segdir o, %_segdir i
+ WHERE (o.level / 1024) = (i.level / 1024)
+ GROUP BY o.level, o.idx;
+
+ DELETE FROM %_segdir;
+ INSERT INTO %_segdir SELECT * FROM temp.tmp_segdir;
+ DROP TABLE temp.tmp_segdir;
+
+ COMMIT;
+ }]
+}
+
+do_test 1.1 {
+ execsql { CREATE VIRTUAL TABLE t2 USING fts4(words, prefix="1,2,3") }
+ foreach {docid words} [db eval { SELECT * FROM t1 }] {
+ execsql { INSERT INTO t2(docid, words) VALUES($docid, $words) }
+ }
+} {}
+
+do_execsql_test 1.2 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level
+} {
+ 0 13 1 15 2 5
+ 1024 13 1025 15 1026 5
+ 2048 13 2049 15 2050 5
+ 3072 13 3073 15 3074 5
+}
+
+do_execsql_test 1.3 { INSERT INTO t2(t2) VALUES('integrity-check') }
+prepare_for_optimize db t2
+do_execsql_test 1.4 { INSERT INTO t2(t2) VALUES('integrity-check') }
+
+do_execsql_test 1.5 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level
+} {
+ 32 33
+ 1056 33
+ 2080 33
+ 3104 33
+}
+
+do_test 1.6 {
+ while 1 {
+ set tc1 [db total_changes]
+ execsql { INSERT INTO t2(t2) VALUES('merge=5,2') }
+ set tc2 [db total_changes]
+ if {($tc2 - $tc1) < 2} break
+ }
+ execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }
+} {33 1 1057 1 2081 1 3105 1}
+do_execsql_test 1.7 { INSERT INTO t2(t2) VALUES('integrity-check') }
+
+do_execsql_test 1.8 {
+ INSERT INTO t2(words) SELECT words FROM t1;
+ SELECT level, count(*) FROM t2_segdir GROUP BY level;
+} {0 2 1024 2 2048 2 3072 2}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 2.0 {
+ DELETE FROM t2;
+}
+do_test 2.1 {
+ foreach {docid words} [db eval { SELECT * FROM t1 }] {
+ execsql { INSERT INTO t2(docid, words) VALUES($docid, $words) }
+ }
+
+ set i 0
+ foreach {docid words} [db eval { SELECT * FROM t1 }] {
+ if {[incr i] % 2} { execsql { DELETE FROM t2 WHERE docid = $docid } }
+ }
+
+ set i 0
+ foreach {docid words} [db eval { SELECT * FROM t1 }] {
+ if {[incr i] % 3} {
+ execsql { INSERT OR REPLACE INTO t2(docid, words) VALUES($docid, $words) }
+ }
+ }
+} {}
+
+do_execsql_test 2.2 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level
+} {
+ 0 10 1 15 2 12
+ 1024 10 1025 15 1026 12
+ 2048 10 2049 15 2050 12
+ 3072 10 3073 15 3074 12
+}
+
+do_execsql_test 2.3 { INSERT INTO t2(t2) VALUES('integrity-check') }
+prepare_for_optimize db t2
+do_execsql_test 2.4 { INSERT INTO t2(t2) VALUES('integrity-check') }
+
+do_execsql_test 2.5 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level
+} {
+ 32 37
+ 1056 37
+ 2080 37
+ 3104 37
+}
+
+do_test 2.6 {
+ while 1 {
+ set tc1 [db total_changes]
+ execsql { INSERT INTO t2(t2) VALUES('merge=5,2') }
+ set tc2 [db total_changes]
+ if {($tc2 - $tc1) < 2} break
+ }
+ execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }
+} {33 1 1057 1 2081 1 3105 1}
+do_execsql_test 2.7 { INSERT INTO t2(t2) VALUES('integrity-check') }
+
+do_execsql_test 2.8 {
+ INSERT INTO t2(words) SELECT words FROM t1;
+ SELECT level, count(*) FROM t2_segdir GROUP BY level;
+} {0 2 1024 2 2048 2 3072 2}
+
+#-------------------------------------------------------------------------
+# Check that 'optimize' works when there is data in the in-memory hash
+# table, but no segments at all on disk.
+#
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE fts USING fts4 (t);
+ INSERT INTO fts (fts) VALUES ('optimize');
+}
+do_execsql_test 3.2 {
+ INSERT INTO fts(fts) VALUES('integrity-check');
+ SELECT count(*) FROM fts_segdir;
+} {0}
+do_execsql_test 3.3 {
+ BEGIN;
+ INSERT INTO fts (rowid, t) VALUES (2, 'test');
+ INSERT INTO fts (fts) VALUES ('optimize');
+ COMMIT;
+ SELECT level, idx FROM fts_segdir;
+} {0 0}
+do_execsql_test 3.4 {
+ INSERT INTO fts(fts) VALUES('integrity-check');
+ SELECT rowid FROM fts WHERE fts MATCH 'test';
+} {2}
+do_execsql_test 3.5 {
+ INSERT INTO fts (fts) VALUES ('optimize');
+ INSERT INTO fts(fts) VALUES('integrity-check');
+}
+do_test 3.6 {
+ set c1 [db total_changes]
+ execsql { INSERT INTO fts (fts) VALUES ('optimize') }
+ expr {[db total_changes] - $c1}
+} {1}
+do_test 3.7 {
+ execsql { INSERT INTO fts (rowid, t) VALUES (3, 'xyz') }
+ set c1 [db total_changes]
+ execsql { INSERT INTO fts (fts) VALUES ('optimize') }
+ expr {([db total_changes] - $c1) > 1}
+} {1}
+do_test 3.8 {
+ set c1 [db total_changes]
+ execsql { INSERT INTO fts (fts) VALUES ('optimize') }
+ expr {[db total_changes] - $c1}
+} {1}
+
+finish_test
diff --git a/test/fts4record.test b/test/fts4record.test
new file mode 100644
index 0000000..f1a3eaf
--- /dev/null
+++ b/test/fts4record.test
@@ -0,0 +1,120 @@
+# 2019 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.
+#
+#*************************************************************************
+# 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
+source $testdir/fts3_common.tcl
+set testprefix fts4record
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+sqlite3_fts3_may_be_corrupt 1
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING fts4(x);
+ INSERT INTO t1 VALUES('terma terma terma termb');
+}
+
+do_execsql_test 1.1 {
+ SELECT quote(root) FROM t1_segdir
+} {
+ X'00057465726D6105010203030004016203010500'
+}
+
+proc make_record_wrapper {args} { make_fts3record $args }
+db func record make_record_wrapper
+
+do_execsql_test 1.2 {
+ select quote(
+ record(0, 5, 'terma', 5, 1, 2, 3, 3, 0,
+ 4, 1, 'b' , 3, 1, 5, 0
+ ) );
+} {
+ X'00057465726D6105010203030004016203010500'
+}
+
+do_execsql_test 1.3.1 {
+ UPDATE t1_segdir SET root =
+ record(0, 5, 'terma', 5, 1, 2, 3, 3, 0,
+ 4, 1, 'b' , 3, 1, 5,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
+ );
+}
+
+do_catchsql_test 1.3.2 {
+ SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
+} {1 {database disk image is malformed}}
+
+do_execsql_test 1.4.1 {
+ UPDATE t1_segdir SET root =
+ record(0, 5, 'terma', 5, 1, 2, 3, 3, 0,
+ 4, 1, 'b' , 4, 1, 5,
+ 256, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
+ );
+}
+
+do_catchsql_test 1.4.2 {
+ SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
+} {1 {database disk image is malformed}}
+
+do_execsql_test 1.4.3 {
+ SELECT quote(root) FROM t1_segdir
+} {
+ X'00057465726D610501020303000401620401058002010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100'
+}
+
+do_execsql_test 1.5.1 {
+ UPDATE t1_segdir SET root =
+ record(0, 5, 'terma', 5, 1, 2, 3, 3, 0,
+ 4, 1, 'b' , 4, 1, 5,
+ 256, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
+ );
+}
+
+do_catchsql_test 1.4.2 {
+ SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
+} {1 {database disk image is malformed}}
+
+do_execsql_test 1.4.3 {
+ SELECT quote(root) FROM t1_segdir
+} {
+ X'00057465726D610501020303000401620401058002010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100'
+}
+
+
+do_execsql_test 1.5.1 {
+ UPDATE t1_segdir SET root =
+ X'00057465726D61050102030300040162040105FF00010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100'
+}
+
+do_catchsql_test 1.5.2 {
+ SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
+} {1 {database disk image is malformed}}
+
+do_catchsql_test 1.5.3 {
+ INSERT INTO t1(t1) VALUES('integrity-check');
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/test/fts4rename.test b/test/fts4rename.test
new file mode 100644
index 0000000..5571ea7
--- /dev/null
+++ b/test/fts4rename.test
@@ -0,0 +1,43 @@
+# 2019 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.
+#
+#*************************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/fts3_common.tcl
+set ::testprefix fts4rename
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE temp.t1 USING fts3(a);
+ BEGIN;
+ CREATE TABLE t2(x);
+} {}
+
+do_catchsql_test 1.1 {
+ ALTER TABLE t1_content RENAME c0a TO docid;
+} {1 {error in table t1_content after rename: duplicate column name: docid}}
+
+do_catchsql_test 1.2 {
+ UPDATE t1 SET Col0 = 1 ;
+} {1 {no such column: Col0}}
+
+do_catchsql_test 1.3 {
+ ROLLBACK;
+ DROP TABLE t1;
+} {0 {}}
+
+finish_test
diff --git a/test/fts4umlaut.test b/test/fts4umlaut.test
new file mode 100644
index 0000000..a5a652f
--- /dev/null
+++ b/test/fts4umlaut.test
@@ -0,0 +1,64 @@
+# 2018 December 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 testing the FTS5 module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts4umlaut
+
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE t1 USING fts4(x, tokenize=unicode61);
+ CREATE VIRTUAL TABLE t2 USING fts4(
+ x,
+ tokenize=unicode61 "remove_diacritics=2"
+ );
+}
+
+foreach {tn q res1 res2} {
+ 1 "Hà Nội" 0 1
+ 2 "Hà Noi" 1 1
+ 3 "Ha Noi" 1 1
+ 4 "Ha N\u1ed9i" 0 1
+ 5 "Ha N\u006fi" 1 1
+ 6 "Ha N\u006f\u0302i" 1 1
+ 7 "Ha N\u006f\u0323\u0302i" 1 1
+} {
+ do_execsql_test 1.$tn.1 {
+ DELETE FROM t1;
+ INSERT INTO t1(rowid, x) VALUES (1, 'Ha Noi');
+ SELECT count(*) FROM t1 WHERE t1 MATCH $q
+ } $res1
+ do_execsql_test 1.$tn.2 {
+ DELETE FROM t1;
+ INSERT INTO t1(rowid, x) VALUES (1, $q);
+ SELECT count(*) FROM t1 WHERE t1 MATCH 'Ha Noi'
+ } $res1
+
+ do_execsql_test 1.$tn.3 {
+ DELETE FROM t2;
+ INSERT INTO t2(rowid, x) VALUES (1, 'Ha Noi');
+ SELECT count(*) FROM t2 WHERE t2 MATCH $q
+ } $res2
+ do_execsql_test 1.$tn.4 {
+ DELETE FROM t2;
+ INSERT INTO t2(rowid, x) VALUES (1, $q);
+ SELECT count(*) FROM t2 WHERE t2 MATCH 'Ha Noi'
+ } $res2
+}
+
+finish_test
diff --git a/test/fts4unicode.test b/test/fts4unicode.test
new file mode 100644
index 0000000..facf2bf
--- /dev/null
+++ b/test/fts4unicode.test
@@ -0,0 +1,588 @@
+# 2012 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.
+#
+#*************************************************************************
+#
+# The tests in this file focus on testing the "unicode" FTS tokenizer.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !fts3_unicode { finish_test ; return }
+set ::testprefix fts4unicode
+
+proc do_unicode_token_test {tn input res} {
+ set input [string map {' ''} $input]
+ uplevel [list do_execsql_test $tn "
+ SELECT fts3_tokenizer_test('unicode61', 'remove_diacritics=0', '$input');
+ " [list [list {*}$res]]]
+}
+
+proc do_unicode_token_test2 {tn input res} {
+ set input [string map {' ''} $input]
+ uplevel [list do_execsql_test $tn "
+ SELECT fts3_tokenizer_test('unicode61', '$input');
+ " [list [list {*}$res]]]
+}
+
+proc do_unicode_token_test3 {tn args} {
+ set res [lindex $args end]
+ set sql "SELECT fts3_tokenizer_test('unicode61'"
+ foreach a [lrange $args 0 end-1] {
+ append sql ", '"
+ append sql [string map {' ''} $a]
+ append sql "'"
+ }
+ append sql ")"
+ uplevel [list do_execsql_test $tn $sql [list [list {*}$res]]]
+}
+
+do_unicode_token_test 1.0 {a B c D} {0 a a 1 b B 2 c c 3 d D}
+
+do_unicode_token_test 1.1 "\uC4 \uD6 \uDC" \
+ "0 \uE4 \uC4 1 \uF6 \uD6 2 \uFC \uDC"
+
+do_unicode_token_test 1.2 "x\uC4x x\uD6x x\uDCx" \
+ "0 x\uE4x x\uC4x 1 x\uF6x x\uD6x 2 x\uFCx x\uDCx"
+
+# 0x00DF is a small "sharp s". 0x1E9E is a capital sharp s.
+do_unicode_token_test 1.3 "\uDF" "0 \uDF \uDF"
+do_unicode_token_test 1.4 "\u1E9E" "0 \uDF \u1E9E"
+
+do_unicode_token_test 1.5 "The quick brown fox" {
+ 0 the The 1 quick quick 2 brown brown 3 fox fox
+}
+do_unicode_token_test 1.6 "The\u00bfquick\u224ebrown\u2263fox" {
+ 0 the The 1 quick quick 2 brown brown 3 fox fox
+}
+
+do_unicode_token_test2 1.7 {a B c D} {0 a a 1 b B 2 c c 3 d D}
+do_unicode_token_test2 1.8 "\uC4 \uD6 \uDC" "0 a \uC4 1 o \uD6 2 u \uDC"
+
+do_unicode_token_test2 1.9 "x\uC4x x\uD6x x\uDCx" \
+ "0 xax x\uC4x 1 xox x\uD6x 2 xux x\uDCx"
+
+# Check that diacritics are removed if remove_diacritics=1 is specified.
+# And that they do not break tokens.
+do_unicode_token_test2 1.10 "xx\u0301xx" "0 xxxx xx\u301xx"
+
+# Title-case mappings work
+do_unicode_token_test 1.11 "\u01c5" "0 \u01c6 \u01c5"
+
+#-------------------------------------------------------------------------
+#
+set docs [list {
+ Enhance the INSERT syntax to allow multiple rows to be inserted via the
+ VALUES clause.
+} {
+ Enhance the CREATE VIRTUAL TABLE command to support the IF NOT EXISTS clause.
+} {
+ Added the sqlite3_stricmp() interface as a counterpart to sqlite3_strnicmp().
+} {
+ Added the sqlite3_db_readonly() interface.
+} {
+ Added the SQLITE_FCNTL_PRAGMA file control, giving VFS implementations the
+ ability to add new PRAGMA statements or to override built-in PRAGMAs.
+} {
+ Queries of the form: "SELECT max(x), y FROM table" returns the value of y on
+ the same row that contains the maximum x value.
+} {
+ Added support for the FTS4 languageid option.
+} {
+ Documented support for the FTS4 content option. This feature has actually
+ been in the code since version 3.7.9 but is only now considered to be
+ officially supported.
+} {
+ Pending statements no longer block ROLLBACK. Instead, the pending statement
+ will return SQLITE_ABORT upon next access after the ROLLBACK.
+} {
+ Improvements to the handling of CSV inputs in the command-line shell
+} {
+ Fix a bug introduced in version 3.7.10 that might cause a LEFT JOIN to be
+ incorrectly converted into an INNER JOIN if the WHERE clause indexable terms
+ connected by OR.
+}]
+
+set map(a) [list "\u00C4" "\u00E4"] ; # LATIN LETTER A WITH DIAERESIS
+set map(e) [list "\u00CB" "\u00EB"] ; # LATIN LETTER E WITH DIAERESIS
+set map(i) [list "\u00CF" "\u00EF"] ; # LATIN LETTER I WITH DIAERESIS
+set map(o) [list "\u00D6" "\u00F6"] ; # LATIN LETTER O WITH DIAERESIS
+set map(u) [list "\u00DC" "\u00FC"] ; # LATIN LETTER U WITH DIAERESIS
+set map(y) [list "\u0178" "\u00FF"] ; # LATIN LETTER Y WITH DIAERESIS
+set map(h) [list "\u1E26" "\u1E27"] ; # LATIN LETTER H WITH DIAERESIS
+set map(w) [list "\u1E84" "\u1E85"] ; # LATIN LETTER W WITH DIAERESIS
+set map(x) [list "\u1E8C" "\u1E8D"] ; # LATIN LETTER X WITH DIAERESIS
+foreach k [array names map] {
+ lappend mappings [string toupper $k] [lindex $map($k) 0]
+ lappend mappings $k [lindex $map($k) 1]
+}
+proc mapdoc {doc} {
+ set doc [regsub -all {[[:space:]]+} $doc " "]
+ string map $::mappings [string trim $doc]
+}
+
+do_test 2.0 {
+ execsql { CREATE VIRTUAL TABLE t2 USING fts4(tokenize=unicode61, x); }
+ foreach doc $docs {
+ set d [mapdoc $doc]
+ execsql { INSERT INTO t2 VALUES($d) }
+ }
+} {}
+
+do_test 2.1 {
+ set q [mapdoc "row"]
+ execsql { SELECT * FROM t2 WHERE t2 MATCH $q }
+} [list [mapdoc {
+ Queries of the form: "SELECT max(x), y FROM table" returns the value of y on
+ the same row that contains the maximum x value.
+}]]
+
+foreach {tn query snippet} {
+ 2 "row" {
+ ...returns the value of y on the same [row] that contains
+ the maximum x value.
+ }
+ 3 "ROW" {
+ ...returns the value of y on the same [row] that contains
+ the maximum x value.
+ }
+ 4 "rollback" {
+ ...[ROLLBACK]. Instead, the pending statement
+ will return SQLITE_ABORT upon next access after the [ROLLBACK].
+ }
+ 5 "rOllback" {
+ ...[ROLLBACK]. Instead, the pending statement
+ will return SQLITE_ABORT upon next access after the [ROLLBACK].
+ }
+ 6 "lang*" {
+ Added support for the FTS4 [languageid] option.
+ }
+} {
+ do_test 2.$tn {
+ set q [mapdoc $query]
+ execsql { SELECT snippet(t2, '[', ']', '...') FROM t2 WHERE t2 MATCH $q }
+ } [list [mapdoc $snippet]]
+}
+
+#-------------------------------------------------------------------------
+# Make sure the unicode61 tokenizer does not crash if it is passed a
+# NULL pointer.
+reset_db
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61, x, y);
+ INSERT INTO t1 VALUES(NULL, 'a b c');
+}
+
+do_execsql_test 3.2 {
+ SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH 'b'
+} {{a [b] c}}
+
+do_execsql_test 3.3 {
+ BEGIN;
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('b b b b b b b b b b b', 'b b b b b b b b b b b b b');
+ 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;
+ 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;
+ INSERT INTO t1 VALUES('a b c', NULL);
+ INSERT INTO t1 VALUES('a x c', NULL);
+ COMMIT;
+}
+
+do_execsql_test 3.4 {
+ SELECT * FROM t1 WHERE t1 MATCH 'a b';
+} {{a b c} {}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+
+do_test 4.1 {
+ set a "abc\uFFFEdef"
+ set b "abc\uD800def"
+ set c "\uFFFEdef"
+ set d "\uD800def"
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61, x);
+ INSERT INTO t1 VALUES($a);
+ INSERT INTO t1 VALUES($b);
+ INSERT INTO t1 VALUES($c);
+ INSERT INTO t1 VALUES($d);
+ }
+} {}
+
+do_test 4.2 {
+ set a [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0x62}]
+ set b [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0x62}]
+ set c [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}]
+ set d [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}]
+ execsql {
+ INSERT INTO t1 VALUES($a);
+ INSERT INTO t1 VALUES($b);
+ INSERT INTO t1 VALUES($c);
+ INSERT INTO t1 VALUES($d);
+ }
+} {}
+
+do_test 4.3 {
+ set a [binary format c* {0xF7 0xBF 0xBF 0xBF}]
+ set b [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF}]
+ set c [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF 0xBF}]
+ set d [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0xBF}]
+ execsql {
+ INSERT INTO t1 VALUES($a);
+ INSERT INTO t1 VALUES($b);
+ INSERT INTO t1 VALUES($c);
+ INSERT INTO t1 VALUES($d);
+ }
+} {}
+
+#-------------------------------------------------------------------------
+
+do_unicode_token_test3 5.1 {tokenchars=} {
+ sqlite3_reset sqlite3_column_int
+} {
+ 0 sqlite3 sqlite3
+ 1 reset reset
+ 2 sqlite3 sqlite3
+ 3 column column
+ 4 int int
+}
+
+do_unicode_token_test3 5.2 {tokenchars=_} {
+ sqlite3_reset sqlite3_column_int
+} {
+ 0 sqlite3_reset sqlite3_reset
+ 1 sqlite3_column_int sqlite3_column_int
+}
+
+do_unicode_token_test3 5.3 {separators=xyz} {
+ Laotianxhorseyrunszfast
+} {
+ 0 laotian Laotian
+ 1 horse horse
+ 2 runs runs
+ 3 fast fast
+}
+
+do_unicode_token_test3 5.4 {tokenchars=xyz} {
+ Laotianxhorseyrunszfast
+} {
+ 0 laotianxhorseyrunszfast Laotianxhorseyrunszfast
+}
+
+do_unicode_token_test3 5.5 {tokenchars=_} {separators=zyx} {
+ sqlite3_resetxsqlite3_column_intyhonda_phantom
+} {
+ 0 sqlite3_reset sqlite3_reset
+ 1 sqlite3_column_int sqlite3_column_int
+ 2 honda_phantom honda_phantom
+}
+
+do_unicode_token_test3 5.6 "separators=\u05D1" "abc\u05D1def" {
+ 0 abc abc 1 def def
+}
+
+do_unicode_token_test3 5.7 \
+ "tokenchars=\u2444\u2445" \
+ "separators=\u05D0\u05D1\u05D2" \
+ "\u2444fre\u2445sh\u05D0water\u05D2fish.\u2445timer" \
+ [list \
+ 0 \u2444fre\u2445sh \u2444fre\u2445sh \
+ 1 water water \
+ 2 fish fish \
+ 3 \u2445timer \u2445timer \
+ ]
+
+# Check that it is not possible to add a standalone diacritic codepoint
+# to either separators or tokenchars.
+do_unicode_token_test3 5.8 "separators=\u0301" \
+ "hello\u0301world \u0301helloworld" \
+ "0 helloworld hello\u0301world 1 helloworld helloworld"
+
+do_unicode_token_test3 5.9 "tokenchars=\u0301" \
+ "hello\u0301world \u0301helloworld" \
+ "0 helloworld hello\u0301world 1 helloworld helloworld"
+
+do_unicode_token_test3 5.10 "separators=\u0301" \
+ "remove_diacritics=0" \
+ "hello\u0301world \u0301helloworld" \
+ "0 hello\u0301world hello\u0301world 1 helloworld helloworld"
+
+do_unicode_token_test3 5.11 "tokenchars=\u0301" \
+ "remove_diacritics=0" \
+ "hello\u0301world \u0301helloworld" \
+ "0 hello\u0301world hello\u0301world 1 helloworld helloworld"
+
+
+#-------------------------------------------------------------------------
+
+proc do_tokenize {tokenizer txt} {
+ set res [list]
+ foreach {a b c} [db one {SELECT fts3_tokenizer_test($tokenizer, $txt)}] {
+ lappend res $b
+ }
+ set res
+}
+
+# Argument $lCodepoint must be a list of codepoints (integers) that
+# correspond to whitespace characters. This command creates a string
+# $W from the codepoints, then tokenizes "${W}hello{$W}world${W}"
+# using tokenizer $tokenizer. The test passes if the tokenizer successfully
+# extracts the two 5 character tokens.
+#
+proc do_isspace_test {tn tokenizer lCp} {
+ set whitespace [format [string repeat %c [llength $lCp]] {*}$lCp]
+ set txt "${whitespace}hello${whitespace}world${whitespace}"
+ uplevel [list do_test $tn [list do_tokenize $tokenizer $txt] {hello world}]
+}
+
+set tokenizers [list unicode61]
+ifcapable icu { lappend tokenizers icu }
+
+# Some tests to check that the tokenizers can both identify white-space
+# codepoints. All codepoints tested below are of type "Zs" in the
+# UnicodeData.txt file.
+#
+# Note that codepoint 6158 has changed from Zs to Cf in recent versions
+# of UnicodeData.txt. So take that into account for the "icu" tests.
+#
+foreach T $tokenizers {
+ do_isspace_test 6.$T.1 $T 32
+ do_isspace_test 6.$T.2 $T 160
+ do_isspace_test 6.$T.3 $T 5760
+ if {$T!="icu"} {
+ do_isspace_test 6.$T.4 $T 6158
+ }
+ do_isspace_test 6.$T.5 $T 8192
+ do_isspace_test 6.$T.6 $T 8193
+ do_isspace_test 6.$T.7 $T 8194
+ do_isspace_test 6.$T.8 $T 8195
+ do_isspace_test 6.$T.9 $T 8196
+ do_isspace_test 6.$T.10 $T 8197
+ do_isspace_test 6.$T.11 $T 8198
+ do_isspace_test 6.$T.12 $T 8199
+ do_isspace_test 6.$T.13 $T 8200
+ do_isspace_test 6.$T.14 $T 8201
+ do_isspace_test 6.$T.15 $T 8202
+ if {$T!="icu"} {
+ do_isspace_test 6.$T.16 $T 8239
+ }
+ do_isspace_test 6.$T.17 $T 8287
+ do_isspace_test 6.$T.18 $T 12288
+
+ if {$T!="icu"} {
+ do_isspace_test 6.$T.19 $T {32 160 5760 6158}
+ } else {
+ do_isspace_test 6.$T.19 $T {32 160 5760 8192}
+ }
+ do_isspace_test 6.$T.20 $T {8192 8193 8194 8195}
+ do_isspace_test 6.$T.21 $T {8196 8197 8198 8199}
+ do_isspace_test 6.$T.22 $T {8200 8201 8202 8239}
+ do_isspace_test 6.$T.23 $T {8287 12288}
+}
+
+#-------------------------------------------------------------------------
+# Test that the private use ranges are treated as alphanumeric.
+#
+foreach {tn1 c} {
+ 1 \ue000 2 \ue001 3 \uf000 4 \uf8fe 5 \uf8ff
+} {
+ foreach {tn2 config res} {
+ 1 "" "0 hello*world hello*world"
+ 2 "separators=*" "0 hello hello 1 world world"
+ } {
+ set config [string map [list * $c] $config]
+ set input [string map [list * $c] "hello*world"]
+ set output [string map [list * $c] $res]
+ do_unicode_token_test3 7.$tn1.$tn2 {*}$config $input $output
+ }
+}
+
+#-------------------------------------------------------------------------
+# Cursory test of remove_diacritics=0.
+#
+# 00C4;LATIN CAPITAL LETTER A WITH DIAERESIS
+# 00D6;LATIN CAPITAL LETTER O WITH DIAERESIS
+# 00E4;LATIN SMALL LETTER A WITH DIAERESIS
+# 00F6;LATIN SMALL LETTER O WITH DIAERESIS
+#
+do_execsql_test 8.1.1 "
+ CREATE VIRTUAL TABLE t3 USING fts4(tokenize=unicode61 'remove_diacritics=1');
+ INSERT INTO t3 VALUES('o');
+ INSERT INTO t3 VALUES('a');
+ INSERT INTO t3 VALUES('O');
+ INSERT INTO t3 VALUES('A');
+ INSERT INTO t3 VALUES('\xD6');
+ INSERT INTO t3 VALUES('\xC4');
+ INSERT INTO t3 VALUES('\xF6');
+ INSERT INTO t3 VALUES('\xE4');
+"
+do_execsql_test 8.1.2 {
+ SELECT rowid FROM t3 WHERE t3 MATCH 'o';
+} {1 3 5 7}
+do_execsql_test 8.1.3 {
+ SELECT rowid FROM t3 WHERE t3 MATCH 'a';
+} {2 4 6 8}
+do_execsql_test 8.2.1 {
+ CREATE VIRTUAL TABLE t4 USING fts4(tokenize=unicode61 "remove_diacritics=0");
+ INSERT INTO t4 SELECT * FROM t3;
+}
+do_execsql_test 8.2.2 {
+ SELECT rowid FROM t4 WHERE t4 MATCH 'o';
+} {1 3}
+do_execsql_test 8.2.3 {
+ SELECT rowid FROM t4 WHERE t4 MATCH 'a';
+} {2 4}
+
+#-------------------------------------------------------------------------
+#
+foreach {tn sql} {
+ 1 {
+ CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 [tokenchars= .]);
+ CREATE VIRTUAL TABLE t6 USING fts4(
+ tokenize=unicode61 [tokenchars=="] "tokenchars=[]");
+ CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 [separators=x\xC4]);
+ }
+ 2 {
+ CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 "tokenchars= .");
+ CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 "tokenchars=[=""]");
+ CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 "separators=x\xC4");
+ }
+ 3 {
+ CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 'tokenchars= .');
+ CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 'tokenchars=="[]');
+ CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 'separators=x\xC4');
+ }
+ 4 {
+ CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 `tokenchars= .`);
+ CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 `tokenchars=[="]`);
+ CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 `separators=x\xC4`);
+ }
+} {
+ do_execsql_test 9.$tn.0 {
+ DROP TABLE IF EXISTS t5;
+ DROP TABLE IF EXISTS t5aux;
+ DROP TABLE IF EXISTS t6;
+ DROP TABLE IF EXISTS t6aux;
+ DROP TABLE IF EXISTS t7;
+ DROP TABLE IF EXISTS t7aux;
+ }
+ do_execsql_test 9.$tn.1 $sql
+
+ do_execsql_test 9.$tn.2 {
+ CREATE VIRTUAL TABLE t5aux USING fts4aux(t5);
+ INSERT INTO t5 VALUES('one two three/four.five.six');
+ SELECT * FROM t5aux;
+ } {
+ four.five.six * 1 1 four.five.six 0 1 1
+ {one two three} * 1 1 {one two three} 0 1 1
+ }
+
+ do_execsql_test 9.$tn.3 {
+ CREATE VIRTUAL TABLE t6aux USING fts4aux(t6);
+ INSERT INTO t6 VALUES('alpha=beta"gamma/delta[epsilon]zeta');
+ SELECT * FROM t6aux;
+ } {
+ {alpha=beta"gamma} * 1 1 {alpha=beta"gamma} 0 1 1
+ {delta[epsilon]zeta} * 1 1 {delta[epsilon]zeta} 0 1 1
+ }
+
+ do_execsql_test 9.$tn.4 {
+ CREATE VIRTUAL TABLE t7aux USING fts4aux(t7);
+ INSERT INTO t7 VALUES('alephxbeth\xC4gimel');
+ SELECT * FROM t7aux;
+ } {
+ aleph * 1 1 aleph 0 1 1
+ beth * 1 1 beth 0 1 1
+ gimel * 1 1 gimel 0 1 1
+ }
+}
+
+# Check that multiple options are handled correctly.
+#
+do_execsql_test 10.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61
+ "tokenchars=xyz" "tokenchars=.=" "separators=.=" "separators=xy"
+ "separators=a" "separators=a" "tokenchars=a" "tokenchars=a"
+ );
+
+ INSERT INTO t1 VALUES('oneatwoxthreeyfour');
+ INSERT INTO t1 VALUES('a.single=word');
+ CREATE VIRTUAL TABLE t1aux USING fts4aux(t1);
+ SELECT * FROM t1aux;
+} {
+ .single=word * 1 1 .single=word 0 1 1
+ four * 1 1 four 0 1 1
+ one * 1 1 one 0 1 1
+ three * 1 1 three 0 1 1
+ two * 1 1 two 0 1 1
+}
+
+# Test that case folding happens after tokenization, not before.
+#
+do_execsql_test 10.2 {
+ DROP TABLE IF EXISTS t2;
+ CREATE VIRTUAL TABLE t2 USING fts4(tokenize=unicode61 "separators=aB");
+ INSERT INTO t2 VALUES('oneatwoBthree');
+ INSERT INTO t2 VALUES('onebtwoAthree');
+ CREATE VIRTUAL TABLE t2aux USING fts4aux(t2);
+ SELECT * FROM t2aux;
+} {
+ one * 1 1 one 0 1 1
+ onebtwoathree * 1 1 onebtwoathree 0 1 1
+ three * 1 1 three 0 1 1
+ two * 1 1 two 0 1 1
+}
+
+# Test that the tokenchars and separators options work with the
+# fts3tokenize table.
+#
+do_execsql_test 11.1 {
+ CREATE VIRTUAL TABLE ft1 USING fts3tokenize(
+ "unicode61", "tokenchars=@.", "separators=1234567890"
+ );
+ SELECT token FROM ft1 WHERE input = 'berlin@street123sydney.road';
+} {
+ berlin@street sydney.road
+}
+
+# Test for embedded nul characters in fts4 unicode index.
+#
+do_execsql_test 12.0 {
+ CREATE VIRTUAL TABLE t12 USING fts4(tokenize=unicode61);
+ INSERT INTO t12 VALUES('abc' || char(0) || 'def');
+ SELECT hex(CAST(content AS blob)) FROM t12;
+} {61626300646566}
+do_execsql_test 12.1 {
+ INSERT INTO t12(t12) VALUES('integrity-check');
+} {}
+do_execsql_test 12.2 {
+ CREATE VIRTUAL TABLE t12aux USING fts4aux(t12);
+ SELECT * FROM t12aux;
+} {abc * 1 1 abc 0 1 1}
+do_execsql_test 12.3 {
+ SELECT hex(CAST(content AS blob)) FROM t12 WHERE t12 MATCH 'abc'
+} {61626300646566}
+
+finish_test
diff --git a/test/fts4upfrom.test b/test/fts4upfrom.test
new file mode 100644
index 0000000..889b64a
--- /dev/null
+++ b/test/fts4upfrom.test
@@ -0,0 +1,139 @@
+# 2020 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 script is testing UPDATE statements with FROM clauses
+# against FTS4 tables.
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix fts4upfrom
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+foreach {tn create_table} {
+ 0 { CREATE VIRTUAL TABLE ft USING fts5(a, b, c) }
+ 1 { CREATE VIRTUAL TABLE ft USING fts3(a, b, c) }
+ 2 { CREATE TABLE ft(a, b, c) }
+ 3 {
+ CREATE TABLE real(a, b, c);
+ CREATE INDEX i1 ON real(a);
+ CREATE VIEW ft AS SELECT rowid, a, b, c FROM real;
+ CREATE TRIGGER tr1 INSTEAD OF INSERT ON ft BEGIN
+ INSERT INTO real(rowid, a, b, c) VALUES(new.rowid, new.a, new.b, new.c);
+ END;
+ CREATE TRIGGER tr2 INSTEAD OF UPDATE ON ft BEGIN
+ UPDATE real SET rowid=new.rowid, a=new.a, b=new.b, c=new.c
+ WHERE rowid=old.rowid;
+ END;
+ }
+} {
+ if {$tn==0} { ifcapable !fts5 { continue } }
+ catchsql { DROP VIEW IF EXISTS changes }
+ catchsql { DROP TABLE IF EXISTS ft }
+ catchsql { DROP VIEW IF EXISTS ft }
+ execsql $create_table
+
+ do_execsql_test 1.$tn.0 {
+ INSERT INTO ft(a, b, c) VALUES('a', NULL, 'apple');
+ INSERT INTO ft(a, b, c) VALUES('b', NULL, 'banana');
+ INSERT INTO ft(a, b, c) VALUES('c', NULL, 'cherry');
+ INSERT INTO ft(a, b, c) VALUES('d', NULL, 'damson plum');
+ }
+
+ do_execsql_test 1.$tn.1 {
+ SELECT a, b, c FROM ft ORDER BY rowid;
+ } {
+ a {} apple
+ b {} banana
+ c {} cherry
+ d {} {damson plum}
+ }
+
+ do_execsql_test 1.$tn.2 {
+ UPDATE ft SET b=o.c FROM ft AS o WHERE (ft.a == char(unicode(o.a)+1))
+ }
+
+ do_execsql_test 1.$tn.3 {
+ SELECT a, b, c FROM ft ORDER BY rowid;
+ } {
+ a {} apple
+ b apple banana
+ c banana cherry
+ d cherry {damson plum}
+ }
+
+ do_catchsql_test 1.$tn.4 {
+ UPDATE ft SET c=v FROM changes WHERE a=k;
+ } {1 {no such table: changes}}
+
+ do_execsql_test 1.$tn.5 {
+ create view changes(k, v) AS
+ VALUES( 'd', 'dewberry' ) UNION ALL
+ VALUES( 'c', 'clementine' ) UNION ALL
+ VALUES( 'b', 'blueberry' ) UNION ALL
+ VALUES( 'a', 'apricot' )
+ ;
+ }
+
+ do_execsql_test 1.$tn.6 {
+ UPDATE ft SET c=v FROM changes WHERE a=k;
+ }
+
+ do_execsql_test 1.$tn.7 {
+ SELECT rowid, a, b, c FROM ft ORDER BY rowid;
+ } {
+ 1 a {} apricot
+ 2 b apple blueberry
+ 3 c banana clementine
+ 4 d cherry dewberry
+ }
+
+ do_execsql_test 1.$tn.8 "
+ WITH x1(o, n) AS (
+ VALUES(1, 11) UNION ALL
+ VALUES(2, 12) UNION ALL
+ VALUES(3, 13) UNION ALL
+ VALUES(4, 14)
+ )
+ SELECT ft.rowid, a, b, c, o, n FROM ft, x1 WHERE ft.rowid = o;
+ " {
+ 1 a {} apricot 1 11
+ 2 b apple blueberry 2 12
+ 3 c banana clementine 3 13
+ 4 d cherry dewberry 4 14
+ }
+
+ set ROWID rowid
+ if {$tn==1} { set ROWID docid }
+ do_execsql_test 1.$tn.9 "
+ WITH x1(o, n) AS (
+ VALUES(1, 11) UNION ALL
+ VALUES(2, 12) UNION ALL
+ VALUES(3, 13) UNION ALL
+ VALUES(4, 14)
+ )
+ UPDATE ft SET $ROWID = n FROM x1 WHERE ft.rowid = o;
+ SELECT rowid, a, b, c FROM ft ORDER BY rowid;
+ " {
+ 11 a {} apricot
+ 12 b apple blueberry
+ 13 c banana clementine
+ 14 d cherry dewberry
+ }
+}
+
+finish_test
diff --git a/test/full.test b/test/full.test
new file mode 100644
index 0000000..a8fe371
--- /dev/null
+++ b/test/full.test
@@ -0,0 +1,20 @@
+# 2012 September 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 runs the "full" test suite. It is a peer of the quick.test
+# and all.test scripts.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/permutations.test
+
+run_test_suite full
+
+finish_test
diff --git a/test/func.test b/test/func.test
new file mode 100644
index 0000000..df9d4da
--- /dev/null
+++ b/test/func.test
@@ -0,0 +1,1525 @@
+# 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
+set testprefix func
+
+# 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.556,2);}
+ } {9999999999999.56}
+ do_test func-4.39 {
+ string tolower [db eval {SELECT round(1e500), round(-1e500);}]
+ } {inf -inf}
+}
+
+# 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}
+}
+do_execsql_test func-9.14 {
+ WITH RECURSIVE c(x) AS (
+ VALUES(1)
+ UNION ALL
+ SELECT x+1 FROM c WHERE x<1040
+ )
+ SELECT
+ count(*),
+ sum(length(replace(printf('abc%.*cxyz',x,'m'),'m','nnnn'))-(6+x*4))
+ FROM c;
+} {1040 0}
+
+# 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}
+
+# Test that auxiliary data is discarded when a statement is reset.
+do_execsql_test 13.8.1 {
+ SELECT test_auxdata('constant') FROM t4;
+} {0 1}
+do_execsql_test 13.8.2 {
+ SELECT test_auxdata('constant') FROM t4;
+} {0 1}
+db cache flush
+do_execsql_test 13.8.3 {
+ SELECT test_auxdata('constant') FROM t4;
+} {0 1}
+set V "one"
+do_execsql_test 13.8.4 {
+ SELECT test_auxdata($V), $V FROM t4;
+} {0 one 1 one}
+set V "two"
+do_execsql_test 13.8.5 {
+ SELECT test_auxdata($V), $V FROM t4;
+} {0 two 1 two}
+db cache flush
+set V "three"
+do_execsql_test 13.8.6 {
+ SELECT test_auxdata($V), $V FROM t4;
+} {0 three 1 three}
+
+
+# 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}
+
+# 2021-06-15 - infinite loop due to unsigned character counter
+# overflow, reported by Zimuzo Ezeozue
+#
+do_execsql_test func-22.23 {
+ SELECT trim('xyzzy',x'c0808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080');
+} {xyzzy}
+
+# 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}
+# Tests to verify ticket http://www.sqlite.org/src/tktview/55746f9e65f8587c0
+do_test func-24.13 {
+ execsql {
+ SELECT typeof(group_concat(x)) FROM (SELECT '' AS x);
+ }
+} {text}
+do_test func-24.14 {
+ execsql {
+ SELECT typeof(group_concat(x,''))
+ FROM (SELECT '' AS x UNION ALL SELECT '');
+ }
+} {text}
+
+
+# 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()}}
+
+# Verify that the length() and typeof() functions do not actually load
+# the content of their argument.
+#
+do_test func-29.1 {
+ db eval {
+ CREATE TABLE t29(id INTEGER PRIMARY KEY, x, y);
+ INSERT INTO t29 VALUES(1, 2, 3), (2, NULL, 4), (3, 4.5, 5);
+ INSERT INTO t29 VALUES(4, randomblob(1000000), 6);
+ INSERT INTO t29 VALUES(5, 'hello', 7);
+ }
+ db close
+ sqlite3 db test.db
+ sqlite3_db_status db CACHE_MISS 1
+ db eval {SELECT typeof(x), length(x), typeof(y) FROM t29 ORDER BY id}
+} {integer 1 integer null {} integer real 3 integer blob 1000000 integer text 5 integer}
+do_test func-29.2 {
+ set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1]
+ if {$x<5} {set x 1}
+ set x
+} {1}
+do_test func-29.3 {
+ db close
+ sqlite3 db test.db
+ sqlite3_db_status db CACHE_MISS 1
+ db eval {SELECT typeof(+x) FROM t29 ORDER BY id}
+} {integer null real blob text}
+if {[permutation] != "mmap"} {
+ ifcapable !direct_read {
+ do_test func-29.4 {
+ set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1]
+ if {$x>100} {set x many}
+ set x
+ } {many}
+ }
+}
+do_test func-29.5 {
+ db close
+ sqlite3 db test.db
+ sqlite3_db_status db CACHE_MISS 1
+ db eval {SELECT sum(length(x)) FROM t29}
+} {1000009}
+do_test func-29.6 {
+ set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1]
+ if {$x<5} {set x 1}
+ set x
+} {1}
+
+# The OP_Column opcode has an optimization that avoids loading content
+# for fields with content-length=0 when the content offset is on an overflow
+# page. Make sure the optimization works.
+#
+do_execsql_test func-29.10 {
+ CREATE TABLE t29b(a,b,c,d,e,f,g,h,i);
+ INSERT INTO t29b
+ VALUES(1, hex(randomblob(2000)), null, 0, 1, '', zeroblob(0),'x',x'01');
+ SELECT typeof(c), typeof(d), typeof(e), typeof(f),
+ typeof(g), typeof(h), typeof(i) FROM t29b;
+} {null integer integer text blob text blob}
+do_execsql_test func-29.11 {
+ SELECT length(f), length(g), length(h), length(i) FROM t29b;
+} {0 0 1 1}
+do_execsql_test func-29.12 {
+ SELECT quote(f), quote(g), quote(h), quote(i) FROM t29b;
+} {'' X'' 'x' X'01'}
+
+# EVIDENCE-OF: R-29701-50711 The unicode(X) function returns the numeric
+# unicode code point corresponding to the first character of the string
+# X.
+#
+# EVIDENCE-OF: R-55469-62130 The char(X1,X2,...,XN) function returns a
+# string composed of characters having the unicode code point values of
+# integers X1 through XN, respectively.
+#
+do_execsql_test func-30.1 {SELECT unicode('$');} 36
+do_execsql_test func-30.2 [subst {SELECT unicode('\u00A2');}] 162
+do_execsql_test func-30.3 [subst {SELECT unicode('\u20AC');}] 8364
+do_execsql_test func-30.4 {SELECT char(36,162,8364);} [subst {$\u00A2\u20AC}]
+
+for {set i 1} {$i<0xd800} {incr i 13} {
+ do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i
+}
+for {set i 57344} {$i<=0xfffd} {incr i 17} {
+ if {$i==0xfeff} continue
+ do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i
+}
+for {set i 65536} {$i<=0x10ffff} {incr i 139} {
+ do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i
+}
+
+# Test char().
+#
+do_execsql_test func-31.1 {
+ SELECT char(), length(char()), typeof(char())
+} {{} 0 text}
+
+# sqlite3_value_frombind()
+#
+do_execsql_test func-32.100 {
+ SELECT test_frombind(1,2,3,4);
+} {0}
+do_execsql_test func-32.110 {
+ SELECT test_frombind(1,2,?,4);
+} {4}
+do_execsql_test func-32.120 {
+ SELECT test_frombind(1,(?),4,?+7);
+} {2}
+do_execsql_test func-32.130 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b,c,e,f);
+ INSERT INTO t1 VALUES(1,2.5,'xyz',x'e0c1b2a3',null);
+ SELECT test_frombind(a,b,c,e,f,$xyz) FROM t1;
+} {32}
+do_execsql_test func-32.140 {
+ SELECT test_frombind(a,b,c,e,f,$xyz+f) FROM t1;
+} {0}
+do_execsql_test func-32.150 {
+ SELECT test_frombind(x.a,y.b,x.c,:123,y.e,x.f,$xyz+y.f) FROM t1 x, t1 y;
+} {8}
+
+# 2019-08-15
+# Direct-only functions.
+#
+proc testdirectonly {x} {return [expr {$x*2}]}
+do_test func-33.1 {
+ db func testdirectonly -directonly testdirectonly
+ db eval {SELECT testdirectonly(15)}
+} {30}
+do_catchsql_test func-33.2 {
+ CREATE VIEW v33(y) AS SELECT testdirectonly(15);
+ SELECT * FROM v33;
+} {1 {unsafe use of testdirectonly()}}
+do_execsql_test func-33.3 {
+ SELECT * FROM (SELECT testdirectonly(15)) AS v33;
+} {30}
+do_execsql_test func-33.4 {
+ WITH c(x) AS (SELECT testdirectonly(15))
+ SELECT * FROM c;
+} {30}
+do_catchsql_test func-33.5 {
+ WITH c(x) AS (SELECT * FROM v33)
+ SELECT * FROM c;
+} {1 {unsafe use of testdirectonly()}}
+do_execsql_test func-33.10 {
+ CREATE TABLE t33a(a,b);
+ CREATE TABLE t33b(x,y);
+ CREATE TRIGGER r1 AFTER INSERT ON t33a BEGIN
+ INSERT INTO t33b(x,y) VALUES(testdirectonly(new.a),new.b);
+ END;
+} {}
+do_catchsql_test func-33.11 {
+ INSERT INTO t33a VALUES(1,2);
+} {1 {unsafe use of testdirectonly()}}
+
+ifcapable altertable {
+do_execsql_test func-33.20 {
+ ALTER TABLE t33a RENAME COLUMN a TO aaa;
+ SELECT sql FROM sqlite_master WHERE name='r1';
+} {{CREATE TRIGGER r1 AFTER INSERT ON t33a BEGIN
+ INSERT INTO t33b(x,y) VALUES(testdirectonly(new.aaa),new.b);
+ END}}
+}
+
+# 2020-01-09 Yongheng fuzzer find
+# The bug is in the register-validity debug logic, not in the SQLite core
+# and as such it only impacts debug builds. Release builds work fine.
+#
+reset_db
+do_execsql_test func-34.10 {
+ CREATE TABLE t1(a INT CHECK(
+ datetime( 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,a)
+ )
+ );
+ INSERT INTO t1(a) VALUES(1),(2);
+ SELECT * FROM t1;
+} {1 2}
+
+# 2020-03-11 COALESCE() should short-circuit
+# See also ticket 3c9eadd2a6ba0aa5
+# Both issues stem from the fact that functions that could
+# throw exceptions were being factored out into initialization
+# code. The fix was to put those function calls inside of
+# OP_Once instead.
+#
+reset_db
+do_execsql_test func-35.100 {
+ CREATE TABLE t1(x);
+ SELECT coalesce(x, abs(-9223372036854775808)) FROM t1;
+} {}
+do_execsql_test func-35.110 {
+ SELECT coalesce(x, 'xyz' LIKE printf('%.1000000c','y')) FROM t1;
+} {}
+do_execsql_test func-35.200 {
+ CREATE TABLE t0(c0 CHECK(ABS(-9223372036854775808)));
+ PRAGMA integrity_check;
+} {ok}
+
+# 2021-01-07: The -> and ->> operators.
+#
+proc ptr1 {a b} { return "$a->$b" }
+db func -> ptr1
+proc ptr2 {a b} { return "$a->>$b" }
+db func ->> ptr2
+do_execsql_test func-36.100 {
+ SELECT 123 -> 456
+} {123->456}
+do_execsql_test func-36.110 {
+ SELECT 123 ->> 456
+} {123->>456}
+
+
+
+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..0221a0d
--- /dev/null
+++ b/test/func3.test
@@ -0,0 +1,211 @@
+# 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
+
+# EVIDENCE-OF: R-41921-05214 The likelihood(X,Y) function returns
+# argument X unchanged.
+#
+do_execsql_test func3-5.1 {
+ SELECT likelihood(9223372036854775807, 0.5);
+} {9223372036854775807}
+do_execsql_test func3-5.2 {
+ SELECT likelihood(-9223372036854775808, 0.5);
+} {-9223372036854775808}
+do_execsql_test func3-5.3 {
+ SELECT likelihood(14.125, 0.5);
+} {14.125}
+do_execsql_test func3-5.4 {
+ SELECT likelihood(NULL, 0.5);
+} {{}}
+do_execsql_test func3-5.5 {
+ SELECT likelihood('test-string', 0.5);
+} {test-string}
+do_execsql_test func3-5.6 {
+ SELECT quote(likelihood(x'010203000405', 0.5));
+} {X'010203000405'}
+
+# EVIDENCE-OF: R-44133-61651 The value Y in likelihood(X,Y) must be a
+# floating point constant between 0.0 and 1.0, inclusive.
+#
+do_execsql_test func3-5.7 {
+ SELECT likelihood(123, 1.0), likelihood(456, 0.0);
+} {123 456}
+do_test func3-5.8 {
+ catchsql {
+ SELECT likelihood(123, 1.000001);
+ }
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+do_test func3-5.9 {
+ catchsql {
+ SELECT likelihood(123, -0.000001);
+ }
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+do_test func3-5.10 {
+ catchsql {
+ SELECT likelihood(123, 0.5+0.3);
+ }
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+
+# EVIDENCE-OF: R-28535-44631 The likelihood(X) function is a no-op that
+# the code generator optimizes away so that it consumes no CPU cycles
+# during run-time (that is, during calls to sqlite3_step()).
+#
+do_test func3-5.20 {
+ db eval {EXPLAIN SELECT likelihood(min(1.0+'2.0',4*11), 0.5)}
+} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
+
+
+# EVIDENCE-OF: R-11152-23456 The unlikely(X) function returns the
+# argument X unchanged.
+#
+do_execsql_test func3-5.30 {
+ SELECT unlikely(9223372036854775807);
+} {9223372036854775807}
+do_execsql_test func3-5.31 {
+ SELECT unlikely(-9223372036854775808);
+} {-9223372036854775808}
+do_execsql_test func3-5.32 {
+ SELECT unlikely(14.125);
+} {14.125}
+do_execsql_test func3-5.33 {
+ SELECT unlikely(NULL);
+} {{}}
+do_execsql_test func3-5.34 {
+ SELECT unlikely('test-string');
+} {test-string}
+do_execsql_test func3-5.35 {
+ SELECT quote(unlikely(x'010203000405'));
+} {X'010203000405'}
+
+# EVIDENCE-OF: R-22887-63324 The unlikely(X) function is a no-op that
+# the code generator optimizes away so that it consumes no CPU cycles at
+# run-time (that is, during calls to sqlite3_step()).
+#
+do_test func3-5.39 {
+ db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))}
+} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
+
+# Unlikely() does not preserve the affinity of X.
+# ticket https://www.sqlite.org/src/tktview/0c620df60b
+#
+do_execsql_test func3-5.40 {
+ SELECT likely(CAST(1 AS INT))=='1';
+} 0
+do_execsql_test func3-5.41 {
+ SELECT unlikely(CAST(1 AS INT))=='1';
+} 0
+do_execsql_test func3-5.41 {
+ SELECT likelihood(CAST(1 AS INT),0.5)=='1';
+} 0
+
+
+# EVIDENCE-OF: R-23735-03107 The likely(X) function returns the argument
+# X unchanged.
+#
+do_execsql_test func3-5.50 {
+ SELECT likely(9223372036854775807);
+} {9223372036854775807}
+do_execsql_test func3-5.51 {
+ SELECT likely(-9223372036854775808);
+} {-9223372036854775808}
+do_execsql_test func3-5.52 {
+ SELECT likely(14.125);
+} {14.125}
+do_execsql_test func3-5.53 {
+ SELECT likely(NULL);
+} {{}}
+do_execsql_test func3-5.54 {
+ SELECT likely('test-string');
+} {test-string}
+do_execsql_test func3-5.55 {
+ SELECT quote(likely(x'010203000405'));
+} {X'010203000405'}
+
+# EVIDENCE-OF: R-43464-09689 The likely(X) function is a no-op that the
+# code generator optimizes away so that it consumes no CPU cycles at
+# run-time (that is, during calls to sqlite3_step()).
+#
+do_test func3-5.59 {
+ db eval {EXPLAIN SELECT likely(min(1.0+'2.0',4*11))}
+} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
+
+
+# Test the outcome of specifying NULL xStep and xFinal pointers (normally
+# used to delete any existing function) and a non-NULL xDestroy when there
+# is no existing function to destroy.
+#
+do_test func3-6.0 {
+ sqlite3_create_function_v2 db nofunc 1 utf8
+} {}
+
+
+
+finish_test
diff --git a/test/func4.test b/test/func4.test
new file mode 100644
index 0000000..924c1fa
--- /dev/null
+++ b/test/func4.test
@@ -0,0 +1,758 @@
+# 2013 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The focus of
+# this file is testing the tointeger() and toreal() functions.
+#
+# Several of the toreal() tests are disabled on platforms where floating
+# point precision is not high enough to represent their constant integer
+# expression arguments as double precision floating point values.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set saved_tcl_precision $tcl_precision
+set tcl_precision 0
+load_static_extension db totype
+
+set highPrecision(1) [expr \
+ {[db eval {SELECT tointeger(9223372036854775807 + 1);}] eq {{}}}]
+
+do_execsql_test func4-1.1 {
+ SELECT tointeger(NULL);
+} {{}}
+do_execsql_test func4-1.2 {
+ SELECT tointeger('');
+} {{}}
+do_execsql_test func4-1.3 {
+ SELECT tointeger(' ');
+} {{}}
+do_execsql_test func4-1.4 {
+ SELECT tointeger('1234');
+} {1234}
+do_execsql_test func4-1.5 {
+ SELECT tointeger(' 1234');
+} {{}}
+do_execsql_test func4-1.6 {
+ SELECT tointeger('bad');
+} {{}}
+do_execsql_test func4-1.7 {
+ SELECT tointeger('0xBAD');
+} {{}}
+do_execsql_test func4-1.8 {
+ SELECT tointeger('123BAD');
+} {{}}
+do_execsql_test func4-1.9 {
+ SELECT tointeger('0x123BAD');
+} {{}}
+do_execsql_test func4-1.10 {
+ SELECT tointeger('123NO');
+} {{}}
+do_execsql_test func4-1.11 {
+ SELECT tointeger('0x123NO');
+} {{}}
+do_execsql_test func4-1.12 {
+ SELECT tointeger('-0x1');
+} {{}}
+do_execsql_test func4-1.13 {
+ SELECT tointeger('-0x0');
+} {{}}
+do_execsql_test func4-1.14 {
+ SELECT tointeger('0x0');
+} {{}}
+do_execsql_test func4-1.15 {
+ SELECT tointeger('0x1');
+} {{}}
+do_execsql_test func4-1.16 {
+ SELECT tointeger(-1);
+} {-1}
+do_execsql_test func4-1.17 {
+ SELECT tointeger(-0);
+} {0}
+do_execsql_test func4-1.18 {
+ SELECT tointeger(0);
+} {0}
+do_execsql_test func4-1.19 {
+ SELECT tointeger(1);
+} {1}
+do_execsql_test func4-1.20 {
+ SELECT tointeger(-1.79769313486232e308 - 1);
+} {{}}
+do_execsql_test func4-1.21 {
+ SELECT tointeger(-1.79769313486232e308);
+} {{}}
+do_execsql_test func4-1.22 {
+ SELECT tointeger(-1.79769313486232e308 + 1);
+} {{}}
+do_execsql_test func4-1.23 {
+ SELECT tointeger(-9223372036854775808 - 1);
+} {-9223372036854775808}
+do_execsql_test func4-1.24 {
+ SELECT tointeger(-9223372036854775808);
+} {-9223372036854775808}
+do_execsql_test func4-1.25 {
+ SELECT tointeger(-9223372036854775808 + 1);
+} {-9223372036854775807}
+do_execsql_test func4-1.26 {
+ SELECT tointeger(-9223372036854775807 - 1);
+} {-9223372036854775808}
+do_execsql_test func4-1.27 {
+ SELECT tointeger(-9223372036854775807);
+} {-9223372036854775807}
+do_execsql_test func4-1.28 {
+ SELECT tointeger(-9223372036854775807 + 1);
+} {-9223372036854775806}
+do_execsql_test func4-1.29 {
+ SELECT tointeger(-2147483648 - 1);
+} {-2147483649}
+do_execsql_test func4-1.30 {
+ SELECT tointeger(-2147483648);
+} {-2147483648}
+do_execsql_test func4-1.31 {
+ SELECT tointeger(-2147483648 + 1);
+} {-2147483647}
+do_execsql_test func4-1.32 {
+ SELECT tointeger(2147483647 - 1);
+} {2147483646}
+do_execsql_test func4-1.33 {
+ SELECT tointeger(2147483647);
+} {2147483647}
+do_execsql_test func4-1.34 {
+ SELECT tointeger(2147483647 + 1);
+} {2147483648}
+do_execsql_test func4-1.35 {
+ SELECT tointeger(9223372036854775807 - 1);
+} {9223372036854775806}
+do_execsql_test func4-1.36 {
+ SELECT tointeger(9223372036854775807);
+} {9223372036854775807}
+if {$highPrecision(1)} {
+ do_execsql_test func4-1.37 {
+ SELECT tointeger(9223372036854775807 + 1);
+ } {{}}
+}
+do_execsql_test func4-1.38 {
+ SELECT tointeger(1.79769313486232e308 - 1);
+} {{}}
+do_execsql_test func4-1.39 {
+ SELECT tointeger(1.79769313486232e308);
+} {{}}
+do_execsql_test func4-1.40 {
+ SELECT tointeger(1.79769313486232e308 + 1);
+} {{}}
+do_execsql_test func4-1.41 {
+ SELECT tointeger(4503599627370496 - 1);
+} {4503599627370495}
+do_execsql_test func4-1.42 {
+ SELECT tointeger(4503599627370496);
+} {4503599627370496}
+do_execsql_test func4-1.43 {
+ SELECT tointeger(4503599627370496 + 1);
+} {4503599627370497}
+do_execsql_test func4-1.44 {
+ SELECT tointeger(9007199254740992 - 1);
+} {9007199254740991}
+do_execsql_test func4-1.45 {
+ SELECT tointeger(9007199254740992);
+} {9007199254740992}
+do_execsql_test func4-1.46 {
+ SELECT tointeger(9007199254740992 + 1);
+} {9007199254740993}
+do_execsql_test func4-1.47 {
+ SELECT tointeger(9223372036854775807 - 1);
+} {9223372036854775806}
+do_execsql_test func4-1.48 {
+ SELECT tointeger(9223372036854775807);
+} {9223372036854775807}
+if {$highPrecision(1)} {
+ do_execsql_test func4-1.49 {
+ SELECT tointeger(9223372036854775807 + 1);
+ } {{}}
+ do_execsql_test func4-1.50 {
+ SELECT tointeger(9223372036854775808 - 1);
+ } {{}}
+ do_execsql_test func4-1.51 {
+ SELECT tointeger(9223372036854775808);
+ } {{}}
+ do_execsql_test func4-1.52 {
+ SELECT tointeger(9223372036854775808 + 1);
+ } {{}}
+}
+do_execsql_test func4-1.53 {
+ SELECT tointeger(18446744073709551616 - 1);
+} {{}}
+do_execsql_test func4-1.54 {
+ SELECT tointeger(18446744073709551616);
+} {{}}
+do_execsql_test func4-1.55 {
+ SELECT tointeger(18446744073709551616 + 1);
+} {{}}
+
+ifcapable floatingpoint {
+ set highPrecision(2) [expr \
+ {[db eval {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}]
+
+ do_execsql_test func4-2.1 {
+ SELECT toreal(NULL);
+ } {{}}
+ do_execsql_test func4-2.2 {
+ SELECT toreal('');
+ } {{}}
+ do_execsql_test func4-2.3 {
+ SELECT toreal(' ');
+ } {{}}
+ do_execsql_test func4-2.4 {
+ SELECT toreal('1234');
+ } {1234.0}
+ do_execsql_test func4-2.5 {
+ SELECT toreal(' 1234');
+ } {{}}
+ do_execsql_test func4-2.6 {
+ SELECT toreal('bad');
+ } {{}}
+ do_execsql_test func4-2.7 {
+ SELECT toreal('0xBAD');
+ } {{}}
+ do_execsql_test func4-2.8 {
+ SELECT toreal('123BAD');
+ } {{}}
+ do_execsql_test func4-2.9 {
+ SELECT toreal('0x123BAD');
+ } {{}}
+ do_execsql_test func4-2.10 {
+ SELECT toreal('123NO');
+ } {{}}
+ do_execsql_test func4-2.11 {
+ SELECT toreal('0x123NO');
+ } {{}}
+ do_execsql_test func4-2.12 {
+ SELECT toreal('-0x1');
+ } {{}}
+ do_execsql_test func4-2.13 {
+ SELECT toreal('-0x0');
+ } {{}}
+ do_execsql_test func4-2.14 {
+ SELECT toreal('0x0');
+ } {{}}
+ do_execsql_test func4-2.15 {
+ SELECT toreal('0x1');
+ } {{}}
+ do_execsql_test func4-2.16 {
+ SELECT toreal(-1);
+ } {-1.0}
+ do_execsql_test func4-2.17 {
+ SELECT toreal(-0);
+ } {0.0}
+ do_execsql_test func4-2.18 {
+ SELECT toreal(0);
+ } {0.0}
+ do_execsql_test func4-2.19 {
+ SELECT toreal(1);
+ } {1.0}
+ do_execsql_test func4-2.20 {
+ SELECT toreal(-1.79769313486232e308 - 1);
+ } {-Inf}
+ do_execsql_test func4-2.21 {
+ SELECT toreal(-1.79769313486232e308);
+ } {-Inf}
+ do_execsql_test func4-2.22 {
+ SELECT toreal(-1.79769313486232e308 + 1);
+ } {-Inf}
+ do_execsql_test func4-2.23 {
+ SELECT toreal(-9223372036854775808 - 1);
+ } {-9.223372036854776e+18}
+ do_execsql_test func4-2.24 {
+ SELECT toreal(-9223372036854775808);
+ } {-9.223372036854776e+18}
+ if {$highPrecision(2)} {
+ do_execsql_test func4-2.25 {
+ SELECT toreal(-9223372036854775808 + 1);
+ } {{}}
+ }
+ do_execsql_test func4-2.26 {
+ SELECT toreal(-9223372036854775807 - 1);
+ } {-9.223372036854776e+18}
+ if {$highPrecision(2)} {
+ do_execsql_test func4-2.27 {
+ SELECT toreal(-9223372036854775807);
+ } {{}}
+ do_execsql_test func4-2.28 {
+ SELECT toreal(-9223372036854775807 + 1);
+ } {{}}
+ }
+ do_execsql_test func4-2.29 {
+ SELECT toreal(-2147483648 - 1);
+ } {-2147483649.0}
+ do_execsql_test func4-2.30 {
+ SELECT toreal(-2147483648);
+ } {-2147483648.0}
+ do_execsql_test func4-2.31 {
+ SELECT toreal(-2147483648 + 1);
+ } {-2147483647.0}
+ do_execsql_test func4-2.32 {
+ SELECT toreal(2147483647 - 1);
+ } {2147483646.0}
+ do_execsql_test func4-2.33 {
+ SELECT toreal(2147483647);
+ } {2147483647.0}
+ do_execsql_test func4-2.34 {
+ SELECT toreal(2147483647 + 1);
+ } {2147483648.0}
+ if {$highPrecision(2)} {
+ do_execsql_test func4-2.35 {
+ SELECT toreal(9223372036854775807 - 1);
+ } {{}}
+ if {$highPrecision(1)} {
+ do_execsql_test func4-2.36 {
+ SELECT toreal(9223372036854775807);
+ } {{}}
+ }
+ }
+ do_execsql_test func4-2.37 {
+ SELECT toreal(9223372036854775807 + 1);
+ } {9.223372036854776e+18}
+ do_execsql_test func4-2.38 {
+ SELECT toreal(1.79769313486232e308 - 1);
+ } {Inf}
+ do_execsql_test func4-2.39 {
+ SELECT toreal(1.79769313486232e308);
+ } {Inf}
+ do_execsql_test func4-2.40 {
+ SELECT toreal(1.79769313486232e308 + 1);
+ } {Inf}
+ do_execsql_test func4-2.41 {
+ SELECT toreal(4503599627370496 - 1);
+ } {4503599627370495.0}
+ do_execsql_test func4-2.42 {
+ SELECT toreal(4503599627370496);
+ } {4503599627370496.0}
+ do_execsql_test func4-2.43 {
+ SELECT toreal(4503599627370496 + 1);
+ } {4503599627370497.0}
+ do_execsql_test func4-2.44 {
+ SELECT toreal(9007199254740992 - 1);
+ } {9007199254740991.0}
+ do_execsql_test func4-2.45 {
+ SELECT toreal(9007199254740992);
+ } {9007199254740992.0}
+ if {$highPrecision(2)} {
+ do_execsql_test func4-2.46 {
+ SELECT toreal(9007199254740992 + 1);
+ } {{}}
+ }
+ do_execsql_test func4-2.47 {
+ SELECT toreal(9007199254740992 + 2);
+ } {9007199254740994.0}
+ do_execsql_test func4-2.48 {
+ SELECT toreal(tointeger(9223372036854775808) - 1);
+ } {{}}
+ if {$highPrecision(1)} {
+ do_execsql_test func4-2.49 {
+ SELECT toreal(tointeger(9223372036854775808));
+ } {{}}
+ do_execsql_test func4-2.50 {
+ SELECT toreal(tointeger(9223372036854775808) + 1);
+ } {{}}
+ }
+ do_execsql_test func4-2.51 {
+ SELECT toreal(tointeger(18446744073709551616) - 1);
+ } {{}}
+ do_execsql_test func4-2.52 {
+ SELECT toreal(tointeger(18446744073709551616));
+ } {{}}
+ do_execsql_test func4-2.53 {
+ SELECT toreal(tointeger(18446744073709551616) + 1);
+ } {{}}
+}
+
+ifcapable check {
+ do_execsql_test func4-3.1 {
+ CREATE TABLE t1(
+ x INTEGER CHECK(tointeger(x) IS NOT NULL)
+ );
+ } {}
+ do_test func4-3.2 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (NULL);
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.3 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (NULL);
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.4 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES ('');
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.5 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES ('bad');
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.6 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES ('1234bad');
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.7 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES ('1234.56bad');
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.8 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (1234);
+ }
+ } {0 {}}
+ do_test func4-3.9 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (1234.56);
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.10 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES ('1234');
+ }
+ } {0 {}}
+ do_test func4-3.11 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES ('1234.56');
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.12 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (ZEROBLOB(4));
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.13 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (X'');
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.14 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (X'1234');
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.15 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (X'12345678');
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ do_test func4-3.16 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES ('1234.00');
+ }
+ } {0 {}}
+ do_test func4-3.17 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (1234.00);
+ }
+ } {0 {}}
+ do_test func4-3.18 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES ('-9223372036854775809');
+ }
+ } {0 {}}
+ if {$highPrecision(1)} {
+ do_test func4-3.19 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES (9223372036854775808);
+ }
+ } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
+ }
+ do_execsql_test func4-3.20 {
+ SELECT x FROM t1 WHERE x>0 ORDER BY x;
+ } {1234 1234 1234 1234}
+
+ ifcapable floatingpoint {
+ do_execsql_test func4-4.1 {
+ CREATE TABLE t2(
+ x REAL CHECK(toreal(x) IS NOT NULL)
+ );
+ } {}
+ do_test func4-4.2 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES (NULL);
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_test func4-4.3 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES (NULL);
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_test func4-4.4 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES ('');
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_test func4-4.5 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES ('bad');
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_test func4-4.6 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES ('1234bad');
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_test func4-4.7 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES ('1234.56bad');
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_test func4-4.8 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES (1234);
+ }
+ } {0 {}}
+ do_test func4-4.9 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES (1234.56);
+ }
+ } {0 {}}
+ do_test func4-4.10 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES ('1234');
+ }
+ } {0 {}}
+ do_test func4-4.11 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES ('1234.56');
+ }
+ } {0 {}}
+ do_test func4-4.12 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES (ZEROBLOB(4));
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_test func4-4.13 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES (X'');
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_test func4-4.14 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES (X'1234');
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_test func4-4.15 {
+ catchsql {
+ INSERT INTO t2 (x) VALUES (X'12345678');
+ }
+ } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
+ do_execsql_test func4-4.16 {
+ SELECT x FROM t2 ORDER BY x;
+ } {1234.0 1234.0 1234.56 1234.56}
+ }
+}
+
+ifcapable floatingpoint {
+ do_execsql_test func4-5.1 {
+ SELECT tointeger(toreal('1234'));
+ } {1234}
+ do_execsql_test func4-5.2 {
+ SELECT tointeger(toreal(-1));
+ } {-1}
+ do_execsql_test func4-5.3 {
+ SELECT tointeger(toreal(-0));
+ } {0}
+ do_execsql_test func4-5.4 {
+ SELECT tointeger(toreal(0));
+ } {0}
+ do_execsql_test func4-5.5 {
+ SELECT tointeger(toreal(1));
+ } {1}
+ do_execsql_test func4-5.6 {
+ SELECT tointeger(toreal(-9223372036854775808 - 1));
+ } {-9223372036854775808}
+ do_execsql_test func4-5.7 {
+ SELECT tointeger(toreal(-9223372036854775808));
+ } {-9223372036854775808}
+ if {$highPrecision(2)} {
+ do_execsql_test func4-5.8 {
+ SELECT tointeger(toreal(-9223372036854775808 + 1));
+ } {{}}
+ }
+ do_execsql_test func4-5.9 {
+ SELECT tointeger(toreal(-2147483648 - 1));
+ } {-2147483649}
+ do_execsql_test func4-5.10 {
+ SELECT tointeger(toreal(-2147483648));
+ } {-2147483648}
+ do_execsql_test func4-5.11 {
+ SELECT tointeger(toreal(-2147483648 + 1));
+ } {-2147483647}
+ do_execsql_test func4-5.12 {
+ SELECT tointeger(toreal(2147483647 - 1));
+ } {2147483646}
+ do_execsql_test func4-5.13 {
+ SELECT tointeger(toreal(2147483647));
+ } {2147483647}
+ do_execsql_test func4-5.14 {
+ SELECT tointeger(toreal(2147483647 + 1));
+ } {2147483648}
+ do_execsql_test func4-5.15 {
+ SELECT tointeger(toreal(9223372036854775807 - 1));
+ } {{}}
+ if {$highPrecision(1)} {
+ do_execsql_test func4-5.16 {
+ SELECT tointeger(toreal(9223372036854775807));
+ } {{}}
+ do_execsql_test func4-5.17 {
+ SELECT tointeger(toreal(9223372036854775807 + 1));
+ } {{}}
+ }
+ do_execsql_test func4-5.18 {
+ SELECT tointeger(toreal(4503599627370496 - 1));
+ } {4503599627370495}
+ do_execsql_test func4-5.19 {
+ SELECT tointeger(toreal(4503599627370496));
+ } {4503599627370496}
+ do_execsql_test func4-5.20 {
+ SELECT tointeger(toreal(4503599627370496 + 1));
+ } {4503599627370497}
+ do_execsql_test func4-5.21 {
+ SELECT tointeger(toreal(9007199254740992 - 1));
+ } {9007199254740991}
+ do_execsql_test func4-5.22 {
+ SELECT tointeger(toreal(9007199254740992));
+ } {9007199254740992}
+ if {$highPrecision(2)} {
+ do_execsql_test func4-5.23 {
+ SELECT tointeger(toreal(9007199254740992 + 1));
+ } {{}}
+ }
+ do_execsql_test func4-5.24 {
+ SELECT tointeger(toreal(9007199254740992 + 2));
+ } {9007199254740994}
+ if {$highPrecision(1)} {
+ do_execsql_test func4-5.25 {
+ SELECT tointeger(toreal(9223372036854775808 - 1));
+ } {{}}
+ do_execsql_test func4-5.26 {
+ SELECT tointeger(toreal(9223372036854775808));
+ } {{}}
+ do_execsql_test func4-5.27 {
+ SELECT tointeger(toreal(9223372036854775808 + 1));
+ } {{}}
+ }
+ do_execsql_test func4-5.28 {
+ SELECT tointeger(toreal(18446744073709551616 - 1));
+ } {{}}
+ do_execsql_test func4-5.29 {
+ SELECT tointeger(toreal(18446744073709551616));
+ } {{}}
+ do_execsql_test func4-5.30 {
+ SELECT tointeger(toreal(18446744073709551616 + 1));
+ } {{}}
+}
+
+for {set i 0} {$i < 10} {incr i} {
+ if {$i == 8} continue
+ do_execsql_test func4-6.1.$i.1 [subst {
+ SELECT tointeger(x'[string repeat 01 $i]');
+ }] {{}}
+ ifcapable floatingpoint {
+ do_execsql_test func4-6.1.$i.2 [subst {
+ SELECT toreal(x'[string repeat 01 $i]');
+ }] {{}}
+ }
+}
+
+do_execsql_test func4-6.2.1 {
+ SELECT tointeger(x'0102030405060708');
+} {578437695752307201}
+do_execsql_test func4-6.2.2 {
+ SELECT tointeger(x'0807060504030201');
+} {72623859790382856}
+
+ifcapable floatingpoint {
+ do_execsql_test func4-6.3.1 {
+ SELECT toreal(x'ffefffffffffffff');
+ } {-1.7976931348623157e+308}
+ do_execsql_test func4-6.3.2 {
+ SELECT toreal(x'8010000000000000');
+ } {-2.2250738585072014e-308}
+ do_execsql_test func4-6.3.3 {
+ SELECT toreal(x'c000000000000000');
+ } {-2.0}
+ do_execsql_test func4-6.3.4 {
+ SELECT toreal(x'bff0000000000000');
+ } {-1.0}
+ do_execsql_test func4-6.3.5 {
+ SELECT toreal(x'8000000000000000');
+ } {-0.0}
+ do_execsql_test func4-6.3.6 {
+ SELECT toreal(x'0000000000000000');
+ } {0.0}
+ do_execsql_test func4-6.3.7 {
+ SELECT toreal(x'3ff0000000000000');
+ } {1.0}
+ do_execsql_test func4-6.3.8 {
+ SELECT toreal(x'4000000000000000');
+ } {2.0}
+ do_execsql_test func4-6.3.9 {
+ SELECT toreal(x'0010000000000000');
+ } {2.2250738585072014e-308}
+ do_execsql_test func4-6.3.10 {
+ SELECT toreal(x'7fefffffffffffff');
+ } {1.7976931348623157e+308}
+ do_execsql_test func4-6.3.11 {
+ SELECT toreal(x'8000000000000001');
+ } {-5e-324}
+ do_execsql_test func4-6.3.12 {
+ SELECT toreal(x'800fffffffffffff');
+ } {-2.225073858507201e-308}
+ do_execsql_test func4-6.3.13 {
+ SELECT toreal(x'0000000000000001');
+ } {5e-324}
+ do_execsql_test func4-6.3.14 {
+ SELECT toreal(x'000fffffffffffff');
+ } {2.225073858507201e-308}
+ do_execsql_test func4-6.3.15 {
+ SELECT toreal(x'fff0000000000000');
+ } {-Inf}
+ do_execsql_test func4-6.3.16 {
+ SELECT toreal(x'7ff0000000000000');
+ } {Inf}
+ do_execsql_test func4-6.3.17 {
+ SELECT toreal(x'fff8000000000000');
+ } {{}}
+ do_execsql_test func4-6.3.18 {
+ SELECT toreal(x'fff0000000000001');
+ } {{}}
+ do_execsql_test func4-6.3.19 {
+ SELECT toreal(x'fff7ffffffffffff');
+ } {{}}
+ do_execsql_test func4-6.3.20 {
+ SELECT toreal(x'7ff0000000000001');
+ } {{}}
+ do_execsql_test func4-6.3.21 {
+ SELECT toreal(x'7ff7ffffffffffff');
+ } {{}}
+ do_execsql_test func4-6.3.22 {
+ SELECT toreal(x'fff8000000000001');
+ } {{}}
+ do_execsql_test func4-6.3.23 {
+ SELECT toreal(x'ffffffffffffffff');
+ } {{}}
+ do_execsql_test func4-6.3.24 {
+ SELECT toreal(x'7ff8000000000000');
+ } {{}}
+ do_execsql_test func4-6.3.25 {
+ SELECT toreal(x'7fffffffffffffff');
+ } {{}}
+}
+
+set tcl_precision $saved_tcl_precision
+unset saved_tcl_precision
+finish_test
diff --git a/test/func5.test b/test/func5.test
new file mode 100644
index 0000000..8c3dd05
--- /dev/null
+++ b/test/func5.test
@@ -0,0 +1,64 @@
+# 2013-11-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.
+#
+#*************************************************************************
+#
+# Testing of function factoring and the SQLITE_DETERMINISTIC flag.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Verify that constant string expressions that get factored into initializing
+# code are not reused between function parameters and other values in the
+# VDBE program, as the function might have changed the encoding.
+#
+do_execsql_test func5-1.1 {
+ PRAGMA encoding=UTF16le;
+ CREATE TABLE t1(x,a,b,c);
+ INSERT INTO t1 VALUES(1,'ab','cd',1);
+ INSERT INTO t1 VALUES(2,'gh','ef',5);
+ INSERT INTO t1 VALUES(3,'pqr','fuzzy',99);
+ INSERT INTO t1 VALUES(4,'abcdefg','xy',22);
+ INSERT INTO t1 VALUES(5,'shoe','mayer',2953);
+ SELECT x FROM t1 WHERE c=instr('abcdefg',b) OR a='abcdefg' ORDER BY +x;
+} {2 4}
+do_execsql_test func5-1.2 {
+ SELECT x FROM t1 WHERE a='abcdefg' OR c=instr('abcdefg',b) ORDER BY +x;
+} {2 4}
+
+# Verify that SQLITE_DETERMINISTIC functions get factored out of the
+# evaluation loop whereas non-deterministic functions do not. counter1()
+# is marked as non-deterministic and so is not factored out of the loop,
+# and it really is non-deterministic, returning a different result each
+# time. But counter2() is marked as deterministic, so it does get factored
+# out of the loop. counter2() has the same implementation as counter1(),
+# returning a different result on each invocation, but because it is
+# only invoked once outside of the loop, it appears to return the same
+# result multiple times.
+#
+do_execsql_test func5-2.1 {
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(1,2),(3,4),(5,6),(7,8);
+ SELECT x, y FROM t2 WHERE x+5=5+x ORDER BY +x;
+} {1 2 3 4 5 6 7 8}
+sqlite3_create_function db
+do_execsql_test func5-2.2 {
+ SELECT x, y FROM t2
+ WHERE x+counter1('hello')=counter1('hello')+x
+ ORDER BY +x;
+} {}
+set cvalue [db one {SELECT counter2('hello')+1}]
+do_execsql_test func5-2.3 {
+ SELECT x, y FROM t2
+ WHERE x+counter2('hello')=$cvalue+x
+ ORDER BY +x;
+} {1 2 3 4 5 6 7 8}
+
+
+finish_test
diff --git a/test/func6.test b/test/func6.test
new file mode 100644
index 0000000..fe90a75
--- /dev/null
+++ b/test/func6.test
@@ -0,0 +1,183 @@
+# 2017-12-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.
+#
+#*************************************************************************
+#
+# Test cases for the sqlite_offset() function.
+#
+# Some of the tests in this file depend on the exact placement of content
+# within b-tree pages. Such placement is at the implementations discretion,
+# and so it is possible for results to change from one release to the next.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !offset_sql_func {
+ finish_test
+ return
+}
+
+set bNullTrim 0
+ifcapable null_trim {
+ set bNullTrim 1
+}
+
+do_execsql_test func6-100 {
+ PRAGMA page_size=4096;
+ PRAGMA auto_vacuum=NONE;
+ CREATE TABLE t1(a,b,c,d);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c,d) SELECT printf('abc%03x',x), x, 1000-x, NULL FROM c;
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1bc ON t1(b,c);
+ CREATE TABLE t2(x TEXT PRIMARY KEY, y) WITHOUT ROWID;
+ INSERT INTO t2(x,y) SELECT a, b FROM t1;
+}
+
+# Load the contents of $file from disk and return it encoded as a hex
+# string.
+proc loadhex {file} {
+ set fd [open $file]
+ fconfigure $fd -translation binary -encoding binary
+ set data [read $fd]
+ close $fd
+ binary encode hex $data
+}
+
+# Each argument is either an integer between 0 and 65535, a text value, or
+# an empty string representing an SQL NULL. This command builds an SQLite
+# record containing the values passed as arguments and returns it encoded
+# as a hex string.
+proc hexrecord {args} {
+ set hdr ""
+ set body ""
+
+ if {$::bNullTrim} {
+ while {[llength $args] && [lindex $args end]=={}} {
+ set args [lrange $args 0 end-1]
+ }
+ }
+
+ foreach x $args {
+ if {$x==""} {
+ append hdr 00
+ } elseif {[string is integer $x]==0} {
+ set n [string length $x]
+ append hdr [format %02x [expr $n*2 + 13]]
+ append body [binary encode hex $x]
+ } elseif {$x == 0} {
+ append hdr 08
+ } elseif {$x == 1} {
+ append hdr 09
+ } elseif {$x <= 127} {
+ append hdr 01
+ append body [format %02x $x]
+ } else {
+ append hdr 02
+ append body [format %04x $x]
+ }
+ }
+ set res [format %02x [expr 1 + [string length $hdr]/2]]
+ append res $hdr
+ append res $body
+}
+
+# Argument $off is an offset into the database image encoded as a hex string
+# in argument $hexdb. This command returns 0 if the offset contains the hex
+# $hexrec, or throws an exception otherwise.
+#
+proc offset_contains_record {off hexdb hexrec} {
+ set n [string length $hexrec]
+ set off [expr $off*2]
+ if { [string compare $hexrec [string range $hexdb $off [expr $off+$n-1]]] } {
+ error "record not found!"
+ }
+ return 0
+}
+
+# This command is the implementation of SQL function "offrec()". The first
+# argument to this is an offset value. The remaining values are used to
+# formulate an SQLite record. If database file test.db does not contain
+# an equivalent record at the specified offset, an exception is thrown.
+# Otherwise, 0 is returned.
+#
+proc offrec {args} {
+ set offset [lindex $args 0]
+ set rec [hexrecord {*}[lrange $args 1 end]]
+ offset_contains_record $offset $::F $rec
+}
+set F [loadhex test.db]
+db func offrec offrec
+
+# Test the sanity of the tests.
+if {$bNullTrim} {
+ set offset 8180
+} else {
+ set offset 8179
+}
+do_execsql_test func6-105 {
+ SELECT sqlite_offset(d) FROM t1 ORDER BY rowid LIMIT 1;
+} $offset
+do_test func6-106 {
+ set r [hexrecord abc001 1 999 {}]
+ offset_contains_record $offset $F $r
+} 0
+
+set z100 [string trim [string repeat "0 " 100]]
+
+# Test offsets within table b-tree t1.
+do_execsql_test func6-110 {
+ SELECT offrec(sqlite_offset(d), a, b, c, d) FROM t1 ORDER BY rowid
+} $z100
+
+do_execsql_test func6-120 {
+ SELECT a, typeof(sqlite_offset(+a)) FROM t1
+ ORDER BY rowid LIMIT 2;
+} {abc001 null abc002 null}
+
+# Test offsets within index b-tree t1a.
+do_execsql_test func6-130 {
+ SELECT offrec(sqlite_offset(a), a, rowid) FROM t1 ORDER BY a
+} $z100
+
+# Test offsets within table b-tree t1 with a temp b-tree ORDER BY.
+do_execsql_test func6-140 {
+ SELECT offrec(sqlite_offset(d), a, b, c, d) FROM t1 ORDER BY a
+} $z100
+
+# Test offsets from both index t1a and table t1 in the same query.
+do_execsql_test func6-150 {
+ SELECT offrec(sqlite_offset(a), a, rowid),
+ offrec(sqlite_offset(d), a, b, c, d)
+ FROM t1 ORDER BY a
+} [concat $z100 $z100]
+
+# Test offsets from both index t1bc and table t1 in the same query.
+do_execsql_test func6-160 {
+ SELECT offrec(sqlite_offset(b), b, c, rowid),
+ offrec(sqlite_offset(c), b, c, rowid),
+ offrec(sqlite_offset(d), a, b, c, d)
+ FROM t1
+ ORDER BY b
+} [concat $z100 $z100 $z100]
+
+# Test offsets in WITHOUT ROWID table t2.
+do_execsql_test func6-200 {
+ SELECT offrec( sqlite_offset(y), x, y ) FROM t2 ORDER BY x
+} $z100
+
+# 2022-03-14 dbsqlfuzz 474499f3977d95fdf2dbcd99c50be1d0082e4c92
+reset_db
+do_execsql_test func6-300 {
+ CREATE TABLE t2(a INT, b INT PRIMARY KEY) WITHOUT ROWID;
+ CREATE INDEX x3 ON t2(b);
+ CREATE TABLE t1(a INT PRIMARY KEY, b TEXT);
+ SELECT * FROM t1 WHERE a IN (SELECT sqlite_offset(b) FROM t2);
+} {}
+
+finish_test
diff --git a/test/func7.test b/test/func7.test
new file mode 100644
index 0000000..bb4f80b
--- /dev/null
+++ b/test/func7.test
@@ -0,0 +1,251 @@
+# 2020-12-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.
+#
+#*************************************************************************
+#
+# Test cases for SQL functions based off the standard math library
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !mathlib {
+ finish_test
+ return
+}
+
+do_execsql_test func7-100 {
+ SELECT ceil(99.9), ceiling(-99.01), floor(17), floor(-17.99);
+} {100.0 -99.0 17 -18.0}
+do_execsql_test func7-110 {
+ SELECT quote(ceil(NULL)), ceil('-99.99');
+} {NULL -99.0}
+do_execsql_test func7-200 {
+ SELECT round(ln(5),2), log(100.0), log(100), log(2,'256');
+} {1.61 2.0 2.0 8.0}
+do_execsql_test func7-210 {
+ SELECT ln(-5), log(-5,100.0);
+} {{} {}}
+
+# Test cases derived from PostgreSQL documentation
+#
+do_execsql_test func7-pg-100 {
+ SELECT abs(-17.4)
+} {17.4}
+do_execsql_test func7-pg-110 {
+ SELECT ceil(42.2)
+} {43.0}
+do_execsql_test func7-pg-120 {
+ SELECT ceil(-42.2)
+} {-42.0}
+do_execsql_test func7-pg-130 {
+ SELECT round(exp(1.0),7)
+} {2.7182818}
+do_execsql_test func7-pg-140 {
+ SELECT floor(42.8)
+} {42.0}
+do_execsql_test func7-pg-150 {
+ SELECT floor(-42.8)
+} {-43.0}
+do_execsql_test func7-pg-160 {
+ SELECT round(ln(2.0),7)
+} {0.6931472}
+do_execsql_test func7-pg-170 {
+ SELECT log(100.0)
+} {2.0}
+do_execsql_test func7-pg-180 {
+ SELECT log10(1000.0)
+} {3.0}
+do_execsql_test func7-pg-181 {
+ SELECT format('%.30f', log10(100.0) );
+} {2.000000000000000000000000000000}
+do_execsql_test func7-pg-182 {
+ SELECT format('%.30f', ln(exp(2.0)) );
+} {2.000000000000000000000000000000}
+do_execsql_test func7-pg-190 {
+ SELECT log(2.0, 64.0)
+} {6.0}
+do_execsql_test func7-pg-200 {
+ SELECT mod(9,4);
+} {1.0}
+do_execsql_test func7-pg-210 {
+ SELECT round(pi(),7);
+} {3.1415927}
+do_execsql_test func7-pg-220 {
+ SELECT power(9,3);
+} {729.0}
+do_execsql_test func7-pg-230 {
+ SELECT round(radians(45.0),7);
+} {0.7853982}
+do_execsql_test func7-pg-240 {
+ SELECT round(42.4);
+} {42.0}
+do_execsql_test func7-pg-250 {
+ SELECT round(42.4382,2);
+} {42.44}
+do_execsql_test func7-pg-260 {
+ SELECT sign(-8.4);
+} {-1}
+do_execsql_test func7-pg-270 {
+ SELECT round( sqrt(2), 7);
+} {1.4142136}
+do_execsql_test func7-pg-280 {
+ SELECT trunc(42.8), trunc(-42.8);
+} {42.0 -42.0}
+do_execsql_test func7-pg-300 {
+ SELECT acos(1);
+} {0.0}
+do_execsql_test func7-pg-301 {
+ SELECT degrees(acos(0.5));
+} {60.0}
+do_execsql_test func7-pg-310 {
+ SELECT round( asin(1), 7);
+} {1.5707963}
+do_execsql_test func7-pg-311 {
+ SELECT degrees( asin(0.5) );
+} {30.0}
+do_execsql_test func7-pg-320 {
+ SELECT round( atan(1), 7);
+} {0.7853982}
+do_execsql_test func7-pg-321 {
+ SELECT degrees( atan(1) );
+} {45.0}
+do_execsql_test func7-pg-330 {
+ SELECT round( atan2(1,0), 7);
+} {1.5707963}
+do_execsql_test func7-pg-331 {
+ SELECT degrees( atan2(1,0) );
+} {90.0}
+do_execsql_test func7-pg-400 {
+ SELECT cos(0);
+} {1.0}
+do_execsql_test func7-pg-401 {
+ SELECT cos( radians(60.0) );
+} {0.5}
+do_execsql_test func7-pg-400 {
+ SELECT cos(0);
+} {1.0}
+do_execsql_test func7-pg-410 {
+ SELECT round( sin(1), 7);
+} {0.841471}
+do_execsql_test func7-pg-411 {
+ SELECT sin( radians(30) );
+} {0.5}
+do_execsql_test func7-pg-420 {
+ SELECT round( tan(1), 7);
+} {1.5574077}
+do_execsql_test func7-pg-421 {
+ SELECT tan( radians(45) );
+} {1.0}
+do_execsql_test func7-pg-500 {
+ SELECT round( sinh(1), 7);
+} {1.1752012}
+do_execsql_test func7-pg-510 {
+ SELECT round( cosh(0), 7);
+} {1.0}
+do_execsql_test func7-pg-520 {
+ SELECT round( tanh(1), 7);
+} {0.7615942}
+do_execsql_test func7-pg-530 {
+ SELECT round( asinh(1), 7);
+} {0.8813736}
+do_execsql_test func7-pg-540 {
+ SELECT round( acosh(1), 7);
+} {0.0}
+do_execsql_test func7-pg-550 {
+ SELECT round( atanh(0.5), 7);
+} {0.5493061}
+
+# Test cases derived from MySQL documentation
+#
+do_execsql_test func7-mysql-100 {
+ SELECT acos(1);
+} {0.0}
+do_execsql_test func7-mysql-110 {
+ SELECT acos(1.0001);
+} {{}}
+do_execsql_test func7-mysql-120 {
+ SELECT round( acos(0.0), 7);
+} {1.5707963}
+do_execsql_test func7-mysql-130 {
+ SELECT round( asin(0.2), 7);
+} {0.2013579}
+do_execsql_test func7-mysql-140 {
+ SELECT asin('foo');
+} {{}} ;# Note: MySQL returns 0 here, not NULL.
+ # SQLite deliberately returns NULL.
+ # SQLServer and Oracle throw an error.
+do_execsql_test func7-mysql-150 {
+ SELECT round( atan(2), 7), round( atan(-2), 7);
+} {1.1071487 -1.1071487}
+do_execsql_test func7-mysql-160 {
+ SELECT round( atan2(-2,2), 7), round( atan2(pi(),0), 7);
+} {-0.7853982 1.5707963}
+do_execsql_test func7-mysql-170 {
+ SELECT ceiling(1.23), ceiling(-1.23);
+} {2.0 -1.0}
+do_execsql_test func7-mysql-180 {
+ SELECT cos(pi());
+} {-1.0}
+do_execsql_test func7-mysql-190 {
+ SELECT degrees(pi()), degrees(pi()/2);
+} {180.0 90.0}
+do_execsql_test func7-mysql-190 {
+ SELECT round( exp(2), 7), round( exp(-2), 7), exp(0);
+} {7.3890561 0.1353353 1.0}
+do_execsql_test func7-mysql-200 {
+ SELECT floor(1.23), floor(-1.23);
+} {1.0 -2.0}
+do_execsql_test func7-mysql-210 {
+ SELECT round(ln(2),7), quote(ln(-2));
+} {0.6931472 NULL}
+#do_execsql_test func7-mysql-220 {
+# SELECT round(log(2),7), log(-2);
+#} {0.6931472 NULL}
+# log() means natural logarithm in MySQL
+do_execsql_test func7-mysql-230 {
+ SELECT log(2,65536), log(10,100), quote(log(1,100)), quote(log(0,100));
+} {16.0 2.0 NULL NULL}
+do_execsql_test func7-mysql-240 {
+ SELECT log2(65536), quote(log2(-100)), quote(log2(0));
+} {16.0 NULL NULL}
+do_execsql_test func7-mysql-250 {
+ SELECT round(log10(2),7), log10(100), quote(log10(-100));
+} {0.30103 2.0 NULL}
+do_execsql_test func7-mysql-260 {
+ SELECT mod(234,10), 253%7, mod(29,9), 29%9;
+} {4.0 1 2.0 2}
+do_execsql_test func7-mysql-270 {
+ SELECT mod(34.5,3);
+} {1.5}
+do_execsql_test func7-mysql-280 {
+ SELECT pow(2,2), pow(2,-2);
+} {4.0 0.25}
+do_execsql_test func7-mysql-281 {
+ SELECT power(2,2), power(2,-2);
+} {4.0 0.25}
+do_execsql_test func7-mysql-290 {
+ SELECT round(radians(90),7);
+} {1.5707963}
+do_execsql_test func7-mysql-300 {
+ SELECT sign(-32), sign(0), sign(234);
+} {-1 0 1}
+do_execsql_test func7-mysql-310 {
+ SELECT sin(pi()) BETWEEN -1.0e-15 AND 1.0e-15;
+} {1}
+do_execsql_test func7-mysql-320 {
+ SELECT sqrt(4), round(sqrt(20),7), quote(sqrt(-16));
+} {2.0 4.472136 NULL}
+do_execsql_test func7-mysql-330 {
+ SELECT tan(pi()) BETWEEN -1.0e-15 AND 1.0e-15;
+} {1}
+do_execsql_test func7-mysql-331 {
+ SELECT round(tan(pi()+1),7);
+} {1.5574077}
+
+
+finish_test
diff --git a/test/fuzz-oss1.test b/test/fuzz-oss1.test
new file mode 100644
index 0000000..46feeb6
--- /dev/null
+++ b/test/fuzz-oss1.test
@@ -0,0 +1,2007 @@
+# 2012 May 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.
+#
+# NB: Portions of this file are extracted from open-source projects
+# covered by permissive licenses. Use of this file for testing is clearly
+# allowed. However, do not incorporate the text of this one file into
+# end-products without checking the licenses on the open-source projects
+# from which this code was extracted. This warning applies to this one
+# file only - not the bulk of the SQLite source code and tests.
+#
+#***********************************************************************
+#
+# This file contains large and complex schemas obtained from open-source
+# software projects. The schemas are parsed just to make sure that nothing
+# breaks in the parser logic.
+#
+# These tests merely verify that the parse occurs without error.
+# No attempt is made to verify correct operation of the resulting schema
+# and statements.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Schema and query extracted from Skrooge.org.
+#
+do_test fuzz-oss1-skrooge {
+ db eval {
+CREATE TABLE parameters (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_uuid_parent TEXT NOT NULL DEFAULT '',t_name TEXT NOT NULL,t_value TEXT NOT NULL DEFAULT '',b_blob BLOB,d_lastmodifdate DATE NOT NULL DEFAULT CURRENT_TIMESTAMP,i_tmp INTEGER NOT NULL DEFAULT 0);
+CREATE TABLE doctransaction (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL,t_mode VARCHAR(1) DEFAULT 'U' CHECK (t_mode IN ('U', 'R')),d_date DATE NOT NULL,t_savestep VARCHAR(1) DEFAULT 'N' CHECK (t_savestep IN ('Y', 'N')),i_parent INTEGER, t_refreshviews VARCHAR(1) DEFAULT 'Y' CHECK (t_refreshviews IN ('Y', 'N')));
+CREATE TABLE doctransactionitem (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, rd_doctransaction_id INTEGER NOT NULL,i_object_id INTEGER NOT NULL,t_object_table TEXT NOT NULL,t_action VARCHAR(1) DEFAULT 'I' CHECK (t_action IN ('I', 'U', 'D')),t_sqlorder TEXT NOT NULL DEFAULT '');
+CREATE TABLE doctransactionmsg (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, rd_doctransaction_id INTEGER NOT NULL,t_message TEXT NOT NULL DEFAULT '',t_popup VARCHAR(1) DEFAULT 'Y' CHECK (t_popup IN ('Y', 'N')));
+CREATE TABLE unit(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL,t_symbol TEXT NOT NULL DEFAULT '',t_country TEXT NOT NULL DEFAULT '',t_type VARCHAR(1) NOT NULL DEFAULT 'C' CHECK (t_type IN ('1', '2', 'C', 'S', 'I', 'O')),t_internet_code TEXT NOT NULL DEFAULT '',i_nbdecimal INT NOT NULL DEFAULT 2,rd_unit_id INTEGER NOT NULL DEFAULT 0, t_source TEXT NOT NULL DEFAULT '');
+CREATE TABLE unitvalue(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,rd_unit_id INTEGER NOT NULL,d_date DATE NOT NULL,f_quantity FLOAT NOT NULL CHECK (f_quantity>=0));
+CREATE TABLE bank (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '',t_bank_number TEXT NOT NULL DEFAULT '',t_icon TEXT NOT NULL DEFAULT '');
+CREATE TABLE interest(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,rd_account_id INTEGER NOT NULL,d_date DATE NOT NULL,f_rate FLOAT NOT NULL CHECK (f_rate>=0),t_income_value_date_mode VARCHAR(1) NOT NULL DEFAULT 'F' CHECK (t_income_value_date_mode IN ('F', '0', '1', '2', '3', '4', '5')),t_expenditure_value_date_mode VARCHAR(1) NOT NULL DEFAULT 'F' CHECK (t_expenditure_value_date_mode IN ('F', '0', '1', '2', '3', '4', '5')),t_base VARCHAR(3) NOT NULL DEFAULT '24' CHECK (t_base IN ('24', '360', '365')));
+CREATE TABLE operation(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,i_group_id INTEGER NOT NULL DEFAULT 0,i_number INTEGER DEFAULT 0 CHECK (i_number>=0),d_date DATE NOT NULL DEFAULT '0000-00-00',rd_account_id INTEGER NOT NULL,t_mode TEXT NOT NULL DEFAULT '',r_payee_id INTEGER NOT NULL DEFAULT 0,t_comment TEXT NOT NULL DEFAULT '',rc_unit_id INTEGER NOT NULL,t_status VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_status IN ('N', 'P', 'Y')),t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')),t_imported VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_imported IN ('Y', 'N', 'P', 'T')),t_template VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_template IN ('Y', 'N')),t_import_id TEXT NOT NULL DEFAULT '',i_tmp INTEGER NOT NULL DEFAULT 0,r_recurrentoperation_id INTEGER NOT NULL DEFAULT 0);
+CREATE TABLE operationbalance(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,f_balance FLOAT NOT NULL DEFAULT 0,r_operation_id INTEGER NOT NULL);
+CREATE TABLE refund (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '',t_comment TEXT NOT NULL DEFAULT '',t_close VARCHAR(1) DEFAULT 'N' CHECK (t_close IN ('Y', 'N')));
+CREATE TABLE payee (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '',t_address TEXT NOT NULL DEFAULT '', t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')));
+CREATE TABLE suboperation(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_comment TEXT NOT NULL DEFAULT '',rd_operation_id INTEGER NOT NULL,r_category_id INTEGER NOT NULL DEFAULT 0,f_value FLOAT NOT NULL DEFAULT 0.0,i_tmp INTEGER NOT NULL DEFAULT 0,r_refund_id INTEGER NOT NULL DEFAULT 0, t_formula TEXT NOT NULL DEFAULT '');
+CREATE TABLE rule (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_description TEXT NOT NULL DEFAULT '',t_definition TEXT NOT NULL DEFAULT '',t_action_description TEXT NOT NULL DEFAULT '',t_action_definition TEXT NOT NULL DEFAULT '',t_action_type VARCHAR(1) DEFAULT 'S' CHECK (t_action_type IN ('S', 'U', 'A')),t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')),f_sortorder FLOAT);
+CREATE TABLE budget (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,rc_category_id INTEGER NOT NULL DEFAULT 0,t_including_subcategories TEXT NOT NULL DEFAULT 'N' CHECK (t_including_subcategories IN ('Y', 'N')),f_budgeted FLOAT NOT NULL DEFAULT 0.0,f_budgeted_modified FLOAT NOT NULL DEFAULT 0.0,f_transferred FLOAT NOT NULL DEFAULT 0.0,i_year INTEGER NOT NULL DEFAULT 2010,i_month INTEGER NOT NULL DEFAULT 0 CHECK (i_month>=0 AND i_month<=12));
+CREATE TABLE budgetcategory(id INTEGER NOT NULL DEFAULT 0,id_category INTEGER NOT NULL DEFAULT 0);
+CREATE TABLE budgetrule (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,rc_category_id INTEGER NOT NULL DEFAULT 0,t_category_condition TEXT NOT NULL DEFAULT 'Y' CHECK (t_category_condition IN ('Y', 'N')),t_year_condition TEXT NOT NULL DEFAULT 'Y' CHECK (t_year_condition IN ('Y', 'N')),i_year INTEGER NOT NULL DEFAULT 2010,i_month INTEGER NOT NULL DEFAULT 0 CHECK (i_month>=0 AND i_month<=12),t_month_condition TEXT NOT NULL DEFAULT 'Y' CHECK (t_month_condition IN ('Y', 'N')),i_condition INTEGER NOT NULL DEFAULT 0 CHECK (i_condition IN (-1,0,1)),f_quantity FLOAT NOT NULL DEFAULT 0.0,t_absolute TEXT NOT NULL DEFAULT 'Y' CHECK (t_absolute IN ('Y', 'N')),rc_category_id_target INTEGER NOT NULL DEFAULT 0,t_category_target TEXT NOT NULL DEFAULT 'Y' CHECK (t_category_target IN ('Y', 'N')),t_rule TEXT NOT NULL DEFAULT 'N' CHECK (t_rule IN ('N', 'C', 'Y')));
+CREATE TABLE "recurrentoperation" (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,d_date DATE NOT NULL DEFAULT '0000-00-00',rd_operation_id INTEGER NOT NULL,i_period_increment INTEGER NOT NULL DEFAULT 1 CHECK (i_period_increment>=0),t_period_unit TEXT NOT NULL DEFAULT 'M' CHECK (t_period_unit IN ('D', 'W', 'M', 'Y')),t_auto_write VARCHAR(1) DEFAULT 'Y' CHECK (t_auto_write IN ('Y', 'N')),i_auto_write_days INTEGER NOT NULL DEFAULT 5 CHECK (i_auto_write_days>=0),t_warn VARCHAR(1) DEFAULT 'Y' CHECK (t_warn IN ('Y', 'N')),i_warn_days INTEGER NOT NULL DEFAULT 5 CHECK (i_warn_days>=0),t_times VARCHAR(1) DEFAULT 'N' CHECK (t_times IN ('Y', 'N')),i_nb_times INTEGER NOT NULL DEFAULT 1 CHECK (i_nb_times>=0));
+CREATE TABLE "category" (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '' CHECK (t_name NOT LIKE '% > %'),t_fullname TEXT,rd_category_id INT,t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')));
+CREATE TABLE "account"(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL,t_number TEXT NOT NULL DEFAULT '',t_agency_number TEXT NOT NULL DEFAULT '',t_agency_address TEXT NOT NULL DEFAULT '',t_comment TEXT NOT NULL DEFAULT '',t_close VARCHAR(1) DEFAULT 'N' CHECK (t_close IN ('Y', 'N')),t_type VARCHAR(1) NOT NULL DEFAULT 'C' CHECK (t_type IN ('C', 'D', 'A', 'I', 'L', 'W', 'O')),t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')),rd_bank_id INTEGER NOT NULL);
+CREATE TABLE "node" (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '' CHECK (t_name NOT LIKE '% > %'),t_fullname TEXT,t_icon TEXT DEFAULT '',f_sortorder FLOAT,t_autostart VARCHAR(1) DEFAULT 'N' CHECK (t_autostart IN ('Y', 'N')),t_data TEXT,rd_node_id INT CONSTRAINT fk_id REFERENCES node(id) ON DELETE CASCADE);
+CREATE TABLE vm_category_display_tmp(
+ id INT,
+ t_name TEXT,
+ t_fullname TEXT,
+ rd_category_id INT,
+ t_bookmarked TEXT,
+ i_NBOPERATIONS,
+ f_REALCURRENTAMOUNT
+);
+CREATE TABLE vm_budget_tmp(
+ id INT,
+ rc_category_id INT,
+ t_including_subcategories TEXT,
+ f_budgeted REAL,
+ f_budgeted_modified REAL,
+ f_transferred REAL,
+ i_year INT,
+ i_month INT,
+ t_CATEGORY,
+ t_PERIOD,
+ f_CURRENTAMOUNT,
+ t_RULES
+);
+CREATE INDEX idx_doctransaction_parent ON doctransaction (i_parent);
+CREATE INDEX idx_doctransactionitem_i_object_id ON doctransactionitem (i_object_id);
+CREATE INDEX idx_doctransactionitem_t_object_table ON doctransactionitem (t_object_table);
+CREATE INDEX idx_doctransactionitem_t_action ON doctransactionitem (t_action);
+CREATE INDEX idx_doctransactionitem_rd_doctransaction_id ON doctransactionitem (rd_doctransaction_id);
+CREATE INDEX idx_doctransactionitem_optimization ON doctransactionitem (rd_doctransaction_id, i_object_id, t_object_table, t_action, id);
+CREATE INDEX idx_unit_unit_id ON unitvalue(rd_unit_id);
+CREATE INDEX idx_account_bank_id ON account(rd_bank_id);
+CREATE INDEX idx_account_type ON account(t_type);
+CREATE INDEX idx_category_category_id ON category(rd_category_id);
+CREATE INDEX idx_category_t_fullname ON category(t_fullname);
+CREATE INDEX idx_operation_account_id ON operation (rd_account_id);
+CREATE INDEX idx_operation_tmp1_found_transfert ON operation (rc_unit_id, d_date);
+CREATE INDEX idx_operation_grouped_operation_id ON operation (i_group_id);
+CREATE INDEX idx_operation_i_number ON operation (i_number);
+CREATE INDEX idx_operation_i_tmp ON operation (i_tmp);
+CREATE INDEX idx_operation_rd_account_id ON operation (rd_account_id);
+CREATE INDEX idx_operation_rc_unit_id ON operation (rc_unit_id);
+CREATE INDEX idx_operation_t_status ON operation (t_status);
+CREATE INDEX idx_operation_t_import_id ON operation (t_import_id);
+CREATE INDEX idx_operation_t_template ON operation (t_template);
+CREATE INDEX idx_operation_d_date ON operation (d_date);
+CREATE INDEX idx_operationbalance_operation_id ON operationbalance (r_operation_id);
+CREATE INDEX idx_suboperation_operation_id ON suboperation (rd_operation_id);
+CREATE INDEX idx_suboperation_i_tmp ON suboperation (i_tmp);
+CREATE INDEX idx_suboperation_category_id ON suboperation (r_category_id);
+CREATE INDEX idx_suboperation_refund_id_id ON suboperation (r_refund_id);
+CREATE INDEX idx_recurrentoperation_rd_operation_id ON recurrentoperation (rd_operation_id);
+CREATE INDEX idx_refund_close ON refund(t_close);
+CREATE INDEX idx_interest_account_id ON interest (rd_account_id);
+CREATE INDEX idx_rule_action_type ON rule(t_action_type);
+CREATE INDEX idx_budget_category_id ON budget(rc_category_id);
+CREATE INDEX idx_budgetcategory_id ON budgetcategory (id);
+CREATE INDEX idx_budgetcategory_id_category ON budgetcategory (id_category);
+CREATE UNIQUE INDEX uidx_parameters_uuid_parent_name ON parameters (t_uuid_parent, t_name);
+CREATE UNIQUE INDEX uidx_node_parent_id_name ON node(t_name,rd_node_id);
+CREATE UNIQUE INDEX uidx_node_fullname ON node(t_fullname);
+CREATE UNIQUE INDEX uidx_unit_name ON unit(t_name);
+CREATE UNIQUE INDEX uidx_unit_symbol ON unit(t_symbol);
+CREATE UNIQUE INDEX uidx_unitvalue ON unitvalue(d_date,rd_unit_id);
+CREATE UNIQUE INDEX uidx_bank_name ON bank(t_name);
+CREATE UNIQUE INDEX uidx_account_name ON account(t_name);
+CREATE UNIQUE INDEX uidx_category_parent_id_name ON category(t_name,rd_category_id);
+CREATE UNIQUE INDEX uidx_category_fullname ON category(t_fullname);
+CREATE UNIQUE INDEX uidx_refund_name ON refund(t_name);
+CREATE UNIQUE INDEX uidx_payee_name ON payee(t_name);
+CREATE UNIQUE INDEX uidx_interest ON interest(d_date,rd_account_id);
+CREATE UNIQUE INDEX uidx_budget ON budget(i_year,i_month, rc_category_id);
+CREATE VIEW v_node AS SELECT * from node;
+CREATE VIEW v_node_displayname AS SELECT *, t_fullname AS t_displayname from node;
+CREATE VIEW v_parameters_displayname AS SELECT *, t_name AS t_displayname from parameters;
+CREATE TRIGGER fkdc_parameters_parameters_uuid BEFORE DELETE ON parameters FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'parameters'; END;
+CREATE TRIGGER fkdc_node_parameters_uuid BEFORE DELETE ON node FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'node'; END;
+CREATE TRIGGER cpt_node_fullname1 AFTER INSERT ON node BEGIN UPDATE node SET t_fullname=CASE WHEN new.rd_node_id IS NULL OR new.rd_node_id='' OR new.rd_node_id=0 THEN new.t_name ELSE (SELECT c.t_fullname from node c where c.id=new.rd_node_id)||' > '||new.t_name END WHERE id=new.id;END;
+CREATE TRIGGER cpt_node_fullname2 AFTER UPDATE OF t_name, rd_node_id ON node BEGIN UPDATE node SET t_fullname=CASE WHEN new.rd_node_id IS NULL OR new.rd_node_id='' OR new.rd_node_id=0 THEN new.t_name ELSE (SELECT c.t_fullname from node c where c.id=new.rd_node_id)||' > '||new.t_name END WHERE id=new.id;UPDATE node SET t_name=t_name WHERE rd_node_id=new.id;END;
+CREATE TRIGGER fki_account_bank_rd_bank_id_id BEFORE INSERT ON account FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (bank est utilisé par account)
+Nom de la contrainte : fki_account_bank_rd_bank_id_id') WHERE NEW.rd_bank_id!=0 AND NEW.rd_bank_id!='' AND (SELECT id FROM bank WHERE id = NEW.rd_bank_id) IS NULL; END;
+CREATE TRIGGER fku_account_bank_rd_bank_id_id BEFORE UPDATE ON account FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (bank est utilisé par account)
+Nom de la contrainte : fku_account_bank_rd_bank_id_id') WHERE NEW.rd_bank_id!=0 AND NEW.rd_bank_id!='' AND (SELECT id FROM bank WHERE id = NEW.rd_bank_id) IS NULL; END;
+CREATE TRIGGER fkdc_bank_account_id_rd_bank_id BEFORE DELETE ON bank FOR EACH ROW BEGIN DELETE FROM account WHERE account.rd_bank_id = OLD.id; END;
+CREATE TRIGGER fki_budget_category_rc_category_id_id BEFORE INSERT ON budget FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par budget)
+Nom de la contrainte : fki_budget_category_rc_category_id_id') WHERE NEW.rc_category_id!=0 AND NEW.rc_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id) IS NULL; END;
+CREATE TRIGGER fku_budget_category_rc_category_id_id BEFORE UPDATE ON budget FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par budget)
+Nom de la contrainte : fku_budget_category_rc_category_id_id') WHERE NEW.rc_category_id!=0 AND NEW.rc_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id) IS NULL; END;
+CREATE TRIGGER fkd_budget_category_rc_category_id_id BEFORE DELETE ON category FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de détruire un objet (category est utilisé par budget)
+Nom de la contrainte : fkd_budget_category_rc_category_id_id') WHERE (SELECT rc_category_id FROM budget WHERE rc_category_id = OLD.id) IS NOT NULL; END;
+CREATE TRIGGER fki_budgetrule_category_rc_category_id_id BEFORE INSERT ON budgetrule FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par budgetrule)
+Nom de la contrainte : fki_budgetrule_category_rc_category_id_id') WHERE NEW.rc_category_id!=0 AND NEW.rc_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id) IS NULL; END;
+CREATE TRIGGER fku_budgetrule_category_rc_category_id_id BEFORE UPDATE ON budgetrule FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par budgetrule)
+Nom de la contrainte : fku_budgetrule_category_rc_category_id_id') WHERE NEW.rc_category_id!=0 AND NEW.rc_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id) IS NULL; END;
+CREATE TRIGGER fkd_budgetrule_category_rc_category_id_id BEFORE DELETE ON category FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de détruire un objet (category est utilisé par budgetrule)
+Nom de la contrainte : fkd_budgetrule_category_rc_category_id_id') WHERE (SELECT rc_category_id FROM budgetrule WHERE rc_category_id = OLD.id) IS NOT NULL; END;
+CREATE TRIGGER fki_budgetrule_category_rc_category_id_target_id BEFORE INSERT ON budgetrule FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par budgetrule)
+Nom de la contrainte : fki_budgetrule_category_rc_category_id_target_id') WHERE NEW.rc_category_id_target!=0 AND NEW.rc_category_id_target!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id_target) IS NULL; END;
+CREATE TRIGGER fku_budgetrule_category_rc_category_id_target_id BEFORE UPDATE ON budgetrule FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par budgetrule)
+Nom de la contrainte : fku_budgetrule_category_rc_category_id_target_id') WHERE NEW.rc_category_id_target!=0 AND NEW.rc_category_id_target!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id_target) IS NULL; END;
+CREATE TRIGGER fkd_budgetrule_category_rc_category_id_target_id BEFORE DELETE ON category FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de détruire un objet (category est utilisé par budgetrule)
+Nom de la contrainte : fkd_budgetrule_category_rc_category_id_target_id') WHERE (SELECT rc_category_id_target FROM budgetrule WHERE rc_category_id_target = OLD.id) IS NOT NULL; END;
+CREATE TRIGGER fki_category_category_rd_category_id_id BEFORE INSERT ON category FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par category)
+Nom de la contrainte : fki_category_category_rd_category_id_id') WHERE NEW.rd_category_id!=0 AND NEW.rd_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rd_category_id) IS NULL; END;
+CREATE TRIGGER fku_category_category_rd_category_id_id BEFORE UPDATE ON category FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par category)
+Nom de la contrainte : fku_category_category_rd_category_id_id') WHERE NEW.rd_category_id!=0 AND NEW.rd_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rd_category_id) IS NULL; END;
+CREATE TRIGGER fkdc_category_category_id_rd_category_id BEFORE DELETE ON category FOR EACH ROW BEGIN DELETE FROM category WHERE category.rd_category_id = OLD.id; END;
+CREATE TRIGGER fki_doctransactionitem_doctransaction_rd_doctransaction_id_id BEFORE INSERT ON doctransactionitem FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (doctransaction est utilisé par doctransactionitem)
+Nom de la contrainte : fki_doctransactionitem_doctransaction_rd_doctransaction_id_id') WHERE NEW.rd_doctransaction_id!=0 AND NEW.rd_doctransaction_id!='' AND (SELECT id FROM doctransaction WHERE id = NEW.rd_doctransaction_id) IS NULL; END;
+CREATE TRIGGER fku_doctransactionitem_doctransaction_rd_doctransaction_id_id BEFORE UPDATE ON doctransactionitem FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (doctransaction est utilisé par doctransactionitem)
+Nom de la contrainte : fku_doctransactionitem_doctransaction_rd_doctransaction_id_id') WHERE NEW.rd_doctransaction_id!=0 AND NEW.rd_doctransaction_id!='' AND (SELECT id FROM doctransaction WHERE id = NEW.rd_doctransaction_id) IS NULL; END;
+CREATE TRIGGER fkdc_doctransaction_doctransactionitem_id_rd_doctransaction_id BEFORE DELETE ON doctransaction FOR EACH ROW BEGIN DELETE FROM doctransactionitem WHERE doctransactionitem.rd_doctransaction_id = OLD.id; END;
+CREATE TRIGGER fki_doctransactionmsg_doctransaction_rd_doctransaction_id_id BEFORE INSERT ON doctransactionmsg FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (doctransaction est utilisé par doctransactionmsg)
+Nom de la contrainte : fki_doctransactionmsg_doctransaction_rd_doctransaction_id_id') WHERE NEW.rd_doctransaction_id!=0 AND NEW.rd_doctransaction_id!='' AND (SELECT id FROM doctransaction WHERE id = NEW.rd_doctransaction_id) IS NULL; END;
+CREATE TRIGGER fku_doctransactionmsg_doctransaction_rd_doctransaction_id_id BEFORE UPDATE ON doctransactionmsg FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (doctransaction est utilisé par doctransactionmsg)
+Nom de la contrainte : fku_doctransactionmsg_doctransaction_rd_doctransaction_id_id') WHERE NEW.rd_doctransaction_id!=0 AND NEW.rd_doctransaction_id!='' AND (SELECT id FROM doctransaction WHERE id = NEW.rd_doctransaction_id) IS NULL; END;
+CREATE TRIGGER fkdc_doctransaction_doctransactionmsg_id_rd_doctransaction_id BEFORE DELETE ON doctransaction FOR EACH ROW BEGIN DELETE FROM doctransactionmsg WHERE doctransactionmsg.rd_doctransaction_id = OLD.id; END;
+CREATE TRIGGER fki_interest_account_rd_account_id_id BEFORE INSERT ON interest FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (account est utilisé par interest)
+Nom de la contrainte : fki_interest_account_rd_account_id_id') WHERE NEW.rd_account_id!=0 AND NEW.rd_account_id!='' AND (SELECT id FROM account WHERE id = NEW.rd_account_id) IS NULL; END;
+CREATE TRIGGER fku_interest_account_rd_account_id_id BEFORE UPDATE ON interest FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (account est utilisé par interest)
+Nom de la contrainte : fku_interest_account_rd_account_id_id') WHERE NEW.rd_account_id!=0 AND NEW.rd_account_id!='' AND (SELECT id FROM account WHERE id = NEW.rd_account_id) IS NULL; END;
+CREATE TRIGGER fkdc_account_interest_id_rd_account_id BEFORE DELETE ON account FOR EACH ROW BEGIN DELETE FROM interest WHERE interest.rd_account_id = OLD.id; END;
+CREATE TRIGGER fki_node_node_rd_node_id_id BEFORE INSERT ON node FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (node est utilisé par node)
+Nom de la contrainte : fki_node_node_rd_node_id_id') WHERE NEW.rd_node_id!=0 AND NEW.rd_node_id!='' AND (SELECT id FROM node WHERE id = NEW.rd_node_id) IS NULL; END;
+CREATE TRIGGER fku_node_node_rd_node_id_id BEFORE UPDATE ON node FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (node est utilisé par node)
+Nom de la contrainte : fku_node_node_rd_node_id_id') WHERE NEW.rd_node_id!=0 AND NEW.rd_node_id!='' AND (SELECT id FROM node WHERE id = NEW.rd_node_id) IS NULL; END;
+CREATE TRIGGER fkdc_node_node_id_rd_node_id BEFORE DELETE ON node FOR EACH ROW BEGIN DELETE FROM node WHERE node.rd_node_id = OLD.id; END;
+CREATE TRIGGER fki_operation_account_rd_account_id_id BEFORE INSERT ON operation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (account est utilisé par operation)
+Nom de la contrainte : fki_operation_account_rd_account_id_id') WHERE NEW.rd_account_id!=0 AND NEW.rd_account_id!='' AND (SELECT id FROM account WHERE id = NEW.rd_account_id) IS NULL; END;
+CREATE TRIGGER fku_operation_account_rd_account_id_id BEFORE UPDATE ON operation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (account est utilisé par operation)
+Nom de la contrainte : fku_operation_account_rd_account_id_id') WHERE NEW.rd_account_id!=0 AND NEW.rd_account_id!='' AND (SELECT id FROM account WHERE id = NEW.rd_account_id) IS NULL; END;
+CREATE TRIGGER fkdc_account_operation_id_rd_account_id BEFORE DELETE ON account FOR EACH ROW BEGIN DELETE FROM operation WHERE operation.rd_account_id = OLD.id; END;
+CREATE TRIGGER fki_operation_payee_r_payee_id_id BEFORE INSERT ON operation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (payee est utilisé par operation)
+Nom de la contrainte : fki_operation_payee_r_payee_id_id') WHERE NEW.r_payee_id!=0 AND NEW.r_payee_id!='' AND (SELECT id FROM payee WHERE id = NEW.r_payee_id) IS NULL; END;
+CREATE TRIGGER fku_operation_payee_r_payee_id_id BEFORE UPDATE ON operation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (payee est utilisé par operation)
+Nom de la contrainte : fku_operation_payee_r_payee_id_id') WHERE NEW.r_payee_id!=0 AND NEW.r_payee_id!='' AND (SELECT id FROM payee WHERE id = NEW.r_payee_id) IS NULL; END;
+CREATE TRIGGER fkd_operation_payee_r_payee_id_id BEFORE DELETE ON payee FOR EACH ROW BEGIN UPDATE operation SET r_payee_id=0 WHERE r_payee_id=OLD.id; END;
+CREATE TRIGGER fki_operation_unit_rc_unit_id_id BEFORE INSERT ON operation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (unit est utilisé par operation)
+Nom de la contrainte : fki_operation_unit_rc_unit_id_id') WHERE NEW.rc_unit_id!=0 AND NEW.rc_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rc_unit_id) IS NULL; END;
+CREATE TRIGGER fku_operation_unit_rc_unit_id_id BEFORE UPDATE ON operation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (unit est utilisé par operation)
+Nom de la contrainte : fku_operation_unit_rc_unit_id_id') WHERE NEW.rc_unit_id!=0 AND NEW.rc_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rc_unit_id) IS NULL; END;
+CREATE TRIGGER fkd_operation_unit_rc_unit_id_id BEFORE DELETE ON unit FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de détruire un objet (unit est utilisé par operation)
+Nom de la contrainte : fkd_operation_unit_rc_unit_id_id') WHERE (SELECT rc_unit_id FROM operation WHERE rc_unit_id = OLD.id) IS NOT NULL; END;
+CREATE TRIGGER fki_operation_recurrentoperation_r_recurrentoperation_id_id BEFORE INSERT ON operation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (recurrentoperation est utilisé par operation)
+Nom de la contrainte : fki_operation_recurrentoperation_r_recurrentoperation_id_id') WHERE NEW.r_recurrentoperation_id!=0 AND NEW.r_recurrentoperation_id!='' AND (SELECT id FROM recurrentoperation WHERE id = NEW.r_recurrentoperation_id) IS NULL; END;
+CREATE TRIGGER fku_operation_recurrentoperation_r_recurrentoperation_id_id BEFORE UPDATE ON operation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (recurrentoperation est utilisé par operation)
+Nom de la contrainte : fku_operation_recurrentoperation_r_recurrentoperation_id_id') WHERE NEW.r_recurrentoperation_id!=0 AND NEW.r_recurrentoperation_id!='' AND (SELECT id FROM recurrentoperation WHERE id = NEW.r_recurrentoperation_id) IS NULL; END;
+CREATE TRIGGER fkd_operation_recurrentoperation_r_recurrentoperation_id_id BEFORE DELETE ON recurrentoperation FOR EACH ROW BEGIN UPDATE operation SET r_recurrentoperation_id=0 WHERE r_recurrentoperation_id=OLD.id; END;
+CREATE TRIGGER fki_operationbalance_operation_r_operation_id_id BEFORE INSERT ON operationbalance FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (operation est utilisé par operationbalance)
+Nom de la contrainte : fki_operationbalance_operation_r_operation_id_id') WHERE NEW.r_operation_id!=0 AND NEW.r_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.r_operation_id) IS NULL; END;
+CREATE TRIGGER fku_operationbalance_operation_r_operation_id_id BEFORE UPDATE ON operationbalance FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (operation est utilisé par operationbalance)
+Nom de la contrainte : fku_operationbalance_operation_r_operation_id_id') WHERE NEW.r_operation_id!=0 AND NEW.r_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.r_operation_id) IS NULL; END;
+CREATE TRIGGER fkd_operationbalance_operation_r_operation_id_id BEFORE DELETE ON operation FOR EACH ROW BEGIN UPDATE operationbalance SET r_operation_id=0 WHERE r_operation_id=OLD.id; END;
+CREATE TRIGGER fki_recurrentoperation_operation_rd_operation_id_id BEFORE INSERT ON recurrentoperation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (operation est utilisé par recurrentoperation)
+Nom de la contrainte : fki_recurrentoperation_operation_rd_operation_id_id') WHERE NEW.rd_operation_id!=0 AND NEW.rd_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.rd_operation_id) IS NULL; END;
+CREATE TRIGGER fku_recurrentoperation_operation_rd_operation_id_id BEFORE UPDATE ON recurrentoperation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (operation est utilisé par recurrentoperation)
+Nom de la contrainte : fku_recurrentoperation_operation_rd_operation_id_id') WHERE NEW.rd_operation_id!=0 AND NEW.rd_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.rd_operation_id) IS NULL; END;
+CREATE TRIGGER fkdc_operation_recurrentoperation_id_rd_operation_id BEFORE DELETE ON operation FOR EACH ROW BEGIN DELETE FROM recurrentoperation WHERE recurrentoperation.rd_operation_id = OLD.id; END;
+CREATE TRIGGER fki_suboperation_operation_rd_operation_id_id BEFORE INSERT ON suboperation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (operation est utilisé par suboperation)
+Nom de la contrainte : fki_suboperation_operation_rd_operation_id_id') WHERE NEW.rd_operation_id!=0 AND NEW.rd_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.rd_operation_id) IS NULL; END;
+CREATE TRIGGER fku_suboperation_operation_rd_operation_id_id BEFORE UPDATE ON suboperation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (operation est utilisé par suboperation)
+Nom de la contrainte : fku_suboperation_operation_rd_operation_id_id') WHERE NEW.rd_operation_id!=0 AND NEW.rd_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.rd_operation_id) IS NULL; END;
+CREATE TRIGGER fkdc_operation_suboperation_id_rd_operation_id BEFORE DELETE ON operation FOR EACH ROW BEGIN DELETE FROM suboperation WHERE suboperation.rd_operation_id = OLD.id; END;
+CREATE TRIGGER fki_suboperation_category_r_category_id_id BEFORE INSERT ON suboperation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par suboperation)
+Nom de la contrainte : fki_suboperation_category_r_category_id_id') WHERE NEW.r_category_id!=0 AND NEW.r_category_id!='' AND (SELECT id FROM category WHERE id = NEW.r_category_id) IS NULL; END;
+CREATE TRIGGER fku_suboperation_category_r_category_id_id BEFORE UPDATE ON suboperation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par suboperation)
+Nom de la contrainte : fku_suboperation_category_r_category_id_id') WHERE NEW.r_category_id!=0 AND NEW.r_category_id!='' AND (SELECT id FROM category WHERE id = NEW.r_category_id) IS NULL; END;
+CREATE TRIGGER fkd_suboperation_category_r_category_id_id BEFORE DELETE ON category FOR EACH ROW BEGIN UPDATE suboperation SET r_category_id=0 WHERE r_category_id=OLD.id; END;
+CREATE TRIGGER fki_suboperation_refund_r_refund_id_id BEFORE INSERT ON suboperation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (refund est utilisé par suboperation)
+Nom de la contrainte : fki_suboperation_refund_r_refund_id_id') WHERE NEW.r_refund_id!=0 AND NEW.r_refund_id!='' AND (SELECT id FROM refund WHERE id = NEW.r_refund_id) IS NULL; END;
+CREATE TRIGGER fku_suboperation_refund_r_refund_id_id BEFORE UPDATE ON suboperation FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (refund est utilisé par suboperation)
+Nom de la contrainte : fku_suboperation_refund_r_refund_id_id') WHERE NEW.r_refund_id!=0 AND NEW.r_refund_id!='' AND (SELECT id FROM refund WHERE id = NEW.r_refund_id) IS NULL; END;
+CREATE TRIGGER fkd_suboperation_refund_r_refund_id_id BEFORE DELETE ON refund FOR EACH ROW BEGIN UPDATE suboperation SET r_refund_id=0 WHERE r_refund_id=OLD.id; END;
+CREATE TRIGGER fki_unit_unit_rd_unit_id_id BEFORE INSERT ON unit FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (unit est utilisé par unit)
+Nom de la contrainte : fki_unit_unit_rd_unit_id_id') WHERE NEW.rd_unit_id!=0 AND NEW.rd_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rd_unit_id) IS NULL; END;
+CREATE TRIGGER fku_unit_unit_rd_unit_id_id BEFORE UPDATE ON unit FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (unit est utilisé par unit)
+Nom de la contrainte : fku_unit_unit_rd_unit_id_id') WHERE NEW.rd_unit_id!=0 AND NEW.rd_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rd_unit_id) IS NULL; END;
+CREATE TRIGGER fkdc_unit_unit_id_rd_unit_id BEFORE DELETE ON unit FOR EACH ROW BEGIN DELETE FROM unit WHERE unit.rd_unit_id = OLD.id; END;
+CREATE TRIGGER fki_unitvalue_unit_rd_unit_id_id BEFORE INSERT ON unitvalue FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (unit est utilisé par unitvalue)
+Nom de la contrainte : fki_unitvalue_unit_rd_unit_id_id') WHERE NEW.rd_unit_id!=0 AND NEW.rd_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rd_unit_id) IS NULL; END;
+CREATE TRIGGER fku_unitvalue_unit_rd_unit_id_id BEFORE UPDATE ON unitvalue FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de modifier un objet (unit est utilisé par unitvalue)
+Nom de la contrainte : fku_unitvalue_unit_rd_unit_id_id') WHERE NEW.rd_unit_id!=0 AND NEW.rd_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rd_unit_id) IS NULL; END;
+CREATE TRIGGER fkdc_unit_unitvalue_id_rd_unit_id BEFORE DELETE ON unit FOR EACH ROW BEGIN DELETE FROM unitvalue WHERE unitvalue.rd_unit_id = OLD.id; END;
+CREATE TRIGGER fkd_vm_budget_tmp_category_rc_category_id_id BEFORE DELETE ON category FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'Impossible de détruire un objet (category est utilisé par vm_budget_tmp)
+Nom de la contrainte : fkd_vm_budget_tmp_category_rc_category_id_id') WHERE (SELECT rc_category_id FROM vm_budget_tmp WHERE rc_category_id = OLD.id) IS NOT NULL; END;
+CREATE TRIGGER fkdc_category_vm_category_display_tmp_id_rd_category_id BEFORE DELETE ON category FOR EACH ROW BEGIN DELETE FROM vm_category_display_tmp WHERE vm_category_display_tmp.rd_category_id = OLD.id; END;
+CREATE VIEW v_unit_displayname AS SELECT *, t_name||' ('||t_symbol||')' AS t_displayname FROM unit;
+CREATE VIEW v_unit_tmp1 AS SELECT *,(SELECT count(*) FROM unitvalue s WHERE s.rd_unit_id=unit.id) AS i_NBVALUES, (CASE WHEN unit.rd_unit_id=0 THEN '' ELSE (SELECT (CASE WHEN s.t_symbol!='' THEN s.t_symbol ELSE s.t_name END) FROM unit s WHERE s.id=unit.rd_unit_id) END) AS t_UNIT,(CASE unit.t_type WHEN '1' THEN 'Monnaie principale' WHEN '2' THEN 'Monnaie secondaire' WHEN 'C' THEN 'Monnaie' WHEN 'S' THEN 'Action' WHEN 'I' THEN 'Indice' ELSE 'Objet' END) AS t_TYPENLS, (SELECT MIN(s.d_date) FROM unitvalue s WHERE s.rd_unit_id=unit.id) AS d_MINDATE, (SELECT MAX(s.d_date) FROM unitvalue s WHERE s.rd_unit_id=unit.id) AS d_MAXDATE from unit;
+CREATE VIEW v_unit_tmp2 AS SELECT *,CASE WHEN v_unit_tmp1.t_type='1' THEN 1 ELSE IFNULL((SELECT s.f_quantity FROM unitvalue s WHERE s.rd_unit_id=v_unit_tmp1.id AND s.d_date=v_unit_tmp1.d_MAXDATE),1) END AS f_LASTVALUE from v_unit_tmp1;
+CREATE VIEW v_unit AS SELECT *,v_unit_tmp2.f_LASTVALUE*IFNULL((SELECT s2.f_LASTVALUE FROM v_unit_tmp2 s2 WHERE s2.id=v_unit_tmp2.rd_unit_id) , 1) AS f_CURRENTAMOUNT from v_unit_tmp2;
+CREATE VIEW v_unitvalue_displayname AS SELECT *, (SELECT t_displayname FROM v_unit_displayname WHERE unitvalue.rd_unit_id=v_unit_displayname.id)||' '||STRFTIME('%d/%m/%Y',d_date) AS t_displayname FROM unitvalue;
+CREATE VIEW v_unitvalue AS SELECT * FROM unitvalue;
+CREATE VIEW v_suboperation AS SELECT * FROM suboperation;
+CREATE VIEW v_operation_numbers AS SELECT DISTINCT i_number, rd_account_id FROM operation;
+CREATE VIEW v_operation_next_numbers AS SELECT T1.i_number+1 AS i_number FROM v_operation_numbers AS T1 LEFT OUTER JOIN v_operation_numbers T2 ON T2.rd_account_id=T1.rd_account_id AND T2.i_number=T1.i_number+1 WHERE T1.i_number!=0 AND (T2.i_number IS NULL) ORDER BY T1.i_number;
+CREATE VIEW v_operation_tmp1 AS SELECT *,(SELECT t_name FROM payee s WHERE s.id=operation.r_payee_id) AS t_PAYEE,(SELECT TOTAL(s.f_value) FROM suboperation s WHERE s.rd_operation_id=operation.ID) AS f_QUANTITY,(SELECT count(*) FROM suboperation s WHERE s.rd_operation_id=operation.ID) AS i_NBSUBCATEGORY FROM operation;
+CREATE VIEW v_operation AS SELECT *,(SELECT s.id FROM suboperation s WHERE s.rd_operation_id=v_operation_tmp1.id AND ABS(s.f_value)=(SELECT MAX(ABS(s2.f_value)) FROM suboperation s2 WHERE s2.rd_operation_id=v_operation_tmp1.id)) AS i_MOSTIMPSUBOP,((SELECT s.f_CURRENTAMOUNT FROM v_unit s WHERE s.id=v_operation_tmp1.rc_unit_id)*v_operation_tmp1.f_QUANTITY) AS f_CURRENTAMOUNT, (CASE WHEN v_operation_tmp1.i_group_id<>0 AND EXISTS (SELECT 1 FROM account a WHERE v_operation_tmp1.rd_account_id=a.id AND a.t_type<>'L') AND EXISTS (SELECT 1 FROM v_operation_tmp1 op2, account a WHERE op2.i_group_id=v_operation_tmp1.i_group_id AND op2.rd_account_id=a.id AND a.t_type<>'L' AND op2.rc_unit_id=v_operation_tmp1.rc_unit_id AND op2.f_QUANTITY=-v_operation_tmp1.f_QUANTITY) THEN 'Y' ELSE 'N' END) AS t_TRANSFER FROM v_operation_tmp1;
+CREATE VIEW v_operation_displayname AS SELECT *, STRFTIME('%d/%m/%Y',d_date)||' '||IFNULL(t_PAYEE,'')||' '||v_operation.f_CURRENTAMOUNT||' '||(SELECT (CASE WHEN s.t_symbol!='' THEN s.t_symbol ELSE s.t_name END) FROM unit s WHERE s.id=v_operation.rc_unit_id) AS t_displayname FROM v_operation;
+CREATE VIEW v_operation_delete AS SELECT *, (CASE WHEN t_status='Y' THEN 'Vous n''êtes pas autorisé à détruire cette opération car en état « rapproché »' END) t_delete_message FROM operation;
+CREATE VIEW v_account AS SELECT *,(SELECT MAX(s.d_date) FROM interest s WHERE s.rd_account_id=account.id) AS d_MAXDATE, (SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_operation s WHERE s.rd_account_id=account.id AND s.t_template='N') AS f_CURRENTAMOUNT FROM account;
+CREATE VIEW v_account_delete AS SELECT *, (CASE WHEN EXISTS(SELECT 1 FROM operation WHERE rd_account_id=account.id AND d_date<>'0000-00-00' AND t_template='N' AND t_status='Y') THEN 'Vous n''êtes pas autorisé à détruire ce compte car il contient des opérations rapprochées' END) t_delete_message FROM account;
+CREATE VIEW v_bank_displayname AS SELECT *, t_name AS t_displayname FROM bank;
+CREATE VIEW v_account_displayname AS SELECT *, (SELECT t_displayname FROM v_bank_displayname WHERE account.rd_bank_id=v_bank_displayname.id)||'-'||t_name AS t_displayname FROM account;
+CREATE VIEW v_bank AS SELECT *,(SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_account s WHERE s.rd_bank_id=bank.id) AS f_CURRENTAMOUNT FROM bank;
+CREATE VIEW v_category_displayname AS SELECT *, t_fullname AS t_displayname FROM category;
+CREATE VIEW v_category AS SELECT * FROM category;
+CREATE VIEW v_recurrentoperation AS SELECT *,i_period_increment||' '||(CASE t_period_unit WHEN 'Y' THEN 'année(s)' WHEN 'M' THEN 'mois' WHEN 'W' THEN 'semaine(s)' ELSE 'jour(s)' END) AS t_PERIODNLS FROM recurrentoperation;
+CREATE VIEW v_recurrentoperation_displayname AS SELECT *, STRFTIME('%d/%m/%Y',d_date)||' '||SUBSTR((SELECT t_displayname FROM v_operation_displayname WHERE v_operation_displayname.id=v_recurrentoperation.rd_operation_id), 11) AS t_displayname FROM v_recurrentoperation;
+CREATE VIEW v_unitvalue_display AS SELECT *,IFNULL((SELECT (CASE WHEN s.t_symbol!='' THEN s.t_symbol ELSE s.t_name END) FROM unit s WHERE s.id=(SELECT s2.rd_unit_id FROM unit s2 WHERE s2.id=unitvalue.rd_unit_id)),'') AS t_UNIT,STRFTIME('%Y-%m',unitvalue.d_date) AS d_DATEMONTH,STRFTIME('%Y',unitvalue.d_date) AS d_DATEYEAR FROM unitvalue;
+CREATE VIEW v_suboperation_display AS SELECT *,IFNULL((SELECT s.t_fullname FROM category s WHERE s.id=v_suboperation.r_category_id),'') AS t_CATEGORY, IFNULL((SELECT s.t_name FROM refund s WHERE s.id=v_suboperation.r_refund_id),'') AS t_REFUND, (CASE WHEN v_suboperation.f_value>=0 THEN v_suboperation.f_value ELSE 0 END) AS f_VALUE_INCOME, (CASE WHEN v_suboperation.f_value<=0 THEN v_suboperation.f_value ELSE 0 END) AS f_VALUE_EXPENSE FROM v_suboperation;
+CREATE VIEW v_suboperation_displayname AS SELECT *, t_CATEGORY||' : '||f_value AS t_displayname FROM v_suboperation_display;
+CREATE VIEW v_operation_display_all AS SELECT *,(SELECT s.t_name FROM account s WHERE s.id=v_operation.rd_account_id) AS t_ACCOUNT,(SELECT (CASE WHEN s.t_symbol!='' THEN s.t_symbol ELSE s.t_name END) FROM unit s WHERE s.id=v_operation.rc_unit_id) AS t_UNIT,(SELECT s.t_CATEGORY FROM v_suboperation_display s WHERE s.id=v_operation.i_MOSTIMPSUBOP) AS t_CATEGORY,(SELECT s.t_REFUND FROM v_suboperation_display s WHERE s.id=v_operation.i_MOSTIMPSUBOP) AS t_REFUND,(CASE WHEN v_operation.f_QUANTITY<0 THEN '-' WHEN v_operation.f_QUANTITY=0 THEN '' ELSE '+' END) AS t_TYPEEXPENSE, (CASE WHEN v_operation.f_QUANTITY<=0 THEN 'Dépense' ELSE 'Revenu' END) AS t_TYPEEXPENSENLS, STRFTIME('%Y-W%W',v_operation.d_date) AS d_DATEWEEK,STRFTIME('%Y-%m',v_operation.d_date) AS d_DATEMONTH,STRFTIME('%Y',v_operation.d_date)||'-Q'||(CASE WHEN STRFTIME('%m',v_operation.d_date)<='03' THEN '1' WHEN STRFTIME('%m',v_operation.d_date)<='06' THEN '2' WHEN STRFTIME('%m',v_operation.d_date)<='09' THEN '3' ELSE '4' END) AS d_DATEQUARTER, STRFTIME('%Y',v_operation.d_date)||'-S'||(CASE WHEN STRFTIME('%m',v_operation.d_date)<='06' THEN '1' ELSE '2' END) AS d_DATESEMESTER, STRFTIME('%Y',v_operation.d_date) AS d_DATEYEAR, (SELECT count(*) FROM v_recurrentoperation s WHERE s.rd_operation_id=v_operation.id) AS i_NBRECURRENT, (CASE WHEN v_operation.f_QUANTITY>=0 THEN v_operation.f_QUANTITY ELSE 0 END) AS f_QUANTITY_INCOME, (CASE WHEN v_operation.f_QUANTITY<=0 THEN v_operation.f_QUANTITY ELSE 0 END) AS f_QUANTITY_EXPENSE, (SELECT o2.f_balance FROM operationbalance o2 WHERE o2.r_operation_id=v_operation.id ) AS f_BALANCE, (CASE WHEN v_operation.f_QUANTITY>=0 THEN v_operation.f_CURRENTAMOUNT ELSE 0 END) AS f_CURRENTAMOUNT_INCOME, (CASE WHEN v_operation.f_QUANTITY<=0 THEN v_operation.f_CURRENTAMOUNT ELSE 0 END) AS f_CURRENTAMOUNT_EXPENSE FROM v_operation;
+CREATE VIEW v_operation_template_display AS SELECT * FROM v_operation_display_all WHERE t_template='Y';
+CREATE VIEW v_operation_display AS SELECT * FROM v_operation_display_all WHERE d_date!='0000-00-00' AND t_template='N';
+CREATE VIEW v_unit_display AS SELECT *,(SELECT TOTAL(o.f_QUANTITY) FROM v_operation_display o WHERE o.rc_unit_id=v_unit.id) AS f_QUANTITYOWNED FROM v_unit;
+CREATE VIEW v_account_display AS SELECT (CASE t_type WHEN 'C' THEN 'Courant' WHEN 'D' THEN 'Carte de crédit' WHEN 'A' THEN 'Actif' WHEN 'I' THEN 'Investissement' WHEN 'W' THEN 'Portefeuille' WHEN 'L' THEN 'Prêt' WHEN 'O' THEN 'Autre' END) AS t_TYPENLS,bank.t_name AS t_BANK,bank.t_bank_number AS t_BANK_NUMBER,bank.t_icon AS t_ICON,v_account.*,(v_account.f_CURRENTAMOUNT/(SELECT u.f_CURRENTAMOUNT FROM v_unit u, operation s WHERE u.id=s.rc_unit_id AND s.rd_account_id=v_account.id AND s.d_date='0000-00-00')) AS f_QUANTITY, (SELECT (CASE WHEN u.t_symbol!='' THEN u.t_symbol ELSE u.t_name END) FROM unit u, operation s WHERE u.id=s.rc_unit_id AND s.rd_account_id=v_account.id AND s.d_date='0000-00-00') AS t_UNIT, (SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_operation s WHERE s.rd_account_id=v_account.id AND s.t_status!='N' AND s.t_template='N') AS f_CHECKED, (SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_operation s WHERE s.rd_account_id=v_account.id AND s.t_status='N' AND s.t_template='N') AS f_COMING_SOON, (SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_operation s WHERE s.rd_account_id=v_account.id AND s.d_date<=date('now') AND s.t_template='N') AS f_TODAYAMOUNT, (SELECT count(*) FROM v_operation_display s WHERE s.rd_account_id=v_account.id) AS i_NBOPERATIONS, IFNULL((SELECT s.f_rate FROM interest s WHERE s.rd_account_id=v_account.id AND s.d_date=v_account.d_MAXDATE),0) AS f_RATE FROM v_account, bank WHERE bank.id=v_account.rd_bank_id;
+CREATE VIEW v_operation_consolidated AS SELECT (SELECT s.t_TYPENLS FROM v_account_display s WHERE s.id=op.rd_account_id) AS t_ACCOUNTTYPE,(SELECT u.t_TYPENLS FROM v_unit u WHERE u.id=op.rc_unit_id) AS t_UNITTYPE,sop.id AS i_SUBOPID, sop.r_refund_id AS r_refund_id, (CASE WHEN sop.t_comment='' THEN op.t_comment ELSE sop.t_comment END) AS t_REALCOMMENT, sop.t_CATEGORY AS t_REALCATEGORY, sop.t_REFUND AS t_REALREFUND, sop.r_category_id AS i_IDCATEGORY, (CASE WHEN sop.f_value<0 THEN '-' WHEN sop.f_value=0 THEN '' ELSE '+' END) AS t_TYPEEXPENSE, (CASE WHEN sop.f_value<0 THEN 'Dépense' WHEN sop.f_value=0 THEN '' ELSE 'Revenu' END) AS t_TYPEEXPENSENLS, sop.f_value AS f_REALQUANTITY, sop.f_VALUE_INCOME AS f_REALQUANTITY_INCOME, sop.f_VALUE_EXPENSE AS f_REALQUANTITY_EXPENSE, ((SELECT u.f_CURRENTAMOUNT FROM v_unit u WHERE u.id=op.rc_unit_id)*sop.f_value) AS f_REALCURRENTAMOUNT, ((SELECT u.f_CURRENTAMOUNT FROM v_unit u WHERE u.id=op.rc_unit_id)*sop.f_VALUE_INCOME) AS f_REALCURRENTAMOUNT_INCOME, ((SELECT u.f_CURRENTAMOUNT FROM v_unit u WHERE u.id=op.rc_unit_id)*sop.f_VALUE_EXPENSE) AS f_REALCURRENTAMOUNT_EXPENSE, op.* FROM v_operation_display_all AS op, v_suboperation_display AS sop WHERE op.t_template='N' AND sop.rd_operation_id=op.ID;
+CREATE VIEW v_operation_prop AS SELECT p.id AS i_PROPPID, p.t_name AS i_PROPPNAME, p.t_value AS i_PROPVALUE, op.* FROM v_operation_consolidated AS op LEFT OUTER JOIN parameters AS p ON p.t_uuid_parent=op.id||'-operation';
+CREATE VIEW v_refund_delete AS SELECT *, (CASE WHEN EXISTS(SELECT 1 FROM v_operation_consolidated WHERE r_refund_id=refund.id AND t_status='Y') THEN 'Vous n''êtes pas autorisé à détruire ce suiveur car utilisé par des opérations rapprochées' END) t_delete_message FROM refund;
+CREATE VIEW v_refund AS SELECT *, (SELECT TOTAL(o.f_REALCURRENTAMOUNT) FROM v_operation_consolidated o WHERE o.r_refund_id=refund.id) AS f_CURRENTAMOUNT FROM refund;
+CREATE VIEW v_refund_display AS SELECT *,(SELECT MIN(o.d_date) FROM v_operation_consolidated o WHERE o.r_refund_id=v_refund.id) AS d_FIRSTDATE, (SELECT MAX(o.d_date) FROM v_operation_consolidated o WHERE o.r_refund_id=v_refund.id) AS d_LASTDATE FROM v_refund;
+CREATE VIEW v_refund_displayname AS SELECT *, t_name AS t_displayname FROM refund;
+CREATE VIEW v_payee_delete AS SELECT *, (CASE WHEN EXISTS(SELECT 1 FROM operation WHERE r_payee_id=payee.id AND t_status='Y') THEN 'Vous n''êtes pas autorisé à détruire ce tiers car utilisé par des opérations rapprochées' END) t_delete_message FROM payee;
+CREATE VIEW v_payee AS SELECT *, (SELECT TOTAL(o.f_CURRENTAMOUNT) FROM v_operation o WHERE o.r_payee_id=payee.id AND o.t_template='N') AS f_CURRENTAMOUNT FROM payee;
+CREATE VIEW v_payee_display AS SELECT * FROM v_payee;
+CREATE VIEW v_payee_displayname AS SELECT *, t_name AS t_displayname FROM payee;
+CREATE VIEW v_category_delete AS SELECT *, (CASE WHEN EXISTS(SELECT 1 FROM v_operation_consolidated WHERE (t_REALCATEGORY=category.t_fullname OR t_REALCATEGORY like category.t_fullname||'%') AND t_status='Y') THEN 'Vous n''êtes pas autorisé à détruire cette catégorie car utilisée par des opérations rapprochées' END) t_delete_message FROM category;
+CREATE VIEW v_category_display_tmp AS SELECT *,(SELECT count(distinct(so.rd_operation_id)) FROM operation o, suboperation so WHERE so.rd_operation_id=o.id AND so.r_category_id=v_category.ID AND o.t_template='N') AS i_NBOPERATIONS, (SELECT TOTAL(o.f_REALCURRENTAMOUNT) FROM v_operation_consolidated o WHERE o.i_IDCATEGORY=v_category.ID) AS f_REALCURRENTAMOUNT FROM v_category;
+CREATE VIEW v_category_display AS SELECT *,f_REALCURRENTAMOUNT+(SELECT TOTAL(c.f_REALCURRENTAMOUNT) FROM vm_category_display_tmp c WHERE c.t_fullname LIKE vm_category_display_tmp.t_fullname||' > %') AS f_SUMCURRENTAMOUNT, i_NBOPERATIONS+(SELECT CAST(TOTAL(c.i_NBOPERATIONS) AS INTEGER) FROM vm_category_display_tmp c WHERE c.t_fullname like vm_category_display_tmp.t_fullname||' > %') AS i_SUMNBOPERATIONS, (CASE WHEN t_bookmarked='Y' THEN 'Y' WHEN EXISTS(SELECT 1 FROM category c WHERE c.t_bookmarked='Y' AND c.t_fullname like vm_category_display_tmp.t_fullname||' > %') THEN 'C' ELSE 'N' END) AS t_HASBOOKMARKEDCHILD, (CASE WHEN vm_category_display_tmp.f_REALCURRENTAMOUNT<0 THEN '-' WHEN vm_category_display_tmp.f_REALCURRENTAMOUNT=0 THEN '' ELSE '+' END) AS t_TYPEEXPENSE,(CASE WHEN vm_category_display_tmp.f_REALCURRENTAMOUNT<0 THEN 'Dépense' WHEN vm_category_display_tmp.f_REALCURRENTAMOUNT=0 THEN '' ELSE 'Revenu' END) AS t_TYPEEXPENSENLS FROM vm_category_display_tmp;
+CREATE VIEW v_recurrentoperation_display AS SELECT rop.*, op.t_ACCOUNT, op.i_number, op.t_mode, op.i_group_id, op.t_TRANSFER, op.t_PAYEE, op.t_comment, op.t_CATEGORY, op.t_status, op.f_CURRENTAMOUNT FROM v_recurrentoperation rop, v_operation_display_all AS op WHERE rop.rd_operation_id=op.ID;
+CREATE VIEW v_rule AS SELECT *,(SELECT COUNT(1) FROM rule r WHERE r.f_sortorder<=rule.f_sortorder) AS i_ORDER FROM rule;
+CREATE VIEW v_rule_displayname AS SELECT *, t_definition AS t_displayname FROM rule;
+CREATE VIEW v_interest AS SELECT *,(SELECT s.t_name FROM account s WHERE s.id=interest.rd_account_id) AS t_ACCOUNT FROM interest;
+CREATE VIEW v_interest_displayname AS SELECT *, STRFTIME('%d/%m/%Y',d_date)||' '||f_rate||'%' AS t_displayname FROM interest;
+CREATE VIEW v_budgetrule AS SELECT *, IFNULL((SELECT s.t_fullname FROM category s WHERE s.id=budgetrule.rc_category_id),'') AS t_CATEGORYCONDITION, IFNULL((SELECT s.t_fullname FROM category s WHERE s.id=budgetrule.rc_category_id_target),'') AS t_CATEGORY, (CASE WHEN budgetrule.i_condition=-1 THEN 'Négatif' WHEN budgetrule.i_condition=1 THEN 'Positif' WHEN budgetrule.i_condition=0 THEN 'Tous' END) AS t_WHENNLS, f_quantity||(CASE WHEN budgetrule.t_absolute='N' THEN '%' ELSE (SELECT t_symbol FROM unit WHERE t_type='1') END) AS t_WHATNLS,(CASE WHEN budgetrule.t_rule='N' THEN 'Suivant' WHEN budgetrule.t_rule='C' THEN 'Courant' WHEN budgetrule.t_rule='Y' THEN 'Année' END) AS t_RULENLS FROM budgetrule;
+CREATE VIEW v_budgetrule_display AS SELECT * FROM v_budgetrule;
+CREATE VIEW v_budgetrule_displayname AS SELECT *, t_WHENNLS||' '||t_WHATNLS||' '||t_RULENLS||' '||t_CATEGORY AS t_displayname FROM v_budgetrule;
+CREATE VIEW v_budget_tmp AS SELECT *, IFNULL((SELECT s.t_fullname FROM category s WHERE s.id=budget.rc_category_id),'') AS t_CATEGORY, (i_year||(CASE WHEN i_month=0 THEN '' WHEN i_month<10 THEN '-0'||i_month ELSE '-'||i_month END)) AS t_PERIOD, (SELECT TOTAL(o.f_REALCURRENTAMOUNT) FROM v_operation_consolidated o WHERE STRFTIME('%Y', o.d_date)=i_year AND (i_month=0 OR STRFTIME('%m', o.d_date)=i_month) AND o.i_IDCATEGORY IN (SELECT b2.id_category FROM budgetcategory b2 WHERE b2.id=budget.id)) AS f_CURRENTAMOUNT, (SELECT GROUP_CONCAT(v_budgetrule_displayname.t_displayname,',') FROM v_budgetrule_displayname WHERE (v_budgetrule_displayname.t_year_condition='N' OR budget.i_year=v_budgetrule_displayname.i_year) AND (v_budgetrule_displayname.t_month_condition='N' OR budget.i_month=v_budgetrule_displayname.i_month) AND (v_budgetrule_displayname.t_category_condition='N' OR budget.rc_category_id=v_budgetrule_displayname.rc_category_id) ORDER BY v_budgetrule_displayname.t_absolute DESC, v_budgetrule_displayname.id) AS t_RULES FROM budget;
+CREATE VIEW v_budget AS SELECT *, (f_CURRENTAMOUNT-f_budgeted_modified) AS f_DELTABEFORETRANSFER, (f_CURRENTAMOUNT-f_budgeted_modified-f_transferred) AS f_DELTA FROM v_budget_tmp;
+CREATE VIEW v_budget_display AS SELECT *, (f_CURRENTAMOUNT-f_budgeted_modified) AS f_DELTABEFORETRANSFER, (f_CURRENTAMOUNT-f_budgeted_modified-f_transferred) AS f_DELTA FROM vm_budget_tmp;
+CREATE VIEW v_budget_displayname AS SELECT *, t_CATEGORY||' '||t_PERIOD||' '||f_budgeted_modified AS t_displayname FROM v_budget;
+CREATE TRIGGER fkdc_bank_parameters_uuid BEFORE DELETE ON bank FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'bank'; END;
+CREATE TRIGGER fkdc_account_parameters_uuid BEFORE DELETE ON account FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'account'; END;
+CREATE TRIGGER fkdc_unit_parameters_uuid BEFORE DELETE ON unit FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'unit'; END;
+CREATE TRIGGER fkdc_unitvalue_parameters_uuid BEFORE DELETE ON unitvalue FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'unitvalue'; END;
+CREATE TRIGGER fkdc_category_parameters_uuid BEFORE DELETE ON category FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'category'; END;
+CREATE TRIGGER fkdc_operation_parameters_uuid BEFORE DELETE ON operation FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'operation'; END;
+CREATE TRIGGER fkdc_interest_parameters_uuid BEFORE DELETE ON interest FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'interest'; END;
+CREATE TRIGGER fkdc_suboperation_parameters_uuid BEFORE DELETE ON suboperation FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'suboperation'; END;
+CREATE TRIGGER fkdc_refund_parameters_uuid BEFORE DELETE ON refund FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'refund'; END;
+CREATE TRIGGER fkdc_payee_parameters_uuid BEFORE DELETE ON payee FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'payee'; END;
+CREATE TRIGGER fkdc_recurrentoperation_parameters_uuid BEFORE DELETE ON recurrentoperation FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'recurrentoperation'; END;
+CREATE TRIGGER fkdc_rule_parameters_uuid BEFORE DELETE ON rule FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'rule'; END;
+CREATE TRIGGER fkdc_budget_parameters_uuid BEFORE DELETE ON budget FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'budget'; END;
+CREATE TRIGGER fkdc_budgetrule_parameters_uuid BEFORE DELETE ON budgetrule FOR EACH ROW BEGIN DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'budgetrule'; END;
+CREATE TRIGGER cpt_category_fullname1 AFTER INSERT ON category BEGIN UPDATE category SET t_fullname=CASE WHEN rd_category_id IS NULL OR rd_category_id='' OR rd_category_id=0 THEN new.t_name ELSE (SELECT c.t_fullname FROM category c WHERE c.id=new.rd_category_id)||' > '||new.t_name END WHERE id=new.id;END;
+CREATE TRIGGER cpt_category_fullname2 AFTER UPDATE OF t_name, rd_category_id ON category BEGIN UPDATE category SET t_fullname=CASE WHEN rd_category_id IS NULL OR rd_category_id='' OR rd_category_id=0 THEN new.t_name ELSE (SELECT c.t_fullname FROM category c WHERE c.id=new.rd_category_id)||' > '||new.t_name END WHERE id=new.id;UPDATE category SET t_name=t_name WHERE rd_category_id=new.id;END;
+CREATE TRIGGER fkdc_category_delete BEFORE DELETE ON category FOR EACH ROW BEGIN UPDATE suboperation SET r_category_id=OLD.rd_category_id WHERE r_category_id=OLD.id; END;
+explain
+ SELECT TOTAL(f_CURRENTAMOUNT), d_DATEMONTH
+ from v_operation_display
+ WHERE d_DATEMONTH IN ('2012-05', '2012-04')
+ group by d_DATEMONTH, t_TYPEEXPENSE;
+ }
+} {/.* Goto .*/}
+
+# The next test requires FTS4
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Taken from the gnome-shell project
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+do_test fuzz-oss1-gnomeshell {
+ db eval {
+CREATE TABLE Resource (ID INTEGER NOT NULL PRIMARY KEY, Uri TEXT NOT
+NULL, UNIQUE (Uri));
+CREATE VIRTUAL TABLE fts USING fts4;
+CREATE TABLE "mfo:Action" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mfo:Enclosure" (ID INTEGER NOT NULL PRIMARY KEY,
+"mfo:remoteLink" INTEGER, "mfo:remoteLink:graph" INTEGER,
+"mfo:groupDefault" INTEGER, "mfo:groupDefault:graph" INTEGER,
+"mfo:localLink" INTEGER, "mfo:localLink:graph" INTEGER, "mfo:optional"
+INTEGER, "mfo:optional:graph" INTEGER);
+CREATE TABLE "mfo:FeedChannel" (ID INTEGER NOT NULL PRIMARY KEY,
+"mfo:updatedTime" INTEGER, "mfo:updatedTime:graph" INTEGER,
+"mfo:updatedTime:localDate" INTEGER, "mfo:updatedTime:localTime"
+INTEGER, "mfo:unreadCount" INTEGER, "mfo:unreadCount:graph" INTEGER,
+"mfo:totalCount" INTEGER, "mfo:totalCount:graph" INTEGER, "mfo:action"
+INTEGER, "mfo:action:graph" INTEGER, "mfo:type" INTEGER,
+"mfo:type:graph" INTEGER);
+CREATE TABLE "mfo:FeedElement" (ID INTEGER NOT NULL PRIMARY KEY,
+"mfo:image" TEXT COLLATE NOCASE, "mfo:image:graph" INTEGER,
+"mfo:feedSettings" INTEGER, "mfo:feedSettings:graph" INTEGER);
+CREATE TABLE "mfo:FeedMessage" (ID INTEGER NOT NULL PRIMARY KEY,
+"mfo:downloadedTime" INTEGER, "mfo:downloadedTime:graph" INTEGER,
+"mfo:downloadedTime:localDate" INTEGER, "mfo:downloadedTime:localTime"
+INTEGER);
+CREATE TABLE "mfo:FeedMessage_mfo:enclosureList" (ID INTEGER NOT NULL,
+"mfo:enclosureList" INTEGER NOT NULL, "mfo:enclosureList:graph"
+INTEGER);
+CREATE TABLE "mfo:FeedSettings" (ID INTEGER NOT NULL PRIMARY KEY,
+"mfo:updateInterval" INTEGER, "mfo:updateInterval:graph" INTEGER,
+"mfo:expiryInterval" INTEGER, "mfo:expiryInterval:graph" INTEGER,
+"mfo:downloadPath" TEXT COLLATE NOCASE, "mfo:downloadPath:graph"
+INTEGER, "mfo:downloadFlag" INTEGER, "mfo:downloadFlag:graph" INTEGER,
+"mfo:maxSize" INTEGER, "mfo:maxSize:graph" INTEGER);
+CREATE TABLE "mfo:FeedType" (ID INTEGER NOT NULL PRIMARY KEY,
+"mfo:name" TEXT COLLATE NOCASE, "mfo:name:graph" INTEGER);
+CREATE TABLE "mlo:GeoBoundingBox" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mlo:GeoBoundingBox_mlo:bbNorthWest" (ID INTEGER NOT
+NULL, "mlo:bbNorthWest" INTEGER NOT NULL, "mlo:bbNorthWest:graph"
+INTEGER);
+CREATE TABLE "mlo:GeoBoundingBox_mlo:bbSouthEast" (ID INTEGER NOT
+NULL, "mlo:bbSouthEast" INTEGER NOT NULL, "mlo:bbSouthEast:graph"
+INTEGER);
+CREATE TABLE "mlo:GeoLocation" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mlo:GeoLocation_mlo:asBoundingBox" (ID INTEGER NOT NULL,
+"mlo:asBoundingBox" INTEGER NOT NULL, "mlo:asBoundingBox:graph"
+INTEGER);
+CREATE TABLE "mlo:GeoLocation_mlo:asGeoPoint" (ID INTEGER NOT NULL,
+"mlo:asGeoPoint" INTEGER NOT NULL, "mlo:asGeoPoint:graph" INTEGER);
+CREATE TABLE "mlo:GeoLocation_mlo:asPostalAddress" (ID INTEGER NOT
+NULL, "mlo:asPostalAddress" INTEGER NOT NULL,
+"mlo:asPostalAddress:graph" INTEGER);
+CREATE TABLE "mlo:GeoPoint" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mlo:GeoPoint_mlo:address" (ID INTEGER NOT NULL,
+"mlo:address" TEXT NOT NULL, "mlo:address:graph" INTEGER);
+CREATE TABLE "mlo:GeoPoint_mlo:altitude" (ID INTEGER NOT NULL,
+"mlo:altitude" REAL NOT NULL, "mlo:altitude:graph" INTEGER);
+CREATE TABLE "mlo:GeoPoint_mlo:city" (ID INTEGER NOT NULL, "mlo:city"
+TEXT NOT NULL, "mlo:city:graph" INTEGER);
+CREATE TABLE "mlo:GeoPoint_mlo:country" (ID INTEGER NOT NULL,
+"mlo:country" TEXT NOT NULL, "mlo:country:graph" INTEGER);
+CREATE TABLE "mlo:GeoPoint_mlo:latitude" (ID INTEGER NOT NULL,
+"mlo:latitude" REAL NOT NULL, "mlo:latitude:graph" INTEGER);
+CREATE TABLE "mlo:GeoPoint_mlo:longitude" (ID INTEGER NOT NULL,
+"mlo:longitude" REAL NOT NULL, "mlo:longitude:graph" INTEGER);
+CREATE TABLE "mlo:GeoPoint_mlo:state" (ID INTEGER NOT NULL,
+"mlo:state" TEXT NOT NULL, "mlo:state:graph" INTEGER);
+CREATE TABLE "mlo:GeoPoint_mlo:timestamp" (ID INTEGER NOT NULL,
+"mlo:timestamp" INTEGER NOT NULL, "mlo:timestamp:graph" INTEGER,
+"mlo:timestamp:localDate" INTEGER NOT NULL, "mlo:timestamp:localTime"
+INTEGER NOT NULL);
+CREATE TABLE "mlo:GeoSphere" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mlo:GeoSphere_mlo:radius" (ID INTEGER NOT NULL,
+"mlo:radius" REAL NOT NULL, "mlo:radius:graph" INTEGER);
+CREATE TABLE "mlo:Landmark" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mlo:LandmarkCategory" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mlo:LandmarkCategory_mlo:isRemovable" (ID INTEGER NOT
+NULL, "mlo:isRemovable" INTEGER NOT NULL, "mlo:isRemovable:graph"
+INTEGER);
+CREATE TABLE "mlo:Landmark_mlo:belongsToCategory" (ID INTEGER NOT
+NULL, "mlo:belongsToCategory" INTEGER NOT NULL,
+"mlo:belongsToCategory:graph" INTEGER);
+CREATE TABLE "mlo:Landmark_mlo:poiLocation" (ID INTEGER NOT NULL,
+"mlo:poiLocation" INTEGER NOT NULL, "mlo:poiLocation:graph" INTEGER);
+CREATE TABLE "mlo:LocationBoundingBox" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mlo:LocationBoundingBox_mlo:boxEastLimit" (ID INTEGER
+NOT NULL, "mlo:boxEastLimit" INTEGER NOT NULL,
+"mlo:boxEastLimit:graph" INTEGER);
+CREATE TABLE "mlo:LocationBoundingBox_mlo:boxNorthLimit" (ID INTEGER
+NOT NULL, "mlo:boxNorthLimit" INTEGER NOT NULL,
+"mlo:boxNorthLimit:graph" INTEGER);
+CREATE TABLE "mlo:LocationBoundingBox_mlo:boxSouthWestCorner" (ID
+INTEGER NOT NULL, "mlo:boxSouthWestCorner" INTEGER NOT NULL,
+"mlo:boxSouthWestCorner:graph" INTEGER);
+CREATE TABLE "mlo:LocationBoundingBox_mlo:boxVerticalLimit" (ID
+INTEGER NOT NULL, "mlo:boxVerticalLimit" INTEGER NOT NULL,
+"mlo:boxVerticalLimit:graph" INTEGER);
+CREATE TABLE "mlo:PointOfInterest" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mlo:Route" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mlo:Route_mlo:endTime" (ID INTEGER NOT NULL,
+"mlo:endTime" INTEGER NOT NULL, "mlo:endTime:graph" INTEGER,
+"mlo:endTime:localDate" INTEGER NOT NULL, "mlo:endTime:localTime"
+INTEGER NOT NULL);
+CREATE TABLE "mlo:Route_mlo:routeDetails" (ID INTEGER NOT NULL,
+"mlo:routeDetails" TEXT NOT NULL, "mlo:routeDetails:graph" INTEGER);
+CREATE TABLE "mlo:Route_mlo:startTime" (ID INTEGER NOT NULL,
+"mlo:startTime" INTEGER NOT NULL, "mlo:startTime:graph" INTEGER,
+"mlo:startTime:localDate" INTEGER NOT NULL, "mlo:startTime:localTime"
+INTEGER NOT NULL);
+CREATE TABLE "mto:DownloadTransfer" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mto:State" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mto:SyncTransfer" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mto:Transfer" (ID INTEGER NOT NULL PRIMARY KEY,
+"mto:transferState" INTEGER, "mto:transferState:graph" INTEGER,
+"mto:method" INTEGER, "mto:method:graph" INTEGER, "mto:created"
+INTEGER, "mto:created:graph" INTEGER, "mto:created:localDate" INTEGER,
+"mto:created:localTime" INTEGER, "mto:account" TEXT COLLATE NOCASE,
+"mto:account:graph" INTEGER, "mto:starter" INTEGER,
+"mto:starter:graph" INTEGER, "mto:agent" INTEGER, "mto:agent:graph"
+INTEGER);
+CREATE TABLE "mto:TransferElement" (ID INTEGER NOT NULL PRIMARY KEY,
+"mto:source" INTEGER, "mto:source:graph" INTEGER, "mto:destination"
+INTEGER, "mto:destination:graph" INTEGER, "mto:startedTime" INTEGER,
+"mto:startedTime:graph" INTEGER, "mto:startedTime:localDate" INTEGER,
+"mto:startedTime:localTime" INTEGER, "mto:completedTime" INTEGER,
+"mto:completedTime:graph" INTEGER, "mto:completedTime:localDate"
+INTEGER, "mto:completedTime:localTime" INTEGER, "mto:state" INTEGER,
+"mto:state:graph" INTEGER);
+CREATE TABLE "mto:TransferMethod" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mto:Transfer_mto:transferList" (ID INTEGER NOT NULL,
+"mto:transferList" INTEGER NOT NULL, "mto:transferList:graph"
+INTEGER);
+CREATE TABLE "mto:Transfer_mto:transferPrivacyLevel" (ID INTEGER NOT
+NULL, "mto:transferPrivacyLevel" TEXT NOT NULL,
+"mto:transferPrivacyLevel:graph" INTEGER);
+CREATE TABLE "mto:UploadTransfer" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "mto:UploadTransfer_mto:transferCategory" (ID INTEGER NOT
+NULL, "mto:transferCategory" TEXT NOT NULL,
+"mto:transferCategory:graph" INTEGER);
+CREATE TABLE "mtp:ScanType" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nao:Property" (ID INTEGER NOT NULL PRIMARY KEY,
+"nao:propertyName" TEXT COLLATE NOCASE, "nao:propertyName:graph"
+INTEGER, "nao:propertyValue" TEXT COLLATE NOCASE,
+"nao:propertyValue:graph" INTEGER);
+CREATE TABLE "nao:Tag" (ID INTEGER NOT NULL PRIMARY KEY,
+"nao:prefLabel" TEXT COLLATE NOCASE, "nao:prefLabel:graph" INTEGER,
+"nao:description" TEXT COLLATE NOCASE, "nao:description:graph"
+INTEGER);
+CREATE TABLE "nao:Tag_tracker:isDefaultTag" (ID INTEGER NOT NULL,
+"tracker:isDefaultTag" INTEGER NOT NULL, "tracker:isDefaultTag:graph"
+INTEGER);
+CREATE TABLE "nao:Tag_tracker:tagRelatedTo" (ID INTEGER NOT NULL,
+"tracker:tagRelatedTo" INTEGER NOT NULL, "tracker:tagRelatedTo:graph"
+INTEGER);
+CREATE TABLE "ncal:AccessClassification" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:Alarm" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:repeat" INTEGER, "ncal:repeat:graph" INTEGER);
+CREATE TABLE "ncal:AlarmAction" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:Alarm_ncal:action" (ID INTEGER NOT NULL,
+"ncal:action" INTEGER NOT NULL, "ncal:action:graph" INTEGER);
+CREATE TABLE "ncal:Attachment" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:attachmentUri" INTEGER, "ncal:attachmentUri:graph" INTEGER,
+"ncal:fmttype" TEXT COLLATE NOCASE, "ncal:fmttype:graph" INTEGER,
+"ncal:encoding" INTEGER, "ncal:encoding:graph" INTEGER,
+"ncal:attachmentContent" TEXT COLLATE NOCASE,
+"ncal:attachmentContent:graph" INTEGER);
+CREATE TABLE "ncal:AttachmentEncoding" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:Attendee" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:delegatedTo" INTEGER, "ncal:delegatedTo:graph" INTEGER,
+"ncal:delegatedFrom" INTEGER, "ncal:delegatedFrom:graph" INTEGER,
+"ncal:cutype" INTEGER, "ncal:cutype:graph" INTEGER, "ncal:member"
+INTEGER, "ncal:member:graph" INTEGER, "ncal:role" INTEGER,
+"ncal:role:graph" INTEGER, "ncal:rsvp" INTEGER, "ncal:rsvp:graph"
+INTEGER, "ncal:partstat" INTEGER, "ncal:partstat:graph" INTEGER);
+CREATE TABLE "ncal:AttendeeOrOrganizer" (ID INTEGER NOT NULL PRIMARY
+KEY, "ncal:dir" INTEGER, "ncal:dir:graph" INTEGER,
+"ncal:involvedContact" INTEGER, "ncal:involvedContact:graph" INTEGER,
+"ncal:sentBy" INTEGER, "ncal:sentBy:graph" INTEGER);
+CREATE TABLE "ncal:AttendeeRole" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:BydayRulePart" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:BydayRulePart_ncal:bydayModifier" (ID INTEGER NOT
+NULL, "ncal:bydayModifier" INTEGER NOT NULL,
+"ncal:bydayModifier:graph" INTEGER);
+CREATE TABLE "ncal:BydayRulePart_ncal:bydayWeekday" (ID INTEGER NOT
+NULL, "ncal:bydayWeekday" INTEGER NOT NULL, "ncal:bydayWeekday:graph"
+INTEGER);
+CREATE TABLE "ncal:Calendar" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:method" TEXT COLLATE NOCASE, "ncal:method:graph" INTEGER,
+"ncal:calscale" INTEGER, "ncal:calscale:graph" INTEGER, "ncal:prodid"
+TEXT COLLATE NOCASE, "ncal:prodid:graph" INTEGER, "ncal:version" TEXT
+COLLATE NOCASE, "ncal:version:graph" INTEGER);
+CREATE TABLE "ncal:CalendarDataObject" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:CalendarScale" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:CalendarUserType" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:Calendar_ncal:component" (ID INTEGER NOT NULL,
+"ncal:component" INTEGER NOT NULL, "ncal:component:graph" INTEGER);
+CREATE TABLE "ncal:Event" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:eventStatus" INTEGER, "ncal:eventStatus:graph" INTEGER,
+"ncal:transp" INTEGER, "ncal:transp:graph" INTEGER);
+CREATE TABLE "ncal:EventStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:Freebusy" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:FreebusyPeriod" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:fbtype" INTEGER, "ncal:fbtype:graph" INTEGER);
+CREATE TABLE "ncal:FreebusyType" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:Freebusy_ncal:freebusy" (ID INTEGER NOT NULL,
+"ncal:freebusy" INTEGER NOT NULL, "ncal:freebusy:graph" INTEGER);
+CREATE TABLE "ncal:Journal" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:journalStatus" INTEGER, "ncal:journalStatus:graph" INTEGER);
+CREATE TABLE "ncal:JournalStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:NcalDateTime" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:ncalTimezone" INTEGER, "ncal:ncalTimezone:graph" INTEGER,
+"ncal:date" INTEGER, "ncal:date:graph" INTEGER, "ncal:date:localDate"
+INTEGER, "ncal:date:localTime" INTEGER, "ncal:dateTime" INTEGER,
+"ncal:dateTime:graph" INTEGER, "ncal:dateTime:localDate" INTEGER,
+"ncal:dateTime:localTime" INTEGER);
+CREATE TABLE "ncal:NcalPeriod" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:periodBegin" INTEGER, "ncal:periodBegin:graph" INTEGER,
+"ncal:periodBegin:localDate" INTEGER, "ncal:periodBegin:localTime"
+INTEGER, "ncal:periodDuration" INTEGER, "ncal:periodDuration:graph"
+INTEGER, "ncal:periodEnd" INTEGER, "ncal:periodEnd:graph" INTEGER,
+"ncal:periodEnd:localDate" INTEGER, "ncal:periodEnd:localTime"
+INTEGER);
+CREATE TABLE "ncal:NcalTimeEntity" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:Organizer" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:ParticipationStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:RecurrenceFrequency" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:RecurrenceIdentifier" (ID INTEGER NOT NULL PRIMARY
+KEY, "ncal:range" INTEGER, "ncal:range:graph" INTEGER,
+"ncal:recurrenceIdDateTime" INTEGER, "ncal:recurrenceIdDateTime:graph"
+INTEGER);
+CREATE TABLE "ncal:RecurrenceIdentifierRange" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:RecurrenceRule" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:until" INTEGER, "ncal:until:graph" INTEGER,
+"ncal:until:localDate" INTEGER, "ncal:until:localTime" INTEGER,
+"ncal:wkst" INTEGER, "ncal:wkst:graph" INTEGER, "ncal:interval"
+INTEGER, "ncal:interval:graph" INTEGER, "ncal:count" INTEGER,
+"ncal:count:graph" INTEGER, "ncal:freq" INTEGER, "ncal:freq:graph"
+INTEGER);
+CREATE TABLE "ncal:RecurrenceRule_ncal:byday" (ID INTEGER NOT NULL,
+"ncal:byday" INTEGER NOT NULL, "ncal:byday:graph" INTEGER);
+CREATE TABLE "ncal:RecurrenceRule_ncal:byhour" (ID INTEGER NOT NULL,
+"ncal:byhour" INTEGER NOT NULL, "ncal:byhour:graph" INTEGER);
+CREATE TABLE "ncal:RecurrenceRule_ncal:byminute" (ID INTEGER NOT NULL,
+"ncal:byminute" INTEGER NOT NULL, "ncal:byminute:graph" INTEGER);
+CREATE TABLE "ncal:RecurrenceRule_ncal:bymonth" (ID INTEGER NOT NULL,
+"ncal:bymonth" INTEGER NOT NULL, "ncal:bymonth:graph" INTEGER);
+CREATE TABLE "ncal:RecurrenceRule_ncal:bymonthday" (ID INTEGER NOT
+NULL, "ncal:bymonthday" INTEGER NOT NULL, "ncal:bymonthday:graph"
+INTEGER);
+CREATE TABLE "ncal:RecurrenceRule_ncal:bysecond" (ID INTEGER NOT NULL,
+"ncal:bysecond" INTEGER NOT NULL, "ncal:bysecond:graph" INTEGER);
+CREATE TABLE "ncal:RecurrenceRule_ncal:bysetpos" (ID INTEGER NOT NULL,
+"ncal:bysetpos" INTEGER NOT NULL, "ncal:bysetpos:graph" INTEGER);
+CREATE TABLE "ncal:RecurrenceRule_ncal:byweekno" (ID INTEGER NOT NULL,
+"ncal:byweekno" INTEGER NOT NULL, "ncal:byweekno:graph" INTEGER);
+CREATE TABLE "ncal:RecurrenceRule_ncal:byyearday" (ID INTEGER NOT
+NULL, "ncal:byyearday" INTEGER NOT NULL, "ncal:byyearday:graph"
+INTEGER);
+CREATE TABLE "ncal:RequestStatus" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:statusDescription" TEXT COLLATE NOCASE,
+"ncal:statusDescription:graph" INTEGER, "ncal:returnStatus" TEXT
+COLLATE NOCASE, "ncal:returnStatus:graph" INTEGER,
+"ncal:requestStatusData" TEXT COLLATE NOCASE,
+"ncal:requestStatusData:graph" INTEGER);
+CREATE TABLE "ncal:TimeTransparency" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:Timezone" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:tzurl" INTEGER, "ncal:tzurl:graph" INTEGER, "ncal:standard"
+INTEGER, "ncal:standard:graph" INTEGER, "ncal:daylight" INTEGER,
+"ncal:daylight:graph" INTEGER, "ncal:tzid" TEXT COLLATE NOCASE,
+"ncal:tzid:graph" INTEGER);
+CREATE TABLE "ncal:TimezoneObservance" (ID INTEGER NOT NULL PRIMARY
+KEY, "ncal:tzoffsetfrom" TEXT COLLATE NOCASE,
+"ncal:tzoffsetfrom:graph" INTEGER, "ncal:tzoffsetto" TEXT COLLATE
+NOCASE, "ncal:tzoffsetto:graph" INTEGER, "ncal:tzname" TEXT COLLATE
+NOCASE, "ncal:tzname:graph" INTEGER);
+CREATE TABLE "ncal:Todo" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:percentComplete" INTEGER, "ncal:percentComplete:graph" INTEGER,
+"ncal:completed" INTEGER, "ncal:completed:graph" INTEGER,
+"ncal:completed:localDate" INTEGER, "ncal:completed:localTime"
+INTEGER, "ncal:todoStatus" INTEGER, "ncal:todoStatus:graph" INTEGER,
+"ncal:due" INTEGER, "ncal:due:graph" INTEGER);
+CREATE TABLE "ncal:TodoStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:Trigger" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:related" INTEGER, "ncal:related:graph" INTEGER,
+"ncal:triggerDateTime" INTEGER, "ncal:triggerDateTime:graph" INTEGER,
+"ncal:triggerDateTime:localDate" INTEGER,
+"ncal:triggerDateTime:localTime" INTEGER, "ncal:triggerDuration"
+INTEGER, "ncal:triggerDuration:graph" INTEGER);
+CREATE TABLE "ncal:TriggerRelation" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "ncal:UnionParentClass" (ID INTEGER NOT NULL PRIMARY KEY,
+"ncal:lastModified" INTEGER, "ncal:lastModified:graph" INTEGER,
+"ncal:lastModified:localDate" INTEGER, "ncal:lastModified:localTime"
+INTEGER, "ncal:trigger" INTEGER, "ncal:trigger:graph" INTEGER,
+"ncal:created" INTEGER, "ncal:created:graph" INTEGER,
+"ncal:created:localDate" INTEGER, "ncal:created:localTime" INTEGER,
+"ncal:url" INTEGER, "ncal:url:graph" INTEGER, "ncal:comment" TEXT
+COLLATE NOCASE, "ncal:comment:graph" INTEGER, "ncal:summaryAltRep"
+INTEGER, "ncal:summaryAltRep:graph" INTEGER, "ncal:priority" INTEGER,
+"ncal:priority:graph" INTEGER, "ncal:location" TEXT COLLATE NOCASE,
+"ncal:location:graph" INTEGER, "ncal:uid" TEXT COLLATE NOCASE,
+"ncal:uid:graph" INTEGER, "ncal:requestStatus" INTEGER,
+"ncal:requestStatus:graph" INTEGER, "ncal:recurrenceId" INTEGER,
+"ncal:recurrenceId:graph" INTEGER, "ncal:dtstamp" INTEGER,
+"ncal:dtstamp:graph" INTEGER, "ncal:dtstamp:localDate" INTEGER,
+"ncal:dtstamp:localTime" INTEGER, "ncal:class" INTEGER,
+"ncal:class:graph" INTEGER, "ncal:organizer" INTEGER,
+"ncal:organizer:graph" INTEGER, "ncal:dtend" INTEGER,
+"ncal:dtend:graph" INTEGER, "ncal:summary" TEXT COLLATE NOCASE,
+"ncal:summary:graph" INTEGER, "ncal:descriptionAltRep" INTEGER,
+"ncal:descriptionAltRep:graph" INTEGER, "ncal:commentAltRep" INTEGER,
+"ncal:commentAltRep:graph" INTEGER, "ncal:sequence" INTEGER,
+"ncal:sequence:graph" INTEGER, "ncal:contact" TEXT COLLATE NOCASE,
+"ncal:contact:graph" INTEGER, "ncal:contactAltRep" INTEGER,
+"ncal:contactAltRep:graph" INTEGER, "ncal:locationAltRep" INTEGER,
+"ncal:locationAltRep:graph" INTEGER, "ncal:geo" INTEGER,
+"ncal:geo:graph" INTEGER, "ncal:resourcesAltRep" INTEGER,
+"ncal:resourcesAltRep:graph" INTEGER, "ncal:dtstart" INTEGER,
+"ncal:dtstart:graph" INTEGER, "ncal:description" TEXT COLLATE NOCASE,
+"ncal:description:graph" INTEGER, "ncal:relatedToSibling" TEXT COLLATE
+NOCASE, "ncal:relatedToSibling:graph" INTEGER, "ncal:duration"
+INTEGER, "ncal:duration:graph" INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:attach" (ID INTEGER NOT NULL,
+"ncal:attach" INTEGER NOT NULL, "ncal:attach:graph" INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:attendee" (ID INTEGER NOT
+NULL, "ncal:attendee" INTEGER NOT NULL, "ncal:attendee:graph"
+INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:categories" (ID INTEGER NOT
+NULL, "ncal:categories" TEXT NOT NULL, "ncal:categories:graph"
+INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:exdate" (ID INTEGER NOT NULL,
+"ncal:exdate" INTEGER NOT NULL, "ncal:exdate:graph" INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:exrule" (ID INTEGER NOT NULL,
+"ncal:exrule" INTEGER NOT NULL, "ncal:exrule:graph" INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:hasAlarm" (ID INTEGER NOT
+NULL, "ncal:hasAlarm" INTEGER NOT NULL, "ncal:hasAlarm:graph"
+INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:ncalRelation" (ID INTEGER NOT
+NULL, "ncal:ncalRelation" TEXT NOT NULL, "ncal:ncalRelation:graph"
+INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:rdate" (ID INTEGER NOT NULL,
+"ncal:rdate" INTEGER NOT NULL, "ncal:rdate:graph" INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:relatedToChild" (ID INTEGER
+NOT NULL, "ncal:relatedToChild" TEXT NOT NULL,
+"ncal:relatedToChild:graph" INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:relatedToParent" (ID INTEGER
+NOT NULL, "ncal:relatedToParent" TEXT NOT NULL,
+"ncal:relatedToParent:graph" INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:resources" (ID INTEGER NOT
+NULL, "ncal:resources" TEXT NOT NULL, "ncal:resources:graph" INTEGER);
+CREATE TABLE "ncal:UnionParentClass_ncal:rrule" (ID INTEGER NOT NULL,
+"ncal:rrule" INTEGER NOT NULL, "ncal:rrule:graph" INTEGER);
+CREATE TABLE "ncal:Weekday" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:Affiliation" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:department" TEXT COLLATE NOCASE, "nco:department:graph" INTEGER,
+"nco:org" INTEGER, "nco:org:graph" INTEGER, "nco:role" TEXT COLLATE
+NOCASE, "nco:role:graph" INTEGER);
+CREATE TABLE "nco:Affiliation_nco:title" (ID INTEGER NOT NULL,
+"nco:title" TEXT NOT NULL, "nco:title:graph" INTEGER);
+CREATE TABLE "nco:AuthorizationStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:BbsNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:CarPhoneNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:CellPhoneNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:Contact" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:fullname" TEXT COLLATE NOCASE, "nco:fullname:graph" INTEGER,
+"nco:key" INTEGER, "nco:key:graph" INTEGER, "nco:contactUID" TEXT
+COLLATE NOCASE, "nco:contactUID:graph" INTEGER, "nco:contactLocalUID"
+TEXT COLLATE NOCASE, "nco:contactLocalUID:graph" INTEGER,
+"nco:hasLocation" INTEGER, "nco:hasLocation:graph" INTEGER,
+"nco:nickname" TEXT COLLATE NOCASE, "nco:nickname:graph" INTEGER,
+"nco:representative" INTEGER, "nco:representative:graph" INTEGER,
+"nco:photo" INTEGER, "nco:photo:graph" INTEGER, "nco:birthDate"
+INTEGER, "nco:birthDate:graph" INTEGER, "nco:birthDate:localDate"
+INTEGER, "nco:birthDate:localTime" INTEGER, "nco:sound" INTEGER,
+"nco:sound:graph" INTEGER);
+CREATE TABLE "nco:ContactGroup" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:contactGroupName" TEXT COLLATE NOCASE,
+"nco:contactGroupName:graph" INTEGER);
+CREATE TABLE "nco:ContactList" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:ContactListDataObject" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:ContactList_nco:containsContact" (ID INTEGER NOT
+NULL, "nco:containsContact" INTEGER NOT NULL,
+"nco:containsContact:graph" INTEGER);
+CREATE TABLE "nco:ContactMedium" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:contactMediumComment" TEXT COLLATE NOCASE,
+"nco:contactMediumComment:graph" INTEGER);
+CREATE TABLE "nco:Contact_ncal:anniversary" (ID INTEGER NOT NULL,
+"ncal:anniversary" INTEGER NOT NULL, "ncal:anniversary:graph"
+INTEGER);
+CREATE TABLE "nco:Contact_ncal:birthday" (ID INTEGER NOT NULL,
+"ncal:birthday" INTEGER NOT NULL, "ncal:birthday:graph" INTEGER);
+CREATE TABLE "nco:Contact_nco:belongsToGroup" (ID INTEGER NOT NULL,
+"nco:belongsToGroup" INTEGER NOT NULL, "nco:belongsToGroup:graph"
+INTEGER);
+CREATE TABLE "nco:Contact_nco:note" (ID INTEGER NOT NULL, "nco:note"
+TEXT NOT NULL, "nco:note:graph" INTEGER);
+CREATE TABLE "nco:Contact_scal:anniversary" (ID INTEGER NOT NULL,
+"scal:anniversary" INTEGER NOT NULL, "scal:anniversary:graph"
+INTEGER);
+CREATE TABLE "nco:Contact_scal:birthday" (ID INTEGER NOT NULL,
+"scal:birthday" INTEGER NOT NULL, "scal:birthday:graph" INTEGER);
+CREATE TABLE "nco:DomesticDeliveryAddress" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:EmailAddress" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:emailAddress" TEXT COLLATE NOCASE UNIQUE,
+"nco:emailAddress:graph" INTEGER);
+CREATE TABLE "nco:FaxNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:Gender" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:IMAccount" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:imAccountAddress" INTEGER UNIQUE, "nco:imAccountAddress:graph"
+INTEGER, "nco:imAccountType" TEXT COLLATE NOCASE,
+"nco:imAccountType:graph" INTEGER, "nco:imDisplayName" TEXT COLLATE
+NOCASE, "nco:imDisplayName:graph" INTEGER, "nco:imEnabled" INTEGER,
+"nco:imEnabled:graph" INTEGER);
+CREATE TABLE "nco:IMAccount_nco:hasIMContact" (ID INTEGER NOT NULL,
+"nco:hasIMContact" INTEGER NOT NULL, "nco:hasIMContact:graph"
+INTEGER);
+CREATE TABLE "nco:IMAddress" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:imID" TEXT COLLATE NOCASE, "nco:imID:graph" INTEGER,
+"nco:imNickname" TEXT COLLATE NOCASE, "nco:imNickname:graph" INTEGER,
+"nco:imAvatar" INTEGER, "nco:imAvatar:graph" INTEGER, "nco:imProtocol"
+TEXT COLLATE NOCASE, "nco:imProtocol:graph" INTEGER,
+"nco:imStatusMessage" TEXT COLLATE NOCASE,
+"nco:imStatusMessage:graph" INTEGER, "nco:imPresence" INTEGER,
+"nco:imPresence:graph" INTEGER, "nco:presenceLastModified" INTEGER,
+"nco:presenceLastModified:graph" INTEGER,
+"nco:presenceLastModified:localDate" INTEGER,
+"nco:presenceLastModified:localTime" INTEGER,
+"nco:imAddressAuthStatusFrom" INTEGER,
+"nco:imAddressAuthStatusFrom:graph" INTEGER,
+"nco:imAddressAuthStatusTo" INTEGER, "nco:imAddressAuthStatusTo:graph"
+INTEGER);
+CREATE TABLE "nco:IMAddress_nco:imCapability" (ID INTEGER NOT NULL,
+"nco:imCapability" INTEGER NOT NULL, "nco:imCapability:graph"
+INTEGER);
+CREATE TABLE "nco:IMCapability" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:InternationalDeliveryAddress" (ID INTEGER NOT NULL
+PRIMARY KEY);
+CREATE TABLE "nco:IsdnNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:MessagingNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:ModemNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:OrganizationContact" (ID INTEGER NOT NULL PRIMARY
+KEY, "nco:logo" INTEGER, "nco:logo:graph" INTEGER);
+CREATE TABLE "nco:PagerNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:ParcelDeliveryAddress" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:PcsNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:PersonContact" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:nameFamily" TEXT COLLATE NOCASE, "nco:nameFamily:graph" INTEGER,
+"nco:nameGiven" TEXT COLLATE NOCASE, "nco:nameGiven:graph" INTEGER,
+"nco:nameAdditional" TEXT COLLATE NOCASE, "nco:nameAdditional:graph"
+INTEGER, "nco:nameHonorificSuffix" TEXT COLLATE NOCASE,
+"nco:nameHonorificSuffix:graph" INTEGER, "nco:nameHonorificPrefix"
+TEXT COLLATE NOCASE, "nco:nameHonorificPrefix:graph" INTEGER,
+"nco:hobby" TEXT COLLATE NOCASE, "nco:hobby:graph" INTEGER,
+"nco:gender" INTEGER, "nco:gender:graph" INTEGER);
+CREATE TABLE "nco:PersonContact_nco:hasAffiliation" (ID INTEGER NOT
+NULL, "nco:hasAffiliation" INTEGER NOT NULL,
+"nco:hasAffiliation:graph" INTEGER);
+CREATE TABLE "nco:PhoneNumber" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:phoneNumber" TEXT COLLATE NOCASE, "nco:phoneNumber:graph"
+INTEGER);
+CREATE TABLE "nco:PostalAddress" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:region" TEXT COLLATE NOCASE, "nco:region:graph" INTEGER,
+"nco:country" TEXT COLLATE NOCASE, "nco:country:graph" INTEGER,
+"nco:extendedAddress" TEXT COLLATE NOCASE,
+"nco:extendedAddress:graph" INTEGER, "nco:addressLocation" INTEGER,
+"nco:addressLocation:graph" INTEGER, "nco:streetAddress" TEXT COLLATE
+NOCASE, "nco:streetAddress:graph" INTEGER, "nco:postalcode" TEXT
+COLLATE NOCASE, "nco:postalcode:graph" INTEGER, "nco:locality" TEXT
+COLLATE NOCASE, "nco:locality:graph" INTEGER, "nco:county" TEXT
+COLLATE NOCASE, "nco:county:graph" INTEGER, "nco:district" TEXT
+COLLATE NOCASE, "nco:district:graph" INTEGER, "nco:pobox" TEXT
+COLLATE NOCASE, "nco:pobox:graph" INTEGER);
+CREATE TABLE "nco:PresenceStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:Role" (ID INTEGER NOT NULL PRIMARY KEY, "nco:video"
+INTEGER, "nco:video:graph" INTEGER);
+CREATE TABLE "nco:Role_nco:blogUrl" (ID INTEGER NOT NULL,
+"nco:blogUrl" INTEGER NOT NULL, "nco:blogUrl:graph" INTEGER);
+CREATE TABLE "nco:Role_nco:foafUrl" (ID INTEGER NOT NULL,
+"nco:foafUrl" INTEGER NOT NULL, "nco:foafUrl:graph" INTEGER);
+CREATE TABLE "nco:Role_nco:hasContactMedium" (ID INTEGER NOT NULL,
+"nco:hasContactMedium" INTEGER NOT NULL, "nco:hasContactMedium:graph"
+INTEGER);
+CREATE TABLE "nco:Role_nco:hasEmailAddress" (ID INTEGER NOT NULL,
+"nco:hasEmailAddress" INTEGER NOT NULL, "nco:hasEmailAddress:graph"
+INTEGER);
+CREATE TABLE "nco:Role_nco:hasIMAddress" (ID INTEGER NOT NULL,
+"nco:hasIMAddress" INTEGER NOT NULL, "nco:hasIMAddress:graph"
+INTEGER);
+CREATE TABLE "nco:Role_nco:hasPhoneNumber" (ID INTEGER NOT NULL,
+"nco:hasPhoneNumber" INTEGER NOT NULL, "nco:hasPhoneNumber:graph"
+INTEGER);
+CREATE TABLE "nco:Role_nco:hasPostalAddress" (ID INTEGER NOT NULL,
+"nco:hasPostalAddress" INTEGER NOT NULL, "nco:hasPostalAddress:graph"
+INTEGER);
+CREATE TABLE "nco:Role_nco:url" (ID INTEGER NOT NULL, "nco:url"
+INTEGER NOT NULL, "nco:url:graph" INTEGER);
+CREATE TABLE "nco:Role_nco:websiteUrl" (ID INTEGER NOT NULL,
+"nco:websiteUrl" INTEGER NOT NULL, "nco:websiteUrl:graph" INTEGER);
+CREATE TABLE "nco:VideoTelephoneNumber" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nco:VoicePhoneNumber" (ID INTEGER NOT NULL PRIMARY KEY,
+"nco:voiceMail" INTEGER, "nco:voiceMail:graph" INTEGER);
+CREATE TABLE "nfo:Application" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Archive" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:uncompressedSize" INTEGER, "nfo:uncompressedSize:graph" INTEGER);
+CREATE TABLE "nfo:ArchiveItem" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:isPasswordProtected" INTEGER, "nfo:isPasswordProtected:graph"
+INTEGER);
+CREATE TABLE "nfo:Attachment" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Audio" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:channels" INTEGER, "nfo:channels:graph" INTEGER,
+"nfo:sideChannels" INTEGER, "nfo:sideChannels:graph" INTEGER,
+"nfo:lfeChannels" INTEGER, "nfo:lfeChannels:graph" INTEGER,
+"nfo:sampleCount" INTEGER, "nfo:sampleCount:graph" INTEGER,
+"nfo:bitsPerSample" INTEGER, "nfo:bitsPerSample:graph" INTEGER,
+"nfo:frontChannels" INTEGER, "nfo:frontChannels:graph" INTEGER,
+"nfo:sampleRate" REAL, "nfo:sampleRate:graph" INTEGER,
+"nfo:averageAudioBitrate" REAL, "nfo:averageAudioBitrate:graph"
+INTEGER, "nfo:rearChannels" INTEGER, "nfo:rearChannels:graph" INTEGER,
+"nfo:gain" INTEGER, "nfo:gain:graph" INTEGER, "nfo:peakGain" INTEGER,
+"nfo:peakGain:graph" INTEGER, "nfo:audioOffset" REAL,
+"nfo:audioOffset:graph" INTEGER);
+CREATE TABLE "nfo:Bookmark" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:bookmarks" INTEGER, "nfo:bookmarks:graph" INTEGER,
+"nfo:characterPosition" INTEGER, "nfo:characterPosition:graph"
+INTEGER, "nfo:pageNumber" INTEGER, "nfo:pageNumber:graph" INTEGER,
+"nfo:streamPosition" INTEGER, "nfo:streamPosition:graph" INTEGER,
+"nfo:streamDuration" INTEGER, "nfo:streamDuration:graph" INTEGER);
+CREATE TABLE "nfo:BookmarkFolder" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:BookmarkFolder_nfo:containsBookmark" (ID INTEGER NOT
+NULL, "nfo:containsBookmark" INTEGER NOT NULL,
+"nfo:containsBookmark:graph" INTEGER);
+CREATE TABLE "nfo:BookmarkFolder_nfo:containsBookmarkFolder" (ID
+INTEGER NOT NULL, "nfo:containsBookmarkFolder" INTEGER NOT NULL,
+"nfo:containsBookmarkFolder:graph" INTEGER);
+CREATE TABLE "nfo:CompressionType" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Cursor" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:DataContainer" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:DeletedResource" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:originalLocation" TEXT COLLATE NOCASE,
+"nfo:originalLocation:graph" INTEGER, "nfo:deletionDate" INTEGER,
+"nfo:deletionDate:graph" INTEGER, "nfo:deletionDate:localDate"
+INTEGER, "nfo:deletionDate:localTime" INTEGER);
+CREATE TABLE "nfo:Document" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:tableOfContents" TEXT COLLATE NOCASE,
+"nfo:tableOfContents:graph" INTEGER);
+CREATE TABLE "nfo:EmbeddedFileDataObject" (ID INTEGER NOT NULL PRIMARY
+KEY, "nfo:encoding" TEXT COLLATE NOCASE, "nfo:encoding:graph"
+INTEGER);
+CREATE TABLE "nfo:Equipment" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:manufacturer" TEXT COLLATE NOCASE, "nfo:manufacturer:graph"
+INTEGER, "nfo:model" TEXT COLLATE NOCASE, "nfo:model:graph" INTEGER,
+"nfo:equipmentSoftware" TEXT COLLATE NOCASE,
+"nfo:equipmentSoftware:graph" INTEGER);
+CREATE TABLE "nfo:Executable" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:FileDataObject" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:fileLastAccessed" INTEGER, "nfo:fileLastAccessed:graph" INTEGER,
+"nfo:fileLastAccessed:localDate" INTEGER,
+"nfo:fileLastAccessed:localTime" INTEGER, "nfo:fileCreated" INTEGER,
+"nfo:fileCreated:graph" INTEGER, "nfo:fileCreated:localDate" INTEGER,
+"nfo:fileCreated:localTime" INTEGER, "nfo:fileSize" INTEGER,
+"nfo:fileSize:graph" INTEGER, "nfo:permissions" TEXT COLLATE NOCASE,
+"nfo:permissions:graph" INTEGER, "nfo:fileName" TEXT COLLATE NOCASE,
+"nfo:fileName:graph" INTEGER, "nfo:hasHash" INTEGER,
+"nfo:hasHash:graph" INTEGER, "nfo:fileOwner" INTEGER,
+"nfo:fileOwner:graph" INTEGER, "nfo:fileLastModified" INTEGER,
+"nfo:fileLastModified:graph" INTEGER, "nfo:fileLastModified:localDate"
+INTEGER, "nfo:fileLastModified:localTime" INTEGER);
+CREATE TABLE "nfo:FileHash" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:hashValue" TEXT COLLATE NOCASE, "nfo:hashValue:graph" INTEGER,
+"nfo:hashAlgorithm" TEXT COLLATE NOCASE, "nfo:hashAlgorithm:graph"
+INTEGER);
+CREATE TABLE "nfo:Filesystem" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:FilesystemImage" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Folder" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Font" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:fontFamily" TEXT COLLATE NOCASE, "nfo:fontFamily:graph" INTEGER,
+"nfo:foundry" INTEGER, "nfo:foundry:graph" INTEGER);
+CREATE TABLE "nfo:HardDiskPartition" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:HelpDocument" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:HtmlDocument" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Icon" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Image" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:verticalResolution" INTEGER, "nfo:verticalResolution:graph"
+INTEGER, "nfo:horizontalResolution" INTEGER,
+"nfo:horizontalResolution:graph" INTEGER, "nfo:orientation" INTEGER,
+"nfo:orientation:graph" INTEGER);
+CREATE TABLE "nfo:Image_nfo:depicts" (ID INTEGER NOT NULL,
+"nfo:depicts" INTEGER NOT NULL, "nfo:depicts:graph" INTEGER);
+CREATE TABLE "nfo:Image_nfo:hasRegionOfInterest" (ID INTEGER NOT NULL,
+"nfo:hasRegionOfInterest" INTEGER NOT NULL,
+"nfo:hasRegionOfInterest:graph" INTEGER);
+CREATE TABLE "nfo:Media" (ID INTEGER NOT NULL PRIMARY KEY, "nfo:count"
+INTEGER, "nfo:count:graph" INTEGER, "nfo:duration" INTEGER,
+"nfo:duration:graph" INTEGER, "nfo:compressionType" INTEGER,
+"nfo:compressionType:graph" INTEGER, "nfo:hasMediaStream" INTEGER,
+"nfo:hasMediaStream:graph" INTEGER, "nfo:bitDepth" INTEGER,
+"nfo:bitDepth:graph" INTEGER, "nfo:codec" TEXT COLLATE NOCASE,
+"nfo:codec:graph" INTEGER, "nfo:encodedBy" TEXT COLLATE NOCASE,
+"nfo:encodedBy:graph" INTEGER, "nfo:bitrateType" TEXT COLLATE NOCASE,
+"nfo:bitrateType:graph" INTEGER, "nfo:averageBitrate" REAL,
+"nfo:averageBitrate:graph" INTEGER, "nfo:genre" TEXT COLLATE NOCASE,
+"nfo:genre:graph" INTEGER, "nfo:equipment" INTEGER,
+"nfo:equipment:graph" INTEGER, "nfo:lastPlayedPosition" INTEGER,
+"nfo:lastPlayedPosition:graph" INTEGER, "nmm:genre" TEXT COLLATE
+NOCASE, "nmm:genre:graph" INTEGER, "nmm:skipCounter" INTEGER,
+"nmm:skipCounter:graph" INTEGER, "nmm:dlnaProfile" TEXT COLLATE
+NOCASE, "nmm:dlnaProfile:graph" INTEGER, "nmm:dlnaMime" TEXT COLLATE
+NOCASE, "nmm:dlnaMime:graph" INTEGER, "nmm:uPnPShared" INTEGER,
+"nmm:uPnPShared:graph" INTEGER, "mtp:credits" TEXT COLLATE NOCASE,
+"mtp:credits:graph" INTEGER, "mtp:creator" TEXT COLLATE NOCASE,
+"mtp:creator:graph" INTEGER);
+CREATE TABLE "nfo:MediaFileListEntry" (ID INTEGER NOT NULL PRIMARY
+KEY, "nfo:listPosition" REAL, "nfo:listPosition:graph" INTEGER,
+"nfo:entryUrl" TEXT COLLATE NOCASE, "nfo:entryUrl:graph" INTEGER);
+CREATE TABLE "nfo:MediaList" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:entryCounter" INTEGER, "nfo:entryCounter:graph" INTEGER,
+"nfo:listDuration" INTEGER, "nfo:listDuration:graph" INTEGER);
+CREATE TABLE "nfo:MediaList_nfo:hasMediaFileListEntry" (ID INTEGER NOT
+NULL, "nfo:hasMediaFileListEntry" INTEGER NOT NULL,
+"nfo:hasMediaFileListEntry:graph" INTEGER);
+CREATE TABLE "nfo:MediaList_nfo:mediaListEntry" (ID INTEGER NOT NULL,
+"nfo:mediaListEntry" INTEGER NOT NULL, "nfo:mediaListEntry:graph"
+INTEGER);
+CREATE TABLE "nfo:MediaStream" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Media_mtp:hidden" (ID INTEGER NOT NULL, "mtp:hidden"
+INTEGER NOT NULL, "mtp:hidden:graph" INTEGER);
+CREATE TABLE "nfo:Media_nmm:alternativeMedia" (ID INTEGER NOT NULL,
+"nmm:alternativeMedia" INTEGER NOT NULL, "nmm:alternativeMedia:graph"
+INTEGER);
+CREATE TABLE "nfo:MindMap" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Note" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:OperatingSystem" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Orientation" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:PaginatedTextDocument" (ID INTEGER NOT NULL PRIMARY
+KEY, "nfo:pageCount" INTEGER, "nfo:pageCount:graph" INTEGER);
+CREATE TABLE "nfo:PlainTextDocument" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Presentation" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:RasterImage" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:RegionOfInterest" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:regionOfInterestX" REAL, "nfo:regionOfInterestX:graph" INTEGER,
+"nfo:regionOfInterestY" REAL, "nfo:regionOfInterestY:graph" INTEGER,
+"nfo:regionOfInterestWidth" REAL, "nfo:regionOfInterestWidth:graph"
+INTEGER, "nfo:regionOfInterestHeight" REAL,
+"nfo:regionOfInterestHeight:graph" INTEGER, "nfo:regionOfInterestType"
+INTEGER, "nfo:regionOfInterestType:graph" INTEGER, "nfo:roiRefersTo"
+INTEGER, "nfo:roiRefersTo:graph" INTEGER);
+CREATE TABLE "nfo:RegionOfInterestContent" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:RemoteDataObject" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:RemotePortAddress" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Software" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:conflicts" INTEGER, "nfo:conflicts:graph" INTEGER,
+"nfo:supercedes" INTEGER, "nfo:supercedes:graph" INTEGER,
+"nfo:softwareIcon" INTEGER, "nfo:softwareIcon:graph" INTEGER,
+"nfo:softwareCmdLine" TEXT COLLATE NOCASE,
+"nfo:softwareCmdLine:graph" INTEGER);
+CREATE TABLE "nfo:SoftwareApplication" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:SoftwareCategory" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:softwareCategoryIcon" INTEGER, "nfo:softwareCategoryIcon:graph"
+INTEGER);
+CREATE TABLE "nfo:SoftwareItem" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:SoftwareService" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:SourceCode" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:commentCharacterCount" INTEGER, "nfo:commentCharacterCount:graph"
+INTEGER, "nfo:programmingLanguage" TEXT COLLATE NOCASE,
+"nfo:programmingLanguage:graph" INTEGER, "nfo:definesClass" TEXT
+COLLATE NOCASE, "nfo:definesClass:graph" INTEGER,
+"nfo:definesFunction" TEXT COLLATE NOCASE,
+"nfo:definesFunction:graph" INTEGER, "nfo:definesGlobalVariable" TEXT
+COLLATE NOCASE, "nfo:definesGlobalVariable:graph" INTEGER);
+CREATE TABLE "nfo:Spreadsheet" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:TextDocument" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:wordCount" INTEGER, "nfo:wordCount:graph" INTEGER,
+"nfo:lineCount" INTEGER, "nfo:lineCount:graph" INTEGER,
+"nfo:characterCount" INTEGER, "nfo:characterCount:graph" INTEGER);
+CREATE TABLE "nfo:Trash" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:VectorImage" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nfo:Video" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:frameRate" REAL, "nfo:frameRate:graph" INTEGER, "nfo:frameCount"
+INTEGER, "nfo:frameCount:graph" INTEGER, "nfo:averageVideoBitrate"
+REAL, "nfo:averageVideoBitrate:graph" INTEGER);
+CREATE TABLE "nfo:Visual" (ID INTEGER NOT NULL PRIMARY KEY,
+"nie:contentCreated" INTEGER, "nie:contentCreated:graph" INTEGER,
+"nie:contentCreated:localDate" INTEGER, "nie:contentCreated:localTime"
+INTEGER, "nfo:aspectRatio" REAL, "nfo:aspectRatio:graph" INTEGER,
+"nfo:heading" REAL, "nfo:heading:graph" INTEGER, "nfo:tilt" REAL,
+"nfo:tilt:graph" INTEGER, "nfo:interlaceMode" INTEGER,
+"nfo:interlaceMode:graph" INTEGER, "nfo:height" INTEGER,
+"nfo:height:graph" INTEGER, "nfo:width" INTEGER, "nfo:width:graph"
+INTEGER, "nfo:colorDepth" INTEGER, "nfo:colorDepth:graph" INTEGER);
+CREATE TABLE "nfo:WebHistory" (ID INTEGER NOT NULL PRIMARY KEY,
+"nfo:domain" TEXT COLLATE NOCASE, "nfo:domain:graph" INTEGER,
+"nfo:uri" TEXT COLLATE NOCASE, "nfo:uri:graph" INTEGER);
+CREATE TABLE "nfo:Website" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nid3:ID3Audio" (ID INTEGER NOT NULL PRIMARY KEY,
+"nid3:title" TEXT COLLATE NOCASE, "nid3:title:graph" INTEGER,
+"nid3:albumTitle" TEXT COLLATE NOCASE, "nid3:albumTitle:graph"
+INTEGER, "nid3:contentType" TEXT COLLATE NOCASE,
+"nid3:contentType:graph" INTEGER, "nid3:length" INTEGER,
+"nid3:length:graph" INTEGER, "nid3:recordingYear" INTEGER,
+"nid3:recordingYear:graph" INTEGER, "nid3:trackNumber" TEXT COLLATE
+NOCASE, "nid3:trackNumber:graph" INTEGER, "nid3:partOfSet" TEXT
+COLLATE NOCASE, "nid3:partOfSet:graph" INTEGER, "nid3:comments" TEXT
+COLLATE NOCASE, "nid3:comments:graph" INTEGER);
+CREATE TABLE "nid3:ID3Audio_nid3:leadArtist" (ID INTEGER NOT NULL,
+"nid3:leadArtist" INTEGER NOT NULL, "nid3:leadArtist:graph" INTEGER);
+CREATE TABLE "nie:DataObject" (ID INTEGER NOT NULL PRIMARY KEY,
+"nie:url" TEXT COLLATE NOCASE UNIQUE, "nie:url:graph" INTEGER,
+"nie:byteSize" INTEGER, "nie:byteSize:graph" INTEGER,
+"nie:interpretedAs" INTEGER, "nie:interpretedAs:graph" INTEGER,
+"nie:lastRefreshed" INTEGER, "nie:lastRefreshed:graph" INTEGER,
+"nie:lastRefreshed:localDate" INTEGER, "nie:lastRefreshed:localTime"
+INTEGER, "nie:created" INTEGER, "nie:created:graph" INTEGER,
+"nie:created:localDate" INTEGER, "nie:created:localTime" INTEGER,
+"nfo:belongsToContainer" INTEGER, "nfo:belongsToContainer:graph"
+INTEGER, "tracker:available" INTEGER, "tracker:available:graph"
+INTEGER);
+CREATE TABLE "nie:DataObject_nie:dataSource" (ID INTEGER NOT NULL,
+"nie:dataSource" INTEGER NOT NULL, "nie:dataSource:graph" INTEGER);
+CREATE TABLE "nie:DataObject_nie:isPartOf" (ID INTEGER NOT NULL,
+"nie:isPartOf" INTEGER NOT NULL, "nie:isPartOf:graph" INTEGER);
+CREATE TABLE "nie:DataSource" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nie:InformationElement" (ID INTEGER NOT NULL PRIMARY
+KEY, "nie:title" TEXT COLLATE NOCASE, "nie:title:graph" INTEGER,
+"nie:contentLastModified" INTEGER, "nie:contentLastModified:graph"
+INTEGER, "nie:contentLastModified:localDate" INTEGER,
+"nie:contentLastModified:localTime" INTEGER, "nie:subject" TEXT
+COLLATE NOCASE, "nie:subject:graph" INTEGER, "nie:mimeType" TEXT
+COLLATE NOCASE, "nie:mimeType:graph" INTEGER, "nie:language" TEXT
+COLLATE NOCASE, "nie:language:graph" INTEGER, "nie:plainTextContent"
+TEXT COLLATE NOCASE, "nie:plainTextContent:graph" INTEGER,
+"nie:legal" TEXT COLLATE NOCASE, "nie:legal:graph" INTEGER,
+"nie:generator" TEXT COLLATE NOCASE, "nie:generator:graph" INTEGER,
+"nie:description" TEXT COLLATE NOCASE, "nie:description:graph"
+INTEGER, "nie:disclaimer" TEXT COLLATE NOCASE, "nie:disclaimer:graph"
+INTEGER, "nie:depends" INTEGER, "nie:depends:graph" INTEGER,
+"nie:links" INTEGER, "nie:links:graph" INTEGER, "nie:copyright" TEXT
+COLLATE NOCASE, "nie:copyright:graph" INTEGER, "nie:comment" TEXT
+COLLATE NOCASE, "nie:comment:graph" INTEGER, "nie:isStoredAs"
+INTEGER, "nie:isStoredAs:graph" INTEGER, "nie:version" TEXT COLLATE
+NOCASE, "nie:version:graph" INTEGER, "nie:contentCreated" INTEGER,
+"nie:contentCreated:graph" INTEGER, "nie:contentCreated:localDate"
+INTEGER, "nie:contentCreated:localTime" INTEGER, "nie:contentAccessed"
+INTEGER, "nie:contentAccessed:graph" INTEGER,
+"nie:contentAccessed:localDate" INTEGER,
+"nie:contentAccessed:localTime" INTEGER, "nie:license" TEXT COLLATE
+NOCASE, "nie:license:graph" INTEGER, "nie:identifier" TEXT COLLATE
+NOCASE, "nie:identifier:graph" INTEGER, "nie:licenseType" TEXT
+COLLATE NOCASE, "nie:licenseType:graph" INTEGER, "nie:characterSet"
+TEXT COLLATE NOCASE, "nie:characterSet:graph" INTEGER,
+"nie:contentSize" INTEGER, "nie:contentSize:graph" INTEGER,
+"nie:rootElementOf" INTEGER, "nie:rootElementOf:graph" INTEGER,
+"nie:usageCounter" INTEGER, "nie:usageCounter:graph" INTEGER,
+"nco:publisher" INTEGER, "nco:publisher:graph" INTEGER,
+"nfo:isContentEncrypted" INTEGER, "nfo:isContentEncrypted:graph"
+INTEGER, "slo:location" INTEGER, "slo:location:graph" INTEGER,
+"nfo:isBootable" INTEGER, "nfo:isBootable:graph" INTEGER, "osinfo:id"
+TEXT COLLATE NOCASE, "osinfo:id:graph" INTEGER, "osinfo:mediaId" TEXT
+COLLATE NOCASE, "osinfo:mediaId:graph" INTEGER);
+CREATE TABLE "nie:InformationElement_mlo:location" (ID INTEGER NOT
+NULL, "mlo:location" INTEGER NOT NULL, "mlo:location:graph" INTEGER);
+CREATE TABLE "nie:InformationElement_nao:hasProperty" (ID INTEGER NOT
+NULL, "nao:hasProperty" INTEGER NOT NULL, "nao:hasProperty:graph"
+INTEGER);
+CREATE TABLE "nie:InformationElement_nco:contributor" (ID INTEGER NOT
+NULL, "nco:contributor" INTEGER NOT NULL, "nco:contributor:graph"
+INTEGER);
+CREATE TABLE "nie:InformationElement_nco:creator" (ID INTEGER NOT
+NULL, "nco:creator" INTEGER NOT NULL, "nco:creator:graph" INTEGER);
+CREATE TABLE "nie:InformationElement_nie:hasLogicalPart" (ID INTEGER
+NOT NULL, "nie:hasLogicalPart" INTEGER NOT NULL,
+"nie:hasLogicalPart:graph" INTEGER);
+CREATE TABLE "nie:InformationElement_nie:hasPart" (ID INTEGER NOT
+NULL, "nie:hasPart" INTEGER NOT NULL, "nie:hasPart:graph" INTEGER);
+CREATE TABLE "nie:InformationElement_nie:informationElementDate" (ID
+INTEGER NOT NULL, "nie:informationElementDate" INTEGER NOT NULL,
+"nie:informationElementDate:graph" INTEGER,
+"nie:informationElementDate:localDate" INTEGER NOT NULL,
+"nie:informationElementDate:localTime" INTEGER NOT NULL);
+CREATE TABLE "nie:InformationElement_nie:isLogicalPartOf" (ID INTEGER
+NOT NULL, "nie:isLogicalPartOf" INTEGER NOT NULL,
+"nie:isLogicalPartOf:graph" INTEGER);
+CREATE TABLE "nie:InformationElement_nie:keyword" (ID INTEGER NOT
+NULL, "nie:keyword" TEXT NOT NULL, "nie:keyword:graph" INTEGER);
+CREATE TABLE "nie:InformationElement_nie:relatedTo" (ID INTEGER NOT
+NULL, "nie:relatedTo" INTEGER NOT NULL, "nie:relatedTo:graph"
+INTEGER);
+CREATE TABLE "nmm:AnalogRadio" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmm:modulation" INTEGER, "nmm:modulation:graph" INTEGER,
+"nmm:frequency" INTEGER, "nmm:frequency:graph" INTEGER);
+CREATE TABLE "nmm:Artist" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmm:artistName" TEXT COLLATE NOCASE, "nmm:artistName:graph"
+INTEGER);
+CREATE TABLE "nmm:DigitalRadio" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmm:streamingBitrate" INTEGER, "nmm:streamingBitrate:graph" INTEGER,
+"nmm:encoding" TEXT COLLATE NOCASE, "nmm:encoding:graph" INTEGER,
+"nmm:protocol" TEXT COLLATE NOCASE, "nmm:protocol:graph" INTEGER);
+CREATE TABLE "nmm:Flash" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmm:ImageList" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmm:MeteringMode" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmm:MusicAlbum" (ID INTEGER NOT NULL PRIMARY KEY,
+"nie:title" TEXT COLLATE NOCASE, "nie:title:graph" INTEGER,
+"nmm:albumTrackCount" INTEGER, "nmm:albumTrackCount:graph" INTEGER,
+"nmm:albumTitle" TEXT COLLATE NOCASE, "nmm:albumTitle:graph" INTEGER,
+"nmm:albumDuration" INTEGER, "nmm:albumDuration:graph" INTEGER,
+"nmm:albumGain" INTEGER, "nmm:albumGain:graph" INTEGER,
+"nmm:albumPeakGain" INTEGER, "nmm:albumPeakGain:graph" INTEGER);
+CREATE TABLE "nmm:MusicAlbumDisc" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmm:albumDiscAlbum" INTEGER, "nmm:albumDiscAlbum:graph" INTEGER,
+"nmm:musicCDIdentifier" TEXT COLLATE NOCASE,
+"nmm:musicCDIdentifier:graph" INTEGER, "nmm:setNumber" INTEGER,
+"nmm:setNumber:graph" INTEGER);
+CREATE TABLE "nmm:MusicAlbum_nmm:albumArtist" (ID INTEGER NOT NULL,
+"nmm:albumArtist" INTEGER NOT NULL, "nmm:albumArtist:graph" INTEGER);
+CREATE TABLE "nmm:MusicPiece" (ID INTEGER NOT NULL PRIMARY KEY,
+"nie:title" TEXT COLLATE NOCASE, "nie:title:graph" INTEGER,
+"nmm:musicAlbum" INTEGER, "nmm:musicAlbum:graph" INTEGER,
+"nmm:musicAlbumDisc" INTEGER, "nmm:musicAlbumDisc:graph" INTEGER,
+"nmm:beatsPerMinute" INTEGER, "nmm:beatsPerMinute:graph" INTEGER,
+"nmm:performer" INTEGER, "nmm:performer:graph" INTEGER, "nmm:composer"
+INTEGER, "nmm:composer:graph" INTEGER, "nmm:lyricist" INTEGER,
+"nmm:lyricist:graph" INTEGER, "nmm:trackNumber" INTEGER,
+"nmm:trackNumber:graph" INTEGER,
+"nmm:internationalStandardRecordingCode" TEXT COLLATE NOCASE,
+"nmm:internationalStandardRecordingCode:graph" INTEGER);
+CREATE TABLE "nmm:MusicPiece_nmm:lyrics" (ID INTEGER NOT NULL,
+"nmm:lyrics" INTEGER NOT NULL, "nmm:lyrics:graph" INTEGER);
+CREATE TABLE "nmm:Photo" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmm:exposureTime" REAL, "nmm:exposureTime:graph" INTEGER, "nmm:flash"
+INTEGER, "nmm:flash:graph" INTEGER, "nmm:fnumber" REAL,
+"nmm:fnumber:graph" INTEGER, "nmm:focalLength" REAL,
+"nmm:focalLength:graph" INTEGER, "nmm:isoSpeed" REAL,
+"nmm:isoSpeed:graph" INTEGER, "nmm:meteringMode" INTEGER,
+"nmm:meteringMode:graph" INTEGER, "nmm:whiteBalance" INTEGER,
+"nmm:whiteBalance:graph" INTEGER, "nmm:isCropped" INTEGER,
+"nmm:isCropped:graph" INTEGER, "nmm:isColorCorrected" INTEGER,
+"nmm:isColorCorrected:graph" INTEGER);
+CREATE TABLE "nmm:Playlist" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmm:RadioModulation" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmm:RadioStation" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmm:radioIcon" INTEGER, "nmm:radioIcon:graph" INTEGER, "nmm:radioPTY"
+INTEGER, "nmm:radioPTY:graph" INTEGER);
+CREATE TABLE "nmm:RadioStation_nmm:carrier" (ID INTEGER NOT NULL,
+"nmm:carrier" INTEGER NOT NULL, "nmm:carrier:graph" INTEGER);
+CREATE TABLE "nmm:SynchronizedText" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmm:isForHearingImpaired" INTEGER, "nmm:isForHearingImpaired:graph"
+INTEGER);
+CREATE TABLE "nmm:Video" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmm:videoAlbum" INTEGER, "nmm:videoAlbum:graph" INTEGER,
+"nmm:isSeries" INTEGER, "nmm:isSeries:graph" INTEGER, "nmm:season"
+INTEGER, "nmm:season:graph" INTEGER, "nmm:episodeNumber" INTEGER,
+"nmm:episodeNumber:graph" INTEGER, "nmm:runTime" INTEGER,
+"nmm:runTime:graph" INTEGER, "nmm:synopsis" TEXT COLLATE NOCASE,
+"nmm:synopsis:graph" INTEGER, "nmm:MPAARating" TEXT COLLATE NOCASE,
+"nmm:MPAARating:graph" INTEGER, "nmm:category" TEXT COLLATE NOCASE,
+"nmm:category:graph" INTEGER, "nmm:producedBy" INTEGER,
+"nmm:producedBy:graph" INTEGER, "nmm:hasSubtitle" INTEGER,
+"nmm:hasSubtitle:graph" INTEGER, "nmm:isContentEncrypted" INTEGER,
+"nmm:isContentEncrypted:graph" INTEGER, "mtp:fourCC" TEXT COLLATE
+NOCASE, "mtp:fourCC:graph" INTEGER, "mtp:waveformat" TEXT COLLATE
+NOCASE, "mtp:waveformat:graph" INTEGER);
+CREATE TABLE "nmm:Video_mtp:scantype" (ID INTEGER NOT NULL,
+"mtp:scantype" INTEGER NOT NULL, "mtp:scantype:graph" INTEGER);
+CREATE TABLE "nmm:Video_nmm:director" (ID INTEGER NOT NULL,
+"nmm:director" INTEGER NOT NULL, "nmm:director:graph" INTEGER);
+CREATE TABLE "nmm:Video_nmm:leadActor" (ID INTEGER NOT NULL,
+"nmm:leadActor" INTEGER NOT NULL, "nmm:leadActor:graph" INTEGER);
+CREATE TABLE "nmm:Video_nmm:subtitle" (ID INTEGER NOT NULL,
+"nmm:subtitle" INTEGER NOT NULL, "nmm:subtitle:graph" INTEGER);
+CREATE TABLE "nmm:WhiteBalance" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:Attachment" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:Call" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmo:sentDate" INTEGER, "nmo:sentDate:graph" INTEGER,
+"nmo:sentDate:localDate" INTEGER, "nmo:sentDate:localTime" INTEGER,
+"nmo:duration" INTEGER, "nmo:duration:graph" INTEGER);
+CREATE TABLE "nmo:CommunicationChannel" (ID INTEGER NOT NULL PRIMARY
+KEY, "nmo:lastMessageDate" INTEGER, "nmo:lastMessageDate:graph"
+INTEGER, "nmo:lastMessageDate:localDate" INTEGER,
+"nmo:lastMessageDate:localTime" INTEGER,
+"nmo:lastSuccessfulMessageDate" INTEGER,
+"nmo:lastSuccessfulMessageDate:graph" INTEGER,
+"nmo:lastSuccessfulMessageDate:localDate" INTEGER,
+"nmo:lastSuccessfulMessageDate:localTime" INTEGER);
+CREATE TABLE "nmo:CommunicationChannel_nmo:hasParticipant" (ID INTEGER
+NOT NULL, "nmo:hasParticipant" INTEGER NOT NULL,
+"nmo:hasParticipant:graph" INTEGER);
+CREATE TABLE "nmo:Conversation" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:DeliveryStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:Email" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmo:hasContent" INTEGER, "nmo:hasContent:graph" INTEGER,
+"nmo:isFlagged" INTEGER, "nmo:isFlagged:graph" INTEGER, "nmo:isRecent"
+INTEGER, "nmo:isRecent:graph" INTEGER, "nmo:status" TEXT COLLATE
+NOCASE, "nmo:status:graph" INTEGER, "nmo:responseType" TEXT COLLATE
+NOCASE, "nmo:responseType:graph" INTEGER);
+CREATE TABLE "nmo:Email_nmo:contentMimeType" (ID INTEGER NOT NULL,
+"nmo:contentMimeType" TEXT NOT NULL, "nmo:contentMimeType:graph"
+INTEGER);
+CREATE TABLE "nmo:IMMessage" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:MMSMessage" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmo:mmsHasContent" INTEGER, "nmo:mmsHasContent:graph" INTEGER);
+CREATE TABLE "nmo:MailAccount" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmo:accountName" TEXT COLLATE NOCASE, "nmo:accountName:graph"
+INTEGER, "nmo:accountDisplayName" TEXT COLLATE NOCASE,
+"nmo:accountDisplayName:graph" INTEGER, "nmo:fromAddress" INTEGER,
+"nmo:fromAddress:graph" INTEGER, "nmo:signature" TEXT COLLATE NOCASE,
+"nmo:signature:graph" INTEGER);
+CREATE TABLE "nmo:MailFolder" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmo:folderName" TEXT COLLATE NOCASE, "nmo:folderName:graph" INTEGER,
+"nmo:serverCount" INTEGER, "nmo:serverCount:graph" INTEGER,
+"nmo:serverUnreadCount" INTEGER, "nmo:serverUnreadCount:graph"
+INTEGER);
+CREATE TABLE "nmo:MailboxDataObject" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:Message" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmo:sentDate" INTEGER, "nmo:sentDate:graph" INTEGER,
+"nmo:sentDate:localDate" INTEGER, "nmo:sentDate:localTime" INTEGER,
+"nmo:from" INTEGER, "nmo:from:graph" INTEGER, "nmo:isAnswered"
+INTEGER, "nmo:isAnswered:graph" INTEGER, "nmo:isDeleted" INTEGER,
+"nmo:isDeleted:graph" INTEGER, "nmo:isDraft" INTEGER,
+"nmo:isDraft:graph" INTEGER, "nmo:isRead" INTEGER, "nmo:isRead:graph"
+INTEGER, "nmo:isSent" INTEGER, "nmo:isSent:graph" INTEGER,
+"nmo:isEmergency" INTEGER, "nmo:isEmergency:graph" INTEGER,
+"nmo:htmlMessageContent" TEXT COLLATE NOCASE,
+"nmo:htmlMessageContent:graph" INTEGER, "nmo:messageId" TEXT COLLATE
+NOCASE, "nmo:messageId:graph" INTEGER, "nmo:messageSubject" TEXT
+COLLATE NOCASE, "nmo:messageSubject:graph" INTEGER,
+"nmo:receivedDate" INTEGER, "nmo:receivedDate:graph" INTEGER,
+"nmo:receivedDate:localDate" INTEGER, "nmo:receivedDate:localTime"
+INTEGER, "nmo:replyTo" INTEGER, "nmo:replyTo:graph" INTEGER,
+"nmo:sender" INTEGER, "nmo:sender:graph" INTEGER, "nmo:conversation"
+INTEGER, "nmo:conversation:graph" INTEGER, "nmo:communicationChannel"
+INTEGER, "nmo:communicationChannel:graph" INTEGER,
+"nmo:deliveryStatus" INTEGER, "nmo:deliveryStatus:graph" INTEGER,
+"nmo:reportDelivery" INTEGER, "nmo:reportDelivery:graph" INTEGER,
+"nmo:sentWithReportRead" INTEGER, "nmo:sentWithReportRead:graph"
+INTEGER, "nmo:reportReadStatus" INTEGER, "nmo:reportReadStatus:graph"
+INTEGER, "nmo:mustAnswerReportRead" INTEGER,
+"nmo:mustAnswerReportRead:graph" INTEGER, "nmo:mmsId" TEXT COLLATE
+NOCASE, "nmo:mmsId:graph" INTEGER);
+CREATE TABLE "nmo:MessageHeader" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmo:headerName" TEXT COLLATE NOCASE, "nmo:headerName:graph" INTEGER,
+"nmo:headerValue" TEXT COLLATE NOCASE, "nmo:headerValue:graph"
+INTEGER);
+CREATE TABLE "nmo:Message_nmo:bcc" (ID INTEGER NOT NULL, "nmo:bcc"
+INTEGER NOT NULL, "nmo:bcc:graph" INTEGER);
+CREATE TABLE "nmo:Message_nmo:cc" (ID INTEGER NOT NULL, "nmo:cc"
+INTEGER NOT NULL, "nmo:cc:graph" INTEGER);
+CREATE TABLE "nmo:Message_nmo:hasAttachment" (ID INTEGER NOT NULL,
+"nmo:hasAttachment" INTEGER NOT NULL, "nmo:hasAttachment:graph"
+INTEGER);
+CREATE TABLE "nmo:Message_nmo:inReplyTo" (ID INTEGER NOT NULL,
+"nmo:inReplyTo" INTEGER NOT NULL, "nmo:inReplyTo:graph" INTEGER);
+CREATE TABLE "nmo:Message_nmo:messageHeader" (ID INTEGER NOT NULL,
+"nmo:messageHeader" INTEGER NOT NULL, "nmo:messageHeader:graph"
+INTEGER);
+CREATE TABLE "nmo:Message_nmo:recipient" (ID INTEGER NOT NULL,
+"nmo:recipient" INTEGER NOT NULL, "nmo:recipient:graph" INTEGER);
+CREATE TABLE "nmo:Message_nmo:references" (ID INTEGER NOT NULL,
+"nmo:references" INTEGER NOT NULL, "nmo:references:graph" INTEGER);
+CREATE TABLE "nmo:Message_nmo:to" (ID INTEGER NOT NULL, "nmo:to"
+INTEGER NOT NULL, "nmo:to:graph" INTEGER);
+CREATE TABLE "nmo:MimePart" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmo:charSet" TEXT COLLATE NOCASE, "nmo:charSet:graph" INTEGER,
+"nmo:contentId" TEXT COLLATE NOCASE, "nmo:contentId:graph" INTEGER,
+"nmo:contentTransferEncoding" TEXT COLLATE NOCASE,
+"nmo:contentTransferEncoding:graph" INTEGER, "nmo:contentDescription"
+TEXT COLLATE NOCASE, "nmo:contentDescription:graph" INTEGER,
+"nmo:contentDisposition" TEXT COLLATE NOCASE,
+"nmo:contentDisposition:graph" INTEGER);
+CREATE TABLE "nmo:MimePart_nmo:mimeHeader" (ID INTEGER NOT NULL,
+"nmo:mimeHeader" INTEGER NOT NULL, "nmo:mimeHeader:graph" INTEGER);
+CREATE TABLE "nmo:Multipart" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:Multipart_nmo:partBoundary" (ID INTEGER NOT NULL,
+"nmo:partBoundary" TEXT NOT NULL, "nmo:partBoundary:graph" INTEGER);
+CREATE TABLE "nmo:PermanentChannel" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:PhoneMessage" (ID INTEGER NOT NULL PRIMARY KEY,
+"nmo:fromVCard" INTEGER, "nmo:fromVCard:graph" INTEGER, "nmo:encoding"
+TEXT COLLATE NOCASE, "nmo:encoding:graph" INTEGER,
+"nmo:phoneMessageId" INTEGER, "nmo:phoneMessageId:graph" INTEGER,
+"nmo:validityPeriod" INTEGER, "nmo:validityPeriod:graph" INTEGER);
+CREATE TABLE "nmo:PhoneMessageFolder" (ID INTEGER NOT NULL PRIMARY
+KEY, "nmo:phoneMessageFolderId" TEXT COLLATE NOCASE,
+"nmo:phoneMessageFolderId:graph" INTEGER);
+CREATE TABLE "nmo:PhoneMessageFolder_nmo:containsPhoneMessage" (ID
+INTEGER NOT NULL, "nmo:containsPhoneMessage" INTEGER NOT NULL,
+"nmo:containsPhoneMessage:graph" INTEGER);
+CREATE TABLE "nmo:PhoneMessageFolder_nmo:containsPhoneMessageFolder"
+(ID INTEGER NOT NULL, "nmo:containsPhoneMessageFolder" INTEGER NOT
+NULL, "nmo:containsPhoneMessageFolder:graph" INTEGER);
+CREATE TABLE "nmo:PhoneMessage_nmo:toVCard" (ID INTEGER NOT NULL,
+"nmo:toVCard" INTEGER NOT NULL, "nmo:toVCard:graph" INTEGER);
+CREATE TABLE "nmo:ReportReadStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:SMSMessage" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:TransientChannel" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nmo:VOIPCall" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "nrl:InverseFunctionalProperty" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "osinfo:Installer" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "poi:ObjectOfInterest" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "rdf:Property" (ID INTEGER NOT NULL PRIMARY KEY,
+"rdfs:domain" INTEGER, "rdfs:domain:graph" INTEGER, "rdfs:range"
+INTEGER, "rdfs:range:graph" INTEGER, "tracker:indexed" INTEGER,
+"tracker:indexed:graph" INTEGER, "tracker:secondaryIndex" INTEGER,
+"tracker:secondaryIndex:graph" INTEGER, "tracker:fulltextIndexed"
+INTEGER, "tracker:fulltextIndexed:graph" INTEGER,
+"tracker:fulltextNoLimit" INTEGER, "tracker:fulltextNoLimit:graph"
+INTEGER, "tracker:transient" INTEGER, "tracker:transient:graph"
+INTEGER, "tracker:weight" INTEGER, "tracker:weight:graph" INTEGER,
+"tracker:defaultValue" TEXT COLLATE NOCASE,
+"tracker:defaultValue:graph" INTEGER, "nrl:maxCardinality" INTEGER,
+"nrl:maxCardinality:graph" INTEGER, "tracker:writeback" INTEGER,
+"tracker:writeback:graph" INTEGER, "tracker:forceJournal" INTEGER,
+"tracker:forceJournal:graph" INTEGER);
+CREATE TABLE "rdf:Property_rdfs:subPropertyOf" (ID INTEGER NOT NULL,
+"rdfs:subPropertyOf" INTEGER NOT NULL, "rdfs:subPropertyOf:graph"
+INTEGER);
+CREATE TABLE "rdfs:Class" (ID INTEGER NOT NULL PRIMARY KEY,
+"tracker:notify" INTEGER, "tracker:notify:graph" INTEGER);
+CREATE TABLE "rdfs:Class_rdfs:subClassOf" (ID INTEGER NOT NULL,
+"rdfs:subClassOf" INTEGER NOT NULL, "rdfs:subClassOf:graph" INTEGER);
+CREATE TABLE "rdfs:Class_tracker:domainIndex" (ID INTEGER NOT NULL,
+"tracker:domainIndex" INTEGER NOT NULL, "tracker:domainIndex:graph"
+INTEGER);
+CREATE TABLE "rdfs:Literal" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "rdfs:Resource" (ID INTEGER NOT NULL PRIMARY KEY,
+Available INTEGER NOT NULL, "rdfs:comment" TEXT COLLATE NOCASE,
+"rdfs:comment:graph" INTEGER, "rdfs:label" TEXT COLLATE NOCASE,
+"rdfs:label:graph" INTEGER, "tracker:added" INTEGER,
+"tracker:added:graph" INTEGER, "tracker:added:localDate" INTEGER,
+"tracker:added:localTime" INTEGER, "tracker:modified" INTEGER,
+"tracker:modified:graph" INTEGER, "tracker:damaged" INTEGER,
+"tracker:damaged:graph" INTEGER, "dc:title" TEXT COLLATE NOCASE,
+"dc:title:graph" INTEGER, "dc:creator" TEXT COLLATE NOCASE,
+"dc:creator:graph" INTEGER, "dc:subject" TEXT COLLATE NOCASE,
+"dc:subject:graph" INTEGER, "dc:description" TEXT COLLATE NOCASE,
+"dc:description:graph" INTEGER, "dc:publisher" TEXT COLLATE NOCASE,
+"dc:publisher:graph" INTEGER, "dc:type" TEXT COLLATE NOCASE,
+"dc:type:graph" INTEGER, "dc:format" TEXT COLLATE NOCASE,
+"dc:format:graph" INTEGER, "dc:identifier" TEXT COLLATE NOCASE,
+"dc:identifier:graph" INTEGER, "dc:language" TEXT COLLATE NOCASE,
+"dc:language:graph" INTEGER, "dc:coverage" TEXT COLLATE NOCASE,
+"dc:coverage:graph" INTEGER, "dc:rights" TEXT COLLATE NOCASE,
+"dc:rights:graph" INTEGER, "nao:identifier" TEXT COLLATE NOCASE,
+"nao:identifier:graph" INTEGER, "nao:numericRating" REAL,
+"nao:numericRating:graph" INTEGER, "nao:lastModified" INTEGER,
+"nao:lastModified:graph" INTEGER, "nao:lastModified:localDate"
+INTEGER, "nao:lastModified:localTime" INTEGER);
+CREATE TABLE "rdfs:Resource_dc:contributor" (ID INTEGER NOT NULL,
+"dc:contributor" TEXT NOT NULL, "dc:contributor:graph" INTEGER);
+CREATE TABLE "rdfs:Resource_dc:date" (ID INTEGER NOT NULL, "dc:date"
+INTEGER NOT NULL, "dc:date:graph" INTEGER, "dc:date:localDate" INTEGER
+NOT NULL, "dc:date:localTime" INTEGER NOT NULL);
+CREATE TABLE "rdfs:Resource_dc:relation" (ID INTEGER NOT NULL,
+"dc:relation" TEXT NOT NULL, "dc:relation:graph" INTEGER);
+CREATE TABLE "rdfs:Resource_dc:source" (ID INTEGER NOT NULL,
+"dc:source" INTEGER NOT NULL, "dc:source:graph" INTEGER);
+CREATE TABLE "rdfs:Resource_nao:deprecated" (ID INTEGER NOT NULL,
+"nao:deprecated" INTEGER NOT NULL, "nao:deprecated:graph" INTEGER);
+CREATE TABLE "rdfs:Resource_nao:hasTag" (ID INTEGER NOT NULL,
+"nao:hasTag" INTEGER NOT NULL, "nao:hasTag:graph" INTEGER);
+CREATE TABLE "rdfs:Resource_nao:isRelated" (ID INTEGER NOT NULL,
+"nao:isRelated" INTEGER NOT NULL, "nao:isRelated:graph" INTEGER);
+CREATE TABLE "rdfs:Resource_rdf:type" (ID INTEGER NOT NULL, "rdf:type"
+INTEGER NOT NULL, "rdf:type:graph" INTEGER);
+CREATE TABLE "scal:AccessLevel" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "scal:AttendanceStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "scal:Attendee" (ID INTEGER NOT NULL PRIMARY KEY,
+"scal:attendanceStatus" INTEGER, "scal:attendanceStatus:graph"
+INTEGER, "scal:attendeeRole" INTEGER, "scal:attendeeRole:graph"
+INTEGER, "scal:attendeeContact" INTEGER, "scal:attendeeContact:graph"
+INTEGER, "scal:rsvp" INTEGER, "scal:rsvp:graph" INTEGER,
+"scal:calendarUserType" INTEGER, "scal:calendarUserType:graph"
+INTEGER);
+CREATE TABLE "scal:AttendeeRole" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "scal:Attendee_scal:delegated-from" (ID INTEGER NOT NULL,
+"scal:delegated-from" INTEGER NOT NULL, "scal:delegated-from:graph"
+INTEGER);
+CREATE TABLE "scal:Attendee_scal:delegated-to" (ID INTEGER NOT NULL,
+"scal:delegated-to" INTEGER NOT NULL, "scal:delegated-to:graph"
+INTEGER);
+CREATE TABLE "scal:Attendee_scal:member" (ID INTEGER NOT NULL,
+"scal:member" INTEGER NOT NULL, "scal:member:graph" INTEGER);
+CREATE TABLE "scal:Attendee_scal:sent-by" (ID INTEGER NOT NULL,
+"scal:sent-by" INTEGER NOT NULL, "scal:sent-by:graph" INTEGER);
+CREATE TABLE "scal:Calendar" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "scal:CalendarAlarm" (ID INTEGER NOT NULL PRIMARY KEY,
+"scal:alarmOffset" INTEGER, "scal:alarmOffset:graph" INTEGER);
+CREATE TABLE "scal:CalendarAlarm_scal:alarmAttendee" (ID INTEGER NOT
+NULL, "scal:alarmAttendee" INTEGER NOT NULL,
+"scal:alarmAttendee:graph" INTEGER);
+CREATE TABLE "scal:CalendarItem" (ID INTEGER NOT NULL PRIMARY KEY,
+"scal:textLocation" INTEGER, "scal:textLocation:graph" INTEGER,
+"scal:resources" TEXT COLLATE NOCASE, "scal:resources:graph" INTEGER,
+"scal:transparency" INTEGER, "scal:transparency:graph" INTEGER,
+"scal:calendarItemAlarm" INTEGER, "scal:calendarItemAlarm:graph"
+INTEGER, "scal:start" INTEGER, "scal:start:graph" INTEGER, "scal:end"
+INTEGER, "scal:end:graph" INTEGER, "scal:isAllDay" INTEGER,
+"scal:isAllDay:graph" INTEGER, "scal:priority" INTEGER,
+"scal:priority:graph" INTEGER, "scal:rdate" INTEGER,
+"scal:rdate:graph" INTEGER, "scal:exceptionRDate" INTEGER,
+"scal:exceptionRDate:graph" INTEGER);
+CREATE TABLE "scal:CalendarItem_scal:access" (ID INTEGER NOT NULL,
+"scal:access" INTEGER NOT NULL, "scal:access:graph" INTEGER);
+CREATE TABLE "scal:CalendarItem_scal:attachment" (ID INTEGER NOT NULL,
+"scal:attachment" INTEGER NOT NULL, "scal:attachment:graph" INTEGER);
+CREATE TABLE "scal:CalendarItem_scal:attendee" (ID INTEGER NOT NULL,
+"scal:attendee" INTEGER NOT NULL, "scal:attendee:graph" INTEGER);
+CREATE TABLE "scal:CalendarItem_scal:belongsToCalendar" (ID INTEGER
+NOT NULL, "scal:belongsToCalendar" INTEGER NOT NULL,
+"scal:belongsToCalendar:graph" INTEGER);
+CREATE TABLE "scal:CalendarItem_scal:contact" (ID INTEGER NOT NULL,
+"scal:contact" INTEGER NOT NULL, "scal:contact:graph" INTEGER);
+CREATE TABLE "scal:CalendarItem_scal:rrule" (ID INTEGER NOT NULL,
+"scal:rrule" INTEGER NOT NULL, "scal:rrule:graph" INTEGER);
+CREATE TABLE "scal:CalendarUserType" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "scal:Event" (ID INTEGER NOT NULL PRIMARY KEY,
+"scal:eventStatus" INTEGER, "scal:eventStatus:graph" INTEGER);
+CREATE TABLE "scal:EventStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "scal:Journal" (ID INTEGER NOT NULL PRIMARY KEY,
+"scal:journalStatus" INTEGER, "scal:journalStatus:graph" INTEGER);
+CREATE TABLE "scal:JournalStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "scal:RSVPValues" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "scal:RecurrenceRule" (ID INTEGER NOT NULL PRIMARY KEY,
+"scal:recurrencePattern" TEXT COLLATE NOCASE,
+"scal:recurrencePattern:graph" INTEGER, "scal:recurrenceStartDate"
+INTEGER, "scal:recurrenceStartDate:graph" INTEGER, "scal:exception"
+INTEGER, "scal:exception:graph" INTEGER);
+CREATE TABLE "scal:TimePoint" (ID INTEGER NOT NULL PRIMARY KEY,
+"scal:dateTime" INTEGER, "scal:dateTime:graph" INTEGER,
+"scal:dateTime:localDate" INTEGER, "scal:dateTime:localTime" INTEGER,
+"scal:TimeZone" TEXT COLLATE NOCASE, "scal:TimeZone:graph" INTEGER);
+CREATE TABLE "scal:Todo" (ID INTEGER NOT NULL PRIMARY KEY,
+"scal:todoStatus" INTEGER, "scal:todoStatus:graph" INTEGER, "scal:due"
+INTEGER, "scal:due:graph" INTEGER, "scal:completed" INTEGER,
+"scal:completed:graph" INTEGER, "scal:percentComplete" INTEGER,
+"scal:percentComplete:graph" INTEGER);
+CREATE TABLE "scal:TodoStatus" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "scal:TransparencyValues" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "slo:GeoLocation" (ID INTEGER NOT NULL PRIMARY KEY,
+"slo:latitude" REAL, "slo:latitude:graph" INTEGER, "slo:longitude"
+REAL, "slo:longitude:graph" INTEGER, "slo:verticalAccuracy" REAL,
+"slo:verticalAccuracy:graph" INTEGER, "slo:horizontalAccuracy" REAL,
+"slo:horizontalAccuracy:graph" INTEGER, "slo:altitude" REAL,
+"slo:altitude:graph" INTEGER, "slo:boundingLatitudeMin" REAL,
+"slo:boundingLatitudeMin:graph" INTEGER, "slo:boundingLatitudeMax"
+REAL, "slo:boundingLatitudeMax:graph" INTEGER,
+"slo:boundingLongitudeMin" REAL, "slo:boundingLongitudeMin:graph"
+INTEGER, "slo:boundingLongitudeMax" REAL,
+"slo:boundingLongitudeMax:graph" INTEGER, "slo:radius" REAL,
+"slo:radius:graph" INTEGER, "slo:timestamp" INTEGER,
+"slo:timestamp:graph" INTEGER, "slo:timestamp:localDate" INTEGER,
+"slo:timestamp:localTime" INTEGER, "slo:postalAddress" INTEGER,
+"slo:postalAddress:graph" INTEGER);
+CREATE TABLE "slo:Landmark" (ID INTEGER NOT NULL PRIMARY KEY,
+"slo:iconUrl" INTEGER, "slo:iconUrl:graph" INTEGER);
+CREATE TABLE "slo:LandmarkCategory" (ID INTEGER NOT NULL PRIMARY KEY,
+"slo:isRemovable" INTEGER, "slo:isRemovable:graph" INTEGER,
+"slo:categoryIconUrl" INTEGER, "slo:categoryIconUrl:graph" INTEGER);
+CREATE TABLE "slo:Landmark_slo:belongsToCategory" (ID INTEGER NOT
+NULL, "slo:belongsToCategory" INTEGER NOT NULL,
+"slo:belongsToCategory:graph" INTEGER);
+CREATE TABLE "slo:Landmark_slo:hasContact" (ID INTEGER NOT NULL,
+"slo:hasContact" INTEGER NOT NULL, "slo:hasContact:graph" INTEGER);
+CREATE TABLE "slo:Route" (ID INTEGER NOT NULL PRIMARY KEY,
+"slo:startTime" INTEGER, "slo:startTime:graph" INTEGER,
+"slo:startTime:localDate" INTEGER, "slo:startTime:localTime" INTEGER,
+"slo:endTime" INTEGER, "slo:endTime:graph" INTEGER,
+"slo:endTime:localDate" INTEGER, "slo:endTime:localTime" INTEGER);
+CREATE TABLE "slo:Route_slo:routeDetails" (ID INTEGER NOT NULL,
+"slo:routeDetails" TEXT NOT NULL, "slo:routeDetails:graph" INTEGER);
+CREATE TABLE "tracker:Namespace" (ID INTEGER NOT NULL PRIMARY KEY,
+"tracker:prefix" TEXT COLLATE NOCASE, "tracker:prefix:graph"
+INTEGER);
+CREATE TABLE "tracker:Ontology" (ID INTEGER NOT NULL PRIMARY KEY);
+CREATE TABLE "tracker:Volume" (ID INTEGER NOT NULL PRIMARY KEY,
+"tracker:isMounted" INTEGER, "tracker:isMounted:graph" INTEGER,
+"tracker:unmountDate" INTEGER, "tracker:unmountDate:graph" INTEGER,
+"tracker:unmountDate:localDate" INTEGER,
+"tracker:unmountDate:localTime" INTEGER, "tracker:mountPoint" INTEGER,
+"tracker:mountPoint:graph" INTEGER, "tracker:isRemovable" INTEGER,
+"tracker:isRemovable:graph" INTEGER, "tracker:isOptical" INTEGER,
+"tracker:isOptical:graph" INTEGER);
+CREATE UNIQUE INDEX "mfo:FeedMessage_mfo:enclosureList_ID_ID" ON
+"mfo:FeedMessage_mfo:enclosureList" (ID, "mfo:enclosureList");
+CREATE UNIQUE INDEX "mlo:GeoBoundingBox_mlo:bbNorthWest_ID_ID" ON
+"mlo:GeoBoundingBox_mlo:bbNorthWest" (ID, "mlo:bbNorthWest");
+CREATE UNIQUE INDEX "mlo:GeoBoundingBox_mlo:bbSouthEast_ID_ID" ON
+"mlo:GeoBoundingBox_mlo:bbSouthEast" (ID, "mlo:bbSouthEast");
+CREATE INDEX "mlo:GeoLocation_mlo:asBoundingBox_ID" ON
+"mlo:GeoLocation_mlo:asBoundingBox" (ID);
+CREATE UNIQUE INDEX "mlo:GeoLocation_mlo:asBoundingBox_ID_ID" ON
+"mlo:GeoLocation_mlo:asBoundingBox" ("mlo:asBoundingBox", ID);
+CREATE INDEX "mlo:GeoLocation_mlo:asGeoPoint_ID" ON
+"mlo:GeoLocation_mlo:asGeoPoint" (ID);
+CREATE UNIQUE INDEX "mlo:GeoLocation_mlo:asGeoPoint_ID_ID" ON
+"mlo:GeoLocation_mlo:asGeoPoint" ("mlo:asGeoPoint", ID);
+CREATE INDEX "mlo:GeoLocation_mlo:asPostalAddress_ID" ON
+"mlo:GeoLocation_mlo:asPostalAddress" (ID);
+CREATE UNIQUE INDEX "mlo:GeoLocation_mlo:asPostalAddress_ID_ID" ON
+"mlo:GeoLocation_mlo:asPostalAddress" ("mlo:asPostalAddress", ID);
+CREATE UNIQUE INDEX "mlo:GeoPoint_mlo:address_ID_ID" ON
+"mlo:GeoPoint_mlo:address" (ID, "mlo:address");
+CREATE UNIQUE INDEX "mlo:GeoPoint_mlo:altitude_ID_ID" ON
+"mlo:GeoPoint_mlo:altitude" (ID, "mlo:altitude");
+CREATE UNIQUE INDEX "mlo:GeoPoint_mlo:city_ID_ID" ON
+"mlo:GeoPoint_mlo:city" (ID, "mlo:city");
+CREATE UNIQUE INDEX "mlo:GeoPoint_mlo:country_ID_ID" ON
+"mlo:GeoPoint_mlo:country" (ID, "mlo:country");
+CREATE UNIQUE INDEX "mlo:GeoPoint_mlo:latitude_ID_ID" ON
+"mlo:GeoPoint_mlo:latitude" (ID, "mlo:latitude");
+CREATE UNIQUE INDEX "mlo:GeoPoint_mlo:longitude_ID_ID" ON
+"mlo:GeoPoint_mlo:longitude" (ID, "mlo:longitude");
+CREATE UNIQUE INDEX "mlo:GeoPoint_mlo:state_ID_ID" ON
+"mlo:GeoPoint_mlo:state" (ID, "mlo:state");
+CREATE UNIQUE INDEX "mlo:GeoPoint_mlo:timestamp_ID_ID" ON
+"mlo:GeoPoint_mlo:timestamp" (ID, "mlo:timestamp");
+CREATE UNIQUE INDEX "mlo:GeoSphere_mlo:radius_ID_ID" ON
+"mlo:GeoSphere_mlo:radius" (ID, "mlo:radius");
+CREATE UNIQUE INDEX "mlo:LandmarkCategory_mlo:isRemovable_ID_ID" ON
+"mlo:LandmarkCategory_mlo:isRemovable" (ID, "mlo:isRemovable");
+CREATE UNIQUE INDEX "mlo:Landmark_mlo:belongsToCategory_ID_ID" ON
+"mlo:Landmark_mlo:belongsToCategory" (ID, "mlo:belongsToCategory");
+CREATE UNIQUE INDEX "mlo:Landmark_mlo:poiLocation_ID_ID" ON
+"mlo:Landmark_mlo:poiLocation" (ID, "mlo:poiLocation");
+CREATE UNIQUE INDEX "mlo:LocationBoundingBox_mlo:boxEastLimit_ID_ID"
+ON "mlo:LocationBoundingBox_mlo:boxEastLimit" (ID,
+"mlo:boxEastLimit");
+CREATE UNIQUE INDEX "mlo:LocationBoundingBox_mlo:boxNorthLimit_ID_ID"
+ON "mlo:LocationBoundingBox_mlo:boxNorthLimit" (ID,
+"mlo:boxNorthLimit");
+CREATE UNIQUE INDEX
+"mlo:LocationBoundingBox_mlo:boxSouthWestCorner_ID_ID" ON
+"mlo:LocationBoundingBox_mlo:boxSouthWestCorner" (ID,
+"mlo:boxSouthWestCorner");
+CREATE UNIQUE INDEX
+"mlo:LocationBoundingBox_mlo:boxVerticalLimit_ID_ID" ON
+"mlo:LocationBoundingBox_mlo:boxVerticalLimit" (ID,
+"mlo:boxVerticalLimit");
+CREATE UNIQUE INDEX "mlo:Route_mlo:endTime_ID_ID" ON
+"mlo:Route_mlo:endTime" (ID, "mlo:endTime");
+CREATE UNIQUE INDEX "mlo:Route_mlo:routeDetails_ID_ID" ON
+"mlo:Route_mlo:routeDetails" (ID, "mlo:routeDetails");
+CREATE UNIQUE INDEX "mlo:Route_mlo:startTime_ID_ID" ON
+"mlo:Route_mlo:startTime" (ID, "mlo:startTime");
+CREATE UNIQUE INDEX "mto:Transfer_mto:transferList_ID_ID" ON
+"mto:Transfer_mto:transferList" (ID, "mto:transferList");
+CREATE UNIQUE INDEX "mto:Transfer_mto:transferPrivacyLevel_ID_ID" ON
+"mto:Transfer_mto:transferPrivacyLevel" (ID,
+"mto:transferPrivacyLevel");
+CREATE UNIQUE INDEX "mto:UploadTransfer_mto:transferCategory_ID_ID" ON
+"mto:UploadTransfer_mto:transferCategory" (ID,
+"mto:transferCategory");
+CREATE UNIQUE INDEX "nao:Tag_tracker:isDefaultTag_ID_ID" ON
+"nao:Tag_tracker:isDefaultTag" (ID, "tracker:isDefaultTag");
+CREATE UNIQUE INDEX "nao:Tag_tracker:tagRelatedTo_ID_ID" ON
+"nao:Tag_tracker:tagRelatedTo" (ID, "tracker:tagRelatedTo");
+CREATE UNIQUE INDEX "ncal:Alarm_ncal:action_ID_ID" ON
+"ncal:Alarm_ncal:action" (ID, "ncal:action");
+CREATE UNIQUE INDEX "ncal:BydayRulePart_ncal:bydayModifier_ID_ID" ON
+"ncal:BydayRulePart_ncal:bydayModifier" (ID, "ncal:bydayModifier");
+CREATE UNIQUE INDEX "ncal:BydayRulePart_ncal:bydayWeekday_ID_ID" ON
+"ncal:BydayRulePart_ncal:bydayWeekday" (ID, "ncal:bydayWeekday");
+CREATE UNIQUE INDEX "ncal:Calendar_ncal:component_ID_ID" ON
+"ncal:Calendar_ncal:component" (ID, "ncal:component");
+CREATE UNIQUE INDEX "ncal:Freebusy_ncal:freebusy_ID_ID" ON
+"ncal:Freebusy_ncal:freebusy" (ID, "ncal:freebusy");
+CREATE UNIQUE INDEX "ncal:RecurrenceRule_ncal:byday_ID_ID" ON
+"ncal:RecurrenceRule_ncal:byday" (ID, "ncal:byday");
+CREATE UNIQUE INDEX "ncal:RecurrenceRule_ncal:byhour_ID_ID" ON
+"ncal:RecurrenceRule_ncal:byhour" (ID, "ncal:byhour");
+CREATE UNIQUE INDEX "ncal:RecurrenceRule_ncal:byminute_ID_ID" ON
+"ncal:RecurrenceRule_ncal:byminute" (ID, "ncal:byminute");
+CREATE UNIQUE INDEX "ncal:RecurrenceRule_ncal:bymonth_ID_ID" ON
+"ncal:RecurrenceRule_ncal:bymonth" (ID, "ncal:bymonth");
+CREATE UNIQUE INDEX "ncal:RecurrenceRule_ncal:bymonthday_ID_ID" ON
+"ncal:RecurrenceRule_ncal:bymonthday" (ID, "ncal:bymonthday");
+CREATE UNIQUE INDEX "ncal:RecurrenceRule_ncal:bysecond_ID_ID" ON
+"ncal:RecurrenceRule_ncal:bysecond" (ID, "ncal:bysecond");
+CREATE UNIQUE INDEX "ncal:RecurrenceRule_ncal:bysetpos_ID_ID" ON
+"ncal:RecurrenceRule_ncal:bysetpos" (ID, "ncal:bysetpos");
+CREATE UNIQUE INDEX "ncal:RecurrenceRule_ncal:byweekno_ID_ID" ON
+"ncal:RecurrenceRule_ncal:byweekno" (ID, "ncal:byweekno");
+CREATE UNIQUE INDEX "ncal:RecurrenceRule_ncal:byyearday_ID_ID" ON
+"ncal:RecurrenceRule_ncal:byyearday" (ID, "ncal:byyearday");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:attach_ID_ID" ON
+"ncal:UnionParentClass_ncal:attach" (ID, "ncal:attach");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:attendee_ID_ID" ON
+"ncal:UnionParentClass_ncal:attendee" (ID, "ncal:attendee");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:categories_ID_ID" ON
+"ncal:UnionParentClass_ncal:categories" (ID, "ncal:categories");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:exdate_ID_ID" ON
+"ncal:UnionParentClass_ncal:exdate" (ID, "ncal:exdate");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:exrule_ID_ID" ON
+"ncal:UnionParentClass_ncal:exrule" (ID, "ncal:exrule");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:hasAlarm_ID_ID" ON
+"ncal:UnionParentClass_ncal:hasAlarm" (ID, "ncal:hasAlarm");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:ncalRelation_ID_ID" ON
+"ncal:UnionParentClass_ncal:ncalRelation" (ID, "ncal:ncalRelation");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:rdate_ID_ID" ON
+"ncal:UnionParentClass_ncal:rdate" (ID, "ncal:rdate");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:relatedToChild_ID_ID"
+ON "ncal:UnionParentClass_ncal:relatedToChild" (ID,
+"ncal:relatedToChild");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:relatedToParent_ID_ID"
+ON "ncal:UnionParentClass_ncal:relatedToParent" (ID,
+"ncal:relatedToParent");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:resources_ID_ID" ON
+"ncal:UnionParentClass_ncal:resources" (ID, "ncal:resources");
+CREATE UNIQUE INDEX "ncal:UnionParentClass_ncal:rrule_ID_ID" ON
+"ncal:UnionParentClass_ncal:rrule" (ID, "ncal:rrule");
+CREATE UNIQUE INDEX "nco:Affiliation_nco:title_ID_ID" ON
+"nco:Affiliation_nco:title" (ID, "nco:title");
+CREATE UNIQUE INDEX "nco:ContactList_nco:containsContact_ID_ID" ON
+"nco:ContactList_nco:containsContact" (ID, "nco:containsContact");
+CREATE UNIQUE INDEX "nco:Contact_ncal:anniversary_ID_ID" ON
+"nco:Contact_ncal:anniversary" (ID, "ncal:anniversary");
+CREATE UNIQUE INDEX "nco:Contact_ncal:birthday_ID_ID" ON
+"nco:Contact_ncal:birthday" (ID, "ncal:birthday");
+CREATE UNIQUE INDEX "nco:Contact_nco:belongsToGroup_ID_ID" ON
+"nco:Contact_nco:belongsToGroup" (ID, "nco:belongsToGroup");
+CREATE UNIQUE INDEX "nco:Contact_nco:note_ID_ID" ON
+"nco:Contact_nco:note" (ID, "nco:note");
+CREATE UNIQUE INDEX "nco:Contact_scal:anniversary_ID_ID" ON
+"nco:Contact_scal:anniversary" (ID, "scal:anniversary");
+CREATE UNIQUE INDEX "nco:Contact_scal:birthday_ID_ID" ON
+"nco:Contact_scal:birthday" (ID, "scal:birthday");
+CREATE UNIQUE INDEX "nco:IMAccount_nco:hasIMContact_ID_ID" ON
+"nco:IMAccount_nco:hasIMContact" (ID, "nco:hasIMContact");
+CREATE UNIQUE INDEX "nco:IMAddress_nco:imCapability_ID_ID" ON
+"nco:IMAddress_nco:imCapability" (ID, "nco:imCapability");
+CREATE UNIQUE INDEX "nco:PersonContact_nco:hasAffiliation_ID_ID" ON
+"nco:PersonContact_nco:hasAffiliation" (ID, "nco:hasAffiliation");
+CREATE INDEX "nco:PersonContact_nco:nameFamily" ON "nco:PersonContact"
+("nco:nameFamily");
+CREATE INDEX "nco:PhoneNumber_nco:phoneNumber" ON "nco:PhoneNumber"
+("nco:phoneNumber");
+CREATE UNIQUE INDEX "nco:Role_nco:blogUrl_ID_ID" ON
+"nco:Role_nco:blogUrl" (ID, "nco:blogUrl");
+CREATE UNIQUE INDEX "nco:Role_nco:foafUrl_ID_ID" ON
+"nco:Role_nco:foafUrl" (ID, "nco:foafUrl");
+CREATE UNIQUE INDEX "nco:Role_nco:hasContactMedium_ID_ID" ON
+"nco:Role_nco:hasContactMedium" (ID, "nco:hasContactMedium");
+CREATE INDEX "nco:Role_nco:hasEmailAddress_ID" ON
+"nco:Role_nco:hasEmailAddress" (ID);
+CREATE UNIQUE INDEX "nco:Role_nco:hasEmailAddress_ID_ID" ON
+"nco:Role_nco:hasEmailAddress" ("nco:hasEmailAddress", ID);
+CREATE UNIQUE INDEX "nco:Role_nco:hasIMAddress_ID_ID" ON
+"nco:Role_nco:hasIMAddress" (ID, "nco:hasIMAddress");
+CREATE UNIQUE INDEX "nco:Role_nco:hasPhoneNumber_ID_ID" ON
+"nco:Role_nco:hasPhoneNumber" (ID, "nco:hasPhoneNumber");
+CREATE INDEX "nco:Role_nco:hasPostalAddress_ID" ON
+"nco:Role_nco:hasPostalAddress" (ID);
+CREATE UNIQUE INDEX "nco:Role_nco:hasPostalAddress_ID_ID" ON
+"nco:Role_nco:hasPostalAddress" ("nco:hasPostalAddress", ID);
+CREATE UNIQUE INDEX "nco:Role_nco:url_ID_ID" ON "nco:Role_nco:url"
+(ID, "nco:url");
+CREATE UNIQUE INDEX "nco:Role_nco:websiteUrl_ID_ID" ON
+"nco:Role_nco:websiteUrl" (ID, "nco:websiteUrl");
+CREATE UNIQUE INDEX
+"nfo:BookmarkFolder_nfo:containsBookmarkFolder_ID_ID" ON
+"nfo:BookmarkFolder_nfo:containsBookmarkFolder" (ID,
+"nfo:containsBookmarkFolder");
+CREATE UNIQUE INDEX "nfo:BookmarkFolder_nfo:containsBookmark_ID_ID" ON
+"nfo:BookmarkFolder_nfo:containsBookmark" (ID,
+"nfo:containsBookmark");
+CREATE INDEX "nfo:FileDataObject_nfo:fileLastModified" ON
+"nfo:FileDataObject" ("nfo:fileLastModified");
+CREATE UNIQUE INDEX "nfo:Image_nfo:depicts_ID_ID" ON
+"nfo:Image_nfo:depicts" (ID, "nfo:depicts");
+CREATE UNIQUE INDEX "nfo:Image_nfo:hasRegionOfInterest_ID_ID" ON
+"nfo:Image_nfo:hasRegionOfInterest" (ID, "nfo:hasRegionOfInterest");
+CREATE UNIQUE INDEX "nfo:MediaList_nfo:hasMediaFileListEntry_ID_ID" ON
+"nfo:MediaList_nfo:hasMediaFileListEntry" (ID,
+"nfo:hasMediaFileListEntry");
+CREATE UNIQUE INDEX "nfo:MediaList_nfo:mediaListEntry_ID_ID" ON
+"nfo:MediaList_nfo:mediaListEntry" (ID, "nfo:mediaListEntry");
+CREATE UNIQUE INDEX "nfo:Media_mtp:hidden_ID_ID" ON
+"nfo:Media_mtp:hidden" (ID, "mtp:hidden");
+CREATE UNIQUE INDEX "nfo:Media_nmm:alternativeMedia_ID_ID" ON
+"nfo:Media_nmm:alternativeMedia" (ID, "nmm:alternativeMedia");
+CREATE INDEX "nfo:Visual_nie:contentCreated" ON "nfo:Visual"
+("nie:contentCreated");
+CREATE UNIQUE INDEX "nid3:ID3Audio_nid3:leadArtist_ID_ID" ON
+"nid3:ID3Audio_nid3:leadArtist" (ID, "nid3:leadArtist");
+CREATE UNIQUE INDEX "nie:DataObject_nie:dataSource_ID_ID" ON
+"nie:DataObject_nie:dataSource" (ID, "nie:dataSource");
+CREATE UNIQUE INDEX "nie:DataObject_nie:isPartOf_ID_ID" ON
+"nie:DataObject_nie:isPartOf" (ID, "nie:isPartOf");
+CREATE INDEX "nie:DataObject_nie:url" ON "nie:DataObject" ("nie:url");
+CREATE INDEX "nie:InformationElement_mlo:location_ID" ON
+"nie:InformationElement_mlo:location" (ID);
+CREATE UNIQUE INDEX "nie:InformationElement_mlo:location_ID_ID" ON
+"nie:InformationElement_mlo:location" ("mlo:location", ID);
+CREATE UNIQUE INDEX "nie:InformationElement_nao:hasProperty_ID_ID" ON
+"nie:InformationElement_nao:hasProperty" (ID, "nao:hasProperty");
+CREATE UNIQUE INDEX "nie:InformationElement_nco:contributor_ID_ID" ON
+"nie:InformationElement_nco:contributor" (ID, "nco:contributor");
+CREATE UNIQUE INDEX "nie:InformationElement_nco:creator_ID_ID" ON
+"nie:InformationElement_nco:creator" (ID, "nco:creator");
+CREATE UNIQUE INDEX "nie:InformationElement_nie:hasLogicalPart_ID_ID"
+ON "nie:InformationElement_nie:hasLogicalPart" (ID,
+"nie:hasLogicalPart");
+CREATE UNIQUE INDEX "nie:InformationElement_nie:hasPart_ID_ID" ON
+"nie:InformationElement_nie:hasPart" (ID, "nie:hasPart");
+CREATE UNIQUE INDEX
+"nie:InformationElement_nie:informationElementDate_ID_ID" ON
+"nie:InformationElement_nie:informationElementDate" (ID,
+"nie:informationElementDate");
+CREATE UNIQUE INDEX "nie:InformationElement_nie:isLogicalPartOf_ID_ID"
+ON "nie:InformationElement_nie:isLogicalPartOf" (ID,
+"nie:isLogicalPartOf");
+CREATE UNIQUE INDEX "nie:InformationElement_nie:keyword_ID_ID" ON
+"nie:InformationElement_nie:keyword" (ID, "nie:keyword");
+CREATE UNIQUE INDEX "nie:InformationElement_nie:relatedTo_ID_ID" ON
+"nie:InformationElement_nie:relatedTo" (ID, "nie:relatedTo");
+CREATE INDEX "nie:InformationElement_slo:location" ON
+"nie:InformationElement" ("slo:location");
+CREATE INDEX "nmm:Artist_nmm:artistName" ON "nmm:Artist" ("nmm:artistName");
+CREATE INDEX "nmm:MusicAlbum_nie:title" ON "nmm:MusicAlbum" ("nie:title");
+CREATE UNIQUE INDEX "nmm:MusicAlbum_nmm:albumArtist_ID_ID" ON
+"nmm:MusicAlbum_nmm:albumArtist" (ID, "nmm:albumArtist");
+CREATE INDEX "nmm:MusicPiece_nie:title" ON "nmm:MusicPiece" ("nie:title");
+CREATE UNIQUE INDEX "nmm:MusicPiece_nmm:lyrics_ID_ID" ON
+"nmm:MusicPiece_nmm:lyrics" (ID, "nmm:lyrics");
+CREATE INDEX "nmm:MusicPiece_nmm:musicAlbum" ON "nmm:MusicPiece"
+("nmm:musicAlbum");
+CREATE INDEX "nmm:MusicPiece_nmm:performer" ON "nmm:MusicPiece"
+("nmm:performer");
+CREATE UNIQUE INDEX "nmm:RadioStation_nmm:carrier_ID_ID" ON
+"nmm:RadioStation_nmm:carrier" (ID, "nmm:carrier");
+CREATE UNIQUE INDEX "nmm:Video_mtp:scantype_ID_ID" ON
+"nmm:Video_mtp:scantype" (ID, "mtp:scantype");
+CREATE UNIQUE INDEX "nmm:Video_nmm:director_ID_ID" ON
+"nmm:Video_nmm:director" (ID, "nmm:director");
+CREATE UNIQUE INDEX "nmm:Video_nmm:leadActor_ID_ID" ON
+"nmm:Video_nmm:leadActor" (ID, "nmm:leadActor");
+CREATE UNIQUE INDEX "nmm:Video_nmm:subtitle_ID_ID" ON
+"nmm:Video_nmm:subtitle" (ID, "nmm:subtitle");
+CREATE INDEX "nmo:Call_nmo:sentDate" ON "nmo:Call" ("nmo:sentDate");
+CREATE INDEX "nmo:CommunicationChannel_nmo:hasParticipant_ID" ON
+"nmo:CommunicationChannel_nmo:hasParticipant" (ID);
+CREATE UNIQUE INDEX
+"nmo:CommunicationChannel_nmo:hasParticipant_ID_ID" ON
+"nmo:CommunicationChannel_nmo:hasParticipant" ("nmo:hasParticipant",
+ID);
+CREATE INDEX "nmo:CommunicationChannel_nmo:lastMessageDate" ON
+"nmo:CommunicationChannel" ("nmo:lastMessageDate");
+CREATE UNIQUE INDEX "nmo:Email_nmo:contentMimeType_ID_ID" ON
+"nmo:Email_nmo:contentMimeType" (ID, "nmo:contentMimeType");
+CREATE UNIQUE INDEX "nmo:Message_nmo:bcc_ID_ID" ON
+"nmo:Message_nmo:bcc" (ID, "nmo:bcc");
+CREATE UNIQUE INDEX "nmo:Message_nmo:cc_ID_ID" ON "nmo:Message_nmo:cc"
+(ID, "nmo:cc");
+CREATE INDEX "nmo:Message_nmo:communicationChannel" ON "nmo:Message"
+("nmo:communicationChannel", "nmo:receivedDate");
+CREATE INDEX "nmo:Message_nmo:conversation" ON "nmo:Message"
+("nmo:conversation");
+CREATE INDEX "nmo:Message_nmo:from" ON "nmo:Message" ("nmo:from");
+CREATE UNIQUE INDEX "nmo:Message_nmo:hasAttachment_ID_ID" ON
+"nmo:Message_nmo:hasAttachment" (ID, "nmo:hasAttachment");
+CREATE UNIQUE INDEX "nmo:Message_nmo:inReplyTo_ID_ID" ON
+"nmo:Message_nmo:inReplyTo" (ID, "nmo:inReplyTo");
+CREATE UNIQUE INDEX "nmo:Message_nmo:messageHeader_ID_ID" ON
+"nmo:Message_nmo:messageHeader" (ID, "nmo:messageHeader");
+CREATE UNIQUE INDEX "nmo:Message_nmo:recipient_ID_ID" ON
+"nmo:Message_nmo:recipient" (ID, "nmo:recipient");
+CREATE UNIQUE INDEX "nmo:Message_nmo:references_ID_ID" ON
+"nmo:Message_nmo:references" (ID, "nmo:references");
+CREATE INDEX "nmo:Message_nmo:sender" ON "nmo:Message" ("nmo:sender");
+CREATE INDEX "nmo:Message_nmo:sentDate" ON "nmo:Message" ("nmo:sentDate");
+CREATE INDEX "nmo:Message_nmo:to_ID" ON "nmo:Message_nmo:to" (ID);
+CREATE UNIQUE INDEX "nmo:Message_nmo:to_ID_ID" ON "nmo:Message_nmo:to"
+("nmo:to", ID);
+CREATE UNIQUE INDEX "nmo:MimePart_nmo:mimeHeader_ID_ID" ON
+"nmo:MimePart_nmo:mimeHeader" (ID, "nmo:mimeHeader");
+CREATE UNIQUE INDEX "nmo:Multipart_nmo:partBoundary_ID_ID" ON
+"nmo:Multipart_nmo:partBoundary" (ID, "nmo:partBoundary");
+CREATE UNIQUE INDEX
+"nmo:PhoneMessageFolder_nmo:containsPhoneMessageFolder_ID_ID" ON
+"nmo:PhoneMessageFolder_nmo:containsPhoneMessageFolder" (ID,
+"nmo:containsPhoneMessageFolder");
+CREATE UNIQUE INDEX
+"nmo:PhoneMessageFolder_nmo:containsPhoneMessage_ID_ID" ON
+"nmo:PhoneMessageFolder_nmo:containsPhoneMessage" (ID,
+"nmo:containsPhoneMessage");
+CREATE UNIQUE INDEX "nmo:PhoneMessage_nmo:toVCard_ID_ID" ON
+"nmo:PhoneMessage_nmo:toVCard" (ID, "nmo:toVCard");
+CREATE UNIQUE INDEX "rdf:Property_rdfs:subPropertyOf_ID_ID" ON
+"rdf:Property_rdfs:subPropertyOf" (ID, "rdfs:subPropertyOf");
+CREATE UNIQUE INDEX "rdfs:Class_rdfs:subClassOf_ID_ID" ON
+"rdfs:Class_rdfs:subClassOf" (ID, "rdfs:subClassOf");
+CREATE UNIQUE INDEX "rdfs:Class_tracker:domainIndex_ID_ID" ON
+"rdfs:Class_tracker:domainIndex" (ID, "tracker:domainIndex");
+CREATE UNIQUE INDEX "rdfs:Resource_dc:contributor_ID_ID" ON
+"rdfs:Resource_dc:contributor" (ID, "dc:contributor");
+CREATE UNIQUE INDEX "rdfs:Resource_dc:date_ID_ID" ON
+"rdfs:Resource_dc:date" (ID, "dc:date");
+CREATE UNIQUE INDEX "rdfs:Resource_dc:relation_ID_ID" ON
+"rdfs:Resource_dc:relation" (ID, "dc:relation");
+CREATE UNIQUE INDEX "rdfs:Resource_dc:source_ID_ID" ON
+"rdfs:Resource_dc:source" (ID, "dc:source");
+CREATE UNIQUE INDEX "rdfs:Resource_nao:deprecated_ID_ID" ON
+"rdfs:Resource_nao:deprecated" (ID, "nao:deprecated");
+CREATE INDEX "rdfs:Resource_nao:hasTag_ID" ON "rdfs:Resource_nao:hasTag" (ID);
+CREATE UNIQUE INDEX "rdfs:Resource_nao:hasTag_ID_ID" ON
+"rdfs:Resource_nao:hasTag" ("nao:hasTag", ID);
+CREATE UNIQUE INDEX "rdfs:Resource_nao:isRelated_ID_ID" ON
+"rdfs:Resource_nao:isRelated" (ID, "nao:isRelated");
+CREATE UNIQUE INDEX "rdfs:Resource_rdf:type_ID_ID" ON
+"rdfs:Resource_rdf:type" (ID, "rdf:type");
+CREATE INDEX "rdfs:Resource_tracker:added" ON "rdfs:Resource" ("tracker:added");
+CREATE UNIQUE INDEX "scal:Attendee_scal:delegated-from_ID_ID" ON
+"scal:Attendee_scal:delegated-from" (ID, "scal:delegated-from");
+CREATE UNIQUE INDEX "scal:Attendee_scal:delegated-to_ID_ID" ON
+"scal:Attendee_scal:delegated-to" (ID, "scal:delegated-to");
+CREATE UNIQUE INDEX "scal:Attendee_scal:member_ID_ID" ON
+"scal:Attendee_scal:member" (ID, "scal:member");
+CREATE UNIQUE INDEX "scal:Attendee_scal:sent-by_ID_ID" ON
+"scal:Attendee_scal:sent-by" (ID, "scal:sent-by");
+CREATE UNIQUE INDEX "scal:CalendarAlarm_scal:alarmAttendee_ID_ID" ON
+"scal:CalendarAlarm_scal:alarmAttendee" (ID, "scal:alarmAttendee");
+CREATE UNIQUE INDEX "scal:CalendarItem_scal:access_ID_ID" ON
+"scal:CalendarItem_scal:access" (ID, "scal:access");
+CREATE UNIQUE INDEX "scal:CalendarItem_scal:attachment_ID_ID" ON
+"scal:CalendarItem_scal:attachment" (ID, "scal:attachment");
+CREATE UNIQUE INDEX "scal:CalendarItem_scal:attendee_ID_ID" ON
+"scal:CalendarItem_scal:attendee" (ID, "scal:attendee");
+CREATE UNIQUE INDEX "scal:CalendarItem_scal:belongsToCalendar_ID_ID"
+ON "scal:CalendarItem_scal:belongsToCalendar" (ID,
+"scal:belongsToCalendar");
+CREATE UNIQUE INDEX "scal:CalendarItem_scal:contact_ID_ID" ON
+"scal:CalendarItem_scal:contact" (ID, "scal:contact");
+CREATE UNIQUE INDEX "scal:CalendarItem_scal:rrule_ID_ID" ON
+"scal:CalendarItem_scal:rrule" (ID, "scal:rrule");
+CREATE INDEX "slo:GeoLocation_slo:postalAddress" ON "slo:GeoLocation"
+("slo:postalAddress");
+CREATE UNIQUE INDEX "slo:Landmark_slo:belongsToCategory_ID_ID" ON
+"slo:Landmark_slo:belongsToCategory" (ID, "slo:belongsToCategory");
+CREATE UNIQUE INDEX "slo:Landmark_slo:hasContact_ID_ID" ON
+"slo:Landmark_slo:hasContact" (ID, "slo:hasContact");
+CREATE UNIQUE INDEX "slo:Route_slo:routeDetails_ID_ID" ON
+"slo:Route_slo:routeDetails" (ID, "slo:routeDetails");
+
+EXPLAIN SELECT "1_u", (SELECT "nco:fullname" FROM "nco:Contact" WHERE
+ID = "1_u") COLLATE NOCASE, (SELECT "nco:nameFamily" FROM
+"nco:PersonContact" WHERE ID = "1_u") COLLATE NOCASE, (SELECT
+"nco:nameGiven" FROM "nco:PersonContact" WHERE ID = "1_u")
+COLLATE NOCASE, (SELECT "nco:nameAdditional" FROM
+"nco:PersonContact" WHERE ID = "1_u") COLLATE NOCASE, (SELECT
+"nco:nameHonorificPrefix" FROM "nco:PersonContact" WHERE ID =
+"1_u") COLLATE NOCASE, (SELECT "nco:nameHonorificSuffix" FROM
+"nco:PersonContact" WHERE ID = "1_u") COLLATE NOCASE, (SELECT
+"nco:nickname" FROM "nco:Contact" WHERE ID = "1_u") COLLATE
+NOCASE, strftime("%s",(SELECT "nco:birthDate" FROM
+"nco:Contact" WHERE ID = "1_u")), (SELECT "nie:url" FROM
+"nie:DataObject" WHERE ID = (SELECT "nco:photo" FROM
+"nco:Contact" WHERE ID = "1_u")) COLLATE NOCASE, (SELECT
+GROUP_CONCAT("2_u"||? COLLATE NOCASE||COALESCE((SELECT
+"nco:imProtocol" FROM "nco:IMAddress" WHERE ID = "3_u") COLLATE
+NOCASE, ? COLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT
+"nco:imID" FROM "nco:IMAddress" WHERE ID = "3_u") COLLATE
+NOCASE, ? COLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT
+"nco:imNickname" FROM "nco:IMAddress" WHERE ID = "3_u") COLLATE
+NOCASE, ? COLLATE NOCASE), '\n') FROM (SELECT
+"nco:PersonContact_nco:hasAffiliation2"."nco:hasAffiliation" AS
+"2_u", "nco:Role_nco:hasIMAddress3"."nco:hasIMAddress" AS
+"3_u" FROM "nco:PersonContact_nco:hasAffiliation" AS
+"nco:PersonContact_nco:hasAffiliation2",
+"nco:Role_nco:hasIMAddress" AS "nco:Role_nco:hasIMAddress3" WHERE
+"1_u" = "nco:PersonContact_nco:hasAffiliation2"."ID" AND
+"nco:PersonContact_nco:hasAffiliation2"."nco:hasAffiliation" =
+"nco:Role_nco:hasIMAddress3"."ID")), (SELECT
+GROUP_CONCAT("2_u"||? COLLATE NOCASE||(SELECT "nco:phoneNumber"
+FROM "nco:PhoneNumber" WHERE ID = "4_u") COLLATE NOCASE, '\n')
+FROM (SELECT "nco:PersonContact_nco:hasAffiliation4"."nco:hasAffiliation"
+AS "2_u", "nco:Role_nco:hasPhoneNumber5"."nco:hasPhoneNumber" AS
+"4_u" FROM "nco:PersonContact_nco:hasAffiliation" AS
+"nco:PersonContact_nco:hasAffiliation4",
+"nco:Role_nco:hasPhoneNumber" AS "nco:Role_nco:hasPhoneNumber5"
+WHERE "1_u" = "nco:PersonContact_nco:hasAffiliation4"."ID" AND
+"nco:PersonContact_nco:hasAffiliation4"."nco:hasAffiliation" =
+"nco:Role_nco:hasPhoneNumber5"."ID")), (SELECT
+GROUP_CONCAT("2_u"||? COLLATE NOCASE||(SELECT "nco:emailAddress"
+FROM "nco:EmailAddress" WHERE ID = "5_u") COLLATE NOCASE, ',')
+FROM (SELECT "nco:PersonContact_nco:hasAffiliation6"."nco:hasAffiliation"
+AS "2_u", "nco:Role_nco:hasEmailAddress7"."nco:hasEmailAddress"
+AS "5_u" FROM "nco:PersonContact_nco:hasAffiliation" AS
+"nco:PersonContact_nco:hasAffiliation6",
+"nco:Role_nco:hasEmailAddress" AS "nco:Role_nco:hasEmailAddress7"
+WHERE "1_u" = "nco:PersonContact_nco:hasAffiliation6"."ID" AND
+"nco:PersonContact_nco:hasAffiliation6"."nco:hasAffiliation" =
+"nco:Role_nco:hasEmailAddress7"."ID")), (SELECT
+GROUP_CONCAT("2_u"||? COLLATE NOCASE||COALESCE((SELECT
+GROUP_CONCAT((SELECT Uri FROM Resource WHERE ID =
+"nco:blogUrl"),',') FROM "nco:Role_nco:blogUrl" WHERE ID =
+"2_u"), ? COLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT
+GROUP_CONCAT((SELECT Uri FROM Resource WHERE ID =
+"nco:websiteUrl"),',') FROM "nco:Role_nco:websiteUrl" WHERE ID =
+"2_u"), ? COLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT
+GROUP_CONCAT((SELECT Uri FROM Resource WHERE ID = "nco:url"),',')
+FROM "nco:Role_nco:url" WHERE ID = "2_u"), ? COLLATE NOCASE),
+'\n') FROM (SELECT
+"nco:PersonContact_nco:hasAffiliation8"."nco:hasAffiliation" AS
+"2_u" FROM "nco:PersonContact_nco:hasAffiliation" AS
+"nco:PersonContact_nco:hasAffiliation8" WHERE "1_u" =
+"nco:PersonContact_nco:hasAffiliation8"."ID")), (SELECT
+GROUP_CONCAT("6_u", ',') FROM (SELECT
+"rdfs:Resource_nao:hasTag9"."nao:hasTag" AS "6_u" FROM
+"rdfs:Resource_nao:hasTag" AS "rdfs:Resource_nao:hasTag9" WHERE
+"1_u" = "rdfs:Resource_nao:hasTag9"."ID")), (SELECT Uri FROM
+Resource WHERE ID = "1_u"), (SELECT GROUP_CONCAT("2_u"||? COLLATE
+NOCASE||COALESCE((SELECT "nco:role" FROM "nco:Affiliation" WHERE
+ID = "2_u") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE
+NOCASE||COALESCE((SELECT "nco:department" FROM "nco:Affiliation"
+WHERE ID = "2_u") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE
+NOCASE||COALESCE((SELECT GROUP_CONCAT("nco:title",',') FROM
+"nco:Affiliation_nco:title" WHERE ID = "2_u"), ? COLLATE NOCASE),
+'\n') FROM (SELECT
+"nco:PersonContact_nco:hasAffiliation10"."nco:hasAffiliation" AS
+"2_u" FROM "nco:PersonContact_nco:hasAffiliation" AS
+"nco:PersonContact_nco:hasAffiliation10" WHERE "1_u" =
+"nco:PersonContact_nco:hasAffiliation10"."ID")), (SELECT
+GROUP_CONCAT("nco:note",',') FROM "nco:Contact_nco:note" WHERE ID
+= "1_u"), (SELECT "nco:gender" FROM "nco:PersonContact" WHERE ID
+= "1_u"), (SELECT GROUP_CONCAT("2_u"||? COLLATE
+NOCASE||COALESCE((SELECT "nco:pobox" FROM "nco:PostalAddress"
+WHERE ID = "7_u") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE
+NOCASE||COALESCE((SELECT "nco:district" FROM "nco:PostalAddress"
+WHERE ID = "7_u") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE
+NOCASE||COALESCE((SELECT "nco:county" FROM "nco:PostalAddress"
+WHERE ID = "7_u") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE
+NOCASE||COALESCE((SELECT "nco:locality" FROM "nco:PostalAddress"
+WHERE ID = "7_u") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE
+NOCASE||COALESCE((SELECT "nco:postalcode" FROM
+"nco:PostalAddress" WHERE ID = "7_u") COLLATE NOCASE, ? COLLATE
+NOCASE)||? COLLATE NOCASE||COALESCE((SELECT "nco:streetAddress"
+FROM "nco:PostalAddress" WHERE ID = "7_u") COLLATE NOCASE, ?
+COLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT Uri FROM
+Resource WHERE ID = (SELECT "nco:addressLocation" FROM
+"nco:PostalAddress" WHERE ID = "7_u")), ? COLLATE NOCASE)||?
+COLLATE NOCASE||COALESCE((SELECT "nco:extendedAddress" FROM
+"nco:PostalAddress" WHERE ID = "7_u") COLLATE NOCASE, ? COLLATE
+NOCASE)||? COLLATE NOCASE||COALESCE((SELECT "nco:country" FROM
+"nco:PostalAddress" WHERE ID = "7_u") COLLATE NOCASE, ? COLLATE
+NOCASE)||? COLLATE NOCASE||COALESCE((SELECT "nco:region" FROM
+"nco:PostalAddress" WHERE ID = "7_u") COLLATE NOCASE, ? COLLATE
+NOCASE), '\n') FROM (SELECT
+"nco:PersonContact_nco:hasAffiliation11"."nco:hasAffiliation" AS
+"2_u", "nco:Role_nco:hasPostalAddress12"."nco:hasPostalAddress"
+AS "7_u" FROM "nco:PersonContact_nco:hasAffiliation" AS
+"nco:PersonContact_nco:hasAffiliation11",
+"nco:Role_nco:hasPostalAddress" AS
+"nco:Role_nco:hasPostalAddress12" WHERE "1_u" =
+"nco:PersonContact_nco:hasAffiliation11"."ID" AND
+"nco:PersonContact_nco:hasAffiliation11"."nco:hasAffiliation" =
+"nco:Role_nco:hasPostalAddress12"."ID")), (SELECT
+GROUP_CONCAT("10_u" COLLATE NOCASE, ',') FROM (SELECT
+"nie:InformationElement_nao:hasProperty13"."nao:hasProperty" AS
+"8_u", "nao:Property14"."nao:propertyName" AS "9_u",
+"nao:Property14"."nao:propertyValue" AS "10_u" FROM
+"nie:InformationElement_nao:hasProperty" AS
+"nie:InformationElement_nao:hasProperty13", "nao:Property" AS
+"nao:Property14" WHERE "1_u" =
+"nie:InformationElement_nao:hasProperty13"."ID" AND
+"nie:InformationElement_nao:hasProperty13"."nao:hasProperty" =
+"nao:Property14"."ID" AND "9_u" IS NOT NULL AND "10_u" IS NOT
+NULL AND ("9_u" COLLATE NOCASE = ? COLLATE NOCASE))) FROM (SELECT
+"nco:PersonContact1"."ID" AS "1_u" FROM "nco:PersonContact" AS
+"nco:PersonContact1") ORDER BY "1_u";
+ }
+} {/.* Goto .*/}
+
+# Crash reported by OSS-FUZZ on 2016-11-10
+do_catchsql_test fuzz-oss1-detach {
+ DETACH x IS #1;
+} {1 {near "#1": syntax error}}
+
+finish_test
diff --git a/test/fuzz.test b/test/fuzz.test
new file mode 100644
index 0000000..83dc79b
--- /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 {{}}}
+
+# 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 view 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..51dfce1
--- /dev/null
+++ b/test/fuzz2.test
@@ -0,0 +1,139 @@
+# 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.
+#
+
+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}
+
+# Test cases discovered by Michal Zalewski on 2015-01-03 and reported on the
+# sqlite-users mailing list. All of these cases cause segfaults in
+# SQLite 3.8.7.4 and earlier.
+#
+do_test fuzz2-6.1 {
+ catchsql {SELECT n()AND+#0;}
+} {1 {near "#0": syntax error}}
+do_test fuzz2-6.2 {
+ catchsql {SELECT strftime()}
+} {0 {{}}}
+do_test fuzz2-6.3 {
+ catchsql {DETACH(SELECT group_concat(q));}
+} {1 {no such column: q}}
+do_test fuzz2-6.4a {
+ db eval {DROP TABLE IF EXISTS t0; CREATE TABLE t0(t);}
+ catchsql {INSERT INTO t0 SELECT strftime();}
+} {0 {}}
+do_test fuzz2-6.4b {
+ db eval {SELECT quote(t) FROM t0}
+} {NULL}
+
+# Another test case discovered by Michal Zalewski, this on on 2015-01-22.
+# Ticket 32b63d542433ca6757cd695aca42addf8ed67aa6
+#
+do_test fuzz2-7.1 {
+ catchsql {select e.*,0 from(s,(L))e;}
+} {1 {no such table: s}}
+do_test fuzz2-7.2 {
+ catchsql {SELECT c.* FROM (a,b) AS c}
+} {1 {no such table: a}}
+
+
+finish_test
diff --git a/test/fuzz3.test b/test/fuzz3.test
new file mode 100644
index 0000000..bf778ed
--- /dev/null
+++ b/test/fuzz3.test
@@ -0,0 +1,175 @@
+# 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
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+test_set_config_pagecache 0 0
+
+
+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 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
+}
+
+test_restore_config_pagecache
+finish_test
diff --git a/test/fuzz4.test b/test/fuzz4.test
new file mode 100644
index 0000000..821cd16
--- /dev/null
+++ b/test/fuzz4.test
@@ -0,0 +1,82 @@
+# 2018-12-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.
+#
+#***********************************************************************
+#
+# Test cases found by Matthew Denton's fuzzer at Chrome.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test fuzz4-100 {
+ CREATE TABLE Table0 (Col0 NOT NULL DEFAULT (CURRENT_TIME IS 1 > 1));
+ INSERT OR REPLACE INTO Table0 DEFAULT VALUES ;
+ SELECT * FROM Table0;
+} {0}
+
+do_execsql_test fuzz4-110 {
+ CREATE TABLE Table1(
+ Col0 TEXT DEFAULT (CASE WHEN 1 IS 3530822107858468864
+ THEN 1 ELSE quote(1) IS 3530822107858468864 END)
+ );
+ INSERT INTO Table1 DEFAULT VALUES;
+ SELECT * FROM Table1;
+} {0}
+
+do_execsql_test fuzz4-200 {
+ CREATE TABLE Table2a(
+ Col0 NOT NULL DEFAULT (CURRENT_TIME IS 1 IS NOT 1 > 1)
+ );
+ INSERT OR REPLACE INTO Table2a DEFAULT VALUES;
+ SELECT * FROM Table2a;
+} {0}
+
+do_execsql_test fuzz4-210 {
+ CREATE TABLE Table2b (Col0 NOT NULL DEFAULT (CURRENT_TIME IS NOT FALSE)) ;
+ INSERT OR REPLACE INTO Table2b DEFAULT VALUES ;
+ SELECT * FROM Table2b;
+} {1}
+
+do_execsql_test fuzz4-300 {
+ CREATE TABLE Table3 (Col0 DEFAULT (CURRENT_TIMESTAMP BETWEEN 1 AND 1));
+ INSERT INTO Table3 DEFAULT VALUES;
+ SELECT * FROM Table3;
+} {0}
+
+do_execsql_test fuzz4-400 {
+ CREATE TABLE Table4 (Col0 DEFAULT (1 BETWEEN CURRENT_TIMESTAMP AND 1));
+ INSERT INTO Table4 DEFAULT VALUES;
+ SELECT * FROM Table4;
+} {0}
+
+do_execsql_test fuzz4-500 {
+ CREATE TABLE Table5 (Col0 DEFAULT (1 BETWEEN 1 AND CURRENT_TIMESTAMP));
+ INSERT INTO Table5 DEFAULT VALUES;
+ SELECT * FROM Table5;
+} {1}
+
+do_execsql_test fuzz4-600 {
+ CREATE TEMPORARY TABLE Table6(
+ Col0 DEFAULT (CASE x'5d' WHEN 1 THEN
+ CASE CURRENT_TIMESTAMP WHEN 1 THEN 1 ELSE 1 END
+ ELSE CASE WHEN 1 THEN FALSE END END )
+ );
+ INSERT INTO temp.Table6 DEFAULT VALUES ;
+ SELECT * FROM Table6;
+} {0}
+do_execsql_test fuzz4-610 {
+ WITH TableX AS (SELECT DISTINCT * ORDER BY 1 , 1 COLLATE RTRIM)
+ DELETE FROM Table6 WHERE Col0 || +8388608 ;
+ SELECT * FROM Table6;
+} {}
+
+
+finish_test
diff --git a/test/fuzz_common.tcl b/test/fuzz_common.tcl
new file mode 100644
index 0000000..520555b
--- /dev/null
+++ b/test/fuzz_common.tcl
@@ -0,0 +1,392 @@
+# 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}
+ lappend ::fuzzyopts(-errorlist) {non-deterministic functions prohibited}
+
+ 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..4449ea8
--- /dev/null
+++ b/test/fuzz_malloc.test
@@ -0,0 +1,100 @@
+#
+# 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
+
+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 ::fmtres} [catchsql "$::sql"] {}
+ if {$rc==0} {
+ set nErr1 [set_test_counter errors]
+ do_faultsim_test $testname-$ii -faults oom* -body {
+ execsql $::sql
+ } -test {
+ if {$testrc && $testresult!="datatype mismatch"} {
+ faultsim_test_result {0 {}}
+ }
+ }
+ if {[set_test_counter errors]>$nErr1} {
+ puts "Previous fuzzy-sql=\[$::sql\]"
+ flush stdout
+ }
+ } 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/fuzzcheck.c b/test/fuzzcheck.c
new file mode 100644
index 0000000..a0bcc3b
--- /dev/null
+++ b/test/fuzzcheck.c
@@ -0,0 +1,2471 @@
+/*
+** 2015-05-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 is a utility program designed to aid running regressions tests on
+** the SQLite library using data from external fuzzers.
+**
+** This program reads content from an SQLite database file with the following
+** schema:
+**
+** CREATE TABLE db(
+** dbid INTEGER PRIMARY KEY, -- database id
+** dbcontent BLOB -- database disk file image
+** );
+** CREATE TABLE xsql(
+** sqlid INTEGER PRIMARY KEY, -- SQL script id
+** sqltext TEXT -- Text of SQL statements to run
+** );
+** CREATE TABLE IF NOT EXISTS readme(
+** msg TEXT -- Human-readable description of this test collection
+** );
+**
+** For each database file in the DB table, the SQL text in the XSQL table
+** is run against that database. All README.MSG values are printed prior
+** to the start of the test (unless the --quiet option is used). If the
+** DB table is empty, then all entries in XSQL are run against an empty
+** in-memory database.
+**
+** This program is looking for crashes, assertion faults, and/or memory leaks.
+** No attempt is made to verify the output. The assumption is that either all
+** of the database files or all of the SQL statements are malformed inputs,
+** generated by a fuzzer, that need to be checked to make sure they do not
+** present a security risk.
+**
+** This program also includes some command-line options to help with
+** creation and maintenance of the source content database. The command
+**
+** ./fuzzcheck database.db --load-sql FILE...
+**
+** Loads all FILE... arguments into the XSQL table. The --load-db option
+** works the same but loads the files into the DB table. The -m option can
+** be used to initialize the README table. The "database.db" file is created
+** if it does not previously exist. Example:
+**
+** ./fuzzcheck new.db --load-sql *.sql
+** ./fuzzcheck new.db --load-db *.db
+** ./fuzzcheck new.db -m 'New test cases'
+**
+** The three commands above will create the "new.db" file and initialize all
+** tables. Then do "./fuzzcheck new.db" to run the tests.
+**
+** DEBUGGING HINTS:
+**
+** If fuzzcheck does crash, it can be run in the debugger and the content
+** of the global variable g.zTextName[] will identify the specific XSQL and
+** DB values that were running when the crash occurred.
+**
+** DBSQLFUZZ: (Added 2020-02-25)
+**
+** The dbsqlfuzz fuzzer includes both a database file and SQL to run against
+** that database in its input. This utility can now process dbsqlfuzz
+** input files. Load such files using the "--load-dbsql FILE ..." command-line
+** option.
+**
+** Dbsqlfuzz inputs are ordinary text. The first part of the file is text
+** that describes the content of the database (using a lot of hexadecimal),
+** then there is a divider line followed by the SQL to run against the
+** database. Because they are ordinary text, dbsqlfuzz inputs are stored
+** in the XSQL table, as if they were ordinary SQL inputs. The isDbSql()
+** function can look at a text string and determine whether or not it is
+** a valid dbsqlfuzz input.
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <assert.h>
+#include "sqlite3.h"
+#include "sqlite3recover.h"
+#define ISSPACE(X) isspace((unsigned char)(X))
+#define ISDIGIT(X) isdigit((unsigned char)(X))
+
+
+#ifdef __unix__
+# include <signal.h>
+# include <unistd.h>
+#endif
+
+#include <stddef.h>
+#if !defined(_MSC_VER)
+# include <stdint.h>
+#endif
+
+#if defined(_MSC_VER)
+typedef unsigned char uint8_t;
+#endif
+
+/*
+** Files in the virtual file system.
+*/
+typedef struct VFile VFile;
+struct VFile {
+ char *zFilename; /* Filename. NULL for delete-on-close. From malloc() */
+ int sz; /* Size of the file in bytes */
+ int nRef; /* Number of references to this file */
+ unsigned char *a; /* Content of the file. From malloc() */
+};
+typedef struct VHandle VHandle;
+struct VHandle {
+ sqlite3_file base; /* Base class. Must be first */
+ VFile *pVFile; /* The underlying file */
+};
+
+/*
+** The value of a database file template, or of an SQL script
+*/
+typedef struct Blob Blob;
+struct Blob {
+ Blob *pNext; /* Next in a list */
+ int id; /* Id of this Blob */
+ int seq; /* Sequence number */
+ int sz; /* Size of this Blob in bytes */
+ unsigned char a[1]; /* Blob content. Extra space allocated as needed. */
+};
+
+/*
+** Maximum number of files in the in-memory virtual filesystem.
+*/
+#define MX_FILE 10
+
+/*
+** Maximum allowed file size
+*/
+#define MX_FILE_SZ 10000000
+
+/*
+** All global variables are gathered into the "g" singleton.
+*/
+static struct GlobalVars {
+ const char *zArgv0; /* Name of program */
+ const char *zDbFile; /* Name of database file */
+ VFile aFile[MX_FILE]; /* The virtual filesystem */
+ int nDb; /* Number of template databases */
+ Blob *pFirstDb; /* Content of first template database */
+ int nSql; /* Number of SQL scripts */
+ Blob *pFirstSql; /* First SQL script */
+ unsigned int uRandom; /* Seed for the SQLite PRNG */
+ unsigned int nInvariant; /* Number of invariant checks run */
+ char zTestName[100]; /* Name of current test */
+} g;
+
+/*
+** Include the external vt02.c module.
+*/
+extern int sqlite3_vt02_init(sqlite3*,char***,void*);
+
+
+/*
+** Print an error message and quit.
+*/
+static void fatalError(const char *zFormat, ...){
+ va_list ap;
+ fprintf(stderr, "%s", g.zArgv0);
+ if( g.zDbFile ) fprintf(stderr, " %s", g.zDbFile);
+ if( g.zTestName[0] ) fprintf(stderr, " (%s)", g.zTestName);
+ fprintf(stderr, ": ");
+ va_start(ap, zFormat);
+ vfprintf(stderr, zFormat, ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+ exit(1);
+}
+
+/*
+** signal handler
+*/
+#ifdef __unix__
+static void signalHandler(int signum){
+ const char *zSig;
+ if( signum==SIGABRT ){
+ zSig = "abort";
+ }else if( signum==SIGALRM ){
+ zSig = "timeout";
+ }else if( signum==SIGSEGV ){
+ zSig = "segfault";
+ }else{
+ zSig = "signal";
+ }
+ fatalError(zSig);
+}
+#endif
+
+/*
+** Set the an alarm to go off after N seconds. Disable the alarm
+** if N==0
+*/
+static void setAlarm(int N){
+#ifdef __unix__
+ alarm(N);
+#else
+ (void)N;
+#endif
+}
+
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+/*
+** This an SQL progress handler. After an SQL statement has run for
+** many steps, we want to interrupt it. This guards against infinite
+** loops from recursive common table expressions.
+**
+** *pVdbeLimitFlag is true if the --limit-vdbe command-line option is used.
+** In that case, hitting the progress handler is a fatal error.
+*/
+static int progressHandler(void *pVdbeLimitFlag){
+ if( *(int*)pVdbeLimitFlag ) fatalError("too many VDBE cycles");
+ return 1;
+}
+#endif
+
+/*
+** Reallocate memory. Show an error and quit if unable.
+*/
+static void *safe_realloc(void *pOld, int szNew){
+ void *pNew = realloc(pOld, szNew<=0 ? 1 : szNew);
+ if( pNew==0 ) fatalError("unable to realloc for %d bytes", szNew);
+ return pNew;
+}
+
+/*
+** Initialize the virtual file system.
+*/
+static void formatVfs(void){
+ int i;
+ for(i=0; i<MX_FILE; i++){
+ g.aFile[i].sz = -1;
+ g.aFile[i].zFilename = 0;
+ g.aFile[i].a = 0;
+ g.aFile[i].nRef = 0;
+ }
+}
+
+
+/*
+** Erase all information in the virtual file system.
+*/
+static void reformatVfs(void){
+ int i;
+ for(i=0; i<MX_FILE; i++){
+ if( g.aFile[i].sz<0 ) continue;
+ if( g.aFile[i].zFilename ){
+ free(g.aFile[i].zFilename);
+ g.aFile[i].zFilename = 0;
+ }
+ if( g.aFile[i].nRef>0 ){
+ fatalError("file %d still open. nRef=%d", i, g.aFile[i].nRef);
+ }
+ g.aFile[i].sz = -1;
+ free(g.aFile[i].a);
+ g.aFile[i].a = 0;
+ g.aFile[i].nRef = 0;
+ }
+}
+
+/*
+** Find a VFile by name
+*/
+static VFile *findVFile(const char *zName){
+ int i;
+ if( zName==0 ) return 0;
+ for(i=0; i<MX_FILE; i++){
+ if( g.aFile[i].zFilename==0 ) continue;
+ if( strcmp(g.aFile[i].zFilename, zName)==0 ) return &g.aFile[i];
+ }
+ return 0;
+}
+
+/*
+** Find a VFile by name. Create it if it does not already exist and
+** initialize it to the size and content given.
+**
+** Return NULL only if the filesystem is full.
+*/
+static VFile *createVFile(const char *zName, int sz, unsigned char *pData){
+ VFile *pNew = findVFile(zName);
+ int i;
+ if( pNew ) return pNew;
+ for(i=0; i<MX_FILE && g.aFile[i].sz>=0; i++){}
+ if( i>=MX_FILE ) return 0;
+ pNew = &g.aFile[i];
+ if( zName ){
+ int nName = (int)strlen(zName)+1;
+ pNew->zFilename = safe_realloc(0, nName);
+ memcpy(pNew->zFilename, zName, nName);
+ }else{
+ pNew->zFilename = 0;
+ }
+ pNew->nRef = 0;
+ pNew->sz = sz;
+ pNew->a = safe_realloc(0, sz);
+ if( sz>0 ) memcpy(pNew->a, pData, sz);
+ return pNew;
+}
+
+/* Return true if the line is all zeros */
+static int allZero(unsigned char *aLine){
+ int i;
+ for(i=0; i<16 && aLine[i]==0; i++){}
+ return i==16;
+}
+
+/*
+** Render a database and query as text that can be input into
+** the CLI.
+*/
+static void renderDbSqlForCLI(
+ FILE *out, /* Write to this file */
+ const char *zFile, /* Name of the database file */
+ unsigned char *aDb, /* Database content */
+ int nDb, /* Number of bytes in aDb[] */
+ unsigned char *zSql, /* SQL content */
+ int nSql /* Bytes of SQL */
+){
+ fprintf(out, ".print ******* %s *******\n", zFile);
+ if( nDb>100 ){
+ int i, j; /* Loop counters */
+ int pgsz; /* Size of each page */
+ int lastPage = 0; /* Last page number shown */
+ int iPage; /* Current page number */
+ unsigned char *aLine; /* Single line to display */
+ unsigned char buf[16]; /* Fake line */
+ unsigned char bShow[256]; /* Characters ok to display */
+
+ memset(bShow, '.', sizeof(bShow));
+ for(i=' '; i<='~'; i++){
+ if( i!='{' && i!='}' && i!='"' && i!='\\' ) bShow[i] = i;
+ }
+ pgsz = (aDb[16]<<8) | aDb[17];
+ if( pgsz==0 ) pgsz = 65536;
+ if( pgsz<512 || (pgsz&(pgsz-1))!=0 ) pgsz = 4096;
+ fprintf(out,".open --hexdb\n");
+ fprintf(out,"| size %d pagesize %d filename %s\n",nDb,pgsz,zFile);
+ for(i=0; i<nDb; i += 16){
+ if( i+16>nDb ){
+ memset(buf, 0, sizeof(buf));
+ memcpy(buf, aDb+i, nDb-i);
+ aLine = buf;
+ }else{
+ aLine = aDb + i;
+ }
+ if( allZero(aLine) ) continue;
+ iPage = i/pgsz + 1;
+ if( lastPage!=iPage ){
+ fprintf(out,"| page %d offset %d\n", iPage, (iPage-1)*pgsz);
+ lastPage = iPage;
+ }
+ fprintf(out,"| %5d:", i-(iPage-1)*pgsz);
+ for(j=0; j<16; j++) fprintf(out," %02x", aLine[j]);
+ fprintf(out," ");
+ for(j=0; j<16; j++){
+ unsigned char c = (unsigned char)aLine[j];
+ fputc( bShow[c], stdout);
+ }
+ fputc('\n', stdout);
+ }
+ fprintf(out,"| end %s\n", zFile);
+ }else{
+ fprintf(out,".open :memory:\n");
+ }
+ fprintf(out,".testctrl prng_seed 1 db\n");
+ fprintf(out,".testctrl internal_functions\n");
+ fprintf(out,"%.*s", nSql, zSql);
+ if( nSql>0 && zSql[nSql-1]!='\n' ) fprintf(out, "\n");
+}
+
+/*
+** Read the complete content of a file into memory. Add a 0x00 terminator
+** and return a pointer to the result.
+**
+** The file content is held in memory obtained from sqlite_malloc64() which
+** should be freed by the caller.
+*/
+static char *readFile(const char *zFilename, long *sz){
+ FILE *in;
+ long nIn;
+ unsigned char *pBuf;
+
+ *sz = 0;
+ if( zFilename==0 ) return 0;
+ in = fopen(zFilename, "rb");
+ if( in==0 ) return 0;
+ fseek(in, 0, SEEK_END);
+ *sz = nIn = ftell(in);
+ rewind(in);
+ pBuf = sqlite3_malloc64( nIn+1 );
+ if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
+ pBuf[nIn] = 0;
+ fclose(in);
+ return (char*)pBuf;
+ }
+ sqlite3_free(pBuf);
+ *sz = 0;
+ fclose(in);
+ return 0;
+}
+
+
+/*
+** Implementation of the "readfile(X)" SQL function. The entire content
+** of the file named X is read and returned as a BLOB. NULL is returned
+** if the file does not exist or is unreadable.
+*/
+static void readfileFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ long nIn;
+ void *pBuf;
+ const char *zName = (const char*)sqlite3_value_text(argv[0]);
+
+ if( zName==0 ) return;
+ pBuf = readFile(zName, &nIn);
+ if( pBuf ){
+ sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
+ }
+}
+
+/*
+** Implementation of the "readtextfile(X)" SQL function. The text content
+** of the file named X through the end of the file or to the first \000
+** character, whichever comes first, is read and returned as TEXT. NULL
+** is returned if the file does not exist or is unreadable.
+*/
+static void readtextfileFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ const char *zName;
+ FILE *in;
+ long nIn;
+ char *pBuf;
+
+ zName = (const char*)sqlite3_value_text(argv[0]);
+ if( zName==0 ) return;
+ in = fopen(zName, "rb");
+ if( in==0 ) return;
+ fseek(in, 0, SEEK_END);
+ nIn = ftell(in);
+ rewind(in);
+ pBuf = sqlite3_malloc64( nIn+1 );
+ if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
+ pBuf[nIn] = 0;
+ sqlite3_result_text(context, pBuf, -1, sqlite3_free);
+ }else{
+ sqlite3_free(pBuf);
+ }
+ fclose(in);
+}
+
+/*
+** Implementation of the "writefile(X,Y)" SQL function. The argument Y
+** is written into file X. The number of bytes written is returned. Or
+** NULL is returned if something goes wrong, such as being unable to open
+** file X for writing.
+*/
+static void writefileFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ FILE *out;
+ const char *z;
+ sqlite3_int64 rc;
+ const char *zFile;
+
+ (void)argc;
+ zFile = (const char*)sqlite3_value_text(argv[0]);
+ if( zFile==0 ) return;
+ out = fopen(zFile, "wb");
+ if( out==0 ) return;
+ z = (const char*)sqlite3_value_blob(argv[1]);
+ if( z==0 ){
+ rc = 0;
+ }else{
+ rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
+ }
+ fclose(out);
+ sqlite3_result_int64(context, rc);
+}
+
+
+/*
+** Load a list of Blob objects from the database
+*/
+static void blobListLoadFromDb(
+ sqlite3 *db, /* Read from this database */
+ const char *zSql, /* Query used to extract the blobs */
+ int onlyId, /* Only load where id is this value */
+ int *pN, /* OUT: Write number of blobs loaded here */
+ Blob **ppList /* OUT: Write the head of the blob list here */
+){
+ Blob head;
+ Blob *p;
+ sqlite3_stmt *pStmt;
+ int n = 0;
+ int rc;
+ char *z2;
+
+ if( onlyId>0 ){
+ z2 = sqlite3_mprintf("%s WHERE rowid=%d", zSql, onlyId);
+ }else{
+ z2 = sqlite3_mprintf("%s", zSql);
+ }
+ rc = sqlite3_prepare_v2(db, z2, -1, &pStmt, 0);
+ sqlite3_free(z2);
+ if( rc ) fatalError("%s", sqlite3_errmsg(db));
+ head.pNext = 0;
+ p = &head;
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){
+ int sz = sqlite3_column_bytes(pStmt, 1);
+ Blob *pNew = safe_realloc(0, sizeof(*pNew)+sz );
+ pNew->id = sqlite3_column_int(pStmt, 0);
+ pNew->sz = sz;
+ pNew->seq = n++;
+ pNew->pNext = 0;
+ memcpy(pNew->a, sqlite3_column_blob(pStmt,1), sz);
+ pNew->a[sz] = 0;
+ p->pNext = pNew;
+ p = pNew;
+ }
+ sqlite3_finalize(pStmt);
+ *pN = n;
+ *ppList = head.pNext;
+}
+
+/*
+** Free a list of Blob objects
+*/
+static void blobListFree(Blob *p){
+ Blob *pNext;
+ while( p ){
+ pNext = p->pNext;
+ free(p);
+ p = pNext;
+ }
+}
+
+/* Return the current wall-clock time
+**
+** The number of milliseconds since the julian epoch.
+** 1907-01-01 00:00:00 -> 210866716800000
+** 2021-01-01 00:00:00 -> 212476176000000
+*/
+static sqlite3_int64 timeOfDay(void){
+ static sqlite3_vfs *clockVfs = 0;
+ sqlite3_int64 t;
+ if( clockVfs==0 ){
+ clockVfs = sqlite3_vfs_find(0);
+ if( clockVfs==0 ) return 0;
+ }
+ if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){
+ clockVfs->xCurrentTimeInt64(clockVfs, &t);
+ }else{
+ double r;
+ clockVfs->xCurrentTime(clockVfs, &r);
+ t = (sqlite3_int64)(r*86400000.0);
+ }
+ return t;
+}
+
+/***************************************************************************
+** Code to process combined database+SQL scripts generated by the
+** dbsqlfuzz fuzzer.
+*/
+
+/* An instance of the following object is passed by pointer as the
+** client data to various callbacks.
+*/
+typedef struct FuzzCtx {
+ sqlite3 *db; /* The database connection */
+ sqlite3_int64 iCutoffTime; /* Stop processing at this time. */
+ sqlite3_int64 iLastCb; /* Time recorded for previous progress callback */
+ sqlite3_int64 mxInterval; /* Longest interval between two progress calls */
+ unsigned nCb; /* Number of progress callbacks */
+ unsigned mxCb; /* Maximum number of progress callbacks allowed */
+ unsigned execCnt; /* Number of calls to the sqlite3_exec callback */
+ int timeoutHit; /* True when reaching a timeout */
+} FuzzCtx;
+
+/* Verbosity level for the dbsqlfuzz test runner */
+static int eVerbosity = 0;
+
+/* True to activate PRAGMA vdbe_debug=on */
+static int bVdbeDebug = 0;
+
+/* Timeout for each fuzzing attempt, in milliseconds */
+static int giTimeout = 10000; /* Defaults to 10 seconds */
+
+/* Maximum number of progress handler callbacks */
+static unsigned int mxProgressCb = 2000;
+
+/* Maximum string length in SQLite */
+static int lengthLimit = 1000000;
+
+/* Maximum expression depth */
+static int depthLimit = 500;
+
+/* Limit on the amount of heap memory that can be used */
+static sqlite3_int64 heapLimit = 100000000;
+
+/* Maximum byte-code program length in SQLite */
+static int vdbeOpLimit = 25000;
+
+/* Maximum size of the in-memory database */
+static sqlite3_int64 maxDbSize = 104857600;
+/* OOM simulation parameters */
+static unsigned int oomCounter = 0; /* Simulate OOM when equals 1 */
+static unsigned int oomRepeat = 0; /* Number of OOMs in a row */
+static void*(*defaultMalloc)(int) = 0; /* The low-level malloc routine */
+
+/* Enable recovery */
+static int bNoRecover = 0;
+
+/* This routine is called when a simulated OOM occurs. It is broken
+** out as a separate routine to make it easy to set a breakpoint on
+** the OOM
+*/
+void oomFault(void){
+ if( eVerbosity ){
+ printf("Simulated OOM fault\n");
+ }
+ if( oomRepeat>0 ){
+ oomRepeat--;
+ }else{
+ oomCounter--;
+ }
+}
+
+/* This routine is a replacement malloc() that is used to simulate
+** Out-Of-Memory (OOM) errors for testing purposes.
+*/
+static void *oomMalloc(int nByte){
+ if( oomCounter ){
+ if( oomCounter==1 ){
+ oomFault();
+ return 0;
+ }else{
+ oomCounter--;
+ }
+ }
+ return defaultMalloc(nByte);
+}
+
+/* Register the OOM simulator. This must occur before any memory
+** allocations */
+static void registerOomSimulator(void){
+ sqlite3_mem_methods mem;
+ sqlite3_shutdown();
+ sqlite3_config(SQLITE_CONFIG_GETMALLOC, &mem);
+ defaultMalloc = mem.xMalloc;
+ mem.xMalloc = oomMalloc;
+ sqlite3_config(SQLITE_CONFIG_MALLOC, &mem);
+}
+
+/* Turn off any pending OOM simulation */
+static void disableOom(void){
+ oomCounter = 0;
+ oomRepeat = 0;
+}
+
+/*
+** Translate a single byte of Hex into an integer.
+** This routine only works if h really is a valid hexadecimal
+** character: 0..9a..fA..F
+*/
+static unsigned char hexToInt(unsigned int h){
+#ifdef SQLITE_EBCDIC
+ h += 9*(1&~(h>>4)); /* EBCDIC */
+#else
+ h += 9*(1&(h>>6)); /* ASCII */
+#endif
+ return h & 0xf;
+}
+
+/*
+** The first character of buffer zIn[0..nIn-1] is a '['. This routine
+** checked to see if the buffer holds "[NNNN]" or "[+NNNN]" and if it
+** does it makes corresponding changes to the *pK value and *pI value
+** and returns true. If the input buffer does not match the patterns,
+** no changes are made to either *pK or *pI and this routine returns false.
+*/
+static int isOffset(
+ const unsigned char *zIn, /* Text input */
+ int nIn, /* Bytes of input */
+ unsigned int *pK, /* half-byte cursor to adjust */
+ unsigned int *pI /* Input index to adjust */
+){
+ int i;
+ unsigned int k = 0;
+ unsigned char c;
+ for(i=1; i<nIn && (c = zIn[i])!=']'; i++){
+ if( !isxdigit(c) ) return 0;
+ k = k*16 + hexToInt(c);
+ }
+ if( i==nIn ) return 0;
+ *pK = 2*k;
+ *pI += i;
+ return 1;
+}
+
+/*
+** Decode the text starting at zIn into a binary database file.
+** The maximum length of zIn is nIn bytes. Store the binary database
+** file in space obtained from sqlite3_malloc().
+**
+** Return the number of bytes of zIn consumed. Or return -1 if there
+** is an error. One potential error is that the recipe specifies a
+** database file larger than MX_FILE_SZ bytes.
+**
+** Abort on an OOM.
+*/
+static int decodeDatabase(
+ const unsigned char *zIn, /* Input text to be decoded */
+ int nIn, /* Bytes of input text */
+ unsigned char **paDecode, /* OUT: decoded database file */
+ int *pnDecode /* OUT: Size of decoded database */
+){
+ unsigned char *a, *aNew; /* Database under construction */
+ int mx = 0; /* Current size of the database */
+ sqlite3_uint64 nAlloc = 4096; /* Space allocated in a[] */
+ unsigned int i; /* Next byte of zIn[] to read */
+ unsigned int j; /* Temporary integer */
+ unsigned int k; /* half-byte cursor index for output */
+ unsigned int n; /* Number of bytes of input */
+ unsigned char b = 0;
+ if( nIn<4 ) return -1;
+ n = (unsigned int)nIn;
+ a = sqlite3_malloc64( nAlloc );
+ if( a==0 ){
+ fprintf(stderr, "Out of memory!\n");
+ exit(1);
+ }
+ memset(a, 0, (size_t)nAlloc);
+ for(i=k=0; i<n; i++){
+ unsigned char c = (unsigned char)zIn[i];
+ if( isxdigit(c) ){
+ k++;
+ if( k & 1 ){
+ b = hexToInt(c)*16;
+ }else{
+ b += hexToInt(c);
+ j = k/2 - 1;
+ if( j>=nAlloc ){
+ sqlite3_uint64 newSize;
+ if( nAlloc==MX_FILE_SZ || j>=MX_FILE_SZ ){
+ if( eVerbosity ){
+ fprintf(stderr, "Input database too big: max %d bytes\n",
+ MX_FILE_SZ);
+ }
+ sqlite3_free(a);
+ return -1;
+ }
+ newSize = nAlloc*2;
+ if( newSize<=j ){
+ newSize = (j+4096)&~4095;
+ }
+ if( newSize>MX_FILE_SZ ){
+ if( j>=MX_FILE_SZ ){
+ sqlite3_free(a);
+ return -1;
+ }
+ newSize = MX_FILE_SZ;
+ }
+ aNew = sqlite3_realloc64( a, newSize );
+ if( aNew==0 ){
+ sqlite3_free(a);
+ return -1;
+ }
+ a = aNew;
+ assert( newSize > nAlloc );
+ memset(a+nAlloc, 0, (size_t)(newSize - nAlloc));
+ nAlloc = newSize;
+ }
+ if( j>=(unsigned)mx ){
+ mx = (j + 4095)&~4095;
+ if( mx>MX_FILE_SZ ) mx = MX_FILE_SZ;
+ }
+ assert( j<nAlloc );
+ a[j] = b;
+ }
+ }else if( zIn[i]=='[' && i<n-3 && isOffset(zIn+i, nIn-i, &k, &i) ){
+ continue;
+ }else if( zIn[i]=='\n' && i<n-4 && memcmp(zIn+i,"\n--\n",4)==0 ){
+ i += 4;
+ break;
+ }
+ }
+ *pnDecode = mx;
+ *paDecode = a;
+ return i;
+}
+
+/*
+** Progress handler callback.
+**
+** The argument is the cutoff-time after which all processing should
+** stop. So return non-zero if the cut-off time is exceeded.
+*/
+static int progress_handler(void *pClientData) {
+ FuzzCtx *p = (FuzzCtx*)pClientData;
+ sqlite3_int64 iNow = timeOfDay();
+ int rc = iNow>=p->iCutoffTime;
+ sqlite3_int64 iDiff = iNow - p->iLastCb;
+ /* printf("time-remaining: %lld\n", p->iCutoffTime - iNow); */
+ if( iDiff > p->mxInterval ) p->mxInterval = iDiff;
+ p->nCb++;
+ if( rc==0 && p->mxCb>0 && p->mxCb<=p->nCb ) rc = 1;
+ if( rc && !p->timeoutHit && eVerbosity>=2 ){
+ printf("Timeout on progress callback %d\n", p->nCb);
+ fflush(stdout);
+ p->timeoutHit = 1;
+ }
+ return rc;
+}
+
+/*
+** Flag bits set by block_troublesome_sql()
+*/
+#define BTS_SELECT 0x000001
+#define BTS_NONSELECT 0x000002
+#define BTS_BADFUNC 0x000004
+#define BTS_BADPRAGMA 0x000008 /* Sticky for rest of the script */
+
+/*
+** Disallow debugging pragmas such as "PRAGMA vdbe_debug" and
+** "PRAGMA parser_trace" since they can dramatically increase the
+** amount of output without actually testing anything useful.
+**
+** Also block ATTACH if attaching a file from the filesystem.
+*/
+static int block_troublesome_sql(
+ void *pClientData,
+ int eCode,
+ const char *zArg1,
+ const char *zArg2,
+ const char *zArg3,
+ const char *zArg4
+){
+ unsigned int *pBtsFlags = (unsigned int*)pClientData;
+
+ (void)zArg3;
+ (void)zArg4;
+ switch( eCode ){
+ case SQLITE_PRAGMA: {
+ if( sqlite3_stricmp("busy_timeout",zArg1)==0
+ && (zArg2==0 || strtoll(zArg2,0,0)>100 || strtoll(zArg2,0,10)>100)
+ ){
+ return SQLITE_DENY;
+ }else if( sqlite3_stricmp("hard_heap_limit", zArg1)==0
+ || sqlite3_stricmp("reverse_unordered_selects", zArg1)==0
+ ){
+ /* BTS_BADPRAGMA is sticky. A hard_heap_limit or
+ ** revert_unordered_selects should inhibit all future attempts
+ ** at verifying query invariants */
+ *pBtsFlags |= BTS_BADPRAGMA;
+ }else if( eVerbosity==0 ){
+ if( sqlite3_strnicmp("vdbe_", zArg1, 5)==0
+ || sqlite3_stricmp("parser_trace", zArg1)==0
+ || sqlite3_stricmp("temp_store_directory", zArg1)==0
+ ){
+ return SQLITE_DENY;
+ }
+ }else if( sqlite3_stricmp("oom",zArg1)==0
+ && zArg2!=0 && zArg2[0]!=0 ){
+ oomCounter = atoi(zArg2);
+ }
+ *pBtsFlags |= BTS_NONSELECT;
+ break;
+ }
+ case SQLITE_ATTACH: {
+ /* Deny the ATTACH if it is attaching anything other than an in-memory
+ ** database. */
+ *pBtsFlags |= BTS_NONSELECT;
+ if( zArg1==0 ) return SQLITE_DENY;
+ if( strcmp(zArg1,":memory:")==0 ) return SQLITE_OK;
+ if( sqlite3_strglob("file:*[?]vfs=memdb", zArg1)==0
+ && sqlite3_strglob("file:*[^/a-zA-Z0-9_.]*[?]vfs=memdb", zArg1)!=0
+ ){
+ return SQLITE_OK;
+ }
+ return SQLITE_DENY;
+ }
+ case SQLITE_SELECT: {
+ *pBtsFlags |= BTS_SELECT;
+ break;
+ }
+ case SQLITE_FUNCTION: {
+ static const char *azBadFuncs[] = {
+ "avg",
+ "count",
+ "cume_dist",
+ "current_date",
+ "current_time",
+ "current_timestamp",
+ "date",
+ "datetime",
+ "decimal_sum",
+ "dense_rank",
+ "first_value",
+ "geopoly_group_bbox",
+ "group_concat",
+ "implies_nonnull_row",
+ "json_group_array",
+ "json_group_object",
+ "julianday",
+ "lag",
+ "last_value",
+ "lead",
+ "max",
+ "min",
+ "nth_value",
+ "ntile",
+ "percent_rank",
+ "random",
+ "randomblob",
+ "rank",
+ "row_number",
+ "sqlite_offset",
+ "strftime",
+ "sum",
+ "time",
+ "total",
+ "unixepoch",
+ };
+ int first, last;
+ first = 0;
+ last = sizeof(azBadFuncs)/sizeof(azBadFuncs[0]) - 1;
+ do{
+ int mid = (first+last)/2;
+ int c = sqlite3_stricmp(azBadFuncs[mid], zArg2);
+ if( c<0 ){
+ first = mid+1;
+ }else if( c>0 ){
+ last = mid-1;
+ }else{
+ *pBtsFlags |= BTS_BADFUNC;
+ break;
+ }
+ }while( first<=last );
+ break;
+ }
+ case SQLITE_READ: {
+ /* Benign */
+ break;
+ }
+ default: {
+ *pBtsFlags |= BTS_NONSELECT;
+ }
+ }
+ return SQLITE_OK;
+}
+
+/* Implementation found in fuzzinvariant.c */
+extern int fuzz_invariant(
+ sqlite3 *db, /* The database connection */
+ sqlite3_stmt *pStmt, /* Test statement stopped on an SQLITE_ROW */
+ int iCnt, /* Invariant sequence number, starting at 0 */
+ int iRow, /* The row number for pStmt */
+ int nRow, /* Total number of output rows */
+ int *pbCorrupt, /* IN/OUT: Flag indicating a corrupt database file */
+ int eVerbosity /* How much debugging output */
+);
+
+/* Implementation of sqlite_dbdata and sqlite_dbptr */
+extern int sqlite3_dbdata_init(sqlite3*,const char**,void*);
+
+
+/*
+** This function is used as a callback by the recover extension. Simply
+** print the supplied SQL statement to stdout.
+*/
+static int recoverSqlCb(void *pCtx, const char *zSql){
+ if( eVerbosity>=2 ){
+ printf("%s\n", zSql);
+ }
+ return SQLITE_OK;
+}
+
+/*
+** This function is called to recover data from the database.
+*/
+static int recoverDatabase(sqlite3 *db){
+ int rc; /* Return code from this routine */
+ const char *zLAF = "lost_and_found"; /* Name of "lost_and_found" table */
+ int bFreelist = 1; /* True to scan the freelist */
+ int bRowids = 1; /* True to restore ROWID values */
+ sqlite3_recover *p; /* The recovery object */
+
+ p = sqlite3_recover_init_sql(db, "main", recoverSqlCb, 0);
+ sqlite3_recover_config(p, SQLITE_RECOVER_LOST_AND_FOUND, (void*)zLAF);
+ sqlite3_recover_config(p, SQLITE_RECOVER_ROWIDS, (void*)&bRowids);
+ sqlite3_recover_config(p, SQLITE_RECOVER_FREELIST_CORRUPT,(void*)&bFreelist);
+ sqlite3_recover_run(p);
+ if( sqlite3_recover_errcode(p)!=SQLITE_OK ){
+ const char *zErr = sqlite3_recover_errmsg(p);
+ int errCode = sqlite3_recover_errcode(p);
+ if( eVerbosity>0 ){
+ printf("recovery error: %s (%d)\n", zErr, errCode);
+ }
+ }
+ rc = sqlite3_recover_finish(p);
+ if( eVerbosity>0 && rc ){
+ printf("recovery returns error code %d\n", rc);
+ }
+ return rc;
+}
+
+/*
+** Run the SQL text
+*/
+static int runDbSql(sqlite3 *db, const char *zSql, unsigned int *pBtsFlags){
+ int rc;
+ sqlite3_stmt *pStmt;
+ int bCorrupt = 0;
+ while( isspace(zSql[0]&0x7f) ) zSql++;
+ if( zSql[0]==0 ) return SQLITE_OK;
+ if( eVerbosity>=4 ){
+ printf("RUNNING-SQL: [%s]\n", zSql);
+ fflush(stdout);
+ }
+ (*pBtsFlags) &= ~BTS_BADPRAGMA;
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ if( rc==SQLITE_OK ){
+ int nRow = 0;
+ while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){
+ nRow++;
+ if( eVerbosity>=4 ){
+ int j;
+ for(j=0; j<sqlite3_column_count(pStmt); j++){
+ if( j ) printf(",");
+ switch( sqlite3_column_type(pStmt, j) ){
+ case SQLITE_NULL: {
+ printf("NULL");
+ break;
+ }
+ case SQLITE_INTEGER:
+ case SQLITE_FLOAT: {
+ printf("%s", sqlite3_column_text(pStmt, j));
+ break;
+ }
+ case SQLITE_BLOB: {
+ int n = sqlite3_column_bytes(pStmt, j);
+ int i;
+ const unsigned char *a;
+ a = (const unsigned char*)sqlite3_column_blob(pStmt, j);
+ printf("x'");
+ for(i=0; i<n; i++){
+ printf("%02x", a[i]);
+ }
+ printf("'");
+ break;
+ }
+ case SQLITE_TEXT: {
+ int n = sqlite3_column_bytes(pStmt, j);
+ int i;
+ const unsigned char *a;
+ a = (const unsigned char*)sqlite3_column_blob(pStmt, j);
+ printf("'");
+ for(i=0; i<n; i++){
+ if( a[i]=='\'' ){
+ printf("''");
+ }else{
+ putchar(a[i]);
+ }
+ }
+ printf("'");
+ break;
+ }
+ } /* End switch() */
+ } /* End for() */
+ printf("\n");
+ fflush(stdout);
+ } /* End if( eVerbosity>=5 ) */
+ } /* End while( SQLITE_ROW */
+ if( rc==SQLITE_DONE ){
+ if( (*pBtsFlags)==BTS_SELECT
+ && !sqlite3_stmt_isexplain(pStmt)
+ && nRow>0
+ ){
+ int iRow = 0;
+ sqlite3_reset(pStmt);
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ int iCnt = 0;
+ iRow++;
+ for(iCnt=0; iCnt<99999; iCnt++){
+ rc = fuzz_invariant(db, pStmt, iCnt, iRow, nRow,
+ &bCorrupt, eVerbosity);
+ if( rc==SQLITE_DONE ) break;
+ if( rc!=SQLITE_ERROR ) g.nInvariant++;
+ if( eVerbosity>0 ){
+ if( rc==SQLITE_OK ){
+ printf("invariant-check: ok\n");
+ }else if( rc==SQLITE_CORRUPT ){
+ printf("invariant-check: failed due to database corruption\n");
+ }
+ }
+ }
+ }
+ }
+ }else if( eVerbosity>=4 ){
+ printf("SQL-ERROR: (%d) %s\n", rc, sqlite3_errmsg(db));
+ fflush(stdout);
+ }
+ }else if( eVerbosity>=4 ){
+ printf("SQL-ERROR (%d): %s\n", rc, sqlite3_errmsg(db));
+ fflush(stdout);
+ } /* End if( SQLITE_OK ) */
+ return sqlite3_finalize(pStmt);
+}
+
+/* Invoke this routine to run a single test case */
+int runCombinedDbSqlInput(
+ const uint8_t *aData, /* Combined DB+SQL content */
+ size_t nByte, /* Size of aData in bytes */
+ int iTimeout, /* Use this timeout */
+ int bScript, /* If true, just render CLI output */
+ int iSqlId /* SQL identifier */
+){
+ int rc; /* SQLite API return value */
+ int iSql; /* Index in aData[] of start of SQL */
+ unsigned char *aDb = 0; /* Decoded database content */
+ int nDb = 0; /* Size of the decoded database */
+ int i; /* Loop counter */
+ int j; /* Start of current SQL statement */
+ char *zSql = 0; /* SQL text to run */
+ int nSql; /* Bytes of SQL text */
+ FuzzCtx cx; /* Fuzzing context */
+ unsigned int btsFlags = 0; /* Parsing flags */
+
+ if( nByte<10 ) return 0;
+ if( sqlite3_initialize() ) return 0;
+ if( sqlite3_memory_used()!=0 ){
+ int nAlloc = 0;
+ int nNotUsed = 0;
+ sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &nAlloc, &nNotUsed, 0);
+ fprintf(stderr,"memory leak prior to test start:"
+ " %lld bytes in %d allocations\n",
+ sqlite3_memory_used(), nAlloc);
+ exit(1);
+ }
+ memset(&cx, 0, sizeof(cx));
+ iSql = decodeDatabase((unsigned char*)aData, (int)nByte, &aDb, &nDb);
+ if( iSql<0 ) return 0;
+ nSql = (int)(nByte - iSql);
+ if( bScript ){
+ char zName[100];
+ sqlite3_snprintf(sizeof(zName),zName,"dbsql%06d.db",iSqlId);
+ renderDbSqlForCLI(stdout, zName, aDb, nDb,
+ (unsigned char*)(aData+iSql), nSql);
+ sqlite3_free(aDb);
+ return 0;
+ }
+ if( eVerbosity>=3 ){
+ printf(
+ "****** %d-byte input, %d-byte database, %d-byte script "
+ "******\n", (int)nByte, nDb, nSql);
+ fflush(stdout);
+ }
+ rc = sqlite3_open(0, &cx.db);
+ if( rc ){
+ sqlite3_free(aDb);
+ return 1;
+ }
+ if( bVdbeDebug ){
+ sqlite3_exec(cx.db, "PRAGMA vdbe_debug=ON", 0, 0, 0);
+ }
+
+ /* Invoke the progress handler frequently to check to see if we
+ ** are taking too long. The progress handler will return true
+ ** (which will block further processing) if more than giTimeout seconds have
+ ** elapsed since the start of the test.
+ */
+ cx.iLastCb = timeOfDay();
+ cx.iCutoffTime = cx.iLastCb + (iTimeout<giTimeout ? iTimeout : giTimeout);
+ cx.mxCb = mxProgressCb;
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ sqlite3_progress_handler(cx.db, 10, progress_handler, (void*)&cx);
+#endif
+
+ /* Set a limit on the maximum size of a prepared statement, and the
+ ** maximum length of a string or blob */
+ if( vdbeOpLimit>0 ){
+ sqlite3_limit(cx.db, SQLITE_LIMIT_VDBE_OP, vdbeOpLimit);
+ }
+ if( lengthLimit>0 ){
+ sqlite3_limit(cx.db, SQLITE_LIMIT_LENGTH, lengthLimit);
+ }
+ if( depthLimit>0 ){
+ sqlite3_limit(cx.db, SQLITE_LIMIT_EXPR_DEPTH, depthLimit);
+ }
+ sqlite3_limit(cx.db, SQLITE_LIMIT_LIKE_PATTERN_LENGTH, 100);
+ sqlite3_hard_heap_limit64(heapLimit);
+
+ if( nDb>=20 && aDb[18]==2 && aDb[19]==2 ){
+ aDb[18] = aDb[19] = 1;
+ }
+ rc = sqlite3_deserialize(cx.db, "main", aDb, nDb, nDb,
+ SQLITE_DESERIALIZE_RESIZEABLE |
+ SQLITE_DESERIALIZE_FREEONCLOSE);
+ if( rc ){
+ fprintf(stderr, "sqlite3_deserialize() failed with %d\n", rc);
+ goto testrun_finished;
+ }
+ if( maxDbSize>0 ){
+ sqlite3_int64 x = maxDbSize;
+ sqlite3_file_control(cx.db, "main", SQLITE_FCNTL_SIZE_LIMIT, &x);
+ }
+
+ /* For high debugging levels, turn on debug mode */
+ if( eVerbosity>=5 ){
+ sqlite3_exec(cx.db, "PRAGMA vdbe_debug=ON;", 0, 0, 0);
+ }
+
+ /* Block debug pragmas and ATTACH/DETACH. But wait until after
+ ** deserialize to do this because deserialize depends on ATTACH */
+ sqlite3_set_authorizer(cx.db, block_troublesome_sql, &btsFlags);
+
+ /* Add the vt02 virtual table */
+ sqlite3_vt02_init(cx.db, 0, 0);
+
+ /* Add support for sqlite_dbdata and sqlite_dbptr virtual tables used
+ ** by the recovery API */
+ sqlite3_dbdata_init(cx.db, 0, 0);
+
+ /* Consistent PRNG seed */
+#ifdef SQLITE_TESTCTRL_PRNG_SEED
+ sqlite3_table_column_metadata(cx.db, 0, "x", 0, 0, 0, 0, 0, 0);
+ sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SEED, 1, cx.db);
+#else
+ sqlite3_randomness(0,0);
+#endif
+
+ /* Run recovery on the initial database, just to make sure recovery
+ ** works. */
+ if( !bNoRecover ){
+ recoverDatabase(cx.db);
+ }
+
+ zSql = sqlite3_malloc( nSql + 1 );
+ if( zSql==0 ){
+ fprintf(stderr, "Out of memory!\n");
+ }else{
+ memcpy(zSql, aData+iSql, nSql);
+ zSql[nSql] = 0;
+ for(i=j=0; zSql[i]; i++){
+ if( zSql[i]==';' ){
+ char cSaved = zSql[i+1];
+ zSql[i+1] = 0;
+ if( sqlite3_complete(zSql+j) ){
+ rc = runDbSql(cx.db, zSql+j, &btsFlags);
+ j = i+1;
+ }
+ zSql[i+1] = cSaved;
+ if( rc==SQLITE_INTERRUPT || progress_handler(&cx) ){
+ goto testrun_finished;
+ }
+ }
+ }
+ if( j<i ){
+ runDbSql(cx.db, zSql+j, &btsFlags);
+ }
+ }
+testrun_finished:
+ sqlite3_free(zSql);
+ rc = sqlite3_close(cx.db);
+ if( rc!=SQLITE_OK ){
+ fprintf(stdout, "sqlite3_close() returns %d\n", rc);
+ }
+ if( eVerbosity>=2 && !bScript ){
+ fprintf(stdout, "Peak memory usages: %f MB\n",
+ sqlite3_memory_highwater(1) / 1000000.0);
+ }
+ if( sqlite3_memory_used()!=0 ){
+ int nAlloc = 0;
+ int nNotUsed = 0;
+ sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &nAlloc, &nNotUsed, 0);
+ fprintf(stderr,"Memory leak: %lld bytes in %d allocations\n",
+ sqlite3_memory_used(), nAlloc);
+ exit(1);
+ }
+ sqlite3_hard_heap_limit64(0);
+ sqlite3_soft_heap_limit64(0);
+ return 0;
+}
+
+/*
+** END of the dbsqlfuzz code
+***************************************************************************/
+
+/* Look at a SQL text and try to determine if it begins with a database
+** description, such as would be found in a dbsqlfuzz test case. Return
+** true if this does appear to be a dbsqlfuzz test case and false otherwise.
+*/
+static int isDbSql(unsigned char *a, int n){
+ unsigned char buf[12];
+ int i;
+ if( n>4 && memcmp(a,"\n--\n",4)==0 ) return 1;
+ while( n>0 && isspace(a[0]) ){ a++; n--; }
+ for(i=0; n>0 && i<8; n--, a++){
+ if( isxdigit(a[0]) ) buf[i++] = a[0];
+ }
+ if( i==8 && memcmp(buf,"53514c69",8)==0 ) return 1;
+ return 0;
+}
+
+/* Implementation of the isdbsql(TEXT) SQL function.
+*/
+static void isDbSqlFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ int n = sqlite3_value_bytes(argv[0]);
+ unsigned char *a = (unsigned char*)sqlite3_value_blob(argv[0]);
+ sqlite3_result_int(context, a!=0 && n>0 && isDbSql(a,n));
+}
+
+/* Methods for the VHandle object
+*/
+static int inmemClose(sqlite3_file *pFile){
+ VHandle *p = (VHandle*)pFile;
+ VFile *pVFile = p->pVFile;
+ pVFile->nRef--;
+ if( pVFile->nRef==0 && pVFile->zFilename==0 ){
+ pVFile->sz = -1;
+ free(pVFile->a);
+ pVFile->a = 0;
+ }
+ return SQLITE_OK;
+}
+static int inmemRead(
+ sqlite3_file *pFile, /* Read from this open file */
+ void *pData, /* Store content in this buffer */
+ int iAmt, /* Bytes of content */
+ sqlite3_int64 iOfst /* Start reading here */
+){
+ VHandle *pHandle = (VHandle*)pFile;
+ VFile *pVFile = pHandle->pVFile;
+ if( iOfst<0 || iOfst>=pVFile->sz ){
+ memset(pData, 0, iAmt);
+ return SQLITE_IOERR_SHORT_READ;
+ }
+ if( iOfst+iAmt>pVFile->sz ){
+ memset(pData, 0, iAmt);
+ iAmt = (int)(pVFile->sz - iOfst);
+ memcpy(pData, pVFile->a + iOfst, iAmt);
+ return SQLITE_IOERR_SHORT_READ;
+ }
+ memcpy(pData, pVFile->a + iOfst, iAmt);
+ return SQLITE_OK;
+}
+static int inmemWrite(
+ sqlite3_file *pFile, /* Write to this file */
+ const void *pData, /* Content to write */
+ int iAmt, /* bytes to write */
+ sqlite3_int64 iOfst /* Start writing here */
+){
+ VHandle *pHandle = (VHandle*)pFile;
+ VFile *pVFile = pHandle->pVFile;
+ if( iOfst+iAmt > pVFile->sz ){
+ if( iOfst+iAmt >= MX_FILE_SZ ){
+ return SQLITE_FULL;
+ }
+ pVFile->a = safe_realloc(pVFile->a, (int)(iOfst+iAmt));
+ if( iOfst > pVFile->sz ){
+ memset(pVFile->a + pVFile->sz, 0, (int)(iOfst - pVFile->sz));
+ }
+ pVFile->sz = (int)(iOfst + iAmt);
+ }
+ memcpy(pVFile->a + iOfst, pData, iAmt);
+ return SQLITE_OK;
+}
+static int inmemTruncate(sqlite3_file *pFile, sqlite3_int64 iSize){
+ VHandle *pHandle = (VHandle*)pFile;
+ VFile *pVFile = pHandle->pVFile;
+ if( pVFile->sz>iSize && iSize>=0 ) pVFile->sz = (int)iSize;
+ return SQLITE_OK;
+}
+static int inmemSync(sqlite3_file *pFile, int flags){
+ return SQLITE_OK;
+}
+static int inmemFileSize(sqlite3_file *pFile, sqlite3_int64 *pSize){
+ *pSize = ((VHandle*)pFile)->pVFile->sz;
+ return SQLITE_OK;
+}
+static int inmemLock(sqlite3_file *pFile, int type){
+ return SQLITE_OK;
+}
+static int inmemUnlock(sqlite3_file *pFile, int type){
+ return SQLITE_OK;
+}
+static int inmemCheckReservedLock(sqlite3_file *pFile, int *pOut){
+ *pOut = 0;
+ return SQLITE_OK;
+}
+static int inmemFileControl(sqlite3_file *pFile, int op, void *pArg){
+ return SQLITE_NOTFOUND;
+}
+static int inmemSectorSize(sqlite3_file *pFile){
+ return 512;
+}
+static int inmemDeviceCharacteristics(sqlite3_file *pFile){
+ return
+ SQLITE_IOCAP_SAFE_APPEND |
+ SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
+ SQLITE_IOCAP_POWERSAFE_OVERWRITE;
+}
+
+
+/* Method table for VHandle
+*/
+static sqlite3_io_methods VHandleMethods = {
+ /* iVersion */ 1,
+ /* xClose */ inmemClose,
+ /* xRead */ inmemRead,
+ /* xWrite */ inmemWrite,
+ /* xTruncate */ inmemTruncate,
+ /* xSync */ inmemSync,
+ /* xFileSize */ inmemFileSize,
+ /* xLock */ inmemLock,
+ /* xUnlock */ inmemUnlock,
+ /* xCheck... */ inmemCheckReservedLock,
+ /* xFileCtrl */ inmemFileControl,
+ /* xSectorSz */ inmemSectorSize,
+ /* xDevchar */ inmemDeviceCharacteristics,
+ /* xShmMap */ 0,
+ /* xShmLock */ 0,
+ /* xShmBarrier */ 0,
+ /* xShmUnmap */ 0,
+ /* xFetch */ 0,
+ /* xUnfetch */ 0
+};
+
+/*
+** Open a new file in the inmem VFS. All files are anonymous and are
+** delete-on-close.
+*/
+static int inmemOpen(
+ sqlite3_vfs *pVfs,
+ const char *zFilename,
+ sqlite3_file *pFile,
+ int openFlags,
+ int *pOutFlags
+){
+ VFile *pVFile = createVFile(zFilename, 0, (unsigned char*)"");
+ VHandle *pHandle = (VHandle*)pFile;
+ if( pVFile==0 ){
+ return SQLITE_FULL;
+ }
+ pHandle->pVFile = pVFile;
+ pVFile->nRef++;
+ pFile->pMethods = &VHandleMethods;
+ if( pOutFlags ) *pOutFlags = openFlags;
+ return SQLITE_OK;
+}
+
+/*
+** Delete a file by name
+*/
+static int inmemDelete(
+ sqlite3_vfs *pVfs,
+ const char *zFilename,
+ int syncdir
+){
+ VFile *pVFile = findVFile(zFilename);
+ if( pVFile==0 ) return SQLITE_OK;
+ if( pVFile->nRef==0 ){
+ free(pVFile->zFilename);
+ pVFile->zFilename = 0;
+ pVFile->sz = -1;
+ free(pVFile->a);
+ pVFile->a = 0;
+ return SQLITE_OK;
+ }
+ return SQLITE_IOERR_DELETE;
+}
+
+/* Check for the existance of a file
+*/
+static int inmemAccess(
+ sqlite3_vfs *pVfs,
+ const char *zFilename,
+ int flags,
+ int *pResOut
+){
+ VFile *pVFile = findVFile(zFilename);
+ *pResOut = pVFile!=0;
+ return SQLITE_OK;
+}
+
+/* Get the canonical pathname for a file
+*/
+static int inmemFullPathname(
+ sqlite3_vfs *pVfs,
+ const char *zFilename,
+ int nOut,
+ char *zOut
+){
+ sqlite3_snprintf(nOut, zOut, "%s", zFilename);
+ return SQLITE_OK;
+}
+
+/* Always use the same random see, for repeatability.
+*/
+static int inmemRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){
+ memset(zBuf, 0, nBuf);
+ memcpy(zBuf, &g.uRandom, nBuf<sizeof(g.uRandom) ? nBuf : sizeof(g.uRandom));
+ return nBuf;
+}
+
+/*
+** Register the VFS that reads from the g.aFile[] set of files.
+*/
+static void inmemVfsRegister(int makeDefault){
+ static sqlite3_vfs inmemVfs;
+ sqlite3_vfs *pDefault = sqlite3_vfs_find(0);
+ inmemVfs.iVersion = 3;
+ inmemVfs.szOsFile = sizeof(VHandle);
+ inmemVfs.mxPathname = 200;
+ inmemVfs.zName = "inmem";
+ inmemVfs.xOpen = inmemOpen;
+ inmemVfs.xDelete = inmemDelete;
+ inmemVfs.xAccess = inmemAccess;
+ inmemVfs.xFullPathname = inmemFullPathname;
+ inmemVfs.xRandomness = inmemRandomness;
+ inmemVfs.xSleep = pDefault->xSleep;
+ inmemVfs.xCurrentTimeInt64 = pDefault->xCurrentTimeInt64;
+ sqlite3_vfs_register(&inmemVfs, makeDefault);
+};
+
+/*
+** Allowed values for the runFlags parameter to runSql()
+*/
+#define SQL_TRACE 0x0001 /* Print each SQL statement as it is prepared */
+#define SQL_OUTPUT 0x0002 /* Show the SQL output */
+
+/*
+** Run multiple commands of SQL. Similar to sqlite3_exec(), but does not
+** stop if an error is encountered.
+*/
+static void runSql(sqlite3 *db, const char *zSql, unsigned runFlags){
+ const char *zMore;
+ sqlite3_stmt *pStmt;
+
+ while( zSql && zSql[0] ){
+ zMore = 0;
+ pStmt = 0;
+ sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore);
+ if( zMore==zSql ) break;
+ if( runFlags & SQL_TRACE ){
+ const char *z = zSql;
+ int n;
+ while( z<zMore && ISSPACE(z[0]) ) z++;
+ n = (int)(zMore - z);
+ while( n>0 && ISSPACE(z[n-1]) ) n--;
+ if( n==0 ) break;
+ if( pStmt==0 ){
+ printf("TRACE: %.*s (error: %s)\n", n, z, sqlite3_errmsg(db));
+ }else{
+ printf("TRACE: %.*s\n", n, z);
+ }
+ }
+ zSql = zMore;
+ if( pStmt ){
+ if( (runFlags & SQL_OUTPUT)==0 ){
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){}
+ }else{
+ int nCol = -1;
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){
+ int i;
+ if( nCol<0 ){
+ nCol = sqlite3_column_count(pStmt);
+ }else if( nCol>0 ){
+ printf("--------------------------------------------\n");
+ }
+ for(i=0; i<nCol; i++){
+ int eType = sqlite3_column_type(pStmt,i);
+ printf("%s = ", sqlite3_column_name(pStmt,i));
+ switch( eType ){
+ case SQLITE_NULL: {
+ printf("NULL\n");
+ break;
+ }
+ case SQLITE_INTEGER: {
+ printf("INT %s\n", sqlite3_column_text(pStmt,i));
+ break;
+ }
+ case SQLITE_FLOAT: {
+ printf("FLOAT %s\n", sqlite3_column_text(pStmt,i));
+ break;
+ }
+ case SQLITE_TEXT: {
+ printf("TEXT [%s]\n", sqlite3_column_text(pStmt,i));
+ break;
+ }
+ case SQLITE_BLOB: {
+ printf("BLOB (%d bytes)\n", sqlite3_column_bytes(pStmt,i));
+ break;
+ }
+ }
+ }
+ }
+ }
+ sqlite3_finalize(pStmt);
+ }
+ }
+}
+
+/*
+** Rebuild the database file.
+**
+** (1) Remove duplicate entries
+** (2) Put all entries in order
+** (3) Vacuum
+*/
+static void rebuild_database(sqlite3 *db, int dbSqlOnly){
+ int rc;
+ char *zSql;
+ zSql = sqlite3_mprintf(
+ "BEGIN;\n"
+ "CREATE TEMP TABLE dbx AS SELECT DISTINCT dbcontent FROM db;\n"
+ "DELETE FROM db;\n"
+ "INSERT INTO db(dbid, dbcontent) "
+ " SELECT NULL, dbcontent FROM dbx ORDER BY 2;\n"
+ "DROP TABLE dbx;\n"
+ "CREATE TEMP TABLE sx AS SELECT DISTINCT sqltext FROM xsql %s;\n"
+ "DELETE FROM xsql;\n"
+ "INSERT INTO xsql(sqlid,sqltext) "
+ " SELECT NULL, sqltext FROM sx ORDER BY 2;\n"
+ "DROP TABLE sx;\n"
+ "COMMIT;\n"
+ "PRAGMA page_size=1024;\n"
+ "VACUUM;\n",
+ dbSqlOnly ? " WHERE isdbsql(sqltext)" : ""
+ );
+ rc = sqlite3_exec(db, zSql, 0, 0, 0);
+ sqlite3_free(zSql);
+ if( rc ) fatalError("cannot rebuild: %s", sqlite3_errmsg(db));
+}
+
+/*
+** Return the value of a hexadecimal digit. Return -1 if the input
+** is not a hex digit.
+*/
+static int hexDigitValue(char c){
+ if( c>='0' && c<='9' ) return c - '0';
+ if( c>='a' && c<='f' ) return c - 'a' + 10;
+ if( c>='A' && c<='F' ) return c - 'A' + 10;
+ return -1;
+}
+
+/*
+** Interpret zArg as an integer value, possibly with suffixes.
+*/
+static int integerValue(const char *zArg){
+ sqlite3_int64 v = 0;
+ static const struct { char *zSuffix; int iMult; } aMult[] = {
+ { "KiB", 1024 },
+ { "MiB", 1024*1024 },
+ { "GiB", 1024*1024*1024 },
+ { "KB", 1000 },
+ { "MB", 1000000 },
+ { "GB", 1000000000 },
+ { "K", 1000 },
+ { "M", 1000000 },
+ { "G", 1000000000 },
+ };
+ int i;
+ int isNeg = 0;
+ if( zArg[0]=='-' ){
+ isNeg = 1;
+ zArg++;
+ }else if( zArg[0]=='+' ){
+ zArg++;
+ }
+ if( zArg[0]=='0' && zArg[1]=='x' ){
+ int x;
+ zArg += 2;
+ while( (x = hexDigitValue(zArg[0]))>=0 ){
+ v = (v<<4) + x;
+ zArg++;
+ }
+ }else{
+ while( ISDIGIT(zArg[0]) ){
+ v = v*10 + zArg[0] - '0';
+ zArg++;
+ }
+ }
+ for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
+ if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
+ v *= aMult[i].iMult;
+ break;
+ }
+ }
+ if( v>0x7fffffff ) fatalError("parameter too large - max 2147483648");
+ return (int)(isNeg? -v : v);
+}
+
+/*
+** Return the number of "v" characters in a string. Return 0 if there
+** are any characters in the string other than "v".
+*/
+static int numberOfVChar(const char *z){
+ int N = 0;
+ while( z[0] && z[0]=='v' ){
+ z++;
+ N++;
+ }
+ return z[0]==0 ? N : 0;
+}
+
+/*
+** Print sketchy documentation for this utility program
+*/
+static void showHelp(void){
+ printf("Usage: %s [options] SOURCE-DB ?ARGS...?\n", g.zArgv0);
+ printf(
+"Read databases and SQL scripts from SOURCE-DB and execute each script against\n"
+"each database, checking for crashes and memory leaks.\n"
+"Options:\n"
+" --cell-size-check Set the PRAGMA cell_size_check=ON\n"
+" --dbid N Use only the database where dbid=N\n"
+" --export-db DIR Write databases to files(s) in DIR. Works with --dbid\n"
+" --export-sql DIR Write SQL to file(s) in DIR. Also works with --sqlid\n"
+" --help Show this help text\n"
+" --info Show information about SOURCE-DB w/o running tests\n"
+" --limit-depth N Limit expression depth to N. Default: 500\n"
+" --limit-heap N Limit heap memory to N. Default: 100M\n"
+" --limit-mem N Limit memory used by test SQLite instance to N bytes\n"
+" --limit-vdbe Panic if any test runs for more than 100,000 cycles\n"
+" --load-sql FILE.. Load SQL scripts fron files into SOURCE-DB\n"
+" --load-db FILE.. Load template databases from files into SOURCE_DB\n"
+" --load-dbsql FILE.. Load dbsqlfuzz outputs into the xsql table\n"
+" ^^^^------ Use \"-\" for FILE to read filenames from stdin\n"
+" -m TEXT Add a description to the database\n"
+" --native-vfs Use the native VFS for initially empty database files\n"
+" --native-malloc Turn off MEMSYS3/5 and Lookaside\n"
+" --no-recover Do not run recovery on dbsqlfuzz databases\n"
+" --oss-fuzz Enable OSS-FUZZ testing\n"
+" --prng-seed N Seed value for the PRGN inside of SQLite\n"
+" -q|--quiet Reduced output\n"
+" --rebuild Rebuild and vacuum the database file\n"
+" --result-trace Show the results of each SQL command\n"
+" --script Output CLI script instead of running tests\n"
+" --skip N Skip the first N test cases\n"
+" --spinner Use a spinner to show progress\n"
+" --sqlid N Use only SQL where sqlid=N\n"
+" --timeout N Maximum time for any one test in N millseconds\n"
+" -v|--verbose Increased output. Repeat for more output.\n"
+" --vdbe-debug Activate VDBE debugging.\n"
+ );
+}
+
+int main(int argc, char **argv){
+ sqlite3_int64 iBegin; /* Start time of this program */
+ int quietFlag = 0; /* True if --quiet or -q */
+ int verboseFlag = 0; /* True if --verbose or -v */
+ char *zInsSql = 0; /* SQL statement for --load-db or --load-sql */
+ int iFirstInsArg = 0; /* First argv[] for --load-db or --load-sql */
+ sqlite3 *db = 0; /* The open database connection */
+ sqlite3_stmt *pStmt; /* A prepared statement */
+ int rc; /* Result code from SQLite interface calls */
+ Blob *pSql; /* For looping over SQL scripts */
+ Blob *pDb; /* For looping over template databases */
+ int i; /* Loop index for the argv[] loop */
+ int dbSqlOnly = 0; /* Only use scripts that are dbsqlfuzz */
+ int onlySqlid = -1; /* --sqlid */
+ int onlyDbid = -1; /* --dbid */
+ int nativeFlag = 0; /* --native-vfs */
+ int rebuildFlag = 0; /* --rebuild */
+ int vdbeLimitFlag = 0; /* --limit-vdbe */
+ int infoFlag = 0; /* --info */
+ int nSkip = 0; /* --skip */
+ int bScript = 0; /* --script */
+ int bSpinner = 0; /* True for --spinner */
+ int timeoutTest = 0; /* undocumented --timeout-test flag */
+ int runFlags = 0; /* Flags sent to runSql() */
+ char *zMsg = 0; /* Add this message */
+ int nSrcDb = 0; /* Number of source databases */
+ char **azSrcDb = 0; /* Array of source database names */
+ int iSrcDb; /* Loop over all source databases */
+ int nTest = 0; /* Total number of tests performed */
+ char *zDbName = ""; /* Appreviated name of a source database */
+ const char *zFailCode = 0; /* Value of the TEST_FAILURE env variable */
+ int cellSzCkFlag = 0; /* --cell-size-check */
+ int sqlFuzz = 0; /* True for SQL fuzz. False for DB fuzz */
+ int iTimeout = 120000; /* Default 120-second timeout */
+ int nMem = 0; /* Memory limit override */
+ int nMemThisDb = 0; /* Memory limit set by the CONFIG table */
+ char *zExpDb = 0; /* Write Databases to files in this directory */
+ char *zExpSql = 0; /* Write SQL to files in this directory */
+ void *pHeap = 0; /* Heap for use by SQLite */
+ int ossFuzz = 0; /* enable OSS-FUZZ testing */
+ int ossFuzzThisDb = 0; /* ossFuzz value for this particular database */
+ int nativeMalloc = 0; /* Turn off MEMSYS3/5 and lookaside if true */
+ sqlite3_vfs *pDfltVfs; /* The default VFS */
+ int openFlags4Data; /* Flags for sqlite3_open_v2() */
+ int bTimer = 0; /* Show elapse time for each test */
+ int nV; /* How much to increase verbosity with -vvvv */
+ sqlite3_int64 tmStart; /* Start of each test */
+
+ sqlite3_config(SQLITE_CONFIG_URI,1);
+ registerOomSimulator();
+ sqlite3_initialize();
+ iBegin = timeOfDay();
+#ifdef __unix__
+ signal(SIGALRM, signalHandler);
+ signal(SIGSEGV, signalHandler);
+ signal(SIGABRT, signalHandler);
+#endif
+ g.zArgv0 = argv[0];
+ openFlags4Data = SQLITE_OPEN_READONLY;
+ zFailCode = getenv("TEST_FAILURE");
+ pDfltVfs = sqlite3_vfs_find(0);
+ inmemVfsRegister(1);
+ for(i=1; i<argc; i++){
+ const char *z = argv[i];
+ if( z[0]=='-' ){
+ z++;
+ if( z[0]=='-' ) z++;
+ if( strcmp(z,"cell-size-check")==0 ){
+ cellSzCkFlag = 1;
+ }else
+ if( strcmp(z,"dbid")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ onlyDbid = integerValue(argv[++i]);
+ }else
+ if( strcmp(z,"export-db")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ zExpDb = argv[++i];
+ }else
+ if( strcmp(z,"export-sql")==0 || strcmp(z,"export-dbsql")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ zExpSql = argv[++i];
+ }else
+ if( strcmp(z,"help")==0 ){
+ showHelp();
+ return 0;
+ }else
+ if( strcmp(z,"info")==0 ){
+ infoFlag = 1;
+ }else
+ if( strcmp(z,"limit-depth")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ depthLimit = integerValue(argv[++i]);
+ }else
+ if( strcmp(z,"limit-heap")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ heapLimit = integerValue(argv[++i]);
+ }else
+ if( strcmp(z,"limit-mem")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ nMem = integerValue(argv[++i]);
+ }else
+ if( strcmp(z,"limit-vdbe")==0 ){
+ vdbeLimitFlag = 1;
+ }else
+ if( strcmp(z,"load-sql")==0 ){
+ zInsSql = "INSERT INTO xsql(sqltext)"
+ "VALUES(CAST(readtextfile(?1) AS text))";
+ iFirstInsArg = i+1;
+ openFlags4Data = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
+ break;
+ }else
+ if( strcmp(z,"load-db")==0 ){
+ zInsSql = "INSERT INTO db(dbcontent) VALUES(readfile(?1))";
+ iFirstInsArg = i+1;
+ openFlags4Data = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
+ break;
+ }else
+ if( strcmp(z,"load-dbsql")==0 ){
+ zInsSql = "INSERT INTO xsql(sqltext)"
+ "VALUES(readfile(?1))";
+ iFirstInsArg = i+1;
+ openFlags4Data = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
+ dbSqlOnly = 1;
+ break;
+ }else
+ if( strcmp(z,"m")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ zMsg = argv[++i];
+ openFlags4Data = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
+ }else
+ if( strcmp(z,"native-malloc")==0 ){
+ nativeMalloc = 1;
+ }else
+ if( strcmp(z,"native-vfs")==0 ){
+ nativeFlag = 1;
+ }else
+ if( strcmp(z,"no-recover")==0 ){
+ bNoRecover = 1;
+ }else
+ if( strcmp(z,"oss-fuzz")==0 ){
+ ossFuzz = 1;
+ }else
+ if( strcmp(z,"prng-seed")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ g.uRandom = atoi(argv[++i]);
+ }else
+ if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
+ quietFlag = 1;
+ verboseFlag = 0;
+ eVerbosity = 0;
+ }else
+ if( strcmp(z,"rebuild")==0 ){
+ rebuildFlag = 1;
+ openFlags4Data = SQLITE_OPEN_READWRITE;
+ }else
+ if( strcmp(z,"result-trace")==0 ){
+ runFlags |= SQL_OUTPUT;
+ }else
+ if( strcmp(z,"script")==0 ){
+ bScript = 1;
+ }else
+ if( strcmp(z,"skip")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ nSkip = atoi(argv[++i]);
+ }else
+ if( strcmp(z,"spinner")==0 ){
+ bSpinner = 1;
+ }else
+ if( strcmp(z,"timer")==0 ){
+ bTimer = 1;
+ }else
+ if( strcmp(z,"sqlid")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ onlySqlid = integerValue(argv[++i]);
+ }else
+ if( strcmp(z,"timeout")==0 ){
+ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
+ iTimeout = integerValue(argv[++i]);
+ }else
+ if( strcmp(z,"timeout-test")==0 ){
+ timeoutTest = 1;
+#ifndef __unix__
+ fatalError("timeout is not available on non-unix systems");
+#endif
+ }else
+ if( strcmp(z,"vdbe-debug")==0 ){
+ bVdbeDebug = 1;
+ }else
+ if( strcmp(z,"verbose")==0 ){
+ quietFlag = 0;
+ verboseFlag++;
+ eVerbosity++;
+ if( verboseFlag>1 ) runFlags |= SQL_TRACE;
+ }else
+ if( (nV = numberOfVChar(z))>=1 ){
+ quietFlag = 0;
+ verboseFlag += nV;
+ eVerbosity += nV;
+ if( verboseFlag>1 ) runFlags |= SQL_TRACE;
+ }else
+ if( strcmp(z,"version")==0 ){
+ int ii;
+ const char *zz;
+ printf("SQLite %s %s\n", sqlite3_libversion(), sqlite3_sourceid());
+ for(ii=0; (zz = sqlite3_compileoption_get(ii))!=0; ii++){
+ printf("%s\n", zz);
+ }
+ return 0;
+ }else
+ if( strcmp(z,"is-dbsql")==0 ){
+ i++;
+ for(i++; i<argc; i++){
+ long nData;
+ char *aData = readFile(argv[i], &nData);
+ printf("%d %s\n", isDbSql((unsigned char*)aData,nData), argv[i]);
+ sqlite3_free(aData);
+ }
+ exit(0);
+ }else
+ {
+ fatalError("unknown option: %s", argv[i]);
+ }
+ }else{
+ nSrcDb++;
+ azSrcDb = safe_realloc(azSrcDb, nSrcDb*sizeof(azSrcDb[0]));
+ azSrcDb[nSrcDb-1] = argv[i];
+ }
+ }
+ if( nSrcDb==0 ) fatalError("no source database specified");
+ if( nSrcDb>1 ){
+ if( zMsg ){
+ fatalError("cannot change the description of more than one database");
+ }
+ if( zInsSql ){
+ fatalError("cannot import into more than one database");
+ }
+ }
+
+ /* Process each source database separately */
+ for(iSrcDb=0; iSrcDb<nSrcDb; iSrcDb++){
+ char *zRawData = 0;
+ long nRawData = 0;
+ g.zDbFile = azSrcDb[iSrcDb];
+ rc = sqlite3_open_v2(azSrcDb[iSrcDb], &db,
+ openFlags4Data, pDfltVfs->zName);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_exec(db, "SELECT count(*) FROM sqlite_schema", 0, 0, 0);
+ }
+ if( rc ){
+ sqlite3_close(db);
+ zRawData = readFile(azSrcDb[iSrcDb], &nRawData);
+ if( zRawData==0 ){
+ fatalError("input file \"%s\" is not recognized\n", azSrcDb[iSrcDb]);
+ }
+ sqlite3_open(":memory:", &db);
+ }
+
+ /* Print the description, if there is one */
+ if( infoFlag ){
+ int n;
+ zDbName = azSrcDb[iSrcDb];
+ i = (int)strlen(zDbName) - 1;
+ while( i>0 && zDbName[i-1]!='/' && zDbName[i-1]!='\\' ){ i--; }
+ zDbName += i;
+ sqlite3_prepare_v2(db, "SELECT msg FROM readme", -1, &pStmt, 0);
+ if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("%s: %s", zDbName, sqlite3_column_text(pStmt,0));
+ }else{
+ printf("%s: (empty \"readme\")", zDbName);
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_prepare_v2(db, "SELECT count(*) FROM db", -1, &pStmt, 0);
+ if( pStmt
+ && sqlite3_step(pStmt)==SQLITE_ROW
+ && (n = sqlite3_column_int(pStmt,0))>0
+ ){
+ printf(" - %d DBs", n);
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_prepare_v2(db, "SELECT count(*) FROM xsql", -1, &pStmt, 0);
+ if( pStmt
+ && sqlite3_step(pStmt)==SQLITE_ROW
+ && (n = sqlite3_column_int(pStmt,0))>0
+ ){
+ printf(" - %d scripts", n);
+ }
+ sqlite3_finalize(pStmt);
+ printf("\n");
+ sqlite3_close(db);
+ sqlite3_free(zRawData);
+ continue;
+ }
+
+ rc = sqlite3_exec(db,
+ "CREATE TABLE IF NOT EXISTS db(\n"
+ " dbid INTEGER PRIMARY KEY, -- database id\n"
+ " dbcontent BLOB -- database disk file image\n"
+ ");\n"
+ "CREATE TABLE IF NOT EXISTS xsql(\n"
+ " sqlid INTEGER PRIMARY KEY, -- SQL script id\n"
+ " sqltext TEXT -- Text of SQL statements to run\n"
+ ");"
+ "CREATE TABLE IF NOT EXISTS readme(\n"
+ " msg TEXT -- Human-readable description of this file\n"
+ ");", 0, 0, 0);
+ if( rc ) fatalError("cannot create schema: %s", sqlite3_errmsg(db));
+ if( zMsg ){
+ char *zSql;
+ zSql = sqlite3_mprintf(
+ "DELETE FROM readme; INSERT INTO readme(msg) VALUES(%Q)", zMsg);
+ rc = sqlite3_exec(db, zSql, 0, 0, 0);
+ sqlite3_free(zSql);
+ if( rc ) fatalError("cannot change description: %s", sqlite3_errmsg(db));
+ }
+ if( zRawData ){
+ zInsSql = "INSERT INTO xsql(sqltext) VALUES(?1)";
+ rc = sqlite3_prepare_v2(db, zInsSql, -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare statement [%s]: %s",
+ zInsSql, sqlite3_errmsg(db));
+ sqlite3_bind_text(pStmt, 1, zRawData, nRawData, SQLITE_STATIC);
+ sqlite3_step(pStmt);
+ rc = sqlite3_reset(pStmt);
+ if( rc ) fatalError("insert failed for %s", argv[i]);
+ sqlite3_finalize(pStmt);
+ rebuild_database(db, dbSqlOnly);
+ zInsSql = 0;
+ sqlite3_free(zRawData);
+ zRawData = 0;
+ }
+ ossFuzzThisDb = ossFuzz;
+
+ /* If the CONFIG(name,value) table exists, read db-specific settings
+ ** from that table */
+ if( sqlite3_table_column_metadata(db,0,"config",0,0,0,0,0,0)==SQLITE_OK ){
+ rc = sqlite3_prepare_v2(db, "SELECT name, value FROM config",
+ -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare query of CONFIG table: %s",
+ sqlite3_errmsg(db));
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){
+ const char *zName = (const char *)sqlite3_column_text(pStmt,0);
+ if( zName==0 ) continue;
+ if( strcmp(zName, "oss-fuzz")==0 ){
+ ossFuzzThisDb = sqlite3_column_int(pStmt,1);
+ if( verboseFlag ) printf("Config: oss-fuzz=%d\n", ossFuzzThisDb);
+ }
+ if( strcmp(zName, "limit-mem")==0 ){
+ nMemThisDb = sqlite3_column_int(pStmt,1);
+ if( verboseFlag ) printf("Config: limit-mem=%d\n", nMemThisDb);
+ }
+ }
+ sqlite3_finalize(pStmt);
+ }
+
+ if( zInsSql ){
+ sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
+ readfileFunc, 0, 0);
+ sqlite3_create_function(db, "readtextfile", 1, SQLITE_UTF8, 0,
+ readtextfileFunc, 0, 0);
+ sqlite3_create_function(db, "isdbsql", 1, SQLITE_UTF8, 0,
+ isDbSqlFunc, 0, 0);
+ rc = sqlite3_prepare_v2(db, zInsSql, -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare statement [%s]: %s",
+ zInsSql, sqlite3_errmsg(db));
+ rc = sqlite3_exec(db, "BEGIN", 0, 0, 0);
+ if( rc ) fatalError("cannot start a transaction");
+ for(i=iFirstInsArg; i<argc; i++){
+ if( strcmp(argv[i],"-")==0 ){
+ /* A filename of "-" means read multiple filenames from stdin */
+ char zLine[2000];
+ while( rc==0 && fgets(zLine,sizeof(zLine),stdin)!=0 ){
+ size_t kk = strlen(zLine);
+ while( kk>0 && zLine[kk-1]<=' ' ) kk--;
+ sqlite3_bind_text(pStmt, 1, zLine, (int)kk, SQLITE_STATIC);
+ if( verboseFlag ) printf("loading %.*s\n", (int)kk, zLine);
+ sqlite3_step(pStmt);
+ rc = sqlite3_reset(pStmt);
+ if( rc ) fatalError("insert failed for %s", zLine);
+ }
+ }else{
+ sqlite3_bind_text(pStmt, 1, argv[i], -1, SQLITE_STATIC);
+ if( verboseFlag ) printf("loading %s\n", argv[i]);
+ sqlite3_step(pStmt);
+ rc = sqlite3_reset(pStmt);
+ if( rc ) fatalError("insert failed for %s", argv[i]);
+ }
+ }
+ sqlite3_finalize(pStmt);
+ rc = sqlite3_exec(db, "COMMIT", 0, 0, 0);
+ if( rc ) fatalError("cannot commit the transaction: %s",
+ sqlite3_errmsg(db));
+ rebuild_database(db, dbSqlOnly);
+ sqlite3_close(db);
+ return 0;
+ }
+ rc = sqlite3_exec(db, "PRAGMA query_only=1;", 0, 0, 0);
+ if( rc ) fatalError("cannot set database to query-only");
+ if( zExpDb!=0 || zExpSql!=0 ){
+ sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
+ writefileFunc, 0, 0);
+ if( zExpDb!=0 ){
+ const char *zExDb =
+ "SELECT writefile(printf('%s/db%06d.db',?1,dbid),dbcontent),"
+ " dbid, printf('%s/db%06d.db',?1,dbid), length(dbcontent)"
+ " FROM db WHERE ?2<0 OR dbid=?2;";
+ rc = sqlite3_prepare_v2(db, zExDb, -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare statement [%s]: %s",
+ zExDb, sqlite3_errmsg(db));
+ sqlite3_bind_text64(pStmt, 1, zExpDb, strlen(zExpDb),
+ SQLITE_STATIC, SQLITE_UTF8);
+ sqlite3_bind_int(pStmt, 2, onlyDbid);
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("write db-%d (%d bytes) into %s\n",
+ sqlite3_column_int(pStmt,1),
+ sqlite3_column_int(pStmt,3),
+ sqlite3_column_text(pStmt,2));
+ }
+ sqlite3_finalize(pStmt);
+ }
+ if( zExpSql!=0 ){
+ const char *zExSql =
+ "SELECT writefile(printf('%s/sql%06d.txt',?1,sqlid),sqltext),"
+ " sqlid, printf('%s/sql%06d.txt',?1,sqlid), length(sqltext)"
+ " FROM xsql WHERE ?2<0 OR sqlid=?2;";
+ rc = sqlite3_prepare_v2(db, zExSql, -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare statement [%s]: %s",
+ zExSql, sqlite3_errmsg(db));
+ sqlite3_bind_text64(pStmt, 1, zExpSql, strlen(zExpSql),
+ SQLITE_STATIC, SQLITE_UTF8);
+ sqlite3_bind_int(pStmt, 2, onlySqlid);
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("write sql-%d (%d bytes) into %s\n",
+ sqlite3_column_int(pStmt,1),
+ sqlite3_column_int(pStmt,3),
+ sqlite3_column_text(pStmt,2));
+ }
+ sqlite3_finalize(pStmt);
+ }
+ sqlite3_close(db);
+ return 0;
+ }
+
+ /* Load all SQL script content and all initial database images from the
+ ** source db
+ */
+ blobListLoadFromDb(db, "SELECT sqlid, sqltext FROM xsql", onlySqlid,
+ &g.nSql, &g.pFirstSql);
+ if( g.nSql==0 ) fatalError("need at least one SQL script");
+ blobListLoadFromDb(db, "SELECT dbid, dbcontent FROM db", onlyDbid,
+ &g.nDb, &g.pFirstDb);
+ if( g.nDb==0 ){
+ g.pFirstDb = safe_realloc(0, sizeof(Blob));
+ memset(g.pFirstDb, 0, sizeof(Blob));
+ g.pFirstDb->id = 1;
+ g.pFirstDb->seq = 0;
+ g.nDb = 1;
+ sqlFuzz = 1;
+ }
+
+ /* Print the description, if there is one */
+ if( !quietFlag && !bScript ){
+ zDbName = azSrcDb[iSrcDb];
+ i = (int)strlen(zDbName) - 1;
+ while( i>0 && zDbName[i-1]!='/' && zDbName[i-1]!='\\' ){ i--; }
+ zDbName += i;
+ sqlite3_prepare_v2(db, "SELECT msg FROM readme", -1, &pStmt, 0);
+ if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("%s: %s\n", zDbName, sqlite3_column_text(pStmt,0));
+ }
+ sqlite3_finalize(pStmt);
+ }
+
+ /* Rebuild the database, if requested */
+ if( rebuildFlag ){
+ if( !quietFlag ){
+ printf("%s: rebuilding... ", zDbName);
+ fflush(stdout);
+ }
+ rebuild_database(db, 0);
+ if( !quietFlag ) printf("done\n");
+ }
+
+ /* Close the source database. Verify that no SQLite memory allocations are
+ ** outstanding.
+ */
+ sqlite3_close(db);
+ if( sqlite3_memory_used()>0 ){
+ fatalError("SQLite has memory in use before the start of testing");
+ }
+
+ /* Limit available memory, if requested */
+ sqlite3_shutdown();
+
+ if( nMemThisDb>0 && nMem==0 ){
+ if( !nativeMalloc ){
+ pHeap = realloc(pHeap, nMemThisDb);
+ if( pHeap==0 ){
+ fatalError("failed to allocate %d bytes of heap memory", nMem);
+ }
+ sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nMemThisDb, 128);
+ }else{
+ sqlite3_hard_heap_limit64((sqlite3_int64)nMemThisDb);
+ }
+ }else{
+ sqlite3_hard_heap_limit64(0);
+ }
+
+ /* Disable lookaside with the --native-malloc option */
+ if( nativeMalloc ){
+ sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0);
+ }
+
+ /* Reset the in-memory virtual filesystem */
+ formatVfs();
+
+ /* Run a test using each SQL script against each database.
+ */
+ if( !verboseFlag && !quietFlag && !bSpinner && !bScript ){
+ printf("%s:", zDbName);
+ }
+ for(pSql=g.pFirstSql; pSql; pSql=pSql->pNext){
+ tmStart = timeOfDay();
+ if( isDbSql(pSql->a, pSql->sz) ){
+ sqlite3_snprintf(sizeof(g.zTestName), g.zTestName, "sqlid=%d",pSql->id);
+ if( bScript ){
+ /* No progress output */
+ }else if( bSpinner ){
+ int nTotal =g.nSql;
+ int idx = pSql->seq;
+ printf("\r%s: %d/%d ", zDbName, idx, nTotal);
+ fflush(stdout);
+ }else if( verboseFlag ){
+ printf("%s\n", g.zTestName);
+ fflush(stdout);
+ }else if( !quietFlag ){
+ static int prevAmt = -1;
+ int idx = pSql->seq;
+ int amt = idx*10/(g.nSql);
+ if( amt!=prevAmt ){
+ printf(" %d%%", amt*10);
+ fflush(stdout);
+ prevAmt = amt;
+ }
+ }
+ if( nSkip>0 ){
+ nSkip--;
+ }else{
+ runCombinedDbSqlInput(pSql->a, pSql->sz, iTimeout, bScript, pSql->id);
+ }
+ nTest++;
+ if( bTimer && !bScript ){
+ sqlite3_int64 tmEnd = timeOfDay();
+ printf("%lld %s\n", tmEnd - tmStart, g.zTestName);
+ }
+ g.zTestName[0] = 0;
+ disableOom();
+ continue;
+ }
+ for(pDb=g.pFirstDb; pDb; pDb=pDb->pNext){
+ int openFlags;
+ const char *zVfs = "inmem";
+ sqlite3_snprintf(sizeof(g.zTestName), g.zTestName, "sqlid=%d,dbid=%d",
+ pSql->id, pDb->id);
+ if( bScript ){
+ /* No progress output */
+ }else if( bSpinner ){
+ int nTotal = g.nDb*g.nSql;
+ int idx = pSql->seq*g.nDb + pDb->id - 1;
+ printf("\r%s: %d/%d ", zDbName, idx, nTotal);
+ fflush(stdout);
+ }else if( verboseFlag ){
+ printf("%s\n", g.zTestName);
+ fflush(stdout);
+ }else if( !quietFlag ){
+ static int prevAmt = -1;
+ int idx = pSql->seq*g.nDb + pDb->id - 1;
+ int amt = idx*10/(g.nDb*g.nSql);
+ if( amt!=prevAmt ){
+ printf(" %d%%", amt*10);
+ fflush(stdout);
+ prevAmt = amt;
+ }
+ }
+ if( nSkip>0 ){
+ nSkip--;
+ continue;
+ }
+ if( bScript ){
+ char zName[100];
+ sqlite3_snprintf(sizeof(zName), zName, "db%06d.db",
+ pDb->id>1 ? pDb->id : pSql->id);
+ renderDbSqlForCLI(stdout, zName,
+ pDb->a, pDb->sz, pSql->a, pSql->sz);
+ continue;
+ }
+ createVFile("main.db", pDb->sz, pDb->a);
+ sqlite3_randomness(0,0);
+ if( ossFuzzThisDb ){
+#ifndef SQLITE_OSS_FUZZ
+ fatalError("--oss-fuzz not supported: recompile"
+ " with -DSQLITE_OSS_FUZZ");
+#else
+ extern int LLVMFuzzerTestOneInput(const uint8_t*, size_t);
+ LLVMFuzzerTestOneInput((const uint8_t*)pSql->a, (size_t)pSql->sz);
+#endif
+ }else{
+ openFlags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE;
+ if( nativeFlag && pDb->sz==0 ){
+ openFlags |= SQLITE_OPEN_MEMORY;
+ zVfs = 0;
+ }
+ rc = sqlite3_open_v2("main.db", &db, openFlags, zVfs);
+ if( rc ) fatalError("cannot open inmem database");
+ sqlite3_limit(db, SQLITE_LIMIT_LENGTH, 100000000);
+ sqlite3_limit(db, SQLITE_LIMIT_LIKE_PATTERN_LENGTH, 50);
+ if( cellSzCkFlag ) runSql(db, "PRAGMA cell_size_check=ON", runFlags);
+ setAlarm((iTimeout+999)/1000);
+ /* Enable test functions */
+ sqlite3_test_control(SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, db);
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ if( sqlFuzz || vdbeLimitFlag ){
+ sqlite3_progress_handler(db, 100000, progressHandler,
+ &vdbeLimitFlag);
+ }
+#endif
+#ifdef SQLITE_TESTCTRL_PRNG_SEED
+ sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SEED, 1, db);
+#endif
+ if( bVdbeDebug ){
+ sqlite3_exec(db, "PRAGMA vdbe_debug=ON", 0, 0, 0);
+ }
+ do{
+ runSql(db, (char*)pSql->a, runFlags);
+ }while( timeoutTest );
+ setAlarm(0);
+ sqlite3_exec(db, "PRAGMA temp_store_directory=''", 0, 0, 0);
+ sqlite3_close(db);
+ }
+ if( sqlite3_memory_used()>0 ){
+ fatalError("memory leak: %lld bytes outstanding",
+ sqlite3_memory_used());
+ }
+ reformatVfs();
+ nTest++;
+ if( bTimer ){
+ sqlite3_int64 tmEnd = timeOfDay();
+ printf("%lld %s\n", tmEnd - tmStart, g.zTestName);
+ }
+ g.zTestName[0] = 0;
+
+ /* Simulate an error if the TEST_FAILURE environment variable is "5".
+ ** This is used to verify that automated test script really do spot
+ ** errors that occur in this test program.
+ */
+ if( zFailCode ){
+ if( zFailCode[0]=='5' && zFailCode[1]==0 ){
+ fatalError("simulated failure");
+ }else if( zFailCode[0]!=0 ){
+ /* If TEST_FAILURE is something other than 5, just exit the test
+ ** early */
+ printf("\nExit early due to TEST_FAILURE being set\n");
+ iSrcDb = nSrcDb-1;
+ goto sourcedb_cleanup;
+ }
+ }
+ }
+ }
+ if( bScript ){
+ /* No progress output */
+ }else if( bSpinner ){
+ int nTotal = g.nDb*g.nSql;
+ printf("\r%s: %d/%d \n", zDbName, nTotal, nTotal);
+ }else if( !quietFlag && !verboseFlag ){
+ printf(" 100%% - %d tests\n", g.nDb*g.nSql);
+ }
+
+ /* Clean up at the end of processing a single source database
+ */
+ sourcedb_cleanup:
+ blobListFree(g.pFirstSql);
+ blobListFree(g.pFirstDb);
+ reformatVfs();
+
+ } /* End loop over all source databases */
+
+ if( !quietFlag && !bScript ){
+ sqlite3_int64 iElapse = timeOfDay() - iBegin;
+ if( g.nInvariant ){
+ printf("fuzzcheck: %u query invariants checked\n", g.nInvariant);
+ }
+ printf("fuzzcheck: 0 errors out of %d tests in %d.%03d seconds\n"
+ "SQLite %s %s\n",
+ nTest, (int)(iElapse/1000), (int)(iElapse%1000),
+ sqlite3_libversion(), sqlite3_sourceid());
+ }
+ free(azSrcDb);
+ free(pHeap);
+ return 0;
+}
diff --git a/test/fuzzdata1.db b/test/fuzzdata1.db
new file mode 100644
index 0000000..11a9174
--- /dev/null
+++ b/test/fuzzdata1.db
Binary files differ
diff --git a/test/fuzzdata2.db b/test/fuzzdata2.db
new file mode 100644
index 0000000..7682790
--- /dev/null
+++ b/test/fuzzdata2.db
Binary files differ
diff --git a/test/fuzzdata3.db b/test/fuzzdata3.db
new file mode 100644
index 0000000..0a41fd6
--- /dev/null
+++ b/test/fuzzdata3.db
Binary files differ
diff --git a/test/fuzzdata4.db b/test/fuzzdata4.db
new file mode 100644
index 0000000..254bf83
--- /dev/null
+++ b/test/fuzzdata4.db
Binary files differ
diff --git a/test/fuzzdata5.db b/test/fuzzdata5.db
new file mode 100644
index 0000000..cfb0ebe
--- /dev/null
+++ b/test/fuzzdata5.db
Binary files differ
diff --git a/test/fuzzdata6.db b/test/fuzzdata6.db
new file mode 100644
index 0000000..b1424c2
--- /dev/null
+++ b/test/fuzzdata6.db
Binary files differ
diff --git a/test/fuzzdata7.db b/test/fuzzdata7.db
new file mode 100644
index 0000000..99daab1
--- /dev/null
+++ b/test/fuzzdata7.db
Binary files differ
diff --git a/test/fuzzdata8.db b/test/fuzzdata8.db
new file mode 100644
index 0000000..aff7e27
--- /dev/null
+++ b/test/fuzzdata8.db
Binary files differ
diff --git a/test/fuzzer1.test b/test/fuzzer1.test
new file mode 100644
index 0000000..5e361e9
--- /dev/null
+++ b/test/fuzzer1.test
@@ -0,0 +1,1820 @@
+# 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
+}
+
+set ::testprefix fuzzer1
+load_static_extension db fuzzer
+
+# Check configuration errors.
+#
+do_catchsql_test fuzzer1-1.1 {
+ CREATE VIRTUAL TABLE f USING fuzzer;
+} {1 {fuzzer: wrong number of CREATE VIRTUAL TABLE arguments}}
+
+do_catchsql_test fuzzer1-1.2 {
+ CREATE VIRTUAL TABLE f USING fuzzer(one, two);
+} {1 {fuzzer: wrong number of CREATE VIRTUAL TABLE arguments}}
+
+do_catchsql_test fuzzer1-1.3 {
+ CREATE VIRTUAL TABLE f USING fuzzer(nosuchtable);
+} {1 {fuzzer: no such table: main.nosuchtable}}
+
+do_catchsql_test fuzzer1-1.4 {
+ CREATE TEMP TABLE nosuchtable(a, b, c, d);
+ CREATE VIRTUAL TABLE f USING fuzzer(nosuchtable);
+} {1 {fuzzer: no such table: main.nosuchtable}}
+
+do_catchsql_test fuzzer1-1.5 {
+ DROP TABLE temp.nosuchtable;
+ CREATE TABLE nosuchtable(a, b, c, d);
+ CREATE VIRTUAL TABLE temp.f USING fuzzer(nosuchtable);
+} {1 {fuzzer: no such table: temp.nosuchtable}}
+
+do_catchsql_test fuzzer1-1.6 {
+ DROP TABLE IF EXISTS f_rules;
+ CREATE TABLE f_rules(a, b, c);
+ CREATE VIRTUAL TABLE f USING fuzzer(f_rules);
+} {1 {fuzzer: f_rules has 3 columns, expected 4}}
+
+do_catchsql_test fuzzer1-1.7 {
+ DROP TABLE IF EXISTS f_rules;
+ CREATE TABLE f_rules(a, b, c, d, e);
+ CREATE VIRTUAL TABLE f USING fuzzer(f_rules);
+} {1 {fuzzer: f_rules has 5 columns, expected 4}}
+
+
+do_execsql_test fuzzer1-2.1 {
+ CREATE TABLE f1_rules(ruleset DEFAULT 0, cfrom, cto, cost);
+ INSERT INTO f1_rules(cfrom, cto, cost) VALUES('e','a',1);
+ INSERT INTO f1_rules(cfrom, cto, cost) VALUES('a','e',10);
+ INSERT INTO f1_rules(cfrom, cto, cost) VALUES('e','o',100);
+
+ CREATE VIRTUAL TABLE f1 USING fuzzer(f1_rules);
+} {}
+
+do_execsql_test fuzzer1-2.1 {
+ 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_execsql_test fuzzer1-2.4 {
+ INSERT INTO f1_rules(ruleset, cfrom, cto, cost) VALUES(1,'b','x',1);
+ INSERT INTO f1_rules(ruleset, cfrom, cto, cost) VALUES(1,'d','y',10);
+ INSERT INTO f1_rules(ruleset, cfrom, cto, cost) VALUES(1,'y','z',100);
+
+ DROP TABLE f1;
+ CREATE VIRTUAL TABLE f1 USING fuzzer(f1_rules);
+} {}
+
+do_execsql_test fuzzer1-2.5 {
+ 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_execsql_test fuzzer1-2.6 {
+ SELECT word, distance FROM f1 WHERE word MATCH 'abcde' AND ruleset=0
+} {
+ abcde 0 abcda 1 ebcde 10
+ ebcda 11 abcdo 100 ebcdo 110
+ obcde 110 obcda 111 obcdo 210
+}
+
+do_execsql_test fuzzer1-2.7 {
+ SELECT word, distance FROM f1 WHERE word MATCH 'abcde' AND ruleset=1
+} {
+ abcde 0 axcde 1 abcye 10
+ axcye 11 abcze 110 axcze 111
+}
+
+do_test fuzzer1-1.8 {
+ db eval {
+ SELECT word, distance FROM f1 WHERE word MATCH 'abcde' AND distance<100
+ }
+} {abcde 0 abcda 1 ebcde 10 ebcda 11}
+do_test fuzzer1-1.9 {
+ db eval {
+ SELECT word, distance FROM f1 WHERE word MATCH 'abcde' AND distance<=100
+ }
+} {abcde 0 abcda 1 ebcde 10 ebcda 11 abcdo 100}
+do_test fuzzer1-1.10 {
+ db eval {
+ SELECT word, distance FROM f1
+ WHERE word MATCH 'abcde' AND distance<100 AND ruleset=0
+ }
+} {abcde 0 abcda 1 ebcde 10 ebcda 11}
+do_test fuzzer1-1.11 {
+ db eval {
+ SELECT word, distance FROM f1
+ WHERE word MATCH 'abcde' AND distance<=100 AND ruleset=0
+ }
+} {abcde 0 abcda 1 ebcde 10 ebcda 11 abcdo 100}
+do_test fuzzer1-1.12 {
+ db eval {
+ SELECT word, distance FROM f1
+ WHERE word MATCH 'abcde' AND distance<11 AND ruleset=1
+ }
+} {abcde 0 axcde 1 abcye 10}
+do_test fuzzer1-1.13 {
+ db eval {
+ SELECT word, distance FROM f1
+ WHERE word MATCH 'abcde' AND distance<=11 AND ruleset=1
+ }
+} {abcde 0 axcde 1 abcye 10 axcye 11}
+do_test fuzzer1-1.14 {
+ catchsql {INSERT INTO f1 VALUES(1)}
+} {1 {table f1 may not be modified}}
+do_test fuzzer1-1.15 {
+ catchsql {DELETE FROM f1}
+} {1 {table f1 may not be modified}}
+do_test fuzzer1-1.16 {
+ catchsql {UPDATE f1 SET rowid=rowid+10000}
+} {1 {table f1 may not be modified}}
+
+
+do_test fuzzer1-2.0 {
+ execsql {
+ -- costs based on English letter frequencies
+ CREATE TEMP TABLE f2_rules(ruleset DEFAULT 0, cFrom, cTo, cost);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('a','e',24);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('a','o',47);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('a','u',50);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('e','a',23);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('e','i',33);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('e','o',37);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('i','e',33);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('i','y',33);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('o','a',41);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('o','e',46);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('o','u',57);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('u','o',58);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('y','i',33);
+
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('t','th',70);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('th','t',66);
+
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('a','',84);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','b',106);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('b','',106);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','c',94);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('c','',94);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','d',89);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('d','',89);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','e',83);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('e','',83);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','f',97);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('f','',97);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','g',99);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('g','',99);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','h',86);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('h','',86);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','i',85);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('i','',85);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','j',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('j','',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','k',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('k','',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','l',89);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('l','',89);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','m',96);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('m','',96);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','n',85);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('n','',85);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','o',85);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('o','',85);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','p',100);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('p','',100);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','q',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('q','',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','r',86);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('r','',86);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','s',86);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('s','',86);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','t',84);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('t','',84);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','u',94);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('u','',94);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','v',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('v','',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','w',96);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('w','',96);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','x',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('x','',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','y',100);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('y','',100);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','z',120);
+ INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('z','',120);
+ INSERT INTO f2_rules(ruleset,cFrom,cTo,cost)
+ SELECT 1, cFrom, cTo, 100 FROM f2_rules WHERE ruleset=0;
+ INSERT INTO f2_rules(ruleset,cFrom,cTo,cost)
+ SELECT 2, cFrom, cTo, 200-cost FROM f2_rules WHERE ruleset=0;
+ INSERT INTO f2_rules(ruleset,cFrom,cTo,cost)
+ SELECT 3, cFrom, cTo, cost FROM f2_rules WHERE ruleset=0;
+ INSERT INTO f2_rules(ruleset,cFrom,cTo,cost)
+ VALUES(3, 'mallard','duck',50),
+ (3, 'duck', 'mallard', 50),
+ (3, 'rock', 'stone', 50),
+ (3, 'stone', 'rock', 50);
+
+
+ CREATE VIRTUAL TABLE temp.f2 USING fuzzer(f2_rules);
+
+ -- 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}
+do_test fuzzer1-2.4 {
+ execsql {
+ SELECT DISTINCT streetname.n
+ FROM f2 JOIN streetname
+ ON (streetname.n>=f2.word AND streetname.n<=(f2.word || 'zzzzzz'))
+ WHERE f2.word MATCH 'duck'
+ AND f2.distance<150
+ AND f2.ruleset=3
+ ORDER BY 1
+ }
+} {mallard {mallard cove} {mallard forest} {mallard grove} {mallard hill} {mallard park} {mallard ridge} {mallard view}}
+do_test fuzzer1-2.5 {
+ execsql {
+ SELECT DISTINCT streetname.n
+ FROM f2 JOIN streetname
+ ON (streetname.n>=f2.word AND streetname.n<=(f2.word || 'zzzzzz'))
+ WHERE f2.word MATCH 'duck'
+ AND f2.distance<150
+ AND f2.ruleset=2
+ ORDER BY 1
+ }
+} {}
+
+forcedelete test.db2
+do_execsql_test fuzzer1-4.1 {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.f3_rules(ruleset, cfrom, cto, cost);
+ INSERT INTO f3_rules(ruleset, cfrom, cto, cost) VALUES(0, 'x','y', 10);
+ INSERT INTO f3_rules(ruleset, cfrom, cto, cost) VALUES(1, 'a','b', 10);
+ CREATE VIRTUAL TABLE aux.f3 USING fuzzer(f3_rules);
+ SELECT word FROM f3 WHERE word MATCH 'ax'
+} {ax ay}
+
+#-------------------------------------------------------------------------
+#
+# 1.5.1 - Check things work with a fuzzer data table name that requires
+# quoting. Also that NULL entries in the "from" column of the
+# data table are treated as zero length strings ('').
+#
+# 1.5.2 - Check that no-op rules (i.e. C->C) are ignored. Test NULL in
+# the "to" column of a fuzzer data table.
+#
+# 1.5.3 - Test out-of-range values for the cost field of the data table.
+#
+# 1.5.4 - Test out-of-range values for the string fields of the data table.
+#
+# 1.5.5 - Test out-of-range values for the ruleset field of the data table.
+#
+do_execsql_test 5.1 {
+ CREATE TABLE "fuzzer [x] rules table"(a, b, c, d);
+ INSERT INTO "fuzzer [x] rules table" VALUES(0, NULL, 'abc', 10);
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+ SELECT word, distance FROM x WHERE word MATCH '123' LIMIT 4;
+} {123 0 abc123 10 1abc23 10 12abc3 10}
+
+do_execsql_test 5.2 {
+ DELETE FROM "fuzzer [x] rules table";
+ INSERT INTO "fuzzer [x] rules table" VALUES(0, 'x', NULL, 20);
+ INSERT INTO "fuzzer [x] rules table" VALUES(0, NULL, NULL, 10);
+ INSERT INTO "fuzzer [x] rules table" VALUES(0, 'x', 'x', 10);
+
+ DROP TABLE x;
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+
+ SELECT word, distance FROM x WHERE word MATCH 'xx';
+} {xx 0 x 20 {} 40}
+
+do_execsql_test 5.3.1 {
+ DROP TABLE IF EXISTS x;
+ INSERT INTO "fuzzer [x] rules table" VALUES(0, 'c', 'd', 1001);
+}
+do_catchsql_test 5.3.2 {
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+} {1 {fuzzer: cost must be between 1 and 1000}}
+
+do_execsql_test 5.3.3 {
+ DROP TABLE IF EXISTS x;
+ DELETE FROM "fuzzer [x] rules table";
+ INSERT INTO "fuzzer [x] rules table" VALUES(0, 'd', 'c', 0);
+}
+do_catchsql_test 5.3.4 {
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+} {1 {fuzzer: cost must be between 1 and 1000}}
+
+do_execsql_test 5.3.5 {
+ DROP TABLE IF EXISTS x;
+ DELETE FROM "fuzzer [x] rules table";
+ INSERT INTO "fuzzer [x] rules table" VALUES(0, 'd', 'c', -20);
+}
+do_catchsql_test 5.3.6 {
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+} {1 {fuzzer: cost must be between 1 and 1000}}
+
+do_execsql_test 5.4.1 {
+ DROP TABLE IF EXISTS x;
+ DELETE FROM "fuzzer [x] rules table";
+ INSERT INTO "fuzzer [x] rules table" VALUES(
+ 0, 'x', '12345678901234567890123456789012345678901234567890', 2
+ );
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+ SELECT word FROM x WHERE word MATCH 'x';
+} {x 12345678901234567890123456789012345678901234567890}
+
+do_execsql_test 5.4.2 {
+ DROP TABLE IF EXISTS x;
+ DELETE FROM "fuzzer [x] rules table";
+ INSERT INTO "fuzzer [x] rules table" VALUES(
+ 0, 'x', '123456789012345678901234567890123456789012345678901', 2
+ );
+}
+do_catchsql_test 5.4.3 {
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+} {1 {fuzzer: maximum string length is 50}}
+
+do_execsql_test 5.4.4 {
+ DROP TABLE IF EXISTS x;
+ DELETE FROM "fuzzer [x] rules table";
+ INSERT INTO "fuzzer [x] rules table" VALUES(
+ 0, '123456789012345678901234567890123456789012345678901', 'x', 2
+ );
+}
+do_catchsql_test 5.4.5 {
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+} {1 {fuzzer: maximum string length is 50}}
+
+do_execsql_test 5.5.1 {
+ DROP TABLE IF EXISTS x;
+ DELETE FROM "fuzzer [x] rules table";
+ INSERT INTO "fuzzer [x] rules table" VALUES(-1, 'x', 'y', 2);
+}
+do_catchsql_test 5.5.2 {
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+} {1 {fuzzer: ruleset must be between 0 and 2147483647}}
+
+do_execsql_test 5.5.3 {
+ DROP TABLE IF EXISTS x;
+ DELETE FROM "fuzzer [x] rules table";
+ INSERT INTO "fuzzer [x] rules table" VALUES((1<<32)+100, 'x', 'y', 2);
+}
+do_catchsql_test 5.5.4 {
+ CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
+} {1 {fuzzer: ruleset must be between 0 and 2147483647}}
+
+#-------------------------------------------------------------------------
+# Test using different types of quotes with CREATE VIRTUAL TABLE
+# arguments.
+#
+do_execsql_test 7.1 {
+ CREATE TABLE [x2 "rules] (a, b, c, d);
+ INSERT INTO [x2 "rules] VALUES(0, 'a', 'b', 5);
+}
+foreach {tn sql} {
+ 1 { CREATE VIRTUAL TABLE x2 USING fuzzer( [x2 "rules] ) }
+ 2 { CREATE VIRTUAL TABLE x2 USING fuzzer( "x2 ""rules" ) }
+ 3 { CREATE VIRTUAL TABLE x2 USING fuzzer( 'x2 "rules' ) }
+ 4 { CREATE VIRTUAL TABLE x2 USING fuzzer( `x2 "rules` ) }
+} {
+ do_execsql_test 7.2.$tn.1 { DROP TABLE IF EXISTS x2 }
+ do_execsql_test 7.2.$tn.2 $sql
+ do_execsql_test 7.2.$tn.3 {
+ SELECT word FROM x2 WHERE word MATCH 'aaa'
+ } {aaa baa aba aab bab abb bba bbb}
+}
+
+#-------------------------------------------------------------------------
+# Test using a fuzzer table in different contexts.
+#
+do_execsql_test 8.1 {
+ CREATE TABLE x3_rules(rule_set, cFrom, cTo, cost);
+ INSERT INTO x3_rules VALUES(2, 'a', 'x', 10);
+ INSERT INTO x3_rules VALUES(2, 'a', 'y', 9);
+ INSERT INTO x3_rules VALUES(2, 'a', 'z', 8);
+ CREATE VIRTUAL TABLE x3 USING fuzzer(x3_rules);
+}
+
+do_execsql_test 8.2.1 {
+ SELECT cFrom, cTo, word
+ FROM x3_rules CROSS JOIN x3
+ WHERE word MATCH 'a' AND cost=distance AND ruleset=2
+ ORDER BY +cTo;
+} {a x x a y y a z z}
+
+do_execsql_test 8.2.2 {
+ SELECT cFrom, cTo, word
+ FROM x3 CROSS JOIN x3_rules
+ WHERE word MATCH 'a' AND cost=distance AND ruleset=2
+ ORDER BY +cTo DESC
+} {a z z a y y a x x}
+
+do_execsql_test 8.2.3 {
+ SELECT cFrom, cTo, word
+ FROM x3_rules, x3
+ WHERE word MATCH 'a' AND cost=distance AND ruleset=2
+ ORDER BY +cTo DESC;
+} {a z z a y y a x x}
+
+do_execsql_test 8.2.4 {
+ SELECT cFrom, cTo, word
+ FROM x3, x3_rules
+ WHERE word MATCH 'a' AND cost=distance AND ruleset=2
+ ORDER BY +cTo DESC;
+} {a z z a y y a x x}
+
+do_execsql_test 8.2.5 {
+ CREATE INDEX i1 ON x3_rules(cost);
+ SELECT cFrom, cTo, word
+ FROM x3_rules, x3
+ WHERE word MATCH 'a' AND cost=distance AND ruleset=2
+ ORDER BY +cTo DESC;
+} {a z z a y y a x x}
+
+do_execsql_test 8.2.5 {
+ SELECT word FROM x3_rules, x3 WHERE word MATCH x3_rules.cFrom AND ruleset=2
+} {a z y x a z y x a z y x}
+
+do_execsql_test 8.2.6 {
+ SELECT word FROM x3_rules, x3
+ WHERE word MATCH x3_rules.cFrom
+ AND ruleset=2
+ AND x3_rules.cost=8;
+} {a z y x}
+
+do_execsql_test 8.2.7 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i2 ON t1(b);
+ SELECT word, distance FROM x3, t1
+ WHERE x3.word MATCH t1.a AND ruleset=2 AND distance=t1.b;
+} {}
+
+do_execsql_test 8.2.8 {
+ INSERT INTO x3_rules VALUES(1, 'a', 't', 5);
+ INSERT INTO x3_rules VALUES(1, 'a', 'u', 4);
+ INSERT INTO x3_rules VALUES(1, 'a', 'v', 3);
+ DROP TABLE x3;
+ CREATE VIRTUAL TABLE x3 USING fuzzer(x3_rules);
+ SELECT * FROM x3_rules;
+} {
+ 2 a x 10
+ 2 a y 9
+ 2 a z 8
+ 1 a t 5
+ 1 a u 4
+ 1 a v 3
+}
+
+do_catchsql_test 8.2.9 {
+ SELECT word FROM x3 WHERE ruleset=2 AND word MATCH 'a' AND WORD MATCH 'b';
+} {1 {unable to use function MATCH in the requested context}}
+
+do_execsql_test 8.2.10 {
+ SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a'
+} {a v u t}
+
+# The term "ruleset<=1" is not handled by the fuzzer module. Instead, it
+# is handled by SQLite, which assumes that all rows have a NULL value in
+# the ruleset column. Since NULL<=1 is never true, this query returns
+# no rows.
+do_execsql_test 8.2.11 {
+ SELECT word FROM x3 WHERE ruleset<=1 AND word MATCH 'a'
+} {}
+
+do_execsql_test 8.2.12 {
+ SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a' ORDER BY distance ASC;
+} {a v u t}
+
+do_execsql_test 8.2.13 {
+ SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a' ORDER BY distance DESC;
+} {t u v a}
+
+do_execsql_test 8.2.13 {
+ SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a' ORDER BY word ASC;
+} {a t u v}
+
+do_execsql_test 8.2.14 {
+ SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a' ORDER BY word DESC;
+} {v u t a}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 9.1 {
+ CREATE TABLE x4_rules(a, b, c, d);
+ INSERT INTO x4_rules VALUES(0, 'a', 'b', 10);
+ INSERT INTO x4_rules VALUES(0, 'a', 'c', 11);
+ INSERT INTO x4_rules VALUES(0, 'bx', 'zz', 20);
+ INSERT INTO x4_rules VALUES(0, 'cx', 'yy', 15);
+ INSERT INTO x4_rules VALUES(0, 'zz', '!!', 50);
+ CREATE VIRTUAL TABLE x4 USING fuzzer(x4_rules);
+}
+
+do_execsql_test 9.2 {
+ SELECT word, distance FROM x4 WHERE word MATCH 'ax';
+} {ax 0 bx 10 cx 11 yy 26 zz 30 !! 80}
+
+
+do_execsql_test 10.1 {
+ CREATE TABLE x5_rules(a, b, c, d);
+ CREATE VIRTUAL TABLE x5 USING fuzzer(x5_rules);
+}
+
+do_execsql_test 10.2 {
+ SELECT word, distance FROM x5 WHERE word MATCH
+ 'aaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaa' ||
+ 'aaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaa' ||
+ 'aaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaa'
+} {}
+
+do_execsql_test 10.3 {
+ INSERT INTO x5_rules VALUES(0, 'a', '0.1.2.3.4.5.6.7.8.9.a', 1);
+ DROP TABLE x5;
+ CREATE VIRTUAL TABLE x5 USING fuzzer(x5_rules);
+ SELECT length(word) FROM x5 WHERE word MATCH 'a' LIMIT 50;
+} {1 21 41 61 81}
+
+finish_test
diff --git a/test/fuzzer2.test b/test/fuzzer2.test
new file mode 100644
index 0000000..44ee9e3
--- /dev/null
+++ b/test/fuzzer2.test
@@ -0,0 +1,72 @@
+# 2016 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.
+#
+#***********************************************************************
+# The focus of the tests is the word-fuzzer virtual table. The tests
+# in this file are slower than those in fuzzer1.test. So this file does
+# not run as part of veryquick.test etc.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+set ::testprefix fuzzer2
+load_static_extension db fuzzer
+
+#-------------------------------------------------------------------------
+# This test uses a fuzzer table with many rules. There is one rule to
+# map each possible two character string, where characters are lower-case
+# letters used in the English language, to all other possible two character
+# strings. In total, (26^4)-(26^2) mappings (the subtracted term represents
+# the no-op mappings discarded automatically by the fuzzer).
+#
+#
+do_execsql_test 1.1.1 {
+ DROP TABLE IF EXISTS x1;
+ DROP TABLE IF EXISTS x1_rules;
+ CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);
+}
+puts "This test is slow - perhaps around 7 seconds on an average pc"
+do_test 1.1.2 {
+ set LETTERS {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}
+ set cost 1
+ db transaction {
+ foreach c1 $LETTERS {
+ foreach c2 $LETTERS {
+ foreach c3 $LETTERS {
+ foreach c4 $LETTERS {
+ db eval {INSERT INTO x1_rules VALUES(0, $c1||$c2, $c3||$c4, $cost)}
+ set cost [expr ($cost%1000) + 1]
+ }
+ }
+ }
+ }
+ db eval {UPDATE x1_rules SET cost = 20 WHERE cost<20 AND cFrom!='xx'}
+ }
+} {}
+
+do_execsql_test 1.2 {
+ SELECT count(*) FROM x1_rules WHERE cTo!=cFrom;
+} [expr 26*26*26*26 - 26*26]
+
+do_execsql_test 1.2.1 {
+ CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);
+ SELECT word FROM x1 WHERE word MATCH 'xx' LIMIT 10;
+} {xx hw hx hy hz ia ib ic id ie}
+do_execsql_test 1.2.2 {
+ SELECT cTo FROM x1_rules WHERE cFrom='xx'
+ ORDER BY cost asc, rowid asc LIMIT 9;
+} {hw hx hy hz ia ib ic id ie}
+
+finish_test
diff --git a/test/fuzzerfault.test b/test/fuzzerfault.test
new file mode 100644
index 0000000..e281cb5
--- /dev/null
+++ b/test/fuzzerfault.test
@@ -0,0 +1,111 @@
+# 2012 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 TCL interface to the
+# SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !vtab { finish_test ; return }
+set ::testprefix fuzzerfault
+
+load_static_extension db fuzzer
+
+do_test 1-pre1 {
+ execsql {
+ CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);
+ INSERT INTO x1_rules VALUES(0, 'a', 'b', 1);
+ INSERT INTO x1_rules VALUES(0, 'a', 'c', 2);
+ INSERT INTO x1_rules VALUES(0, 'a', 'd', 3);
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+ load_static_extension db fuzzer
+} -body {
+ execsql {
+ CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);
+ SELECT word FROM x1 WHERE word MATCH 'xax';
+ }
+} -test {
+ faultsim_test_result {0 {xax xbx xcx xdx}} \
+ {1 {vtable constructor failed: x1}}
+}
+
+do_test 2-pre1 {
+ faultsim_delete_and_reopen
+ load_static_extension db fuzzer
+ execsql {
+ CREATE TABLE x2_rules(ruleset, cFrom, cTo, cost);
+ INSERT INTO x2_rules VALUES(0, 'a', 'x', 1);
+ INSERT INTO x2_rules VALUES(0, 'b', 'x', 2);
+ INSERT INTO x2_rules VALUES(0, 'c', 'x', 3);
+ CREATE VIRTUAL TABLE x2 USING fuzzer(x2_rules);
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test 2 -prep {
+ faultsim_restore_and_reopen
+ load_static_extension db fuzzer
+} -body {
+ execsql {
+ SELECT count(*) FROM x2 WHERE word MATCH 'abc';
+ }
+} -test {
+ faultsim_test_result {0 8} {1 {vtable constructor failed: x2}}
+}
+
+do_test 3-pre1 {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);
+ INSERT INTO x1_rules VALUES(0, 'a',
+ '123456789012345678901234567890a1234567890123456789', 10
+ );
+ }
+ faultsim_save_and_close
+} {}
+
+do_faultsim_test 3 -prep {
+ faultsim_restore_and_reopen
+ load_static_extension db fuzzer
+} -body {
+ execsql {
+ CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);
+ SELECT count(*) FROM (SELECT * FROM x1 WHERE word MATCH 'a' LIMIT 2);
+ }
+} -test {
+ faultsim_test_result {0 2} {1 {vtable constructor failed: x1}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1_a(a INTEFDR PRIMARY KEY, b TEXT);
+ CREATE TABLE t3_a(k FnTEGER PRIMARY KEY, v TEXT);
+ CREATE TABLE t3_b(k INTEÀ5R PRIMARY KEY, v TEXT);
+ CREATE VIEW t3 AS SELECT * FROM t3_a UNION ALL SELECT * FROM t3_b;
+}
+faultsim_save_and_close
+
+do_faultsim_test 4 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT 1 FROM t1_a LEFT JOIN t3 ON ((1+1) AND k=1)
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/fuzzinvariants.c b/test/fuzzinvariants.c
new file mode 100644
index 0000000..c0ed2dd
--- /dev/null
+++ b/test/fuzzinvariants.c
@@ -0,0 +1,487 @@
+/*
+** 2022-06-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 library is used by fuzzcheck to test query invariants.
+**
+** An sqlite3_stmt is passed in that has just returned SQLITE_ROW. This
+** routine does:
+**
+** * Record the output of the current row
+** * Construct an alternative query that should return the same row
+** * Run the alternative query and verify that it does in fact return
+** the same row
+**
+*/
+#include "sqlite3.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+/* Forward references */
+static char *fuzz_invariant_sql(sqlite3_stmt*, int);
+static int sameValue(sqlite3_stmt*,int,sqlite3_stmt*,int,sqlite3_stmt*);
+static void reportInvariantFailed(sqlite3_stmt*,sqlite3_stmt*,int);
+
+/*
+** Do an invariant check on pStmt. iCnt determines which invariant check to
+** perform. The first check is iCnt==0.
+**
+** *pbCorrupt is a flag that, if true, indicates that the database file
+** is known to be corrupt. A value of non-zero means "yes, the database
+** is corrupt". A zero value means "we do not know whether or not the
+** database is corrupt". The value might be set prior to entry, or this
+** routine might set the value.
+**
+** Return values:
+**
+** SQLITE_OK This check was successful.
+**
+** SQLITE_DONE iCnt is out of range. The caller typically sets
+** up a loop on iCnt starting with zero, and increments
+** iCnt until this code is returned.
+**
+** SQLITE_CORRUPT The invariant failed, but the underlying database
+** file is indicating that it is corrupt, which might
+** be the cause of the malfunction. The *pCorrupt
+** value will also be set.
+**
+** SQLITE_INTERNAL The invariant failed, and the database file is not
+** corrupt. (This never happens because this function
+** will call abort() following an invariant failure.)
+**
+** (other) Some other kind of error occurred.
+*/
+int fuzz_invariant(
+ sqlite3 *db, /* The database connection */
+ sqlite3_stmt *pStmt, /* Test statement stopped on an SQLITE_ROW */
+ int iCnt, /* Invariant sequence number, starting at 0 */
+ int iRow, /* Current row number */
+ int nRow, /* Number of output rows from pStmt */
+ int *pbCorrupt, /* IN/OUT: Flag indicating a corrupt database file */
+ int eVerbosity /* How much debugging output */
+){
+ char *zTest;
+ sqlite3_stmt *pTestStmt = 0;
+ int rc;
+ int i;
+ int nCol;
+ int nParam;
+
+ if( *pbCorrupt ) return SQLITE_DONE;
+ nParam = sqlite3_bind_parameter_count(pStmt);
+ if( nParam>100 ) return SQLITE_DONE;
+ zTest = fuzz_invariant_sql(pStmt, iCnt);
+ if( zTest==0 ) return SQLITE_DONE;
+ rc = sqlite3_prepare_v2(db, zTest, -1, &pTestStmt, 0);
+ if( rc ){
+ if( eVerbosity ){
+ printf("invariant compile failed: %s\n%s\n",
+ sqlite3_errmsg(db), zTest);
+ }
+ sqlite3_free(zTest);
+ sqlite3_finalize(pTestStmt);
+ return rc;
+ }
+ sqlite3_free(zTest);
+ nCol = sqlite3_column_count(pStmt);
+ for(i=0; i<nCol; i++){
+ rc = sqlite3_bind_value(pTestStmt,i+1+nParam,sqlite3_column_value(pStmt,i));
+ if( rc!=SQLITE_OK && rc!=SQLITE_RANGE ){
+ sqlite3_finalize(pTestStmt);
+ return rc;
+ }
+ }
+ if( eVerbosity>=2 ){
+ char *zSql = sqlite3_expanded_sql(pTestStmt);
+ printf("invariant-sql #%d:\n%s\n", iCnt, zSql);
+ sqlite3_free(zSql);
+ }
+ while( (rc = sqlite3_step(pTestStmt))==SQLITE_ROW ){
+ for(i=0; i<nCol; i++){
+ if( !sameValue(pStmt, i, pTestStmt, i, 0) ) break;
+ }
+ if( i>=nCol ) break;
+ }
+ if( rc==SQLITE_DONE ){
+ /* No matching output row found */
+ sqlite3_stmt *pCk = 0;
+
+ /* This is not a fault if the database file is corrupt, because anything
+ ** can happen with a corrupt database file */
+ rc = sqlite3_prepare_v2(db, "PRAGMA integrity_check", -1, &pCk, 0);
+ if( rc ){
+ sqlite3_finalize(pCk);
+ sqlite3_finalize(pTestStmt);
+ return rc;
+ }
+ rc = sqlite3_step(pCk);
+ if( rc!=SQLITE_ROW
+ || sqlite3_column_text(pCk, 0)==0
+ || strcmp((const char*)sqlite3_column_text(pCk,0),"ok")!=0
+ ){
+ *pbCorrupt = 1;
+ sqlite3_finalize(pCk);
+ sqlite3_finalize(pTestStmt);
+ return SQLITE_CORRUPT;
+ }
+ sqlite3_finalize(pCk);
+
+ if( sqlite3_strlike("%group%by%order%by%desc%",sqlite3_sql(pStmt),0)==0 ){
+ /* dbsqlfuzz crash-647c162051c9b23ce091b7bbbe5125ce5f00e922
+ ** Original statement is:
+ **
+ ** SELECT a,c,d,b,'' FROM t1 GROUP BY 1 HAVING d<>345 ORDER BY a DESC;
+ **
+ ** The values of c, d, and b are indeterminate and change when the
+ ** enclosed in the test query because the DESC is dropped.
+ **
+ ** SELECT * FROM (...) WHERE "a"==0
+ */
+ goto not_a_fault;
+ }
+
+ if( sqlite3_strlike("%limit%)%order%by%", sqlite3_sql(pTestStmt),0)==0 ){
+ /* crash-89bd6a6f8c6166e9a4c5f47b3e70b225f69b76c6
+ ** Original statement is:
+ **
+ ** SELECT a,b,c* FROM t1 LIMIT 1%5<4
+ **
+ ** When running:
+ **
+ ** SELECT * FROM (...) ORDER BY 1
+ **
+ ** A different subset of the rows come out
+ */
+ goto not_a_fault;
+ }
+
+ /* The original sameValue() comparison assumed a collating sequence
+ ** of "binary". It can sometimes get an incorrect result for different
+ ** collating sequences. So rerun the test with no assumptions about
+ ** collations.
+ */
+ rc = sqlite3_prepare_v2(db,
+ "SELECT ?1=?2 OR ?1=?2 COLLATE nocase OR ?1=?2 COLLATE rtrim",
+ -1, &pCk, 0);
+ if( rc==SQLITE_OK ){
+ sqlite3_reset(pTestStmt);
+ while( (rc = sqlite3_step(pTestStmt))==SQLITE_ROW ){
+ for(i=0; i<nCol; i++){
+ if( !sameValue(pStmt, i, pTestStmt, i, pCk) ) break;
+ }
+ if( i>=nCol ){
+ sqlite3_finalize(pCk);
+ goto not_a_fault;
+ }
+ }
+ }
+ sqlite3_finalize(pCk);
+
+ /* Invariants do not necessarily work if there are virtual tables
+ ** involved in the query */
+ rc = sqlite3_prepare_v2(db,
+ "SELECT 1 FROM bytecode(?1) WHERE opcode='VOpen'", -1, &pCk, 0);
+ if( rc==SQLITE_OK ){
+ sqlite3_bind_pointer(pCk, 1, pStmt, "stmt-pointer", 0);
+ rc = sqlite3_step(pCk);
+ }
+ sqlite3_finalize(pCk);
+ if( rc==SQLITE_DONE ){
+ reportInvariantFailed(pStmt, pTestStmt, iRow);
+ return SQLITE_INTERNAL;
+ }else if( eVerbosity>0 ){
+ printf("invariant-error ignored due to the use of virtual tables\n");
+ }
+ }
+not_a_fault:
+ sqlite3_finalize(pTestStmt);
+ return SQLITE_OK;
+}
+
+
+/*
+** Generate SQL used to test a statement invariant.
+**
+** Return 0 if the iCnt is out of range.
+**
+** iCnt meanings:
+**
+** 0 SELECT * FROM (<query>)
+** 1 SELECT DISTINCT * FROM (<query>)
+** 2 SELECT * FROM (<query>) WHERE ORDER BY 1
+** 3 SELECT DISTINCT * FROM (<query>) ORDER BY 1
+** 4 SELECT * FROM (<query>) WHERE <all-columns>=<all-values>
+** 5 SELECT DISTINCT * FROM (<query>) WHERE <all-columns=<all-values
+** 6 SELECT * FROM (<query>) WHERE <all-column>=<all-value> ORDER BY 1
+** 7 SELECT DISTINCT * FROM (<query>) WHERE <all-column>=<all-value>
+** ORDER BY 1
+** N+0 SELECT * FROM (<query>) WHERE <nth-column>=<value>
+** N+1 SELECT DISTINCT * FROM (<query>) WHERE <Nth-column>=<value>
+** N+2 SELECT * FROM (<query>) WHERE <Nth-column>=<value> ORDER BY 1
+** N+3 SELECT DISTINCT * FROM (<query>) WHERE <Nth-column>=<value>
+** ORDER BY N
+**
+*/
+static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){
+ const char *zIn;
+ size_t nIn;
+ const char *zAnd = "WHERE";
+ int i;
+ sqlite3_str *pTest;
+ sqlite3_stmt *pBase = 0;
+ sqlite3 *db = sqlite3_db_handle(pStmt);
+ int rc;
+ int nCol = sqlite3_column_count(pStmt);
+ int mxCnt;
+ int bDistinct = 0;
+ int bOrderBy = 0;
+ int nParam = sqlite3_bind_parameter_count(pStmt);
+
+ switch( iCnt % 4 ){
+ case 1: bDistinct = 1; break;
+ case 2: bOrderBy = 1; break;
+ case 3: bDistinct = bOrderBy = 1; break;
+ }
+ iCnt /= 4;
+ mxCnt = nCol;
+ if( iCnt<0 || iCnt>mxCnt ) return 0;
+ zIn = sqlite3_sql(pStmt);
+ if( zIn==0 ) return 0;
+ nIn = strlen(zIn);
+ while( nIn>0 && (isspace(zIn[nIn-1]) || zIn[nIn-1]==';') ) nIn--;
+ if( strchr(zIn, '?') ) return 0;
+ pTest = sqlite3_str_new(0);
+ sqlite3_str_appendf(pTest, "SELECT %s* FROM (",
+ bDistinct ? "DISTINCT " : "");
+ sqlite3_str_append(pTest, zIn, (int)nIn);
+ sqlite3_str_append(pTest, ")", 1);
+ rc = sqlite3_prepare_v2(db, sqlite3_str_value(pTest), -1, &pBase, 0);
+ if( rc ){
+ sqlite3_finalize(pBase);
+ pBase = pStmt;
+ }
+ for(i=0; i<sqlite3_column_count(pStmt); i++){
+ const char *zColName = sqlite3_column_name(pBase,i);
+ const char *zSuffix = zColName ? strrchr(zColName, ':') : 0;
+ if( zSuffix
+ && isdigit(zSuffix[1])
+ && (zSuffix[1]>'3' || isdigit(zSuffix[2]))
+ ){
+ /* This is a randomized column name and so cannot be used in the
+ ** WHERE clause. */
+ continue;
+ }
+ if( iCnt==0 ) continue;
+ if( iCnt>1 && i+2!=iCnt ) continue;
+ if( zColName==0 ) continue;
+ if( sqlite3_column_type(pStmt, i)==SQLITE_NULL ){
+ sqlite3_str_appendf(pTest, " %s \"%w\" ISNULL", zAnd, zColName);
+ }else{
+ sqlite3_str_appendf(pTest, " %s \"%w\"=?%d", zAnd, zColName,
+ i+1+nParam);
+ }
+ zAnd = "AND";
+ }
+ if( pBase!=pStmt ) sqlite3_finalize(pBase);
+ if( bOrderBy ){
+ sqlite3_str_appendf(pTest, " ORDER BY %d", iCnt>2 ? iCnt-1 : 1);
+ }
+ return sqlite3_str_finish(pTest);
+}
+
+/*
+** Return true if and only if v1 and is the same as v2.
+*/
+static int sameValue(
+ sqlite3_stmt *pS1, int i1, /* Value to text on the left */
+ sqlite3_stmt *pS2, int i2, /* Value to test on the right */
+ sqlite3_stmt *pTestCompare /* COLLATE comparison statement or NULL */
+){
+ int x = 1;
+ int t1 = sqlite3_column_type(pS1,i1);
+ int t2 = sqlite3_column_type(pS2,i2);
+ if( t1!=t2 ){
+ if( (t1==SQLITE_INTEGER && t2==SQLITE_FLOAT)
+ || (t1==SQLITE_FLOAT && t2==SQLITE_INTEGER)
+ ){
+ /* Comparison of numerics is ok */
+ }else{
+ return 0;
+ }
+ }
+ switch( sqlite3_column_type(pS1,i1) ){
+ case SQLITE_INTEGER: {
+ x = sqlite3_column_int64(pS1,i1)==sqlite3_column_int64(pS2,i2);
+ break;
+ }
+ case SQLITE_FLOAT: {
+ x = sqlite3_column_double(pS1,i1)==sqlite3_column_double(pS2,i2);
+ break;
+ }
+ case SQLITE_TEXT: {
+ int e1 = sqlite3_value_encoding(sqlite3_column_value(pS1,i1));
+ int e2 = sqlite3_value_encoding(sqlite3_column_value(pS2,i2));
+ if( e1!=e2 ){
+ const char *z1 = (const char*)sqlite3_column_text(pS1,i1);
+ const char *z2 = (const char*)sqlite3_column_text(pS2,i2);
+ x = ((z1==0 && z2==0) || (z1!=0 && z2!=0 && strcmp(z1,z1)==0));
+ printf("Encodings differ. %d on left and %d on right\n", e1, e2);
+ abort();
+ }
+ if( pTestCompare ){
+ sqlite3_bind_value(pTestCompare, 1, sqlite3_column_value(pS1,i1));
+ sqlite3_bind_value(pTestCompare, 2, sqlite3_column_value(pS2,i2));
+ x = sqlite3_step(pTestCompare)==SQLITE_ROW
+ && sqlite3_column_int(pTestCompare,0)!=0;
+ sqlite3_reset(pTestCompare);
+ break;
+ }
+ if( e1!=SQLITE_UTF8 ){
+ int len1 = sqlite3_column_bytes16(pS1,i1);
+ const unsigned char *b1 = sqlite3_column_blob(pS1,i1);
+ int len2 = sqlite3_column_bytes16(pS2,i2);
+ const unsigned char *b2 = sqlite3_column_blob(pS2,i2);
+ if( len1!=len2 ){
+ x = 0;
+ }else if( len1==0 ){
+ x = 1;
+ }else{
+ x = (b1!=0 && b2!=0 && memcmp(b1,b2,len1)==0);
+ }
+ break;
+ }
+ /* Fall through into the SQLITE_BLOB case */
+ }
+ case SQLITE_BLOB: {
+ int len1 = sqlite3_column_bytes(pS1,i1);
+ const unsigned char *b1 = sqlite3_column_blob(pS1,i1);
+ int len2 = sqlite3_column_bytes(pS2,i2);
+ const unsigned char *b2 = sqlite3_column_blob(pS2,i2);
+ if( len1!=len2 ){
+ x = 0;
+ }else if( len1==0 ){
+ x = 1;
+ }else{
+ x = (b1!=0 && b2!=0 && memcmp(b1,b2,len1)==0);
+ }
+ break;
+ }
+ }
+ return x;
+}
+
+/*
+** Print binary data as hex
+*/
+static void printHex(const unsigned char *a, int n, int mx){
+ int j;
+ for(j=0; j<mx && j<n; j++){
+ printf("%02x", a[j]);
+ }
+ if( j<n ) printf("...");
+}
+
+/*
+** Print a single row from the prepared statement
+*/
+static void printRow(sqlite3_stmt *pStmt, int iRow){
+ int i, n, nCol;
+ unsigned const char *data;
+ nCol = sqlite3_column_count(pStmt);
+ for(i=0; i<nCol; i++){
+ printf("row%d.col%d = ", iRow, i);
+ switch( sqlite3_column_type(pStmt, i) ){
+ case SQLITE_NULL: {
+ printf("NULL\n");
+ break;
+ }
+ case SQLITE_INTEGER: {
+ printf("(integer) %lld\n", sqlite3_column_int64(pStmt, i));
+ break;
+ }
+ case SQLITE_FLOAT: {
+ printf("(float) %f\n", sqlite3_column_double(pStmt, i));
+ break;
+ }
+ case SQLITE_TEXT: {
+ switch( sqlite3_value_encoding(sqlite3_column_value(pStmt,i)) ){
+ case SQLITE_UTF8: {
+ printf("(utf8) x'");
+ n = sqlite3_column_bytes(pStmt, i);
+ data = sqlite3_column_blob(pStmt, i);
+ printHex(data, n, 35);
+ printf("'\n");
+ break;
+ }
+ case SQLITE_UTF16BE: {
+ printf("(utf16be) x'");
+ n = sqlite3_column_bytes16(pStmt, i);
+ data = sqlite3_column_blob(pStmt, i);
+ printHex(data, n, 35);
+ printf("'\n");
+ break;
+ }
+ case SQLITE_UTF16LE: {
+ printf("(utf16le) x'");
+ n = sqlite3_column_bytes16(pStmt, i);
+ data = sqlite3_column_blob(pStmt, i);
+ printHex(data, n, 35);
+ printf("'\n");
+ break;
+ }
+ default: {
+ printf("Illegal return from sqlite3_value_encoding(): %d\n",
+ sqlite3_value_encoding(sqlite3_column_value(pStmt,i)));
+ abort();
+ }
+ }
+ break;
+ }
+ case SQLITE_BLOB: {
+ n = sqlite3_column_bytes(pStmt, i);
+ data = sqlite3_column_blob(pStmt, i);
+ printf("(blob %d bytes) x'", n);
+ printHex(data, n, 35);
+ printf("'\n");
+ break;
+ }
+ }
+ }
+}
+
+/*
+** Report a failure of the invariant: The current output row of pOrig
+** does not appear in any row of the output from pTest.
+*/
+static void reportInvariantFailed(
+ sqlite3_stmt *pOrig, /* The original query */
+ sqlite3_stmt *pTest, /* The alternative test query with a missing row */
+ int iRow /* Row number in pOrig */
+){
+ int iTestRow = 0;
+ printf("Invariant check failed on row %d.\n", iRow);
+ printf("Original query --------------------------------------------------\n");
+ printf("%s\n", sqlite3_expanded_sql(pOrig));
+ printf("Alternative query -----------------------------------------------\n");
+ printf("%s\n", sqlite3_expanded_sql(pTest));
+ printf("Result row that is missing from the alternative -----------------\n");
+ printRow(pOrig, iRow);
+ printf("Complete results from the alternative query ---------------------\n");
+ sqlite3_reset(pTest);
+ while( sqlite3_step(pTest)==SQLITE_ROW ){
+ iTestRow++;
+ printRow(pTest, iTestRow);
+ }
+ sqlite3_finalize(pTest);
+ abort();
+}
diff --git a/test/gcfault.test b/test/gcfault.test
new file mode 100644
index 0000000..d54b78f
--- /dev/null
+++ b/test/gcfault.test
@@ -0,0 +1,56 @@
+# 2016 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 OOM error handling within the built-in
+# group_concat() function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix gcfault
+
+
+foreach {enc} {
+ utf16
+ utf8
+} {
+ reset_db
+ sqlite3_db_config_lookaside db 0 0 0
+ execsql "PRAGMA encoding = $enc"
+
+ do_execsql_test 1.$enc.1 {
+ CREATE TABLE s(i, s);
+ INSERT INTO s VALUES(1, ',0123456789,');
+ INSERT INTO s VALUES(2, X'2c303132333435363738392c');
+
+ CREATE TABLE e(e);
+ INSERT INTO e VALUES('v1'), ('v2');
+ } {}
+
+ do_faultsim_test 1.$enc.1 -faults oom* -body {
+ execsql { SELECT group_concat(e, (SELECT s FROM s WHERE i=1)) FROM e }
+ }
+
+ do_faultsim_test 1.$enc.2 -faults oom-t* -body {
+ execsql { SELECT group_concat(e, (SELECT s FROM s WHERE i=2)) FROM e }
+ }
+
+ do_faultsim_test 1.$enc.3 -faults oom-t* -prep {
+ set ::STMT [sqlite3_prepare db {SELECT group_concat(e, ?) FROM e} -1 dummy]
+ sqlite3_bind_text $::STMT 1 ",0123456789," 12
+ } -body {
+ while { "SQLITE_ROW"==[sqlite3_step $::STMT] } { }
+ } -test {
+ sqlite3_finalize $::STMT
+ }
+}
+
+finish_test
diff --git a/test/gencol1.test b/test/gencol1.test
new file mode 100644
index 0000000..ee0ebc5
--- /dev/null
+++ b/test/gencol1.test
@@ -0,0 +1,618 @@
+# 2019-10-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.
+#
+#***********************************************************************
+#
+# Test cases for generated columns.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# ticket 830277d9db6c3ba1 on 2019-10-31
+do_execsql_test gencol1-100 {
+ CREATE TABLE t0(c0 AS(TYPEOF(c1)), c1);
+ INSERT INTO t0(c1) VALUES(0);
+ CREATE TABLE t1(x AS (typeof(y)), y);
+ INSERT INTO t1 SELECT * FROM t0;
+ SELECT * FROM t1;
+} {integer 0}
+
+foreach {tn schema} {
+1 {
+ CREATE TABLE t1(
+ a INT,
+ b TEXT,
+ c ANY,
+ w INT GENERATED ALWAYS AS (a*10),
+ x TEXT AS (typeof(c)),
+ y TEXT AS (substr(b,a,a+2))
+ );
+ }
+2 {
+ CREATE TABLE t1(
+ w INT GENERATED ALWAYS AS (a*10),
+ x TEXT AS (typeof(c)),
+ y TEXT AS (substr(b,a,a+2)),
+ a INT,
+ b TEXT,
+ c ANY
+ );
+ }
+3 {
+ CREATE TABLE t1(
+ w INT GENERATED ALWAYS AS (a*10),
+ a INT,
+ x TEXT AS (typeof(c)) STORED,
+ b TEXT,
+ y TEXT AS (substr(b,a,a+2)),
+ c ANY
+ );
+ }
+4 {
+ CREATE TABLE t1(
+ a INTEGER PRIMARY KEY,
+ w INT GENERATED ALWAYS AS (a*10),
+ b TEXT,
+ x TEXT AS (typeof(c)),
+ y TEXT AS (substr(b,a,a+2)) STORED,
+ c ANY
+ );
+ }
+5 {
+ CREATE TABLE t1(
+ w INT GENERATED ALWAYS AS (a*10),
+ a INT,
+ x TEXT AS (typeof(c)),
+ b TEXT,
+ y TEXT AS (substr(b,a,a+2)) STORED,
+ c ANY,
+ PRIMARY KEY(a,b)
+ ) WITHOUT ROWID;
+ }
+6 {
+ CREATE TABLE t1(
+ w INT GENERATED ALWAYS AS (m*5),
+ m INT AS (a*2) STORED,
+ a INT,
+ x TEXT AS (typeof(c)),
+ b TEXT,
+ y TEXT AS (substr(b,m/2,m/2+2)) STORED,
+ c ANY,
+ PRIMARY KEY(a,b)
+ );
+ }
+7 {
+ CREATE TABLE t1(
+ w INT GENERATED ALWAYS AS (m*5),
+ m INT AS (a*2) NOT NULL,
+ a INT,
+ x TEXT AS (typeof(c)) CHECK (x<>'blank'),
+ b TEXT,
+ y TEXT AS (substr(b,m/2,m/2+2)) STORED,
+ c ANY,
+ PRIMARY KEY(b,a)
+ ) WITHOUT ROWID;
+ }
+} {
+ catch {db close}
+ sqlite3 db :memory:
+ db eval $schema
+ do_execsql_test gencol1-2.$tn.100 {
+ INSERT INTO t1(a,b,c) VALUES(1,'abcdef',5.5),(3,'cantaloupe',NULL);
+ SELECT w, x, y, '|' FROM t1 ORDER BY a;
+ } {10 real abc | 30 null ntalo |}
+ do_execsql_test gencol1-2.$tn.101 {
+ SELECT w, x, y, '|' FROM t1 ORDER BY w;
+ } {10 real abc | 30 null ntalo |}
+ do_execsql_test gencol1-2.$tn.102 {
+ SELECT a FROM t1 WHERE w=30;
+ } {3}
+ do_execsql_test gencol1-2.$tn.103 {
+ SELECT a FROM t1 WHERE x='real';
+ } {1}
+ do_execsql_test gencol1-2.$tn.104 {
+ SELECT a FROM t1 WHERE y LIKE '%tal%' OR x='real' ORDER BY b;
+ } {1 3}
+ do_execsql_test gencol1-2.$tn.110 {
+ CREATE INDEX t1w ON t1(w);
+ SELECT a FROM t1 WHERE w=10;
+ } {1}
+ do_execsql_test gencol1-2.$tn.120 {
+ CREATE INDEX t1x ON t1(x) WHERE w BETWEEN 20 AND 40;
+ SELECT a FROM t1 WHERE x='null' AND w BETWEEN 20 AND 40;
+ } {3}
+ do_execsql_test gencol1-2.$tn.121 {
+ SELECT a FROM t1 WHERE x='real';
+ } {1}
+ do_execsql_test gencol1-2.$tn.130 {
+ VACUUM;
+ PRAGMA integrity_check;
+ } {ok}
+ do_execsql_test gencol1-2.$tn.140 {
+ UPDATE t1 SET a=a+100 WHERE w<20;
+ SELECT a, w, '|' FROM t1 ORDER BY w;
+ } {3 30 | 101 1010 |}
+ do_execsql_test gencol1-2.$tn.150 {
+ INSERT INTO t1 VALUES(4,'jambalaya','Chef John'),(15,87719874135,0);
+ SELECT w, x, y, '|' FROM t1 ORDER BY w;
+ } {30 null ntalo | 40 text balaya | 150 integer {} | 1010 real {} |}
+}
+
+# 2019-10-31 ticket b9befa4b83a660cc
+db close
+sqlite3 db :memory:
+do_execsql_test gencol1-3.100 {
+ PRAGMA foreign_keys = true;
+ CREATE TABLE t0(c0 PRIMARY KEY, c1, c2 AS (c0+c1-c3) REFERENCES t0, c3);
+ INSERT INTO t0 VALUES (0, 0, 0), (11, 5, 5);
+ UPDATE t0 SET c1 = c0, c3 = c0;
+ SELECT *, '|' FROM t0 ORDER BY +c0;
+} {0 0 0 0 | 11 11 11 11 |}
+do_catchsql_test gencol1-3.110 {
+ UPDATE t0 SET c1 = c0, c3 = c0+1;
+} {1 {FOREIGN KEY constraint failed}}
+
+# 2019-11-01 ticket c28a01da72f8957c
+db close
+sqlite3 db :memory:
+do_execsql_test gencol1-4.100 {
+ CREATE TABLE t0 (
+ c0,
+ c1 a UNIQUE AS (1),
+ c2,
+ c3 REFERENCES t0(c1)
+ );
+ PRAGMA foreign_keys = true;
+ INSERT INTO t0(c0,c2,c3) VALUES(0,0,1);
+} {}
+do_catchsql_test gencol1-4.110 {
+ REPLACE INTO t0(c0,c2,c3) VALUES(0,0,0),(0,0,0);
+} {1 {FOREIGN KEY constraint failed}}
+
+# 2019-11-01 Problem found while adding new foreign key test cases in TH3.
+db close
+sqlite3 db :memory:
+do_execsql_test gencol1-5.100 {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE t1(
+ gcb AS (b*1),
+ a INTEGER PRIMARY KEY,
+ gcc AS (c+0),
+ b UNIQUE,
+ gca AS (1*a+0),
+ c UNIQUE
+ ) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(4,5,6);
+ INSERT INTO t1 VALUES(7,8,9);
+ CREATE TABLE t1a(
+ gcx AS (x+0) REFERENCES t1(a) ON DELETE CASCADE,
+ id,
+ x,
+ gcid AS (1*id)
+ );
+ INSERT INTO t1a VALUES(1, 1);
+ INSERT INTO t1a VALUES(2, 4);
+ INSERT INTO t1a VALUES(3, 7);
+ DELETE FROM t1 WHERE b=5;
+ SELECT id,x,'|' FROM t1a ORDER BY id;
+} {1 1 | 3 7 |}
+
+do_catchsql_test gencol1-6.10 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 NOT NULL AS(c1), c1);
+ REPLACE INTO t0(c1) VALUES(NULL);
+} {1 {NOT NULL constraint failed: t0.c0}}
+
+# 2019-11-06 ticket https://www.sqlite.org/src/info/2399f5986134f79c
+# 2019-12-27 ticket https://www.sqlite.org/src/info/5fbc159eeb092130
+# 2019-12-27 ticket https://www.sqlite.org/src/info/37823501c68a09f9
+#
+# All of the above tickets deal with NOT NULL ON CONFLICT REPLACE
+# constraints on tables that have generated columns.
+#
+reset_db
+do_execsql_test gencol1-7.10 {
+ CREATE TABLE t0 (c0 GENERATED ALWAYS AS (1), c1 UNIQUE, c2 UNIQUE);
+ INSERT INTO t0(c1) VALUES (1);
+ SELECT quote(0 = t0.c2 OR t0.c1 BETWEEN t0.c2 AND 1) FROM t0;
+} {NULL}
+do_execsql_test gencol1-7.11 {
+ DROP TABLE t0;
+ CREATE TABLE t0(c0 NOT NULL DEFAULT 'xyz', c1 AS(c0) NOT NULL);
+ REPLACE INTO t0(c0) VALUES(NULL);
+ SELECT * FROM t0;
+} {xyz xyz}
+do_execsql_test gencol1-7.12 {
+ DROP TABLE t0;
+ CREATE TABLE t0(c0 NOT NULL DEFAULT 'xyz', c1 AS(c0) STORED NOT NULL);
+ REPLACE INTO t0(c0) VALUES(NULL);
+ SELECT * FROM t0;
+} {xyz xyz}
+do_execsql_test gencol1-7.20 {
+ CREATE TABLE t1(
+ a NOT NULL DEFAULT 'aaa',
+ b AS(c) NOT NULL,
+ c NOT NULL DEFAULT 'ccc');
+ REPLACE INTO t1(a,c) VALUES(NULL,NULL);
+ SELECT * FROM t1;
+} {aaa ccc ccc}
+do_execsql_test gencol1-7.21 {
+ DROP TABLE t1;
+ CREATE TABLE t1(
+ a NOT NULL DEFAULT 'aaa',
+ b AS(c) STORED NOT NULL,
+ c NOT NULL DEFAULT 'ccc');
+ REPLACE INTO t1(a,c) VALUES(NULL,NULL);
+ SELECT * FROM t1;
+} {aaa ccc ccc}
+do_execsql_test gencol1-7.30 {
+ CREATE TABLE t2(
+ a NOT NULL DEFAULT 'aaa',
+ b AS(a) NOT NULL,
+ c NOT NULL DEFAULT 'ccc');
+ REPLACE INTO t2(a,c) VALUES(NULL,NULL);
+ SELECT * FROM t2;
+} {aaa aaa ccc}
+do_execsql_test gencol1-7.31 {
+ DROP TABLE t2;
+ CREATE TABLE t2(
+ a NOT NULL DEFAULT 'aaa',
+ b AS(a) STORED NOT NULL,
+ c NOT NULL DEFAULT 'ccc');
+ REPLACE INTO t2(a,c) VALUES(NULL,NULL);
+ SELECT * FROM t2;
+} {aaa aaa ccc}
+do_execsql_test gencol1-7.40 {
+ CREATE TABLE t3(a NOT NULL DEFAULT 123, b AS(a) UNIQUE);
+ REPLACE INTO t3 VALUES(NULL);
+ SELECT * FROM t3;
+} {123 123}
+do_execsql_test gencol1-7.41 {
+ SELECT * FROM t3 WHERE b=123;
+} {123 123}
+do_execsql_test gencol1-7.50 {
+ CREATE TABLE t4(a NOT NULL DEFAULT 123, b AS(a*10+4) STORED UNIQUE);
+ REPLACE INTO t4 VALUES(NULL);
+ SELECT * FROM t4;
+} {123 1234}
+do_execsql_test gencol1-7.51 {
+ SELECT * FROM t4 WHERE b=1234;
+} {123 1234}
+
+# 2019-11-06 ticket 4fc08501f4e56692
+do_execsql_test gencol1-8.10 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(
+ c0 AS (('a', 9) < ('b', c1)),
+ c1 AS (1),
+ c2 CHECK (1 = c1)
+ );
+ INSERT INTO t0 VALUES (0),(99);
+ SELECT * FROM t0;
+} {1 1 0 1 1 99}
+do_catchsql_test gencol1-8.20 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(
+ c0,
+ c1 AS(c0 + c2),
+ c2 AS(c1) CHECK(c2)
+ );
+ UPDATE t0 SET c0 = NULL;
+} {1 {generated column loop on "c2"}}
+
+# 2019-11-21 Problems in the new generated column logic
+# reported by Yongheng Chen and Rui Zhong
+reset_db
+do_execsql_test gencol1-9.10 {
+ PRAGMA foreign_keys=OFF;
+ CREATE TABLE t1(aa , bb AS (17) UNIQUE);
+ INSERT INTO t1 VALUES(17);
+ CREATE TABLE t2(cc);
+ INSERT INTO t2 VALUES(41);
+ SELECT * FROM t2 JOIN t1 WHERE t1.bb=t1.aa AND t1.bb=17;
+} {41 17 17}
+do_execsql_test gencol1-9.20 {
+ CREATE TABLE t3(aa INT PRIMARY KEY, bb UNIQUE AS(aa));
+ INSERT INTO t3 VALUES(1);
+ SELECT 100, * FROM t3;
+ DELETE FROM t3 WHERE (SELECT bb FROM t3);
+ SELECT 200, * FROM t3;
+} {100 1 1}
+
+# 2019-12-04 Generated column in a CREATE TABLE IF NOT EXISTS that
+# does already exist.
+#
+sqlite3 db :memory:
+do_execsql_test gencol1-10.10 {
+ CREATE TABLE t1(aa,bb);
+ CREATE TABLE IF NOT EXISTS t1(aa, bb AS (aa+1));
+ PRAGMA integrity_check;
+} {ok}
+
+# 2019-12-06 Found by mrigger
+#
+sqlite3 db :memory:
+do_execsql_test gencol1-11.10 {
+ PRAGMA foreign_keys = true;
+ CREATE TABLE t0(
+ c0,
+ c1 INTEGER PRIMARY KEY,
+ c2 BLOB UNIQUE DEFAULT x'00',
+ c3 BLOB GENERATED ALWAYS AS (1),
+ FOREIGN KEY(c1) REFERENCES t0(c2)
+ );
+}
+do_catchsql_test gencol1-11.20 {
+ INSERT OR REPLACE INTO t0(c0, c1) VALUES (2, 1), (1, 0)
+} {1 {FOREIGN KEY constraint failed}}
+do_execsql_test gencol1-11.30 {
+ DROP TABLE t0;
+ CREATE TABLE t0(
+ c0,
+ c1 INTEGER PRIMARY KEY,
+ c3 BLOB GENERATED ALWAYS AS (1),
+ c2 BLOB UNIQUE DEFAULT x'00',
+ FOREIGN KEY(c1) REFERENCES t0(c2)
+ );
+}
+do_catchsql_test gencol1-11.40 {
+ INSERT OR REPLACE INTO t0(c0, c1) VALUES (2, 1), (1, 0)
+} {1 {FOREIGN KEY constraint failed}}
+do_execsql_test gencol1-11.50 {
+ DROP TABLE t0;
+ CREATE TABLE t0(
+ c0,
+ c3 BLOB GENERATED ALWAYS AS (1),
+ c1 INTEGER PRIMARY KEY,
+ c2 BLOB UNIQUE DEFAULT x'00',
+ FOREIGN KEY(c1) REFERENCES t0(c2)
+ );
+}
+do_catchsql_test gencol1-11.60 {
+ INSERT OR REPLACE INTO t0(c0, c1) VALUES (2, 1), (1, 0)
+} {1 {FOREIGN KEY constraint failed}}
+do_execsql_test gencol1-11.70 {
+ DROP TABLE t0;
+ CREATE TABLE t0(
+ c3 BLOB GENERATED ALWAYS AS (1),
+ c0,
+ c1 INTEGER PRIMARY KEY,
+ c2 BLOB UNIQUE DEFAULT x'00',
+ FOREIGN KEY(c1) REFERENCES t0(c2)
+ );
+}
+do_catchsql_test gencol1-11.80 {
+ INSERT OR REPLACE INTO t0(c0, c1) VALUES (2, 1), (1, 0)
+} {1 {FOREIGN KEY constraint failed}}
+
+# 2019-12-09 ticket bd8c280671ba44a7
+# With generated columns, the sqlite3ExprGetColumnOfTable() routine might
+# generate a code sequence that does not end with OP_Column. So check to
+# make sure that the last instruction generated is an OP_column prior to
+# applying the OPFLAG_TYPEOFARG optimization to NOT NULL checks in the
+# PRAGMA integrity_check code.
+#
+sqlite3 db :memory:
+do_execsql_test gencol1-12.10 {
+ CREATE TABLE t0 (c0, c1 NOT NULL AS (c0==0));
+ INSERT INTO t0(c0) VALUES (0);
+ PRAGMA integrity_check;
+} {ok}
+
+# 2019-12-09 bug report from Yongheng Chen
+# Ensure that the SrcList_item.colUsed field is set correctly when a
+# generated column appears in the USING clause of a join.
+#
+do_execsql_test gencol1-13.10 {
+ CREATE TABLE t1(x, y AS(x+1));
+ INSERT INTO t1 VALUES(10);
+ SELECT y FROM t1 JOIN t1 USING (y,y);
+} {11}
+do_execsql_test gencol1-13.11 {
+ SELECT 123 FROM t1 JOIN t1 USING (x);
+} {123}
+do_execsql_test gencol1-13.11 {
+ SELECT 456 FROM t1 JOIN t1 USING (x,x);
+} {456}
+do_execsql_test gencol1-13.20 {
+ CREATE INDEX t1y ON t1(y);
+ SELECT y FROM t1 JOIN t1 USING (y,y);
+} {11}
+do_execsql_test gencol1-13.21 {
+ CREATE INDEX t1x ON t1(x);
+ SELECT 123 FROM t1 JOIN t1 USING (x);
+} {123}
+do_execsql_test gencol1-13.22 {
+ SELECT 456 FROM t1 JOIN t1 USING (x,x);
+} {456}
+
+# 2019-12-14 ticket b439bfcfb7deedc6
+#
+sqlite3 db :memory:
+do_execsql_test gencol1-14.10 {
+ CREATE TABLE t0(c0 AS(1 >= 1), c1 UNIQUE AS(TYPEOF(c0)), c2);
+ INSERT INTO t0 VALUES(0);
+ REINDEX;
+ SELECT * FROM t0;
+} {1 integer 0}
+do_catchsql_test gencol1-14.10 {
+ INSERT INTO t0 VALUES(2);
+} {1 {UNIQUE constraint failed: t0.c1}}
+
+# 2019-12-14 gramfuzz1 find
+# The schema is malformed in that it has a subquery on a generated
+# column expression. This will be loaded if writable_schema=ON. SQLite
+# must not use such an expression during code generation as the code generator
+# will add bits of content to the expression tree that might be allocated
+# from lookaside. But the schema is not tied to a particular database
+# connection, so the use of lookaside memory is prohibited. The fix
+# is to change the generated column expression to NULL before adding it
+# to the schema.
+#
+reset_db
+do_test gencol1-15.10 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 8192 pagesize 4096 filename c27.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 02 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ................
+| 96: 00 2e 3f d8 0d 00 00 00 01 0f ba 00 0f ba 00 00 ..?.............
+| 4016: 00 00 00 00 00 00 00 00 00 00 44 01 06 17 11 11 ..........D.....
+| 4032: 01 75 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .utablet1t1.CREA
+| 4048: 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e TE TABLE t1(a IN
+| 4064: 54 2c 20 62 20 41 53 28 28 56 41 4c 55 45 53 28 T, b AS((VALUES(
+| 4080: 31 29 29 20 49 53 20 75 6e 6b 6e 6f 77 6e 29 29 1)) IS unknown))
+| page 2 offset 4096
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| end c27.db
+}]} {}
+do_execsql_test gencol1-15.20 {
+ PRAGMA writable_schema=ON;
+ REPLACE INTO t1 VALUES(9);
+ SELECT a, quote(b) FROM t1
+} {9 NULL}
+
+# 2019-12-16 ticket 3b84b42943644d6f
+# When a table is the right table of a LEFT JOIN and the ON clause is
+# false, make sure any generated columns evaluate to NULL.
+reset_db
+do_execsql_test gencol1-16.10 {
+ CREATE TABLE t0(c0);
+ CREATE TABLE t1(c1, c2 AS(1));
+ INSERT INTO t0 VALUES(0);
+ SELECT c0, c1, c2 FROM t0 LEFT JOIN t1;
+} {0 {} {}}
+do_execsql_test gencol1-16.20 {
+ DROP TABLE t1;
+ CREATE TABLE t1(c1, c2 AS (c1 ISNULL));
+ SELECT c0, c1, c2 FROM t0 LEFT JOIN t1;
+} {0 {} {}}
+do_execsql_test gencol1-16.30 {
+ INSERT INTO t1(c1) VALUES(1),(NULL);
+ SELECT * FROM t1;
+} {1 0 {} 1}
+do_execsql_test gencol1-16.40 {
+ SELECT c0, c1, c2 FROM t0 LEFT JOIN t1 ON c0=c1;
+} {0 {} {}}
+
+# 2019-12-20 ticket e0a8120553f4b082
+# Generated columns with REAL affinity need to have an OP_RealAffinity
+# opcode applied, even when the column value is extracted from an index.
+#
+reset_db
+do_execsql_test gencol1-17.10 {
+ CREATE TABLE t0(c0 REAL AS(1) UNIQUE, c1 INT);
+ INSERT INTO t0 VALUES('');
+ SELECT quote(c0), quote(c1) from t0;
+} {1.0 ''}
+do_execsql_test gencol1-17.20 {
+ SELECT *, (1 BETWEEN CAST(t0.c0 AS TEXT) AND t0.c0) FROM t0;
+} {1.0 {} 0}
+do_execsql_test gencol1-17.30 {
+ SELECT * FROM t0 WHERE (1 BETWEEN CAST(t0.c0 AS TEXT) AND t0.c0);
+} {}
+do_execsql_test gencol1-17.40 {
+ CREATE TABLE t1(a TEXT AS(b) COLLATE nocase, b TEXT, c INT, d DEFAULT 1);
+ INSERT INTO t1(b,c) VALUES('abc',11),('DEF',22),('ghi',33);
+ SELECT a FROM t1 WHERE b='DEF' AND a='def';
+} {DEF}
+do_execsql_test gencol1-17.50 {
+ CREATE INDEX t1bca ON t1(b,c,a);
+ SELECT a FROM t1 WHERE b='DEF' AND a='def';
+} {DEF}
+
+# 2019-12-26 ticket ec8abb025e78f40c
+# An index on a virtual column with a constant value (why would anybody
+# ever do such a thing?) can cause problems for a one-pass DELETE.
+#
+reset_db
+do_execsql_test gencol1-18.10 {
+ CREATE TABLE t0(c0 UNIQUE AS(0), c1, c2);
+ INSERT INTO t0(c1) VALUES(0);
+ SELECT * FROM t0;
+} {0 0 {}}
+do_execsql_test gencol1-18.20 {
+ UPDATE t0 SET c1=0, c2=0 WHERE c0>=0;
+ SELECT * FROM t0;
+} {0 0 0}
+
+# 2019-12-27 ticket de4b04149b9fdeae
+#
+reset_db
+do_catchsql_test gencol1-19.10 {
+ CREATE TABLE t0(
+ c0 INT AS(2) UNIQUE,
+ c1 TEXT UNIQUE,
+ FOREIGN KEY(c0) REFERENCES t0(c1)
+ );
+ INSERT INTO t0(c1) VALUES(0.16334143182538696), (0);
+} {1 {UNIQUE constraint failed: t0.c0}}
+
+# 2020-06-29 forum bug report.
+# https://sqlite.org/forum/forumpost/73b9a8ccfb
+#
+do_execsql_test gencol1-20.1 {
+ CREATE TEMPORARY TABLE tab (
+ prim DATE PRIMARY KEY,
+ a INTEGER,
+ comp INTEGER AS (a),
+ b INTEGER,
+ x INTEGER
+ );
+ -- Add some data
+ INSERT INTO tab (prim, a, b) VALUES ('2001-01-01', 0, 0);
+ -- Check that each column is 0 like I expect
+ SELECT * FROM tab;
+} {2001-01-01 0 0 0 {}}
+do_execsql_test gencol1-20.2 {
+ -- Do an UPSERT on the b column
+ INSERT INTO tab (prim, b)
+ VALUES ('2001-01-01',5)
+ ON CONFLICT(prim) DO UPDATE SET b=excluded.b;
+ -- Now b is NULL rather than 5
+ SELECT * FROM tab;
+} {2001-01-01 0 0 5 {}}
+
+# 2021-07-30 forum https://sqlite.org/forum/forumpost/ff3ffe09251c105b?t=h
+#
+ifcapable vtab {
+reset_db
+ do_execsql_test gencol1-21.1 {
+ CREATE TABLE t1(
+ a integer primary key,
+ b int generated always as (a+5),
+ c text GENERATED ALWAYS as (printf('%08x',a)),
+ d Generated
+ Always
+ AS ('xyzzy'),
+ e int Always default(5)
+ );
+ INSERT INTO t1(a) VALUES(5);
+ SELECT name, type FROM pragma_table_xinfo('t1');
+ } {a INTEGER b INT c TEXT d {} e INT}
+}
+
+# 2021-09-07 forum https://sqlite.org/forum/forumpost/699b44b3ee
+#
+reset_db
+do_execsql_test gencol1-22.1 {
+ CREATE TABLE t0(a PRIMARY KEY,b TEXT AS ('2') UNIQUE);
+ INSERT INTO t0(a) VALUES(2);
+ SELECT * FROM t0 AS x JOIN t0 AS y
+ WHERE x.b='2'
+ AND (y.a=2 OR (x.b LIKE '2*' AND y.a=x.b));
+} {2 2 2 2}
+
+finish_test
diff --git a/test/genesis.tcl b/test/genesis.tcl
new file mode 100644
index 0000000..4ba4c8e
--- /dev/null
+++ b/test/genesis.tcl
@@ -0,0 +1,1560 @@
+# 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 a TCL function that fills an FTS table with
+# lots of content useful for testing. This routine is broken out into
+# a separate file to facilitate its use by multiple test scripts.
+#
+
+# The fts_kjv_genesis routine is already loaded. This script is a no-op.
+if {[lsearch [info procs] fts_kjv_genesis]>=0} 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 fts_kjv_genesis {} {
+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;
+}
+}
diff --git a/test/having.test b/test/having.test
new file mode 100644
index 0000000..3bfa812
--- /dev/null
+++ b/test/having.test
@@ -0,0 +1,191 @@
+# 2017 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.
+#
+#***********************************************************************
+#
+# Test the HAVING->WHERE optimization.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix having
+
+do_execsql_test 1.0 {
+ CREATE TABLE t2(c, d);
+
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 2);
+ INSERT INTO t1 VALUES(1, 3);
+ INSERT INTO t1 VALUES(2, 4);
+ INSERT INTO t1 VALUES(1, 5);
+ INSERT INTO t1 VALUES(2, 6);
+} {}
+
+foreach {tn sql res} {
+ 1 "SELECT a, sum(b) FROM t1 GROUP BY a HAVING a=2" {2 12}
+ 2 "SELECT a, sum(b) FROM t1 GROUP BY a HAVING a=2 AND sum(b)>10" {2 12}
+ 3 "SELECT a, sum(b) FROM t1 GROUP BY a HAVING sum(b)>12" {}
+} {
+ do_execsql_test 1.$tn $sql $res
+}
+
+# Run an EXPLAIN command for both SQL statements. Return true if
+# the outputs are identical, or false otherwise.
+#
+proc compare_vdbe {sql1 sql2} {
+ set r1 [list]
+ set r2 [list]
+ db eval "explain $sql1" { lappend r1 $opcode $p1 $p2 $p3 $p4 $p5}
+ db eval "explain $sql2" { lappend r2 $opcode $p1 $p2 $p3 $p4 $p5}
+ return [expr {$r1==$r2}]
+}
+
+proc do_compare_vdbe_test {tn sql1 sql2 res} {
+ uplevel [list do_test $tn [list compare_vdbe $sql1 $sql2] $res]
+}
+
+#-------------------------------------------------------------------------
+# Test that various statements that are eligible for the optimization
+# produce the same VDBE code as optimizing by hand does.
+#
+foreach {tn sql1 sql2} {
+ 1 "SELECT a, sum(b) FROM t1 GROUP BY a HAVING a=2"
+ "SELECT a, sum(b) FROM t1 WHERE a=2 GROUP BY a"
+
+ 2 "SELECT a, sum(b) FROM t1 GROUP BY a HAVING sum(b)>5 AND a=2"
+ "SELECT a, sum(b) FROM t1 WHERE a=2 GROUP BY a HAVING sum(b)>5"
+
+ 3 "SELECT a, sum(b) FROM t1 GROUP BY a COLLATE binary HAVING a=2"
+ "SELECT a, sum(b) FROM t1 WHERE a=2 GROUP BY a COLLATE binary"
+
+ 5 "SELECT a, sum(b) FROM t1 GROUP BY a COLLATE binary HAVING 1"
+ "SELECT a, sum(b) FROM t1 WHERE 1 GROUP BY a COLLATE binary"
+
+ 6 "SELECT count(*) FROM t1,t2 WHERE a=c GROUP BY b, d HAVING b=d"
+ "SELECT count(*) FROM t1,t2 WHERE a=c AND b=d GROUP BY b, d"
+
+ 7 {
+ SELECT count(*) FROM t1,t2 WHERE a=c GROUP BY b, d
+ HAVING b=d COLLATE nocase
+ } {
+ SELECT count(*) FROM t1,t2 WHERE a=c AND b=d COLLATE nocase
+ GROUP BY b, d
+ }
+
+ 8 "SELECT a, sum(b) FROM t1 GROUP BY a||b HAVING substr(a||b, 1, 1)='a'"
+ "SELECT a, sum(b) FROM t1 WHERE substr(a||b, 1, 1)='a' GROUP BY a||b"
+} {
+ do_compare_vdbe_test 2.$tn $sql1 $sql2 1
+}
+
+# The (4) test in the above set used to generate identical bytecode, but
+# that is no longer the case. The byte code is equivalent, though.
+#
+do_execsql_test 2.4a {
+ SELECT x,y FROM (
+ SELECT a AS x, sum(b) AS y FROM t1
+ GROUP BY a
+ ) WHERE x BETWEEN 2 AND 9999
+} {2 12}
+do_execsql_test 2.4b {
+ SELECT x,y FROM (
+ SELECT a AS x, sum(b) AS y FROM t1
+ WHERE x BETWEEN 2 AND 9999
+ GROUP BY a
+ )
+} {2 12}
+
+
+#-------------------------------------------------------------------------
+# 1: Test that the optimization is only applied if the GROUP BY term
+# uses BINARY collation.
+#
+# 2: Not applied if there is a non-deterministic function in the HAVING
+# term.
+#
+foreach {tn sql1 sql2} {
+ 1 "SELECT a, sum(b) FROM t1 GROUP BY a COLLATE nocase HAVING a=2"
+ "SELECT a, sum(b) FROM t1 WHERE a=2 GROUP BY a COLLATE nocase"
+
+ 2 "SELECT a, sum(b) FROM t1 GROUP BY a HAVING randomblob(a)<X'88'"
+ "SELECT a, sum(b) FROM t1 WHERE randomblob(a)<X'88' GROUP BY a"
+} {
+ do_compare_vdbe_test 3.$tn $sql1 $sql2 0
+}
+
+
+#-------------------------------------------------------------------------
+# Test that non-deterministic functions disqualify a term from being
+# moved from the HAVING to WHERE clause.
+#
+do_execsql_test 4.1 {
+ CREATE TABLE t3(a, b);
+ INSERT INTO t3 VALUES(1, 1);
+ INSERT INTO t3 VALUES(1, 2);
+ INSERT INTO t3 VALUES(1, 3);
+ INSERT INTO t3 VALUES(2, 1);
+ INSERT INTO t3 VALUES(2, 2);
+ INSERT INTO t3 VALUES(2, 3);
+}
+
+proc nondeter {args} {
+ incr ::nondeter_ret
+ expr {$::nondeter_ret % 2}
+}
+db func nondeter nondeter
+
+set ::nondeter_ret 0
+do_execsql_test 4.2 {
+ SELECT a, sum(b) FROM t3 GROUP BY a HAVING nondeter(a)
+} {1 6}
+
+# If the term where moved, the query above would return the same
+# result as the following. But it does not.
+#
+set ::nondeter_ret 0
+do_execsql_test 4.3 {
+ SELECT a, sum(b) FROM t3 WHERE nondeter(a) GROUP BY a
+} {1 4 2 2}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t1 VALUES('a', 'b');
+}
+
+# The WHERE clause (a=2), uses an aggregate column from the outer query.
+# If the HAVING term (0) is moved into the WHERE clause in this case,
+# SQLite would at one point optimize (a=2 AND 0) to simply (0). Which
+# is logically correct, but happened to cause problems in aggregate
+# processing for the outer query. This test case verifies that those
+# problems are no longer present.
+do_execsql_test 5.1 {
+ SELECT min(b), (
+ SELECT x FROM t2 WHERE a=2 GROUP BY y HAVING 0
+ ) FROM t1;
+} {b {}}
+
+# From chromium
+# https://bugs.chromium.org/p/chromium/issues/detail?id=1161869
+#
+do_execsql_test 5.2 {
+ SELECT EXISTS (
+ SELECT * FROM (
+ SELECT * FROM (
+ SELECT 1
+ ) WHERE Col0 = 1 GROUP BY 1
+ ) WHERE 0
+ )
+ FROM (SELECT 1 Col0) GROUP BY 1
+} {0}
+
+finish_test
diff --git a/test/hexlit.test b/test/hexlit.test
new file mode 100644
index 0000000..2161f27
--- /dev/null
+++ b/test/hexlit.test
@@ -0,0 +1,125 @@
+# 2014-07-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 tests for hexadecimal literals
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc hexlit1 {tnum val ans} {
+ do_execsql_test hexlit-$tnum "SELECT $val" $ans
+}
+
+hexlit1 100 0x0 0
+hexlit1 101 0x0000000000000000000000000000000000000000000001 1
+hexlit1 102 0x2 2
+hexlit1 103 0x4 4
+hexlit1 104 0x8 8
+hexlit1 105 0x00000000000000000000000000000000000000000000010 16
+hexlit1 103 0x20 32
+hexlit1 106 0x40 64
+hexlit1 107 0x80 128
+hexlit1 108 0x100 256
+hexlit1 109 0x200 512
+hexlit1 110 0X400 1024
+hexlit1 111 0x800 2048
+hexlit1 112 0x1000 4096
+hexlit1 113 0x2000 8192
+hexlit1 114 0x4000 16384
+hexlit1 115 0x8000 32768
+hexlit1 116 0x10000 65536
+hexlit1 117 0x20000 131072
+hexlit1 118 0x40000 262144
+hexlit1 119 0x80000 524288
+hexlit1 120 0x100000 1048576
+hexlit1 121 0x200000 2097152
+hexlit1 122 0x400000 4194304
+hexlit1 123 0x800000 8388608
+hexlit1 124 0x1000000 16777216
+hexlit1 125 0x2000000 33554432
+hexlit1 126 0x4000000 67108864
+hexlit1 127 0x8000000 134217728
+hexlit1 128 0x10000000 268435456
+hexlit1 129 0x20000000 536870912
+hexlit1 130 0x40000000 1073741824
+hexlit1 131 0x80000000 2147483648
+hexlit1 132 0x100000000 4294967296
+hexlit1 133 0x200000000 8589934592
+hexlit1 134 0x400000000 17179869184
+hexlit1 135 0x800000000 34359738368
+hexlit1 136 0x1000000000 68719476736
+hexlit1 137 0x2000000000 137438953472
+hexlit1 138 0x4000000000 274877906944
+hexlit1 139 0x8000000000 549755813888
+hexlit1 140 0x10000000000 1099511627776
+hexlit1 141 0x20000000000 2199023255552
+hexlit1 142 0x40000000000 4398046511104
+hexlit1 143 0x80000000000 8796093022208
+hexlit1 144 0x100000000000 17592186044416
+hexlit1 145 0x200000000000 35184372088832
+hexlit1 146 0x400000000000 70368744177664
+hexlit1 147 0x800000000000 140737488355328
+hexlit1 148 0x1000000000000 281474976710656
+hexlit1 149 0x2000000000000 562949953421312
+hexlit1 150 0x4000000000000 1125899906842624
+hexlit1 151 0x8000000000000 2251799813685248
+hexlit1 152 0x10000000000000 4503599627370496
+hexlit1 153 0x20000000000000 9007199254740992
+hexlit1 154 0x40000000000000 18014398509481984
+hexlit1 155 0x80000000000000 36028797018963968
+hexlit1 156 0x100000000000000 72057594037927936
+hexlit1 157 0x200000000000000 144115188075855872
+hexlit1 158 0x400000000000000 288230376151711744
+hexlit1 159 0x800000000000000 576460752303423488
+hexlit1 160 0X1000000000000000 1152921504606846976
+hexlit1 161 0x2000000000000000 2305843009213693952
+hexlit1 162 0X4000000000000000 4611686018427387904
+hexlit1 163 0x8000000000000000 -9223372036854775808
+hexlit1 164 0XFFFFFFFFFFFFFFFF -1
+
+for {set n 1} {$n < 0x10} {incr n} {
+ hexlit1 200.$n.1 0X[format %03X $n] $n
+ hexlit1 200.$n.2 0x[format %03X $n] $n
+ hexlit1 200.$n.3 0X[format %03x $n] $n
+ hexlit1 200.$n.4 0x[format %03x $n] $n
+}
+
+# String literals that look like hex do not get cast or coerced.
+#
+do_execsql_test hexlit-300 {
+ CREATE TABLE t1(x INT, y REAL);
+ INSERT INTO t1 VALUES('1234','4567'),('0x1234','0x4567');
+ SELECT typeof(x), x, typeof(y), y, '#' FROM t1 ORDER BY rowid;
+} {integer 1234 real 4567.0 # text 0x1234 text 0x4567 #}
+do_execsql_test hexlit-301 {
+ SELECT CAST('0x1234' AS INTEGER);
+} {0}
+
+# Oversized hex literals are rejected
+#
+do_catchsql_test hexlist-400 {
+ SELECT 0x10000000000000000;
+} {1 {hex literal too big: 0x10000000000000000}}
+do_catchsql_test hexlist-401 {
+ SELECT DISTINCT 0x10000000000000000;
+} {1 {hex literal too big: 0x10000000000000000}}
+do_catchsql_test hexlist-402 {
+ SELECT DISTINCT -0x08000000000000000;
+} {1 {hex literal too big: -0x08000000000000000}}
+do_catchsql_test hexlist-410 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1+0x10000000000000000);
+} {1 {hex literal too big: 0x10000000000000000}}
+
+
+finish_test
diff --git a/test/hidden.test b/test/hidden.test
new file mode 100644
index 0000000..1db2cad
--- /dev/null
+++ b/test/hidden.test
@@ -0,0 +1,153 @@
+# 2015 November 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.
+#
+#***********************************************************************
+#
+# Test the __hidden__ hack.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix hidden
+
+ifcapable !hiddencolumns {
+ finish_test
+ return
+}
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(__hidden__a, b);
+ INSERT INTO t1 VALUES('1');
+ INSERT INTO t1(__hidden__a, b) VALUES('x', 'y');
+} {}
+
+do_execsql_test 1.2 {
+ SELECT * FROM t1;
+} {1 y}
+
+do_execsql_test 1.3 {
+ SELECT __hidden__a, * FROM t1;
+} {{} 1 x y}
+
+foreach {tn view} {
+ 1 { CREATE VIEW v1(a, b, __hidden__c) AS SELECT a, b, c FROM x1 }
+ 2 { CREATE VIEW v1 AS SELECT a, b, c AS __hidden__c FROM x1 }
+} {
+ do_execsql_test 2.$tn.1 {
+ DROP TABLE IF EXISTS x1;
+ CREATE TABLE x1(a, b, c);
+ INSERT INTO x1 VALUES(1, 2, 3);
+ }
+
+ catchsql { DROP VIEW v1 }
+ execsql $view
+
+ do_execsql_test 2.$tn.2 {
+ SELECT a, b, __hidden__c FROM v1;
+ } {1 2 3}
+
+ do_execsql_test 2.$tn.3 {
+ SELECT * FROM v1;
+ } {1 2}
+
+ do_execsql_test 2.$tn.4 {
+ CREATE TRIGGER tr1 INSTEAD OF INSERT ON v1 BEGIN
+ INSERT INTO x1 VALUES(new.a, new.b, new.__hidden__c);
+ END;
+
+ INSERT INTO v1 VALUES(4, 5);
+ SELECT * FROM x1;
+ } {1 2 3 4 5 {}}
+
+ do_execsql_test 2.$tn.5 {
+ INSERT INTO v1(a, b, __hidden__c) VALUES(7, 8, 9);
+ SELECT * FROM x1;
+ } {1 2 3 4 5 {} 7 8 9}
+}
+
+#-------------------------------------------------------------------------
+# Test INSERT INTO ... SELECT ... statements that write to tables with
+# hidden columns.
+#
+do_execsql_test 3.1 {
+ CREATE TABLE t4(a, __hidden__b, c);
+ INSERT INTO t4 SELECT 1, 2;
+ SELECT a, __hidden__b, c FROM t4;
+} {1 {} 2}
+
+do_execsql_test 3.2.1 {
+ CREATE TABLE t5(__hidden__a, b, c);
+ CREATE TABLE t6(__hidden__a, b, c);
+ INSERT INTO t6(__hidden__a, b, c) VALUES(1, 2, 3);
+ INSERT INTO t6(__hidden__a, b, c) VALUES(4, 5, 6);
+ INSERT INTO t6(__hidden__a, b, c) VALUES(7, 8, 9);
+}
+
+do_execsql_test 3.2.2 {
+ INSERT INTO t5 SELECT * FROM t6;
+ SELECT * FROM t5;
+} {2 3 5 6 8 9}
+
+do_execsql_test 3.2.3 {
+ SELECT __hidden__a FROM t5;
+} {{} {} {}}
+
+
+do_execsql_test 3.3.1 {
+ CREATE TABLE t5a(a, b, __hidden__c);
+ CREATE TABLE t6a(a, b, __hidden__c);
+ INSERT INTO t6a(a, b, __hidden__c) VALUES(1, 2, 3);
+ INSERT INTO t6a(a, b, __hidden__c) VALUES(4, 5, 6);
+ INSERT INTO t6a(a, b, __hidden__c) VALUES(7, 8, 9);
+}
+
+do_execsql_test 3.3.2 {
+ INSERT INTO t5a SELECT * FROM t6a;
+ SELECT * FROM t5a;
+} {1 2 4 5 7 8}
+
+do_execsql_test 3.3.3 {
+ SELECT __hidden__c FROM t5a;
+} {{} {} {}}
+
+do_execsql_test 3.4.1 {
+ CREATE TABLE t5b(a, __hidden__b, c);
+ CREATE TABLE t6b(a, b, __hidden__c);
+ INSERT INTO t6b(a, b, __hidden__c) VALUES(1, 2, 3);
+ INSERT INTO t6b(a, b, __hidden__c) VALUES(4, 5, 6);
+ INSERT INTO t6b(a, b, __hidden__c) VALUES(7, 8, 9);
+}
+
+do_execsql_test 3.4.2 {
+ INSERT INTO t5b SELECT * FROM t6b;
+ SELECT * FROM t5b;
+} {1 2 4 5 7 8}
+
+do_execsql_test 3.4.3 {
+ SELECT __hidden__b FROM t5b;
+} {{} {} {}}
+
+#-------------------------------------------------------------------------
+# Test VACUUM
+#
+reset_db
+do_execsql_test 4.1 {
+ CREATE TABLE t1(a, __hidden__b, c UNIQUE);
+ INSERT INTO t1(a, __hidden__b, c) VALUES(1, 2, 3);
+ INSERT INTO t1(a, __hidden__b, c) VALUES(4, 5, 6);
+ INSERT INTO t1(a, __hidden__b, c) VALUES(7, 8, 9);
+ DELETE FROM t1 WHERE __hidden__b = 5;
+ SELECT rowid, a, __hidden__b, c FROM t1;
+} {1 1 2 3 3 7 8 9}
+do_execsql_test 4.2 {
+ VACUUM;
+ SELECT rowid, a, __hidden__b, c FROM t1;
+} {1 1 2 3 3 7 8 9}
+
+finish_test
diff --git a/test/hook.test b/test/hook.test
new file mode 100644
index 0000000..bb868df
--- /dev/null
+++ b/test/hook.test
@@ -0,0 +1,1024 @@
+# 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
+set ::testprefix hook
+
+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}}
+verify_ex_errcode hook-3.6b SQLITE_CONSTRAINT_COMMITHOOK
+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.
+#
+# EVIDENCE-OF: R-21999-45122 The sqlite3_update_hook() interface
+# registers a callback function with the database connection identified
+# by the first argument to be invoked whenever a row is updated,
+# inserted or deleted in a rowid table.
+
+# Simple tests
+do_test hook-4.1.1a {
+ catchsql {
+ DROP TABLE t1;
+ }
+ unset -nocomplain ::update_hook
+ set ::update_hook {}
+ db update_hook [list lappend ::update_hook]
+ #
+ # EVIDENCE-OF: R-24531-54682 The update hook is not invoked when
+ # internal system tables are modified (i.e. sqlite_sequence).
+ #
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t1w(a INT PRIMARY KEY, b) WITHOUT ROWID;
+ }
+ set ::update_hook
+} {}
+do_test hook-4.1.1b {
+ execsql {
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+ INSERT INTO t1w SELECT * FROM t1;
+ }
+} {}
+
+# EVIDENCE-OF: R-15506-57666 The second callback argument is one of
+# SQLITE_INSERT, SQLITE_DELETE, or SQLITE_UPDATE, depending on the
+# operation that caused the callback to be invoked.
+#
+# EVIDENCE-OF: R-29213-61195 The third and fourth arguments to the
+# callback contain pointers to the database and table name containing
+# the affected row.
+#
+# EVIDENCE-OF: R-30809-57812 The final callback parameter is the rowid
+# of the row.
+#
+do_test hook-4.1.2 {
+ set ::update_hook {}
+ 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 \
+]
+
+# EVIDENCE-OF: R-61808-14344 The sqlite3_update_hook() interface does
+# not fire callbacks for changes to a WITHOUT ROWID table.
+#
+# EVIDENCE-OF: R-33257-44249 The update hook is not invoked when WITHOUT
+# ROWID tables are modified.
+#
+do_test hook-4.1.2w {
+ set ::update_hook {}
+ execsql {
+ INSERT INTO t1w VALUES(4, 'four');
+ DELETE FROM t1w WHERE b = 'two';
+ UPDATE t1w SET b = '' WHERE a = 1 OR a = 3;
+ DELETE FROM t1w WHERE 1; -- Avoid the truncate optimization (for now)
+ }
+ set ::update_hook
+} {}
+
+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
+
+#----------------------------------------------------------------------------
+# The following tests - hook-7.* - test the pre-update hook.
+#
+ifcapable !preupdate {
+ finish_test
+ return
+}
+#
+# 7.1.1 - INSERT statement.
+# 7.1.2 - INSERT INTO ... SELECT statement.
+# 7.1.3 - REPLACE INTO ... (rowid conflict)
+# 7.1.4 - REPLACE INTO ... (other index conflicts)
+# 7.1.5 - REPLACE INTO ... (both rowid and other index conflicts)
+#
+# 7.2.1 - DELETE statement.
+# 7.2.2 - DELETE statement that uses the truncate optimization.
+#
+# 7.3.1 - UPDATE statement.
+# 7.3.2 - UPDATE statement that modifies the rowid.
+# 7.3.3 - UPDATE OR REPLACE ... (rowid conflict).
+# 7.3.4 - UPDATE OR REPLACE ... (other index conflicts)
+# 7.3.4 - UPDATE OR REPLACE ... (both rowid and other index conflicts)
+#
+# 7.4.1 - Test that the pre-update-hook is invoked only once if a row being
+# deleted is removed by a BEFORE trigger.
+#
+# 7.4.2 - Test that the pre-update-hook is invoked if a BEFORE trigger
+# removes a row being updated. In this case the update hook should
+# be invoked with SQLITE_INSERT as the opcode when inserting the
+# new version of the row.
+#
+# TODO: Short records (those created before a column is added to a table
+# using ALTER TABLE)
+#
+
+proc do_preupdate_test {tn sql x} {
+ set X [list]
+ foreach elem $x {lappend X $elem}
+ uplevel do_test $tn [list "
+ set ::preupdate \[list\]
+ execsql { $sql }
+ set ::preupdate
+ "] [list $X]
+}
+
+proc preupdate_hook {args} {
+ set type [lindex $args 0]
+ eval lappend ::preupdate $args
+ if {$type != "INSERT"} {
+ for {set i 0} {$i < [db preupdate count]} {incr i} {
+ lappend ::preupdate [db preupdate old $i]
+ }
+ }
+ if {$type != "DELETE"} {
+ for {set i 0} {$i < [db preupdate count]} {incr i} {
+ set rc [catch { db preupdate new $i } v]
+ lappend ::preupdate $v
+ }
+ }
+}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+db preupdate hook preupdate_hook
+
+# Set up a schema to use for tests 7.1.* to 7.3.*.
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(x, y);
+ CREATE TABLE t3(i, j, UNIQUE(i));
+
+ INSERT INTO t2 VALUES('a', 'b');
+ INSERT INTO t2 VALUES('c', 'd');
+
+ INSERT INTO t3 VALUES(4, 16);
+ INSERT INTO t3 VALUES(5, 25);
+ INSERT INTO t3 VALUES(6, 36);
+}
+
+do_preupdate_test 7.1.1 {
+ INSERT INTO t1 VALUES('x', 'y')
+} {INSERT main t1 1 1 x y}
+
+# 7.1.2.1 does not use the xfer optimization. 7.1.2.2 does.
+do_preupdate_test 7.1.2.1 {
+ INSERT INTO t1 SELECT y, x FROM t2;
+} {INSERT main t1 2 2 b a INSERT main t1 3 3 d c}
+do_preupdate_test 7.1.2.2 {
+ INSERT INTO t1 SELECT * FROM t2;
+} {INSERT main t1 4 4 a b INSERT main t1 5 5 c d}
+
+do_preupdate_test 7.1.3 {
+ REPLACE INTO t1(rowid, a, b) VALUES(1, 1, 1);
+} {
+ DELETE main t1 1 1 x y
+ INSERT main t1 1 1 1 1
+}
+
+do_preupdate_test 7.1.4 {
+ REPLACE INTO t3 VALUES(4, NULL);
+} {
+ DELETE main t3 1 1 4 16
+ INSERT main t3 4 4 4 {}
+}
+
+do_preupdate_test 7.1.5 {
+ REPLACE INTO t3(rowid, i, j) VALUES(2, 6, NULL);
+} {
+ DELETE main t3 2 2 5 25
+ DELETE main t3 3 3 6 36
+ INSERT main t3 2 2 6 {}
+}
+
+do_execsql_test 7.2.0 { SELECT rowid FROM t1 } {1 2 3 4 5}
+
+do_preupdate_test 7.2.1 {
+ DELETE FROM t1 WHERE rowid = 3
+} {
+ DELETE main t1 3 3 d c
+}
+do_preupdate_test 7.2.2 {
+ DELETE FROM t1
+} {
+ DELETE main t1 1 1 1 1
+ DELETE main t1 2 2 b a
+ DELETE main t1 4 4 a b
+ DELETE main t1 5 5 c d
+}
+
+do_execsql_test 7.3.0 {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ DELETE FROM t3;
+
+ INSERT INTO t2 VALUES('a', 'b');
+ INSERT INTO t2 VALUES('c', 'd');
+
+ INSERT INTO t3 VALUES(4, 16);
+ INSERT INTO t3 VALUES(5, 25);
+ INSERT INTO t3 VALUES(6, 36);
+}
+
+do_preupdate_test 7.3.1 {
+ UPDATE t2 SET y = y||y;
+} {
+ UPDATE main t2 1 1 a b a bb
+ UPDATE main t2 2 2 c d c dd
+}
+
+do_preupdate_test 7.3.2 {
+ UPDATE t2 SET rowid = rowid-1;
+} {
+ UPDATE main t2 1 0 a bb a bb
+ UPDATE main t2 2 1 c dd c dd
+}
+
+do_preupdate_test 7.3.3 {
+ UPDATE OR REPLACE t2 SET rowid = 1 WHERE x = 'a'
+} {
+ DELETE main t2 1 1 c dd
+ UPDATE main t2 0 1 a bb a bb
+}
+
+do_preupdate_test 7.3.4.1 {
+ UPDATE OR REPLACE t3 SET i = 5 WHERE i = 6
+} {
+ DELETE main t3 2 2 5 25
+ UPDATE main t3 3 3 6 36 5 36
+}
+
+do_execsql_test 7.3.4.2 {
+ INSERT INTO t3 VALUES(10, 100);
+ SELECT rowid, * FROM t3;
+} {1 4 16 3 5 36 4 10 100}
+
+do_preupdate_test 7.3.5 {
+ UPDATE OR REPLACE t3 SET rowid = 1, i = 5 WHERE j = 100;
+} {
+ DELETE main t3 1 1 4 16
+ DELETE main t3 3 3 5 36
+ UPDATE main t3 4 1 10 100 5 100
+}
+
+do_execsql_test 7.4.1.0 {
+ CREATE TABLE t4(a, b);
+ INSERT INTO t4 VALUES('a', 1);
+ INSERT INTO t4 VALUES('b', 2);
+ INSERT INTO t4 VALUES('c', 3);
+
+ CREATE TRIGGER t4t BEFORE DELETE ON t4 BEGIN
+ DELETE FROM t4 WHERE b = 1;
+ END;
+}
+
+do_preupdate_test 7.4.1.1 {
+ DELETE FROM t4 WHERE b = 3
+} {
+ DELETE main t4 1 1 a 1
+ DELETE main t4 3 3 c 3
+}
+
+do_execsql_test 7.4.1.2 {
+ INSERT INTO t4(rowid, a, b) VALUES(1, 'a', 1);
+ INSERT INTO t4(rowid, a, b) VALUES(3, 'c', 3);
+}
+do_preupdate_test 7.4.1.3 {
+ DELETE FROM t4 WHERE b = 1
+} {
+ DELETE main t4 1 1 a 1
+}
+
+do_execsql_test 7.4.2.0 {
+ CREATE TABLE t5(a, b);
+ INSERT INTO t5 VALUES('a', 1);
+ INSERT INTO t5 VALUES('b', 2);
+ INSERT INTO t5 VALUES('c', 3);
+
+ CREATE TRIGGER t5t BEFORE UPDATE ON t5 BEGIN
+ DELETE FROM t5 WHERE b = 1;
+ END;
+}
+do_preupdate_test 7.4.2.1 {
+ UPDATE t5 SET b = 4 WHERE a = 'c'
+} {
+ DELETE main t5 1 1 a 1
+ UPDATE main t5 3 3 c 3 c 4
+}
+
+do_execsql_test 7.4.2.2 {
+ INSERT INTO t5(rowid, a, b) VALUES(1, 'a', 1);
+}
+
+do_preupdate_test 7.4.2.3 {
+ UPDATE t5 SET b = 5 WHERE a = 'a'
+} {
+ DELETE main t5 1 1 a 1
+}
+
+ifcapable altertable {
+ do_execsql_test 7.5.1.0 {
+ CREATE TABLE t7(a, b);
+ INSERT INTO t7 VALUES('one', 'two');
+ INSERT INTO t7 VALUES('three', 'four');
+ ALTER TABLE t7 ADD COLUMN c DEFAULT NULL;
+ }
+
+ do_preupdate_test 7.5.1.1 {
+ DELETE FROM t7 WHERE a = 'one'
+ } {
+ DELETE main t7 1 1 one two {}
+ }
+
+ do_preupdate_test 7.5.1.2 {
+ UPDATE t7 SET b = 'five'
+ } {
+ UPDATE main t7 2 2 three four {} three five {}
+ }
+
+ do_execsql_test 7.5.2.0 {
+ CREATE TABLE t8(a, b);
+ INSERT INTO t8 VALUES('one', 'two');
+ INSERT INTO t8 VALUES('three', 'four');
+ ALTER TABLE t8 ADD COLUMN c DEFAULT 'xxx';
+ }
+}
+
+if 0 {
+ # At time of writing, these two are broken. They demonstrate that the
+ # sqlite3_preupdate_old() method does not handle the case where ALTER TABLE
+ # has been used to add a column with a default value other than NULL.
+ #
+ do_preupdate_test 7.5.2.1 {
+ DELETE FROM t8 WHERE a = 'one'
+ } {
+ DELETE main t8 1 1 one two xxx
+ }
+ do_preupdate_test 7.5.2.2 {
+ UPDATE t8 SET b = 'five'
+ } {
+ UPDATE main t8 2 2 three four xxx three five xxx
+ }
+}
+
+# This block of tests verifies that IPK values are correctly reported
+# by the sqlite3_preupdate_old() and sqlite3_preupdate_new() functions.
+#
+do_execsql_test 7.6.1 { CREATE TABLE t9(a, b INTEGER PRIMARY KEY, c) }
+do_preupdate_test 7.6.2 {
+ INSERT INTO t9 VALUES(1, 2, 3);
+ UPDATE t9 SET b = b+1, c = c+1;
+ DELETE FROM t9 WHERE a = 1;
+} {
+ INSERT main t9 2 2 1 2 3
+ UPDATE main t9 2 3 1 2 3 1 3 4
+ DELETE main t9 3 3 1 3 4
+}
+
+#--------------------------------------------------------------------------
+# Test that the sqlite3_preupdate_depth() API seems to work.
+#
+proc preupdate_hook {args} {
+ set type [lindex $args 0]
+ eval lappend ::preupdate $args
+ eval lappend ::preupdate [db preupdate depth]
+
+ if {$type != "INSERT"} {
+ for {set i 0} {$i < [db preupdate count]} {incr i} {
+ lappend ::preupdate [db preupdate old $i]
+ }
+ }
+ if {$type != "DELETE"} {
+ for {set i 0} {$i < [db preupdate count]} {incr i} {
+ set rc [catch { db preupdate new $i } v]
+ lappend ::preupdate $v
+ }
+ }
+}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+db preupdate hook preupdate_hook
+
+do_execsql_test 7.6.1 {
+ CREATE TABLE t1(x PRIMARY KEY);
+ CREATE TABLE t2(x PRIMARY KEY);
+ CREATE TABLE t3(x PRIMARY KEY);
+ CREATE TABLE t4(x PRIMARY KEY);
+
+ CREATE TRIGGER a AFTER INSERT ON t1 BEGIN INSERT INTO t2 VALUES(new.x); END;
+ CREATE TRIGGER b AFTER INSERT ON t2 BEGIN INSERT INTO t3 VALUES(new.x); END;
+ CREATE TRIGGER c AFTER INSERT ON t3 BEGIN INSERT INTO t4 VALUES(new.x); END;
+
+ CREATE TRIGGER d AFTER UPDATE ON t1 BEGIN UPDATE t2 SET x = new.x; END;
+ CREATE TRIGGER e AFTER UPDATE ON t2 BEGIN UPDATE t3 SET x = new.x; END;
+ CREATE TRIGGER f AFTER UPDATE ON t3 BEGIN UPDATE t4 SET x = new.x; END;
+
+ CREATE TRIGGER g AFTER DELETE ON t1 BEGIN DELETE FROM t2 WHERE 1; END;
+ CREATE TRIGGER h AFTER DELETE ON t2 BEGIN DELETE FROM t3 WHERE 1; END;
+ CREATE TRIGGER i AFTER DELETE ON t3 BEGIN DELETE FROM t4 WHERE 1; END;
+}
+
+do_preupdate_test 7.6.2 {
+ INSERT INTO t1 VALUES('xyz');
+} {
+ INSERT main t1 1 1 0 xyz
+ INSERT main t2 1 1 1 xyz
+ INSERT main t3 1 1 2 xyz
+ INSERT main t4 1 1 3 xyz
+}
+do_preupdate_test 7.6.3 {
+ UPDATE t1 SET x = 'abc';
+} {
+ UPDATE main t1 1 1 0 xyz abc
+ UPDATE main t2 1 1 1 xyz abc
+ UPDATE main t3 1 1 2 xyz abc
+ UPDATE main t4 1 1 3 xyz abc
+}
+do_preupdate_test 7.6.4 {
+ DELETE FROM t1 WHERE 1;
+} {
+ DELETE main t1 1 1 0 abc
+ DELETE main t2 1 1 1 abc
+ DELETE main t3 1 1 2 abc
+ DELETE main t4 1 1 3 abc
+}
+
+do_execsql_test 7.6.5 {
+ DROP TRIGGER a; DROP TRIGGER b; DROP TRIGGER c;
+ DROP TRIGGER d; DROP TRIGGER e; DROP TRIGGER f;
+ DROP TRIGGER g; DROP TRIGGER h; DROP TRIGGER i;
+
+ CREATE TRIGGER a BEFORE INSERT ON t1 BEGIN INSERT INTO t2 VALUES(new.x); END;
+ CREATE TRIGGER b BEFORE INSERT ON t2 BEGIN INSERT INTO t3 VALUES(new.x); END;
+ CREATE TRIGGER c BEFORE INSERT ON t3 BEGIN INSERT INTO t4 VALUES(new.x); END;
+
+ CREATE TRIGGER d BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET x = new.x; END;
+ CREATE TRIGGER e BEFORE UPDATE ON t2 BEGIN UPDATE t3 SET x = new.x; END;
+ CREATE TRIGGER f BEFORE UPDATE ON t3 BEGIN UPDATE t4 SET x = new.x; END;
+
+ CREATE TRIGGER g BEFORE DELETE ON t1 BEGIN DELETE FROM t2 WHERE 1; END;
+ CREATE TRIGGER h BEFORE DELETE ON t2 BEGIN DELETE FROM t3 WHERE 1; END;
+ CREATE TRIGGER i BEFORE DELETE ON t3 BEGIN DELETE FROM t4 WHERE 1; END;
+}
+
+do_preupdate_test 7.6.6 {
+ INSERT INTO t1 VALUES('xyz');
+} {
+ INSERT main t4 1 1 3 xyz
+ INSERT main t3 1 1 2 xyz
+ INSERT main t2 1 1 1 xyz
+ INSERT main t1 1 1 0 xyz
+}
+do_preupdate_test 7.6.3 {
+ UPDATE t1 SET x = 'abc';
+} {
+ UPDATE main t4 1 1 3 xyz abc
+ UPDATE main t3 1 1 2 xyz abc
+ UPDATE main t2 1 1 1 xyz abc
+ UPDATE main t1 1 1 0 xyz abc
+}
+do_preupdate_test 7.6.4 {
+ DELETE FROM t1 WHERE 1;
+} {
+ DELETE main t4 1 1 3 abc
+ DELETE main t3 1 1 2 abc
+ DELETE main t2 1 1 1 abc
+ DELETE main t1 1 1 0 abc
+}
+
+# No preupdate callbacks for modifying sqlite_master.
+ifcapable altertable {
+ do_preupdate_test 8.1 { CREATE TABLE x1(x, y); } { }
+ do_preupdate_test 8.2 { ALTER TABLE x1 ADD COLUMN z } { }
+ do_preupdate_test 8.3 { ALTER TABLE x1 RENAME TO y1 } { }
+ do_preupdate_test 8.4 { CREATE INDEX y1x ON y1(x) } { }
+ do_preupdate_test 8.5 { CREATE VIEW v1 AS SELECT * FROM y1 } { }
+ do_preupdate_test 8.6 { DROP TABLE y1 } { }
+}
+
+#-------------------------------------------------------------------------
+reset_db
+db preupdate hook preupdate_hook
+
+ifcapable altertable {
+ do_execsql_test 9.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ CREATE TABLE t2(a, b INTEGER PRIMARY KEY);
+ }
+ do_preupdate_test 9.1 {
+ INSERT INTO t1 VALUES(456, NULL, NULL);
+ } {
+ INSERT main t1 456 456 0 456 {} {}
+ }
+ do_execsql_test 9.2 {
+ ALTER TABLE t1 ADD COLUMN d;
+ }
+ do_preupdate_test 9.3 {
+ INSERT INTO t1(a, b, c) VALUES(457, NULL, NULL);
+ } {
+ INSERT main t1 457 457 0 457 {} {} {}
+ }
+ do_preupdate_test 9.4 {
+ DELETE FROM t1 WHERE a=456
+ } {
+ DELETE main t1 456 456 0 456 {} {} {}
+ }
+ do_preupdate_test 9.5 {
+ INSERT INTO t2 DEFAULT VALUES;
+ } {
+ INSERT main t2 1 1 0 {} 1
+ }
+ do_preupdate_test 9.6 {
+ INSERT INTO t1 DEFAULT VALUES;
+ } {
+ INSERT main t1 458 458 0 458 {} {} {}
+ }
+}
+
+
+do_execsql_test 10.0 {
+ CREATE TABLE t3(a, b INTEGER PRIMARY KEY);
+}
+do_preupdate_test 10.1 {
+ INSERT INTO t3 DEFAULT VALUES
+} {
+ INSERT main t3 1 1 0 {} 1
+}
+do_execsql_test 10.2 { SELECT * FROM t3 } {{} 1}
+do_preupdate_test 10.3 {
+ DELETE FROM t3 WHERE b=1
+} {DELETE main t3 1 1 0 {} 1}
+
+#-------------------------------------------------------------------------
+# Test that the "update" hook is not fired for operations on the
+# sqlite_stat1 table performed by ANALYZE, even if a pre-update hook is
+# registered.
+ifcapable analyze {
+ reset_db
+ do_execsql_test 11.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX idx1 ON t1(a);
+ CREATE INDEX idx2 ON t1(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);
+ }
+
+ db preupdate hook preupdate_cb
+ db update_hook update_cb
+
+ proc preupdate_cb {args} { lappend ::res "preupdate" $args }
+ proc update_cb {args} { lappend ::res "update" $args }
+
+ set ::res [list]
+ do_test 11.2 {
+ execsql ANALYZE
+ set ::res
+ } [list {*}{
+ preupdate {INSERT main sqlite_stat1 1 1}
+ preupdate {INSERT main sqlite_stat1 2 2}
+ }]
+
+ do_execsql_test 11.3 {
+ INSERT INTO t1 VALUES(9, 10);
+ INSERT INTO t1 VALUES(11, 12);
+ INSERT INTO t1 VALUES(13, 14);
+ INSERT INTO t1 VALUES(15, 16);
+ }
+
+ set ::res [list]
+ do_test 11.4 {
+ execsql ANALYZE
+ set ::res
+ } [list {*}{
+ preupdate {DELETE main sqlite_stat1 1 1}
+ preupdate {DELETE main sqlite_stat1 2 2}
+ preupdate {INSERT main sqlite_stat1 1 1}
+ preupdate {INSERT main sqlite_stat1 2 2}
+ }]
+}
+
+#-------------------------------------------------------------------------
+# Test that the pre-update hook is fired for INSERT statements that use
+# the xfer optimization on without rowid tables.
+#
+reset_db
+do_execsql_test 12.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b) WITHOUT ROWID;
+
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t2 VALUES(5, 6);
+ INSERT INTO t2 VALUES(7, 8);
+
+ CREATE TABLE t3 (a INTEGER PRIMARY KEY, b) WITHOUT ROWID;
+}
+
+db preupdate hook preupdate_cb
+db update_hook update_cb
+
+proc preupdate_cb {args} { lappend ::res "preupdate" $args }
+proc update_cb {args} { lappend ::res "update" $args }
+
+set ::res [list]
+do_test 12.2 {
+ execsql VACUUM
+ set ::res
+} {}
+
+do_test 12.3 {
+ set ::res [list]
+ execsql { INSERT INTO t3 SELECT a, b FROM t2 }
+ set ::res
+} {preupdate {INSERT main t3 0 0} preupdate {INSERT main t3 0 0}}
+
+do_test 12.4 {
+ execsql { DELETE FROM t3 }
+ set ::res [list]
+ execsql { INSERT INTO t3 SELECT * FROM t2 }
+ set ::res
+} {preupdate {INSERT main t3 0 0} preupdate {INSERT main t3 0 0}}
+
+do_execsql_test 12.5 {
+ CREATE TABLE t4(a COLLATE nocase PRIMARY KEY, b) WITHOUT ROWID;
+ INSERT INTO t4 VALUES('abc', 1);
+ INSERT INTO t4 VALUES('DEF', 2);
+}
+
+set ::res [list]
+do_test 12.6 {
+ execsql VACUUM
+ set ::res
+} {}
+
+do_catchsql_test 12.6 {
+ INSERT INTO t4 VALUES('def', 3);
+} {1 {UNIQUE constraint failed: t4.a}}
+
+finish_test
diff --git a/test/hook2.test b/test/hook2.test
new file mode 100644
index 0000000..9ae1103
--- /dev/null
+++ b/test/hook2.test
@@ -0,0 +1,218 @@
+# 2017 Jan 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 tests in this file focus on the pre-update hook.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix hook2
+
+ifcapable !preupdate {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+proc do_preupdate_test {tn sql x} {
+ set X [list]
+ foreach elem $x {lappend X $elem}
+ uplevel do_test $tn [list "
+ set ::preupdate \[list\]
+ execsql { $sql }
+ set ::preupdate
+ "] [list $X]
+}
+
+proc preupdate_hook {args} {
+ set type [lindex $args 0]
+ eval lappend ::preupdate $args
+ if {$type != "INSERT"} {
+ for {set i 0} {$i < [db preupdate count]} {incr i} {
+ lappend ::preupdate [db preupdate old $i]
+ }
+ }
+ if {$type != "DELETE"} {
+ for {set i 0} {$i < [db preupdate count]} {incr i} {
+ set rc [catch { db preupdate new $i } v]
+ lappend ::preupdate $v
+ }
+ }
+}
+
+#-------------------------------------------------------------------------
+# Simple tests - INSERT, UPDATE and DELETE on a WITHOUT ROWID table.
+#
+db preupdate hook preupdate_hook
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT ROWID;
+}
+do_preupdate_test 1.1 {
+ INSERT INTO t1 VALUES('one', 1);
+} {
+ INSERT main t1 0 0 one 1
+}
+do_preupdate_test 1.2 {
+ UPDATE t1 SET b=2 WHERE a='one';
+} {
+ UPDATE main t1 0 0 one 1 one 2
+}
+do_preupdate_test 1.3 {
+ DELETE FROM t1 WHERE a='one';
+} {
+ DELETE main t1 0 0 one 2
+}
+
+#-------------------------------------------------------------------------
+# Some more complex tests for the pre-update callback on WITHOUT ROWID
+# tables.
+#
+# 2.1.1 - INSERT statement.
+# 2.1.2 - INSERT INTO ... SELECT statement.
+# 2.1.3 - REPLACE INTO ... (PK conflict)
+# 2.1.4 - REPLACE INTO ... (other index conflicts)
+# 2.1.5 - REPLACE INTO ... (both PK and other index conflicts)
+#
+# 2.2.1 - DELETE statement.
+# 2.2.2 - DELETE statement that uses the truncate optimization.
+#
+# 2.3.1 - UPDATE statement.
+# 2.3.2 - UPDATE statement that modifies the PK.
+# 2.3.3 - UPDATE OR REPLACE ... (PK conflict).
+# 2.3.4 - UPDATE OR REPLACE ... (other index conflicts)
+# 2.3.4 - UPDATE OR REPLACE ... (both PK and other index conflicts)
+#
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a DEFAULT 4, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID;
+ CREATE UNIQUE INDEX t2a ON t2(a);
+}
+
+do_preupdate_test 2.1.1 {
+ INSERT INTO t2(b, c) VALUES(1, 1);
+} {
+ INSERT main t2 0 0 4 1 1
+}
+
+do_execsql_test 2.1.2.0 {
+ CREATE TABLE d1(a DEFAULT 4, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID;
+ CREATE UNIQUE INDEX d1a ON d1(a);
+ INSERT INTO d1 VALUES(1, 2, 3);
+ INSERT INTO d1 VALUES(11, 12, 13);
+}
+do_preupdate_test 2.1.2.1 {
+ INSERT INTO t2 SELECT * FROM d1;
+} {
+ INSERT main t2 0 0 1 2 3
+ INSERT main t2 0 0 11 12 13
+}
+do_preupdate_test 2.1.2.2 {
+ INSERT INTO t2 SELECT a+20, b+20, c+20 FROM d1;
+} {
+ INSERT main t2 0 0 21 22 23
+ INSERT main t2 0 0 31 32 33
+}
+do_execsql_test 2.1.2.3 {
+ SELECT * FROM t2 ORDER BY b, c;
+} {
+ 4 1 1
+ 1 2 3
+ 11 12 13
+ 21 22 23
+ 31 32 33
+}
+do_preupdate_test 2.1.3 {
+ REPLACE INTO t2 VALUES(45, 22, 23);
+} {
+ DELETE main t2 0 0 21 22 23
+ INSERT main t2 0 0 45 22 23
+}
+do_preupdate_test 2.1.4 {
+ REPLACE INTO t2 VALUES(11, 100, 100);
+} {
+ DELETE main t2 0 0 11 12 13
+ INSERT main t2 0 0 11 100 100
+}
+do_preupdate_test 2.1.5 {
+ REPLACE INTO t2(c, b) VALUES(33, 32)
+} {
+ DELETE main t2 0 0 4 1 1
+ DELETE main t2 0 0 31 32 33
+ INSERT main t2 0 0 4 32 33
+}
+
+do_execsql_test 2.2.0 {
+ SELECT * FROM t2 ORDER BY b,c;
+} {
+ 1 2 3
+ 45 22 23
+ 4 32 33
+ 11 100 100
+}
+do_preupdate_test 2.2.1 {
+ DELETE FROM t2 WHERE b=22;
+} {
+ DELETE main t2 0 0 45 22 23
+}
+do_preupdate_test 2.2.2 {
+ DELETE FROM t2;
+} {
+ DELETE main t2 0 0 1 2 3
+ DELETE main t2 0 0 4 32 33
+ DELETE main t2 0 0 11 100 100
+}
+
+do_execsql_test 2.3.0 {
+ CREATE TABLE t3(x, y PRIMARY KEY, z UNIQUE) WITHOUT ROWID;
+ INSERT INTO t3 VALUES('a', 'b', 'c');
+ INSERT INTO t3 VALUES('d', 'e', 'f');
+
+ INSERT INTO t3 VALUES(1, 1, 1);
+ INSERT INTO t3 VALUES(2, 2, 2);
+ INSERT INTO t3 VALUES(3, 3, 3);
+}
+
+do_preupdate_test 2.3.1 {
+ UPDATE t3 SET x=4 WHERE y IN ('b', 'e', 'x');
+} {
+ UPDATE main t3 0 0 a b c 4 b c
+ UPDATE main t3 0 0 d e f 4 e f
+}
+
+do_preupdate_test 2.3.2 {
+ UPDATE t3 SET y=y||y WHERE z IN('c', 'f');
+} {
+ UPDATE main t3 0 0 4 b c 4 bb c
+ UPDATE main t3 0 0 4 e f 4 ee f
+}
+
+do_preupdate_test 2.3.3 {
+ UPDATE OR REPLACE t3 SET y='bb' WHERE z='f'
+} {
+ DELETE main t3 0 0 4 bb c
+ UPDATE main t3 0 0 4 ee f 4 bb f
+}
+
+do_preupdate_test 2.3.4 {
+ UPDATE OR REPLACE t3 SET z=2 WHERE y=1;
+} {
+ DELETE main t3 0 0 2 2 2
+ UPDATE main t3 0 0 1 1 1 1 1 2
+}
+
+do_preupdate_test 2.3.5 {
+ UPDATE OR REPLACE t3 SET z=2, y='bb' WHERE y=3;
+} {
+ DELETE main t3 0 0 1 1 2
+ DELETE main t3 0 0 4 bb f
+ UPDATE main t3 0 0 3 3 3 3 bb 2
+}
+
+
+finish_test
diff --git a/test/icu.test b/test/icu.test
new file mode 100644
index 0000000..644cbb1
--- /dev/null
+++ b/test/icu.test
@@ -0,0 +1,167 @@
+# 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&&!icu_collations {
+ 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
+}
+
+ifcapable icu {
+
+ # 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"
+
+ do_execsql_test icu-2.9 {
+ SELECT upper(char(0xfb04,0xfb04,0xfb04,0xfb04));
+ } {FFLFFLFFLFFL}
+
+ # 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
+#
+ifcapable icu {
+ 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.5 {SELECT 'abc' REGEXP } {1 {incomplete input}}
+ do_catchsql_test icu-5.6 {SELECT 'abc' REGEXP, 1} {1 {near ",": syntax error}}
+
+ do_malloc_test icu-6.10 -sqlbody {
+ SELECT upper(char(0xfb04,0xdf,0xfb04,0xe8,0xfb04));
+ }
+}
+
+# 2020-03-19
+# The ESCAPE clause on LIKE takes precedence over wildcards
+#
+do_execsql_test idu-6.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, x TEXT);
+ INSERT INTO t1 VALUES
+ (1,'abcde'),
+ (2,'abc_'),
+ (3,'abc__'),
+ (4,'abc%'),
+ (5,'abc%%');
+ SELECT id FROM t1 WHERE x LIKE 'abc%%' ESCAPE '%';
+} {4}
+do_execsql_test icu-6.1 {
+ SELECT id FROM t1 WHERE x LIKE 'abc__' ESCAPE '_';
+} {2}
+
+finish_test
diff --git a/test/ieee754.test b/test/ieee754.test
new file mode 100644
index 0000000..bd806d2
--- /dev/null
+++ b/test/ieee754.test
@@ -0,0 +1,60 @@
+# 2015-11-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.
+#
+#***********************************************************************
+#
+# Tests of the iee754 extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+load_static_extension db ieee754
+
+foreach {id float rep} {
+ 1 1.0 1,0
+ 2 2.0 2,0
+ 3 0.5 1,-1
+ 4 1.5 3,-1
+ 5 0.0 0,-1075
+ 6 4.9406564584124654e-324 1,-1074
+ 7 2.2250738585072009e-308 4503599627370495,-1074
+ 8 2.2250738585072014e-308 1,-1022
+} {
+ do_test ieee754-100-$id-1 {
+ db eval "SELECT ieee754($float);"
+ } "ieee754($rep)"
+ do_test ieee754-100-$id-2 {
+ db eval "SELECT ieee754($rep)==$float;"
+ } {1}
+ if {$float!=0.0} {
+ do_test ieee754-100-$id-3 {
+ db eval "SELECT ieee754(-$float);"
+ } "ieee754(-$rep)"
+ do_test ieee754-100-$id-4 {
+ db eval "SELECT ieee754(-$rep)==-$float;"
+ } {1}
+ }
+}
+
+do_test ieee754-110 {
+ string tolower [
+ db eval {SELECT ieee754(1,1024), ieee754(4503599627370495,972);}
+ ]
+} {inf 1.79769313486232e+308}
+do_test ieee754-111 {
+ string tolower [
+ db eval {SELECT ieee754(-1,1024), ieee754(-4503599627370495,972);}
+ ]
+} {-inf -1.79769313486232e+308}
+do_execsql_test ieee754-112 {
+ SELECT ieee754(4503599627370495,973) is null;
+} {1}
+
+finish_test
diff --git a/test/imposter1.test b/test/imposter1.test
new file mode 100644
index 0000000..196767b
--- /dev/null
+++ b/test/imposter1.test
@@ -0,0 +1,141 @@
+# 2015-01-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 for SQLite library.
+#
+# The focus of this file is adding extra entries in the symbol table
+# using sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER) and verifying that
+# SQLite handles those as expected.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix imposter
+
+# Create a bunch of data to sort against
+#
+do_test imposter-1.0 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d NOT NULL);
+ CREATE INDEX t1b ON t1(b);
+ CREATE UNIQUE INDEX t1c ON t1(c);
+ WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)
+ INSERT INTO t1(a,b,c,d) SELECT i,1000+i,2000+i,3000+i FROM c;
+ }
+ set t1_root [db one {SELECT rootpage FROM sqlite_master WHERE name='t1'}]
+ set t1b_root [db one {SELECT rootpage FROM sqlite_master WHERE name='t1b'}]
+ set t1c_root [db one {SELECT rootpage FROM sqlite_master WHERE name='t1c'}]
+
+ # Create an imposter table that uses the same b-tree as t1 but which does
+ # not have the indexes
+ #
+ sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 1 $t1_root
+ db eval {CREATE TABLE xt1(a,b,c,d)}
+
+ # And create an imposter table for the t1c index.
+ sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 1 $t1c_root
+ db eval {CREATE TABLE xt1c(c,rowid,PRIMARY KEY(c,rowid))WITHOUT ROWID;}
+
+ # Go out of imposter mode for now.
+ sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 0 0
+
+ # Create triggers to record changes to xt1.
+ #
+ db eval {
+ CREATE TEMP TABLE chnglog(desc TEXT);
+ CREATE TEMP TRIGGER xt1_del AFTER DELETE ON xt1 BEGIN
+ INSERT INTO chnglog VALUES(
+ printf('DELETE t1: rowid=%d, a=%s, b=%s, c=%s, d=%s',
+ old.rowid, quote(old.a), quote(old.b), quote(old.c),
+ quote(old.d)));
+ END;
+ CREATE TEMP TRIGGER xt1_ins AFTER INSERT ON xt1 BEGIN
+ INSERT INTO chnglog VALUES(
+ printf('INSERT t1: rowid=%d, a=%s, b=%s, c=%s, d=%s',
+ new.rowid, quote(new.a), quote(new.b), quote(new.c),
+ quote(new.d)));
+ END;
+ }
+} {}
+
+# The xt1 table has separate xt1.rowid and xt1.a columns. The xt1.rowid
+# column corresponds to t1.rowid and t1.a, but the xt1.a column is always
+# NULL
+#
+do_execsql_test imposter-1.1 {
+ SELECT rowid FROM xt1 WHERE a IS NOT NULL;
+} {}
+do_execsql_test imposter-1.2 {
+ SELECT a,b,c,d FROM t1 EXCEPT SELECT rowid,b,c,d FROM xt1;
+ SELECT rowid,b,c,d FROM xt1 EXCEPT SELECT a,b,c,d FROM t1;
+} {}
+
+
+# Make changes via the xt1 shadow table. This will not update the
+# indexes on t1 nor check the uniqueness constraint on t1.c nor check
+# the NOT NULL constraint on t1.d, resulting in a logically inconsistent
+# database.
+#
+do_execsql_test imposter-1.3 {
+ DELETE FROM xt1 WHERE rowid=5;
+ INSERT INTO xt1(rowid,a,b,c,d) VALUES(99,'hello',1099,2022,NULL);
+ SELECT * FROM chnglog ORDER BY rowid;
+} [list \
+ {DELETE t1: rowid=5, a=NULL, b=1005, c=2005, d=3005} \
+ {INSERT t1: rowid=99, a='hello', b=1099, c=2022, d=NULL} \
+]
+
+do_execsql_test imposter-1.4a {
+ PRAGMA integrity_check;
+} {/NULL value in t1.d/}
+do_execsql_test imposter-1.4b {
+ PRAGMA integrity_check;
+} {/row # missing from index t1b/}
+do_execsql_test imposter-1.4c {
+ PRAGMA integrity_check;
+} {/row # missing from index t1c/}
+
+# Cleanup the corruption.
+# Then demonstrate that the xt1c imposter table can insert non-unique
+# and NULL values into the UNIQUE index.
+#
+do_execsql_test imposter-2.0 {
+ DELETE FROM t1;
+ WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)
+ INSERT INTO t1(a,b,c,d) SELECT i,i,i,i FROM c;
+ UPDATE xt1c SET c=NULL WHERE rowid=5;
+ PRAGMA integrity_check;
+} {/row # missing from index t1c/}
+
+do_execsql_test imposter-2.1 {
+ DELETE FROM t1;
+ WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)
+ INSERT INTO t1(a,b,c,d) SELECT i,i,i,i FROM c;
+ UPDATE xt1c SET c=99 WHERE rowid IN (5,7,9);
+ SELECT c FROM t1 ORDER BY c;
+} {1 2 3 4 6 8 10 99 99 99}
+do_execsql_test imposter-2.2 {
+ UPDATE xt1 SET c=99 WHERE rowid IN (5,7,9);
+ PRAGMA integrity_check;
+} {/non-unique entry in index t1c/}
+
+# Erase the imposter tables
+#
+do_test imposter-3.1 {
+ sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 0 1
+ db eval {
+ DELETE FROM t1 WHERE rowid IN (5,7,9);
+ PRAGMA integrity_check;
+ }
+} {ok}
+
+
+finish_test
diff --git a/test/in.test b/test/in.test
new file mode 100644
index 0000000..7c4cc51
--- /dev/null
+++ b/test/in.test
@@ -0,0 +1,810 @@
+# 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.1 {
+ execsql {
+ SELECT a FROM ta WHERE a IN ();
+ }
+} {}
+do_test in-7.6.2 {
+ db status step
+} {0}
+do_test in-7.7 {
+ execsql {
+ SELECT a FROM ta WHERE a NOT IN ();
+ }
+} {1 2 3 4 6 8 10}
+
+do_test in-7.8.1 {
+ execsql {
+ SELECT * FROM ta LEFT JOIN tb ON (ta.b=tb.b) WHERE ta.a IN ();
+ }
+} {}
+do_test in-7.8.2 {
+ db status step
+} {0}
+
+do_test in-8.3 {
+ execsql {
+ SELECT b FROM t1 WHERE a IN ('hello','there')
+ }
+} {world}
+do_test in-8.4 {
+ sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+ 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 {sub-select returns 2 columns - expected 1}}
+
+# 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 {CHECK constraint failed: a IN (111,222,333)}}
+
+# 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 {sub-select returns 2 columns - expected 1}}
+do_test in-12.3 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 UNION SELECT a, b FROM t2
+ );
+ }
+} {1 {sub-select returns 2 columns - expected 1}}
+do_test in-12.4 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 EXCEPT SELECT a, b FROM t2
+ );
+ }
+} {1 {sub-select returns 2 columns - expected 1}}
+do_test in-12.5 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 INTERSECT SELECT a, b FROM t2
+ );
+ }
+} {1 {sub-select returns 2 columns - expected 1}}
+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}}
+}
+
+ifcapable compound {
+do_test in-12.10 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a FROM t3 UNION ALL SELECT a, b 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.11 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a FROM t3 UNION SELECT a, b FROM t2
+ );
+ }
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+do_test in-12.12 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a FROM t3 EXCEPT SELECT a, b FROM t2
+ );
+ }
+} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}
+do_test in-12.13 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a FROM t3 INTERSECT SELECT a, b FROM t2
+ );
+ }
+} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}
+do_test in-12.14 {
+ catchsql {
+ SELECT * FROM t2 WHERE a IN (
+ SELECT a, b FROM t3 UNION ALL SELECT a, b FROM t2
+ );
+ }
+} {1 {sub-select returns 2 columns - expected 1}}
+do_test in-12.15 {
+ 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}}
+}; #ifcapable compound
+
+
+#------------------------------------------------------------------------
+# 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.15 {
+ catchsql {
+ SELECT 0 WHERE (SELECT 0,0) OR (0 IN (1,2));
+ }
+} {1 {sub-select returns 2 columns - expected 1}}
+
+
+do_test in-13.X {
+ db nullvalue ""
+} {}
+
+# At one point the following was causing valgrind to report a "jump
+# depends on unitialized location" problem.
+#
+do_execsql_test in-14.0 {
+ CREATE TABLE c1(a);
+ INSERT INTO c1 VALUES(1), (2), (4), (3);
+}
+do_execsql_test in-14.1 {
+ SELECT * FROM c1 WHERE a IN (SELECT a FROM c1) ORDER BY 1
+} {1 2 3 4}
+
+# 2019-02-20 Ticket https://www.sqlite.org/src/tktview/df46dfb631f75694fbb97033b69
+#
+do_execsql_test in-15.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE IF NOT EXISTS t1(id INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(1);
+ SELECT a.id FROM t1 AS a JOIN t1 AS b ON a.id=b.id WHERE a.id IN (1,2,3);
+} {1}
+do_execsql_test in-15.1 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER PRIMARY KEY,b);
+ INSERT INTO t2 VALUES(1,11);
+ INSERT INTO t2 VALUES(2,22);
+ INSERT INTO t2 VALUES(3,33);
+ SELECT b, a IN (3,4,5) FROM t2 ORDER BY b;
+} {11 0 22 0 33 1}
+do_execsql_test in-15.2 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(x INTEGER PRIMARY KEY);
+ INSERT INTO t3 VALUES(8);
+ SELECT CASE WHEN x NOT IN (5,6,7) THEN 'yes' ELSE 'no' END FROM t3;
+ SELECT CASE WHEN x NOT IN (NULL,6,7) THEN 'yes' ELSE 'no' END FROM t3;
+} {yes no}
+do_execsql_test in-15.3 {
+ SELECT CASE WHEN x NOT IN (5,6,7) OR x=0 THEN 'yes' ELSE 'no' END FROM t3;
+ SELECT CASE WHEN x NOT IN (NULL,6,7) OR x=0 THEN 'yes' ELSE 'no' END FROM t3;
+} {yes no}
+do_execsql_test in-15.4 {
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(a INTEGER PRIMARY KEY, b INT);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)
+ INSERT INTO t4(a,b) SELECT x, x+100 FROM c;
+ SELECT b FROM t4 WHERE a IN (3,null,8) ORDER BY +b;
+} {103 108}
+do_execsql_test in-15.5 {
+ SELECT b FROM t4 WHERE a NOT IN (3,null,8);
+} {}
+do_execsql_test in-15.6 {
+ DROP TABLE IF EXISTS t5;
+ DROP TABLE IF EXISTS t6;
+ CREATE TABLE t5(id INTEGER PRIMARY KEY, name TEXT);
+ CREATE TABLE t6(id INTEGER PRIMARY KEY, name TEXT, t5_id INT);
+ INSERT INTO t5 VALUES(1,'Alice'),(2,'Emma');
+ INSERT INTO t6 VALUES(1,'Bob',1),(2,'Cindy',1),(3,'Dave',2);
+ SELECT a.*
+ FROM t5 AS 'a' JOIN t5 AS 'b' ON b.id=a.id
+ WHERE b.id IN (
+ SELECT t6.t5_id
+ FROM t6
+ WHERE name='Bob'
+ AND t6.t5_id IS NOT NULL
+ AND t6.id IN (
+ SELECT id
+ FROM (SELECT t6.id, count(*) AS x
+ FROM t6
+ WHERE name='Bob'
+ ) AS 't'
+ WHERE x=1
+ )
+ AND t6.id IN (1,id)
+ );
+} {1 Alice}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test in-16.0 {
+ CREATE TABLE x1(a, b);
+ INSERT INTO x1(a) VALUES(1), (2), (3), (4), (5), (6);
+ CREATE INDEX x1i ON x1(a, b);
+}
+
+do_execsql_test in-16.1 {
+ SELECT * FROM x1
+ WHERE a IN (SELECT a FROM x1 WHERE (a%2)==0)
+ ORDER BY a DESC, b;
+} {6 {} 4 {} 2 {}}
+
+do_execsql_test in-16.2 {
+ SELECT * FROM x1
+ WHERE a IN (SELECT a FROM x1 WHERE (a%7)==0)
+ ORDER BY a DESC, b;
+} {}
+
+# 2019-06-11
+# https://www.sqlite.org/src/info/57353f8243c637c0
+#
+do_execsql_test in-17.1 {
+ SELECT 1 IN ('1');
+} 0
+do_execsql_test in-17.2 {
+ SELECT 1 IN ('1' COLLATE nocase);
+} 0
+do_execsql_test in-17.3 {
+ SELECT 1 IN (CAST('1' AS text));
+} 0
+do_execsql_test in-17.4 {
+ SELECT 1 IN (CAST('1' AS text) COLLATE nocase);
+} 0
+
+# 2019-08-27 ticket https://sqlite.org/src/info/dbaf8a6820be1ece
+#
+do_execsql_test in-18.1 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 INT UNIQUE);
+ INSERT INTO t0(c0) VALUES (1);
+ SELECT * FROM t0 WHERE '1' IN (t0.c0);
+} {}
+
+# 2019-09-02 ticket https://www.sqlite.org/src/info/2841e99d104c6436
+# For the IN_INDEX_NOOP optimization, apply REAL affinity to the LHS
+# values prior to comparison if the RHS has REAL affinity.
+#
+# Also ticket https://sqlite.org/src/info/29f635e0af71234b
+#
+do_execsql_test in-19.10 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 REAL UNIQUE);
+ INSERT INTO t0(c0) VALUES(2.0625E00);
+ SELECT 1 FROM t0 WHERE c0 IN ('2.0625');
+} {1}
+do_execsql_test in-19.20 {
+ SELECT c0 IN ('2.0625') FROM t0;
+} {1}
+do_execsql_test in-19.21 {
+ SELECT c0 = ('2.0625') FROM t0;
+} {1}
+do_execsql_test in-19.22 {
+ SELECT c0 = ('0.20625e+01') FROM t0;
+} {1}
+do_execsql_test in-19.30 {
+ SELECT c0 IN ('2.0625',2,3) FROM t0;
+} {1}
+do_execsql_test in-19.40 {
+ DROP TABLE t0;
+ CREATE TABLE t0(c0 TEXT, c1 REAL, c2, PRIMARY KEY(c2, c0, c1));
+ CREATE INDEX i0 ON t0(c1 IN (c0));
+ INSERT INTO t0(c0, c2) VALUES (0, NULL) ON CONFLICT(c2, c1, c0) DO NOTHING;
+ PRAGMA integrity_check;
+} {ok}
+
+# Ticket f3ff1472887
+#
+do_execsql_test in-20.1 {
+ SELECT (1 IN (2 IS TRUE));
+} {1}
+
+# Forum post: https://sqlite.org/forum/forumpost/5782619992.
+#
+reset_db
+do_execsql_test in-21.1 {
+ CREATE TABLE t0(c0);
+ SELECT COUNT(*) FROM t0 ORDER BY (t0.c0 IN ());
+} {0}
+
+
+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..a3fe22e
--- /dev/null
+++ b/test/in4.test
@@ -0,0 +1,520 @@
+# 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
+set testprefix in4
+
+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 ()}
+} {}
+
+# Tests for "... IN (?)" and "... NOT IN (?)". In other words, tests
+# for when the RHS of IN is a single expression. This should work the
+# same as the == and <> operators.
+#
+do_execsql_test in4-3.21 {
+ SELECT * FROM t3 WHERE x=10 AND y IN (10);
+} {10 10 10}
+do_execsql_test in4-3.22 {
+ SELECT * FROM t3 WHERE x IN (10) AND y=10;
+} {10 10 10}
+do_execsql_test in4-3.23 {
+ SELECT * FROM t3 WHERE x IN (10) AND y IN (10);
+} {10 10 10}
+do_execsql_test in4-3.24 {
+ SELECT * FROM t3 WHERE x=1 AND y NOT IN (10);
+} {1 1 1}
+do_execsql_test in4-3.25 {
+ SELECT * FROM t3 WHERE x NOT IN (10) AND y=1;
+} {1 1 1}
+do_execsql_test in4-3.26 {
+ SELECT * FROM t3 WHERE x NOT IN (10) AND y NOT IN (10);
+} {1 1 1}
+
+# The query planner recognizes that "x IN (?)" only generates a
+# single match and can use this information to optimize-out ORDER BY
+# clauses.
+#
+do_execsql_test in4-3.31 {
+ DROP INDEX t3i1;
+ CREATE UNIQUE INDEX t3xy ON t3(x,y);
+
+ SELECT *, '|' FROM t3 A, t3 B
+ WHERE A.x=10 AND A.y IN (10)
+ AND B.x=1 AND B.y IN (1);
+} {10 10 10 1 1 1 |}
+do_execsql_test in4-3.32 {
+ EXPLAIN QUERY PLAN
+ SELECT *, '|' FROM t3 A, t3 B
+ WHERE A.x=10 AND A.y IN (10)
+ AND B.x=1 AND B.y IN (1);
+} {~/B-TREE/} ;# No separate sorting pass
+do_execsql_test in4-3.33 {
+ SELECT *, '|' FROM t3 A, t3 B
+ WHERE A.x IN (10) AND A.y=10
+ AND B.x IN (1) AND B.y=1;
+} {10 10 10 1 1 1 |}
+do_execsql_test in4-3.34 {
+ EXPLAIN QUERY PLAN
+ SELECT *, '|' FROM t3 A, t3 B
+ WHERE A.x IN (10) AND A.y=10
+ AND B.x IN (1) AND B.y=1;
+} {~/B-TREE/} ;# No separate sorting pass
+
+# An expression of the form "x IN (?,?)" creates an ephemeral table to
+# hold the list of values on the RHS. But "x IN (?)" does not create
+# an ephemeral table.
+#
+do_execsql_test in4-3.41 {
+ SELECT * FROM t3 WHERE x IN (10,11);
+} {10 10 10}
+do_execsql_test in4-3.42 {
+ EXPLAIN
+ SELECT * FROM t3 WHERE x IN (10,11);
+} {/OpenEphemeral/}
+do_execsql_test in4-3.43 {
+ SELECT * FROM t3 WHERE x IN (10);
+} {10 10 10}
+
+# This test would verify that the "X IN (Y)" -> "X==Y" optimization
+# was working. But we have now taken that optimization out.
+#do_execsql_test in4-3.44 {
+# EXPLAIN
+# SELECT * FROM t3 WHERE x IN (10);
+#} {~/OpenEphemeral/}
+do_execsql_test in4-3.45 {
+ SELECT * FROM t3 WHERE x NOT IN (10,11,99999);
+} {1 1 1}
+do_execsql_test in4-3.46 {
+ EXPLAIN
+ SELECT * FROM t3 WHERE x NOT IN (10,11,99999);
+} {/OpenEphemeral/}
+do_execsql_test in4-3.47 {
+ SELECT * FROM t3 WHERE x NOT IN (10);
+} {1 1 1}
+do_execsql_test in4-3.48 {
+ EXPLAIN
+ SELECT * FROM t3 WHERE x NOT IN (10);
+} {~/OpenEphemeral/}
+
+# Make sure that when "x IN (?)" is converted into "x==?" that collating
+# sequence and affinity computations do not get messed up.
+#
+do_execsql_test in4-4.1 {
+ CREATE TABLE t4a(a TEXT, b TEXT COLLATE nocase, c);
+ INSERT INTO t4a VALUES('ABC','abc',1);
+ INSERT INTO t4a VALUES('def','xyz',2);
+ INSERT INTO t4a VALUES('ghi','ghi',3);
+ SELECT c FROM t4a WHERE a=b ORDER BY c;
+} {3}
+do_execsql_test in4-4.2 {
+ SELECT c FROM t4a WHERE b=a ORDER BY c;
+} {1 3}
+do_execsql_test in4-4.3 {
+ SELECT c FROM t4a WHERE (a||'')=b ORDER BY c;
+} {1 3}
+do_execsql_test in4-4.4 {
+ SELECT c FROM t4a WHERE (a||'')=(b||'') ORDER BY c;
+} {3}
+do_execsql_test in4-4.5 {
+ SELECT c FROM t4a WHERE a IN (b) ORDER BY c;
+} {3}
+do_execsql_test in4-4.6 {
+ SELECT c FROM t4a WHERE (a||'') IN (b) ORDER BY c;
+} {3}
+
+
+do_execsql_test in4-4.11 {
+ CREATE TABLE t4b(a TEXT, b NUMERIC, c);
+ INSERT INTO t4b VALUES('1.0',1,4);
+ SELECT c FROM t4b WHERE a=b;
+} {4}
+do_execsql_test in4-4.12 {
+ SELECT c FROM t4b WHERE b=a;
+} {4}
+do_execsql_test in4-4.13 {
+ SELECT c FROM t4b WHERE +a=b;
+} {4}
+do_execsql_test in4-4.14 {
+ SELECT c FROM t4b WHERE a=+b;
+} {}
+do_execsql_test in4-4.15 {
+ SELECT c FROM t4b WHERE +b=a;
+} {}
+do_execsql_test in4-4.16 {
+ SELECT c FROM t4b WHERE b=+a;
+} {4}
+do_execsql_test in4-4.17 {
+ SELECT c FROM t4b WHERE a IN (b);
+} {}
+do_execsql_test in4-4.18 {
+ SELECT c FROM t4b WHERE b IN (a);
+} {4}
+do_execsql_test in4-4.19 {
+ SELECT c FROM t4b WHERE +b IN (a);
+} {}
+
+do_execsql_test in4-5.1 {
+ CREATE TABLE t5(c INTEGER PRIMARY KEY, d TEXT COLLATE nocase);
+ INSERT INTO t5 VALUES(17, 'fuzz');
+ SELECT 1 FROM t5 WHERE 'fuzz' IN (d); -- match
+ SELECT 2 FROM t5 WHERE 'FUZZ' IN (d); -- no match
+ SELECT 3 FROM t5 WHERE d IN ('fuzz'); -- match
+ SELECT 4 FROM t5 WHERE d IN ('FUZZ'); -- match
+} {1 3 4}
+
+# An expression of the form "x IN (y)" can be used as "x=y" by the
+# query planner when computing transitive constraints or to run the
+# query using an index on y.
+#
+do_execsql_test in4-6.1 {
+ CREATE TABLE t6a(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t6a VALUES(1,2),(3,4),(5,6);
+ CREATE TABLE t6b(c INTEGER PRIMARY KEY, d);
+ INSERT INTO t6b VALUES(4,44),(5,55),(6,66);
+
+ SELECT * FROM t6a, t6b WHERE a=3 AND b IN (c);
+} {3 4 4 44}
+do_execsql_test in4-6.1-eqp {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t6a, t6b WHERE a=3 AND b IN (c);
+} {~/SCAN t6a/}
+do_execsql_test in4-6.2 {
+ SELECT * FROM t6a, t6b WHERE a=3 AND c IN (b);
+} {3 4 4 44}
+do_execsql_test in4-6.2-eqp {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t6a, t6b WHERE a=3 AND c IN (b);
+} {~/SCAN/}
+
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e);
+ CREATE INDEX t1bc ON t1(c, b);
+ INSERT INTO t2(e) VALUES(1);
+ INSERT INTO t1 VALUES(NULL, NULL, NULL);
+}
+
+do_execsql_test 7.1 {
+ SELECT * FROM t2 LEFT JOIN t1 ON c = d AND b IN (10,10,10);
+} {{} 1 {} {} {}}
+
+ifcapable rtree {
+ reset_db
+ do_execsql_test 7.2 {
+ CREATE VIRTUAL TABLE t1 USING rtree(a, b, c);
+ CREATE TABLE t2(d INTEGER, e INT);
+ INSERT INTO t2(e) VALUES(1);
+ }
+
+ do_execsql_test 7.3 {
+ SELECT * FROM t2 LEFT JOIN t1 ON c IN (d) AND b IN (10,10,10);
+ } {{} 1 {} {} {}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ CREATE UNIQUE INDEX t1y ON t1(y);
+ INSERT INTO t1 VALUES(111, 'AAA'),(222, 'BBB'),(333, 'CCC');
+ CREATE TABLE t2(z);
+ INSERT INTO t2 VALUES('BBB'),('AAA');
+ ANALYZE sqlite_schema;
+ INSERT INTO sqlite_stat1 VALUES('t1', 't1y','100 1');
+}
+
+db close
+sqlite3 db test.db
+
+do_execsql_test 8.1 {
+ SELECT t1.x FROM t2 CROSS JOIN t1 WHERE t2.z = t1.y;
+} {222 111}
+
+do_execsql_test 8.2 {
+ SELECT t1.x FROM t2 CROSS JOIN t1 WHERE t2.z = t1.y AND +t1.x IN (111, 222);
+} {222 111}
+
+do_execsql_test 8.3 {
+ SELECT t1.x FROM t2 CROSS JOIN t1 WHERE t2.z = t1.y AND t1.x IN (111, 222);
+} {222 111}
+
+# 2021-06-02 forum post https://sqlite.org/forum/forumpost/b4fcb8a598
+# OP_SeekScan changes from check-in 4a43430fd23f8835 on 2020-09-30 causes
+# performance regression.
+#
+reset_db
+do_execsql_test 9.0 {
+ CREATE TABLE node(node_id INTEGER PRIMARY KEY);
+ CREATE TABLE edge(node_from INT, node_to INT);
+ CREATE TABLE sub_nodes(node_id INTEGER PRIMARY KEY);
+ CREATE INDEX edge_from_to ON edge(node_from,node_to);
+ CREATE INDEX edge_to_from ON edge(node_to,node_from);
+ ANALYZE;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1 VALUES
+ ('sub_nodes',NULL,'1000000'),
+ ('edge','edge_to_from','20000000 2 2'),
+ ('edge','edge_from_to','20000000 2 2'),
+ ('node',NULL,'10000000');
+ ANALYZE sqlite_schema;
+} {}
+do_eqp_test 9.1 {
+SELECT count(*) FROM edge
+ WHERE node_from IN sub_nodes AND node_to IN sub_nodes;
+} {
+ QUERY PLAN
+ |--SEARCH edge USING COVERING INDEX edge_to_from (node_to=?)
+ |--USING ROWID SEARCH ON TABLE sub_nodes FOR IN-OPERATOR
+ `--USING ROWID SEARCH ON TABLE sub_nodes FOR IN-OPERATOR
+}
+# ^^^^^ the key to the above is that the index should only use a single
+# term (node_to=?), not two terms (node_to=? AND node_from=).
+
+# dbsqlfuzz case
+#
+reset_db
+do_execsql_test 10.0 {
+ CREATE TABLE t1(a,b,c,d,PRIMARY KEY(a,b,c)) WITHOUT ROWID;
+ INSERT INTO t1(a,b,c,d) VALUES
+ (0,-2,2,3),
+ (0,2,3,4),
+ (0,5,8,10),
+ (1,7,11,13);
+ ANALYZE sqlite_schema;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1','10 3 2 1');
+ ANALYZE sqlite_schema;
+ PRAGMA reverse_unordered_selects(1);
+ SELECT d FROM t1 WHERE 0=a AND b IN (-17,-4,-3,1,5,25,7798);
+} {10}
+
+# 2021-06-13 dbsqlfuzz e41762333a4d6e90a49e628f488d0873b2dba4c5
+# The opcode that preceeds OP_SeekScan is usually OP_IdxGT, but can
+# sometimes be OP_IdxGE
+#
+reset_db
+do_execsql_test 11.0 {
+ CREATE TABLE t1(a TEXT, b INT, c INT, d INT);
+ INSERT INTO t1 VALUES('abc',123,4,5);
+ INSERT INTO t1 VALUES('xyz',1,'abcdefxyz',99);
+ CREATE INDEX t1abc ON t1(b,b,c);
+ ANALYZE sqlite_schema;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1abc','10000 5 00 2003 10');
+ ANALYZE sqlite_schema;
+} {}
+do_execsql_test 11.1 {
+ SELECT * FROM t1
+ WHERE b IN (345, (SELECT 1 FROM t1
+ WHERE b IN (345 NOT GLOB 510)
+ AND c GLOB 'abc*xyz'))
+ AND c BETWEEN 'abc' AND 'xyz';
+} {xyz 1 abcdefxyz 99}
+do_execsql_test 11.2 {
+ EXPLAIN SELECT * FROM t1
+ WHERE b IN (345, (SELECT 1 FROM t1
+ WHERE b IN (345 NOT GLOB 510)
+ AND c GLOB 'abc*xyz'))
+ AND c BETWEEN 'abc' AND 'xyz';
+} {/ SeekScan /}
+
+# 2021-06-25 ticket 6dcbfd11cf666e21
+# Another problem with OP_SeekScan
+#
+reset_db
+do_execsql_test 12.0 {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1abc ON t1(a,b,c);
+ CREATE INDEX t1bca on t1(b,c,a);
+ INSERT INTO t1 VALUES(56,1119,1115);
+ INSERT INTO t1 VALUES(57,1147,1137);
+ INSERT INTO t1 VALUES(100,1050,1023);
+ INSERT INTO t1 VALUES(101,1050,1023);
+ ANALYZE sqlite_schema;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1abc','358677 2 2 1');
+ INSERT INTO sqlite_stat1 VALUES('t1','t1bca','358677 4 2 1');
+ ANALYZE sqlite_schema;
+ SELECT * FROM t1 NOT INDEXED
+ WHERE (b = 1137 AND c IN (97, 98))
+ OR (b = 1119 AND c IN (1115, 1023));
+} {56 1119 1115}
+do_execsql_test 12.1 {
+ SELECT * FROM t1
+ WHERE (b = 1137 AND c IN (97, 98))
+ OR (b = 1119 AND c IN (1115, 1023));
+} {56 1119 1115}
+
+# 2021-11-02 ticket 5981a8c041a3c2f3
+# Another OP_SeekScan problem.
+#
+reset_db
+do_execsql_test 13.0 {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, a INT, b INT, c INT);
+ INSERT INTO t1 VALUES(10,1,2,5);
+ INSERT INTO t1 VALUES(20,1,3,5);
+ INSERT INTO t1 VALUES(30,1,2,4);
+ INSERT INTO t1 VALUES(40,1,3,4);
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1x','84000 3 2 1');
+ CREATE INDEX t1x ON t1(a,b,c);
+ PRAGMA writable_schema=RESET;
+ SELECT * FROM t1
+ WHERE a=1
+ AND b IN (2,3)
+ AND c BETWEEN 4 AND 5
+ ORDER BY +id;
+} {10 1 2 5 20 1 3 5 30 1 2 4 40 1 3 4}
+
+finish_test
diff --git a/test/in5.test b/test/in5.test
new file mode 100644
index 0000000..6680641
--- /dev/null
+++ b/test/in5.test
@@ -0,0 +1,269 @@
+# 2012 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix in5
+
+do_test in5-1.1 {
+ execsql {
+ CREATE TABLE t1x(x INTEGER PRIMARY KEY);
+ INSERT INTO t1x VALUES(1),(3),(5),(7),(9);
+ CREATE TABLE t1y(y INTEGER UNIQUE);
+ INSERT INTO t1y VALUES(2),(4),(6),(8);
+ CREATE TABLE t1z(z TEXT UNIQUE);
+ INSERT INTO t1z VALUES('a'),('c'),('e'),('g');
+ CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT, d TEXT);
+ INSERT INTO t2 VALUES(1,2,'a','12a'),(1,2,'b','12b'),
+ (2,3,'g','23g'),(3,5,'c','35c'),
+ (4,6,'h','46h'),(5,6,'e','56e');
+ CREATE TABLE t3x AS SELECT x FROM t1x;
+ CREATE TABLE t3y AS SELECT y FROM t1y;
+ CREATE TABLE t3z AS SELECT z FROM t1z;
+ SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY c;
+ }
+} {12a 56e}
+do_test in5-1.2 {
+ execsql {
+ SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;
+ }
+} {23g}
+do_test in5-1.3 {
+ execsql {
+ SELECT d FROM t2 WHERE a IN t3x AND b IN t3y AND c IN t3z ORDER BY d;
+ }
+} {12a 56e}
+
+
+do_test in5-2.1 {
+ execsql {
+ CREATE INDEX t2abc ON t2(a,b,c);
+ SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY d;
+ }
+} {12a 56e}
+do_test in5-2.2 {
+ execsql {
+ SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;
+ }
+} {23g}
+do_test in5-2.3 {
+ regexp {OpenEphemeral} [db eval {
+ EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z
+ }]
+} {0}
+do_test in5-2.4 {
+ execsql {
+ SELECT d FROM t2 WHERE a IN t3x AND b IN t3y AND c IN t3z ORDER BY d;
+ }
+} {12a 56e}
+do_test in5-2.5.1 {
+ regexp {OpenEphemeral} [db eval {
+ EXPLAIN SELECT d FROM t2 WHERE a IN t3x AND b IN t1y AND c IN t1z
+ }]
+} {1}
+do_test in5-2.5.2 {
+ regexp {OpenEphemeral} [db eval {
+ EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t3y AND c IN t1z
+ }]
+} {1}
+do_test in5-2.5.3 {
+ regexp {OpenEphemeral} [db eval {
+ EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t3z
+ }]
+} {1}
+
+do_test in5-3.1 {
+ execsql {
+ DROP INDEX t2abc;
+ CREATE INDEX t2ab ON t2(a,b);
+ SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY d;
+ }
+} {12a 56e}
+do_test in5-3.2 {
+ execsql {
+ SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;
+ }
+} {23g}
+do_test in5-3.3 {
+ regexp {OpenEphemeral} [db eval {
+ EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z
+ }]
+} {0}
+
+do_test in5-4.1 {
+ execsql {
+ DROP INDEX t2ab;
+ CREATE INDEX t2abcd ON t2(a,b,c,d);
+ SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY d;
+ }
+} {12a 56e}
+do_test in5-4.2 {
+ execsql {
+ SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;
+ }
+} {23g}
+do_test in5-4.3 {
+ regexp {OpenEphemeral} [db eval {
+ EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z
+ }]
+} {0}
+
+
+do_test in5-5.1 {
+ execsql {
+ DROP INDEX t2abcd;
+ CREATE INDEX t2cbad ON t2(c,b,a,d);
+ SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY d;
+ }
+} {12a 56e}
+do_test in5-5.2 {
+ execsql {
+ SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;
+ }
+} {23g}
+do_test in5-5.3 {
+ regexp {OpenEphemeral} [db eval {
+ EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z
+ }]
+} {0}
+
+#-------------------------------------------------------------------------
+# At one point SQLite was removing the DISTINCT keyword from expressions
+# similar to:
+#
+# <expr1> IN (SELECT DISTINCT <expr2> FROM...)
+#
+# However, there are a few obscure cases where this is incorrect. For
+# example, if the SELECT features a LIMIT clause, or if the collation
+# sequence or affinity used by the DISTINCT does not match the one used
+# by the IN(...) expression.
+#
+do_execsql_test 6.1.1 {
+ CREATE TABLE t1(a COLLATE nocase);
+ INSERT INTO t1 VALUES('one');
+ INSERT INTO t1 VALUES('ONE');
+}
+do_execsql_test 6.1.2 {
+ SELECT count(*) FROM t1 WHERE a COLLATE BINARY IN (SELECT DISTINCT a FROM t1)
+} {1}
+
+do_execsql_test 6.2.1 {
+ CREATE TABLE t3(a, b);
+ INSERT INTO t3 VALUES(1, 1);
+ INSERT INTO t3 VALUES(1, 2);
+ INSERT INTO t3 VALUES(1, 3);
+ INSERT INTO t3 VALUES(2, 4);
+ INSERT INTO t3 VALUES(2, 5);
+ INSERT INTO t3 VALUES(2, 6);
+ INSERT INTO t3 VALUES(3, 7);
+ INSERT INTO t3 VALUES(3, 8);
+ INSERT INTO t3 VALUES(3, 9);
+}
+do_execsql_test 6.2.2 {
+ SELECT count(*) FROM t3 WHERE b IN (SELECT DISTINCT a FROM t3 LIMIT 5);
+} {3}
+do_execsql_test 6.2.3 {
+ SELECT count(*) FROM t3 WHERE b IN (SELECT a FROM t3 LIMIT 5);
+} {2}
+
+do_execsql_test 6.3.1 {
+ CREATE TABLE x1(a);
+ CREATE TABLE x2(b);
+ INSERT INTO x1 VALUES(1), (1), (2);
+ INSERT INTO x2 VALUES(1), (2);
+ SELECT count(*) FROM x2 WHERE b IN (SELECT DISTINCT a FROM x1 LIMIT 2);
+} {2}
+
+#-------------------------------------------------------------------------
+# Test to confirm that bug [5e3c886796e5] is fixed.
+#
+do_execsql_test 7.1 {
+ CREATE TABLE y1(a, b);
+ CREATE TABLE y2(c);
+
+ INSERT INTO y1 VALUES(1, 'one');
+ INSERT INTO y1 VALUES('two', 'two');
+ INSERT INTO y1 VALUES(3, 'three');
+
+ INSERT INTO y2 VALUES('one');
+ INSERT INTO y2 VALUES('two');
+ INSERT INTO y2 VALUES('three');
+} {}
+
+do_execsql_test 7.2.1 {
+ SELECT a FROM y1 WHERE b NOT IN (SELECT a FROM y2);
+} {1 3}
+do_execsql_test 7.2.2 {
+ SELECT a FROM y1 WHERE b IN (SELECT a FROM y2);
+} {two}
+
+do_execsql_test 7.3.1 {
+ CREATE INDEX y2c ON y2(c);
+ SELECT a FROM y1 WHERE b NOT IN (SELECT a FROM y2);
+} {1 3}
+do_execsql_test 7.3.2 {
+ SELECT a FROM y1 WHERE b IN (SELECT a FROM y2);
+} {two}
+
+#-------------------------------------------------------------------------
+# Tests to confirm that indexes on the rowid column do not confuse
+# the query planner. See ticket [0eab1ac7591f511d].
+#
+do_execsql_test 8.0 {
+ CREATE TABLE n1(a INTEGER PRIMARY KEY, b VARCHAR(500));
+ CREATE UNIQUE INDEX n1a ON n1(a);
+}
+
+do_execsql_test 8.1 {
+ SELECT count(*) FROM n1 WHERE a IN (1, 2, 3)
+} 0
+do_execsql_test 8.2 {
+ SELECT count(*) FROM n1 WHERE a IN (SELECT +a FROM n1)
+} 0
+do_execsql_test 8.3 {
+ INSERT INTO n1 VALUES(1, NULL), (2, NULL), (3, NULL);
+ SELECT count(*) FROM n1 WHERE a IN (1, 2, 3)
+} 3
+do_execsql_test 8.4 {
+ SELECT count(*) FROM n1 WHERE a IN (SELECT +a FROM n1)
+} 3
+
+#-------------------------------------------------------------------------
+# Test that ticket 61fe97454c is fixed.
+#
+do_execsql_test 9.0 {
+ CREATE TABLE t9(a INTEGER PRIMARY KEY);
+ INSERT INTO t9 VALUES (44), (45);
+}
+do_execsql_test 9.1 {
+ SELECT * FROM t9 WHERE a IN (44, 45, 44, 45)
+} {44 45}
+
+#-------------------------------------------------------------------------
+# Test that ticket c7a117190 is fixed.
+#
+reset_db
+do_execsql_test 9.0 {
+ CREATE TABLE t0(c0);
+ CREATE VIEW v0(c0) AS SELECT LOWER(CAST('1e500' AS TEXT)) FROM t0;
+ INSERT INTO t0(c0) VALUES (NULL);
+}
+
+do_execsql_test 9.1 {
+ SELECT lower('1e500') FROM t0 WHERE rowid NOT IN (0, 0, lower('1e500'));
+} {1e500}
+
+do_execsql_test 9.2 {
+ SELECT lower('1e500') FROM t0 WHERE rowid != lower('1e500');
+} {1e500}
+
+finish_test
diff --git a/test/in6.test b/test/in6.test
new file mode 100644
index 0000000..f477f60
--- /dev/null
+++ b/test/in6.test
@@ -0,0 +1,119 @@
+# 2018-06-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.
+#
+#***********************************************************************
+#
+# A multi-key index that uses an IN operator on one of the keys other
+# than the left-most key is able to abort the IN-operator loop early
+# if key terms further to the left do not match.
+#
+# Call this the "multikey-IN-operator early-out optimization" or
+# just "IN-early-out" optimization for short.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix in6
+
+do_test in6-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b,c,d);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c,d)
+ SELECT 100, 200+x/2, 300+x/5, x FROM c;
+ CREATE INDEX t1abc ON t1(a,b,c);
+ ANALYZE;
+ UPDATE sqlite_stat1 SET stat='1000000 500000 500 50';
+ ANALYZE sqlite_master;
+ }
+ set ::sqlite_search_count 0
+ db eval {
+ SELECT d FROM t1
+ WHERE a=99
+ AND b IN (200,205,201,204)
+ AND c IN (304,302,309,308);
+ }
+} {}
+do_test in6-1.2 {
+ set ::sqlite_search_count
+} {0} ;# Without the IN-early-out optimization, this value would be 15
+
+# The multikey-IN-operator early-out optimization does not apply
+# when the IN operator is on the left-most column of the index.
+#
+do_test in6-1.3 {
+ db eval {
+ EXPLAIN
+ SELECT d FROM t1
+ WHERE a IN (98,99,100,101)
+ AND b=200 AND c=300;
+ }
+} {~/(IfNoHope|SeekHit)/}
+
+set sqlite_search_count 0
+do_execsql_test in6-1.4 {
+ SELECT d FROM t1
+ WHERE a=100
+ AND b IN (200,201,202,204)
+ AND c IN (300,302,301,305)
+ ORDER BY +d;
+} {1 2 3 4 5 8 9}
+do_test in6-1.5 {
+ set ::sqlite_search_count
+} {39}
+
+do_execsql_test in6-2.1 {
+ CREATE TABLE t2(e INT UNIQUE, f TEXT);
+ SELECT d, f FROM t1 LEFT JOIN t2 ON (e=d)
+ WHERE a=100
+ AND b IN (200,201,202,204)
+ AND c IN (300,302,301,305)
+ ORDER BY +d;
+} {1 {} 2 {} 3 {} 4 {} 5 {} 8 {} 9 {}}
+
+# 2020-03-16 ticket 82b588d342d515d1
+# Ensure that the IN-early-out optimization works with LEFT JOINs
+#
+reset_db
+do_execsql_test in6-3.100 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(0);
+ CREATE TABLE t2(b, c, d);
+ INSERT INTO t2(b,c,d) VALUES(4,5,3),(4,5,4),(4,5,8);
+ CREATE INDEX t2bcd ON t2(b, c, d);
+ SELECT * FROM t1 LEFT JOIN t2 ON b=NULL AND c=5 AND d IN (2,3,4);
+} {0 {} {} {}}
+do_execsql_test in6-3.110 {
+ CREATE TABLE v0(v1);
+ CREATE TABLE v3(v5, v4);
+ INSERT INTO v0 VALUES(0);
+ CREATE INDEX v9 ON v3(v4, v4, v5);
+ SELECT quote(v5) FROM v0 LEFT JOIN v3 ON v4 = NULL AND v5 IN(0);
+} {NULL}
+
+# 2021-04-29 forum https://sqlite.org/forum/forumpost/6a3ec138e9
+# An early OP_IsNull bypass might skip over the OP_Affinity and
+# cause the OP_IfNoHope to jump on a false-positive, resulting in
+# incomplete output.
+#
+reset_db
+do_execsql_test in6-3.120 {
+ CREATE TABLE t1(a TEXT, b TEXT);
+ INSERT INTO t1 VALUES(null,10),(0,10),(10,10);
+ CREATE INDEX t1ab ON t1(a,b);
+ SELECT quote(a), quote(b), '|' FROM t1 WHERE b in (SELECT a FROM t1) AND a=0;
+} {'0' '10' |}
+do_execsql_test in6-3.130 {
+ CREATE TABLE t2(x TEXT);
+ INSERT INTO t2(x) VALUES(NULL),(0),(10);
+ SELECT quote(x), quote(a), quote(b), 'x'
+ FROM t2 LEFT JOIN t1 ON a=x AND b in (null,0,10);
+} {NULL NULL NULL x '0' '0' '10' x '10' '10' '10' x}
+
+finish_test
diff --git a/test/incrblob.test b/test/incrblob.test
new file mode 100644
index 0000000..c56689e
--- /dev/null
+++ b/test/incrblob.test
@@ -0,0 +1,693 @@
+# 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 mmap_size = 0"
+ execsql "PRAGMA auto_vacuum = $AutoVacuumMode"
+
+ # Extra value added to size answers
+ set ib2_extra 0
+ if {$AutoVacuumMode} {incr ib2_extra}
+ if {[nonzero_reserved_bytes]} {incr ib2_extra}
+
+ 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 + $ib2_extra]
+
+ 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
+ execsql "PRAGMA mmap_size = 0"
+
+ # 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+$ib2_extra]
+
+ 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
+ execsql "PRAGMA mmap_size = 0"
+
+ # 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 + $ib2_extra]
+
+ # 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 { PRAGMA mmap_size = 0 }
+
+ execsql { SELECT i FROM blobs }
+ } {45}
+
+ do_test incrblob-2.$AutoVacuumMode.9 {
+ nRead db
+ } [expr $AutoVacuumMode ? 4 : 30 + $ib2_extra]
+}
+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 $::cmdlinearg(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 $::cmdlinearg(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 $::cmdlinearg(INFO_SCRIPT)]
+ do_test incrblob-5.2 {
+ set fd2 [open $::cmdlinearg(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 ORDER BY rowid
+ }
+ } {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 commit should be illegal (because
+ # there is an open blob channel).
+ #
+ 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 behavior 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 behavior 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 $::cmdlinearg(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..989da14
--- /dev/null
+++ b/test/incrblob2.test
@@ -0,0 +1,453 @@
+# 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}
+
+if {$::tcl_platform(pointerSize)>=8} {
+ do_test incrblob2-6.2b {
+ set rc [catch {
+ # Prior to 2015-02-07, the following caused a segfault due to
+ # integer overflow.
+ sqlite3_blob_read $rdHandle 2147483647 2147483647
+ } errmsg]
+ if {[string match {out of memory in *test_blob.c} $errmsg]} {
+ set errmsg SQLITE_ERROR
+ }
+ lappend rc $errmsg
+ } {1 SQLITE_ERROR}
+}
+do_test incrblob2-6.2c {
+ set rc [catch {
+ # Prior to 2015-02-07, the following caused a segfault due to
+ # integer overflow.
+ sqlite3_blob_read $rdHandle 2147483647 100
+ } errmsg]
+ lappend rc $errmsg
+} {1 SQLITE_ERROR}
+
+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.3b {
+ set rc [catch {
+ # Prior to 2015-02-07, the following caused a segfault due to
+ # integer overflow.
+ sqlite3_blob_write $wrHandle 2147483647 YYYYYYYYYYYYYYYYYY
+ } errmsg]
+ lappend rc $errmsg
+} {1 SQLITE_ERROR}
+do_test incrblob2-6.3c {
+ 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 {UNIQUE constraint failed: t3.a}}
+do_test incrblob2-8.6 {
+ catchsql {UPDATE t3 SET a = 6 WHERE a > 3}
+} {1 {UNIQUE constraint failed: t3.a}}
+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 {UNIQUE constraint failed: t3.a}}
+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..a9097e0
--- /dev/null
+++ b/test/incrblob3.test
@@ -0,0 +1,314 @@
+# 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
+set testprefix incrblob3
+
+ifcapable !incrblob {
+ finish_test
+ return
+}
+
+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
+
+#-------------------------------------------------------------------------
+#
+reset_db
+forcedelete test.db2
+do_execsql_test 8.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b);
+
+ INSERT INTO t1 VALUES(4, 'hello');
+ INSERT INTO aux.t1 VALUES(4, 'world');
+}
+
+do_test 8.2 {
+ set ::blob [db incrblob -readonly main t1 b 4]
+ read $::blob
+} {hello}
+close $::blob
+
+do_test 8.3 {
+ set ::blob [db incrblob -readonly aux t1 b 4]
+ read $::blob
+} {world}
+close $::blob
+
+do_test 8.4 {
+ set ::blob [db incrblob -readonly t1 b 4]
+ read $::blob
+} {hello}
+close $::blob
+
+do_test 8.5 {
+ list [catch { db incrblob -readonly nosuchdb t1 b 4 } msg] $msg
+} {1 {no such table: nosuchdb.t1}}
+
+
+db close
+finish_test
diff --git a/test/incrblob4.test b/test/incrblob4.test
new file mode 100644
index 0000000..dbff8eb
--- /dev/null
+++ b/test/incrblob4.test
@@ -0,0 +1,109 @@
+# 2012 March 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
+ifcapable {!incrblob} { finish_test ; return }
+set testprefix incrblob4
+
+proc create_t1 {} {
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(k INTEGER PRIMARY KEY, v);
+ }
+}
+
+proc populate_t1 {} {
+ set data [list 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]
+ foreach d $data {
+ set blob [string repeat $d 900]
+ execsql { INSERT INTO t1(v) VALUES($blob) }
+ }
+}
+
+
+do_test 1.1 {
+ create_t1
+ populate_t1
+} {}
+
+do_test 1.2 {
+ set blob [db incrblob t1 v 5]
+ read $blob 10
+} {eeeeeeeeee}
+
+do_test 1.3 {
+ execsql { DELETE FROM t1 }
+ populate_t1
+} {}
+
+
+
+do_test 2.1 {
+ reset_db
+ create_t1
+ populate_t1
+} {}
+
+do_test 2.2 {
+ set blob [db incrblob t1 v 10]
+ read $blob 10
+} {jjjjjjjjjj}
+
+do_test 2.3 {
+ set new [string repeat % 900]
+ execsql { DELETE FROM t1 WHERE k=10 }
+ execsql { DELETE FROM t1 WHERE k=9 }
+ execsql { INSERT INTO t1(v) VALUES($new) }
+} {}
+
+
+
+do_test 3.1 {
+ reset_db
+ create_t1
+ populate_t1
+} {}
+
+do_test 3.2 {
+ set blob [db incrblob t1 v 20]
+ read $blob 10
+} {tttttttttt}
+
+do_test 3.3 {
+ set new [string repeat % 900]
+ execsql { UPDATE t1 SET v = $new WHERE k = 20 }
+ execsql { DELETE FROM t1 WHERE k=19 }
+ execsql { INSERT INTO t1(v) VALUES($new) }
+} {}
+
+#-------------------------------------------------------------------------
+# Test that it is not possible to DROP a table with an incremental blob
+# cursor open on it.
+#
+do_execsql_test 4.1 {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t2 VALUES(456, '0123456789');
+}
+do_test 4.2 {
+ set blob [db incrblob -readonly t2 b 456]
+ read $blob 5
+} {01234}
+do_catchsql_test 4.3 {
+ DROP TABLE t2
+} {1 {database table is locked}}
+do_test 4.4 {
+ sqlite3_extended_errcode db
+} {SQLITE_LOCKED}
+close $blob
+
+finish_test
diff --git a/test/incrblob_err.test b/test/incrblob_err.test
new file mode 100644
index 0000000..3c52331
--- /dev/null
+++ b/test/incrblob_err.test
@@ -0,0 +1,140 @@
+# 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
+set ::testprefix incrblob_err
+
+ifcapable {!incrblob || !tclvar} {
+ finish_test
+ return
+}
+
+source $testdir/malloc_common.tcl
+
+unset -nocomplain ::fd ::data
+set ::fd [open $::cmdlinearg(INFO_SCRIPT)]
+set ::data [read $::fd]
+close $::fd
+
+do_malloc_test 1 -tclprep {
+ set bytes [file size $::cmdlinearg(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..d070bab
--- /dev/null
+++ b/test/incrblobfault.test
@@ -0,0 +1,74 @@
+# 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
+
+ifcapable !incrblob {
+ finish_test
+ return
+}
+
+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}} {1 {disk I/O error}}
+ 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/incrcorrupt.test b/test/incrcorrupt.test
new file mode 100644
index 0000000..2ea68c8
--- /dev/null
+++ b/test/incrcorrupt.test
@@ -0,0 +1,126 @@
+# 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.
+#
+#***********************************************************************
+# Test that "PRAGMA incremental_vacuum" detects and reports database
+# corruption properly. And that "PRAGMA auto_vacuum = INCREMENTAL"
+# does as well.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix incrcorrupt
+
+# If this build of the library does not support auto-vacuum, omit this
+# whole file.
+ifcapable {!autovacuum} {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ PRAGMA auto_vacuum = 2;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+
+ WITH data(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM data
+ )
+ INSERT INTO t1 SELECT i, randomblob(600) FROM data LIMIT 20;
+ PRAGMA page_count;
+} {24}
+
+do_execsql_test 1.1 {
+ PRAGMA incremental_vacuum;
+} {}
+
+do_test 1.2 {
+ db_save
+ hexio_write test.db 36 00000019
+ catchsql { PRAGMA incremental_vacuum; }
+} {1 {database disk image is malformed}}
+
+do_test 1.3 {
+ set stmt [sqlite3_prepare_v2 db "PRAGMA incremental_vacuum" -1 dummy]
+ sqlite3_step $stmt
+} {SQLITE_CORRUPT}
+do_test 1.4 { sqlite3_errcode db } {SQLITE_CORRUPT}
+do_test 1.5 { sqlite3_errmsg db } {database disk image is malformed}
+do_test 1.6 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}
+do_test 1.7 { sqlite3_errcode db } {SQLITE_CORRUPT}
+do_test 1.8 { sqlite3_errmsg db } {database disk image is malformed}
+
+do_test 1.9 {
+ set stmt [sqlite3_prepare_v2 db "PRAGMA incremental_vacuum" -1 dummy]
+ sqlite3_step $stmt
+} {SQLITE_CORRUPT}
+do_test 1.10 { sqlite3_errcode db } {SQLITE_CORRUPT}
+do_test 1.11 { sqlite3_errmsg db } {database disk image is malformed}
+
+do_test 1.12 {
+ set stmt2 [sqlite3_prepare_v2 db "SELECT 1" -1 dummy]
+ sqlite3_finalize $stmt2
+} {SQLITE_OK}
+do_test 1.13 { sqlite3_errcode db } {SQLITE_OK}
+do_test 1.14 { sqlite3_errmsg db } {not an error}
+
+do_test 1.15 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}
+do_test 1.16 { sqlite3_errcode db } {SQLITE_CORRUPT}
+do_test 1.17 { sqlite3_errmsg db } {database disk image is malformed}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+
+do_execsql_test 2.1 {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ WITH data(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM data
+ )
+ INSERT INTO t1 SELECT i, randomblob(600) FROM data LIMIT 20;
+ PRAGMA page_count;
+} {24}
+
+do_test 2.2 {
+ db_save
+ set fd [open test.db r+]
+ chan truncate $fd [expr 22*1024]
+ close $fd
+ catchsql { PRAGMA incremental_vacuum; }
+} {1 {database disk image is malformed}}
+
+do_test 2.3 {
+ set stmt [sqlite3_prepare_v2 db "PRAGMA auto_vacuum = INCREMENTAL" -1 dummy]
+ sqlite3_step $stmt
+} {SQLITE_CORRUPT}
+do_test 2.4 { sqlite3_errcode db } {SQLITE_CORRUPT}
+do_test 2.5 { sqlite3_errmsg db } {database disk image is malformed}
+do_test 2.6 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}
+do_test 2.7 { sqlite3_errcode db } {SQLITE_CORRUPT}
+do_test 2.8 { sqlite3_errmsg db } {database disk image is malformed}
+
+do_test 2.9 {
+ set stmt [sqlite3_prepare_v2 db "PRAGMA auto_vacuum = INCREMENTAL" -1 dummy]
+ sqlite3_step $stmt
+} {SQLITE_CORRUPT}
+do_test 2.10 { sqlite3_errcode db } {SQLITE_CORRUPT}
+do_test 2.11 { sqlite3_errmsg db } {database disk image is malformed}
+
+do_test 2.12 {
+ set stmt2 [sqlite3_prepare_v2 db "SELECT 1" -1 dummy]
+ sqlite3_finalize $stmt2
+} {SQLITE_OK}
+do_test 2.13 { sqlite3_errcode db } {SQLITE_OK}
+do_test 2.14 { sqlite3_errmsg db } {not an error}
+
+do_test 2.15 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}
+do_test 2.16 { sqlite3_errcode db } {SQLITE_CORRUPT}
+do_test 2.17 { sqlite3_errmsg db } {database disk image is malformed}
+
+finish_test
diff --git a/test/incrvacuum.test b/test/incrvacuum.test
new file mode 100644
index 0000000..d06005c
--- /dev/null
+++ b/test/incrvacuum.test
@@ -0,0 +1,892 @@
+# 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 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}
+
+#-------------------------------------------------------------------------
+# At one point it was unsafe to truncate a db file on windows while there
+# were outstanding xFetch() references. This test case attempts to hit
+# that case.
+#
+ifcapable mmap {
+ reset_db
+ do_execsql_test incrvacuum-16.0 {
+ PRAGMA auto_vacuum = 2;
+ CREATE TABLE t3(a);
+ INSERT INTO t3 VALUES(1), (2), (3), (4);
+
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ } {}
+
+ # Reopen db to ensure the page-cache is empty.
+ #
+ db close
+ sqlite3 db test.db
+
+ # Open db in mmap-mode. Open a transaction, delete some data, then run
+ # incremental-vacuum. Do not commit the transaction.
+ #
+ do_execsql_test incrvacuum-16.1 {
+ PRAGMA mmap_size = 1000000;
+ BEGIN;
+ DELETE FROM t2;
+ PRAGMA incremental_vacuum = 1000;
+ } {1000000}
+
+ # Scan through table t3 (which is all clean pages - so mmap is used). Then,
+ # midway through, commit the transaction. This causes the db to be truncated
+ # while there are outstanding xFetch pages.
+ #
+ do_test incrvacuum-16.2 {
+ set res [list]
+ db eval { SELECT a FROM t3 } {
+ if {$a==3} { db eval COMMIT }
+ lappend res $a
+ }
+ set res
+ } {1 2 3 4}
+}
+
+# 2021-04-05 dbsqlfuzz cced0668cfd4da4eb2382cb9dd26c17c64aaff76
+#
+# This is an incremental vacuum database that has one free page that
+# needs to be filled. After removing the last page from the end of
+# the database file to fill the free page slot, the last page that
+# is left is the tail of an overflow chain.
+#
+# But the size of the database file is shorter than the actual data
+# so that after incremental vacuum runs, the file is actually too
+# small to hold the last page of the overflow chain.
+#
+# At one point this caused an assertion fault in
+# sqlite3PagerTruncateImage().
+#
+do_test incrvacuum-17.0 {
+ sqlite3 db {}
+ database_may_be_corrupt
+ db deserialize [decode_hexdb {
+| size 20480 pagesize 4096 filename x2.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 05 00 00 00 07 .....@ ........
+| 32: 00 00 00 04 00 00 00 01 00 00 00 03 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 03 00 00 00 01 00 00 00 00 ................
+| 64: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................
+| 96: 00 2e 53 60 0d 0f dc 00 01 0f b8 00 0f b8 0f b8 ..S`............
+| 4016: 00 00 00 00 00 00 00 00 22 02 06 17 11 11 01 31 ...............1
+| 4032: 74 61 62 6c 65 74 32 74 32 03 43 52 45 41 54 45 tablet2t2.CREATE
+| 4048: 20 54 41 42 4c 45 20 74 32 28 79 29 00 00 00 24 TABLE t2(y)...$
+| 4064: 11 11 01 31 74 61 62 6c 65 74 31 74 31 03 43 52 ...1tablet1t1.CR
+| 4080: 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 78 29 EATE TABLE t1(x)
+| page 2 offset 4096
+| 0: 01 00 00 00 00 02 00 00 00 00 03 00 00 00 03 04 ................
+| 16: 00 00 00 05 03 00 00 00 03 00 00 00 00 00 00 00 ................
+| page 3 offset 8192
+| 0: 0d 00 00 00 02 05 47 00 08 dd 05 47 00 00 00 00 ......G....G....
+| 1344: 00 00 00 00 00 00 00 a7 0b 02 03 ce 1c 00 00 00 ................
+| 2256: 00 00 00 00 00 00 00 00 00 00 00 00 07 ce 14 01 ................
+| 2272: 04 81 9c 2c 00 00 00 00 00 00 00 00 00 00 00 00 ...,............
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................
+| page 4 offset 12288
+| 0: 00 00 00 00 00 00 00 00 08 dd 05 47 00 00 00 00 ...........G....
+| 1344: 00 00 00 00 00 00 00 a7 0b 02 03 ce 1c 00 00 00 ................
+| 2256: 00 00 00 00 00 00 00 00 00 00 00 00 07 ce 14 01 ................
+| 2272: 04 81 9c 2c 00 00 00 00 00 00 00 00 00 00 00 00 ...,............
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................
+| page 5 offset 16384
+| 0: 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| end x2.db
+}]} {}
+do_catchsql_test incrvacuum-17.1 {
+ PRAGMA writable_schema=ON;
+ PRAGMA incremental_vacuum(10);
+} {0 {}}
+
+finish_test
diff --git a/test/incrvacuum2.test b/test/incrvacuum2.test
new file mode 100644
index 0000000..6ec66c9
--- /dev/null
+++ b/test/incrvacuum2.test
@@ -0,0 +1,213 @@
+# 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
+
+if {[wal_is_capable]} {
+ # 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);
+ }
+ } {wal}
+ do_test 4.2.1 {
+ execsql { PRAGMA wal_checkpoint }
+ file size test.db-wal
+ } [expr {32+2*(512+24)}]
+
+ 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
+ } [expr {32+3*(512+24)}]
+}
+
+finish_test
diff --git a/test/incrvacuum3.test b/test/incrvacuum3.test
new file mode 100644
index 0000000..e901bfe
--- /dev/null
+++ b/test/incrvacuum3.test
@@ -0,0 +1,153 @@
+# 2013 Feb 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 the SQLite library, focusing
+# on the incremental vacuum feature.
+#
+# The tests in this file were added at the same time as optimizations
+# were made to:
+#
+# * Truncate the database after a rollback mode commit, and
+#
+# * Avoid moving pages to locations from which they may need to be moved
+# a second time if an incremental-vacuum proccess is allowed to vacuum
+# the entire database.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix incrvacuum3
+
+# If this build of the library does not support auto-vacuum, omit this
+# whole file.
+ifcapable {!autovacuum || !pragma} {
+ finish_test
+ return
+}
+
+proc check_on_disk {} {
+
+ # Copy the wal and journal files for database "test.db" to "test2.db".
+ forcedelete test2.db test2.db-journal test2.db-wal
+ if {[file exists test.db-journal]} {
+ forcecopy test.db-journal test2.db-journal
+ }
+ if {[file exists test.db-wal]} {
+ forcecopy test.db-wal test2.db-wal
+ }
+
+ # Now copy the database file itself. Do this using open/read/puts
+ # instead of the [file copy] command in order to avoid attempting
+ # to read the 512 bytes begining at offset $sqlite_pending_byte.
+ #
+ set sz [file size test.db]
+ set fd [open test.db]
+ set fd2 [open test2.db w]
+ fconfigure $fd -encoding binary -translation binary
+ fconfigure $fd2 -encoding binary -translation binary
+ if {$sz>$::sqlite_pending_byte} {
+ puts -nonewline $fd2 [read $fd $::sqlite_pending_byte]
+ seek $fd [expr $::sqlite_pending_byte+512]
+ seek $fd2 [expr $::sqlite_pending_byte+512]
+ }
+ puts -nonewline $fd2 [read $fd]
+ close $fd2
+ close $fd
+
+ # Open "test2.db" and check it is Ok.
+ sqlite3 dbcheck test2.db
+ set ret [dbcheck eval { PRAGMA integrity_check }]
+ dbcheck close
+ set ret
+}
+
+# Run these tests once in rollback journal mode, and once in wal mode.
+#
+foreach {T jrnl_mode} {
+ 1 delete
+ 2 wal
+} {
+ catch { db close }
+ forcedelete test.db test.db-journal test.db-wal
+ sqlite3 db test.db
+ db eval {
+ PRAGMA cache_size = 5;
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 2;
+ }
+ db eval "PRAGMA journal_mode = $jrnl_mode"
+
+ foreach {tn sql} {
+ 1 {
+ CREATE TABLE t1(x UNIQUE);
+ INSERT INTO t1 VALUES(randomblob(400));
+ INSERT INTO t1 VALUES(randomblob(400));
+ 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
+ }
+
+ 2 {
+ DELETE FROM t1 WHERE rowid%8;
+ }
+
+ 3 {
+ BEGIN;
+ PRAGMA incremental_vacuum = 100;
+ 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
+ ROLLBACK;
+ }
+
+ 4 {
+ BEGIN;
+ SAVEPOINT one;
+ PRAGMA incremental_vacuum = 100;
+ SAVEPOINT two;
+ 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
+ }
+
+ 5 { ROLLBACK to two }
+
+ 6 { ROLLBACK to one }
+
+ 7 {
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64
+ PRAGMA incremental_vacuum = 1000;
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 256
+ ROLLBACK;
+ }
+
+ 8 {
+ BEGIN;
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64
+ PRAGMA incremental_vacuum = 1000;
+ INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128
+ COMMIT;
+ }
+ } {
+ do_execsql_test $T.1.$tn.1 $sql
+ do_execsql_test $T.1.$tn.2 {PRAGMA integrity_check} ok
+ do_test $T.1.$tn.3 { check_on_disk } ok
+ }
+
+ do_execsql_test $T.1.x.1 { PRAGMA freelist_count } 0
+ do_execsql_test $T.1.x.2 { SELECT count(*) FROM t1 } 128
+}
+
+finish_test
diff --git a/test/incrvacuum_ioerr.test b/test/incrvacuum_ioerr.test
new file mode 100644
index 0000000..50f7fa2
--- /dev/null
+++ b/test/incrvacuum_ioerr.test
@@ -0,0 +1,182 @@
+# 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 nFree [execsql {pragma freelist_count} db1]
+ set nPage [execsql {pragma page_count} db1]
+ puts "nFree=$nFree nPage=$nPage"
+
+ # 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 [execsql {pragma page_count} db1]
+
+ do_test incrvacuum-ioerr-4.$iTest.2 {
+ set shrink [expr {$nPage-$nPage2}]
+ expr {$shrink==0 || $shrink==5 || ($nFree<5 && $shrink==$nFree)}
+ } {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..11d3d71
--- /dev/null
+++ b/test/index.test
@@ -0,0 +1,769 @@
+# 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.1b {
+ 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 {no such column: 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 {no such column: 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.1.2 {
+ catchsql {
+ CREATE TABLE sqlite_t1(a, b, c);
+ }
+} {1 {object name reserved for internal use: sqlite_t1}}
+sqlite3_db_config db DEFENSIVE 0
+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 {UNIQUE constraint failed: t7.a}}
+ 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 {UNIQUE constraint failed: t8.a}}
+ 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";
+ }
+} {}
+
+# Try to create a TEMP index on a non-TEMP table. */
+#
+do_test index-21.1 {
+ catchsql {
+ CREATE INDEX temp.i21 ON t6(c);
+ }
+} {1 {cannot create a TEMP index on non-TEMP table "t6"}}
+do_test index-21.2 {
+ catchsql {
+ CREATE TEMP TABLE t6(x);
+ INSERT INTO temp.t6 values(1),(5),(9);
+ CREATE INDEX temp.i21 ON t6(x);
+ SELECT x FROM t6 ORDER BY x DESC;
+ }
+} {0 {9 5 1}}
+
+# 2019-05-01 ticket https://www.sqlite.org/src/info/3be1295b264be2fa
+do_execsql_test index-22.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b TEXT);
+ CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==0);
+ CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
+ INSERT INTO t1(a,b) VALUES('a',1),('a',0);
+ SELECT a, b, '|' FROM t1;
+} {a 1 | a 0 |}
+
+# 2019-05-10 ticket https://www.sqlite.org/src/info/ae0f637bddc5290b
+do_execsql_test index-23.0 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a TEXT, b REAL);
+ CREATE UNIQUE INDEX t1x1 ON t1(a GLOB b);
+ INSERT INTO t1(a,b) VALUES('0.0','1'),('1.0','1');
+ SELECT * FROM t1;
+ REINDEX;
+} {0.0 1.0 1.0 1.0}
+do_execsql_test index-23.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a REAL);
+ CREATE UNIQUE INDEX index_0 ON t1(TYPEOF(a));
+ INSERT OR IGNORE INTO t1(a) VALUES (0.1),(FALSE);
+ SELECT * FROM t1;
+ REINDEX;
+} {0.1}
+
+finish_test
diff --git a/test/index2.test b/test/index2.test
new file mode 100644
index 0000000..b1d7e22
--- /dev/null
+++ b/test/index2.test
@@ -0,0 +1,73 @@
+# 2005-01-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.
+#
+
+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..6100f48
--- /dev/null
+++ b/test/index3.test
@@ -0,0 +1,96 @@
+# 2005-02-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.
+#
+
+
+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 {UNIQUE constraint failed: t1.a}}
+do_test index3-1.3 {
+ catchsql COMMIT;
+} {0 {}}
+integrity_check index3-1.4
+
+# Backwards compatibility test:
+#
+# Verify that CREATE INDEX statements that use strings instead of
+# identifiers for the the column names continue to work correctly.
+# This is undocumented behavior retained for backwards compatiblity.
+#
+do_execsql_test index3-2.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a, b, c, d, e,
+ PRIMARY KEY('a'), UNIQUE('b' COLLATE nocase DESC));
+ CREATE INDEX t1c ON t1('c');
+ CREATE INDEX t1d ON t1('d' COLLATE binary ASC);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<30)
+ INSERT INTO t1(a,b,c,d,e)
+ SELECT x, printf('ab%03xxy',x), x, x, x FROM c;
+} {}
+do_execsql_test index3-2.2 {
+ SELECT a FROM t1 WHERE b='ab005xy' COLLATE nocase;
+} {5}
+do_execsql_test index3-2.2eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE b='ab005xy' COLLATE nocase;
+} {/USING INDEX/}
+do_execsql_test index3-2.3 {
+ SELECT name FROM sqlite_master WHERE tbl_name='t1' ORDER BY name
+} {sqlite_autoindex_t1_1 sqlite_autoindex_t1_2 t1 t1c t1d}
+do_execsql_test index3-2.4 {
+ CREATE TABLE t2a(a integer, b, PRIMARY KEY(a));
+ CREATE TABLE t2b("a" integer, b, PRIMARY KEY("a"));
+ CREATE TABLE t2c([a] integer, b, PRIMARY KEY([a]));
+ CREATE TABLE t2d('a' integer, b, PRIMARY KEY('a'));
+}
+do_execsql_test index3-2.5 {
+ SELECT name FROM sqlite_master WHERE tbl_name LIKE 't2_' ORDER BY name
+} {t2a t2b t2c t2d}
+
+
+
+
+
+# This test corrupts the database file so it must be the last test
+# in the series.
+#
+do_test index3-99.1 {
+ sqlite3_db_config db DEFENSIVE 0
+ execsql {
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET sql='nonsense' WHERE name='t1d'
+ }
+ db close
+ catch { sqlite3 db test.db }
+ catchsql { DROP INDEX t1c }
+} {1 {malformed database schema (t1d)}}
+
+finish_test
diff --git a/test/index4.test b/test/index4.test
new file mode 100644
index 0000000..4fbfa52
--- /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 {UNIQUE constraint failed: t2.x}}
+
+
+finish_test
diff --git a/test/index5.test b/test/index5.test
new file mode 100644
index 0000000..4c0aa04
--- /dev/null
+++ b/test/index5.test
@@ -0,0 +1,80 @@
+# 2012 August 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 index5
+
+do_test 1.1 {
+ if {[permutation]=="memsubsys1"} {
+ execsql { PRAGMA auto_vacuum = 0; }
+ }
+ execsql {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ BEGIN;
+ }
+ for {set i 0} {$i < 100000} {incr i} {
+ execsql { INSERT INTO t1 VALUES(randstr(100,100)) }
+ }
+ execsql COMMIT
+ execsql {
+ CREATE INDEX i1 ON t1(x);
+ DROP INDEX I1;
+ PRAGMA main.page_size;
+ }
+} {1024}
+
+db close
+testvfs tvfs
+tvfs filter xWrite
+tvfs script write_cb
+proc write_cb {xCall file handle iOfst args} {
+ if {[file tail $file]=="test.db"} {
+ lappend ::write_list [expr $iOfst/1024 + 1]
+ }
+}
+
+do_test 1.2 {
+ sqlite3 db test.db -vfs tvfs
+ set ::write_list [list]
+ execsql { CREATE INDEX i1 ON t1(x) }
+} {}
+
+do_test 1.3 {
+ set nForward 0
+ set nBackward 0
+ set nNoncont 0
+ set iPrev [lindex $::write_list 0]
+ for {set i 1} {$i < [llength $::write_list]} {incr i} {
+ set iNext [lindex $::write_list $i]
+ if {$iNext==($iPrev+1)} {
+ incr nForward
+ } elseif {$iNext==($iPrev-1)} {
+ incr nBackward
+ } else {
+ incr nNoncont
+ }
+ set iPrev $iNext
+ }
+ if {0} {
+ puts -nonewline \
+ " (forward=$nForward, back=$nBackward, noncontiguous=$nNoncont)"
+ }
+
+ expr {$nForward > 2*($nBackward + $nNoncont)}
+} {1}
+db close
+tvfs delete
+
+finish_test
diff --git a/test/index6.test b/test/index6.test
new file mode 100644
index 0000000..16370f5
--- /dev/null
+++ b/test/index6.test
@@ -0,0 +1,531 @@
+# 2013-07-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.
+#
+#***********************************************************************
+#
+# Test cases for partial indices
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+load_static_extension db wholenumber;
+do_test index6-1.1 {
+ # Able to parse and manage partial indices
+ execsql {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1a ON t1(a) WHERE a IS NOT NULL;
+ CREATE INDEX t1b ON t1(b) WHERE b>10;
+ CREATE VIRTUAL TABLE nums USING wholenumber;
+ INSERT INTO t1(a,b,c)
+ SELECT CASE WHEN value%3!=0 THEN value END, value, value
+ FROM nums WHERE value<=20;
+ SELECT count(a), count(b) FROM t1;
+ PRAGMA integrity_check;
+ }
+} {14 20 ok}
+
+# Make sure the count(*) optimization works correctly with
+# partial indices. Ticket [a5c8ed66cae16243be6] 2013-10-03.
+#
+do_execsql_test index6-1.1.1 {
+ SELECT count(*) FROM t1;
+} {20}
+
+# Error conditions during parsing...
+#
+do_test index6-1.2 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE x IS NOT NULL;
+ }
+} {1 {no such column: x}}
+do_test index6-1.3 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE EXISTS(SELECT * FROM t1);
+ }
+} {1 {subqueries prohibited in partial index WHERE clauses}}
+do_test index6-1.4 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE a!=?1;
+ }
+} {1 {parameters prohibited in partial index WHERE clauses}}
+do_test index6-1.5 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE a!=random();
+ }
+} {1 {non-deterministic functions prohibited in partial index WHERE clauses}}
+do_test index6-1.6 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE a NOT LIKE 'abc%';
+ }
+} {0 {}}
+do_execsql_test index6-1.7 {
+ DROP INDEX IF EXISTS bad1;
+}
+
+do_test index6-1.10 {
+ execsql {
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {{} 20 t1a {14 1} t1b {10 1} ok}
+
+# STAT1 shows the partial indices have a reduced number of
+# rows.
+#
+do_test index6-1.11 {
+ execsql {
+ UPDATE t1 SET a=b;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {{} 20 t1a {20 1} t1b {10 1} ok}
+
+do_test index6-1.11 {
+ execsql {
+ UPDATE t1 SET a=NULL WHERE b%3!=0;
+ UPDATE t1 SET b=b+100;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {{} 20 t1a {6 1} t1b {20 1} ok}
+
+do_test index6-1.12 {
+ execsql {
+ UPDATE t1 SET a=CASE WHEN b%3!=0 THEN b END;
+ UPDATE t1 SET b=b-100;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {{} 20 t1a {13 1} t1b {10 1} ok}
+
+do_test index6-1.13 {
+ execsql {
+ DELETE FROM t1 WHERE b BETWEEN 8 AND 12;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {{} 15 t1a {10 1} t1b {8 1} ok}
+
+do_test index6-1.14 {
+ execsql {
+ REINDEX;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {{} 15 t1a {10 1} t1b {8 1} ok}
+
+do_test index6-1.15 {
+ execsql {
+ CREATE INDEX t1c ON t1(c);
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {t1a {10 1} t1b {8 1} t1c {15 1} ok}
+
+# Queries use partial indices as appropriate times.
+#
+do_test index6-2.1 {
+ execsql {
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2(a,b) SELECT value, value FROM nums WHERE value<1000;
+ UPDATE t2 SET a=NULL WHERE b%2==0;
+ CREATE INDEX t2a1 ON t2(a) WHERE a IS NOT NULL;
+ SELECT count(*) FROM t2 WHERE a IS NOT NULL;
+ }
+} {500}
+do_test index6-2.2 {
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a=5;
+ }
+} {/(SEARCH|SCAN) t2 USING INDEX t2a1 /}
+ifcapable stat4 {
+ execsql ANALYZE
+ do_test index6-2.3stat4 {
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a IS NOT NULL;
+ }
+ } {/(SEARCH|SCAN) t2 USING INDEX t2a1 /}
+} else {
+ do_test index6-2.3stat4 {
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a IS NOT NULL AND a>0;
+ }
+ } {/(SEARCH|SCANE) t2 USING INDEX t2a1 /}
+}
+do_test index6-2.4 {
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a IS NULL;
+ }
+} {~/INDEX t2a1/}
+
+do_execsql_test index6-2.101 {
+ DROP INDEX t2a1;
+ UPDATE t2 SET a=b, b=b+10000;
+ SELECT b FROM t2 WHERE a=15;
+} {10015}
+do_execsql_test index6-2.102 {
+ CREATE INDEX t2a2 ON t2(a) WHERE a<100 OR a>200;
+ SELECT b FROM t2 WHERE a=15;
+ PRAGMA integrity_check;
+} {10015 ok}
+do_execsql_test index6-2.102eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t2 WHERE a=15;
+} {~/.*INDEX t2a2.*/}
+do_execsql_test index6-2.103 {
+ SELECT b FROM t2 WHERE a=15 AND a<100;
+} {10015}
+do_execsql_test index6-2.103eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t2 WHERE a=15 AND a<100;
+} {/.*INDEX t2a2.*/}
+do_execsql_test index6-2.104 {
+ SELECT b FROM t2 WHERE a=515 AND a>200;
+} {10515}
+do_execsql_test index6-2.104eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t2 WHERE a=515 AND a>200;
+} {/.*INDEX t2a2.*/}
+
+# Partial UNIQUE indices
+#
+do_execsql_test index6-3.1 {
+ CREATE TABLE t3(a,b);
+ INSERT INTO t3 SELECT value, value FROM nums WHERE value<200;
+ UPDATE t3 SET a=999 WHERE b%5!=0;
+ CREATE UNIQUE INDEX t3a ON t3(a) WHERE a<>999;
+} {}
+do_test index6-3.2 {
+ # unable to insert a duplicate row a-value that is not 999.
+ catchsql {
+ INSERT INTO t3(a,b) VALUES(150, 'test1');
+ }
+} {1 {UNIQUE constraint failed: t3.a}}
+do_test index6-3.3 {
+ # can insert multiple rows with a==999 because such rows are not
+ # part of the unique index.
+ catchsql {
+ INSERT INTO t3(a,b) VALUES(999, 'test1'), (999, 'test2');
+ }
+} {0 {}}
+do_execsql_test index6-3.4 {
+ SELECT count(*) FROM t3 WHERE a=999;
+} {162}
+integrity_check index6-3.5
+
+do_execsql_test index6-4.0 {
+ VACUUM;
+ PRAGMA integrity_check;
+} {ok}
+
+# Silently ignore database name qualifiers in partial indices.
+#
+do_execsql_test index6-5.0 {
+ CREATE INDEX t3b ON t3(b) WHERE xyzzy.t3.b BETWEEN 5 AND 10;
+ /* ^^^^^-- ignored */
+ ANALYZE;
+ SELECT count(*) FROM t3 WHERE t3.b BETWEEN 5 AND 10;
+ SELECT stat+0 FROM sqlite_stat1 WHERE idx='t3b';
+} {6 6}
+
+# Test case for ticket [2ea3e9fe6379fc3f6ce7e090ce483c1a3a80d6c9] from
+# 2014-04-13: Partial index causes assertion fault on UPDATE OR REPLACE.
+#
+do_execsql_test index6-6.0 {
+ CREATE TABLE t6(a,b);
+ CREATE UNIQUE INDEX t6ab ON t1(a,b);
+ CREATE INDEX t6b ON t6(b) WHERE b=1;
+ INSERT INTO t6(a,b) VALUES(123,456);
+ SELECT * FROM t6;
+} {123 456}
+do_execsql_test index6-6.1 {
+ UPDATE OR REPLACE t6 SET b=789;
+ SELECT * FROM t6;
+} {123 789}
+do_execsql_test index6-6.2 {
+ PRAGMA integrity_check;
+} {ok}
+
+# Test case for ticket [2326c258d02ead33d69faa63de8f4686b9b1b9d9] on
+# 2015-02-24. Any use of a partial index qualifying constraint inside
+# the ON clause of a LEFT JOIN was causing incorrect results for all
+# versions of SQLite 3.8.0 through 3.8.8.
+#
+do_execsql_test index6-7.0 {
+ CREATE TABLE t7a(x);
+ CREATE TABLE t7b(y);
+ INSERT INTO t7a(x) VALUES(1);
+ CREATE INDEX t7ax ON t7a(x) WHERE x=99;
+ PRAGMA automatic_index=OFF;
+ SELECT * FROM t7a LEFT JOIN t7b ON (x=99) ORDER BY x;
+} {1 {}}
+do_execsql_test index6-7.1 {
+ INSERT INTO t7b(y) VALUES(2);
+ SELECT * FROM t7a JOIN t7b ON (x=99) ORDER BY x;
+} {}
+do_execsql_test index6-7.2 {
+ INSERT INTO t7a(x) VALUES(99);
+ SELECT * FROM t7a LEFT JOIN t7b ON (x=99) ORDER BY x;
+} {1 {} 99 2}
+do_execsql_test index6-7.3 {
+ SELECT * FROM t7a JOIN t7b ON (x=99) ORDER BY x;
+} {99 2}
+do_execsql_test index6-7.4 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t7a JOIN t7b ON (x=99) ORDER BY x;
+} {/USING COVERING INDEX t7ax/}
+
+
+do_execsql_test index6-8.0 {
+ CREATE TABLE t8a(a,b);
+ CREATE TABLE t8b(x,y);
+ CREATE INDEX i8c ON t8b(y) WHERE x = 'value';
+
+ INSERT INTO t8a VALUES(1, 'one');
+ INSERT INTO t8a VALUES(2, 'two');
+ INSERT INTO t8a VALUES(3, 'three');
+
+ INSERT INTO t8b VALUES('value', 1);
+ INSERT INTO t8b VALUES('dummy', 2);
+ INSERT INTO t8b VALUES('value', 3);
+ INSERT INTO t8b VALUES('dummy', 4);
+} {}
+
+do_eqp_test index6-8.1 {
+ SELECT * FROM t8a LEFT JOIN t8b ON (x = 'value' AND y = a)
+} {
+ QUERY PLAN
+ |--SCAN t8a
+ `--SEARCH t8b USING INDEX i8c (y=?) LEFT-JOIN
+}
+
+do_execsql_test index6-8.2 {
+ SELECT * FROM t8a LEFT JOIN t8b ON (x = 'value' AND y = a)
+} {
+ 1 one value 1
+ 2 two {} {}
+ 3 three value 3
+}
+
+# 2015-06-11. Assertion fault found by AFL
+#
+do_execsql_test index6-9.1 {
+ CREATE TABLE t9(a int, b int, c int);
+ CREATE INDEX t9ca ON t9(c,a) WHERE a in (10,12,20);
+ INSERT INTO t9 VALUES(1,1,9),(10,2,35),(11,15,82),(20,19,5),(NULL,7,3);
+ UPDATE t9 SET b=c WHERE a in (10,12,20);
+ SELECT a,b,c,'|' FROM t9 ORDER BY a;
+} {{} 7 3 | 1 1 9 | 10 35 35 | 11 15 82 | 20 5 5 |}
+do_execsql_test index6-9.2 {
+ DROP TABLE t9;
+ CREATE TABLE t9(a int, b int, c int, PRIMARY KEY(a)) WITHOUT ROWID;
+ CREATE INDEX t9ca ON t9(c,a) WHERE a in (10,12,20);
+ INSERT INTO t9 VALUES(1,1,9),(10,2,35),(11,15,82),(20,19,5);
+ UPDATE t9 SET b=c WHERE a in (10,12,20);
+ SELECT a,b,c,'|' FROM t9 ORDER BY a;
+} {1 1 9 | 10 35 35 | 11 15 82 | 20 5 5 |}
+
+# AND-connected terms in the WHERE clause of a partial index
+#
+do_execsql_test index6-10.1 {
+ CREATE TABLE t10(a,b,c,d,e INTEGER PRIMARY KEY);
+ INSERT INTO t10 VALUES
+ (1,2,3,4,5),
+ (2,3,4,5,6),
+ (3,4,5,6,7),
+ (1,2,3,8,9);
+ CREATE INDEX t10x ON t10(d) WHERE a=1 AND b=2 AND c=3;
+ SELECT e FROM t10 WHERE a=1 AND b=2 AND c=3 ORDER BY d;
+} {5 9}
+do_execsql_test index6-10.1eqp {
+ EXPLAIN QUERY PLAN
+ SELECT e FROM t10 WHERE a=1 AND b=2 AND c=3 ORDER BY d;
+} {/USING INDEX t10x/}
+do_execsql_test index6-10.2 {
+ SELECT e FROM t10 WHERE c=3 AND 2=b AND a=1 ORDER BY d DESC;
+} {9 5}
+do_execsql_test index6-10.2eqp {
+ EXPLAIN QUERY PLAN
+ SELECT e FROM t10 WHERE c=3 AND 2=b AND a=1 ORDER BY d DESC;
+} {/USING INDEX t10x/}
+do_execsql_test index6-10.3 {
+ SELECT e FROM t10 WHERE a=1 AND b=2 ORDER BY d DESC;
+} {9 5}
+do_execsql_test index6-10.3eqp {
+ EXPLAIN QUERY PLAN
+ SELECT e FROM t10 WHERE a=1 AND b=2 ORDER BY d DESC;
+} {~/USING INDEX t10x/}
+
+# A partial index will be used for a full table scan, where possible
+do_execsql_test index6-11.1 {
+ CREATE TABLE t11(a,b,c);
+ CREATE INDEX t11x ON t11(a) WHERE b<>99;
+ EXPLAIN QUERY PLAN SELECT a FROM t11 WHERE b<>99;
+} {/USING INDEX t11x/}
+do_execsql_test index6-11.2 {
+ EXPLAIN QUERY PLAN SELECT a FROM t11 WHERE b<>99 AND c<>98;
+} {/USING INDEX t11x/}
+
+# 2018-12-08
+# Ticket https://www.sqlite.org/src/info/1d958d90596593a7
+# NOT IN operator fails when using a partial index.
+#
+do_execsql_test index6-12.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,1);
+ INSERT INTO t1 VALUES(2,2);
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ SELECT 'one', * FROM t2 WHERE x NOT IN (SELECT a FROM t1);
+ CREATE INDEX t1a ON t1(a) WHERE b=1;
+ SELECT 'two', * FROM t2 WHERE x NOT IN (SELECT a FROM t1);
+} {}
+do_execsql_test index6-12.2 {
+ SELECT x FROM t2 WHERE x IN (SELECT a FROM t1) ORDER BY +x;
+} {1 2}
+
+# 2019-05-04
+# Ticket https://www.sqlite.org/src/tktview/5c6955204c392ae763a95
+# Theorem prover error
+#
+do_execsql_test index6-13.1 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0);
+ CREATE INDEX index_0 ON t0(c0) WHERE c0 NOT NULL;
+ INSERT INTO t0(c0) VALUES (NULL);
+ SELECT * FROM t0 WHERE c0 OR 1;
+} {{}}
+
+# 2019-05-11
+# Ticket https://sqlite.org/src/tktview/8025674847
+reset_db
+do_execsql_test index6-14.1 {
+ CREATE TABLE IF NOT EXISTS t0 (c0, c1);
+ CREATE INDEX IF NOT EXISTS i0 ON t0(c0, c1) WHERE c0 NOT NULL;
+ INSERT INTO t0(c0, c1) VALUES(NULL, 'row');
+ SELECT * FROM t0 WHERE t0.c0 IS NOT 1;
+} {{} row}
+
+do_execsql_test index6-14.2 {
+ SELECT * FROM t0 WHERE CASE c0 WHEN 0 THEN 0 ELSE 1 END;
+} {{} row}
+
+# 2019-08-30
+# Ticket https://www.sqlite.org/src/info/a6408d42b9f44462
+# Ticket https://www.sqlite.org/src/info/fba33c8b1df6a915
+# https://sqlite.org/src/info/bac716244fddac1fe841
+#
+do_execsql_test index6-15.1 {
+ DROP TABLE t0;
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES (NULL);
+ CREATE INDEX i0 ON t0(1) WHERE c0 NOT NULL;
+ SELECT 1 FROM t0 WHERE (t0.c0 IS FALSE) IS FALSE;
+} {1}
+do_execsql_test index6-15.2 {
+ SELECT 1 FROM t0 WHERE (t0.c0 IS FALSE) BETWEEN FALSE AND TRUE;
+} {1}
+do_execsql_test index6-15.3 {
+ SELECT 1 FROM t0 WHERE TRUE BETWEEN (t0.c0 IS FALSE) AND TRUE;
+} {1}
+do_execsql_test index6-15.4 {
+ SELECT 1 FROM t0 WHERE FALSE BETWEEN FALSE AND (t0.c0 IS FALSE);
+} {1}
+do_execsql_test index6-15.5 {
+ SELECT 1 FROM t0 WHERE (c0 IS FALSE) IN (FALSE);
+} {1}
+
+# 2019-09-03
+# Ticket https://sqlite.org/src/info/767a8cbc6d20bd68
+do_execsql_test index6-16.1 {
+ DROP TABLE t0;
+ CREATE TABLE t0(c0 COLLATE NOCASE, c1);
+ CREATE INDEX i0 ON t0(0) WHERE c0 >= c1;
+ INSERT INTO t0 VALUES('a', 'B');
+ SELECT c1 <= c0, c0 >= c1 FROM t0;
+} {1 0}
+do_execsql_test index6-16.2 {
+ SELECT 2 FROM t0 WHERE c0 >= c1;
+} {}
+do_execsql_test index6-16.3 {
+ SELECT 3 FROM t0 WHERE c1 <= c0;
+} {3}
+
+# 2019-11-02
+# Ticket https://sqlite.org/src/tktview/a9efb42811fa41ee286e8
+db close
+sqlite3 db :memory:
+do_execsql_test index6-17.1 {
+ CREATE TABLE t0(c0);
+ CREATE INDEX i0 ON t0(0) WHERE c0 GLOB c0;
+ INSERT INTO t0 VALUES (0);
+ CREATE UNIQUE INDEX i1 ON t0(0);
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test index6-17.2 {
+ CREATE UNIQUE INDEX i2 ON t0(0);
+ REPLACE INTO t0 VALUES(0);
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test index6-17.3 {
+ SELECT COUNT(*) FROM t0 WHERE t0.c0 GLOB t0.c0;
+} {1}
+
+# 2021-05-29
+# Forum https://sqlite.org/forum/forumpost/d813704d7c
+reset_db
+do_execsql_test index6-18.1 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(10,10);
+ CREATE UNIQUE INDEX t1b ON t1(b) WHERE a>NULL;
+ SELECT * FROM t1 WHERE a IS NOT NULL;
+} {10 10}
+
+# 2022-06-09
+# https://sqlite.org/forum/forumpost/c4676c4956
+# Cannot do a scan of a partial index on the left table of a RIGHT JOIN
+# since that will cause extra rows to appear in the output during the
+# right-join no-match loop. The following testcase is verify using
+# PostgreSQL 14.
+#
+reset_db
+do_execsql_test index6-19.1 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1(a) VALUES(2);
+ CREATE TABLE t2(c INT);
+ CREATE INDEX i0 ON t2(c) WHERE c=3;
+ CREATE TABLE t3(d INT);
+ INSERT INTO t3 VALUES(1);
+}
+do_execsql_test index6-19.2 {
+ SELECT * FROM t2 RIGHT JOIN t3 ON d<>0 LEFT JOIN t1 ON c=3 WHERE t1.a<>0;
+} {}
+
+finish_test
diff --git a/test/index7.test b/test/index7.test
new file mode 100644
index 0000000..eeb36ba
--- /dev/null
+++ b/test/index7.test
@@ -0,0 +1,355 @@
+# 2013-11-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.
+#
+#***********************************************************************
+#
+# Test cases for partial indices in WITHOUT ROWID tables
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+# Capture the output of a pragma in a TEMP table.
+#
+proc capture_pragma {db tabname sql} {
+ $db eval "DROP TABLE IF EXISTS temp.$tabname"
+ set once 1
+ $db eval $sql x {
+ if {$once} {
+ set once 0
+ set ins "INSERT INTO $tabname VALUES"
+ set crtab "CREATE TEMP TABLE $tabname "
+ set sep "("
+ foreach col $x(*) {
+ append ins ${sep}\$x($col)
+ append crtab ${sep}\"$col\"
+ set sep ,
+ }
+ append ins )
+ append crtab )
+ $db eval $crtab
+ }
+ $db eval $ins
+ }
+}
+
+
+load_static_extension db wholenumber;
+do_test index7-1.1 {
+ # Able to parse and manage partial indices
+ execsql {
+ CREATE TABLE t1(a,b,c PRIMARY KEY) WITHOUT rowid;
+ CREATE INDEX t1a ON t1(a) WHERE a IS NOT NULL;
+ CREATE INDEX t1b ON t1(b) WHERE b>10;
+ CREATE VIRTUAL TABLE nums USING wholenumber;
+ INSERT INTO t1(a,b,c)
+ SELECT CASE WHEN value%3!=0 THEN value END, value, value
+ FROM nums WHERE value<=20;
+ SELECT count(a), count(b) FROM t1;
+ PRAGMA integrity_check;
+ }
+} {14 20 ok}
+
+# (The "partial" column of the PRAGMA index_list output is...)
+# EVIDENCE-OF: R-34457-09668 "1" if the index is a partial index and "0"
+# if not.
+#
+do_test index7-1.1a {
+ capture_pragma db out {PRAGMA index_list(t1)}
+ db eval {SELECT "name", "partial", '|' FROM out ORDER BY "name"}
+} {sqlite_autoindex_t1_1 0 | t1a 1 | t1b 1 |}
+
+# Make sure the count(*) optimization works correctly with
+# partial indices. Ticket [a5c8ed66cae16243be6] 2013-10-03.
+#
+do_execsql_test index7-1.1.1 {
+ SELECT count(*) FROM t1;
+} {20}
+
+# Error conditions during parsing...
+#
+do_test index7-1.2 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE x IS NOT NULL;
+ }
+} {1 {no such column: x}}
+do_test index7-1.3 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE EXISTS(SELECT * FROM t1);
+ }
+} {1 {subqueries prohibited in partial index WHERE clauses}}
+do_test index7-1.4 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE a!=?1;
+ }
+} {1 {parameters prohibited in partial index WHERE clauses}}
+do_test index7-1.5 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE a!=random();
+ }
+} {1 {non-deterministic functions prohibited in partial index WHERE clauses}}
+do_test index7-1.6 {
+ catchsql {
+ CREATE INDEX bad1 ON t1(a,b) WHERE a NOT LIKE 'abc%';
+ }
+} {0 {}}
+do_execsql_test index7-1.7 {
+ INSERT INTO t1(a,b,c)
+ VALUES('abcde',1,101),('abdef',2,102),('xyz',3,103),('abcz',4,104);
+ SELECT c FROM t1 WHERE a NOT LIKE 'abc%' AND a=7 ORDER BY +b;
+} {7}
+do_execsql_test index7-1.7eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t1 WHERE a NOT LIKE 'abc%' AND a=7 ORDER BY +b;
+} {/SEARCH t1 USING COVERING INDEX bad1 /}
+do_execsql_test index7-1.8 {
+ DELETE FROM t1 WHERE c>=101;
+ DROP INDEX IF EXISTS bad1;
+} {}
+
+do_test index7-1.10 {
+ execsql {
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {t1 {20 1} t1a {14 1} t1b {10 1} ok}
+
+# STAT1 shows the partial indices have a reduced number of
+# rows.
+#
+do_test index7-1.11 {
+ execsql {
+ UPDATE t1 SET a=b;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {t1 {20 1} t1a {20 1} t1b {10 1} ok}
+
+do_test index7-1.11b {
+ execsql {
+ UPDATE t1 SET a=NULL WHERE b%3!=0;
+ UPDATE t1 SET b=b+100;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {t1 {20 1} t1a {6 1} t1b {20 1} ok}
+
+do_test index7-1.12 {
+ execsql {
+ UPDATE t1 SET a=CASE WHEN b%3!=0 THEN b END;
+ UPDATE t1 SET b=b-100;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {t1 {20 1} t1a {13 1} t1b {10 1} ok}
+
+do_test index7-1.13 {
+ execsql {
+ DELETE FROM t1 WHERE b BETWEEN 8 AND 12;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {t1 {15 1} t1a {10 1} t1b {8 1} ok}
+
+do_test index7-1.14 {
+ execsql {
+ REINDEX;
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {t1 {15 1} t1a {10 1} t1b {8 1} ok}
+
+do_test index7-1.15 {
+ execsql {
+ CREATE INDEX t1c ON t1(c);
+ ANALYZE;
+ SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;
+ PRAGMA integrity_check;
+ }
+} {t1 {15 1} t1a {10 1} t1b {8 1} t1c {15 1} ok}
+
+# Queries use partial indices at appropriate times.
+#
+do_test index7-2.1 {
+ execsql {
+ CREATE TABLE t2(a,b PRIMARY KEY) without rowid;
+ INSERT INTO t2(a,b) SELECT value, value FROM nums WHERE value<1000;
+ UPDATE t2 SET a=NULL WHERE b%5==0;
+ CREATE INDEX t2a1 ON t2(a) WHERE a IS NOT NULL;
+ SELECT count(*) FROM t2 WHERE a IS NOT NULL;
+ }
+} {800}
+do_test index7-2.2 {
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a=5;
+ }
+} {/(SCAN|SEARCH) t2 USING COVERING INDEX t2a1 /}
+ifcapable stat4 {
+ do_test index7-2.3stat4 {
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a IS NOT NULL;
+ }
+ } {/(SCAN|SEARCH) t2 USING COVERING INDEX t2a1 /}
+} else {
+ do_test index7-2.3stat4 {
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a IS NOT NULL AND a>0;
+ }
+ } {/(SCAN|SEARCH) t2 USING COVERING INDEX t2a1 /}
+}
+do_test index7-2.4 {
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a IS NULL;
+ }
+} {~/INDEX t2a1/}
+
+do_execsql_test index7-2.101 {
+ DROP INDEX t2a1;
+ UPDATE t2 SET a=b, b=b+10000;
+ SELECT b FROM t2 WHERE a=15;
+} {10015}
+do_execsql_test index7-2.102 {
+ CREATE INDEX t2a2 ON t2(a) WHERE a<100 OR a>200;
+ SELECT b FROM t2 WHERE a=15;
+ PRAGMA integrity_check;
+} {10015 ok}
+do_execsql_test index7-2.102eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t2 WHERE a=15;
+} {~/.*INDEX t2a2.*/}
+do_execsql_test index7-2.103 {
+ SELECT b FROM t2 WHERE a=15 AND a<100;
+} {10015}
+do_execsql_test index7-2.103eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t2 WHERE a=15 AND a<100;
+} {/.*INDEX t2a2.*/}
+do_execsql_test index7-2.104 {
+ SELECT b FROM t2 WHERE a=515 AND a>200;
+} {10515}
+do_execsql_test index7-2.104eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b FROM t2 WHERE a=515 AND a>200;
+} {/.*INDEX t2a2.*/}
+
+# Partial UNIQUE indices
+#
+do_execsql_test index7-3.1 {
+ CREATE TABLE t3(a,b PRIMARY KEY) without rowid;
+ INSERT INTO t3 SELECT value, value FROM nums WHERE value<200;
+ UPDATE t3 SET a=999 WHERE b%5!=0;
+ CREATE UNIQUE INDEX t3a ON t3(a) WHERE a<>999;
+} {}
+do_test index7-3.2 {
+ # unable to insert a duplicate row a-value that is not 999.
+ catchsql {
+ INSERT INTO t3(a,b) VALUES(150, 'test1');
+ }
+} {1 {UNIQUE constraint failed: t3.a}}
+do_test index7-3.3 {
+ # can insert multiple rows with a==999 because such rows are not
+ # part of the unique index.
+ catchsql {
+ INSERT INTO t3(a,b) VALUES(999, 'test1'), (999, 'test2');
+ }
+} {0 {}}
+do_execsql_test index7-3.4 {
+ SELECT count(*) FROM t3 WHERE a=999;
+} {162}
+integrity_check index7-3.5
+
+do_execsql_test index7-4.0 {
+ VACUUM;
+ PRAGMA integrity_check;
+} {ok}
+
+# Silently ignore database name qualifiers in partial indices.
+#
+do_execsql_test index7-5.0 {
+ CREATE INDEX t3b ON t3(b) WHERE xyzzy.t3.b BETWEEN 5 AND 10;
+ /* ^^^^^-- ignored */
+ ANALYZE;
+ SELECT count(*) FROM t3 WHERE t3.b BETWEEN 5 AND 10;
+ SELECT stat+0 FROM sqlite_stat1 WHERE idx='t3b';
+} {6 6}
+
+# Verify that the problem identified by ticket [98d973b8f5] has been fixed.
+#
+do_execsql_test index7-6.1 {
+ CREATE TABLE t5(a, b);
+ CREATE TABLE t4(c, d);
+ INSERT INTO t5 VALUES(1, 'xyz');
+ INSERT INTO t4 VALUES('abc', 'not xyz');
+ SELECT * FROM (SELECT * FROM t5 WHERE a=1 AND b='xyz'), t4 WHERE c='abc';
+} {
+ 1 xyz abc {not xyz}
+}
+do_execsql_test index7-6.2 {
+ CREATE INDEX i4 ON t4(c) WHERE d='xyz';
+ SELECT * FROM (SELECT * FROM t5 WHERE a=1 AND b='xyz'), t4 WHERE c='abc';
+} {
+ 1 xyz abc {not xyz}
+}
+do_execsql_test index7-6.3 {
+ CREATE VIEW v4 AS SELECT * FROM t4;
+ INSERT INTO t4 VALUES('def', 'xyz');
+ SELECT * FROM v4 WHERE d='xyz' AND c='def'
+} {
+ def xyz
+}
+do_eqp_test index7-6.4 {
+ SELECT * FROM v4 WHERE d='xyz' AND c='def'
+} {SEARCH t4 USING INDEX i4 (c=?)}
+
+do_catchsql_test index7-6.5 {
+ CREATE INDEX t5a ON t5(a) WHERE a=#1;
+} {1 {near "#1": syntax error}}
+
+do_execsql_test index7-7.0 {
+ CREATE TABLE t6(x, y);
+ INSERT INTO t6 VALUES(1, 1);
+ INSERT INTO t6 VALUES(0, 0);
+ SELECT * FROM t6 WHERE y IS TRUE ORDER BY x;
+} {1 1}
+
+do_execsql_test index7-7.1 {
+ CREATE INDEX i6 ON t6(x) WHERE y IS NOT TRUE;
+ SELECT * FROM t6 WHERE y IS TRUE ORDER BY x;
+} {1 1}
+
+# 2020-05-27. tag-20200527-1.
+# Incomplete stat1 information on a table with few rows should still use the
+# index.
+reset_db
+do_execsql_test index7-8.1 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ CREATE INDEX t1y ON t1(y) WHERE y IS NOT NULL;
+ INSERT INTO t1(x) VALUES(1),(2);
+ ANALYZE;
+ EXPLAIN QUERY PLAN SELECT 1 FROM t1 WHERE y=5;
+} {/SEARCH t1 USING COVERING INDEX t1y/}
+
+
+finish_test
diff --git a/test/index8.test b/test/index8.test
new file mode 100644
index 0000000..41ccf4b
--- /dev/null
+++ b/test/index8.test
@@ -0,0 +1,60 @@
+# 2016-07-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 cases for ORDER BY and LIMIT on an index scan.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Performance regression reported at
+# http://www.mail-archive.com/sqlite-users@mailinglists.sqlite.org/msg98615.html
+#
+# Caused by the ORDER BY LIMIT optionation for check-in
+# https://sqlite.org/src/info/bf46179d44843769
+#
+# Fixed on approximately 2016-07-27 by changes that compute a better score
+# for index scans by taking into account WHERE clause constraints that can
+# be handled by the index and do not require a table lookup.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a,b,c,d);
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c,d)
+ SELECT x/10, x%10, x%19, x FROM c;
+ CREATE INDEX t1abc ON t1(a,b,c);
+ SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2;
+} {0 4 4 4 2 3 4 23}
+
+# Prior to the fix, the following EQP would show a table scan and a sort
+# rather than an index scan.
+#
+do_execsql_test 1.0eqp {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2;
+} {/SCAN t1 USING INDEX t1abc/}
+
+# If we change the index so that it no longer covers the WHERE clause,
+# then we should (correctly) revert to using a table scan.
+#
+do_execsql_test 1.1 {
+ DROP INDEX t1abc;
+ CREATE INDEX t1abd ON t1(a,b,d);
+ SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2;
+} {0 4 4 4 2 3 4 23}
+do_execsql_test 1.1eqp {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2;
+} {~/USING INDEX/}
+
+
+finish_test
diff --git a/test/index9.test b/test/index9.test
new file mode 100644
index 0000000..00e99a8
--- /dev/null
+++ b/test/index9.test
@@ -0,0 +1,96 @@
+# 2017 Jun 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.
+#
+#***********************************************************************
+#
+# Test that partial indexes work with bound variables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix index9
+
+proc sqluses {sql} {
+ array unset ::T
+ uplevel [list db eval "EXPLAIN $sql" a {
+ if {$a(opcode)=="OpenRead"} { set ::T($a(p2)) 1 }
+ }]
+
+ set in [join [array names ::T] ,]
+ db eval "SELECT name FROM sqlite_master WHERE rootpage IN ($in) ORDER BY 1"
+}
+
+proc do_sqluses_test {tn sql objects} {
+ uplevel [list do_test $tn [list sqluses $sql] $objects]
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+ CREATE INDEX t1x ON t1(x) WHERE y=45;
+}
+unset -nocomplain a
+set y [expr 45]
+do_sqluses_test 1.1 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1 t1x}
+set y [expr 45.1]
+do_sqluses_test 1.2 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1}
+set y [expr 44]
+do_sqluses_test 1.3 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1}
+unset -nocomplain y
+do_sqluses_test 1.4 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1}
+set y [string range "45" 0 end]
+do_sqluses_test 1.5 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1}
+
+do_execsql_test 2.0 {
+ CREATE INDEX t1x2 ON t1(x) WHERE y=-20111000111
+}
+do_sqluses_test 2.1 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}
+set y [expr -20111000111]
+do_sqluses_test 2.2 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1 t1x2}
+set y [expr -20111000110]
+do_sqluses_test 2.3 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}
+set y [expr -20111000112]
+do_sqluses_test 2.4 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}
+
+do_execsql_test 3.0 {
+ CREATE INDEX t1x3 ON t1(x) WHERE y=9223372036854775807
+}
+set y [expr 9223372036854775807]
+do_sqluses_test 3.1 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1 t1x3}
+set y [expr 9223372036854775808]
+do_sqluses_test 3.2 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}
+set y [expr 9223372036854775806]
+do_sqluses_test 3.3 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}
+db cache flush
+sqlite3_db_config db QPSG 1
+set y [expr 9223372036854775807]
+do_sqluses_test 3.4 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}
+set y [expr 9223372036854775808]
+do_sqluses_test 3.5 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}
+sqlite3_db_config db QPSG 0
+db cache flush
+
+
+do_execsql_test 4.0 {
+ CREATE INDEX t1x4 ON t1(x) WHERE y=-9223372036854775808
+}
+set y [expr -9223372036854775808]
+do_sqluses_test 4.1 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1 t1x4}
+set y [expr -9223372036854775807]
+do_sqluses_test 4.2 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}
+set y [expr -9223372036854775809]
+do_sqluses_test 4.3 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}
+set y [expr -9223372036854775808]
+do_sqluses_test 4.4 { SELECT * FROM t1 WHERE $y=y ORDER BY x } {t1 t1x4}
+db cache flush
+sqlite3_db_config db QPSG 1
+do_sqluses_test 4.5 { SELECT * FROM t1 WHERE $y=y ORDER BY x } {t1}
+sqlite3_db_config db QPSG 0
+db cache flush
+
+finish_test
diff --git a/test/indexedby.test b/test/indexedby.test
new file mode 100644
index 0000000..6a37111
--- /dev/null
+++ b/test/indexedby.test
@@ -0,0 +1,385 @@
+# 2008-10-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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix indexedby
+
+# 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_eqp_test indexedby-1.2 {
+ select * from t1 WHERE a = 10;
+} {SEARCH t1 USING INDEX i1 (a=?)}
+do_eqp_test indexedby-1.3 {
+ select * from t1 ;
+} {SCAN t1}
+do_eqp_test indexedby-1.4 {
+ select * from t1, t2 WHERE c = 10;
+} {
+ QUERY PLAN
+ |--SEARCH t2 USING INDEX i3 (c=?)
+ `--SCAN t1
+}
+
+# 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.
+#
+# X-EVIDENCE-OF: R-07004-11522 -- syntax diagram qualified-table-name
+#
+# EVIDENCE-OF: R-58230-57098 The "INDEXED BY index-name" phrase
+# specifies that the named index must be used in order to look up values
+# on the preceding table.
+#
+do_test indexedby-2.1 {
+ execsql { SELECT * FROM t1 NOT INDEXED WHERE a = 'one' AND b = 'two'}
+} {}
+do_test indexedby-2.1b {
+ execsql { SELECT * FROM main.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.2b {
+ execsql { SELECT * FROM main.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'}
+} {}
+# EVIDENCE-OF: R-44699-55558 The INDEXED BY clause does not give the
+# optimizer hints about which index to use; it gives the optimizer a
+# requirement of which index to use.
+# EVIDENCE-OF: R-15800-25719 If index-name does not exist or cannot be
+# used for the query, then the preparation of the SQL statement fails.
+#
+do_test indexedby-2.4 {
+ catchsql { SELECT * FROM t1 INDEXED BY i3 WHERE a = 'one' AND b = 'two'}
+} {1 {no such index: i3}}
+
+# EVIDENCE-OF: R-05301-32681 If the query optimizer is unable to use the
+# index specified by the INDEXED BY clause, then the query will fail
+# with an error.
+do_test indexedby-2.4.1 {
+ catchsql { SELECT b FROM t1 INDEXED BY i1 WHERE b = 'two' }
+} {0 {}}
+
+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.
+#
+# EVIDENCE-OF: R-37002-28871 The "NOT INDEXED" clause specifies that no
+# index shall be used when accessing the preceding table, including
+# implied indices create by UNIQUE and PRIMARY KEY constraints. However,
+# the rowid can still be used to look up entries even when "NOT INDEXED"
+# is specified.
+#
+do_eqp_test indexedby-3.1 {
+ SELECT * FROM t1 WHERE a = 'one' AND b = 'two'
+} {/SEARCH t1 USING INDEX/}
+do_eqp_test indexedby-3.1.1 {
+ SELECT * FROM t1 NOT INDEXED WHERE a = 'one' AND b = 'two'
+} {SCAN t1}
+do_eqp_test indexedby-3.1.2 {
+ SELECT * FROM t1 NOT INDEXED WHERE rowid=1
+} {/SEARCH t1 USING INTEGER PRIMARY KEY .rowid=/}
+
+
+do_eqp_test indexedby-3.2 {
+ SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' AND b = 'two'
+} {SEARCH t1 USING INDEX i1 (a=?)}
+do_eqp_test indexedby-3.3 {
+ SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' AND b = 'two'
+} {SEARCH t1 USING INDEX i2 (b=?)}
+do_test indexedby-3.4 {
+ catchsql { SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' }
+} {0 {}}
+do_test indexedby-3.5 {
+ catchsql { SELECT * FROM t1 INDEXED BY i2 ORDER BY a }
+} {0 {}}
+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_eqp_test indexedby-3.8 {
+ SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 ORDER BY e
+} {SCAN t3 USING INDEX sqlite_autoindex_t3_1}
+do_eqp_test indexedby-3.9 {
+ SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 WHERE e = 10
+} {SEARCH t3 USING INDEX sqlite_autoindex_t3_1 (e=?)}
+do_test indexedby-3.10 {
+ catchsql { SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 WHERE f = 10 }
+} {0 {}}
+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_eqp_test indexedby-4.1 {
+ SELECT * FROM t1, t2 WHERE a = c
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SEARCH t2 USING INDEX i3 (c=?)
+}
+do_eqp_test indexedby-4.2 {
+ SELECT * FROM t1 INDEXED BY i1, t2 WHERE a = c
+} {
+ QUERY PLAN
+ |--SCAN t1 USING INDEX i1
+ `--SEARCH t2 USING INDEX i3 (c=?)
+}
+do_test indexedby-4.3 {
+ catchsql {
+ SELECT * FROM t1 INDEXED BY i1, t2 INDEXED BY i3 WHERE a=c
+ }
+} {0 {}}
+do_test indexedby-4.4 {
+ catchsql {
+ SELECT * FROM t2 INDEXED BY i3, t1 INDEXED BY i1 WHERE a=c
+ }
+} {0 {}}
+
+# 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
+} {/*SEARCH t1 USING INDEX i1 (a>?)*/}
+do_execsql_test indexedby-5.2 {
+ EXPLAIN QUERY PLAN SELECT * FROM v2 WHERE b = 10
+} {/*SEARCH t1 USING INDEX i1 (a>?)*/}
+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 }
+} {0 {}}
+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_eqp_test indexedby-6.1 {
+ SELECT * FROM t1 WHERE b = 10 ORDER BY rowid
+} {SEARCH t1 USING INDEX i2 (b=?)}
+do_eqp_test indexedby-6.2 {
+ SELECT * FROM t1 NOT INDEXED WHERE b = 10 ORDER BY rowid
+} {SCAN t1}
+
+# EVIDENCE-OF: R-40297-14464 The INDEXED BY phrase forces the SQLite
+# query planner to use a particular named index on a DELETE, SELECT, or
+# UPDATE statement.
+#
+# Test that "INDEXED BY" can be used in a DELETE statement.
+#
+do_eqp_test indexedby-7.1 {
+ DELETE FROM t1 WHERE a = 5
+} {SEARCH t1 USING INDEX i1 (a=?)}
+do_eqp_test indexedby-7.2 {
+ DELETE FROM t1 NOT INDEXED WHERE a = 5
+} {SCAN t1}
+do_eqp_test indexedby-7.3 {
+ DELETE FROM t1 INDEXED BY i1 WHERE a = 5
+} {SEARCH t1 USING INDEX i1 (a=?)}
+do_eqp_test indexedby-7.4 {
+ DELETE FROM t1 INDEXED BY i1 WHERE a = 5 AND b = 10
+} {SEARCH t1 USING INDEX i1 (a=?)}
+do_eqp_test indexedby-7.5 {
+ DELETE FROM t1 INDEXED BY i2 WHERE a = 5 AND b = 10
+} {SEARCH t1 USING INDEX i2 (b=?)}
+do_test indexedby-7.6 {
+ catchsql { DELETE FROM t1 INDEXED BY i2 WHERE a = 5}
+} {0 {}}
+
+# Test that "INDEXED BY" can be used in an UPDATE statement.
+#
+do_eqp_test indexedby-8.1 {
+ UPDATE t1 SET rowid=rowid+1 WHERE a = 5
+} {SEARCH t1 USING COVERING INDEX i1 (a=?)}
+do_eqp_test indexedby-8.2 {
+ UPDATE t1 NOT INDEXED SET rowid=rowid+1 WHERE a = 5
+} {SCAN t1}
+do_eqp_test indexedby-8.3 {
+ UPDATE t1 INDEXED BY i1 SET rowid=rowid+1 WHERE a = 5
+} {SEARCH t1 USING COVERING INDEX i1 (a=?)}
+do_eqp_test indexedby-8.4 {
+ UPDATE t1 INDEXED BY i1 SET rowid=rowid+1 WHERE a = 5 AND b = 10
+} {SEARCH t1 USING INDEX i1 (a=?)}
+do_eqp_test indexedby-8.5 {
+ UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5 AND b = 10
+} {SEARCH t1 USING INDEX i2 (b=?)}
+do_test indexedby-8.6 {
+ catchsql { UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5}
+} {0 {}}
+
+# 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)
+ }
+} {0 {}}
+do_test indexedby-9.3 {
+ catchsql { select * from maintable, joinme INDEXED by joinme_id_text_idx }
+} {0 {}}
+
+# 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}
+
+#-------------------------------------------------------------------------
+# Ensure that the rowid at the end of each index entry may be used
+# for equality constraints in the same way as other indexed fields.
+#
+do_execsql_test 11.1 {
+ CREATE TABLE x1(a, b TEXT);
+ CREATE INDEX x1i ON x1(a, b);
+ INSERT INTO x1 VALUES(1, 1);
+ INSERT INTO x1 VALUES(1, 1);
+ INSERT INTO x1 VALUES(1, 1);
+ INSERT INTO x1 VALUES(1, 1);
+}
+do_execsql_test 11.2 {
+ SELECT a,b,rowid FROM x1 INDEXED BY x1i WHERE a=1 AND b=1 AND rowid=3;
+} {1 1 3}
+do_execsql_test 11.3 {
+ SELECT a,b,rowid FROM x1 INDEXED BY x1i WHERE a=1 AND b=1 AND rowid='3';
+} {1 1 3}
+do_execsql_test 11.4 {
+ SELECT a,b,rowid FROM x1 INDEXED BY x1i WHERE a=1 AND b=1 AND rowid='3.0';
+} {1 1 3}
+do_eqp_test 11.5 {
+ SELECT a,b,rowid FROM x1 INDEXED BY x1i WHERE a=1 AND b=1 AND rowid='3.0';
+} {SEARCH x1 USING COVERING INDEX x1i (a=? AND b=? AND rowid=?)}
+
+do_execsql_test 11.6 {
+ CREATE TABLE x2(c INTEGER PRIMARY KEY, a, b TEXT);
+ CREATE INDEX x2i ON x2(a, b);
+ INSERT INTO x2 VALUES(1, 1, 1);
+ INSERT INTO x2 VALUES(2, 1, 1);
+ INSERT INTO x2 VALUES(3, 1, 1);
+ INSERT INTO x2 VALUES(4, 1, 1);
+}
+do_execsql_test 11.7 {
+ SELECT a,b,c FROM x2 INDEXED BY x2i WHERE a=1 AND b=1 AND c=3;
+} {1 1 3}
+do_execsql_test 11.8 {
+ SELECT a,b,c FROM x2 INDEXED BY x2i WHERE a=1 AND b=1 AND c='3';
+} {1 1 3}
+do_execsql_test 11.9 {
+ SELECT a,b,c FROM x2 INDEXED BY x2i WHERE a=1 AND b=1 AND c='3.0';
+} {1 1 3}
+do_eqp_test 11.10 {
+ SELECT a,b,c FROM x2 INDEXED BY x2i WHERE a=1 AND b=1 AND c='3.0';
+} {SEARCH x2 USING COVERING INDEX x2i (a=? AND b=? AND rowid=?)}
+
+#-------------------------------------------------------------------------
+# Check INDEXED BY works (throws an exception) with partial indexes that
+# cannot be used.
+do_execsql_test 12.1 {
+ CREATE TABLE o1(x INTEGER PRIMARY KEY, y, z);
+ CREATE INDEX p1 ON o1(z);
+ CREATE INDEX p2 ON o1(y) WHERE z=1;
+}
+do_catchsql_test 12.2 {
+ SELECT * FROM o1 INDEXED BY p2 ORDER BY 1;
+} {1 {no query solution}}
+do_execsql_test 12.3 {
+ DROP INDEX p1;
+ DROP INDEX p2;
+ CREATE INDEX p2 ON o1(y) WHERE z=1;
+ CREATE INDEX p1 ON o1(z);
+}
+do_catchsql_test 12.4 {
+ SELECT * FROM o1 INDEXED BY p2 ORDER BY 1;
+} {1 {no query solution}}
+
+finish_test
diff --git a/test/indexexpr1.test b/test/indexexpr1.test
new file mode 100644
index 0000000..042132b
--- /dev/null
+++ b/test/indexexpr1.test
@@ -0,0 +1,509 @@
+# 2015-08-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 indexes on expressions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test indexexpr1-100 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1(a,b,c)
+ /* 123456789 123456789 123456789 123456789 123456789 123456789 */
+ VALUES('In_the_beginning_was_the_Word',1,1),
+ ('and_the_Word_was_with_God',1,2),
+ ('and_the_Word_was_God',1,3),
+ ('The_same_was_in_the_beginning_with_God',2,1),
+ ('All_things_were_made_by_him',3,1),
+ ('and_without_him_was_not_any_thing_made_that_was_made',3,2);
+ CREATE INDEX t1a1 ON t1(substr(a,1,12));
+} {}
+do_execsql_test indexexpr1-110 {
+ SELECT b, c, '|' FROM t1 WHERE substr(a,1,12)=='and_the_Word' ORDER BY b, c;
+} {1 2 | 1 3 |}
+do_execsql_test indexexpr1-110eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b, c, '|' FROM t1 WHERE substr(a,1,12)=='and_the_Word' ORDER BY b, c;
+} {/USING INDEX t1a1/}
+do_execsql_test indexexpr1-120 {
+ SELECT b, c, '|' FROM t1 WHERE 'and_the_Word'==substr(a,1,12) ORDER BY b, c;
+} {1 2 | 1 3 |}
+do_execsql_test indexexpr1-120eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b, c, '|' FROM t1 WHERE 'and_the_Word'==substr(a,1,12) ORDER BY b, c;
+} {/USING INDEX t1a1/}
+
+do_execsql_test indexexpr1-130 {
+ CREATE INDEX t1ba ON t1(b,substr(a,2,3),c);
+ SELECT c FROM t1 WHERE b=1 AND substr(a,2,3)='nd_' ORDER BY c;
+} {2 3}
+do_execsql_test indexexpr1-130eqp {
+ EXPLAIN QUERY PLAN
+ SELECT c FROM t1 WHERE b=1 AND substr(a,2,3)='nd_' ORDER BY c;
+} {/USING INDEX t1ba/}
+
+do_execsql_test indexexpr1-140 {
+ SELECT rowid, substr(a,b,3), '|' FROM t1 ORDER BY 2;
+} {1 In_ | 2 and | 3 and | 6 d_w | 4 he_ | 5 l_t |}
+do_execsql_test indexexpr1-141 {
+ CREATE INDEX t1abx ON t1(substr(a,b,3));
+ SELECT rowid FROM t1 WHERE substr(a,b,3)<='and' ORDER BY +rowid;
+} {1 2 3}
+do_execsql_test indexexpr1-141eqp {
+ EXPLAIN QUERY PLAN
+ SELECT rowid FROM t1 WHERE substr(a,b,3)<='and' ORDER BY +rowid;
+} {/USING INDEX t1abx/}
+do_execsql_test indexexpr1-142 {
+ SELECT rowid FROM t1 WHERE +substr(a,b,3)<='and' ORDER BY +rowid;
+} {1 2 3}
+do_execsql_test indexexpr1-150 {
+ SELECT rowid FROM t1 WHERE substr(a,b,3) IN ('and','l_t','xyz')
+ ORDER BY +rowid;
+} {2 3 5}
+do_execsql_test indexexpr1-150eqp {
+ EXPLAIN QUERY PLAN
+ SELECT rowid FROM t1 WHERE substr(a,b,3) IN ('and','l_t','xyz')
+ ORDER BY +rowid;
+} {/USING INDEX t1abx/}
+
+ifcapable altertable {
+ do_execsql_test indexexpr1-160 {
+ ALTER TABLE t1 ADD COLUMN d;
+ UPDATE t1 SET d=length(a);
+ CREATE INDEX t1a2 ON t1(SUBSTR(a, 27, 3)) WHERE d>=29;
+ SELECT rowid, b, c FROM t1
+ WHERE substr(a,27,3)=='ord' AND d>=29;
+ } {1 1 1}
+ do_execsql_test indexexpr1-160eqp {
+ EXPLAIN QUERY PLAN
+ SELECT rowid, b, c FROM t1
+ WHERE substr(a,27,3)=='ord' AND d>=29;
+ } {/USING INDEX t1a2/}
+}
+
+# ORDER BY using an indexed expression
+#
+do_execsql_test indexexpr1-170 {
+ CREATE INDEX t1alen ON t1(length(a));
+ SELECT length(a) FROM t1 ORDER BY length(a);
+} {20 25 27 29 38 52}
+do_execsql_test indexexpr1-170eqp {
+ EXPLAIN QUERY PLAN
+ SELECT length(a) FROM t1 ORDER BY length(a);
+} {/SCAN t1 USING INDEX t1alen/}
+do_execsql_test indexexpr1-171 {
+ SELECT length(a) FROM t1 ORDER BY length(a) DESC;
+} {52 38 29 27 25 20}
+do_execsql_test indexexpr1-171eqp {
+ EXPLAIN QUERY PLAN
+ SELECT length(a) FROM t1 ORDER BY length(a) DESC;
+} {/SCAN t1 USING INDEX t1alen/}
+
+do_execsql_test indexexpr1-200 {
+ DROP TABLE t1;
+ CREATE TABLE t1(id ANY PRIMARY KEY, a,b,c) WITHOUT ROWID;
+ INSERT INTO t1(id,a,b,c)
+ VALUES(1,'In_the_beginning_was_the_Word',1,1),
+ (2,'and_the_Word_was_with_God',1,2),
+ (3,'and_the_Word_was_God',1,3),
+ (4,'The_same_was_in_the_beginning_with_God',2,1),
+ (5,'All_things_were_made_by_him',3,1),
+ (6,'and_without_him_was_not_any_thing_made_that_was_made',3,2);
+ CREATE INDEX t1a1 ON t1(substr(a,1,12));
+} {}
+do_execsql_test indexexpr1-210 {
+ SELECT b, c, '|' FROM t1 WHERE substr(a,1,12)=='and_the_Word' ORDER BY b, c;
+} {1 2 | 1 3 |}
+do_execsql_test indexexpr1-210eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b, c, '|' FROM t1 WHERE substr(a,1,12)=='and_the_Word' ORDER BY b, c;
+} {/USING INDEX t1a1/}
+do_execsql_test indexexpr1-220 {
+ SELECT b, c, '|' FROM t1 WHERE 'and_the_Word'==substr(a,1,12) ORDER BY b, c;
+} {1 2 | 1 3 |}
+do_execsql_test indexexpr1-220eqp {
+ EXPLAIN QUERY PLAN
+ SELECT b, c, '|' FROM t1 WHERE 'and_the_Word'==substr(a,1,12) ORDER BY b, c;
+} {/USING INDEX t1a1/}
+
+do_execsql_test indexexpr1-230 {
+ CREATE INDEX t1ba ON t1(b,substr(a,2,3),c);
+ SELECT c FROM t1 WHERE b=1 AND substr(a,2,3)='nd_' ORDER BY c;
+} {2 3}
+do_execsql_test indexexpr1-230eqp {
+ EXPLAIN QUERY PLAN
+ SELECT c FROM t1 WHERE b=1 AND substr(a,2,3)='nd_' ORDER BY c;
+} {/USING INDEX t1ba/}
+
+do_execsql_test indexexpr1-240 {
+ SELECT id, substr(a,b,3), '|' FROM t1 ORDER BY 2;
+} {1 In_ | 2 and | 3 and | 6 d_w | 4 he_ | 5 l_t |}
+do_execsql_test indexexpr1-241 {
+ CREATE INDEX t1abx ON t1(substr(a,b,3));
+ SELECT id FROM t1 WHERE substr(a,b,3)<='and' ORDER BY +id;
+} {1 2 3}
+do_execsql_test indexexpr1-241eqp {
+ EXPLAIN QUERY PLAN
+ SELECT id FROM t1 WHERE substr(a,b,3)<='and' ORDER BY +id;
+} {/USING INDEX t1abx/}
+do_execsql_test indexexpr1-242 {
+ SELECT id FROM t1 WHERE +substr(a,b,3)<='and' ORDER BY +id;
+} {1 2 3}
+do_execsql_test indexexpr1-250 {
+ SELECT id FROM t1 WHERE substr(a,b,3) IN ('and','l_t','xyz')
+ ORDER BY +id;
+} {2 3 5}
+do_execsql_test indexexpr1-250eqp {
+ EXPLAIN QUERY PLAN
+ SELECT id FROM t1 WHERE substr(a,b,3) IN ('and','l_t','xyz')
+ ORDER BY +id;
+} {/USING INDEX t1abx/}
+
+ifcapable altertable {
+ do_execsql_test indexexpr1-260 {
+ ALTER TABLE t1 ADD COLUMN d;
+ UPDATE t1 SET d=length(a);
+ CREATE INDEX t1a2 ON t1(SUBSTR(a, 27, 3)) WHERE d>=29;
+ SELECT id, b, c FROM t1
+ WHERE substr(a,27,3)=='ord' AND d>=29;
+ } {1 1 1}
+ do_execsql_test indexexpr1-260eqp {
+ EXPLAIN QUERY PLAN
+ SELECT id, b, c FROM t1
+ WHERE substr(a,27,3)=='ord' AND d>=29;
+ } {/USING INDEX t1a2/}
+}
+
+
+do_catchsql_test indexexpr1-300 {
+ CREATE TABLE t2(a,b,c); INSERT INTO t2 VALUES(1,2,3);
+ CREATE INDEX t2x1 ON t2(a,b+random());
+} {1 {non-deterministic functions prohibited in index expressions}}
+do_catchsql_test indexexpr1-301 {
+ CREATE INDEX t2x1 ON t2(julianday('now',a));
+} {1 {non-deterministic use of julianday() in an index}}
+do_catchsql_test indexexpr1-310 {
+ CREATE INDEX t2x2 ON t2(a,b+(SELECT 15));
+} {1 {subqueries prohibited in index expressions}}
+do_catchsql_test indexexpr1-320 {
+ CREATE TABLE e1(x,y,UNIQUE(y,substr(x,1,5)));
+} {1 {expressions prohibited in PRIMARY KEY and UNIQUE constraints}}
+do_catchsql_test indexexpr1-330 {
+ CREATE TABLE e1(x,y,PRIMARY KEY(y,substr(x,1,5)));
+} {1 {expressions prohibited in PRIMARY KEY and UNIQUE constraints}}
+do_catchsql_test indexexpr1-331 {
+ CREATE TABLE e1(x,y,PRIMARY KEY(y,substr(x,1,5))) WITHOUT ROWID;
+} {1 {expressions prohibited in PRIMARY KEY and UNIQUE constraints}}
+do_catchsql_test indexexpr1-340 {
+ CREATE TABLE e1(x,y,FOREIGN KEY(substr(y,1,5)) REFERENCES t1);
+} {1 {near "(": syntax error}}
+
+do_execsql_test indexexpr1-400 {
+ CREATE TABLE t3(a,b,c);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<30)
+ INSERT INTO t3(a,b,c)
+ SELECT x, printf('ab%04xyz',x), random() FROM c;
+ CREATE UNIQUE INDEX t3abc ON t3(CAST(a AS text), b, substr(c,1,3));
+ SELECT a FROM t3 WHERE CAST(a AS text)<='10' ORDER BY +a;
+ PRAGMA integrity_check;
+} {1 10 ok}
+do_catchsql_test indexexpr1-410 {
+ INSERT INTO t3 SELECT * FROM t3 WHERE rowid=10;
+} {1 {UNIQUE constraint failed: index 't3abc'}}
+
+do_execsql_test indexexpr1-500 {
+ CREATE TABLE t5(a);
+ CREATE TABLE cnt(x);
+ WITH RECURSIVE
+ c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ INSERT INTO cnt(x) SELECT x FROM c;
+ INSERT INTO t5(a) SELECT printf('abc%03dxyz',x) FROM cnt;
+ CREATE INDEX t5ax ON t5( substr(a,4,3) );
+} {}
+do_execsql_test indexexpr1-510 {
+ -- The use of the "k" alias in the WHERE clause is technically
+ -- illegal, but SQLite allows it for historical reasons. In this
+ -- test and the next, verify that "k" can be used by the t5ax index
+ SELECT substr(a,4,3) AS k FROM cnt, t5 WHERE k=printf('%03d',x);
+} {001 002 003 004 005}
+do_execsql_test indexexpr1-510eqp {
+ EXPLAIN QUERY PLAN
+ SELECT substr(a,4,3) AS k FROM cnt, t5 WHERE k=printf('%03d',x);
+} {/USING INDEX t5ax/}
+
+# Skip-scan on an indexed expression
+#
+do_execsql_test indexexpr1-600 {
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(a,b,c,d,e,f,g,h,i);
+ CREATE INDEX t4all ON t4(a,b,c<d,e,f,i,h);
+ INSERT INTO t4 VALUES(1,2,3,4,5,6,7,8,9);
+ ANALYZE;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1
+ VALUES('t4','t4all','600000 160000 40000 10000 2000 600 100 40 10');
+ ANALYZE sqlite_master;
+ SELECT i FROM t4 WHERE e=5;
+} {9}
+
+# Indexed expressions on both sides of an == in a WHERE clause.
+#
+do_execsql_test indexexpr1-700 {
+ DROP TABLE IF EXISTS t7;
+ CREATE TABLE t7(a,b,c);
+ INSERT INTO t7(a,b,c) VALUES(1,2,2),('abc','def','def'),(4,5,6);
+ CREATE INDEX t7b ON t7(+b);
+ CREATE INDEX t7c ON t7(+c);
+ SELECT *, '|' FROM t7 WHERE +b=+c ORDER BY +a;
+} {1 2 2 | abc def def |}
+do_execsql_test indexexpr1-710 {
+ CREATE TABLE t71(a,b,c);
+ CREATE INDEX t71bc ON t71(b+c);
+ CREATE TABLE t72(x,y,z);
+ CREATE INDEX t72yz ON t72(y+z);
+ INSERT INTO t71(a,b,c) VALUES(1,11,2),(2,7,15),(3,5,4);
+ INSERT INTO t72(x,y,z) VALUES(1,10,3),(2,8,14),(3,9,9);
+ SELECT a, x, '|' FROM t71, t72
+ WHERE b+c=y+z
+ ORDER BY +a, +x;
+} {1 1 | 2 2 |}
+
+# Collating sequences on indexes of expressions
+#
+do_execsql_test indexexpr1-800 {
+ DROP TABLE IF EXISTS t8;
+ CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE UNIQUE INDEX t8bx ON t8(substr(b,2,4) COLLATE nocase);
+ INSERT INTO t8(a,b) VALUES(1,'Alice'),(2,'Bartholemew'),(3,'Cynthia');
+ SELECT * FROM t8 WHERE substr(b,2,4)='ARTH' COLLATE nocase;
+} {2 Bartholemew}
+do_catchsql_test indexexpr1-810 {
+ INSERT INTO t8(a,b) VALUES(4,'BARTHMERE');
+} {1 {UNIQUE constraint failed: index 't8bx'}}
+do_catchsql_test indexexpr1-820 {
+ DROP INDEX t8bx;
+ CREATE UNIQUE INDEX t8bx ON t8(substr(b,2,4) COLLATE rtrim);
+ INSERT INTO t8(a,b) VALUES(4,'BARTHMERE');
+} {0 {}}
+
+# Check that PRAGMA integrity_check works correctly on a
+# UNIQUE index that includes rowid and expression terms.
+#
+do_execsql_test indexexpr1-900 {
+ CREATE TABLE t9(a,b,c,d);
+ CREATE UNIQUE INDEX t9x1 ON t9(c,abs(d),b);
+ INSERT INTO t9(rowid,a,b,c,d) VALUES(1,2,3,4,5);
+ INSERT INTO t9(rowid,a,b,c,d) VALUES(2,NULL,NULL,NULL,NULL);
+ INSERT INTO t9(rowid,a,b,c,d) VALUES(3,NULL,NULL,NULL,NULL);
+ INSERT INTO t9(rowid,a,b,c,d) VALUES(4,5,6,7,8);
+ PRAGMA integrity_check;
+} {ok}
+do_catchsql_test indexexpr1-910 {
+ INSERT INTO t9(a,b,c,d) VALUES(5,6,7,-8);
+} {1 {UNIQUE constraint failed: index 't9x1'}}
+
+# Test cases derived from a NEVER() maro failure discovered by
+# Jonathan Metzman using AFL
+#
+do_execsql_test indexexpr1-1000 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(a,b,t);
+ CREATE INDEX i ON t0(a in(0,1));
+ INSERT INTO t0 VALUES(0,1,2),(2,3,4),(5,6,7);
+ UPDATE t0 SET b=99 WHERE (a in(0,1))=0;
+ SELECT *, '|' FROM t0 ORDER BY +a;
+} {0 1 2 | 2 99 4 | 5 99 7 |}
+do_execsql_test indexexpr1-1010 {
+ UPDATE t0 SET b=88 WHERE (a in(0,1))=1;
+ SELECT *, '|' FROM t0 ORDER BY +a;
+} {0 88 2 | 2 99 4 | 5 99 7 |}
+
+# 2016-10-10
+# Make sure indexes on expressions skip over initial NULL values in the
+# index as they are suppose to do.
+# Ticket https://www.sqlite.org/src/tktview/4baa46491212947
+#
+do_execsql_test indexexpr1-1100 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(NULL),(1);
+ SELECT '1:', typeof(a), a FROM t1 WHERE a<10;
+ SELECT '2:', typeof(a), a FROM t1 WHERE a+0<10;
+ CREATE INDEX t1x1 ON t1(a);
+ CREATE INDEX t1x2 ON t1(a+0);
+ SELECT '3:', typeof(a), a FROM t1 WHERE a<10;
+ SELECT '4:', typeof(a), a FROM t1 WHERE a+0<10;
+} {1: integer 1 2: integer 1 3: integer 1 4: integer 1}
+
+do_execsql_test indexexpr1-1200 {
+ CREATE TABLE t10(a int, b int, c int, d int);
+ INSERT INTO t10(a, b, c, d) VALUES(0, 0, 2, 2);
+ INSERT INTO t10(a, b, c, d) VALUES(0, 0, 0, 0);
+ INSERT INTO t10(a, b, c, d) VALUES(0, 0, 1, 1);
+ INSERT INTO t10(a, b, c, d) VALUES(1, 1, 1, 1);
+ INSERT INTO t10(a, b, c, d) VALUES(1, 1, 0, 0);
+ INSERT INTO t10(a, b, c, d) VALUES(2, 2, 0, 0);
+
+ SELECT a+b, c+d FROM t10 ORDER BY a+b, c+d;
+} {
+ 0 0 0 2 0 4 2 0 2 2 4 0
+}
+do_execsql_test indexexpr1-1200.1 {
+ CREATE INDEX t10_ab ON t10(a+b);
+}
+do_execsql_test indexexpr1-1200.2 {
+ SELECT a+b, c+d FROM t10 ORDER BY a+b, c+d;
+} {
+ 0 0 0 2 0 4 2 0 2 2 4 0
+}
+do_execsql_test indexexpr1-1200.3 {
+ CREATE INDEX t10_abcd ON t10(a+b,c+d);
+}
+do_execsql_test indexexpr1-1200.4 {
+ SELECT a+b, c+d FROM t10 ORDER BY a+b, c+d;
+} {
+ 0 0 0 2 0 4 2 0 2 2 4 0
+}
+
+# Ticket https://www.sqlite.org/src/tktview/eb703ba7b50c1a
+# Incorrect result using an index on an expression with a collating function
+#
+do_execsql_test indexexpr1-1300.1 {
+ CREATE TABLE t1300(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1300 VALUES(1,'coffee'),(2,'COFFEE'),(3,'stress'),(4,'STRESS');
+ CREATE INDEX t1300bexpr ON t1300( substr(b,4) );
+ SELECT a FROM t1300 WHERE substr(b,4)='ess' COLLATE nocase ORDER BY +a;
+} {3 4}
+
+# Ticket https://sqlite.org/src/tktview/aa98619a
+# Assertion fault using an index on a constant
+#
+do_execsql_test indexexpr1-1400 {
+ CREATE TABLE t1400(x TEXT);
+ CREATE INDEX t1400x ON t1400(1); -- Index on a constant
+ SELECT 1 IN (SELECT 2) FROM t1400;
+} {}
+do_execsql_test indexexpr1-1410 {
+ INSERT INTO t1400 VALUES('a'),('b');
+ SELECT 1 IN (SELECT 2) FROM t1400;
+} {0 0}
+do_execsql_test indexexpr1-1420 {
+ SELECT 1 IN (SELECT 2 UNION ALL SELECT 1) FROM t1400;
+} {1 1}
+do_execsql_test indexexpr1-1430 {
+ DROP INDEX t1400x;
+ CREATE INDEX t1400x ON t1400(abs(15+3));
+ SELECT abs(15+3) IN (SELECT 17 UNION ALL SELECT 18) FROM t1;
+} {1 1}
+
+# 2018-01-02 ticket https://sqlite.org/src/info/dc3f932f5a147771
+# A REPLACE into a table that uses an index on an expression causes
+# an assertion fault. Problem discovered by OSSFuzz.
+#
+do_execsql_test indexexpr1-1500 {
+ CREATE TABLE t1500(a INT PRIMARY KEY, b INT UNIQUE);
+ CREATE INDEX t1500ab ON t1500(a*b);
+ INSERT INTO t1500(a,b) VALUES(1,2);
+ REPLACE INTO t1500(a,b) VALUES(1,3); -- formerly caused assertion fault
+ SELECT * FROM t1500;
+} {1 3}
+
+# 2018-01-03 OSSFuzz discovers another test case for the same problem
+# above.
+#
+do_execsql_test indexexpr-1510 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a PRIMARY KEY,b UNIQUE);
+ REPLACE INTO t1 VALUES(2, 1);
+ REPLACE INTO t1 SELECT 6,1;
+ CREATE INDEX t1aa ON t1(a-a);
+ REPLACE INTO t1 SELECT a, randomblob(a) FROM t1
+} {}
+
+# 2018-01-31 https://www.sqlite.org/src/tktview/343634942dd54ab57b702411
+# When an index on an expression depends on the string representation of
+# a numeric table column, trouble can arise since there are multiple
+# string that can map to the same numeric value. (Ex: 123, 0123, 000123).
+#
+do_execsql_test indexexpr-1600 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1 (a INTEGER, b);
+ CREATE INDEX idx1 ON t1 (lower(a));
+ INSERT INTO t1 VALUES('0001234',3);
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test indexexpr-1610 {
+ INSERT INTO t1 VALUES('1234',0),('001234',2),('01234',1);
+ SELECT b FROM t1 WHERE lower(a)='1234' ORDER BY +b;
+} {0 1 2 3}
+do_execsql_test indexexpr-1620 {
+ SELECT b FROM t1 WHERE lower(a)='01234' ORDER BY +b;
+} {}
+
+# 2019-08-09 https://www.sqlite.org/src/info/9080b6227fabb466
+# ExprImpliesExpr theorem prover bug:
+# "(NULL IS FALSE) IS FALSE" does not imply "NULL IS NULL"
+#
+do_execsql_test indexexpr-1700 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES (0);
+ CREATE INDEX i0 ON t0(NULL > c0) WHERE (NULL NOT NULL);
+ SELECT * FROM t0 WHERE ((NULL IS FALSE) IS FALSE);
+} {0}
+
+# 2019-09-02 https://www.sqlite.org/src/tktview/57af00b6642ecd6848
+# When the expression of an an index-on-expression references a
+# table column of type REAL that is actually holding an MEM_IntReal
+# value, be sure to use the REAL value and not the INT value when
+# computing the expression.
+#
+ifcapable like_match_blobs {
+ do_execsql_test indexexpr-1800 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 REAL, c1 TEXT);
+ CREATE INDEX i0 ON t0(+c0, c0);
+ INSERT INTO t0(c0) VALUES(0);
+ SELECT CAST(+ t0.c0 AS BLOB) LIKE 0 FROM t0;
+ } {0}
+ do_execsql_test indexexpr-1810 {
+ SELECT CAST(+ t0.c0 AS BLOB) LIKE '0.0' FROM t0;
+ } {1}
+ do_execsql_test indexexpr-1820 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x REAL);
+ CREATE INDEX t1x ON t1(x, +x);
+ INSERT INTO t1(x) VALUES(2);
+ SELECT +x FROM t1 WHERE x=2;
+ } {2.0}
+}
+
+# 2022-04-30 https://sqlite.org/forum/info/7efabf4b03328e57
+# Assertion fault during a DELETE INDEXED BY.
+#
+reset_db
+do_execsql_test indexexpr-1900 {
+ CREATE TABLE t1(x TEXT PRIMARY KEY, y TEXT, z INT);
+ INSERT INTO t1(x,y,z) VALUES('alpha','ALPHA',1),('bravo','charlie',1);
+ CREATE INDEX i1 ON t1(+y COLLATE NOCASE);
+ SELECT * FROM t1;
+} {alpha ALPHA 1 bravo charlie 1}
+do_execsql_test indexexpr-1910 {
+ DELETE FROM t1 INDEXED BY i1
+ WHERE x IS +y COLLATE NOCASE IN (SELECT z FROM t1)
+ RETURNING *;
+} {alpha ALPHA 1}
+do_execsql_test indexexpr-1920 {
+ SELECT * FROM t1;
+} {bravo charlie 1}
+
+finish_test
diff --git a/test/indexexpr2.test b/test/indexexpr2.test
new file mode 100644
index 0000000..8c1171e
--- /dev/null
+++ b/test/indexexpr2.test
@@ -0,0 +1,375 @@
+# 2017 April 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix indexexpr2
+
+do_execsql_test 1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+
+ CREATE INDEX i1 ON t1(b || 'x');
+}
+
+do_execsql_test 1.1 {
+ SELECT 'TWOX' == (b || 'x') FROM t1 WHERE (b || 'x')>'onex'
+} {0 0}
+
+do_execsql_test 1.2 {
+ SELECT 'TWOX' == (b || 'x') COLLATE nocase FROM t1 WHERE (b || 'x')>'onex'
+} {0 1}
+
+do_execsql_test 2.0 {
+ CREATE INDEX i2 ON t1(a+1);
+}
+
+do_execsql_test 2.1 {
+ SELECT a+1, quote(a+1) FROM t1 ORDER BY 1;
+} {2 2 3 3 4 4}
+
+#-------------------------------------------------------------------------
+# At one point SQLite was incorrectly using indexes on expressions to
+# optimize ORDER BY and GROUP BY clauses even when the collation
+# sequences of the query and index did not match (ticket [e20dd54ab0e4]).
+# The following tests - 3.* - attempt to verify that this has been fixed.
+#
+
+reset_db
+do_execsql_test 3.1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+} {}
+
+do_eqp_test 3.1.1 {
+ SELECT b FROM t1 WHERE b IS NOT NULL AND a IS NULL
+ GROUP BY b COLLATE nocase
+ ORDER BY b COLLATE nocase;
+} {/USE TEMP B-TREE FOR GROUP BY/}
+
+do_execsql_test 3.2.0 {
+ CREATE TABLE t2(x);
+
+ INSERT INTO t2 VALUES('.ABC');
+ INSERT INTO t2 VALUES('.abcd');
+ INSERT INTO t2 VALUES('.defg');
+ INSERT INTO t2 VALUES('.DEF');
+} {}
+
+do_execsql_test 3.2.1 {
+ SELECT x FROM t2 ORDER BY substr(x, 2) COLLATE nocase;
+} {
+ .ABC .abcd .DEF .defg
+}
+
+do_execsql_test 3.2.2 {
+ CREATE INDEX i2 ON t2( substr(x, 2) );
+ SELECT x FROM t2 ORDER BY substr(x, 2) COLLATE nocase;
+} {
+ .ABC .abcd .DEF .defg
+}
+
+do_execsql_test 3.3.0 {
+ CREATE TABLE t3(x);
+}
+
+ifcapable json1 {
+ do_eqp_test 3.3.1 {
+ SELECT json_extract(x, '$.b') FROM t2
+ WHERE json_extract(x, '$.b') IS NOT NULL AND json_extract(x, '$.a') IS NULL
+ GROUP BY json_extract(x, '$.b') COLLATE nocase
+ ORDER BY json_extract(x, '$.b') COLLATE nocase;
+ } [string map {"\n " \n} {
+ QUERY PLAN
+ |--SCAN t2
+ `--USE TEMP B-TREE FOR GROUP BY
+ }]
+
+ do_execsql_test 3.3.2 {
+ CREATE INDEX i3 ON t3(json_extract(x, '$.a'), json_extract(x, '$.b'));
+ } {}
+
+ do_eqp_test 3.3.3 {
+ SELECT json_extract(x, '$.b') FROM t3
+ WHERE json_extract(x, '$.b') IS NOT NULL AND json_extract(x, '$.a') IS NULL
+ GROUP BY json_extract(x, '$.b') COLLATE nocase
+ ORDER BY json_extract(x, '$.b') COLLATE nocase;
+ } [string map {"\n " \n} {
+ QUERY PLAN
+ |--SEARCH t3 USING INDEX i3 (<expr>=?)
+ `--USE TEMP B-TREE FOR GROUP BY
+ }]
+}
+
+do_execsql_test 3.4.0 {
+ CREATE TABLE t4(a, b);
+ INSERT INTO t4 VALUES('.ABC', 1);
+ INSERT INTO t4 VALUES('.abc', 2);
+ INSERT INTO t4 VALUES('.ABC', 3);
+ INSERT INTO t4 VALUES('.abc', 4);
+}
+
+do_execsql_test 3.4.1 {
+ SELECT * FROM t4
+ WHERE substr(a, 2) = 'abc' COLLATE NOCASE
+ ORDER BY substr(a, 2), b;
+} {
+ .ABC 1 .ABC 3 .abc 2 .abc 4
+}
+
+do_execsql_test 3.4.2 {
+ CREATE INDEX i4 ON t4( substr(a, 2) COLLATE NOCASE, b );
+ SELECT * FROM t4
+ WHERE substr(a, 2) = 'abc' COLLATE NOCASE
+ ORDER BY substr(a, 2), b;
+} {
+ .ABC 1 .ABC 3 .abc 2 .abc 4
+}
+
+do_execsql_test 3.4.3 {
+ DROP INDEX i4;
+ UPDATE t4 SET a = printf('%s%d',a,b);
+ SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE nocase;
+} {.ABC1 1 .abc2 2 .ABC3 3 .abc4 4}
+do_execsql_test 3.4.4 {
+ SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE binary;
+} {.ABC1 1 .ABC3 3 .abc2 2 .abc4 4}
+
+do_execsql_test 3.4.5 {
+ CREATE INDEX i4 ON t4( Substr(a,-2) COLLATE nocase );
+ SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE nocase;
+} {.ABC1 1 .abc2 2 .ABC3 3 .abc4 4}
+do_execsql_test 3.4.5eqp {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE nocase;
+} {/SCAN t4 USING INDEX i4/}
+do_execsql_test 3.4.6 {
+ SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE binary;
+} {.ABC1 1 .ABC3 3 .abc2 2 .abc4 4}
+
+# 2014-09-15: Verify that UPDATEs of columns not referenced by a
+# index on expression do not modify the index.
+#
+unset -nocomplain cnt
+set cnt 0
+proc refcnt {x} {
+ global cnt
+ incr cnt
+ return $x
+}
+db close
+sqlite3 db :memory:
+db function refcnt -deterministic refcnt
+do_test 4.100 {
+ db eval {
+ CREATE TABLE t1(a,b,c,d,e,f);
+ CREATE INDEX t1abc ON t1(refcnt(a+b+c));
+ }
+ set ::cnt
+} {0}
+do_test 4.110 {
+ db eval {INSERT INTO t1 VALUES(1,2,3,4,5,6);}
+ set ::cnt
+ # The refcnt() function is invoked once to compute the index value
+} {1}
+do_test 4.120 {
+ set ::cnt 0
+ db eval {UPDATE t1 SET b=b+1;}
+ set ::cnt
+ # The refcnt() function is invoked twice, once to remove the old index
+ # entry and a second time to insert the new one.
+} {2}
+do_test 4.130 {
+ set ::cnt 0
+ db eval {UPDATE t1 SET d=d+1;}
+ set ::cnt
+ # Refcnt() should not be invoked because that index does not change.
+} {0}
+
+# Additional test cases to show that UPDATE does not modify indexes that
+# do not involve unchanged columns.
+#
+ifcapable vtab {
+ load_static_extension db explain
+ do_execsql_test 4.200 {
+ CREATE TABLE t2(a,b,c,d,e,f);
+ INSERT INTO t2 VALUES(2,3,4,5,6,7);
+ CREATE INDEX t2abc ON t2(a+b+c);
+ CREATE INDEX t2cd ON t2(c*d);
+ CREATE INDEX t2def ON t2(d,e+25*f);
+ SELECT sqlite_master.name
+ FROM sqlite_master, explain('UPDATE t2 SET b=b+1')
+ WHERE explain.opcode LIKE 'Open%'
+ AND sqlite_master.rootpage=explain.p2
+ ORDER BY 1;
+ } {t2 t2abc}
+ do_execsql_test 4.210 {
+ SELECT sqlite_master.name
+ FROM sqlite_master, explain('UPDATE t2 SET c=c+1')
+ WHERE explain.opcode LIKE 'Open%'
+ AND sqlite_master.rootpage=explain.p2
+ ORDER BY 1;
+ } {t2 t2abc t2cd}
+ do_execsql_test 4.220 {
+ SELECT sqlite_master.name
+ FROM sqlite_master, explain('UPDATE t2 SET c=c+1, f=NULL')
+ WHERE explain.opcode LIKE 'Open%'
+ AND sqlite_master.rootpage=explain.p2
+ ORDER BY 1;
+ } {t2 t2abc t2cd t2def}
+}
+
+#-------------------------------------------------------------------------
+# Test that ticket [d96eba87] has been fixed.
+#
+do_execsql_test 5.0 {
+ CREATE TABLE t5(a INTEGER, b INTEGER);
+ INSERT INTO t5 VALUES(2, 4), (3, 9);
+}
+do_execsql_test 5.1 {
+ SELECT * FROM t5 WHERE abs(a)=2 or abs(b)=9;
+} {2 4 3 9}
+do_execsql_test 5.2 {
+ CREATE INDEX t5a ON t5( abs(a) );
+ CREATE INDEX t5b ON t5( abs(b) );
+}
+do_execsql_test 5.4 {
+ SELECT * FROM t5 WHERE abs(a)=2 or abs(b)=9;
+} {2 4 3 9}
+
+#-------------------------------------------------------------------------
+do_execsql_test 6.0 {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO x1 VALUES
+ (1, 123), (2, '123'), (3, '123abc'), (4, 123.0), (5, 1234);
+}
+
+do_execsql_test 6.1.1 {
+ SELECT a, b FROM x1 WHERE CAST(b AS INTEGER) = 123;
+} {1 123 2 123 3 123abc 4 123.0}
+do_execsql_test 6.1.2 {
+ CREATE INDEX x1i ON x1( CAST(b AS INTEGER) );
+ SELECT a, b FROM x1 WHERE CAST(b AS INTEGER) = 123;
+} {1 123 2 123 3 123abc 4 123.0}
+do_eqp_test 6.1.3 {
+ SELECT a, b FROM x1 WHERE CAST(b AS INTEGER) = 123;
+} {SEARCH x1 USING INDEX x1i (<expr>=?)}
+
+do_execsql_test 6.2.1 {
+ SELECT a, b FROM x1 WHERE CAST(b AS TEXT) = 123;
+} {1 123 2 123}
+do_execsql_test 6.2.2 {
+ CREATE INDEX x1i2 ON x1( CAST(b AS TEXT) );
+ SELECT a, b FROM x1 WHERE CAST(b AS TEXT) = 123;
+} {1 123 2 123}
+do_eqp_test 6.2.3 {
+ SELECT a, b FROM x1 WHERE CAST(b AS TEXT) = 123;
+} {SEARCH x1 USING INDEX x1i2 (<expr>=?)}
+
+do_execsql_test 7.0 {
+ CREATE TABLE IF NOT EXISTS t0(c0);
+ INSERT INTO t0(c0) VALUES (-9223372036854775808);
+ BEGIN;
+}
+do_catchsql_test 7.1 {
+ CREATE INDEX i0 ON t0(ABS(c0));
+} {1 {integer overflow}}
+do_execsql_test 7.2 {
+ COMMIT;
+ SELECT sql FROM sqlite_master WHERE tbl_name = 't0';
+ CREATE INDEX i0 ON t0(c0);
+} {{CREATE TABLE t0(c0)}}
+do_execsql_test 7.3 {
+ REINDEX;
+} {}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE t0(c0);
+ CREATE INDEX i0 ON t0(c0) WHERE c0 NOT NULL;
+ INSERT INTO t0(c0) VALUES (NULL);
+}
+
+do_execsql_test 8.1.1 {
+ SELECT * FROM t0 WHERE ~('' BETWEEN t0.c0 AND TRUE);
+} {{}}
+do_execsql_test 8.1.2 {
+ SELECT ~('' BETWEEN t0.c0 AND TRUE) FROM t0;
+} {-1}
+
+foreach {tn expr} {
+ 1 " 0 == (34 BETWEEN c0 AND 33)"
+ 2 " 1 != (34 BETWEEN c0 AND 33)"
+ 3 "-1 < (34 BETWEEN c0 AND 33)"
+ 4 "-1 <= (34 BETWEEN c0 AND 33)"
+ 5 " 1 > (34 BETWEEN c0 AND 33)"
+ 6 " 1 >= (34 BETWEEN c0 AND 33)"
+ 7 " 1 - (34 BETWEEN c0 AND 33)"
+ 8 "-1 + (34 BETWEEN c0 AND 33)"
+ 9 " 1 | (34 BETWEEN c0 AND 33)"
+ 10 " 1 << (34 BETWEEN c0 AND 33)"
+ 11 " 1 >> (34 BETWEEN c0 AND 33)"
+ 12 " 1 || (34 BETWEEN c0 AND 33)"
+} {
+ do_execsql_test 8.3.$tn.1 "SELECT * FROM t0 WHERE $expr ORDER BY c0" { {} }
+ do_execsql_test 8.3.$tn.2 "SELECT ($expr) IS TRUE FROM t0" { 1 }
+}
+
+do_execsql_test 8.4 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2), (3, 4);
+ CREATE TABLE t2(x, y);
+}
+
+foreach {tn expr} {
+ 1 " 0 == (a=0 AND y=1)"
+ 2 " 1 != (a=0 AND y=1)"
+ 3 "-1 < (a=0 AND y=1)"
+ 4 "-1 <= (a=0 AND y=1)"
+ 5 " 1 > (a=0 AND y=1)"
+ 6 " 1 >= (a=0 AND y=1)"
+ 7 " 1 - (a=0 AND y=1)"
+ 8 "-1 + (a=0 AND y=1)"
+ 9 " 1 | (a=0 AND y=1)"
+ 10 "1 << (a=0 AND y=1)"
+ 11 "1 >> (a=0 AND y=1)"
+ 12 "1 || (a=0 AND y=1)"
+
+ 13 " 0 == (10 BETWEEN y AND b)"
+ 14 " 1 != (10 BETWEEN y AND b)"
+ 15 "-1 < (10 BETWEEN y AND b)"
+ 16 "-1 <= (10 BETWEEN y AND b)"
+ 17 " 1 > (10 BETWEEN y AND b)"
+ 18 " 1 >= (10 BETWEEN y AND b)"
+ 19 " 1 - (10 BETWEEN y AND b)"
+ 20 "-1 + (10 BETWEEN y AND b)"
+ 21 " 1 | (10 BETWEEN y AND b)"
+ 22 " 1 << (10 BETWEEN y AND b)"
+ 23 " 1 >> (10 BETWEEN y AND b)"
+ 24 " 1 || (10 BETWEEN y AND b)"
+
+ 25 " 1 || (10 BETWEEN y AND b)"
+} {
+ do_execsql_test 8.5.$tn.1 "
+ SELECT * FROM t1 LEFT JOIN t2 WHERE $expr
+ " {1 2 {} {} 3 4 {} {}}
+
+ do_execsql_test 8.5.$tn.2 "
+ SELECT ($expr) IS TRUE FROM t1 LEFT JOIN t2
+ " {1 1}
+}
+
+finish_test
diff --git a/test/indexfault.test b/test/indexfault.test
new file mode 100644
index 0000000..0e65179
--- /dev/null
+++ b/test/indexfault.test
@@ -0,0 +1,352 @@
+# 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 {}}
+}
+
+do_faultsim_test 5 -prep {
+ reset_db
+} -body {
+ execsql {
+ CREATE TABLE reallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongname(a PRIMARY KEY) WITHOUT ROWID;
+ }
+} -test {
+ 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..51e6226
--- /dev/null
+++ b/test/insert.test
@@ -0,0 +1,603 @@
+# 2001-09-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.
+#
+
+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}
+
+# Multiple VALUES clauses
+#
+ifcapable compound {
+ do_test insert-10.1 {
+ execsql {
+ CREATE TABLE t10(a,b,c);
+ INSERT INTO t10 VALUES(1,2,3), (4,5,6), (7,8,9);
+ SELECT * FROM t10;
+ }
+ } {1 2 3 4 5 6 7 8 9}
+ do_test insert-10.2 {
+ catchsql {
+ INSERT INTO t10 VALUES(11,12,13), (14,15), (16,17,28);
+ }
+ } {1 {all VALUES must have the same number of terms}}
+}
+
+# Need for the OP_SoftNull opcode
+#
+do_execsql_test insert-11.1 {
+ CREATE TABLE t11a AS SELECT '123456789' AS x;
+ CREATE TABLE t11b (a INTEGER PRIMARY KEY, b, c);
+ INSERT INTO t11b SELECT x, x, x FROM t11a;
+ SELECT quote(a), quote(b), quote(c) FROM t11b;
+} {123456789 '123456789' '123456789'}
+
+
+# More columns of input than there are columns in the table.
+# Ticket http://www.sqlite.org/src/info/e9654505cfda9361
+#
+do_execsql_test insert-12.1 {
+ CREATE TABLE t12a(a,b,c,d,e,f,g);
+ INSERT INTO t12a VALUES(101,102,103,104,105,106,107);
+ CREATE TABLE t12b(x);
+ INSERT INTO t12b(x,rowid,x,x,x,x,x) SELECT * FROM t12a;
+ SELECT rowid, x FROM t12b;
+} {102 101}
+do_execsql_test insert-12.2 {
+ CREATE TABLE tab1( value INTEGER);
+ INSERT INTO tab1 (value, _rowid_) values( 11, 1);
+ INSERT INTO tab1 (value, _rowid_) SELECT 22,999;
+ SELECT * FROM tab1;
+} {11 22}
+do_execsql_test insert-12.3 {
+ CREATE TABLE t12c(a, b DEFAULT 'xyzzy', c);
+ INSERT INTO t12c(a, rowid, c) SELECT 'one', 999, 'two';
+ SELECT * FROM t12c;
+} {one xyzzy two}
+
+# 2018-06-11. From OSSFuzz. A column cache malfunction in
+# the constraint checking on an index of expressions causes
+# an assertion fault in a REPLACE. Ticket
+# https://www.sqlite.org/src/info/c2432ef9089ee73b
+#
+do_execsql_test insert-13.1 {
+ DROP TABLE IF EXISTS t13;
+ CREATE TABLE t13(a INTEGER PRIMARY KEY,b UNIQUE);
+ CREATE INDEX t13x1 ON t13(-b=b);
+ INSERT INTO t13 VALUES(1,5),(6,2);
+ REPLACE INTO t13 SELECT b,0 FROM t13;
+ SELECT * FROM t13 ORDER BY +b;
+} {2 0 6 2 1 5}
+
+# 2019-01-17. From the chromium fuzzer.
+#
+do_execsql_test insert-14.1 {
+ DROP TABLE IF EXISTS t14;
+ CREATE TABLE t14(x INTEGER PRIMARY KEY);
+ INSERT INTO t14 VALUES(CASE WHEN 1 THEN null END);
+ SELECT x FROM t14;
+} {1}
+
+integrity_check insert-14.2
+
+# 2019-08-12.
+#
+do_execsql_test insert-15.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE INDEX i1 ON t1(b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES(4, randomblob(31000));
+ INSERT INTO t2 VALUES(4, randomblob(32000));
+ INSERT INTO t2 VALUES(4, randomblob(33000));
+ REPLACE INTO t1 SELECT a, b FROM t2;
+ SELECT a, length(b) FROM t1;
+} {4 33000}
+
+# 2019-10-16
+# ticket https://www.sqlite.org/src/info/a8a4847a2d96f5de
+# On a REPLACE INTO, if an AFTER trigger adds back the conflicting
+# row, you can end up with the wrong number of rows in an index.
+#
+db close
+sqlite3 db :memory:
+do_catchsql_test insert-16.1 {
+ PRAGMA recursive_triggers = true;
+ CREATE TABLE t0(c0,c1);
+ CREATE UNIQUE INDEX i0 ON t0(c0);
+ INSERT INTO t0(c0,c1) VALUES(123,1);
+ CREATE TRIGGER tr0 AFTER DELETE ON t0
+ BEGIN
+ INSERT INTO t0 VALUES(123,2);
+ END;
+ REPLACE INTO t0(c0,c1) VALUES(123,3);
+} {1 {UNIQUE constraint failed: t0.c0}}
+do_execsql_test insert-16.2 {
+ SELECT * FROM t0;
+} {123 1}
+integrity_check insert-16.3
+do_catchsql_test insert-16.4 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE INDEX t1b ON t1(b);
+ INSERT INTO t1 VALUES(1, 'one');
+ CREATE TRIGGER tr3 AFTER DELETE ON t1 BEGIN
+ INSERT INTO t1 VALUES(1, 'three');
+ END;
+ REPLACE INTO t1 VALUES(1, 'two');
+} {1 {UNIQUE constraint failed: t1.a}}
+integrity_check insert-16.5
+do_catchsql_test insert-16.6 {
+ PRAGMA foreign_keys = 1;
+ CREATE TABLE p1(a, b UNIQUE);
+ CREATE TABLE c1(c, d REFERENCES p1(b) ON DELETE CASCADE);
+ CREATE TRIGGER tr6 AFTER DELETE ON c1 BEGIN
+ INSERT INTO p1 VALUES(4, 1);
+ END;
+ INSERT INTO p1 VALUES(1, 1);
+ INSERT INTO c1 VALUES(2, 1);
+ REPLACE INTO p1 VALUES(3, 1);2
+} {1 {UNIQUE constraint failed: p1.b}}
+integrity_check insert-16.7
+
+# 2019-10-25 ticket c1e19e12046d23fe
+do_catchsql_test insert-17.1 {
+ PRAGMA temp.recursive_triggers = true;
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(aa, bb);
+ CREATE UNIQUE INDEX t0bb ON t0(bb);
+ CREATE TRIGGER "r17.1" BEFORE DELETE ON t0
+ BEGIN INSERT INTO t0(aa,bb) VALUES(99,1);
+ END;
+ INSERT INTO t0(aa,bb) VALUES(10,20);
+ REPLACE INTO t0(aa,bb) VALUES(30,20);
+} {1 {UNIQUE constraint failed: t0.rowid}}
+integrity_check insert-17.2
+do_catchsql_test insert-17.3 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b UNIQUE, c UNIQUE);
+ INSERT INTO t1(a,b,c) VALUES(1,1,1),(2,2,2),(3,3,3),(4,4,4);
+ CREATE TRIGGER "r17.3" AFTER DELETE ON t1 WHEN OLD.c<>3 BEGIN
+ INSERT INTO t1(rowid,a,b,c) VALUES(100,100,100,3);
+ END;
+ REPLACE INTO t1(rowid,a,b,c) VALUES(200,1,2,3);
+} {1 {UNIQUE constraint failed: t1.c}}
+integrity_check insert-17.4
+do_execsql_test insert-17.5 {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ CREATE UNIQUE INDEX t2b ON t2(b);
+ INSERT INTO t2(a,b) VALUES(1,1),(2,2),(3,3),(4,4);
+ CREATE TABLE fire(x);
+ CREATE TRIGGER t2r1 AFTER DELETE ON t2 BEGIN
+ INSERT INTO fire VALUES(old.a);
+ END;
+ UPDATE OR REPLACE t2 SET a=4, b=3 WHERE a=1;
+ SELECT *, 'x' FROM t2 ORDER BY a;
+} {2 2 x 4 3 x}
+do_execsql_test insert-17.6 {
+ SELECT x FROM fire ORDER BY x;
+} {3 4}
+do_execsql_test insert-17.7 {
+ DELETE FROM t2;
+ DELETE FROM fire;
+ INSERT INTO t2(a,b) VALUES(1,1),(2,2),(3,3),(4,4);
+ UPDATE OR REPLACE t2 SET a=1, b=3 WHERE a=1;
+ SELECT *, 'x' FROM t2 ORDER BY a;
+} {1 3 x 2 2 x 4 4 x}
+do_execsql_test insert-17.8 {
+ SELECT x FROM fire ORDER BY x;
+} {3}
+do_execsql_test insert-17.10 {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b INT, c INT, d INT);
+ CREATE UNIQUE INDEX t3bpi ON t3(b) WHERE c<=d;
+ CREATE UNIQUE INDEX t3d ON t3(d);
+ INSERT INTO t3(a,b,c,d) VALUES(1,1,1,1),(2,1,3,2),(3,4,5,6);
+ CREATE TRIGGER t3r1 AFTER DELETE ON t3 BEGIN
+ SELECT 'hi';
+ END;
+ REPLACE INTO t3(a,b,c,d) VALUES(4,4,8,9);
+} {}
+do_execsql_test insert-17.11 {
+ SELECT *, 'x' FROM t3 ORDER BY a;
+} {1 1 1 1 x 2 1 3 2 x 4 4 8 9 x}
+do_execsql_test insert-17.12 {
+ REPLACE INTO t3(a,b,c,d) VALUES(5,1,11,2);
+ SELECT *, 'x' FROM t3 ORDER BY a;
+} {1 1 1 1 x 4 4 8 9 x 5 1 11 2 x}
+
+do_execsql_test insert-17.13 {
+ DELETE FROM t3;
+ INSERT INTO t3(a,b,c,d) VALUES(1,1,1,1),(2,1,3,2),(3,4,5,6);
+ DROP TRIGGER t3r1;
+ CREATE TRIGGER t3r1 AFTER DELETE ON t3 BEGIN
+ INSERT INTO t3(b,c,d) VALUES(old.b,old.c,old.d);
+ END;
+} {}
+do_catchsql_test insert-17.14 {
+ REPLACE INTO t3(a,b,c,d) VALUES(4,4,8,9);
+} {1 {UNIQUE constraint failed: t3.b}}
+do_catchsql_test insert-17.15 {
+ REPLACE INTO t3(a,b,c,d) VALUES(5,1,11,2);
+} {1 {UNIQUE constraint failed: t3.d}}
+
+
+finish_test
diff --git a/test/insert2.test b/test/insert2.test
new file mode 100644
index 0000000..977fbc5
--- /dev/null
+++ b/test/insert2.test
@@ -0,0 +1,298 @@
+# 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
+set testprefix insert2
+
+# 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}
+}
+
+do_execsql_test 6.0 {
+ CREATE TABLE t5(a, b, c DEFAULT 'c', d);
+}
+do_execsql_test 6.1 {
+ INSERT INTO t5(a) SELECT 456 UNION ALL SELECT 123 ORDER BY 1;
+ SELECT * FROM t5 ORDER BY rowid;
+} {123 {} c {} 456 {} c {}}
+
+ifcapable fts3 {
+ do_execsql_test 6.2 {
+ CREATE VIRTUAL TABLE t0 USING fts4(a);
+ }
+ do_execsql_test 6.3 {
+ INSERT INTO t0 SELECT 0 UNION SELECT 0 AS 'x' ORDER BY x;
+ SELECT * FROM t0;
+ } {0}
+}
+
+
+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..8bd65a0
--- /dev/null
+++ b/test/insert4.test
@@ -0,0 +1,628 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix insert4
+
+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.
+#
+sqlite3_db_config db LEGACY_FILE_FORMAT 0
+execsql {
+ 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 {CHECK constraint failed: b>a}}
+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 {CHECK constraint failed: b>a}}
+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 {CHECK constraint failed: b>a}}
+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 a, b 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 {CHECK constraint failed: x<>'abc' COLLATE nocase}}
+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 {CHECK constraint failed: x COLLATE nocase <>'abc'}}
+
+# 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}
+}
+
+# Ticket [676bc02b87176125635cb174d110b431581912bb]
+# Make sure INTEGER PRIMARY KEY ON CONFLICT ... works with the xfer
+# optimization.
+#
+do_test insert4-8.1 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT REPLACE, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT REPLACE, y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(1,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {1 3}
+do_test insert4-8.2 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT REPLACE, b);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(1,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {1 3}
+do_test insert4-8.3 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT IGNORE, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT IGNORE, y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(1,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {1 2}
+do_test insert4-8.4 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT IGNORE, b);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(1,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {1 2}
+do_test insert4-8.5 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT FAIL, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT FAIL, y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(-99,100);
+ INSERT INTO t2 VALUES(1,3);
+ SELECT * FROM t1;
+ }
+ catchsql {
+ INSERT INTO t1 SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t1.a}}
+do_test insert4-8.6 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {-99 100 1 2}
+do_test insert4-8.7 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT ABORT, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ABORT, y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(-99,100);
+ INSERT INTO t2 VALUES(1,3);
+ SELECT * FROM t1;
+ }
+ catchsql {
+ INSERT INTO t1 SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t1.a}}
+do_test insert4-8.8 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {1 2}
+do_test insert4-8.9 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(-99,100);
+ INSERT INTO t2 VALUES(1,3);
+ SELECT * FROM t1;
+ }
+ catchsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(2,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ }
+} {1 {UNIQUE constraint failed: t1.a}}
+do_test insert4-8.10 {
+ catchsql {COMMIT}
+} {1 {cannot commit - no transaction is active}}
+do_test insert4-8.11 {
+ execsql {
+ SELECT * FROM t1;
+ }
+} {1 2}
+
+do_test insert4-8.21 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT REPLACE, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT REPLACE, y);
+ INSERT INTO t2 VALUES(1,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {1 3}
+do_test insert4-8.22 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT IGNORE, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT IGNORE, y);
+ INSERT INTO t2 VALUES(1,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {1 3}
+do_test insert4-8.23 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT ABORT, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ABORT, y);
+ INSERT INTO t2 VALUES(1,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {1 3}
+do_test insert4-8.24 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT FAIL, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT FAIL, y);
+ INSERT INTO t2 VALUES(1,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {1 3}
+do_test insert4-8.25 {
+ execsql {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, y);
+ INSERT INTO t2 VALUES(1,3);
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+ }
+} {1 3}
+
+do_catchsql_test insert4-9.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(5 COLLATE xyzzy) UNION SELECT 0;
+} {1 {no such collation sequence: xyzzy}}
+
+#-------------------------------------------------------------------------
+# Check that running an integrity-check does not disable the xfer
+# optimization for tables with CHECK constraints.
+#
+do_execsql_test 10.1 {
+ CREATE TABLE t8(
+ rid INTEGER,
+ pid INTEGER,
+ mid INTEGER,
+ px INTEGER DEFAULT(0) CHECK(px IN(0, 1))
+ );
+ CREATE TEMP TABLE x(
+ rid INTEGER,
+ pid INTEGER,
+ mid INTEGER,
+ px INTEGER DEFAULT(0) CHECK(px IN(0, 1))
+ );
+}
+do_test 10.2 {
+ set sqlite3_xferopt_count 0
+ execsql { INSERT INTO x SELECT * FROM t8 }
+ set sqlite3_xferopt_count
+} {1}
+
+do_test 10.3 {
+ execsql { PRAGMA integrity_check }
+ set sqlite3_xferopt_count 0
+ execsql { INSERT INTO x SELECT * FROM t8 }
+ set sqlite3_xferopt_count
+} {1}
+
+do_test 10.4 {
+ execsql { PRAGMA integrity_check }
+ set sqlite3_xferopt_count 0
+ execsql { INSERT INTO x SELECT * FROM t8 RETURNING * }
+ set sqlite3_xferopt_count
+} {0}
+
+#-------------------------------------------------------------------------
+# xfer transfer between tables where the source has an empty partial index.
+#
+do_execsql_test 11.0 {
+ CREATE TABLE t9(a, b, c);
+ CREATE INDEX t9a ON t9(a);
+ CREATE INDEX t9b ON t9(b) WHERE c=0;
+
+ INSERT INTO t9 VALUES(1, 1, 1);
+ INSERT INTO t9 VALUES(2, 2, 2);
+ INSERT INTO t9 VALUES(3, 3, 3);
+
+ CREATE TABLE t10(a, b, c);
+ CREATE INDEX t10a ON t10(a);
+ CREATE INDEX t10b ON t10(b) WHERE c=0;
+
+ INSERT INTO t10 SELECT * FROM t9;
+ SELECT * FROM t10;
+ PRAGMA integrity_check;
+} {1 1 1 2 2 2 3 3 3 ok}
+
+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/insertfault.test b/test/insertfault.test
new file mode 100644
index 0000000..53849a1
--- /dev/null
+++ b/test/insertfault.test
@@ -0,0 +1,36 @@
+# 2019-01-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 cases for INSERT
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix insertfault
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d DEFAULT true);
+ INSERT INTO t1 DEFAULT VALUES;
+ SELECT * FROM t1;
+} {1 {} {} 1}
+faultsim_save_and_close
+
+breakpoint
+do_faultsim_test 1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+ db eval { SELECT * FROM sqlite_master }
+} -body {
+ execsql { SELECT * FROM t1 }
+} -test {
+ faultsim_test_result {0 {1 {} {} 1}}
+}
+
+
+finish_test
diff --git a/test/instr.test b/test/instr.test
new file mode 100644
index 0000000..d23d66c
--- /dev/null
+++ b/test/instr.test
@@ -0,0 +1,281 @@
+# 2012 October 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 built-in INSTR() functions.
+#
+# EVIDENCE-OF: R-27549-59611 The instr(X,Y) function finds the first
+# occurrence of string Y within string X and returns the number of prior
+# characters plus 1, or 0 if Y is nowhere found within X.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table to work with.
+#
+do_test instr-1.1 {
+ db eval {SELECT instr('abcdefg','a');}
+} {1}
+do_test instr-1.2 {
+ db eval {SELECT instr('abcdefg','b');}
+} {2}
+do_test instr-1.3 {
+ db eval {SELECT instr('abcdefg','c');}
+} {3}
+do_test instr-1.4 {
+ db eval {SELECT instr('abcdefg','d');}
+} {4}
+do_test instr-1.5 {
+ db eval {SELECT instr('abcdefg','e');}
+} {5}
+do_test instr-1.6 {
+ db eval {SELECT instr('abcdefg','f');}
+} {6}
+do_test instr-1.7 {
+ db eval {SELECT instr('abcdefg','g');}
+} {7}
+do_test instr-1.8 {
+ db eval {SELECT instr('abcdefg','h');}
+} {0}
+do_test instr-1.9 {
+ db eval {SELECT instr('abcdefg','abcdefg');}
+} {1}
+do_test instr-1.10 {
+ db eval {SELECT instr('abcdefg','abcdefgh');}
+} {0}
+do_test instr-1.11 {
+ db eval {SELECT instr('abcdefg','bcdefg');}
+} {2}
+do_test instr-1.12 {
+ db eval {SELECT instr('abcdefg','bcdefgh');}
+} {0}
+do_test instr-1.13 {
+ db eval {SELECT instr('abcdefg','cdefg');}
+} {3}
+do_test instr-1.14 {
+ db eval {SELECT instr('abcdefg','cdefgh');}
+} {0}
+do_test instr-1.15 {
+ db eval {SELECT instr('abcdefg','defg');}
+} {4}
+do_test instr-1.16 {
+ db eval {SELECT instr('abcdefg','defgh');}
+} {0}
+do_test instr-1.17 {
+ db eval {SELECT instr('abcdefg','efg');}
+} {5}
+do_test instr-1.18 {
+ db eval {SELECT instr('abcdefg','efgh');}
+} {0}
+do_test instr-1.19 {
+ db eval {SELECT instr('abcdefg','fg');}
+} {6}
+do_test instr-1.20 {
+ db eval {SELECT instr('abcdefg','fgh');}
+} {0}
+do_test instr-1.21 {
+ db eval {SELECT coalesce(instr('abcdefg',NULL),'nil');}
+} {nil}
+do_test instr-1.22 {
+ db eval {SELECT coalesce(instr(NULL,'x'),'nil');}
+} {nil}
+do_test instr-1.23 {
+ db eval {SELECT instr(12345,34);}
+} {3}
+do_test instr-1.24 {
+ db eval {SELECT instr(123456.78,34);}
+} {3}
+do_test instr-1.25 {
+ db eval {SELECT instr(123456.78,x'3334');}
+} {3}
+do_test instr-1.26 {
+ db eval {SELECT instr('äbcdefg','efg');}
+} {5}
+do_test instr-1.27 {
+ db eval {SELECT instr('€xyzzy','xyz');}
+} {2}
+do_test instr-1.28 {
+ db eval {SELECT instr('abc€xyzzy','xyz');}
+} {5}
+do_test instr-1.29 {
+ db eval {SELECT instr('abc€xyzzy','€xyz');}
+} {4}
+do_test instr-1.30 {
+ db eval {SELECT instr('abc€xyzzy','c€xyz');}
+} {3}
+do_test instr-1.31 {
+ db eval {SELECT instr(x'0102030405',x'01');}
+} {1}
+do_test instr-1.32 {
+ db eval {SELECT instr(x'0102030405',x'02');}
+} {2}
+do_test instr-1.33 {
+ db eval {SELECT instr(x'0102030405',x'03');}
+} {3}
+do_test instr-1.34 {
+ db eval {SELECT instr(x'0102030405',x'04');}
+} {4}
+do_test instr-1.35 {
+ db eval {SELECT instr(x'0102030405',x'05');}
+} {5}
+do_test instr-1.36 {
+ db eval {SELECT instr(x'0102030405',x'06');}
+} {0}
+do_test instr-1.37 {
+ db eval {SELECT instr(x'0102030405',x'0102030405');}
+} {1}
+do_test instr-1.38 {
+ db eval {SELECT instr(x'0102030405',x'02030405');}
+} {2}
+do_test instr-1.39 {
+ db eval {SELECT instr(x'0102030405',x'030405');}
+} {3}
+do_test instr-1.40 {
+ db eval {SELECT instr(x'0102030405',x'0405');}
+} {4}
+do_test instr-1.41 {
+ db eval {SELECT instr(x'0102030405',x'0506');}
+} {0}
+do_test instr-1.42 {
+ db eval {SELECT instr(x'0102030405',x'');}
+} {1}
+do_test instr-1.43 {
+ db eval {SELECT instr(x'',x'');}
+} {1}
+do_test instr-1.44 {
+ db eval {SELECT instr('','');}
+} {1}
+do_test instr-1.45 {
+ db eval {SELECT instr('abcdefg','');}
+} {1}
+unset -nocomplain longstr
+set longstr abcdefghijklmonpqrstuvwxyz
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+append longstr $longstr
+# puts [string length $longstr]
+append longstr Xabcde
+do_test instr-1.46 {
+ db eval {SELECT instr($longstr,'X');}
+} {106497}
+do_test instr-1.47 {
+ db eval {SELECT instr($longstr,'Y');}
+} {0}
+do_test instr-1.48 {
+ db eval {SELECT instr($longstr,'Xa');}
+} {106497}
+do_test instr-1.49 {
+ db eval {SELECT instr($longstr,'zXa');}
+} {106496}
+set longstr [string map {a ä} $longstr]
+do_test instr-1.50 {
+ db eval {SELECT instr($longstr,'X');}
+} {106497}
+do_test instr-1.51 {
+ db eval {SELECT instr($longstr,'Y');}
+} {0}
+do_test instr-1.52 {
+ db eval {SELECT instr($longstr,'Xä');}
+} {106497}
+do_test instr-1.53 {
+ db eval {SELECT instr($longstr,'zXä');}
+} {106496}
+do_test instr-1.54 {
+ db eval {SELECT instr(x'78c3a4e282ac79','x');}
+} {1}
+do_test instr-1.55 {
+ db eval {SELECT instr(x'78c3a4e282ac79','y');}
+} {4}
+
+# EVIDENCE-OF: R-46421-32541 Or, if X and Y are both BLOBs, then
+# instr(X,Y) returns one more than the number bytes prior to the first
+# occurrence of Y, or 0 if Y does not occur anywhere within X.
+#
+do_test instr-1.56.1 {
+ db eval {SELECT instr(x'78c3a4e282ac79',x'79');}
+} {7}
+do_test instr-1.56.2 {
+ db eval {SELECT instr(x'78c3a4e282ac79',x'7a');}
+} {0}
+do_test instr-1.56.3 {
+ db eval {SELECT instr(x'78c3a4e282ac79',x'78');}
+} {1}
+do_test instr-1.56.3 {
+ db eval {SELECT instr(x'78c3a4e282ac79',x'a4');}
+} {3}
+
+# EVIDENCE-OF: R-17329-35644 If both arguments X and Y to instr(X,Y) are
+# non-NULL and are not BLOBs then both are interpreted as strings.
+#
+do_test instr-1.57.1 {
+ db eval {SELECT instr('xä€y',x'79');}
+} {4}
+do_test instr-1.57.2 {
+ db eval {SELECT instr('xä€y',x'a4');}
+} {0}
+do_test instr-1.57.3 {
+ db eval {SELECT instr(x'78c3a4e282ac79','y');}
+} {4}
+
+# EVIDENCE-OF: R-14708-27487 If either X or Y are NULL in instr(X,Y)
+# then the result is NULL.
+#
+do_execsql_test instr-1.60 {
+ SELECT coalesce(instr(NULL,'abc'), 999);
+} {999}
+do_execsql_test instr-1.61 {
+ SELECT coalesce(instr('abc',NULL), 999);
+} {999}
+do_execsql_test instr-1.62 {
+ SELECT coalesce(instr(NULL,NULL), 999);
+} {999}
+
+do_execsql_test instr-1.63 {
+ SELECT instr(X'', 'abc')
+} 0
+do_execsql_test instr-1.64 {
+ CREATE TABLE x1(a, b);
+ INSERT INTO x1 VALUES(X'', 'abc');
+ SELECT instr(a, b) FROM x1;
+} 0
+
+# 2019-09-16 ticket https://www.sqlite.org/src/info/587791f92620090e
+#
+do_execsql_test instr-2.0 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 PRIMARY KEY, c1);
+ INSERT INTO t0(c0) VALUES (x'bb'), (0);
+ SELECT COUNT(*) FROM t0 WHERE INSTR(x'aabb', t0.c0) ORDER BY t0.c0, t0.c1;
+} {1}
+do_execsql_test instr-2.1 {
+ SELECT quote(c0) FROM t0 WHERE INSTR(x'aabb', t0.c0) ORDER BY t0.c0, t0.c1;
+} {X'BB'}
+do_execsql_test instr-2.2 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES('text'),(x'bb');
+ SELECT quote(x) FROM t1 WHERE instr(x'aabb',x);
+} {X'BB'}
+do_execsql_test instr-2.3 {
+ SELECT quote(x) FROM t1 WHERE x>'zzz' AND instr(x'aabb',x);
+} {X'BB'}
+
+finish_test
diff --git a/test/instrfault.test b/test/instrfault.test
new file mode 100644
index 0000000..848e46e
--- /dev/null
+++ b/test/instrfault.test
@@ -0,0 +1,92 @@
+# 2016 November 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 OOM error handling within the built-in
+# INSTR() function.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix instrfault
+
+# Use big NEEDLE and HAYSTACK strings. Strings so large they cannot
+# use lookaside buffers.
+#
+set ::NEEDLE [string repeat "abcdefghijklmnopqrstuvwxyz" 10]
+set ::HAYSTACK "[string repeat 123 10]$NEEDLE[string repeat 456 10]"
+
+foreach {enc} {
+ utf8
+ utf16
+} {
+ reset_db
+ sqlite3_db_config_lookaside db 0 0 0
+
+ execsql "PRAGMA encoding = $enc"
+ do_execsql_test 1.$enc.1 {
+ CREATE TABLE t1(n, h);
+ INSERT INTO t1 VALUES($::NEEDLE, $::HAYSTACK);
+ } {}
+
+ do_faultsim_test 1.$enc.1 -faults oom-t* -prep {
+ execsql { SELECT instr(h, n) FROM t1 }
+ } -body {
+ execsql { SELECT instr(h, n) FROM t1 }
+ } -test {
+ faultsim_test_result {0 31}
+ }
+
+ do_faultsim_test 1.$enc.2 -faults oom-t* -prep {
+ execsql { SELECT instr($::HAYSTACK, $::NEEDLE) FROM t1 }
+ } -body {
+ execsql { SELECT instr($::HAYSTACK, $::NEEDLE) FROM t1 }
+ } -test {
+ faultsim_test_result {0 31}
+ }
+
+ do_faultsim_test 1.$enc.3 -faults oom-t* -prep {
+ set ::stmt [sqlite3_prepare_v2 db "SELECT instr(?, ?)" -1 dummy]
+ sqlite3_bind_text $::stmt 1 $::HAYSTACK [string length $::HAYSTACK]
+ sqlite3_bind_text $::stmt 2 $::NEEDLE [string length $::NEEDLE]
+ } -body {
+ set rc [sqlite3_step $::stmt]
+ if {$rc=="SQLITE_NOMEM"} { error "out of memory" }
+ sqlite3_column_int $::stmt 0
+ } -test {
+ faultsim_test_result {0 31}
+ sqlite3_finalize $::stmt
+ }
+
+ do_faultsim_test 1.$enc.4 -faults oom-t* -prep {
+ set ::stmt [sqlite3_prepare_v2 db "SELECT instr(?, ?)" -1 dummy]
+ sqlite3_bind_blob $::stmt 1 $::HAYSTACK [string length $::HAYSTACK]
+ sqlite3_bind_blob $::stmt 2 $::NEEDLE [string length $::NEEDLE]
+ } -body {
+ set rc [sqlite3_step $::stmt]
+ if {$rc=="SQLITE_NOMEM"} { error "out of memory" }
+ sqlite3_column_int $::stmt 0
+ } -test {
+ faultsim_test_result {0 31}
+ sqlite3_finalize $::stmt
+ }
+
+ do_execsql_test 1.$enc.5.0 {
+ CREATE TABLE h1(a, b);
+ INSERT INTO h1 VALUES('abcdefg%200hijkl', randomblob(200));
+ INSERT INTO h1 SELECT b, a FROM h1;
+ }
+ do_faultsim_test 1.$enc.5 -faults oom-t* -body {
+ execsql { SELECT rowid FROM h1 WHERE instr(a,b) }
+ } -test {}
+}
+
+finish_test
diff --git a/test/intarray.test b/test/intarray.test
new file mode 100644
index 0000000..2250027
--- /dev/null
+++ b/test/intarray.test
@@ -0,0 +1,116 @@
+# 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 temp.sqlite_master
+ ORDER BY name
+ }
+} {table ia1 table ia2 table ia3 table ia4}
+
+# Verify the ability to DROP and recreate an intarray virtual table.
+do_test intarray-1.1b {
+ db eval {DROP TABLE ia1}
+ set rc [catch {sqlite3_intarray_create db ia1} ia1]
+ lappend rc $ia1
+} {/0 [0-9A-Z]+/}
+
+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..8774aee
--- /dev/null
+++ b/test/interrupt.test
@@ -0,0 +1,185 @@
+# 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 temp.sqlite_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 temp.sqlite_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}
+}
+
+if {0} { # This doesn't work anymore since the collation factor is
+ # no longer called during schema parsing.
+# 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/interrupt2.test b/test/interrupt2.test
new file mode 100644
index 0000000..b9c66bd
--- /dev/null
+++ b/test/interrupt2.test
@@ -0,0 +1,159 @@
+# 2016 Aug 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 using the sqlite_interrupt() API to
+# interrupt WAL checkpoint operations.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/wal_common.tcl
+set testprefix interrupt2
+
+if {[permutation]=="journaltest" || [permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+db close
+testvfs tvfs -default 1
+
+tvfs filter xWrite
+tvfs script write_cb
+
+set ::trigger_interrupt 0
+proc write_cb {method args} {
+ set filename [lindex $args 0]
+ if {[file tail $filename]=="test.db" && $::trigger_interrupt} {
+ if {$::trigger_interrupt} {
+ incr ::trigger_interrupt -1
+ if {$::trigger_interrupt==0} { sqlite3_interrupt db }
+ }
+ }
+ return 0
+}
+
+sqlite3 db test.db
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ PRAGMA journal_mode = wal;
+
+ WITH ii(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM ii WHERE i<1000 )
+ INSERT INTO t1 SELECT i, i FROM ii;
+} {wal}
+
+foreach idelay {
+ 5
+ 10
+ 15
+ 20
+} {
+
+ set ::trigger_interrupt $idelay
+ do_catchsql_test 1.$idelay.1 { PRAGMA wal_checkpoint; } {1 interrupted}
+ do_execsql_test 1.$idelay.2 { SELECT count(*) FROM t1 } 1000
+
+ set ::trigger_interrupt $idelay
+ do_test 1.$idelay.3 {
+ list [catch { sqlite3_wal_checkpoint_v2 db truncate } msg] $msg
+ } {1 {SQLITE_INTERRUPT - interrupted}}
+ do_execsql_test 1.$idelay.4 { SELECT count(*) FROM t1 } 1000
+}
+
+#-------------------------------------------------------------------------
+# Check that if there are other SQL statements running, a checkpoint does
+# not clear the isInterrupted flag.
+#
+do_execsql_test 2.0 {
+ CREATE TEMP TABLE z1(a, b);
+ INSERT INTO z1 SELECT * FROM t1;
+}
+
+do_test 2.1 {
+ set i 10
+ set res [list [catch {
+ set i 10
+ db eval {SELECT * FROM z1} {
+ incr i -1
+ if {$i==0} {
+ set ::trigger_interrupt 10
+ set cres [catch { sqlite3_wal_checkpoint_v2 db truncate } msg]
+ lappend cres $msg
+ }
+ }
+ } msg] $msg]
+
+ list $cres $res
+} {{1 {SQLITE_INTERRUPT - interrupted}} {1 interrupted}}
+
+do_execsql_test 2.0 {
+ SELECT count(*) FROM t1
+ UNION ALL
+ SELECT count(*) FROM z1
+} {1000 1000}
+
+#-------------------------------------------------------------------------
+# Check the effect of an interrupt during sqlite3_close().
+#
+db_save_and_close
+
+db_restore_and_reopen
+do_test 3.1.1 {
+ set ::trigger_interrupt 10
+ db eval { SELECT * FROM sqlite_master }
+ db close
+ set {} {}
+} {}
+do_test 3.1.2 {
+ list [file exists test.db] [file exists test.db-wal]
+} {1 1}
+
+db_restore_and_reopen
+do_test 3.2.1 {
+ db eval { SELECT * FROM sqlite_master }
+ db close
+ set {} {}
+} {}
+do_test 3.2.2 {
+ list [file exists test.db] [file exists test.db-wal]
+} {1 0}
+
+#-------------------------------------------------------------------------
+# Check the effect of an interrupt during an automatic checkpoint
+#
+db_restore_and_reopen
+do_test 4.0 {
+ execsql { PRAGMA wal_autocheckpoint = 10 }
+ set ::trigger_interrupt 10
+ execsql { CREATE TABLE t2(x, y) }
+} {}
+
+# The auto-checkpoint in test 4.0 should have been interrupted. So this
+# db write should cause the wal file to grow.
+do_test 4.1 {
+ set nFrame1 [wal_frame_count test.db-wal 1024]
+ execsql { CREATE TABLE t3(x, y) }
+ set nFrame2 [wal_frame_count test.db-wal 1024]
+ expr $nFrame2 > $nFrame1
+} {1}
+
+# The auto-checkpoint in test 4.0 should not have been interrupted. So
+# this db write should not cause the wal file to grow.
+do_test 4.2 {
+ set nFrame1 [wal_frame_count test.db-wal 1024]
+ execsql { CREATE TABLE t4(x, y) }
+ set nFrame2 [wal_frame_count test.db-wal 1024]
+ expr $nFrame2 == $nFrame1
+} {1}
+
+finish_test
diff --git a/test/intpkey.test b/test/intpkey.test
new file mode 100644
index 0000000..d6b8833
--- /dev/null
+++ b/test/intpkey.test
@@ -0,0 +1,645 @@
+# 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 {UNIQUE constraint failed: t1.a}}
+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 {
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a==4;
+ }
+} {/SEARCH 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 3}
+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 ORDER BY rowid
+ }
+} {-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;
+ }
+} {}
+
+# 2016-04-18 ticket https://www.sqlite.org/src/tktview/7d7525cb01b68712495d3a
+# Be sure to escape quoted typenames.
+#
+do_execsql_test intpkey-16.0 {
+ CREATE TABLE t16a(id "INTEGER" PRIMARY KEY AUTOINCREMENT, b [TEXT], c `INT`);
+} {}
+do_execsql_test intpkey-16.1 {
+ PRAGMA table_info=t16a;
+} {0 id INTEGER 0 {} 1 1 b TEXT 0 {} 0 2 c INT 0 {} 0}
+
+# 2016-05-06 ticket https://www.sqlite.org/src/tktview/16c9801ceba4923939085
+# When the schema contains an index on the IPK and no other index
+# and a WHERE clause on a delete uses an OR where both sides referencing
+# the IPK, then it is possible that the OP_Delete will fail because there
+# deferred seek of the OP_Seek is not resolved prior to reaching the OP_Delete.
+#
+do_execsql_test intpkey-17.0 {
+ CREATE TABLE t17(x INTEGER PRIMARY KEY, y TEXT);
+ INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe');
+ CREATE INDEX t17x ON t17(x);
+ DELETE FROM t17 WHERE x=99 OR x<130;
+ SELECT * FROM t17;
+} {248 giraffe}
+do_execsql_test intpkey-17.1 {
+ DROP INDEX t17x;
+ DELETE FROM t17;
+ INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe');
+ CREATE UNIQUE INDEX t17x ON t17(abs(x));
+ DELETE FROM t17 WHERE abs(x) IS NULL OR abs(x)<130;
+ SELECT * FROM t17;
+} {248 giraffe}
+do_execsql_test intpkey-17.2 {
+ DELETE FROM t17;
+ INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe');
+ UPDATE t17 SET y='ostrich' WHERE abs(x)=248;
+ SELECT * FROM t17 ORDER BY +x;
+} {123 elephant 248 ostrich}
+
+finish_test
diff --git a/test/intreal.test b/test/intreal.test
new file mode 100644
index 0000000..1a3db0a
--- /dev/null
+++ b/test/intreal.test
@@ -0,0 +1,98 @@
+# 2019-05-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.
+#
+#***********************************************************************
+# Tests to exercise the MEM_IntReal representation of Mem objects.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix intreal
+
+sqlite3_create_function db
+do_execsql_test 100 {
+ SELECT intreal(5);
+} {5.0}
+do_execsql_test 110 {
+ SELECT intreal(5)=5, 6=intreal(6);
+} {1 1}
+do_execsql_test 120 {
+ SELECT intreal(7)=7.0, 8.0=intreal(8);
+} {1 1}
+do_execsql_test 130 {
+ SELECT typeof(intreal(9));
+} {real}
+do_execsql_test 140 {
+ SELECT 'a'||intreal(11)||'z';
+} {a11.0z}
+
+do_execsql_test 150 {
+ SELECT max(1.0,intreal(2),3.0), max(1,intreal(2),3);
+} {3.0 3}
+do_execsql_test 160 {
+ SELECT max(1.0,intreal(4),3.0), max(1,intreal(4),3);
+} {4.0 4.0}
+do_execsql_test 170 {
+ SELECT max(1.0,intreal(2),intreal(3),4.0),
+ max(1,intreal(2),intreal(3),4);
+} {4.0 4}
+do_execsql_test 180 {
+ SELECT max(1.0,intreal(5),intreal(3),4.0),
+ max(1,intreal(5),intreal(3),4);
+} {5.0 5.0}
+
+#-------------------------------------------------------------------------
+do_execsql_test 2.1 {
+ CREATE TABLE t2(a REAL);
+ INSERT INTO t2 VALUES( 836627109860825358 );
+ SELECT substr(a,1,4) FROM t2 WHERE a = CAST(836627109860825358 AS REAL);
+} {8.36}
+
+do_execsql_test 2.2 {
+ CREATE INDEX i2 ON t2(a);
+ SELECT substr(a,1,4) FROM t2 WHERE a = CAST(836627109860825358 AS REAL);
+} {8.36}
+
+do_execsql_test 2.3 {
+ CREATE TABLE t0 (c0);
+ CREATE TABLE t1 (c1 REAL);
+ INSERT INTO t1(c1) VALUES (8366271098608253588);
+ INSERT INTO t0(c0) VALUES ('a');
+}
+set D [db one {SELECT c1 FROM t1}]
+
+do_execsql_test 2.4 {
+ SELECT * FROM t1 WHERE (t1.c1 = CAST(8366271098608253588 AS REAL));
+} $D
+
+do_execsql_test 2.5 {
+ SELECT * FROM t0, t1 WHERE (t1.c1 = CAST(8366271098608253588 AS REAL));
+} [list a $D]
+
+do_execsql_test 2.6 {
+ SELECT * FROM t0, t1
+ WHERE (
+ t1.c1 >= CAST(8366271098608253588 AS REAL)
+ AND t1.c1 <= CAST(8366271098608253588 AS REAL)
+ );
+} [list a $D]
+
+# 2019-07-29 ticket ba2f4585cf495231
+#
+db close
+sqlite3 db :memory:
+do_execsql_test 3.0 {
+ CREATE TABLE t0 (c0 REAL, c1);
+ CREATE UNIQUE INDEX i0 ON t0(c1, 0 | c0);
+ INSERT INTO t0(c0) VALUES (4750228396194493326), (0);
+ UPDATE OR REPLACE t0 SET c0 = 'a', c1 = '';
+ SELECT * FROM t0 ORDER BY t0.c1;
+ PRAGMA integrity_check;
+} {a {} ok}
+
+finish_test
diff --git a/test/io.test b/test/io.test
new file mode 100644
index 0000000..dfadcd1
--- /dev/null
+++ b/test/io.test
@@ -0,0 +1,645 @@
+# 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
+set ::testprefix io
+
+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.
+#
+# io-6.* - Test that the pager-cache is not being flushed unnecessarily
+# after a transaction that uses the special atomic-write path
+# is committed.
+#
+
+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.
+#
+# UPDATE: As of [05f98d4eec] (adding SQLITE_DBSTATUS_CACHE_WRITE), the
+# second write is also counted. So this now reports two writes and a
+# single fsync.
+#
+sqlite3_simulate_device -char atomic
+do_test io-2.3 {
+ execsql { INSERT INTO abc VALUES(3, 4) }
+ list [nWrite db] [nSync]
+} {2 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
+# existence. 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]
+ } "[expr {[nonzero_reserved_bytes]?40960: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
+}
+
+#----------------------------------------------------------------------
+#
+do_test io-6.1 {
+ db close
+ sqlite3_simulate_device -char atomic
+ forcedelete test.db
+ sqlite3 db test.db -vfs devsym
+ execsql {
+ PRAGMA mmap_size = 0;
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 2000;
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(x);
+ CREATE TABLE t3(x);
+ CREATE INDEX i3 ON t3(x);
+ INSERT INTO t3 VALUES(randomblob(100));
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ }
+
+ db_save_and_close
+} {}
+
+foreach {tn sql} {
+ 1 { BEGIN;
+ INSERT INTO t1 VALUES('123');
+ INSERT INTO t2 VALUES('456');
+ COMMIT;
+ }
+ 2 { BEGIN;
+ INSERT INTO t1 VALUES('123');
+ COMMIT;
+ }
+} {
+
+ # These tests don't work with memsubsys1, as it causes the effective page
+ # cache size to become too small to hold the entire db in memory.
+ if {[permutation] == "memsubsys1"} continue
+
+ db_restore
+ sqlite3 db test.db -vfs devsym
+ execsql {
+ PRAGMA cache_size = 2000;
+ PRAGMA mmap_size = 0;
+ SELECT x FROM t3 ORDER BY rowid;
+ SELECT x FROM t3 ORDER BY x;
+ }
+ do_execsql_test 6.2.$tn.1 { PRAGMA integrity_check } {ok}
+ do_execsql_test 6.2.$tn.2 $sql
+
+ # Corrupt the database file on disk. This should not matter for the
+ # purposes of the following "PRAGMA integrity_check", as the entire
+ # database should be cached in the pager-cache. If corruption is
+ # reported, it indicates that executing $sql caused the pager cache
+ # to be flushed. Which is a bug.
+ hexio_write test.db [expr 1024 * 5] [string repeat 00 2048]
+ do_execsql_test 6.2.$tn.3 { PRAGMA integrity_check } {ok}
+ db close
+}
+
+sqlite3_simulate_device -char {} -sectorsize 0
+unregister_devsim
+
+finish_test
diff --git a/test/ioerr.test b/test/ioerr.test
new file mode 100644
index 0000000..29a3ded
--- /dev/null
+++ b/test/ioerr.test
@@ -0,0 +1,466 @@
+# 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" && ![atomic_batch_write test.db]} {
+ 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" && [atomic_batch_write test.db]==0} {
+ 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 != "UNIQUE constraint failed: t1.a"} {
+ 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}
+unregister_devsim
+
+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..c08c345
--- /dev/null
+++ b/test/ioerr2.test
@@ -0,0 +1,176 @@
+# 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
+ }
+}
+
+# When this test was written, an IO error within the UPDATE statement caused
+# a rollback, which tripped all read-cursors, causing the outer SELECT to
+# fail with "abort due to ROLLBACK". Now, the loop continues until the UPDATE
+# is run successfully. At this point the next IO error occurs within the
+# SELECT - throwing the "disk I/O error" that the test case now expects.
+#
+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 {disk I/O error}} ;# used to be "{1 {abort due to ROLLBACK}}"
+
+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/ioerr6.test b/test/ioerr6.test
new file mode 100644
index 0000000..d1847b2
--- /dev/null
+++ b/test/ioerr6.test
@@ -0,0 +1,91 @@
+# 2012 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set ::testprefix ioerr6
+
+ifcapable !atomicwrite {
+ puts "skipping tests - not compiled with SQLITE_ENABLE_ATOMIC_WRITE..."
+ finish_test
+ return
+}
+
+if {[permutation]=="inmemory_journal"} {
+ # These tests will not work with in-memory journals (as persistent VFS
+ # errors commencing after a transaction has started to write to the db
+ # cannot be recovered from).
+ finish_test
+ return
+}
+
+faultsim_save_and_close
+
+do_test 1.1 {
+ testvfs shmfault -default true
+ shmfault devchar atomic
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(2, 4);
+ INSERT INTO t1 VALUES(3, 6);
+ INSERT INTO t1 VALUES(4, 8);
+ }
+
+ # Cause the first call to xWrite() to fail with SQLITE_FULL.
+ shmfault full 2 1
+ catchsql { INSERT INTO t1 VALUES(5, 10) }
+} {1 {database or disk is full}}
+
+do_test 1.2 {
+ execsql { PRAGMA integrity_check }
+} {ok}
+
+db close
+shmfault delete
+
+do_faultsim_test 2 -faults full* -prep {
+ shmfault devchar atomic
+ faultsim_restore
+ sqlite3 db test.db
+} -body {
+ db eval {
+ CREATE TABLE t1(x PRIMARY KEY);
+ INSERT INTO t1 VALUES('abc');
+ }
+} -test {
+ set res [db one { PRAGMA integrity_check }]
+ if {$res != "ok"} {
+ error "integrity check: $res"
+ }
+}
+
+do_faultsim_test 3 -faults full* -prep {
+ shmfault devchar atomic
+ faultsim_restore
+ sqlite3 db test.db
+} -body {
+ db eval {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(x);
+ }
+} -test {
+ db eval { CREATE TABLE t3(x) }
+ if {[db one { PRAGMA integrity_check }] != "ok"} {
+ error "integrity check failed"
+ }
+}
+
+finish_test
diff --git a/test/istrue.test b/test/istrue.test
new file mode 100644
index 0000000..f1ba632
--- /dev/null
+++ b/test/istrue.test
@@ -0,0 +1,206 @@
+# 2018-02-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 expressions of the form
+#
+# x IS TRUE
+# x IS FALSE
+# x IS NOT TRUE
+# x IS NOT FALSE
+#
+# Tests are also included for the use of TRUE and FALSE as
+# literal values.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test istrue-100 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y BOOLEAN);
+ INSERT INTO t1 VALUES(1, true),(2, false),(3, null);
+ SELECT x FROM t1 WHERE y IS TRUE;
+} {1}
+do_execsql_test istrue-110 {
+ SELECT x FROM t1 WHERE y IS FALSE;
+} {2}
+do_execsql_test istrue-120 {
+ SELECT x FROM t1 WHERE y IS NULL;
+} {3}
+do_execsql_test istrue-130 {
+ SELECT x FROM t1 WHERE y IS NOT TRUE;
+} {2 3}
+do_execsql_test istrue-140 {
+ SELECT x FROM t1 WHERE y IS NOT FALSE;
+} {1 3}
+do_execsql_test istrue-150 {
+ SELECT x FROM t1 WHERE y IS NOT NULL;
+} {1 2}
+unset -nocomplain X
+set X 9
+do_execsql_test istrue-160 {
+ SELECT x FROM t1 WHERE y IS TRUE OR (8==$X)
+} {1}
+do_execsql_test istrue-170 {
+ SELECT x FROM t1 WHERE y IS FALSE OR (8==$X)
+} {2}
+do_execsql_test istrue-180 {
+ SELECT x FROM t1 WHERE y IS NULL OR (8==$X);
+} {3}
+do_execsql_test istrue-190 {
+ SELECT x FROM t1 WHERE y IS NOT TRUE OR (8==$X);
+} {2 3}
+do_execsql_test istrue-200 {
+ SELECT x FROM t1 WHERE y IS NOT FALSE OR (8==$X);
+} {1 3}
+do_execsql_test istrue-210 {
+ SELECT x FROM t1 WHERE y IS NOT NULL OR (8==$X);
+} {1 2}
+
+do_execsql_test istrue-300 {
+ SELECT x,
+ y IS TRUE, y IS FALSE, y is NULL,
+ y IS NOT TRUE, y IS NOT FALSE, y IS NOT NULL, '|'
+ FROM t1 ORDER BY x;
+} {1 1 0 0 0 1 1 | 2 0 1 0 1 0 1 | 3 0 0 1 1 1 0 |}
+
+do_execsql_test istrue-400 {
+ SELECT x FROM t1 WHERE true;
+} {1 2 3}
+do_execsql_test istrue-410 {
+ SELECT x FROM t1 WHERE false;
+} {}
+
+do_execsql_test istrue-500 {
+ CREATE TABLE t2(
+ a INTEGER PRIMARY KEY,
+ b BOOLEAN DEFAULT true,
+ c BOOLEAN DEFAULT(true),
+ d BOOLEAN DEFAULT false,
+ e BOOLEAN DEFAULT(false)
+ );
+ INSERT INTO t2 DEFAULT VALUES;
+ SELECT * FROM t2;
+} {1 1 1 0 0}
+do_execsql_test istrue-510 {
+ DROP TABLE t2;
+ CREATE TABLE t2(
+ a INTEGER PRIMARY KEY,
+ b BOOLEAN DEFAULT(not true),
+ c BOOLEAN DEFAULT(not false)
+ );
+ INSERT INTO t2(a) VALUES(99);
+ SELECT * FROM t2;
+} {99 0 1}
+do_execsql_test istrue-520 {
+ DROP TABLE t2;
+ CREATE TABLE t2(
+ a INTEGER PRIMARY KEY,
+ b BOOLEAN CHECK(b IS TRUE),
+ c BOOLEAN CHECK(c IS FALSE),
+ d BOOLEAN CHECK(d IS NOT TRUE),
+ e BOOLEAN CHECK(e IS NOT FALSE)
+ );
+ INSERT INTO t2 VALUES(1,true,false,null,null);
+ SELECT * FROM t2;
+} {1 1 0 {} {}}
+do_catchsql_test istrue-521 {
+ INSERT INTO t2 VALUES(2,false,false,null,null);
+} {1 {CHECK constraint failed: b IS TRUE}}
+do_catchsql_test istrue-522 {
+ INSERT INTO t2 VALUES(2,true,true,null,null);
+} {1 {CHECK constraint failed: c IS FALSE}}
+do_catchsql_test istrue-523 {
+ INSERT INTO t2 VALUES(2,true,false,true,null);
+} {1 {CHECK constraint failed: d IS NOT TRUE}}
+do_catchsql_test istrue-524 {
+ INSERT INTO t2 VALUES(2,true,false,null,false);
+} {1 {CHECK constraint failed: e IS NOT FALSE}}
+
+foreach {tn val} [list 1 NaN 2 -NaN 3 NaN0 4 -NaN0 5 Inf 6 -Inf] {
+ do_execsql_test istrue-600.$tn.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ }
+ do_test istrue-600.$tn.2 {
+ set ::STMT [sqlite3_prepare db "INSERT INTO t1 VALUES(?)" -1 TAIL]
+ sqlite3_bind_double $::STMT 1 $val
+ sqlite3_step $::STMT
+ sqlite3_reset $::STMT
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+ do_execsql_test istrue-600.$tn.3 {
+ SELECT x IS TRUE FROM t1;
+ } [expr {$tn in [list 5 6] ? {1} : {0}}]
+ do_execsql_test istrue-600.$tn.4 {
+ SELECT x IS FALSE FROM t1;
+ } {0}
+}
+
+ifcapable altertable {
+ do_execsql_test istrue-700 {
+ CREATE TABLE t7(
+ a INTEGER PRIMARY KEY,
+ b BOOLEAN DEFAULT false,
+ c BOOLEAN DEFAULT true
+ );
+ INSERT INTO t7(a) VALUES(1);
+ INSERT INTO t7(a,b,c) VALUES(2,true,false);
+ ALTER TABLE t7 ADD COLUMN d BOOLEAN DEFAULT false;
+ ALTER TABLE t7 ADD COLUMN e BOOLEAN DEFAULT true;
+ INSERT INTO t7(a,b,c) VALUES(3,true,false);
+ INSERT INTO t7 VALUES(4,false,true,true,false);
+ SELECT *,'x' FROM t7 ORDER BY a;
+ } {1 0 1 0 1 x 2 1 0 0 1 x 3 1 0 0 1 x 4 0 1 1 0 x}
+}
+
+do_execsql_test istrue-710 {
+ SELECT 0.5 IS TRUE COLLATE NOCASE;
+ SELECT 0.5 IS TRUE COLLATE RTRIM;
+ SELECT 0.5 IS TRUE COLLATE BINARY;
+
+ SELECT 0.5 IS TRUE;
+ SELECT 0.5 COLLATE NOCASE IS TRUE;
+ SELECT 0.0 IS FALSE;
+
+ SELECT 0.0 IS FALSE COLLATE NOCASE;
+ SELECT 0.0 IS FALSE COLLATE RTRIM;
+ SELECT 0.0 IS FALSE COLLATE BINARY;
+} {1 1 1 1 1 1 1 1 1}
+
+# 2020-06-12 bug report from Chromium
+# https://bugs.chromium.org/p/chromium/issues/detail?id=1094247
+do_catchsql_test istrue-800 {
+ SELECT 9 IN (false.false);
+} {1 {no such column: false.false}}
+do_execsql_test istrue-810 {
+ CREATE TABLE t8(a INT, true INT, false INT, d INT);
+ INSERT INTO t8(a,true,false,d) VALUES(5,6,7,8),(4,3,2,1),('a','b','c','d');
+ SELECT * FROM t8 ORDER BY false;
+} {4 3 2 1 5 6 7 8 a b c d}
+do_catchsql_test istrue-820 {
+ SELECT 9 IN (false.false) FROM t8;
+} {1 {no such column: false.false}}
+do_execsql_test istrue-830 {
+ CREATE TABLE false(true INT, false INT, x INT CHECK (5 IN (false.false)));
+} {}
+do_execsql_test istrue-840 {
+ INSERT INTO False VALUES(4,5,6);
+} {}
+do_catchsql_test istrue-841 {
+ INSERT INTO False VALUES(5,6,7);
+} {1 {CHECK constraint failed: 5 IN (false.false)}}
+do_execsql_test istrue-850 {
+ SELECT 9 IN (false.false) FROM false;
+} {0}
+do_execsql_test istrue-851 {
+ SELECT 5 IN (false.false) FROM false;
+} {1}
+
+finish_test
diff --git a/test/join.test b/test/join.test
new file mode 100644
index 0000000..f0ac0be
--- /dev/null
+++ b/test/join.test
@@ -0,0 +1,1210 @@
+# 2002-05-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.
+#
+
+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}
+
+# A FROM clause of the form: "<table>, <table> ON <expr>" is not
+# allowed by the SQLite syntax diagram, nor by any other SQL database
+# engine that we are aware of. Nevertheless, historic versions of
+# SQLite have allowed it. We need to continue to support it moving
+# forward to prevent breakage of legacy applications. Though, we will
+# not advertise it as being supported.
+#
+do_execsql_test join-1.2.1 {
+ SELECT t1.rowid, t2.rowid, '|' FROM t1, t2 ON t1.a=t2.b;
+} {1 1 | 2 2 | 3 3 |}
+
+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 {}}
+
+# EVIDENCE-OF: R-52129-05406 you can say things like "OUTER LEFT NATURAL
+# JOIN" which means the same as "NATURAL LEFT OUTER JOIN".
+do_test join-2.1b {
+ execsql {
+ SELECT * FROM t1 OUTER LEFT NATURAL JOIN t2;
+ }
+} {1 2 3 4 2 3 4 5 3 4 5 {}}
+do_test join-2.1c {
+ execsql {
+ SELECT * FROM t1 NATURAL LEFT OUTER 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 {near "USING": syntax error}}
+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}}
+
+# EVIDENCE-OF: R-47973-48020 you cannot say "INNER OUTER JOIN", because
+# that would be contradictory.
+do_test join-3.7 {
+ catchsql {
+ SELECT * FROM t1 INNER OUTER JOIN t2;
+ }
+} {1 {unknown join type: INNER OUTER}}
+do_test join-3.8 {
+ catchsql {
+ SELECT * FROM t1 INNER OUTER CROSS JOIN t2;
+ }
+} {1 {unknown join type: INNER OUTER CROSS}}
+do_test join-3.9 {
+ catchsql {
+ SELECT * FROM t1 OUTER NATURAL INNER JOIN t2;
+ }
+} {1 {unknown join type: OUTER NATURAL INNER}}
+do_test join-3.10 {
+ catchsql {
+ SELECT * FROM t1 LEFT BOGUS JOIN t2;
+ }
+} {1 {unknown join type: LEFT BOGUS}}
+do_test join-3.11 {
+ catchsql {
+ SELECT * FROM t1 INNER BOGUS CROSS JOIN t2;
+ }
+} {1 {unknown join type: INNER BOGUS CROSS}}
+do_test join-3.12 {
+ catchsql {
+ SELECT * FROM t1 NATURAL AWK SED JOIN t2;
+ }
+} {1 {unknown 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 {
+ sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 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}
+
+#-------------------------------------------------------------------------
+# Test that at most 64 tables are allowed in a join.
+#
+do_execsql_test join-12.1 {
+ CREATE TABLE t14(x);
+ INSERT INTO t14 VALUES('abcdefghij');
+}
+
+proc jointest {tn nTbl res} {
+ set sql "SELECT 1 FROM [string repeat t14, [expr $nTbl-1]] t14;"
+ uplevel [list do_catchsql_test $tn $sql $res]
+}
+
+jointest join-12.2 30 {0 1}
+jointest join-12.3 63 {0 1}
+jointest join-12.4 64 {0 1}
+jointest join-12.5 65 {1 {at most 64 tables in a join}}
+jointest join-12.6 66 {1 {at most 64 tables in a join}}
+jointest join-12.7 127 {1 {at most 64 tables in a join}}
+jointest join-12.8 128 {1 {at most 64 tables in a join}}
+
+# As of 2019-01-17, the number of elements in a SrcList is limited
+# to 200. The following tests still run, but the answer is now
+# an SQLITE_NOMEM error.
+#
+# jointest join-12.9 1000 {1 {at most 64 tables in a join}}
+#
+# If SQLite is built with SQLITE_MEMDEBUG, then the huge number of realloc()
+# calls made by the following test cases are too time consuming to run.
+# Without SQLITE_MEMDEBUG, realloc() is fast enough that these are not
+# a problem.
+#
+# ifcapable pragma&&compileoption_diags {
+# if {[lsearch [db eval {PRAGMA compile_options}] MEMDEBUG]<0} {
+# jointest join-12.10 65534 {1 {at most 64 tables in a join}}
+# jointest join-12.11 65535 {1 {too many references to "t14": max 65535}}
+# jointest join-12.12 65536 {1 {too many references to "t14": max 65535}}
+# jointest join-12.13 65537 {1 {too many references to "t14": max 65535}}
+# }
+# }
+
+
+#-------------------------------------------------------------------------
+# Test a problem with reordering tables following a LEFT JOIN.
+#
+do_execsql_test join-13.0 {
+ CREATE TABLE aa(a);
+ CREATE TABLE bb(b);
+ CREATE TABLE cc(c);
+
+ INSERT INTO aa VALUES(45);
+ INSERT INTO cc VALUES(45);
+ INSERT INTO cc VALUES(45);
+}
+
+do_execsql_test join-13.1 {
+ SELECT * FROM aa LEFT JOIN bb, cc WHERE cc.c=aa.a;
+} {45 {} 45 45 {} 45}
+
+# In the following, the order of [cc] and [bb] must not be exchanged, even
+# though this would be helpful if the query used an inner join.
+do_execsql_test join-13.2 {
+ CREATE INDEX ccc ON cc(c);
+ SELECT * FROM aa LEFT JOIN bb, cc WHERE cc.c=aa.a;
+} {45 {} 45 45 {} 45}
+
+# Verify that that iTable attributes the TK_IF_NULL_ROW operators in the
+# expression tree are correctly updated by the query flattener. This was
+# a bug discovered on 2017-05-22 by Mark Brand.
+#
+do_execsql_test join-14.1 {
+ SELECT *
+ FROM (SELECT 1 a) AS x
+ LEFT JOIN (SELECT 1, * FROM (SELECT * FROM (SELECT 1)));
+} {1 1 1}
+do_execsql_test join-14.2 {
+ SELECT *
+ FROM (SELECT 1 a) AS x
+ LEFT JOIN (SELECT 1, * FROM (SELECT * FROM (SELECT * FROM (SELECT 1)))) AS y
+ JOIN (SELECT * FROM (SELECT 9)) AS z;
+} {1 1 1 9}
+do_execsql_test join-14.3 {
+ SELECT *
+ FROM (SELECT 111)
+ LEFT JOIN (SELECT cc+222, * FROM (SELECT * FROM (SELECT 333 cc)));
+} {111 555 333}
+
+do_execsql_test join-14.4 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(c PRIMARY KEY, a TEXT(10000), b TEXT(10000));
+ SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1) GROUP BY 1;
+} {111 {}}
+do_execsql_test join-14.4b {
+ SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1);
+} {111 {}}
+do_execsql_test join-14.5 {
+ SELECT * FROM (SELECT 111 AS x UNION ALL SELECT 222)
+ LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y GROUP BY 1;
+} {111 {} 222 {}}
+do_execsql_test join-14.5b {
+ SELECT count(*)
+ FROM (SELECT 111 AS x UNION ALL SELECT 222)
+ LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y;
+} {2}
+do_execsql_test join-14.5c {
+ SELECT count(*)
+ FROM (SELECT c+333 AS y FROM t1)
+ RIGHT JOIN (SELECT 111 AS x UNION ALL SELECT 222) ON x=y;
+} {2}
+do_execsql_test join-14.6 {
+ SELECT * FROM (SELECT 111 AS x UNION ALL SELECT 111)
+ LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y GROUP BY 1;
+} {111 {}}
+do_execsql_test join-14.7 {
+ SELECT * FROM (SELECT 111 AS x UNION ALL SELECT 111 UNION ALL SELECT 222)
+ LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y GROUP BY 1;
+} {111 {} 222 {}}
+do_execsql_test join-14.8 {
+ INSERT INTO t1(c) VALUES(-111);
+ SELECT * FROM (SELECT 111 AS x UNION ALL SELECT 111 UNION ALL SELECT 222)
+ LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y GROUP BY 1;
+} {111 {} 222 222}
+do_execsql_test join-14.9 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(c PRIMARY KEY) WITHOUT ROWID;
+ SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1) GROUP BY 1;
+} {111 {}}
+
+# Verify the fix to ticket
+# https://www.sqlite.org/src/tktview/7fde638e94287d2c948cd9389
+#
+db close
+sqlite3 db :memory:
+do_execsql_test join-14.10 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1),(2),(3);
+ CREATE VIEW v2 AS SELECT a, 1 AS b FROM t1;
+ CREATE TABLE t3(x);
+ INSERT INTO t3 VALUES(2),(4);
+ SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x WHERE b=1;
+} {2 2 1 |}
+do_execsql_test join-14.11 {
+ SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x WHERE b+1=x;
+} {2 2 1 |}
+do_execsql_test join-14.12 {
+ SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x ORDER BY b;
+} {4 {} {} | 2 2 1 |}
+
+# Verify the fix for ticket
+# https://www.sqlite.org/src/info/892fc34f173e99d8
+#
+db close
+sqlite3 db :memory:
+do_execsql_test join-14.20 {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY);
+ CREATE TABLE t2(id INTEGER PRIMARY KEY, c2 INTEGER);
+ CREATE TABLE t3(id INTEGER PRIMARY KEY, c3 INTEGER);
+ INSERT INTO t1(id) VALUES(456);
+ INSERT INTO t3(id) VALUES(1),(2);
+ SELECT t1.id, x2.id, x3.id
+ FROM t1
+ LEFT JOIN (SELECT * FROM t2) AS x2 ON t1.id=x2.c2
+ LEFT JOIN t3 AS x3 ON x2.id=x3.c3;
+} {456 {} {}}
+
+# 2018-03-24.
+# E.Pasma discovered that the LEFT JOIN strength reduction optimization
+# was misbehaving. The problem turned out to be that the
+# sqlite3ExprImpliesNotNull() routine was saying that CASE expressions
+# like
+#
+# CASE WHEN true THEN true ELSE x=0 END
+#
+# could never be true if x is NULL. The following test cases verify
+# that this error has been resolved.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test join-15.100 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(1,2),(3,4);
+ CREATE TABLE t2(x INT, y INT);
+ SELECT *, 'x'
+ FROM t1 LEFT JOIN t2
+ WHERE CASE WHEN FALSE THEN a=x ELSE 1 END;
+} {1 2 {} {} x 3 4 {} {} x}
+do_execsql_test join-15.105 {
+ SELECT *, 'x'
+ FROM t1 LEFT JOIN t2
+ WHERE a IN (1,3,x,y);
+} {1 2 {} {} x 3 4 {} {} x}
+do_execsql_test join-15.106a {
+ SELECT *, 'x'
+ FROM t1 LEFT JOIN t2
+ WHERE NOT ( 'x'='y' AND t2.y=1 );
+} {1 2 {} {} x 3 4 {} {} x}
+do_execsql_test join-15.106b {
+ SELECT *, 'x'
+ FROM t1 LEFT JOIN t2
+ WHERE ~ ( 'x'='y' AND t2.y=1 );
+} {1 2 {} {} x 3 4 {} {} x}
+do_execsql_test join-15.107 {
+ SELECT *, 'x'
+ FROM t1 LEFT JOIN t2
+ WHERE t2.y IS NOT 'abc'
+} {1 2 {} {} x 3 4 {} {} x}
+do_execsql_test join-15.110 {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER);
+ INSERT INTO t1(a,b) VALUES(1,0),(11,1),(12,1),(13,1),(121,12);
+ CREATE INDEX t1b ON t1(b);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY);
+ INSERT INTO t2(x) VALUES(0),(1);
+ SELECT a1, a2, a3, a4, a5
+ FROM (SELECT a AS a1 FROM t1 WHERE b=0)
+ JOIN (SELECT x AS x1 FROM t2)
+ LEFT JOIN (SELECT a AS a2, b AS b2 FROM t1)
+ ON x1 IS TRUE AND b2=a1
+ JOIN (SELECT x AS x2 FROM t2)
+ ON x2<=CASE WHEN x1 THEN CASE WHEN a2 THEN 1 ELSE -1 END ELSE 0 END
+ LEFT JOIN (SELECT a AS a3, b AS b3 FROM t1)
+ ON x2 IS TRUE AND b3=a2
+ JOIN (SELECT x AS x3 FROM t2)
+ ON x3<=CASE WHEN x2 THEN CASE WHEN a3 THEN 1 ELSE -1 END ELSE 0 END
+ LEFT JOIN (SELECT a AS a4, b AS b4 FROM t1)
+ ON x3 IS TRUE AND b4=a3
+ JOIN (SELECT x AS x4 FROM t2)
+ ON x4<=CASE WHEN x3 THEN CASE WHEN a4 THEN 1 ELSE -1 END ELSE 0 END
+ LEFT JOIN (SELECT a AS a5, b AS b5 FROM t1)
+ ON x4 IS TRUE AND b5=a4
+ ORDER BY a1, a2, a3, a4, a5;
+} {1 {} {} {} {} 1 11 {} {} {} 1 12 {} {} {} 1 12 121 {} {} 1 13 {} {} {}}
+
+# 2019-02-05 Ticket https://www.sqlite.org/src/tktview/5948e09b8c415bc45da5c
+# Error in join due to the LEFT JOIN strength reduction optimization.
+#
+do_execsql_test join-16.100 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INT);
+ INSERT INTO t1(a) VALUES(1);
+ CREATE TABLE t2(b INT);
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON 0
+ WHERE (b IS NOT NULL)=0;
+} {1 {}}
+
+# 2019-08-17 ticket https://sqlite.org/src/tktview/6710d2f7a13a299728ab
+# Ensure that constants that derive from the right-hand table of a LEFT JOIN
+# are never factored out, since they are not really constant.
+#
+do_execsql_test join-17.100 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(0),(1);
+ SELECT * FROM t1 LEFT JOIN (SELECT abs(1) AS y FROM t1) ON x WHERE NOT(y='a');
+} {1 1 1 1}
+do_execsql_test join-17.110 {
+ SELECT * FROM t1 LEFT JOIN (SELECT abs(1)+2 AS y FROM t1) ON x
+ WHERE NOT(y='a');
+} {1 3 1 3}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test join-18.1 {
+ CREATE TABLE t0(a);
+ CREATE TABLE t1(b);
+ CREATE VIEW v0 AS SELECT a FROM t1 LEFT JOIN t0;
+ INSERT INTO t1 VALUES (1);
+} {}
+
+do_execsql_test join-18.2 {
+ SELECT * FROM v0 WHERE NOT(v0.a IS FALSE);
+} {{}}
+
+do_execsql_test join-18.3 {
+ SELECT * FROM t1 LEFT JOIN t0 WHERE NOT(a IS FALSE);
+} {1 {}}
+
+do_execsql_test join-18.4 {
+ SELECT NOT(v0.a IS FALSE) FROM v0
+} {1}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test join-19.0 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b);
+ INSERT INTO t1(a) VALUES(0);
+ CREATE VIEW v0(c) AS SELECT t2.b FROM t1 LEFT JOIN t2;
+}
+
+do_execsql_test join-19.1 {
+ SELECT * FROM v0 WHERE v0.c NOTNULL NOTNULL;
+} {{}}
+
+do_execsql_test join-19.2 {
+ SELECT * FROM t1 LEFT JOIN t2
+} {0 {}}
+
+do_execsql_test join-19.3 {
+ SELECT * FROM t1 LEFT JOIN t2 WHERE (b IS NOT NULL) IS NOT NULL;
+} {0 {}}
+
+do_execsql_test join-19.4 {
+ SELECT (b IS NOT NULL) IS NOT NULL FROM t1 LEFT JOIN t2
+} {1}
+
+do_execsql_test join-19.5 {
+ SELECT * FROM t1 LEFT JOIN t2 WHERE
+ (b IS NOT NULL AND b IS NOT NULL) IS NOT NULL;
+} {0 {}}
+
+# 2019-11-02 ticket 623eff57e76d45f6
+# The optimization of exclusing the WHERE expression of a partial index
+# from the WHERE clause of the query if the index is used does not work
+# of the table of the index is the right-hand table of a LEFT JOIN.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test join-20.1 {
+ CREATE TABLE t1(c1);
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES (0);
+ SELECT * FROM t0 LEFT JOIN t1 WHERE NULL IN (c1);
+} {}
+do_execsql_test join-20.2 {
+ CREATE INDEX t1x ON t1(0) WHERE NULL IN (c1);
+ SELECT * FROM t0 LEFT JOIN t1 WHERE NULL IN (c1);
+} {}
+
+# 2019-11-30 ticket 7f39060a24b47353
+# Do not allow a WHERE clause term to qualify a partial index on the
+# right table of a LEFT JOIN.
+#
+do_execsql_test join-21.10 {
+ DROP TABLE t0;
+ DROP TABLE t1;
+ CREATE TABLE t0(aa);
+ CREATE TABLE t1(bb);
+ INSERT INTO t0(aa) VALUES (1);
+ INSERT INTO t1(bb) VALUES (1);
+ SELECT 11, * FROM t1 LEFT JOIN t0 WHERE aa ISNULL;
+ SELECT 12, * FROM t1 LEFT JOIN t0 WHERE +aa ISNULL;
+ SELECT 13, * FROM t1 LEFT JOIN t0 ON aa ISNULL;
+ SELECT 14, * FROM t1 LEFT JOIN t0 ON +aa ISNULL;
+ CREATE INDEX i0 ON t0(aa) WHERE aa ISNULL;
+ SELECT 21, * FROM t1 LEFT JOIN t0 WHERE aa ISNULL;
+ SELECT 22, * FROM t1 LEFT JOIN t0 WHERE +aa ISNULL;
+ SELECT 23, * FROM t1 LEFT JOIN t0 ON aa ISNULL;
+ SELECT 24, * FROM t1 LEFT JOIN t0 ON +aa ISNULL;
+} {13 1 {} 14 1 {} 23 1 {} 24 1 {}}
+
+# 2019-12-18 problem with a LEFT JOIN where the RHS is a view.
+# Detected by Yongheng and Rui.
+# Follows from the optimization attempt of check-in 41c27bc0ff1d3135
+# on 2017-04-18
+#
+reset_db
+do_execsql_test join-22.10 {
+ CREATE TABLE t0(a, b);
+ CREATE INDEX t0a ON t0(a);
+ INSERT INTO t0 VALUES(10,10),(10,11),(10,12);
+ SELECT DISTINCT c FROM t0 LEFT JOIN (SELECT a+1 AS c FROM t0) ORDER BY c ;
+} {11}
+
+# 2019-12-22 ticket 7929c1efb2d67e98
+#
+reset_db
+ifcapable vtab {
+do_execsql_test join-23.10 {
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES(123);
+ CREATE VIEW v0(c0) AS SELECT 0 GROUP BY 1;
+ SELECT t0.c0, v0.c0, vt0.name
+ FROM v0, t0 LEFT JOIN pragma_table_info('t0') AS vt0
+ ON vt0.name LIKE 'c0'
+ WHERE v0.c0 == 0;
+} {123 0 c0}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test join-24.1 {
+ CREATE TABLE t1(a PRIMARY KEY, x);
+ CREATE TABLE t2(b INT);
+ CREATE INDEX t1aa ON t1(a, a);
+
+ INSERT INTO t1 VALUES('abc', 'def');
+ INSERT INTO t2 VALUES(1);
+}
+
+do_execsql_test join-24.2 {
+ SELECT * FROM t2 JOIN t1 WHERE a='abc' AND x='def';
+} {1 abc def}
+do_execsql_test join-24.3 {
+ SELECT * FROM t2 JOIN t1 WHERE a='abc' AND x='abc';
+} {}
+
+do_execsql_test join-24.2 {
+ SELECT * FROM t2 LEFT JOIN t1 ON a=0 WHERE (x='x' OR x IS NULL);
+} {1 {} {}}
+
+# 2020-09-30 ticket 66e4b0e271c47145
+# The query flattener inserts an "expr AND expr" expression as a substitution
+# for the column of a view where that view column is part of an ON expression
+# of a LEFT JOIN.
+#
+reset_db
+do_execsql_test join-25.1 {
+ CREATE TABLE t0(c0 INT);
+ CREATE VIEW v0 AS SELECT (NULL AND 5) as c0 FROM t0;
+ INSERT INTO t0(c0) VALUES (NULL);
+ SELECT count(*) FROM v0 LEFT JOIN t0 ON v0.c0;
+} {1}
+
+# 2022-04-21 Parser issue detected by dbsqlfuzz
+#
+reset_db
+do_catchsql_test join-26.1 {
+ CREATE TABLE t4(a,b);
+ CREATE TABLE t5(a,c);
+ CREATE TABLE t6(a,d);
+ SELECT * FROM t5 JOIN ((t4 JOIN (t5 JOIN t6)) t7);
+} {/1 {.*}/}
+
+# 2022-06-09 Invalid subquery flattening caused by
+# check-in 3f45007d544e5f78 and detected by dbsqlfuzz
+#
+reset_db
+do_execsql_test join-27.1 {
+ CREATE TABLE t1(a INT,b INT,c INT); INSERT INTO t1 VALUES(NULL,NULL,NULL);
+ CREATE TABLE t2(d INT,e INT); INSERT INTO t2 VALUES(NULL,NULL);
+ CREATE INDEX x2 ON t1(c,b);
+ CREATE TABLE t3(x INT); INSERT INTO t3 VALUES(NULL);
+}
+do_execsql_test join-27.2 {
+ WITH t99(b) AS MATERIALIZED (
+ SELECT b FROM t2 LEFT JOIN t1 ON c IN (SELECT x FROM t3)
+ )
+ SELECT 5 FROM t2 JOIN t99 ON b IN (1,2,3);
+} {}
+do_execsql_test join-27.3 {
+ WITH t99(b) AS NOT MATERIALIZED (
+ SELECT b FROM t2 LEFT JOIN t1 ON c IN (SELECT x FROM t3)
+ )
+ SELECT 5 FROM t2 JOIN t99 ON b IN (1,2,3);
+} {}
+do_execsql_test join-27.4 {
+ WITH t99(b) AS (SELECT b FROM t2 LEFT JOIN t1 ON c IN (SELECT x FROM t3))
+ SELECT 5 FROM t2 JOIN t99 ON b IN (1,2,3);
+} {}
+do_execsql_test join-27.5 {
+ SELECT 5
+ FROM t2 JOIN (
+ SELECT b FROM t2 LEFT JOIN t1 ON c IN (SELECT x FROM t3)
+ ) AS t99 ON b IN (1,2,3);
+} {}
+
+db null NULL
+do_execsql_test join-27.6 {
+ INSERT INTO t1 VALUES(3,4,NULL);
+ INSERT INTO t2 VALUES(1,2);
+ WITH t99(b) AS (
+ SELECT coalesce(b,3) FROM t2 AS x LEFT JOIN t1 ON c IN (SELECT x FROM t3)
+ )
+ SELECT d, e, b FROM t2 JOIN t99 ON b IN (1,2,3) ORDER BY +d;
+} {NULL NULL 3 NULL NULL 3 1 2 3 1 2 3}
+do_execsql_test join-27.7 {
+ SELECT d, e, b2
+ FROM t2
+ JOIN (SELECT coalesce(b,3) AS b2 FROM t2 AS x LEFT JOIN t1
+ ON c IN (SELECT x FROM t3)) AS t99
+ ON b2 IN (1,2,3) ORDER BY +d;
+} {NULL NULL 3 NULL NULL 3 1 2 3 1 2 3}
+
+do_execsql_test join-27.8 {
+ DELETE FROM t1;
+ DELETE FROM t2 WHERE d IS NOT NULL;
+ DELETE FROM t3;
+ SELECT * FROM t2 JOIN (SELECT b FROM t2 LEFT JOIN t1
+ ON c IN (SELECT x FROM t3)) AS t99 ON b IN (1,2,3);
+} {}
+
+do_execsql_test join-27.9 {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ DELETE FROM t3;
+ INSERT INTO t1 VALUES(4,3,5);
+ INSERT INTO t2 VALUES(1,2);
+ INSERT INTO t3 VALUES(5);
+ SELECT * FROM t2 JOIN (SELECT b FROM t2 LEFT JOIN t1
+ ON c IN (SELECT x FROM t3)) AS t99 ON b IS NULL;
+} {}
+do_execsql_test join-27.10 {
+ WITH t99(b) AS (
+ SELECT b FROM t2 AS x LEFT JOIN t1 ON c IN (SELECT x FROM t3)
+ )
+ SELECT d, e, b FROM t2 JOIN t99 ON b IS NULL;
+} {}
+
+
+# 2022-09-19 https://sqlite.org/forum/forumpost/96b9e5709cf47cda
+# Performance regression relative to version 3.38.0 that resulted from
+# a new query flattener restriction that was added to fixes the join-27.*
+# tests above. The restriction needed to be removed and the join-27.*
+# problem fixed another way.
+#
+reset_db
+do_execsql_test join-28.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c INT);
+ CREATE TABLE t2(d INTEGER PRIMARY KEY, e INT);
+ CREATE VIEW t3(a,b,c,d,e) AS SELECT * FROM t1 LEFT JOIN t2 ON d=c;
+ CREATE TABLE t4(x INT, y INT);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t2 VALUES(1,5);
+ INSERT INTO t4 VALUES(1,4);
+ SELECT a, b, y FROM t4 JOIN t3 ON a=x;
+} {1 2 4}
+do_eqp_test join-28.2 {
+ SELECT a, b, y FROM t4 JOIN t3 ON a=x;
+} {
+ QUERY PLAN
+ |--SCAN t4
+ `--SEARCH t1 USING INTEGER PRIMARY KEY (rowid=?)
+}
+# ^^^^^^^ Without the fix (if the query flattening optimization does not
+# run) the query plan above would look like this:
+#
+# QUERY PLAN
+# |--MATERIALIZE t3
+# | |--SCAN t1
+# | `--SEARCH t2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN
+# |--SCAN t4
+# `--SEARCH t3 USING AUTOMATIC COVERING INDEX (a=?)
+
+finish_test
diff --git a/test/join2.test b/test/join2.test
new file mode 100644
index 0000000..e549c49
--- /dev/null
+++ b/test/join2.test
@@ -0,0 +1,358 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix join2
+
+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}
+do_test join2-1.6-rj {
+ execsql {
+ SELECT * FROM
+ t2 NATURAL RIGHT OUTER JOIN t1 NATURAL JOIN t3
+ }
+} {11 111 1 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 {} {}}
+ do_test join2-1.7-rj {
+ execsql {
+ SELECT a, b, c, d FROM
+ t2 NATURAL JOIN t3 NATURAL RIGHT JOIN t1
+ }
+ } {1 11 111 1111 2 22 {} {} 3 33 {} {}}
+}
+
+#-------------------------------------------------------------------------
+# Check that ticket [25e335f802ddc] has been resolved. It should be an
+# error for the ON clause of a LEFT JOIN to refer to a table to its right.
+#
+do_execsql_test 2.0 {
+ CREATE TABLE aa(a);
+ CREATE TABLE bb(b);
+ CREATE TABLE cc(c);
+ INSERT INTO aa VALUES('one');
+ INSERT INTO bb VALUES('one');
+ INSERT INTO cc VALUES('one');
+}
+
+do_catchsql_test 2.1 {
+ SELECT * FROM aa LEFT JOIN cc ON (a=b) JOIN bb ON (b=coalesce(c,1));
+} {1 {ON clause references tables to its right}}
+do_catchsql_test 2.1b {
+ SELECT * FROM aa RIGHT JOIN cc ON (a=b) JOIN bb ON (b=coalesce(c,1));
+} {1 {ON clause references tables to its right}}
+do_catchsql_test 2.2 {
+ SELECT * FROM aa JOIN cc ON (a=b) JOIN bb ON (b=c);
+} {0 {one one one}}
+
+#-------------------------------------------------------------------------
+# Test that a problem causing where.c to overlook opportunities to
+# omit unnecessary tables from a LEFT JOIN when UNIQUE, NOT NULL column
+# that makes this possible happens to be the leftmost in its table.
+#
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(k1 INTEGER PRIMARY KEY, k2, k3);
+ CREATE TABLE t2(k2 INTEGER PRIMARY KEY, v2);
+
+ -- Prior to this problem being fixed, table t3_2 would be omitted from
+ -- the join queries below, but if t3_1 were used in its place it would
+ -- not.
+ CREATE TABLE t3_1(k3 PRIMARY KEY, v3) WITHOUT ROWID;
+ CREATE TABLE t3_2(v3, k3 PRIMARY KEY) WITHOUT ROWID;
+}
+
+do_eqp_test 3.1 {
+ SELECT v2 FROM t1 LEFT JOIN t2 USING (k2) LEFT JOIN t3_1 USING (k3);
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SEARCH t2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN
+}
+
+do_eqp_test 3.2 {
+ SELECT v2 FROM t1 LEFT JOIN t2 USING (k2) LEFT JOIN t3_2 USING (k3);
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--SEARCH t2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN
+}
+
+#-------------------------------------------------------------------------
+# Test that tables other than the rightmost can be omitted from a
+# LEFT JOIN query.
+#
+do_execsql_test 4.0 {
+ CREATE TABLE c1(k INTEGER PRIMARY KEY, v1);
+ CREATE TABLE c2(k INTEGER PRIMARY KEY, v2);
+ CREATE TABLE c3(k INTEGER PRIMARY KEY, v3);
+
+ INSERT INTO c1 VALUES(1, 2);
+ INSERT INTO c2 VALUES(2, 3);
+ INSERT INTO c3 VALUES(3, 'v3');
+
+ INSERT INTO c1 VALUES(111, 1112);
+ INSERT INTO c2 VALUES(112, 1113);
+ INSERT INTO c3 VALUES(113, 'v1113');
+}
+do_execsql_test 4.1.1 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 ON (c2.k=v1) LEFT JOIN c3 ON (c3.k=v2);
+} {2 v3 1112 {}}
+do_execsql_test 4.1.2 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 ON (c2.k=v1) LEFT JOIN c3 ON (c3.k=v1+1);
+} {2 v3 1112 {}}
+
+do_execsql_test 4.1.3 {
+ SELECT DISTINCT v1, v3 FROM c1 LEFT JOIN c2 LEFT JOIN c3 ON (c3.k=v1+1);
+} {2 v3 1112 {}}
+
+do_execsql_test 4.1.4 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 LEFT JOIN c3 ON (c3.k=v1+1);
+} {2 v3 2 v3 1112 {} 1112 {}}
+
+do_eqp_test 4.1.5 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 ON (c2.k=v1) LEFT JOIN c3 ON (c3.k=v2);
+} {
+ QUERY PLAN
+ |--SCAN c1
+ |--SEARCH c2 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN
+ `--SEARCH c3 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN
+}
+do_eqp_test 4.1.6 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 ON (c2.k=v1) LEFT JOIN c3 ON (c3.k=v1+1);
+} {
+ QUERY PLAN
+ |--SCAN c1
+ `--SEARCH c3 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN
+}
+
+do_execsql_test 4.2.0 {
+ DROP TABLE c1;
+ DROP TABLE c2;
+ DROP TABLE c3;
+ CREATE TABLE c1(k UNIQUE, v1);
+ CREATE TABLE c2(k UNIQUE, v2);
+ CREATE TABLE c3(k UNIQUE, v3);
+
+ INSERT INTO c1 VALUES(1, 2);
+ INSERT INTO c2 VALUES(2, 3);
+ INSERT INTO c3 VALUES(3, 'v3');
+
+ INSERT INTO c1 VALUES(111, 1112);
+ INSERT INTO c2 VALUES(112, 1113);
+ INSERT INTO c3 VALUES(113, 'v1113');
+}
+do_execsql_test 4.2.1 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 ON (c2.k=v1) LEFT JOIN c3 ON (c3.k=v2);
+} {2 v3 1112 {}}
+do_execsql_test 4.2.2 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 ON (c2.k=v1) LEFT JOIN c3 ON (c3.k=v1+1);
+} {2 v3 1112 {}}
+
+do_execsql_test 4.2.3 {
+ SELECT DISTINCT v1, v3 FROM c1 LEFT JOIN c2 LEFT JOIN c3 ON (c3.k=v1+1);
+} {2 v3 1112 {}}
+
+do_execsql_test 4.2.4 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 LEFT JOIN c3 ON (c3.k=v1+1);
+} {2 v3 2 v3 1112 {} 1112 {}}
+
+do_eqp_test 4.2.5 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 ON (c2.k=v1) LEFT JOIN c3 ON (c3.k=v2);
+} {
+ QUERY PLAN
+ |--SCAN c1
+ |--SEARCH c2 USING INDEX sqlite_autoindex_c2_1 (k=?) LEFT-JOIN
+ `--SEARCH c3 USING INDEX sqlite_autoindex_c3_1 (k=?) LEFT-JOIN
+}
+do_eqp_test 4.2.6 {
+ SELECT v1, v3 FROM c1 LEFT JOIN c2 ON (c2.k=v1) LEFT JOIN c3 ON (c3.k=v1+1);
+} {
+ QUERY PLAN
+ |--SCAN c1
+ `--SEARCH c3 USING INDEX sqlite_autoindex_c3_1 (k=?) LEFT-JOIN
+}
+
+# 2017-11-23 (Thanksgiving day)
+# OSSFuzz found an assertion fault in the new LEFT JOIN eliminator code.
+#
+do_execsql_test 4.3.0 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(x PRIMARY KEY) WITHOUT ROWID;
+ CREATE TABLE t2(x);
+ SELECT a.x
+ FROM t1 AS a
+ LEFT JOIN t1 AS b ON (a.x=b.x)
+ LEFT JOIN t2 AS c ON (a.x=c.x);
+} {}
+do_execsql_test 4.3.1 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10)
+ INSERT INTO t1(x) SELECT x FROM c;
+ INSERT INTO t2(x) SELECT x+9 FROM t1;
+ SELECT a.x, c.x
+ FROM t1 AS a
+ LEFT JOIN t1 AS b ON (a.x=b.x)
+ LEFT JOIN t2 AS c ON (a.x=c.x);
+} {1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 10}
+
+do_execsql_test 5.0 {
+ CREATE TABLE s1 (a INTEGER PRIMARY KEY);
+ CREATE TABLE s2 (a INTEGER PRIMARY KEY);
+ CREATE TABLE s3 (a INTEGER);
+ CREATE UNIQUE INDEX ndx on s3(a);
+}
+do_eqp_test 5.1 {
+ SELECT s1.a FROM s1 left join s2 using (a);
+} {SCAN s1}
+
+do_eqp_test 5.2 {
+ SELECT s1.a FROM s1 left join s3 using (a);
+} {SCAN s1}
+
+do_execsql_test 6.0 {
+ CREATE TABLE u1(a INTEGER PRIMARY KEY, b, c);
+ CREATE TABLE u2(a INTEGER PRIMARY KEY, b, c);
+ CREATE INDEX u1ab ON u1(b, c);
+}
+do_eqp_test 6.1 {
+ SELECT u2.* FROM u2 LEFT JOIN u1 ON( u1.a=u2.a AND u1.b=u2.b AND u1.c=u2.c );
+} {SCAN u2}
+
+db close
+sqlite3 db :memory:
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2),(3,4),(5,6);
+ CREATE TABLE t2(c,d); INSERT INTO t2 VALUES(2,4),(3,6);
+ CREATE TABLE t3(x); INSERT INTO t3 VALUES(9);
+ CREATE VIEW test AS
+ SELECT *, 'x'
+ FROM t1 LEFT JOIN (SELECT * FROM t2, t3) ON (c=b AND x=9)
+ WHERE c IS NULL;
+ SELECT * FROM test;
+} {3 4 {} {} {} x 5 6 {} {} {} x}
+
+#-------------------------------------------------------------------------
+# Ticket [dfd66334].
+#
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE t0(c0);
+ CREATE TABLE t1(c0);
+}
+
+do_execsql_test 8.1 {
+ SELECT * FROM t0 LEFT JOIN t1
+ WHERE (t1.c0 BETWEEN 0 AND 0) > ('' AND t0.c0);
+}
+
+#-------------------------------------------------------------------------
+# Ticket [45f4bf4eb] reported by Manuel Rigger (2020-04-25)
+#
+# Follow up error reported by Eric Speckman on the SQLite forum
+# https://sqlite.org/forum/info/c49496d24d35bd7c (2020-08-19)
+#
+reset_db
+do_execsql_test 9.0 {
+ CREATE TABLE t0(c0 INT);
+ CREATE VIEW v0(c0) AS SELECT CAST(t0.c0 AS INTEGER) FROM t0;
+ INSERT INTO t0(c0) VALUES (0);
+}
+
+do_execsql_test 9.1 {
+ SELECT typeof(c0), c0 FROM v0 WHERE c0>='0'
+} {integer 0}
+
+do_execsql_test 9.2 {
+ SELECT * FROM t0, v0 WHERE v0.c0 >= '0';
+} {0 0}
+
+do_execsql_test 9.3 {
+ SELECT * FROM t0 LEFT JOIN v0 WHERE v0.c0 >= '0';
+} {0 0}
+
+do_execsql_test 9.4 {
+ SELECT * FROM t0 LEFT JOIN v0 ON v0.c0 >= '0';
+} {0 0}
+
+do_execsql_test 9.5 {
+ SELECT * FROM t0 LEFT JOIN v0 ON v0.c0 >= '0' WHERE TRUE
+ UNION SELECT 0,0 WHERE 0;
+} {0 0}
+
+do_execsql_test 9.10 {
+ CREATE TABLE t1 (aaa);
+ INSERT INTO t1 VALUES(23456);
+ CREATE TABLE t2(bbb);
+ CREATE VIEW v2(ccc) AS SELECT bbb IS 1234 FROM t2;
+ SELECT ccc, ccc IS NULL AS ddd FROM t1 LEFT JOIN v2;
+} {{} 1}
+optimization_control db query-flattener 0
+do_execsql_test 9.11 {
+ SELECT ccc, ccc IS NULL AS ddd FROM t1 LEFT JOIN v2;
+} {{} 1}
+
+
+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..2ffe3f8
--- /dev/null
+++ b/test/join5.test
@@ -0,0 +1,430 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix join5
+
+
+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}
+} {}
+
+# Ticket https://www.sqlite.org/src/tktview/6f2222d550f5b0ee7ed37601
+# Incorrect output on a LEFT JOIN.
+#
+do_execsql_test join5-3.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE x1(a);
+ INSERT INTO x1 VALUES(1);
+ CREATE TABLE x2(b NOT NULL);
+ CREATE TABLE x3(c, d);
+ INSERT INTO x3 VALUES('a', NULL);
+ INSERT INTO x3 VALUES('b', NULL);
+ INSERT INTO x3 VALUES('c', NULL);
+ SELECT * FROM x1 LEFT JOIN x2 LEFT JOIN x3 ON x3.d = x2.b;
+} {1 {} {} {}}
+do_execsql_test join5-3.2 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ DROP TABLE IF EXISTS t3;
+ DROP TABLE IF EXISTS t4;
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t1(x text NOT NULL, y text);
+ CREATE TABLE t2(u text NOT NULL, x text NOT NULL);
+ CREATE TABLE t3(w text NOT NULL, v text);
+ CREATE TABLE t4(w text NOT NULL, z text NOT NULL);
+ CREATE TABLE t5(z text NOT NULL, m text);
+ INSERT INTO t1 VALUES('f6d7661f-4efe-4c90-87b5-858e61cd178b',NULL);
+ INSERT INTO t1 VALUES('f6ea82c3-2cad-45ce-ae8f-3ddca4fb2f48',NULL);
+ INSERT INTO t1 VALUES('f6f47499-ecb4-474b-9a02-35be73c235e5',NULL);
+ INSERT INTO t1 VALUES('56f47499-ecb4-474b-9a02-35be73c235e5',NULL);
+ INSERT INTO t3 VALUES('007f2033-cb20-494c-b135-a1e4eb66130c',
+ 'f6d7661f-4efe-4c90-87b5-858e61cd178b');
+ SELECT *
+ FROM t3
+ INNER JOIN t1 ON t1.x= t3.v AND t1.y IS NULL
+ LEFT JOIN t4 ON t4.w = t3.w
+ LEFT JOIN t5 ON t5.z = t4.z
+ LEFT JOIN t2 ON t2.u = t5.m
+ LEFT JOIN t1 xyz ON xyz.y = t2.x;
+} {007f2033-cb20-494c-b135-a1e4eb66130c f6d7661f-4efe-4c90-87b5-858e61cd178b f6d7661f-4efe-4c90-87b5-858e61cd178b {} {} {} {} {} {} {} {} {}}
+do_execsql_test join5-3.3 {
+ DROP TABLE IF EXISTS x1;
+ DROP TABLE IF EXISTS x2;
+ DROP TABLE IF EXISTS x3;
+ CREATE TABLE x1(a);
+ INSERT INTO x1 VALUES(1);
+ CREATE TABLE x2(b NOT NULL);
+ CREATE TABLE x3(c, d);
+ INSERT INTO x3 VALUES('a', NULL);
+ INSERT INTO x3 VALUES('b', NULL);
+ INSERT INTO x3 VALUES('c', NULL);
+ SELECT * FROM x1 LEFT JOIN x2 JOIN x3 WHERE x3.d = x2.b;
+} {}
+
+# Ticket https://www.sqlite.org/src/tktview/c2a19d81652f40568c770c43 on
+# 2015-08-20. LEFT JOIN and the push-down optimization.
+#
+do_execsql_test join5-4.1 {
+ SELECT *
+ FROM (
+ SELECT 'apple' fruit
+ UNION ALL SELECT 'banana'
+ ) a
+ JOIN (
+ SELECT 'apple' fruit
+ UNION ALL SELECT 'banana'
+ ) b ON a.fruit=b.fruit
+ LEFT JOIN (
+ SELECT 1 isyellow
+ ) c ON b.fruit='banana';
+} {apple apple {} banana banana 1}
+do_execsql_test join5-4.2 {
+ SELECT *
+ FROM (SELECT 'apple' fruit UNION ALL SELECT 'banana')
+ LEFT JOIN (SELECT 1) ON fruit='banana';
+} {apple {} banana 1}
+
+#-------------------------------------------------------------------------
+do_execsql_test 5.0 {
+ CREATE TABLE y1(x, y, z);
+ INSERT INTO y1 VALUES(0, 0, 1);
+ CREATE TABLE y2(a);
+}
+
+do_execsql_test 5.1 {
+ SELECT count(z) FROM y1 LEFT JOIN y2 ON x GROUP BY y;
+} 1
+
+do_execsql_test 5.2 {
+ SELECT count(z) FROM ( SELECT * FROM y1 ) LEFT JOIN y2 ON x GROUP BY y;
+} 1
+
+do_execsql_test 5.3 {
+ CREATE VIEW v1 AS SELECT x, y, z FROM y1;
+ SELECT count(z) FROM v1 LEFT JOIN y2 ON x GROUP BY y;
+} 1
+
+do_execsql_test 5.4 {
+ SELECT count(z) FROM ( SELECT * FROM y1 ) LEFT JOIN y2 ON x
+} 1
+
+do_execsql_test 5.5 {
+ SELECT * FROM ( SELECT * FROM y1 ) LEFT JOIN y2 ON x
+} {0 0 1 {}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 6.1 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+
+ CREATE TABLE t2(y INTEGER PRIMARY KEY,a,b);
+ INSERT INTO t2 VALUES(1,2,3);
+ CREATE INDEX t2a ON t2(a);
+ CREATE INDEX t2b ON t2(b);
+}
+
+do_execsql_test 6.2 {
+ SELECT * FROM t1 LEFT JOIN t2 ON a=2 OR b=3 WHERE y IS NULL;
+} {}
+
+do_execsql_test 6.3.1 {
+ CREATE TABLE t3(x);
+ INSERT INTO t3 VALUES(1);
+ CREATE TABLE t4(y, z);
+ SELECT ifnull(z, '!!!') FROM t3 LEFT JOIN t4 ON (x=y);
+} {!!!}
+
+do_execsql_test 6.3.2 {
+ CREATE INDEX t4i ON t4(y, ifnull(z, '!!!'));
+ SELECT ifnull(z, '!!!') FROM t3 LEFT JOIN t4 ON (x=y);
+} {!!!}
+
+# 2019-02-08 https://sqlite.org/src/info/4e8e4857d32d401f
+reset_db
+do_execsql_test 6.100 {
+ CREATE TABLE t1(aa, bb);
+ CREATE INDEX t1x1 on t1(abs(aa), abs(bb));
+ INSERT INTO t1 VALUES(-2,-3),(+2,-3),(-2,+3),(+2,+3);
+ SELECT * FROM (t1)
+ WHERE ((abs(aa)=1 AND 1=2) OR abs(aa)=2)
+ AND abs(bb)=3
+ ORDER BY +1, +2;
+} {-2 -3 -2 3 2 -3 2 3}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+}
+
+do_execsql_test 7.1 {
+ CREATE TABLE t2(x, y, z);
+ CREATE INDEX t2xy ON t2(x, y);
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50000
+ )
+ INSERT INTO t2 SELECT i/10, i, NULL FROM s;
+ ANALYZE;
+}
+
+do_eqp_test 7.2 {
+ SELECT * FROM t1 LEFT JOIN t2 ON (
+ t2.x = t1.x AND (t2.y=? OR (t2.y=? AND t2.z IS NOT NULL))
+ );
+} {
+ QUERY PLAN
+ |--SCAN t1
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SEARCH t2 USING INDEX t2xy (x=? AND y=?) LEFT-JOIN
+ `--INDEX 2
+ `--SEARCH t2 USING INDEX t2xy (x=? AND y=?) LEFT-JOIN
+}
+
+do_execsql_test 7.3 {
+ CREATE TABLE t3(x);
+
+ CREATE TABLE t4(x, y, z);
+ CREATE INDEX t4xy ON t4(x, y);
+ CREATE INDEX t4xz ON t4(x, z);
+
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50000)
+ INSERT INTO t4 SELECT i/10, i, i FROM s;
+
+ ANALYZE;
+}
+
+do_eqp_test 7.4 {
+ SELECT * FROM t3 LEFT JOIN t4 ON (t4.x = t3.x) WHERE (t4.y = ? OR t4.z = ?);
+} {
+ QUERY PLAN
+ |--SCAN t3
+ `--SEARCH t4 USING INDEX t4xz (x=?) LEFT-JOIN
+}
+do_eqp_test 7.4b {
+ SELECT * FROM t3 CROSS JOIN t4 ON (t4.x = t3.x) WHERE (+t4.y = ? OR t4.z = ?);
+} {
+ QUERY PLAN
+ |--SCAN t3
+ |--BLOOM FILTER ON t4 (x=?)
+ `--SEARCH t4 USING INDEX t4xz (x=?)
+}
+
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE t0 (c0, c1, PRIMARY KEY (c0, c1));
+ CREATE TABLE t1 (c0);
+
+ INSERT INTO t1 VALUES (2);
+
+ INSERT INTO t0 VALUES(0, 10);
+ INSERT INTO t0 VALUES(1, 10);
+ INSERT INTO t0 VALUES(2, 10);
+ INSERT INTO t0 VALUES(3, 10);
+}
+
+do_execsql_test 8.1 {
+ SELECT * FROM t0, t1
+ WHERE (t0.c1 >= 1 OR t0.c1 < 1) AND t0.c0 IN (1, t1.c0) ORDER BY 1;
+} {
+ 1 10 2
+ 2 10 2
+}
+
+
+# 2022-01-31 dbsqlfuzz 787d9bd73164c6f0c85469e2e48b2aff19af6938
+#
+reset_db
+do_execsql_test 9.1 {
+ CREATE TABLE t1(a ,b FLOAT);
+ INSERT INTO t1 VALUES(1,1);
+ CREATE INDEX t1x1 ON t1(a,b,a,a,a,a,a,a,a,a,a,b);
+ ANALYZE sqlite_schema;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1x1','648 324 81 81 81 81 81 81 81081 81 81 81');
+ ANALYZE sqlite_schema;
+ SELECT a FROM (SELECT a FROM t1 NATURAL LEFT JOIN t1) NATURAL LEFT JOIN t1 WHERE (rowid,1)<=(5,0);
+} {1}
+
+# 2022-03-02 https://sqlite.org/forum/info/50a1bbe08ce4c29c
+# Bloom-filter pulldown is incompatible with skip-scan.
+#
+reset_db
+do_execsql_test 10.1 {
+ CREATE TABLE t1(x INT);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)
+ INSERT INTO t1(x) SELECT 0 FROM c;
+ CREATE INDEX t1x1 ON t1(x BETWEEN 0 AND 10, x);
+ ANALYZE;
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(0),(0);
+ CREATE VIEW v1 AS SELECT * FROM t1 NATURAL JOIN t1 WHERE (x BETWEEN 0 AND 10) OR true;
+ CREATE VIEW v2 AS SELECT * FROM v1 NATURAL JOIN v1;
+ CREATE VIEW v3 AS SELECT * FROM v2, v1 USING (x) GROUP BY x;
+ SELECT x FROM v3;
+} {0}
+
+# 2022-03-24 https://sqlite.org/forum/forumpost/031e262a89b6a9d2
+# Bloom-filter on a LEFT JOIN with NULL-based WHERE constraints.
+#
+reset_db
+do_execsql_test 11.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
+ CREATE TABLE t2(c INTEGER PRIMARY KEY, d INT);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<8)
+ INSERT INTO t1(a,b) SELECT x, 10*x FROM c;
+ INSERT INTO t2(c,d) SELECT b*2, 100*a FROM t1;
+ ANALYZE;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES
+ ('t1',NULL,150105),('t2',NULL,98747);
+ ANALYZE sqlite_schema;
+} {}
+do_execsql_test 11.2 {
+ SELECT count(*) FROM t1 LEFT JOIN t2 ON c=b WHERE d IS NULL;
+} {4}
+do_execsql_test 11.3 {
+ SELECT count(*) FROM t1 LEFT JOIN t2 ON c=b WHERE d=100;
+} {1}
+do_execsql_test 11.4 {
+ SELECT count(*) FROM t1 LEFT JOIN t2 ON c=b WHERE d>=300;
+} {2}
+
+# 2022-05-03 https://sqlite.org/forum/forumpost/2482b32700384a0f
+# Bloom-filter pull-down does not handle NOT NULL constraints correctly.
+#
+reset_db
+do_execsql_test 12.1 {
+ CREATE TABLE t1(a INT, b INT, c INT);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c) SELECT x, x*1000, x*1000000 FROM c;
+ CREATE TABLE t2(b INT, x INT);
+ INSERT INTO t2(b,x) SELECT b, a FROM t1 WHERE a%3==0;
+ CREATE INDEX t2b ON t2(b);
+ CREATE TABLE t3(c INT, y INT);
+ INSERT INTO t3(c,y) SELECT c, a FROM t1 WHERE a%4==0;
+ CREATE INDEX t3c ON t3(c);
+ INSERT INTO t1(a,b,c) VALUES(200, 200000, NULL);
+ ANALYZE;
+} {}
+do_execsql_test 12.2 {
+ SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3 WHERE x>0 AND y>0
+ ORDER BY +a;
+} {
+ 12 12000 12000000 12 12
+ 24 24000 24000000 24 24
+ 36 36000 36000000 36 36
+ 48 48000 48000000 48 48
+ 60 60000 60000000 60 60
+ 72 72000 72000000 72 72
+ 84 84000 84000000 84 84
+ 96 96000 96000000 96 96
+}
+
+
+
+
+finish_test
diff --git a/test/join6.test b/test/join6.test
new file mode 100644
index 0000000..802f1b3
--- /dev/null
+++ b/test/join6.test
@@ -0,0 +1,176 @@
+# 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}
+
+ifcapable compound {
+ 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}
+}
+
+do_execsql_test join6-5.1 {
+ CREATE TABLE tx(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o PRIMARY KEY)
+ WITHOUT ROWID;
+ INSERT INTO tx VALUES(
+ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+ );
+} {}
+do_execsql_test joint6-5.2 {
+ SELECT o FROM tx NATURAL JOIN tx;
+} {15}
+
+do_execsql_test join6-5.3 {
+ CREATE TABLE ty(a,Ñ,x6,x7,x8,Q,I,v,x1,L,E,x2,x3,x4,x5,s,g PRIMARY KEY,b,c)
+ WITHOUT ROWID;
+ SELECT a FROM ty NATURAL JOIN ty;
+}
+
+
+
+
+
+
+
+
+
+
+finish_test
diff --git a/test/join7.test b/test/join7.test
new file mode 100644
index 0000000..42cc357
--- /dev/null
+++ b/test/join7.test
@@ -0,0 +1,355 @@
+# 2022-04-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.
+#
+# This file implements tests for RIGHT and FULL OUTER JOINs.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+foreach {id schema} {
+ 1 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(1,2),(1,3),(1,4);
+ CREATE INDEX t1a ON t1(a);
+ CREATE TABLE t2(c INT, d INT);
+ INSERT INTO t2 VALUES(3,33),(4,44),(5,55);
+ CREATE INDEX t2c ON t2(c);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ }
+ 2 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(1,2),(1,3),(1,4);
+ CREATE INDEX t1ab ON t1(a,b);
+ CREATE TABLE t2(c INT, d INT);
+ INSERT INTO t2 VALUES(3,33),(4,44),(5,55);
+ CREATE INDEX t2cd ON t2(c,d);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ }
+ 3 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(1,2),(1,3),(1,4);
+ CREATE INDEX t1a ON t1(a);
+ CREATE TABLE t2(c INT, d INT PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t2 VALUES(3,33),(4,44),(5,55);
+ CREATE INDEX t2c ON t2(c);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ }
+ 4 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(1,2),(1,3),(1,4);
+ CREATE TABLE t2(c INTEGER PRIMARY KEY, d INT);
+ INSERT INTO t2 VALUES(3,33),(4,44),(5,55);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ }
+ 5 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(1,2),(1,3),(1,4);
+ CREATE TABLE t2(c INT PRIMARY KEY, d INT) WITHOUT ROWID;
+ INSERT INTO t2 VALUES(3,33),(4,44),(5,55);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ }
+ 6 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(1,2),(1,3),(1,4);
+ CREATE VIEW t2(c,d) AS VALUES(3,33),(4,44),(5,55);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ }
+ 7 {
+ CREATE VIEW t1(a,b) AS VALUES(1,2),(1,3),(1,4);
+ CREATE TABLE t2(c INTEGER PRIMARY KEY, d INT);
+ INSERT INTO t2 VALUES(3,33),(4,44),(5,55);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ }
+ 8 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(1,2),(1,3),(1,4);
+ CREATE TABLE t2(c INT, d INT);
+ INSERT INTO t2 VALUES(3,33),(4,44),(5,55);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ }
+ 9 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1 VALUES(1,2),(1,3),(1,4);
+ CREATE TABLE t2a(c INTEGER PRIMARY KEY, i1 INT);
+ CREATE TABLE t2b(i1 INTEGER PRIMARY KEY, d INT);
+ CREATE VIEW t2(c,d) AS SELECT c, d FROM t2a NATURAL JOIN t2b;
+ INSERT INTO t2a VALUES(3,93),(4,94),(5,95),(6,96),(7,97);
+ INSERT INTO t2b VALUES(91,11),(92,22),(93,33),(94,44),(95,55);
+ CREATE TABLE dual(dummy TEXT);
+ INSERT INTO dual(dummy) VALUES('x');
+ }
+ 10 {
+ CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a,b)) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1,2),(1,3),(1,4);
+ CREATE TABLE t2a(c INTEGER PRIMARY KEY, i1 INT);
+ CREATE TABLE t2b(i1 INTEGER PRIMARY KEY, d INT);
+ CREATE VIEW t2(c,d) AS SELECT c, d FROM t2a NATURAL JOIN t2b;
+ INSERT INTO t2a VALUES(3,93),(4,94),(5,95),(6,96),(7,97);
+ INSERT INTO t2b VALUES(91,11),(92,22),(93,33),(94,44),(95,55);
+ CREATE TABLE dual(dummy TEXT);
+ INSERT INTO dual(dummy) VALUES('x');
+ }
+} {
+ reset_db
+ db nullvalue NULL
+ do_execsql_test join7-$id.setup $schema {}
+
+ # Verified against PG-14 for case 1
+ do_execsql_test join7-$id.10 {
+ SELECT b, d FROM t1 FULL OUTER JOIN t2 ON b=c ORDER BY +b;
+ } {
+ NULL 55
+ 2 NULL
+ 3 33
+ 4 44
+ }
+
+ # Verified against PG-14 for case 1
+ do_execsql_test join7-$id.20 {
+ SELECT a, c FROM t1 FULL OUTER JOIN t2 ON b=c ORDER BY +b;
+ } {
+ NULL 5
+ 1 NULL
+ 1 3
+ 1 4
+ }
+
+ do_execsql_test join7-$id.30 {
+ SELECT * FROM t1 FULL OUTER JOIN t2 ON b=c ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.31 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.32 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c
+ WHERE b=c
+ ORDER BY +b;
+ } {
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.33 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c
+ WHERE b>0
+ ORDER BY +b;
+ } {
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.34 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c
+ WHERE b>0 OR b IS NULL
+ ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.35 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c AND b>3 AND c>4
+ ORDER BY coalesce(b,c,0);
+ } {
+ 1 2 NULL NULL
+ NULL NULL 3 33
+ 1 3 NULL NULL
+ NULL NULL 4 44
+ 1 4 NULL NULL
+ NULL NULL 5 55
+ }
+ do_execsql_test join7-$id.36 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c AND b>3 WHERE c>4
+ ORDER BY coalesce(b,c,0);
+ } {
+ NULL NULL 5 55
+ }
+ do_execsql_test join7-$id.37 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c WHERE b>3 AND c>4
+ ORDER BY coalesce(b,c,0);
+ } {
+ }
+ do_execsql_test join7-$id.38 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c WHERE b>3 OR c>4
+ ORDER BY coalesce(b,c,0);
+ } {
+ 1 4 4 44
+ NULL NULL 5 55
+ }
+ do_execsql_test join7-$id.39 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c AND (b>3 OR c>4)
+ ORDER BY coalesce(b,c,0);
+ } {
+ 1 2 NULL NULL
+ NULL NULL 3 33
+ 1 3 NULL NULL
+ 1 4 4 44
+ NULL NULL 5 55
+ }
+ do_execsql_test join7-$id.40 {
+ SELECT * FROM t1 RIGHT OUTER JOIN t2 ON b=c ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.50 {
+ SELECT t1.*, t2.* FROM t2 LEFT OUTER JOIN t1 ON b=c ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.60 {
+ SELECT * FROM dual JOIN t1 ON true RIGHT OUTER JOIN t2 ON b=c ORDER BY +b;
+ } {
+ NULL NULL NULL 5 55
+ x 1 3 3 33
+ x 1 4 4 44
+ }
+ do_execsql_test join7-$id.70 {
+ SELECT t1.*, t2.*
+ FROM t2 LEFT JOIN (dual JOIN t1 ON true) ON b=c ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.80 {
+ SELECT * FROM dual CROSS JOIN t1 RIGHT OUTER JOIN t2 ON b=c ORDER BY +b;
+ } {
+ NULL NULL NULL 5 55
+ x 1 3 3 33
+ x 1 4 4 44
+ }
+ do_execsql_test join7-$id.81 {
+ SELECT dual.*, t1.*, t2.*
+ FROM t1 CROSS JOIN dual RIGHT OUTER JOIN t2 ON b=c ORDER BY +b;
+ } {
+ NULL NULL NULL 5 55
+ x 1 3 3 33
+ x 1 4 4 44
+ }
+ do_execsql_test join7-$id.90 {
+ SELECT * FROM t1 LEFT OUTER JOIN t2 ON b=c ORDER BY +b;
+ } {
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.100 {
+ SELECT * FROM t1 FULL OUTER JOIN t2 ON b=c AND a=1 ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+ do_execsql_test join7-$id.101 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c AND a=1 ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+
+ # Verified against PG-14 for case 1
+ do_execsql_test join7-$id.110 {
+ SELECT * FROM t1 FULL OUTER JOIN t2 ON b=c WHERE a=1 ORDER BY +b;
+ } {
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+
+ do_execsql_test join7-$id.111 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c WHERE a=1 ORDER BY +b;
+ } {
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+
+ # Verified against PG-14 for case 1
+ do_execsql_test join7-$id.115 {
+ SELECT * FROM t1 FULL OUTER JOIN t2 ON b=c
+ WHERE a=1 OR a IS NULL ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+
+ do_execsql_test join7-$id.116 {
+ SELECT t1.*, t2.* FROM t2 FULL OUTER JOIN t1 ON b=c
+ WHERE a=1 OR a IS NULL ORDER BY +b;
+ } {
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ 1 3 3 33
+ 1 4 4 44
+ }
+
+ # Verified against PG-14 for case 1:
+ do_execsql_test join7-$id.120 {
+ SELECT * FROM t1 FULL OUTER JOIN t2 ON b=c WHERE a IS NULL ORDER BY +d;
+ } {
+ NULL NULL 5 55
+ }
+
+ # Verified against PG-14 for case 1:
+ do_execsql_test join7-$id.130 {
+ SELECT * FROM t1 FULL OUTER JOIN t2 ON b=c AND d<=0 ORDER BY +b, +d;
+ } {
+ NULL NULL 3 33
+ NULL NULL 4 44
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ 1 3 NULL NULL
+ 1 4 NULL NULL
+ }
+
+ # Verified against PG-14 for case 1:
+ do_execsql_test join7-$id.140 {
+ SELECT a, b, c, d
+ FROM t2 FULL OUTER JOIN t1 ON b=c AND d<=0 ORDER BY +b, +d;
+ } {
+ NULL NULL 3 33
+ NULL NULL 4 44
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ 1 3 NULL NULL
+ 1 4 NULL NULL
+ }
+
+ do_execsql_test join7-$id.141 {
+ SELECT a, b, c, d
+ FROM t2 FULL OUTER JOIN t1 ON b=c AND d<=0
+ ORDER BY +b, +d LIMIT 2 OFFSET 2
+ } {
+ NULL NULL 5 55
+ 1 2 NULL NULL
+ }
+}
+finish_test
diff --git a/test/join8.test b/test/join8.test
new file mode 100644
index 0000000..4814305
--- /dev/null
+++ b/test/join8.test
@@ -0,0 +1,804 @@
+# 2022-04-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 tests for RIGHT and FULL OUTER JOINs.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+db null NULL
+# EVIDENCE-OF: R-33754-02880 you can say "LEFT RIGHT JOIN" which is the
+# same as "FULL JOIN".
+do_execsql_test join8-10 {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE t2(x,y);
+ CREATE INDEX t2x ON t2(x);
+ SELECT avg(DISTINCT b) FROM (SELECT * FROM t2 LEFT RIGHT JOIN t1 ON c);
+} {NULL}
+
+# Pending optimization opportunity:
+# Row-value initialization subroutines must be called from with the
+# RIGHT JOIN body subroutine before the first use of any register containing
+# the results of that subroutine. This seems dodgy. Test case:
+#
+reset_db
+do_execsql_test join8-1000 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT,b,c,d,e,f,g,h,j,k,l,m,n,o,p,q,r,s);
+ CREATE INDEX t1x1 ON t1(g+h,j,k);
+ CREATE INDEX t1x2 ON t1(b);
+ INSERT INTO t1 DEFAULT VALUES;
+} {}
+do_catchsql_test join8-1010 {
+ SELECT a
+ FROM (
+ SELECT a
+ FROM (
+ SELECT a
+ FROM (
+ SELECT a FROM t1 NATURAL LEFT JOIN t1
+ WHERE (b, 2 ) IS ( SELECT 2 IN(2,2),2)
+ )
+ NATURAL LEFT FULL JOIN t1
+ WHERE ( rowid , 1 )<=(CASE 5 WHEN 619 THEN 841 ELSE 3374391096 END,0)
+ ORDER BY a ASC
+ )
+ NATURAL LEFT JOIN t1
+ WHERE (b, 2 ) IS ( SELECT 3 IN(3,3),3)
+ )
+ NATURAL LEFT FULL JOIN t1
+ WHERE ( rowid , 1 )<=(CASE 5 WHEN 619 THEN 841 ELSE 3374391096 END,0)
+ ORDER BY a ASC;
+} {0 1}
+
+# Pending issue #2: (now resolved)
+# Jump to addrHalt inside the RIGHT JOIN body subroutine bypasses the
+# OP_Return, resulting in a subroutine loop. Test case:
+#
+reset_db
+do_execsql_test join8-2000 {
+ CREATE TABLE t1(a int, b int, c int);
+ INSERT INTO t1 VALUES(1,2,3),(4,5,6);
+ CREATE TABLE t2(d int, e int);
+ INSERT INTO t2 VALUES(3,333),(4,444);
+ CREATE TABLE t3(f int, g int);
+ PRAGMA automatic_index=off;
+} {}
+do_catchsql_test join8-2010 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON c=d JOIN t3 ON f=e;
+} {0 {}}
+
+# Demonstrate that nested FULL JOINs and USING clauses work
+#
+reset_db
+load_static_extension db series
+do_execsql_test join8-3000 {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, a INT);
+ CREATE TABLE t2(id INTEGER PRIMARY KEY, b INT);
+ CREATE TABLE t3(id INTEGER PRIMARY KEY, c INT);
+ CREATE TABLE t4(id INTEGER PRIMARY KEY, d INT);
+ CREATE TABLE t5(id INTEGER PRIMARY KEY, e INT);
+ CREATE TABLE t6(id INTEGER PRIMARY KEY, f INT);
+ CREATE TABLE t7(id INTEGER PRIMARY KEY, g INT);
+ CREATE TABLE t8(id INTEGER PRIMARY KEY, h INT);
+ INSERT INTO t1 SELECT value, 1 FROM generate_series(1,256) WHERE value & 1;
+ INSERT INTO t2 SELECT value, 1 FROM generate_series(1,256) WHERE value & 2;
+ INSERT INTO t3 SELECT value, 1 FROM generate_series(1,256) WHERE value & 4;
+ INSERT INTO t4 SELECT value, 1 FROM generate_series(1,256) WHERE value & 8;
+ INSERT INTO t5 SELECT value, 1 FROM generate_series(1,256) WHERE value & 16;
+ INSERT INTO t6 SELECT value, 1 FROM generate_series(1,256) WHERE value & 32;
+ INSERT INTO t7 SELECT value, 1 FROM generate_series(1,256) WHERE value & 64;
+ INSERT INTO t8 SELECT value, 1 FROM generate_series(1,256) WHERE value & 128;
+ CREATE TABLE t9 AS
+ SELECT id, h, g, f, e, d, c, b, a
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ NATURAL FULL JOIN t6
+ NATURAL FULL JOIN t7
+ NATURAL FULL JOIN t8;
+} {}
+do_execsql_test join8-3010 {
+ SELECT count(*) FROM t9;
+} {255}
+do_execsql_test join8-3020 {
+ SELECT id, count(*) FROM t9 GROUP BY id HAVING count(*)!=1;
+} {}
+do_execsql_test join8-3030 {
+ UPDATE t9 SET a=0 WHERE a IS NULL;
+ UPDATE t9 SET b=0 WHERE b IS NULL;
+ UPDATE t9 SET c=0 WHERE c IS NULL;
+ UPDATE t9 SET d=0 WHERE d IS NULL;
+ UPDATE t9 SET e=0 WHERE e IS NULL;
+ UPDATE t9 SET f=0 WHERE f IS NULL;
+ UPDATE t9 SET g=0 WHERE g IS NULL;
+ UPDATE t9 SET h=0 WHERE h IS NULL;
+ SELECT count(*) FROM t9 WHERE id=128*h+64*g+32*f+16*e+8*d+4*c+2*b+a;
+} {255}
+do_execsql_test join8-3040 {
+ SELECT * FROM t9 WHERE id<>128*h+64*g+32*f+16*e+8*d+4*c+2*b+a;
+} {}
+
+# 2022-04-21 dbsqlfuzz find
+#
+reset_db
+do_execsql_test join8-4000 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, a, b);
+ INSERT INTO t1 VALUES(1,5555,4);
+ CREATE INDEX i1a ON t1(a);
+ CREATE INDEX i1b ON t1(b);
+ SELECT a FROM t1 NATURAL RIGHT JOIN t1 WHERE a=5555 OR (1,b)==(SELECT 2 IN (2,2),4);
+} {5555}
+
+# 2022-04-23 dbsqlfuzz c7ee5500e3abddec3557016de777713b80c790d3
+# Escape from the right-join body subroutine via the ORDER BY LIMIT optimization.
+#
+reset_db
+db null -
+do_catchsql_test join8-5000 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(NULL),(NULL);
+ CREATE TABLE t2(c, d);
+ INSERT INTO t2(c,d) SELECT x, x FROM t1;
+ CREATE INDEX t2dc ON t2(d, c);
+ SELECT (SELECT c FROM sqlite_temp_schema FULL JOIN t2 ON d IN (1,2,3) ORDER BY d) AS x FROM t1;
+} {0 {- -}}
+
+# 2022-04-29 dbsqlfuzz 19f1102a70cf966ab249de56d944fc20dbebcfcf
+#
+reset_db
+do_execsql_test join8-6000 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d REAL);
+ INSERT INTO t1 VALUES(1,'A','aa',2.5);
+ SELECT * FROM t1 AS t2 NATURAL RIGHT JOIN t1 AS t3
+ WHERE (a,b) IN (SELECT rowid, b FROM t1);
+} {1 A aa 2.5}
+do_execsql_test join8-6010 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INT PRIMARY KEY, b TEXT, c TEXT, d INT) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(15,'xray','baker',42);
+ SELECT value, t1.* FROM json_each('7') NATURAL RIGHT JOIN t1
+ WHERE (a,b) IN (SELECT a, b FROM t1);
+} {7 15 xray baker 42}
+do_execsql_test join8-6020 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b);
+ INSERT INTO t1 VALUES(0,NULL),(1,2);
+ SELECT value, t1.* FROM json_each('17') NATURAL RIGHT JOIN t1
+ WHERE (a,b) IN (SELECT rowid, b FROM t1);
+} {17 1 2}
+
+# Bloom filter usage by RIGHT and FULL JOIN
+#
+reset_db
+do_execsql_test join8-7000 {
+CREATE TABLE t1(a INT, b INT, c INT, d INT);
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<10)
+ INSERT INTO t1(a,b,c,d) SELECT x, x+100, x+200, x+300 FROM c;
+ CREATE TABLE t2(b INT, x INT);
+ INSERT INTO t2(b,x) SELECT b, a FROM t1 WHERE a%2=0;
+ CREATE INDEX t2b ON t2(b);
+ CREATE TABLE t3(c INT, y INT);
+ INSERT INTO t3(c,y) SELECT c, a FROM t1 WHERE a%3=0;
+ CREATE INDEX t3c ON t3(c);
+ CREATE TABLE t4(d INT, z INT);
+ INSERT INTO t4(d,z) SELECT d, a FROM t1 WHERE a%5=0;
+ CREATE INDEX t4d ON t4(d);
+ INSERT INTO t1(a,b,c,d) VALUES
+ (96,NULL,296,396),
+ (97,197,NULL,397),
+ (98,198,298,NULL),
+ (99,NULL,NULL,NULL);
+ ANALYZE sqlite_schema;
+ INSERT INTO sqlite_stat1 VALUES('t4','t4d','20 1');
+ INSERT INTO sqlite_stat1 VALUES('t3','t3c','32 1');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2b','48 1');
+ INSERT INTO sqlite_stat1 VALUES('t1',NULL,'100');
+ ANALYZE sqlite_schema;
+} {}
+db null -
+do_execsql_test join8-7010 {
+ WITH t0 AS MATERIALIZED (
+ SELECT t1.*, t2.*, t3.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ )
+ SELECT * FROM t0 FULL JOIN t4 ON t0.a=t4.d AND t4.z>0
+ ORDER BY coalesce(t0.a, t0.y+200, t4.d);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+}
+
+# EVIDENCE-OF: R-33754-02880 you can say "LEFT RIGHT JOIN" which is the
+# same as "FULL JOIN".
+do_execsql_test join8-7011 {
+ WITH t0 AS MATERIALIZED (
+ SELECT t1.*, t2.*, t3.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ )
+ SELECT * FROM t0 LEFT RIGHT JOIN t4 ON t0.a=t4.d AND t4.z>0
+ ORDER BY coalesce(t0.a, t0.y+200, t4.d);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+}
+
+do_execsql_test join8-7020 {
+ EXPLAIN QUERY PLAN
+ WITH t0 AS MATERIALIZED (
+ SELECT t1.*, t2.*, t3.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ )
+ SELECT * FROM t0 FULL JOIN t4 ON t0.a=t4.d AND t4.z>0
+ ORDER BY coalesce(t0.a, t0.y+200, t4.d);
+} {/.*BLOOM FILTER ON t2.*BLOOM FILTER ON t3.*BLOOM FILTER ON t4.*/}
+
+# 2022-05-12 Difference with PG found (by Dan) while exploring
+# https://sqlite.org/forum/forumpost/677a0ab93fcd9ccd
+#
+reset_db
+do_execsql_test join8-8000 {
+ CREATE TABLE t1(a INT, b INT);
+ CREATE TABLE t2(c INT, d INT);
+ CREATE TABLE t3(e INT, f INT);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ INSERT INTO t3 VALUES(5, 6);
+} {}
+do_execsql_test join8-8010 {
+ SELECT *
+ FROM t3 LEFT JOIN t2 ON true
+ JOIN t1 ON (t3.e IS t2.c);
+} {}
+do_execsql_test join8-8020 {
+ SELECT *
+ FROM t3 LEFT JOIN t2 ON true
+ JOIN t1 ON (t3.e IS NOT DISTINCT FROM t2.c);
+} {}
+
+# 2022-05-13 The idea of reusing subquery cursors does not
+# work, if the cursors are used both for scanning and lookups.
+#
+reset_db
+db null -
+do_execsql_test join8-9000 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d REAL);
+ INSERT INTO t1 VALUES(1,'E','bb',NULL),(2,NULL,NULL,NULL);
+ SELECT * FROM t1 NATURAL RIGHT JOIN t1 AS t2 WHERE (a,b) IN (SELECT a+0, b FROM t1);
+} {1 E bb -}
+
+# 2022-05-14 https://sqlite.org/forum/forumpost/c06b10ad7e
+#
+reset_db
+db null -
+do_execsql_test join8-10000 {
+ CREATE TABLE t1(c0 INT UNIQUE);
+ CREATE TABLE t2(c0);
+ CREATE TABLE t2i(c0 INT);
+ CREATE TABLE t3(c0 INT);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ INSERT INTO t2i VALUES(2);
+ INSERT INTO t3 VALUES(3);
+} {}
+do_execsql_test join8-10010 {
+ SELECT DISTINCT t1.c0, t3.c0
+ FROM t2 NATURAL JOIN t1 RIGHT JOIN t3 ON t1.c0;
+} {- 3}
+do_execsql_test join8-10020 {
+ SELECT t1.c0, t3.c0
+ FROM t2 NATURAL JOIN t1 RIGHT JOIN t3 ON t1.c0;
+} {- 3}
+do_execsql_test join8-10030 {
+ SELECT DISTINCT t1.c0, t3.c0
+ FROM t2 NATURAL CROSS JOIN t1 RIGHT JOIN t3 ON t1.c0;
+} {- 3}
+do_execsql_test join8-10040 {
+ SELECT t1.c0, t3.c0
+ FROM t1 NATURAL CROSS JOIN t2 RIGHT JOIN t3 ON t1.c0;
+} {- 3}
+do_execsql_test join8-10050 {
+ SELECT DISTINCT t1.c0, t3.c0
+ FROM t2i NATURAL JOIN t1 RIGHT JOIN t3 ON t1.c0;
+} {- 3}
+do_execsql_test join8-10060 {
+ SELECT DISTINCT +t1.c0, t3.c0
+ FROM t2 NATURAL JOIN t1 RIGHT JOIN t3 ON t1.c0;
+} {- 3}
+do_execsql_test join8-10070 {
+ SELECT DISTINCT +t1.c0, t3.c0
+ FROM t1 NATURAL CROSS JOIN t2 RIGHT JOIN t3 ON t1.c0;
+} {- 3}
+do_execsql_test join8-10080 {
+ SELECT DISTINCT t1.c0, t3.c0
+ FROM t2 NATURAL JOIN t1 RIGHT JOIN t3 ON t1.c0<>0;
+} {- 3}
+
+# 2022-05-14
+# index-on-expr scan on a RIGHT JOIN
+# dbsqlfuzz 39ee60004ff027a9e2846cf76e02cd5ac0953739
+#
+reset_db
+db null -
+do_execsql_test join8-11000 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b);
+ INSERT INTO t2 VALUES(0),(1),(2);
+ SELECT * FROM t1 RIGHT JOIN t2 ON (a=b) WHERE 99+(b+1)!=99;
+} {- 0 - 1 - 2}
+do_execsql_test join8-11010 {
+ CREATE INDEX t2b ON t2(b+1) WHERE b IS NOT NULL;
+ SELECT * FROM t1 RIGHT JOIN t2 ON (a=b) WHERE 99+(b+1)!=99;
+} {- 0 - 1 - 2}
+do_execsql_test join8-11020 {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b, c, d);
+ INSERT INTO t2 VALUES(1, 3, 'not-4');
+ SELECT b, d FROM t1 RIGHT JOIN t2 WHERE (b+0)=1 AND d!=4;
+} {1 not-4}
+do_execsql_test join8-11030 {
+ CREATE INDEX i2 ON t2((b+0), d);
+ SELECT b, d FROM t1 RIGHT JOIN t2 WHERE (b+0)=1 AND d!=4;
+} {1 not-4}
+do_execsql_test join8-11040 {
+ DROP INDEX i2;
+ CREATE INDEX i2 ON t2((b+0), d) WHERE d IS NOT NULL;
+ SELECT b, d FROM t1 RIGHT JOIN t2 WHERE (b+0)=1 AND d!=4;
+} {1 not-4}
+
+# 2022-05-23
+# NATURAL JOIN name resolution is more forgiving with LEFT JOIN
+# https://sqlite.org/forum/forumpost/e90a8e6e6f
+#
+reset_db
+db null -
+do_execsql_test join8-12000 {
+ CREATE TABLE t1(a INT); INSERT INTO t1 VALUES(0),(1);
+ CREATE TABLE t2(a INT); INSERT INTO t2 VALUES(0),(2);
+ CREATE TABLE t3(a INT); INSERT INTO t3 VALUES(0),(3);
+} {}
+do_catchsql_test join8-12010 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON t2.a<>0 NATURAL RIGHT JOIN t3;
+} {1 {ambiguous reference to a in USING()}}
+do_catchsql_test join8-12020 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON t2.a<>0 NATURAL LEFT JOIN t3;
+} {1 {ambiguous reference to a in USING()}}
+do_catchsql_test join8-12030 {
+ SELECT * FROM t1 LEFT JOIN t2 ON t2.a<>0 NATURAL RIGHT JOIN t3;
+} {1 {ambiguous reference to a in USING()}}
+
+# The following query should probably also return the same error as the
+# previous three cases. However, historical versions of SQLite have always
+# let it pass. We will not "fix" this, since to do so might break legacy
+# applications.
+#
+do_catchsql_test join8-12040 {
+ SELECT * FROM t1 LEFT JOIN t2 ON t2.a<>0 NATURAL LEFT JOIN t3;
+} {0 {0 2 1 2}}
+
+# 2022-05-24
+# https://sqlite.org/forum/forumpost/687b0bf563a1d4f1
+#
+reset_db
+do_execsql_test join8-13000 {
+ CREATE TABLE t0(t TEXT, u TEXT); INSERT INTO t0 VALUES('t', 'u');
+ CREATE TABLE t1(v TEXT, w TEXT); INSERT INTO t1 VALUES('v', 'w');
+ CREATE TABLE t2(x TEXT, y TEXT); INSERT INTO t2 VALUES('x', 'y');
+ SELECT * FROM t0 JOIN t1 ON (t2.x NOTNULL) LEFT JOIN t2 ON false;
+ SELECT * FROM t0 JOIN t1 ON (t2.x NOTNULL) LEFT JOIN t2 ON false
+ WHERE t2.y ISNULL;
+} {}
+
+# 2022-05-25
+# https://sqlite.org/forum/forumpost/5cfe08eed6
+#
+reset_db
+do_execsql_test join8-14000 {
+ CREATE TABLE t0(a TEXT, b TEXT, c TEXT);
+ CREATE TABLE t1(a TEXT);
+ INSERT INTO t1 VALUES('1');
+ CREATE VIEW v0 AS SELECT 'xyz' AS d;
+ SELECT * FROM v0 RIGHT JOIN t1 ON t1.a<>'' INNER JOIN t0 ON t0.c<>'';
+ SELECT * FROM v0 RIGHT JOIN t1 ON t1.a<>'' INNER JOIN t0 ON t0.c<>'' WHERE b ISNULL;
+} {}
+do_execsql_test join8-14010 {
+ CREATE TABLE y0(a INT);
+ CREATE TABLE y1(b INT); INSERT INTO y1 VALUES(1), (2);
+ CREATE TABLE y2(c INT); INSERT INTO y2 VALUES(3), (4);
+} {}
+db null -
+do_execsql_test join8-14020 {
+ SELECT * FROM y0 RIGHT JOIN y1 ON true INNER JOIN y2 ON true WHERE y2.c!=99 AND y2.c!=98;
+} {
+ - 1 3
+ - 1 4
+ - 2 3
+ - 2 4
+}
+
+# 2022-05-30
+# https://sqlite.org/forum/forumpost/3902c7b833
+#
+reset_db
+do_execsql_test join8-15000 {
+ CREATE TABLE t1(x INT);
+ CREATE TABLE t2(y INT);
+ CREATE TABLE t3(z INT);
+ INSERT INTO t1 VALUES(10);
+ INSERT INTO t3 VALUES(20),(30);
+}
+do_execsql_test join8-15010 {
+ SELECT * FROM t1 LEFT JOIN t2 ON true JOIN t3 ON t2.y IS NOT NULL;
+} {}
+do_execsql_test join8-15020 {
+ SELECT * FROM t1 LEFT JOIN t2 ON true JOIN t3 ON t2.y IS NOT NULL
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600);
+} {}
+do_execsql_test join8-15100 {
+ PRAGMA automatic_index = 0;
+ CREATE TABLE t4(x TEXT);
+ CREATE TABLE t5(y TEXT);
+ CREATE TABLE t6(z TEXT);
+ INSERT INTO t4 VALUES('a'), ('b');
+ INSERT INTO t5 VALUES('b'), ('c');
+ INSERT INTO t6 VALUES('a'), ('d');
+} {}
+db null -
+do_execsql_test join8-15110 {
+ SELECT * FROM t4 LEFT JOIN t5 ON x=y LEFT JOIN t6 ON (x=z) ORDER BY +x;
+} {a - a b b -}
+do_execsql_test join8-15120 {
+ SELECT * FROM t4 LEFT JOIN t5 ON x=y LEFT JOIN t6 ON (x=z)
+ WHERE t5.y!='x' AND t4.x!='x';
+} {b b -}
+
+# 2022-05-31
+# https://sqlite.org/forum/forumpost/c2554d560b
+reset_db
+do_execsql_test join8-16000 {
+ CREATE TABLE t1(a TEXT);
+ CREATE TABLE t2(b TEXT);
+ CREATE TABLE t3(c TEXT);
+ INSERT INTO t2(b) VALUES ('x');
+ INSERT INTO t3(c) VALUES ('y'), ('z');
+} {}
+db null -
+do_execsql_test join8-16010 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON true LEFT JOIN t3 ON a<>'';
+} {- x -}
+do_execsql_test join8-16020 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON true LEFT JOIN t3 ON a<>'' WHERE c IS NULL;
+} {- x -}
+do_execsql_test join8-16020 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON true JOIN t3 ON a<>'' WHERE c IS NULL;
+} {}
+do_execsql_test join8-16030 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON true JOIN t3 ON a<>'';
+} {}
+do_execsql_test join8-16040 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON true LEFT JOIN t3 ON a<>'' WHERE c<>'';
+} {}
+do_execsql_test join8-16050 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON true LEFT JOIN t3 ON a<>'' WHERE c IS NOT NULL;
+} {}
+do_execsql_test join8-16060 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON true JOIN t3 ON a<>'' WHERE c<>'';
+} {}
+do_execsql_test join8-16070 {
+ SELECT * FROM t1 RIGHT JOIN t2 ON true JOIN t3 ON a<>'' WHERE c IS NOT NULL;
+} {}
+
+# 2022-06-01
+# https://sqlite.org/forum/forumpost/087de2d9ec
+#
+reset_db
+do_execsql_test join8-17000 {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, x INT, y INT);
+ CREATE TABLE t2(z INT);
+ INSERT INTO t1(id,x,y) VALUES(1, 0, 0);
+} {}
+db null NULL
+do_execsql_test join8-17010 {
+ SELECT * FROM t2 RIGHT JOIN t1 ON true;
+} {NULL 1 0 0}
+do_execsql_test join8-17020 {
+ SELECT 99=id AND 0=y AS "truth" FROM t2 RIGHT JOIN t1 ON true;
+} {0}
+do_execsql_test join8-17030 {
+ SELECT (99, 0)==(id, y) AS "truth" FROM t2 RIGHT JOIN t1;
+} {0}
+do_execsql_test join8-17040 {
+ SELECT * FROM t2 RIGHT JOIN t1 WHERE 99=id AND 0=y;
+} {}
+do_execsql_test join8-17041 {
+ SELECT * FROM t2 RIGHT JOIN t1 WHERE 99=+id AND 0=y;
+} {}
+do_execsql_test join8-17050 {
+ SELECT * FROM t2 RIGHT JOIN t1 WHERE (99, 0)==(id,y);
+} {}
+do_execsql_test join8-17051 {
+ SELECT * FROM t2 RIGHT JOIN t1 WHERE (99, 0)==(+id,y);
+} {}
+do_execsql_test join8-17060 {
+ SELECT * FROM t2 RIGHT JOIN t1 WHERE 1=id AND 0=y;
+} {NULL 1 0 0}
+do_execsql_test join8-17061 {
+ SELECT * FROM t2 RIGHT JOIN t1 WHERE 1=+id AND 0=y;
+} {NULL 1 0 0}
+do_execsql_test join8-17070 {
+ SELECT * FROM t2 RIGHT JOIN t1 WHERE (1, 0)==(id,y);
+} {NULL 1 0 0}
+do_execsql_test join8-17071 {
+ SELECT * FROM t2 RIGHT JOIN t1 WHERE (1, 0)==(+id,y);
+} {NULL 1 0 0}
+do_execsql_test join8-17080 {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b INT);
+ CREATE TABLE t4(x INT, y INT);
+ INSERT INTO t3(a,b) VALUES(1, 3);
+} {}
+do_execsql_test join8-17090 {
+ SELECT t3.a FROM t4 RIGHT JOIN t3 ON (x=a) WHERE (b, 4)=(SELECT 3, 4);
+} {1}
+do_execsql_test join8-17091 {
+ SELECT t3.a FROM t4 RIGHT JOIN t3 ON (x=a) WHERE (b, 4) IS (SELECT 3, 4);
+} {1}
+
+# 2022-06-06
+# https://sqlite.org/forum/forumpost/206d99a16dd9212f
+# tag-20191211-001
+#
+reset_db
+do_execsql_test join8-18000 {
+ CREATE TABLE t1(a BOOLEAN); INSERT INTO t1 VALUES (false);
+ CREATE TABLE t2(x INT); INSERT INTO t2 VALUES (0);
+ SELECT *, x NOTNULL, (x NOTNULL)=a FROM t2 RIGHT JOIN t1 ON true WHERE (x NOTNULL)=a;
+} {}
+do_execsql_test join8-18010 {
+ CREATE INDEX t1a ON t1(a);
+ SELECT *, x NOTNULL, (x NOTNULL)=a FROM t2 RIGHT JOIN t1 ON true WHERE (x NOTNULL)=a;
+} {}
+
+do_execsql_test join8-18020 {
+ CREATE TABLE t3(z);
+ INSERT INTO t3 VALUES('t3value');
+ SELECT *, x NOTNULL, (x NOTNULL)=a FROM t2 RIGHT JOIN t1 ON true INNER JOIN t3 ON (x NOTNULL)=a;
+} {}
+
+ifcapable rtree {
+ do_execsql_test join8-18030 {
+ CREATE VIRTUAL TABLE rtree1 USING rtree(a, x1, x2);
+ INSERT INTO rtree1 VALUES(0, 0, 0);
+ }
+ do_execsql_test join8-18040 {
+ SELECT *, x NOTNULL, (x NOTNULL)=a FROM t2
+ RIGHT JOIN rtree1 ON true INNER JOIN t3 ON (x NOTNULL)=+a;
+ } {}
+ do_execsql_test join8-18050 {
+ SELECT *, x NOTNULL, (x NOTNULL)=a FROM t2
+ RIGHT JOIN rtree1 ON true INNER JOIN t3 ON (x NOTNULL)=a;
+ } {}
+}
+
+
+reset_db
+do_execsql_test join8-19000 {
+ CREATE TABLE t1(a INT);
+ CREATE TABLE t2(b INT, c INT);
+ CREATE TABLE t3(d INT);
+
+ INSERT INTO t1 VALUES(10);
+ INSERT INTO t2 VALUES(50,51);
+ INSERT INTO t3 VALUES(299);
+
+ CREATE INDEX t2b ON t2( (b IS NOT NULL) );
+}
+
+do_execsql_test join8-19010 {
+ SELECT * FROM t1 LEFT JOIN t2 ON true INNER JOIN t3 ON (b IS NOT NULL)=0;
+}
+
+# 2022-06-07
+# https://sqlite.org/forum/forumpost/323f86cc30
+reset_db
+do_execsql_test join8-20000 {
+ CREATE TABLE t1(x TEXT);
+ INSERT INTO t1(x) VALUES('aaa');
+ CREATE VIEW v0(y) AS SELECT x FROM t1;
+ CREATE TABLE t2(z TEXT);
+} {}
+db null -
+do_execsql_test join8-20010 {
+ SELECT * FROM t2 JOIN v0 ON z<>'bbb' RIGHT JOIN t1 ON z<>'ccc';
+} {- - aaa}
+do_execsql_test join8-20020 {
+ SELECT * FROM t2 JOIN v0 ON z<>'bbb' RIGHT JOIN t1 ON z<>'ccc' ORDER BY z;
+} {- - aaa}
+do_execsql_test join8-20030 {
+ SELECT 99 as "m" FROM t2 JOIN v0 ON z<>'bbb' RIGHT JOIN t1 ON z<>'ccc';
+} {99}
+do_execsql_test join8-20040 {
+ SELECT 99 as "m" FROM t2 JOIN v0 ON z<>'bbb' RIGHT JOIN t1 ON z<>'ccc' ORDER BY z;
+} {99}
+do_execsql_test join8-20050 {
+ SELECT count(*)
+ FROM (SELECT 99 as "m" FROM t2 JOIN v0 ON z<>'' RIGHT JOIN t1 ON z<>'') AS "t3";
+} {1}
+do_execsql_test join8-20060 {
+ SELECT count(*)
+ FROM (SELECT 99 as "m" FROM t2 JOIN v0 ON z<>'' RIGHT JOIN t1 ON z<>'' ORDER BY z) AS "t3";
+} {1}
+
+# 2022-06-10
+# https://sqlite.org/forum/forumpost/8e4c352937e82929
+#
+# Do not allow constant propagation between ON and WHERE clause terms.
+# (Updated 2022-06-20) See also https://sqlite.org/forum/forumpost/57bdf2217d
+#
+reset_db
+do_execsql_test join8-21000 {
+ CREATE TABLE t1(a INT,b BOOLEAN);
+ CREATE TABLE t2(c INT); INSERT INTO t2 VALUES(NULL);
+ CREATE TABLE t3(d INT);
+}
+do_execsql_test join8-21010 {
+ SELECT (b IS TRUE) FROM t1 JOIN t3 ON (b=TRUE) RIGHT JOIN t2 ON TRUE;
+} {0}
+do_execsql_test join8-22020 {
+ SELECT * FROM t1 JOIN t3 ON (b=TRUE) RIGHT JOIN t2 ON TRUE WHERE (b IS TRUE);
+} {}
+do_execsql_test join8-22030 {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE t3;
+ CREATE TABLE t1(a INT);
+ CREATE TABLE t2(b INT);
+ CREATE TABLE t3(c INTEGER PRIMARY KEY, d INT);
+ CREATE INDEX t3d ON t3(d);
+ INSERT INTO t3 VALUES(0, 0);
+}
+do_catchsql_test join8-22031 {
+ SELECT * FROM t1 JOIN t2 ON d>b RIGHT JOIN t3 ON true WHERE +d = 0;
+} {1 {ON clause references tables to its right}}
+do_catchsql_test join8-22040 {
+ SELECT * FROM t1 JOIN t2 ON d>b RIGHT JOIN t3 ON true WHERE d = 0;
+} {1 {ON clause references tables to its right}}
+
+
+# 2022-06-10
+# https://sqlite.org/forum/forumpost/51e6959f61
+#
+# Restrictions on the usage of WHERE clause constraints by joins that are
+# involved with a RIGHT JOIN must also be applied to automatic indexes.
+#
+reset_db
+do_execsql_test join8-22000 {
+ CREATE TABLE t1(a INT);
+ CREATE TABLE t2(b INT);
+ CREATE TABLE t3(c TEXT); INSERT INTO t3 VALUES('x');
+ CREATE TABLE t4(d TEXT); INSERT INTO t4 VALUES('y');
+ SELECT 99
+ FROM t1
+ LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON true
+ RIGHT JOIN t4 ON true
+ WHERE a=b;
+} {}
+
+# 2022-06-13
+# https://sqlite.org/forum/forumpost/b40696f501
+#
+# This optimization that converts "x ISNULL" into "FALSE" when column "x" has a
+# NOT NULL constraint is too aggresive if the query contains RIGHT JOIN.
+#
+reset_db
+db null -
+do_execsql_test join8-23000 {
+ CREATE TABLE t1(a TEXT);
+ INSERT INTO t1 VALUES('c');
+ CREATE TABLE t2(b TEXT, c TEXT NOT NULL);
+ INSERT INTO t2 VALUES('a', 'b');
+ CREATE TABLE t3(d TEXT);
+ INSERT INTO t3 VALUES('x');
+ CREATE TABLE t4(e TEXT);
+ INSERT INTO t4 VALUES('y');
+}
+do_execsql_test join8-23010 {
+ SELECT *
+ FROM t1
+ LEFT JOIN t2 ON TRUE
+ JOIN t3 ON c=''
+ RIGHT JOIN t4 ON b='';
+} {- - - - y}
+do_execsql_test join8-23020 {
+ SELECT *
+ FROM t1
+ LEFT JOIN t2 ON TRUE
+ JOIN t3 ON c=''
+ RIGHT JOIN t4 ON b=''
+ WHERE d ISNULL
+} {- - - - y}
+
+# 2022-06-14
+# dbsqlfuzz 2f3101834d14325a976f601b9267a0fd323d6bbd
+#
+# When the OP_NullRow opcode creates a new cursor, it must
+# set the cursor to no-reuse so that an OP_OpenEphemeral in
+# a subroutine does not try to reuse it.
+#
+reset_db
+db null -
+do_execsql_test join8-24000 {
+ CREATE TABLE t4(b INT, c INT);
+ CREATE TABLE t5(a INT, f INT);
+ INSERT INTO t5 VALUES(1,2);
+ WITH t7(x, y) AS (SELECT 100, 200 FROM t5)
+ SELECT * FROM t4 JOIN t7 ON true RIGHT JOIN (SELECT y AS z FROM t7) AS t6 ON (x=z);
+} {- - - - 200}
+
+# 2022-06-20
+# forum/forumpost/6650cd40b5634f35
+#
+reset_db
+do_execsql_test join8-25000 {
+ CREATE TABLE t1(a1 INT);
+ CREATE TABLE t2(b2 INT);
+ CREATE TABLE t3(c3 INT, d3 INT UNIQUE);
+ CREATE TABLE t4(e4 INT, f4 TEXT);
+ INSERT INTO t3(c3, d3) VALUES (2, 1);
+ INSERT INTO t4(f4) VALUES ('x');
+ CREATE INDEX i0 ON t3(c3) WHERE d3 ISNULL;
+ ANALYZE main;
+}
+db null -
+do_execsql_test join8-25010 {
+ SELECT * FROM t1 LEFT JOIN t2 ON true JOIN t3 ON (b2 IN (a1)) FULL JOIN t4 ON true;
+} {- - - - - x}
+do_execsql_test join8-25020 {
+ SELECT 1 FROM t1 LEFT JOIN t2 ON true JOIN t3 ON (b2 IN (a1)) FULL JOIN t4 ON true;
+} {1}
+
+# 2022-07-13
+# forum/forumpost/174afeae57
+#
+reset_db
+db null -
+do_execsql_test join8-26000 {
+ CREATE TABLE t1(a INT);
+ CREATE TABLE t2(b INT, c INT);
+ CREATE VIEW t3(d) AS SELECT NULL FROM t2 FULL OUTER JOIN t1 ON c=a UNION ALL SELECT b FROM t2;
+ INSERT INTO t1(a) VALUES (NULL);
+ INSERT INTO t2(b, c) VALUES (99, NULL);
+ SELECT DISTINCT b, c, d FROM t2, t3 WHERE b<>0
+ UNION SELECT DISTINCT b, c, d FROM t2, t3 WHERE b ISNULL;
+} {99 - - 99 - 99}
+
+finish_test
diff --git a/test/join9.test b/test/join9.test
new file mode 100644
index 0000000..e547d4c
--- /dev/null
+++ b/test/join9.test
@@ -0,0 +1,565 @@
+# 2022-04-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 RIGHT and FULL OUTER JOINs.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+foreach {id schema} {
+ 1 {
+ CREATE TABLE t3(id INTEGER PRIMARY KEY, w TEXT);
+ CREATE TABLE t4(id INTEGER PRIMARY KEY, x TEXT);
+ CREATE TABLE t5(id INTEGER PRIMARY KEY, y TEXT);
+ CREATE TABLE t6(id INTEGER PRIMARY KEY, z INT);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ INSERT INTO t3(id,w) VALUES(2,'two'),(3,'three'),(6,'six'),(7,'seven');
+ INSERT INTO t4(id,x) VALUES(2,'alice'),(4,'bob'),(6,'cindy'),(8,'dave');
+ INSERT INTO t5(id,y) VALUES(1,'red'),(2,'orange'),(3,'yellow'),(4,'green'),
+ (5,'blue');
+ INSERT INTO t6(id,z) VALUES(3,333),(4,444),(5,555),(0,1000),(9,999);
+ }
+ 2 {
+ CREATE TABLE t3(id INT PRIMARY KEY, w TEXT) WITHOUT ROWID;
+ CREATE TABLE t4(id INT PRIMARY KEY, x TEXT) WITHOUT ROWID;
+ CREATE TABLE t5(id INT PRIMARY KEY, y TEXT) WITHOUT ROWID;
+ CREATE TABLE t6(id INT PRIMARY KEY, z INT) WITHOUT ROWID;
+ CREATE TABLE dual(dummy TEXT);
+ INSERT INTO dual(dummy) VALUES('x');
+ INSERT INTO t3(id,w) VALUES(2,'two'),(3,'three'),(6,'six'),(7,'seven');
+ INSERT INTO t4(id,x) VALUES(2,'alice'),(4,'bob'),(6,'cindy'),(8,'dave');
+ INSERT INTO t5(id,y) VALUES(1,'red'),(2,'orange'),(3,'yellow'),(4,'green'),
+ (5,'blue');
+ INSERT INTO t6(id,z) VALUES(3,333),(4,444),(5,555),(0,1000),(9,999);
+ }
+ 3 {
+ CREATE TABLE t3x(id INTEGER PRIMARY KEY, w TEXT);
+ CREATE TABLE t4x(id INTEGER PRIMARY KEY, x TEXT);
+ CREATE TABLE t5x(id INTEGER PRIMARY KEY, y TEXT);
+ CREATE TABLE t6x(id INTEGER PRIMARY KEY, z INT);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ INSERT INTO t3x(id,w) VALUES(2,'two'),(3,'three'),(6,'six'),(7,'seven');
+ INSERT INTO t4x(id,x) VALUES(2,'alice'),(4,'bob'),(6,'cindy'),(8,'dave');
+ INSERT INTO t5x(id,y) VALUES(1,'red'),(2,'orange'),(3,'yellow'),(4,'green'),
+ (5,'blue');
+ INSERT INTO t6x(id,z) VALUES(3,333),(4,444),(5,555),(0,1000),(9,999);
+ CREATE VIEW t3 AS SELECT * FROM t3x LIMIT 1000;
+ CREATE VIEW t4 AS SELECT * FROM t4x LIMIT 1000;
+ CREATE VIEW t5 AS SELECT * FROM t5x LIMIT 1000;
+ CREATE VIEW t6 AS SELECT * FROM t6x LIMIT 1000;
+ }
+ 4 {
+ CREATE TABLE t3a(id INTEGER PRIMARY KEY, w TEXT);
+ CREATE TABLE t3b(id INTEGER PRIMARY KEY, w TEXT);
+ CREATE TABLE t4a(id INTEGER PRIMARY KEY, x TEXT);
+ CREATE TABLE t4b(id INTEGER PRIMARY KEY, x TEXT);
+ CREATE TABLE t5a(id INTEGER PRIMARY KEY, y TEXT);
+ CREATE TABLE t5b(id INTEGER PRIMARY KEY, y TEXT);
+ CREATE TABLE t6a(id INTEGER PRIMARY KEY, z INT);
+ CREATE TABLE t6b(id INTEGER PRIMARY KEY, z INT);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ INSERT INTO t3a(id,w) VALUES(2,'two'),(3,'three');
+ INSERT INTO t3b(id,w) VALUES(6,'six'),(7,'seven');
+ INSERT INTO t4a(id,x) VALUES(2,'alice'),(4,'bob');
+ INSERT INTO t4b(id,x) VALUES(6,'cindy'),(8,'dave');
+ INSERT INTO t5a(id,y) VALUES(1,'red'),(2,'orange'),(3,'yellow');
+ INSERT INTO t5b(id,y) VALUES(4,'green'),(5,'blue');
+ INSERT INTO t6a(id,z) VALUES(3,333),(4,444);
+ INSERT INTO t6b(id,z) VALUES(5,555),(0,1000),(9,999);
+ CREATE VIEW t3 AS SELECT * FROM t3a UNION ALL SELECT * FROM t3b;
+ CREATE VIEW t4 AS SELECT * FROM t4a UNION ALL SELECT * FROM t4b;
+ CREATE VIEW t5 AS SELECT * FROM t5a UNION ALL SELECT * FROM t5b;
+ CREATE VIEW t6 AS SELECT * FROM t6a UNION ALL SELECT * FROM t6b;
+ }
+ 5 {
+ CREATE TABLE t3a(id INTEGER PRIMARY KEY, w TEXT) WITHOUT ROWID;
+ CREATE TABLE t3b(id INTEGER PRIMARY KEY, w TEXT);
+ CREATE TABLE t4a(id INTEGER PRIMARY KEY, x TEXT) WITHOUT ROWID;
+ CREATE TABLE t4b(id INTEGER PRIMARY KEY, x TEXT) WITHOUT ROWID;
+ CREATE TABLE t5a(id INTEGER PRIMARY KEY, y TEXT);
+ CREATE TABLE t5b(id INTEGER PRIMARY KEY, y TEXT) WITHOUT ROWID;
+ CREATE TABLE t6a(id INTEGER PRIMARY KEY, z INT);
+ CREATE TABLE t6b(id INTEGER PRIMARY KEY, z INT);
+ CREATE VIEW dual(dummy) AS VALUES('x');
+ INSERT INTO t3a(id,w) VALUES(2,'two'),(3,'three');
+ INSERT INTO t3b(id,w) VALUES(6,'six'),(7,'seven');
+ INSERT INTO t4a(id,x) VALUES(2,'alice'),(4,'bob');
+ INSERT INTO t4b(id,x) VALUES(6,'cindy'),(8,'dave');
+ INSERT INTO t5a(id,y) VALUES(1,'red'),(2,'orange'),(3,'yellow');
+ INSERT INTO t5b(id,y) VALUES(4,'green'),(5,'blue');
+ INSERT INTO t6a(id,z) VALUES(3,333),(4,444);
+ INSERT INTO t6b(id,z) VALUES(5,555),(0,1000),(9,999);
+ CREATE VIEW t3 AS SELECT * FROM t3a UNION ALL SELECT * FROM t3b;
+ CREATE VIEW t4 AS SELECT * FROM t4a UNION ALL SELECT * FROM t4b LIMIT 50;
+ CREATE VIEW t5 AS SELECT * FROM t5a UNION ALL SELECT * FROM t5b LIMIT 100;
+ CREATE VIEW t6 AS SELECT * FROM t6a UNION ALL SELECT * FROM t6b;
+ }
+} {
+ reset_db
+ db nullvalue -
+ do_execsql_test join9-$id.setup $schema {}
+
+ # Verifid by PG-14 for case 1
+ do_execsql_test join9-$id.100 {
+ SELECT *, t4.id, t5.id, t6.id
+ FROM t4 NATURAL LEFT JOIN t5 NATURAL LEFT JOIN t6
+ ORDER BY 1;
+ } {
+ 2 alice orange - 2 2 -
+ 4 bob green 444 4 4 4
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ }
+
+ do_execsql_test join9-$id.101 {
+ SELECT *, t4.id, t5.id, t6.id
+ FROM t4 NATURAL LEFT JOIN t5 NATURAL LEFT JOIN t6
+ ORDER BY id;
+ } {
+ 2 alice orange - 2 2 -
+ 4 bob green 444 4 4 4
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ }
+ do_execsql_test join9-$id.102 {
+ SELECT *, t4.id, t5.id, t6.id
+ FROM t4 LEFT JOIN t5 USING(id) LEFT JOIN t6 USING(id)
+ ORDER BY id;
+ } {
+ 2 alice orange - 2 2 -
+ 4 bob green 444 4 4 4
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ }
+
+ # Verifid by PG-14 using case 1
+ do_execsql_test join9-$id.200 {
+ SELECT id, x, y, z, t4.id, t5.id, t6.id
+ FROM t5 NATURAL RIGHT JOIN t4 NATURAL LEFT JOIN t6
+ ORDER BY 1;
+ } {
+ 2 alice orange - 2 2 -
+ 4 bob green 444 4 4 4
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ }
+
+ do_execsql_test join9-$id.201 {
+ SELECT id, x, y, z, t4.id, t5.id, t6.id
+ FROM t5 NATURAL RIGHT JOIN t4 NATURAL LEFT JOIN t6
+ ORDER BY id;
+ } {
+ 2 alice orange - 2 2 -
+ 4 bob green 444 4 4 4
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ }
+
+ # Verified by PG-14 using case 1
+ do_execsql_test join9-$id.300 {
+ SELECT *, t4.id, t5.id, t6.id
+ FROM t4 NATURAL RIGHT JOIN t5 NATURAL RIGHT JOIN t6
+ ORDER BY 1;
+ } {
+ 0 - - 1000 - - 0
+ 3 - yellow 333 - 3 3
+ 4 bob green 444 4 4 4
+ 5 - blue 555 - 5 5
+ 9 - - 999 - - 9
+ }
+
+ do_execsql_test join9-$id.301 {
+ SELECT *, t4.id, t5.id, t6.id
+ FROM t4 NATURAL RIGHT JOIN t5 NATURAL RIGHT JOIN t6
+ ORDER BY id;
+ } {
+ 0 - - 1000 - - 0
+ 3 - yellow 333 - 3 3
+ 4 bob green 444 4 4 4
+ 5 - blue 555 - 5 5
+ 9 - - 999 - - 9
+ }
+
+ # Verified by PG-14 for case 1
+ do_execsql_test join9-$id.400 {
+ SELECT *, t4.id, t5.id, t6.id
+ FROM t4 NATURAL FULL JOIN t5 NATURAL FULL JOIN t6
+ ORDER BY 1;
+ } {
+ 0 - - 1000 - - 0
+ 1 - red - - 1 -
+ 2 alice orange - 2 2 -
+ 3 - yellow 333 - 3 3
+ 4 bob green 444 4 4 4
+ 5 - blue 555 - 5 5
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ 9 - - 999 - - 9
+ }
+
+ do_execsql_test join9-$id.401 {
+ SELECT *, t4.id, t5.id, t6.id
+ FROM t4 NATURAL FULL JOIN t5 NATURAL FULL JOIN t6
+ ORDER BY id;
+ } {
+ 0 - - 1000 - - 0
+ 1 - red - - 1 -
+ 2 alice orange - 2 2 -
+ 3 - yellow 333 - 3 3
+ 4 bob green 444 4 4 4
+ 5 - blue 555 - 5 5
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ 9 - - 999 - - 9
+ }
+ do_execsql_test join9-$id.402 {
+ SELECT id, x, y, z, t4.id, t5.id, t6.id
+ FROM t4 NATURAL FULL JOIN t6 NATURAL FULL JOIN t5
+ ORDER BY id;
+ } {
+ 0 - - 1000 - - 0
+ 1 - red - - 1 -
+ 2 alice orange - 2 2 -
+ 3 - yellow 333 - 3 3
+ 4 bob green 444 4 4 4
+ 5 - blue 555 - 5 5
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ 9 - - 999 - - 9
+ }
+ do_execsql_test join9-$id.403 {
+ SELECT id, x, y, z, t4.id, t5.id, t6.id
+ FROM t5 NATURAL FULL JOIN t4 NATURAL FULL JOIN t6
+ ORDER BY id;
+ } {
+ 0 - - 1000 - - 0
+ 1 - red - - 1 -
+ 2 alice orange - 2 2 -
+ 3 - yellow 333 - 3 3
+ 4 bob green 444 4 4 4
+ 5 - blue 555 - 5 5
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ 9 - - 999 - - 9
+ }
+ do_execsql_test join9-$id.404 {
+ SELECT id, x, y, z, t4.id, t5.id, t6.id
+ FROM t5 NATURAL FULL JOIN t6 NATURAL FULL JOIN t4
+ ORDER BY id;
+ } {
+ 0 - - 1000 - - 0
+ 1 - red - - 1 -
+ 2 alice orange - 2 2 -
+ 3 - yellow 333 - 3 3
+ 4 bob green 444 4 4 4
+ 5 - blue 555 - 5 5
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ 9 - - 999 - - 9
+ }
+ do_execsql_test join9-$id.405 {
+ SELECT id, x, y, z, t4.id, t5.id, t6.id
+ FROM t6 NATURAL FULL JOIN t4 NATURAL FULL JOIN t5
+ ORDER BY id;
+ } {
+ 0 - - 1000 - - 0
+ 1 - red - - 1 -
+ 2 alice orange - 2 2 -
+ 3 - yellow 333 - 3 3
+ 4 bob green 444 4 4 4
+ 5 - blue 555 - 5 5
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ 9 - - 999 - - 9
+ }
+ do_execsql_test join9-$id.406 {
+ SELECT id, x, y, z, t4.id, t5.id, t6.id
+ FROM t6 NATURAL FULL JOIN t5 NATURAL FULL JOIN t4
+ ORDER BY id;
+ } {
+ 0 - - 1000 - - 0
+ 1 - red - - 1 -
+ 2 alice orange - 2 2 -
+ 3 - yellow 333 - 3 3
+ 4 bob green 444 4 4 4
+ 5 - blue 555 - 5 5
+ 6 cindy - - 6 - -
+ 8 dave - - 8 - -
+ 9 - - 999 - - 9
+ }
+
+ # Verified by PG-14 using case 1
+ do_execsql_test join9-$id.500 {
+ SELECT id, w, x, y, z
+ FROM t3 FULL JOIN t4 USING(id)
+ NATURAL FULL JOIN t5
+ FULL JOIN t6 USING(id)
+ ORDER BY 1;
+ } {
+ 0 - - - 1000
+ 1 - - red -
+ 2 two alice orange -
+ 3 three - yellow 333
+ 4 - bob green 444
+ 5 - - blue 555
+ 6 six cindy - -
+ 7 seven - - -
+ 8 - dave - -
+ 9 - - - 999
+ }
+
+ # Verified by PG-14 using case 1
+ do_execsql_test join9-$id.600 {
+ SELECT id, w, x, y, z
+ FROM t3 JOIN dual AS d1 ON true
+ FULL JOIN t4 USING(id)
+ JOIN dual AS d2 ON true
+ NATURAL FULL JOIN t5
+ JOIN dual AS d3 ON true
+ FULL JOIN t6 USING(id)
+ CROSS JOIN dual AS d4
+ ORDER BY 1;
+ } {
+ 0 - - - 1000
+ 1 - - red -
+ 2 two alice orange -
+ 3 three - yellow 333
+ 4 - bob green 444
+ 5 - - blue 555
+ 6 six cindy - -
+ 7 seven - - -
+ 8 - dave - -
+ 9 - - - 999
+ }
+
+ # Verified by PG-14 using case 1
+ do_execsql_test join9-$id.700 {
+ SELECT id, w, x, y, z
+ FROM t3 JOIN dual AS d1 ON true
+ FULL JOIN t4 USING(id)
+ JOIN dual AS d2 ON true
+ NATURAL FULL JOIN t5
+ JOIN dual AS d3 ON true
+ FULL JOIN t6 USING(id)
+ CROSS JOIN dual AS d4
+ WHERE x<>'bob' OR x IS NULL
+ ORDER BY 1;
+ } {
+ 0 - - - 1000
+ 1 - - red -
+ 2 two alice orange -
+ 3 three - yellow 333
+ 5 - - blue 555
+ 6 six cindy - -
+ 7 seven - - -
+ 8 - dave - -
+ 9 - - - 999
+ }
+
+ # Verified by PG-14 using case 1
+ do_execsql_test join9-$id.800 {
+ WITH t7(id,a) AS MATERIALIZED (SELECT * FROM t4 WHERE false)
+ SELECT *
+ FROM t7
+ JOIN t7 AS t7b USING(id)
+ FULL JOIN t3 USING(id);
+ } {
+ 2 - - two
+ 3 - - three
+ 6 - - six
+ 7 - - seven
+ }
+
+ # Verified by PG-14
+ do_execsql_test join9-$id.900 {
+ SELECT *
+ FROM (t3 NATURAL FULL JOIN t4)
+ NATURAL FULL JOIN
+ (t5 NATURAL FULL JOIN t6)
+ ORDER BY 1;
+ } {
+ 0 - - - 1000
+ 1 - - red -
+ 2 two alice orange -
+ 3 three - yellow 333
+ 4 - bob green 444
+ 5 - - blue 555
+ 6 six cindy - -
+ 7 seven - - -
+ 8 - dave - -
+ 9 - - - 999
+ }
+ do_execsql_test join9-$id.910 {
+ SELECT *
+ FROM t3 NATURAL FULL JOIN
+ (t4 NATURAL FULL JOIN
+ (t5 NATURAL FULL JOIN t6))
+ ORDER BY 1;
+ } {
+ 0 - - - 1000
+ 1 - - red -
+ 2 two alice orange -
+ 3 three - yellow 333
+ 4 - bob green 444
+ 5 - - blue 555
+ 6 six cindy - -
+ 7 seven - - -
+ 8 - dave - -
+ 9 - - - 999
+ }
+ do_execsql_test join9-$id.920 {
+ SELECT *
+ FROM t3 FULL JOIN (
+ t4 FULL JOIN (
+ t5 FULL JOIN t6 USING (id)
+ ) USING(id)
+ ) USING(id)
+ ORDER BY 1;
+ } {
+ 0 - - - 1000
+ 1 - - red -
+ 2 two alice orange -
+ 3 three - yellow 333
+ 4 - bob green 444
+ 5 - - blue 555
+ 6 six cindy - -
+ 7 seven - - -
+ 8 - dave - -
+ 9 - - - 999
+ }
+ do_execsql_test join9-$id.920 {
+ SELECT *
+ FROM t3 FULL JOIN (
+ t4 FULL JOIN (
+ t5 FULL JOIN t6 USING (id)
+ ) USING(id)
+ ) USING(id)
+ ORDER BY 1;
+ } {
+ 0 - - - 1000
+ 1 - - red -
+ 2 two alice orange -
+ 3 three - yellow 333
+ 4 - bob green 444
+ 5 - - blue 555
+ 6 six cindy - -
+ 7 seven - - -
+ 8 - dave - -
+ 9 - - - 999
+ }
+
+ # Verified by PG-14
+ do_execsql_test join9-$id.930 {
+ SELECT *
+ FROM t3 FULL JOIN (
+ t4 FULL JOIN (
+ t5 FULL JOIN t6 USING(id)
+ ) USING(id)
+ ) AS j1 ON j1.id=t3.id
+ ORDER BY coalesce(t3.id,j1.id);
+ } {
+ - - 0 - - 1000
+ - - 1 - red -
+ 2 two 2 alice orange -
+ 3 three 3 - yellow 333
+ - - 4 bob green 444
+ - - 5 - blue 555
+ 6 six 6 cindy - -
+ 7 seven - - - -
+ - - 8 dave - -
+ - - 9 - - 999
+ }
+
+ # Verified by PG-14
+ do_execsql_test join9-$id.940 {
+ SELECT *
+ FROM t3 FULL JOIN (
+ t4 RIGHT JOIN (
+ t5 FULL JOIN t6 USING(id)
+ ) USING(id)
+ ) AS j1 ON j1.id=t3.id
+ ORDER BY coalesce(t3.id,j1.id);
+ } {
+ - - 0 - - 1000
+ - - 1 - red -
+ 2 two 2 alice orange -
+ 3 three 3 - yellow 333
+ - - 4 bob green 444
+ - - 5 - blue 555
+ 6 six - - - -
+ 7 seven - - - -
+ - - 9 - - 999
+ }
+
+ # Verified by PG-14
+ do_execsql_test join9-$id.950 {
+ SELECT *
+ FROM t3 FULL JOIN (
+ t4 LEFT JOIN (
+ t5 FULL JOIN t6 USING(id)
+ ) USING(id)
+ ) AS j1 ON j1.id=t3.id
+ ORDER BY coalesce(t3.id,j1.id);
+ } {
+ 2 two 2 alice orange -
+ 3 three - - - -
+ - - 4 bob green 444
+ 6 six 6 cindy - -
+ 7 seven - - - -
+ - - 8 dave - -
+ }
+
+ # Restriction (27) in the query flattener
+ # Verified by PG-14
+ do_execsql_test join9-$id.1000 {
+ WITH t56(id,y,z) AS (SELECT * FROM t5 FULL JOIN t6 USING(id) LIMIT 50)
+ SELECT id,x,y,z FROM t4 JOIN t56 USING(id)
+ ORDER BY 1;
+ } {
+ 2 alice orange -
+ 4 bob green 444
+ }
+
+ # Verified by PG-14
+ do_execsql_test join9-$id.1010 {
+ SELECT id,x,y,z
+ FROM t4 INNER JOIN (t5 FULL JOIN t6 USING(id)) USING(id)
+ ORDER BY 1;
+ } {
+ 2 alice orange -
+ 4 bob green 444
+ }
+
+ # Verified by PG-14
+ do_execsql_test join9-$id.1020 {
+ SELECT id,x,y,z
+ FROM t4 FULL JOIN t5 USING(id) INNER JOIN t6 USING(id)
+ ORDER BY 1;
+ } {
+ 3 - yellow 333
+ 4 bob green 444
+ 5 - blue 555
+ }
+
+ # Verified by PG-14
+ do_execsql_test join9-$id.1030 {
+ WITH t45(id,x,y) AS (SELECT * FROM t4 FULL JOIN t5 USING(id) LIMIT 50)
+ SELECT id,x,y,z FROM t45 JOIN t6 USING(id)
+ ORDER BY 1;
+ } {
+ 3 - yellow 333
+ 4 bob green 444
+ 5 - blue 555
+ }
+
+}
+finish_test
diff --git a/test/joinA.test b/test/joinA.test
new file mode 100644
index 0000000..d6bb678
--- /dev/null
+++ b/test/joinA.test
@@ -0,0 +1,214 @@
+# 2022-04-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 for RIGHT and FULL OUTER JOINs.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+foreach {id schema} {
+ 1 {
+ CREATE TABLE t1(a INT, b INT, c INT, d INT);
+ CREATE TABLE t2(c INT, d INT, e INT, f INT);
+ CREATE TABLE t3(a INT, b INT, e INT, f INT);
+ CREATE TABLE t4(a INT, c INT, d INT, f INT);
+ INSERT INTO t1 VALUES(11,21,31,41),(12,22,32,42),(15,25,35,45),(18,28,38,48);
+ INSERT INTO t2 VALUES(12,22,32,42),(13,23,33,43),(15,25,35,45),(17,27,37,47);
+ INSERT INTO t3 VALUES(14,24,34,44),(15,25,35,45),(16,26,36,46);
+ INSERT INTO t4 VALUES(11,21,31,41),(13,23,33,43),(16,26,36,46),(19,29,39,49);
+ }
+ 2 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c INT, d INT);
+ CREATE TABLE t2(c INT, d INTEGER PRIMARY KEY, e INT, f INT);
+ CREATE TABLE t3(a INT, b INT, e INTEGER PRIMARY KEY, f INT);
+ CREATE TABLE t4(a INT, c INT, d INT, f INT PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(11,21,31,41),(12,22,32,42),(15,25,35,45),(18,28,38,48);
+ INSERT INTO t2 VALUES(12,22,32,42),(13,23,33,43),(15,25,35,45),(17,27,37,47);
+ INSERT INTO t3 VALUES(14,24,34,44),(15,25,35,45),(16,26,36,46);
+ INSERT INTO t4 VALUES(11,21,31,41),(13,23,33,43),(16,26,36,46),(19,29,39,49);
+ }
+ 3 {
+ CREATE TABLE t1a(a INT, b INT, c INT, d INT);
+ CREATE TABLE t2a(c INT, d INT, e INT, f INT);
+ CREATE TABLE t3a(a INT, b INT, e INT, f INT);
+ CREATE TABLE t4a(a INT, c INT, d INT, f INT);
+ INSERT INTO t1a VALUES(11,21,31,41),(12,22,32,42);
+ INSERT INTO t2a VALUES(12,22,32,42),(13,23,33,43);
+ INSERT INTO t3a VALUES(14,24,34,44),(15,25,35,45);
+ INSERT INTO t4a VALUES(11,21,31,41),(13,23,33,43);
+ CREATE TABLE t1b(a INT, b INT, c INT, d INT);
+ CREATE TABLE t2b(c INT, d INT, e INT, f INT);
+ CREATE TABLE t3b(a INT, b INT, e INT, f INT);
+ CREATE TABLE t4b(a INT, c INT, d INT, f INT);
+ INSERT INTO t1b VALUES(15,25,35,45),(18,28,38,48);
+ INSERT INTO t2b VALUES(15,25,35,45),(17,27,37,47);
+ INSERT INTO t3b VALUES(15,25,35,45),(16,26,36,46);
+ INSERT INTO t4b VALUES(16,26,36,46),(19,29,39,49);
+ CREATE VIEW t1 AS SELECT * FROM t1a UNION SELECT * FROM t1b;
+ CREATE VIEW t2 AS SELECT * FROM t2a UNION SELECT * FROM t2b;
+ CREATE VIEW t3 AS SELECT * FROM t3a UNION SELECT * FROM t3b;
+ CREATE VIEW t4 AS SELECT * FROM t4a UNION SELECT * FROM t4b;
+ }
+} {
+ reset_db
+ db nullvalue -
+ do_execsql_test joinA-$id.setup $schema {}
+
+ # Verified by PG-14
+ do_execsql_test joinA-$id.100 {
+ SELECT a,b,c,d,t2.e,f,t3.e
+ FROM t1
+ INNER JOIN t2 USING(c,d)
+ INNER JOIN t3 USING(a,b,f)
+ INNER JOIN t4 USING(a,c,d,f)
+ ORDER BY 1 nulls first, 3 nulls first;
+ } {}
+
+
+ # Verified by PG-14
+ do_execsql_test joinA-$id.110 {
+ SELECT a,b,c,d,t2.e,f,t3.e
+ FROM t1
+ LEFT JOIN t2 USING(c,d)
+ LEFT JOIN t3 USING(a,b,f)
+ LEFT JOIN t4 USING(a,c,d,f)
+ ORDER BY 1 nulls first, 3 nulls first;
+ } {
+ 11 21 31 41 - - -
+ 12 22 32 42 - - -
+ 15 25 35 45 - - -
+ 18 28 38 48 - - -
+ }
+
+ # Verified by PG-14
+ do_execsql_test joinA-$id.120 {
+ SELECT a,b,c,d,t2.e,f,t3.e
+ FROM t1
+ LEFT JOIN t2 USING(c,d)
+ RIGHT JOIN t3 USING(a,b,f)
+ LEFT JOIN t4 USING(a,c,d,f)
+ ORDER BY 1 nulls first, 3 nulls first;
+ } {
+ 14 24 - - - 44 34
+ 15 25 - - - 45 35
+ 16 26 - - - 46 36
+ }
+
+ # Verified by PG-14
+ do_execsql_test joinA-$id.130 {
+ SELECT a,b,c,d,t2.e,f,t3.e
+ FROM t1
+ RIGHT JOIN t2 USING(c,d)
+ LEFT JOIN t3 USING(a,b,f)
+ RIGHT JOIN t4 USING(a,c,d,f)
+ ORDER BY 1 nulls first, 3 nulls first;
+ } {
+ 11 - 21 31 - 41 -
+ 13 - 23 33 - 43 -
+ 16 - 26 36 - 46 -
+ 19 - 29 39 - 49 -
+ }
+
+ # Verified by PG-14
+ do_execsql_test joinA-$id.140 {
+ SELECT a,b,c,d,t2.e,f,t3.e
+ FROM t1
+ FULL JOIN t2 USING(c,d)
+ LEFT JOIN t3 USING(a,b,f)
+ RIGHT JOIN t4 USING(a,c,d,f)
+ ORDER BY 1 nulls first, 3 nulls first;
+ } {
+ 11 - 21 31 - 41 -
+ 13 - 23 33 - 43 -
+ 16 - 26 36 - 46 -
+ 19 - 29 39 - 49 -
+ }
+
+ # Verified by PG-14
+ do_execsql_test joinA-$id.150 {
+ SELECT a,b,c,d,t2.e,f,t3.e
+ FROM t1
+ RIGHT JOIN t2 USING(c,d)
+ FULL JOIN t3 USING(a,b,f)
+ RIGHT JOIN t4 USING(a,c,d,f)
+ ORDER BY 1 nulls first, 3 nulls first;
+ } {
+ 11 - 21 31 - 41 -
+ 13 - 23 33 - 43 -
+ 16 - 26 36 - 46 -
+ 19 - 29 39 - 49 -
+ }
+
+ # Verified by PG-14
+ do_execsql_test joinA-$id.160 {
+ SELECT a,b,c,d,t2.e,f,t3.e
+ FROM t1
+ RIGHT JOIN t2 USING(c,d)
+ LEFT JOIN t3 USING(a,b,f)
+ FULL JOIN t4 USING(a,c,d,f)
+ ORDER BY 1 nulls first, 3 nulls first;
+ } {
+ - - 12 22 32 42 -
+ - - 13 23 33 43 -
+ - - 15 25 35 45 -
+ - - 17 27 37 47 -
+ 11 - 21 31 - 41 -
+ 13 - 23 33 - 43 -
+ 16 - 26 36 - 46 -
+ 19 - 29 39 - 49 -
+ }
+
+ # Verified by PG-14
+ do_execsql_test joinA-$id.170 {
+ SELECT a,b,c,d,t2.e,f,t3.e
+ FROM t1
+ LEFT JOIN t2 USING(c,d)
+ RIGHT JOIN t3 USING(a,b,f)
+ FULL JOIN t4 USING(a,c,d,f)
+ ORDER BY 1 nulls first, 3 nulls first;
+ } {
+ 11 - 21 31 - 41 -
+ 13 - 23 33 - 43 -
+ 14 24 - - - 44 34
+ 15 25 - - - 45 35
+ 16 26 - - - 46 36
+ 16 - 26 36 - 46 -
+ 19 - 29 39 - 49 -
+ }
+
+ # Verified by PG-14
+ do_execsql_test joinA-$id.200 {
+ SELECT a,b,c,d,t2.e,f,t3.e
+ FROM t1
+ FULL JOIN t2 USING(c,d)
+ FULL JOIN t3 USING(a,b,f)
+ FULL JOIN t4 USING(a,c,d,f)
+ ORDER BY 1 nulls first, 3 nulls first;
+ } {
+ - - 12 22 32 42 -
+ - - 13 23 33 43 -
+ - - 15 25 35 45 -
+ - - 17 27 37 47 -
+ 11 - 21 31 - 41 -
+ 11 21 31 41 - - -
+ 12 22 32 42 - - -
+ 13 - 23 33 - 43 -
+ 14 24 - - - 44 34
+ 15 25 - - - 45 35
+ 15 25 35 45 - - -
+ 16 26 - - - 46 36
+ 16 - 26 36 - 46 -
+ 18 28 38 48 - - -
+ 19 - 29 39 - 49 -
+ }
+}
+finish_test
diff --git a/test/joinB.test b/test/joinB.test
new file mode 100644
index 0000000..baaeae6
--- /dev/null
+++ b/test/joinB.test
@@ -0,0 +1,7252 @@
+set testdir [file dirname $argv0]
+# 2022-04-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 JOINs.
+#
+# The test case output is all generated by PostgreSQL 14. This test module
+# was created as follows:
+#
+# 1. Run a TCL script (included at the bottom of this file) that
+# generates an input script for "psql" that will run man
+# diverse tests on joins.
+#
+# 2. Run the script from step (1) through psql and collect the
+# output.
+#
+# 3. Make a few minor global search-and-replace operations to convert
+# the psql output into a form suitable for this test module.
+#
+# 4. Add this header, and the script content at the footer.
+#
+source $testdir/tester.tcl
+db nullvalue -
+db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ DROP TABLE IF EXISTS t3;
+ DROP TABLE IF EXISTS t4;
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t1(a INT, b INT, c INT);
+ CREATE TABLE t2(a INT, b INT, d INT);
+ CREATE TABLE t3(a INT, b INT, e INT);
+ CREATE TABLE t4(a INT, b INT, f INT);
+ CREATE TABLE t5(a INT, b INT, g INT);
+ INSERT INTO t1 VALUES(11,21,31),(12,22,32),(15,25,35),(17,27,37);
+ INSERT INTO t2 VALUES(12,22,32),(13,23,33),(15,25,35),(18,28,38),
+ (NULL,NULL,36);
+ INSERT INTO t4 VALUES(11,21,31),(13,23,33),(15,25,35),(19,29,39);
+ INSERT INTO t3 SELECT * FROM t1 UNION SELECT * FROM t2 UNION SELECT * FROM t4;
+ INSERT INTO t5 SELECT * FROM t3 WHERE a>=15;
+}
+do_execsql_test joinB-1 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-2 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-3 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-4 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-5 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-6 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-7 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-8 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-9 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-10 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-11 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-12 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 32 32 32 - -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-13 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-14 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-15 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-16 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-17 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-18 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-19 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-20 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 31 -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-21 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-22 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-23 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-24 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-25 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-26 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-27 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 12 12 12 12 - -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-28 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 31 -
+ 12 32 32 32 - -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-29 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-30 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-31 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 12 12 12 12 - -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-32 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-33 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-34 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-35 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-36 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-37 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-38 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-39 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-40 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-41 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-42 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-43 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-44 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 32 32 32 - -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-45 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-46 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-47 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-48 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-49 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-50 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-51 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-52 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 31 -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-53 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-54 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-55 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-56 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-57 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-58 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-59 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 12 12 12 12 - -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-60 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 31 -
+ 12 32 32 32 - -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-61 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-62 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-63 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 12 12 12 12 - -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-64 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-65 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-66 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-67 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-68 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-69 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-70 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-71 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-72 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-73 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-74 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 - - 37 - 37
+ 18 - - 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-75 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-76 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+}
+do_execsql_test joinB-77 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-78 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - 37 - 37
+ 18 28 - - 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-79 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-80 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-81 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-82 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-83 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-84 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-85 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-86 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-87 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-88 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-89 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-90 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 - - 37 - 37
+ 18 - - 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-91 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-92 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+}
+do_execsql_test joinB-93 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-94 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - 37 - 37
+ 18 28 - - 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-95 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-96 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-97 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-98 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-99 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-100 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-101 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-102 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-103 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-104 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-105 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-106 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 - - 37 - 37
+ 18 - - 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-107 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-108 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+}
+do_execsql_test joinB-109 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-110 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - 37 - 37
+ 18 28 - - 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-111 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-112 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-113 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-114 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-115 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-116 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-117 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-118 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-119 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-120 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-121 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-122 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 - - 37 - 37
+ 18 - - 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-123 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-124 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ INNER JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+}
+do_execsql_test joinB-125 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-126 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ INNER JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - 37 - 37
+ 18 28 - - 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-127 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ INNER JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-128 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL INNER JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-129 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-130 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-131 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-132 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-133 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-134 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-135 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-136 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-137 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+}
+do_execsql_test joinB-138 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+}
+do_execsql_test joinB-139 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+}
+do_execsql_test joinB-140 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 12 32 32 32 - -
+ 15 35 35 35 35 35
+ 17 37 - - - -
+}
+do_execsql_test joinB-141 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-142 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-143 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-144 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-145 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-146 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-147 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-148 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-149 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-150 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-151 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-152 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-153 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 19 - - - 19 19
+}
+do_execsql_test joinB-154 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 19 - - - 39 39
+}
+do_execsql_test joinB-155 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 19 - - - 19 19
+}
+do_execsql_test joinB-156 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 12 32 32 32 - -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+ 17 37 - - - -
+}
+do_execsql_test joinB-157 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-158 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-159 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-160 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-161 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-162 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-163 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-164 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-165 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-166 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-167 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-168 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-169 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+}
+do_execsql_test joinB-170 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+}
+do_execsql_test joinB-171 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+}
+do_execsql_test joinB-172 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 12 32 32 32 - -
+ 15 35 35 35 35 35
+ 17 37 - - - -
+}
+do_execsql_test joinB-173 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-174 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-175 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-176 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-177 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-178 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-179 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-180 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-181 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-182 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-183 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-184 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-185 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 19 - - - 19 19
+}
+do_execsql_test joinB-186 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 19 - - - 39 39
+}
+do_execsql_test joinB-187 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 19 - - - 19 19
+}
+do_execsql_test joinB-188 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 12 32 32 32 - -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+ 17 37 - - - -
+}
+do_execsql_test joinB-189 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-190 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-191 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - - 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-192 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-193 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-194 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-195 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-196 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-197 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-198 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-199 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-200 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-201 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-202 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - - 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-203 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-204 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+}
+do_execsql_test joinB-205 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-206 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - - 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-207 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-208 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-209 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-210 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-211 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-212 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-213 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-214 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-215 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-216 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-217 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-218 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - - 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-219 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-220 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+}
+do_execsql_test joinB-221 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-222 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - - 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-223 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-224 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-225 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-226 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-227 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-228 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-229 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-230 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-231 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-232 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-233 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-234 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - - 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-235 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-236 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+}
+do_execsql_test joinB-237 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-238 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - - 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-239 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-240 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-241 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-242 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-243 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-244 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-245 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-246 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-247 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-248 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-249 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-250 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - - 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-251 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-252 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ LEFT JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - - - 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+}
+do_execsql_test joinB-253 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-254 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ LEFT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - - 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-255 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ LEFT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - - 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - - 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-256 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL LEFT JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-257 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-258 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-259 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-260 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-261 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-262 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-263 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-264 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-265 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+}
+do_execsql_test joinB-266 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 18 - 38 38 - 38
+}
+do_execsql_test joinB-267 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+}
+do_execsql_test joinB-268 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-269 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - 18 18 - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-270 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-271 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - 18 18 - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-272 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-273 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-274 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-275 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-276 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-277 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-278 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-279 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-280 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-281 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-282 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 18 - 38 38 - 38
+ 19 - - - 39 39
+}
+do_execsql_test joinB-283 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-284 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-285 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-286 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-287 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-288 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-289 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-290 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-291 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-292 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-293 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-294 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-295 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-296 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-297 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+}
+do_execsql_test joinB-298 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 18 - 38 38 - 38
+}
+do_execsql_test joinB-299 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+}
+do_execsql_test joinB-300 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-301 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - 18 18 - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-302 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-303 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - 18 18 - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-304 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-305 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-306 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-307 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-308 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-309 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-310 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-311 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-312 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-313 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-314 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 18 - 38 38 - 38
+ 19 - - - 39 39
+}
+do_execsql_test joinB-315 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - - 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-316 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - - 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-317 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-318 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-319 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - - 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-320 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-321 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-322 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-323 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-324 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-325 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-326 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-327 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-328 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-329 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-330 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 - - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-331 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-332 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-333 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-334 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-335 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-336 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-337 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-338 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-339 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-340 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-341 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-342 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-343 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-344 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-345 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-346 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 - - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-347 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-348 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-349 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-350 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-351 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-352 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-353 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-354 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-355 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-356 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-357 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-358 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-359 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-360 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-361 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-362 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 - - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-363 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-364 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-365 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-366 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-367 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-368 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-369 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-370 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-371 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-372 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-373 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-374 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-375 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 - - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-376 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-377 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-378 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 - - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-379 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-380 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-381 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-382 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ RIGHT JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-383 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ RIGHT JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 - - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-384 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL RIGHT JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-385 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-386 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-387 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-388 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-389 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-390 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-391 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-392 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-393 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+}
+do_execsql_test joinB-394 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - 38 38 - 38
+}
+do_execsql_test joinB-395 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+}
+do_execsql_test joinB-396 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - - - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-397 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-398 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-399 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-400 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-401 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-402 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-403 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-404 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-405 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-406 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-407 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-408 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-409 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-410 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - - 39 39
+}
+do_execsql_test joinB-411 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-412 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 INNER JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - - - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-413 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-414 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ INNER JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-415 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ INNER JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-416 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL INNER JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-417 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-418 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-419 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+}
+do_execsql_test joinB-420 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-421 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-422 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-423 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-424 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-425 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+}
+do_execsql_test joinB-426 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - 38 38 - 38
+}
+do_execsql_test joinB-427 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+}
+do_execsql_test joinB-428 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - - - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-429 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-430 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - - - 39
+}
+do_execsql_test joinB-431 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - - 19
+}
+do_execsql_test joinB-432 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-433 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-434 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - - 39 39
+}
+do_execsql_test joinB-435 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - - 19 19
+}
+do_execsql_test joinB-436 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-437 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-438 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-439 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-440 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-441 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-442 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - - 39 39
+}
+do_execsql_test joinB-443 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-444 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 LEFT JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - - 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - - - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-445 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-446 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ LEFT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - - 39 39
+}
+do_execsql_test joinB-447 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ LEFT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - - 19 19
+}
+do_execsql_test joinB-448 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL LEFT JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-449 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-450 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-451 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-452 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-453 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-454 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-455 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-456 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-457 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-458 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-459 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-460 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-461 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-462 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-463 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-464 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-465 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-466 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-467 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-468 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-469 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-470 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-471 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-472 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-473 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-474 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-475 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-476 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 RIGHT JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-477 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-478 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ RIGHT JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-479 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ RIGHT JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-480 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL RIGHT JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-481 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-482 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-483 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-484 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ INNER JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-485 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-486 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ INNER JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-487 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ INNER JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-488 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL INNER JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-489 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-490 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-491 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-492 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ LEFT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-493 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-494 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ LEFT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-495 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ LEFT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-496 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL LEFT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-497 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-498 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-499 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-500 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ RIGHT JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+}
+do_execsql_test joinB-501 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-502 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ RIGHT JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 - - - - 37
+ 18 28 - - - - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-503 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ RIGHT JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 - - - - 17
+ 18 - - - - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-504 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL RIGHT JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+do_execsql_test joinB-505 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ INNER JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-506 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ INNER JOIN t5 USING(a,b)
+ WHERE a<>13
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 35 35 35 35 35
+ 17 37 - 37 - 37
+ 18 - 38 38 - 38
+ 19 - - 39 39 39
+}
+do_execsql_test joinB-507 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ LEFT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-508 {
+ SELECT a, c, d, e, f, g
+ FROM t1
+ FULL JOIN (t2 FULL JOIN t3 USING(a)) USING(a)
+ FULL JOIN (t4 LEFT JOIN t5 USING(a)) USING(a)
+ WHERE a<=18
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 31 - 31 31 -
+ 12 32 32 32 - -
+ 13 - 33 33 33 -
+ 15 35 35 35 35 35
+ 17 37 - 37 - -
+ 18 - 38 38 - -
+}
+do_execsql_test joinB-509 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ RIGHT JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-510 {
+ SELECT a, b, c, d, e, f, g
+ FROM t1
+ FULL JOIN t2 USING(a,b)
+ FULL JOIN t3 USING(a,b)
+ FULL JOIN t4 USING(a,b)
+ RIGHT JOIN t5 USING(a,b)
+ WHERE d<>33 OR d IS NULL
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 25 35 35 35 35 35
+ 17 27 37 - 37 - 37
+ 18 28 - 38 38 - 38
+ 19 29 - - 39 39 39
+}
+do_execsql_test joinB-511 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1
+ FULL JOIN t2 USING(a)
+ FULL JOIN t3 USING(a)
+ FULL JOIN t4 USING(a)
+ FULL JOIN t5 USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+}
+do_execsql_test joinB-512 {
+ SELECT b, c, d, e, f, g
+ FROM t1
+ NATURAL FULL JOIN t2
+ NATURAL FULL JOIN t3
+ NATURAL FULL JOIN t4
+ NATURAL FULL JOIN t5
+ WHERE b BETWEEN 12 AND 17
+ ORDER BY 1 NULLS FIRST;
+} {
+}
+finish_test
+
+##############################################################################
+# Here is the original TCL script that generated the psql input file:
+#
+#
+# puts "
+# \\pset border off
+# \\pset tuples_only on
+# \\pset null -
+#
+# DROP TABLE IF EXISTS t1;
+# DROP TABLE IF EXISTS t2;
+# DROP TABLE IF EXISTS t3;
+# DROP TABLE IF EXISTS t4;
+# DROP TABLE IF EXISTS t5;
+# CREATE TABLE t1(a INT, b INT, c INT);
+# CREATE TABLE t2(a INT, b INT, d INT);
+# CREATE TABLE t3(a INT, b INT, e INT);
+# CREATE TABLE t4(a INT, b INT, f INT);
+# CREATE TABLE t5(a INT, b INT, g INT);
+# INSERT INTO t1 VALUES(11,21,31),(12,22,32),(15,25,35),(17,27,37);
+# INSERT INTO t2 VALUES(12,22,32),(13,23,33),(15,25,35),(18,28,38),(NULL,NULL,36);
+# INSERT INTO t4 VALUES(11,21,31),(13,23,33),(15,25,35),(19,29,39);
+# INSERT INTO t3 SELECT * FROM t1 UNION SELECT * FROM t2 UNION SELECT * FROM t4;
+# INSERT INTO t5 SELECT * FROM t3 WHERE a>=15;
+# "
+#
+# proc echo {prefix txt} {
+# regsub -all {\n} $txt \n$prefix txt
+# puts "$prefix$txt"
+# }
+#
+# set n 0
+# set k 0
+# foreach j1 {INNER LEFT RIGHT FULL} {
+# foreach j2 {INNER LEFT RIGHT FULL} {
+# foreach j3 {INNER LEFT RIGHT FULL} {
+# foreach j4 {INNER LEFT RIGHT FULL} {
+#
+# incr n
+# incr k
+# set q1 ""
+# append q1 "SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a\n"
+# append q1 " FROM t1\n"
+# append q1 " $j1 JOIN t2 USING(a)\n"
+# append q1 " $j2 JOIN t3 USING(a)\n"
+# append q1 " $j3 JOIN t4 USING(a)\n"
+# append q1 " $j4 JOIN t5 USING(a)\n"
+# append q1 " ORDER BY 1 NULLS FIRST;"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# switch [expr {$k%4}] {
+# 0 {
+# set q2 ""
+# append q2 "SELECT b, c, d, e, f, g\n"
+# append q2 " FROM t1\n"
+# append q2 " NATURAL $j1 JOIN t2\n"
+# append q2 " NATURAL $j2 JOIN t3\n"
+# append q2 " NATURAL $j3 JOIN t4\n"
+# append q2 " NATURAL $j4 JOIN t5\n"
+# append q2 " WHERE b BETWEEN 12 AND 17\n"
+# append q2 " ORDER BY 1 NULLS FIRST;"
+# incr n
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q2
+# echo "\\qecho " "\} \{"
+# puts $q2
+# echo "\\qecho " "\}"
+# }
+# 1 {
+# set q2 ""
+# append q2 "SELECT a, c, d, e, f, g\n"
+# append q2 " FROM t1\n"
+# append q2 " $j1 JOIN t2 USING(a,b)\n"
+# append q2 " $j2 JOIN t3 USING(a,b)\n"
+# append q2 " $j3 JOIN t4 USING(a,b)\n"
+# append q2 " $j4 JOIN t5 USING(a,b)\n"
+# append q2 " WHERE a<>13\n"
+# append q2 " ORDER BY 1 NULLS FIRST;"
+# incr n
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q2
+# echo "\\qecho " "\} \{"
+# puts $q2
+# echo "\\qecho " "\}"
+# }
+# 2 {
+# set q2 ""
+# append q2 "SELECT a, c, d, e, f, g\n"
+# append q2 " FROM t1\n"
+# append q2 " $j1 JOIN (t2 $j2 JOIN t3 USING(a)) USING(a)\n"
+# append q2 " $j3 JOIN (t4 $j4 JOIN t5 USING(a)) USING(a)\n"
+# append q2 " WHERE a<=18\n"
+# append q2 " ORDER BY 1 NULLS FIRST;"
+# incr n
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q2
+# echo "\\qecho " "\} \{"
+# puts $q2
+# echo "\\qecho " "\}"
+# }
+# 3 {
+# set q2 ""
+# append q2 "SELECT a, b, c, d, e, f, g\n"
+# append q2 " FROM t1\n"
+# append q2 " $j1 JOIN t2 USING(a,b)\n"
+# append q2 " $j2 JOIN t3 USING(a,b)\n"
+# append q2 " $j3 JOIN t4 USING(a,b)\n"
+# append q2 " $j4 JOIN t5 USING(a,b)\n"
+# append q2 " WHERE d<>33 OR d IS NULL\n"
+# append q2 " ORDER BY 1 NULLS FIRST;"
+# incr n
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q2
+# echo "\\qecho " "\} \{"
+# puts $q2
+# echo "\\qecho " "\}"
+# }
+# }
+#
+# }
+# }
+# }
+# }
+##############################################################################
diff --git a/test/joinC.test b/test/joinC.test
new file mode 100644
index 0000000..a6f9395
--- /dev/null
+++ b/test/joinC.test
@@ -0,0 +1,4594 @@
+# 2022-04-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 JOINs.
+#
+# The test case output is all generated by PostgreSQL 14. This test module
+# was created as follows:
+#
+# 1. Run a TCL script (included at the bottom of this file) that
+# generates an input script for "psql" that will run man
+# diverse tests on joins.
+#
+# 2. Run the script from step (1) through psql and collect the
+# output.
+#
+# 3. Make a few minor global search-and-replace operations to convert
+# the psql output into a form suitable for this test module.
+#
+# 4. Add this header, and the script content at the footer.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db nullvalue -
+db eval {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ DROP TABLE IF EXISTS t3;
+ DROP TABLE IF EXISTS t4;
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t1(a INT, b INT, c INT);
+ CREATE TABLE t2(a INT, b INT, d INT);
+ CREATE TABLE t3(a INT, b INT, e INT);
+ CREATE TABLE t4(a INT, b INT, f INT);
+ CREATE TABLE t5(a INT, b INT, g INT);
+ INSERT INTO t1 VALUES(11,21,31),(12,22,32),(15,25,35),(17,27,37);
+ INSERT INTO t2 VALUES(12,22,32),(13,23,33),(15,25,35),(18,28,38),
+ (NULL,NULL,36);
+ INSERT INTO t4 VALUES(11,21,31),(13,23,33),(15,25,35),(19,29,39);
+ INSERT INTO t3 SELECT * FROM t1 UNION SELECT * FROM t2 UNION SELECT * FROM t4;
+ INSERT INTO t5 SELECT * FROM t3 WHERE a>=15;
+}
+do_execsql_test joinC-1 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-2 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-3 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-4 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-5 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-6 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-7 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-8 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-9 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-10 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-11 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-12 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-13 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-14 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-15 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-16 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-17 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-18 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-19 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-20 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-21 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-22 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-23 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-24 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-25 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-26 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-27 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-28 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-29 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-30 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-31 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-32 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-33 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-34 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-35 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-36 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-37 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-38 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-39 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-40 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-41 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-42 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-43 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-44 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-45 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-46 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-47 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-48 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-49 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-50 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-51 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-52 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-53 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-54 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-55 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-56 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-57 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-58 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-59 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-60 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-61 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-62 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-63 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-64 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 INNER JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-65 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-66 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-67 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-68 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-69 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-70 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-71 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-72 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-73 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-74 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-75 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-76 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-77 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-78 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-79 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-80 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-81 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-82 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-83 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-84 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-85 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-86 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-87 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-88 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-89 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-90 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-91 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-92 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-93 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-94 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-95 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-96 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-97 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-98 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-99 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-100 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-101 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-102 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-103 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-104 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-105 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-106 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-107 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-108 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-109 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-110 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-111 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-112 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-113 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-114 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-115 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-116 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-117 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-118 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-119 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-120 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-121 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-122 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-123 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-124 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-125 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-126 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+
+}
+do_execsql_test joinC-127 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-128 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 LEFT JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+
+}
+do_execsql_test joinC-129 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-130 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-131 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-132 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-133 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-134 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-135 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-136 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-137 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-138 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+
+}
+do_execsql_test joinC-139 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-140 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-141 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-142 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-143 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-144 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-145 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 18 - 18 - - -
+
+}
+do_execsql_test joinC-146 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 - - -
+
+}
+do_execsql_test joinC-147 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-148 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-149 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-150 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-151 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-152 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-153 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 18 - 18 - - -
+
+}
+do_execsql_test joinC-154 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 - - -
+
+}
+do_execsql_test joinC-155 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-156 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-157 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-158 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-159 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-160 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-161 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-162 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-163 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-164 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-165 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-166 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-167 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-168 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-169 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-170 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-171 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-172 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-173 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-174 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-175 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-176 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-177 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 18 - 18 - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-178 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-179 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-180 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-181 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-182 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-183 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-184 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-185 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 18 - 18 - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-186 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 18 - 18 - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-187 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-188 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-189 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-190 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-191 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-192 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 RIGHT JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-193 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-194 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-195 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-196 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-197 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-198 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-199 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-200 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-201 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-202 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+
+}
+do_execsql_test joinC-203 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-204 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-205 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-206 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-207 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-208 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 INNER JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-209 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 - - -
+
+}
+do_execsql_test joinC-210 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 - - -
+
+}
+do_execsql_test joinC-211 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-212 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-213 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-214 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-215 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-216 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-217 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 - - -
+
+}
+do_execsql_test joinC-218 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 - - -
+
+}
+do_execsql_test joinC-219 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-220 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-221 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-222 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - -
+
+}
+do_execsql_test joinC-223 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-224 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 LEFT JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 18 - 18
+
+}
+do_execsql_test joinC-225 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-226 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 - - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-227 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-228 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 - - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-229 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-230 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-231 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-232 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-233 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-234 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 - - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-235 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - - - -
+ 12 12 - - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-236 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ 11 11 - 11 11 -
+ 12 12 - - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-237 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-238 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-239 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-240 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 RIGHT JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-241 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-242 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-243 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-244 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 INNER JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-245 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-246 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-247 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-248 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 LEFT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-249 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-250 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - - - -
+ 18 - 18 - - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-251 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - - - -
+ 12 12 12 - - -
+ 13 - 13 - - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-252 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 RIGHT JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 - - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-253 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 INNER JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-254 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 LEFT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - -
+ 18 - 18 18 - -
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-255 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 RIGHT JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 - -
+ 12 12 12 12 - -
+ 13 - 13 13 - -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+do_execsql_test joinC-256 {
+ SELECT a, t1.a, t2.a, t3.a, t4.a, t5.a
+ FROM t1 FULL JOIN (
+ t2 FULL JOIN (
+ t3 FULL JOIN (
+ t4 FULL JOIN t5 USING(a)
+ ) USING(a)
+ ) USING(a)
+ ) USING(a)
+ ORDER BY 1 NULLS FIRST;
+} {
+ - - - - - -
+ - - - - - -
+ 11 11 - 11 11 -
+ 12 12 12 12 - -
+ 13 - 13 13 13 -
+ 15 15 15 15 15 15
+ 17 17 - 17 - 17
+ 18 - 18 18 - 18
+ 19 - - 19 19 19
+
+}
+finish_test
diff --git a/test/joinD.test b/test/joinD.test
new file mode 100644
index 0000000..e4e4553
--- /dev/null
+++ b/test/joinD.test
@@ -0,0 +1,35136 @@
+# 2022-05-04
+# revised 2022-05-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.
+#
+#***********************************************************************
+#
+# TESTRUNNER: slow
+#
+# This file implements tests for JOINs that use Bloom filters.
+#
+# The test case output is (mostly) all generated by PostgreSQL 14. This
+# test module was created as follows:
+#
+# 1. Run a TCL script (included at the bottom of this file) that
+# generates an input script for "psql" that will run man
+# diverse tests on joins.
+#
+# 2. Run the script from step (1) through psql and collect the
+# output.
+#
+# 3. Make a few minor global search-and-replace operations to convert
+# the psql output into a form suitable for this test module.
+#
+# 4. Add this header, and the script content at the footer.
+#
+# A few extra tests that were not generated from postgresql output are
+# added at the end.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db nullvalue -
+db eval {
+ CREATE TABLE t1(a INT, b INT, c INT, d INT);
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<95)
+ INSERT INTO t1(a,b,c,d) SELECT x, x+100, x+200, x+300 FROM c;
+ CREATE TABLE t2(b INT, x INT);
+ INSERT INTO t2(b,x) SELECT b, a FROM t1 WHERE a%2=0;
+ CREATE INDEX t2b ON t2(b);
+ CREATE TABLE t3(c INT, y INT);
+ INSERT INTO t3(c,y) SELECT c, a FROM t1 WHERE a%3=0;
+ CREATE INDEX t3c ON t3(c);
+ CREATE TABLE t4(d INT, z INT);
+ INSERT INTO t4(d,z) SELECT d, a FROM t1 WHERE a%5=0;
+ CREATE INDEX t4d ON t4(d);
+ INSERT INTO t1(a,b,c,d) VALUES
+ (96,NULL,296,396),
+ (97,197,NULL,397),
+ (98,198,298,NULL),
+ (99,NULL,NULL,NULL);
+ ANALYZE;
+}
+do_execsql_test joinD-1 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-2 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-3 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-4 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-5 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-6 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-7 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-8 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-9 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-10 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-11 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-12 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-13 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-14 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-15 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-16 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-17 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-18 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-19 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-20 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-21 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-22 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-23 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-24 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-25 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-26 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-27 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-28 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-29 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-30 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-31 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-32 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-33 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-34 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-35 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-36 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-37 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-38 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-39 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-40 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-41 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-42 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-43 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-44 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-45 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-46 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-47 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-48 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-49 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-50 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-51 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-52 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-53 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-54 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-55 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-56 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-57 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-58 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-59 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-60 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-61 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-62 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-63 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-64 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-65 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-66 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-67 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-68 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-69 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-70 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-71 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-72 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-73 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-74 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-75 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-76 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-77 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-78 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-79 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-80 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-81 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-82 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-83 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-84 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-85 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-86 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-87 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-88 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-89 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-90 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-91 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-92 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-93 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-94 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-95 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-96 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-97 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-98 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-99 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-100 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-101 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-102 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-103 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-104 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-105 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-106 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-107 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-108 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-109 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-110 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-111 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-112 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-113 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-114 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-115 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-116 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-117 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-118 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-119 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-120 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-121 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-122 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-123 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-124 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-125 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-126 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-127 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-128 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-129 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-130 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-131 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-132 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-133 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-134 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-135 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-136 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-137 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-138 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-139 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-140 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-141 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-142 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-143 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-144 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-145 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-146 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-147 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-148 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-149 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-150 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-151 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-152 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-153 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-154 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-155 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-156 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-157 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-158 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-159 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-160 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-161 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-162 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-163 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-164 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-165 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-166 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-167 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-168 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-169 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-170 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-171 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-172 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-173 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-174 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-175 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-176 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-177 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-178 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-179 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-180 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-181 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-182 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-183 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-184 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-185 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-186 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-187 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-188 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-189 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-190 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-191 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-192 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-193 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-194 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-195 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-196 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-197 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-198 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-199 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-200 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-201 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-202 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-203 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-204 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-205 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-206 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-207 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-208 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-209 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-210 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-211 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-212 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-213 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-214 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-215 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-216 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-217 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-218 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-219 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-220 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-221 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-222 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-223 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-224 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-225 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-226 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-227 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-228 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-229 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-230 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-231 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-232 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-233 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-234 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-235 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-236 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-237 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-238 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-239 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-240 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-241 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-242 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-243 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-244 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-245 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-246 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-247 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-248 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-249 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-250 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-251 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-252 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-253 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-254 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-255 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-256 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-257 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-258 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-259 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-260 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-261 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-262 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-263 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-264 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-265 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-266 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-267 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-268 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-269 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-270 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-271 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-272 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-273 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-274 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-275 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-276 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-277 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-278 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-279 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-280 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-281 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-282 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-283 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-284 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-285 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-286 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-287 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-288 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-289 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-290 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-291 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-292 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-293 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-294 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-295 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-296 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-297 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-298 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-299 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-300 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 INNER JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-301 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-302 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-303 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-304 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-305 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-306 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-307 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-308 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-309 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-310 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-311 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-312 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-313 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-314 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-315 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-316 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-317 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-318 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-319 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-320 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-321 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-322 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-323 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-324 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-325 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-326 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-327 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-328 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-329 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-330 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-331 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-332 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-333 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-334 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-335 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-336 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-337 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-338 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-339 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-340 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-341 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-342 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-343 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-344 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-345 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-346 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-347 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-348 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-349 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-350 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-351 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-352 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-353 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-354 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-355 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-356 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-357 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-358 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-359 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-360 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-361 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-362 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-363 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-364 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-365 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-366 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-367 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-368 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-369 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-370 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-371 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-372 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-373 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-374 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-375 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-376 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-377 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-378 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-379 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-380 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-381 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-382 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-383 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-384 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-385 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-386 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-387 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-388 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-389 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-390 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-391 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-392 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-393 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-394 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-395 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-396 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-397 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-398 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-399 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-400 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-401 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-402 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-403 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-404 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-405 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-406 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-407 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-408 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-409 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-410 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-411 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-412 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-413 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-414 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-415 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-416 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-417 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-418 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-419 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-420 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-421 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-422 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-423 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-424 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-425 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-426 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-427 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-428 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-429 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-430 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-431 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-432 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-433 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-434 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-435 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-436 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-437 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-438 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-439 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-440 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-441 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-442 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-443 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-444 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-445 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-446 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-447 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-448 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-449 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-450 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-451 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-452 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-453 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-454 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-455 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-456 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-457 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-458 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-459 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-460 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-461 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-462 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-463 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-464 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-465 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-466 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-467 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-468 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-469 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-470 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-471 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-472 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-473 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-474 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-475 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-476 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-477 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-478 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-479 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-480 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-481 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-482 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-483 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-484 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-485 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-486 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-487 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-488 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-489 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-490 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-491 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-492 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-493 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-494 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-495 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-496 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-497 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-498 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-499 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-500 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-501 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-502 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-503 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-504 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-505 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-506 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-507 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-508 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-509 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-510 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-511 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-512 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-513 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-514 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-515 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-516 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-517 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-518 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-519 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-520 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-521 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-522 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-523 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-524 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-525 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-526 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-527 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-528 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-529 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-530 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-531 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-532 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-533 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-534 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-535 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-536 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-537 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-538 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-539 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-540 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-541 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-542 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-543 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-544 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-545 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-546 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-547 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-548 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-549 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-550 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-551 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-552 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-553 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-554 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-555 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-556 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-557 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-558 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-559 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-560 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-561 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-562 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-563 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-564 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-565 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-566 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-567 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-568 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-569 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-570 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-571 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-572 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-573 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-574 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-575 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-576 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-577 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-578 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-579 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-580 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-581 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-582 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-583 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-584 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-585 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-586 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-587 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-588 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-589 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-590 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-591 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-592 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-593 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-594 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-595 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-596 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-597 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-598 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-599 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-600 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 LEFT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-601 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-602 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-603 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-604 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-605 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-606 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-607 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-608 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-609 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-610 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-611 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-612 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-613 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-614 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-615 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-616 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-617 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-618 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-619 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-620 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-621 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-622 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-623 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-624 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-625 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-626 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-627 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-628 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-629 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-630 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-631 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-632 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-633 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-634 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-635 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-636 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-637 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-638 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-639 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-640 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-641 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-642 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-643 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-644 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-645 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-646 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-647 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-648 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-649 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-650 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-651 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-652 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-653 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-654 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-655 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-656 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-657 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-658 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-659 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-660 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-661 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-662 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-663 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-664 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-665 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-666 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-667 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-668 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-669 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-670 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-671 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-672 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-673 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-674 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-675 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-676 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-677 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-678 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-679 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-680 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-681 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-682 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-683 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-684 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-685 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-686 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-687 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-688 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-689 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-690 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-691 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-692 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-693 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-694 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-695 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-696 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-697 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-698 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-699 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-700 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-701 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-702 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-703 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-704 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-705 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-706 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-707 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-708 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-709 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-710 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-711 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-712 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-713 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-714 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-715 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-716 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-717 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-718 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-719 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-720 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-721 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-722 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-723 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-724 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-725 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-726 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-727 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-728 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-729 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-730 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-731 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-732 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-733 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-734 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-735 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-736 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-737 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-738 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-739 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-740 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-741 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-742 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-743 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-744 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-745 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-746 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-747 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-748 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-749 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-750 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-751 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-752 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-753 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-754 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-755 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-756 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-757 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-758 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-759 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-760 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-761 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-762 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-763 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-764 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-765 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-766 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-767 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-768 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-769 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-770 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-771 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-772 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-773 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-774 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-775 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-776 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-777 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-778 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-779 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-780 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-781 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-782 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-783 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-784 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-785 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-786 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-787 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-788 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-789 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-790 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-791 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-792 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-793 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-794 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-795 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-796 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-797 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-798 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-799 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-800 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-801 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-802 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-803 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-804 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-805 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-806 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-807 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-808 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-809 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-810 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-811 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-812 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-813 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-814 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-815 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-816 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-817 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-818 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-819 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-820 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-821 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-822 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-823 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-824 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-825 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-826 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-827 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-828 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 315 15
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 345 45
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 375 75
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-829 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-830 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-831 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-832 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-833 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-834 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-835 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-836 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-837 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-838 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-839 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-840 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-841 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-842 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-843 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-844 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-845 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-846 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-847 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-848 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-849 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-850 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-851 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-852 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-853 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-854 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-855 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-856 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-857 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-858 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-859 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-860 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-861 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-862 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-863 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-864 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-865 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-866 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-867 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-868 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-869 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-870 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-871 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-872 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-873 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-874 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-875 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-876 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-877 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-878 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-879 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-880 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-881 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-882 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-883 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-884 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-885 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-886 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-887 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-888 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+}
+do_execsql_test joinD-889 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-890 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-891 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-892 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-893 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-894 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-895 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-896 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-897 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-898 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-899 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b IS NOT DISTINCT FROM t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-900 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 RIGHT JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - 203 3 - -
+ - - - - - - 209 9 - -
+ - - - - - - 215 15 - -
+ - - - - - - 221 21 - -
+ - - - - - - 227 27 - -
+ - - - - - - 233 33 - -
+ - - - - - - 239 39 - -
+ - - - - - - 245 45 - -
+ - - - - - - 251 51 - -
+ - - - - - - 257 57 - -
+ - - - - - - 263 63 - -
+ - - - - - - 269 69 - -
+ - - - - - - 275 75 - -
+ - - - - - - 281 81 - -
+ - - - - - - 287 87 - -
+ - - - - - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 315 15
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 345 45
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 375 75
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-901 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-902 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-903 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-904 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-905 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-906 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-907 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-908 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-909 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-910 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-911 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-912 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-913 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-914 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-915 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-916 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-917 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-918 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-919 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-920 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-921 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-922 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-923 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-924 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-925 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-926 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-927 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-928 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-929 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-930 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-931 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-932 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-933 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-934 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-935 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-936 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-937 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-938 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-939 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-940 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-941 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-942 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-943 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-944 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-945 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-946 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-947 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-948 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-949 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-950 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-951 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-952 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-953 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-954 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-955 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-956 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-957 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-958 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-959 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-960 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-961 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-962 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-963 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ INNER JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-964 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-965 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-966 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-967 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ INNER JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-968 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ INNER JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-969 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-970 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-971 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-972 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-973 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-974 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-975 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-976 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-977 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-978 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-979 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-980 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-981 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-982 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-983 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-984 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-985 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-986 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-987 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-988 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+}
+do_execsql_test joinD-989 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-990 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-991 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-992 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-993 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-994 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-995 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-996 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-997 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-998 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-999 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1000 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1001 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1002 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-1003 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1004 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1005 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1006 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1007 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1008 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1009 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1010 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1011 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1012 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1013 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1014 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1015 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1016 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1017 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1018 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1019 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1020 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1021 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1022 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1023 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1024 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-1025 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1026 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1027 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-1028 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1029 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1030 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1031 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ LEFT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1032 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1033 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1034 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1035 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ LEFT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1036 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ LEFT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1037 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1038 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1039 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1040 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1041 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1042 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1043 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1044 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1045 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1046 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1047 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1048 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1049 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1050 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1051 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1052 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1053 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1054 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1055 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1056 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1057 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1058 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-1059 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-1060 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1061 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1062 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1063 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1064 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1065 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1066 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1067 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1068 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1069 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1070 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1071 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1072 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1073 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1074 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1075 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1076 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1077 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1078 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1079 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1080 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1081 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1082 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1083 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1084 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1085 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1086 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1087 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1088 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1089 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1090 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1091 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1092 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-1093 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1094 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1095 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1096 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1097 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1098 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1099 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ RIGHT JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1100 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1101 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1102 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c IS NOT DISTINCT FROM t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1103 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ RIGHT JOIN t3 ON t1.c IS NOT DISTINCT FROM t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1104 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+ - - - - - - - - 305 5
+ - - - - - - - - 310 10
+ - - - - - - - - 320 20
+ - - - - - - - - 325 25
+ - - - - - - - - 335 35
+ - - - - - - - - 340 40
+ - - - - - - - - 350 50
+ - - - - - - - - 355 55
+ - - - - - - - - 365 65
+ - - - - - - - - 370 70
+ - - - - - - - - 380 80
+ - - - - - - - - 385 85
+ - - - - - - - - 395 95
+}
+do_execsql_test joinD-1105 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1106 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1107 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1108 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1109 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1110 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1111 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1112 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1113 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1114 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1115 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1116 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ INNER JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1117 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1118 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1119 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ INNER JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1120 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ INNER JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1121 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1122 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1123 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1124 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1125 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-1126 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+}
+do_execsql_test joinD-1127 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1128 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1129 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1130 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1131 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1132 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ LEFT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1133 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1134 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1135 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ LEFT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1136 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ LEFT JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1137 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1138 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1139 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1140 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1141 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1142 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1143 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1144 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1145 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1146 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1147 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1148 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ RIGHT JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1149 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1150 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1151 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ RIGHT JOIN t4 ON t1.d IS NOT DISTINCT FROM t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1152 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ RIGHT JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d IS NOT DISTINCT FROM t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1153 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1154 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1155 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE (t2.x>0 OR t2.x IS NULL)
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1156 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON true
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t1.b=t2.b AND t2.x>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1157 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 3 103 203 303 - - 203 3 - -
+ 6 106 206 306 106 6 206 6 - -
+ 9 109 209 309 - - 209 9 - -
+ 12 112 212 312 112 12 212 12 - -
+ 15 115 215 315 - - 215 15 315 15
+ 18 118 218 318 118 18 218 18 - -
+ 21 121 221 321 - - 221 21 - -
+ 24 124 224 324 124 24 224 24 - -
+ 27 127 227 327 - - 227 27 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 33 133 233 333 - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ 39 139 239 339 - - 239 39 - -
+ 42 142 242 342 142 42 242 42 - -
+ 45 145 245 345 - - 245 45 345 45
+ 48 148 248 348 148 48 248 48 - -
+ 51 151 251 351 - - 251 51 - -
+ 54 154 254 354 154 54 254 54 - -
+ 57 157 257 357 - - 257 57 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 63 163 263 363 - - 263 63 - -
+ 66 166 266 366 166 66 266 66 - -
+ 69 169 269 369 - - 269 69 - -
+ 72 172 272 372 172 72 272 72 - -
+ 75 175 275 375 - - 275 75 375 75
+ 78 178 278 378 178 78 278 78 - -
+ 81 181 281 381 - - 281 81 - -
+ 84 184 284 384 184 84 284 84 - -
+ 87 187 287 387 - - 287 87 - -
+ 90 190 290 390 190 90 290 90 390 90
+ 93 193 293 393 - - 293 93 - -
+}
+do_execsql_test joinD-1158 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t3.y>0 OR t3.y IS NULL
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1159 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 5 105 205 305 - - - - 305 5
+ 10 110 210 310 110 10 - - 310 10
+ 15 115 215 315 - - 215 15 315 15
+ 20 120 220 320 120 20 - - 320 20
+ 25 125 225 325 - - - - 325 25
+ 30 130 230 330 130 30 230 30 330 30
+ 35 135 235 335 - - - - 335 35
+ 40 140 240 340 140 40 - - 340 40
+ 45 145 245 345 - - 245 45 345 45
+ 50 150 250 350 150 50 - - 350 50
+ 55 155 255 355 - - - - 355 55
+ 60 160 260 360 160 60 260 60 360 60
+ 65 165 265 365 - - - - 365 65
+ 70 170 270 370 170 70 - - 370 70
+ 75 175 275 375 - - 275 75 375 75
+ 80 180 280 380 180 80 - - 380 80
+ 85 185 285 385 - - - - 385 85
+ 90 190 290 390 190 90 290 90 390 90
+ 95 195 295 395 - - - - 395 95
+}
+do_execsql_test joinD-1160 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z IS NULL OR t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+}
+do_execsql_test joinD-1161 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1162 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t4.z>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 15 115 215 315 - - 215 15 315 15
+ 30 130 230 330 130 30 230 30 330 30
+ 45 145 245 345 - - 245 45 345 45
+ 60 160 260 360 160 60 260 60 360 60
+ 75 175 275 375 - - 275 75 375 75
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1163 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d AND t4.z>0
+ WHERE t2.x>0 AND t3.y>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1164 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b=t2.b
+ FULL JOIN t3 ON t1.c=t3.c
+ FULL JOIN t4 ON t1.d=t4.d
+ WHERE t2.x>0 AND t3.y>0 AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ 60 160 260 360 160 60 260 60 360 60
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1165 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t1.b = t2.b AND t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 0 100 200 300 - - - - - -
+ 1 101 201 301 - - - - - -
+ 2 102 202 302 102 2 - - - -
+ 3 103 203 303 - - 203 3 - -
+ 4 104 204 304 104 4 - - - -
+ 5 105 205 305 - - - - 305 5
+ 6 106 206 306 106 6 206 6 - -
+ 7 107 207 307 - - - - - -
+ 8 108 208 308 108 8 - - - -
+ 9 109 209 309 - - 209 9 - -
+ 10 110 210 310 110 10 - - 310 10
+ 11 111 211 311 - - - - - -
+ 12 112 212 312 112 12 212 12 - -
+ 13 113 213 313 - - - - - -
+ 14 114 214 314 114 14 - - - -
+ 15 115 215 315 - - 215 15 315 15
+ 16 116 216 316 116 16 - - - -
+ 17 117 217 317 - - - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 19 119 219 319 - - - - - -
+ 20 120 220 320 120 20 - - 320 20
+ 21 121 221 321 - - 221 21 - -
+ 22 122 222 322 122 22 - - - -
+ 23 123 223 323 - - - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 25 125 225 325 - - - - 325 25
+ 26 126 226 326 126 26 - - - -
+ 27 127 227 327 - - 227 27 - -
+ 28 128 228 328 128 28 - - - -
+ 29 129 229 329 - - - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 31 131 231 331 - - - - - -
+ 32 132 232 332 132 32 - - - -
+ 33 133 233 333 - - 233 33 - -
+ 34 134 234 334 134 34 - - - -
+ 35 135 235 335 - - - - 335 35
+ 36 136 236 336 136 36 236 36 - -
+ 37 137 237 337 - - - - - -
+ 38 138 238 338 138 38 - - - -
+ 39 139 239 339 - - 239 39 - -
+ 40 140 240 340 140 40 - - 340 40
+ 41 141 241 341 - - - - - -
+ 42 142 242 342 142 42 242 42 - -
+ 43 143 243 343 - - - - - -
+ 44 144 244 344 144 44 - - - -
+ 45 145 245 345 - - 245 45 345 45
+ 46 146 246 346 146 46 - - - -
+ 47 147 247 347 - - - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 49 149 249 349 - - - - - -
+ 50 150 250 350 150 50 - - 350 50
+ 51 151 251 351 - - 251 51 - -
+ 52 152 252 352 152 52 - - - -
+ 53 153 253 353 - - - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 55 155 255 355 - - - - 355 55
+ 56 156 256 356 156 56 - - - -
+ 57 157 257 357 - - 257 57 - -
+ 58 158 258 358 158 58 - - - -
+ 59 159 259 359 - - - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 61 161 261 361 - - - - - -
+ 62 162 262 362 162 62 - - - -
+ 63 163 263 363 - - 263 63 - -
+ 64 164 264 364 164 64 - - - -
+ 65 165 265 365 - - - - 365 65
+ 66 166 266 366 166 66 266 66 - -
+ 67 167 267 367 - - - - - -
+ 68 168 268 368 168 68 - - - -
+ 69 169 269 369 - - 269 69 - -
+ 70 170 270 370 170 70 - - 370 70
+ 71 171 271 371 - - - - - -
+ 72 172 272 372 172 72 272 72 - -
+ 73 173 273 373 - - - - - -
+ 74 174 274 374 174 74 - - - -
+ 75 175 275 375 - - 275 75 375 75
+ 76 176 276 376 176 76 - - - -
+ 77 177 277 377 - - - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 79 179 279 379 - - - - - -
+ 80 180 280 380 180 80 - - 380 80
+ 81 181 281 381 - - 281 81 - -
+ 82 182 282 382 182 82 - - - -
+ 83 183 283 383 - - - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 85 185 285 385 - - - - 385 85
+ 86 186 286 386 186 86 - - - -
+ 87 187 287 387 - - 287 87 - -
+ 88 188 288 388 188 88 - - - -
+ 89 189 289 389 - - - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 91 191 291 391 - - - - - -
+ 92 192 292 392 192 92 - - - -
+ 93 193 293 393 - - 293 93 - -
+ 94 194 294 394 194 94 - - - -
+ 95 195 295 395 - - - - 395 95
+ 96 - 296 396 - - - - - -
+ 97 197 - 397 - - - - - -
+ 98 198 298 - - - - - - -
+ 99 - - - - - - - - -
+ - - - - 100 0 - - - -
+ - - - - - - 200 0 - -
+ - - - - - - - - 300 0
+}
+do_execsql_test joinD-1166 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b = t2.b
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 2 102 202 302 102 2 - - - -
+ 4 104 204 304 104 4 - - - -
+ 6 106 206 306 106 6 206 6 - -
+ 8 108 208 308 108 8 - - - -
+ 10 110 210 310 110 10 - - 310 10
+ 12 112 212 312 112 12 212 12 - -
+ 14 114 214 314 114 14 - - - -
+ 16 116 216 316 116 16 - - - -
+ 18 118 218 318 118 18 218 18 - -
+ 20 120 220 320 120 20 - - 320 20
+ 22 122 222 322 122 22 - - - -
+ 24 124 224 324 124 24 224 24 - -
+ 26 126 226 326 126 26 - - - -
+ 28 128 228 328 128 28 - - - -
+ 30 130 230 330 130 30 230 30 330 30
+ 32 132 232 332 132 32 - - - -
+ 34 134 234 334 134 34 - - - -
+ 36 136 236 336 136 36 236 36 - -
+ 38 138 238 338 138 38 - - - -
+ 40 140 240 340 140 40 - - 340 40
+ 42 142 242 342 142 42 242 42 - -
+ 44 144 244 344 144 44 - - - -
+ 46 146 246 346 146 46 - - - -
+ 48 148 248 348 148 48 248 48 - -
+ 50 150 250 350 150 50 - - 350 50
+ 52 152 252 352 152 52 - - - -
+ 54 154 254 354 154 54 254 54 - -
+ 56 156 256 356 156 56 - - - -
+ 58 158 258 358 158 58 - - - -
+ 60 160 260 360 160 60 260 60 360 60
+ 62 162 262 362 162 62 - - - -
+ 64 164 264 364 164 64 - - - -
+ 66 166 266 366 166 66 266 66 - -
+ 68 168 268 368 168 68 - - - -
+ 70 170 270 370 170 70 - - 370 70
+ 72 172 272 372 172 72 272 72 - -
+ 74 174 274 374 174 74 - - - -
+ 76 176 276 376 176 76 - - - -
+ 78 178 278 378 178 78 278 78 - -
+ 80 180 280 380 180 80 - - 380 80
+ 82 182 282 382 182 82 - - - -
+ 84 184 284 384 184 84 284 84 - -
+ 86 186 286 386 186 86 - - - -
+ 88 188 288 388 188 88 - - - -
+ 90 190 290 390 190 90 290 90 390 90
+ 92 192 292 392 192 92 - - - -
+ 94 194 294 394 194 94 - - - -
+}
+do_execsql_test joinD-1167 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t3.y>0
+ FULL JOIN t4 ON t1.d = t4.d AND t4.z>0
+ WHERE t1.b = t2.b AND t1.c = t3.c
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 6 106 206 306 106 6 206 6 - -
+ 12 112 212 312 112 12 212 12 - -
+ 18 118 218 318 118 18 218 18 - -
+ 24 124 224 324 124 24 224 24 - -
+ 30 130 230 330 130 30 230 30 330 30
+ 36 136 236 336 136 36 236 36 - -
+ 42 142 242 342 142 42 242 42 - -
+ 48 148 248 348 148 48 248 48 - -
+ 54 154 254 354 154 54 254 54 - -
+ 60 160 260 360 160 60 260 60 360 60
+ 66 166 266 366 166 66 266 66 - -
+ 72 172 272 372 172 72 272 72 - -
+ 78 178 278 378 178 78 278 78 - -
+ 84 184 284 384 184 84 284 84 - -
+ 90 190 290 390 190 90 290 90 390 90
+}
+do_execsql_test joinD-1168 {
+ SELECT t1.*, t2.*, t3.*, t4.*
+ FROM t1 FULL JOIN t2 ON t2.x>0
+ FULL JOIN t3 ON t1.c = t3.c AND t3.y>0
+ FULL JOIN t4 ON t4.z>0
+ WHERE t1.b = t2.b AND t1.d = t4.d
+ ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);
+} {
+ 10 110 210 310 110 10 - - 310 10
+ 20 120 220 320 120 20 - - 320 20
+ 30 130 230 330 130 30 230 30 330 30
+ 40 140 240 340 140 40 - - 340 40
+ 50 150 250 350 150 50 - - 350 50
+ 60 160 260 360 160 60 260 60 360 60
+ 70 170 270 370 170 70 - - 370 70
+ 80 180 280 380 180 80 - - 380 80
+ 90 190 290 390 190 90 290 90 390 90
+}
+#############################################################################
+# The following are extra tests added manually
+do_execsql_test joinD-extra-1000 {
+ CREATE VIEW v1 AS
+ SELECT *
+ FROM t1 INNER JOIN t2 ON t1.b=t2.b AND t2.x>0
+ RIGHT JOIN t3 ON t1.c=t3.c AND t3.y>0
+ LEFT JOIN t4 ON t1.d=t4.d AND t4.z>0;
+ CREATE TRIGGER v1r1 INSTEAD OF UPDATE OF c ON v1 BEGIN
+ UPDATE t1 SET c=new.c WHERE (a,b,c,d) IS (old.a,old.b,old.c,old.d);
+ UPDATE t3 SET c=new.c WHERE (c,y) IS (old.c,old.y);
+ END;
+ SELECT * FROM v1 WHERE y BETWEEN 30 AND 40 ORDER BY y;
+} {
+ 30 130 230 330 130 30 230 30 330 30
+ - - - - - - 233 33 - -
+ 36 136 236 336 136 36 236 36 - -
+ - - - - - - 239 39 - -
+}
+do_execsql_test joinD-extra-1010 {
+ BEGIN;
+ UPDATE v1 SET c=c+1000 WHERE y BETWEEN 30 and 40;
+ SELECT * FROM v1 WHERE y BETWEEN 30 AND 40 ORDER BY y;
+ ROLLBACK;
+} {
+ 30 130 1230 330 130 30 1230 30 330 30
+ - - - - - - 233 33 - -
+ 36 136 1236 336 136 36 1236 36 - -
+ - - - - - - 239 39 - -
+}
+finish_test
+#############################################################################
+# This is the TCL script used to generate the psql script that generated
+# the data above.
+#
+# puts "
+# \\pset border off
+# \\pset tuples_only on
+# \\pset null -
+#
+# DROP TABLE IF EXISTS t1;
+# DROP TABLE IF EXISTS t2;
+# DROP TABLE IF EXISTS t3;
+# DROP TABLE IF EXISTS t4;
+# CREATE TABLE t1(a INT, b INT, c INT, d INT);
+# WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<95)
+# INSERT INTO t1(a,b,c,d) SELECT x, x+100, x+200, x+300 FROM c;
+# CREATE TABLE t2(b INT, x INT);
+# INSERT INTO t2(b,x) SELECT b, a FROM t1 WHERE a%2=0;
+# CREATE INDEX t2b ON t2(b);
+# CREATE TABLE t3(c INT, y INT);
+# INSERT INTO t3(c,y) SELECT c, a FROM t1 WHERE a%3=0;
+# CREATE INDEX t3c ON t3(c);
+# CREATE TABLE t4(d INT, z INT);
+# INSERT INTO t4(d,z) SELECT d, a FROM t1 WHERE a%5=0;
+# CREATE INDEX t4d ON t4(d);
+# INSERT INTO t1(a,b,c,d) VALUES
+# (96,NULL,296,396),
+# (97,197,NULL,397),
+# (98,198,298,NULL),
+# (99,NULL,NULL,NULL);
+# "
+#
+# proc echo {prefix txt} {
+# regsub -all {\n} $txt \n$prefix txt
+# puts "$prefix$txt"
+# }
+#
+# set n 0
+# foreach j1 {INNER LEFT RIGHT FULL} {
+# foreach j2 {INNER LEFT RIGHT FULL} {
+# foreach j3 {INNER LEFT RIGHT FULL} {
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# if {$j1!="FULL"} {
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b IS NOT DISTINCT FROM t2.b AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+# }
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " WHERE t2.x>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " WHERE (t2.x>0 OR t2.x IS NULL)\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON true\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " WHERE t1.b=t2.b AND t2.x>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " WHERE t3.y>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " WHERE t3.y>0 OR t3.y IS NULL\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d\n"
+# append q1 " WHERE t4.z>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d\n"
+# append q1 " WHERE t4.z IS NULL OR t4.z>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d\n"
+# append q1 " WHERE t2.x>0 AND t4.z>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d\n"
+# append q1 " WHERE t4.z>0 AND t3.y>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " WHERE t2.x>0 AND t3.y>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d\n"
+# append q1 " WHERE t2.x>0 AND t3.y>0 AND t4.z>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# set op1 [expr {$j1=="FULL"?"=":"IS NOT DISTINCT FROM"}]
+# set op2 [expr {$j2=="FULL"?"=":"IS NOT DISTINCT FROM"}]
+# set op3 [expr {$j3=="FULL"?"=":"IS NOT DISTINCT FROM"}]
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b $op1 t2.b AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c $op2 t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d $op3 t4.d AND t4.z>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c $op2 t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d $op3 t4.d AND t4.z>0\n"
+# append q1 " WHERE t1.b $op1 t2.b\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d $op3 t4.d AND t4.z>0\n"
+# append q1 " WHERE t1.b $op1 t2.b AND t1.c $op2 t3.c\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c $op2 t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t4.z>0\n"
+# append q1 " WHERE t1.b $op1 t2.b AND t1.d $op3 t4.d\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# if {$j1!="FULL"} {
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b IN (t2.b,-2,-3) AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c=t3.c AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+# }
+#
+# if {$j2!="FULL"} {
+# incr n
+# set q1 ""
+# append q1 "SELECT t1.*, t2.*, t3.*, t4.*\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON t1.b=t2.b AND t2.x>0\n"
+# append q1 " $j2 JOIN t3 ON t1.c IN (-4,t3.c,-5) AND t3.y>0\n"
+# append q1 " $j3 JOIN t4 ON t1.d=t4.d AND t4.z>0\n"
+# append q1 " ORDER BY coalesce(t1.a,t2.b,t3.c,t4.d,0);"
+#
+# echo "\\qecho " "do_execsql_test joinB-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+# }
+# }
+# }
+# }
+#
diff --git a/test/joinE.test b/test/joinE.test
new file mode 100644
index 0000000..8c8e72a
--- /dev/null
+++ b/test/joinE.test
@@ -0,0 +1,443 @@
+# 2022-05-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 JOINs that use Bloom filters.
+#
+# The test case output is (mostly) all generated by PostgreSQL 14. This
+# test module was created as follows:
+#
+# 1. Run a TCL script (included at the bottom of this file) that
+# generates an input script for "psql" that will run man
+# diverse tests on joins.
+#
+# 2. Run the script from step (1) through psql and collect the
+# output.
+#
+# 3. Make a few minor global search-and-replace operations to convert
+# the psql output into a form suitable for this test module.
+#
+# 4. Add this header, and the script content at the footer.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db nullvalue -
+db eval {
+ CREATE TABLE t1(a INT);
+ INSERT INTO t1 VALUES(1),(NULL);
+ CREATE TABLE t2(b INT);
+ INSERT INTO t2 VALUES(2),(NULL);
+}
+do_execsql_test joinE-1 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON true
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 2
+ 1 -
+ - 2
+ - -
+}
+do_execsql_test joinE-2 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON true WHERE a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ - 2
+ - -
+}
+do_execsql_test joinE-3 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ - 2
+ - -
+}
+do_execsql_test joinE-4 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON true WHERE b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+ - -
+}
+do_execsql_test joinE-5 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+ - -
+}
+do_execsql_test joinE-6 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON true
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 2
+ 1 -
+ - 2
+ - -
+}
+do_execsql_test joinE-7 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON true WHERE a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ - 2
+ - -
+}
+do_execsql_test joinE-8 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+ - 2
+ - -
+}
+do_execsql_test joinE-9 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON true WHERE b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+ - -
+}
+do_execsql_test joinE-10 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+ - -
+}
+do_execsql_test joinE-11 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON true
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 2
+ 1 -
+ - 2
+ - -
+}
+do_execsql_test joinE-12 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON true WHERE a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ - 2
+ - -
+}
+do_execsql_test joinE-13 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ - 2
+ - -
+}
+do_execsql_test joinE-14 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON true WHERE b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+ - -
+}
+do_execsql_test joinE-15 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+ - 2
+ - -
+}
+do_execsql_test joinE-16 {
+ SELECT a, b
+ FROM t1 FULL JOIN t2 ON true
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 2
+ 1 -
+ - 2
+ - -
+}
+do_execsql_test joinE-17 {
+ SELECT a, b
+ FROM t1 FULL JOIN t2 ON true WHERE a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ - 2
+ - -
+}
+
+# PG-14 is unable to perform this join. It says: FULL JOIN is only
+# supported with merge-joinable or hash-joinable join conditions
+#
+# do_execsql_test joinE-18 {
+# SELECT a, b
+# FROM t1 FULL JOIN t2 ON a IS NULL
+# ORDER BY coalesce(a,b,3);
+# } {
+# }
+
+do_execsql_test joinE-19 {
+ SELECT a, b
+ FROM t1 FULL JOIN t2 ON true WHERE b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+ - -
+}
+
+# PG-14 is unable to perform this join. It says: FULL JOIN is only
+# supported with merge-joinable or hash-joinable join conditions
+#
+# do_execsql_test joinE-20 {
+# SELECT a, b
+# FROM t1 FULL JOIN t2 ON b IS NULL
+# ORDER BY coalesce(a,b,3);
+# } {
+# }
+
+db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1);
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(NULL);
+}
+
+do_execsql_test joinE-21 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON true
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-22 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON true WHERE a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+}
+do_execsql_test joinE-23 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+}
+do_execsql_test joinE-24 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON true WHERE b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-25 {
+ SELECT a, b
+ FROM t1 INNER JOIN t2 ON b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-26 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON true
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-27 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON true WHERE a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+}
+do_execsql_test joinE-28 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-29 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON true WHERE b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-30 {
+ SELECT a, b
+ FROM t1 LEFT JOIN t2 ON b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-31 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON true
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+
+do_execsql_test joinE-32 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON true WHERE a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+}
+
+do_execsql_test joinE-33 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ - -
+}
+do_execsql_test joinE-34 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON true WHERE b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-35 {
+ SELECT a, b
+ FROM t1 RIGHT JOIN t2 ON b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-36 {
+ SELECT a, b
+ FROM t1 FULL JOIN t2 ON true
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+do_execsql_test joinE-37 {
+ SELECT a, b
+ FROM t1 FULL JOIN t2 ON true WHERE a IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+}
+
+# PG-14 is unable
+#
+# do_execsql_test joinE-38 {
+# SELECT a, b
+# FROM t1 FULL JOIN t2 ON a IS NULL
+# ORDER BY coalesce(a,b,3);
+# } {
+# }
+
+do_execsql_test joinE-39 {
+ SELECT a, b
+ FROM t1 FULL JOIN t2 ON true WHERE b IS NULL
+ ORDER BY coalesce(a,b,3);
+} {
+ 1 -
+}
+
+# PG-14 is unable
+# do_execsql_test joinE-40 {
+# SELECT a, b
+# FROM t1 FULL JOIN t2 ON b IS NULL
+# ORDER BY coalesce(a,b,3);
+# } {
+# }
+
+finish_test
+
+##############################################################################
+# This is the PG-14 test script generator
+#
+# puts "
+# \\pset border off
+# \\pset tuples_only on
+# \\pset null -
+#
+# DROP TABLE IF EXISTS t1;
+# DROP TABLE IF EXISTS t2;
+# CREATE TABLE t1(a INT);
+# INSERT INTO t1 VALUES(1),(NULL);
+# CREATE TABLE t2(b INT);
+# INSERT INTO t2 VALUES(2),(NULL);
+# "
+#
+# proc echo {prefix txt} {
+# regsub -all {\n} $txt \n$prefix txt
+# puts "$prefix$txt"
+# }
+#
+# set n 0
+# set k 0
+# foreach j1 {INNER LEFT RIGHT FULL} {
+# foreach on1 {
+# true
+# {true WHERE a IS NULL}
+# {a IS NULL}
+# {true WHERE b IS NULL}
+# {b IS NULL}
+# } {
+#
+# incr n
+# incr k
+# set q1 ""
+# append q1 "SELECT a, b\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON $on1\n"
+# append q1 " ORDER BY coalesce(a,b,3);"
+#
+# echo "\\qecho " "do_execsql_test joinE-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# }
+# }
+#
+# puts "
+# DELETE FROM t1;
+# INSERT INTO t1 VALUES(1);
+# DELETE FROM t2;
+# INSERT INTO t2 VALUES(NULL);
+# "
+#
+# foreach j1 {INNER LEFT RIGHT FULL} {
+# foreach on1 {
+# true
+# {true WHERE a IS NULL}
+# {a IS NULL}
+# {true WHERE b IS NULL}
+# {b IS NULL}
+# } {
+#
+# incr n
+# incr k
+# set q1 ""
+# append q1 "SELECT a, b\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON $on1\n"
+# append q1 " ORDER BY coalesce(a,b,3);"
+#
+# echo "\\qecho " "do_execsql_test joinE-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# }
+# }
diff --git a/test/joinF.test b/test/joinF.test
new file mode 100644
index 0000000..0848e37
--- /dev/null
+++ b/test/joinF.test
@@ -0,0 +1,613 @@
+# 2022-05-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 tests for JOINs
+#
+# The test case output is (mostly) all generated by PostgreSQL 14. This
+# test module was created as follows:
+#
+# 1. Run a TCL script (included at the bottom of this file) that
+# generates an input script for "psql" that will run man
+# diverse tests on joins.
+#
+# 2. Run the script from step (1) through psql and collect the
+# output.
+#
+# 3. Make a few minor global search-and-replace operations to convert
+# the psql output into a form suitable for this test module.
+#
+# 4. Add this header, and the script content at the footer.
+#
+# A few extra tests that were not generated from postgresql output are
+# added at the end.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db nullvalue -
+db eval {
+ CREATE TABLE t1(x INT);
+ CREATE TABLE t2(y INT);
+ CREATE TABLE t3(z INT);
+ CREATE TABLE t4(w INT);
+ INSERT INTO t1 VALUES(10);
+ INSERT INTO t3 VALUES(20),(30);
+ INSERT INTO t4 VALUES(50);
+}
+do_execsql_test joinF-1 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-2 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-3 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-4 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-5 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - - 50
+}
+do_execsql_test joinF-6 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-7 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-8 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-9 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-10 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-11 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - - 50
+}
+do_execsql_test joinF-12 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-13 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-14 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-15 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-16 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-17 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-18 {
+ SELECT *
+ FROM t1 INNER JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-19 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-20 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-21 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-22 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-23 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - - 50
+}
+do_execsql_test joinF-24 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-25 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ 10 - - 50
+}
+do_execsql_test joinF-26 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-27 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ 10 - - 50
+}
+do_execsql_test joinF-28 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-29 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ 10 - - 50
+}
+do_execsql_test joinF-30 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-31 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-32 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-33 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-34 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-35 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-36 {
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-37 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-38 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-39 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-40 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-41 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - - 50
+}
+do_execsql_test joinF-42 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ INNER JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-43 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-44 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-45 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-46 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-47 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - - 50
+}
+do_execsql_test joinF-48 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ LEFT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-49 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-50 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ INNER JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-51 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-52 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ LEFT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-53 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+do_execsql_test joinF-54 {
+ SELECT *
+ FROM t1 RIGHT JOIN t2 ON true
+ RIGHT JOIN t3 ON t2.y IS NOT NULL
+ RIGHT JOIN t4 ON true
+ WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+ ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+ - - 20 50
+ - - 30 50
+}
+finish_test
+
+############################################################################
+# This is the TCL script used to generate the psql script that generated
+# the data above.
+#
+# puts "
+# \\pset border off
+# \\pset tuples_only on
+# \\pset null -
+#
+# DROP TABLE IF EXISTS t1;
+# DROP TABLE IF EXISTS t2;
+# DROP TABLE IF EXISTS t3;
+# DROP TABLE IF EXISTS t4;
+# CREATE TABLE t1(x INT);
+# CREATE TABLE t2(y INT);
+# CREATE TABLE t3(z INT);
+# CREATE TABLE t4(w INT);
+# INSERT INTO t1 VALUES(10);
+# INSERT INTO t3 VALUES(20),(30);
+# INSERT INTO t4 VALUES(50);
+# "
+#
+# proc echo {prefix txt} {
+# regsub -all {\n} $txt \n$prefix txt
+# puts "$prefix$txt"
+# }
+#
+# set n 0
+# foreach j1 {INNER LEFT RIGHT} {
+# foreach j2 {INNER LEFT RIGHT} {
+# foreach j3 {INNER LEFT RIGHT} {
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT *\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON true\n"
+# append q1 " $j2 JOIN t3 ON t2.y IS NOT NULL\n"
+# append q1 " $j3 JOIN t4 ON true\n"
+# append q1 " ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);"
+#
+# echo "\\qecho " "do_execsql_test joinF-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# incr n
+# set q1 ""
+# append q1 "SELECT *\n"
+# append q1 " FROM t1 $j1 JOIN t2 ON true\n"
+# append q1 " $j2 JOIN t3 ON t2.y IS NOT NULL\n"
+# append q1 " $j3 JOIN t4 ON true\n"
+# append q1 " WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)\n"
+# append q1 " ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);"
+#
+# echo "\\qecho " "do_execsql_test joinF-$n \{"
+# echo "\\qecho X " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+#
+# }
+# }
+# }
+#
diff --git a/test/joinH.test b/test/joinH.test
new file mode 100644
index 0000000..1d5f66a
--- /dev/null
+++ b/test/joinH.test
@@ -0,0 +1,93 @@
+# 2022 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix joinH
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INT);
+ CREATE TABLE t2(b INT);
+ INSERT INTO t2(b) VALUES(NULL);
+}
+
+db nullvalue NULL
+
+do_execsql_test 1.1 {
+ SELECT DISTINCT a FROM t1 FULL JOIN t2 ON true WHERE (b ISNULL);
+} {NULL}
+do_execsql_test 1.2 {
+ SELECT a FROM t1 FULL JOIN t2 ON true;
+} {NULL}
+do_execsql_test 1.3 {
+ SELECT a FROM t1 FULL JOIN t2 ON true WHERE (b ISNULL);
+} {NULL}
+do_execsql_test 1.4 {
+ SELECT DISTINCT a FROM t1 FULL JOIN t2 ON true;
+} {NULL}
+
+#-----------------------------------------------------------
+
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE r3(x);
+ CREATE TABLE r4(y INTEGER PRIMARY KEY);
+ INSERT INTO r4 VALUES(55);
+}
+
+do_execsql_test 2.1 {
+ SELECT 'value!' FROM r3 FULL JOIN r4 ON (y=x);
+} {value!}
+
+do_execsql_test 2.2 {
+ SELECT 'value!' FROM r3 FULL JOIN r4 ON (y=x) WHERE +y=55;
+} {value!}
+
+#-----------------------------------------------------------
+reset_db
+do_execsql_test 3.1 {
+ CREATE TABLE t0 (c0);
+ CREATE TABLE t1 (c0);
+ CREATE TABLE t2 (c0 , c1 , c2 , UNIQUE (c0), UNIQUE (c2 DESC));
+ INSERT INTO t2 VALUES ('x', 'y', 'z');
+ ANALYZE;
+ CREATE VIEW v0(c0) AS SELECT FALSE;
+}
+
+do_catchsql_test 3.2 {
+ SELECT * FROM t0 LEFT OUTER JOIN t1 ON v0.c0 INNER JOIN v0 INNER JOIN t2 ON (t2.c2 NOT NULL);
+} {1 {ON clause references tables to its right}}
+
+#-------------------------------------------------------------
+
+reset_db
+do_execsql_test 4.1 {
+ CREATE TABLE t1(a,b,c,d,e,f,g,h,PRIMARY KEY(a,b,c)) WITHOUT ROWID;
+ CREATE TABLE t2(i, j);
+ INSERT INTO t2 VALUES(10, 20);
+}
+
+do_execsql_test 4.2 {
+ SELECT (d IS NULL) FROM t1 RIGHT JOIN t2 ON (j=33);
+} {1}
+
+do_execsql_test 4.3 {
+ CREATE INDEX i1 ON t1( (d IS NULL), d );
+}
+
+do_execsql_test 4.4 {
+ SELECT (d IS NULL) FROM t1 RIGHT JOIN t2 ON (j=33);
+} {1}
+
+
+finish_test
diff --git a/test/journal1.test b/test/journal1.test
new file mode 100644
index 0000000..bcbafe3
--- /dev/null
+++ b/test/journal1.test
@@ -0,0 +1,72 @@
+# 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.
+#
+# Or with atomic_batch_write systems, as journal files are
+# not created.
+#
+if {$tcl_platform(platform)=="windows"
+ || [atomic_batch_write test.db]
+} {
+ 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 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..7cbe0ef
--- /dev/null
+++ b/test/journal2.test
@@ -0,0 +1,233 @@
+# 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 powersafe_overwrite}
+
+# 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.
+#
+if {[wal_is_capable]} {
+ 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..c3e3d12
--- /dev/null
+++ b/test/journal3.test
@@ -0,0 +1,69 @@
+# 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"
+ && [atomic_batch_write test.db]==0
+} {
+
+ # Changed on 2012-02-13: umask is deliberately ignored for -wal, -journal,
+ # and -shm files.
+ #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]]
+ set res "/[regsub {^00} $permissions {0.}]/"
+ if {$tcl_version>=8.7} {
+ regsub {^00} $permissions {0o} permissions
+ }
+ set effective $permissions
+ do_test journal3-1.2.$tn.1 {
+ catch { forcedelete test.db-journal }
+ file attributes test.db -permissions $permissions
+ file attributes test.db -permissions
+ } $res
+ 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
+ } $res
+ 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..99823a8
--- /dev/null
+++ b/test/jrnlmode.test
@@ -0,0 +1,585 @@
+# 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.4a {
+ # When defensive is on, unable to set journal_mode to OFF
+ sqlite3_db_config db DEFENSIVE 1
+ execsql {
+ PRAGMA journal_mode = off;
+ }
+} {persist}
+do_test jrnlmode-1.4b {
+ # When defensive is on, unable to set journal_mode to OFF
+ sqlite3_db_config db DEFENSIVE 0
+ 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 {
+if {[atomic_batch_write test.db]==0} {
+ 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 {
+if {[atomic_batch_write test.db]==0} {
+ # 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}
+
+# Assertion fault on 2015-05-01
+do_test jrnlmode-9.1 {
+ forcedelete test2.db
+ sqlite3 db2 test2.db
+ db2 eval {CREATE TEMP TABLE t(l); PRAGMA journal_mode=off;}
+ db2 close
+} {}
+do_execsql_test jrnlmode-9.2 {
+ PRAGMA locking_mode = exclusive;
+ CREATE TABLE tx(a);
+ PRAGMA journal_mode = off;
+} {exclusive off}
+
+
+finish_test
diff --git a/test/jrnlmode2.test b/test/jrnlmode2.test
new file mode 100644
index 0000000..6cc54dc
--- /dev/null
+++ b/test/jrnlmode2.test
@@ -0,0 +1,128 @@
+# 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
+}
+
+if {[atomic_batch_write test.db]} {
+ 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/json101.test b/test/json101.test
new file mode 100644
index 0000000..135c988
--- /dev/null
+++ b/test/json101.test
@@ -0,0 +1,888 @@
+# 2015-08-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 tests for JSON SQL functions extension to the
+# SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test json101-1.1.00 {
+ SELECT json_array(1,2.5,null,'hello');
+} {[1,2.5,null,"hello"]}
+do_execsql_test json101-1.1.01 {
+ SELECT json_array(1,'{"abc":2.5,"def":null,"ghi":hello}',99);
+ -- the second term goes in as a string:
+} {[1,"{\\"abc\\":2.5,\\"def\\":null,\\"ghi\\":hello}",99]}
+do_execsql_test json101-1.1.02 {
+ SELECT json_array(1,json('{"abc":2.5,"def":null,"ghi":"hello"}'),99);
+ -- the second term goes in as JSON
+} {[1,{"abc":2.5,"def":null,"ghi":"hello"},99]}
+do_execsql_test json101-1.1.03 {
+ SELECT json_array(1,json_object('abc',2.5,'def',null,'ghi','hello'),99);
+ -- the second term goes in as JSON
+} {[1,{"abc":2.5,"def":null,"ghi":"hello"},99]}
+do_execsql_test json101-1.2 {
+ SELECT hex(json_array('String "\ Test'));
+} {5B22537472696E67205C225C5C2054657374225D}
+do_catchsql_test json101-1.3 {
+ SELECT json_array(1,printf('%.1000c','x'),x'abcd',3);
+} {1 {JSON cannot hold BLOB values}}
+do_execsql_test json101-1.4 {
+ SELECT json_array(-9223372036854775808,9223372036854775807,0,1,-1,
+ 0.0, 1.0, -1.0, -1e99, +2e100,
+ 'one','two','three',
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+ 19, NULL, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 99);
+} {[-9223372036854775808,9223372036854775807,0,1,-1,0.0,1.0,-1.0,-1.0e+99,2.0e+100,"one","two","three",4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,null,21,22,23,24,25,26,27,28,29,30,31,"abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ",99]}
+
+do_execsql_test json101-2.1 {
+ SELECT json_object('a',1,'b',2.5,'c',null,'d','String Test');
+} {{{"a":1,"b":2.5,"c":null,"d":"String Test"}}}
+do_catchsql_test json101-2.2 {
+ SELECT json_object('a',printf('%.1000c','x'),2,2.5);
+} {1 {json_object() labels must be TEXT}}
+do_catchsql_test json101-2.3 {
+ SELECT json_object('a',1,'b');
+} {1 {json_object() requires an even number of arguments}}
+do_catchsql_test json101-2.4 {
+ SELECT json_object('a',printf('%.1000c','x'),'b',x'abcd');
+} {1 {JSON cannot hold BLOB values}}
+
+do_execsql_test json101-3.1 {
+ SELECT json_replace('{"a":1,"b":2}','$.a','[3,4,5]');
+} {{{"a":"[3,4,5]","b":2}}}
+do_execsql_test json101-3.2 {
+ SELECT json_replace('{"a":1,"b":2}','$.a',json('[3,4,5]'));
+} {{{"a":[3,4,5],"b":2}}}
+do_execsql_test json101-3.3 {
+ SELECT json_type(json_set('{"a":1,"b":2}','$.b','{"x":3,"y":4}'),'$.b');
+} {text}
+do_execsql_test json101-3.4 {
+ SELECT json_type(json_set('{"a":1,"b":2}','$.b',json('{"x":3,"y":4}')),'$.b');
+} {object}
+ifcapable vtab {
+do_execsql_test json101-3.5 {
+ SELECT fullkey, atom, '|' FROM json_tree(json_set('{}','$.x',123,'$.x',456));
+} {{$} {} | {$.x} 456 |}
+}
+
+# Per rfc7159, any JSON value is allowed at the top level, and whitespace
+# is permitting before and/or after that value.
+#
+do_execsql_test json101-4.1 {
+ CREATE TABLE j1(x);
+ INSERT INTO j1(x)
+ VALUES('true'),('false'),('null'),('123'),('-234'),('34.5e+6'),
+ ('""'),('"\""'),('"\\"'),('"abcdefghijlmnopqrstuvwxyz"'),
+ ('[]'),('{}'),('[true,false,null,123,-234,34.5e+6,{},[]]'),
+ ('{"a":true,"b":{"c":false}}');
+ SELECT * FROM j1 WHERE NOT json_valid(x);
+} {}
+do_execsql_test json101-4.2 {
+ SELECT * FROM j1 WHERE NOT json_valid(char(0x20,0x09,0x0a,0x0d)||x);
+} {}
+do_execsql_test json101-4.3 {
+ SELECT * FROM j1 WHERE NOT json_valid(x||char(0x20,0x09,0x0a,0x0d));
+} {}
+
+# But an empty string, or a string of pure whitespace is not valid JSON.
+#
+do_execsql_test json101-4.4 {
+ SELECT json_valid(''), json_valid(char(0x20,0x09,0x0a,0x0d));
+} {0 0}
+
+# json_remove() and similar functions with no edit operations return their
+# input unchanged.
+#
+do_execsql_test json101-4.5 {
+ SELECT x FROM j1 WHERE json_remove(x)<>x;
+} {}
+do_execsql_test json101-4.6 {
+ SELECT x FROM j1 WHERE json_replace(x)<>x;
+} {}
+do_execsql_test json101-4.7 {
+ SELECT x FROM j1 WHERE json_set(x)<>x;
+} {}
+do_execsql_test json101-4.8 {
+ SELECT x FROM j1 WHERE json_insert(x)<>x;
+} {}
+
+# json_extract(JSON,'$') will return objects and arrays without change.
+#
+do_execsql_test json-4.10 {
+ SELECT count(*) FROM j1 WHERE json_type(x) IN ('object','array');
+ SELECT x FROM j1
+ WHERE json_extract(x,'$')<>x
+ AND json_type(x) IN ('object','array');
+} {4}
+
+do_execsql_test json-5.1 {
+ CREATE TABLE j2(id INTEGER PRIMARY KEY, json, src);
+ INSERT INTO j2(id,json,src)
+ VALUES(1,'{
+ "firstName": "John",
+ "lastName": "Smith",
+ "isAlive": true,
+ "age": 25,
+ "address": {
+ "streetAddress": "21 2nd Street",
+ "city": "New York",
+ "state": "NY",
+ "postalCode": "10021-3100"
+ },
+ "phoneNumbers": [
+ {
+ "type": "home",
+ "number": "212 555-1234"
+ },
+ {
+ "type": "office",
+ "number": "646 555-4567"
+ }
+ ],
+ "children": [],
+ "spouse": null
+ }','https://en.wikipedia.org/wiki/JSON');
+ INSERT INTO j2(id,json,src)
+ VALUES(2, '{
+ "id": "0001",
+ "type": "donut",
+ "name": "Cake",
+ "ppu": 0.55,
+ "batters":
+ {
+ "batter":
+ [
+ { "id": "1001", "type": "Regular" },
+ { "id": "1002", "type": "Chocolate" },
+ { "id": "1003", "type": "Blueberry" },
+ { "id": "1004", "type": "Devil''s Food" }
+ ]
+ },
+ "topping":
+ [
+ { "id": "5001", "type": "None" },
+ { "id": "5002", "type": "Glazed" },
+ { "id": "5005", "type": "Sugar" },
+ { "id": "5007", "type": "Powdered Sugar" },
+ { "id": "5006", "type": "Chocolate with Sprinkles" },
+ { "id": "5003", "type": "Chocolate" },
+ { "id": "5004", "type": "Maple" }
+ ]
+ }','https://adobe.github.io/Spry/samples/data_region/JSONDataSetSample.html');
+ INSERT INTO j2(id,json,src)
+ VALUES(3,'[
+ {
+ "id": "0001",
+ "type": "donut",
+ "name": "Cake",
+ "ppu": 0.55,
+ "batters":
+ {
+ "batter":
+ [
+ { "id": "1001", "type": "Regular" },
+ { "id": "1002", "type": "Chocolate" },
+ { "id": "1003", "type": "Blueberry" },
+ { "id": "1004", "type": "Devil''s Food" }
+ ]
+ },
+ "topping":
+ [
+ { "id": "5001", "type": "None" },
+ { "id": "5002", "type": "Glazed" },
+ { "id": "5005", "type": "Sugar" },
+ { "id": "5007", "type": "Powdered Sugar" },
+ { "id": "5006", "type": "Chocolate with Sprinkles" },
+ { "id": "5003", "type": "Chocolate" },
+ { "id": "5004", "type": "Maple" }
+ ]
+ },
+ {
+ "id": "0002",
+ "type": "donut",
+ "name": "Raised",
+ "ppu": 0.55,
+ "batters":
+ {
+ "batter":
+ [
+ { "id": "1001", "type": "Regular" }
+ ]
+ },
+ "topping":
+ [
+ { "id": "5001", "type": "None" },
+ { "id": "5002", "type": "Glazed" },
+ { "id": "5005", "type": "Sugar" },
+ { "id": "5003", "type": "Chocolate" },
+ { "id": "5004", "type": "Maple" }
+ ]
+ },
+ {
+ "id": "0003",
+ "type": "donut",
+ "name": "Old Fashioned",
+ "ppu": 0.55,
+ "batters":
+ {
+ "batter":
+ [
+ { "id": "1001", "type": "Regular" },
+ { "id": "1002", "type": "Chocolate" }
+ ]
+ },
+ "topping":
+ [
+ { "id": "5001", "type": "None" },
+ { "id": "5002", "type": "Glazed" },
+ { "id": "5003", "type": "Chocolate" },
+ { "id": "5004", "type": "Maple" }
+ ]
+ }
+ ]','https://adobe.github.io/Spry/samples/data_region/JSONDataSetSample.html');
+ SELECT count(*) FROM j2;
+} {3}
+
+do_execsql_test json-5.2 {
+ SELECT id, json_valid(json), json_type(json), '|' FROM j2 ORDER BY id;
+} {1 1 object | 2 1 object | 3 1 array |}
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+# fullkey is always the same as path+key (with appropriate formatting)
+#
+do_execsql_test json-5.3 {
+ SELECT j2.rowid, jx.rowid, fullkey, path, key
+ FROM j2, json_tree(j2.json) AS jx
+ WHERE fullkey!=(path || CASE WHEN typeof(key)=='integer' THEN '['||key||']'
+ ELSE '.'||key END);
+} {}
+do_execsql_test json-5.4 {
+ SELECT j2.rowid, jx.rowid, fullkey, path, key
+ FROM j2, json_each(j2.json) AS jx
+ WHERE fullkey!=(path || CASE WHEN typeof(key)=='integer' THEN '['||key||']'
+ ELSE '.'||key END);
+} {}
+
+
+# Verify that the json_each.json and json_tree.json output is always the
+# same as input.
+#
+do_execsql_test json-5.5 {
+ SELECT j2.rowid, jx.rowid, fullkey, path, key
+ FROM j2, json_each(j2.json) AS jx
+ WHERE jx.json<>j2.json;
+} {}
+do_execsql_test json-5.6 {
+ SELECT j2.rowid, jx.rowid, fullkey, path, key
+ FROM j2, json_tree(j2.json) AS jx
+ WHERE jx.json<>j2.json;
+} {}
+do_execsql_test json-5.7 {
+ SELECT j2.rowid, jx.rowid, fullkey, path, key
+ FROM j2, json_each(j2.json) AS jx
+ WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
+} {}
+do_execsql_test json-5.8 {
+ SELECT j2.rowid, jx.rowid, fullkey, path, key
+ FROM j2, json_tree(j2.json) AS jx
+ WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
+} {}
+
+do_execsql_test json-6.1 {
+ SELECT json_valid('{"a":55,"b":72,}');
+} {0}
+do_execsql_test json-6.2 {
+ SELECT json_valid('{"a":55,"b":72}');
+} {1}
+do_execsql_test json-6.3 {
+ SELECT json_valid('["a",55,"b",72,]');
+} {0}
+do_execsql_test json-6.4 {
+ SELECT json_valid('["a",55,"b",72]');
+} {1}
+
+# White-space tests. Note that form-feed is not white-space in JSON.
+# ticket [57eec374ae1d0a1d4a23077a95f4e173fe269113]
+#
+foreach {tn isvalid ws} {
+ 7.1 1 char(0x20)
+ 7.2 1 char(0x09)
+ 7.3 1 char(0x0A)
+ 7.4 1 char(0x0D)
+ 7.5 0 char(0x0C)
+ 7.6 1 char(0x20,0x09,0x0a,0x0d,0x20)
+ 7.7 0 char(0x20,0x09,0x0a,0x0c,0x0d,0x20)
+} {
+ do_execsql_test json-$tn.1 \
+ "SELECT json_valid(printf('%s{%s\"x\"%s:%s9%s}%s',
+ $::ws,$::ws,$::ws,$::ws,$::ws,$::ws));" \
+ $isvalid
+}
+
+# Ticket https://www.sqlite.org/src/info/ad2559db380abf8e
+# Control characters must be escaped in JSON strings.
+#
+do_execsql_test json-8.1 {
+ DROP TABLE IF EXISTS t8;
+ CREATE TABLE t8(a,b);
+ INSERT INTO t8(a) VALUES('abc' || char(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) || 'xyz');
+ UPDATE t8 SET b=json_array(a);
+ SELECT b FROM t8;
+} {{["abc\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#xyz"]}}
+do_execsql_test json-8.2 {
+ SELECT a=json_extract(b,'$[0]') FROM t8;
+} {1}
+
+# 2017-04-12. Regression reported on the mailing list by Rolf Ade
+#
+do_execsql_test json-8.3 {
+ SELECT json_valid(char(0x22,0xe4,0x22));
+} {1}
+do_execsql_test json-8.4 {
+ SELECT unicode(json_extract(char(0x22,228,0x22),'$'));
+} {228}
+
+# The json_quote() function transforms an SQL value into a JSON value.
+# String values are quoted and interior quotes are escaped. NULL values
+# are rendered as the unquoted string "null".
+#
+do_execsql_test json-9.1 {
+ SELECT json_quote('abc"xyz');
+} {{"abc\"xyz"}}
+do_execsql_test json-9.2 {
+ SELECT json_quote(3.14159);
+} {3.14159}
+do_execsql_test json-9.3 {
+ SELECT json_quote(12345);
+} {12345}
+do_execsql_test json-9.4 {
+ SELECT json_quote(null);
+} {"null"}
+do_catchsql_test json-9.5 {
+ SELECT json_quote(x'30313233');
+} {1 {JSON cannot hold BLOB values}}
+do_catchsql_test json-9.6 {
+ SELECT json_quote(123,456)
+} {1 {wrong number of arguments to function json_quote()}}
+do_catchsql_test json-9.7 {
+ SELECT json_quote()
+} {1 {wrong number of arguments to function json_quote()}}
+
+# Make sure only valid backslash-escapes are accepted.
+#
+do_execsql_test json-10.1 {
+ SELECT json_valid('" \ "');
+} {0}
+do_execsql_test json-10.2 {
+ SELECT json_valid('" \! "');
+} {0}
+do_execsql_test json-10.3 {
+ SELECT json_valid('" \" "');
+} {1}
+do_execsql_test json-10.4 {
+ SELECT json_valid('" \# "');
+} {0}
+do_execsql_test json-10.5 {
+ SELECT json_valid('" \$ "');
+} {0}
+do_execsql_test json-10.6 {
+ SELECT json_valid('" \% "');
+} {0}
+do_execsql_test json-10.7 {
+ SELECT json_valid('" \& "');
+} {0}
+do_execsql_test json-10.8 {
+ SELECT json_valid('" \'' "');
+} {0}
+do_execsql_test json-10.9 {
+ SELECT json_valid('" \( "');
+} {0}
+do_execsql_test json-10.10 {
+ SELECT json_valid('" \) "');
+} {0}
+do_execsql_test json-10.11 {
+ SELECT json_valid('" \* "');
+} {0}
+do_execsql_test json-10.12 {
+ SELECT json_valid('" \+ "');
+} {0}
+do_execsql_test json-10.13 {
+ SELECT json_valid('" \, "');
+} {0}
+do_execsql_test json-10.14 {
+ SELECT json_valid('" \- "');
+} {0}
+do_execsql_test json-10.15 {
+ SELECT json_valid('" \. "');
+} {0}
+do_execsql_test json-10.16 {
+ SELECT json_valid('" \/ "');
+} {1}
+do_execsql_test json-10.17 {
+ SELECT json_valid('" \0 "');
+} {0}
+do_execsql_test json-10.18 {
+ SELECT json_valid('" \1 "');
+} {0}
+do_execsql_test json-10.19 {
+ SELECT json_valid('" \2 "');
+} {0}
+do_execsql_test json-10.20 {
+ SELECT json_valid('" \3 "');
+} {0}
+do_execsql_test json-10.21 {
+ SELECT json_valid('" \4 "');
+} {0}
+do_execsql_test json-10.22 {
+ SELECT json_valid('" \5 "');
+} {0}
+do_execsql_test json-10.23 {
+ SELECT json_valid('" \6 "');
+} {0}
+do_execsql_test json-10.24 {
+ SELECT json_valid('" \7 "');
+} {0}
+do_execsql_test json-10.25 {
+ SELECT json_valid('" \8 "');
+} {0}
+do_execsql_test json-10.26 {
+ SELECT json_valid('" \9 "');
+} {0}
+do_execsql_test json-10.27 {
+ SELECT json_valid('" \: "');
+} {0}
+do_execsql_test json-10.28 {
+ SELECT json_valid('" \; "');
+} {0}
+do_execsql_test json-10.29 {
+ SELECT json_valid('" \< "');
+} {0}
+do_execsql_test json-10.30 {
+ SELECT json_valid('" \= "');
+} {0}
+do_execsql_test json-10.31 {
+ SELECT json_valid('" \> "');
+} {0}
+do_execsql_test json-10.32 {
+ SELECT json_valid('" \? "');
+} {0}
+do_execsql_test json-10.33 {
+ SELECT json_valid('" \@ "');
+} {0}
+do_execsql_test json-10.34 {
+ SELECT json_valid('" \A "');
+} {0}
+do_execsql_test json-10.35 {
+ SELECT json_valid('" \B "');
+} {0}
+do_execsql_test json-10.36 {
+ SELECT json_valid('" \C "');
+} {0}
+do_execsql_test json-10.37 {
+ SELECT json_valid('" \D "');
+} {0}
+do_execsql_test json-10.38 {
+ SELECT json_valid('" \E "');
+} {0}
+do_execsql_test json-10.39 {
+ SELECT json_valid('" \F "');
+} {0}
+do_execsql_test json-10.40 {
+ SELECT json_valid('" \G "');
+} {0}
+do_execsql_test json-10.41 {
+ SELECT json_valid('" \H "');
+} {0}
+do_execsql_test json-10.42 {
+ SELECT json_valid('" \I "');
+} {0}
+do_execsql_test json-10.43 {
+ SELECT json_valid('" \J "');
+} {0}
+do_execsql_test json-10.44 {
+ SELECT json_valid('" \K "');
+} {0}
+do_execsql_test json-10.45 {
+ SELECT json_valid('" \L "');
+} {0}
+do_execsql_test json-10.46 {
+ SELECT json_valid('" \M "');
+} {0}
+do_execsql_test json-10.47 {
+ SELECT json_valid('" \N "');
+} {0}
+do_execsql_test json-10.48 {
+ SELECT json_valid('" \O "');
+} {0}
+do_execsql_test json-10.49 {
+ SELECT json_valid('" \P "');
+} {0}
+do_execsql_test json-10.50 {
+ SELECT json_valid('" \Q "');
+} {0}
+do_execsql_test json-10.51 {
+ SELECT json_valid('" \R "');
+} {0}
+do_execsql_test json-10.52 {
+ SELECT json_valid('" \S "');
+} {0}
+do_execsql_test json-10.53 {
+ SELECT json_valid('" \T "');
+} {0}
+do_execsql_test json-10.54 {
+ SELECT json_valid('" \U "');
+} {0}
+do_execsql_test json-10.55 {
+ SELECT json_valid('" \V "');
+} {0}
+do_execsql_test json-10.56 {
+ SELECT json_valid('" \W "');
+} {0}
+do_execsql_test json-10.57 {
+ SELECT json_valid('" \X "');
+} {0}
+do_execsql_test json-10.58 {
+ SELECT json_valid('" \Y "');
+} {0}
+do_execsql_test json-10.59 {
+ SELECT json_valid('" \Z "');
+} {0}
+do_execsql_test json-10.60 {
+ SELECT json_valid('" \[ "');
+} {0}
+do_execsql_test json-10.61 {
+ SELECT json_valid('" \\ "');
+} {1}
+do_execsql_test json-10.62 {
+ SELECT json_valid('" \] "');
+} {0}
+do_execsql_test json-10.63 {
+ SELECT json_valid('" \^ "');
+} {0}
+do_execsql_test json-10.64 {
+ SELECT json_valid('" \_ "');
+} {0}
+do_execsql_test json-10.65 {
+ SELECT json_valid('" \` "');
+} {0}
+do_execsql_test json-10.66 {
+ SELECT json_valid('" \a "');
+} {0}
+do_execsql_test json-10.67 {
+ SELECT json_valid('" \b "');
+} {1}
+do_execsql_test json-10.68 {
+ SELECT json_valid('" \c "');
+} {0}
+do_execsql_test json-10.69 {
+ SELECT json_valid('" \d "');
+} {0}
+do_execsql_test json-10.70 {
+ SELECT json_valid('" \e "');
+} {0}
+do_execsql_test json-10.71 {
+ SELECT json_valid('" \f "');
+} {1}
+do_execsql_test json-10.72 {
+ SELECT json_valid('" \g "');
+} {0}
+do_execsql_test json-10.73 {
+ SELECT json_valid('" \h "');
+} {0}
+do_execsql_test json-10.74 {
+ SELECT json_valid('" \i "');
+} {0}
+do_execsql_test json-10.75 {
+ SELECT json_valid('" \j "');
+} {0}
+do_execsql_test json-10.76 {
+ SELECT json_valid('" \k "');
+} {0}
+do_execsql_test json-10.77 {
+ SELECT json_valid('" \l "');
+} {0}
+do_execsql_test json-10.78 {
+ SELECT json_valid('" \m "');
+} {0}
+do_execsql_test json-10.79 {
+ SELECT json_valid('" \n "');
+} {1}
+do_execsql_test json-10.80 {
+ SELECT json_valid('" \o "');
+} {0}
+do_execsql_test json-10.81 {
+ SELECT json_valid('" \p "');
+} {0}
+do_execsql_test json-10.82 {
+ SELECT json_valid('" \q "');
+} {0}
+do_execsql_test json-10.83 {
+ SELECT json_valid('" \r "');
+} {1}
+do_execsql_test json-10.84 {
+ SELECT json_valid('" \s "');
+} {0}
+do_execsql_test json-10.85 {
+ SELECT json_valid('" \t "');
+} {1}
+do_execsql_test json-10.86.0 {
+ SELECT json_valid('" \u "');
+} {0}
+do_execsql_test json-10.86.1 {
+ SELECT json_valid('" \ua "');
+} {0}
+do_execsql_test json-10.86.2 {
+ SELECT json_valid('" \uab "');
+} {0}
+do_execsql_test json-10.86.3 {
+ SELECT json_valid('" \uabc "');
+} {0}
+do_execsql_test json-10.86.4 {
+ SELECT json_valid('" \uabcd "');
+} {1}
+do_execsql_test json-10.86.5 {
+ SELECT json_valid('" \uFEDC "');
+} {1}
+do_execsql_test json-10.86.6 {
+ SELECT json_valid('" \u1234 "');
+} {1}
+do_execsql_test json-10.87 {
+ SELECT json_valid('" \v "');
+} {0}
+do_execsql_test json-10.88 {
+ SELECT json_valid('" \w "');
+} {0}
+do_execsql_test json-10.89 {
+ SELECT json_valid('" \x "');
+} {0}
+do_execsql_test json-10.90 {
+ SELECT json_valid('" \y "');
+} {0}
+do_execsql_test json-10.91 {
+ SELECT json_valid('" \z "');
+} {0}
+do_execsql_test json-10.92 {
+ SELECT json_valid('" \{ "');
+} {0}
+do_execsql_test json-10.93 {
+ SELECT json_valid('" \| "');
+} {0}
+do_execsql_test json-10.94 {
+ SELECT json_valid('" \} "');
+} {0}
+do_execsql_test json-10.95 {
+ SELECT json_valid('" \~ "');
+} {0}
+
+#--------------------------------------------------------------------------
+# 2017-04-11. https://www.sqlite.org/src/info/981329adeef51011
+# Stack overflow on deeply nested JSON.
+#
+# The following tests confirm that deeply nested JSON is considered invalid.
+#
+do_execsql_test json-11.0 {
+ /* Shallow enough to be parsed */
+ SELECT json_valid(printf('%.2000c0%.2000c','[',']'));
+} {1}
+do_execsql_test json-11.1 {
+ /* Too deep by one */
+ SELECT json_valid(printf('%.2001c0%.2001c','[',']'));
+} {0}
+do_execsql_test json-11.2 {
+ /* Shallow enough to be parsed { */
+ SELECT json_valid(replace(printf('%.2000c0%.2000c','[','}'),'[','{"a":'));
+ /* } */
+} {1}
+do_execsql_test json-11.3 {
+ /* Too deep by one { */
+ SELECT json_valid(replace(printf('%.2001c0%.2001c','[','}'),'[','{"a":'));
+ /* } */
+} {0}
+
+# 2017-10-27. Demonstrate the ability to access an element from
+# a json structure even though the element name constains a "."
+# character, by quoting the element name in the path.
+#
+do_execsql_test json-12.100 {
+ CREATE TABLE t12(x);
+ INSERT INTO t12(x) VALUES(
+ '{"settings":
+ {"layer2":
+ {"hapax.legomenon":
+ {"forceDisplay":true,
+ "transliterate":true,
+ "add.footnote":true,
+ "summary.report":true},
+ "dis.legomenon":
+ {"forceDisplay":true,
+ "transliterate":false,
+ "add.footnote":false,
+ "summary.report":true},
+ "tris.legomenon":
+ {"forceDisplay":true,
+ "transliterate":false,
+ "add.footnote":false,
+ "summary.report":false}
+ }
+ }
+ }');
+} {}
+do_execsql_test json-12.110 {
+ SELECT json_remove(x, '$.settings.layer2."dis.legomenon".forceDisplay')
+ FROM t12;
+} {{{"settings":{"layer2":{"hapax.legomenon":{"forceDisplay":true,"transliterate":true,"add.footnote":true,"summary.report":true},"dis.legomenon":{"transliterate":false,"add.footnote":false,"summary.report":true},"tris.legomenon":{"forceDisplay":true,"transliterate":false,"add.footnote":false,"summary.report":false}}}}}}
+do_execsql_test json-12.120 {
+ SELECT json_extract(x, '$.settings.layer2."tris.legomenon"."summary.report"')
+ FROM t12;
+} {0}
+
+# 2018-01-26
+# ticket https://www.sqlite.org/src/tktview/80177f0c226ff54f6ddd41
+# Make sure the query planner knows about the arguments to table-valued functions.
+#
+do_execsql_test json-13.100 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(id, json);
+ INSERT INTO t1(id,json) VALUES(1,'{"items":[3,5]}');
+ CREATE TABLE t2(id, json);
+ INSERT INTO t2(id,json) VALUES(2,'{"value":2}');
+ INSERT INTO t2(id,json) VALUES(3,'{"value":3}');
+ INSERT INTO t2(id,json) VALUES(4,'{"value":4}');
+ INSERT INTO t2(id,json) VALUES(5,'{"value":5}');
+ INSERT INTO t2(id,json) VALUES(6,'{"value":6}');
+ SELECT * FROM t1 CROSS JOIN t2
+ WHERE EXISTS(SELECT 1 FROM json_each(t1.json,'$.items') AS Z
+ WHERE Z.value==t2.id);
+} {1 {{"items":[3,5]}} 3 {{"value":3}} 1 {{"items":[3,5]}} 5 {{"value":5}}}
+do_execsql_test json-13.110 {
+ SELECT * FROM t2 CROSS JOIN t1
+ WHERE EXISTS(SELECT 1 FROM json_each(t1.json,'$.items') AS Z
+ WHERE Z.value==t2.id);
+} {3 {{"value":3}} 1 {{"items":[3,5]}} 5 {{"value":5}} 1 {{"items":[3,5]}}}
+
+# 2018-05-16
+# Incorrect fullkey output from json_each()
+# when the input JSON is not an array or object.
+#
+do_execsql_test json-14.100 {
+ SELECT fullkey FROM json_each('123');
+} {$}
+do_execsql_test json-14.110 {
+ SELECT fullkey FROM json_each('123.56');
+} {$}
+do_execsql_test json-14.120 {
+ SELECT fullkey FROM json_each('"hello"');
+} {$}
+do_execsql_test json-14.130 {
+ SELECT fullkey FROM json_each('null');
+} {$}
+do_execsql_test json-14.140 {
+ SELECT fullkey FROM json_tree('123');
+} {$}
+do_execsql_test json-14.150 {
+ SELECT fullkey FROM json_tree('123.56');
+} {$}
+do_execsql_test json-14.160 {
+ SELECT fullkey FROM json_tree('"hello"');
+} {$}
+do_execsql_test json-14.170 {
+ SELECT fullkey FROM json_tree('null');
+} {$}
+
+# 2018-12-03
+# Make sure the table-valued functions contained within parentheses
+# work correctly.
+#
+# Bug reported via private email. See TH3 for more information.
+#
+do_execsql_test json-15.100 {
+ SELECT * FROM JSON_EACH('{"a":1, "b":2}');
+} {a 1 integer 1 2 {} {$.a} {$} b 2 integer 2 4 {} {$.b} {$}}
+do_execsql_test json-15.110 {
+ SELECT xyz.* FROM JSON_EACH('{"a":1, "b":2}') AS xyz;
+} {a 1 integer 1 2 {} {$.a} {$} b 2 integer 2 4 {} {$.b} {$}}
+do_execsql_test json-15.120 {
+ SELECT * FROM (JSON_EACH('{"a":1, "b":2}'));
+} {a 1 integer 1 2 {} {$.a} {$} b 2 integer 2 4 {} {$.b} {$}}
+do_execsql_test json-15.130 {
+ SELECT xyz.* FROM (JSON_EACH('{"a":1, "b":2}')) AS xyz;
+} {a 1 integer 1 2 {} {$.a} {$} b 2 integer 2 4 {} {$.b} {$}}
+
+# 2019-11-10
+# Mailing list bug report on the handling of surrogate pairs
+# in JSON.
+#
+do_execsql_test json-16.10 {
+ SELECT length(json_extract('"abc\uD834\uDD1Exyz"','$'));
+} {7}
+do_execsql_test json-16.20 {
+ SELECT length(json_extract('"\uD834\uDD1E"','$'));
+} {1}
+do_execsql_test json-16.30 {
+ SELECT unicode(json_extract('"\uD834\uDD1E"','$'));
+} {119070}
+
+# 2022-01-30 dbsqlfuzz 4678cf825d27f87c9b8343720121e12cf944b71a
+do_execsql_test json-17.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE t2(d);
+ SELECT * FROM t1 LEFT JOIN t2 ON (SELECT b FROM json_each ORDER BY 1);
+} {}
+
+# 2022-04-04 forum post https://sqlite.org/forum/forumpost/c082aeab43
+do_execsql_test json-18.1 {
+ SELECT json_valid('{"":5}');
+} {1}
+do_execsql_test json-18.2 {
+ SELECT json_extract('{"":5}', '$.""');
+} {5}
+do_execsql_test json-18.3 {
+ SELECT json_extract('[3,{"a":4,"":[5,{"hi":6},7]},8]', '$[1].""[1].hi');
+} {6}
+do_execsql_test json-18.4 {
+ SELECT json_extract('[3,{"a":4,"":[5,{"hi":6},7]},8]', '$[1].""[1]."hi"');
+} {6}
+do_catchsql_test json-18.5 {
+ SELECT json_extract('{"":8}', '$.');
+} {1 {JSON path error near ''}}
+
+# 2022-08-29 https://sqlite.org/forum/forumpost/9b9e4716c0d7bbd1
+# This is not a problem specifically with JSON functions. It is
+# a problem with transaction control. But the json() function makes
+# the problem more easily accessible, so it is tested here.
+#
+do_execsql_test json-19.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+} {}
+do_catchsql_test json-19.2 {
+ BEGIN;
+ INSERT INTO t1 VALUES(0), (json('not-valid-json'));
+} {1 {malformed JSON}}
+do_execsql_test json-19.3 {
+ COMMIT;
+ SELECT * FROM t1;
+} {}
+
+finish_test
diff --git a/test/json102.test b/test/json102.test
new file mode 100644
index 0000000..f551c4b
--- /dev/null
+++ b/test/json102.test
@@ -0,0 +1,391 @@
+# 2015-08-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 tests for JSON SQL functions extension to the
+# SQLite library.
+#
+# This file contains tests automatically generated from the json1
+# documentation.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test json102-100 {
+ SELECT json_object('ex','[52,3.14159]');
+} {{{"ex":"[52,3.14159]"}}}
+do_execsql_test json102-110 {
+ SELECT json_object('ex',json('[52,3.14159]'));
+} {{{"ex":[52,3.14159]}}}
+do_execsql_test json102-120 {
+ SELECT json_object('ex',json_array(52,3.14159));
+} {{{"ex":[52,3.14159]}}}
+do_execsql_test json102-130 {
+ SELECT json(' { "this" : "is", "a": [ "test" ] } ');
+} {{{"this":"is","a":["test"]}}}
+do_execsql_test json102-140 {
+ SELECT json_array(1,2,'3',4);
+} {{[1,2,"3",4]}}
+do_execsql_test json102-150 {
+ SELECT json_array('[1,2]');
+} {{["[1,2]"]}}
+do_execsql_test json102-160 {
+ SELECT json_array(json_array(1,2));
+} {{[[1,2]]}}
+do_execsql_test json102-170 {
+ SELECT json_array(1,null,'3','[4,5]','{"six":7.7}');
+} {{[1,null,"3","[4,5]","{\"six\":7.7}"]}}
+do_execsql_test json102-180 {
+ SELECT json_array(1,null,'3',json('[4,5]'),json('{"six":7.7}'));
+} {{[1,null,"3",[4,5],{"six":7.7}]}}
+do_execsql_test json102-190 {
+ SELECT json_array_length('[1,2,3,4]');
+} {{4}}
+do_execsql_test json102-200 {
+ SELECT json_array_length('[1,2,3,4]', '$');
+} {{4}}
+do_execsql_test json102-210 {
+ SELECT json_array_length('[1,2,3,4]', '$[2]');
+} {{0}}
+do_execsql_test json102-220 {
+ SELECT json_array_length('{"one":[1,2,3]}');
+} {{0}}
+do_execsql_test json102-230 {
+ SELECT json_array_length('{"one":[1,2,3]}', '$.one');
+} {{3}}
+do_execsql_test json102-240 {
+ SELECT json_array_length('{"one":[1,2,3]}', '$.two');
+} {{}}
+do_execsql_test json102-250 {
+ SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$');
+} {{{"a":2,"c":[4,5,{"f":7}]}}}
+do_execsql_test json102-260 {
+ SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c');
+} {{[4,5,{"f":7}]}}
+do_execsql_test json102-270 {
+ SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2]');
+} {{{"f":7}}}
+do_execsql_test json102-280 {
+ SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2].f');
+} {{7}}
+do_execsql_test json102-290 {
+ SELECT json_extract('{"a":2,"c":[4,5],"f":7}','$.c','$.a');
+} {{[[4,5],2]}}
+do_execsql_test json102-300 {
+ SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.x');
+} {{}}
+do_execsql_test json102-310 {
+ SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.x', '$.a');
+} {{[null,2]}}
+do_execsql_test json102-320 {
+ SELECT json_insert('{"a":2,"c":4}', '$.a', 99);
+} {{{"a":2,"c":4}}}
+do_execsql_test json102-330 {
+ SELECT json_insert('{"a":2,"c":4}', '$.e', 99);
+} {{{"a":2,"c":4,"e":99}}}
+do_execsql_test json102-340 {
+ SELECT json_replace('{"a":2,"c":4}', '$.a', 99);
+} {{{"a":99,"c":4}}}
+do_execsql_test json102-350 {
+ SELECT json_replace('{"a":2,"c":4}', '$.e', 99);
+} {{{"a":2,"c":4}}}
+do_execsql_test json102-360 {
+ SELECT json_set('{"a":2,"c":4}', '$.a', 99);
+} {{{"a":99,"c":4}}}
+do_execsql_test json102-370 {
+ SELECT json_set('{"a":2,"c":4}', '$.e', 99);
+} {{{"a":2,"c":4,"e":99}}}
+do_execsql_test json102-380 {
+ SELECT json_set('{"a":2,"c":4}', '$.c', '[97,96]');
+} {{{"a":2,"c":"[97,96]"}}}
+do_execsql_test json102-390 {
+ SELECT json_set('{"a":2,"c":4}', '$.c', json('[97,96]'));
+} {{{"a":2,"c":[97,96]}}}
+do_execsql_test json102-400 {
+ SELECT json_set('{"a":2,"c":4}', '$.c', json_array(97,96));
+} {{{"a":2,"c":[97,96]}}}
+do_execsql_test json102-410 {
+ SELECT json_object('a',2,'c',4);
+} {{{"a":2,"c":4}}}
+do_execsql_test json102-420 {
+ SELECT json_object('a',2,'c','{e:5}');
+} {{{"a":2,"c":"{e:5}"}}}
+do_execsql_test json102-430 {
+ SELECT json_object('a',2,'c',json_object('e',5));
+} {{{"a":2,"c":{"e":5}}}}
+do_execsql_test json102-440 {
+ SELECT json_remove('[0,1,2,3,4]','$[2]');
+} {{[0,1,3,4]}}
+do_execsql_test json102-450 {
+ SELECT json_remove('[0,1,2,3,4]','$[2]','$[0]');
+} {{[1,3,4]}}
+do_execsql_test json102-460 {
+ SELECT json_remove('[0,1,2,3,4]','$[0]','$[2]');
+} {{[1,2,4]}}
+do_execsql_test json102-470 {
+ SELECT json_remove('{"x":25,"y":42}');
+} {{{"x":25,"y":42}}}
+do_execsql_test json102-480 {
+ SELECT json_remove('{"x":25,"y":42}','$.z');
+} {{{"x":25,"y":42}}}
+do_execsql_test json102-490 {
+ SELECT json_remove('{"x":25,"y":42}','$.y');
+} {{{"x":25}}}
+do_execsql_test json102-500 {
+ SELECT json_remove('{"x":25,"y":42}','$');
+} {{}}
+do_execsql_test json102-510 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}');
+} {{object}}
+do_execsql_test json102-520 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$');
+} {{object}}
+do_execsql_test json102-530 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a');
+} {{array}}
+do_execsql_test json102-540 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[0]');
+} {{integer}}
+do_execsql_test json102-550 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[1]');
+} {{real}}
+do_execsql_test json102-560 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[2]');
+} {{true}}
+do_execsql_test json102-570 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[3]');
+} {{false}}
+do_execsql_test json102-580 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[4]');
+} {{null}}
+do_execsql_test json102-590 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[5]');
+} {{text}}
+do_execsql_test json102-600 {
+ SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[6]');
+} {{}}
+do_execsql_test json102-610 {
+ SELECT json_valid(char(123)||'"x":35'||char(125));
+} {{1}}
+do_execsql_test json102-620 {
+ SELECT json_valid(char(123)||'"x":35');
+} {{0}}
+
+ifcapable vtab {
+do_execsql_test json102-1000 {
+ CREATE TABLE user(name,phone);
+ INSERT INTO user(name,phone) VALUES
+ ('Alice','["919-555-2345","804-555-3621"]'),
+ ('Bob','["201-555-8872"]'),
+ ('Cindy','["704-555-9983"]'),
+ ('Dave','["336-555-8421","704-555-4321","803-911-4421"]');
+ SELECT DISTINCT user.name
+ FROM user, json_each(user.phone)
+ WHERE json_each.value LIKE '704-%'
+ ORDER BY 1;
+} {Cindy Dave}
+
+do_execsql_test json102-1010 {
+ UPDATE user
+ SET phone=json_extract(phone,'$[0]')
+ WHERE json_array_length(phone)<2;
+ SELECT name, substr(phone,1,5) FROM user ORDER BY name;
+} {Alice {["919} Bob 201-5 Cindy 704-5 Dave {["336}}
+do_execsql_test json102-1011 {
+ SELECT name FROM user WHERE phone LIKE '704-%'
+ UNION
+ SELECT user.name
+ FROM user, json_each(user.phone)
+ WHERE json_valid(user.phone)
+ AND json_each.value LIKE '704-%';
+} {Cindy Dave}
+
+do_execsql_test json102-1100 {
+ CREATE TABLE big(json JSON);
+ INSERT INTO big(json) VALUES('{
+ "id":123,
+ "stuff":[1,2,3,4],
+ "partlist":[
+ {"uuid":"bb108722-572e-11e5-9320-7f3b63a4ca74"},
+ {"uuid":"c690dc14-572e-11e5-95f9-dfc8861fd535"},
+ {"subassembly":[
+ {"uuid":"6fa5181e-5721-11e5-a04e-57f3d7b32808"}
+ ]}
+ ]
+ }');
+ INSERT INTO big(json) VALUES('{
+ "id":456,
+ "stuff":["hello","world","xyzzy"],
+ "partlist":[
+ {"uuid":false},
+ {"uuid":"c690dc14-572e-11e5-95f9-dfc8861fd535"}
+ ]
+ }');
+} {}
+set correct_answer [list \
+ 1 {$.id} 123 \
+ 1 {$.stuff[0]} 1 \
+ 1 {$.stuff[1]} 2 \
+ 1 {$.stuff[2]} 3 \
+ 1 {$.stuff[3]} 4 \
+ 1 {$.partlist[0].uuid} bb108722-572e-11e5-9320-7f3b63a4ca74 \
+ 1 {$.partlist[1].uuid} c690dc14-572e-11e5-95f9-dfc8861fd535 \
+ 1 {$.partlist[2].subassembly[0].uuid} 6fa5181e-5721-11e5-a04e-57f3d7b32808 \
+ 2 {$.id} 456 \
+ 2 {$.stuff[0]} hello \
+ 2 {$.stuff[1]} world \
+ 2 {$.stuff[2]} xyzzy \
+ 2 {$.partlist[0].uuid} 0 \
+ 2 {$.partlist[1].uuid} c690dc14-572e-11e5-95f9-dfc8861fd535]
+do_execsql_test json102-1110 {
+ SELECT big.rowid, fullkey, value
+ FROM big, json_tree(big.json)
+ WHERE json_tree.type NOT IN ('object','array')
+ ORDER BY +big.rowid, +json_tree.id
+} $correct_answer
+do_execsql_test json102-1120 {
+ SELECT big.rowid, fullkey, atom
+ FROM big, json_tree(big.json)
+ WHERE atom IS NOT NULL
+ ORDER BY +big.rowid, +json_tree.id
+} $correct_answer
+
+do_execsql_test json102-1130 {
+ SELECT DISTINCT json_extract(big.json,'$.id')
+ FROM big, json_tree(big.json,'$.partlist')
+ WHERE json_tree.key='uuid'
+ AND json_tree.value='6fa5181e-5721-11e5-a04e-57f3d7b32808';
+} {123}
+do_execsql_test json102-1131 {
+ SELECT DISTINCT json_extract(big.json,'$.id')
+ FROM big, json_tree(big.json,'$')
+ WHERE json_tree.key='uuid'
+ AND json_tree.value='6fa5181e-5721-11e5-a04e-57f3d7b32808';
+} {123}
+do_execsql_test json102-1132 {
+ SELECT DISTINCT json_extract(big.json,'$.id')
+ FROM big, json_tree(big.json)
+ WHERE json_tree.key='uuid'
+ AND json_tree.value='6fa5181e-5721-11e5-a04e-57f3d7b32808';
+} {123}
+} ;# end ifcapable vtab
+
+#-------------------------------------------------------------------------
+# Test that json_valid() correctly identifies non-ascii range
+# characters as non-whitespace.
+#
+do_execsql_test json102-1201 { SELECT json_valid(char(32) || '"xyz"') } 1
+do_execsql_test json102-1202 { SELECT json_valid(char(200) || '"xyz"') } 0
+
+# Off-by-one error in jsonAppendString()
+#
+for {set i 0} {$i<100} {incr i} {
+ set str abcdef[string repeat \" [expr {$i+50}]]uvwxyz
+ do_test json102-[format %d [expr {$i+1300}]] {
+ db eval {SELECT json_extract(json_array($::str),'$[0]')==$::str}
+ } {1}
+}
+
+#-------------------------------------------------------------------------
+# 2017-04-08 ticket b93be8729a895a528e2849fca99f7
+# JSON extension accepts invalid numeric values
+#
+# JSON does not allow leading zeros. But the JSON extension was
+# allowing them. The following tests verify that the problem is now
+# fixed.
+#
+do_execsql_test json102-1401 { SELECT json_valid('{"x":01}') } 0
+do_execsql_test json102-1402 { SELECT json_valid('{"x":-01}') } 0
+do_execsql_test json102-1403 { SELECT json_valid('{"x":0}') } 1
+do_execsql_test json102-1404 { SELECT json_valid('{"x":-0}') } 1
+do_execsql_test json102-1405 { SELECT json_valid('{"x":0.1}') } 1
+do_execsql_test json102-1406 { SELECT json_valid('{"x":-0.1}') } 1
+do_execsql_test json102-1407 { SELECT json_valid('{"x":0.0000}') } 1
+do_execsql_test json102-1408 { SELECT json_valid('{"x":-0.0000}') } 1
+do_execsql_test json102-1409 { SELECT json_valid('{"x":01.5}') } 0
+do_execsql_test json102-1410 { SELECT json_valid('{"x":-01.5}') } 0
+do_execsql_test json102-1411 { SELECT json_valid('{"x":00}') } 0
+do_execsql_test json102-1412 { SELECT json_valid('{"x":-00}') } 0
+
+#------------------------------------------------------------------------
+# 2017-04-10 ticket 6c9b5514077fed34551f98e64c09a10dc2fc8e16
+# JSON extension accepts strings containing control characters.
+#
+# The JSON spec requires that all control characters be escaped.
+#
+do_execsql_test json102-1500 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<0x20)
+ SELECT x FROM c WHERE json_valid(printf('{"a":"x%sz"}', char(x))) ORDER BY x;
+} {32}
+
+# All control characters are escaped
+#
+do_execsql_test json102-1501 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<0x1f)
+ SELECT sum(json_valid(json_quote('a'||char(x)||'z'))) FROM c ORDER BY x;
+} {31}
+
+# 2022-01-10 tests for -> and ->> operators
+#
+reset_db
+do_execsql_test json102-1600 {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, x JSON);
+ INSERT INTO t1(id,x) VALUES
+ (1, '{"a":null}'),
+ (2, '{"a":123}'),
+ (3, '{"a":4.5}'),
+ (4, '{"a":"six"}'),
+ (5, '{"a":[7,8]}'),
+ (6, '{"a":{"b":9}}'),
+ (7, '{"b":999}');
+ SELECT
+ id,
+ x->'a' AS '->',
+ CASE WHEN subtype(x->'a') THEN 'json' ELSE typeof(x->'a') END AS 'type',
+ x->>'a' AS '->>',
+ CASE WHEN subtype(x->>'a') THEN 'json' ELSE typeof(x->>'a') END AS 'type',
+ json_extract(x,'$.a') AS 'json_extract',
+ CASE WHEN subtype(json_extract(x,'$.a'))
+ THEN 'json' ELSE typeof(json_extract(x,'$.a')) END AS 'type'
+ FROM t1 ORDER BY id;
+} [list \
+ 1 null json {} null {} null \
+ 2 123 json 123 integer 123 integer \
+ 3 4.5 json 4.5 real 4.5 real \
+ 4 {"six"} json six text six text \
+ 5 {[7,8]} json {[7,8]} text {[7,8]} json \
+ 6 {{"b":9}} json {{"b":9}} text {{"b":9}} json \
+ 7 {} null {} null {} null
+]
+do_execsql_test json102-1610 {
+ DELETE FROM t1;
+ INSERT INTO t1(x) VALUES('[null,123,4.5,"six",[7,8],{"b":9}]');
+ WITH c(y) AS (VALUES(0),(1),(2),(3),(4),(5),(6))
+ SELECT
+ y,
+ x->y AS '->',
+ CASE WHEN subtype(x->y) THEN 'json' ELSE typeof(x->y) END AS 'type',
+ x->>y AS '->>',
+ CASE WHEN subtype(x->>y) THEN 'json' ELSE typeof(x->>y) END AS 'type',
+ json_extract(x,format('$[%d]',y)) AS 'json_extract',
+ CASE WHEN subtype(json_extract(x,format('$[%d]',y)))
+ THEN 'json' ELSE typeof(json_extract(x,format('$[%d]',y))) END AS 'type'
+ FROM c, t1 ORDER BY y;
+} [list \
+ 0 null json {} null {} null \
+ 1 123 json 123 integer 123 integer \
+ 2 4.5 json 4.5 real 4.5 real \
+ 3 {"six"} json six text six text \
+ 4 {[7,8]} json {[7,8]} text {[7,8]} json \
+ 5 {{"b":9}} json {{"b":9}} text {{"b":9}} json \
+ 6 {} null {} null {} null
+]
+
+finish_test
diff --git a/test/json103.test b/test/json103.test
new file mode 100644
index 0000000..e748307
--- /dev/null
+++ b/test/json103.test
@@ -0,0 +1,93 @@
+# 2015-12-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 for JSON aggregate SQL functions
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test json103-100 {
+ CREATE TABLE t1(a,b,c);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c) SELECT x, x%3, printf('n%d',x) FROM c;
+ UPDATE t1 SET a='orange' WHERE rowid=39;
+ UPDATE t1 SET a=32.5 WHERE rowid=31;
+ UPDATE t1 SET a=x'303132' WHERE rowid=29;
+ UPDATE t1 SET a=NULL WHERE rowid=37;
+ SELECT json_group_array(a) FROM t1 WHERE a<0 AND typeof(a)!='blob';
+} {{[]}}
+do_catchsql_test json103-101 {
+ SELECT json_group_array(a) FROM t1;
+} {1 {JSON cannot hold BLOB values}}
+do_execsql_test json103-110 {
+ SELECT json_group_array(a) FROM t1
+ WHERE rowid BETWEEN 31 AND 39;
+} {{[32.5,32,33,34,35,36,null,38,"orange"]}}
+do_execsql_test json103-111 {
+ SELECT json_array_length(json_group_array(a)) FROM t1
+ WHERE rowid BETWEEN 31 AND 39;
+} {9}
+do_execsql_test json103-120 {
+ SELECT b, json_group_array(a) FROM t1 WHERE rowid<10 GROUP BY b ORDER BY b;
+} {0 {[3,6,9]} 1 {[1,4,7]} 2 {[2,5,8]}}
+
+do_execsql_test json103-200 {
+ SELECT json_group_object(c,a) FROM t1 WHERE a<0 AND typeof(a)!='blob';
+} {{{}}}
+do_catchsql_test json103-201 {
+ SELECT json_group_object(c,a) FROM t1;
+} {1 {JSON cannot hold BLOB values}}
+
+do_execsql_test json103-210 {
+ SELECT json_group_object(c,a) FROM t1
+ WHERE rowid BETWEEN 31 AND 39 AND rowid%2==1;
+} {{{"n31":32.5,"n33":33,"n35":35,"n37":null,"n39":"orange"}}}
+do_execsql_test json103-220 {
+ SELECT b, json_group_object(c,a) FROM t1
+ WHERE rowid<7 GROUP BY b ORDER BY b;
+} {0 {{"n3":3,"n6":6}} 1 {{"n1":1,"n4":4}} 2 {{"n2":2,"n5":5}}}
+
+# ticket https://www.sqlite.org/src/info/f45ac567eaa9f93c 2016-01-30
+# Invalid JSON generated by json_group_array()
+#
+# The underlying problem is a failure to reset Mem.eSubtype
+#
+do_execsql_test json103-300 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1),('abc');
+ SELECT
+ json_group_array(x),
+ json_group_array(json_object('x',x))
+ FROM t1;
+} {{[1,"abc"]} {[{"x":1},{"x":"abc"}]}}
+
+# json_group_array() and json_group_object() work as window functions.
+#
+ifcapable windowfunc {
+ do_execsql_test json103-400 {
+ CREATE TABLE t4(x);
+ INSERT INTO t4 VALUES
+ (1),
+ ('a,b'),
+ (3),
+ ('x"y'),
+ (5),
+ (6),
+ (7);
+ SELECT json_group_array(x) OVER (ROWS 2 PRECEDING) FROM t4;
+ } {{[1]} {[1,"a,b"]} {[1,"a,b",3]} {["a,b",3,"x\"y"]} {[3,"x\"y",5]} {["x\"y",5,6]} {[5,6,7]}}
+ do_execsql_test json103-410 {
+ SELECT json_group_object(rowid, x) OVER (ROWS 2 PRECEDING) FROM t4;
+ } {{{"1":1}} {{"1":1,"2":"a,b"}} {{"1":1,"2":"a,b","3":3}} {{"2":"a,b","3":3,"4":"x\"y"}} {{"3":3,"4":"x\"y","5":5}} {{"4":"x\"y","5":5,"6":6}} {{"5":5,"6":6,"7":7}}}
+}
+
+finish_test
diff --git a/test/json104.test b/test/json104.test
new file mode 100644
index 0000000..56dd273
--- /dev/null
+++ b/test/json104.test
@@ -0,0 +1,153 @@
+# 2017-03-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 tests for json_patch(A,B) SQL function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix json104
+
+# This is the example from pages 2 and 3 of RFC-7396
+do_execsql_test json104-100 {
+ SELECT json_patch('{
+ "a": "b",
+ "c": {
+ "d": "e",
+ "f": "g"
+ }
+ }','{
+ "a":"z",
+ "c": {
+ "f": null
+ }
+ }');
+} {{{"a":"z","c":{"d":"e"}}}}
+
+
+# This is the example from pages 4 and 5 of RFC-7396
+do_execsql_test json104-110 {
+ SELECT json_patch('{
+ "title": "Goodbye!",
+ "author" : {
+ "givenName" : "John",
+ "familyName" : "Doe"
+ },
+ "tags":[ "example", "sample" ],
+ "content": "This will be unchanged"
+ }','{
+ "title": "Hello!",
+ "phoneNumber": "+01-123-456-7890",
+ "author": {
+ "familyName": null
+ },
+ "tags": [ "example" ]
+ }');
+} {{{"title":"Hello!","author":{"givenName":"John"},"tags":["example"],"content":"This will be unchanged","phoneNumber":"+01-123-456-7890"}}}
+
+do_execsql_test json104-200 {
+ SELECT json_patch('[1,2,3]','{"x":null}');
+} {{{}}}
+do_execsql_test json104-210 {
+ SELECT json_patch('[1,2,3]','{"x":null,"y":1,"z":null}');
+} {{{"y":1}}}
+do_execsql_test json104-220 {
+ SELECT json_patch('{}','{"a":{"bb":{"ccc":null}}}');
+} {{{"a":{"bb":{}}}}}
+do_execsql_test json104-221 {
+ SELECT json_patch('{}','{"a":{"bb":{"ccc":[1,null,3]}}}');
+} {{{"a":{"bb":{"ccc":[1,null,3]}}}}}
+do_execsql_test json104-222 {
+ SELECT json_patch('{}','{"a":{"bb":{"ccc":[1,{"dddd":null},3]}}}');
+} {{{"a":{"bb":{"ccc":[1,{"dddd":null},3]}}}}}
+
+# Example test cases at the end of the RFC-7396 document
+do_execsql_test json104-300 {
+ SELECT json_patch('{"a":"b"}','{"a":"c"}');
+} {{{"a":"c"}}}
+do_execsql_test json104-300a {
+ SELECT coalesce(json_patch(null,'{"a":"c"}'), 'real-null');
+} {{real-null}}
+do_execsql_test json104-301 {
+ SELECT json_patch('{"a":"b"}','{"b":"c"}');
+} {{{"a":"b","b":"c"}}}
+do_execsql_test json104-302 {
+ SELECT json_patch('{"a":"b"}','{"a":null}');
+} {{{}}}
+do_execsql_test json104-303 {
+ SELECT json_patch('{"a":"b","b":"c"}','{"a":null}');
+} {{{"b":"c"}}}
+do_execsql_test json104-304 {
+ SELECT json_patch('{"a":["b"]}','{"a":"c"}');
+} {{{"a":"c"}}}
+do_execsql_test json104-305 {
+ SELECT json_patch('{"a":"c"}','{"a":["b"]}');
+} {{{"a":["b"]}}}
+do_execsql_test json104-306 {
+ SELECT json_patch('{"a":{"b":"c"}}','{"a":{"b":"d","c":null}}');
+} {{{"a":{"b":"d"}}}}
+do_execsql_test json104-307 {
+ SELECT json_patch('{"a":[{"b":"c"}]}','{"a":[1]}');
+} {{{"a":[1]}}}
+do_execsql_test json104-308 {
+ SELECT json_patch('["a","b"]','["c","d"]');
+} {{["c","d"]}}
+do_execsql_test json104-309 {
+ SELECT json_patch('{"a":"b"}','["c"]');
+} {{["c"]}}
+do_execsql_test json104-310 {
+ SELECT json_patch('{"a":"foo"}','null');
+} {{null}}
+do_execsql_test json104-310a {
+ SELECT coalesce(json_patch('{"a":"foo"}',null), 'real-null');
+} {{real-null}}
+do_execsql_test json104-311 {
+ SELECT json_patch('{"a":"foo"}','"bar"');
+} {{"bar"}}
+do_execsql_test json104-312 {
+ SELECT json_patch('{"e":null}','{"a":1}');
+} {{{"e":null,"a":1}}}
+do_execsql_test json104-313 {
+ SELECT json_patch('[1,2]','{"a":"b","c":null}');
+} {{{"a":"b"}}}
+do_execsql_test json104-314 {
+ SELECT json_patch('{}','{"a":{"bb":{"ccc":null}}}');
+} {{{"a":{"bb":{}}}}}
+do_execsql_test json104-320 {
+ SELECT json_patch('{"x":{"one":1}}','{"x":{"two":2},"x":"three"}');
+} {{{"x":"three"}}}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 401 {
+ CREATE TABLE obj(x);
+ INSERT INTO obj VALUES('{"a":1,"b":2}');
+ SELECT * FROM obj;
+} {{{"a":1,"b":2}}}
+do_execsql_test 402 {
+ UPDATE obj SET x = json_insert(x, '$.c', 3);
+ SELECT * FROM obj;
+} {{{"a":1,"b":2,"c":3}}}
+do_execsql_test 403 {
+ SELECT json_extract(x, '$.b') FROM obj;
+ SELECT json_extract(x, '$."b"') FROM obj;
+} {2 2}
+do_execsql_test 404 {
+ UPDATE obj SET x = json_set(x, '$."b"', 555);
+ SELECT json_extract(x, '$.b') FROM obj;
+ SELECT json_extract(x, '$."b"') FROM obj;
+} {555 555}
+do_execsql_test 405 {
+ UPDATE obj SET x = json_set(x, '$."d"', 4);
+ SELECT json_extract(x, '$."d"') FROM obj;
+} {4}
+
+
+finish_test
diff --git a/test/json105.test b/test/json105.test
new file mode 100644
index 0000000..83face1
--- /dev/null
+++ b/test/json105.test
@@ -0,0 +1,113 @@
+# 2019-11-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 tests for "[#]" extension to json-path
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix json104
+
+# This is the example from pages 2 and 3 of RFC-7396
+db eval {
+ CREATE TABLE t1(j);
+ INSERT INTO t1(j) VALUES('{"a":1,"b":[1,[2,3],4],"c":99}');
+}
+proc json_extract_test {testnum path result} {
+ do_execsql_test json105-1.$testnum "SELECT quote(json_extract(j,$path)) FROM t1" $result
+}
+json_extract_test 10 {'$.b[#]'} NULL
+json_extract_test 20 {'$.b[#-1]'} 4
+json_extract_test 30 {'$.b[#-2]'} {'[2,3]'}
+json_extract_test 31 {'$.b[#-02]'} {'[2,3]'}
+json_extract_test 40 {'$.b[#-3]'} 1
+json_extract_test 50 {'$.b[#-4]'} NULL
+json_extract_test 60 {'$.b[#-2][#-1]'} 3
+json_extract_test 70 {'$.b[0]','$.b[#-1]'} {'[1,4]'}
+
+json_extract_test 100 {'$.a[#-1]'} NULL
+json_extract_test 110 {'$.b[#-000001]'} 4
+
+proc json_remove_test {testnum path result} {
+ do_execsql_test json105-2.$testnum "SELECT quote(json_remove(j,$path)) FROM t1" $result
+}
+json_remove_test 10 {'$.b[#]'} {'{"a":1,"b":[1,[2,3],4],"c":99}'}
+json_remove_test 20 {'$.b[#-0]'} {'{"a":1,"b":[1,[2,3],4],"c":99}'}
+json_remove_test 30 {'$.b[#-1]'} {'{"a":1,"b":[1,[2,3]],"c":99}'}
+json_remove_test 40 {'$.b[#-2]'} {'{"a":1,"b":[1,4],"c":99}'}
+json_remove_test 50 {'$.b[#-3]'} {'{"a":1,"b":[[2,3],4],"c":99}'}
+json_remove_test 60 {'$.b[#-4]'} {'{"a":1,"b":[1,[2,3],4],"c":99}'}
+json_remove_test 70 {'$.b[#-2][#-1]'} {'{"a":1,"b":[1,[2],4],"c":99}'}
+
+json_remove_test 100 {'$.b[0]','$.b[#-1]'} {'{"a":1,"b":[[2,3]],"c":99}'}
+json_remove_test 110 {'$.b[#-1]','$.b[0]'} {'{"a":1,"b":[[2,3]],"c":99}'}
+json_remove_test 120 {'$.b[#-1]','$.b[#-2]'} {'{"a":1,"b":[[2,3]],"c":99}'}
+json_remove_test 130 {'$.b[#-1]','$.b[#-1]'} {'{"a":1,"b":[1],"c":99}'}
+json_remove_test 140 {'$.b[#-2]','$.b[#-1]'} {'{"a":1,"b":[1],"c":99}'}
+
+proc json_insert_test {testnum x result} {
+ do_execsql_test json105-3.$testnum "SELECT quote(json_insert(j,$x)) FROM t1" $result
+}
+json_insert_test 10 {'$.b[#]','AAA'} {'{"a":1,"b":[1,[2,3],4,"AAA"],"c":99}'}
+json_insert_test 20 {'$.b[1][#]','AAA'} {'{"a":1,"b":[1,[2,3,"AAA"],4],"c":99}'}
+json_insert_test 30 {'$.b[1][#]','AAA','$.b[#]','BBB'} \
+ {'{"a":1,"b":[1,[2,3,"AAA"],4,"BBB"],"c":99}'}
+json_insert_test 40 {'$.b[#]','AAA','$.b[#]','BBB'} \
+ {'{"a":1,"b":[1,[2,3],4,"AAA","BBB"],"c":99}'}
+
+proc json_set_test {testnum x result} {
+ do_execsql_test json105-4.$testnum "SELECT quote(json_set(j,$x)) FROM t1" $result
+}
+json_set_test 10 {'$.b[#]','AAA'} {'{"a":1,"b":[1,[2,3],4,"AAA"],"c":99}'}
+json_set_test 20 {'$.b[1][#]','AAA'} {'{"a":1,"b":[1,[2,3,"AAA"],4],"c":99}'}
+json_set_test 30 {'$.b[1][#]','AAA','$.b[#]','BBB'} \
+ {'{"a":1,"b":[1,[2,3,"AAA"],4,"BBB"],"c":99}'}
+json_set_test 40 {'$.b[#]','AAA','$.b[#]','BBB'} \
+ {'{"a":1,"b":[1,[2,3],4,"AAA","BBB"],"c":99}'}
+json_set_test 50 {'$.b[#-1]','AAA'} {'{"a":1,"b":[1,[2,3],"AAA"],"c":99}'}
+json_set_test 60 {'$.b[1][#-1]','AAA'} {'{"a":1,"b":[1,[2,"AAA"],4],"c":99}'}
+json_set_test 70 {'$.b[1][#-1]','AAA','$.b[#-1]','BBB'} \
+ {'{"a":1,"b":[1,[2,"AAA"],"BBB"],"c":99}'}
+json_set_test 80 {'$.b[#-1]','AAA','$.b[#-1]','BBB'} \
+ {'{"a":1,"b":[1,[2,3],"BBB"],"c":99}'}
+
+proc json_replace_test {testnum x result} {
+ do_execsql_test json105-5.$testnum "SELECT quote(json_replace(j,$x)) FROM t1" $result
+}
+json_replace_test 10 {'$.b[#]','AAA'} {'{"a":1,"b":[1,[2,3],4],"c":99}'}
+json_replace_test 20 {'$.b[1][#]','AAA'} {'{"a":1,"b":[1,[2,3],4],"c":99}'}
+json_replace_test 30 {'$.b[1][#]','AAA','$.b[#]','BBB'} \
+ {'{"a":1,"b":[1,[2,3],4],"c":99}'}
+json_replace_test 40 {'$.b[#]','AAA','$.b[#]','BBB'} \
+ {'{"a":1,"b":[1,[2,3],4],"c":99}'}
+json_replace_test 50 {'$.b[#-1]','AAA'} {'{"a":1,"b":[1,[2,3],"AAA"],"c":99}'}
+json_replace_test 60 {'$.b[1][#-1]','AAA'} {'{"a":1,"b":[1,[2,"AAA"],4],"c":99}'}
+json_replace_test 70 {'$.b[1][#-1]','AAA','$.b[#-1]','BBB'} \
+ {'{"a":1,"b":[1,[2,"AAA"],"BBB"],"c":99}'}
+json_replace_test 80 {'$.b[#-1]','AAA','$.b[#-1]','BBB'} \
+ {'{"a":1,"b":[1,[2,3],"BBB"],"c":99}'}
+
+do_catchsql_test json105-6.10 {
+ SELECT json_extract(j, '$.b[#-]') FROM t1;
+} {1 {JSON path error near '[#-]'}}
+do_catchsql_test json105-6.20 {
+ SELECT json_extract(j, '$.b[#9]') FROM t1;
+} {1 {JSON path error near '[#9]'}}
+do_catchsql_test json105-6.30 {
+ SELECT json_extract(j, '$.b[#+2]') FROM t1;
+} {1 {JSON path error near '[#+2]'}}
+do_catchsql_test json105-6.40 {
+ SELECT json_extract(j, '$.b[#-1') FROM t1;
+} {1 {JSON path error near '[#-1'}}
+do_catchsql_test json105-6.50 {
+ SELECT json_extract(j, '$.b[#-1x]') FROM t1;
+} {1 {JSON path error near '[#-1x]'}}
+
+finish_test
diff --git a/test/keyword1.test b/test/keyword1.test
new file mode 100644
index 0000000..2bc1ff5
--- /dev/null
+++ b/test/keyword1.test
@@ -0,0 +1,121 @@
+# 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
+ recursive
+ regexp
+ reindex
+ release
+ rename
+ replace
+ restrict
+ rollback
+ row
+ savepoint
+ temp
+ temporary
+ trigger
+ vacuum
+ view
+ virtual
+ with
+ without
+};
+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/kvtest.c b/test/kvtest.c
new file mode 100644
index 0000000..04dc010
--- /dev/null
+++ b/test/kvtest.c
@@ -0,0 +1,1137 @@
+/*
+** 2016-12-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 "key-value" performance test for SQLite. The
+** purpose is to compare the speed of SQLite for accessing large BLOBs
+** versus reading those same BLOB values out of individual files in the
+** filesystem.
+**
+** Run "kvtest" with no arguments for on-line help, or see comments below.
+**
+** HOW TO COMPILE:
+**
+** (1) Gather this source file and a recent SQLite3 amalgamation with its
+** header into the working directory. You should have:
+**
+** kvtest.c >--- this file
+** sqlite3.c \___ SQLite
+** sqlite3.h / amlagamation & header
+**
+** (2) Run you compiler against the two C source code files.
+**
+** (a) On linux or mac:
+**
+** OPTS="-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION"
+** gcc -Os -I. $OPTS kvtest.c sqlite3.c -o kvtest
+**
+** The $OPTS options can be omitted. The $OPTS merely omit
+** the need to link against -ldl and -lpthread, or whatever
+** the equivalent libraries are called on your system.
+**
+** (b) Windows with MSVC:
+**
+** cl -I. kvtest.c sqlite3.c
+**
+** USAGE:
+**
+** (1) Create a test database by running "kvtest init" with appropriate
+** options. See the help message for available options.
+**
+** (2) Construct the corresponding pile-of-files database on disk using
+** the "kvtest export" command.
+**
+** (3) Run tests using "kvtest run" against either the SQLite database or
+** the pile-of-files database and with appropriate options.
+**
+** For example:
+**
+** ./kvtest init x1.db --count 100000 --size 10000
+** mkdir x1
+** ./kvtest export x1.db x1
+** ./kvtest run x1.db --count 10000 --max-id 1000000
+** ./kvtest run x1 --count 10000 --max-id 1000000
+*/
+static const char zHelp[] =
+"Usage: kvtest COMMAND ARGS...\n"
+"\n"
+" kvtest init DBFILE --count N --size M --pagesize X\n"
+"\n"
+" Generate a new test database file named DBFILE containing N\n"
+" BLOBs each of size M bytes. The page size of the new database\n"
+" file will be X. Additional options:\n"
+"\n"
+" --variance V Randomly vary M by plus or minus V\n"
+"\n"
+" kvtest export DBFILE DIRECTORY [--tree]\n"
+"\n"
+" Export all the blobs in the kv table of DBFILE into separate\n"
+" files in DIRECTORY. DIRECTORY is created if it does not previously\n"
+" exist. If the --tree option is used, then the blobs are written\n"
+" into a hierarchy of directories, using names like 00/00/00,\n"
+" 00/00/01, 00/00/02, and so forth. Without the --tree option, all\n"
+" files are in the top-level directory with names like 000000, 000001,\n"
+" 000002, and so forth.\n"
+"\n"
+" kvtest stat DBFILE [options]\n"
+"\n"
+" Display summary information about DBFILE. Options:\n"
+"\n"
+" --vacuum Run VACUUM on the database file\n"
+"\n"
+" kvtest run DBFILE [options]\n"
+"\n"
+" Run a performance test. DBFILE can be either the name of a\n"
+" database or a directory containing sample files. Options:\n"
+"\n"
+" --asc Read blobs in ascending order\n"
+" --blob-api Use the BLOB API\n"
+" --cache-size N Database cache size\n"
+" --count N Read N blobs\n"
+" --desc Read blobs in descending order\n"
+" --fsync Synchronous file writes\n"
+" --integrity-check Run \"PRAGMA integrity_check\" after test\n"
+" --max-id N Maximum blob key to use\n"
+" --mmap N Mmap as much as N bytes of DBFILE\n"
+" --multitrans Each read or write in its own transaction\n"
+" --nocheckpoint Omit the checkpoint on WAL mode writes\n"
+" --nosync Set \"PRAGMA synchronous=OFF\"\n"
+" --jmode MODE Set MODE journal mode prior to starting\n"
+" --random Read blobs in a random order\n"
+" --start N Start reading with this blob key\n"
+" --stats Output operating stats before exiting\n"
+" --update Do an overwrite test\n"
+;
+
+/* Reference resources used */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <assert.h>
+#include <string.h>
+#include "sqlite3.h"
+
+#ifndef _WIN32
+# include <unistd.h>
+#else
+ /* Provide Windows equivalent for the needed parts of unistd.h */
+# include <direct.h>
+# include <io.h>
+# define R_OK 2
+# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+# define access _access
+#endif
+
+#if !defined(_MSC_VER)
+# include <stdint.h>
+#endif
+
+/*
+** The following macros are used to cast pointers to integers and
+** integers to pointers. The way you do this varies from one compiler
+** to the next, so we have developed the following set of #if statements
+** to generate appropriate macros for a wide range of compilers.
+**
+** The correct "ANSI" way to do this is to use the intptr_t type.
+** Unfortunately, that typedef is not available on all compilers, or
+** if it is available, it requires an #include of specific headers
+** that vary from one machine to the next.
+**
+** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
+** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
+** So we have to define the macros in different ways depending on the
+** compiler.
+*/
+#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
+# define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
+# define SQLITE_PTR_TO_INT(X) ((sqlite3_int64)(__PTRDIFF_TYPE__)(X))
+#else
+# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
+# define SQLITE_PTR_TO_INT(X) ((sqlite3_int64)(intptr_t)(X))
+#endif
+
+/*
+** Show thqe help text and quit.
+*/
+static void showHelp(void){
+ fprintf(stdout, "%s", zHelp);
+ exit(1);
+}
+
+/*
+** Show an error message an quit.
+*/
+static void fatalError(const char *zFormat, ...){
+ va_list ap;
+ fprintf(stdout, "ERROR: ");
+ va_start(ap, zFormat);
+ vfprintf(stdout, zFormat, ap);
+ va_end(ap);
+ fprintf(stdout, "\n");
+ exit(1);
+}
+
+/*
+** Return the value of a hexadecimal digit. Return -1 if the input
+** is not a hex digit.
+*/
+static int hexDigitValue(char c){
+ if( c>='0' && c<='9' ) return c - '0';
+ if( c>='a' && c<='f' ) return c - 'a' + 10;
+ if( c>='A' && c<='F' ) return c - 'A' + 10;
+ return -1;
+}
+
+/*
+** Interpret zArg as an integer value, possibly with suffixes.
+*/
+static int integerValue(const char *zArg){
+ int v = 0;
+ static const struct { char *zSuffix; int iMult; } aMult[] = {
+ { "KiB", 1024 },
+ { "MiB", 1024*1024 },
+ { "GiB", 1024*1024*1024 },
+ { "KB", 1000 },
+ { "MB", 1000000 },
+ { "GB", 1000000000 },
+ { "K", 1000 },
+ { "M", 1000000 },
+ { "G", 1000000000 },
+ };
+ int i;
+ int isNeg = 0;
+ if( zArg[0]=='-' ){
+ isNeg = 1;
+ zArg++;
+ }else if( zArg[0]=='+' ){
+ zArg++;
+ }
+ if( zArg[0]=='0' && zArg[1]=='x' ){
+ int x;
+ zArg += 2;
+ while( (x = hexDigitValue(zArg[0]))>=0 ){
+ v = (v<<4) + x;
+ zArg++;
+ }
+ }else{
+ while( zArg[0]>='0' && zArg[0]<='9' ){
+ v = v*10 + zArg[0] - '0';
+ zArg++;
+ }
+ }
+ for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
+ if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
+ v *= aMult[i].iMult;
+ break;
+ }
+ }
+ return isNeg? -v : v;
+}
+
+
+/*
+** Check the filesystem object zPath. Determine what it is:
+**
+** PATH_DIR A single directory holding many files
+** PATH_TREE A directory hierarchy with files at the leaves
+** PATH_DB An SQLite database
+** PATH_NEXIST Does not exist
+** PATH_OTHER Something else
+**
+** PATH_DIR means all of the separate files are grouped together
+** into a single directory with names like 000000, 000001, 000002, and
+** so forth. PATH_TREE means there is a hierarchy of directories so
+** that no single directory has too many entries. The files have names
+** like 00/00/00, 00/00/01, 00/00/02 and so forth. The decision between
+** PATH_DIR and PATH_TREE is determined by the presence of a subdirectory
+** named "00" at the top-level.
+*/
+#define PATH_DIR 1
+#define PATH_TREE 2
+#define PATH_DB 3
+#define PATH_NEXIST 0
+#define PATH_OTHER 99
+static int pathType(const char *zPath){
+ struct stat x;
+ int rc;
+ if( access(zPath,R_OK) ) return PATH_NEXIST;
+ memset(&x, 0, sizeof(x));
+ rc = stat(zPath, &x);
+ if( rc<0 ) return PATH_OTHER;
+ if( S_ISDIR(x.st_mode) ){
+ char *zLayer1 = sqlite3_mprintf("%s/00", zPath);
+ memset(&x, 0, sizeof(x));
+ rc = stat(zLayer1, &x);
+ sqlite3_free(zLayer1);
+ if( rc<0 ) return PATH_DIR;
+ if( S_ISDIR(x.st_mode) ) return PATH_TREE;
+ return PATH_DIR;
+ }
+ if( (x.st_size%512)==0 ) return PATH_DB;
+ return PATH_OTHER;
+}
+
+/*
+** Return the size of a file in bytes. Or return -1 if the
+** named object is not a regular file or does not exist.
+*/
+static sqlite3_int64 fileSize(const char *zPath){
+ struct stat x;
+ int rc;
+ memset(&x, 0, sizeof(x));
+ rc = stat(zPath, &x);
+ if( rc<0 ) return -1;
+ if( !S_ISREG(x.st_mode) ) return -1;
+ return x.st_size;
+}
+
+/*
+** A Pseudo-random number generator with a fixed seed. Use this so
+** that the same sequence of "random" numbers are generated on each
+** run, for repeatability.
+*/
+static unsigned int randInt(void){
+ static unsigned int x = 0x333a13cd;
+ static unsigned int y = 0xecb2adea;
+ x = (x>>1) ^ ((1+~(x&1)) & 0xd0000001);
+ y = y*1103515245 + 12345;
+ return x^y;
+}
+
+/*
+** Do database initialization.
+*/
+static int initMain(int argc, char **argv){
+ char *zDb;
+ int i, rc;
+ int nCount = 1000;
+ int sz = 10000;
+ int iVariance = 0;
+ int pgsz = 4096;
+ sqlite3 *db;
+ char *zSql;
+ char *zErrMsg = 0;
+
+ assert( strcmp(argv[1],"init")==0 );
+ assert( argc>=3 );
+ zDb = argv[2];
+ for(i=3; i<argc; i++){
+ char *z = argv[i];
+ if( z[0]!='-' ) fatalError("unknown argument: \"%s\"", z);
+ if( z[1]=='-' ) z++;
+ if( strcmp(z, "-count")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ nCount = integerValue(argv[++i]);
+ if( nCount<1 ) fatalError("the --count must be positive");
+ continue;
+ }
+ if( strcmp(z, "-size")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ sz = integerValue(argv[++i]);
+ if( sz<1 ) fatalError("the --size must be positive");
+ continue;
+ }
+ if( strcmp(z, "-variance")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ iVariance = integerValue(argv[++i]);
+ continue;
+ }
+ if( strcmp(z, "-pagesize")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ pgsz = integerValue(argv[++i]);
+ if( pgsz<512 || pgsz>65536 || ((pgsz-1)&pgsz)!=0 ){
+ fatalError("the --pagesize must be power of 2 between 512 and 65536");
+ }
+ continue;
+ }
+ fatalError("unknown option: \"%s\"", argv[i]);
+ }
+ rc = sqlite3_open(zDb, &db);
+ if( rc ){
+ fatalError("cannot open database \"%s\": %s", zDb, sqlite3_errmsg(db));
+ }
+ zSql = sqlite3_mprintf(
+ "DROP TABLE IF EXISTS kv;\n"
+ "PRAGMA page_size=%d;\n"
+ "VACUUM;\n"
+ "BEGIN;\n"
+ "CREATE TABLE kv(k INTEGER PRIMARY KEY, v BLOB);\n"
+ "WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<%d)"
+ " INSERT INTO kv(k,v) SELECT x, randomblob(%d+(random()%%(%d))) FROM c;\n"
+ "COMMIT;\n",
+ pgsz, nCount, sz, iVariance+1
+ );
+ rc = sqlite3_exec(db, zSql, 0, 0, &zErrMsg);
+ if( rc ) fatalError("database create failed: %s", zErrMsg);
+ sqlite3_free(zSql);
+ sqlite3_close(db);
+ return 0;
+}
+
+/*
+** Analyze an existing database file. Report its content.
+*/
+static int statMain(int argc, char **argv){
+ char *zDb;
+ int i, rc;
+ sqlite3 *db;
+ char *zSql;
+ sqlite3_stmt *pStmt;
+ int doVacuum = 0;
+
+ assert( strcmp(argv[1],"stat")==0 );
+ assert( argc>=3 );
+ zDb = argv[2];
+ for(i=3; i<argc; i++){
+ char *z = argv[i];
+ if( z[0]!='-' ) fatalError("unknown argument: \"%s\"", z);
+ if( z[1]=='-' ) z++;
+ if( strcmp(z, "-vacuum")==0 ){
+ doVacuum = 1;
+ continue;
+ }
+ fatalError("unknown option: \"%s\"", argv[i]);
+ }
+ rc = sqlite3_open(zDb, &db);
+ if( rc ){
+ fatalError("cannot open database \"%s\": %s", zDb, sqlite3_errmsg(db));
+ }
+ if( doVacuum ){
+ printf("Vacuuming...."); fflush(stdout);
+ sqlite3_exec(db, "VACUUM", 0, 0, 0);
+ printf(" done\n");
+ }
+ zSql = sqlite3_mprintf(
+ "SELECT count(*), min(length(v)), max(length(v)), avg(length(v))"
+ " FROM kv"
+ );
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare SQL [%s]: %s", zSql, sqlite3_errmsg(db));
+ sqlite3_free(zSql);
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("Number of entries: %8d\n", sqlite3_column_int(pStmt, 0));
+ printf("Average value size: %8d\n", sqlite3_column_int(pStmt, 3));
+ printf("Minimum value size: %8d\n", sqlite3_column_int(pStmt, 1));
+ printf("Maximum value size: %8d\n", sqlite3_column_int(pStmt, 2));
+ }else{
+ printf("No rows\n");
+ }
+ sqlite3_finalize(pStmt);
+ zSql = sqlite3_mprintf("PRAGMA page_size");
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare SQL [%s]: %s", zSql, sqlite3_errmsg(db));
+ sqlite3_free(zSql);
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("Page-size: %8d\n", sqlite3_column_int(pStmt, 0));
+ }
+ sqlite3_finalize(pStmt);
+ zSql = sqlite3_mprintf("PRAGMA page_count");
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare SQL [%s]: %s", zSql, sqlite3_errmsg(db));
+ sqlite3_free(zSql);
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("Page-count: %8d\n", sqlite3_column_int(pStmt, 0));
+ }
+ sqlite3_finalize(pStmt);
+ zSql = sqlite3_mprintf("PRAGMA freelist_count");
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare SQL [%s]: %s", zSql, sqlite3_errmsg(db));
+ sqlite3_free(zSql);
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("Freelist-count: %8d\n", sqlite3_column_int(pStmt, 0));
+ }
+ sqlite3_finalize(pStmt);
+ rc = sqlite3_prepare_v2(db, "PRAGMA integrity_check(10)", -1, &pStmt, 0);
+ if( rc ) fatalError("cannot prepare integrity check: %s", sqlite3_errmsg(db));
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("Integrity-check: %s\n", sqlite3_column_text(pStmt, 0));
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_close(db);
+ return 0;
+}
+
+/*
+** remember(V,PTR)
+**
+** Return the integer value V. Also save the value of V in a
+** C-language variable whose address is PTR.
+*/
+static void rememberFunc(
+ sqlite3_context *pCtx,
+ int argc,
+ sqlite3_value **argv
+){
+ sqlite3_int64 v;
+ sqlite3_int64 ptr;
+ assert( argc==2 );
+ v = sqlite3_value_int64(argv[0]);
+ ptr = sqlite3_value_int64(argv[1]);
+ *(sqlite3_int64*)SQLITE_INT_TO_PTR(ptr) = v;
+ sqlite3_result_int64(pCtx, v);
+}
+
+/*
+** Make sure a directory named zDir exists.
+*/
+static void kvtest_mkdir(const char *zDir){
+#if defined(_WIN32)
+ (void)mkdir(zDir);
+#else
+ (void)mkdir(zDir, 0755);
+#endif
+}
+
+/*
+** Export the kv table to individual files in the filesystem
+*/
+static int exportMain(int argc, char **argv){
+ char *zDb;
+ char *zDir;
+ sqlite3 *db;
+ sqlite3_stmt *pStmt;
+ int rc;
+ int ePathType;
+ int nFN;
+ char *zFN;
+ char *zTail;
+ size_t nWrote;
+ int i;
+
+ assert( strcmp(argv[1],"export")==0 );
+ assert( argc>=3 );
+ if( argc<4 ) fatalError("Usage: kvtest export DATABASE DIRECTORY [OPTIONS]");
+ zDb = argv[2];
+ zDir = argv[3];
+ kvtest_mkdir(zDir);
+ for(i=4; i<argc; i++){
+ const char *z = argv[i];
+ if( z[0]=='-' && z[1]=='-' ) z++;
+ if( strcmp(z,"-tree")==0 ){
+ zFN = sqlite3_mprintf("%s/00", zDir);
+ kvtest_mkdir(zFN);
+ sqlite3_free(zFN);
+ continue;
+ }
+ fatalError("unknown argument: \"%s\"\n", argv[i]);
+ }
+ ePathType = pathType(zDir);
+ if( ePathType!=PATH_DIR && ePathType!=PATH_TREE ){
+ fatalError("object \"%s\" is not a directory", zDir);
+ }
+ rc = sqlite3_open(zDb, &db);
+ if( rc ){
+ fatalError("cannot open database \"%s\": %s", zDb, sqlite3_errmsg(db));
+ }
+ rc = sqlite3_prepare_v2(db, "SELECT k, v FROM kv ORDER BY k", -1, &pStmt, 0);
+ if( rc ){
+ fatalError("prepare_v2 failed: %s\n", sqlite3_errmsg(db));
+ }
+ nFN = (int)strlen(zDir);
+ zFN = sqlite3_mprintf("%s/00/00/00.extra---------------------", zDir);
+ if( zFN==0 ){
+ fatalError("malloc failed\n");
+ }
+ zTail = zFN + nFN + 1;
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ int iKey = sqlite3_column_int(pStmt, 0);
+ sqlite3_int64 nData = sqlite3_column_bytes(pStmt, 1);
+ const void *pData = sqlite3_column_blob(pStmt, 1);
+ FILE *out;
+ if( ePathType==PATH_DIR ){
+ sqlite3_snprintf(20, zTail, "%06d", iKey);
+ }else{
+ sqlite3_snprintf(20, zTail, "%02d", iKey/10000);
+ kvtest_mkdir(zFN);
+ sqlite3_snprintf(20, zTail, "%02d/%02d", iKey/10000, (iKey/100)%100);
+ kvtest_mkdir(zFN);
+ sqlite3_snprintf(20, zTail, "%02d/%02d/%02d",
+ iKey/10000, (iKey/100)%100, iKey%100);
+ }
+ out = fopen(zFN, "wb");
+ nWrote = fwrite(pData, 1, (size_t)nData, out);
+ fclose(out);
+ printf("\r%s ", zTail); fflush(stdout);
+ if( nWrote!=(size_t)nData ){
+ fatalError("Wrote only %d of %d bytes to %s\n",
+ (int)nWrote, nData, zFN);
+ }
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_close(db);
+ sqlite3_free(zFN);
+ printf("\n");
+ return 0;
+}
+
+/*
+** Read the content of file zName into memory obtained from sqlite3_malloc64()
+** and return a pointer to the buffer. The caller is responsible for freeing
+** the memory.
+**
+** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes
+** read.
+**
+** For convenience, a nul-terminator byte is always appended to the data read
+** from the file before the buffer is returned. This byte is not included in
+** the final value of (*pnByte), if applicable.
+**
+** NULL is returned if any error is encountered. The final value of *pnByte
+** is undefined in this case.
+*/
+static unsigned char *readFile(const char *zName, sqlite3_int64 *pnByte){
+ FILE *in; /* FILE from which to read content of zName */
+ sqlite3_int64 nIn; /* Size of zName in bytes */
+ size_t nRead; /* Number of bytes actually read */
+ unsigned char *pBuf; /* Content read from disk */
+
+ nIn = fileSize(zName);
+ if( nIn<0 ) return 0;
+ in = fopen(zName, "rb");
+ if( in==0 ) return 0;
+ pBuf = sqlite3_malloc64( nIn );
+ if( pBuf==0 ) return 0;
+ nRead = fread(pBuf, (size_t)nIn, 1, in);
+ fclose(in);
+ if( nRead!=1 ){
+ sqlite3_free(pBuf);
+ return 0;
+ }
+ if( pnByte ) *pnByte = nIn;
+ return pBuf;
+}
+
+/*
+** Overwrite a file with randomness. Do not change the size of the
+** file.
+*/
+static void updateFile(const char *zName, sqlite3_int64 *pnByte, int doFsync){
+ FILE *out; /* FILE from which to read content of zName */
+ sqlite3_int64 sz; /* Size of zName in bytes */
+ size_t nWritten; /* Number of bytes actually read */
+ unsigned char *pBuf; /* Content to store on disk */
+ const char *zMode = "wb"; /* Mode for fopen() */
+
+ sz = fileSize(zName);
+ if( sz<0 ){
+ fatalError("No such file: \"%s\"", zName);
+ }
+ *pnByte = sz;
+ if( sz==0 ) return;
+ pBuf = sqlite3_malloc64( sz );
+ if( pBuf==0 ){
+ fatalError("Cannot allocate %lld bytes\n", sz);
+ }
+ sqlite3_randomness((int)sz, pBuf);
+#if defined(_WIN32)
+ if( doFsync ) zMode = "wbc";
+#endif
+ out = fopen(zName, zMode);
+ if( out==0 ){
+ fatalError("Cannot open \"%s\" for writing\n", zName);
+ }
+ nWritten = fwrite(pBuf, 1, (size_t)sz, out);
+ if( doFsync ){
+#if defined(_WIN32)
+ fflush(out);
+#else
+ fsync(fileno(out));
+#endif
+ }
+ fclose(out);
+ if( nWritten!=(size_t)sz ){
+ fatalError("Wrote only %d of %d bytes to \"%s\"\n",
+ (int)nWritten, (int)sz, zName);
+ }
+ sqlite3_free(pBuf);
+}
+
+/*
+** Return the current time in milliseconds since the beginning of
+** the Julian epoch.
+*/
+static sqlite3_int64 timeOfDay(void){
+ static sqlite3_vfs *clockVfs = 0;
+ sqlite3_int64 t;
+ if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
+ if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
+ clockVfs->xCurrentTimeInt64(clockVfs, &t);
+ }else{
+ double r;
+ clockVfs->xCurrentTime(clockVfs, &r);
+ t = (sqlite3_int64)(r*86400000.0);
+ }
+ return t;
+}
+
+#ifdef __linux__
+/*
+** Attempt to display I/O stats on Linux using /proc/PID/io
+*/
+static void displayLinuxIoStats(FILE *out){
+ FILE *in;
+ char z[200];
+ sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid());
+ in = fopen(z, "rb");
+ if( in==0 ) return;
+ while( fgets(z, sizeof(z), in)!=0 ){
+ static const struct {
+ const char *zPattern;
+ const char *zDesc;
+ } aTrans[] = {
+ { "rchar: ", "Bytes received by read():" },
+ { "wchar: ", "Bytes sent to write():" },
+ { "syscr: ", "Read() system calls:" },
+ { "syscw: ", "Write() system calls:" },
+ { "read_bytes: ", "Bytes read from storage:" },
+ { "write_bytes: ", "Bytes written to storage:" },
+ { "cancelled_write_bytes: ", "Cancelled write bytes:" },
+ };
+ int i;
+ for(i=0; i<sizeof(aTrans)/sizeof(aTrans[0]); i++){
+ int n = (int)strlen(aTrans[i].zPattern);
+ if( strncmp(aTrans[i].zPattern, z, n)==0 ){
+ fprintf(out, "%-36s %s", aTrans[i].zDesc, &z[n]);
+ break;
+ }
+ }
+ }
+ fclose(in);
+}
+#endif
+
+/*
+** Display memory stats.
+*/
+static int display_stats(
+ sqlite3 *db, /* Database to query */
+ int bReset /* True to reset SQLite stats */
+){
+ int iCur;
+ int iHiwtr;
+ FILE *out = stdout;
+
+ fprintf(out, "\n");
+
+ iHiwtr = iCur = -1;
+ sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
+ fprintf(out,
+ "Memory Used: %d (max %d) bytes\n",
+ iCur, iHiwtr);
+ iHiwtr = iCur = -1;
+ sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
+ fprintf(out, "Number of Outstanding Allocations: %d (max %d)\n",
+ iCur, iHiwtr);
+ iHiwtr = iCur = -1;
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
+ fprintf(out,
+ "Number of Pcache Pages Used: %d (max %d) pages\n",
+ iCur, iHiwtr);
+ iHiwtr = iCur = -1;
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
+ fprintf(out,
+ "Number of Pcache Overflow Bytes: %d (max %d) bytes\n",
+ iCur, iHiwtr);
+ iHiwtr = iCur = -1;
+ sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
+ fprintf(out, "Largest Allocation: %d bytes\n",
+ iHiwtr);
+ iHiwtr = iCur = -1;
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);
+ fprintf(out, "Largest Pcache Allocation: %d bytes\n",
+ iHiwtr);
+
+ iHiwtr = iCur = -1;
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
+ fprintf(out, "Pager Heap Usage: %d bytes\n",
+ iCur);
+ iHiwtr = iCur = -1;
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
+ fprintf(out, "Page cache hits: %d\n", iCur);
+ iHiwtr = iCur = -1;
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
+ fprintf(out, "Page cache misses: %d\n", iCur);
+ iHiwtr = iCur = -1;
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
+ fprintf(out, "Page cache writes: %d\n", iCur);
+ iHiwtr = iCur = -1;
+
+#ifdef __linux__
+ displayLinuxIoStats(out);
+#endif
+
+ return 0;
+}
+
+/* Blob access order */
+#define ORDER_ASC 1
+#define ORDER_DESC 2
+#define ORDER_RANDOM 3
+
+
+/*
+** Run a performance test
+*/
+static int runMain(int argc, char **argv){
+ int eType; /* Is zDb a database or a directory? */
+ char *zDb; /* Database or directory name */
+ int i; /* Loop counter */
+ int rc; /* Return code from SQLite calls */
+ int nCount = 1000; /* Number of blob fetch operations */
+ int nExtra = 0; /* Extra cycles */
+ int iKey = 1; /* Next blob key */
+ int iMax = 0; /* Largest allowed key */
+ int iPagesize = 0; /* Database page size */
+ int iCache = 1000; /* Database cache size in kibibytes */
+ int bBlobApi = 0; /* Use the incremental blob I/O API */
+ int bStats = 0; /* Print stats before exiting */
+ int eOrder = ORDER_ASC; /* Access order */
+ int isUpdateTest = 0; /* Do in-place updates rather than reads */
+ int doIntegrityCk = 0; /* Run PRAGMA integrity_check after the test */
+ int noSync = 0; /* Disable synchronous mode */
+ int doFsync = 0; /* Update disk files synchronously */
+ int doMultiTrans = 0; /* Each operation in its own transaction */
+ int noCheckpoint = 0; /* Omit the checkpoint in WAL mode */
+ sqlite3 *db = 0; /* Database connection */
+ sqlite3_stmt *pStmt = 0; /* Prepared statement for SQL access */
+ sqlite3_blob *pBlob = 0; /* Handle for incremental Blob I/O */
+ sqlite3_int64 tmStart; /* Start time */
+ sqlite3_int64 tmElapsed; /* Elapsed time */
+ int mmapSize = 0; /* --mmap N argument */
+ sqlite3_int64 nData = 0; /* Bytes of data */
+ sqlite3_int64 nTotal = 0; /* Total data read */
+ unsigned char *pData = 0; /* Content of the blob */
+ sqlite3_int64 nAlloc = 0; /* Space allocated for pData[] */
+ const char *zJMode = 0; /* Journal mode */
+
+
+ assert( strcmp(argv[1],"run")==0 );
+ assert( argc>=3 );
+ zDb = argv[2];
+ eType = pathType(zDb);
+ if( eType==PATH_OTHER ) fatalError("unknown object type: \"%s\"", zDb);
+ if( eType==PATH_NEXIST ) fatalError("object does not exist: \"%s\"", zDb);
+ for(i=3; i<argc; i++){
+ char *z = argv[i];
+ if( z[0]!='-' ) fatalError("unknown argument: \"%s\"", z);
+ if( z[1]=='-' ) z++;
+ if( strcmp(z, "-asc")==0 ){
+ eOrder = ORDER_ASC;
+ continue;
+ }
+ if( strcmp(z, "-blob-api")==0 ){
+ bBlobApi = 1;
+ continue;
+ }
+ if( strcmp(z, "-cache-size")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ iCache = integerValue(argv[++i]);
+ continue;
+ }
+ if( strcmp(z, "-count")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ nCount = integerValue(argv[++i]);
+ if( nCount<1 ) fatalError("the --count must be positive");
+ continue;
+ }
+ if( strcmp(z, "-desc")==0 ){
+ eOrder = ORDER_DESC;
+ continue;
+ }
+ if( strcmp(z, "-fsync")==0 ){
+ doFsync = 1;
+ continue;
+ }
+ if( strcmp(z, "-integrity-check")==0 ){
+ doIntegrityCk = 1;
+ continue;
+ }
+ if( strcmp(z, "-jmode")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ zJMode = argv[++i];
+ continue;
+ }
+ if( strcmp(z, "-mmap")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ mmapSize = integerValue(argv[++i]);
+ if( nCount<0 ) fatalError("the --mmap must be non-negative");
+ continue;
+ }
+ if( strcmp(z, "-max-id")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ iMax = integerValue(argv[++i]);
+ continue;
+ }
+ if( strcmp(z, "-multitrans")==0 ){
+ doMultiTrans = 1;
+ continue;
+ }
+ if( strcmp(z, "-nocheckpoint")==0 ){
+ noCheckpoint = 1;
+ continue;
+ }
+ if( strcmp(z, "-nosync")==0 ){
+ noSync = 1;
+ continue;
+ }
+ if( strcmp(z, "-random")==0 ){
+ eOrder = ORDER_RANDOM;
+ continue;
+ }
+ if( strcmp(z, "-start")==0 ){
+ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]);
+ iKey = integerValue(argv[++i]);
+ if( iKey<1 ) fatalError("the --start must be positive");
+ continue;
+ }
+ if( strcmp(z, "-stats")==0 ){
+ bStats = 1;
+ continue;
+ }
+ if( strcmp(z, "-update")==0 ){
+ isUpdateTest = 1;
+ continue;
+ }
+ fatalError("unknown option: \"%s\"", argv[i]);
+ }
+ if( eType==PATH_DB ){
+ /* Recover any prior crashes prior to starting the timer */
+ sqlite3_open(zDb, &db);
+ sqlite3_exec(db, "SELECT rowid FROM sqlite_schema LIMIT 1", 0, 0, 0);
+ sqlite3_close(db);
+ db = 0;
+ }
+ tmStart = timeOfDay();
+ if( eType==PATH_DB ){
+ char *zSql;
+ rc = sqlite3_open(zDb, &db);
+ if( rc ){
+ fatalError("cannot open database \"%s\": %s", zDb, sqlite3_errmsg(db));
+ }
+ zSql = sqlite3_mprintf("PRAGMA mmap_size=%d", mmapSize);
+ sqlite3_exec(db, zSql, 0, 0, 0);
+ sqlite3_free(zSql);
+ zSql = sqlite3_mprintf("PRAGMA cache_size=%d", iCache);
+ sqlite3_exec(db, zSql, 0, 0, 0);
+ sqlite3_free(zSql);
+ if( noSync ){
+ sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0);
+ }
+ pStmt = 0;
+ sqlite3_prepare_v2(db, "PRAGMA page_size", -1, &pStmt, 0);
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ iPagesize = sqlite3_column_int(pStmt, 0);
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_prepare_v2(db, "PRAGMA cache_size", -1, &pStmt, 0);
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ iCache = sqlite3_column_int(pStmt, 0);
+ }else{
+ iCache = 0;
+ }
+ sqlite3_finalize(pStmt);
+ pStmt = 0;
+ if( zJMode ){
+ zSql = sqlite3_mprintf("PRAGMA journal_mode=%Q", zJMode);
+ sqlite3_exec(db, zSql, 0, 0, 0);
+ sqlite3_free(zSql);
+ if( noCheckpoint ){
+ sqlite3_exec(db, "PRAGMA wal_autocheckpoint=0", 0, 0, 0);
+ }
+ }
+ sqlite3_prepare_v2(db, "PRAGMA journal_mode", -1, &pStmt, 0);
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ zJMode = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
+ }else{
+ zJMode = "???";
+ }
+ sqlite3_finalize(pStmt);
+ if( iMax<=0 ){
+ sqlite3_prepare_v2(db, "SELECT max(k) FROM kv", -1, &pStmt, 0);
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ iMax = sqlite3_column_int(pStmt, 0);
+ }
+ sqlite3_finalize(pStmt);
+ }
+ pStmt = 0;
+ if( !doMultiTrans ) sqlite3_exec(db, "BEGIN", 0, 0, 0);
+ }
+ if( iMax<=0 ) iMax = 1000;
+ for(i=0; i<nCount; i++){
+ if( eType==PATH_DIR || eType==PATH_TREE ){
+ /* CASE 1: Reading or writing blobs out of separate files */
+ char *zKey;
+ if( eType==PATH_DIR ){
+ zKey = sqlite3_mprintf("%s/%06d", zDb, iKey);
+ }else{
+ zKey = sqlite3_mprintf("%s/%02d/%02d/%02d", zDb, iKey/10000,
+ (iKey/100)%100, iKey%100);
+ }
+ nData = 0;
+ if( isUpdateTest ){
+ updateFile(zKey, &nData, doFsync);
+ }else{
+ pData = readFile(zKey, &nData);
+ sqlite3_free(pData);
+ }
+ sqlite3_free(zKey);
+ }else if( bBlobApi ){
+ /* CASE 2: Reading from database using the incremental BLOB I/O API */
+ if( pBlob==0 ){
+ rc = sqlite3_blob_open(db, "main", "kv", "v", iKey,
+ isUpdateTest, &pBlob);
+ if( rc ){
+ fatalError("could not open sqlite3_blob handle: %s",
+ sqlite3_errmsg(db));
+ }
+ }else{
+ rc = sqlite3_blob_reopen(pBlob, iKey);
+ }
+ if( rc==SQLITE_OK ){
+ nData = sqlite3_blob_bytes(pBlob);
+ if( nAlloc<nData+1 ){
+ nAlloc = nData+100;
+ pData = sqlite3_realloc64(pData, nAlloc);
+ }
+ if( pData==0 ) fatalError("cannot allocate %d bytes", nData+1);
+ if( isUpdateTest ){
+ sqlite3_randomness((int)nData, pData);
+ rc = sqlite3_blob_write(pBlob, pData, (int)nData, 0);
+ if( rc!=SQLITE_OK ){
+ fatalError("could not write the blob at %d: %s", iKey,
+ sqlite3_errmsg(db));
+ }
+ }else{
+ rc = sqlite3_blob_read(pBlob, pData, (int)nData, 0);
+ if( rc!=SQLITE_OK ){
+ fatalError("could not read the blob at %d: %s", iKey,
+ sqlite3_errmsg(db));
+ }
+ }
+ }
+ }else{
+ /* CASE 3: Reading from database using SQL */
+ if( pStmt==0 ){
+ if( isUpdateTest ){
+ sqlite3_create_function(db, "remember", 2, SQLITE_UTF8, 0,
+ rememberFunc, 0, 0);
+
+ rc = sqlite3_prepare_v2(db,
+ "UPDATE kv SET v=randomblob(remember(length(v),?2))"
+ " WHERE k=?1", -1, &pStmt, 0);
+ sqlite3_bind_int64(pStmt, 2, SQLITE_PTR_TO_INT(&nData));
+ }else{
+ rc = sqlite3_prepare_v2(db,
+ "SELECT v FROM kv WHERE k=?1", -1, &pStmt, 0);
+ }
+ if( rc ){
+ fatalError("cannot prepare query: %s", sqlite3_errmsg(db));
+ }
+ }else{
+ sqlite3_reset(pStmt);
+ }
+ sqlite3_bind_int(pStmt, 1, iKey);
+ nData = 0;
+ rc = sqlite3_step(pStmt);
+ if( rc==SQLITE_ROW ){
+ nData = sqlite3_column_bytes(pStmt, 0);
+ pData = (unsigned char*)sqlite3_column_blob(pStmt, 0);
+ }
+ }
+ if( eOrder==ORDER_ASC ){
+ iKey++;
+ if( iKey>iMax ) iKey = 1;
+ }else if( eOrder==ORDER_DESC ){
+ iKey--;
+ if( iKey<=0 ) iKey = iMax;
+ }else{
+ iKey = (randInt()%iMax)+1;
+ }
+ nTotal += nData;
+ if( nData==0 ){ nCount++; nExtra++; }
+ }
+ if( nAlloc ) sqlite3_free(pData);
+ if( pStmt ) sqlite3_finalize(pStmt);
+ if( pBlob ) sqlite3_blob_close(pBlob);
+ if( bStats ){
+ display_stats(db, 0);
+ }
+ if( db ){
+ if( !doMultiTrans ) sqlite3_exec(db, "COMMIT", 0, 0, 0);
+ if( !noCheckpoint ){
+ sqlite3_close(db);
+ db = 0;
+ }
+ }
+ tmElapsed = timeOfDay() - tmStart;
+ if( db && noCheckpoint ){
+ sqlite3_close(db);
+ db = 0;
+ }
+ if( nExtra ){
+ printf("%d cycles due to %d misses\n", nCount, nExtra);
+ }
+ if( eType==PATH_DB ){
+ printf("SQLite version: %s\n", sqlite3_libversion());
+ if( doIntegrityCk ){
+ sqlite3_open(zDb, &db);
+ sqlite3_prepare_v2(db, "PRAGMA integrity_check", -1, &pStmt, 0);
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("integrity-check: %s\n", sqlite3_column_text(pStmt, 0));
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_close(db);
+ db = 0;
+ }
+ }
+ printf("--count %d --max-id %d", nCount-nExtra, iMax);
+ switch( eOrder ){
+ case ORDER_RANDOM: printf(" --random\n"); break;
+ case ORDER_DESC: printf(" --desc\n"); break;
+ default: printf(" --asc\n"); break;
+ }
+ if( eType==PATH_DB ){
+ printf("--cache-size %d --jmode %s\n", iCache, zJMode);
+ printf("--mmap %d%s\n", mmapSize, bBlobApi ? " --blob-api" : "");
+ if( noSync ) printf("--nosync\n");
+ }
+ if( iPagesize ) printf("Database page size: %d\n", iPagesize);
+ printf("Total elapsed time: %.3f\n", tmElapsed/1000.0);
+ if( isUpdateTest ){
+ printf("Microseconds per BLOB write: %.3f\n", tmElapsed*1000.0/nCount);
+ printf("Content write rate: %.1f MB/s\n", nTotal/(1000.0*tmElapsed));
+ }else{
+ printf("Microseconds per BLOB read: %.3f\n", tmElapsed*1000.0/nCount);
+ printf("Content read rate: %.1f MB/s\n", nTotal/(1000.0*tmElapsed));
+ }
+ return 0;
+}
+
+
+int main(int argc, char **argv){
+ if( argc<3 ) showHelp();
+ if( strcmp(argv[1],"init")==0 ){
+ return initMain(argc, argv);
+ }
+ if( strcmp(argv[1],"export")==0 ){
+ return exportMain(argc, argv);
+ }
+ if( strcmp(argv[1],"run")==0 ){
+ return runMain(argc, argv);
+ }
+ if( strcmp(argv[1],"stat")==0 ){
+ return statMain(argc, argv);
+ }
+ showHelp();
+ return 0;
+}
diff --git a/test/lastinsert.test b/test/lastinsert.test
new file mode 100644
index 0000000..c5bc267
--- /dev/null
+++ b/test/lastinsert.test
@@ -0,0 +1,377 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you 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}
+
+# EVIDENCE-OF: R-47220-63683 The sqlite3_last_insert_rowid() function
+# does not work for WITHOUT ROWID tables.
+#
+do_test lastinsert-1.1w {
+ catchsql {
+ create table t1w (k integer primary key) WITHOUT ROWID;
+ insert into t1w values (123456);
+ select last_insert_rowid(); -- returns 3 from above.
+ }
+} {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/lemon-test01.y b/test/lemon-test01.y
new file mode 100644
index 0000000..0fd514f
--- /dev/null
+++ b/test/lemon-test01.y
@@ -0,0 +1,75 @@
+// A test case for the LEMON parser generator. Run as follows:
+//
+// lemon lemon-test01.y && gcc -g lemon-test01.c && ./a.out
+//
+%token_prefix TK_
+%token_type int
+%default_type int
+%include {
+ static int nSyntaxError = 0;
+ static int nAccept = 0;
+ static int nFailure = 0;
+}
+
+all ::= A B.
+all ::= error B.
+
+%syntax_error {
+ nSyntaxError++;
+}
+%parse_accept {
+ nAccept++;
+}
+%parse_failure {
+ nFailure++;
+}
+%code {
+ #include <assert.h>
+ #include "lemon-test01.h"
+ static int nTest = 0;
+ static int nErr = 0;
+ static int testCase(int testId, int shouldBe, int actual){
+ nTest++;
+ if( shouldBe==actual ){
+ printf("test %d: ok\n", testId);
+ }else{
+ printf("test %d: got %d, expected %d\n", testId, actual, shouldBe);
+ nErr++;
+ }
+ }
+ int main(int argc, char **argv){
+ yyParser xp;
+ ParseInit(&xp);
+ Parse(&xp, TK_A, 0);
+ Parse(&xp, TK_B, 0);
+ Parse(&xp, 0, 0);
+ ParseFinalize(&xp);
+ testCase(100, 0, nSyntaxError);
+ testCase(110, 1, nAccept);
+ testCase(120, 0, nFailure);
+ nSyntaxError = nAccept = nFailure = 0;
+ ParseInit(&xp);
+ Parse(&xp, TK_B, 0);
+ Parse(&xp, TK_B, 0);
+ Parse(&xp, 0, 0);
+ ParseFinalize(&xp);
+ testCase(200, 1, nSyntaxError);
+ testCase(210, 1, nAccept);
+ testCase(220, 0, nFailure);
+ nSyntaxError = nAccept = nFailure = 0;
+ ParseInit(&xp);
+ Parse(&xp, TK_A, 0);
+ Parse(&xp, TK_A, 0);
+ Parse(&xp, 0, 0);
+ ParseFinalize(&xp);
+ testCase(200, 1, nSyntaxError);
+ testCase(210, 0, nAccept);
+ testCase(220, 0, nFailure);
+ if( nErr==0 ){
+ printf("%d tests pass\n", nTest);
+ }else{
+ printf("%d errors out %d tests\n", nErr, nTest);
+ }
+ return nErr;
+ }
+}
diff --git a/test/like.test b/test/like.test
new file mode 100644
index 0000000..e8662dc
--- /dev/null
+++ b/test/like.test
@@ -0,0 +1,1143 @@
+# 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
+set testprefix like
+
+# 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 names of the table and index used.
+#
+proc queryplan {sql} {
+ set ::sqlite_sort_count 0
+ db cache flush
+ set data [execsql $sql]
+ if {$::sqlite_sort_count} {set x sort} {set x nosort}
+ lappend data $x
+ set eqp [execsql "EXPLAIN QUERY PLAN $sql"]
+ # puts eqp=$eqp
+ foreach {a b c x} $eqp {
+ if {[regexp {(SCAN|SEARCH) (\w+ AS )?(\w+) USING COVERING INDEX (\w+)\y} \
+ $x all ss as tab idx]} {
+ lappend data {} $idx
+ } elseif {[regexp {(SCAN|SEARCH) (\w+ AS )?(\w+) USING.* INDEX (\w+)\y} \
+ $x all ss as tab idx]} {
+ lappend data $tab $idx
+ } elseif {[regexp {(SCAN|SEARCH) (\w+ AS )?(\w+)\y} $x all ss as tab]} {
+ lappend data $tab *
+ }
+ }
+ return $data
+}
+
+# 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.100 {
+ 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.3.100.cnt {
+ set sqlite_like_count
+} 0
+
+# The like optimization works even when the pattern is a bound parameter
+#
+# Exception: It does not work if sqlite3_prepare() is used instead of
+# sqlite3_prepare_v2(), as in that case the statement cannot be reprepared
+# after the parameter is bound.
+#
+unset -nocomplain ::likepat
+set ::likepat abc%
+if {[permutation]!="prepare"} {
+ do_test like-3.3.102 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE $::likepat ORDER BY 1;
+ }
+ } {abc abcd nosort {} i1}
+ do_test like-3.3.103 {
+ set sqlite_like_count
+ } 0
+}
+
+# Except, the like optimization does not work for bound parameters if
+# the query planner stability guarantee is active.
+#
+do_test like-3.3.104 {
+ set sqlite_like_count 0
+ sqlite3_db_config db QPSG 1
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE $::likepat ORDER BY 1;
+ }
+} {abc abcd nosort {} i1}
+do_test like-3.3.105 {
+ set sqlite_like_count
+} 12
+
+# The query planner stability guarantee does not disrupt explicit patterns
+#
+do_test like-3.3.105 {
+ set sqlite_like_count 0
+ queryplan {
+ SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
+ }
+} {abc abcd nosort {} i1}
+do_test like-3.3.106 {
+ set sqlite_like_count
+} 0
+sqlite3_db_config db QPSG 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
+ db eval {PRAGMA case_sensitive_like=off;}
+ queryplan {
+ 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
+ db eval {
+ PRAGMA case_sensitive_like=on;
+ DROP INDEX i1;
+ }
+ queryplan {
+ 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
+ db eval {PRAGMA case_sensitive_like=on;}
+ queryplan {
+ 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
+ db eval {PRAGMA case_sensitive_like=off;}
+ queryplan {
+ 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 ORDER BY rowid;
+ 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 {SCAN t2} $res
+ } {1}
+ }
+ 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}
+ ifcapable like_match_blobs {
+ do_test like-10.5a {
+ count {
+ SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY +a;
+ }
+ } {12 123 scan 4 like 0}
+ } else {
+ do_test like-10.5b {
+ 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}
+ ifcapable like_match_blobs {
+ do_test like-10.14 {
+ count {
+ SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY +a;
+ }
+ } {12 123 scan 4 like 0}
+ } else {
+ 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 {
+ db eval {PRAGMA case_sensitive_like=OFF;}
+ queryplan {
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
+ }
+} {abc abcd ABC ABCD nosort t11 *}
+do_test like-11.2 {
+ db eval {PRAGMA case_sensitive_like=ON;}
+ queryplan {
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
+ }
+} {abc abcd nosort t11 *}
+do_test like-11.3 {
+ db eval {
+ PRAGMA case_sensitive_like=OFF;
+ CREATE INDEX t11b ON t11(b);
+ }
+ queryplan {
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
+ }
+} {abc abcd ABC ABCD sort {} t11b}
+do_test like-11.4 {
+ db eval {PRAGMA case_sensitive_like=ON;}
+ queryplan {
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
+ }
+} {abc abcd nosort t11 *}
+do_test like-11.5 {
+ db eval {
+ PRAGMA case_sensitive_like=OFF;
+ DROP INDEX t11b;
+ CREATE INDEX t11bnc ON t11(b COLLATE nocase);
+ }
+ queryplan {
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
+ }
+} {abc abcd ABC ABCD sort {} t11bnc}
+do_test like-11.6 {
+ db eval {CREATE INDEX t11bb ON t11(b COLLATE binary);}
+ queryplan {
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
+ }
+} {abc abcd ABC ABCD sort {} t11bnc}
+do_test like-11.7 {
+ db eval {PRAGMA case_sensitive_like=ON;}
+ queryplan {
+ SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
+ }
+} {abc abcd sort {} t11bb}
+do_test like-11.8 {
+ db eval {PRAGMA case_sensitive_like=OFF;}
+ queryplan {
+ SELECT b FROM t11 WHERE b GLOB 'abc*' ORDER BY +a;
+ }
+} {abc abcd sort {} t11bb}
+do_test like-11.9 {
+ db eval {
+ CREATE INDEX t11cnc ON t11(c COLLATE nocase);
+ CREATE INDEX t11cb ON t11(c COLLATE binary);
+ }
+ queryplan {
+ 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}
+
+# A COLLATE clause on the pattern does not change the result of a
+# LIKE operator.
+#
+do_execsql_test like-12.1 {
+ CREATE TABLE t12nc(id INTEGER, x TEXT UNIQUE COLLATE nocase);
+ INSERT INTO t12nc VALUES(1,'abcde'),(2,'uvwxy'),(3,'ABCDEF');
+ CREATE TABLE t12b(id INTEGER, x TEXT UNIQUE COLLATE binary);
+ INSERT INTO t12b VALUES(1,'abcde'),(2,'uvwxy'),(3,'ABCDEF');
+ SELECT id FROM t12nc WHERE x LIKE 'abc%' ORDER BY +id;
+} {1 3}
+do_execsql_test like-12.2 {
+ SELECT id FROM t12b WHERE x LIKE 'abc%' ORDER BY +id;
+} {1 3}
+do_execsql_test like-12.3 {
+ SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;
+} {1 3}
+do_execsql_test like-12.4 {
+ SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;
+} {1 3}
+do_execsql_test like-12.5 {
+ SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;
+} {1 3}
+do_execsql_test like-12.6 {
+ SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;
+} {1 3}
+
+# Adding a COLLATE clause to the pattern of a LIKE operator does nothing
+# to change the suitability of using an index to satisfy that LIKE
+# operator.
+#
+do_execsql_test like-12.11 {
+ EXPLAIN QUERY PLAN
+ SELECT id FROM t12nc WHERE x LIKE 'abc%' ORDER BY +id;
+} {/SEARCH/}
+do_execsql_test like-12.12 {
+ EXPLAIN QUERY PLAN
+ SELECT id FROM t12b WHERE x LIKE 'abc%' ORDER BY +id;
+} {/SCAN/}
+do_execsql_test like-12.13 {
+ EXPLAIN QUERY PLAN
+ SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;
+} {/SEARCH/}
+do_execsql_test like-12.14 {
+ EXPLAIN QUERY PLAN
+ SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;
+} {/SCAN/}
+do_execsql_test like-12.15 {
+ EXPLAIN QUERY PLAN
+ SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;
+} {/SEARCH/}
+do_execsql_test like-12.16 {
+ EXPLAIN QUERY PLAN
+ SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;
+} {/SCAN/}
+
+# Ticket [https://www.sqlite.org/src/tktview/80369eddd5c94d49f7fbbcf5]
+# 2016-01-20
+#
+do_execsql_test like-13.1 {
+ SELECT char(0x304d) LIKE char(0x306d);
+} {0}
+do_execsql_test like-13.2 {
+ SELECT char(0x4d) LIKE char(0x306d);
+} {0}
+do_execsql_test like-13.3 {
+ SELECT char(0x304d) LIKE char(0x6d);
+} {0}
+do_execsql_test like-13.4 {
+ SELECT char(0x4d) LIKE char(0x6d);
+} {1}
+
+# Performance testing for patterns with many wildcards. These LIKE and GLOB
+# patterns were quite slow with SQLite 3.15.2 and earlier.
+#
+do_test like-14.1 {
+ set x [lindex [time {
+ db one {SELECT 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz'GLOB'*a*a*a*a*a*a*a*a*y'}
+ }] 0]
+ set tlimit [expr {1000 * $::sqlite_options(configslower)}]
+ puts -nonewline " ($x ms - want less than $tlimit) "
+ expr {$x<$tlimit}
+} {1}
+ifcapable !icu {
+ do_test like-14.2 {
+ set x [lindex [time {
+ db one {SELECT 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz'LIKE'%a%a%a%a%a%a%a%a%y'}
+ }] 0]
+ set tlimit [expr {1000 * $::sqlite_options(configslower)}]
+ puts -nonewline " ($x ms - want less than $tlimit) "
+ expr {$x<$tlimit}
+ } {1}
+}
+
+ifcapable !icu {
+# As of 2017-07-27 (3.21.0) the LIKE optimization works with ESCAPE as
+# long as the ESCAPE is a single-byte literal.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test like-15.100 {
+ CREATE TABLE t15(x TEXT COLLATE nocase, y, PRIMARY KEY(x));
+ INSERT INTO t15(x,y) VALUES
+ ('abcde',1), ('ab%de',2), ('a_cde',3),
+ ('uvwxy',11),('uvwx%',12),('uvwx_',13),
+ ('_bcde',21),('%bcde',22),
+ ('abcd_',31),('abcd%',32),
+ ('ab%xy',41);
+ SELECT y FROM t15 WHERE x LIKE 'ab/%d%' ESCAPE '/';
+} {2}
+do_execsql_test like-15.101 {
+ EXPLAIN QUERY PLAN
+ SELECT y FROM t15 WHERE x LIKE 'ab/%d%' ESCAPE '/';
+} {/SEARCH/}
+do_execsql_test like-15.102 {
+ EXPLAIN QUERY PLAN
+ SELECT y FROM t15 WHERE x LIKE 'ab/%d%' ESCAPE '//';
+} {/SCAN/}
+do_execsql_test like-15.103 {
+ EXPLAIN QUERY PLAN
+ SELECT y FROM t15 WHERE x LIKE 'ab/%d%' ESCAPE '';
+} {/SCAN/}
+do_execsql_test like-15.110 {
+ SELECT y FROM t15 WHERE x LIKE 'abcdx%%' ESCAPE 'x';
+} {32}
+do_execsql_test like-15.111 {
+ SELECT y FROM t15 WHERE x LIKE 'abx%%' ESCAPE 'x' ORDER BY +y
+} {2 41}
+do_execsql_test like-15.112 {
+ EXPLAIN QUERY PLAN
+ SELECT y FROM t15 WHERE x LIKE 'abx%%' ESCAPE 'x' ORDER BY +y
+} {/SEARCH/}
+do_execsql_test like-15.120 {
+ SELECT y FROM t15 WHERE x LIKE '/%bc%' ESCAPE '/';
+} {22}
+do_execsql_test like-15.121 {
+ EXPLAIN QUERY PLAN
+ SELECT y FROM t15 WHERE x LIKE '/%bc%' ESCAPE '/';
+} {/SEARCH/}
+}
+
+#-------------------------------------------------------------------------
+# Tests for ticket [b1d8c79314].
+#
+reset_db
+do_execsql_test 16.0 {
+ CREATE TABLE t1(a INTEGER COLLATE NOCASE);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1 VALUES(' 1x');
+ INSERT INTO t1 VALUES(' 1-');
+}
+do_execsql_test 16.1 {
+ SELECT * FROM t1 WHERE a LIKE ' 1%';
+} {{ 1x} { 1-}}
+do_execsql_test 16.2 {
+ SELECT * FROM t1 WHERE a LIKE ' 1-';
+} {{ 1-}}
+
+# 2020-03-19
+# The ESCAPE clause on LIKE takes precedence over wildcards
+#
+do_execsql_test 17.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, x TEXT);
+ INSERT INTO t1 VALUES
+ (1,'abcde'),
+ (2,'abc_'),
+ (3,'abc__'),
+ (4,'abc%'),
+ (5,'abc%%');
+ SELECT id FROM t1 WHERE x LIKE 'abc%%' ESCAPE '%';
+} {4}
+do_execsql_test 17.1 {
+ SELECT id FROM t1 WHERE x LIKE 'abc__' ESCAPE '_';
+} {2}
+
+# 2021-02-15 ticket c0aeea67d58ae0fd
+#
+do_execsql_test 17.1 {
+ SELECT 'x' LIKE '%' ESCAPE '_';
+} {1}
+
+
+finish_test
diff --git a/test/like2.test b/test/like2.test
new file mode 100644
index 0000000..2a4474e
--- /dev/null
+++ b/test/like2.test
@@ -0,0 +1,1017 @@
+# 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}
+
+
+do_test like-3.1 {
+ db eval "SELECT '\u01C0' LIKE '%\x80'"
+} {0}
+do_test like-3.2 {
+ db eval "SELECT '\u0080' LIKE '%\x80'"
+} {1}
+
+
+finish_test
diff --git a/test/like3.test b/test/like3.test
new file mode 100644
index 0000000..a93e113
--- /dev/null
+++ b/test/like3.test
@@ -0,0 +1,278 @@
+# 2015-03-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 LIKE and GLOB operators and
+# in particular the optimizations that occur to help those operators
+# run faster and that those optimizations work correctly when there
+# are both strings and blobs being tested.
+#
+# Ticket 05f43be8fdda9fbd948d374319b99b054140bc36 shows that the following
+# SQL was not working correctly:
+#
+# CREATE TABLE t1(x TEXT UNIQUE COLLATE nocase);
+# INSERT INTO t1(x) VALUES(x'616263');
+# SELECT 'query-1', x FROM t1 WHERE x LIKE 'a%';
+# SELECT 'query-2', x FROM t1 WHERE +x LIKE 'a%';
+#
+# This script verifies that it works right now.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !like_match_blobs {
+ finish_test
+ return
+}
+
+do_execsql_test like3-1.1 {
+ PRAGMA encoding=UTF8;
+ CREATE TABLE t1(a,b TEXT COLLATE nocase);
+ INSERT INTO t1(a,b)
+ VALUES(1,'abc'),
+ (2,'ABX'),
+ (3,'BCD'),
+ (4,x'616263'),
+ (5,x'414258'),
+ (6,x'424344');
+ CREATE INDEX t1ba ON t1(b,a);
+
+ SELECT a, b FROM t1 WHERE b LIKE 'aB%' ORDER BY +a;
+} {1 abc 2 ABX 4 abc 5 ABX}
+do_execsql_test like3-1.2 {
+ SELECT a, b FROM t1 WHERE +b LIKE 'aB%' ORDER BY +a;
+} {1 abc 2 ABX 4 abc 5 ABX}
+
+do_execsql_test like3-2.0 {
+ CREATE TABLE t2(a, b TEXT);
+ INSERT INTO t2 SELECT a, b FROM t1;
+ CREATE INDEX t2ba ON t2(b,a);
+ SELECT a, b FROM t2 WHERE b GLOB 'ab*' ORDER BY +a;
+} {1 abc 4 abc}
+do_execsql_test like3-2.1 {
+ SELECT a, b FROM t2 WHERE +b GLOB 'ab*' ORDER BY +a;
+} {1 abc 4 abc}
+do_execsql_test like3-2.2 {
+ SELECT a, b FROM t2 WHERE b>=x'6162' AND b GLOB 'ab*'
+} {4 abc}
+do_execsql_test like3-2.3 {
+ SELECT a, b FROM t2 WHERE +b>=x'6162' AND +b GLOB 'ab*'
+} {4 abc}
+do_execsql_test like3-2.4 {
+ SELECT a, b FROM t2 WHERE b GLOB 'ab*' AND b>=x'6162'
+} {4 abc}
+do_execsql_test like3-2.5 {
+ SELECT a, b FROM t2 WHERE +b GLOB 'ab*' AND +b>=x'6162'
+} {4 abc}
+
+do_execsql_test like3-3.0 {
+ CREATE TABLE t3(x TEXT PRIMARY KEY COLLATE nocase);
+ INSERT INTO t3(x) VALUES('aaa'),('abc'),('abd'),('abe'),('acz');
+ INSERT INTO t3(x) SELECT CAST(x AS blob) FROM t3;
+ SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY x;
+} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}
+do_execsql_test like3-3.1 {
+ SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY x DESC;
+} {X'616265' X'616264' X'616263' 'abe' 'abd' 'abc'}
+do_execsql_test like3-3.1ck {
+ SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY +x DESC;
+} {X'616265' X'616264' X'616263' 'abe' 'abd' 'abc'}
+do_execsql_test like3-3.2 {
+ SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY x ASC;
+} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}
+do_execsql_test like3-3.2ck {
+ SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY +x ASC;
+} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}
+
+do_execsql_test like3-4.0 {
+ CREATE TABLE t4(x TEXT COLLATE nocase);
+ CREATE INDEX t4x ON t4(x DESC);
+ INSERT INTO t4(x) SELECT x FROM t3;
+ SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY x;
+} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}
+do_execsql_test like3-4.1 {
+ SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY x DESC;
+} {X'616265' X'616264' X'616263' 'abe' 'abd' 'abc'}
+do_execsql_test like3-4.1ck {
+ SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY +x DESC;
+} {X'616265' X'616264' X'616263' 'abe' 'abd' 'abc'}
+do_execsql_test like3-4.2 {
+ SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY x ASC;
+} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}
+do_execsql_test like3-4.2ck {
+ SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY +x ASC;
+} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}
+
+# 2018-09-10 ticket https://www.sqlite.org/src/tktview/c94369cae9b561b1f996
+# The like optimization fails for a column with numeric affinity if
+# the pattern '/%' or begins with the escape character.
+#
+do_execsql_test like3-5.100 {
+ CREATE TABLE t5a(x INT UNIQUE COLLATE nocase);
+ INSERT INTO t5a(x) VALUES('/abc'),(123),(-234);
+ SELECT x FROM t5a WHERE x LIKE '/%';
+} {/abc}
+do_eqp_test like3-5.101 {
+ SELECT x FROM t5a WHERE x LIKE '/%';
+} {
+ QUERY PLAN
+ `--SCAN t5a
+}
+do_execsql_test like3-5.110 {
+ SELECT x FROM t5a WHERE x LIKE '/a%';
+} {/abc}
+ifcapable !icu {
+do_eqp_test like3-5.111 {
+ SELECT x FROM t5a WHERE x LIKE '/a%';
+} {
+ QUERY PLAN
+ `--SEARCH t5a USING COVERING INDEX sqlite_autoindex_t5a_1 (x>? AND x<?)
+}
+}
+do_execsql_test like3-5.120 {
+ SELECT x FROM t5a WHERE x LIKE '^12%' ESCAPE '^';
+} {123}
+do_eqp_test like3-5.121 {
+ SELECT x FROM t5a WHERE x LIKE '^12%' ESCAPE '^';
+} {
+ QUERY PLAN
+ `--SCAN t5a
+}
+do_execsql_test like3-5.122 {
+ SELECT x FROM t5a WHERE x LIKE '^-2%' ESCAPE '^';
+} {-234}
+do_eqp_test like3-5.123 {
+ SELECT x FROM t5a WHERE x LIKE '^12%' ESCAPE '^';
+} {
+ QUERY PLAN
+ `--SCAN t5a
+}
+
+do_execsql_test like3-5.200 {
+ CREATE TABLE t5b(x INT UNIQUE COLLATE binary);
+ INSERT INTO t5b(x) VALUES('/abc'),(123),(-234);
+ SELECT x FROM t5b WHERE x GLOB '/*';
+} {/abc}
+do_eqp_test like3-5.201 {
+ SELECT x FROM t5b WHERE x GLOB '/*';
+} {
+ QUERY PLAN
+ `--SCAN t5b
+}
+do_execsql_test like3-5.210 {
+ SELECT x FROM t5b WHERE x GLOB '/a*';
+} {/abc}
+do_eqp_test like3-5.211 {
+ SELECT x FROM t5b WHERE x GLOB '/a*';
+} {
+ QUERY PLAN
+ `--SEARCH t5b USING COVERING INDEX sqlite_autoindex_t5b_1 (x>? AND x<?)
+}
+
+# 2019-05-01
+# another case of the above reported on the mailing list by Manuel Rigger.
+#
+do_execsql_test like3-5.300 {
+ CREATE TABLE t5c (c0 REAL);
+ CREATE INDEX t5c_0 ON t5c(c0 COLLATE NOCASE);
+ INSERT INTO t5c(rowid, c0) VALUES (99,'+/');
+ SELECT * FROM t5c WHERE (c0 LIKE '+/');
+} {+/}
+
+# 2019-05-08
+# Yet another case for the above from Manuel Rigger.
+#
+do_execsql_test like3-5.400 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 INT UNIQUE COLLATE NOCASE);
+ INSERT INTO t0(c0) VALUES ('./');
+ SELECT * FROM t0 WHERE t0.c0 LIKE './';
+} {./}
+
+# 2019-06-14
+# Ticket https://www.sqlite.org/src/info/ce8717f0885af975
+do_execsql_test like3-5.410 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 INT UNIQUE COLLATE NOCASE);
+ INSERT INTO t0(c0) VALUES ('.1%');
+ SELECT * FROM t0 WHERE t0.c0 LIKE '.1%';
+} {.1%}
+
+# 2019-09-03
+# Ticket https://www.sqlite.org/src/info/0f0428096f
+do_execsql_test like3-5.420 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 UNIQUE);
+ INSERT INTO t0(c0) VALUES(-1);
+ SELECT * FROM t0 WHERE t0.c0 GLOB '-*';
+} {-1}
+do_execsql_test like3-5.421 {
+ SELECT t0.c0 GLOB '-*' FROM t0;
+} {1}
+
+
+
+# 2019-02-27
+# Verify that the LIKE optimization works with an ESCAPE clause when
+# using PRAGMA case_sensitive_like=ON.
+#
+ifcapable !icu {
+do_execsql_test like3-6.100 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(path TEXT COLLATE nocase PRIMARY KEY,a,b,c) WITHOUT ROWID;
+}
+do_eqp_test like3-6.110 {
+ SELECT * FROM t1 WHERE path LIKE 'a%';
+} {
+ QUERY PLAN
+ `--SEARCH t1 USING PRIMARY KEY (path>? AND path<?)
+}
+do_eqp_test like3-6.120 {
+ SELECT * FROM t1 WHERE path LIKE 'a%' ESCAPE 'x';
+} {
+ QUERY PLAN
+ `--SEARCH t1 USING PRIMARY KEY (path>? AND path<?)
+}
+do_execsql_test like3-6.200 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(path TEXT,x,y,z);
+ CREATE INDEX t2path ON t2(path COLLATE nocase);
+ CREATE INDEX t2path2 ON t2(path);
+}
+do_eqp_test like3-6.210 {
+ SELECT * FROM t2 WHERE path LIKE 'a%';
+} {
+ QUERY PLAN
+ `--SEARCH t2 USING INDEX t2path (path>? AND path<?)
+}
+do_eqp_test like3-6.220 {
+ SELECT * FROM t2 WHERE path LIKE 'a%' ESCAPE '\';
+} {
+ QUERY PLAN
+ `--SEARCH t2 USING INDEX t2path (path>? AND path<?)
+}
+db eval {PRAGMA case_sensitive_like=ON}
+do_eqp_test like3-6.230 {
+ SELECT * FROM t2 WHERE path LIKE 'a%';
+} {
+ QUERY PLAN
+ `--SEARCH t2 USING INDEX t2path2 (path>? AND path<?)
+}
+do_eqp_test like3-6.240 {
+ SELECT * FROM t2 WHERE path LIKE 'a%' ESCAPE '\';
+} {
+ QUERY PLAN
+ `--SEARCH t2 USING INDEX t2path2 (path>? AND path<?)
+}
+}
+
+finish_test
diff --git a/test/limit.test b/test/limit.test
new file mode 100644
index 0000000..05fbfb7
--- /dev/null
+++ b/test/limit.test
@@ -0,0 +1,668 @@
+# 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
+#
+# EVIDENCE-OF: R-13512-64012 In a compound SELECT, only the last or
+# right-most simple SELECT may contain a LIMIT clause.
+#
+# EVIDENCE-OF: R-03782-50113 In a compound SELECT, the LIMIT clause
+# applies to the entire compound, not just the final SELECT.
+#
+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}}
+
+# Ticket [db4d96798da8b]
+# LIMIT does not work with nested views containing UNION ALL
+#
+do_test limit-13.1 {
+ db eval {
+ CREATE TABLE t13(x);
+ INSERT INTO t13 VALUES(1),(2);
+ CREATE VIEW v13a AS SELECT x AS y FROM t13;
+ CREATE VIEW v13b AS SELECT y AS z FROM v13a UNION ALL SELECT y+10 FROM v13a;
+ CREATE VIEW v13c AS SELECT z FROM v13b UNION ALL SELECT z+20 FROM v13b;
+ }
+} {}
+do_test limit-13.2 {
+ db eval {SELECT z FROM v13c LIMIT 1}
+} {1}
+do_test limit-13.3 {
+ db eval {SELECT z FROM v13c LIMIT 2}
+} {1 2}
+do_test limit-13.4 {
+ db eval {SELECT z FROM v13c LIMIT 3}
+} {1 2 11}
+do_test limit-13.5 {
+ db eval {SELECT z FROM v13c LIMIT 4}
+} {1 2 11 12}
+do_test limit-13.6 {
+ db eval {SELECT z FROM v13c LIMIT 5}
+} {1 2 11 12 21}
+do_test limit-13.7 {
+ db eval {SELECT z FROM v13c LIMIT 6}
+} {1 2 11 12 21 22}
+do_test limit-13.8 {
+ db eval {SELECT z FROM v13c LIMIT 7}
+} {1 2 11 12 21 22 31}
+do_test limit-13.9 {
+ db eval {SELECT z FROM v13c LIMIT 8}
+} {1 2 11 12 21 22 31 32}
+do_test limit-13.10 {
+ db eval {SELECT z FROM v13c LIMIT 9}
+} {1 2 11 12 21 22 31 32}
+do_test limit-13.11 {
+ db eval {SELECT z FROM v13c LIMIT 1 OFFSET 1}
+} {2}
+do_test limit-13.12 {
+ db eval {SELECT z FROM v13c LIMIT 2 OFFSET 1}
+} {2 11}
+do_test limit-13.13 {
+ db eval {SELECT z FROM v13c LIMIT 3 OFFSET 1}
+} {2 11 12}
+do_test limit-13.14 {
+ db eval {SELECT z FROM v13c LIMIT 4 OFFSET 1}
+} {2 11 12 21}
+do_test limit-13.15 {
+ db eval {SELECT z FROM v13c LIMIT 5 OFFSET 1}
+} {2 11 12 21 22}
+do_test limit-13.16 {
+ db eval {SELECT z FROM v13c LIMIT 6 OFFSET 1}
+} {2 11 12 21 22 31}
+do_test limit-13.17 {
+ db eval {SELECT z FROM v13c LIMIT 7 OFFSET 1}
+} {2 11 12 21 22 31 32}
+do_test limit-13.18 {
+ db eval {SELECT z FROM v13c LIMIT 8 OFFSET 1}
+} {2 11 12 21 22 31 32}
+do_test limit-13.21 {
+ db eval {SELECT z FROM v13c LIMIT 1 OFFSET 2}
+} {11}
+do_test limit-13.22 {
+ db eval {SELECT z FROM v13c LIMIT 2 OFFSET 2}
+} {11 12}
+do_test limit-13.23 {
+ db eval {SELECT z FROM v13c LIMIT 3 OFFSET 2}
+} {11 12 21}
+do_test limit-13.24 {
+ db eval {SELECT z FROM v13c LIMIT 4 OFFSET 2}
+} {11 12 21 22}
+do_test limit-13.25 {
+ db eval {SELECT z FROM v13c LIMIT 5 OFFSET 2}
+} {11 12 21 22 31}
+do_test limit-13.26 {
+ db eval {SELECT z FROM v13c LIMIT 6 OFFSET 2}
+} {11 12 21 22 31 32}
+do_test limit-13.27 {
+ db eval {SELECT z FROM v13c LIMIT 7 OFFSET 2}
+} {11 12 21 22 31 32}
+do_test limit-13.31 {
+ db eval {SELECT z FROM v13c LIMIT 1 OFFSET 3}
+} {12}
+do_test limit-13.32 {
+ db eval {SELECT z FROM v13c LIMIT 2 OFFSET 3}
+} {12 21}
+do_test limit-13.33 {
+ db eval {SELECT z FROM v13c LIMIT 3 OFFSET 3}
+} {12 21 22}
+do_test limit-13.34 {
+ db eval {SELECT z FROM v13c LIMIT 4 OFFSET 3}
+} {12 21 22 31}
+do_test limit-13.35 {
+ db eval {SELECT z FROM v13c LIMIT 5 OFFSET 3}
+} {12 21 22 31 32}
+do_test limit-13.36 {
+ db eval {SELECT z FROM v13c LIMIT 6 OFFSET 3}
+} {12 21 22 31 32}
+do_test limit-13.41 {
+ db eval {SELECT z FROM v13c LIMIT 1 OFFSET 4}
+} {21}
+do_test limit-13.42 {
+ db eval {SELECT z FROM v13c LIMIT 2 OFFSET 4}
+} {21 22}
+do_test limit-13.43 {
+ db eval {SELECT z FROM v13c LIMIT 3 OFFSET 4}
+} {21 22 31}
+do_test limit-13.44 {
+ db eval {SELECT z FROM v13c LIMIT 4 OFFSET 4}
+} {21 22 31 32}
+do_test limit-13.45 {
+ db eval {SELECT z FROM v13c LIMIT 5 OFFSET 4}
+} {21 22 31 32}
+do_test limit-13.51 {
+ db eval {SELECT z FROM v13c LIMIT 1 OFFSET 5}
+} {22}
+do_test limit-13.52 {
+ db eval {SELECT z FROM v13c LIMIT 2 OFFSET 5}
+} {22 31}
+do_test limit-13.53 {
+ db eval {SELECT z FROM v13c LIMIT 3 OFFSET 5}
+} {22 31 32}
+do_test limit-13.54 {
+ db eval {SELECT z FROM v13c LIMIT 4 OFFSET 5}
+} {22 31 32}
+do_test limit-13.61 {
+ db eval {SELECT z FROM v13c LIMIT 1 OFFSET 6}
+} {31}
+do_test limit-13.62 {
+ db eval {SELECT z FROM v13c LIMIT 2 OFFSET 6}
+} {31 32}
+do_test limit-13.63 {
+ db eval {SELECT z FROM v13c LIMIT 3 OFFSET 6}
+} {31 32}
+do_test limit-13.71 {
+ db eval {SELECT z FROM v13c LIMIT 1 OFFSET 7}
+} {32}
+do_test limit-13.72 {
+ db eval {SELECT z FROM v13c LIMIT 2 OFFSET 7}
+} {32}
+do_test limit-13.81 {
+ db eval {SELECT z FROM v13c LIMIT 1 OFFSET 8}
+} {}
+
+do_execsql_test limit-14.1 {
+ SELECT 123 LIMIT 1 OFFSET 0
+} {123}
+do_execsql_test limit-14.2 {
+ SELECT 123 LIMIT 1 OFFSET 1
+} {}
+do_execsql_test limit-14.3 {
+ SELECT 123 LIMIT 0 OFFSET 0
+} {}
+do_execsql_test limit-14.4 {
+ SELECT 123 LIMIT 0 OFFSET 1
+} {}
+do_execsql_test limit-14.6 {
+ SELECT 123 LIMIT -1 OFFSET 0
+} {123}
+do_execsql_test limit-14.7 {
+ SELECT 123 LIMIT -1 OFFSET 1
+} {}
+
+# 2021-03-05 dbsqlfuzz crash-d811039c9f44f2d43199d5889fcf4085ef6221b9
+#
+reset_db
+do_execsql_test limit-15.1 {
+ CREATE TABLE t1(a PRIMARY KEY, b TEXT);
+ CREATE TABLE t4(c PRIMARY KEY, d);
+ CREATE TABLE t5(e PRIMARY KEY, f);
+ CREATE TABLE t6(g, h);
+ CREATE TABLE t3_a(k, v);
+ CREATE TABLE t3_b(k, v);
+ CREATE VIEW t3 AS SELECT * FROM t3_a UNION ALL SELECT * FROM t3_b;
+ INSERT INTO t5(e,f) VALUES(500000,'orange');
+ INSERT INTO t4(c,d) VALUES(300000,'blue'),(400,'green'),(8000,'grey');
+ INSERT INTO t1(a,b) VALUES(300000,'purple');
+ INSERT INTO t3_a VALUES(300000,'yellow'),(500,'pink'),(8000,'red');
+ INSERT INTO t6 default values;
+ SELECT (
+ SELECT 100000 FROM
+ (SELECT 200000 FROM t6 WHERE a = ( SELECT 300000 FROM t3 WHERE a ) ),
+ (SELECT 400000 FROM t5 WHERE e=500000),
+ (SELECT 600000 FROM t4 WHERE c=a)
+ ) FROM t1;
+} {100000}
+
+finish_test
diff --git a/test/limit2.test b/test/limit2.test
new file mode 100644
index 0000000..c03f39c
--- /dev/null
+++ b/test/limit2.test
@@ -0,0 +1,217 @@
+# 2016-05-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 file is testing the LIMIT in combination with ORDER BY
+# and in particular, the optimizations in the inner loop that cause an
+# early exit of the inner loop when the LIMIT is reached and the inner
+# loop is emitting rows in ORDER BY order.
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix limit2
+
+do_execsql_test limit2-100 {
+ CREATE TABLE t1(a,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t1(a,b) SELECT 1, (x*17)%1000 + 1000 FROM c;
+ INSERT INTO t1(a,b) VALUES(2,2),(3,1006),(4,4),(5,9999);
+ CREATE INDEX t1ab ON t1(a,b);
+}
+set sqlite_search_count 0
+do_execsql_test limit2-100.1 {
+ SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY b LIMIT 5;
+} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |}
+set fast_count $sqlite_search_count
+set sqlite_search_count 0
+do_execsql_test limit2-100.2 {
+ SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY +b LIMIT 5;
+} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |}
+do_test limit2-100.3 {
+ set slow_count $sqlite_search_count
+ expr {$fast_count < 0.02*$slow_count}
+} {1}
+
+do_execsql_test limit2-110 {
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2(x,y) VALUES('a',1),('a',2),('a',3),('a',4);
+ INSERT INTO t2(x,y) VALUES('b',1),('c',2),('d',3),('e',4);
+ CREATE INDEX t2xy ON t2(x,y);
+}
+set sqlite_search_count 0
+do_execsql_test limit2-110.1 {
+ SELECT a, b, '|' FROM t2, t1 WHERE t2.x='a' AND t1.a=t2.y ORDER BY t1.b LIMIT 5;
+} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |}
+set fast_count $sqlite_search_count
+set sqlite_search_count 0
+do_execsql_test limit2-110.2 {
+ SELECT a, b, '|' FROM t2, t1 WHERE t2.x='a' AND t1.a=t2.y ORDER BY +t1.b LIMIT 5;
+} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |}
+set slow_count $sqlite_search_count
+do_test limit2-110.3 {
+ expr {$fast_count < 0.02*$slow_count}
+} {1}
+
+do_execsql_test limit2-120 {
+ DROP INDEX t1ab;
+ CREATE INDEX t1ab ON t1(a,b DESC);
+}
+set sqlite_search_count 0
+do_execsql_test limit2-120.1 {
+ SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY b DESC LIMIT 5;
+} {5 9999 | 1 1999 | 1 1998 | 1 1997 | 1 1996 |}
+set fast_count $sqlite_search_count
+set sqlite_search_count 0
+do_execsql_test limit2-120.2 {
+ SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY +b DESC LIMIT 5;
+} {5 9999 | 1 1999 | 1 1998 | 1 1997 | 1 1996 |}
+do_test limit2-120.3 {
+ set slow_count $sqlite_search_count
+ expr {$fast_count < 0.02*$slow_count}
+} {1}
+
+# Bug report against the new ORDER BY LIMIT optimization just prior to
+# release. (Unreleased so there is no ticket).
+#
+# Make sure the optimization is not applied if the inner loop can only
+# provide a single row of output.
+#
+do_execsql_test limit2-200 {
+ CREATE TABLE t200(a, b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t200(a,b) SELECT x, x FROM c;
+ CREATE TABLE t201(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t201(x,y) VALUES(2,12345);
+
+ SELECT *, '|' FROM t200, t201 WHERE x=b ORDER BY y LIMIT 3;
+} {2 2 2 12345 |}
+do_execsql_test limit2-210 {
+ SELECT *, '|' FROM t200 LEFT JOIN t201 ON x=b ORDER BY y LIMIT 3;
+} {1 1 {} {} | 3 3 {} {} | 4 4 {} {} |}
+
+# Bug in the ORDER BY LIMIT optimization reported on 2016-09-06.
+# Ticket https://www.sqlite.org/src/info/559733b09e96
+#
+do_execsql_test limit2-300 {
+ CREATE TABLE t300(a,b,c);
+ CREATE INDEX t300x ON t300(a,b,c);
+ INSERT INTO t300 VALUES(0,1,99),(0,1,0),(0,0,0);
+ SELECT *,'.' FROM t300 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC;
+} {0 1 99 . 0 0 0 . 0 1 0 .}
+do_execsql_test limit2-310 {
+ SELECT *,'.' FROM t300 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC LIMIT 1;
+} {0 1 99 .}
+
+# Make sure the SELECT loop is ordered correctly for the direction of
+# the ORDER BY
+#
+do_execsql_test limit2-400 {
+ CREATE TABLE t400(a,b);
+ CREATE INDEX t400_ab ON t400(a,b);
+ INSERT INTO t400(a,b) VALUES(1,90),(1,40),(2,80),(2,30),(3,70),(3,20);
+ SELECT *,'x' FROM t400 WHERE a IN (1,2,3) ORDER BY b DESC LIMIT 3;
+ SELECT *,'y' FROM t400 WHERE a IN (1,2,3) ORDER BY +b DESC LIMIT 3;
+} {1 90 x 2 80 x 3 70 x 1 90 y 2 80 y 3 70 y}
+
+
+do_execsql_test 500 {
+ CREATE TABLE t500(i INTEGER PRIMARY KEY, j);
+ INSERT INTO t500 VALUES(1, 1);
+ INSERT INTO t500 VALUES(2, 2);
+ INSERT INTO t500 VALUES(3, 3);
+ INSERT INTO t500 VALUES(4, 0);
+ INSERT INTO t500 VALUES(5, 5);
+ SELECT j FROM t500 WHERE i IN (1,2,3,4,5) ORDER BY j DESC LIMIT 3;
+} {5 3 2}
+do_execsql_test 501 {
+ CREATE TABLE t501(i INTEGER PRIMARY KEY, j);
+ INSERT INTO t501 VALUES(1, 5);
+ INSERT INTO t501 VALUES(2, 4);
+ INSERT INTO t501 VALUES(3, 3);
+ INSERT INTO t501 VALUES(4, 6);
+ INSERT INTO t501 VALUES(5, 1);
+ SELECT j FROM t501 WHERE i IN (1,2,3,4,5) ORDER BY j LIMIT 3;
+} {1 3 4}
+do_execsql_test 502 {
+ CREATE TABLE t502(i INT PRIMARY KEY, j);
+ INSERT INTO t502 VALUES(1, 5);
+ INSERT INTO t502 VALUES(2, 4);
+ INSERT INTO t502 VALUES(3, 3);
+ INSERT INTO t502 VALUES(4, 6);
+ INSERT INTO t502 VALUES(5, 1);
+ SELECT j FROM t502 WHERE i IN (1,2,3,4,5) ORDER BY j LIMIT 3;
+} {1 3 4}
+
+# Ticket https://www.sqlite.org/src/info/123c9ba32130a6c9 2017-12-13
+# Incorrect result when an idnex is used for an ordered join.
+#
+# This test case is in the limit2.test module because the problem was first
+# exposed by check-in https://www.sqlite.org/src/info/559733b09e which
+# implemented the ORDER BY LIMIT optimization that limit2.test strives to
+# test.
+#
+do_execsql_test 600 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1,2);
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x, y); INSERT INTO t2 VALUES(1,3);
+ CREATE INDEX t1ab ON t1(a,b);
+ SELECT y FROM t1, t2 WHERE a=x AND b<=y ORDER BY b DESC;
+} {3}
+
+# Ticket https://www.sqlite.org/src/info/9936b2fa443fec03 2018-09-08
+# Infinite loop due to the ORDER BY LIMIT optimization.
+#
+do_execsql_test 700 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(aa VARCHAR PRIMARY KEY NOT NULL,bb,cc,x VARCHAR(400));
+ INSERT INTO t1(aa,bb,cc) VALUES('maroon','meal','lecture');
+ INSERT INTO t1(aa,bb,cc) VALUES('reality','meal','catsear');
+ CREATE TABLE t2(aa VARCHAR PRIMARY KEY, dd INT DEFAULT 1, ee, x VARCHAR(100));
+ INSERT INTO t2(aa,dd,ee) VALUES('maroon',0,'travel'),('reality',0,'hour');
+ CREATE INDEX t2x1 ON t2(dd,ee);
+ ANALYZE;
+ DROP TABLE IF EXISTS sqlite_stat4;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1 VALUES
+ ('t2','t2x1','3 3 3'),
+ ('t2','sqlite_autoindex_t2_1','3 1'),
+ ('t1','sqlite_autoindex_t1_1','2 1');
+ ANALYZE sqlite_master;
+ SELECT *
+ FROM t1 LEFT JOIN t2 ON t1.aa=t2.aa
+ WHERE t1.bb='meal'
+ ORDER BY t2.dd DESC
+ LIMIT 1;
+} {maroon meal lecture {} maroon 0 travel {}}
+do_execsql_test 710 {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(aa, bb);
+ INSERT INTO t1 VALUES('maroon','meal');
+ CREATE TABLE t2(cc, dd, ee, x VARCHAR(100));
+ INSERT INTO t2(cc,dd,ee) VALUES('maroon',1,'one');
+ INSERT INTO t2(cc,dd,ee) VALUES('maroon',2,'two');
+ INSERT INTO t2(cc,dd,ee) VALUES('maroon',0,'zero');
+ CREATE INDEX t2ddee ON t2(dd,ee);
+ CREATE INDEX t2cc ON t2(cc);
+ ANALYZE;
+ SELECT t2.cc, t2.dd, t2.ee FROM t1 CROSS JOIN t2 ON t1.aa=t2.cc
+ ORDER BY t2.dd LIMIT 1;
+} {maroon 0 zero}
+do_execsql_test 720 {
+ SELECT t2.cc, t2.dd, t2.ee FROM t1 CROSS JOIN t2 ON t1.aa=t2.cc
+ WHERE t1.bb='meal'
+ ORDER BY t2.dd LIMIT 1;
+} {maroon 0 zero}
+
+finish_test
diff --git a/test/loadext.test b/test/loadext.test
new file mode 100644
index 0000000..6da8a52
--- /dev/null
+++ b/test/loadext.test
@@ -0,0 +1,299 @@
+# 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"} {
+ 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.*found.*}
+ set dlerror_notadll {dlopen.%1$s, 10.: .*image.*found.*}
+ set dlerror_nosymbol {dlsym.XXX, %2$s.: symbol not found}
+}
+
+if {$::tcl_platform(platform) eq "windows"} {
+ set dlerror_nosuchfile {The specified module could not be found.*}
+ set dlerror_notadll {%%1 is not a valid Win32 application.*}
+ set dlerror_nosymbol {The specified procedure could not be 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. -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_db_config db2 SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 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 "./notasharedlib.so" w]
+ puts $fd blah
+ close $fd
+ set fd [open "./notasharedlib.dll" w]
+ puts $fd blah
+ close $fd
+ set rc [catch {
+ sqlite3_load_extension db "./notasharedlib"
+ } msg]
+ list $rc $msg
+} /[list 1 [format $dlerror_notadll ./notasharedlib.*]]/
+
+# 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_.*_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 {{}}}
+
+# disable all extension loading
+do_test loadext-4.3 {
+ sqlite3_enable_load_extension db 0
+ catchsql {
+ SELECT load_extension($::testextension,'testloadext_init')
+ }
+} {1 {not authorized}}
+
+# enable C-api extension loading only. Show that the SQL function
+# still does not work.
+do_test loadext-4.4 {
+ sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1
+ 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"}
+}
+
+# On Windows, this malloc test must be skipped because the winDlOpen
+# function itself can fail due to "out of memory" conditions.
+#
+if {$::tcl_platform(platform) ne "windows"} {
+ 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..d5b6ea8
--- /dev/null
+++ b/test/loadext2.test
@@ -0,0 +1,168 @@
+# 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}}
+
+# Extensions loaders not currently registered
+#
+do_test loadext2-1.2.1 {
+ sqlite3_cancel_auto_extension_sqr
+} {0}
+do_test loadext2-1.2.2 {
+ sqlite3_cancel_auto_extension_sqr
+} {0}
+do_test loadext2-1.2.3 {
+ sqlite3_cancel_auto_extension_sqr
+} {0}
+
+
+# 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.1 {
+ sqlite3_cancel_auto_extension_sqr
+} {1}
+do_test loadext2-1.7.2 {
+ sqlite3_cancel_auto_extension_sqr
+} {0}
+do_test loadext2-1.7.3 {
+ sqlite3_cancel_auto_extension_cube
+} {1}
+do_test loadext2-1.7.4 {
+ sqlite3_cancel_auto_extension_cube
+} {0}
+do_test loadext2-1.7.5 {
+ 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..534aa3b
--- /dev/null
+++ b/test/lock.test
@@ -0,0 +1,453 @@
+# 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
+#
+# EVIDENCE-OF: R-23579-05241 PRAGMA busy_timeout; PRAGMA busy_timeout =
+# milliseconds; Query or change the setting of the busy timeout.
+#
+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.8b {
+ db2 eval {PRAGMA busy_timeout}
+} {400}
+do_test lock-2.9 {
+ db2 timeout 0
+ execsql COMMIT
+} {}
+do_test lock-2.9b {
+ db2 eval {PRAGMA busy_timeout}
+} {0}
+integrity_check lock-2.10
+do_test lock-2.11 {
+ db2 eval {PRAGMA busy_timeout(400)}
+ execsql BEGIN
+ execsql {UPDATE t1 SET a = 0 WHERE 0}
+ catchsql {BEGIN EXCLUSIVE;} db2
+} {1 {database is locked}}
+do_test lock-2.11b {
+ db2 eval {PRAGMA busy_timeout}
+} {400}
+do_test lock-2.12 {
+ db2 eval {PRAGMA busy_timeout(0)}
+ execsql COMMIT
+} {}
+do_test lock-2.12b {
+ db2 eval {PRAGMA busy_timeout}
+} {0}
+integrity_check lock-2.13
+
+# 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}
+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..58dd206
--- /dev/null
+++ b/test/lock4.test
@@ -0,0 +1,126 @@
+# 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
+
+if {[atomic_batch_write test.db]} {
+ # This test uses two processes, one of which blocks until the other
+ # creates a *-journal file. Which doesn't work if atomic writes are
+ # available.
+ finish_test
+ return
+}
+
+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..99214af
--- /dev/null
+++ b/test/lock5.test
@@ -0,0 +1,196 @@
+# 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 { PRAGMA mmap_size = 0 } db2
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+} {}
+do_test lock5-none.2 {
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+do_test lock5-none.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-none.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..02f2c6c
--- /dev/null
+++ b/test/lock7.test
@@ -0,0 +1,60 @@
+# 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..3e1821b
--- /dev/null
+++ b/test/lock_common.tcl
@@ -0,0 +1,206 @@
+# 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 {tn code} [list 1 {
+ 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 }
+ } 2 {
+ proc code2 {tcl} { uplevel #0 $tcl }
+ proc code3 {tcl} { uplevel #0 $tcl }
+ }] {
+ # Do not run multi-process tests with the unix-excl VFS.
+ #
+ if {$tn==1 && [permutation]=="unix-excl"} continue
+
+ 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 args} {
+
+ if {[llength $args] == 0} {
+ fconfigure $chan -blocking 1
+ 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
+ }
+ return $r
+ } else {
+ set ::tfnb($chan) ""
+ fconfigure $chan -blocking 0 -buffering none
+ puts $chan $cmd
+ puts $chan OVER
+ fileevent $chan readable [list testfixture_script_cb $chan [lindex $args 0]]
+ return ""
+ }
+}
+
+proc testfixture_script_cb {chan script} {
+ if {[eof $chan]} {
+ append ::tfnb($chan) "ERROR: Child process hung up"
+ set line "OVER"
+ } else {
+ set line [gets $chan]
+ }
+
+ if { $line == "OVER" } {
+ uplevel #0 $script [list [lindex $::tfnb($chan) 1]]
+ unset ::tfnb($chan)
+ fileevent $chan readable ""
+ } else {
+ append ::tfnb($chan) $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..e1d91c8
--- /dev/null
+++ b/test/lookaside.test
@@ -0,0 +1,136 @@
+# 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:dbconfig)] && $::G(perm:dbconfig)!=""} {
+ finish_test
+ return
+}
+
+test_set_config_pagecache 0 0
+
+catch {db close}
+sqlite3_shutdown
+sqlite3_initialize
+autoinstall_test_functions
+
+sqlite3 db test.db
+db cache size 4
+
+# 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 {
+ db eval {SELECT 1}
+ 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
+
+test_restore_config_pagecache
+finish_test
diff --git a/test/main.test b/test/main.test
new file mode 100644
index 0000000..13a385b
--- /dev/null
+++ b/test/main.test
@@ -0,0 +1,538 @@
+# 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 {incomplete input}}
+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 {incomplete input}}
+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}}
+ }
+}
+
+# Print the version number so that it can be picked up by releasetest.tcl.
+#
+puts [db one {SELECT 'VERSION: ' ||
+ sqlite_version() || ' ' ||
+ sqlite_source_id();}]
+
+# Do deliberate failures if the TEST_FAILURE environment variable is set.
+# This is done to verify that failure notifications are detected by the
+# releasetest.tcl script, or possibly by other scripts involved in automatic
+# testing.
+#
+if {[info exists ::env(TEST_FAILURE)]} {
+ set res 123
+ if {$::env(TEST_FAILURE)==0} {set res 234}
+ do_test main-99.1 {
+ bad_behavior $::env(TEST_FAILURE)
+ set x 123
+ } $res
+}
+
+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..5e82e80
--- /dev/null
+++ b/test/malloc.test
@@ -0,0 +1,954 @@
+# 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
+set ::testprefix malloc
+
+
+# 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" && [atomic_batch_write test.db]==0} {
+ 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 occurred 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
+}
+
+reset_db
+add_test_utf16bin_collate db
+do_execsql_test 40.1 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES('fghij');
+ INSERT INTO t1 VALUES('pqrst');
+ INSERT INTO t1 VALUES('abcde');
+ INSERT INTO t1 VALUES('uvwxy');
+ INSERT INTO t1 VALUES('klmno');
+}
+do_execsql_test 40.2 {
+ SELECT * FROM t1 ORDER BY 1 COLLATE utf16bin;
+} {abcde fghij klmno pqrst uvwxy}
+do_faultsim_test 40.3 -faults oom-trans* -body {
+ execsql {
+ SELECT * FROM t1 ORDER BY 1 COLLATE utf16bin;
+ }
+} -test {
+ faultsim_test_result {0 {abcde fghij klmno pqrst uvwxy}}
+ faultsim_integrity_check
+}
+
+reset_db
+add_test_utf16bin_collate db
+set big [string repeat x 200]
+do_execsql_test 41.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a COLLATE utf16bin);
+ INSERT INTO t1 VALUES('fghij' || $::big);
+ INSERT INTO t1 VALUES('pqrst' || $::big);
+ INSERT INTO t1 VALUES('abcde' || $::big);
+ INSERT INTO t1 VALUES('uvwxy' || $::big);
+ INSERT INTO t1 VALUES('klmno' || $::big);
+ CREATE INDEX i1 ON t1(a);
+}
+do_faultsim_test 41.2 -faults oom* -body {
+ execsql { SELECT * FROM t1 WHERE a = ('abcde' || $::big)}
+} -test {
+ faultsim_test_result [list 0 "abcde$::big"]
+ faultsim_integrity_check
+}
+
+reset_db
+do_execsql_test 42.0 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);
+ CREATE TABLE t2(a, b);
+ CREATE VIEW a002 AS SELECT *, sum(b) AS m FROM t2 GROUP BY a;
+}
+faultsim_save_and_close
+do_faultsim_test 42 -faults oom-tran* -prep {
+ faultsim_restore_and_reopen
+ execsql { SELECT * FROM sqlite_master }
+} -body {
+ execsql {
+ SELECT t1.z, a002.m
+ FROM t1 JOIN a002 ON t1.y=a002.m
+ WHERE t1.x IN (1,2,3);
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+# 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..b497ab6
--- /dev/null
+++ b/test/malloc3.test
@@ -0,0 +1,703 @@
+# 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
+}
+
+# Do not run these tests if F2FS batch writes are supported. In this case,
+# it is possible for a single DML statement in an implicit transaction
+# to fail with SQLITE_NOMEM, but for the transaction to still end up
+# committed to disk. Which confuses the tests in this module.
+#
+if {[atomic_batch_write test.db]} {
+ puts "Skipping malloc3 tests: atomic-batch support"
+ finish_test
+ return
+}
+
+
+# Do not run these tests with an in-memory journal.
+#
+# In the pager layer, if an IO or OOM error occurs during a ROLLBACK, or
+# when flushing a page to disk due to cache-stress, the pager enters an
+# "error state". The only way out of the error state is to unlock the
+# database file and end the transaction, leaving whatever journal and
+# database files happen to be on disk in place. The next time the current
+# (or any other) connection opens a read transaction, hot-journal rollback
+# is performed if necessary.
+#
+# Of course, this doesn't work with an in-memory journal.
+#
+if {[permutation]=="inmemory_journal"} {
+ 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_sql_id 0
+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 three elements, an id, a boolean
+ # value indicating if the statement may cause transaction rollback when
+ # malloc() fails, and the sql statement itself.
+ set id [incr ::run_test_sql_id]
+ if {$a2 == ""} {
+ lappend ::run_test_script -sql [list $id true [string trim $a1]]
+ } else {
+ lappend ::run_test_script -sql [list $id 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 < 100} {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 2]}
+ -prep {db eval $v2}
+ -debug {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]} {
+ # Fetch the current instruction type and payload.
+ set k [lindex $arglist [expr {2 * $pc}]]
+ set v [lindex $arglist [expr {2 * $pc + 1}]]
+
+ # Id of this iteration:
+ set iterid "pc=$pc.iFail=$iFail$k"
+
+ switch -- $k {
+
+ -test {
+ foreach {id script} $v {}
+ set testid "malloc3-(test $id).$iterid"
+ eval $script
+ incr pc
+ }
+
+ -sql {
+ set ::rollback_hook_count 0
+
+ set id [lindex $v 0]
+ set testid "malloc3-(integrity $id).$iterid"
+
+ set ac [sqlite3_get_autocommit $::DB] ;# Auto-Commit
+ sqlite3_memdebug_fail $iFail -repeat 0
+ set rc [catch {db eval [lindex $v 2]} 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 occurred we assume this was not a
+ # commit - therefore a rollback occurred. Check that the
+ # rollback-hook was invoked.
+ do_test malloc3-rollback_hook_count.$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.
+ #
+ set expr {$nFail!=$nBenign}
+ if {[expr $expr]} {
+ error "Unreported malloc() failure, test \"$testid\", $expr"
+ }
+
+ 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 $testid
+ } elseif {[regexp {.*out of memory} $msg] || [db errorcode] == 3082} {
+ # Out of memory error, as expected.
+ #
+ integrity_check $testid
+ incr iFail
+ if {$nac && !$ac} {
+ if {![lindex $v 1] && [db errorcode] != 3082} {
+ # error "Statement \"[lindex $v 2]\" 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 2]}
+ -prep {set catchupsql $v2}
+ }
+ db eval $catchupsql
+ }
+ }
+ } else {
+ error $msg
+ }
+
+ # back up to the previous "-test" block.
+ 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 off 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..906ac89
--- /dev/null
+++ b/test/malloc5.test
@@ -0,0 +1,421 @@
+# 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
+}
+
+# The sizes of memory allocations from system malloc() might vary,
+# depending on the memory allocator algorithms used. The following
+# routine is designed to support answers that fall within a range
+# of values while also supplying easy-to-understand "expected" values
+# when errors occur.
+#
+proc value_in_range {target x args} {
+ set v [lindex $args 0]
+ if {$v!=""} {
+ if {$v<$target*$x} {return $v}
+ if {$v>$target/$x} {return $v}
+ }
+ return "number between [expr {int($target*$x)}] and [expr {int($target/$x)}]"
+}
+set mrange 0.98 ;# plus or minus 2%
+
+test_set_config_pagecache 0 100
+
+sqlite3_soft_heap_limit 0
+sqlite3 db test.db
+# db eval {PRAGMA cache_size=1}
+
+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 {PRAGMA cache_size=2; 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]
+ value_in_range 1288 0.75
+} [value_in_range 1288 0.75]
+
+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;
+ }
+ value_in_range $::pgalloc $::mrange [sqlite3_release_memory]
+} [value_in_range $::pgalloc $::mrange]
+
+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 }
+ value_in_range $::pgalloc $::mrange [sqlite3_release_memory]
+} [value_in_range $::pgalloc $::mrange]
+
+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;
+ CREATE TABLE def(d, e, f);
+ SELECT * FROM abc;
+ }
+ value_in_range $::pgalloc $::mrange [sqlite3_release_memory 500]
+} [value_in_range $::pgalloc $::mrange]
+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;
+ }
+ value_in_range $::pgalloc $::mrange $nRelease
+} [value_in_range $::pgalloc $::mrange]
+do_test malloc5-2.2.1 {
+ set data
+} {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
+ value_in_range [expr $::pgalloc*2] 0.99 [sqlite3_release_memory]
+} [value_in_range [expr $::pgalloc * 2] 0.99]
+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;}
+ db cache flush
+ 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 {
+ db eval {PRAGMA cache_size=1}
+ db cache flush
+ sqlite3_release_memory
+ sqlite3_soft_heap_limit 200000
+ sqlite3_memory_highwater 1
+ execsql {SELECT * FROM abc}
+ set nMaxBytes [sqlite3_memory_highwater 1]
+ puts -nonewline " (Highwater mark: $nMaxBytes) "
+ expr $nMaxBytes <= 210000
+} {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=2;
+ }
+ 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
+ db2 eval {PRAGMA cache_size=2}
+ 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]
+} {2 2}
+
+do_test malloc5-6.2.1 {
+ execsql {SELECT * FROM abc} db2
+ execsql {SELECT * FROM abc} db
+ expr [nPage db] + [nPage db2]
+} {4}
+
+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]
+} {1}
+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]
+} {0}
+
+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.
+ #
+ # UPDATE: No longer. As release_memory() does not cause a sync()
+ 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]
+} {4}
+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*1132]
+ list [nPage db] [nPage db2]
+} {0 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]
+} {0 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 10500
+ } 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
+test_restore_config_pagecache
+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..ff91d2a
--- /dev/null
+++ b/test/mallocA.test
@@ -0,0 +1,127 @@
+# 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
+set testprefix mallocA
+
+# 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;
+ }
+}
+
+reset_db
+sqlite3_db_config_lookaside db 0 0 0
+do_execsql_test 6-prep {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES('abc', 'w'); -- rowid=1
+ INSERT INTO t1 VALUES('abc', 'x'); -- rowid=2
+ INSERT INTO t1 VALUES('abc', 'y'); -- rowid=3
+ INSERT INTO t1 VALUES('abc', 'z'); -- rowid=4
+
+ INSERT INTO t1 VALUES('def', 'w'); -- rowid=5
+ INSERT INTO t1 VALUES('def', 'x'); -- rowid=6
+ INSERT INTO t1 VALUES('def', 'y'); -- rowid=7
+ INSERT INTO t1 VALUES('def', 'z'); -- rowid=8
+
+ ANALYZE;
+}
+
+do_faultsim_test 6.1 -faults oom* -body {
+ execsql { SELECT rowid FROM t1 WHERE a='abc' AND b='x' }
+} -test {
+ faultsim_test_result [list 0 2]
+}
+do_faultsim_test 6.2 -faults oom* -body {
+ execsql { SELECT rowid FROM t1 WHERE a='abc' AND b<'y' }
+} -test {
+ faultsim_test_result [list 0 {1 2}]
+}
+
+do_execsql_test 7.0 {
+ PRAGMA cache_size = 5;
+}
+do_faultsim_test 7 -faults oom-trans* -prep {
+} -body {
+ execsql {
+ WITH r(x,y) AS (
+ SELECT 1, randomblob(100)
+ UNION ALL
+ SELECT x+1, randomblob(100) FROM r
+ LIMIT 1000
+ )
+ SELECT count(x), length(y) FROM r GROUP BY (x%5)
+ }
+} -test {
+ set res [list 200 100 200 100 200 100 200 100 200 100]
+ faultsim_test_result [list 0 $res]
+}
+
+
+# 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..4f2395d
--- /dev/null
+++ b/test/mallocG.test
@@ -0,0 +1,73 @@
+# 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'
+}
+
+ifcapable !utf16 {
+ finish_test
+ return
+}
+
+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..ee4a603
--- /dev/null
+++ b/test/mallocI.test
@@ -0,0 +1,75 @@
+# 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 }
+
+do_faultsim_test mallocI-5 -faults oom* -prep {
+ catch { db close }
+ sqlite3 db test.db
+ sqlite3_db_config_lookaside db 0 0 0
+} -body {
+ db eval { Select CAST(1 AS blob) }
+} -test {
+ faultsim_test_result {0 1}
+}
+
+
+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..567a4c1
--- /dev/null
+++ b/test/mallocK.test
@@ -0,0 +1,175 @@
+# 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 testprefix mallocK
+
+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);
+ }
+ }
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that OOM errors are correctly handled by the code that uses stat4
+# data to estimate the number of rows visited by a skip-scan range query.
+#
+add_alignment_test_collations db
+do_execsql_test 6.0 {
+ CREATE TABLE t3(a TEXT, b TEXT COLLATE utf16_aligned, c);
+ INSERT INTO t3 VALUES('one', '.....', 0);
+ INSERT INTO t3 VALUES('one', '....x', 1);
+ INSERT INTO t3 VALUES('one', '...x.', 2);
+ INSERT INTO t3 VALUES('one', '...xx', 3);
+ INSERT INTO t3 VALUES('one', '..x..', 4);
+ INSERT INTO t3 VALUES('one', '..x.x', 5);
+ INSERT INTO t3 VALUES('one', '..xx.', 6);
+ INSERT INTO t3 VALUES('one', '..xxx', 7);
+ INSERT INTO t3 VALUES('one', '.x...', 8);
+ INSERT INTO t3 VALUES('one', '.x..x', 9);
+ INSERT INTO t3 VALUES('one', '.x.x.', 10);
+ INSERT INTO t3 VALUES('one', '.x.xx', 11);
+ INSERT INTO t3 VALUES('one', '.xx..', 12);
+ INSERT INTO t3 VALUES('one', '.xx.x', 13);
+ INSERT INTO t3 VALUES('one', '.xxx.', 14);
+ INSERT INTO t3 VALUES('one', '.xxxx', 15);
+
+ INSERT INTO t3 VALUES('two', 'x....', 16);
+ INSERT INTO t3 VALUES('two', 'x...x', 17);
+ INSERT INTO t3 VALUES('two', 'x..x.', 18);
+ INSERT INTO t3 VALUES('two', 'x..xx', 19);
+ INSERT INTO t3 VALUES('two', 'x.x..', 20);
+ INSERT INTO t3 VALUES('two', 'x.x.x', 21);
+ INSERT INTO t3 VALUES('two', 'x.xx.', 22);
+ INSERT INTO t3 VALUES('two', 'x.xxx', 23);
+ INSERT INTO t3 VALUES('two', 'xx...', 24);
+ INSERT INTO t3 VALUES('two', 'xx..x', 25);
+ INSERT INTO t3 VALUES('two', 'xx.x.', 26);
+ INSERT INTO t3 VALUES('two', 'xx.xx', 27);
+ INSERT INTO t3 VALUES('two', 'xxx..', 28);
+ INSERT INTO t3 VALUES('two', 'xxx.x', 29);
+ INSERT INTO t3 VALUES('two', 'xxxx.', 30);
+ INSERT INTO t3 VALUES('two', 'xxxxx', 31);
+
+ INSERT INTO t3 SELECT * FROM t3;
+
+ CREATE INDEX i3 ON t3(a, b);
+ ANALYZE;
+
+ SELECT 'x' > '.';
+} {1}
+
+ifcapable stat4 {
+ do_eqp_test 6.1 {
+ SELECT DISTINCT c FROM t3 WHERE b BETWEEN '.xx..' AND '.xxxx';
+ } [string map {"\n " \n} {
+ QUERY PLAN
+ |--SEARCH t3 USING INDEX i3 (ANY(a) AND b>? AND b<?)
+ `--USE TEMP B-TREE FOR DISTINCT
+ }]
+}
+
+do_faultsim_test 6 -faults oom* -body {
+ db cache flush
+ db eval { SELECT DISTINCT c FROM t3 WHERE b BETWEEN '.xx..' AND '.xxxx' }
+} -test {
+ faultsim_test_result {0 {12 13 14 15}}
+}
+
+do_execsql_test 7.1 {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b);
+}
+do_faultsim_test 7.2 -faults oom* -body {
+ execsql { SELECT * FROM x1 WHERE a = (SELECT 1) }
+} -test {
+ faultsim_test_result [list 0 {}]
+}
+
+reset_db
+
+proc isqrt {i} { expr { int(sqrt($i)) } }
+db func isqrt isqrt
+
+do_execsql_test 8.0 {
+ PRAGMA encoding = 'utf-16';
+ CREATE TABLE x2(x TEXT, y TEXT);
+ WITH data(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM data
+ )
+ INSERT INTO x2 SELECT isqrt(i), isqrt(i) FROM data LIMIT 400;
+ CREATE INDEX x2x ON x2(x);
+ CREATE INDEX x2y ON x2(y);
+ ANALYZE;
+ DELETE FROM x2;
+}
+
+proc str {a} { return $a }
+db func str -deterministic str
+
+do_faultsim_test 8 -faults oom* -body {
+ execsql { SELECT * FROM x2 WHERE x = str('19') AND y = str('4') }
+} -test {
+ faultsim_test_result [list 0 {}]
+}
+
+
+finish_test
diff --git a/test/mallocL.test b/test/mallocL.test
new file mode 100644
index 0000000..5c2a4ec
--- /dev/null
+++ b/test/mallocL.test
@@ -0,0 +1,42 @@
+# 2014 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 test script is designed to show that the assert() fix at
+# [f1cb48f412] really is required.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix mallocL
+
+do_test 1.0 {
+ for {set i 0} {$i < 40} {incr i} {
+ lappend cols "c$i"
+ lappend vals $i
+ }
+
+ execsql "CREATE TABLE t1([join $cols ,])"
+ execsql "CREATE INDEX i1 ON t1([join $cols ,])"
+ execsql "INSERT INTO t1 VALUES([join $vals ,])"
+} {}
+
+for {set j 1} {$j < 40} {incr j} {
+ set ::sql "SELECT DISTINCT [join [lrange $cols 0 $j] ,] FROM t1"
+ do_faultsim_test 1.$j -faults oom* -body {
+ execsql $::sql
+ } -test {
+ faultsim_test_result [list 0 [lrange $::vals 0 $::j]]
+ }
+}
+
+
+finish_test
diff --git a/test/mallocM.test b/test/mallocM.test
new file mode 100644
index 0000000..4da3a9e
--- /dev/null
+++ b/test/mallocM.test
@@ -0,0 +1,48 @@
+# 2017 March 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.
+#
+#***********************************************************************
+# Further OOM tests.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix mallocM
+
+sqlite3_db_config_lookaside db 0 0 0
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x);
+}
+do_faultsim_test 1 -faults oom* -body {
+ execsql {
+ SELECT 'abc' FROM ( SELECT 'xyz' FROM t1 WHERE (SELECT 1) )
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_execsql_test 2.0.1 { SELECT instr(x'', x'') } {1}
+do_execsql_test 2.0.2 { SELECT instr(x'12345678', x'') } {1}
+do_execsql_test 2.0.3 { SELECT instr(x'', x'1234') } {0}
+
+do_faultsim_test 2.1 -faults oom* -body {
+ execsql { SELECT instr (x'00', zeroblob(1)) }
+} -test {
+ faultsim_test_result {0 1}
+}
+
+do_faultsim_test 2.2 -faults oom* -body {
+ execsql { SELECT instr (zeroblob(1), x'00') }
+} -test {
+ faultsim_test_result {0 1}
+}
+
+finish_test
diff --git a/test/malloc_common.tcl b/test/malloc_common.tcl
new file mode 100644
index 0000000..7d3c942
--- /dev/null
+++ b/test/malloc_common.tcl
@@ -0,0 +1,698 @@
+# 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 \
+]
+
+set FAULTSIM(interrupt) [list \
+ -injectinstall interrupt_injectinstall \
+ -injectstart interrupt_injectstart \
+ -injectstop interrupt_injectstop \
+ -injecterrlist {{1 interrupted} {1 interrupt}} \
+ -injectuninstall interrupt_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
+
+ foreach n [array names FAULTSIM] {
+ if {$n != "interrupt"} {lappend DEFAULT(-faults) $n}
+ }
+ set DEFAULT(-prep) ""
+ set DEFAULT(-body) ""
+ set DEFAULT(-test) ""
+ set DEFAULT(-install) ""
+ set DEFAULT(-uninstall) ""
+ set DEFAULT(-start) 1
+ set DEFAULT(-end) 0
+
+ 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) \
+ -start $O(-start) -end $O(-end)
+ ]
+ 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
+}
+
+# The following procs are used as [do_one_faultsim_test] callbacks
+# when injecting SQLITE_INTERRUPT error faults into test cases.
+#
+proc interrupt_injectinstall {} {
+}
+proc interrupt_injectuninstall {} {
+}
+proc interrupt_injectstart {iFail} {
+ set ::sqlite_interrupt_count $iFail
+}
+proc interrupt_injectstop {} {
+ set res [expr $::sqlite_interrupt_count<=0]
+ set ::sqlite_interrupt_count 0
+ set res
+}
+
+# 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 -exact $r $t]<0 } {
+ error "nfail=$testnfail rc=$testrc result=$testresult list=$r"
+ }
+}
+
+#--------------------------------------------------------------------------
+# 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.
+#
+# -start Index of first fault to inject (default 1)
+#
+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) ""
+ set DEFAULT(-start) 1
+ set DEFAULT(-end) 0
+
+ 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 $O(-start)} \
+ {!$stop && ($O(-end)==0 || $iFail<=$O(-end))} \
+ {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
+ catch { set tn $::testprefix-$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 {}}]
+ lappend answers [list 1 {unable to open a temporary database file for storing temporary tables}]
+ 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/malloctraceviewer.tcl b/test/malloctraceviewer.tcl
new file mode 100644
index 0000000..4517fdc
--- /dev/null
+++ b/test/malloctraceviewer.tcl
@@ -0,0 +1,253 @@
+
+package require sqlite3
+package require Tk
+
+#############################################################################
+# Code to set up scrollbars for widgets. This is generic, boring stuff.
+#
+namespace eval autoscroll {
+ proc scrollable {widget path args} {
+ ::ttk::frame $path
+ set w [$widget ${path}.widget {*}$args]
+ set vs [::ttk::scrollbar ${path}.vs]
+ set hs [::ttk::scrollbar ${path}.hs -orient horizontal]
+ grid $w -row 0 -column 0 -sticky nsew
+
+ grid rowconfigure $path 0 -weight 1
+ grid columnconfigure $path 0 -weight 1
+
+ set grid [list grid $vs -row 0 -column 1 -sticky nsew]
+ $w configure -yscrollcommand [list ::autoscroll::scrollcommand $grid $vs]
+ $vs configure -command [list $w yview]
+ set grid [list grid $hs -row 1 -column 0 -sticky nsew]
+ $w configure -xscrollcommand [list ::autoscroll::scrollcommand $grid $hs]
+ $hs configure -command [list $w xview]
+
+ return $w
+ }
+ proc scrollcommand {grid sb args} {
+ $sb set {*}$args
+ set isRequired [expr {[lindex $args 0] != 0.0 || [lindex $args 1] != 1.0}]
+ if {$isRequired && ![winfo ismapped $sb]} {
+ {*}$grid
+ }
+ if {!$isRequired && [winfo ismapped $sb]} {
+ grid forget $sb
+ }
+ }
+ namespace export scrollable
+}
+namespace import ::autoscroll::*
+#############################################################################
+
+proc populate_text_widget {db} {
+ $::O(text) configure -state normal
+ set id [lindex [$::O(tree) selection] 0]
+ set frame [lindex $id end]
+
+ set line [$db one {SELECT line FROM frame WHERE frame = $frame}]
+ if {$line ne ""} {
+ regexp {^([^:]*):([0-9]*)} $line -> file line
+ set content [$db one "SELECT content FROM file WHERE name = '$file'"]
+ $::O(text) delete 0.0 end
+
+ set iLine 1
+ foreach L [split $content "\n"] {
+ if {$iLine == $line} {
+ $::O(text) insert end "$L\n" highlight
+ } else {
+ $::O(text) insert end "$L\n"
+ }
+ incr iLine
+ }
+ $::O(text) yview -pickplace ${line}.0
+ }
+ $::O(text) configure -state disabled
+}
+
+proc populate_index {db} {
+ $::O(text) configure -state normal
+
+ $::O(text) delete 0.0 end
+ $::O(text) insert end "\n\n"
+
+ set L [format " % -40s%12s%12s\n" "Test Case" "Allocations" "Bytes"]
+ $::O(text) insert end $L
+ $::O(text) insert end " [string repeat - 64]\n"
+
+ $db eval {
+ SELECT 'TOTAL' AS ztest, sum(ncall) AS calls, sum(nbyte) AS bytes
+ FROM malloc
+ UNION ALL
+ SELECT ztest AS ztest, sum(ncall) AS calls, sum(nbyte) AS bytes
+ FROM malloc
+ GROUP BY ztest
+
+ ORDER BY 3 DESC
+ } {
+ set tags [list $ztest]
+ if {$ztest eq $::O(current)} {
+ lappend tags highlight
+ }
+ set L [format " % -40s%12s%12s\n" $ztest $calls $bytes]
+ $::O(text) insert end $L $tags
+
+ $::O(text) tag bind $ztest <1> [list populate_tree_widget $db $ztest]
+ $::O(text) tag bind $ztest <Enter> [list $::O(text) configure -cursor hand2]
+ $::O(text) tag bind $ztest <Leave> [list $::O(text) configure -cursor ""]
+ }
+
+ $::O(text) configure -state disabled
+}
+
+proc sort_tree_compare {iLeft iRight} {
+ global O
+ switch -- [expr (int($O(tree_sort)/2))] {
+ 0 {
+ set left [$O(tree) item $iLeft -text]
+ set right [$O(tree) item $iRight -text]
+ set res [string compare $left $right]
+ }
+ 1 {
+ set left [lindex [$O(tree) item $iLeft -values] 0]
+ set right [lindex [$O(tree) item $iRight -values] 0]
+ set res [expr $left - $right]
+ }
+ 2 {
+ set left [lindex [$O(tree) item $iLeft -values] 1]
+ set right [lindex [$O(tree) item $iRight -values] 1]
+ set res [expr $left - $right]
+ }
+ }
+ if {$O(tree_sort)&0x01} {
+ set res [expr -1 * $res]
+ }
+ return $res
+}
+
+proc sort_tree {iMode} {
+ global O
+ if {$O(tree_sort) == $iMode} {
+ incr O(tree_sort)
+ } else {
+ set O(tree_sort) $iMode
+ }
+ set T $O(tree)
+ set items [$T children {}]
+ set items [lsort -command sort_tree_compare $items]
+ for {set ii 0} {$ii < [llength $items]} {incr ii} {
+ $T move [lindex $items $ii] {} $ii
+ }
+}
+
+proc trim_frames {stack} {
+ while {[info exists ::O(ignore.[lindex $stack 0])]} {
+ set stack [lrange $stack 1 end]
+ }
+ return $stack
+}
+
+proc populate_tree_widget {db zTest} {
+ $::O(tree) delete [$::O(tree) children {}]
+
+ for {set ii 0} {$ii < 15} {incr ii} {
+ $db eval {
+ SELECT
+ sum(ncall) AS calls,
+ sum(nbyte) AS bytes,
+ trim_frames(lrange(lstack, 0, $ii)) AS stack
+ FROM malloc
+ WHERE (zTest = $zTest OR $zTest = 'TOTAL') AND llength(lstack)>$ii
+ GROUP BY stack
+ HAVING stack != ''
+ } {
+ set parent_id [lrange $stack 0 end-1]
+ set frame [lindex $stack end]
+ set line [$db one {SELECT line FROM frame WHERE frame = $frame}]
+ set line [lindex [split $line /] end]
+ set v [list $calls $bytes]
+
+ catch {
+ $::O(tree) insert $parent_id end -id $stack -text $line -values $v
+ }
+ }
+ }
+
+ set ::O(current) $zTest
+ populate_index $db
+}
+
+
+
+set O(tree_sort) 0
+
+::ttk::panedwindow .pan -orient horizontal
+set O(tree) [scrollable ::ttk::treeview .pan.tree]
+
+frame .pan.right
+set O(text) [scrollable text .pan.right.text]
+button .pan.right.index -command {populate_index mddb} -text "Show Index"
+pack .pan.right.index -side top -fill x
+pack .pan.right.text -fill both -expand true
+
+$O(text) tag configure highlight -background wheat
+$O(text) configure -wrap none -height 35
+
+.pan add .pan.tree
+.pan add .pan.right
+
+$O(tree) configure -columns {calls bytes}
+$O(tree) heading #0 -text Line -anchor w -command {sort_tree 0}
+$O(tree) heading calls -text Calls -anchor w -command {sort_tree 2}
+$O(tree) heading bytes -text Bytes -anchor w -command {sort_tree 4}
+$O(tree) column #0 -width 150
+$O(tree) column calls -width 100
+$O(tree) column bytes -width 100
+
+pack .pan -fill both -expand 1
+
+#--------------------------------------------------------------------
+# Open the database containing the malloc data. The user specifies the
+# database to use by passing the file-name on the command line.
+#
+proc open_database {} {
+ if {[info exists ::BUILTIN]} {
+ sqlite3 mddb :memory:
+ mddb eval $::BUILTIN
+ wm title . $::argv0
+ } else {
+ set zFilename [lindex $::argv 0]
+ if {$zFilename eq ""} {
+ set zFilename mallocs.sql
+ }
+ set fd [open $zFilename]
+ set zHdr [read $fd 15]
+ if {$zHdr eq "SQLite format 3"} {
+ close $fd
+ sqlite3 mddb $zFilename
+ } else {
+ seek $fd 0
+ sqlite3 mddb :memory:
+ mddb eval [read $fd]
+ close $fd
+ }
+ wm title . $zFilename
+ }
+
+ mddb function lrange -argcount 3 lrange
+ mddb function llength -argcount 1 llength
+ mddb function trim_frames -argcount 1 trim_frames
+
+ mddb eval {
+ SELECT frame FROM frame
+ WHERE line LIKE '%malloc.c:%' OR line LIKE '%mem2.c:%'
+ } {
+ set ::O(ignore.$frame) 1
+ }
+}
+
+open_database
+bind $O(tree) <<TreeviewSelect>> [list populate_text_widget mddb]
+
+populate_tree_widget mddb [mddb one {SELECT zTest FROM malloc LIMIT 1}]
+
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..7bad26f
--- /dev/null
+++ b/test/memdb.test
@@ -0,0 +1,431 @@
+# 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 {UNIQUE constraint failed: t1.a}}
+ 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 {
+ load_static_extension db wholenumber
+ 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 before [db one {PRAGMA page_count}]
+ execsql { DELETE FROM t1 }
+ set after [db one {PRAGMA page_count}]
+ expr {$before>$after}
+ } {1}
+}
+
+} ;# ifcapable memorydb
+
+finish_test
diff --git a/test/memdb1.test b/test/memdb1.test
new file mode 100644
index 0000000..5e219a4
--- /dev/null
+++ b/test/memdb1.test
@@ -0,0 +1,270 @@
+# 2018-01-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 the "memdb" VFS
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix memdb1
+do_not_use_codec
+
+ifcapable !deserialize {
+ finish_test
+ return
+}
+
+# Create a MEMDB and populate it with some dummy data.
+# Then extract the database into the $::db1 variable.
+# Verify that the size of $::db1 is the same as the size of
+# the database.
+#
+unset -nocomplain db1
+unset -nocomplain sz1
+unset -nocomplain pgsz
+do_test 100 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ }
+ set ::pgsz [db one {PRAGMA page_size}]
+ set ::sz1 [expr {$::pgsz*[db one {PRAGMA page_count}]}]
+ set ::db1 [db serialize]
+ expr {[string length $::db1]==$::sz1}
+} 1
+set fd [open db1.db wb]
+puts -nonewline $fd $db1
+close $fd
+
+# Create a new MEMDB and initialize it to the content of $::db1
+# Verify that the content is the same.
+#
+db close
+sqlite3 db
+db deserialize $db1
+do_execsql_test 110 {
+ SELECT * FROM t1;
+} {1 2}
+
+# What happens when we try to VACUUM a MEMDB database?
+#
+do_execsql_test 120 {
+ PRAGMA auto_vacuum = off;
+ VACUUM;
+} {}
+do_execsql_test 130 {
+ CREATE TABLE t2(x, y);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t2(x, y) SELECT x, randomblob(1000) FROM c;
+ DROP TABLE t2;
+ PRAGMA page_count;
+} {116}
+do_execsql_test 140 {
+ VACUUM;
+ PRAGMA page_count;
+} {2}
+
+do_test 150 {
+ catch {db deserialize -unknown 1 $db1} msg
+ set msg
+} {unknown option: -unknown}
+do_test 151 {
+ db deserialize -readonly 1 $db1
+ db eval {SELECT * FROM t1}
+} {1 2}
+do_test 152 {
+ catchsql {INSERT INTO t1 VALUES(3,4);}
+} {1 {attempt to write a readonly database}}
+
+breakpoint
+do_test 160 {
+ db deserialize -maxsize 32768 $db1
+ db eval {SELECT * FROM t1}
+} {1 2}
+do_test 161 {
+ db eval {INSERT INTO t1 VALUES(3,4); SELECT * FROM t1}
+} {1 2 3 4}
+do_test 162 {
+ catchsql {INSERT INTO t1 VALUES(5,randomblob(100000))}
+} {1 {database or disk is full}}
+
+
+# Build a largish on-disk database and serialize it. Verify that the
+# serialization works.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 200 {
+ CREATE TABLE t3(x, y);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<400)
+ INSERT INTO t3(x, y) SELECT x, randomblob(1000) FROM c;
+ PRAGMA quick_check;
+} {ok}
+set fd [open test.db rb]
+unset -nocomplain direct
+set direct [read $fd]
+close $fd
+do_test 210 {
+ string length [db serialize]
+} [string length $direct]
+do_test 220 {
+ db eval {ATTACH ':memory:' AS aux1}
+ db deserialize aux1 $::direct
+ db eval {
+ SELECT x, y FROM main.t3 EXCEPT SELECT x, y FROM aux1.t3;
+ }
+} {}
+unset -nocomplain direct
+
+# Do the same with a :memory: database.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test 300 {
+ CREATE TABLE t3(x, y);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<400)
+ INSERT INTO t3(x, y) SELECT x, randomblob(1000) FROM c;
+ PRAGMA quick_check;
+} {ok}
+do_test 310 {
+ db eval {ATTACH ':memory:' AS aux1}
+ db deserialize aux1 [db serialize main]
+ db eval {
+ SELECT x, y FROM main.t3 EXCEPT SELECT x, y FROM aux1.t3;
+ }
+} {}
+
+# Deserialize an empty database
+#
+db close
+sqlite3 db
+db deserialize {}
+do_execsql_test 400 {
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test 410 {
+ CREATE TABLE t4(a,b);
+ INSERT INTO t4 VALUES('hello','world!');
+ PRAGMA integrity_check;
+ SELECT * FROM t4;
+} {ok hello world!}
+do_execsql_test 420 {
+ PRAGMA journal_mode=TRUNCATE;
+ PRAGMA journal_mode=OFF;
+ PRAGMA journal_mode=DELETE;
+ PRAGMA journal_mode=WAL;
+ PRAGMA journal_mode=PERSIST;
+ PRAGMA journal_mode=MEMORY;
+ PRAGMA journal_mode=OFF;
+ PRAGMA journal_mode=DELETE;
+} {truncate off delete delete persist memory off delete}
+
+# Deserialize something that is not a database.
+#
+db close
+sqlite3 db
+do_test 500 {
+ set rc [catch {db deserialize not-a-database} msg]
+ lappend rc $msg
+} {0 {}}
+do_catchsql_test 510 {
+ PRAGMA integrity_check;
+} {1 {file is not a database}}
+
+# Abuse the serialize and deserialize commands. Make sure errors are caught.
+#
+do_test 600 {
+ set rc [catch {db deserialize} msg]
+ lappend rc $msg
+} {1 {wrong # args: should be "db deserialize ?DATABASE? VALUE"}}
+do_test 610 {
+ set rc [catch {db deserialize a b c} msg]
+ lappend rc $msg
+} {1 {unknown option: a}}
+do_test 620 {
+ set rc [catch {db serialize a b} msg]
+ lappend rc $msg
+} {1 {wrong # args: should be "db serialize ?DATABASE?"}}
+
+# 2021-07-19 https://sqlite.org/forum/forumpost/e1cbb5f450b98aa6
+# The TEMP database cannot participate in serialization or
+# deserialization.
+#
+reset_db
+do_test 650 {
+ db eval {
+ CREATE TEMP TABLE t0(a);
+ CREATE TABLE t1(x);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t1(x) SELECT random() FROM c;
+ }
+ set rc [catch {db deserialize temp [db serialize main]} err]
+ lappend rc err
+} {1 err}
+
+#-------------------------------------------------------------------------
+ifcapable vtab {
+ reset_db
+ do_execsql_test 700 {
+ CREATE TABLE t1(a, b);
+ PRAGMA schema_version = 0;
+ }
+ do_test 710 {
+ set ser [db serialize main]
+ db close
+ sqlite3 db
+ db deserialize main $ser
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING rtree(id, a, b, c, d);
+ }
+ } {1 {table t1 already exists}}
+}
+
+
+#-------------------------------------------------------------------------
+# dbsqlfuzz 0a13dfb474d4f2f11a48a2ea57075c96fb456dd7
+#
+if {[wal_is_capable]} {
+ reset_db
+ do_execsql_test 800 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 8192;
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ CREATE TABLE t2(x, y);
+ } {wal}
+ db close
+
+ set fd [open test.db]
+ fconfigure $fd -translation binary -encoding binary
+ set data [read $fd [expr 20*1024]]
+
+ sqlite3 db ""
+ db deserialize $data
+
+ do_execsql_test 810 {
+ PRAGMA locking_mode = exclusive;
+ SELECT * FROM t1
+ } {exclusive 1 2}
+
+ do_execsql_test 820 {
+ INSERT INTO t1 VALUES(3, 4);
+ SELECT * FROM t1;
+ } {1 2 3 4}
+
+ do_catchsql_test 830 {
+ PRAGMA wal_checkpoint;
+ } {1 {database disk image is malformed}}
+}
+
+finish_test
diff --git a/test/memjournal.test b/test/memjournal.test
new file mode 100644
index 0000000..73f984b
--- /dev/null
+++ b/test/memjournal.test
@@ -0,0 +1,48 @@
+# 2021 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.
+#
+#***********************************************************************
+# Tests focused on the in-memory journal.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix memjournal
+
+
+do_execsql_test 1.0 {
+ PRAGMA journal_mode = memory;
+ CREATE TABLE t1(a);
+} {memory}
+
+set nRow [expr 1]
+
+do_execsql_test 1.1 {
+ BEGIN;
+ INSERT INTO t1 VALUES( randomblob(500) );
+} {}
+
+do_test 1.2 {
+ for {set i 1} {$i <= 500} {incr i} {
+ execsql {
+ SAVEPOINT one;
+ UPDATE t1 SET a=randomblob(500);
+ }
+ execsql { SAVEPOINT abc }
+ execsql { UPDATE t1 SET a=randomblob(500) WHERE rowid<=$i AND 0 }
+ execsql { RELEASE abc }
+ }
+} {}
+
+do_execsql_test 1.3 {
+ COMMIT;
+}
+
+finish_test
diff --git a/test/memjournal2.test b/test/memjournal2.test
new file mode 100644
index 0000000..ec5ba56
--- /dev/null
+++ b/test/memjournal2.test
@@ -0,0 +1,63 @@
+# 2022 Jan 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 focused on the in-memory journal.
+#
+# TESTRUNNER: slow
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix memjournal2
+
+do_execsql_test 1.0 {
+ PRAGMA journal_mode = memory;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
+} {memory}
+
+set nRow [expr 2000]
+
+do_execsql_test 1.1 {
+ BEGIN;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<$nRow
+ )
+ INSERT INTO t1 SELECT NULL, randomblob(700) FROM s;
+}
+
+for {set jj 200} {$jj <= 300} {incr jj} {
+ do_execsql_test 1.2.$jj.1 {
+ SAVEPOINT one;
+ UPDATE t1 SET b=randomblob(700) WHERE a<=$jj;
+ }
+ do_execsql_test 1.2.$jj.2 {
+ SAVEPOINT two;
+ UPDATE t1 SET b=randomblob(700) WHERE a==1;
+ ROLLBACK TO two;
+ RELEASE two;
+ }
+ do_execsql_test 1.2.$jj.3 {
+ SAVEPOINT two;
+ UPDATE t1 SET b=randomblob(700) WHERE a==1;
+ ROLLBACK TO two;
+ RELEASE two;
+ }
+
+ do_execsql_test 1.2.$jj.4 {
+ PRAGMA integrity_check;
+ ROLLBACK TO one;
+ RELEASE one;
+ } {ok}
+}
+
+
+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..fda35a9
--- /dev/null
+++ b/test/memsubsys1.test
@@ -0,0 +1,189 @@
+# 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 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
+}
+
+test_set_config_pagecache 0 0
+
+# 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 290
+
+# Test 1: Both PAGECACHE and SCRATCH are shut down.
+#
+db close
+sqlite3_shutdown
+sqlite3_config_lookaside 0 0
+sqlite3_config_pagecache 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; PRAGMA mmap_size=0}
+#show_memstats
+set MEMORY_MANAGEMENT $sqlite_options(memorymanage)
+ifcapable pagecache_overflow_stats {
+ ifcapable !malloc_usable_size {
+ 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_config singlethread
+sqlite3_initialize
+reset_highwater_marks
+build_test_db memsubsys1-3.1 {PRAGMA page_size=1024}
+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]
+ # Note: The measured PAGECACHE_OVERFLOW is amount malloc() returns, not what
+ # was requested. System malloc() implementations might (arbitrarily) return
+ # slightly different oversize buffers, which can result in slightly different
+ # PAGECACHE_OVERFLOW sizes between consecutive runs. So we cannot do an
+ # exact comparison. Simply verify that the amount is within 5%.
+ expr {$overflow>=$max_pagecache*0.95 && $overflow<=$max_pagecache*1.05}
+} 1
+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 PAGECACHE
+#
+db close
+sqlite3_shutdown
+sqlite3_config_pagecache [expr 1024+$xtra_size] 50
+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<9000}
+} 1
+
+db close
+sqlite3_shutdown
+sqlite3_config_memstatus 1
+sqlite3_config_lookaside 100 500
+sqlite3_config serialized
+sqlite3_initialize
+autoinstall_test_functions
+
+test_restore_config_pagecache
+finish_test
diff --git a/test/memsubsys2.test b/test/memsubsys2.test
new file mode 100644
index 0000000..68e4e22
--- /dev/null
+++ b/test/memsubsys2.test
@@ -0,0 +1,176 @@
+# 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.1 {
+ expr {[sqlite3_memory_highwater 0]>=[sqlite3_memory_used]+100000}
+} {1}
+do_test memsubsys2-2.2.2 {
+ expr {[sqlite3_memory_highwater 0]>=$highwater+50000}
+} {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/merge1.test b/test/merge1.test
new file mode 100644
index 0000000..7ec4dab
--- /dev/null
+++ b/test/merge1.test
@@ -0,0 +1,145 @@
+# 2021-12-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.
+#
+#***********************************************************************
+#
+# Testing the compound-SELECT merge algorithm to ensure that it works
+# when it tries to balance the merge tree.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix merge1
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+load_static_extension db series
+
+
+optimization_control db all on
+do_execsql_test 100 {
+ WITH data(v) AS (
+ SELECT value FROM generate_series(1,35,3)
+ UNION ALL
+ SELECT value FROM generate_series(10,30,4)
+ UNION ALL
+ SELECT value FROM generate_series(20,50,5)
+ UNION ALL
+ SELECT value FROM generate_series(30,60,6)
+ UNION ALL
+ SELECT value FROM generate_series(1,50,7)
+ UNION ALL
+ SELECT value FROM generate_series(10,80,8)
+ )
+ SELECT v FROM data ORDER BY v;
+} {1 1 4 7 8 10 10 10 13 14 15 16 18 18 19 20 22 22 22 25 25 26 26 28 29 30 30 30 31 34 34 35 36 36 40 42 42 43 45 48 50 50 50 54 58 60 66 74}
+do_eqp_test 101 {
+ WITH data(v) AS (
+ SELECT value FROM generate_series(1,35,3)
+ UNION ALL
+ SELECT value FROM generate_series(10,30,4)
+ UNION ALL
+ SELECT value FROM generate_series(20,50,5)
+ UNION ALL
+ SELECT value FROM generate_series(30,60,6)
+ UNION ALL
+ SELECT value FROM generate_series(1,50,7)
+ UNION ALL
+ SELECT value FROM generate_series(10,80,8)
+ )
+ SELECT v FROM data ORDER BY v;
+} {
+ QUERY PLAN
+ `--MERGE (UNION ALL)
+ |--LEFT
+ | `--MERGE (UNION ALL)
+ | |--LEFT
+ | | `--MERGE (UNION ALL)
+ | | |--LEFT
+ | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ | | `--RIGHT
+ | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ | `--RIGHT
+ | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ `--RIGHT
+ `--MERGE (UNION ALL)
+ |--LEFT
+ | `--MERGE (UNION ALL)
+ | |--LEFT
+ | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ | `--RIGHT
+ | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ `--RIGHT
+ `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+}
+
+# Same test with the blanced-merge optimization
+# disabled. Should give the exact same answer.
+#
+optimization_control db balanced-merge off
+db cache flush
+do_execsql_test 110 {
+ WITH data(v) AS (
+ SELECT value FROM generate_series(1,35,3)
+ UNION ALL
+ SELECT value FROM generate_series(10,30,4)
+ UNION ALL
+ SELECT value FROM generate_series(20,50,5)
+ UNION ALL
+ SELECT value FROM generate_series(30,60,6)
+ UNION ALL
+ SELECT value FROM generate_series(1,50,7)
+ UNION ALL
+ SELECT value FROM generate_series(10,80,8)
+ )
+ SELECT v FROM data ORDER BY v;
+} {1 1 4 7 8 10 10 10 13 14 15 16 18 18 19 20 22 22 22 25 25 26 26 28 29 30 30 30 31 34 34 35 36 36 40 42 42 43 45 48 50 50 50 54 58 60 66 74}
+do_eqp_test 111 {
+ WITH data(v) AS (
+ SELECT value FROM generate_series(1,35,3)
+ UNION ALL
+ SELECT value FROM generate_series(10,30,4)
+ UNION ALL
+ SELECT value FROM generate_series(20,50,5)
+ UNION ALL
+ SELECT value FROM generate_series(30,60,6)
+ UNION ALL
+ SELECT value FROM generate_series(1,50,7)
+ UNION ALL
+ SELECT value FROM generate_series(10,80,8)
+ )
+ SELECT v FROM data ORDER BY v;
+} {
+ QUERY PLAN
+ `--MERGE (UNION ALL)
+ |--LEFT
+ | `--MERGE (UNION ALL)
+ | |--LEFT
+ | | `--MERGE (UNION ALL)
+ | | |--LEFT
+ | | | `--MERGE (UNION ALL)
+ | | | |--LEFT
+ | | | | `--MERGE (UNION ALL)
+ | | | | |--LEFT
+ | | | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ | | | | `--RIGHT
+ | | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ | | | `--RIGHT
+ | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ | | `--RIGHT
+ | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ | `--RIGHT
+ | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ `--RIGHT
+ `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+}
+
+finish_test
diff --git a/test/minmax.test b/test/minmax.test
new file mode 100644
index 0000000..81bd46d
--- /dev/null
+++ b/test/minmax.test
@@ -0,0 +1,661 @@
+# 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
+set ::testprefix minmax
+
+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.0 {
+ execsql {
+ SELECT max(rowid) AS yy FROM t4 UNION SELECT max(rowid) FROM t5
+ }
+ } {3}
+ do_test minmax-9.1 {
+ execsql {
+ SELECT max(yy) FROM (
+ SELECT max(rowid) AS yy FROM t4 UNION SELECT max(rowid) FROM t5
+ )
+ }
+ } {3}
+ do_test minmax-9.2 {
+ execsql {
+ SELECT max(yy) FROM (
+ SELECT max(rowid) AS yy 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}
+
+#-------------------------------------------------------------------------
+reset_db
+
+proc do_test_13 {op name sql1 sql2 res} {
+ set ::sqlite_search_count 0
+ uplevel [list do_execsql_test $name.1 $sql1 $res]
+ set a $::sqlite_search_count
+
+ set ::sqlite_search_count 0
+ uplevel [list do_execsql_test $name.2 $sql2 $res]
+ set b $::sqlite_search_count
+
+ uplevel [list do_test $name.3 [list expr "$a $op $b"] 1]
+}
+
+# Run a test named $name. Check that SQL statements $sql1 and $sql2 both
+# return the same result, but that $sql2 increments the $sqlite_search_count
+# variable more often (indicating that it is visiting more rows to determine
+# the result).
+#
+proc do_test_13_opt {name sql1 sql2 res} {
+ uplevel [list do_test_13 < $name $sql1 $sql2 $res]
+}
+
+# Like [do_test_13_noopt], except this time check that the $sqlite_search_count
+# variable is incremented the same number of times by both SQL statements.
+#
+proc do_test_13_noopt {name sql1 sql2 res} {
+ uplevel [list do_test_13 == $name $sql1 $sql2 $res]
+}
+
+do_execsql_test 13.1 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('a', 1, 1);
+ INSERT INTO t1 VALUES('b', 6, 6);
+ INSERT INTO t1 VALUES('c', 5, 5);
+ INSERT INTO t1 VALUES('a', 4, 4);
+ INSERT INTO t1 VALUES('a', 5, 5);
+ INSERT INTO t1 VALUES('c', 6, 6);
+ INSERT INTO t1 VALUES('b', 4, 4);
+ INSERT INTO t1 VALUES('c', 7, 7);
+ INSERT INTO t1 VALUES('b', 2, 2);
+ INSERT INTO t1 VALUES('b', 3, 3);
+ INSERT INTO t1 VALUES('a', 3, 3);
+ INSERT INTO t1 VALUES('b', 5, 5);
+ INSERT INTO t1 VALUES('c', 4, 4);
+ INSERT INTO t1 VALUES('c', 3, 3);
+ INSERT INTO t1 VALUES('a', 2, 2);
+ SELECT * FROM t1 ORDER BY a, b, c;
+} {a 1 1 a 2 2 a 3 3 a 4 4 a 5 5
+ b 2 2 b 3 3 b 4 4 b 5 5 b 6 6
+ c 3 3 c 4 4 c 5 5 c 6 6 c 7 7
+}
+do_execsql_test 13.2 { CREATE INDEX i1 ON t1(a, b, c) }
+
+do_test_13_opt 13.3 {
+ SELECT min(b) FROM t1 WHERE a='b'
+} {
+ SELECT min(c) FROM t1 WHERE a='b'
+} {2}
+
+do_test_13_opt 13.4 {
+ SELECT a, min(b) FROM t1 WHERE a='b'
+} {
+ SELECT a, min(c) FROM t1 WHERE a='b'
+} {b 2}
+
+do_test_13_opt 13.4 {
+ SELECT a||c, max(b)+4 FROM t1 WHERE a='c'
+} {
+ SELECT a||c, max(c)+4 FROM t1 WHERE a='c'
+} {c7 11}
+
+do_test_13_noopt 13.5 {
+ SELECT a||c, max(b+1) FROM t1 WHERE a='c'
+} {
+ SELECT a||c, max(c+1) FROM t1 WHERE a='c'
+} {c7 8}
+
+do_test_13_noopt 13.6 {
+ SELECT count(b) FROM t1 WHERE a='c'
+} {
+ SELECT count(c) FROM t1 WHERE a='c'
+} {5}
+
+do_test_13_noopt 13.7 {
+ SELECT min(b), count(b) FROM t1 WHERE a='a';
+} {
+ SELECT min(c), count(c) FROM t1 WHERE a='a';
+} {1 5}
+
+# 2016-07-26. https://www.sqlite.org/src/info/a0bac8b3c3d1bb75
+# Incorrect result on a min() query after a CREATE INDEX.
+#
+do_execsql_test 14.1 {
+ CREATE TABLE t14(a INTEGER, b INTEGER);
+ INSERT INTO t14(a,b) VALUES(100,2),(200,2),(300,2),(400,1),(500,2);
+ SELECT min(a) FROM t14 WHERE b='2' AND a>'50';
+} {100}
+do_execsql_test 14.2 {
+ CREATE INDEX t14ba ON t14(b,a);
+ SELECT min(a) FROM t14 WHERE b='2' AND a>'50';
+} {100}
+
+# 2021-08-21. https://sqlite.org/forum/forumpost/cfcb4b461d
+#
+reset_db
+do_execsql_test 15.1 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b);
+ CREATE TABLE t3(c);
+ INSERT INTO t1 VALUES(0);
+ INSERT INTO t2 VALUES(5);
+ SELECT MIN((SELECT b FROM t2 UNION SELECT x FROM (SELECT x FROM (SELECT 1 AS x WHERE t1.a=1) UNION ALL SELECT c FROM t3))) FROM t1;
+} {5}
+
+finish_test
diff --git a/test/minmax2.test b/test/minmax2.test
new file mode 100644
index 0000000..9ea6b67
--- /dev/null
+++ b/test/minmax2.test
@@ -0,0 +1,426 @@
+# 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 {
+ sqlite3_db_config db LEGACY_FILE_FORMAT 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 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.0 {
+ execsql {
+ SELECT max(rowid) FROM t4 UNION SELECT max(rowid) FROM t5
+ }
+ } {3}
+ do_test minmax2-9.1 {
+ execsql {
+ SELECT max(yy) FROM (
+ SELECT max(rowid) AS yy FROM t4 UNION SELECT max(rowid) FROM t5
+ )
+ }
+ } {3}
+ do_test minmax2-9.2 {
+ execsql {
+ SELECT max(yy) FROM (
+ SELECT max(rowid) AS yy 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;
+ }
+} {{} {}}
+
+# 2017-10-26. Extend the min/max optimization to indexes on expressions
+#
+do_execsql_test minmax2-11.100 {
+ CREATE TABLE t11(a,b,c);
+ INSERT INTO t11(a,b,c) VALUES(1,10,5),(2,8,11),(3,1,4),(4,20,1),(5,16,4);
+ CREATE INDEX t11bc ON t11(b+c);
+ SELECT max(b+c) FROM t11;
+} {21}
+do_execsql_test minmax2-11.110 {
+ SELECT a, max(b+c) FROM t11;
+} {4 21}
+do_test minmax2-11.111 {
+ db eval {SELECT max(b+c) FROM t11}
+ db status step
+} {0}
+do_test minmax2-11.112 {
+ db eval {SELECT max(c+b) FROM t11}
+ db status step
+} {4}
+do_execsql_test minmax2-11.120 {
+ SELECT a, min(b+c) FROM t11;
+} {3 5}
+do_test minmax2-11.121 {
+ db eval {SELECT min(b+c) FROM t11}
+ db status step
+} {0}
+do_test minmax2-11.122 {
+ db eval {SELECT min(c+b) FROM t11}
+ db status step
+} {4}
+do_execsql_test minmax2-11.130 {
+ INSERT INTO t11(a,b,c) VALUES(6,NULL,0),(7,0,NULL);
+ SELECT a, min(b+c) FROM t11;
+} {3 5}
+
+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/minmax4.test b/test/minmax4.test
new file mode 100644
index 0000000..775fee8
--- /dev/null
+++ b/test/minmax4.test
@@ -0,0 +1,236 @@
+# 2012 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.
+#
+#***********************************************************************
+#
+# Test for queries of the form:
+#
+# SELECT p, max(q) FROM t1;
+#
+# Demonstration that the value returned for p is on the same row as
+# the maximum q.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix minmax4
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+do_test minmax4-1.1 {
+ db eval {
+ CREATE TABLE t1(p,q);
+ SELECT p, max(q) FROM t1;
+ }
+} {{} {}}
+do_test minmax4-1.2 {
+ db eval {
+ SELECT p, min(q) FROM t1;
+ }
+} {{} {}}
+do_test minmax4-1.3 {
+ db eval {
+ INSERT INTO t1 VALUES(1,2);
+ SELECT p, max(q) FROM t1;
+ }
+} {1 2}
+do_test minmax4-1.4 {
+ db eval {
+ SELECT p, min(q) FROM t1;
+ }
+} {1 2}
+do_test minmax4-1.5 {
+ db eval {
+ INSERT INTO t1 VALUES(3,4);
+ SELECT p, max(q) FROM t1;
+ }
+} {3 4}
+do_test minmax4-1.6 {
+ db eval {
+ SELECT p, min(q) FROM t1;
+ SELECT p FROM (SELECT p, min(q) FROM t1);
+ }
+} {1 2 1}
+do_test minmax4-1.7 {
+ db eval {
+ INSERT INTO t1 VALUES(5,0);
+ SELECT p, max(q) FROM t1;
+ SELECT p FROM (SELECT max(q), p FROM t1);
+ }
+} {3 4 3}
+do_test minmax4-1.8 {
+ db eval {
+ SELECT p, min(q) FROM t1;
+ }
+} {5 0}
+do_test minmax4-1.9 {
+ db eval {
+ INSERT INTO t1 VALUES(6,1);
+ SELECT p, max(q) FROM t1;
+ SELECT p FROM (SELECT max(q), p FROM t1);
+ }
+} {3 4 3}
+do_test minmax4-1.10 {
+ db eval {
+ SELECT p, min(q) FROM t1;
+ }
+} {5 0}
+do_test minmax4-1.11 {
+ db eval {
+ INSERT INTO t1 VALUES(7,NULL);
+ SELECT p, max(q) FROM t1;
+ }
+} {3 4}
+do_test minmax4-1.12 {
+ db eval {
+ SELECT p, min(q) FROM t1;
+ }
+} {5 0}
+do_test minmax4-1.13 {
+ db eval {
+ DELETE FROM t1 WHERE q IS NOT NULL;
+ SELECT p, max(q) FROM t1;
+ }
+} {7 {}}
+do_test minmax4-1.14 {
+ db eval {
+ SELECT p, min(q) FROM t1;
+ }
+} {7 {}}
+
+do_test minmax4-2.1 {
+ db eval {
+ CREATE TABLE t2(a,b,c);
+ INSERT INTO t2 VALUES
+ (1,null,2),
+ (1,2,3),
+ (1,1,4),
+ (2,3,5);
+ SELECT a, max(b), c FROM t2 GROUP BY a ORDER BY a;
+ }
+} {1 2 3 2 3 5}
+do_test minmax4-2.2 {
+ db eval {
+ SELECT a, min(b), c FROM t2 GROUP BY a ORDER BY a;
+ }
+} {1 1 4 2 3 5}
+do_test minmax4-2.3 {
+ db eval {
+ SELECT a, min(b), avg(b), count(b), c FROM t2 GROUP BY a ORDER BY a DESC;
+ }
+} {2 3 3.0 1 5 1 1 1.5 2 4}
+do_test minmax4-2.4 {
+ db eval {
+ SELECT a, min(b), max(b), c FROM t2 GROUP BY a ORDER BY a;
+ }
+} {1 1 2 3 2 3 3 5}
+do_test minmax4-2.5 {
+ db eval {
+ SELECT a, max(b), min(b), c FROM t2 GROUP BY a ORDER BY a;
+ }
+} {1 2 1 4 2 3 3 5}
+do_test minmax4-2.6 {
+ db eval {
+ SELECT a, max(b), b, max(c), c FROM t2 GROUP BY a ORDER BY a;
+ }
+} {1 2 1 4 4 2 3 3 5 5}
+do_test minmax4-2.7 {
+ db eval {
+ SELECT a, min(b), b, min(c), c FROM t2 GROUP BY a ORDER BY a;
+ }
+} {1 1 {} 2 2 2 3 3 5 5}
+
+#-------------------------------------------------------------------------
+foreach {tn sql} {
+ 1 { CREATE INDEX i1 ON t1(a) }
+ 2 { CREATE INDEX i1 ON t1(a DESC) }
+ 3 { }
+} {
+ reset_db
+ do_execsql_test 3.$tn.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(NULL, 1);
+ }
+ execsql $sql
+ do_execsql_test 3.$tn.1 {
+ SELECT min(a), b FROM t1;
+ } {{} 1}
+ do_execsql_test 3.$tn.2 {
+ SELECT min(a), b FROM t1 WHERE a<50;
+ } {{} {}}
+ do_execsql_test 3.$tn.3 {
+ INSERT INTO t1 VALUES(2, 2);
+ }
+ do_execsql_test 3.$tn.4 {
+ SELECT min(a), b FROM t1;
+ } {2 2}
+ do_execsql_test 3.$tn.5 {
+ SELECT min(a), b FROM t1 WHERE a<50;
+ } {2 2}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t0 (c0, c1);
+ CREATE INDEX i0 ON t0(c1, c1 + 1 DESC);
+ INSERT INTO t0(c0) VALUES (1);
+}
+do_execsql_test 4.1 {
+ SELECT MIN(t0.c1), t0.c0 FROM t0 WHERE t0.c1 ISNULL;
+} {{} 1}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1 (a, b);
+ INSERT INTO t1 VALUES(123, NULL);
+ CREATE INDEX i1 ON t1(a, b DESC);
+}
+do_execsql_test 5.1 {
+ SELECT MIN(a) FROM t1 WHERE a=123;
+} {123}
+
+#-------------------------------------------------------------------------
+# Tests for ticket f8a7060ece.
+#
+reset_db
+do_execsql_test 6.1.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(NULL, 1, 'x');
+ CREATE INDEX i1 ON t1(a);
+}
+do_execsql_test 6.1.1 {
+ SELECT min(a), b, c FROM t1 WHERE c='x';
+} {{} 1 x}
+do_execsql_test 6.1.2 {
+ INSERT INTO t1 VALUES(1, 2, 'y');
+} {}
+do_execsql_test 6.1.3 {
+ SELECT min(a), b, c FROM t1 WHERE c='x';
+} {{} 1 x}
+
+do_execsql_test 6.2.0 {
+ CREATE TABLE t0(c0 UNIQUE, c1);
+ INSERT INTO t0(c1) VALUES (0);
+ INSERT INTO t0(c0) VALUES (0);
+ CREATE VIEW v0(c0, c1) AS
+ SELECT t0.c1, t0.c0 FROM t0 WHERE CAST(t0.rowid AS INT) = 1;
+}
+do_execsql_test 6.2.1 {
+ SELECT c0, c1 FROM v0;
+} {0 {}}
+do_execsql_test 6.2.2 {
+ SELECT v0.c0, MIN(v0.c1) FROM v0;
+} {0 {}}
+
+finish_test
diff --git a/test/misc1.test b/test/misc1.test
new file mode 100644
index 0000000..b1b1b08
--- /dev/null
+++ b/test/misc1.test
@@ -0,0 +1,769 @@
+# 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.
+#
+
+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 {UNIQUE constraint failed: t5.a, t5.b}}
+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}
+}
+
+#
+# The following tests can only work if the current SQLite VFS has the concept
+# of a current directory.
+#
+ifcapable curdir {
+# Make sure a database connection still works after changing the
+# working directory.
+#
+if {[atomic_batch_write test.db]==0} {
+ 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}
+
+# 2014-01-10: In a CREATE TABLE AS, if one or more of the column names
+# are an empty string, that is still OK.
+#
+do_execsql_test misc1-19.1 {
+ CREATE TABLE t19 AS SELECT 1, 2 AS '', 3;
+ SELECT * FROM t19;
+} {1 2 3}
+do_execsql_test misc1-19.2 {
+ CREATE TABLE t19b AS SELECT 4 AS '', 5 AS '', 6 AS '';
+ SELECT * FROM t19b;
+} {4 5 6}
+
+# 2015-05-20: CREATE TABLE AS should not store INT value is a TEXT
+# column.
+#
+do_execsql_test misc1-19.3 {
+ CREATE TABLE t19c(x TEXT);
+ CREATE TABLE t19d AS SELECT * FROM t19c UNION ALL SELECT 1234;
+ SELECT x, typeof(x) FROM t19d;
+} {1234 text}
+
+# 2014-05-16: Tests for the SQLITE_TESTCTRL_FAULT_INSTALL feature.
+#
+unset -nocomplain fault_callbacks
+set fault_callbacks {}
+proc fault_callback {n} {
+ lappend ::fault_callbacks $n
+ return 0
+}
+do_test misc1-19.1 {
+ sqlite3_test_control_fault_install fault_callback
+ set fault_callbacks
+} {0}
+do_test misc1-19.2 {
+ sqlite3_test_control_fault_install
+ set fault_callbacks
+} {0}
+
+# 2015-01-26: Valgrind-detected over-read.
+# Reported on sqlite-users@sqlite.org by Michal Zalewski. Found by afl-fuzz
+# presumably.
+#
+do_execsql_test misc1-20.1 {
+ CREATE TABLE t0(x INTEGER DEFAULT(0==0) NOT NULL);
+ REPLACE INTO t0(x) VALUES('');
+ SELECT rowid, quote(x) FROM t0;
+} {1 ''}
+
+# 2015-03-22: NULL pointer dereference after a syntax error
+#
+do_catchsql_test misc1-21.1 {
+ select''like''like''like#0;
+} {1 {near "#0": syntax error}}
+do_catchsql_test misc1-21.2 {
+ VALUES(0,0x0MATCH#0;
+} {1 {near ";": syntax error}}
+
+# 2015-04-15
+do_execsql_test misc1-22.1 {
+ SELECT ''+3 FROM (SELECT ''+5);
+} {3}
+
+# 2015-04-19: NULL pointer dereference on a corrupt schema
+#
+db close
+sqlite3 db :memory:
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test misc1-23.1 {
+ CREATE TABLE t1(x);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_master SET sql='CREATE table t(d CHECK(T(#0)';
+ BEGIN;
+ CREATE TABLE t2(y);
+ ROLLBACK;
+ DROP TABLE IF EXISTS t3;
+} {}
+
+# 2015-04-19: Faulty assert() statement
+#
+db close
+database_may_be_corrupt
+sqlite3 db :memory:
+sqlite3_db_config db DEFENSIVE 0
+do_catchsql_test misc1-23.2 {
+ CREATE TABLE t1(x UNIQUE);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_master SET sql='CREATE TABLE IF not EXISTS t(c)';
+ BEGIN;
+ CREATE TABLE t2(x);
+ ROLLBACK;
+ DROP TABLE F;
+} {1 {no such table: F}}
+db close
+sqlite3 db :memory:
+sqlite3_db_config db DEFENSIVE 0
+do_catchsql_test misc1-23.3 {
+ CREATE TABLE t1(x UNIQUE);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_master SET sql='CREATE table y(a TEXT, a TEXT)';
+ BEGIN;
+ CREATE TABLE t2(y);
+ ROLLBACK;
+ DROP TABLE IF EXISTS t;
+} {0 {}}
+
+
+# At one point, running this would read one byte passed the end of a
+# buffer, upsetting valgrind.
+#
+do_test misc1-24.0 {
+ list [catch { sqlite3_prepare_v2 db ! -1 dummy } msg] $msg
+} {1 {(1) unrecognized token: "!"}}
+
+# The following query (provided by Kostya Serebryany) used to take 25
+# minutes to prepare. This has been speeded up to about 250 milliseconds.
+#
+do_catchsql_test misc1-25.0 {
+SELECT-1 UNION SELECT 5 UNION SELECT 0 UNION SElECT*from(SELECT-5) UNION SELECT*from(SELECT-0) UNION SELECT:SELECT-0 UNION SELECT-1 UNION SELECT 1 UNION SELECT 1 ORDER BY S in(WITH K AS(WITH K AS(select'CREINDERcharREADEVIRTUL5TABLECONFLICT !1 USIN'' MFtOR(b38q,eWITH K AS(selectCREATe TABLE t0(a,b,c,d,e, PRIMARY KEY(a,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,b,c,d,c,a,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d'CEIl,k'',ab, g, a,b,o11b, i'nEX/charREDE IVT LR!VABLt5SG',N ,N in rement,l_vacuum,M&U,'te3(''5l' a,bB,b,l*e)SELECT:SELECT, *,*,*from(( SELECT
+$group,:conc ap0,1)fro,(select"",:PBAG,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,c,d,c,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d, foreign_keysc,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,c,d,c,a,b,d,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,bb,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,c,d,c,a,b,d,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,MAato_aecSELEC,+?b," "O,"i","a",""b ,5 ))KEY)SELECT*FROM((k()reaC,k,K) eA,k '' )t ,K M);
+} {1 {'k' is not a function}}
+
+# 2017-09-17
+#
+# Sometimes sqlite3ExprListAppend() can be invoked on an ExprList that
+# was obtained from sqlite3ExprListDup().
+#
+do_execsql_test misc1-26.0 {
+ DROP TABLE IF EXISTS abc;
+ CREATE TABLE abc(a, b, c);
+ SELECT randomblob(min(max(coalesce(EXISTS (SELECT 1 FROM ( SELECT (SELECT 2147483647) NOT IN (SELECT 2147483649 UNION ALL SELECT DISTINCT -1) IN (SELECT 2147483649), 'fault', (SELECT ALL -1 INTERSECT SELECT 'experiments') IN (SELECT ALL 56.1 ORDER BY 'experiments' DESC) FROM (SELECT DISTINCT 2147483648, 'hardware' UNION ALL SELECT -2147483648, 'experiments' ORDER BY 2147483648 LIMIT 1 OFFSET 123456789.1234567899) GROUP BY (SELECT ALL 0 INTERSECT SELECT 'in') IN (SELECT DISTINCT 'experiments' ORDER BY zeroblob(1000) LIMIT 56.1 OFFSET -456) HAVING EXISTS (SELECT 'fault' EXCEPT SELECT DISTINCT 56.1) UNION SELECT 'The', 'The', 2147483649 UNION ALL SELECT DISTINCT 'hardware', 'first', 'experiments' ORDER BY 'hardware' LIMIT 123456789.1234567899 OFFSET -2147483647)) NOT IN (SELECT (SELECT DISTINCT (SELECT 'The') FROM abc ORDER BY EXISTS (SELECT -1 INTERSECT SELECT ALL NULL) ASC) IN (SELECT DISTINCT EXISTS (SELECT ALL 123456789.1234567899 ORDER BY 1 ASC, NULL DESC) FROM sqlite_master INTERSECT SELECT 456)), (SELECT ALL 'injection' UNION ALL SELECT ALL (SELECT DISTINCT 'first' UNION SELECT DISTINCT 'The') FROM (SELECT 456, 'in', 2147483649))),1), 500)), 'first', EXISTS (SELECT DISTINCT 456 FROM abc ORDER BY 'experiments' DESC) FROM abc;
+} {}
+
+# 2017-12-29
+#
+# The following behaviors (duplicate column names on an INSERT or UPDATE)
+# are undocumented. <<--- Not so. There is a long-standing requirement
+# in lang_update.in to say that when the columns to be updated appear more
+# than once in an UPDATE statement that only the rightmost expression is used.
+# See e_update-1.6.* for the tests. This is unfortunate, since omitting
+# that requirement would greatly simplify the fix to the problem identified
+# by forum post https://sqlite.org/forum/info/16ca0e9f32c38567
+#
+# These tests are added to ensure that historical behavior
+# does not change accidentally.
+#
+# For duplication columns on an INSERT, the first value is used.
+# For duplication columns on an UPDATE, the last value is used.
+#
+do_execsql_test misc1-27.0 {
+ CREATE TABLE dup1(a,b,c);
+ INSERT INTO dup1(a,b,c,a,b,c) VALUES(1,2,3,4,5,6);
+ SELECT a,b,c FROM dup1;
+} {1 2 3}
+do_execsql_test misc1-27.1 {
+ UPDATE dup1 SET a=7, b=8, c=9, a=10, b=11, c=12;
+ SELECT a,b,c FROM dup1;
+} {10 11 12}
+
+# 2018-12-20
+#
+# The Cursor.seekOp debugging value set incorrectly
+# in OP_NotExists.
+#
+sqlite3 db :memory:
+do_execsql_test misc1-28.0 {
+ CREATE TABLE t1(x);
+ CREATE UNIQUE INDEX t1x ON t1(x) WHERE x=1;
+ INSERT OR ABORT INTO t1 DEFAULT VALUES;
+ UPDATE OR REPLACE t1 SET x = 1;
+ PRAGMA integrity_check;
+ SELECT * FROM t1;
+} {ok 1}
+
+finish_test
diff --git a/test/misc2.test b/test/misc2.test
new file mode 100644
index 0000000..4796d5d
--- /dev/null
+++ b/test/misc2.test
@@ -0,0 +1,444 @@
+# 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_catchsql_test misc2-2.2 {
+ SELECT rowid, * FROM (SELECT * FROM t1, t2);
+ } {1 {no such column: rowid}}
+ do_catchsql_test misc2-2.2b {
+ SELECT 'rowid', * FROM (SELECT * FROM t1, t2);
+ } {0 {rowid 1 2 3 7 8 9}}
+}
+
+ifcapable view {
+ do_catchsql_test misc2-2.3 {
+ CREATE VIEW v1 AS SELECT * FROM t1, t2;
+ SELECT rowid, * FROM v1;
+ } {1 {no such column: rowid}}
+ do_catchsql_test misc2-2.3b {
+ SELECT 'rowid', * FROM v1;
+ } {0 {rowid 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..bc1f0ff
--- /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 {,-B} $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 {,-B} $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..3d39188
--- /dev/null
+++ b/test/misc4.test
@@ -0,0 +1,233 @@
+# 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}
+
+# 2015-05-15. Error message formatting problem.
+#
+db close
+sqlite3 db :memory:
+sqlite3_db_config db DEFENSIVE 0
+do_catchsql_test misc4-7.1 {
+ CREATE TABLE t7(x);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_master SET sql='CREATE TABLE [M%s%s%s%s%s%s%s%s%s%s%s%s%s';
+ VACUUM;
+} {1 {unrecognized token: "[M%s%s%s%s%s%s%s%s%s%s%s%s%s"}}
+
+# 2015-05-18. Use of ephermeral Mem content after the cursor that holds
+# the canonical content has moved on.
+#
+do_execsql_test misc4-7.2 {
+ CREATE TABLE t0(a,b);
+ INSERT INTO t0 VALUES(1,0),(2,0);
+ UPDATE t0 SET b=9 WHERE a AND (SELECT a FROM t0 WHERE a);
+ SELECT * FROM t0 ORDER BY +a;
+} {1 9 2 9}
+
+finish_test
diff --git a/test/misc5.test b/test/misc5.test
new file mode 100644
index 0000000..f7c6048
--- /dev/null
+++ b/test/misc5.test
@@ -0,0 +1,1895 @@
+# 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 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.
+#
+# This test fails when building with -DYYSTACKDEPTH=0
+#
+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}}
+
+# Parser stack overflow is silently ignored when it occurs while parsing the
+# schema and PRAGMA writable_schema is turned on.
+#
+do_test misc5-7.2 {
+ sqlite3 db2 :memory:
+ sqlite3_db_config db2 DEFENSIVE 0
+ catchsql {
+ CREATE TABLE t1(x UNIQUE);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_master SET sql='CREATE table t(o CHECK(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((;VALUES(o)';
+ BEGIN;
+ CREATE TABLE t2(y);
+ ROLLBACK;
+ DROP TABLE IF EXISTS D;
+ } db2
+} {0 {}}
+db2 close
+
+
+# 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..add9014
--- /dev/null
+++ b/test/misc7.test
@@ -0,0 +1,573 @@
+# 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
+set testprefix misc7
+
+if {[clang_sanitize_address]==0} {
+ 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.
+#
+if {[atomic_batch_write test.db]==0} {
+ 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.
+#
+# Note: The PRAGMA omit_readlock was an early hack to disable the
+# fcntl() calls for read-only databases so that read-only databases could
+# be read on broken NFS systems. That pragma has now been removed.
+# (Use the unix-none VFS as a replacement, if needed.) But these tests
+# do not really depend on omit_readlock, so we left them in place.
+#
+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
+ do_catchsql_test misc7-10.1 {
+ INSERT INTO t1(a,b,c) VALUES(12345,2,3) ON CONFLICT(a) DO NOTHING;
+ } {1 {UPSERT not implemented for virtual table "t1"}}
+
+ # 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.0 {
+ CREATE TABLE abc(a PRIMARY KEY, b, c);
+ }
+ do_eqp_test misc7-14.1 {
+ SELECT * FROM abc AS t2 WHERE rowid = 1;
+ } {
+ QUERY PLAN
+ `--SEARCH t2 USING INTEGER PRIMARY KEY (rowid=?)
+}
+ do_eqp_test misc7-14.2 {
+ SELECT * FROM abc AS t2 WHERE a = 1;
+} {
+ QUERY PLAN
+ `--SEARCH t2 USING INDEX sqlite_autoindex_abc_1 (a=?)
+}
+ do_eqp_test misc7-14.3 {
+ SELECT * FROM abc AS t2 ORDER BY a;
+ } {
+ QUERY PLAN
+ `--SCAN t2 USING INDEX sqlite_autoindex_abc_1
+}
+}
+
+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 "UNIQUE" $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"} {
+
+ # 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 {
+ sqlite3_db_config db DEFENSIVE 0
+ 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 {malformed database schema (t3) - invalid rootpage}}
+ }
+}
+
+# Ticket #2470
+#
+reset_db
+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 [get_pwd] "[string repeat abcde 104].db"]
+ set rc [catch {sqlite3 db2 $zFile} msg]
+ list $rc $msg
+} {1 {unable to open database file}}
+
+# Try to do hot-journal rollback with a read-only connection. The
+# error code should be SQLITE_READONLY_ROLLBACK.
+#
+do_test misc7-22.1 {
+ db close
+ forcedelete test.db copy.db-journal
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ db close
+ sqlite3 db test.db -readonly 1
+ catchsql {
+ INSERT INTO t1 VALUES(5, 6);
+ }
+} {1 {attempt to write a readonly database}}
+do_test misc7-22.2 { execsql { SELECT * FROM t1 } } {1 2 3 4}
+do_test misc7-22.3 {
+ set fd [open test.db-journal w]
+ puts $fd [string repeat abc 1000]
+ close $fd
+ catchsql { SELECT * FROM t1 }
+} {1 {attempt to write a readonly database}}
+do_test misc7-22.4 {
+ sqlite3_extended_errcode db
+} SQLITE_READONLY_ROLLBACK
+catch { db close }
+forcedelete test.db
+
+if {$::tcl_platform(platform)=="unix"
+ && [atomic_batch_write test.db]==0
+} {
+ reset_db
+ do_execsql_test 23.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+
+ do_test 23.1 {
+ db close
+ forcedelete tst
+ file mkdir tst
+ forcecopy test.db tst/test.db
+ file attributes tst -permissions r-xr-xr-x
+ } {}
+
+ sqlite3 db tst/test.db
+ do_execsql_test 23.2 {
+ SELECT * FROM t1;
+ } {1 2}
+
+ do_catchsql_test 23.3 {
+ INSERT INTO t1 VALUES(3, 4);
+ } {1 {attempt to write a readonly database}}
+
+ do_test 23.4 {
+ sqlite3_extended_errcode db
+ } {SQLITE_READONLY_DIRECTORY}
+
+ do_test 23.5 {
+ db close
+ forcedelete tst
+ } {}
+}
+
+finish_test
diff --git a/test/misc8.test b/test/misc8.test
new file mode 100644
index 0000000..32b3a59
--- /dev/null
+++ b/test/misc8.test
@@ -0,0 +1,141 @@
+# 2014-11-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 "eval.c" loadable extension.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+load_static_extension db eval
+do_execsql_test misc8-1.0 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3),(4,5,6);
+ SELECT quote(eval('SELECT * FROM t1 ORDER BY a','-abc-'));
+} {'1-abc-2-abc-3-abc-4-abc-5-abc-6'}
+do_execsql_test misc8-1.1 {
+ SELECT quote(eval('SELECT * FROM t1 ORDER BY a'));
+} {{'1 2 3 4 5 6'}}
+do_catchsql_test misc8-1.2 {
+ SELECT quote(eval('SELECT d FROM t1 ORDER BY a'));
+} {1 {no such column: d}}
+do_execsql_test misc8-1.3 {
+ INSERT INTO t1 VALUES(7,null,9);
+ SELECT eval('SELECT * FROM t1 ORDER BY a',',');
+} {1,2,3,4,5,6,7,,9}
+do_catchsql_test misc8-1.4 {
+ BEGIN;
+ INSERT INTO t1 VALUES(10,11,12);
+ SELECT a, coalesce(b, eval('ROLLBACK; SELECT ''bam'';')), c
+ FROM t1 ORDER BY a;
+} {0 {1 2 3 4 5 6 7 bam 9}}
+do_catchsql_test misc8-1.5 {
+ INSERT INTO t1 VALUES(10,11,12);
+ SELECT a, coalesce(b, eval('SELECT ''bam''')), c
+ FROM t1
+ ORDER BY rowid;
+} {0 {1 2 3 4 5 6 7 bam 9 10 11 12}}
+do_catchsql_test misc8-1.6 {
+ SELECT a, coalesce(b, eval('DELETE FROM t1; SELECT ''bam''')), c
+ FROM t1
+ ORDER BY rowid;
+} {0 {1 2 3 4 5 6 7 bam {}}}
+do_catchsql_test misc8-1.7 {
+ INSERT INTO t1 VALUES(1,2,3),(4,5,6),(7,null,9);
+ BEGIN;
+ CREATE TABLE t2(x);
+ SELECT a, coalesce(b, eval('ROLLBACK; SELECT ''bam''')), c
+ FROM t1
+ ORDER BY rowid;
+} {1 {abort due to ROLLBACK}}
+
+do_catchsql_test misc8-1.8 {
+ PRAGMA empty_result_callbacks = 1;
+ SELECT eval('SELECT * FROM t1 WHERE 1 = 0;');
+} {0 {{}}}
+
+reset_db
+
+proc dbeval {sql} { db eval $sql }
+db func eval dbeval
+
+do_execsql_test misc8-2.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER) WITHOUT ROWID;
+ CREATE TABLE t2(c INTEGER PRIMARY KEY, d INTEGER, x BLOB);
+ INSERT INTO t1 VALUES(0,0);
+ INSERT INTO t1 VALUES(10,10);
+ INSERT INTO t2 VALUES(1,1,zeroblob(200));
+ INSERT INTO t2 VALUES(2,2,zeroblob(200));
+ INSERT INTO t2 VALUES(3,3,zeroblob(200));
+ INSERT INTO t2 VALUES(4,4,zeroblob(200));
+ INSERT INTO t2 VALUES(5,5,zeroblob(200));
+ INSERT INTO t2 VALUES(6,6,zeroblob(200));
+ INSERT INTO t2 VALUES(7,7,zeroblob(200));
+ INSERT INTO t2 VALUES(8,8,zeroblob(200));
+ INSERT INTO t2 VALUES(9,9,zeroblob(200));
+ INSERT INTO t2 VALUES(10,10,zeroblob(200));
+ SELECT a, c, eval(
+ printf('DELETE FROM t2 WHERE c=%d AND %d>5', a+c, a+c)
+ ) FROM t1, t2;
+} {
+ 0 1 {} 10 1 {}
+ 0 2 {} 10 2 {}
+ 0 3 {} 10 3 {}
+ 0 4 {} 10 4 {}
+ 0 5 {} 10 5 {}
+ 0 6 {} 10 {} {}
+ 0 7 {} 10 {} {}
+ 0 8 {} 10 {} {}
+ 0 9 {} 10 {} {}
+ 0 10 {} 10 {} {}
+}
+
+# 2016-02-26: An assertion fault found by the libFuzzer project
+#
+do_catchsql_test misc8-3.0 {
+ SELECT *
+ FROM
+ (
+ (SELECT 0 AS i) AS x1,
+ (SELECT 1) AS x2
+ ) AS x3,
+ (SELECT 6 AS j UNION ALL SELECT 7) AS x4
+ WHERE i<rowid
+ ORDER BY 1;
+} {1 {no such column: rowid}}
+
+# The SQLITE_DBCONFIG_MAINDBNAME interface
+#
+db close
+forcedelete test.db test2.db
+sqlite3 db test.db
+do_execsql_test misc8-4.0 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ ATTACH 'test2.db' AS aux2;
+ CREATE TABLE aux2.t2(c,d,e);
+ INSERT INTO t2 VALUES(4,5,6);
+ SELECT * FROM t1, t2;
+} {1 2 3 4 5 6}
+do_execsql_test misc8-4.1 {
+ PRAGMA database_list;
+} {/0 main .* 2 aux2/}
+dbconfig_maindbname_icecube db
+do_execsql_test misc8-4.2 {
+ SELECT name FROM icecube.sqlite_master;
+} {t1}
+do_test misc8-4.3 {
+ regexp {0 icecube .* 2 aux2} [db eval {PRAGMA database_list}]
+} 1
+
+
+
+finish_test
diff --git a/test/misuse.test b/test/misuse.test
new file mode 100644
index 0000000..e15cf33
--- /dev/null
+++ b/test/misuse.test
@@ -0,0 +1,210 @@
+# 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}
+
+if {[clang_sanitize_address]==0} {
+ 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 {bad parameter or other API misuse}}
+ do_test misuse-4.5 {
+ catchsql {
+ SELECT * FROM t1
+ }
+ } {1 {bad parameter or other API misuse}}
+
+ # 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) bad parameter or other API misuse}}
+}
+
+finish_test
diff --git a/test/mjournal.test b/test/mjournal.test
new file mode 100644
index 0000000..7aaa86b
--- /dev/null
+++ b/test/mjournal.test
@@ -0,0 +1,162 @@
+# 2017 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix mjournal
+
+if {[permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+# Test that nothing bad happens if a journal file contains a pointer to
+# a master journal file that does not have a "-" in the name. At one point
+# this was causing a segfault on unix.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+}
+
+do_test 1.1 {
+ forcedelete test.db2journal test.db-journal
+
+ close [open test.db-journal w]
+
+ hexio_write test.db-journal 0 746573742e6462326a6f75726e616c00
+ hexio_write test.db-journal 16 00000010
+ hexio_write test.db-journal 20 000005e1
+ hexio_write test.db-journal 24 d9d505f920a163d7
+
+ close [open test.db2journal w]
+ hexio_write test.db2journal 0 abcd
+} {2}
+
+do_execsql_test 1.2 {
+ SELECT * FROM t1;
+}
+
+do_test 1.3 {
+ forcedelete test0db2journal test.db-journal
+ close [open test.db-journal w]
+ hexio_write test.db-journal 0 74657374306462326a6f75726e616c00
+ hexio_write test.db-journal 16 00000010
+ hexio_write test.db-journal 20 000005e3
+ hexio_write test.db-journal 24 d9d505f920a163d7
+
+ close [open test0db2journal w]
+ hexio_write test0db2journal 0 abcd
+} {2}
+
+do_execsql_test 1.4 {
+ SELECT * FROM t1;
+}
+
+# And now test that nothing bad happens if a master journal contains a
+# pointer to a journal file that does not have a "-" in the name.
+#
+do_test 1.5 {
+ forcedelete test.db2-master test.db-journal test1
+ close [open test.db-journal w]
+ hexio_write test.db-journal 0 746573742e6462322d6d617374657200
+ hexio_write test.db-journal 16 00000010
+ hexio_write test.db-journal 20 0000059f
+ hexio_write test.db-journal 24 d9d505f920a163d7
+
+ close [open test.db2-master w]
+ hexio_write test.db2-master 0 746573743100
+
+ close [open test1 w]
+ hexio_write test1 0 abcd
+} {2}
+
+do_execsql_test 1.6 {
+ SELECT * FROM t1;
+}
+
+#-------------------------------------------------------------------------
+# Check that master journals are not created if the transaction involves
+# multiple temp files.
+#
+db close
+testvfs tvfs
+tvfs filter xOpen
+tvfs script open_cb
+set ::open ""
+proc open_cb {method file arglist} {
+ lappend ::open $file
+}
+
+proc contains_mj {} {
+ foreach f $::open {
+ set t [file tail $f]
+ if {[string match *mj* $t]} { return 1 }
+ }
+ return 0
+}
+
+# Like [do_execsql_test], except that a boolean indicating whether or
+# not a master journal file was opened ([file tail] contains "mj") or
+# not. Example:
+#
+# do_hasmj_test 1.0 { SELECT 'a', 'b' } {0 a b}
+#
+proc do_hasmj_test {tn sql expected} {
+ set ::open [list]
+ uplevel [list do_test $tn [subst -nocommands {
+ set res [execsql "$sql"]
+ concat [contains_mj] [set res]
+ }] [list {*}$expected]]
+}
+
+forcedelete test.db
+forcedelete test.db2
+forcedelete test.db3
+sqlite3 db test.db -vfs tvfs
+
+do_execsql_test 2.0 {
+ ATTACH 'test.db2' AS dbfile;
+ ATTACH '' AS dbtemp;
+ ATTACH ':memory:' AS dbmem;
+
+ CREATE TABLE t1(x);
+ CREATE TABLE dbfile.t2(x);
+ CREATE TABLE dbtemp.t3(x);
+ CREATE TABLE dbmem.t4(x);
+}
+
+# Two real files.
+do_hasmj_test 2.1 {
+ BEGIN;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t2 VALUES(1);
+ COMMIT;
+} {1}
+
+# One real, one temp file.
+do_hasmj_test 2.2 {
+ BEGIN;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t3 VALUES(1);
+ COMMIT;
+} {0}
+
+# One file, one :memory: db.
+do_hasmj_test 2.3 {
+ BEGIN;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t4 VALUES(1);
+ COMMIT;
+} {0}
+
+finish_test
diff --git a/test/mmap1.test b/test/mmap1.test
new file mode 100644
index 0000000..3362f71
--- /dev/null
+++ b/test/mmap1.test
@@ -0,0 +1,323 @@
+# 2013 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !mmap||!incrblob {
+ finish_test
+ return
+}
+source $testdir/lock_common.tcl
+set testprefix mmap1
+
+proc nRead {db} {
+ set bt [btree_from_db $db]
+ db_enter $db
+ array set stats [btree_pager_stats $bt]
+ db_leave $db
+ # puts [array get stats]
+ return $stats(read)
+}
+
+# Return a Tcl script that registers a user-defined scalar function
+# named rblob() with database handle $dbname. The function returns a
+# sequence of pseudo-random blobs based on seed value $seed.
+#
+proc register_rblob_code {dbname seed} {
+ return [subst -nocommands {
+ set ::rcnt $seed
+ proc rblob {n} {
+ set ::rcnt [expr (([set ::rcnt] << 3) + [set ::rcnt] + 456) & 0xFFFFFFFF]
+ set str [format %.8x [expr [set ::rcnt] ^ 0xbdf20da3]]
+ string range [string repeat [set str] [expr [set n]/4]] 1 [set n]
+ }
+ $dbname func rblob rblob
+ }]
+}
+
+
+# For cases 1.1 and 1.4, the number of pages read using xRead() is 4 on
+# unix and 9 on windows. The difference is that windows only ever maps
+# an integer number of OS pages (i.e. creates mappings that are a multiple
+# of 4KB in size). Whereas on unix any sized mapping may be created.
+#
+foreach {t mmap_size nRead c2init} {
+ 1.1 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 0}
+ 1.2 { PRAGMA mmap_size = 53248 } 150 {PRAGMA mmap_size = 0}
+ 1.3 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 0}
+ 1.4 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 67108864 }
+ 1.5 { PRAGMA mmap_size = 53248 } 150 {PRAGMA mmap_size = 67108864 }
+ 1.6 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 67108864 }
+} {
+
+ do_multiclient_test tn {
+ sql1 {PRAGMA cache_size=2000}
+ sql2 {PRAGMA cache_size=2000}
+
+ sql1 {PRAGMA page_size=1024}
+ sql1 $mmap_size
+ sql2 $c2init
+
+ code2 [register_rblob_code db2 0]
+
+ sql2 {
+ PRAGMA page_size=1024;
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ INSERT INTO t1 VALUES(rblob(500), rblob(500));
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 2
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 4
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 8
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 16
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 32
+ }
+ do_test $t.$tn.1 {
+ sql1 "SELECT count(*) FROM t1; PRAGMA integrity_check ; PRAGMA page_count"
+ } {32 ok 77}
+
+ # Have connection 2 shrink the file. Check connection 1 can still read it.
+ sql2 { DELETE FROM t1 WHERE rowid%2; }
+ do_test $t.$tn.2 {
+ sql1 "SELECT count(*) FROM t1; PRAGMA integrity_check ; PRAGMA page_count"
+ } "16 ok [expr {42+[nonzero_reserved_bytes]}]"
+
+ # Have connection 2 grow the file. Check connection 1 can still read it.
+ sql2 { INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1 }
+ do_test $t.$tn.3 {
+ sql1 "SELECT count(*) FROM t1; PRAGMA integrity_check ; PRAGMA page_count"
+ } {32 ok 79}
+
+ # Have connection 2 grow the file again. Check connection 1 is still ok.
+ sql2 { INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1 }
+ do_test $t.$tn.4 {
+ sql1 "SELECT count(*) FROM t1; PRAGMA integrity_check ; PRAGMA page_count"
+ } {64 ok 149}
+
+ # Check that the number of pages read by connection 1 indicates that the
+ # "PRAGMA mmap_size" command worked.
+ if {[nonzero_reserved_bytes]==0} {
+ do_test $t.$tn.5 { nRead db } $nRead
+ }
+ }
+}
+
+set ::rcnt 0
+proc rblob {n} {
+ set ::rcnt [expr (($::rcnt << 3) + $::rcnt + 456) & 0xFFFFFFFF]
+ set str [format %.8x [expr $::rcnt ^ 0xbdf20da3]]
+ string range [string repeat $str [expr $n/4]] 1 $n
+}
+
+reset_db
+db func rblob rblob
+
+ifcapable wal {
+ do_execsql_test 2.1 {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA mmap_size = 67108864;
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ INSERT INTO t1 VALUES(rblob(500), rblob(500));
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 2
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 4
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 8
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 16
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 32
+ PRAGMA wal_checkpoint;
+ } {67108864 wal 0 103 103}
+
+ do_execsql_test 2.2 {
+ PRAGMA auto_vacuum;
+ SELECT count(*) FROM t1;
+ } {1 32}
+
+ if {[permutation] != "inmemory_journal"} {
+ do_test 2.3 {
+ sqlite3 db2 test.db
+ db2 func rblob rblob
+ db2 eval {
+ DELETE FROM t1 WHERE (rowid%4);
+ PRAGMA wal_checkpoint;
+ }
+ db2 eval {
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 16
+ SELECT count(*) FROM t1;
+ }
+ } {16}
+
+ do_execsql_test 2.4 {
+ PRAGMA wal_checkpoint;
+ } {0 24 24}
+ db2 close
+ }
+}
+
+reset_db
+execsql { PRAGMA mmap_size = 67108864; }
+db func rblob rblob
+do_execsql_test 3.1 {
+ PRAGMA auto_vacuum = 1;
+
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ INSERT INTO t1 VALUES(rblob(500), rblob(500));
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 2
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 4
+ INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 8
+
+ CREATE TABLE t2(a, b, UNIQUE(a, b));
+ INSERT INTO t2 SELECT * FROM t1;
+} {}
+
+do_test 3.2 {
+ set nRow 0
+ db eval {SELECT * FROM t2 ORDER BY a, b} {
+ if {$nRow==4} { db eval { DELETE FROM t1 } }
+ incr nRow
+ }
+ set nRow
+} {8}
+
+#-------------------------------------------------------------------------
+# Ensure that existing cursors using xFetch() pages see changes made
+# to rows using the incrblob API.
+#
+reset_db
+execsql { PRAGMA mmap_size = 67108864; }
+set aaa [string repeat a 400]
+set bbb [string repeat b 400]
+set ccc [string repeat c 400]
+set ddd [string repeat d 400]
+set eee [string repeat e 400]
+
+do_execsql_test 4.1 {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES($aaa);
+ INSERT INTO t1 VALUES($bbb);
+ INSERT INTO t1 VALUES($ccc);
+ INSERT INTO t1 VALUES($ddd);
+ SELECT * FROM t1;
+ BEGIN;
+} [list $aaa $bbb $ccc $ddd]
+
+do_test 4.2 {
+ set ::STMT [sqlite3_prepare db "SELECT * FROM t1 ORDER BY rowid" -1 dummy]
+ sqlite3_step $::STMT
+ sqlite3_column_text $::STMT 0
+} $aaa
+
+do_test 4.3 {
+ foreach r {2 3 4} {
+ set fd [db incrblob t1 x $r]
+ puts -nonewline $fd $eee
+ close $fd
+ }
+
+ set res [list]
+ while {"SQLITE_ROW" == [sqlite3_step $::STMT]} {
+ lappend res [sqlite3_column_text $::STMT 0]
+ }
+ set res
+} [list $eee $eee $eee]
+
+do_test 4.4 {
+ sqlite3_finalize $::STMT
+} SQLITE_OK
+
+do_execsql_test 4.5 { COMMIT }
+
+#-------------------------------------------------------------------------
+# Ensure that existing cursors holding xFetch() references are not
+# confused if those pages are moved to make way for the root page of a
+# new table or index.
+#
+reset_db
+execsql { PRAGMA mmap_size = 67108864; }
+do_execsql_test 5.1 {
+ PRAGMA auto_vacuum = 2;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES($aaa);
+ INSERT INTO t1 VALUES($bbb);
+ INSERT INTO t1 VALUES($ccc);
+ INSERT INTO t1 VALUES($ddd);
+
+ PRAGMA auto_vacuum;
+ SELECT * FROM t1;
+} [list 2 $aaa $bbb $ccc $ddd]
+
+do_test 5.2 {
+ set ::STMT [sqlite3_prepare db "SELECT * FROM t1 ORDER BY rowid" -1 dummy]
+ sqlite3_step $::STMT
+ sqlite3_column_text $::STMT 0
+} $aaa
+
+do_execsql_test 5.3 {
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES('tricked you!');
+ INSERT INTO t2 VALUES('tricked you!');
+}
+
+do_test 5.4 {
+ sqlite3_step $::STMT
+ sqlite3_column_text $::STMT 0
+} $bbb
+
+do_test 5.5 {
+ sqlite3_finalize $::STMT
+} SQLITE_OK
+
+#
+# The "6.*" tests are designed to test the interaction of mmap with file
+# truncation (e.g. on Win32) via the VACUUM command.
+#
+forcedelete test2.db
+sqlite3 db2 test2.db
+do_test 6.0 {
+ db2 eval {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 4096;
+ }
+} {}
+do_test 6.1 {
+ db2 eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(randomblob(1000000));
+ }
+} {}
+do_test 6.2 {
+ db2 eval {
+ PRAGMA mmap_size = 1048576;
+ }
+} {1048576}
+do_test 6.3 {
+ expr {[file size test2.db] > 1000000}
+} {1}
+do_test 6.4 {
+ db2 eval {
+ DELETE FROM t1;
+ }
+} {}
+do_test 6.5 {
+ expr {[file size test2.db] > 1000000}
+} {1}
+do_test 6.6 {
+ db2 eval {
+ VACUUM;
+ }
+} {}
+do_test 6.7 {
+ expr {[file size test2.db] < 1000000}
+} {1}
+db2 close
+
+finish_test
diff --git a/test/mmap2.test b/test/mmap2.test
new file mode 100644
index 0000000..1f8346b
--- /dev/null
+++ b/test/mmap2.test
@@ -0,0 +1,87 @@
+# 2013 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.
+#
+#***********************************************************************
+#
+# This file tests the effect of the mmap() or mremap() system calls
+# returning an error on the library.
+#
+# If either mmap() or mremap() fails, SQLite should log an error
+# message, then continue accessing the database using read() and
+# write() exclusively.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix mmap2
+
+if {$::tcl_platform(platform)!="unix" || [test_syscall defaultvfs] != "unix"} {
+ finish_test
+ return
+}
+ifcapable !mmap {
+ finish_test
+ return
+}
+
+db close
+sqlite3_shutdown
+test_sqlite3_log xLog
+proc xLog {error_code msg} {
+ if {[string match os_unix.c* $msg]} {
+ lappend ::log $msg
+ }
+}
+
+foreach syscall {mmap mremap} {
+ test_syscall uninstall
+ if {[catch {test_syscall install $syscall}]} continue
+
+ for {set i 1} {$i < 20} {incr i} {
+ reset_db
+ execsql { PRAGMA mmap_size = 8000000 }
+
+ test_syscall fault $i 1
+ test_syscall errno $syscall ENOMEM
+ set ::log ""
+
+ do_execsql_test 1.$syscall.$i.1 {
+ CREATE TABLE t1(a, b, UNIQUE(a, b));
+ INSERT INTO t1 VALUES(randomblob(1000), randomblob(1000));
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ }
+
+ set nFail [test_syscall fault 0 0]
+
+ do_execsql_test 1.$syscall.$i.2 {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ } {64 ok}
+
+ do_test 1.$syscall.$i.3 {
+ expr {$nFail==0 || $nFail==1}
+ } {1}
+
+ do_test 1.$syscall.$i.4.nFail=$nFail {
+ regexp ".*${syscall}.*" $::log
+ } [expr $nFail>0]
+ }
+}
+
+db close
+test_syscall uninstall
+sqlite3_shutdown
+test_sqlite3_log
+sqlite3_initialize
+finish_test
diff --git a/test/mmap3.test b/test/mmap3.test
new file mode 100644
index 0000000..184dda5
--- /dev/null
+++ b/test/mmap3.test
@@ -0,0 +1,101 @@
+# 2013-05-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
+ifcapable !mmap||!vtab {
+ finish_test
+ return
+}
+source $testdir/lock_common.tcl
+set testprefix mmap3
+
+# A codec shuts down memory-mapped I/O
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+do_test mmap3-1.0 {
+ load_static_extension db wholenumber
+ db eval {
+ PRAGMA mmap_size=100000;
+ CREATE TABLE t1(x, y);
+ CREATE VIRTUAL TABLE nums USING wholenumber;
+ INSERT INTO t1 SELECT value, randomblob(value) FROM nums
+ WHERE value BETWEEN 1 and 1000;
+ SELECT sum(x), sum(length(y)) from t1;
+ PRAGMA mmap_size;
+ }
+} {100000 500500 500500 100000}
+do_test mmap3-1.2 {
+ db eval {
+ PRAGMA mmap_size=50000;
+ CREATE TABLE t2(a,b);
+ SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
+ PRAGMA quick_check;
+ PRAGMA mmap_size;
+ }
+} {50000 nums t1 t2 ok 50000}
+do_test mmap3-1.3 {
+ db eval {
+ PRAGMA mmap_size=250000;
+ DROP TABLE t2;
+ SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
+ PRAGMA quick_check;
+ PRAGMA mmap_size;
+ }
+} {250000 nums t1 ok 250000}
+do_test mmap3-1.4 {
+ db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
+ db eval {PRAGMA mmap_size=150000}
+ }
+ db eval {
+ PRAGMA quick_check;
+ PRAGMA mmap_size;
+ }
+} {ok 250000}
+do_test mmap3-1.5 {
+ db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
+ db eval {PRAGMA mmap_size=0}
+ }
+ db eval {
+ PRAGMA quick_check;
+ PRAGMA mmap_size;
+ }
+} {ok 250000}
+do_test mmap3-1.6 {
+ db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
+ set x [db one {PRAGMA mmap_size}]
+ }
+ set x [concat $x [db eval {
+ PRAGMA quick_check;
+ PRAGMA mmap_size;
+ }]]
+} {250000 ok 250000}
+do_test mmap3-1.7 {
+ db eval {
+ PRAGMA mmap_size(0);
+ CREATE TABLE t3(a,b,c);
+ SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
+ PRAGMA quick_check;
+ PRAGMA mmap_size;
+ }
+} {0 nums t1 t3 ok 0}
+do_test mmap3-1.8 {
+ db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
+ db eval {PRAGMA mmap_size=75000}
+ }
+ db eval {
+ PRAGMA quick_check;
+ PRAGMA mmap_size;
+ }
+} {ok 75000}
+
+finish_test
diff --git a/test/mmap4.test b/test/mmap4.test
new file mode 100644
index 0000000..9701548
--- /dev/null
+++ b/test/mmap4.test
@@ -0,0 +1,104 @@
+# 2016 February 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 tests the effect of the mmap() or mremap() system calls
+# returning an error on the library.
+#
+# If either mmap() or mremap() fails, SQLite should log an error
+# message, then continue accessing the database using read() and
+# write() exclusively.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !mmap {
+ finish_test
+ return
+}
+source $testdir/lock_common.tcl
+set testprefix mmap4
+
+# Return a Tcl script that registers a user-defined scalar function
+# named rblob() with database handle $dbname. The function returns a
+# sequence of pseudo-random blobs based on seed value $seed.
+#
+proc register_rblob_code {dbname seed} {
+ return [subst -nocommands {
+ set ::rcnt $seed
+ proc rblob {n} {
+ set ::rcnt [expr (([set ::rcnt] << 3) + [set ::rcnt] + 456) & 0xFFFFFFFF]
+ set str [format %.8x [expr [set ::rcnt] ^ 0xbdf20da3]]
+ string range [string repeat [set str] [expr [set n]/4]] 1 [set n]
+ }
+ $dbname func rblob rblob
+ }]
+}
+
+#-------------------------------------------------------------------------
+# Test various mmap_size settings.
+#
+foreach {tn1 mmap1 mmap2} {
+ 1 6144 167773
+ 2 18432 140399
+ 3 43008 401302
+ 4 92160 253899
+ 5 190464 2
+ 6 387072 752431
+ 7 780288 291143
+ 8 1566720 594306
+ 9 3139584 829137
+ 10 6285312 793963
+ 11 12576768 1015590
+} {
+ do_multiclient_test tn {
+ sql1 {
+ CREATE TABLE t1(a PRIMARY KEY);
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES('');
+ }
+
+ code1 [register_rblob_code db 0]
+ code2 [register_rblob_code db2 444]
+
+ sql1 "PRAGMA mmap_size = $mmap1"
+ sql2 "PRAGMA mmap_size = $mmap2"
+
+ do_test $tn1.$tn {
+ for {set i 1} {$i <= 100} {incr i} {
+ if {$i % 2} {
+ set c1 sql1
+ set c2 sql2
+ } else {
+ set c1 sql2
+ set c2 sql1
+ }
+
+ $c1 {
+ INSERT INTO t1 VALUES( rblob(5000) );
+ UPDATE t2 SET x = (SELECT md5sum(a) FROM t1);
+ }
+
+ set res [$c2 {
+ SELECT count(*) FROM t1;
+ SELECT x == (SELECT md5sum(a) FROM t1) FROM t2;
+ PRAGMA integrity_check;
+ }]
+ if {$res != [list $i 1 ok]} {
+ do_test $tn1.$tn.$i {
+ set ::res
+ } [list $i 1 ok]
+ }
+ }
+ set res 1
+ } {1}
+ }
+}
+
+finish_test
diff --git a/test/mmapfault.test b/test/mmapfault.test
new file mode 100644
index 0000000..10c5e25
--- /dev/null
+++ b/test/mmapfault.test
@@ -0,0 +1,76 @@
+# 2013-05-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 !mmap {
+ finish_test
+ return
+}
+set testprefix mmapfault
+
+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 1-pre {
+ 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 1 -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA mmap_size = 1000000;
+ PRAGMA cache_size = 5;
+ BEGIN;
+ 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 t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ }
+} -body {
+ execsql { INSERT INTO t1 VALUES(a_string(200), a_string(300)) }
+} -test {
+ faultsim_test_result {0 {}}
+
+ if {[sqlite3_get_autocommit db]} {
+ sqlite3 db2 test.db
+ set nRow [db2 one {SELECT count(*) FROM t1}]
+ if {$nRow!=4} { error "Database content appears incorrect (1)" }
+ db2 close
+ }
+
+ execsql { INSERT INTO t1 VALUES(a_string(201), a_string(301)) }
+ set nRow [db one {SELECT count(*) FROM t1}]
+ if {$nRow!=5 && $nRow!=66 && $nRow!=65} {
+ error "Database content appears incorrect (2) ($nRow)"
+ }
+
+ catch { execsql COMMIT }
+}
+
+
+
+finish_test
diff --git a/test/mmapwarm.test b/test/mmapwarm.test
new file mode 100644
index 0000000..b077047
--- /dev/null
+++ b/test/mmapwarm.test
@@ -0,0 +1,81 @@
+# 20 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+if 0 {
+ db close
+ sqlite3_shutdown
+ proc msg {args} { puts $args }
+ test_sqlite3_log msg
+ sqlite3 db test.db
+}
+
+set testprefix mmapwarm
+
+
+do_execsql_test 1.0 {
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(x, y);
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500
+ )
+ INSERT INTO t1 SELECT randomblob(400), randomblob(500) FROM s;
+ PRAGMA page_count;
+} {507}
+db close
+
+do_test 1.1 {
+ sqlite3 db test.db
+ db eval {PRAGMA mmap_size = 1000000}
+ sqlite3_mmap_warm db
+} {SQLITE_OK}
+
+do_test 1.2 {
+ db close
+ sqlite3 db test.db
+ db eval {PRAGMA mmap_size = 1000000}
+ sqlite3_mmap_warm db "main"
+} {SQLITE_OK}
+
+do_test 1.3 {
+ sqlite3 db test.db
+ sqlite3_mmap_warm db
+} {SQLITE_OK}
+
+do_test 1.4 {
+ db close
+ sqlite3 db test.db
+ sqlite3_mmap_warm db "main"
+} {SQLITE_OK}
+
+do_test 2.0 {
+ db close
+ sqlite3 db test.db
+ db eval BEGIN
+ sqlite3_mmap_warm db "main"
+} {SQLITE_MISUSE}
+
+do_faultsim_test 3 -faults oom* -prep {
+ sqlite3 db test.db
+ sqlite3_db_config_lookaside db 0 0 0
+ db eval { PRAGMA mmap_size = 1000000 }
+ db eval { SELECT * FROM sqlite_master }
+} -body {
+ sqlite3_mmap_warm db "main"
+} -test {
+ faultsim_test_result {0 SQLITE_OK} {0 SQLITE_NOMEM}
+}
+
+finish_test
diff --git a/test/multiplex.test b/test/multiplex.test
new file mode 100644
index 0000000..2f1a02f
--- /dev/null
+++ b/test/multiplex.test
@@ -0,0 +1,615 @@
+# 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
+
+# The tests in this file assume that SQLite is compiled without
+# ENABLE_8_3_NAMES.
+#
+ifcapable 8_3_names {
+ puts -nonewline "SQLite compiled with SQLITE_ENABLE_8_3_NAMES. "
+ puts "Skipping tests multiplex-*."
+ finish_test
+ return
+}
+
+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 "%03d" $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
+sqlite3_shutdown
+test_sqlite3_log xLog
+proc xLog {error_code msg} {
+ lappend ::log $error_code $msg
+}
+unset -nocomplain log
+
+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
+foreach f [glob -nocomplain {test.x*[0-9][0-9][0-9]}] {
+ forcedelete $f
+}
+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_execsql_test multiplex-2.1.5 {
+ PRAGMA multiplex_enabled;
+ PRAGMA multiplex_filecount;
+ PRAGMA multiplex_chunksize;
+} {1 1 2147418112}
+
+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
+} {}
+
+
+unset -nocomplain ::log
+#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.3 {
+# set ::log
+#} {SQLITE_MISUSE {sqlite3_multiplex_shutdown() called while database connections are still open}}
+
+do_test multiplex-2.4.4 { file size [multiplex_name test.x 0] } {7168}
+do_test multiplex-2.4.5 {
+ db close
+ sqlite3 db test.x
+ db eval vacuum
+ db close
+ glob test.x*
+} {test.x}
+do_test multiplex-2.4.99 {
+ 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_execsql_test multiplex-2.5.11 {
+ PRAGMA multiplex_enabled;
+ PRAGMA multiplex_filecount;
+ PRAGMA multiplex_chunksize;
+} {1 3 65536}
+sqlite3 db test.x
+do_execsql_test multiplex-2.5.12 {
+ PRAGMA multiplex_filecount;
+ PRAGMA multiplex_chunksize;
+} {3 65536}
+
+
+
+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 {} {
+ glob -nocomplain test2.db*
+}
+
+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
+} {test2.db}
+
+
+#-------------------------------------------------------------------------
+# 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 { db close }
+catch { sqlite3_multiplex_shutdown }
+sqlite3_shutdown
+test_sqlite3_log
+sqlite3_initialize
+finish_test
diff --git a/test/multiplex2.test b/test/multiplex2.test
new file mode 100644
index 0000000..bdfc05b
--- /dev/null
+++ b/test/multiplex2.test
@@ -0,0 +1,70 @@
+# 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
+source $testdir/lock_common.tcl
+
+
+do_multiclient_test tn {
+ code1 { catch { sqlite3_multiplex_initialize "" 0 } }
+ code2 { catch { sqlite3_multiplex_initialize "" 0 } }
+
+ code1 { db close }
+ code2 { db2 close }
+
+ code1 { sqlite3 db test.db -vfs multiplex }
+ code2 { sqlite3 db2 test.db -vfs multiplex }
+
+ code1 { sqlite3_multiplex_control db main chunk_size [expr 1024*1024] }
+ code2 { sqlite3_multiplex_control db2 main chunk_size [expr 1024*1024] }
+
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(randomblob(10), randomblob(4000)); -- 1
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 2
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 4
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 8
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 64
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 128
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 256
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 512
+ SELECT count(*) FROM t1;
+ }
+
+ do_test multiplex-1.$tn.1 { sql1 { SELECT count(*) FROM t1 } } 512
+ do_test multiplex-1.$tn.2 { sql2 { SELECT count(*) FROM t1 } } 512
+ sql2 { DELETE FROM t1 ; VACUUM }
+ do_test multiplex-1.$tn.3 { sql1 { SELECT count(*) FROM t1 } } 0
+
+ sql1 {
+ INSERT INTO t1 VALUES(randomblob(10), randomblob(4000)); -- 1
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 2
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 4
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 8
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 64
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 128
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 256
+ INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1; -- 512
+ SELECT count(*) FROM t1;
+ }
+
+ do_test multiplex-1.$tn.4 { sql2 { SELECT count(*) FROM t1 } } 512
+}
+
+catch { sqlite3_multiplex_shutdown }
+finish_test
diff --git a/test/multiplex3.test b/test/multiplex3.test
new file mode 100644
index 0000000..c1e741a
--- /dev/null
+++ b/test/multiplex3.test
@@ -0,0 +1,166 @@
+
+# 2011 December 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 contains tests for error (IO, OOM etc.) handling when using
+# the multiplexor extension with 8.3 filenames.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set ::testprefix multiplex3
+
+ifcapable !8_3_names {
+ puts -nonewline "SQLite compiled without SQLITE_ENABLE_8_3_NAMES. "
+ puts "Skipping tests multiplex3-*."
+ finish_test
+ return
+}
+
+db close
+sqlite3_shutdown
+sqlite3_config_uri 1
+autoinstall_test_functions
+
+sqlite3_multiplex_initialize "" 1
+
+proc destroy_vfs_stack {} {
+ generic_unregister stack
+ sqlite3_multiplex_shutdown
+}
+
+proc multiplex_delete_db {} {
+ forcedelete test.db
+ for {set i 1} {$i <= 1000} {incr i} {
+ forcedelete test.[format %03d $i]
+ }
+}
+
+# Procs to save and restore the current muliplexed database.
+#
+proc multiplex_save_db {} {
+ foreach f [glob -nocomplain sv_test.*] { forcedelete $f }
+ foreach f [glob -nocomplain test.*] { forcecopy $f "sv_$f" }
+}
+proc multiplex_restore_db {} {
+ foreach f [glob -nocomplain test.*] {forcedelete $f}
+ foreach f [glob -nocomplain sv_test.*] {forcecopy $f [string range $f 3 end]} }
+
+proc setup_and_save_db {} {
+ multiplex_delete_db
+ sqlite3 db file:test.db?8_3_names=1
+ sqlite3_multiplex_control db main chunk_size [expr 256*1024]
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(randomblob(15), randomblob(2000));
+ INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1; -- 2
+ INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1; -- 4
+ INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1; -- 8
+ INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1; -- 16
+ INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1; -- 32
+ INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1; -- 64
+ INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1; -- 128
+ INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1; -- 256
+ INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1; -- 512
+ }
+ set ::cksum1 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a}]
+ db close
+ multiplex_save_db
+}
+
+do_test 1.0 { setup_and_save_db } {}
+do_faultsim_test 1 -prep {
+ multiplex_restore_db
+ sqlite3 db file:test.db?8_3_names=1
+ sqlite3_multiplex_control db main chunk_size [expr 256*1024]
+} -body {
+ execsql {
+ UPDATE t1 SET a=randomblob(12), b=randomblob(1500) WHERE (rowid%32)=0
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ if {$testrc!=0} {
+ set cksum2 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a}]
+ if {$cksum2 != $::cksum1} { error "data mismatch" }
+ }
+}
+
+#-------------------------------------------------------------------------
+# The following tests verify that hot-journal rollback works. As follows:
+#
+# 1. Create a large database.
+# 2. Set the pager cache to be very small.
+# 3. Open a transaction.
+# 4. Run the following 100 times:
+# a. Update a row.
+# b. Copy all files on disk to a new db location, including the journal.
+# c. Verify that the new db can be opened and that the content matches
+# the database created in step 1 (proving the journal was rolled
+# back).
+
+do_test 2.0 {
+ setup_and_save_db
+ multiplex_restore_db
+ sqlite3 db file:test.db?8_3_names=1
+ execsql { PRAGMA cache_size = 10 }
+ execsql { BEGIN }
+} {}
+
+for {set iTest 1} {$iTest<=100} {incr iTest} {
+ do_test 2.$iTest {
+ execsql {
+ UPDATE t1 SET a=randomblob(12), b=randomblob(1400) WHERE rowid=5*$iTest
+ }
+ foreach f [glob -nocomplain test.*] {forcecopy $f "xx_$f"}
+ sqlite3 db2 file:xx_test.db?8_3_names=1
+ execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a} db2
+ } $::cksum1
+
+ db2 close
+}
+catch { db close }
+
+
+do_test 3.0 { setup_and_save_db } {}
+do_faultsim_test 3 -faults ioerr-trans* -prep {
+
+ forcedelete test2.db
+ set fd [open test2.wal w]
+ seek $fd 4095
+ puts -nonewline $fd x
+ close $fd
+
+ multiplex_restore_db
+ sqlite3 db file:test.db?8_3_names=1
+ sqlite3 db2 file:test2.db?8_3_names=1
+ sqlite3_multiplex_control db main chunk_size [expr 256*1024]
+ sqlite3_multiplex_control db2 main chunk_size [expr 256*1024]
+} -body {
+ sqlite3_backup B db2 main db main
+ B step 100000
+ set rc [B finish]
+ if { [string match SQLITE_IOERR_* $rc] } {error "disk I/O error"}
+ set rc
+} -test {
+ faultsim_test_result {0 SQLITE_OK}
+ if {$testrc==0} {
+ set cksum2 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a} db2]
+ if {$cksum2 != $::cksum1} { error "data mismatch" }
+ }
+ catch { B finish }
+ catch { db close }
+ catch { db2 close }
+}
+
+catch { db close }
+sqlite3_multiplex_shutdown
+finish_test
diff --git a/test/multiplex4.test b/test/multiplex4.test
new file mode 100644
index 0000000..2caebea
--- /dev/null
+++ b/test/multiplex4.test
@@ -0,0 +1,132 @@
+# 2014-09-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 tests for the "truncate" option in the multiplexor.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix multiplex4
+
+db close
+sqlite3_shutdown
+sqlite3_multiplex_initialize {} 0
+
+# delete all filesl with the base name of $basename
+#
+proc multiplex_delete_db {basename} {
+ foreach file [glob -nocomplain $basename.*] {
+ forcedelete $file
+ }
+}
+
+# Return a sorted list of all files with the base name of $basename.
+# Except, delete all text from the end of $basename through the NNN
+# suffix on the end of the filename.
+#
+proc multiplex_file_list {basename} {
+ set x {}
+ foreach file [glob -nocomplain $basename.*] {
+ regsub "^$basename\\..*(\\d\\d\\d)\$" $file $basename.\\1 file
+ lappend x $file
+ }
+ return [lsort $x]
+}
+
+do_test multiplex4-1.0 {
+ multiplex_delete_db mx4test
+ sqlite3 db {file:mx4test.db?chunksize=10&truncate=1} -uri 1 -vfs multiplex
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(randomblob(250000));
+ }
+ multiplex_file_list mx4test
+} {mx4test.001 mx4test.db}
+
+do_test multiplex4-1.1 {
+ db eval {
+ DELETE FROM t1;
+ VACUUM;
+ }
+ multiplex_file_list mx4test
+} {mx4test.db}
+
+# NB: The PRAGMA multiplex_truncate command is implemented using the
+# SQLITE_FCNTL_PRAGMA file-control...
+#
+# EVIDENCE-OF: R-12238-55120 Whenever a PRAGMA statement is parsed, an
+# SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file
+# object corresponding to the database file to which the pragma
+# statement refers.
+#
+do_test multiplex4-1.2 {
+ db eval {PRAGMA multiplex_truncate}
+} {on}
+do_test multiplex4-1.3 {
+ db eval {PRAGMA multiplex_truncate=off}
+} {off}
+do_test multiplex4-1.4 {
+ db eval {PRAGMA multiplex_truncate}
+} {off}
+do_test multiplex4-1.5 {
+ db eval {PRAGMA multiplex_truncate=on}
+} {on}
+do_test multiplex4-1.6 {
+ db eval {PRAGMA multiplex_truncate}
+} {on}
+do_test multiplex4-1.7 {
+ db eval {PRAGMA multiplex_truncate=0}
+} {off}
+do_test multiplex4-1.8 {
+ db eval {PRAGMA multiplex_truncate=1}
+} {on}
+do_test multiplex4-1.9 {
+ db eval {PRAGMA multiplex_truncate=0}
+} {off}
+
+# EVIDENCE-OF: R-26188-08449 If the SQLITE_FCNTL_PRAGMA file control
+# returns SQLITE_OK, then the parser assumes that the VFS has handled
+# the PRAGMA itself and the parser generates a no-op prepared statement
+# if result string is NULL, or that returns a copy of the result string
+# if the string is non-NULL.
+#
+do_test multiplex4-1.9-explain {
+ db eval {EXPLAIN PRAGMA multiplex_truncate=0;}
+} {/String8 \d \d \d off/}
+
+do_test multiplex4-1.10 {
+ db eval {
+ INSERT INTO t1(x) VALUES(randomblob(250000));
+ }
+ multiplex_file_list mx4test
+} {mx4test.001 mx4test.db}
+
+do_test multiplex4-1.11 {
+ db eval {
+ DELETE FROM t1;
+ VACUUM;
+ }
+ multiplex_file_list mx4test
+} {mx4test.001 mx4test.db}
+
+do_test multiplex4-1.12 {
+ db eval {
+ PRAGMA multiplex_truncate=ON;
+ DROP TABLE t1;
+ VACUUM;
+ }
+ multiplex_file_list mx4test
+} {mx4test.db}
+
+catch { db close }
+forcedelete mx4test.db
+sqlite3_multiplex_shutdown
+finish_test
diff --git a/test/mutex1.test b/test/mutex1.test
new file mode 100644
index 0000000..aac04bf
--- /dev/null
+++ b/test/mutex1.test
@@ -0,0 +1,215 @@
+# 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_main' 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_main)
+ 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_main)
+} {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 threadsafe1&&shared_cache {
+ set enable_shared_cache [sqlite3_enable_shared_cache 1]
+ foreach {mode mutexes} {
+ singlethread {}
+ multithread {
+ fast static_app1 static_app2 static_app3
+ static_lru static_main static_mem static_open
+ static_prng static_pmem static_vfs1 static_vfs2
+ static_vfs3
+ }
+ serialized {
+ fast recursive static_app1 static_app2
+ static_app3 static_lru static_main static_mem
+ static_open static_prng static_pmem static_vfs1
+ static_vfs2 static_vfs3
+ }
+ } {
+
+ 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
+ }
+ if {$mode ne "singlethread"} {
+ do_test mutex1.2.$mode.3 {
+ #
+ # NOTE: Make sure all the app and vfs mutexes get used.
+ #
+ enter_static_mutex static_app1
+ leave_static_mutex static_app1
+ enter_static_mutex static_app2
+ leave_static_mutex static_app2
+ enter_static_mutex static_app3
+ leave_static_mutex static_app3
+ enter_static_mutex static_vfs1
+ leave_static_mutex static_vfs1
+ enter_static_mutex static_vfs2
+ leave_static_mutex static_vfs2
+ enter_static_mutex static_vfs3
+ leave_static_mutex static_vfs3
+ } {}
+ }
+ do_test mutex1.2.$mode.4 {
+ 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..615a4ad
--- /dev/null
+++ b/test/nan.test
@@ -0,0 +1,375 @@
+# 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.
+#
+if {![nonzero_reserved_bytes]} {
+ 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}
+
+do_realnum_test nan-4.40 {
+ db eval {
+ SELECT cast('-1e999' AS real);
+ }
+} {-inf}
+
+finish_test
diff --git a/test/nockpt.test b/test/nockpt.test
new file mode 100644
index 0000000..4cc61d1
--- /dev/null
+++ b/test/nockpt.test
@@ -0,0 +1,147 @@
+# 2016 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 the SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE
+# option.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+source $testdir/wal_common.tcl
+ifcapable !wal {finish_test ; return }
+if {[permutation]=="journaltest" || [permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+set testprefix nockpt
+
+do_execsql_test 1.0 {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = wal;
+ CREATE TABLE c1(x, y, z);
+ INSERT INTO c1 VALUES(1, 2, 3);
+} {wal}
+
+do_test 1.1 { file exists test.db-wal } 1
+do_test 1.2 { file size test.db-wal } [wal_file_size 3 1024]
+do_test 1.3 { db close } {}
+do_test 1.4 { file exists test.db-wal } 0
+
+sqlite3 db test.db
+do_execsql_test 1.5 {
+ INSERT INTO c1 VALUES(4, 5, 6);
+ INSERT INTO c1 VALUES(7, 8, 9);
+}
+do_test 1.6 { file exists test.db-wal } 1
+do_test 1.7 { sqlite3_db_config db NO_CKPT_ON_CLOSE 1 } {1}
+do_test 1.8 { file size test.db-wal } [wal_file_size 2 1024]
+do_test 1.9 { db close } {}
+do_test 1.10 { file exists test.db-wal } 1
+do_test 1.11 { file size test.db-wal } [wal_file_size 2 1024]
+
+sqlite3 db test.db
+do_execsql_test 1.12 {
+ SELECT * FROM c1
+} {1 2 3 4 5 6 7 8 9}
+
+do_execsql_test 1.13 { PRAGMA main.journal_mode } {wal}
+do_test 1.14 { sqlite3_db_config db NO_CKPT_ON_CLOSE 1 } {1}
+do_execsql_test 1.14 { PRAGMA main.journal_mode = delete } {delete}
+do_test 1.15 { file exists test.db-wal } {0}
+
+if {$::tcl_platform(platform)!="windows"} {
+#-------------------------------------------------------------------------
+# Test an unusual scenario:
+#
+# 1. A wal mode db is opened and written. Then sqlite3_close_v2() used
+# to close the db handle while there is still an unfinalized
+# statement (so the db handle stays open).
+#
+# 2. The db, wal and *-shm files are deleted from the file system.
+#
+# 3. Another connection creates a new wal mode db at the same file-system
+# location as the previous one.
+#
+# 4. The statement left unfinalized in (1) is finalized.
+#
+# The test is to ensure that the connection left open in step (1) does
+# not try to delete the wal file from the file-system as part of step
+# 4.
+#
+reset_db
+db close
+
+# Open a connection on a wal database. Write to it a bit. Then prepare
+# a statement and call sqlite3_close_v2() (so that the statement handle
+# holds the db connection open).
+#
+set ::db1 [sqlite3_open_v2 test.db SQLITE_OPEN_READWRITE ""]
+do_test 2.0 {
+ lindex [
+ sqlite3_exec $::db1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x PRIMARY KEY, y UNIQUE, z);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ PRAGMA wal_checkpoint;
+ }] 0
+} {0}
+set ::stmt [sqlite3_prepare $::db1 "SELECT * FROM t1" -1 dummy]
+sqlite3_close_v2 $::db1
+
+# Delete the database, wal and shm files.
+#
+forcedelete test.db test.db-wal test.db-shm
+
+# Open and populate a new database file at the same file-system location
+# as the one just deleted. Contrive a partial checkpoint on it.
+#
+sqlite3 db test.db
+sqlite3 db2 test.db
+do_execsql_test 2.1 {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA journal_mode = wal;
+ CREATE TABLE y1(a PRIMARY KEY, b UNIQUE, c);
+ INSERT INTO y1 VALUES('a', 'b', 'c');
+ INSERT INTO y1 VALUES('d', 'e', 'f');
+} {wal}
+do_execsql_test -db db2 2.2 {
+ BEGIN;
+ SELECT * FROM y1;
+} {a b c d e f}
+do_execsql_test 2.3 {
+ UPDATE y1 SET c='g' WHERE a='d';
+ PRAGMA wal_checkpoint;
+} {0 11 10}
+do_execsql_test -db db2 2.4 {
+ COMMIT
+}
+
+# Finalize the statement handle, causing the first connection to be
+# closed. Test that this has not corrupted the database file by
+# deleting the new wal file from the file-system. If it has, this
+# test should fail with an IO or corruption error.
+#
+do_test 2.5 {
+ sqlite3_finalize $::stmt
+ sqlite3 db3 test.db
+ execsql {
+ PRAGMA integrity_check;
+ SELECT * FROM y1;
+ } db3
+} {ok a b c d e g}
+}
+
+
+finish_test
diff --git a/test/nolock.test b/test/nolock.test
new file mode 100644
index 0000000..e732dcf
--- /dev/null
+++ b/test/nolock.test
@@ -0,0 +1,220 @@
+# 2014-05-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 file is testing the nolock=1 and immutable=1 query
+# parameters and the SQLITE_IOCAP_IMMUTABLE device characteristic.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+unset -nocomplain tvfs_calls
+proc tvfs_reset {} {
+ global tvfs_calls
+ array set tvfs_calls {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}
+}
+proc tvfs_callback {op args} {
+ global tvfs_calls
+ incr tvfs_calls($op)
+ return SQLITE_OK
+}
+tvfs_reset
+
+testvfs tvfs
+tvfs script tvfs_callback
+tvfs filter {xLock xUnlock xCheckReservedLock xAccess}
+
+############################################################################
+# Verify that the nolock=1 query parameter for URI filenames disables all
+# calls to xLock and xUnlock for rollback databases.
+#
+do_test nolock-1.0 {
+ db close
+ forcedelete test.db
+ tvfs_reset
+ sqlite db test.db -vfs tvfs
+ db eval {CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3);}
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock)
+} {xLock 7 xUnlock 5 xCheckReservedLock 0}
+
+do_test nolock-1.1 {
+ db close
+ forcedelete test.db
+ tvfs_reset
+ sqlite db file:test.db?nolock=0 -vfs tvfs -uri 1
+ db eval {CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3);}
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock)
+} {xLock 7 xUnlock 5 xCheckReservedLock 0}
+
+do_test nolock-1.2 {
+ db close
+ forcedelete test.db
+ tvfs_reset
+ sqlite db file:test.db?nolock=1 -vfs tvfs -uri 1
+ db eval {CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3);}
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock)
+} {xLock 0 xUnlock 0 xCheckReservedLock 0}
+
+do_test nolock-1.3 {
+ db close
+ tvfs_reset
+ sqlite db file:test.db?nolock=0 -vfs tvfs -uri 1 -readonly 1
+ db eval {SELECT * FROM t1}
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock)
+} {xLock 2 xUnlock 2 xCheckReservedLock 0}
+
+do_test nolock-1.4 {
+ db close
+ tvfs_reset
+ sqlite db file:test.db?nolock=1 -vfs tvfs -uri 1 -readonly 1
+ db eval {SELECT * FROM t1}
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock)
+} {xLock 0 xUnlock 0 xCheckReservedLock 0}
+
+#############################################################################
+# Verify that immutable=1 disables both locking and xAccess calls to the
+# journal files.
+#
+do_test nolock-2.0 {
+ db close
+ forcedelete test.db
+ # begin by creating a test database
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES('hello','world');
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(12345,67890);
+ SELECT * FROM t1, t2;
+ }
+} {hello world 12345 67890}
+do_test nolock-2.1 {
+ tvfs_reset
+ sqlite3 db2 test.db -vfs tvfs
+ db2 eval {SELECT * FROM t1, t2}
+} {hello world 12345 67890}
+do_test nolock-2.2 {
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \
+ xAccess $::tvfs_calls(xAccess)
+} {xLock 2 xUnlock 2 xCheckReservedLock 0 xAccess 4}
+
+
+do_test nolock-2.11 {
+ db2 close
+ tvfs_reset
+ sqlite3 db2 file:test.db?immutable=0 -vfs tvfs -uri 1
+ db2 eval {SELECT * FROM t1, t2}
+} {hello world 12345 67890}
+do_test nolock-2.12 {
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \
+ xAccess $::tvfs_calls(xAccess)
+} {xLock 2 xUnlock 2 xCheckReservedLock 0 xAccess 4}
+
+
+do_test nolock-2.21 {
+ db2 close
+ tvfs_reset
+ sqlite3 db2 file:test.db?immutable=1 -vfs tvfs -uri 1
+ db2 eval {SELECT * FROM t1, t2}
+} {hello world 12345 67890}
+do_test nolock-2.22 {
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \
+ xAccess $::tvfs_calls(xAccess)
+} {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}
+
+do_test nolock-2.31 {
+ db2 close
+ tvfs_reset
+ sqlite3 db2 file:test.db?immutable=1 -vfs tvfs -uri 1 -readonly 1
+ db2 eval {SELECT * FROM t1, t2}
+} {hello world 12345 67890}
+do_test nolock-2.32 {
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \
+ xAccess $::tvfs_calls(xAccess)
+} {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}
+
+############################################################################
+# Verify that the SQLITE_IOCAP_IMMUTABLE flag works
+#
+do_test nolock-3.1 {
+ db2 close
+ tvfs devchar immutable
+ tvfs_reset
+ sqlite3 db2 test.db -vfs tvfs
+ db2 eval {SELECT * FROM t1, t2}
+} {hello world 12345 67890}
+do_test nolock-3.2 {
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \
+ xAccess $::tvfs_calls(xAccess)
+} {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}
+
+do_test nolock-3.11 {
+ db2 close
+ tvfs_reset
+ sqlite3 db2 test.db -vfs tvfs -readonly 1
+ db2 eval {SELECT * FROM t1, t2}
+} {hello world 12345 67890}
+do_test nolock-3.12 {
+ list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \
+ xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \
+ xAccess $::tvfs_calls(xAccess)
+} {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}
+
+db2 close
+db close
+tvfs delete
+
+if {[permutation]!="inmemory_journal"} {
+ # 2016-03-11: Make sure all works when transitioning to WAL mode
+ # under nolock.
+ #
+ do_test nolock-4.1 {
+ forcedelete test.db
+ sqlite3 db file:test.db?nolock=1 -uri 1
+ db eval {
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('youngling');
+ SELECT * FROM t1;
+ }
+ } {delete youngling}
+ db close
+
+ do_test nolock-4.2 {
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('catbird');
+ SELECT * FROM t1;
+ }
+ } {wal catbird}
+ do_test nolock-4.3 {
+ db close
+ sqlite3 db file:test.db?nolock=1 -uri 1
+ set rc [catch {db eval {SELECT * FROM t1}} msg]
+ lappend rc $msg
+ } {1 {unable to open database file}}
+}
+
+finish_test
diff --git a/test/normalize.test b/test/normalize.test
new file mode 100644
index 0000000..29a5aab
--- /dev/null
+++ b/test/normalize.test
@@ -0,0 +1,394 @@
+# 2018-01-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.
+#
+#***********************************************************************
+#
+# Tests for the sqlite3_normalize() extension function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix normalize
+
+foreach {tnum sql norm} {
+ 100
+ {SELECT * FROM t1 WHERE a IN (1) AND b=51.42}
+ {select*from t1 where a in(?,?,?)and b=?;}
+
+ 110
+ {SELECT a, b+15, c FROM t1 WHERE d NOT IN (SELECT x FROM t2);}
+ {select a,b+?,c from t1 where d not in(select x from t2);}
+
+ 120
+ { SELECT NULL, b FROM t1 -- comment text
+ WHERE d IN (WITH t(a) AS (VALUES(5)) /* CTE */
+ SELECT a FROM t)
+ OR e='hello';
+ }
+ {select?,b from t1 where d in(with t(a)as(values(?))select a from t)or e=?;}
+
+ 121
+ {/*Initial comment*/
+ -- another comment line
+ SELECT NULL /* comment */ , b FROM t1 -- comment text
+ WHERE d IN (WITH t(a) AS (VALUES(5)) /* CTE */
+ SELECT a FROM t)
+ OR e='hello';
+ }
+ {select?,b from t1 where d in(with t(a)as(values(?))select a from t)or e=?;}
+
+ 130
+ {/* Query containing parameters */
+ SELECT x,$::abc(15),y,@abc,z,?99,w FROM t1 /* Trailing comment */}
+ {select x,?,y,?,z,?,w from t1;}
+
+ 140
+ {/* Long list on the RHS of IN */
+ SELECT 15 IN (1,2,3,(SELECT * FROM t1),'xyz',x'abcd',22*(x+5),null);}
+ {select?in(?,?,?);}
+
+ 150
+ {SELECT x'abc'; -- illegal token}
+ {}
+
+ 160
+ {SELECT a,NULL,b FROM t1 WHERE c IS NOT NULL or D is null or e=5}
+ {select a,?,b from t1 where c is not null or d is null or e=?;}
+
+ 170
+ {/* IN list exactly 5 bytes long */
+ SELECT * FROM t1 WHERE x IN (1,2,3);}
+ {select*from t1 where x in(?,?,?);}
+ 180
+ { }
+ {}
+} {
+ do_test $tnum [list sqlite3_normalize $sql] $norm
+}
+
+ifcapable normalize {
+do_test 200 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ }
+} {}
+do_test 201 {
+ set STMT [sqlite3_prepare_v3 $DB \
+ "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 0 TAIL]
+
+ sqlite3_bind_null $STMT 1
+} {}
+do_test 202 {
+ sqlite3_normalized_sql $STMT
+} {SELECT a,b FROM t1 WHERE b=?ORDER BY a;}
+do_test 203 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test 210 {
+ set STMT [sqlite3_prepare_v3 $DB \
+ "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 2 TAIL]
+
+ sqlite3_bind_null $STMT 1
+} {}
+do_test 211 {
+ sqlite3_normalized_sql $STMT
+} {SELECT a,b FROM t1 WHERE b=?ORDER BY a;}
+do_test 212 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test 220 {
+ set STMT [sqlite3_prepare_v3 $DB \
+ "SELECT a, b FROM t1 WHERE b = 'a' ORDER BY a;" -1 2 TAIL]
+} {/^[0-9A-Fa-f]+$/}
+do_test 221 {
+ sqlite3_normalized_sql $STMT
+} {SELECT a,b FROM t1 WHERE b=?ORDER BY a;}
+do_test 222 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test 297 {
+ execsql {
+ DROP TABLE t1;
+ }
+} {}
+do_test 298 {
+ execsql {
+ CREATE TABLE t1(a,b,c,d,e,"col f",w,x,y,z);
+ CREATE TABLE t2(x,"col y");
+ }
+} {}
+do_test 299 {
+ sqlite3_create_function db
+} {SQLITE_OK}
+
+foreach {tnum sql flags norm} {
+ 300
+ {SELECT * FROM t1 WHERE a IN (1) AND b=51.42}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE a IN(?,?,?)AND b=?;}}
+
+ 310
+ {SELECT a, b+15, c FROM t1 WHERE d NOT IN (SELECT x FROM t2);}
+ 0x2
+ {0 {SELECT a,b+?,c FROM t1 WHERE d NOT IN(SELECT x FROM t2);}}
+
+ 320
+ { SELECT NULL, b FROM t1 -- comment text
+ WHERE d IN (WITH t(a) AS (VALUES(5)) /* CTE */
+ SELECT a FROM t)
+ OR e='hello';
+ }
+ 0x2
+ {0 {SELECT?,b FROM t1 WHERE d IN(WITH t(a)AS(VALUES(?))SELECT a FROM t)OR e=?;}}
+
+ 321
+ {/*Initial comment*/
+ -- another comment line
+ SELECT NULL /* comment */ , b FROM t1 -- comment text
+ WHERE d IN (WITH t(a) AS (VALUES(5)) /* CTE */
+ SELECT a FROM t)
+ OR e='hello';
+ }
+ 0x2
+ {0 {SELECT?,b FROM t1 WHERE d IN(WITH t(a)AS(VALUES(?))SELECT a FROM t)OR e=?;}}
+
+ 330
+ {/* Query containing parameters */
+ SELECT x,$::abc(15),y,@abc,z,?99,w FROM t1 /* Trailing comment */}
+ 0x2
+ {0 {SELECT x,?,y,?,z,?,w FROM t1;}}
+
+ 340
+ {/* Long list on the RHS of IN */
+ SELECT 15 IN (1,2,3,(SELECT * FROM t1),'xyz',x'abcd',22*(x+5),null);}
+ 0x2
+ {1 {(1) no such column: x}}
+
+ 350
+ {SELECT x'abc'; -- illegal token}
+ 0x2
+ {1 {(1) unrecognized token: "x'abc'"}}
+
+ 360
+ {SELECT a,NULL,b FROM t1 WHERE c IS NOT NULL or D is null or e=5}
+ 0x2
+ {0 {SELECT a,?,b FROM t1 WHERE c IS NOT NULL OR d IS NULL OR e=?;}}
+
+ 370
+ {/* IN list exactly 5 bytes long */
+ SELECT * FROM t1 WHERE x IN (1,2,3);}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(?,?,?);}}
+
+ 400
+ {SELECT a FROM t1 WHERE x IN (1,2,3) AND sqlite_version();}
+ 0x2
+ {0 {SELECT a FROM t1 WHERE x IN(?,?,?)AND sqlite_version();}}
+
+ 410
+ {SELECT a FROM t1 WHERE x IN (1,2,3) AND hex8();}
+ 0x2
+ {1 {(1) wrong number of arguments to function hex8()}}
+
+ 420
+ {SELECT a FROM t1 WHERE x IN (1,2,3) AND hex8('abc');}
+ 0x2
+ {0 {SELECT a FROM t1 WHERE x IN(?,?,?)AND hex8(?);}}
+
+ 430
+ {SELECT "a" FROM t1 WHERE "x" IN ("1","2",'3');}
+ 0x2
+ {0 {SELECT a FROM t1 WHERE x IN(?,?,?);}}
+
+ 440
+ {SELECT 'a' FROM t1 WHERE 'x';}
+ 0x2
+ {0 {SELECT?FROM t1 WHERE?;}}
+
+ 450
+ {SELECT [a] FROM t1 WHERE [x];}
+ 0x2
+ {0 {SELECT a FROM t1 WHERE x;}}
+
+ 460
+ {SELECT * FROM t1 WHERE x IN (x);}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(x);}}
+
+ 470
+ {SELECT * FROM t1 WHERE x IN (x,a);}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(x,a);}}
+
+ 480
+ {SELECT * FROM t1 WHERE x IN ([x],"a");}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(x,a);}}
+
+ 500
+ {SELECT * FROM t1 WHERE x IN ([x],"a",'b',sqlite_version());}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(x,a,?,sqlite_version());}}
+
+ 520
+ {SELECT * FROM t1 WHERE x IN (SELECT x FROM t1);}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(SELECT x FROM t1);}}
+
+ 540
+ {SELECT * FROM t1 WHERE x IN ((SELECT x FROM t1));}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN((SELECT x FROM t1));}}
+
+ 550
+ {SELECT a, a+1, a||'b', a+"b" FROM t1;}
+ 0x2
+ {0 {SELECT a,a+?,a||?,a+b FROM t1;}}
+
+ 570
+ {SELECT * FROM t1 WHERE x IN (1);}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(?,?,?);}}
+
+ 580
+ {SELECT * FROM t1 WHERE x IN (1,2);}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(?,?,?);}}
+
+ 590
+ {SELECT * FROM t1 WHERE x IN (1,2,3);}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(?,?,?);}}
+
+ 600
+ {SELECT * FROM t1 WHERE x IN (1,2,3,4);}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(?,?,?);}}
+
+ 610
+ {SELECT * FROM t1 WHERE x IN (SELECT x FROM t1);}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(SELECT x FROM t1);}}
+
+ 620
+ {SELECT * FROM t1 WHERE x IN (SELECT x FROM t1 WHERE x IN (1,2,3));}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(?,?,?));}}
+
+ 630
+ {SELECT * FROM t1 WHERE x IN (SELECT x FROM t1 WHERE x IN (x));}
+ 0x2
+ {0 {SELECT*FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(x));}}
+
+ 640
+ {SELECT x FROM t1 WHERE x IN (SELECT x FROM t1 WHERE x IN (
+ SELECT x FROM t1 WHERE x IN (SELECT x FROM t1 WHERE x IN (
+ SELECT x FROM t1 WHERE x IN (x)))));}
+ 0x2
+ {0 {SELECT x FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(x)))));}}
+
+ 650
+ {SELECT x FROM t1 WHERE x IN (SELECT x FROM t1 WHERE x IN (
+ SELECT x FROM t1 WHERE x IN (SELECT x FROM t1 WHERE x IN (
+ SELECT x FROM t1 WHERE x IN (1)))));}
+ 0x2
+ {0 {SELECT x FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(SELECT x FROM t1 WHERE x IN(?,?,?)))));}}
+
+ 660
+ {SELECT x FROM t1 WHERE x IN (1) UNION ALL SELECT x FROM t1 WHERE x IN (1);}
+ 0x2
+ {0 {SELECT x FROM t1 WHERE x IN(?,?,?)UNION ALL SELECT x FROM t1 WHERE x IN(?,?,?);}}
+
+ 670
+ {SELECT "col f", [col f] FROM t1;}
+ 0x2
+ {0 {SELECT"col f","col f"FROM t1;}}
+
+ 680
+ {SELECT a, "col f" FROM t1 LEFT OUTER JOIN t2 ON [t1].[col f] == [t2].[col y];}
+ 0x2
+ {0 {SELECT a,"col f"FROM t1 LEFT OUTER JOIN t2 ON t1."col f"==t2."col y";}}
+
+ 690
+ {SELECT * FROM ( WITH x AS ( SELECT * FROM t1 WHERE x IN ( 1)) SELECT 10);}
+ 0x2
+ {0 {SELECT*FROM(WITH x AS(SELECT*FROM t1 WHERE x IN(?,?,?))SELECT?);}}
+
+ 700
+ {SELECT rowid, oid, _rowid_ FROM t1;}
+ 0x2
+ {0 {SELECT rowid,oid,_rowid_ FROM t1;}}
+
+ 710
+ {SELECT x FROM t1 WHERE x IS NULL;}
+ 0x2
+ {0 {SELECT x FROM t1 WHERE x IS NULL;}}
+
+ 740
+ {SELECT x FROM t1 WHERE x IS NOT NULL;}
+ 0x2
+ {0 {SELECT x FROM t1 WHERE x IS NOT NULL;}}
+
+ 750
+ {SELECT x FROM t1 WHERE x = NULL;}
+ 0x2
+ {0 {SELECT x FROM t1 WHERE x=?;}}
+
+ 760
+ {SELECT x FROM t1 WHERE x IN ([x] IS NOT NULL, NULL, 1, 'a', "b", x'00');}
+ 0x2
+ {0 {SELECT x FROM t1 WHERE x IN(x IS NOT NULL,?,?,?,b,?);}}
+
+ 800
+ {ATTACH "normalize800.db" AS somefile;}
+ 0x2
+ {0 {ATTACH"normalize800.db"AS somefile;}}
+
+ 810
+ {ATTACH DATABASE "normalize810.db" AS somefile;}
+ 0x2
+ {0 {ATTACH DATABASE"normalize810.db"AS somefile;}}
+
+ 900
+ {INSERT INTO t1 (x) VALUES("sl1"), (1), ("sl2"), ('i');}
+ 0x2
+ {0 {INSERT INTO t1(x)VALUES(?),(?),(?),(?);}}
+
+ 910
+ {UPDATE t1 SET x = "sl1" WHERE x IN (1, "sl2", 'i');}
+ 0x2
+ {0 {UPDATE t1 SET x=?WHERE x IN(?,?,?);}}
+
+ 920
+ {UPDATE t1 SET x = "y" WHERE x IN (1, "sl1", 'i');}
+ 0x2
+ {0 {UPDATE t1 SET x=y WHERE x IN(?,?,?);}}
+
+ 930
+ {DELETE FROM t1 WHERE x IN (1, "sl1", 'i');}
+ 0x2
+ {0 {DELETE FROM t1 WHERE x IN(?,?,?);}}
+} {
+ do_test $tnum {
+ set code [catch {
+ set STMT [sqlite3_prepare_v3 $DB $sql -1 $flags TAIL]
+ sqlite3_normalized_sql $STMT
+ } res]
+ if {[info exists STMT]} {
+ sqlite3_finalize $STMT; unset STMT
+ }
+ list $code $res
+ } $norm
+}
+}
+
+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..12c6a53
--- /dev/null
+++ b/test/notify2.test
@@ -0,0 +1,267 @@
+# 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]
+ set nOp 0
+ set nAttempt 0
+ 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.
+ #
+ incr nAttempt
+ 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 occurred. Check that any SELECT statements in the transaction
+ # returned "1". Otherwise, the invariant was false, indicating that
+ # some malfunction has occurred.
+ foreach r $msg { if {$r != 1} { puts "Invariant check failed: $msg" } }
+ incr nOp
+ }
+ }
+
+ # Close the database connection and return 0.
+ #
+ sqlite3_close $::DB
+ list $nOp $nAttempt
+}
+
+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) }
+ incr anSuccess($xStep) [lindex $finished($ii) 0]
+ incr anAttempt($xStep) [lindex $finished($ii) 1]
+ expr 0
+ } {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(). "Faster" in this case means uses fewer
+# CPU cycles. This is not always the same as faster in wall-clock time
+# for this type of test. The number of CPU cycles per transaction is
+# roughly proportional to the number of attempts made (i.e. one plus the
+# number of SQLITE_BUSY or SQLITE_LOCKED errors that require the transaction
+# to be retried). So this test just measures that a greater percentage of
+# transactions attempted using blocking_step() succeed.
+#
+# The blocking_step() function is almost 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 more efficiently. This test"
+puts "sometimes fails on single-core machines."
+puts [array get anWrite]
+do_test notify2-3 {
+ set blocking [expr {
+ double($anSuccess(sqlite3_blocking_step)) /
+ double($anAttempt(sqlite3_blocking_step))
+ }]
+ set non [expr {
+ double($anSuccess(sqlite3_step)) /
+ double($anAttempt(sqlite3_step))
+ }]
+ puts -nonewline [format " blocking: %.1f%% non-blocking %.1f%% ..." \
+ [expr $blocking*100.0] [expr $non*100.0]]
+
+ expr {$blocking > $non}
+} {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..4b5e801
--- /dev/null
+++ b/test/notify3.test
@@ -0,0 +1,152 @@
+# 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..23abe31
--- /dev/null
+++ b/test/notnull.test
@@ -0,0 +1,608 @@
+# 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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-1.2b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-1.4b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-1.5b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.b}}
+verify_ex_errcode notnull-1.10b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.c}}
+verify_ex_errcode notnull-1.16b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.d}}
+verify_ex_errcode notnull-1.17b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.e}}
+verify_ex_errcode notnull-1.20b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-2.1b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-2.2b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-2.4b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.b}}
+verify_ex_errcode notnull-2.6b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.e}}
+verify_ex_errcode notnull-2.10b SQLITE_CONSTRAINT_NOTNULL
+
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-3.2b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-3.4b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-3.5b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.b}}
+verify_ex_errcode notnull-3.10b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.c}}
+verify_ex_errcode notnull-3.16b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.d}}
+verify_ex_errcode notnull-3.17b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.e}}
+verify_ex_errcode notnull-3.20b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-4.1b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-4.2b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.a}}
+verify_ex_errcode notnull-4.4b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.b}}
+verify_ex_errcode notnull-4.5b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.e}}
+verify_ex_errcode notnull-4.10b SQLITE_CONSTRAINT_NOTNULL
+
+# 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 {NOT NULL constraint failed: t1.b}}
+verify_ex_errcode notnull-5.2b SQLITE_CONSTRAINT_NOTNULL
+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 {NOT NULL constraint failed: t1.b}}
+verify_ex_errcode notnull-5.4b SQLITE_CONSTRAINT_NOTNULL
+do_test notnull-5.5 {
+ execsql { SELECT * FROM t1 }
+} {1 2}
+
+#-------------------------------------------------------------------------
+# Check that UNIQUE NOT NULL indexes are always recognized as such.
+#
+proc uses_op_next {sql} {
+ db eval "EXPLAIN $sql" a {
+ if {$a(opcode)=="Next"} { return 1 }
+ }
+ return 0
+}
+
+proc do_uses_op_next_test {tn sql res} {
+ uplevel [list do_test $tn [list uses_op_next $sql] $res]
+}
+
+reset_db
+do_execsql_test notnull-6.0 {
+ CREATE TABLE t1(a UNIQUE);
+ CREATE TABLE t2(a NOT NULL UNIQUE);
+ CREATE TABLE t3(a UNIQUE NOT NULL);
+ CREATE TABLE t4(a NOT NULL);
+ CREATE UNIQUE INDEX t4a ON t4(a);
+
+ CREATE TABLE t5(a PRIMARY KEY);
+ CREATE TABLE t6(a PRIMARY KEY NOT NULL);
+ CREATE TABLE t7(a NOT NULL PRIMARY KEY);
+ CREATE TABLE t8(a PRIMARY KEY) WITHOUT ROWID;
+
+ CREATE TABLE t9(a PRIMARY KEY UNIQUE NOT NULL);
+ CREATE TABLE t10(a UNIQUE PRIMARY KEY NOT NULL);
+}
+
+do_uses_op_next_test notnull-6.1 "SELECT * FROM t1 WHERE a IS ?" 1
+do_uses_op_next_test notnull-6.2 "SELECT * FROM t2 WHERE a IS ?" 0
+do_uses_op_next_test notnull-6.3 "SELECT * FROM t3 WHERE a IS ?" 0
+do_uses_op_next_test notnull-6.4 "SELECT * FROM t4 WHERE a IS ?" 0
+
+do_uses_op_next_test notnull-6.5 "SELECT * FROM t5 WHERE a IS ?" 1
+do_uses_op_next_test notnull-6.6 "SELECT * FROM t6 WHERE a IS ?" 0
+do_uses_op_next_test notnull-6.7 "SELECT * FROM t7 WHERE a IS ?" 0
+do_uses_op_next_test notnull-6.8 "SELECT * FROM t8 WHERE a IS ?" 0
+
+do_uses_op_next_test notnull-6.9 "SELECT * FROM t8 WHERE a IS ?" 0
+do_uses_op_next_test notnull-6.10 "SELECT * FROM t8 WHERE a IS ?" 0
+
+finish_test
diff --git a/test/notnull2.test b/test/notnull2.test
new file mode 100644
index 0000000..12fffe2
--- /dev/null
+++ b/test/notnull2.test
@@ -0,0 +1,132 @@
+# 2021 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 optimizations associated with "IS NULL"
+# and "IS NOT NULL" operators on columns with NOT NULL constraints.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix notnull2
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d NOT NULL);
+
+ WITH x(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<1000
+ )
+ INSERT INTO t1 SELECT i, i FROM x;
+ INSERT INTO t2 SELECT * FROM t1;
+}
+
+proc do_vmstep_test {tn sql nstep {res {}}} {
+ uplevel [list do_execsql_test $tn.0 $sql $res]
+
+ set vmstep [db status vmstep]
+ if {[string range $nstep 0 0]=="+"} {
+ set body "if {$vmstep<$nstep} {
+ error \"got $vmstep, expected more than [string range $nstep 1 end]\"
+ }"
+ } else {
+ set body "if {$vmstep>$nstep} {
+ error \"got $vmstep, expected less than $nstep\"
+ }"
+ }
+
+ # set name "$tn.vmstep=$vmstep,expect=$nstep"
+ set name "$tn.1"
+ uplevel [list do_test $name $body {}]
+}
+
+do_vmstep_test 1.1.1 {
+ SELECT * FROM t1 LEFT JOIN t2 WHERE a=c AND d IS NULL;
+} 100 {}
+do_vmstep_test 1.1.2 {
+ SELECT * FROM t1 LEFT JOIN t2 WHERE a=c AND c IS NULL;
+} +1000 {}
+
+do_vmstep_test 1.2.1 {
+ SELECT * FROM ( SELECT * FROM t2 ) WHERE d IS NULL
+} 100 {}
+do_vmstep_test 1.2.2 {
+ SELECT * FROM ( SELECT * FROM t2 ) WHERE c IS NULL
+} +1000 {}
+
+do_vmstep_test 1.3.1 {
+ SELECT * FROM t2 WHERE d IS NULL
+} 100 {}
+do_vmstep_test 1.3.2 {
+ SELECT * FROM t2 WHERE c IS NULL
+} +1000 {}
+
+do_vmstep_test 1.4.1 {
+ SELECT (d IS NOT NULL) FROM t2 WHERE 0==( d IS NOT NULL )
+} 100 {}
+do_vmstep_test 1.4.2 {
+ SELECT * FROM t2 WHERE 0==( c IS NOT NULL )
+} +1000 {}
+
+do_vmstep_test 1.5.1 {
+ SELECT count(*) FROM t2 WHERE EXISTS(
+ SELECT t2.d IS NULL FROM t1 WHERE t1.a=450
+ )
+} 10000 {1000}
+do_vmstep_test 1.5.2 {
+ SELECT count(*) FROM t2 WHERE EXISTS(
+ SELECT t2.c IS NULL FROM t1 WHERE t1.a=450
+ )
+} +100000 {1000}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE T1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE T3(k, v);
+}
+
+do_execsql_test 2.1 {
+ SELECT * FROM (SELECT a, b FROM t1) LEFT JOIN t3 ON a IS NULL;
+}
+
+
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t0(c0 PRIMARY KEY);
+ INSERT INTO t0(c0) VALUES (0);
+}
+do_execsql_test 3.1 {
+ SELECT * FROM t0 WHERE ((c0 NOT NULL) AND 1) OR (c0 == NULL);
+} {0}
+
+# 2021-07-22 https://sqlite.org/forum/forumpost/2078b7edd2
+#
+reset_db
+do_execsql_test 4.0 {
+ SELECT *, '/'
+ FROM (
+ SELECT NULL val FROM (SELECT 1)
+ UNION ALL
+ SELECT 'missing' FROM (SELECT 1)
+ ) a
+ LEFT JOIN (SELECT 1)
+ ON a.val IS NULL;
+} {{} 1 / missing {} /}
+do_execsql_test 4.1 {
+ CREATE TABLE t1(a INT);
+ INSERT INTO t1(a) VALUES(1);
+ CREATE TABLE t2(b INT);
+ SELECT * FROM (SELECT 3 AS c FROM t1) AS t3 LEFT JOIN t2 ON c IS NULL;
+} {3 {}}
+
+finish_test
diff --git a/test/notnullfault.test b/test/notnullfault.test
new file mode 100644
index 0000000..0db8e4a
--- /dev/null
+++ b/test/notnullfault.test
@@ -0,0 +1,55 @@
+# 2021 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 optimizations associated with "IS NULL"
+# and "IS NOT NULL" operators on columns with NOT NULL constraints.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix notnullfault
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d NOT NULL);
+}
+faultsim_save_and_close
+
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT * FROM t2 WHERE d NOT NULL
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b, c)) WITHOUT ROWID;
+}
+faultsim_save_and_close
+
+do_faultsim_test 2.1 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT dense_rank() OVER win FROM t2
+ WINDOW win AS (ORDER BY c IS NULL)
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/null.test b/test/null.test
new file mode 100644
index 0000000..5057e25
--- /dev/null
+++ b/test/null.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.
+#
+# 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}
+
+do_execsql_test null-9.1 {
+ CREATE TABLE t5(a, b, c);
+ CREATE UNIQUE INDEX t5ab ON t5(a, b);
+
+ INSERT INTO t5 VALUES(1, NULL, 'one');
+ INSERT INTO t5 VALUES(1, NULL, 'i');
+ INSERT INTO t5 VALUES(NULL, 'x', 'two');
+ INSERT INTO t5 VALUES(NULL, 'x', 'ii');
+}
+
+do_execsql_test null-9.2 {
+ SELECT * FROM t5 WHERE a = 1 AND b IS NULL;
+} {1 {} one 1 {} i}
+
+do_execsql_test null-9.3 {
+ SELECT * FROM t5 WHERE a IS NULL AND b = 'x';
+} {{} x two {} x ii}
+
+# 2020-09-30 ticket 5c4e7aa793943803
+reset_db
+do_execsql_test null-10.1 {
+ CREATE TABLE t0(c0 PRIMARY KEY DESC);
+ INSERT INTO t0(c0) VALUES (0);
+ SELECT * FROM t0 WHERE t0.c0 > NULL;
+} {}
+
+finish_test
diff --git a/test/nulls1.test b/test/nulls1.test
new file mode 100644
index 0000000..c44d0af
--- /dev/null
+++ b/test/nulls1.test
@@ -0,0 +1,343 @@
+# 2019 August 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix nulls1
+
+do_execsql_test 1.0 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a INTEGER);
+ INSERT INTO t3 VALUES(NULL), (10), (30), (20), (NULL);
+} {}
+
+for {set a 0} {$a < 3} {incr a} {
+ foreach {tn limit} {
+ 1 ""
+ 2 "LIMIT 10"
+ } {
+ do_execsql_test 1.$a.$tn.1 "
+ SELECT a FROM t3 ORDER BY a nULLS FIRST $limit
+ " {{} {} 10 20 30}
+
+ do_execsql_test 1.$a.$tn.2 "
+ SELECT a FROM t3 ORDER BY a nULLS LAST $limit
+ " {10 20 30 {} {}}
+
+ do_execsql_test 1.$a.$tn.3 "
+ SELECT a FROM t3 ORDER BY a DESC nULLS FIRST $limit
+ " {{} {} 30 20 10}
+
+ do_execsql_test 1.$a.$tn.4 "
+ SELECT a FROM t3 ORDER BY a DESC nULLS LAST $limit
+ " {30 20 10 {} {}}
+ }
+
+ switch $a {
+ 0 {
+ execsql { CREATE INDEX i1 ON t3(a) }
+ }
+ 1 {
+ execsql { DROP INDEX i1 ; CREATE INDEX i1 ON t3(a DESC) }
+ }
+ }
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a, b, c);
+ CREATE INDEX i2 ON t2(a, b);
+ INSERT INTO t2 VALUES(1, 1, 1);
+ INSERT INTO t2 VALUES(1, NULL, 2);
+ INSERT INTO t2 VALUES(1, NULL, 3);
+ INSERT INTO t2 VALUES(1, 4, 4);
+}
+
+do_execsql_test 2.1 {
+ SELECT * FROM t2 WHERE a=1 ORDER BY b NULLS LAST
+} {
+ 1 1 1 1 4 4 1 {} 2 1 {} 3
+}
+
+do_execsql_test 2.2 {
+ SELECT * FROM t2 WHERE a=1 ORDER BY b DESC NULLS FIRST
+} {
+ 1 {} 3
+ 1 {} 2
+ 1 4 4
+ 1 1 1
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(a, b, c, d, UNIQUE (b));
+}
+foreach {tn sql err} {
+ 1 { CREATE INDEX i1 ON t1(a ASC NULLS LAST) } LAST
+ 2 { CREATE INDEX i1 ON t1(a ASC NULLS FIRST) } FIRST
+ 3 { CREATE INDEX i1 ON t1(a, b ASC NULLS LAST) } LAST
+ 4 { CREATE INDEX i1 ON t1(a, b ASC NULLS FIRST) } FIRST
+ 5 { CREATE INDEX i1 ON t1(a DESC NULLS LAST) } LAST
+ 6 { CREATE INDEX i1 ON t1(a DESC NULLS FIRST) } FIRST
+ 7 { CREATE INDEX i1 ON t1(a, b DESC NULLS LAST) } LAST
+ 8 { CREATE INDEX i1 ON t1(a, b DESC NULLS FIRST) } FIRST
+ 9 { CREATE TABLE t2(a, b, PRIMARY KEY(a DESC, b NULLS FIRST)) } FIRST
+ 10 { CREATE TABLE t2(a, b, UNIQUE(a DESC NULLS FIRST, b)) } FIRST
+ 11 { INSERT INTO t1 VALUES(1, 2, 3, 4)
+ ON CONFLICT (b DESC NULLS LAST) DO UPDATE SET a = a+1 } LAST
+ 12 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t1 VALUES(1, 2, 3, 4)
+ ON CONFLICT (b DESC NULLS FIRST) DO UPDATE SET a = a+1;
+ END
+ } FIRST
+} {
+ do_catchsql_test 3.1.$tn $sql "1 {unsupported use of NULLS $err}"
+}
+
+do_execsql_test 3.2 {
+ CREATE TABLE first(nulls, last);
+ INSERT INTO first(last, nulls) VALUES(100,200), (300,400), (200,300);
+ SELECT * FROM first ORDER BY nulls;
+} {
+ 200 100
+ 300 200
+ 400 300
+}
+
+#-------------------------------------------------------------------------
+#
+ifcapable vtab {
+ register_echo_module db
+ do_execsql_test 4.0 {
+ CREATE TABLE tx(a INTEGER PRIMARY KEY, b, c);
+ CREATE INDEX i1 ON tx(b);
+ INSERT INTO tx VALUES(1, 1, 1);
+ INSERT INTO tx VALUES(2, NULL, 2);
+ INSERT INTO tx VALUES(3, 3, 3);
+ INSERT INTO tx VALUES(4, NULL, 4);
+ INSERT INTO tx VALUES(5, 5, 5);
+ CREATE VIRTUAL TABLE te USING echo(tx);
+ }
+
+ do_execsql_test 4.1 {
+ SELECT * FROM tx ORDER BY b NULLS FIRST;
+ } {2 {} 2 4 {} 4 1 1 1 3 3 3 5 5 5}
+ do_execsql_test 4.2 {
+ SELECT * FROM te ORDER BY b NULLS FIRST;
+ } {2 {} 2 4 {} 4 1 1 1 3 3 3 5 5 5}
+
+ do_execsql_test 4.3 {
+ SELECT * FROM tx ORDER BY b NULLS LAST;
+ } {1 1 1 3 3 3 5 5 5 2 {} 2 4 {} 4}
+ do_execsql_test 4.4 {
+ SELECT * FROM te ORDER BY b NULLS LAST;
+ } {1 1 1 3 3 3 5 5 5 2 {} 2 4 {} 4}
+}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 5.0 {
+ CREATE TABLE t4(a, b, c);
+ INSERT INTO t4 VALUES(1, 1, 11);
+ INSERT INTO t4 VALUES(1, 2, 12);
+ INSERT INTO t4 VALUES(1, NULL, 1);
+
+ INSERT INTO t4 VALUES(2, NULL, 1);
+ INSERT INTO t4 VALUES(2, 2, 12);
+ INSERT INTO t4 VALUES(2, 1, 11);
+
+ INSERT INTO t4 VALUES(3, NULL, 1);
+ INSERT INTO t4 VALUES(3, 2, 12);
+ INSERT INTO t4 VALUES(3, NULL, 3);
+}
+
+do_execsql_test 5.1 {
+ SELECT * FROM t4 WHERE a IN (1, 2, 3) ORDER BY a, b NULLS LAST
+} {
+ 1 1 11 1 2 12 1 {} 1
+ 2 1 11 2 2 12 2 {} 1
+ 3 2 12 3 {} 1 3 {} 3
+}
+do_execsql_test 5.2 {
+ CREATE INDEX t4ab ON t4(a, b);
+ SELECT * FROM t4 WHERE a IN (1, 2, 3) ORDER BY a, b NULLS LAST
+} {
+ 1 1 11 1 2 12 1 {} 1
+ 2 1 11 2 2 12 2 {} 1
+ 3 2 12 3 {} 1 3 {} 3
+}
+do_eqp_test 5.3 {
+ SELECT * FROM t4 WHERE a IN (1, 2, 3) ORDER BY a, b NULLS LAST
+} {
+ QUERY PLAN
+ `--SEARCH t4 USING INDEX t4ab (a=?)
+}
+
+do_execsql_test 5.4 {
+ SELECT * FROM t4 WHERE a IN (1, 2, 3) ORDER BY a DESC, b DESC NULLS FIRST
+} {
+ 3 {} 3 3 {} 1 3 2 12
+ 2 {} 1 2 2 12 2 1 11
+ 1 {} 1 1 2 12 1 1 11
+}
+do_eqp_test 5.5 {
+ SELECT * FROM t4 WHERE a IN (1, 2, 3) ORDER BY a DESC, b DESC NULLS FIRST
+} {
+ QUERY PLAN
+ `--SEARCH t4 USING INDEX t4ab (a=?)
+}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 6.0 {
+ CREATE TABLE t5(a, b, c);
+ WITH s(i) AS (
+ VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<200
+ )
+ INSERT INTO t5 SELECT i%2, CASE WHEN (i%10)==0 THEN NULL ELSE i END, i FROM s;
+}
+
+set res1 [db eval { SELECT a,b FROM t5 WHERE a=1 ORDER BY b NULLS LAST, c }]
+set res2 [db eval {
+ SELECT a,b FROM t5 WHERE a=1 ORDER BY b DESC NULLS FIRST, c DESC
+}]
+
+do_execsql_test 6.1.1 {
+ CREATE INDEX t5ab ON t5(a, b, c);
+ SELECT a,b FROM t5 WHERE a=1 ORDER BY b NULLS LAST, c;
+} $res1
+do_eqp_test 6.1.2 {
+ SELECT a,b FROM t5 WHERE a=1 ORDER BY b NULLS LAST, c;
+} {
+ QUERY PLAN
+ `--SEARCH t5 USING COVERING INDEX t5ab (a=?)
+}
+do_execsql_test 6.2.1 {
+ SELECT a,b FROM t5 WHERE a=1 ORDER BY b DESC NULLS FIRST, c DESC
+} $res2
+do_eqp_test 6.2.2 {
+ SELECT a,b FROM t5 WHERE a=1 ORDER BY b DESC NULLS FIRST, c DESC
+} {
+ QUERY PLAN
+ `--SEARCH t5 USING COVERING INDEX t5ab (a=?)
+}
+
+#-------------------------------------------------------------------------
+do_execsql_test 7.0 {
+ CREATE TABLE t71(a, b, c);
+ CREATE INDEX t71abc ON t71(a, b, c);
+
+ SELECT * FROM t71 WHERE a=1 AND b=2 ORDER BY c NULLS LAST;
+ SELECT * FROM t71 WHERE a=1 AND b=2 ORDER BY c DESC NULLS FIRST;
+
+ SELECT * FROM t71 ORDER BY a NULLS LAST;
+ SELECT * FROM t71 ORDER BY a DESC NULLS FIRST;
+}
+
+# 2019-12-18 gramfuzz1 find
+# NULLS LAST not allows on an INTEGER PRIMARY KEY.
+#
+do_catchsql_test 8.0 {
+ CREATE TABLE t80(a, b INTEGER, PRIMARY KEY(b NULLS LAST)) WITHOUT ROWID;
+} {1 {unsupported use of NULLS LAST}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 9.0 {
+ CREATE TABLE v0 (c1, c2, c3);
+ CREATE INDEX v3 ON v0 (c1, c2, c3);
+}
+do_execsql_test 9.1 {
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1 VALUES('v0','v3','648 324 81');
+ ANALYZE sqlite_master;
+}
+
+do_execsql_test 9.2 {
+ INSERT INTO v0 VALUES
+ (1, 10, 'b'),
+ (1, 10, 'd'),
+ (1, 10, NULL),
+ (2, 10, 'a'),
+ (2, 10, NULL),
+ (1, 10, 'c'),
+ (2, 10, 'b'),
+ (1, 10, 'a'),
+ (1, 10, NULL),
+ (2, 10, NULL),
+ (2, 10, 'd'),
+ (2, 10, 'c');
+}
+
+do_execsql_test 9.3 {
+ SELECT c1, c2, ifnull(c3, 'NULL') FROM v0
+ WHERE c2=10 ORDER BY c1, c3 NULLS LAST
+} {
+ 1 10 a 1 10 b 1 10 c 1 10 d 1 10 NULL 1 10 NULL
+ 2 10 a 2 10 b 2 10 c 2 10 d 2 10 NULL 2 10 NULL
+}
+
+do_eqp_test 9.4 {
+ SELECT c1, c2, ifnull(c3, 'NULL') FROM v0
+ WHERE c2=10 ORDER BY c1, c3 NULLS LAST
+} {SEARCH v0 USING COVERING INDEX v3 (ANY(c1) AND c2=?)}
+
+
+# 2020-03-01 ticket e12a0ae526bb51c7
+# NULLS LAST on a LEFT JOIN
+#
+reset_db
+do_execsql_test 10.10 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES('X');
+ CREATE TABLE t2(c, d);
+ CREATE INDEX t2dc ON t2(d, c);
+ SELECT c FROM t1 LEFT JOIN t2 ON d=NULL ORDER BY d, c NULLS LAST;
+} {{}}
+do_execsql_test 10.20 {
+ INSERT INTO t2(c,d) VALUES(5,'X'),(6,'Y'),(7,'Z'),(3,'A'),(4,'B');
+ SELECT c FROM t1 LEFT JOIN t2 ON d=x ORDER BY d, c NULLS LAST;
+} {5}
+do_execsql_test 10.30 {
+ UPDATE t2 SET d='X';
+ UPDATE t2 SET c=NULL WHERE c=6;
+ SELECT c FROM t1 LEFT JOIN t2 ON d=x ORDER BY d NULLS FIRST, c NULLS FIRST;
+} {{} 3 4 5 7}
+do_execsql_test 10.40 {
+ SELECT c FROM t1 LEFT JOIN t2 ON d=x ORDER BY d NULLS LAST, c NULLS LAST;
+} {3 4 5 7 {}}
+do_execsql_test 10.41 {
+ SELECT c FROM t1 LEFT JOIN t2 ON d=x ORDER BY c NULLS LAST;
+} {3 4 5 7 {}}
+do_execsql_test 10.42 {
+ SELECT c FROM t1 LEFT JOIN t2 ON d=x ORDER BY +d NULLS LAST, +c NULLS LAST;
+} {3 4 5 7 {}}
+do_execsql_test 10.50 {
+ INSERT INTO t1(x) VALUES(NULL),('Y');
+ SELECT x, c, d, '|' FROM t1 LEFT JOIN t2 ON d=x
+ ORDER BY d NULLS LAST, c NULLS LAST;
+} {X 3 X | X 4 X | X 5 X | X 7 X | X {} X | {} {} {} | Y {} {} |}
+do_execsql_test 10.51 {
+ SELECT x, c, d, '|' FROM t1 LEFT JOIN t2 ON d=x
+ ORDER BY +d NULLS LAST, +c NULLS LAST;
+} {X 3 X | X 4 X | X 5 X | X 7 X | X {} X | {} {} {} | Y {} {} |}
+
+
+
+
+
+finish_test
diff --git a/test/numcast.test b/test/numcast.test
new file mode 100644
index 0000000..926bbe4
--- /dev/null
+++ b/test/numcast.test
@@ -0,0 +1,46 @@
+# 2013 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+# This particular file does testing of casting strings into numeric
+# values.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+foreach enc {utf8 utf16le utf16be} {
+ do_test numcast-$enc.0 {
+ db close
+ sqlite3 db :memory:
+ db eval "PRAGMA encoding='$enc'"
+ set x [db eval {PRAGMA encoding}]
+ string map {- {}} [string tolower $x]
+ } $enc
+ foreach {idx str rval ival} {
+ 1 12345.0 12345.0 12345
+ 2 12345.0e0 12345.0 12345
+ 3 -12345.0e0 -12345.0 -12345
+ 4 -12345.25 -12345.25 -12345
+ 5 { -12345.0} -12345.0 -12345
+ 6 { 876xyz} 876.0 876
+ 7 { 456ķ89} 456.0 456
+ 8 { Ġ 321.5} 0.0 0
+ } {
+ do_test numcast-$enc.$idx.1 {
+ db eval {SELECT CAST($str AS real)}
+ } $rval
+ do_test numcast-$enc.$idx.2 {
+ db eval {SELECT CAST($str AS integer)}
+ } $ival
+ }
+}
+
+finish_test
diff --git a/test/numindex1.test b/test/numindex1.test
new file mode 100644
index 0000000..c647fc5
--- /dev/null
+++ b/test/numindex1.test
@@ -0,0 +1,79 @@
+# 2015-11-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 tests for indexes on large numeric values.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+# Test cases from Zsbán Ambrus:
+#
+do_execsql_test numindex1-1.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE INDEX t1b ON t1(b);
+ INSERT INTO t1(a,b) VALUES(100, 356282677878746339);
+ INSERT INTO t1(a,b) VALUES(50, 356282677878746339.0);
+ INSERT INTO t1(a,b) VALUES(0, 356282677878746340);
+ DELETE FROM t1 WHERE a=50;
+ PRAGMA integrity_check;
+} {ok}
+
+do_execsql_test numindex1-1.2 {
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2(a,b) VALUES('b', 1<<58),
+ ('c', (1<<58)+1e-7), ('d', (1<<58)+1);
+ SELECT a, b, typeof(b), '|' FROM t2 ORDER BY +a;
+} {b 288230376151711744 integer | c 2.88230376151712e+17 real | d 288230376151711745 integer |}
+
+do_execsql_test numindex1-1.3 {
+ SELECT x.a || CASE WHEN x.b==y.b THEN '==' ELSE '<>' END || y.a
+ FROM t2 AS x, t2 AS y
+ ORDER BY +x.a, +x.b;
+} {b==b b==c b<>d c==b c==c c<>d d<>b d<>c d==d}
+
+# New test cases
+#
+do_execsql_test numindex1-2.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b);
+ CREATE INDEX t1b ON t1(b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b) SELECT x, 10000000000000004.0 FROM c
+ WHERE x NOT IN (23,37);
+ INSERT INTO t1(a,b) VALUES(23,10000000000000005);
+ INSERT INTO t1(a,b) VALUES(37,10000000000000003);
+ DELETE FROM t1 WHERE a NOT IN (23,37);
+ PRAGMA integrity_check;
+} {ok}
+
+do_execsql_test numindex1-3.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b);
+ CREATE INDEX t1b ON t1(b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)
+ INSERT INTO t1(a,b) SELECT x, 100000000000000005.0
+ FROM c WHERE x NOT IN (3,5,7,11,13,17,19);
+ INSERT INTO t1(a,b) VALUES(3,100000000000000005);
+ INSERT INTO t1(a,b) VALUES(5,100000000000000000);
+ INSERT INTO t1(a,b) VALUES(7,100000000000000008);
+ INSERT INTO t1(a,b) VALUES(11,100000000000000006);
+ INSERT INTO t1(a,b) VALUES(13,100000000000000001);
+ INSERT INTO t1(a,b) VALUES(17,100000000000000004);
+ INSERT INTO t1(a,b) VALUES(19,100000000000000003);
+ PRAGMA integrity_check;
+} {ok}
+
+do_execsql_test numindex1-3.2 {
+ SELECT a FROM t1 ORDER BY b;
+} {1 2 4 5 6 8 9 10 12 14 15 16 18 20 13 19 17 3 11 7}
+
+finish_test
diff --git a/test/offset1.test b/test/offset1.test
new file mode 100644
index 0000000..5b04bd8
--- /dev/null
+++ b/test/offset1.test
@@ -0,0 +1,202 @@
+# 2015-10-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 test cases for the [b65cb2c8d91f6685841d7d1e13b6]
+# bug: Correct handling of LIMIT and OFFSET on a UNION ALL query where
+# the right-hand SELECT contains an ORDER BY in a subquery.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+do_execsql_test offset1-1.1 {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(8,'y'),(9,'z'),(6,'w'),(7,'x');
+ SELECT count(*) FROM t1, t2;
+} {20}
+
+do_execsql_test offset1-1.2.0 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 0;
+} {1 a 2 b 3 c}
+do_execsql_test offset1-1.2.1 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 1;
+} {2 b 3 c 4 d}
+do_execsql_test offset1-1.2.2 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 2;
+} {3 c 4 d 5 e}
+do_execsql_test offset1-1.2.3 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 3;
+} {4 d 5 e 6 w}
+do_execsql_test offset1-1.2.4 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 4;
+} {5 e 6 w 7 x}
+do_execsql_test offset1-1.2.5 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 5;
+} {6 w 7 x 8 y}
+do_execsql_test offset1-1.2.6 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 6;
+} {7 x 8 y 9 z}
+do_execsql_test offset1-1.2.7 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 7;
+} {8 y 9 z}
+do_execsql_test offset1-1.2.8 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 8;
+} {9 z}
+do_execsql_test offset1-1.2.9 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 9;
+} {}
+
+do_execsql_test offset1-1.3.0 {
+ SELECT * FROM t1 LIMIT 0;
+} {}
+
+do_execsql_test offset1-1.4.0 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 0 OFFSET 1;
+} {}
+do_execsql_test offset1-1.4.1 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 1 OFFSET 1;
+} {2 b}
+do_execsql_test offset1-1.4.2 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 2 OFFSET 1;
+} {2 b 3 c}
+do_execsql_test offset1-1.4.3 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 3 OFFSET 1;
+} {2 b 3 c 4 d}
+do_execsql_test offset1-1.4.4 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 4 OFFSET 1;
+} {2 b 3 c 4 d 5 e}
+do_execsql_test offset1-1.4.5 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 5 OFFSET 1;
+} {2 b 3 c 4 d 5 e 6 w}
+do_execsql_test offset1-1.4.6 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 6 OFFSET 1;
+} {2 b 3 c 4 d 5 e 6 w 7 x}
+do_execsql_test offset1-1.4.7 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 7 OFFSET 1;
+} {2 b 3 c 4 d 5 e 6 w 7 x 8 y}
+do_execsql_test offset1-1.4.8 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 8 OFFSET 1;
+} {2 b 3 c 4 d 5 e 6 w 7 x 8 y 9 z}
+do_execsql_test offset1-1.4.9 {
+ SELECT a, b FROM t1
+ UNION ALL
+ SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)
+ LIMIT 9 OFFSET 1;
+} {2 b 3 c 4 d 5 e 6 w 7 x 8 y 9 z}
+
+# 2022-08-04
+# https://sqlite.org/forum/forumpost/6b5e9188f0657616
+#
+do_execsql_test offset1-2.0 {
+ CREATE TABLE employees (
+ id integer primary key,
+ name text,
+ city text,
+ department text,
+ salary integer
+ );
+ INSERT INTO employees VALUES
+ (11,'Diane','London','hr',70),
+ (12,'Bob','London','hr',78),
+ (21,'Emma','London','it',84),
+ (22,'Grace','Berlin','it',90),
+ (23,'Henry','London','it',104),
+ (24,'Irene','Berlin','it',104),
+ (25,'Frank','Berlin','it',120),
+ (31,'Cindy','Berlin','sales',96),
+ (32,'Dave','London','sales',96),
+ (33,'Alice','Berlin','sales',100);
+ CREATE VIEW v AS
+ SELECT * FROM (
+ SELECT * FROM employees
+ WHERE salary < 100
+ ORDER BY salary desc)
+ UNION ALL
+ SELECT * FROM (
+ SELECT * FROM employees
+ WHERE salary >= 100
+ ORDER BY salary asc);
+} {}
+do_execsql_test offset1-2.1 {
+ SELECT * FROM v LIMIT 5 OFFSET 2;
+} {
+ 22 Grace Berlin it 90
+ 21 Emma London it 84
+ 12 Bob London hr 78
+ 11 Diane London hr 70
+ 33 Alice Berlin sales 100
+}
+
+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/optfuzz-db01.c b/test/optfuzz-db01.c
new file mode 100644
index 0000000..e11f15c
--- /dev/null
+++ b/test/optfuzz-db01.c
@@ -0,0 +1,947 @@
+/* content of file testdb01.db */
+unsigned char data001[] = {
+ 83, 81, 76,105,116,101, 32,102,111,114,109, 97,116, 32, 51, 0, 2, 0, 1,
+ 1, 0, 64, 32, 32, 0, 0, 0, 2, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 31, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 2, 0, 46, 32,152, 5, 0, 0, 0, 7, 1,221, 0, 0, 0, 0, 35, 1,251,
+ 1,246, 1,241, 1,236, 1,231, 1,226, 1,221, 84, 4, 7, 23, 17, 17, 1,
+ 129, 19,116, 97, 98,108,101,116, 52,116, 52, 5, 67, 82, 69, 65, 84, 69, 32,
+ 84, 65, 66, 76, 69, 32,116, 52, 40, 97, 32, 73, 78, 84, 32, 85, 78, 73, 81,
+ 85, 69, 32, 78, 79, 84, 32, 78, 85, 76, 76, 44, 32, 98, 32, 73, 78, 84, 32,
+ 85, 78, 73, 81, 85, 69, 32, 78, 79, 84, 32, 78, 85, 76, 76, 44, 99, 44,100,
+ 44,101, 41, 35, 6, 6, 23, 55, 17, 1, 0,105,110,100,101,120,115,113,108,
+ 105,116,101, 95, 97,117,116,111,105,110,100,101,120, 95,116, 52, 95, 50,116,
+ 52, 7, 35, 5, 6, 23, 55, 17, 1, 0,105,110,100,101,120,115,113,108,105,
+ 116,101, 95, 97,117,116,111,105,110,100,101,120, 95,116, 52, 95, 49,116, 52,
+ 6, 42, 3, 6, 23, 17, 17, 1, 65,116, 97, 98,108,101,116, 51,116, 51, 4,
+ 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 51, 40, 97, 44, 98,
+ 44, 99, 44,100, 44,101, 41, 95, 2, 7, 23, 17, 17, 1,129, 41,116, 97, 98,
+ 108,101,116, 50,116, 50, 3, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69,
+ 32,116, 50, 40, 97, 32, 73, 78, 84, 44, 32, 98, 32, 73, 78, 84, 44, 32, 99,
+ 32, 73, 78, 84, 44,100, 32, 73, 78, 84, 44,101, 32, 73, 78, 84, 44, 80, 82,
+ 73, 77, 65, 82, 89, 32, 75, 69, 89, 40, 98, 44, 97, 41, 41, 87, 73, 84, 72,
+ 79, 85, 84, 32, 82, 79, 87, 73, 68, 83, 1, 7, 23, 17, 17, 1,129, 17,116,
+ 97, 98,108,101,116, 49,116, 49, 2, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66,
+ 76, 69, 32,116, 49, 40, 97, 32, 73, 78, 84, 69, 71, 69, 82, 32, 80, 82, 73,
+ 77, 65, 0, 0, 0, 34, 32, 0, 0, 0, 33, 29, 0, 0, 0, 32, 26, 0, 0,
+ 0, 31, 23, 0, 0, 0, 30, 19, 0, 0, 0, 11, 14, 0, 0, 0, 9, 7, 5,
+ 0, 0, 0, 1, 1,251, 0, 0, 0, 0, 16, 1,251, 1,195, 1,180, 1,166,
+ 1,151, 1,136, 1,121, 1,105, 1, 91, 1, 76, 1, 61, 1, 46, 1, 29, 1,
+ 14, 0,252, 0,238, 0,224, 0,209, 0,194, 0,177, 0,157, 0,143, 0,128,
+ 0,110, 0, 94, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 14, 28, 6, 0, 1, 1, 1, 23, 17, 67, 31,119,111,114,107,115, 14, 27,
+ 6, 0, 1, 1, 1, 23, 22, 71, 3, 97,110,103,101,108, 16, 26, 6, 0, 1,
+ 1, 1, 27, 40, 98, 17,109,111,114,110,105,110,103, 13, 25, 6, 0, 1, 1,
+ 1, 21, 10, 7, 19,103,111,110,101, 12, 24, 6, 0, 1, 1, 9, 21, 43, 46,
+ 119, 97,121,115, 18, 23, 6, 0, 1, 1, 1, 31, 6, 37, 31,115, 97, 99,114,
+ 105,102,105, 99,101, 15, 22, 6, 0, 1, 1, 1, 25, 45, 71, 28,116,104,111,
+ 117,103,104, 13, 21, 6, 0, 1, 1, 1, 21, 22, 92, 18,115,111,109,101, 13,
+ 20, 6, 0, 9, 1, 1, 23, 2, 45, 97, 98,111,118,101, 12, 19, 6, 0, 1,
+ 1, 8, 21, 4, 58,119, 97,121,115, 12, 18, 6, 0, 1, 1, 1, 19, 44, 19,
+ 43,119, 97,114, 16, 17, 6, 0, 1, 1, 1, 27, 29, 74, 36, 98,101,116,119,
+ 101,101,110, 13, 16, 6, 0, 1, 1, 1, 21, 44, 52, 19,112,111,111,114, 15,
+ 15, 6, 0, 1, 1, 1, 25, 6, 3, 11,116,101,109,112,108,101, 13, 14, 6,
+ 0, 1, 1, 1, 21, 35, 48, 27,100,105,101,100, 13, 13, 6, 0, 1, 1, 1,
+ 21, 4, 21, 39,100,111,116,104, 13, 12, 6, 0, 1, 1, 1, 21, 4, 38, 36,
+ 115,101,110,100, 12, 11, 6, 0, 1, 1, 1, 19, 13, 48, 22,115,105,120, 14,
+ 10, 6, 0, 1, 1, 1, 23, 41, 89, 14,115,101,114,118,101, 13, 9, 6, 0,
+ 8, 1, 1, 23, 16, 50, 98,101,103, 97,116, 13, 8, 6, 0, 1, 1, 1, 21,
+ 42, 49, 34,115,101,110,100, 13, 7, 6, 0, 1, 1, 1, 21, 21, 91, 38,110,
+ 101, 97,114, 12, 6, 6, 0, 1, 1, 1, 19, 2, 37, 11, 99, 97,110, 13, 5,
+ 6, 0, 1, 1, 1, 21, 25, 27, 28,103,111,110,101, 13, 4, 6, 0, 1, 1,
+ 1, 21, 41, 32, 35,110,101, 97,114, 14, 3, 6, 0, 1, 1, 1, 23, 32, 24,
+ 26,115,101,114,118,101, 13, 2, 6, 0, 1, 1, 1, 21, 45, 14, 39,115, 97,
+ 118,101, 13, 1, 6, 0, 1, 1, 1, 21, 40, 68, 0, 0, 0, 15, 28, 2, 0,
+ 0, 0, 1, 1,238, 0, 0, 0, 0, 22, 1,238, 1,197, 1,181, 1,166, 1,
+ 151, 1,137, 1,121, 1,104, 1, 84, 1, 73, 1, 59, 1, 41, 1, 26, 1, 11,
+ 0,253, 0,238, 0,223, 0,207, 0,191, 0,175, 0,159, 0,144, 0,129, 0,
+ 113, 0, 97, 0, 82, 0, 68, 0, 0, 13, 6, 1, 1, 1, 1, 19, 26, 34, 15,
+ 20, 97,114,107, 14, 6, 1, 1, 1, 1, 21, 25, 5, 27, 28,103,111,110,101,
+ 15, 6, 1, 1, 1, 1, 23, 22, 47, 16, 40, 97,110,103,101,114, 15, 6, 1,
+ 1, 1, 1, 23, 22, 27, 71, 3, 97,110,103,101,108, 14, 6, 1, 1, 1, 1,
+ 21, 22, 21, 92, 18,115,111,109,101, 14, 6, 1, 1, 1, 1, 21, 21, 7, 91,
+ 38,110,101, 97,114, 15, 6, 1, 1, 1, 1, 23, 20, 42, 18, 5, 98,101,103,
+ 97,116, 15, 6, 1, 1, 1, 1, 23, 17, 37, 66, 18,100,119,101,108,116, 15,
+ 6, 1, 1, 1, 1, 23, 17, 28, 67, 31,119,111,114,107,115, 15, 6, 1, 1,
+ 1, 8, 25, 16, 32, 7,112,108, 97, 99,101,115, 14, 6, 1, 1, 1, 1, 21,
+ 16, 30, 81, 25,119, 97,108,107, 14, 6, 1, 1, 1, 1, 21, 14, 40, 30, 26,
+ 115,101,110,100, 13, 6, 1, 1, 1, 1, 19, 13, 11, 48, 22,115,105,120, 14,
+ 6, 1, 1, 1, 1, 21, 10, 38, 97, 34,115,104,101,119, 14, 6, 1, 1, 1,
+ 1, 21, 10, 25, 7, 19,103,111,110,101, 17, 6, 1, 1, 1, 1, 27, 9, 50,
+ 92, 29,116,104,101,114,101,105,110, 13, 6, 1, 1, 1, 1, 19, 9, 49, 51,
+ 38,111,105,108, 10, 6, 1, 1, 1, 1, 0, 7, 33, 72, 31, 19, 6, 1, 1,
+ 1, 1, 31, 6, 23, 37, 31,115, 97, 99,114,105,102,105, 99,101, 16, 6, 1,
+ 1, 1, 1, 25, 6, 15, 3, 11,116,101,109,112,108,101, 15, 6, 1, 1, 1,
+ 1, 23, 5, 43, 23, 41, 98,101,103, 97,116, 13, 6, 1, 1, 1, 8, 21, 4,
+ 19, 58,119, 97,121,115, 14, 6, 1, 1, 1, 1, 21, 4, 13, 21, 39,100,111,
+ 116,104, 14, 6, 1, 1, 1, 1, 21, 4, 12, 38, 36,115,101,110,100, 15, 6,
+ 1, 1, 1, 1, 23, 3, 39, 21, 45, 98,101,103, 97,116, 13, 6, 1, 1, 1,
+ 1, 19, 2, 6, 37, 11, 99, 97,110, 14, 6, 9, 1, 1, 1, 23, 20, 2, 45,
+ 97, 98,111,118,101, 14, 6, 8, 1, 1, 1, 23, 36, 52, 17, 99,104, 0, 0,
+ 0, 21, 13, 6, 1, 1, 1, 1, 19, 26, 34, 15, 20, 97,114,107, 13, 0, 0,
+ 0, 35, 0, 92, 0, 1,244, 1,232, 1,216, 1,204, 1,186, 1,171, 1,160,
+ 1,149, 1,138, 1,128, 1,117, 1,106, 1, 92, 1, 76, 1, 65, 1, 49, 1,
+ 32, 1, 21, 1, 10, 0,255, 0,241, 0,225, 0,214, 0,203, 0,192, 0,180,
+ 0,168, 0,156, 0,144, 0,132, 0,124, 0,116, 0,108, 0,100, 0, 92, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 35, 6, 0, 0, 0,
+ 0, 0, 6, 34, 6, 0, 0, 0, 0, 0, 6, 33, 6, 0, 0, 0, 0, 0, 6,
+ 32, 6, 0, 0, 0, 0, 0, 6, 31, 6, 0, 0, 0, 0, 0, 10, 30, 6, 1,
+ 1, 1, 1, 0, 48, 37, 93, 7, 10, 29, 6, 1, 1, 1, 1, 0, 28, 17, 67,
+ 31, 10, 28, 6, 1, 1, 1, 1, 0, 22, 45, 71, 28, 10, 27, 6, 1, 1, 1,
+ 1, 0, 12, 4, 38, 36, 10, 26, 6, 1, 1, 1, 1, 0, 49, 9, 51, 38, 9,
+ 25, 6, 1, 1, 1, 0, 0, 17, 29, 74, 9, 24, 6, 1, 1, 1, 0, 0, 47,
+ 22, 16, 9, 23, 6, 1, 1, 1, 0, 0, 32, 16, 7, 14, 22, 6, 1, 1, 1,
+ 0, 23, 42, 20, 18, 98,101,103, 97,116, 12, 21, 6, 1, 1, 1, 0, 19, 34,
+ 26, 15, 97,114,107, 9, 20, 6, 1, 1, 0, 1, 0, 49, 9, 38, 9, 19, 6,
+ 1, 1, 0, 1, 0, 44, 48, 9, 9, 18, 6, 1, 1, 0, 1, 0, 21, 22, 18,
+ 15, 17, 6, 1, 1, 0, 1, 25, 35, 38, 22, 99,117, 98,105,116,115, 14, 16,
+ 6, 1, 1, 0, 1, 23, 37, 17, 18,100,119,101,108,116, 9, 15, 6, 1, 0,
+ 1, 1, 0, 49, 51, 38, 14, 14, 6, 1, 0, 1, 1, 23, 10, 89, 14,115,101,
+ 114,118,101, 12, 13, 6, 9, 0, 1, 1, 21, 68, 32,100,111,116,104, 9, 12,
+ 6, 1, 0, 1, 1, 0, 47, 16, 40, 9, 11, 6, 1, 0, 1, 1, 0, 25, 7,
+ 19, 8, 10, 6, 0, 1, 1, 8, 0, 16, 7, 9, 9, 6, 0, 1, 1, 1, 0,
+ 16, 81, 25, 9, 8, 6, 0, 1, 1, 1, 0, 7, 72, 31, 9, 7, 6, 0, 1,
+ 1, 1, 0, 6, 37, 31, 13, 6, 6, 0, 1, 1, 1, 21, 21, 91, 38,110,101,
+ 97,114, 16, 5, 6, 1, 1, 1, 1, 25, 15, 6, 3, 11,116,101,109,112,108,
+ 101, 10, 4, 6, 1, 1, 1, 1, 0, 21, 22, 92, 18, 14, 3, 6, 1, 1, 1,
+ 1, 21, 4, 41, 32, 35,110,101, 97,114, 10, 2, 6, 1, 1, 1, 1, 0, 46,
+ 28, 88, 22, 10, 1, 6, 1, 1, 1, 1, 0, 17, 29, 74, 36, 13, 0, 0, 0,
+ 15, 1, 71, 0, 1,243, 1,230, 1,217, 1,204, 1,191, 1,179, 1,167, 1,
+ 155, 1,143, 1,131, 1,119, 1,107, 1, 95, 1, 83, 1, 71, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 10, 15, 6, 1, 1, 1, 1, 0, 48, 37, 93, 7, 10, 14, 6, 1, 1, 1, 1,
+ 0, 22, 45, 71, 28, 10, 13, 6, 1, 1, 1, 1, 0, 12, 4, 38, 36, 10, 12,
+ 6, 1, 1, 1, 0, 1, 32, 16, 7, 79, 10, 11, 6, 1, 1, 1, 0, 1, 42,
+ 20, 18, 19, 10, 10, 6, 1, 1, 1, 0, 1, 34, 26, 15, 13, 10, 9, 6, 1,
+ 1, 0, 1, 1, 49, 9, 38, 97, 10, 8, 6, 1, 1, 0, 1, 1, 44, 48, 9,
+ 90, 10, 7, 6, 1, 1, 0, 1, 1, 35, 38, 22, 33, 10, 6, 6, 1, 1, 0,
+ 1, 1, 37, 17, 18, 18, 11, 5, 6, 1, 1, 1, 1, 1, 15, 6, 3, 11, 43,
+ 11, 4, 6, 1, 1, 1, 1, 1, 21, 22, 92, 18, 62, 11, 3, 6, 1, 1, 1,
+ 1, 1, 4, 41, 32, 35, 36, 11, 2, 6, 1, 1, 1, 1, 1, 46, 28, 88, 22,
+ 77, 11, 1, 6, 1, 1, 1, 1, 1, 17, 29, 74, 36, 61, 10, 0, 0, 0, 15,
+ 1,167, 0, 1,250, 1,244, 1,238, 1,233, 1,227, 1,221, 1,215, 1,209,
+ 1,203, 1,197, 1,191, 1,185, 1,179, 1,173, 1,167, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 5, 3, 1, 1, 49, 9, 5, 3, 1, 1, 48, 15, 5, 3, 1, 1, 46, 2, 5,
+ 3, 1, 1, 44, 8, 5, 3, 1, 1, 42, 11, 5, 3, 1, 1, 37, 6, 5, 3,
+ 1, 1, 35, 7, 5, 3, 1, 1, 34, 10, 5, 3, 1, 1, 32, 12, 5, 3, 1,
+ 1, 22, 14, 5, 3, 1, 1, 21, 4, 4, 3, 1, 9, 17, 5, 3, 1, 1, 15,
+ 5, 5, 3, 1, 1, 12, 13, 5, 3, 1, 1, 4, 3, 10, 0, 0, 0, 15, 1,
+ 167, 0, 1,250, 1,244, 1,238, 1,232, 1,226, 1,220, 1,214, 1,208, 1,
+ 202, 1,197, 1,191, 1,185, 1,179, 1,173, 1,167, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
+ 3, 1, 1, 48, 8, 5, 3, 1, 1, 45, 14, 5, 3, 1, 1, 41, 3, 5, 3,
+ 1, 1, 38, 7, 5, 3, 1, 1, 37, 15, 4, 3, 1, 9, 29, 5, 3, 1, 1,
+ 28, 2, 5, 3, 1, 1, 26, 10, 5, 3, 1, 1, 22, 4, 5, 3, 1, 1, 20,
+ 11, 5, 3, 1, 1, 17, 6, 5, 3, 1, 1, 16, 12, 5, 3, 1, 1, 9, 9,
+ 5, 3, 1, 1, 6, 5, 5, 3, 1, 1, 4, 13, 5, 0, 0, 0, 2, 1,246,
+ 0, 0, 0, 0, 27, 1,251, 1,246, 1,168, 1,148, 1,130, 1,107, 1, 86,
+ 1, 65, 1, 44, 1, 27, 1, 14, 0,250, 0,224, 0,205, 0,184, 0,165, 0,
+ 145, 0,123, 0,106, 0, 86, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 17, 23, 6, 0, 23, 1, 1, 21,107,110,111,119,110, 52, 19,112,
+ 111,111,114, 18, 22, 6, 0, 23, 1, 1, 23, 97, 98,111,118,101, 24, 26,115,
+ 101,114,118,101, 15, 21, 6, 0, 19, 1, 1, 21,119, 97,114, 52, 19,112,111,
+ 111,114, 20, 20, 6, 0, 27, 1, 8, 25,110,111,116,104,105,110,103, 7,112,
+ 108, 97, 99,101,115, 18, 19, 6, 0, 23, 1, 1, 23, 98,101,103, 97,116, 90,
+ 27,116,114,117,116,104, 17, 18, 6, 0, 23, 1, 1, 21,100,119,101,108,116,
+ 21, 39,100,111,116,104, 19, 17, 6, 0, 27, 1, 1, 21,109,111,114,110,105,
+ 110,103, 52, 19,112,111,111,114, 17, 16, 6, 0, 21, 1, 1, 23,115,104,101,
+ 119, 90, 27,116,114,117,116,104, 24, 15, 6, 0, 27, 1, 1, 31,116,104,101,
+ 114,101,105,110, 37, 31,115, 97, 99,114,105,102,105, 99,101, 18, 14, 6, 0,
+ 23, 1, 8, 25,115,109,111,116,101, 7,112,108, 97, 99,101,115, 11, 13, 6,
+ 0, 19, 1, 1, 0, 97,114,107, 72, 31, 15, 12, 6, 0, 21, 1, 8, 21,119,
+ 105,110,101, 58,119, 97,121,115, 19, 11, 6, 0, 21, 1, 1, 27,115,111,109,
+ 101, 98, 17,109,111,114,110,105,110,103, 19, 10, 6, 0, 27, 1, 1, 21, 98,
+ 101,116,119,101,101,110, 92, 18,115,111,109,101, 19, 9, 6, 0, 21, 1, 1,
+ 27,115, 97,118,101, 74, 36, 98,101,116,119,101,101,110, 21, 8, 6, 0, 25,
+ 1, 1, 27,116,104,111,117,103,104, 98, 17,109,111,114,110,105,110,103, 16,
+ 7, 6, 0, 21, 1, 1, 21,115,101,110,100, 49, 34,115,101,110,100, 18, 6,
+ 6, 0, 25, 1, 1, 21,119,105,115,100,111,109, 38, 36,115,101,110,100, 16,
+ 5, 6, 0, 23, 1, 9, 21, 97,110,103,101,114, 46,119, 97,121,115, 14, 4,
+ 6, 0, 19, 1, 1, 19, 99, 97,110, 19, 43,119, 97,114, 16, 3, 6, 0, 23,
+ 1, 1, 19,111,102,102,101,114, 48, 22,115,105,120, 16, 2, 6, 0, 23, 1,
+ 8, 21,119,111,114,107,115, 58,119, 97,121,115, 16, 1, 6, 0, 23, 1, 1,
+ 19, 0, 0, 0, 26, 45, 0, 0, 0, 25, 23, 13, 0, 0, 0, 7, 0, 48, 0,
+ 1,171, 1, 74, 1, 30, 0,126, 0,249, 0,212, 0, 48, 0, 81, 0, 0, 84,
+ 4, 7, 23, 17, 17, 1,129, 19,116, 97, 98,108,101,116, 52,116, 52, 5, 67,
+ 82, 69, 76, 7, 7, 23, 17, 17, 1,129, 3,116, 97, 98,108,101,116, 53,116,
+ 53, 8, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 53, 40, 97,
+ 32, 73, 78, 84, 69, 71, 69, 82, 32, 80, 82, 73, 77, 65, 82, 89, 32, 75, 69,
+ 89, 44, 32, 98, 32, 84, 69, 88, 84, 32, 85, 78, 73, 81, 85, 69, 44, 99, 44,
+ 100, 44,101, 41, 84, 4, 7, 23, 17, 17, 1,129, 19,116, 97, 98,108,101,116,
+ 52,116, 52, 5, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 52,
+ 40, 97, 32, 73, 78, 84, 32, 85, 78, 73, 81, 85, 69, 32, 78, 79, 84, 32, 78,
+ 85, 76, 76, 44, 32, 98, 32, 73, 78, 84, 32, 85, 78, 73, 81, 85, 69, 32, 78,
+ 79, 84, 32, 78, 85, 76, 76, 44, 99, 44,100, 44,101, 41, 35, 6, 6, 23, 55,
+ 17, 1, 0,105,110,100,101,120,115,113,108,105,116,101, 95, 97,117,116,111,
+ 105,110,100,101,120, 95,116, 52, 95, 50,116, 52, 7, 35, 5, 6, 23, 55, 17,
+ 1, 0,105,110,100,101,120,115,113,108,105,116,101, 95, 97,117,116,111,105,
+ 110,100,101,120, 95,116, 52, 95, 49,116, 52, 6, 42, 3, 6, 23, 17, 17, 1,
+ 65,116, 97, 98,108,101,116, 51,116, 51, 4, 67, 82, 69, 65, 84, 69, 32, 84,
+ 65, 66, 76, 69, 32,116, 51, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 95,
+ 2, 7, 23, 17, 17, 1,129, 41,116, 97, 98,108,101,116, 50,116, 50, 3, 67,
+ 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 50, 40, 97, 32, 73, 78,
+ 84, 44, 32, 98, 32, 73, 78, 84, 44, 32, 99, 32, 73, 78, 84, 44,100, 32, 73,
+ 78, 84, 44,101, 32, 73, 78, 84, 44, 80, 82, 73, 77, 65, 82, 89, 32, 75, 69,
+ 89, 40, 98, 44, 97, 41, 41, 87, 73, 84, 72, 79, 85, 84, 32, 82, 79, 87, 73,
+ 68, 83, 1, 7, 23, 17, 17, 1,129, 17,116, 97, 98,108,101,116, 49,116, 49,
+ 2, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 49, 40, 97, 32,
+ 73, 78, 84, 69, 71, 69, 82, 32, 80, 82, 73, 77, 65, 82, 89, 32, 75, 69, 89,
+ 44, 32, 98, 32, 73, 78, 84, 44, 32, 99, 32, 73, 78, 84, 44, 32,100, 32, 73,
+ 78, 84, 44, 32,101, 32, 73, 78, 84, 41, 2, 0, 0, 0, 1, 1,243, 0, 0,
+ 0, 0, 29, 1,243, 1,218, 1,209, 1,199, 1,187, 1,179, 1,169, 1,158,
+ 1,145, 1,136, 1,127, 1,117, 1,107, 1, 98, 1, 82, 1, 72, 1, 63, 1,
+ 51, 1, 42, 1, 30, 1, 20, 1, 12, 1, 3, 0,248, 0,239, 0,225, 0,216,
+ 0,207, 0,197, 0,188, 0,180, 0,170, 0,161, 0,152, 0,141, 0,129, 0,
+ 118, 0,106, 0, 97, 0, 0, 0, 0, 0, 0, 0, 8, 3, 21, 1,116,114,101,
+ 101, 49, 11, 3, 27, 1,116,104,121,115,101,108,102, 27, 10, 3, 25, 1,116,
+ 104,111,117,103,104, 8, 11, 3, 27, 1,116,104,101,114,101,105,110, 15, 10,
+ 3, 25, 1,116,101,109,112,108,101, 43, 8, 3, 21, 1,116,101,108,108, 25,
+ 8, 3, 21, 1,115,111,109,101, 11, 9, 3, 23, 1,115,109,111,116,101, 14,
+ 7, 3, 19, 1,115,105,120, 48, 8, 3, 21, 1,115,104,101,119, 16, 9, 3,
+ 23, 1,115,101,114,118,101, 37, 8, 3, 21, 1,115,101,110,100, 7, 8, 3,
+ 21, 1,115, 97,118,101, 9, 13, 3, 31, 1,115, 97, 99,114,105,102,105, 99,
+ 101, 24, 8, 3, 21, 1,112,111,111,114, 40, 10, 3, 25, 1,112,108, 97, 99,
+ 101,115, 28, 8, 3, 21, 1,112, 97,114,116, 30, 7, 3, 19, 1,111,105,108,
+ 46, 9, 3, 23, 1,111,102,102,101,114, 3, 11, 3, 27, 1,110,111,116,104,
+ 105,110,103, 20, 8, 3, 21, 1,110,101, 97,114, 36, 11, 3, 27, 1,109,111,
+ 114,110,105,110,103, 17, 8, 3, 21, 1,108,111,110,103, 35, 9, 3, 23, 1,
+ 107,110,111,119,110, 23, 15, 3, 35, 1,105,110,104, 97, 98,105,116, 97,110,
+ 116,115, 45, 8, 3, 21, 1,103,111,110,101, 32, 9, 3, 23, 1,102,114,117,
+ 105,116, 38, 9, 3, 23, 1,100,119,101,108,116, 18, 8, 3, 21, 1,100,111,
+ 116,104, 39, 8, 3, 21, 1,100,105,101,100, 47, 12, 3, 29, 1,100,101,112,
+ 97,114,116,101,100, 26, 10, 3, 25, 1, 99,117, 98,105,116,115, 33, 9, 3,
+ 23, 1, 99,104,105,108,100, 42, 7, 3, 19, 1, 99, 97,110, 4, 11, 3, 27,
+ 1, 98,101,116,119,101,101,110, 10, 9, 3, 23, 1, 98,101,103, 97,116, 19,
+ 8, 3, 21, 1, 98,101, 97,114, 29, 7, 3, 19, 1, 97,114,107, 13, 9, 3,
+ 23, 1, 97,110,103,101,114, 5, 9, 3, 23, 1, 97,110,103, 0, 0, 0, 28,
+ 8, 3, 21, 1,116,114,101,101, 49, 13, 1,104, 0, 7, 0, 24, 0, 1, 67,
+ 1, 13, 0,225, 0,177, 0,109, 1,171, 0, 24, 0, 0, 83, 14, 7, 21, 19,
+ 19, 8,129, 17,118,105,101,119,118, 50, 48,118, 50, 48, 67, 82, 69, 65, 84,
+ 69, 32, 86, 73, 69, 87, 32,118, 50, 48, 40, 97, 44, 98, 44, 99, 44,100, 44,
+ 101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,
+ 100, 44,101, 32, 70, 82, 79, 77, 32,116, 50, 32, 87, 72, 69, 82, 69, 32, 97,
+ 60, 62, 50, 53, 66, 12, 6, 21, 19, 19, 8,113,118,105,101,119,118, 48, 48,
+ 118, 48, 48, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 48, 48, 40,
+ 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67,
+ 84, 32, 49, 44, 49, 44, 49, 44, 49, 44, 39,111,110,101, 39, 46, 11, 6, 23,
+ 21, 17, 1, 69,105,110,100,101,120,116, 50,101,100,116, 50, 14, 67, 82, 69,
+ 65, 84, 69, 32, 73, 78, 68, 69, 88, 32,116, 50,101,100, 32, 79, 78, 32,116,
+ 50, 40,101, 44,100, 41, 42, 10, 6, 23, 19, 17, 1, 63,105,110,100,101,120,
+ 116, 49,101,116, 49, 13, 67, 82, 69, 65, 84, 69, 32, 73, 78, 68, 69, 88, 32,
+ 116, 49,101, 32, 79, 78, 32,116, 49, 40,101, 41, 52, 9, 6, 23, 21, 17, 1,
+ 81,105,110,100,101,120,116, 51,120, 49,116, 51, 12, 67, 82, 69, 65, 84, 69,
+ 32, 73, 78, 68, 69, 88, 32,116, 51,120, 49, 32, 79, 78, 32,116, 51, 40, 97,
+ 44, 98, 44, 99, 44,100, 44,101, 41, 35, 8, 6, 23, 55, 17, 1, 0,105,110,
+ 100,101,120,115,113,108,105,116,101, 95, 97,117,116,111,105,110,100,101,120,
+ 95,116, 53, 95, 49,116, 53, 10, 0, 0, 0, 67, 17, 17, 1,129, 3,116, 97,
+ 98,108,101,116, 53,116, 53, 8, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76,
+ 69, 32,116, 53, 40, 97, 32, 73, 78, 84, 69, 71, 69, 82, 32, 80, 82, 73, 77,
+ 65, 82, 89, 32, 75, 69, 89, 44, 32, 98, 32, 84, 69, 88, 84, 32, 85, 78, 83,
+ 13, 7, 21, 19, 19, 8,129, 17,118,105,101,119,118, 49, 48,118, 49, 48, 67,
+ 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 49, 48, 40, 97, 44, 98, 44,
+ 99, 44,100, 44,101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44,
+ 98, 44, 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 49, 32, 87, 72, 69,
+ 82, 69, 32, 97, 60, 62, 50, 53, 2, 0, 0, 0, 1, 1,240, 0, 0, 0, 0,
+ 24, 1,240, 1,220, 1,211, 1,199, 1,187, 1,176, 1,164, 1,148, 1,133,
+ 1,116, 1, 99, 1, 86, 1, 67, 1, 55, 1, 43, 1, 31, 1, 18, 1, 5, 0,
+ 249, 0,236, 0,224, 0,209, 0,191, 0,174, 0,157, 0,145, 0,132, 0,120,
+ 0,108, 0, 95, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 7, 1, 0,
+ 1, 1, 0, 1, 49, 51, 38, 15, 12, 7, 1, 1, 1, 1, 0, 1, 48, 37, 93,
+ 7, 30, 11, 7, 1, 1, 1, 0, 0, 1, 47, 22, 16, 24, 11, 7, 1, 0, 1,
+ 1, 0, 1, 47, 16, 40, 12, 12, 7, 1, 1, 1, 1, 0, 1, 46, 28, 88, 22,
+ 2, 11, 7, 1, 1, 0, 1, 0, 1, 44, 48, 9, 19, 16, 7, 1, 1, 1, 0,
+ 23, 1, 42, 20, 18, 98,101,103, 97,116, 22, 16, 7, 1, 1, 0, 1, 23, 1,
+ 37, 17, 18,100,119,101,108,116, 16, 17, 7, 1, 1, 0, 1, 25, 1, 35, 38,
+ 22, 99,117, 98,105,116,115, 17, 14, 7, 1, 1, 1, 0, 19, 1, 34, 26, 15,
+ 97,114,107, 21, 11, 7, 1, 1, 1, 0, 0, 1, 32, 16, 7, 23, 12, 7, 1,
+ 1, 1, 1, 0, 1, 28, 17, 67, 31, 29, 11, 7, 1, 0, 1, 1, 0, 1, 25,
+ 7, 19, 11, 12, 7, 1, 1, 1, 1, 0, 1, 22, 45, 71, 28, 28, 12, 7, 1,
+ 1, 1, 1, 0, 1, 21, 22, 92, 18, 4, 11, 7, 1, 1, 0, 1, 0, 1, 21,
+ 22, 18, 18, 11, 7, 1, 1, 1, 1, 0, 9, 17, 29, 74, 36, 11, 7, 1, 1,
+ 1, 0, 0, 1, 17, 29, 74, 25, 18, 7, 1, 1, 1, 1, 25, 1, 15, 6, 3,
+ 11,116,101,109,112,108,101, 5, 12, 7, 1, 1, 1, 1, 0, 1, 12, 4, 38,
+ 36, 27, 16, 7, 1, 0, 1, 1, 23, 1, 10, 89, 14,115,101,114,118,101, 14,
+ 16, 7, 1, 1, 1, 1, 21, 1, 4, 41, 32, 35,110,101, 97,114, 3, 14, 7,
+ 9, 0, 1, 1, 21, 1, 68, 32,100,111,116,104, 13, 15, 7, 0, 1, 1, 1,
+ 21, 1, 21, 91, 38,110,101, 97,114, 6, 11, 7, 0, 1, 1, 1, 0, 1, 16,
+ 81, 25, 9, 10, 7, 0, 1, 1, 8, 0, 1, 16, 7, 10, 11, 7, 0, 1, 1,
+ 1, 0, 1, 7, 72, 31, 8, 11, 7, 0, 1, 1, 1, 0, 1, 6, 37, 31, 7,
+ 8, 7, 0, 0, 0, 0, 0, 1, 35, 8, 7, 0, 0, 0, 0, 0, 1, 34, 8,
+ 7, 0, 0, 0, 0, 0, 1, 33, 8, 7, 0, 0, 0, 23, 11, 7, 1, 0, 1,
+ 1, 0, 1, 49, 51, 38, 15, 2, 0, 0, 0, 1, 1,241, 0, 0, 0, 0, 18,
+ 1,241, 1,221, 1,211, 1,203, 1,193, 1,183, 1,173, 1,163, 1,151, 1,
+ 143, 1,133, 1,122, 1,109, 1,100, 1, 92, 1, 83, 1, 74, 1, 64, 1, 55,
+ 1, 46, 1, 34, 1, 22, 1, 13, 1, 4, 0,252, 0,241, 0,232, 0,218, 0,
+ 209, 0,200, 0,191, 0,182, 0,173, 0,163, 0,153, 0,144, 0,136, 0,127,
+ 0,116, 0,105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 3,
+ 25, 1,116,101,109,112,108,101, 48, 10, 3, 25, 1,116,101,109,112,108,101,
+ 15, 8, 3, 21, 1,115,111,109,101, 21, 7, 3, 19, 1,115,105,120, 11, 8,
+ 3, 21, 1,115,104,101,119, 38, 9, 3, 23, 1,115,101,114,118,101, 10, 9,
+ 3, 23, 1,115,101,114,118,101, 3, 8, 3, 21, 1,115,101,110,100, 40, 8,
+ 3, 21, 1,115,101,110,100, 29, 8, 3, 21, 1,115,101,110,100, 12, 8, 3,
+ 21, 1,115,101,110,100, 8, 8, 3, 21, 1,115, 97,118,101, 2, 13, 3, 31,
+ 1,115, 97, 99,114,105,102,105, 99,101, 23, 8, 3, 21, 1,112,111,111,114,
+ 16, 10, 3, 25, 1,112,108, 97, 99,101,115, 32, 7, 3, 19, 1,111,105,108,
+ 49, 8, 3, 21, 1,110,101, 97,114, 7, 8, 3, 21, 1,110,101, 97,114, 4,
+ 11, 3, 27, 1,109,111,114,110,105,110,103, 41, 11, 3, 27, 1,109,111,114,
+ 110,105,110,103, 26, 8, 3, 21, 1,103,111,110,101, 25, 8, 3, 21, 1,103,
+ 111,110,101, 5, 9, 3, 23, 1,100,119,101,108,116, 37, 8, 3, 21, 1,100,
+ 111,116,104, 44, 8, 3, 21, 1,100,111,116,104, 13, 7, 3, 21, 9,100,111,
+ 116,104, 8, 3, 21, 1,100,105,101,100, 14, 12, 3, 29, 1,100,101,112, 97,
+ 114,116,101,100, 46, 10, 3, 25, 1, 99,117, 98,105,116,115, 35, 9, 3, 23,
+ 1, 99,104,105,108,100, 36, 7, 3, 19, 1, 99, 97,110, 6, 11, 3, 27, 1,
+ 98,101,116,119,101,101,110, 17, 9, 3, 23, 1, 98,101,103, 97,116, 43, 9,
+ 3, 23, 1, 98,101,103, 97,116, 42, 9, 3, 23, 1, 98,101,103, 97,116, 39,
+ 9, 3, 23, 1, 98,101,103, 97,116, 9, 7, 3, 19, 1, 97,114,107, 34, 9,
+ 3, 23, 1, 97,110,103,101,114, 47, 9, 3, 23, 1, 97,110,103,101,108, 27,
+ 9, 3, 23, 1, 97, 98,111,118,101, 45, 0, 0, 0, 17, 10, 3, 25, 1,116,
+ 101,109,112,108,101, 48, 2, 0, 0, 0, 1, 1,239, 0, 0, 0, 0, 20, 1,
+ 239, 1,206, 1,192, 1,180, 1,166, 1,152, 1,138, 1,125, 1,109, 1, 97,
+ 1, 84, 1, 69, 1, 52, 1, 39, 1, 26, 1, 14, 1, 1, 0,243, 0,230, 0,
+ 217, 0,201, 0,185, 0,172, 0,159, 0,147, 0,133, 0,120, 0,102, 0, 89,
+ 0, 76, 0, 0, 0, 0, 12, 5, 21, 1, 1, 1,115,101,110,100, 26, 14, 40,
+ 12, 5, 21, 1, 1, 1,115, 97,118,101, 39, 45, 2, 17, 5, 31, 1, 1, 1,
+ 115, 97, 99,114,105,102,105, 99,101, 31, 6, 23, 12, 5, 21, 1, 1, 1,112,
+ 111,111,114, 19, 44, 16, 13, 5, 25, 8, 1, 1,112,108, 97, 99,101,115, 16,
+ 32, 11, 5, 19, 1, 1, 1,111,105,108, 38, 9, 49, 12, 5, 21, 1, 1, 1,
+ 110,101, 97,114, 38, 21, 7, 12, 5, 21, 1, 1, 1,110,101, 97,114, 35, 41,
+ 4, 15, 5, 27, 1, 1, 1,109,111,114,110,105,110,103, 17, 40, 26, 15, 5,
+ 27, 1, 1, 1,109,111,114,110,105,110,103, 13, 46, 41, 12, 5, 21, 1, 1,
+ 1,103,111,110,101, 28, 25, 5, 12, 5, 21, 1, 1, 1,103,111,110,101, 19,
+ 10, 25, 13, 5, 23, 1, 1, 1,100,119,101,108,116, 18, 17, 37, 12, 5, 21,
+ 1, 1, 1,100,111,116,104, 39, 4, 13, 11, 5, 21, 1, 1, 9,100,111,116,
+ 104, 32, 40, 12, 5, 21, 1, 1, 1,100,111,116,104, 9, 48, 44, 12, 5, 21,
+ 1, 1, 1,100,105,101,100, 27, 35, 14, 16, 5, 29, 1, 1, 1,100,101,112,
+ 97,114,116,101,100, 22, 28, 46, 14, 5, 25, 1, 1, 1, 99,117, 98,105,116,
+ 115, 22, 38, 35, 12, 5, 23, 1, 8, 1, 99,104,105,108,100, 17, 36, 11, 5,
+ 19, 1, 1, 1, 99, 97,110, 11, 2, 6, 15, 5, 27, 1, 1, 1, 98,101,116,
+ 119,101,101,110, 36, 29, 17, 12, 5, 23, 1, 8, 1, 98,101,103, 97,116, 50,
+ 9, 13, 5, 23, 1, 1, 1, 98,101,103, 97,116, 45, 3, 39, 13, 5, 23, 1,
+ 1, 1, 98,101,103, 97,116, 41, 5, 43, 13, 5, 23, 1, 1, 1, 98,101,103,
+ 97,116, 5, 20, 42, 11, 5, 19, 1, 1, 1, 97,114,107, 20, 26, 34, 13, 5,
+ 23, 1, 1, 1, 97,110,103,101,114, 40, 22, 47, 13, 5, 23, 1, 1, 1, 97,
+ 110,103,101,108, 3, 22, 27, 12, 5, 23, 1, 9, 1, 97, 98,111,118,101, 45,
+ 20, 13, 5, 23, 1, 1, 1, 0, 0, 0, 19, 12, 5, 21, 1, 1, 1,115,101,
+ 110,100, 26, 14, 40, 13, 0, 0, 0, 28, 0, 78, 0, 1,241, 1,226, 1,210,
+ 1,195, 1,180, 1,166, 1,151, 1,136, 1,121, 1,105, 1, 91, 1, 76, 1,
+ 61, 1, 46, 1, 29, 1, 14, 0,252, 0,238, 0,224, 0,209, 0,194, 0,177,
+ 0,157, 0,143, 0,128, 0,110, 0, 94, 0, 78, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 14, 28, 6, 0, 1, 1, 1, 23, 17, 67, 31,119,
+ 111,114,107,115, 14, 27, 6, 0, 1, 1, 1, 23, 22, 71, 3, 97,110,103,101,
+ 108, 16, 26, 6, 0, 1, 1, 1, 27, 40, 98, 17,109,111,114,110,105,110,103,
+ 13, 25, 6, 0, 1, 1, 1, 21, 10, 7, 19,103,111,110,101, 12, 24, 6, 0,
+ 1, 1, 9, 21, 43, 46,119, 97,121,115, 18, 23, 6, 0, 1, 1, 1, 31, 6,
+ 37, 31,115, 97, 99,114,105,102,105, 99,101, 15, 22, 6, 0, 1, 1, 1, 25,
+ 45, 71, 28,116,104,111,117,103,104, 13, 21, 6, 0, 1, 1, 1, 21, 22, 92,
+ 18,115,111,109,101, 13, 20, 6, 0, 9, 1, 1, 23, 2, 45, 97, 98,111,118,
+ 101, 12, 19, 6, 0, 1, 1, 8, 21, 4, 58,119, 97,121,115, 12, 18, 6, 0,
+ 1, 1, 1, 19, 44, 19, 43,119, 97,114, 16, 17, 6, 0, 1, 1, 1, 27, 29,
+ 74, 36, 98,101,116,119,101,101,110, 13, 16, 6, 0, 1, 1, 1, 21, 44, 52,
+ 19,112,111,111,114, 15, 15, 6, 0, 1, 1, 1, 25, 6, 3, 11,116,101,109,
+ 112,108,101, 13, 14, 6, 0, 1, 1, 1, 21, 35, 48, 27,100,105,101,100, 13,
+ 13, 6, 0, 1, 1, 1, 21, 4, 21, 39,100,111,116,104, 13, 12, 6, 0, 1,
+ 1, 1, 21, 4, 38, 36,115,101,110,100, 12, 11, 6, 0, 1, 1, 1, 19, 13,
+ 48, 22,115,105,120, 14, 10, 6, 0, 1, 1, 1, 23, 41, 89, 14,115,101,114,
+ 118,101, 13, 9, 6, 0, 8, 1, 1, 23, 16, 50, 98,101,103, 97,116, 13, 8,
+ 6, 0, 1, 1, 1, 21, 42, 49, 34,115,101,110,100, 13, 7, 6, 0, 1, 1,
+ 1, 21, 21, 91, 38,110,101, 97,114, 12, 6, 6, 0, 1, 1, 1, 19, 2, 37,
+ 11, 99, 97,110, 13, 5, 6, 0, 1, 1, 1, 21, 25, 27, 28,103,111,110,101,
+ 13, 4, 6, 0, 1, 1, 1, 21, 41, 32, 35,110,101, 97,114, 14, 3, 6, 0,
+ 1, 1, 1, 23, 32, 24, 26,115,101,114,118,101, 13, 2, 6, 0, 1, 1, 1,
+ 21, 45, 14, 39,115, 97,118,101, 13, 1, 6, 0, 1, 1, 1, 21, 40, 68, 32,
+ 100,111,116,104, 13, 0, 0, 0, 22, 0,166, 0, 1,241, 1,226, 1,210, 1,
+ 194, 1,183, 1,169, 1,152, 1,137, 1,121, 1,106, 1, 90, 1, 75, 1, 57,
+ 1, 41, 1, 25, 1, 10, 0,250, 0,231, 0,215, 0,198, 0,184, 0,166, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
+ 50, 6, 0, 1, 1, 1, 27, 9, 92, 29,116,104,101,114,101,105,110, 12, 49,
+ 6, 0, 1, 1, 1, 19, 9, 51, 38,111,105,108, 15, 48, 6, 0, 1, 1, 1,
+ 25, 37, 93, 7,116,101,109,112,108,101, 14, 47, 6, 0, 1, 1, 1, 23, 22,
+ 16, 40, 97,110,103,101,114, 17, 46, 6, 0, 1, 1, 1, 29, 28, 88, 22,100,
+ 101,112, 97,114,116,101,100, 14, 45, 6, 0, 1, 1, 1, 23, 47, 54, 12, 97,
+ 98,111,118,101, 13, 44, 6, 0, 1, 1, 1, 21, 48, 15, 9,100,111,116,104,
+ 14, 43, 6, 0, 1, 1, 1, 23, 5, 23, 41, 98,101,103, 97,116, 14, 42, 6,
+ 0, 1, 1, 1, 23, 20, 18, 5, 98,101,103, 97,116, 16, 41, 6, 0, 1, 1,
+ 1, 27, 46, 92, 13,109,111,114,110,105,110,103, 13, 40, 6, 0, 1, 1, 1,
+ 21, 14, 30, 26,115,101,110,100, 14, 39, 6, 0, 1, 1, 1, 23, 3, 21, 45,
+ 98,101,103, 97,116, 13, 38, 6, 0, 1, 1, 1, 21, 10, 97, 34,115,104,101,
+ 119, 14, 37, 6, 0, 1, 1, 1, 23, 17, 66, 18,100,119,101,108,116, 13, 36,
+ 6, 0, 8, 1, 1, 23, 52, 17, 99,104,105,108,100, 15, 35, 6, 0, 1, 1,
+ 1, 25, 38, 34, 22, 99,117, 98,105,116,115, 12, 34, 6, 0, 1, 1, 1, 19,
+ 26, 15, 20, 97,114,107, 9, 33, 6, 0, 1, 1, 1, 0, 7, 72, 31, 14, 32,
+ 6, 0, 1, 1, 8, 25, 16, 7,112,108, 97, 99,101,115, 14, 31, 6, 0, 1,
+ 1, 1, 23, 39, 90, 27,116,114,117,116,104, 13, 30, 6, 0, 1, 1, 1, 21,
+ 16, 81, 25,119, 97,108,107, 13, 29, 6, 0, 1, 1, 1, 21, 34, 62, 27,115,
+ 101,110,100, 10, 0, 0, 0, 41, 0,116, 0, 1,251, 1,241, 1,231, 1,221,
+ 1,211, 1,203, 1,193, 1,183, 1,173, 1,163, 1,151, 1,143, 1,133, 1,
+ 122, 1,109, 1,100, 1, 92, 1, 83, 1, 74, 1, 64, 1, 55, 1, 46, 1, 34,
+ 1, 22, 1, 13, 1, 4, 0,252, 0,241, 0,232, 0,218, 0,209, 0,200, 0,
+ 191, 0,182, 0,173, 0,163, 0,153, 0,144, 0,136, 0,127, 0,116, 0,105,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11,116,101,
+ 109,112,108,101, 48, 10, 3, 25, 1,116,101,109,112,108,101, 15, 8, 3, 21,
+ 1,115,111,109,101, 21, 7, 3, 19, 1,115,105,120, 11, 8, 3, 21, 1,115,
+ 104,101,119, 38, 9, 3, 23, 1,115,101,114,118,101, 10, 9, 3, 23, 1,115,
+ 101,114,118,101, 3, 8, 3, 21, 1,115,101,110,100, 40, 8, 3, 21, 1,115,
+ 101,110,100, 29, 8, 3, 21, 1,115,101,110,100, 12, 8, 3, 21, 1,115,101,
+ 110,100, 8, 8, 3, 21, 1,115, 97,118,101, 2, 13, 3, 31, 1,115, 97, 99,
+ 114,105,102,105, 99,101, 23, 8, 3, 21, 1,112,111,111,114, 16, 10, 3, 25,
+ 1,112,108, 97, 99,101,115, 32, 7, 3, 19, 1,111,105,108, 49, 8, 3, 21,
+ 1,110,101, 97,114, 7, 8, 3, 21, 1,110,101, 97,114, 4, 11, 3, 27, 1,
+ 109,111,114,110,105,110,103, 41, 11, 3, 27, 1,109,111,114,110,105,110,103,
+ 26, 8, 3, 21, 1,103,111,110,101, 25, 8, 3, 21, 1,103,111,110,101, 5,
+ 9, 3, 23, 1,100,119,101,108,116, 37, 8, 3, 21, 1,100,111,116,104, 44,
+ 8, 3, 21, 1,100,111,116,104, 13, 7, 3, 21, 9,100,111,116,104, 8, 3,
+ 21, 1,100,105,101,100, 14, 12, 3, 29, 1,100,101,112, 97,114,116,101,100,
+ 46, 10, 3, 25, 1, 99,117, 98,105,116,115, 35, 9, 3, 23, 1, 99,104,105,
+ 108,100, 36, 7, 3, 19, 1, 99, 97,110, 6, 11, 3, 27, 1, 98,101,116,119,
+ 101,101,110, 17, 9, 3, 23, 1, 98,101,103, 97,116, 43, 9, 3, 23, 1, 98,
+ 101,103, 97,116, 42, 9, 3, 23, 1, 98,101,103, 97,116, 39, 9, 3, 23, 1,
+ 98,101,103, 97,116, 9, 7, 3, 19, 1, 97,114,107, 34, 9, 3, 23, 1, 97,
+ 110,103,101,114, 47, 9, 3, 23, 1, 97,110,103,101,108, 27, 9, 3, 23, 1,
+ 97, 98,111,118,101, 45, 9, 3, 23, 1, 97, 98,111,118,101, 20, 4, 3, 0,
+ 1, 33, 10, 0, 0, 0, 8, 1,178, 0, 1,244, 1,233, 1,223, 1,214, 1,
+ 206, 1,197, 1,188, 1,178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
+ 3, 23, 1,119,111,114,107,115, 28, 8, 3, 21, 1,119, 97,121,115, 24, 8,
+ 3, 21, 1,119, 97,121,115, 19, 7, 3, 19, 1,119, 97,114, 18, 8, 3, 21,
+ 1,119, 97,108,107, 30, 9, 3, 23, 1,116,114,117,116,104, 31, 10, 3, 25,
+ 1,116,104,111,117,103,104, 22, 11, 3, 27, 1,116,104,101,114,101,105,110,
+ 50, 10, 0, 0, 0, 31, 0, 89, 0, 1,247, 1,233, 1,220, 1,206, 1,192,
+ 1,180, 1,166, 1,152, 1,138, 1,125, 1,109, 1, 97, 1, 84, 1, 69, 1,
+ 52, 1, 39, 1, 26, 1, 14, 1, 1, 0,243, 0,230, 0,217, 0,201, 0,185,
+ 0,172, 0,159, 0,147, 0,133, 0,120, 0,102, 0, 89, 0, 76, 0, 0, 0,
+ 0, 0, 0, 0, 13, 1, 1,115,101,110,100, 26, 14, 40, 12, 5, 21, 1, 1,
+ 1,115, 97,118,101, 39, 45, 2, 17, 5, 31, 1, 1, 1,115, 97, 99,114,105,
+ 102,105, 99,101, 31, 6, 23, 12, 5, 21, 1, 1, 1,112,111,111,114, 19, 44,
+ 16, 13, 5, 25, 8, 1, 1,112,108, 97, 99,101,115, 16, 32, 11, 5, 19, 1,
+ 1, 1,111,105,108, 38, 9, 49, 12, 5, 21, 1, 1, 1,110,101, 97,114, 38,
+ 21, 7, 12, 5, 21, 1, 1, 1,110,101, 97,114, 35, 41, 4, 15, 5, 27, 1,
+ 1, 1,109,111,114,110,105,110,103, 17, 40, 26, 15, 5, 27, 1, 1, 1,109,
+ 111,114,110,105,110,103, 13, 46, 41, 12, 5, 21, 1, 1, 1,103,111,110,101,
+ 28, 25, 5, 12, 5, 21, 1, 1, 1,103,111,110,101, 19, 10, 25, 13, 5, 23,
+ 1, 1, 1,100,119,101,108,116, 18, 17, 37, 12, 5, 21, 1, 1, 1,100,111,
+ 116,104, 39, 4, 13, 11, 5, 21, 1, 1, 9,100,111,116,104, 32, 40, 12, 5,
+ 21, 1, 1, 1,100,111,116,104, 9, 48, 44, 12, 5, 21, 1, 1, 1,100,105,
+ 101,100, 27, 35, 14, 16, 5, 29, 1, 1, 1,100,101,112, 97,114,116,101,100,
+ 22, 28, 46, 14, 5, 25, 1, 1, 1, 99,117, 98,105,116,115, 22, 38, 35, 12,
+ 5, 23, 1, 8, 1, 99,104,105,108,100, 17, 36, 11, 5, 19, 1, 1, 1, 99,
+ 97,110, 11, 2, 6, 15, 5, 27, 1, 1, 1, 98,101,116,119,101,101,110, 36,
+ 29, 17, 12, 5, 23, 1, 8, 1, 98,101,103, 97,116, 50, 9, 13, 5, 23, 1,
+ 1, 1, 98,101,103, 97,116, 45, 3, 39, 13, 5, 23, 1, 1, 1, 98,101,103,
+ 97,116, 41, 5, 43, 13, 5, 23, 1, 1, 1, 98,101,103, 97,116, 5, 20, 42,
+ 11, 5, 19, 1, 1, 1, 97,114,107, 20, 26, 34, 13, 5, 23, 1, 1, 1, 97,
+ 110,103,101,114, 40, 22, 47, 13, 5, 23, 1, 1, 1, 97,110,103,101,108, 3,
+ 22, 27, 12, 5, 23, 1, 9, 1, 97, 98,111,118,101, 45, 20, 13, 5, 23, 1,
+ 1, 1, 97, 98,111,118,101, 12, 47, 45, 8, 5, 0, 1, 1, 1, 31, 7, 33,
+ 10, 0, 0, 0, 18, 1, 13, 0, 1,243, 1,230, 1,217, 1,203, 1,189, 1,
+ 176, 1,164, 1,151, 1,136, 1,121, 1,105, 1, 90, 1, 76, 1, 63, 1, 51,
+ 1, 39, 1, 27, 1, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 13, 5, 23, 1, 1, 1,119,111,114,107,115, 31, 17, 28, 11, 5,
+ 21, 9, 1, 1,119, 97,121,115, 43, 24, 11, 5, 21, 8, 1, 1,119, 97,121,
+ 115, 4, 19, 11, 5, 19, 1, 1, 1,119, 97,114, 43, 44, 18, 12, 5, 21, 1,
+ 1, 1,119, 97,108,107, 25, 16, 30, 13, 5, 23, 1, 1, 1,116,114,117,116,
+ 104, 27, 39, 31, 14, 5, 25, 1, 1, 1,116,104,111,117,103,104, 28, 45, 22,
+ 15, 5, 27, 1, 1, 1,116,104,101,114,101,105,110, 29, 9, 50, 14, 5, 25,
+ 1, 1, 1,116,101,109,112,108,101, 11, 6, 15, 14, 5, 25, 1, 1, 1,116,
+ 101,109,112,108,101, 7, 37, 48, 12, 5, 21, 1, 1, 1,115,111,109,101, 18,
+ 22, 21, 11, 5, 19, 1, 1, 1,115,105,120, 22, 13, 11, 12, 5, 21, 1, 1,
+ 1,115,104,101,119, 34, 10, 38, 13, 5, 23, 1, 1, 1,115,101,114,118,101,
+ 26, 32, 3, 13, 5, 23, 1, 1, 1,115,101,114,118,101, 14, 41, 10, 12, 5,
+ 21, 1, 1, 1,115,101,110,100, 36, 4, 12, 12, 5, 21, 1, 1, 1,115,101,
+ 110,100, 34, 42, 8, 12, 5, 21, 1, 1, 1,115,101,110,100, 27, 34, 29, 10,
+ 0, 0, 0, 28, 0, 82, 0, 1,241, 1,226, 1,211, 1,197, 1,181, 1,166,
+ 1,151, 1,137, 1,121, 1,104, 1, 84, 1, 73, 1, 59, 1, 41, 1, 26, 1,
+ 11, 0,253, 0,238, 0,223, 0,207, 0,191, 0,175, 0,159, 0,144, 0,129,
+ 0,113, 0, 97, 0, 82, 0, 68, 0, 0, 0, 0, 0, 14, 1, 1, 19, 26, 34,
+ 15, 20, 97,114,107, 14, 6, 1, 1, 1, 1, 21, 25, 5, 27, 28,103,111,110,
+ 101, 15, 6, 1, 1, 1, 1, 23, 22, 47, 16, 40, 97,110,103,101,114, 15, 6,
+ 1, 1, 1, 1, 23, 22, 27, 71, 3, 97,110,103,101,108, 14, 6, 1, 1, 1,
+ 1, 21, 22, 21, 92, 18,115,111,109,101, 14, 6, 1, 1, 1, 1, 21, 21, 7,
+ 91, 38,110,101, 97,114, 15, 6, 1, 1, 1, 1, 23, 20, 42, 18, 5, 98,101,
+ 103, 97,116, 15, 6, 1, 1, 1, 1, 23, 17, 37, 66, 18,100,119,101,108,116,
+ 15, 6, 1, 1, 1, 1, 23, 17, 28, 67, 31,119,111,114,107,115, 15, 6, 1,
+ 1, 1, 8, 25, 16, 32, 7,112,108, 97, 99,101,115, 14, 6, 1, 1, 1, 1,
+ 21, 16, 30, 81, 25,119, 97,108,107, 14, 6, 1, 1, 1, 1, 21, 14, 40, 30,
+ 26,115,101,110,100, 13, 6, 1, 1, 1, 1, 19, 13, 11, 48, 22,115,105,120,
+ 14, 6, 1, 1, 1, 1, 21, 10, 38, 97, 34,115,104,101,119, 14, 6, 1, 1,
+ 1, 1, 21, 10, 25, 7, 19,103,111,110,101, 17, 6, 1, 1, 1, 1, 27, 9,
+ 50, 92, 29,116,104,101,114,101,105,110, 13, 6, 1, 1, 1, 1, 19, 9, 49,
+ 51, 38,111,105,108, 10, 6, 1, 1, 1, 1, 0, 7, 33, 72, 31, 19, 6, 1,
+ 1, 1, 1, 31, 6, 23, 37, 31,115, 97, 99,114,105,102,105, 99,101, 16, 6,
+ 1, 1, 1, 1, 25, 6, 15, 3, 11,116,101,109,112,108,101, 15, 6, 1, 1,
+ 1, 1, 23, 5, 43, 23, 41, 98,101,103, 97,116, 13, 6, 1, 1, 1, 8, 21,
+ 4, 19, 58,119, 97,121,115, 14, 6, 1, 1, 1, 1, 21, 4, 13, 21, 39,100,
+ 111,116,104, 14, 6, 1, 1, 1, 1, 21, 4, 12, 38, 36,115,101,110,100, 15,
+ 6, 1, 1, 1, 1, 23, 3, 39, 21, 45, 98,101,103, 97,116, 13, 6, 1, 1,
+ 1, 1, 19, 2, 6, 37, 11, 99, 97,110, 14, 6, 9, 1, 1, 1, 23, 20, 2,
+ 45, 97, 98,111,118,101, 14, 6, 8, 1, 1, 1, 23, 36, 52, 17, 99,104,105,
+ 108,100, 14, 6, 8, 1, 1, 1, 23, 9, 16, 50, 98,101,103, 97,116, 10, 0,
+ 0, 0, 21, 0,177, 0, 1,237, 1,219, 1,203, 1,188, 1,173, 1,156, 1,
+ 139, 1,123, 1,109, 1, 91, 1, 76, 1, 60, 1, 45, 1, 31, 1, 16, 1, 2,
+ 0,243, 0,226, 0,208, 0,192, 0,177, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 14, 6, 1, 1, 1, 1, 21, 48, 44, 15, 9,100,111,116,104,
+ 15, 6, 1, 1, 1, 1, 23, 47, 45, 54, 12, 97, 98,111,118,101, 17, 6, 1,
+ 1, 1, 1, 27, 46, 41, 92, 13,109,111,114,110,105,110,103, 16, 6, 1, 1,
+ 1, 1, 25, 45, 22, 71, 28,116,104,111,117,103,104, 14, 6, 1, 1, 1, 1,
+ 21, 45, 2, 14, 39,115, 97,118,101, 13, 6, 1, 1, 1, 1, 19, 44, 18, 19,
+ 43,119, 97,114, 14, 6, 1, 1, 1, 1, 21, 44, 16, 52, 19,112,111,111,114,
+ 13, 6, 1, 1, 1, 9, 21, 43, 24, 46,119, 97,121,115, 14, 6, 1, 1, 1,
+ 1, 21, 42, 8, 49, 34,115,101,110,100, 15, 6, 1, 1, 1, 1, 23, 41, 10,
+ 89, 14,115,101,114,118,101, 14, 6, 1, 1, 1, 1, 21, 41, 4, 32, 35,110,
+ 101, 97,114, 17, 6, 1, 1, 1, 1, 27, 40, 26, 98, 17,109,111,114,110,105,
+ 110,103, 13, 6, 1, 9, 1, 1, 21, 40, 68, 32,100,111,116,104, 15, 6, 1,
+ 1, 1, 1, 23, 39, 31, 90, 27,116,114,117,116,104, 16, 6, 1, 1, 1, 1,
+ 25, 38, 35, 34, 22, 99,117, 98,105,116,115, 16, 6, 1, 1, 1, 1, 25, 37,
+ 48, 93, 7,116,101,109,112,108,101, 14, 6, 1, 1, 1, 1, 21, 35, 14, 48,
+ 27,100,105,101,100, 14, 6, 1, 1, 1, 1, 21, 34, 29, 62, 27,115,101,110,
+ 100, 15, 6, 1, 1, 1, 1, 23, 32, 3, 24, 26,115,101,114,118,101, 17, 6,
+ 1, 1, 1, 1, 27, 29, 17, 74, 36, 98,101,116,119,101,101,110, 18, 6, 1,
+ 1, 1, 1, 29, 28, 46, 88, 22,100,101,112, 97,114,116,101,100, 10, 0, 0,
+ 0, 32, 0, 95, 0, 1,247, 1,238, 1,229, 1,220, 1,211, 1,199, 1,187,
+ 1,176, 1,164, 1,148, 1,133, 1,116, 1, 99, 1, 86, 1, 67, 1, 55, 1,
+ 43, 1, 31, 1, 18, 1, 5, 0,249, 0,236, 0,224, 0,209, 0,191, 0,174,
+ 0,157, 0,145, 0,132, 0,120, 0,108, 0, 95, 0, 83, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 12, 1, 1, 0, 1, 49, 51, 38, 15, 12, 7, 1,
+ 1, 1, 1, 0, 1, 48, 37, 93, 7, 30, 11, 7, 1, 1, 1, 0, 0, 1, 47,
+ 22, 16, 24, 11, 7, 1, 0, 1, 1, 0, 1, 47, 16, 40, 12, 12, 7, 1, 1,
+ 1, 1, 0, 1, 46, 28, 88, 22, 2, 11, 7, 1, 1, 0, 1, 0, 1, 44, 48,
+ 9, 19, 16, 7, 1, 1, 1, 0, 23, 1, 42, 20, 18, 98,101,103, 97,116, 22,
+ 16, 7, 1, 1, 0, 1, 23, 1, 37, 17, 18,100,119,101,108,116, 16, 17, 7,
+ 1, 1, 0, 1, 25, 1, 35, 38, 22, 99,117, 98,105,116,115, 17, 14, 7, 1,
+ 1, 1, 0, 19, 1, 34, 26, 15, 97,114,107, 21, 11, 7, 1, 1, 1, 0, 0,
+ 1, 32, 16, 7, 23, 12, 7, 1, 1, 1, 1, 0, 1, 28, 17, 67, 31, 29, 11,
+ 7, 1, 0, 1, 1, 0, 1, 25, 7, 19, 11, 12, 7, 1, 1, 1, 1, 0, 1,
+ 22, 45, 71, 28, 28, 12, 7, 1, 1, 1, 1, 0, 1, 21, 22, 92, 18, 4, 11,
+ 7, 1, 1, 0, 1, 0, 1, 21, 22, 18, 18, 11, 7, 1, 1, 1, 1, 0, 9,
+ 17, 29, 74, 36, 11, 7, 1, 1, 1, 0, 0, 1, 17, 29, 74, 25, 18, 7, 1,
+ 1, 1, 1, 25, 1, 15, 6, 3, 11,116,101,109,112,108,101, 5, 12, 7, 1,
+ 1, 1, 1, 0, 1, 12, 4, 38, 36, 27, 16, 7, 1, 0, 1, 1, 23, 1, 10,
+ 89, 14,115,101,114,118,101, 14, 16, 7, 1, 1, 1, 1, 21, 1, 4, 41, 32,
+ 35,110,101, 97,114, 3, 14, 7, 9, 0, 1, 1, 21, 1, 68, 32,100,111,116,
+ 104, 13, 15, 7, 0, 1, 1, 1, 21, 1, 21, 91, 38,110,101, 97,114, 6, 11,
+ 7, 0, 1, 1, 1, 0, 1, 16, 81, 25, 9, 10, 7, 0, 1, 1, 8, 0, 1,
+ 16, 7, 10, 11, 7, 0, 1, 1, 1, 0, 1, 7, 72, 31, 8, 11, 7, 0, 1,
+ 1, 1, 0, 1, 6, 37, 31, 7, 8, 7, 0, 0, 0, 0, 0, 1, 35, 8, 7,
+ 0, 0, 0, 0, 0, 1, 34, 8, 7, 0, 0, 0, 0, 0, 1, 33, 8, 7, 0,
+ 0, 0, 0, 0, 1, 32, 8, 7, 0, 0, 0, 0, 0, 1, 31, 10, 0, 0, 0,
+ 2, 1,231, 0, 1,244, 1,231, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 12, 7, 1, 1, 1, 1, 0, 1, 49, 9, 51,
+ 38, 26, 11, 7, 1, 1, 0, 1, 0, 1, 49, 9, 38, 20, 13, 0, 0, 0, 23,
+ 0, 67, 0, 1,238, 1,220, 1,202, 1,186, 1,168, 1,148, 1,130, 1,107,
+ 1, 86, 1, 65, 1, 44, 1, 27, 1, 14, 0,250, 0,224, 0,205, 0,184, 0,
+ 165, 0,145, 0,123, 0,106, 0, 86, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 17, 23, 6, 0, 23, 1, 1, 21,107,110,111,119,110, 52,
+ 19,112,111,111,114, 18, 22, 6, 0, 23, 1, 1, 23, 97, 98,111,118,101, 24,
+ 26,115,101,114,118,101, 15, 21, 6, 0, 19, 1, 1, 21,119, 97,114, 52, 19,
+ 112,111,111,114, 20, 20, 6, 0, 27, 1, 8, 25,110,111,116,104,105,110,103,
+ 7,112,108, 97, 99,101,115, 18, 19, 6, 0, 23, 1, 1, 23, 98,101,103, 97,
+ 116, 90, 27,116,114,117,116,104, 17, 18, 6, 0, 23, 1, 1, 21,100,119,101,
+ 108,116, 21, 39,100,111,116,104, 19, 17, 6, 0, 27, 1, 1, 21,109,111,114,
+ 110,105,110,103, 52, 19,112,111,111,114, 17, 16, 6, 0, 21, 1, 1, 23,115,
+ 104,101,119, 90, 27,116,114,117,116,104, 24, 15, 6, 0, 27, 1, 1, 31,116,
+ 104,101,114,101,105,110, 37, 31,115, 97, 99,114,105,102,105, 99,101, 18, 14,
+ 6, 0, 23, 1, 8, 25,115,109,111,116,101, 7,112,108, 97, 99,101,115, 11,
+ 13, 6, 0, 19, 1, 1, 0, 97,114,107, 72, 31, 15, 12, 6, 0, 21, 1, 8,
+ 21,119,105,110,101, 58,119, 97,121,115, 19, 11, 6, 0, 21, 1, 1, 27,115,
+ 111,109,101, 98, 17,109,111,114,110,105,110,103, 19, 10, 6, 0, 27, 1, 1,
+ 21, 98,101,116,119,101,101,110, 92, 18,115,111,109,101, 19, 9, 6, 0, 21,
+ 1, 1, 27,115, 97,118,101, 74, 36, 98,101,116,119,101,101,110, 21, 8, 6,
+ 0, 25, 1, 1, 27,116,104,111,117,103,104, 98, 17,109,111,114,110,105,110,
+ 103, 16, 7, 6, 0, 21, 1, 1, 21,115,101,110,100, 49, 34,115,101,110,100,
+ 18, 6, 6, 0, 25, 1, 1, 21,119,105,115,100,111,109, 38, 36,115,101,110,
+ 100, 16, 5, 6, 0, 23, 1, 9, 21, 97,110,103,101,114, 46,119, 97,121,115,
+ 14, 4, 6, 0, 19, 1, 1, 19, 99, 97,110, 19, 43,119, 97,114, 16, 3, 6,
+ 0, 23, 1, 1, 19,111,102,102,101,114, 48, 22,115,105,120, 16, 2, 6, 0,
+ 23, 1, 8, 21,119,111,114,107,115, 58,119, 97,121,115, 16, 1, 6, 0, 23,
+ 1, 1, 19,116,114,117,116,104, 37, 11, 99, 97,110, 13, 0, 0, 0, 22, 0,
+ 64, 0, 1,230, 1,213, 1,191, 1,169, 1,148, 1,130, 1,108, 1, 89, 1,
+ 70, 1, 51, 1, 34, 1, 16, 0,253, 0,233, 0,214, 0,194, 0,174, 0,151,
+ 0,132, 0,109, 0, 90, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 24, 45, 6, 0, 35, 1, 1, 23,105,110,104, 97, 98,105,116, 97,110,116,
+ 115, 23, 41, 98,101,103, 97,116, 17, 44, 6, 0, 23, 1, 1, 21, 97,110,103,
+ 101,108, 48, 27,100,105,101,100, 21, 43, 6, 0, 25, 1, 1, 27,116,101,109,
+ 112,108,101, 74, 36, 98,101,116,119,101,101,110, 17, 42, 6, 0, 23, 1, 1,
+ 21, 99,104,105,108,100, 81, 25,119, 97,108,107, 21, 41, 6, 0, 21, 1, 1,
+ 31,119, 97,121,115, 37, 31,115, 97, 99,114,105,102,105, 99,101, 18, 40, 6,
+ 0, 21, 1, 1, 25,112,111,111,114, 93, 7,116,101,109,112,108,101, 18, 39,
+ 6, 0, 21, 1, 1, 25,100,111,116,104, 3, 11,116,101,109,112,108,101, 17,
+ 38, 6, 0, 23, 1, 1, 21,102,114,117,105,116, 62, 27,115,101,110,100, 18,
+ 37, 6, 0, 23, 1, 1, 23,115,101,114,118,101, 90, 27,116,114,117,116,104,
+ 17, 36, 6, 0, 21, 1, 1, 23,110,101, 97,114, 90, 27,116,114,117,116,104,
+ 16, 35, 6, 0, 21, 1, 1, 21,108,111,110,103, 14, 39,115, 97,118,101, 15,
+ 34, 6, 0, 21, 1, 1, 19,119, 97,108,107, 15, 20, 97,114,107, 17, 33, 6,
+ 0, 25, 1, 9, 21, 99,117, 98,105,116,115, 46,119, 97,121,115, 17, 32, 6,
+ 0, 21, 1, 1, 23,103,111,110,101, 23, 41, 98,101,103, 97,116, 17, 31, 6,
+ 0, 23, 1, 1, 21,119,104,105,108,101, 49, 34,115,101,110,100, 20, 30, 6,
+ 0, 21, 1, 1, 29,112, 97,114,116, 88, 22,100,101,112, 97,114,116,101,100,
+ 16, 29, 6, 0, 21, 1, 1, 21, 98,101, 97,114, 92, 18,115,111,109,101, 19,
+ 28, 6, 0, 25, 1, 1, 23,112,108, 97, 99,101,115, 23, 41, 98,101,103, 97,
+ 116, 20, 27, 6, 0, 27, 1, 1, 23,116,104,121,115,101,108,102, 54, 12, 97,
+ 98,111,118,101, 20, 26, 6, 0, 29, 1, 1, 21,100,101,112, 97,114,116,101,
+ 100, 92, 18,115,111,109,101, 15, 25, 6, 0, 21, 1, 1, 19,116,101,108,108,
+ 19, 43,119, 97,114, 24, 24, 6, 0, 31, 1, 1, 27,115, 97, 99,114,105,102,
+ 105, 99,101, 92, 13,109,111,114,110,105,110,103, 13, 0, 0, 0, 5, 1,162,
+ 0, 1,239, 1,221, 1,203, 1,182, 1,162, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 50, 6, 0, 23, 1, 1,
+ 23,119,114, 97,116,104, 21, 45, 98,101,103, 97,116, 19, 49, 6, 0, 21, 1,
+ 1, 27,116,114,101,101, 98, 17,109,111,114,110,105,110,103, 16, 48, 6, 0,
+ 19, 1, 1, 23,115,105,120, 71, 3, 97,110,103,101,108, 16, 47, 6, 0, 21,
+ 1, 1, 21,100,105,101,100, 7, 19,103,111,110,101, 15, 46, 6, 0, 19, 1,
+ 1, 21,111,105,108, 81, 25,119, 97,108,107, 10, 0, 0, 0, 40, 0,106, 0,
+ 1,246, 1,236, 1,226, 1,218, 1,209, 1,199, 1,187, 1,179, 1,169, 1,
+ 158, 1,145, 1,136, 1,127, 1,117, 1,107, 1, 98, 1, 82, 1, 72, 1, 63,
+ 1, 51, 1, 42, 1, 30, 1, 20, 1, 12, 1, 3, 0,248, 0,239, 0,225, 0,
+ 216, 0,207, 0,197, 0,188, 0,180, 0,170, 0,161, 0,152, 0,141, 0,129,
+ 0,118, 0,106, 0, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,116,114,
+ 101,101, 49, 11, 3, 27, 1,116,104,121,115,101,108,102, 27, 10, 3, 25, 1,
+ 116,104,111,117,103,104, 8, 11, 3, 27, 1,116,104,101,114,101,105,110, 15,
+ 10, 3, 25, 1,116,101,109,112,108,101, 43, 8, 3, 21, 1,116,101,108,108,
+ 25, 8, 3, 21, 1,115,111,109,101, 11, 9, 3, 23, 1,115,109,111,116,101,
+ 14, 7, 3, 19, 1,115,105,120, 48, 8, 3, 21, 1,115,104,101,119, 16, 9,
+ 3, 23, 1,115,101,114,118,101, 37, 8, 3, 21, 1,115,101,110,100, 7, 8,
+ 3, 21, 1,115, 97,118,101, 9, 13, 3, 31, 1,115, 97, 99,114,105,102,105,
+ 99,101, 24, 8, 3, 21, 1,112,111,111,114, 40, 10, 3, 25, 1,112,108, 97,
+ 99,101,115, 28, 8, 3, 21, 1,112, 97,114,116, 30, 7, 3, 19, 1,111,105,
+ 108, 46, 9, 3, 23, 1,111,102,102,101,114, 3, 11, 3, 27, 1,110,111,116,
+ 104,105,110,103, 20, 8, 3, 21, 1,110,101, 97,114, 36, 11, 3, 27, 1,109,
+ 111,114,110,105,110,103, 17, 8, 3, 21, 1,108,111,110,103, 35, 9, 3, 23,
+ 1,107,110,111,119,110, 23, 15, 3, 35, 1,105,110,104, 97, 98,105,116, 97,
+ 110,116,115, 45, 8, 3, 21, 1,103,111,110,101, 32, 9, 3, 23, 1,102,114,
+ 117,105,116, 38, 9, 3, 23, 1,100,119,101,108,116, 18, 8, 3, 21, 1,100,
+ 111,116,104, 39, 8, 3, 21, 1,100,105,101,100, 47, 12, 3, 29, 1,100,101,
+ 112, 97,114,116,101,100, 26, 10, 3, 25, 1, 99,117, 98,105,116,115, 33, 9,
+ 3, 23, 1, 99,104,105,108,100, 42, 7, 3, 19, 1, 99, 97,110, 4, 11, 3,
+ 27, 1, 98,101,116,119,101,101,110, 10, 9, 3, 23, 1, 98,101,103, 97,116,
+ 19, 8, 3, 21, 1, 98,101, 97,114, 29, 7, 3, 19, 1, 97,114,107, 13, 9,
+ 3, 23, 1, 97,110,103,101,114, 5, 9, 3, 23, 1, 97,110,103,101,108, 44,
+ 9, 3, 23, 1, 97, 98,111,118,101, 22, 10, 0, 0, 0, 9, 1,171, 0, 1,
+ 247, 1,238, 1,230, 1,221, 1,211, 1,202, 1,191, 1,181, 1,171, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 9, 3, 23, 1,119,114, 97,116,104, 50, 9, 3, 23, 1,119,111,114,107,115,
+ 2, 10, 3, 25, 1,119,105,115,100,111,109, 6, 8, 3, 21, 1,119,105,110,
+ 101, 12, 9, 3, 23, 1,119,104,105,108,101, 31, 8, 3, 21, 1,119, 97,121,
+ 115, 41, 7, 3, 19, 1,119, 97,114, 21, 8, 3, 21, 1,119, 97,108,107, 34,
+ 8, 3, 23, 9,116,114,117,116,104, 13, 0, 0, 0, 5, 0, 84, 0, 1, 78,
+ 0,249, 0,177, 1,163, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 19,
+ 7, 21, 19, 19, 8,129, 33,118,105,101,119,118, 50, 49,118, 50, 49, 67, 82,
+ 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 50, 49, 40, 97, 44, 98, 44, 99,
+ 44,100, 44,101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98,
+ 44, 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 50, 32, 79, 82, 68, 69,
+ 82, 32, 66, 89, 32, 98, 32, 76, 73, 77, 73, 84, 32, 49, 48, 70, 17, 6, 21,
+ 19, 19, 8,121,118,105,101,119,118, 53, 48,118, 53, 48, 67, 82, 69, 65, 84,
+ 69, 32, 86, 73, 69, 87, 32,118, 53, 48, 40, 97, 44, 98, 41, 32, 65, 83, 32,
+ 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 32, 70, 82, 79, 77, 32,116, 53, 32,
+ 87, 72, 69, 82, 69, 32, 97, 60, 62, 50, 53, 83, 16, 7, 21, 19, 19, 8,129,
+ 17,118,105,101,119,118, 52, 48,118, 52, 48, 67, 82, 69, 65, 84, 69, 32, 86,
+ 73, 69, 87, 32,118, 52, 48, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32,
+ 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101,
+ 32, 70, 82, 79, 77, 32,116, 52, 32, 87, 72, 69, 82, 69, 32, 97, 60, 62, 50,
+ 53, 83, 15, 7, 21, 19, 19, 8,129, 17,118,105,101,119,118, 51, 48,118, 51,
+ 48, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 51, 48, 40, 97, 44,
+ 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32,
+ 97, 44, 98, 44, 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 51, 32, 87,
+ 72, 69, 82, 69, 32, 97, 60, 62, 50, 53, 91, 18, 7, 21, 19, 19, 8,129, 33,
+ 118,105,101,119,118, 49, 49,118, 49, 49, 67, 82, 69, 65, 84, 69, 32, 86, 73,
+ 69, 87, 32,118, 49, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65,
+ 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101, 32,
+ 70, 82, 79, 77, 32,116, 49, 32, 79, 82, 68, 69, 82, 32, 66, 89, 32, 98, 32,
+ 76, 73, 77, 73, 84, 32, 49, 48, 13, 1,163, 0, 4, 0, 40, 0, 1, 70, 0,
+ 233, 0,152, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,110, 23, 7, 21, 19, 19, 8,129, 71,
+ 118,105,101,119,118, 49, 50,118, 49, 50, 67, 82, 69, 65, 84, 69, 32, 86, 73,
+ 69, 87, 32,118, 49, 50, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65,
+ 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,115,117,109, 40, 97, 41, 44, 32,
+ 97,118,103, 40, 98, 41, 44, 32, 99,111,117,110,116, 40, 42, 41, 44, 32,109,
+ 105,110, 40,100, 41, 44, 32,101, 32, 70, 82, 79, 77, 32,116, 49, 32, 71, 82,
+ 79, 85, 80, 32, 66, 89, 32, 53, 79, 22, 7, 21, 19, 19, 8,129, 9,118,105,
+ 101,119,118, 53, 49,118, 53, 49, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87,
+ 32,118, 53, 49, 40, 97, 44, 98, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84,
+ 32, 97, 44, 98, 32, 70, 82, 79, 77, 32,116, 53, 32, 79, 82, 68, 69, 82, 32,
+ 66, 89, 32, 98, 32, 76, 73, 77, 73, 84, 32, 49, 48, 91, 21, 7, 21, 19, 19,
+ 8,129, 33,118,105,101,119,118, 52, 49,118, 52, 49, 67, 82, 69, 65, 84, 69,
+ 32, 86, 73, 69, 87, 32,118, 52, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101,
+ 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100,
+ 44,101, 32, 70, 82, 79, 77, 32,116, 52, 32, 79, 82, 68, 69, 82, 32, 66, 89,
+ 32, 98, 32, 76, 73, 77, 73, 84, 32, 49, 48, 91, 20, 7, 21, 19, 19, 8,129,
+ 33,118,105,101,119,118, 51, 49,118, 51, 49, 67, 82, 69, 65, 84, 69, 32, 86,
+ 73, 69, 87, 32,118, 51, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32,
+ 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101,
+ 32, 70, 82, 79, 77, 32,116, 51, 32, 79, 82, 68, 69, 82, 32, 66, 89, 32, 98,
+ 32, 76, 73, 77, 73, 84, 32, 49, 48, 0, 0, 0, 93, 19, 19, 8,129, 33,118,
+ 105,101,119,118, 50, 49,118, 50, 49, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69,
+ 87, 32,118, 50, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83,
+ 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101, 32, 70,
+ 82, 79, 77, 32,116, 50, 32, 79, 82, 68, 69, 82, 32, 66, 89, 32, 98, 32, 76,
+ 73, 77, 73, 84, 32, 49, 48, 13, 0, 0, 0, 3, 0, 66, 0, 1,107, 0,214,
+ 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,129, 17, 26,
+ 7, 21, 19, 19, 8,130, 13,118,105,101,119,118, 52, 50,118, 52, 50, 67, 82,
+ 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 52, 50, 40, 97, 44, 98, 44, 99,
+ 44,100, 44,101, 41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,115,
+ 117,109, 40, 97, 41, 44, 32, 97,118,103, 40, 98, 41, 44, 32, 99,111,117,110,
+ 116, 40, 42, 41, 44, 32,109,105,110, 40,100, 41, 44, 32,101, 32, 70, 82, 79,
+ 77, 32,116, 52, 32, 71, 82, 79, 85, 80, 32, 66, 89, 32, 53, 10, 32, 32, 32,
+ 32, 72, 65, 86, 73, 78, 71, 32,109,105,110, 40,100, 41, 60, 51, 48, 32, 79,
+ 82, 68, 69, 82, 32, 66, 89, 32, 51, 44, 32, 49,129, 18, 25, 7, 21, 19, 19,
+ 8,130, 15,118,105,101,119,118, 51, 50,118, 51, 50, 67, 82, 69, 65, 84, 69,
+ 32, 86, 73, 69, 87, 32,118, 51, 50, 40, 97, 44, 98, 44, 99, 44,100, 44,101,
+ 41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,115,117,109, 40, 97,
+ 41, 44, 32, 97,118,103, 40, 98, 41, 44, 32, 99,111,117,110,116, 40, 42, 41,
+ 44, 32,109,105,110, 40,100, 41, 44, 32,101, 32, 70, 82, 79, 77, 32,116, 51,
+ 32, 71, 82, 79, 85, 80, 32, 66, 89, 32, 53, 10, 32, 32, 32, 32, 72, 65, 86,
+ 73, 78, 71, 32, 99,111,117,110,116, 40, 42, 41, 62, 49, 32, 79, 82, 68, 69,
+ 82, 32, 66, 89, 32, 51, 44, 32, 49,129, 18, 24, 7, 21, 19, 19, 8,130, 15,
+ 118,105,101,119,118, 50, 50,118, 50, 50, 67, 82, 69, 65, 84, 69, 32, 86, 73,
+ 69, 87, 32,118, 50, 50, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65,
+ 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,115,117,109, 40, 97, 41, 44, 32,
+ 97,118,103, 40, 98, 41, 44, 32, 99,111,117,110,116, 40, 42, 41, 44, 32,109,
+ 105,110, 40,100, 41, 44, 32,101, 32, 70, 82, 79, 77, 32,116, 50, 32, 71, 82,
+ 79, 85, 80, 32, 66, 89, 32, 53, 10, 32, 32, 32, 32, 72, 65, 86, 73, 78, 71,
+ 32, 99,111,117,110,116, 40, 42, 41, 62, 49, 32, 79, 82, 68, 69, 82, 32, 66,
+ 89, 32, 51, 44, 32, 49, 13, 1,108, 0, 3, 0, 83, 0, 0,225, 0, 83, 1,
+ 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,129, 11, 28, 7, 21, 19,
+ 19, 8,130, 1,118,105,101,119,118, 49, 51,118, 49, 51, 67, 82, 69, 65, 84,
+ 69, 32, 86, 73, 69, 87, 32,118, 49, 51, 40, 97, 44, 98, 44, 99, 44,100, 44,
+ 101, 41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44,
+ 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 49, 10, 32, 32, 85, 78, 73,
+ 79, 78, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101,
+ 32, 70, 82, 79, 77, 32,116, 50, 10, 32, 32, 85, 78, 73, 79, 78, 32, 83, 69,
+ 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101, 32, 70, 82, 79, 77,
+ 32,116, 51,129, 8, 27, 7, 21, 19, 19, 8,129,123,118,105,101,119,118, 53,
+ 50,118, 53, 50, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 53, 50,
+ 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 10, 32, 32, 83, 69,
+ 76, 69, 67, 84, 32, 99,111,117,110,116, 40, 42, 41, 44, 32,109,105,110, 40,
+ 98, 41, 44, 32,115,117, 98,115,116,114, 40, 98, 44, 49, 44, 49, 41, 44, 32,
+ 109,105,110, 40, 97, 41, 44, 32,109, 97,120, 40, 97, 41, 32, 70, 82, 79, 77,
+ 32,116, 53, 10, 32, 32, 32, 71, 82, 79, 85, 80, 32, 66, 89, 32, 51, 32, 79,
+ 82, 68, 69, 82, 32, 66, 89, 32, 49, 0, 0, 0, 28, 21, 19, 19, 8,130, 13,
+ 118,105,101,119,118, 52, 50,118, 52, 50, 67, 82, 69, 65, 84, 69, 32, 86,118,
+ 29, 7, 21, 19, 19, 8,129, 87,118,105,101,119,118, 50, 51,118, 50, 51, 67,
+ 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 50, 51, 40, 97, 44, 98, 44,
+ 99, 44,100, 44,101, 41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,
+ 97, 44, 98, 44, 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 49, 10, 32,
+ 32, 69, 88, 67, 69, 80, 84, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44,
+ 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 49, 32, 87, 72, 69, 82, 69,
+ 32, 98, 60, 50, 53, 13, 0, 0, 0, 3, 0, 40, 0, 1,134, 1, 12, 0, 40,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,129, 97, 32, 7, 21, 19, 19, 8,131, 45,118,105,
+ 101,119,118, 54, 50,118, 54, 50, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87,
+ 32,118, 54, 50, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 10,
+ 32, 32, 83, 69, 76, 69, 67, 84, 32,116, 49, 46, 97, 44,116, 50, 46, 98, 44,
+ 116, 51, 46, 99, 44,116, 52, 46,100, 44,116, 53, 46, 98, 10, 32, 32, 32, 32,
+ 70, 82, 79, 77, 32,116, 49, 32, 74, 79, 73, 78, 32,116, 50, 32, 79, 78, 32,
+ 40,116, 49, 46, 97, 61,116, 50, 46, 98, 41, 10, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 74, 79, 73, 78, 32,116, 51, 32, 79, 78, 32, 40,116, 49,
+ 46, 97, 61,116, 51, 46, 97, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 74, 79, 73, 78, 32,116, 52, 32, 79, 78, 32, 40,116, 52, 46, 98, 61,
+ 116, 51, 46, 98, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 76,
+ 69, 70, 84, 32, 74, 79, 73, 78, 32,116, 53, 32, 79, 78, 32, 40,116, 53, 46,
+ 97, 61,116, 49, 46, 99, 41,120, 31, 7, 21, 19, 19, 8,129, 91,118,105,101,
+ 119,118, 54, 49,118, 54, 49, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,
+ 118, 54, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 10, 32,
+ 32, 83, 69, 76, 69, 67, 84, 32,116, 50, 46, 97, 44,116, 51, 46, 98, 44,116,
+ 50, 46, 99, 44,116, 51, 46,100, 44,116, 50, 46,101, 10, 32, 32, 32, 32, 70,
+ 82, 79, 77, 32,116, 50, 32, 76, 69, 70, 84, 32, 74, 79, 73, 78, 32,116, 51,
+ 32, 79, 78, 32, 40,116, 50, 46, 97, 61,116, 51, 46, 97, 41,120, 30, 7, 21,
+ 19, 19, 8,129, 91,118,105,101,119,118, 54, 48,118, 54, 48, 67, 82, 69, 65,
+ 84, 69, 32, 86, 73, 69, 87, 32,118, 54, 48, 40, 97, 44, 98, 44, 99, 44,100,
+ 44,101, 41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,116, 49, 46,
+ 97, 44,116, 50, 46, 98, 44,116, 49, 46, 99, 44,116, 50, 46,100, 44,116, 49,
+ 46,101, 10, 32, 32, 32, 32, 70, 82, 79, 77, 32,116, 49, 32, 76, 69, 70, 84,
+ 32, 74, 79, 73, 78, 32,116, 50, 32, 79, 78, 32, 40,116, 49, 46, 97, 61,116,
+ 50, 46, 98, 41, 13, 0, 0, 0, 1, 1, 73, 0, 1, 73, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,129, 52, 33, 7, 21, 19, 19, 8,130,
+ 83,118,105,101,119,118, 55, 48,118, 55, 48, 67, 82, 69, 65, 84, 69, 32, 86,
+ 73, 69, 87, 32,118, 55, 48, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32,
+ 65, 83, 10, 32, 32, 87, 73, 84, 72, 32, 82, 69, 67, 85, 82, 83, 73, 86, 69,
+ 32, 99, 48, 40,120, 41, 32, 65, 83, 32, 40, 86, 65, 76, 85, 69, 83, 40, 49,
+ 41, 32, 85, 78, 73, 79, 78, 32, 65, 76, 76, 32, 83, 69, 76, 69, 67, 84, 32,
+ 120, 43, 49, 32, 70, 82, 79, 77, 32, 99, 48, 32, 87, 72, 69, 82, 69, 32,120,
+ 60, 57, 41, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,120, 44, 32, 98, 44, 32,
+ 99, 44, 32,100, 44, 32,101, 32, 70, 82, 79, 77, 32, 99, 48, 32, 74, 79, 73,
+ 78, 32,116, 49, 32, 79, 78, 32, 40,116, 49, 46, 97, 61, 53, 48, 45, 99, 48,
+ 46,120, 41,
+};
diff --git a/test/optfuzz-db01.txt b/test/optfuzz-db01.txt
new file mode 100644
index 0000000..d9eef93
--- /dev/null
+++ b/test/optfuzz-db01.txt
@@ -0,0 +1,142 @@
+-- Run this script through the sqlite3 command-line shell in order to generate
+-- a database file containing lots of data for testing purposes.
+--
+-- This script assumes that the "bin2c" program is available on ones $PATH.
+-- The "bin2c" program reads a binary file and outputs C-code that creates
+-- an array of bytes holding the content of that file.
+--
+-- This script is designed to create many tables and views all having
+-- 5 columns, "a" through "e", and with a variety of integers, short strings,
+-- and NULL values.
+--
+.open -new testdb01.db
+PRAGMA page_size=512;
+BEGIN;
+CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c INT, d INT, e INT);
+WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<50)
+INSERT INTO t1(a,b,c,d,e) SELECT x,abs(random()%51),
+ abs(random()%100), abs(random()%51), abs(random()%100) FROM c;
+CREATE TABLE t2(a INT, b INT, c INT,d INT,e INT,PRIMARY KEY(b,a))WITHOUT ROWID;
+INSERT INTO t2 SELECT * FROM t1;
+CREATE TABLE t3(a,b,c,d,e);
+INSERT INTO t3 SELECT a,b,c,d,e FROM t1 ORDER BY random() LIMIT 5;
+INSERT INTO t3 SELECT null,b,c,d,e FROM t1 ORDER BY random() LIMIT 5;
+INSERT INTO t3 SELECT a,null,c,d,e FROM t1 ORDER BY random() LIMIT 5;
+INSERT INTO t3 SELECT a,b,null,d,e FROM t1 ORDER BY random() LIMIT 5;
+INSERT INTO t3 SELECT a,b,c,null,e FROM t1 ORDER BY random() LIMIT 5;
+INSERT INTO t3 SELECT a,b,c,d,null FROM t1 ORDER BY random() LIMIT 5;
+INSERT INTO t3 SELECT null,null,null,null,null FROM t1 LIMIT 5;
+CREATE INDEX t3x1 ON t3(a,b,c,d,e);
+CREATE TABLE t4(a INT UNIQUE NOT NULL, b INT UNIQUE NOT NULL,c,d,e);
+INSERT OR IGNORE INTO t4 SELECT a,b,c,d,e FROM t3;
+CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT UNIQUE,c,d,e);
+INSERT INTO t5(b) VALUES
+ ('truth'),
+ ('works'),
+ ('offer'),
+ ('can'),
+ ('anger'),
+ ('wisdom'),
+ ('send'),
+ ('though'),
+ ('save'),
+ ('between'),
+ ('some'),
+ ('wine'),
+ ('ark'),
+ ('smote'),
+ ('therein'),
+ ('shew'),
+ ('morning'),
+ ('dwelt'),
+ ('begat'),
+ ('nothing'),
+ ('war'),
+ ('above'),
+ ('known'),
+ ('sacrifice'),
+ ('tell'),
+ ('departed'),
+ ('thyself'),
+ ('places'),
+ ('bear'),
+ ('part'),
+ ('while'),
+ ('gone'),
+ ('cubits'),
+ ('walk'),
+ ('long'),
+ ('near'),
+ ('serve'),
+ ('fruit'),
+ ('doth'),
+ ('poor'),
+ ('ways'),
+ ('child'),
+ ('temple'),
+ ('angel'),
+ ('inhabitants'),
+ ('oil'),
+ ('died'),
+ ('six'),
+ ('tree'),
+ ('wrath');
+UPDATE t1 SET e=(SELECT b FROM t5 WHERE t5.a=(t1.e%51));
+UPDATE t5 SET (c,d,e) =
+ (SELECT c,d,e FROM t1 WHERE t1.a=abs(t5.a+random()/100)%50+1);
+UPDATE t2 SET e=(SELECT b FROM t5 WHERE t5.a=(t2.e%51));
+UPDATE t3 SET e=(SELECT b FROM t5 WHERE t5.a=t3.e);
+CREATE INDEX t1e ON t1(e);
+CREATE INDEX t2ed ON t2(e,d);
+CREATE VIEW v00(a,b,c,d,e) AS SELECT 1,1,1,1,'one';
+CREATE VIEW v10(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t1 WHERE a<>25;
+CREATE VIEW v20(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t2 WHERE a<>25;
+CREATE VIEW v30(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t3 WHERE a<>25;
+CREATE VIEW v40(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t4 WHERE a<>25;
+CREATE VIEW v50(a,b) AS SELECT a,b FROM t5 WHERE a<>25;
+CREATE VIEW v11(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t1 ORDER BY b LIMIT 10;
+CREATE VIEW v21(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t2 ORDER BY b LIMIT 10;
+CREATE VIEW v31(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t3 ORDER BY b LIMIT 10;
+CREATE VIEW v41(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t4 ORDER BY b LIMIT 10;
+CREATE VIEW v51(a,b) AS SELECT a,b FROM t5 ORDER BY b LIMIT 10;
+CREATE VIEW v12(a,b,c,d,e) AS
+ SELECT sum(a), avg(b), count(*), min(d), e FROM t1 GROUP BY 5;
+CREATE VIEW v22(a,b,c,d,e) AS
+ SELECT sum(a), avg(b), count(*), min(d), e FROM t2 GROUP BY 5
+ HAVING count(*)>1 ORDER BY 3, 1;
+CREATE VIEW v32(a,b,c,d,e) AS
+ SELECT sum(a), avg(b), count(*), min(d), e FROM t3 GROUP BY 5
+ HAVING count(*)>1 ORDER BY 3, 1;
+CREATE VIEW v42(a,b,c,d,e) AS
+ SELECT sum(a), avg(b), count(*), min(d), e FROM t4 GROUP BY 5
+ HAVING min(d)<30 ORDER BY 3, 1;
+CREATE VIEW v52(a,b,c,d,e) AS
+ SELECT count(*), min(b), substr(b,1,1), min(a), max(a) FROM t5
+ GROUP BY 3 ORDER BY 1;
+
+CREATE VIEW v13(a,b,c,d,e) AS
+ SELECT a,b,c,d,e FROM t1
+ UNION SELECT a,b,c,d,e FROM t2
+ UNION SELECT a,b,c,d,e FROM t3;
+CREATE VIEW v23(a,b,c,d,e) AS
+ SELECT a,b,c,d,e FROM t1
+ EXCEPT SELECT a,b,c,d,e FROM t1 WHERE b<25;
+
+CREATE VIEW v60(a,b,c,d,e) AS
+ SELECT t1.a,t2.b,t1.c,t2.d,t1.e
+ FROM t1 LEFT JOIN t2 ON (t1.a=t2.b);
+CREATE VIEW v61(a,b,c,d,e) AS
+ SELECT t2.a,t3.b,t2.c,t3.d,t2.e
+ FROM t2 LEFT JOIN t3 ON (t2.a=t3.a);
+CREATE VIEW v62(a,b,c,d,e) AS
+ SELECT t1.a,t2.b,t3.c,t4.d,t5.b
+ FROM t1 JOIN t2 ON (t1.a=t2.b)
+ JOIN t3 ON (t1.a=t3.a)
+ JOIN t4 ON (t4.b=t3.b)
+ LEFT JOIN t5 ON (t5.a=t1.c);
+CREATE VIEW v70(a,b,c,d,e) AS
+ WITH RECURSIVE c0(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c0 WHERE x<9)
+ SELECT x, b, c, d, e FROM c0 JOIN t1 ON (t1.a=50-c0.x);
+COMMIT;
+VACUUM;
+.shell bin2c testdb01.db
diff --git a/test/optfuzz.c b/test/optfuzz.c
new file mode 100644
index 0000000..2acb0ce
--- /dev/null
+++ b/test/optfuzz.c
@@ -0,0 +1,308 @@
+/*
+** 2018-03-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 program attempts to verify the correctness of the SQLite query
+** optimizer by fuzzing.
+**
+** The input is an SQL script, presumably generated by a fuzzer. The
+** argument is the name of the input. If no files are named, standard
+** input is read.
+**
+** The SQL script is run twice, once with optimization enabled, and again
+** with optimization disabled. If the output is not equivalent, an error
+** is printed and the program returns non-zero.
+*/
+
+/* Include the SQLite amalgamation, after making appropriate #defines.
+*/
+#define SQLITE_THREADSAFE 0
+#define SQLITE_OMIT_LOAD_EXTENSION 1
+#include "sqlite3.c"
+
+/* Content of the read-only test database */
+#include "optfuzz-db01.c"
+
+/*
+** Prepare a single SQL statement. Panic if anything goes wrong
+*/
+static sqlite3_stmt *prepare_sql(sqlite3 *db, const char *zFormat, ...){
+ char *zSql;
+ int rc;
+ sqlite3_stmt *pStmt = 0;
+ va_list ap;
+
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ if( rc ){
+ printf("Error: %s\nSQL: %s\n",
+ sqlite3_errmsg(db), zSql);
+ exit(1);
+ }
+ sqlite3_free(zSql);
+ return pStmt;
+}
+
+/*
+** Run SQL. Panic if anything goes wrong
+*/
+static void run_sql(sqlite3 *db, const char *zFormat, ...){
+ char *zSql;
+ int rc;
+ char *zErr = 0;
+ va_list ap;
+
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
+ if( rc || zErr ){
+ printf("Error: %s\nsqlite3_errmsg: %s\nSQL: %s\n",
+ zErr, sqlite3_errmsg(db), zSql);
+ exit(1);
+ }
+ sqlite3_free(zSql);
+}
+
+/*
+** Run one or more SQL statements contained in zSql against database dbRun.
+** Store the input in database dbOut.
+*/
+static int optfuzz_exec(
+ sqlite3 *dbRun, /* The database on which the SQL executes */
+ const char *zSql, /* The SQL to be executed */
+ sqlite3 *dbOut, /* Store results in this database */
+ const char *zOutTab, /* Store results in this table of dbOut */
+ int *pnStmt, /* Write the number of statements here */
+ int *pnRow, /* Write the number of rows here */
+ int bTrace /* Print query results if true */
+){
+ int rc = SQLITE_OK; /* Return code */
+ const char *zLeftover; /* Tail of unprocessed SQL */
+ sqlite3_stmt *pStmt = 0; /* The current SQL statement */
+ sqlite3_stmt *pIns = 0; /* Statement to insert into dbOut */
+ const char *zCol; /* Single column value */
+ int nCol; /* Number of output columns */
+ char zLine[4000]; /* Complete row value */
+
+ run_sql(dbOut, "BEGIN");
+ run_sql(dbOut, "CREATE TABLE IF NOT EXISTS staging(x TEXT)");
+ run_sql(dbOut, "CREATE TABLE IF NOT EXISTS \"%w\"(x TEXT)", zOutTab);
+ pIns = prepare_sql(dbOut, "INSERT INTO staging(x) VALUES(?1)");
+ *pnRow = *pnStmt = 0;
+ while( rc==SQLITE_OK && zSql && zSql[0] ){
+ zLeftover = 0;
+ rc = sqlite3_prepare_v2(dbRun, zSql, -1, &pStmt, &zLeftover);
+ zSql = zLeftover;
+ assert( rc==SQLITE_OK || pStmt==0 );
+ if( rc!=SQLITE_OK ){
+ printf("Error with [%s]\n%s\n", zSql, sqlite3_errmsg(dbRun));
+ break;
+ }
+ if( !pStmt ) continue;
+ (*pnStmt)++;
+ nCol = sqlite3_column_count(pStmt);
+ run_sql(dbOut, "DELETE FROM staging;");
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ int i, j;
+ for(i=j=0; i<nCol && j<sizeof(zLine)-50; i++){
+ int eType = sqlite3_column_type(pStmt, i);
+ if( eType==SQLITE_NULL ){
+ zCol = "NULL";
+ }else{
+ zCol = (const char*)sqlite3_column_text(pStmt, i);
+ }
+ if( i ) zLine[j++] = ',';
+ if( eType==SQLITE_TEXT ){
+ sqlite3_snprintf(sizeof(zLine)-j, zLine+j, "'%q'", zCol);
+ }else{
+ sqlite3_snprintf(sizeof(zLine)-j, zLine+j, "%s", zCol);
+ }
+ j += (int)strlen(zLine+j);
+ }
+ /* Detect if any row is too large and throw an error, because we will
+ ** want to go back and look more closely at that case */
+ if( j>=sizeof(zLine)-100 ){
+ printf("Excessively long output line: %d bytes\n" ,j);
+ exit(1);
+ }
+ if( bTrace ){
+ printf("%s\n", zLine);
+ }
+ (*pnRow)++;
+ sqlite3_bind_text(pIns, 1, zLine, j, SQLITE_TRANSIENT);
+ rc = sqlite3_step(pIns);
+ assert( rc==SQLITE_DONE );
+ rc = sqlite3_reset(pIns);
+ }
+ run_sql(dbOut,
+ "INSERT INTO \"%w\"(x) VALUES('### %q ###')",
+ zOutTab, sqlite3_sql(pStmt)
+ );
+ run_sql(dbOut,
+ "INSERT INTO \"%w\"(x) SELECT group_concat(x,char(10))"
+ " FROM (SELECT x FROM staging ORDER BY x)",
+ zOutTab
+ );
+ run_sql(dbOut, "COMMIT");
+ sqlite3_finalize(pStmt);
+ pStmt = 0;
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_finalize(pIns);
+ return rc;
+}
+
+/*
+** Read the content of file zName into memory obtained from sqlite3_malloc64()
+** and return a pointer to the buffer. The caller is responsible for freeing
+** the memory.
+**
+** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes
+** read.
+**
+** For convenience, a nul-terminator byte is always appended to the data read
+** from the file before the buffer is returned. This byte is not included in
+** the final value of (*pnByte), if applicable.
+**
+** NULL is returned if any error is encountered. The final value of *pnByte
+** is undefined in this case.
+*/
+static char *readFile(const char *zName, int *pnByte){
+ FILE *in = fopen(zName, "rb");
+ long nIn;
+ size_t nRead;
+ char *pBuf;
+ if( in==0 ) return 0;
+ fseek(in, 0, SEEK_END);
+ nIn = ftell(in);
+ rewind(in);
+ pBuf = sqlite3_malloc64( nIn+1 );
+ if( pBuf==0 ) return 0;
+ nRead = fread(pBuf, nIn, 1, in);
+ fclose(in);
+ if( nRead!=1 ){
+ sqlite3_free(pBuf);
+ return 0;
+ }
+ pBuf[nIn] = 0;
+ if( pnByte ) *pnByte = nIn;
+ return pBuf;
+}
+
+int main(int argc, char **argv){
+ int nIn = 0; /* Number of input files */
+ char **azIn = 0; /* Names of input files */
+ sqlite3 *dbOut = 0; /* Database to hold results */
+ sqlite3 *dbRun = 0; /* Database used for tests */
+ int bTrace = 0; /* Show query results */
+ int bShowValid = 0; /* Just list inputs that are valid SQL */
+ int nRow, nStmt; /* Number of rows and statements */
+ int i, rc;
+
+ for(i=1; i<argc; i++){
+ const char *z = argv[i];
+ if( z[0]=='-' && z[1]=='-' ) z++;
+ if( strcmp(z,"-help")==0 ){
+ printf("Usage: %s [OPTIONS] FILENAME ...\n", argv[0]);
+ printf("Options:\n");
+ printf(" --help Show his message\n");
+ printf(" --output-trace Show each line of SQL output\n");
+ printf(" --valid-sql List FILEs that are valid SQL\n");
+ return 0;
+ }
+ else if( strcmp(z,"-output-trace")==0 ){
+ bTrace = 1;
+ }
+ else if( strcmp(z,"-valid-sql")==0 ){
+ bShowValid = 1;
+ }
+ else if( z[0]=='-' ){
+ printf("unknown option \"%s\". Use --help for details\n", argv[i]);
+ return 1;
+ }
+ else {
+ nIn++;
+ azIn = realloc(azIn, sizeof(azIn[0])*nIn);
+ if( azIn==0 ){
+ printf("out of memory\n");
+ exit(1);
+ }
+ azIn[nIn-1] = argv[i];
+ }
+ }
+
+ sqlite3_open(":memory:", &dbOut);
+ sqlite3_open(":memory:", &dbRun);
+ sqlite3_deserialize(dbRun, "main", data001, sizeof(data001),
+ sizeof(data001), SQLITE_DESERIALIZE_READONLY);
+ for(i=0; i<nIn; i++){
+ char *zSql = readFile(azIn[i], 0);
+ sqlite3_stmt *pCk;
+ sqlite3_exec(dbRun, "ROLLBACK", 0, 0, 0);
+ if( bShowValid ){
+ rc = sqlite3_exec(dbRun, zSql, 0, 0, 0);
+ if( rc==SQLITE_OK ) printf("%s\n", azIn[i]);
+ sqlite3_free(zSql);
+ continue;
+ }
+ sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, dbRun, 0);
+ if( bTrace ) printf("%s: Optimized\n", azIn[i]);
+ rc = optfuzz_exec(dbRun, zSql, dbOut, "opt", &nStmt, &nRow, bTrace);
+ if( rc ){
+ printf("%s: optimized run failed: %s\n",
+ azIn[i], sqlite3_errmsg(dbRun));
+ }else{
+ sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, dbRun, 0xffff);
+ if( bTrace ) printf("%s: Non-optimized\n", azIn[i]);
+ rc = optfuzz_exec(dbRun, zSql, dbOut, "noopt", &nStmt, &nRow, bTrace);
+ if( rc ){
+ printf("%s: non-optimized run failed: %s\n",
+ azIn[i], sqlite3_errmsg(dbRun));
+ exit(1);
+ }
+ pCk = prepare_sql(dbOut,
+ "SELECT (SELECT group_concat(x,char(10)) FROM opt)=="
+ " (SELECT group_concat(x,char(10)) FROM noopt)");
+ rc = sqlite3_step(pCk);
+ if( rc!=SQLITE_ROW ){
+ printf("%s: comparison failed\n", sqlite3_errmsg(dbOut));
+ exit(1);
+ }
+ if( !sqlite3_column_int(pCk, 0) ){
+ printf("%s: opt/no-opt outputs differ\n", azIn[i]);
+ pCk = prepare_sql(dbOut,
+ "SELECT group_concat(x,char(10)) FROM opt "
+ "UNION ALL "
+ "SELECT group_concat(x,char(10)) FROM noopt");
+ sqlite3_step(pCk);
+ printf("opt:\n%s\n", sqlite3_column_text(pCk,0));
+ sqlite3_step(pCk);
+ printf("noopt:\n%s\n", sqlite3_column_text(pCk,0));
+ exit(1);
+ }else{
+ printf("%s: %d stmts %d rows ok\n", azIn[i], nStmt, nRow);
+ }
+ sqlite3_finalize(pCk);
+ }
+ sqlite3_free(zSql);
+ }
+ sqlite3_close(dbRun);
+ sqlite3_close(dbOut);
+ free(azIn);
+ if( sqlite3_memory_used() ){
+ printf("Memory leak of %lld bytes\n", sqlite3_memory_used());
+ exit(1);
+ }
+ return 0;
+}
diff --git a/test/orderby1.test b/test/orderby1.test
new file mode 100644
index 0000000..9b5df4c
--- /dev/null
+++ b/test/orderby1.test
@@ -0,0 +1,566 @@
+# 2012 Sept 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 the optimizations that disable
+# ORDER BY clauses when the natural order of a query is correct.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby1
+
+# Generate test data for a join. Verify that the join gets the
+# correct answer.
+#
+do_test 1.0 {
+ db eval {
+ BEGIN;
+ CREATE TABLE album(
+ aid INTEGER PRIMARY KEY,
+ title TEXT UNIQUE NOT NULL
+ );
+ CREATE TABLE track(
+ tid INTEGER PRIMARY KEY,
+ aid INTEGER NOT NULL REFERENCES album,
+ tn INTEGER NOT NULL,
+ name TEXT,
+ UNIQUE(aid, tn)
+ );
+ INSERT INTO album VALUES(1, '1-one'), (2, '2-two'), (3, '3-three');
+ INSERT INTO track VALUES
+ (NULL, 1, 1, 'one-a'),
+ (NULL, 2, 2, 'two-b'),
+ (NULL, 3, 3, 'three-c'),
+ (NULL, 1, 3, 'one-c'),
+ (NULL, 2, 1, 'two-a'),
+ (NULL, 3, 1, 'three-a');
+ COMMIT;
+ }
+} {}
+do_test 1.1a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
+ }
+} {one-a one-c two-a two-b three-a three-c}
+
+# Verify that the ORDER BY clause is optimized out
+#
+do_test 1.1b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
+ }
+} {~/ORDER BY/} ;# ORDER BY optimized out
+
+# The same query with ORDER BY clause optimization disabled via + operators
+# should give exactly the same answer.
+#
+do_test 1.2a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
+ }
+} {one-a one-c two-a two-b three-a three-c}
+
+# The output is sorted manually in this case.
+#
+do_test 1.2b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
+ }
+} {/ORDER BY/} ;# separate sorting pass due to "+" on ORDER BY terms
+
+# The same query with ORDER BY optimizations turned off via built-in test.
+#
+do_test 1.3a {
+ optimization_control db order-by-idx-join 0
+ db cache flush
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
+ }
+} {one-a one-c two-a two-b three-a three-c}
+do_test 1.3b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
+ }
+} {/ORDER BY/} ;# separate sorting pass due to disabled optimization
+optimization_control db all 1
+db cache flush
+
+# Reverse order sorts
+#
+do_test 1.4a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn
+ }
+} {three-a three-c two-a two-b one-a one-c}
+do_test 1.4b {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn
+ }
+} {three-a three-c two-a two-b one-a one-c} ;# verify same order after sorting
+do_test 1.4c {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn
+ }
+} {~/ORDER BY/} ;# ORDER BY suppressed due to uniqueness constraints
+
+do_test 1.5a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
+ }
+} {one-c one-a two-b two-a three-c three-a}
+do_test 1.5b {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC
+ }
+} {one-c one-a two-b two-a three-c three-a} ;# verify same order after sorting
+do_test 1.5c {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
+ }
+} {~/ORDER BY/} ;# ORDER BY suppressed due to uniqueness constraints
+
+do_test 1.6a {
+ db eval {
+ SELECT name FROM album CROSS JOIN track USING (aid)
+ ORDER BY title DESC, tn DESC
+ }
+} {three-c three-a two-b two-a one-c one-a}
+do_test 1.6b {
+ db eval {
+ SELECT name FROM album CROSS JOIN track USING (aid)
+ ORDER BY +title DESC, +tn DESC
+ }
+} {three-c three-a two-b two-a one-c one-a} ;# verify same order after sorting
+do_test 1.6c {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album CROSS JOIN track USING (aid)
+ ORDER BY title DESC, tn DESC
+ }
+} {~/ORDER BY/} ;# ORDER BY
+
+
+# Reconstruct the test data to use indices rather than integer primary keys.
+#
+do_test 2.0 {
+ db eval {
+ BEGIN;
+ DROP TABLE album;
+ DROP TABLE track;
+ CREATE TABLE album(
+ aid INT PRIMARY KEY,
+ title TEXT NOT NULL
+ );
+ CREATE INDEX album_i1 ON album(title, aid);
+ CREATE TABLE track(
+ aid INTEGER NOT NULL REFERENCES album,
+ tn INTEGER NOT NULL,
+ name TEXT,
+ UNIQUE(aid, tn)
+ );
+ INSERT INTO album VALUES(1, '1-one'), (20, '2-two'), (3, '3-three');
+ INSERT INTO track VALUES
+ (1, 1, 'one-a'),
+ (20, 2, 'two-b'),
+ (3, 3, 'three-c'),
+ (1, 3, 'one-c'),
+ (20, 1, 'two-a'),
+ (3, 1, 'three-a');
+ COMMIT;
+ }
+} {}
+do_test 2.1a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
+ }
+} {one-a one-c two-a two-b three-a three-c}
+
+# Verify that the ORDER BY clause is optimized out
+#
+do_test 2.1b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
+ }
+} {/ORDER BY/} ;# ORDER BY required because of missing aid term in ORDER BY
+
+do_test 2.1c {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, aid, tn
+ }
+} {one-a one-c two-a two-b three-a three-c}
+do_test 2.1d {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, aid, tn
+ }
+} {/ORDER BY/} ;# ORDER BY required in this case
+
+# The same query with ORDER BY clause optimization disabled via + operators
+# should give exactly the same answer.
+#
+do_test 2.2a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
+ }
+} {one-a one-c two-a two-b three-a three-c}
+
+# The output is sorted manually in this case.
+#
+do_test 2.2b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
+ }
+} {/ORDER BY/} ;# separate sorting pass due to "+" on ORDER BY terms
+
+# The same query with ORDER BY optimizations turned off via built-in test.
+#
+do_test 2.3a {
+ optimization_control db order-by-idx-join 0
+ db cache flush
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
+ }
+} {one-a one-c two-a two-b three-a three-c}
+do_test 2.3b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
+ }
+} {/ORDER BY/} ;# separate sorting pass due to disabled optimization
+optimization_control db all 1
+db cache flush
+
+# Reverse order sorts
+#
+do_test 2.4a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn
+ }
+} {three-a three-c two-a two-b one-a one-c}
+do_test 2.4b {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn
+ }
+} {three-a three-c two-a two-b one-a one-c} ;# verify same order after sorting
+do_test 2.4c {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn
+ }
+} {/ORDER BY/} ;# separate sorting pass due to mixed DESC/ASC
+
+
+do_test 2.5a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
+ }
+} {one-c one-a two-b two-a three-c three-a}
+do_test 2.5b {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC
+ }
+} {one-c one-a two-b two-a three-c three-a} ;# verify same order after sorting
+do_test 2.5c {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
+ }
+} {/ORDER BY/} ;# separate sorting pass due to mixed ASC/DESC
+
+do_test 2.6a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC
+ }
+} {three-c three-a two-b two-a one-c one-a}
+do_test 2.6b {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn DESC
+ }
+} {three-c three-a two-b two-a one-c one-a} ;# verify same order after sorting
+do_test 2.6c {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC
+ }
+} {/ORDER BY/} ;# ORDER BY required
+
+
+# Generate another test dataset, but this time using mixed ASC/DESC indices.
+#
+do_test 3.0 {
+ db eval {
+ BEGIN;
+ DROP TABLE album;
+ DROP TABLE track;
+ CREATE TABLE album(
+ aid INTEGER PRIMARY KEY,
+ title TEXT UNIQUE NOT NULL
+ );
+ CREATE TABLE track(
+ tid INTEGER PRIMARY KEY,
+ aid INTEGER NOT NULL REFERENCES album,
+ tn INTEGER NOT NULL,
+ name TEXT,
+ UNIQUE(aid ASC, tn DESC)
+ );
+ INSERT INTO album VALUES(1, '1-one'), (2, '2-two'), (3, '3-three');
+ INSERT INTO track VALUES
+ (NULL, 1, 1, 'one-a'),
+ (NULL, 2, 2, 'two-b'),
+ (NULL, 3, 3, 'three-c'),
+ (NULL, 1, 3, 'one-c'),
+ (NULL, 2, 1, 'two-a'),
+ (NULL, 3, 1, 'three-a');
+ COMMIT;
+ }
+} {}
+do_test 3.1a {
+ db eval {
+ SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC
+ }
+} {one-c one-a two-b two-a three-c three-a}
+
+# Verify that the ORDER BY clause is optimized out
+#
+do_test 3.1b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC
+ }
+} {~/ORDER BY/} ;# ORDER BY optimized out
+
+# The same query with ORDER BY clause optimization disabled via + operators
+# should give exactly the same answer.
+#
+do_test 3.2a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC
+ }
+} {one-c one-a two-b two-a three-c three-a}
+
+# The output is sorted manually in this case.
+#
+do_test 3.2b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC
+ }
+} {/ORDER BY/} ;# separate sorting pass due to "+" on ORDER BY terms
+
+# The same query with ORDER BY optimizations turned off via built-in test.
+#
+do_test 3.3a {
+ optimization_control db order-by-idx-join 0
+ db cache flush
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
+ }
+} {one-c one-a two-b two-a three-c three-a}
+do_test 3.3b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
+ }
+} {/ORDER BY/} ;# separate sorting pass due to disabled optimization
+optimization_control db all 1
+db cache flush
+
+# Without the mixed ASC/DESC on ORDER BY
+#
+do_test 3.4a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
+ }
+} {one-a one-c two-a two-b three-a three-c}
+do_test 3.4b {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
+ }
+} {one-a one-c two-a two-b three-a three-c} ;# verify same order after sorting
+do_test 3.4c {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
+ }
+} {~/ORDER BY/} ;# ORDER BY suppressed by uniqueness constraints
+
+do_test 3.5a {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC
+ }
+} {three-c three-a two-b two-a one-c one-a}
+do_test 3.5b {
+ db eval {
+ SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn DESC
+ }
+} {three-c three-a two-b two-a one-c one-a} ;# verify same order after sorting
+do_test 3.5c {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC
+ }
+} {~/ORDER BY/} ;# ORDER BY suppressed by uniqueness constraints
+
+
+do_test 3.6a {
+ db eval {
+ SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn
+ }
+} {three-a three-c two-a two-b one-a one-c}
+do_test 3.6b {
+ db eval {
+ SELECT name FROM album CROSS JOIN track USING (aid)
+ ORDER BY +title DESC, +tn
+ }
+} {three-a three-c two-a two-b one-a one-c} ;# verify same order after sorting
+do_test 3.6c {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn
+ }
+} {~/ORDER BY/} ;# inverted ASC/DESC is optimized out
+
+# Ticket 5ed1772895bf3deeab78c5e3519b1da9165c541b (2013-06-04)
+# Incorrect ORDER BY on an indexed JOIN
+#
+do_test 4.0 {
+ db eval {
+ CREATE TABLE t41(a INT UNIQUE NOT NULL, b INT NOT NULL);
+ CREATE INDEX t41ba ON t41(b,a);
+ CREATE TABLE t42(x INT NOT NULL REFERENCES t41(a), y INT NOT NULL);
+ CREATE UNIQUE INDEX t42xy ON t42(x,y);
+ INSERT INTO t41 VALUES(1,1),(3,1);
+ INSERT INTO t42 VALUES(1,13),(1,15),(3,14),(3,16);
+
+ SELECT b, y FROM t41 CROSS JOIN t42 ON x=a ORDER BY b, y;
+ }
+} {1 13 1 14 1 15 1 16}
+
+# No sorting of queries that omit the FROM clause.
+#
+do_eqp_test 5.0 {
+ SELECT 5 ORDER BY 1
+} {
+ QUERY PLAN
+ `--SCAN CONSTANT ROW
+}
+do_execsql_test 5.1 {
+ EXPLAIN QUERY PLAN SELECT 5 UNION ALL SELECT 3 ORDER BY 1
+} {~/B-TREE/}
+do_execsql_test 5.2 {
+ SELECT 5 UNION ALL SELECT 3 ORDER BY 1
+} {3 5}
+do_execsql_test 5.3 {
+ SELECT 986 AS x GROUP BY X ORDER BY X
+} {986}
+
+# The following test (originally derived from a single test within fuzz.test)
+# verifies that a PseudoTable cursor is not closed prematurely in a deeply
+# nested query. This test caused a segfault on 3.8.5 beta.
+#
+do_execsql_test 6.0 {
+ 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);
+ SELECT (
+ SELECT 'hardware' FROM (
+ SELECT 'software' ORDER BY 'firmware' ASC, 'sportswear' DESC
+ ) GROUP BY 1 HAVING length(b)
+ )
+ FROM abc;
+} {hardware hardware hardware}
+
+# Here is a test for a query-planner problem reported on the SQLite
+# mailing list on 2014-09-18 by "Merike". Beginning with version 3.8.0,
+# a separate sort was being used rather than using the single-column
+# index. This was due to an oversight in the indexMightHelpWithOrderby()
+# routine in where.c.
+#
+do_execsql_test 7.0 {
+ CREATE TABLE t7(a,b);
+ CREATE INDEX t7a ON t7(a);
+ CREATE INDEX t7ab ON t7(a,b);
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t7 WHERE a=?1 ORDER BY rowid;
+} {~/ORDER BY/}
+
+#-------------------------------------------------------------------------
+# Test a partial sort large enough to cause the sorter to spill data
+# to disk.
+#
+reset_db
+do_execsql_test 8.0 {
+ PRAGMA cache_size = 5;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a);
+}
+
+do_eqp_test 8.1 {
+ SELECT * FROM t1 ORDER BY a, b;
+} {
+ QUERY PLAN
+ |--SCAN t1 USING INDEX i1
+ `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY
+}
+
+do_execsql_test 8.2 {
+ WITH cnt(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<10000
+ )
+ INSERT INTO t1 SELECT i%2, randomblob(500) FROM cnt;
+}
+
+do_test 8.3 {
+ db eval { SELECT * FROM t1 ORDER BY a, b } { incr res $a }
+ set res
+} 5000
+
+#---------------------------------------------------------------------------
+# https://www.sqlite.org/src/tktview/cb3aa0641d9a413841c004293a4fc06cdc122029
+#
+# Adverse interaction between scalar subqueries and the partial-sorting
+# logic.
+#
+do_execsql_test 9.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(1),(2);
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(y);
+ INSERT INTO t2 VALUES(9),(8),(3),(4);
+ SELECT (SELECT x||y FROM t2, t1 ORDER BY x, y);
+} {13}
+
+# Problem found by OSSFuzz on 2018-05-05. This was caused by a new
+# optimization that had not been previously released.
+#
+do_execsql_test 10.0 {
+ CREATE TABLE t10(a,b);
+ INSERT INTO t10 VALUES(1,2),(8,9),(3,4),(5,4),(0,7);
+ CREATE INDEX t10b ON t10(b);
+ SELECT b, rowid, '^' FROM t10 ORDER BY b, a LIMIT 4;
+} {2 1 ^ 4 3 ^ 4 4 ^ 7 5 ^}
+
+do_catchsql_test 11.0 {
+ VALUES(2) EXCEPT SELECT '' ORDER BY abc
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+
+finish_test
diff --git a/test/orderby2.test b/test/orderby2.test
new file mode 100644
index 0000000..cfd6477
--- /dev/null
+++ b/test/orderby2.test
@@ -0,0 +1,117 @@
+# 2012 Sept 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 the optimizations that disable
+# ORDER BY clauses when the natural order of a query is correct.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby2
+
+# Generate test data for a join. Verify that the join gets the
+# correct answer.
+#
+do_test 1.0 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1,11), (2,22);
+ CREATE TABLE t2(d, e, UNIQUE(d,e));
+ INSERT INTO t2 VALUES(10, 'ten'), (11,'eleven'), (12,'twelve'),
+ (11, 'oneteen');
+ }
+} {}
+
+do_test 1.1a {
+ db eval {
+ SELECT e FROM t1, t2 WHERE a=1 AND d=b ORDER BY d, e;
+ }
+} {eleven oneteen}
+do_test 1.1b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT e FROM t1, t2 WHERE a=1 AND d=b ORDER BY d, e;
+ }
+} {~/ORDER BY/}
+
+do_test 1.2a {
+ db eval {
+ SELECT e FROM t1, t2 WHERE a=1 AND d=b ORDER BY e;
+ }
+} {eleven oneteen}
+do_test 1.2b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT e FROM t1, t2 WHERE a=1 AND d=b ORDER BY e;
+ }
+} {~/ORDER BY/}
+
+do_test 1.3a {
+ db eval {
+ SELECT e, b FROM t1, t2 WHERE a=1 ORDER BY d, e;
+ }
+} {ten 11 eleven 11 oneteen 11 twelve 11}
+do_test 1.3b {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT e, b FROM t1, t2 WHERE a=1 ORDER BY d, e;
+ }
+} {~/ORDER BY/}
+
+# The following tests derived from TH3 test module cov1/where34.test
+#
+do_test 2.0 {
+ db eval {
+ CREATE TABLE t31(a,b); CREATE INDEX t31ab ON t31(a,b);
+ CREATE TABLE t32(c,d); CREATE INDEX t32cd ON t32(c,d);
+ CREATE TABLE t33(e,f); CREATE INDEX t33ef ON t33(e,f);
+ CREATE TABLE t34(g,h); CREATE INDEX t34gh ON t34(g,h);
+
+ INSERT INTO t31 VALUES(1,4), (2,3), (1,3);
+ INSERT INTO t32 VALUES(4,5), (3,6), (3,7), (4,8);
+ INSERT INTO t33 VALUES(5,9), (7,10), (6,11), (8,12), (8,13), (7,14);
+ INSERT INTO t34 VALUES(11,20), (10,21), (12,22), (9,23), (13,24),
+ (14,25), (12,26);
+ SELECT a||','||c||','||e||','||g FROM t31, t32, t33, t34
+ WHERE c=b AND e=d AND g=f
+ ORDER BY a ASC, c ASC, e DESC, g ASC;
+ }
+} {1,3,7,10 1,3,7,14 1,3,6,11 1,4,8,12 1,4,8,12 1,4,8,13 1,4,5,9 2,3,7,10 2,3,7,14 2,3,6,11}
+do_test 2.1 {
+ db eval {
+ SELECT a||','||c||','||e||','||g FROM t31, t32, t33, t34
+ WHERE c=b AND e=d AND g=f
+ ORDER BY +a ASC, +c ASC, +e DESC, +g ASC;
+ }
+} {1,3,7,10 1,3,7,14 1,3,6,11 1,4,8,12 1,4,8,12 1,4,8,13 1,4,5,9 2,3,7,10 2,3,7,14 2,3,6,11}
+do_test 2.2 {
+ db eval {
+ SELECT a||','||c||','||e||','||g FROM t31, t32, t33, t34
+ WHERE c=b AND e=d AND g=f
+ ORDER BY a ASC, c ASC, e ASC, g ASC;
+ }
+} {1,3,6,11 1,3,7,10 1,3,7,14 1,4,5,9 1,4,8,12 1,4,8,12 1,4,8,13 2,3,6,11 2,3,7,10 2,3,7,14}
+do_test 2.3 {
+ optimization_control db cover-idx-scan off
+ db cache flush
+ db eval {
+ SELECT a||','||c||','||e||','||g FROM t31, t32, t33, t34
+ WHERE c=b AND e=d AND g=f
+ ORDER BY a ASC, c ASC, e ASC, g ASC;
+ }
+} {1,3,6,11 1,3,7,10 1,3,7,14 1,4,5,9 1,4,8,12 1,4,8,12 1,4,8,13 2,3,6,11 2,3,7,10 2,3,7,14}
+optimization_control db all on
+db cache flush
+
+
+
+finish_test
diff --git a/test/orderby3.test b/test/orderby3.test
new file mode 100644
index 0000000..f005f0d
--- /dev/null
+++ b/test/orderby3.test
@@ -0,0 +1,123 @@
+# 2013 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 file is testing that the optimizations that disable
+# ORDER BY clauses work correctly on a 3-way join. See ticket
+# http://www.sqlite.org/src/956e4d7f89
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby3
+
+# Generate test data for a join. Verify that the join gets the
+# correct answer.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY);
+ CREATE TABLE t2(b INTEGER PRIMARY KEY, c INTEGER);
+ CREATE TABLE t3(d INTEGER);
+
+ INSERT INTO t1 VALUES(1),(2),(3);
+
+ INSERT INTO t2 VALUES(3, 1);
+ INSERT INTO t2 VALUES(4, 2);
+ INSERT INTO t2 VALUES(5, 3);
+
+ INSERT INTO t3 VALUES(4),(3),(5);
+} {}
+do_execsql_test 1.1.asc {
+ SELECT t1.a
+ FROM t1, t2, t3
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a;
+} {1 2 3}
+do_execsql_test 1.1.desc {
+ SELECT t1.a
+ FROM t1, t2, t3
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a DESC;
+} {3 2 1}
+do_execsql_test 1.123.asc {
+ SELECT t1.a
+ FROM t1 CROSS JOIN t2 CROSS JOIN t3
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a;
+} {1 2 3}
+do_execsql_test 1.123.desc {
+ SELECT t1.a
+ FROM t1 CROSS JOIN t2 CROSS JOIN t3
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a DESC;
+} {3 2 1}
+do_execsql_test 1.132.asc {
+ SELECT t1.a
+ FROM t1 CROSS JOIN t3 CROSS JOIN t2
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a;
+} {1 2 3}
+do_execsql_test 1.132.desc {
+ SELECT t1.a
+ FROM t1 CROSS JOIN t3 CROSS JOIN t2
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a DESC;
+} {3 2 1}
+do_execsql_test 1.213.asc {
+ SELECT t1.a
+ FROM t2 CROSS JOIN t1 CROSS JOIN t3
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a;
+} {1 2 3}
+do_execsql_test 1.213.desc {
+ SELECT t1.a
+ FROM t2 CROSS JOIN t1 CROSS JOIN t3
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a DESC;
+} {3 2 1}
+do_execsql_test 1.231.asc {
+ SELECT t1.a
+ FROM t2 CROSS JOIN t3 CROSS JOIN t1
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a;
+} {1 2 3}
+do_execsql_test 1.231.desc {
+ SELECT t1.a
+ FROM t2 CROSS JOIN t3 CROSS JOIN t1
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a DESC;
+} {3 2 1}
+do_execsql_test 1.312.asc {
+ SELECT t1.a
+ FROM t3 CROSS JOIN t1 CROSS JOIN t2
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a;
+} {1 2 3}
+do_execsql_test 1.312.desc {
+ SELECT t1.a
+ FROM t3 CROSS JOIN t1 CROSS JOIN t2
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a DESC;
+} {3 2 1}
+do_execsql_test 1.321.asc {
+ SELECT t1.a
+ FROM t3 CROSS JOIN t2 CROSS JOIN t1
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a;
+} {1 2 3}
+do_execsql_test 1.321.desc {
+ SELECT t1.a
+ FROM t3 CROSS JOIN t2 CROSS JOIN t1
+ WHERE t1.a=t2.c AND t2.b=t3.d
+ ORDER BY t1.a DESC;
+} {3 2 1}
+
+finish_test
diff --git a/test/orderby4.test b/test/orderby4.test
new file mode 100644
index 0000000..ec6eb04
--- /dev/null
+++ b/test/orderby4.test
@@ -0,0 +1,56 @@
+# 2013 March 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 that the optimizations that disable
+# ORDER BY clauses work correctly on multi-value primary keys and
+# unique indices when only some prefix of the terms in the key are
+# used. See ticket http://www.sqlite.org/src/info/a179fe74659
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby4
+
+# Generate test data for a join. Verify that the join gets the
+# correct answer.
+#
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a, b, PRIMARY KEY(a,b));
+ INSERT INTO t1 VALUES(1,1),(1,2);
+ CREATE TABLE t2(x, y, PRIMARY KEY(x,y));
+ INSERT INTO t2 VALUES(3,3),(4,4);
+ SELECT a, x FROM t1, t2 ORDER BY 1, 2;
+} {1 3 1 3 1 4 1 4}
+do_execsql_test 1.2 {
+ SELECT a, x FROM t1 CROSS JOIN t2 ORDER BY 1, 2;
+} {1 3 1 3 1 4 1 4}
+do_execsql_test 1.3 {
+ SELECT a, x FROM t2 CROSS JOIN t1 ORDER BY 1, 2;
+} {1 3 1 3 1 4 1 4}
+
+do_execsql_test 2.1 {
+ CREATE TABLE t3(a);
+ INSERT INTO t3 VALUES(1),(1);
+ CREATE INDEX t3a ON t3(a);
+ CREATE TABLE t4(x);
+ INSERT INTO t4 VALUES(3),(4);
+ CREATE INDEX t4x ON t4(x);
+ SELECT a, x FROM t3, t4 ORDER BY 1, 2;
+} {1 3 1 3 1 4 1 4}
+do_execsql_test 2.2 {
+ SELECT a, x FROM t3 CROSS JOIN t4 ORDER BY 1, 2;
+} {1 3 1 3 1 4 1 4}
+do_execsql_test 2.3 {
+ SELECT a, x FROM t4 CROSS JOIN t3 ORDER BY 1, 2;
+} {1 3 1 3 1 4 1 4}
+
+finish_test
diff --git a/test/orderby5.test b/test/orderby5.test
new file mode 100644
index 0000000..ccdcf1d
--- /dev/null
+++ b/test/orderby5.test
@@ -0,0 +1,187 @@
+# 2013-06-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 that the optimizations that disable
+# ORDER BY clauses work correctly
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby5
+
+# Generate test data for a join. Verify that the join gets the
+# correct answer.
+#
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1bc ON t1(b,c);
+
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a, b, c FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.2.1 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a, c, b FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.2.2 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a, c, b FROM t1 WHERE a='xyz' COLLATE nocase;
+} {/B-TREE/}
+do_execsql_test 1.2.3 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz';
+} {/B-TREE/}
+do_execsql_test 1.2.4 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz' COLLATE nocase;
+} {~/B-TREE/}
+do_execsql_test 1.3 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT b, a, c FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.4 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT b, c, a FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.5 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT c, a, b FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.6 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT c, b, a FROM t1 WHERE a=0;
+} {~/B-TREE/}
+do_execsql_test 1.7 {
+ EXPLAIN QUERY PLAN
+ SELECT DISTINCT c, b, a FROM t1 WHERE +a=0;
+} {/B-TREE/}
+
+# In some cases, it is faster to do repeated index lookups than it is to
+# sort. But in other cases, it is faster to sort than to do repeated index
+# lookups.
+#
+do_execsql_test 2.1a {
+ CREATE TABLE t2(a,b,c);
+ CREATE INDEX t2bc ON t2(b,c);
+ ANALYZE;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1bc','1000000 10 9');
+ INSERT INTO sqlite_stat1 VALUES('t2','t2bc','100 10 5');
+ ANALYZE sqlite_master;
+
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t2 WHERE a=0 ORDER BY a, b, c;
+} {~/B-TREE/}
+
+do_execsql_test 2.1b {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE likelihood(a=0, 0.03) ORDER BY a, b, c;
+} {/B-TREE/}
+
+do_execsql_test 2.2 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE +a=0 ORDER BY a, b, c;
+} {/B-TREE/}
+do_execsql_test 2.3 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY b, a, c;
+} {~/B-TREE/}
+do_execsql_test 2.4 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY b, c, a;
+} {~/B-TREE/}
+do_execsql_test 2.5 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY a, c, b;
+} {/B-TREE/}
+do_execsql_test 2.6 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY c, a, b;
+} {/B-TREE/}
+do_execsql_test 2.7 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1 WHERE a=0 ORDER BY c, b, a;
+} {/B-TREE/}
+
+
+do_execsql_test 3.0 {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b, c, d, e, f);
+ CREATE INDEX t3bcde ON t3(b, c, d, e);
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t3 WHERE b=2 AND c=3 ORDER BY d DESC, e DESC, b, c, a DESC;
+} {~/B-TREE/}
+do_execsql_test 3.1 {
+ DROP TABLE t3;
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b, c, d, e, f) WITHOUT rowid;
+ CREATE INDEX t3bcde ON t3(b, c, d, e);
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t3 WHERE b=2 AND c=3 ORDER BY d DESC, e DESC, b, c, a DESC;
+} {~/B-TREE/}
+
+#-------------------------------------------------------------------------
+do_execsql_test 4.1.0 {
+ CREATE TABLE t4(b COLLATE nocase);
+ INSERT INTO t4 VALUES('abc');
+ INSERT INTO t4 VALUES('ABC');
+ INSERT INTO t4 VALUES('aBC');
+}
+do_execsql_test 4.1.1 {
+ SELECT * FROM t4 ORDER BY b COLLATE binary
+} {ABC aBC abc}
+do_execsql_test 4.1.2 {
+ SELECT * FROM t4 WHERE b='abc' ORDER BY b COLLATE binary
+} {ABC aBC abc}
+
+do_execsql_test 4.2.1 {
+ CREATE TABLE Records(typeID INTEGER, key TEXT COLLATE nocase, value TEXT);
+ CREATE INDEX RecordsIndex ON Records(typeID, key, value);
+}
+do_execsql_test 4.2.2 {
+ explain query plan
+ SELECT typeID, key, value FROM Records
+ WHERE typeID = 2 AND key = 'x'
+ ORDER BY key, value;
+} {~/TEMP B-TREE/}
+do_execsql_test 4.2.3 {
+ explain query plan
+ SELECT typeID, key, value FROM Records
+ WHERE typeID = 2 AND (key = 'x' COLLATE binary)
+ ORDER BY key, value;
+} {~/TEMP B-TREE/}
+do_execsql_test 4.2.4 {
+ explain query plan
+ SELECT typeID, key, value FROM Records
+ WHERE typeID = 2
+ ORDER BY key, value;
+} {~/TEMP B-TREE/}
+
+db collate hello [list string match]
+do_execsql_test 4.3.1 {
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b COLLATE hello, c, d);
+}
+db close
+sqlite3 db test.db
+do_catchsql_test 4.3.2 {
+ SELECT a FROM t5 WHERE b='def' ORDER BY b;
+} {1 {no such collation sequence: hello}}
+
+# 2020-02-13 ticket 41c1456a6e61c0e7
+do_execsql_test 4.4.0 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a);
+ DROP TABLE t2;
+ CREATE TABLE t2(b INTEGER PRIMARY KEY, c INT);
+ SELECT DISTINCT *
+ FROM t1 LEFT JOIN t2 ON b=c AND b=(SELECT a FROM t1)
+ WHERE c>10;
+} {}
+
+finish_test
diff --git a/test/orderby6.test b/test/orderby6.test
new file mode 100644
index 0000000..403250d
--- /dev/null
+++ b/test/orderby6.test
@@ -0,0 +1,183 @@
+# 2014-03-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 file is testing that the block-sort optimization.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby6
+
+# Run all tests twice. Once with a normal table and a second time
+# with a WITHOUT ROWID table
+#
+foreach {tn rowidclause} {1 {} 2 {WITHOUT ROWID}} {
+
+ # Construct a table with 1000 rows and a split primary key
+ #
+ reset_db
+ do_test $tn.1 {
+ db eval "CREATE TABLE t1(a,b,c,PRIMARY KEY(b,c)) $rowidclause;"
+ db eval {
+ WITH RECURSIVE
+ cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1000)
+ INSERT INTO t1 SELECT x, x%40, x/40 FROM cnt;
+ }
+ } {}
+
+ # Run various ORDER BY queries that can benefit from block-sort.
+ # Compare the output to the same output using a full-sort enforced
+ # by adding + to each term of the ORDER BY clause.
+ #
+ do_execsql_test $tn.2 {
+ SELECT b,a,c FROM t1 ORDER BY b,a,c;
+ } [db eval {SELECT b,a,c FROM t1 ORDER BY +b,+a,+c}]
+ do_execsql_test $tn.3 {
+ SELECT b,a,c FROM t1 ORDER BY b,c DESC,a;
+ } [db eval {SELECT b,a,c FROM t1 ORDER BY +b,+c DESC,+a}]
+ do_execsql_test $tn.4 {
+ SELECT b,a,c FROM t1 ORDER BY b DESC,c,a;
+ } [db eval {SELECT b,a,c FROM t1 ORDER BY +b DESC,+c,+a}]
+ do_execsql_test $tn.5 {
+ SELECT b,a,c FROM t1 ORDER BY b DESC,a,c;
+ } [db eval {SELECT b,a,c FROM t1 ORDER BY +b DESC,+a,+c}]
+
+ # LIMIT and OFFSET clauses on block-sort queries.
+ #
+ do_execsql_test $tn.11 {
+ SELECT a FROM t1 ORDER BY b, a LIMIT 10 OFFSET 20;
+ } {840 880 920 960 1000 1 41 81 121 161}
+ do_execsql_test $tn.11x {
+ SELECT a FROM t1 ORDER BY +b, a LIMIT 10 OFFSET 20;
+ } {840 880 920 960 1000 1 41 81 121 161}
+
+ do_execsql_test $tn.12 {
+ SELECT a FROM t1 ORDER BY b DESC, a LIMIT 10 OFFSET 20;
+ } {839 879 919 959 999 38 78 118 158 198}
+ do_execsql_test $tn.12 {
+ SELECT a FROM t1 ORDER BY +b DESC, a LIMIT 10 OFFSET 20;
+ } {839 879 919 959 999 38 78 118 158 198}
+
+ do_execsql_test $tn.13 {
+ SELECT a FROM t1 ORDER BY b, a DESC LIMIT 10 OFFSET 45;
+ } {161 121 81 41 1 962 922 882 842 802}
+ do_execsql_test $tn.13x {
+ SELECT a FROM t1 ORDER BY +b, a DESC LIMIT 10 OFFSET 45;
+ } {161 121 81 41 1 962 922 882 842 802}
+
+ do_execsql_test $tn.14 {
+ SELECT a FROM t1 ORDER BY b DESC, a LIMIT 10 OFFSET 45;
+ } {838 878 918 958 998 37 77 117 157 197}
+ do_execsql_test $tn.14x {
+ SELECT a FROM t1 ORDER BY +b DESC, a LIMIT 10 OFFSET 45;
+ } {838 878 918 958 998 37 77 117 157 197}
+
+ # Many test cases where the LIMIT+OFFSET window is in various
+ # alignments with block-sort boundaries.
+ #
+ foreach {tx limit offset orderby} {
+ 1 10 24 {+b,+a}
+ 2 10 25 {+b,+a}
+ 3 10 26 {+b,+a}
+ 4 10 39 {+b,+a}
+ 5 10 40 {+b,+a}
+ 6 10 41 {+b,+a}
+ 7 27 24 {+b,+a}
+ 8 27 49 {+b,+a}
+ 11 10 24 {+b DESC,+a}
+ 12 10 25 {+b DESC,+a}
+ 13 10 26 {+b DESC,+a}
+ 14 10 39 {+b DESC,+a}
+ 15 10 40 {+b DESC,+a}
+ 16 10 41 {+b DESC,+a}
+ 17 27 24 {+b DESC,+a}
+ 18 27 49 {+b DESC,+a}
+ 21 10 24 {+b,+a DESC}
+ 22 10 25 {+b,+a DESC}
+ 23 10 26 {+b,+a DESC}
+ 24 10 39 {+b,+a DESC}
+ 25 10 40 {+b,+a DESC}
+ 26 10 41 {+b,+a DESC}
+ 27 27 24 {+b,+a DESC}
+ 28 27 49 {+b,+a DESC}
+ 31 10 24 {+b DESC,+a DESC}
+ 32 10 25 {+b DESC,+a DESC}
+ 33 10 26 {+b DESC,+a DESC}
+ 34 10 39 {+b DESC,+a DESC}
+ 35 10 40 {+b DESC,+a DESC}
+ 36 10 41 {+b DESC,+a DESC}
+ 37 27 24 {+b DESC,+a DESC}
+ 38 27 49 {+b DESC,+a DESC}
+ } {
+ set sql1 "SELECT a FROM t1 ORDER BY $orderby LIMIT $limit OFFSET $offset;"
+ set sql2 [string map {+ {}} $sql1]
+ # puts $sql2\n$sql1\n[db eval $sql2]
+ do_test $tn.21.$tx {db eval $::sql2} [db eval $sql1]
+ }
+
+ ########################################################################
+ # A second test table, t2, has many columns open to sorting.
+ do_test $tn.31 {
+ db eval "CREATE TABLE t2(a,b,c,d,e,f,PRIMARY KEY(b,c,d,e,f)) $rowidclause;"
+ db eval {
+ WITH RECURSIVE
+ cnt(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM cnt WHERE x<242)
+ INSERT INTO t2 SELECT x, x%3, (x/3)%3, (x/9)%3, (x/27)%3, (x/81)%3
+ FROM cnt;
+ }
+ } {}
+
+ do_execsql_test $tn.32 {
+ SELECT a FROM t2 ORDER BY b,c,d,e,f;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]
+ do_execsql_test $tn.33 {
+ SELECT a FROM t2 ORDER BY b,c,d,e,+f;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]
+ do_execsql_test $tn.34 {
+ SELECT a FROM t2 ORDER BY b,c,d,+e,+f;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]
+ do_execsql_test $tn.35 {
+ SELECT a FROM t2 ORDER BY b,c,+d,+e,+f;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]
+ do_execsql_test $tn.36 {
+ SELECT a FROM t2 ORDER BY b,+c,+d,+e,+f;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]
+
+ do_execsql_test $tn.37 {
+ SELECT a FROM t2 ORDER BY b,c,d,e,f DESC;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f DESC;}]
+ do_execsql_test $tn.38 {
+ SELECT a FROM t2 ORDER BY b,c,d,e DESC,f;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e DESC,+f;}]
+ do_execsql_test $tn.39 {
+ SELECT a FROM t2 ORDER BY b,c,d DESC,e,f;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d DESC,+e,+f;}]
+ do_execsql_test $tn.40 {
+ SELECT a FROM t2 ORDER BY b,c DESC,d,e,f;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c DESC,+d,+e,+f;}]
+ do_execsql_test $tn.41 {
+ SELECT a FROM t2 ORDER BY b DESC,c,d,e,f;
+ } [db eval {SELECT a FROM t2 ORDER BY +b DESC,+c,+d,+e,+f;}]
+
+ do_execsql_test $tn.42 {
+ SELECT a FROM t2 ORDER BY b DESC,c DESC,d,e,f LIMIT 31;
+ } [db eval {SELECT a FROM t2 ORDER BY +b DESC,+c DESC,+d,+e,+f LIMIT 31}]
+ do_execsql_test $tn.43 {
+ SELECT a FROM t2 ORDER BY b,c,d,e,f DESC LIMIT 8 OFFSET 7;
+ } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f DESC LIMIT 8 OFFSET 7}]
+
+
+}
+
+
+
+finish_test
diff --git a/test/orderby7.test b/test/orderby7.test
new file mode 100644
index 0000000..8c5fc9a
--- /dev/null
+++ b/test/orderby7.test
@@ -0,0 +1,106 @@
+# 2014-04-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 ORDER BY optimizations on joins
+# that involve virtual tables.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby7
+
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE fts USING fts3(content TEXT);
+ INSERT INTO fts(rowid,content)
+ VALUES(1,'this is a test of the fts3 virtual'),
+ (2,'table used as part of a join together'),
+ (3,'with the DISTINCT keyword. There was'),
+ (4,'a bug at one time (2013-06 through 2014-04)'),
+ (5,'that prevented this from working correctly.'),
+ (11,'a row that occurs twice'),
+ (12,'a row that occurs twice');
+
+ CREATE TABLE t1(x TEXT PRIMARY KEY, y);
+ INSERT OR IGNORE INTO t1 SELECT content, rowid+100 FROM fts;
+} {}
+do_execsql_test 1.1 {
+ SELECT DISTINCT fts.rowid, t1.y
+ FROM fts, t1
+ WHERE fts MATCH 'that twice'
+ AND content=x
+ ORDER BY y;
+} {11 111 12 111}
+do_execsql_test 1.2 {
+ SELECT DISTINCT fts.rowid, t1.x
+ FROM fts, t1
+ WHERE fts MATCH 'that twice'
+ AND content=x
+ ORDER BY 1;
+} {11 {a row that occurs twice} 12 {a row that occurs twice}}
+do_execsql_test 1.3 {
+ SELECT DISTINCT t1.x
+ FROM fts, t1
+ WHERE fts MATCH 'that twice'
+ AND content=x
+ ORDER BY 1;
+} {{a row that occurs twice}}
+do_execsql_test 1.4 {
+ SELECT t1.x
+ FROM fts, t1
+ WHERE fts MATCH 'that twice'
+ AND content=x
+ ORDER BY 1;
+} {{a row that occurs twice} {a row that occurs twice}}
+do_execsql_test 1.5 {
+ SELECT DISTINCT t1.x
+ FROM fts, t1
+ WHERE fts MATCH 'that twice'
+ AND content=x;
+} {{a row that occurs twice}}
+do_execsql_test 1.6 {
+ SELECT t1.x
+ FROM fts, t1
+ WHERE fts MATCH 'that twice'
+ AND content=x;
+} {{a row that occurs twice} {a row that occurs twice}}
+
+do_execsql_test 2.1 {
+ SELECT DISTINCT t1.x
+ FROM fts, t1
+ WHERE fts.rowid=11
+ AND content=x
+ ORDER BY fts.rowid;
+} {{a row that occurs twice}}
+do_execsql_test 2.2 {
+ SELECT DISTINCT t1.*
+ FROM fts, t1
+ WHERE fts.rowid=11
+ AND content=x
+ ORDER BY fts.rowid;
+} {{a row that occurs twice} 111}
+do_execsql_test 2.3 {
+ SELECT DISTINCT t1.*
+ FROM fts, t1
+ WHERE fts.rowid=11
+ AND content=x
+ ORDER BY t1.y
+} {{a row that occurs twice} 111}
+
+
+
+
+finish_test
diff --git a/test/orderby8.test b/test/orderby8.test
new file mode 100644
index 0000000..53da971
--- /dev/null
+++ b/test/orderby8.test
@@ -0,0 +1,41 @@
+# 2015-01-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 ORDER BY and LIMIT on tables with
+# many columns.
+#
+# These tests verify that ticket [f97c4637102a3ae72b7911167e1d4da12ce60722]
+# from 2015-01-19 has been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby8
+
+do_test 1.0 {
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(1),(5),(9),(7),(3),(2),(4),(6),(8);
+ }
+ set ::result_set "x"
+} {x}
+for {set i 1} {$i<200} {incr i} {
+ append ::result_set ", x+$i"
+ do_test 1.$i {
+ set res {}
+ db eval "SELECT $::result_set FROM t1 ORDER BY x LIMIT -1" {
+ lappend res $x
+ }
+ set res
+ } {1 2 3 4 5 6 7 8 9}
+}
+
+finish_test
diff --git a/test/orderby9.test b/test/orderby9.test
new file mode 100644
index 0000000..581951c
--- /dev/null
+++ b/test/orderby9.test
@@ -0,0 +1,62 @@
+# 2015-08-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 seeks to verify that expressions (and especially functions)
+# that are in both the ORDER BY clause and the result set are only
+# evaluated once.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderby9
+
+
+do_execsql_test setup {
+ -- create a table with many entries
+ CREATE TABLE t1(x);
+ WITH RECURSIVE
+ c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1 SELECT x FROM c;
+}
+
+# Some versions of TCL are unable to [lsort -int] for
+# 64-bit integers. So we write our own comparison
+# routine.
+proc bigintcompare {a b} {
+ set x [expr {$a-$b}]
+ if {$x<0} {return -1}
+ if {$x>0} {return +1}
+ return 0
+}
+do_test 1.0 {
+ set l1 {}
+ # If random() is only evaluated once and then reused for each row, then
+ # the output should appear in sorted order. If random() is evaluated
+ # separately for the result set and the ORDER BY clause, then the output
+ # order will be random.
+ db eval {SELECT random() AS y FROM t1 ORDER BY 1;} {lappend l1 $y}
+ expr {$l1==[lsort -command bigintcompare $l1]}
+} {1}
+
+do_test 1.1 {
+ set l1 {}
+ db eval {SELECT random() AS y FROM t1 ORDER BY random();} {lappend l1 $y}
+ expr {$l1==[lsort -command bigintcompare $l1]}
+} {1}
+
+do_test 1.2 {
+ set l1 {}
+ db eval {SELECT random() AS y FROM t1 ORDER BY +random();} {lappend l1 $y}
+ expr {$l1==[lsort -command bigintcompare $l1]}
+} {0}
+
+finish_test
diff --git a/test/orderbyA.test b/test/orderbyA.test
new file mode 100644
index 0000000..4400f4e
--- /dev/null
+++ b/test/orderbyA.test
@@ -0,0 +1,147 @@
+# 2019-09-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.
+#
+# Specifically, it tests cases where the expressions in a GROUP BY
+# clause are the same as those in the ORDER BY clause.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix orderbyA
+
+proc do_sortcount_test {tn sql cnt res} {
+ set eqp [execsql "EXPLAIN QUERY PLAN $sql"]
+ set rcnt [regexp -all {USE TEMP} $eqp]
+ uplevel [list do_test $tn.1 [list set {} $rcnt] $cnt]
+ uplevel [list do_execsql_test $tn.2 $sql $res]
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('one', 1, 11);
+ INSERT INTO t1 VALUES('three', 7, 11);
+ INSERT INTO t1 VALUES('one', 2, 11);
+ INSERT INTO t1 VALUES('one', 3, 11);
+ INSERT INTO t1 VALUES('two', 4, 11);
+ INSERT INTO t1 VALUES('two', 6, 11);
+ INSERT INTO t1 VALUES('three', 8, 11);
+ INSERT INTO t1 VALUES('two', 5, 11);
+ INSERT INTO t1 VALUES('three', 9, 11);
+}
+
+foreach {tn idx} {
+ 1 {}
+ 2 {CREATE INDEX i1 ON t1(a)}
+ 3 {CREATE INDEX i1 ON t1(a DESC)}
+} {
+ execsql { DROP INDEX IF EXISTS i1 }
+ execsql $idx
+
+ # $match is the number of temp-table sorts we expect if the GROUP BY
+ # can use the same sort order as the ORDER BY. $nomatch is the number
+ # of expected sorts if the GROUP BY and ORDER BY are not compatible.
+ set match 1
+ set nomatch 2
+ if {$tn>=2} {
+ set match 0
+ set nomatch 1
+ }
+
+ do_sortcount_test 1.$tn.1.1 {
+ SELECT a, sum(b) FROM t1 GROUP BY a ORDER BY a
+ } $match {one 6 three 24 two 15}
+ do_sortcount_test 1.$tn.1.2 {
+ SELECT a, sum(b) FROM t1 GROUP BY a ORDER BY a DESC
+ } $match {two 15 three 24 one 6}
+
+ do_sortcount_test 1.$tn.2.1 {
+ SELECT a, sum(b) FROM t1 GROUP BY a ORDER BY a||''
+ } $nomatch {one 6 three 24 two 15}
+ do_sortcount_test 1.$tn.2.2 {
+ SELECT a, sum(b) FROM t1 GROUP BY a ORDER BY a||'' DESC
+ } $nomatch {two 15 three 24 one 6}
+
+ do_sortcount_test 1.$tn.3.1 {
+ SELECT a, sum(b) FROM t1 GROUP BY a ORDER BY a NULLS LAST
+ } $nomatch {one 6 three 24 two 15}
+ do_sortcount_test 1.$tn.3.2 {
+ SELECT a, sum(b) FROM t1 GROUP BY a ORDER BY a DESC NULLS FIRST
+ } $nomatch {two 15 three 24 one 6}
+}
+
+#-------------------------------------------------------------------------
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a, b, c);
+ INSERT INTO t2 VALUES(1, 'one', 1);
+ INSERT INTO t2 VALUES(1, 'two', 2);
+ INSERT INTO t2 VALUES(1, 'one', 3);
+ INSERT INTO t2 VALUES(1, 'two', 4);
+ INSERT INTO t2 VALUES(1, 'one', 5);
+ INSERT INTO t2 VALUES(1, 'two', 6);
+
+ INSERT INTO t2 VALUES(2, 'one', 7);
+ INSERT INTO t2 VALUES(2, 'two', 8);
+ INSERT INTO t2 VALUES(2, 'one', 9);
+ INSERT INTO t2 VALUES(2, 'two', 10);
+ INSERT INTO t2 VALUES(2, 'one', 11);
+ INSERT INTO t2 VALUES(2, 'two', 12);
+
+ INSERT INTO t2 VALUES(NULL, 'one', 13);
+ INSERT INTO t2 VALUES(NULL, 'two', 14);
+ INSERT INTO t2 VALUES(NULL, 'one', 15);
+ INSERT INTO t2 VALUES(NULL, 'two', 16);
+ INSERT INTO t2 VALUES(NULL, 'one', 17);
+ INSERT INTO t2 VALUES(NULL, 'two', 18);
+}
+
+foreach {tn idx} {
+ 1 {}
+
+ 2 { CREATE INDEX i2 ON t2(a, b) }
+ 3 { CREATE INDEX i2 ON t2(a DESC, b DESC) }
+
+ 4 { CREATE INDEX i2 ON t2(a, b DESC) }
+ 5 { CREATE INDEX i2 ON t2(a DESC, b) }
+} {
+ execsql { DROP INDEX IF EXISTS i2 }
+ execsql $idx
+
+
+ set nSort [expr ($tn==2 || $tn==3) ? 0 : 1]
+ do_sortcount_test 2.$tn.1.1 {
+ SELECT a, b, sum(c) FROM t2 GROUP BY a, b ORDER BY a, b;
+ } $nSort {{} one 45 {} two 48 1 one 9 1 two 12 2 one 27 2 two 30}
+ do_sortcount_test 2.$tn.1.2 {
+ SELECT a, b, sum(c) FROM t2 GROUP BY a, b ORDER BY a DESC, b DESC;
+ } $nSort {2 two 30 2 one 27 1 two 12 1 one 9 {} two 48 {} one 45}
+
+ set nSort [expr ($tn==4 || $tn==5) ? 0 : 1]
+ do_sortcount_test 2.$tn.2.1 {
+ SELECT a, b, sum(c) FROM t2 GROUP BY a, b ORDER BY a, b DESC;
+ } $nSort { {} two 48 {} one 45 1 two 12 1 one 9 2 two 30 2 one 27 }
+ do_sortcount_test 2.$tn.2.2 {
+ SELECT a, b, sum(c) FROM t2 GROUP BY a, b ORDER BY a DESC, b;
+ } $nSort { 2 one 27 2 two 30 1 one 9 1 two 12 {} one 45 {} two 48 }
+
+ # ORDER BY can never piggyback on the GROUP BY sort if it uses
+ # non-standard NULLS behaviour.
+ set nSort [expr $tn==1 ? 2 : 1]
+ do_sortcount_test 2.$tn.3.1 {
+ SELECT a, b, sum(c) FROM t2 GROUP BY a, b ORDER BY a, b DESC NULLS FIRST;
+ } $nSort { {} two 48 {} one 45 1 two 12 1 one 9 2 two 30 2 one 27 }
+ do_sortcount_test 2.$tn.3.2 {
+ SELECT a, b, sum(c) FROM t2 GROUP BY a, b ORDER BY a DESC, b NULLS LAST;
+ } $nSort { 2 one 27 2 two 30 1 one 9 1 two 12 {} one 45 {} two 48 }
+}
+
+
+finish_test
diff --git a/test/oserror.test b/test/oserror.test
new file mode 100644
index 0000000..a51301c
--- /dev/null
+++ b/test/oserror.test
@@ -0,0 +1,142 @@
+# 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.
+#
+if {![clang_sanitize_address]} {
+ unset -nocomplain rc
+ unset -nocomplain nOpen
+ set nOpen 20000
+ do_test 1.1.1 {
+ set ::log [list]
+ set ::rc [catch {
+ for {set i 0} {$i < $::nOpen} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
+ } msg]
+ if {$::rc==0} {
+ # Some system (ex: Debian) are able to create 20000+ file descriptiors
+ # such systems will not fail here
+ set x ok
+ } elseif {$::rc==1 && $msg=="unable to open database file"} {
+ set x ok
+ } else {
+ set x [list $::rc $msg]
+ }
+ } {ok}
+ do_test 1.1.2 {
+ catch { for {set i 0} {$i < $::nOpen} {incr i} { dbh_$i close } }
+ } $::rc
+ if {$rc} {
+ 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|readlink|lstat)\(.*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/ossfuzz.c b/test/ossfuzz.c
new file mode 100644
index 0000000..b0156a6
--- /dev/null
+++ b/test/ossfuzz.c
@@ -0,0 +1,201 @@
+/*
+** This module interfaces SQLite to the Google OSS-Fuzz, fuzzer as a service.
+** (https://github.com/google/oss-fuzz)
+*/
+#include <stddef.h>
+#if !defined(_MSC_VER)
+# include <stdint.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+#include "sqlite3.h"
+
+#if defined(_MSC_VER)
+typedef unsigned char uint8_t;
+#endif
+
+/* Global debugging settings. OSS-Fuzz will have all debugging turned
+** off. But if LLVMFuzzerTestOneInput() is called interactively from
+** the ossshell utility program, then these flags might be set.
+*/
+static unsigned mDebug = 0;
+#define FUZZ_SQL_TRACE 0x0001 /* Set an sqlite3_trace() callback */
+#define FUZZ_SHOW_MAX_DELAY 0x0002 /* Show maximum progress callback delay */
+#define FUZZ_SHOW_ERRORS 0x0004 /* Print error messages from SQLite */
+
+/* The ossshell utility program invokes this interface to see the
+** debugging flags. Unused by OSS-Fuzz.
+*/
+void ossfuzz_set_debug_flags(unsigned x){
+ mDebug = x;
+}
+
+/* Return the current real-world time in milliseconds since the
+** Julian epoch (-4714-11-24).
+*/
+static sqlite3_int64 timeOfDay(void){
+ static sqlite3_vfs *clockVfs = 0;
+ sqlite3_int64 t;
+ if( clockVfs==0 ){
+ clockVfs = sqlite3_vfs_find(0);
+ if( clockVfs==0 ) return 0;
+ }
+ if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
+ clockVfs->xCurrentTimeInt64(clockVfs, &t);
+ }else{
+ double r;
+ clockVfs->xCurrentTime(clockVfs, &r);
+ t = (sqlite3_int64)(r*86400000.0);
+ }
+ return t;
+}
+
+/* An instance of the following object is passed by pointer as the
+** client data to various callbacks.
+*/
+typedef struct FuzzCtx {
+ sqlite3 *db; /* The database connection */
+ sqlite3_int64 iCutoffTime; /* Stop processing at this time. */
+ sqlite3_int64 iLastCb; /* Time recorded for previous progress callback */
+ sqlite3_int64 mxInterval; /* Longest interval between two progress calls */
+ unsigned nCb; /* Number of progress callbacks */
+ unsigned execCnt; /* Number of calls to the sqlite3_exec callback */
+} FuzzCtx;
+
+/*
+** Progress handler callback.
+**
+** The argument is the cutoff-time after which all processing should
+** stop. So return non-zero if the cut-off time is exceeded.
+*/
+static int progress_handler(void *pClientData) {
+ FuzzCtx *p = (FuzzCtx*)pClientData;
+ sqlite3_int64 iNow = timeOfDay();
+ int rc = iNow>=p->iCutoffTime;
+ sqlite3_int64 iDiff = iNow - p->iLastCb;
+ if( iDiff > p->mxInterval ) p->mxInterval = iDiff;
+ p->nCb++;
+ return rc;
+}
+
+/*
+** Disallow debugging pragmas such as "PRAGMA vdbe_debug" and
+** "PRAGMA parser_trace" since they can dramatically increase the
+** amount of output without actually testing anything useful.
+*/
+static int block_debug_pragmas(
+ void *Notused,
+ int eCode,
+ const char *zArg1,
+ const char *zArg2,
+ const char *zArg3,
+ const char *zArg4
+){
+ if( eCode==SQLITE_PRAGMA
+ && (sqlite3_strnicmp("vdbe_", zArg1, 5)==0
+ || sqlite3_stricmp("parser_trace", zArg1)==0)
+ ){
+ return SQLITE_DENY;
+ }
+ return SQLITE_OK;
+}
+
+/*
+** Callback for sqlite3_exec().
+*/
+static int exec_handler(void *pClientData, int argc, char **argv, char **namev){
+ FuzzCtx *p = (FuzzCtx*)pClientData;
+ int i;
+ if( argv ){
+ for(i=0; i<argc; i++) sqlite3_free(sqlite3_mprintf("%s", argv[i]));
+ }
+ return (p->execCnt--)<=0 || progress_handler(pClientData);
+}
+
+/*
+** Main entry point. The fuzzer invokes this function with each
+** fuzzed input.
+*/
+int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ char *zErrMsg = 0; /* Error message returned by sqlite_exec() */
+ uint8_t uSelector; /* First byte of input data[] */
+ int rc; /* Return code from various interfaces */
+ char *zSql; /* Zero-terminated copy of data[] */
+ FuzzCtx cx; /* Fuzzing context */
+
+ memset(&cx, 0, sizeof(cx));
+ if( size<3 ) return 0; /* Early out if unsufficient data */
+
+ /* Extract the selector byte from the beginning of the input. But only
+ ** do this if the second byte is a \n. If the second byte is not \n,
+ ** then use a default selector */
+ if( data[1]=='\n' ){
+ uSelector = data[0]; data += 2; size -= 2;
+ }else{
+ uSelector = 0xfd;
+ }
+
+ /* Open the database connection. Only use an in-memory database. */
+ if( sqlite3_initialize() ) return 0;
+ rc = sqlite3_open_v2("fuzz.db", &cx.db,
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY, 0);
+ if( rc ) return 0;
+
+ /* Invoke the progress handler frequently to check to see if we
+ ** are taking too long. The progress handler will return true
+ ** (which will block further processing) if more than 10 seconds have
+ ** elapsed since the start of the test.
+ */
+ cx.iLastCb = timeOfDay();
+ cx.iCutoffTime = cx.iLastCb + 10000; /* Now + 10 seconds */
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ sqlite3_progress_handler(cx.db, 10, progress_handler, (void*)&cx);
+#endif
+
+ /* Set a limit on the maximum size of a prepared statement */
+ sqlite3_limit(cx.db, SQLITE_LIMIT_VDBE_OP, 25000);
+
+ /* Limit total memory available to SQLite to 20MB */
+ sqlite3_hard_heap_limit64(20000000);
+
+ /* Set a limit on the maximum length of a string or BLOB. Without this
+ ** limit, fuzzers will invoke randomblob(N) for a large N, and the process
+ ** will timeout trying to generate the huge blob */
+ sqlite3_limit(cx.db, SQLITE_LIMIT_LENGTH, 50000);
+
+ /* Bit 1 of the selector enables foreign key constraints */
+ sqlite3_db_config(cx.db, SQLITE_DBCONFIG_ENABLE_FKEY, uSelector&1, &rc);
+ uSelector >>= 1;
+
+ /* Do not allow debugging pragma statements that might cause excess output */
+ sqlite3_set_authorizer(cx.db, block_debug_pragmas, 0);
+
+ /* Remaining bits of the selector determine a limit on the number of
+ ** output rows */
+ cx.execCnt = uSelector + 1;
+
+ /* Run the SQL. The sqlite_exec() interface expects a zero-terminated
+ ** string, so make a copy. */
+ zSql = sqlite3_mprintf("%.*s", (int)size, data);
+#ifndef SQLITE_OMIT_COMPLETE
+ sqlite3_complete(zSql);
+#endif
+ sqlite3_exec(cx.db, zSql, exec_handler, (void*)&cx, &zErrMsg);
+
+ /* Show any errors */
+ if( (mDebug & FUZZ_SHOW_ERRORS)!=0 && zErrMsg ){
+ printf("Error: %s\n", zErrMsg);
+ }
+
+ /* Cleanup and return */
+ sqlite3_free(zErrMsg);
+ sqlite3_free(zSql);
+ sqlite3_exec(cx.db, "PRAGMA temp_store_directory=''", 0, 0, 0);
+ sqlite3_close(cx.db);
+
+ if( mDebug & FUZZ_SHOW_MAX_DELAY ){
+ printf("Progress callback count....... %d\n", cx.nCb);
+ printf("Max time between callbacks.... %d ms\n", (int)cx.mxInterval);
+ }
+ return 0;
+}
diff --git a/test/ossshell.c b/test/ossshell.c
new file mode 100644
index 0000000..54849f9
--- /dev/null
+++ b/test/ossshell.c
@@ -0,0 +1,100 @@
+/*
+** This is a test interface for the ossfuzz.c module. The ossfuzz.c module
+** is an adaptor for OSS-FUZZ. (https://github.com/google/oss-fuzz)
+**
+** This program links against ossfuzz.c. It reads files named on the
+** command line and passes them one by one into ossfuzz.c.
+*/
+#include <stddef.h>
+#if !defined(_MSC_VER)
+# include <stdint.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "sqlite3.h"
+
+#if defined(_MSC_VER)
+typedef unsigned char uint8_t;
+#endif
+
+/*
+** The entry point in ossfuzz.c that this routine will be calling
+*/
+int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
+
+/* Must match equivalent #defines in ossfuzz.c */
+#define FUZZ_SQL_TRACE 0x0001 /* Set an sqlite3_trace() callback */
+#define FUZZ_SHOW_MAX_DELAY 0x0002 /* Show maximum progress callback delay */
+#define FUZZ_SHOW_ERRORS 0x0004 /* Show SQL errors */
+extern void ossfuzz_set_debug_flags(unsigned);
+
+
+
+/*
+** Read files named on the command-line and invoke the fuzzer for
+** each one.
+*/
+int main(int argc, char **argv){
+ FILE *in;
+ int i;
+ int nErr = 0;
+ uint8_t *zBuf = 0;
+ size_t sz;
+ unsigned mDebug = 0;
+
+ for(i=1; i<argc; i++){
+ const char *zFilename = argv[i];
+ if( zFilename[0]=='-' ){
+ if( zFilename[1]=='-' ) zFilename++;
+ if( strcmp(zFilename, "-show-errors")==0 ){
+ mDebug |= FUZZ_SHOW_ERRORS;
+ ossfuzz_set_debug_flags(mDebug);
+ }else
+ if( strcmp(zFilename, "-show-max-delay")==0 ){
+ mDebug |= FUZZ_SHOW_MAX_DELAY;
+ ossfuzz_set_debug_flags(mDebug);
+ }else
+ if( strcmp(zFilename, "-sql-trace")==0 ){
+ mDebug |= FUZZ_SQL_TRACE;
+ ossfuzz_set_debug_flags(mDebug);
+ }else
+ {
+ printf("unknown option \"%s\"\n", argv[i]);
+ printf("should be one of: --show-errors --show-max-delay"
+ " --sql-trace\n");
+ exit(1);
+ }
+ continue;
+ }
+ in = fopen(zFilename, "rb");
+ if( in==0 ){
+ fprintf(stderr, "cannot open \"%s\"\n", zFilename);
+ nErr++;
+ continue;
+ }
+ fseek(in, 0, SEEK_END);
+ sz = ftell(in);
+ rewind(in);
+ zBuf = realloc(zBuf, sz);
+ if( zBuf==0 ){
+ fprintf(stderr, "cannot malloc() for %d bytes\n", (int)sz);
+ exit(1);
+ }
+ if( fread(zBuf, sz, 1, in)!=1 ){
+ fprintf(stderr, "cannot read %d bytes from \"%s\"\n",
+ (int)sz, zFilename);
+ nErr++;
+ }else{
+ printf("%s... ", zFilename);
+ if( mDebug ) printf("\n");
+ fflush(stdout);
+ (void)LLVMFuzzerTestOneInput(zBuf, sz);
+ if( mDebug ) printf("%s: ", zFilename);
+ printf("ok\n");
+ }
+ fclose(in);
+ }
+ free(zBuf);
+ return nErr;
+}
diff --git a/test/ovfl.test b/test/ovfl.test
new file mode 100644
index 0000000..4be7568
--- /dev/null
+++ b/test/ovfl.test
@@ -0,0 +1,47 @@
+# 2014 October 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 file implements regression tests for SQLite library. The
+# focus of this file is testing the SQLITE_DIRECT_OVERFLOW_READ logic.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix ovfl
+
+# Populate table t2:
+#
+# CREATE TABLE t1(c1 TEXT, c2 TEXT);
+#
+# with 2000 rows. In each row, c2 spans multiple overflow pages. The text
+# value of c1 ranges in size from 1 to 2000 bytes. The idea is to create
+# at least one row where the first byte of c2 is also the first byte of
+# an overflow page. This was at one point exposing an obscure bug in the
+# SQLITE_DIRECT_OVERFLOW_READ logic.
+#
+do_test 1.1 {
+ set c2 [string repeat abcdefghij 200]
+ execsql {
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(c1 TEXT, c2 TEXT);
+ BEGIN;
+ }
+ for {set i 1} {$i <= 2000} {incr i} {
+ set c1 [string repeat . $i]
+ execsql { INSERT INTO t1 VALUES($c1, $c2) }
+ }
+ execsql COMMIT
+} {}
+
+do_execsql_test 1.2 {
+ SELECT sum(length(c2)) FROM t1;
+} [expr 2000 * 2000]
+
+finish_test
diff --git a/test/pager1.test b/test/pager1.test
new file mode 100644
index 0000000..79598e2
--- /dev/null
+++ b/test/pager1.test
@@ -0,0 +1,2956 @@
+# 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
+set testprefix pager1
+
+if {[atomic_batch_write test.db]} {
+ finish_test
+ return
+}
+ifcapable !incrblob {
+ finish_test
+ return
+}
+
+# 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"
+# (The omit_readlock pragma has been removed and so have
+# these tests.)
+#
+# 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 {CHECK constraint failed: i<5}}
+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]-30] 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]-30] 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.
+#
+set pwd [get_pwd]
+testvfs tv -default 1
+tv script copy_on_mj_delete
+set ::mj_filename_length 0
+set ::mj_delete_cnt 0
+proc copy_on_mj_delete {method filename args} {
+ if {[string match *mj* [file tail $filename]]} {
+ #
+ # NOTE: Is the file name relative? If so, add the length of the current
+ # directory.
+ #
+ if {[is_relative_file $filename]} {
+ set ::mj_filename_length \
+ [expr {[string length $filename] + [string length $::pwd]}]
+ } else {
+ set ::mj_filename_length [string length $filename]
+ }
+ faultsim_save
+ incr ::mj_delete_cnt
+ }
+ return SQLITE_OK
+}
+
+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 usesMJ} {
+ o {
+ PRAGMA main.synchronous=OFF;
+ PRAGMA aux.synchronous=OFF;
+ PRAGMA journal_mode = DELETE;
+ } 0
+ o512 {
+ PRAGMA main.synchronous=OFF;
+ PRAGMA aux.synchronous=OFF;
+ PRAGMA main.page_size = 512;
+ PRAGMA aux.page_size = 512;
+ PRAGMA journal_mode = DELETE;
+ } 0
+ n {
+ PRAGMA main.synchronous=NORMAL;
+ PRAGMA aux.synchronous=NORMAL;
+ PRAGMA journal_mode = DELETE;
+ } 1
+ f {
+ PRAGMA main.synchronous=FULL;
+ PRAGMA aux.synchronous=FULL;
+ PRAGMA journal_mode = DELETE;
+ } 1
+ w1 {
+ PRAGMA main.synchronous=NORMAL;
+ PRAGMA aux.synchronous=NORMAL;
+ PRAGMA journal_mode = WAL;
+ } 0
+ w2 {
+ PRAGMA main.synchronous=NORMAL;
+ PRAGMA aux.synchronous=NORMAL;
+ PRAGMA main.journal_mode=DELETE;
+ PRAGMA aux.journal_mode=WAL;
+ } 0
+ o1a {
+ PRAGMA main.synchronous=FULL;
+ PRAGMA aux.synchronous=OFF;
+ PRAGMA journal_mode=DELETE;
+ } 0
+ o1b {
+ PRAGMA main.synchronous=OFF;
+ PRAGMA aux.synchronous=NORMAL;
+ PRAGMA journal_mode=DELETE;
+ } 0
+ m1 {
+ PRAGMA main.synchronous=NORMAL;
+ PRAGMA aux.synchronous=NORMAL;
+ PRAGMA main.journal_mode=DELETE;
+ PRAGMA aux.journal_mode = MEMORY;
+ } 0
+ t1 {
+ PRAGMA main.synchronous=NORMAL;
+ PRAGMA aux.synchronous=NORMAL;
+ PRAGMA main.journal_mode=DELETE;
+ PRAGMA aux.journal_mode = TRUNCATE;
+ } 1
+ p1 {
+ PRAGMA main.synchronous=NORMAL;
+ PRAGMA aux.synchronous=NORMAL;
+ PRAGMA main.journal_mode=DELETE;
+ PRAGMA aux.journal_mode = PERSIST;
+ } 1
+ } {
+
+ 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 {
+ set ::mj_delete_cnt 0
+ 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 {}
+
+ # Verify that a master journal was deleted only for those cases where
+ # master journals really ought to be used
+ #
+ do_test pager1-4.4.$tn.1b {
+ set ::mj_delete_cnt
+ } $usesMJ
+
+ # 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}
+
+ if {$usesMJ} {
+ # 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 {
+ if {$::mj_delete_cnt>0} {
+ faultsim_restore_and_reopen $prefix
+ foreach f [glob ${prefix}-mj*] { forcedelete $f }
+ } else {
+ db close
+ sqlite3 db $prefix
+ }
+ execsql "ATTACH '${prefix}2' AS aux"
+ glob -nocomplain ${prefix}-mj*
+ } {}
+ 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 {attempt to write a readonly database}}
+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
+catch {
+ test_syscall install fchmod
+ test_syscall fault 1 1
+}
+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}}
+catch {
+ test_syscall reset
+ test_syscall fault 0 0
+}
+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}
+do_test pager1.4.8.1 {
+ catch {file attributes test.db -permissions r--------}
+ catch {file attributes test.db -readonly 1}
+ sqlite3 db test.db
+ db eval { SELECT * FROM t1 }
+ sqlite3_db_readonly db main
+} {1}
+do_test pager1.4.8.2 {
+ sqlite3_db_readonly db xyz
+} {-1}
+do_test pager1.4.8.3 {
+ db close
+ catch {file attributes test.db -readonly 0}
+ catch {file attributes test.db -permissions rw-rw-rw-} msg
+ sqlite3 db test.db
+ db eval { SELECT * FROM t1 }
+ sqlite3_db_readonly db main
+} {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;
+ }
+
+ # The size of the journal file is now:
+ #
+ # 1) 512 byte header +
+ # 2) 2 * (1024+8) byte records +
+ # 3) 20+N bytes of master-journal pointer, where N is the size of
+ # the master-journal name encoded as utf-8 with no nul term.
+ #
+ set mj_pointer [expr {
+ 20 + [string length "test.db-mjXXXXXX9XX"]
+ }]
+ #
+ # NOTE: For item 3 above, if the current SQLite VFS lacks the concept of a
+ # current directory, the length of the current directory name plus 1
+ # character for the directory separator character are NOT counted as
+ # part of the total size; otherwise, they are.
+ #
+ ifcapable curdir {
+ set mj_pointer [expr {$mj_pointer + [string length [get_pwd]] + 1}]
+ }
+ expr {$::max_journal==(512+2*(1024+8)+$mj_pointer)}
+} 1
+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;
+ }
+
+ # In synchronous=full mode, the master-journal pointer is not written
+ # directly after the last record in the journal file. Instead, it is
+ # written starting at the next (in this case 512 byte) sector boundary.
+ #
+ set mj_pointer [expr {
+ 20 + [string length "test.db-mjXXXXXX9XX"]
+ }]
+ #
+ # NOTE: If the current SQLite VFS lacks the concept of a current directory,
+ # the length of the current directory name plus 1 character for the
+ # directory separator character are NOT counted as part of the total
+ # size; otherwise, they are.
+ #
+ ifcapable curdir {
+ set mj_pointer [expr {$mj_pointer + [string length [get_pwd]] + 1}]
+ }
+ expr {$::max_journal==(((512+2*(1024+8)+511)/512)*512 + $mj_pointer)}
+} 1
+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(1501);
+ }
+ 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)" }
+} {}
+if {[nonzero_reserved_bytes]} {
+ # backup with a page size changes is not possible with the codec
+ #
+ do_test pager1-9.3.2codec {
+ 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_READONLY SQLITE_READONLY}
+ do_test pager1-9.3.3codec {
+ db2 close
+ db close
+ tv delete
+ file size test.db2
+ } [file size test.db2]
+} else {
+ 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]
+} {1024 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 {
+ 16
+ 32 64 128 256 512 1024 2048
+ 4096 8192 16384 32768 65536 131072 262144
+} {
+ tv sectorsize $sectorsize
+ tv devchar {}
+ 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<32 ? 512 : $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.
+#
+# Do not run these tests for SQLITE_ENABLE_ZIPVFS builds. Such builds
+# cause the pager to enter the error state if a statement transaction
+# cannot be rolled back due to a prior "PRAGMA journal_mode=OFF". Which
+# causes these tests to fail.
+#
+if {[info commands zip_register]==""} {
+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 {UNIQUE constraint failed: t1.rowid}}
+do_execsql_test pager1-14.1.5 {
+ COMMIT;
+}
+do_execsql_test pager1-14.1.6 {
+ 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 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]
+ sqlite3_db_config db DEFENSIVE 0
+ 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.1 {
+ 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
+ # even though x is malformed, because typeof() does
+ # not load the content of x, the error is not noticed.
+ catchsql { SELECT typeof(x) FROM t2 } db2
+} {0 text}
+do_test pager1-18.3.2 {
+ # in this case, the value of x is loaded and so the error is
+ # detected
+ catchsql { SELECT length(x||'') FROM t2 } db2
+} {1 {database disk image is malformed}}
+db2 close
+do_test pager1-18.3.3 {
+ execsql {
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(randomblob(5000));
+ }
+ set pgno [expr ([file size test.db] / 1024)-2]
+ hexio_write test.db [expr ($pgno-1)*1024] 00000000
+ sqlite3 db2 test.db
+ # even though x is malformed, because length() and typeof() do
+ # not load the content of x, the error is not noticed.
+ catchsql { SELECT length(x), typeof(x) FROM t2 } db2
+} {0 {5000 blob}}
+do_test pager1-18.3.4 {
+ # in this case, the value of x is loaded and so the error is
+ # detected
+ 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
+extra_schema_checks 0
+ifcapable altertable {
+ do_test pager1-18.5 {
+ sqlite3 db ""
+ sqlite3_db_config db DEFENSIVE 0
+ 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
+}
+extra_schema_checks 1
+
+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
+} {}
+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]
+if {[nonzero_reserved_bytes]} {
+ # VACUUM with size changes is not possible with the codec.
+ do_test pager1-29.2 {
+ catchsql {
+ PRAGMA page_size = 4096;
+ VACUUM;
+ }
+ } {1 {attempt to write a readonly database}}
+} else {
+ 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
+
+#-------------------------------------------------------------------------
+# Test that if a transaction is committed in journal_mode=DELETE mode,
+# and the call to unlink() returns an ENOENT error, the COMMIT does not
+# succeed.
+#
+if {$::tcl_platform(platform)=="unix"} {
+ do_test pager1-33.1 {
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('one');
+ INSERT INTO t1 VALUES('two');
+ BEGIN;
+ INSERT INTO t1 VALUES('three');
+ INSERT INTO t1 VALUES('four');
+ }
+ forcedelete bak-journal
+ file rename test.db-journal bak-journal
+
+ catchsql COMMIT
+ } {1 {disk I/O error}}
+
+ do_test pager1-33.2 {
+ file rename bak-journal test.db-journal
+ execsql { SELECT * FROM t1 }
+ } {one two}
+}
+
+#-------------------------------------------------------------------------
+# Test that appending pages to the database file then moving those pages
+# to the free-list before the transaction is committed does not cause
+# an error.
+#
+foreach {tn pragma strsize} {
+ 1 { PRAGMA mmap_size = 0 } 2400
+ 2 { } 2400
+ 3 { PRAGMA mmap_size = 0 } 4400
+ 4 { } 4400
+} {
+ reset_db
+ db func a_string a_string
+ db eval $pragma
+ do_execsql_test 34.$tn.1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ do_execsql_test 34.$tn.2 {
+ BEGIN;
+ INSERT INTO t1 VALUES(2, a_string($strsize));
+ DELETE FROM t1 WHERE oid=2;
+ COMMIT;
+ PRAGMA integrity_check;
+ } {ok}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_test 35 {
+ sqlite3 db test.db
+
+ execsql {
+ CREATE TABLE t1(x, y);
+ PRAGMA journal_mode = WAL;
+ INSERT INTO t1 VALUES(1, 2);
+ }
+
+ execsql {
+ BEGIN;
+ CREATE TABLE t2(a, b);
+ }
+
+ hexio_write test.db-shm [expr 16*1024] [string repeat 0055 8192]
+ catchsql ROLLBACK
+} {0 {}}
+
+do_multiclient_test tn {
+ sql1 {
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+
+ do_test 36.$tn.1 {
+ sql2 { PRAGMA max_page_count = 2 }
+ list [catch { sql2 { CREATE TABLE t2(x) } } msg] $msg
+ } {1 {database or disk is full}}
+
+ sql1 { PRAGMA checkpoint_fullfsync = 1 }
+ sql1 { CREATE TABLE t2(x) }
+
+ do_test 36.$tn.2 {
+ sql2 { INSERT INTO t2 VALUES('xyz') }
+ list [catch { sql2 { CREATE TABLE t3(x) } } msg] $msg
+ } {1 {database or disk is full}}
+}
+
+forcedelete test1 test2
+foreach {tn uri} {
+ 1 {file:?mode=memory&cache=shared}
+ 2 {file:one?mode=memory&cache=shared}
+ 3 {file:test1?cache=shared}
+ 4 {file:test2?another=parameter&yet=anotherone}
+} {
+ do_test 37.$tn {
+ catch { db close }
+ sqlite3_shutdown
+ sqlite3_config_uri 1
+ sqlite3 db $uri
+
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ SELECT * FROM t1;
+ }
+ } {1}
+
+ do_execsql_test 37.$tn.2 {
+ VACUUM;
+ SELECT * FROM t1;
+ } {1}
+
+ db close
+ sqlite3_shutdown
+ sqlite3_config_uri 0
+}
+
+do_test 38.1 {
+ catch { db close }
+ forcedelete test.db
+ set fd [open test.db w]
+ puts $fd "hello world"
+ close $fd
+ sqlite3 db test.db
+ catchsql { CREATE TABLE t1(x) }
+} {1 {file is not a database}}
+do_test 38.2 {
+ catch { db close }
+ forcedelete test.db
+} {}
+
+do_test 39.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('xxx');
+ INSERT INTO t1 VALUES('two');
+ INSERT INTO t1 VALUES(randomblob(400));
+ INSERT INTO t1 VALUES(randomblob(400));
+ INSERT INTO t1 VALUES(randomblob(400));
+ INSERT INTO t1 VALUES(randomblob(400));
+ BEGIN;
+ UPDATE t1 SET x = 'one' WHERE rowid=1;
+ }
+ set ::stmt [sqlite3_prepare db "SELECT * FROM t1 ORDER BY rowid" -1 dummy]
+ sqlite3_step $::stmt
+ sqlite3_column_text $::stmt 0
+} {one}
+do_test 39.2 {
+ execsql { CREATE TABLE t2(x) }
+ sqlite3_step $::stmt
+ sqlite3_column_text $::stmt 0
+} {two}
+do_test 39.3 {
+ sqlite3_finalize $::stmt
+ execsql COMMIT
+} {}
+
+do_execsql_test 39.4 {
+ PRAGMA auto_vacuum = 2;
+ CREATE TABLE t3(x);
+ CREATE TABLE t4(x);
+
+ DROP TABLE t2;
+ DROP TABLE t3;
+ DROP TABLE t4;
+}
+do_test 39.5 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA cache_size = 1;
+ PRAGMA incremental_vacuum;
+ PRAGMA integrity_check;
+ }
+} {ok}
+
+do_test 40.1 {
+ reset_db
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(x PRIMARY KEY);
+ INSERT INTO t1 VALUES(randomblob(1200));
+ PRAGMA page_count;
+ }
+} {6}
+do_test 40.2 {
+ execsql {
+ INSERT INTO t1 VALUES(randomblob(1200));
+ INSERT INTO t1 VALUES(randomblob(1200));
+ INSERT INTO t1 VALUES(randomblob(1200));
+ }
+} {}
+do_test 40.3 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA cache_size = 1;
+ CREATE TABLE t2(x);
+ PRAGMA integrity_check;
+ }
+} {ok}
+
+do_test 41.1 {
+ reset_db
+ execsql {
+ CREATE TABLE t1(x PRIMARY KEY);
+ 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;
+ INSERT INTO t1 SELECT randomblob(200) FROM t1;
+ }
+} {}
+do_test 41.2 {
+ testvfs tv -default 1
+ tv sectorsize 16384;
+ tv devchar [list]
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA cache_size = 1;
+ DELETE FROM t1 WHERE rowid%4;
+ PRAGMA integrity_check;
+ }
+} {ok}
+db close
+tv delete
+
+set pending_prev [sqlite3_test_control_pending_byte 0x1000000]
+do_test 42.1 {
+ reset_db
+ execsql {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ }
+ db close
+ sqlite3_test_control_pending_byte 0x0010000
+ sqlite3 db test.db
+ db eval { PRAGMA mmap_size = 0 }
+ catchsql { SELECT sum(length(y)) FROM t1 }
+} {1 {database disk image is malformed}}
+do_test 42.2 {
+ reset_db
+ execsql {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ }
+ db close
+
+ testvfs tv -default 1
+ tv sectorsize 16384;
+ tv devchar [list]
+ sqlite3 db test.db -vfs tv
+ execsql { UPDATE t1 SET x = randomblob(200) }
+} {}
+db close
+tv delete
+sqlite3_test_control_pending_byte $pending_prev
+
+do_test 43.1 {
+ reset_db
+ execsql {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES(1, 2);
+ CREATE TABLE t3(x, y);
+ INSERT INTO t3 VALUES(1, 2);
+ }
+ db close
+ sqlite3 db test.db
+
+ db eval { PRAGMA mmap_size = 0 }
+ db eval { SELECT * FROM t1 }
+ sqlite3_db_status db CACHE_MISS 0
+} {0 2 0}
+
+do_test 43.2 {
+ db eval { SELECT * FROM t2 }
+ sqlite3_db_status db CACHE_MISS 1
+} {0 3 0}
+
+do_test 43.3 {
+ db eval { SELECT * FROM t3 }
+ sqlite3_db_status db CACHE_MISS 0
+} {0 1 0}
+
+# 2022-03-01 Forum post https://sqlite.org/forum/forumpost/3b9e894312
+# Ensure that max_page_count gets adjusted upward, if needed, on a
+# ROLLBACK.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test 44.1 {
+ PRAGMA page_size=4096;
+ PRAGMA auto_vacuum=FULL;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b ANY);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<50)
+ INSERT INTO t1(a,b) SELECT x, zeroblob(1000) FROM c;
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ PRAGMA page_count;
+} {31}
+do_execsql_test 44.2 {
+ BEGIN;
+ DROP TABLE t2;
+ PRAGMA incremental_vacuum=50;
+ PRAGMA page_count;
+ PRAGMA max_page_count=2;
+} {16 16}
+do_execsql_test 44.3 {
+ ROLLBACK;
+ PRAGMA page_count;
+ PRAGMA max_page_count;
+} {31 31}
+
+finish_test
diff --git a/test/pager2.test b/test/pager2.test
new file mode 100644
index 0000000..0e2b33b
--- /dev/null
+++ b/test/pager2.test
@@ -0,0 +1,168 @@
+# 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}
+
+#-------------------------------------------------------------------------
+# Test that shared in-memory databases seem to work.
+#
+db close
+do_test pager2-3.1 {
+ forcedelete test.db
+ sqlite3_shutdown
+ sqlite3_config_uri 1
+
+ sqlite3 db1 {file:test.db?mode=memory&cache=shared}
+ sqlite3 db2 {file:test.db?mode=memory&cache=shared}
+ sqlite3 db3 test.db
+
+ db1 eval { CREATE TABLE t1(a, b) }
+ db2 eval { INSERT INTO t1 VALUES(1, 2) }
+ list [catch { db3 eval { INSERT INTO t1 VALUES(3, 4) } } msg] $msg
+} {1 {no such table: t1}}
+
+finish_test
diff --git a/test/pager3.test b/test/pager3.test
new file mode 100644
index 0000000..e815f27
--- /dev/null
+++ b/test/pager3.test
@@ -0,0 +1,37 @@
+# 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
+
+if {[atomic_batch_write test.db]} {
+ finish_test
+ return
+}
+
+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/pager4.test b/test/pager4.test
new file mode 100644
index 0000000..2cf73d1
--- /dev/null
+++ b/test/pager4.test
@@ -0,0 +1,99 @@
+# 2013-12-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.
+#
+#***********************************************************************
+#
+# Tests for the SQLITE_READONLY_DBMOVED error condition: the database file
+# is unlinked or renamed out from under SQLite.
+#
+
+if {$tcl_platform(platform)!="unix"} return
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {[permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+# Create a database file for testing
+#
+do_execsql_test pager4-1.1 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(673,'stone','philips');
+ SELECT * FROM t1;
+} {673 stone philips}
+
+# After renaming the database file while it is open, one can still
+# read from the database, but writing returns a READONLY error.
+#
+file delete -force test-xyz.db
+file rename test.db test-xyz.db
+do_catchsql_test pager4-1.2 {
+ SELECT * FROM t1;
+} {0 {673 stone philips}}
+do_catchsql_test pager4-1.3 {
+ UPDATE t1 SET a=537;
+} {1 {attempt to write a readonly database}}
+
+# Creating a different database file with the same name of the original
+# is detected and still leaves the database read-only.
+#
+sqlite3 db2 test.db
+db2 eval {CREATE TABLE t2(x,y,z)}
+do_catchsql_test pager4-1.4 {
+ UPDATE t1 SET a=948;
+} {1 {attempt to write a readonly database}}
+
+# Changing the name back clears the READONLY error
+#
+db2 close
+file delete -force test.db
+file rename test-xyz.db test.db
+do_catchsql_test pager4-1.5 {
+ SELECT * FROM t1;
+} {0 {673 stone philips}}
+do_catchsql_test pager4-1.6 {
+ UPDATE t1 SET a=537;
+ SELECT * FROM t1;
+} {0 {537 stone philips}}
+
+# We can write to a renamed database if journal_mode=OFF or
+# journal_mode=MEMORY.
+#
+file rename test.db test-xyz.db
+do_catchsql_test pager4-1.7 {
+ PRAGMA journal_mode=OFF;
+ UPDATE t1 SET a=107;
+ SELECT * FROM t1;
+} {0 {off 107 stone philips}}
+do_catchsql_test pager4-1.8 {
+ PRAGMA journal_mode=MEMORY;
+ UPDATE t1 SET b='magpie';
+ SELECT * FROM t1;
+} {0 {memory 107 magpie philips}}
+
+# Any other journal mode gives a READONLY error
+#
+do_catchsql_test pager4-1.9 {
+ PRAGMA journal_mode=DELETE;
+ UPDATE t1 SET c='jaguar';
+} {1 {attempt to write a readonly database}}
+do_catchsql_test pager4-1.10 {
+ PRAGMA journal_mode=TRUNCATE;
+ UPDATE t1 SET c='jaguar';
+} {1 {attempt to write a readonly database}}
+do_catchsql_test pager4-1.11 {
+ PRAGMA journal_mode=PERSIST;
+ UPDATE t1 SET c='jaguar';
+} {1 {attempt to write a readonly database}}
+
+
+finish_test
diff --git a/test/pagerfault.test b/test/pagerfault.test
new file mode 100644
index 0000000..3006dad
--- /dev/null
+++ b/test/pagerfault.test
@@ -0,0 +1,1553 @@
+# 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}}
+}
+
+# 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.
+#
+# Update: It is no longer possible to change the page size of any temp
+# database after it has been created.
+#
+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 {1 {attempt to write a readonly database}} \
+ {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)" }
+
+ if {[atomic_batch_write test.db]==0} {
+ set sz [file size test.db]
+ if {$testrc!=0 && $sz!=1024*3 && $sz!=4096*3} {
+ error "Expected file size 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
+}
+
+
+#-------------------------------------------------------------------------
+#
+do_test pagerfault-28-pre {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA page_size = 512;
+
+ PRAGMA journal_mode = wal;
+ PRAGMA wal_autocheckpoint = 0;
+ PRAGMA cache_size = 100000;
+
+ BEGIN;
+ 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 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;
+ COMMIT;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ }
+ expr {[file size test.db-shm] >= 96*1024}
+} {1}
+faultsim_save_and_close
+
+do_faultsim_test pagerfault-28a -faults oom* -prep {
+ faultsim_restore_and_reopen
+ execsql { PRAGMA mmap_size=0 }
+
+ sqlite3 db2 test.db
+ db2 eval { SELECT count(*) FROM t2 }
+
+ db func a_string a_string
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(a_string(2000), a_string(2000));
+ INSERT INTO t1 VALUES(a_string(2000), a_string(2000));
+ }
+ set ::STMT [sqlite3_prepare db "SELECT * FROM t1 ORDER BY a" -1 DUMMY]
+ sqlite3_step $::STMT
+} -body {
+ execsql { ROLLBACK }
+} -test {
+ db2 close
+ sqlite3_finalize $::STMT
+ catchsql { ROLLBACK }
+ faultsim_integrity_check
+}
+
+faultsim_restore_and_reopen
+sqlite3 db2 test.db
+db2 eval {SELECT count(*) FROM t2}
+db close
+
+do_faultsim_test pagerfault-28b -faults oom* -prep {
+ sqlite3 db test.db
+} -body {
+ execsql { SELECT count(*) FROM t2 }
+} -test {
+ faultsim_test_result {0 2048}
+ db close
+}
+
+db2 close
+
+#-------------------------------------------------------------------------
+# Try this:
+#
+# 1) Put the pager in ERROR state (error during rollback)
+#
+# 2) Next time the connection is used inject errors into all xWrite() and
+# xUnlock() calls. This causes the hot-journal rollback to fail and
+# the pager to declare its locking state UNKNOWN.
+#
+# 3) Same again.
+#
+# 4a) Stop injecting errors. Allow the rollback to succeed. Check that
+# the database is Ok. Or,
+#
+# 4b) Close and reopen the db. Check that the db is Ok.
+#
+proc custom_injectinstall {} {
+ testvfs custom -default true
+ custom filter {xWrite xUnlock}
+}
+proc custom_injectuninstall {} {
+ catch {db close}
+ catch {db2 close}
+ custom delete
+}
+proc custom_injectstart {iFail} {
+ custom ioerr $iFail 1
+}
+proc custom_injectstop {} {
+ custom ioerr
+}
+set ::FAULTSIM(custom) [list \
+ -injectinstall custom_injectinstall \
+ -injectstart custom_injectstart \
+ -injectstop custom_injectstop \
+ -injecterrlist {{1 {disk I/O error}}} \
+ -injectuninstall custom_injectuninstall \
+]
+
+do_test pagerfault-29-pre {
+ faultsim_delete_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 5;
+
+ BEGIN;
+ 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;
+ COMMIT;
+ }
+ expr {[file size test.db] >= 50*1024}
+} {1}
+faultsim_save_and_close
+foreach {tn tt} {
+ 29 { catchsql ROLLBACK }
+ 30 { db close ; sqlite3 db test.db }
+} {
+ do_faultsim_test pagerfault-$tn -faults custom -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA cache_size = 5;
+ BEGIN;
+ UPDATE t2 SET a = a_string(799);
+ }
+ } -body {
+ catchsql ROLLBACK
+ catchsql ROLLBACK
+ catchsql ROLLBACK
+ } -test {
+ eval $::tt
+ if {"ok" != [db one {PRAGMA integrity_check}]} {
+ error "integrity check failed"
+ }
+ }
+}
+
+do_test pagerfault-31-pre {
+ sqlite3_shutdown
+ sqlite3_config_uri 1
+} {SQLITE_OK}
+do_faultsim_test pagerfault-31 -faults oom* -body {
+ sqlite3 db {file:one?mode=memory&cache=shared}
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ SELECT * FROM t1;
+ }
+} -test {
+ faultsim_test_result {0 1} {1 {}}
+ catch { db close }
+}
+sqlite3_shutdown
+sqlite3_config_uri 0
+
+do_test pagerfault-32-pre {
+ reset_db
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('one');
+ }
+} {}
+faultsim_save_and_close
+
+do_faultsim_test pagerfault-32 -prep {
+ faultsim_restore_and_reopen
+ db eval { SELECT * FROM t1; }
+} -body {
+ execsql { SELECT * FROM t1; }
+} -test {
+ faultsim_test_result {0 one}
+}
+sqlite3_shutdown
+sqlite3_config_uri 0
+
+do_faultsim_test pagerfault-33a -prep {
+ sqlite3 db :memory:
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+} -body {
+ execsql { VACUUM }
+} -test {
+ faultsim_test_result {0 {}}
+}
+do_faultsim_test pagerfault-33b -prep {
+ sqlite3 db ""
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+} -body {
+ execsql { VACUUM }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_test pagerfault-34-pre {
+ reset_db
+ execsql {
+ CREATE TABLE t1(x PRIMARY KEY);
+ }
+} {}
+faultsim_save_and_close
+do_faultsim_test pagerfault-34 -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES( randomblob(4000) );
+ DELETE FROM t1;
+ }
+} -body {
+ execsql COMMIT
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_test pagerfault-35-pre {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE t1(x PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ }
+ faultsim_save_and_close
+} {}
+testvfs tv -default 1
+tv sectorsize 8192;
+tv devchar [list]
+do_faultsim_test pagerfault-35 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { UPDATE t1 SET x=randomblob(200) }
+} -test {
+ faultsim_test_result {0 {}}
+}
+catch {db close}
+tv delete
+
+sqlite3_shutdown
+sqlite3_config_uri 1
+do_test pagerfault-36-pre {
+ faultsim_delete_and_reopen
+ execsql {
+ CREATE TABLE t1(x PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test pagerfault-36 -prep {
+ faultsim_restore
+ sqlite3 db file:test.db?cache=shared
+ sqlite3 db2 file:test.db?cache=shared
+ db2 eval {
+ BEGIN;
+ SELECT count(*) FROM sqlite_master;
+ }
+ db eval {
+ PRAGMA cache_size = 1;
+ BEGIN;
+ UPDATE t1 SET x = randomblob(200);
+ }
+} -body {
+ execsql ROLLBACK db
+} -test {
+ catch { db eval {UPDATE t1 SET x = randomblob(200)} }
+ faultsim_test_result {0 {}}
+ catch { db close }
+ catch { db2 close }
+}
+
+sqlite3_shutdown
+sqlite3_config_uri 0
+sqlite3_initialize
+
+finish_test
diff --git a/test/pagerfault2.test b/test/pagerfault2.test
new file mode 100644
index 0000000..7f6c995
--- /dev/null
+++ b/test/pagerfault2.test
@@ -0,0 +1,98 @@
+# 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..a4301cd
--- /dev/null
+++ b/test/pagerfault3.test
@@ -0,0 +1,63 @@
+# 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..f58b8ee
--- /dev/null
+++ b/test/pageropt.test
@@ -0,0 +1,209 @@
+# 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
+do_not_use_codec
+
+ifcapable {!pager_pragmas||secure_delete||direct_read} {
+ finish_test
+ return
+}
+
+# A non-zero reserved_bytes value changes the number of pages in the
+# database file, which messes up the results in this test.
+if {[nonzero_reserved_bytes]} {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.
+#
+ifcapable mmap {
+ set x [expr {[permutation]=="mmap" ? 1 : 6}]
+} else {
+ set x 6
+}
+do_test pageropt-1.5 {
+ db2 eval {CREATE TABLE t2(y)}
+ pagercount_sql {
+ SELECT hex(x) FROM t1
+ }
+} [list $x 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..8800530
--- /dev/null
+++ b/test/pagesize.test
@@ -0,0 +1,237 @@
+# 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]
+}
+
+reset_db
+do_execsql_test pagesize-3.1 {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ PRAGMA page_size=2048;
+ PRAGMA main.page_size;
+} {1024}
+do_execsql_test pagesize-3.2 {
+ CREATE TABLE t1(x);
+ COMMIT;
+}
+do_execsql_test pagesize-3.3 {
+ BEGIN;
+ PRAGMA page_size = 2048;
+ COMMIT;
+ PRAGMA main.page_size;
+} {1024}
+
+finish_test
diff --git a/test/parser1.test b/test/parser1.test
new file mode 100644
index 0000000..ad95b49
--- /dev/null
+++ b/test/parser1.test
@@ -0,0 +1,103 @@
+# 2014-08-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 details of the SQL language parser.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_catchsql_test parser1-1.1 {
+ CREATE TABLE t1(
+ a TEXT PRIMARY KEY,
+ b TEXT,
+ FOREIGN KEY(b COLLATE nocase DESC) REFERENCES t1(a COLLATE binary ASC)
+ );
+} {1 {syntax error after column name "b"}}
+
+
+# Verify that a legacy schema in the sqlite_master file is allowed to have
+# COLLATE, ASC, and DESC keywords on the id list of a FK constraint, and that
+# those keywords are silently ignored.
+#
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test parser1-1.2 {
+ CREATE TABLE t1(
+ a TEXT PRIMARY KEY,
+ b TEXT,
+ FOREIGN KEY(b) REFERENCES t1(a)
+ );
+ INSERT INTO t1 VALUES('abc',NULL),('xyz','abc');
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_master SET sql='CREATE TABLE t1(
+ a TEXT PRIMARY KEY,
+ b TEXT,
+ FOREIGN KEY(b COLLATE nocase) REFERENCES t1(a)
+ )' WHERE name='t1';
+ SELECT name FROM sqlite_master WHERE sql LIKE '%collate%';
+} {t1}
+sqlite3 db2 test.db
+do_test parser1-1.3 {
+ sqlite3 db2 test.db
+ db2 eval {SELECT * FROM t1 ORDER BY 1}
+} {abc {} xyz abc}
+db2 close
+
+do_execsql_test parser1-1.4 {
+ UPDATE sqlite_master SET sql='CREATE TABLE t1(
+ a TEXT PRIMARY KEY,
+ b TEXT,
+ FOREIGN KEY(b ASC) REFERENCES t1(a)
+ )' WHERE name='t1';
+ SELECT name FROM sqlite_master WHERE sql LIKE '%ASC%';
+} {t1}
+sqlite3 db2 test.db
+do_test parser1-1.5 {
+ sqlite3 db2 test.db
+ db2 eval {SELECT * FROM t1 ORDER BY 1}
+} {abc {} xyz abc}
+db2 close
+
+do_catchsql_test parser1-2.1 {
+ WITH RECURSIVE
+ c(x COLLATE binary) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<5)
+ SELECT x FROM c;
+} {1 {syntax error after column name "x"}}
+do_catchsql_test parser1-2.2 {
+ WITH RECURSIVE
+ c(x ASC) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<5)
+ SELECT x FROM c;
+} {1 {syntax error after column name "x"}}
+
+# Verify that the comma between multiple table constraints is
+# optional.
+#
+# The missing comma is technically a syntax error. But we have to support
+# it because there might be legacy databases that omit the commas in their
+# sqlite_master tables.
+#
+do_execsql_test parser1-3.1 {
+ CREATE TABLE t300(id INTEGER PRIMARY KEY);
+ CREATE TABLE t301(
+ id INTEGER PRIMARY KEY,
+ c1 INTEGER NOT NULL,
+ c2 INTEGER NOT NULL,
+ c3 BOOLEAN NOT NULL DEFAULT 0,
+ FOREIGN KEY(c1) REFERENCES t300(id) ON DELETE CASCADE ON UPDATE RESTRICT
+ /* no comma */
+ FOREIGN KEY(c2) REFERENCES t300(id) ON DELETE CASCADE ON UPDATE RESTRICT
+ /* no comma */
+ UNIQUE(c1, c2)
+ );
+ PRAGMA foreign_key_list(t301);
+} {0 0 t300 c2 id RESTRICT CASCADE NONE 1 0 t300 c1 id RESTRICT CASCADE NONE}
+
+finish_test
diff --git a/test/pcache.test b/test/pcache.test
new file mode 100644
index 0000000..5d9d93e
--- /dev/null
+++ b/test/pcache.test
@@ -0,0 +1,182 @@
+# 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;
+ PRAGMA mmap_size=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; 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..a0d7496
--- /dev/null
+++ b/test/pcache2.test
@@ -0,0 +1,84 @@
+# 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
+
+test_set_config_pagecache 0 0
+
+# 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_config singlethread
+ 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; SELECT 1 FROM sqlite_master;}
+ 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; SELECT 1 FROM sqlite_master;}
+ 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_config serialized
+sqlite3_initialize
+autoinstall_test_functions
+
+test_restore_config_pagecache
+finish_test
diff --git a/test/percentile.test b/test/percentile.test
new file mode 100644
index 0000000..b2bd061
--- /dev/null
+++ b/test/percentile.test
@@ -0,0 +1,209 @@
+# 2013-05-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 percentile.c extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Basic test of the percentile() function.
+#
+do_test percentile-1.0 {
+ load_static_extension db percentile
+ execsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1),(4),(6),(7),(8),(9),(11),(11),(11);
+ }
+ execsql {SELECT percentile(x,0) FROM t1}
+} {1.0}
+foreach {in out} {
+ 100 11.0
+ 50 8.0
+ 12.5 4.0
+ 15 4.4
+ 20 5.2
+ 80 11.0
+ 89 11.0
+} {
+ do_test percentile-1.1.$in {
+ execsql {SELECT percentile(x,$in) FROM t1}
+ } $out
+}
+
+# Add some NULL values.
+#
+do_test percentile-1.2 {
+ execsql {INSERT INTO t1 VALUES(NULL),(NULL);}
+} {}
+foreach {in out} {
+ 100 11.0
+ 50 8.0
+ 12.5 4.0
+ 15 4.4
+ 20 5.2
+ 80 11.0
+ 89 11.0
+} {
+ do_test percentile-1.3.$in {
+ execsql {SELECT percentile(x,$in) FROM t1}
+ } $out
+}
+
+# The second argument to percentile can change some, but not much.
+#
+do_test percentile-1.4 {
+ catchsql {SELECT round(percentile(x, 15+0.000001*rowid),1) FROM t1}
+} {0 4.4}
+do_test percentile-1.5 {
+ catchsql {SELECT round(percentile(x, 15+0.1*rowid),1) FROM t1}
+} {1 {2nd argument to percentile() is not the same for all input rows}}
+
+# Input values in a random order
+#
+do_test percentile-1.6 {
+ execsql {
+ CREATE TABLE t2(x);
+ INSERT INTO t2 SELECT x+0.0 FROM t1 ORDER BY random();
+ }
+} {}
+foreach {in out} {
+ 100 11.0
+ 50 8.0
+ 12.5 4.0
+ 15 4.4
+ 20 5.2
+ 80 11.0
+ 89 11.0
+} {
+ do_test percentile-1.7.$in {
+ execsql {SELECT percentile(x,$in) FROM t2}
+ } $out
+}
+
+# Wrong number of arguments
+#
+do_test percentile-1.8 {
+ catchsql {SELECT percentile(x,0,1) FROM t1}
+} {1 {wrong number of arguments to function percentile()}}
+do_test percentile-1.9 {
+ catchsql {SELECT percentile(x) FROM t1}
+} {1 {wrong number of arguments to function percentile()}}
+
+# Second argument must be numeric
+#
+do_test percentile-1.10 {
+ catchsql {SELECT percentile(x,null) FROM t1}
+} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
+do_test percentile-1.11 {
+ catchsql {SELECT percentile(x,'fifty') FROM t1}
+} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
+do_test percentile-1.12 {
+ catchsql {SELECT percentile(x,x'3530') FROM t1}
+} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
+
+# Second argument is out of range
+#
+do_test percentile-1.13 {
+ catchsql {SELECT percentile(x,-0.0000001) FROM t1}
+} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
+do_test percentile-1.14 {
+ catchsql {SELECT percentile(x,100.0000001) FROM t1}
+} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
+
+# First argument is not NULL and is not NUMERIC
+#
+do_test percentile-1.15 {
+ catchsql {
+ BEGIN;
+ UPDATE t1 SET x='50' WHERE x IS NULL;
+ SELECT percentile(x, 50) FROM t1;
+ }
+} {1 {1st argument to percentile() is not numeric}}
+do_test percentile-1.16 {
+ catchsql {
+ ROLLBACK;
+ BEGIN;
+ UPDATE t1 SET x=x'3530' WHERE x IS NULL;
+ SELECT percentile(x, 50) FROM t1;
+ }
+} {1 {1st argument to percentile() is not numeric}}
+do_test percentile-1.17 {
+ catchsql {
+ ROLLBACK;
+ SELECT percentile(x, 50) FROM t1;
+ }
+} {0 8.0}
+
+# No non-NULL entries.
+#
+do_test percentile-1.18 {
+ execsql {
+ UPDATE t1 SET x=NULL;
+ SELECT ifnull(percentile(x, 50),'NULL') FROM t1
+ }
+} {NULL}
+
+# Exactly one non-NULL entry
+#
+do_test percentile-1.19 {
+ execsql {
+ UPDATE t1 SET x=12345 WHERE rowid=5;
+ SELECT percentile(x, 0), percentile(x, 50), percentile(x,100) FROM t1
+ }
+} {12345.0 12345.0 12345.0}
+
+# Infinity as an input
+#
+do_test percentile-1.20 {
+ catchsql {
+ DELETE FROM t1;
+ INSERT INTO t1 SELECT x+0.0 FROM t2;
+ UPDATE t1 SET x=1.0e300*1.0e300 WHERE rowid=5;
+ SELECT percentile(x,50) from t1;
+ }
+} {1 {Inf input to percentile()}}
+do_test percentile-1.21 {
+ catchsql {
+ UPDATE t1 SET x=-1.0e300*1.0e300 WHERE rowid=5;
+ SELECT percentile(x,50) from t1;
+ }
+} {1 {Inf input to percentile()}}
+
+# Million-row Inputs
+#
+ifcapable vtab {
+ do_test percentile-2.0 {
+ load_static_extension db wholenumber
+ execsql {
+ CREATE VIRTUAL TABLE nums USING wholenumber;
+ CREATE TABLE t3(x);
+ INSERT INTO t3 SELECT value-1 FROM nums WHERE value BETWEEN 1 AND 500000;
+ INSERT INTO t3 SELECT value*10 FROM nums
+ WHERE value BETWEEN 500000 AND 999999;
+ SELECT count(*) FROM t3;
+ }
+ } {1000000}
+ foreach {in out} {
+ 0 0.0
+ 100 9999990.0
+ 50 2749999.5
+ 10 99999.9
+ } {
+ do_test percentile-2.1.$in {
+ execsql {
+ SELECT round(percentile(x, $in),1) from t3;
+ }
+ } $out
+ }
+}
+
+finish_test
diff --git a/test/permutations.test b/test/permutations.test
new file mode 100644
index 0000000..add02d2
--- /dev/null
+++ b/test/permutations.test
@@ -0,0 +1,1258 @@
+# 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 \
+ $testdir/../ext/fts5/test/*.test \
+ $testdir/../ext/expert/*.test \
+ $testdir/../ext/lsm1/test/*.test \
+ $testdir/../ext/recover/*.test \
+] {
+ lappend alltests $f
+}
+foreach f [glob -nocomplain $testdir/../ext/session/*.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 full.test extraquick.test
+ session.test rbu.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 walcrash3.test
+ walthread.test rtree3.test indexfault.test securedel2.test
+ sort3.test sort4.test fts4growth.test fts4growth2.test
+ bigsort.test walprotocol.test mmap4.test fuzzer2.test
+ walcrash2.test e_fkey.test backup.test
+
+ fts4merge.test fts4merge2.test fts4merge4.test fts4check.test
+ fts4merge5.test
+ fts3cov.test fts3snippet.test fts3corrupt2.test fts3an.test
+ fts3defer.test fts4langid.test fts3sort.test fts5unicode.test
+ recovercorrupt.test
+
+ rtree4.test
+ sessionbig.test
+
+ writecrash.test view3.test
+ fts5dlidx.test fts5ac.test fts4merge3.test fts5prefix.test
+ sessionB.test
+}]
+if {[info exists ::env(QUICKTEST_INCLUDE)]} {
+ set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
+}
+if {[info exists ::env(QUICKTEST_OMIT)]} {
+ # If environment variable QUICKTEST_OMIT is set, it is a comma-separated
+ # list of regular expressions to match against test file names in
+ # the "allquicktests" set. Any matches are excluded. Only the filename
+ # is matched, not any directory component of the path.
+ set all [list]
+ foreach a $allquicktests {
+ set bIn 1
+ foreach x [split $::env(QUICKTEST_OMIT) ,] {
+ if {[regexp $x [file tail $a]]} {
+ set bIn 0
+ break
+ }
+ }
+ if {$bIn} {
+ lappend all $a
+ }
+ }
+ set allquicktests $all
+}
+
+# If the TEST_FAILURE environment variable is set, it means that we what to
+# deliberately provoke test failures in order to test the test infrastructure.
+# Only the main.test module is needed for this.
+#
+if {[info exists ::env(TEST_FAILURE)]} {
+ set allquicktests main.test
+}
+
+#############################################################################
+# 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 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* *bigfile* *_err* \
+ *fts5corrupt* *fts5big* *fts5aj*
+]
+
+test_suite "shell" -prefix "" -description {
+ Run tests of the command-line shell
+} -files [
+ test_set [glob $testdir/shell*.test]
+]
+
+test_suite "extraquick" -prefix "" -description {
+ "Extra" quick test suite. Runs in a few minutes on a workstation.
+ This test suite is the same as the "veryquick" tests, except that
+ slower tests are omitted.
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
+ wal3.test fts4merge* sort2.test mmap1.test walcrash* \
+ percentile.test where8m.test walcksum.test savepoint3.test \
+ fuzzer1.test fuzzer3.test fts3expr3.test
+]
+
+test_suite "mmap" -prefix "mm-" -description {
+ Similar to veryquick. Except with memory mapping enabled.
+} -presql {
+ pragma mmap_size = 268435456;
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault* -include malloc.test
+]
+
+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* *_err* wal.test \
+ shell2.test shell6.test shell7.test \
+ crash8.test atof1.test selectG.test \
+ tkt-fc62af4523.test numindex1.test corruptK.test
+] -initialize {
+ set ::G(valgrind) 1
+} -shutdown {
+ unset -nocomplain ::G(valgrind)
+}
+
+test_suite "valgrind-nolookaside" -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* *_err* \
+ wal.test atof1.test
+] -initialize {
+ set ::G(valgrind) 1
+ 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
+ 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
+ fts3auto.test fts3aux1.test fts3aux2.test fts3b.test
+ fts3comp1.test fts3conf.test fts3corrupt2.test fts3corrupt.test
+ fts3corrupt4.test
+ fts3cov.test fts3c.test fts3defer2.test fts3defer3.test
+ fts3defer.test fts3drop.test fts3d.test fts3e.test
+ fts3expr2.test fts3expr3.test fts3expr4.test fts3expr5.test
+ fts3expr.test fts3fault2.test fts3fault.test fts3first.test
+ fts3join.test fts3malloc.test fts3matchinfo.test fts3near.test
+ fts3offsets.test fts3prefix2.test fts3prefix.test fts3query.test
+ fts3shared.test fts3snippet.test fts3sort.test fts3tok1.test
+ fts3tok_err.test fts3varint.test fts4aa.test fts4check.test
+ fts4content.test fts4docid.test fts4growth2.test fts4growth.test
+ fts4incr.test fts4langid.test fts4lastrowid.test fts4merge2.test
+ fts4merge4.test fts4merge.test fts4noti.test fts4onepass.test
+ fts4opt.test fts4unicode.test
+ fts3corrupt3.test
+ fts3misc.test
+}
+
+test_suite "fts5" -prefix "" -description {
+ All FTS5 tests.
+} -files [glob -nocomplain $::testdir/../ext/fts5/test/*.test]
+
+test_suite "fts5-light" -prefix "" -description {
+ All FTS5 tests.
+} -files [
+ test_set \
+ [glob -nocomplain $::testdir/../ext/fts5/test/*.test] \
+ -exclude *corrupt* *fault* *big* *fts5aj*
+]
+
+test_suite "window" -prefix "" -description {
+ All window function related tests .
+} -files [
+ test_set [glob -nocomplain $::testdir/window*.test]
+]
+
+test_suite "lsm1" -prefix "" -description {
+ All LSM1 tests.
+} -files [glob -nocomplain $::testdir/../ext/lsm1/test/*.test]
+
+test_suite "nofaultsim" -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* *_err*
+] -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ install_malloc_faultsim 0
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ unset -nocomplain ::G(valgrind)
+}
+
+test_suite "queryplanner" -prefix "" -description {
+ Tests of the query planner and query optimizer
+} -files {
+ alter2.test alter3.test alter4.test alter.test analyze3.test
+ analyze4.test analyze5.test analyze6.test analyze7.test analyze8.test
+ analyze.test attach2.test attach3.test attach4.test
+ attach.test autoinc.test autoindex1.test between.test cast.test
+ check.test closure01.test coalesce.test collate1.test collate2.test
+ collate3.test collate4.test collate5.test collate6.test collate7.test
+ collate8.test collate9.test collateA.test colmeta.test colname.test
+ conflict.test count.test coveridxscan.test createtab.test cse.test
+ date.test dbstatus2.test dbstatus.test default.test delete2.test
+ delete3.test delete.test descidx1.test descidx2.test descidx3.test
+ distinctagg.test distinct.test e_createtable.test e_delete.test
+ e_droptrigger.test e_dropview.test e_expr.test e_insert.test
+ eqp.test e_reindex.test e_resolve.test e_select2.test e_select.test
+ e_update.test exists.test expr.test fkey1.test fkey2.test fkey3.test
+ fkey4.test fkey5.test func2.test func3.test func.test
+ in3.test in4.test in5.test index2.test index3.test
+ index4.test index5.test indexedby.test index.test
+ insert2.test insert3.test insert4.test insert5.test insert.test
+ instr.test in.test intpkey.test join2.test join3.test join4.test
+ join5.test join6.test join.test like2.test like.test limit.test
+ minmax2.test minmax3.test minmax4.test minmax.test misc1.test misc2.test
+ misc3.test misc4.test misc5.test misc6.test misc7.test orderby1.test
+ orderby2.test orderby3.test orderby4.test randexpr1.test regexp1.test
+ reindex.test rowhash.test rowid.test schema2.test schema3.test
+ schema4.test schema5.test schema.test
+ select1.test select2.test select3.test select4.test select5.test
+ select6.test select7.test select8.test select9.test selectA.test
+ selectB.test selectC.test selectD.test selectE.test sidedelete.test
+ sort.test spellfix.test subquery2.test subquery.test subselect.test
+ substr.test tkt-02a8e81d44.test tkt1435.test tkt1443.test tkt1444.test
+ tkt1449.test tkt1473.test tkt1501.test tkt1512.test tkt1514.test
+ tkt1536.test tkt1537.test tkt1567.test tkt1644.test tkt1667.test
+ tkt1873.test tkt2141.test tkt2192.test tkt2213.test tkt2251.test
+ tkt2285.test tkt2332.test tkt2339.test tkt2391.test tkt2409.test
+ tkt2450.test tkt2565.test tkt2640.test tkt2643.test tkt2686.test
+ tkt-26ff0c2d1e.test tkt2767.test tkt2817.test tkt2820.test tkt2822.test
+ tkt2832.test tkt2854.test tkt2920.test tkt2927.test tkt2942.test
+ tkt-2a5629202f.test tkt-2d1a5c67d.test tkt-2ea2425d34.test tkt3080.test
+ tkt3093.test tkt3121.test tkt-31338dca7e.test tkt-313723c356.test
+ tkt3201.test tkt3292.test tkt3298.test tkt3334.test tkt3346.test
+ tkt3357.test tkt3419.test tkt3424.test tkt3442.test tkt3457.test
+ tkt3461.test tkt3493.test tkt3508.test tkt3522.test tkt3527.test
+ tkt3541.test tkt3554.test tkt3581.test tkt35xx.test tkt3630.test
+ tkt3718.test tkt3731.test tkt3757.test tkt3761.test tkt3762.test
+ tkt3773.test tkt3791.test tkt3793.test tkt3810.test tkt3824.test
+ tkt3832.test tkt3838.test tkt3841.test tkt-385a5b56b9.test tkt3871.test
+ tkt3879.test tkt-38cb5df375.test tkt3911.test tkt3918.test tkt3922.test
+ tkt3929.test tkt3935.test tkt3992.test tkt3997.test tkt-3998683a16.test
+ tkt-3a77c9714e.test tkt-3fe897352e.test tkt4018.test tkt-4a03edc4c8.test
+ tkt-4dd95f6943.test tkt-54844eea3f.test tkt-5d863f876e.test
+ tkt-5e10420e8d.test tkt-5ee23731f.test tkt-6bfb98dfc0.test
+ tkt-752e1646fc.test tkt-78e04e52ea.test tkt-7a31705a7e6.test
+ tkt-7bbfb7d442.test tkt-80ba201079.test tkt-80e031a00f.test
+ tkt-8454a207b9.test tkt-91e2e8ba6f.test tkt-94c04eaadb.test
+ tkt-9d68c883.test tkt-a7b7803e.test tkt-b1d3a2e531.test
+ tkt-b351d95f9.test tkt-b72787b1.test tkt-bd484a090c.test
+ tkt-bdc6bbbb38.test tkt-c48d99d690.test tkt-cbd054fa6b.test
+ tkt-d11f09d36e.test tkt-d635236375.test tkt-d82e3f3721.test
+ tkt-f3e5abed55.test tkt-f777251dc7a.test tkt-f7b4edec.test
+ tkt-f973c7ac31.test tkt-fa7bf5ec.test tkt-fc62af4523.test
+ tkt-fc7bd6358f.test trigger1.test trigger2.test trigger3.test
+ trigger4.test trigger5.test trigger6.test trigger7.test trigger8.test
+ trigger9.test triggerA.test triggerB.test triggerC.test triggerD.test
+ types2.test types3.test types.test unique.test unordered.test
+ update.test view.test vtab1.test vtab2.test vtab3.test vtab4.test
+ vtab5.test vtab6.test vtab7.test vtab8.test vtab9.test vtab_alter.test
+ vtabA.test vtabB.test vtabC.test vtabD.test vtabE.test
+ vtabF.test where2.test where3.test where4.test where5.test where6.test
+ where7.test where8m.test where8.test where9.test whereA.test whereB.test
+ whereC.test whereD.test whereE.test whereF.test wherelimit.test
+ where.test
+}
+
+test_suite "vfslog" -prefix "" -description {
+ "Vfslog" quick test suite. Like "veryquick" except does not omits
+ a few tests that do not work with a version 1 VFS. And the quota* tests,
+ which do not work with a VFS that uses the pVfs argument passed to
+ sqlite3_vfs methods.
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault* oserror.test \
+ pager1.test syscall.test sysfault.test tkt3457.test quota* superlock* \
+ wal* mmap*
+]
+
+test_suite "atomic-batch-write" -prefix "" -description {
+ Like veryquick.test, but must be run on a file-system that supports
+ atomic-batch-writes. Tests that depend on the journal file being present
+ are omitted.
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
+ *fts5corrupt* *fts5big* *fts5aj* \
+ crash8.test delete_db.test \
+ exclusive.test journal3.test \
+ journal1.test \
+ jrnlmode.test jrnlmode2.test \
+ lock4.test pager1.test \
+ pager3.test sharedA.test \
+ symlink.test stmt.test \
+ sync.test sync2.test \
+ tempdb.test tkt3457.test \
+ vacuum5.test wal2.test \
+ walmode.test zerodamage.test
+] -initialize {
+ if {[atomic_batch_write test.db]==0} {
+ error "File system does NOT support atomic-batch-write"
+ }
+}
+
+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 wal4.test wal5.test
+ wal64k.test wal6.test wal7.test wal8.test wal9.test
+ walbak.test walbig.test walblock.test walcksum.test walcrash2.test
+ walcrash3.test walcrash4.test walcrash.test walfault.test walhook.test
+ walmode.test walnoshm.test waloverwrite.test walpersist.test
+ walprotocol2.test walprotocol.test walro2.test walrofault.test
+ walro.test walshared.test walslow.test walvfs.test
+ walfault2.test
+ nockpt.test
+
+ snapshot2.test snapshot3.test snapshot4.test
+ snapshot_fault.test snapshot.test snapshot_up.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
+}
+
+test_suite "coverage-analyze" -description {
+ Coverage tests for file analyze.c.
+} -files {
+ analyze3.test analyze4.test analyze5.test analyze6.test
+ analyze7.test analyze8.test analyze9.test
+ analyze.test mallocA.test
+}
+
+test_suite "coverage-sorter" -description {
+ Coverage tests for file vdbesort.c.
+} -files {
+ sort.test sortfault.test
+}
+
+
+lappend ::testsuitelist xxx
+#-------------------------------------------------------------------------
+# Define the permutation test suites:
+#
+
+# Run some tests using pre-allocated page blocks.
+#
+# mmap1.test is excluded because a good number of its tests depend on
+# the page-cache being larger than the database. But this permutation
+# causes the effective limit on the page-cache to be just 24 pages.
+#
+test_suite "memsubsys1" -description {
+ Tests using pre-allocated page blocks
+} -files [
+ test_set $::allquicktests -exclude ioerr5.test malloc5.test mmap1.test
+] -initialize {
+ test_set_config_pagecache 4096 24
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ test_restore_config_pagecache
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_initialize
+ autoinstall_test_functions
+}
+
+# Run some tests using pre-allocated page 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 blocks
+} -files [
+ test_set $::allquicktests -exclude ioerr5.test malloc5.test
+] -initialize {
+ test_set_config_pagecache 512 5
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ test_restore_config_pagecache
+ catch {db close}
+ sqlite3_shutdown
+ 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 {
+ set ::G(perm:sqlite3_args) [list -fullmutex 0 -nomutex 1]
+} -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
+}
+
+# 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 sort4.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 {
+ set ::G(perm:sqlite3_args) [list -nomutex 0 -fullmutex 1]
+} -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
+}
+
+# Run some tests using the "onefile" demo.
+#
+test_suite "onefile" -description {
+ Run some tests using the "test_onefile.c" demo
+} -initialize {
+ set ::G(perm:sqlite3_args) [list -vfs fs]
+} -files {
+ conflict.test insert.test insert2.test insert3.test
+ rollback.test select1.test select2.test select3.test
+}
+
+# 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
+ analyze.test analyze3.test analyze4.test analyze5.test analyze6.test
+ analyze7.test analyze8.test analyze9.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
+ bestindex1.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 cffault.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 mmapfault.test sessionfault.test sessionfault2.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 shmlock.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 symlink.test
+
+ zerodamage.test
+
+ # WAL mode is different.
+ wal* tkt-2d1a5c67d.test backcompat.test e_wal* rowallock.test
+
+ # This test does not work as the "PRAGMA journal_mode = memory"
+ # statement switches the database out of wal mode at inopportune
+ # times.
+ snapshot_fault.test
+
+ # This test assumes a journal file is created on disk.
+ delete_db.test
+
+ # This test depends on a successful recovery from the pager error
+ # state. Which is not possible with an in-memory journal
+ fts5fault1.test
+
+ recoverpgsz.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 {
+ set ::G(perm:sqlite3_args) [list -vfs devsym]
+ sqlite3_simulate_device -char safe_append
+} -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 e_wal* fstat.test mmap2.test
+ pager1.test syscall.test tkt3457.test *malloc* mmap* multiplex* nolock*
+ pager2.test *fault* rowal* snapshot* superlock* symlink.test
+ delete_db.test shmlock.test chunksize.test
+ busy2.test avfs.test external_reader.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 "session" -description {
+ All session module related tests.
+} -files [glob -nocomplain $::testdir/../ext/session/*.test]
+
+test_suite "session_eec" -description {
+ All session module related tests with sqlite3_extended_result_codes() set.
+} -files [
+ glob -nocomplain $::testdir/../ext/session/*.test
+] -dbconfig {
+ sqlite3_extended_result_codes $::dbhandle 1
+}
+
+test_suite "session_strm" -description {
+ All session module related tests using the streaming APIs.
+} -files [
+ glob -nocomplain $::testdir/../ext/session/*.test
+] -dbconfig {
+ set ::sqlite3session_streams 1
+}
+
+test_suite "rbu" -description {
+ RBU tests.
+} -files [
+ test_set [glob -nocomplain $::testdir/../ext/rbu/*.test] -exclude rbu.test
+]
+
+test_suite "no_optimization" -description {
+ Run test scripts with optimizations disabled using the
+ sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) interface.
+} -files [
+ test_set \
+ [glob -nocomplain $::testdir/window*.test] \
+ 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 \
+ -exclude windowpushd.test
+] -dbconfig {
+ optimization_control $::dbhandle all 0
+}
+
+test_suite "prepare" -description {
+ Run tests with the db connection using sqlite3_prepare() instead of _v2().
+} -dbconfig {
+ $::dbhandle version -use-legacy-prepare 1
+ #$::dbhandle cache size 0
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault* \
+ stmtvtab1.test index9.test
+]
+
+test_suite "sorterref" -prefix "" -description {
+ Run the "veryquick" test suite with SQLITE_CONFIG_SORTERREF_SIZE set
+ to 0 so that sorter-references are used whenever possible.
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
+ *fts5corrupt* *fts5big* *fts5aj*
+] -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_sorterref 0
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_sorterref -1
+ sqlite3_initialize
+ autoinstall_test_functions
+}
+
+test_suite "maindbname" -prefix "" -description {
+ Run the "veryquick" test suite with SQLITE_DBCONFIG_MAINDBNAME used to
+ set the name of database 0 to "icecube".
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
+ *fts5corrupt* *fts5big* *fts5aj*
+] -dbconfig {
+ dbconfig_maindbname_icecube $::dbhandle
+}
+
+# End of tests
+#############################################################################
+
+# run_tests NAME OPTIONS
+#
+# where available options are:
+#
+# -description TITLE
+# -initialize SCRIPT
+# -shutdown SCRIPT
+# -files LIST-OF-FILES
+# -prefix NAME
+# -dbconfig SCRIPT
+#
+proc run_tests {name args} {
+ set options(-initialize) ""
+ set options(-shutdown) ""
+ set options(-prefix) ""
+ set options(-dbconfig) ""
+ set options(-presql) ""
+
+ array set options $args
+
+ set ::G(perm:name) $name
+ set ::G(perm:prefix) $options(-prefix)
+ set ::G(isquick) 1
+ set ::G(perm:dbconfig) $options(-dbconfig)
+ set ::G(perm:presql) $options(-presql)
+
+ set filelist [lsort $options(-files)]
+ if {[info exists ::env(TCLTEST_PART)]} {
+ regexp {^([0-9]*)/([0-9]*)$} $::env(TCLTEST_PART) -> A B
+ set nFile [expr {([llength $filelist]+$B-1)/$B}]
+ set filelist [lrange $filelist [expr ($A-1)*$nFile] [expr $A*$nFile-1]]
+ }
+
+ foreach file $filelist {
+ if {[file tail $file] == $file} { set file [file join $::testdir $file] }
+
+ if {[info exists ::env(SQLITE_TEST_PATTERN_LIST)]} {
+ set ok 0
+ foreach p $::env(SQLITE_TEST_PATTERN_LIST) {
+ set p [string map {% *} $p]
+ if {[string match $p [file tail $file]]} {set ok 1 ; break}
+ }
+ if {!$ok} continue
+ }
+
+ uplevel $options(-initialize)
+ slave_test_file $file
+ uplevel $options(-shutdown)
+ unset -nocomplain ::G(perm:sqlite3_args)
+ }
+
+ unset ::G(perm:name)
+ unset ::G(perm:prefix)
+ unset ::G(perm:dbconfig)
+ unset ::G(perm:presql)
+}
+
+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:"
+
+ set iPos 0
+ foreach k $::testsuitelist {
+ if {[info exists ::testspec($k)]} {
+ switch $iPos {
+ 0 {
+ puts ""
+ puts -nonewline " [format %-30s $k]"
+ }
+
+ 1 {
+ puts -nonewline [format %-30s $k]
+ }
+
+ 2 {
+ puts -nonewline $k
+ }
+ }
+
+ set iPos [expr (($iPos+1) % 3)]
+ }
+ }
+ puts ""
+ exit -1
+}
+
+if {[file tail $argv0] == "permutations.test"} {
+ proc main {argv} {
+ if {[llength $argv]==0} {
+ help
+ } else {
+
+ # See if the first argument is a named test-suite.
+ #
+ set suite [file tail [lindex $argv 0]]
+ if {[info exists ::testspec($suite)]} {
+ set S $::testspec($suite)
+ set i 1
+ } else {
+ set suite default
+ set S [list]
+ set i 0
+ }
+
+ set extra ""
+ if {$i < [llength $argv] && [string range [lindex $argv $i] 0 0]!="-" } {
+ set files [list]
+ for {} {$i < [llength $argv]} {incr i} {
+ set pattern [string map {% *} [lindex $argv $i]]
+ if {[string range $pattern 0 0]=="-"} break
+ foreach f $::alltests {
+ set tail [file tail $f]
+ if {[lsearch $files $f]<0 && [string match $pattern $tail]} {
+ lappend files $f
+ }
+ }
+ }
+ set extra [list -files $files]
+ }
+
+ eval [list run_tests $suite] $S $extra
+ }
+ }
+ main $argv
+ set argv {}
+ finish_test
+}
diff --git a/test/pg_common.tcl b/test/pg_common.tcl
new file mode 100644
index 0000000..dd16659
--- /dev/null
+++ b/test/pg_common.tcl
@@ -0,0 +1,175 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+package require sqlite3
+package require Pgtcl
+
+set db [pg_connect -conninfo "dbname=postgres user=postgres password=postgres"]
+sqlite3 sqlite ""
+
+proc execsql {sql} {
+
+ set sql [string map {{WITHOUT ROWID} {}} $sql]
+
+ set lSql [list]
+ set frag ""
+ while {[string length $sql]>0} {
+ set i [string first ";" $sql]
+ if {$i>=0} {
+ append frag [string range $sql 0 $i]
+ set sql [string range $sql $i+1 end]
+ if {[sqlite complete $frag]} {
+ lappend lSql $frag
+ set frag ""
+ }
+ } else {
+ set frag $sql
+ set sql ""
+ }
+ }
+ if {$frag != ""} {
+ lappend lSql $frag
+ }
+ #puts $lSql
+
+ set ret ""
+ set nChar 0
+ foreach stmt $lSql {
+ set res [pg_exec $::db $stmt]
+ set err [pg_result $res -error]
+ if {$err!=""} { error $err }
+
+ for {set i 0} {$i < [pg_result $res -numTuples]} {incr i} {
+ set t [pg_result $res -getTuple $i]
+ set nNew [string length $t]
+ if {$nChar>0 && ($nChar+$nNew+3)>75} {
+ append ret "\n "
+ set nChar 0
+ } else {
+ if {$nChar>0} {
+ append ret " "
+ incr nChar 3
+ }
+ }
+ incr nChar $nNew
+ append ret $t
+ }
+ pg_result $res -clear
+ }
+
+ set ret
+}
+
+proc execsql_test {tn sql} {
+ set res [execsql $sql]
+ set sql [string map {string_agg group_concat} $sql]
+ # set sql [string map [list {NULLS FIRST} {}] $sql]
+ # set sql [string map [list {NULLS LAST} {}] $sql]
+ puts $::fd "do_execsql_test $tn {"
+ puts $::fd " [string trim $sql]"
+ puts $::fd "} {$res}"
+ puts $::fd ""
+}
+
+proc errorsql_test {tn sql} {
+ set rc [catch {execsql $sql} msg]
+ if {$rc==0} {
+ error "errorsql_test SQL did not cause an error!"
+ }
+ set msg [lindex [split [string trim $msg] "\n"] 0]
+ puts $::fd "# PG says $msg"
+ set sql [string map {string_agg group_concat} $sql]
+ puts $::fd "do_test $tn { catch { execsql {"
+ puts $::fd " [string trim $sql]"
+ puts $::fd "} } } 1"
+ puts $::fd ""
+}
+
+# Same as [execsql_test], except coerce all results to floating point values
+# with two decimal points.
+#
+proc execsql_float_test {tn sql} {
+ set F "%.4f"
+ set T 0.0001
+ set res [execsql $sql]
+ set res2 [list]
+ foreach r $res {
+ if {$r != ""} { set r [format $F $r] }
+ lappend res2 $r
+ }
+
+ set sql [string trim $sql]
+puts $::fd [subst -nocommands {
+do_test $tn {
+ set myres {}
+ foreach r [db eval {$sql}] {
+ lappend myres [format $F [set r]]
+ }
+ set res2 {$res2}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-$T) || [set r]>([set r2]+$T)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+}]
+}
+
+proc start_test {name date} {
+ set dir [file dirname $::argv0]
+ set output [file join $dir $name.test]
+ set ::fd [open $output w]
+puts $::fd [string trimleft "
+# $date
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+"]
+ puts $::fd {set testdir [file dirname $argv0]}
+ puts $::fd {source $testdir/tester.tcl}
+ puts $::fd "set testprefix $name"
+ puts $::fd ""
+}
+
+proc -- {args} {
+ puts $::fd "# $args"
+}
+
+proc ========== {args} {
+ puts $::fd "#[string repeat = 74]"
+ puts $::fd ""
+}
+
+proc finish_test {} {
+ puts $::fd finish_test
+ close $::fd
+}
+
+proc ifcapable {arg} {
+ puts $::fd "ifcapable $arg { finish_test ; return }"
+}
+
diff --git a/test/pragma.test b/test/pragma.test
new file mode 100644
index 0000000..4fc9764
--- /dev/null
+++ b/test/pragma.test
@@ -0,0 +1,2006 @@
+# 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
+set testprefix pragma
+
+# 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
+# pragma-20.*: Test data_store_directory.
+# pragma-22.*: Test that "PRAGMA [db].integrity_check" respects the "db"
+# directive - if it is present.
+#
+
+ifcapable !pragma {
+ finish_test
+ return
+}
+
+# Capture the output of a pragma in a TEMP table.
+#
+proc capture_pragma {db tabname sql} {
+ $db eval "DROP TABLE IF EXISTS temp.$tabname"
+ set once 1
+ $db eval $sql x {
+ if {$once} {
+ set once 0
+ set ins "INSERT INTO $tabname VALUES"
+ set crtab "CREATE TEMP TABLE $tabname "
+ set sep "("
+ foreach col $x(*) {
+ append ins ${sep}\$x($col)
+ append crtab ${sep}\"$col\"
+ set sep ,
+ }
+ append ins )
+ append crtab )
+ $db eval $crtab
+ }
+ $db eval $ins
+ }
+}
+
+# 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]
+
+# EVIDENCE-OF: R-13861-56665 PRAGMA schema.cache_size; PRAGMA
+# schema.cache_size = pages; PRAGMA schema.cache_size = -kibibytes;
+# Query or change the suggested maximum number of database disk pages
+# that SQLite will hold in memory at once per open database file.
+#
+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 {
+ # EVIDENCE-OF: R-42059-47211 If the argument N is positive then the
+ # suggested cache size is set to N.
+ 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.1 {
+ execsql {
+ PRAGMA synchronous=EXTRA;
+ PRAGMA cache_size;
+ PRAGMA default_cache_size;
+ PRAGMA synchronous;
+ }
+} {123 123 3}
+do_test pragma-1.11.2 {
+ 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}
+do_test pragma-1.14.1 {
+ execsql {
+ PRAGMA synchronous=4;
+ PRAGMA synchronous;
+ }
+} {4}
+do_test pragma-1.14.2 {
+ execsql {
+ PRAGMA synchronous=3;
+ PRAGMA synchronous;
+ }
+} {3}
+do_test pragma-1.14.3 {
+ execsql {
+ PRAGMA synchronous=8;
+ PRAGMA synchronous;
+ }
+} {0}
+do_test pragma-1.14.4 {
+ execsql {
+ PRAGMA synchronous=10;
+ PRAGMA synchronous;
+ }
+} {2}
+
+do_execsql_test 1.15.1 {
+ PRAGMA default_cache_size = 0;
+}
+do_execsql_test 1.15.2 {
+ PRAGMA default_cache_size;
+} $DFLT_CACHE_SZ
+do_execsql_test 1.15.3 {
+ PRAGMA default_cache_size = -500;
+}
+do_execsql_test 1.15.4 {
+ PRAGMA default_cache_size;
+} 500
+do_execsql_test 1.15.3 {
+ PRAGMA default_cache_size = 500;
+}
+do_execsql_test 1.15.4 {
+ PRAGMA default_cache_size;
+} 500
+db close
+hexio_write test.db 48 FFFFFF00
+sqlite3 db test.db
+do_execsql_test 1.15.4 {
+ PRAGMA default_cache_size;
+} 256
+} ;# 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}
+ } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}
+ do_test pragma-3.3 {
+ execsql {PRAGMA integrity_check=1}
+ } {{row 1 missing from index i2}}
+ do_test pragma-3.4 {
+ execsql {
+ ATTACH DATABASE 'test.db' AS t2;
+ PRAGMA integrity_check
+ }
+ } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}
+ do_test pragma-3.5 {
+ execsql {
+ PRAGMA integrity_check=4
+ }
+ } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2}}
+ do_catchsql_test pragma-3.6 {
+ PRAGMA integrity_check=xyz
+ } {1 {no such table: xyz}}
+ do_catchsql_test pragma-3.6b {
+ PRAGMA integrity_check=t2
+ } {0 {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}}
+ do_catchsql_test pragma-3.6c {
+ PRAGMA integrity_check=sqlite_schema
+ } {0 ok}
+ do_test pragma-3.7 {
+ execsql {
+ PRAGMA integrity_check=0
+ }
+ } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 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.9a {
+ 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} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}
+ do_execsql_test pragma-3.9b {
+ PRAGMA t2.integrity_check=t2;
+ } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}
+ do_execsql_test pragma-3.9c {
+ PRAGMA t2.integrity_check=sqlite_schema;
+ } {ok}
+ 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} {row 1 missing from index i2} {row 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} {row 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} {row 1 missing from index i2} {row 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} {row 1 missing from index i2} {row 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} {row 1 missing from index i2} {row 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} {row 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} {row 1 missing from index i2} {row 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} {row 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}
+}
+
+# Verify that PRAGMA integrity_check catches UNIQUE and NOT NULL
+# constraint violations.
+#
+ifcapable altertable {
+ sqlite3_db_config db DEFENSIVE 0
+ do_execsql_test pragma-3.20 {
+ CREATE TABLE t1(a,b);
+ CREATE INDEX t1a ON t1(a);
+ INSERT INTO t1 VALUES(1,1),(2,2),(3,3),(2,4),(NULL,5),(NULL,6);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_master SET sql='CREATE UNIQUE INDEX t1a ON t1(a)'
+ WHERE name='t1a';
+ UPDATE sqlite_master SET sql='CREATE TABLE t1(a NOT NULL,b)'
+ WHERE name='t1';
+ PRAGMA writable_schema=OFF;
+ ALTER TABLE t1 RENAME TO t1x;
+ PRAGMA integrity_check;
+ } {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in index t1a} {NULL value in t1x.a}}
+ do_execsql_test pragma-3.21 {
+ PRAGMA integrity_check(3);
+ } {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in index t1a}}
+ do_execsql_test pragma-3.22 {
+ PRAGMA integrity_check(2);
+ } {{non-unique entry in index t1a} {NULL value in t1x.a}}
+ do_execsql_test pragma-3.23 {
+ PRAGMA integrity_check(1);
+ } {{non-unique entry in index t1a}}
+}
+
+# PRAGMA integrity check (or more specifically the sqlite3BtreeCount()
+# interface) used to leave index cursors in an inconsistent state
+# which could result in an assertion fault in sqlite3BtreeKey()
+# called from saveCursorPosition() if content is removed from the
+# index while the integrity_check is still running. This test verifies
+# that problem has been fixed.
+#
+do_test pragma-3.30 {
+ catch { db close }
+ delete_file test.db
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(a,b,c);
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)
+ INSERT INTO t1(a,b,c) SELECT i, printf('xyz%08x',i), 2000-i FROM c;
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1bc ON t1(b,c);
+ }
+ db eval {PRAGMA integrity_check} {
+ db eval {DELETE FROM t1}
+ }
+} {}
+
+# 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 TYPE_X, b [TYPE_Y], c "TYPE_Z");
+ pragma table_info(t2)
+ }
+} {0 a TYPE_X 0 {} 0 1 b TYPE_Y 0 {} 0 2 c TYPE_Z 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 '',
+ UNIQUE(b,c,d),
+ PRIMARY KEY(e,b,c)
+ );
+ PRAGMA table_info(t5);
+ }
+} {0 a TEXT 0 CURRENT_TIMESTAMP 0 1 b {} 0 5+3 2 2 c TEXT 0 <<NULL>> 3 3 d INTEGER 0 NULL 0 4 e TEXT 0 '' 1}
+db nullvalue {}
+do_test pragma-6.2.3 {
+ execsql {
+ CREATE TABLE t2_3(a,b INTEGER PRIMARY KEY,c);
+ pragma table_info(t2_3)
+ }
+} {0 a {} 0 {} 0 1 b INTEGER 0 {} 1 2 c {} 0 {} 0}
+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 {
+ capture_pragma db out {
+ pragma index_list(t3);
+ }
+ db eval {SELECT seq, "name", "unique" FROM out ORDER BY seq}
+ } {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);
+ }
+ capture_pragma db out {
+ pragma index_info(t3i1);
+ }
+ db eval {SELECT seqno, cid, name FROM out ORDER BY seqno}
+} {0 0 a 1 1 b}
+
+# EVIDENCE-OF: R-23114-21695 The auxiliary index-columns are not shown
+# by the index_info pragma, but they are listed by the index_xinfo
+# pragma.
+#
+do_test pragma-6.5.1b {
+ capture_pragma db out {PRAGMA index_xinfo(t3i1)}
+ db eval {SELECT seqno, cid, name FROM out ORDER BY seqno}
+} {0 0 a 1 1 b 2 -1 {}}
+
+
+# EVIDENCE-OF: R-29448-60346 PRAGMA schema.index_info(index-name); This
+# pragma returns one row for each key column in the named index.
+#
+# (The first column of output from PRAGMA index_info is...)
+# EVIDENCE-OF: R-34186-52914 The rank of the column within the index. (0
+# means left-most.)
+#
+# (The second column of output from PRAGMA index_info is...)
+# EVIDENCE-OF: R-65019-08383 The rank of the column within the table
+# being indexed.
+#
+# (The third column of output from PRAGMA index_info is...)
+# EVIDENCE-OF: R-09773-34266 The name of the column being indexed.
+#
+do_execsql_test pragma-6.5.1c {
+ CREATE INDEX t3i2 ON t3(b,a);
+ PRAGMA index_info='t3i2';
+ DROP INDEX t3i2;
+} {0 1 b 1 0 a}
+
+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
+ );
+ }
+ capture_pragma db out {PRAGMA table_info(test_table)}
+ db eval {SELECT cid, "name", type, "notnull", dflt_value, pk FROM out
+ ORDER BY cid}
+} [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} \
+]
+do_test pragma-6.8 {
+ execsql {
+ CREATE TABLE t68(a,b,c,PRIMARY KEY(a,b,a,c));
+ PRAGMA table_info(t68);
+ }
+} [concat \
+ {0 a {} 0 {} 1} \
+ {1 b {} 0 {} 2} \
+ {2 c {} 0 {} 4} \
+]
+} ;# ifcapable schema_pragmas
+# Miscellaneous tests
+#
+ifcapable schema_pragmas {
+# EVIDENCE-OF: R-64103-17776 PRAGMA schema.index_list(table-name); This
+# pragma returns one row for each index associated with the given table.
+#
+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
+ capture_pragma db out "PRAGMA index_list(t3)"
+ db eval {SELECT name, "origin" FROM out ORDER BY name DESC}
+} {t3i1 c sqlite_autoindex_t3_1 u}
+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}
+sqlite3_db_config db DEFENSIVE 1
+do_execsql_test pragma-8.1.3 {
+ PRAGMA schema_version = 106;
+ PRAGMA schema_version;
+} 105
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test pragma-8.1.4 {
+ PRAGMA schema_version = 106;
+ 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 {
+ PRAGMA temp.cache_size = 1;
+ CREATE TEMP TABLE IF NOT EXISTS a(b);
+ DELETE FROM a;
+ INSERT INTO a VALUES(randomblob(1000));
+ INSERT INTO a SELECT * FROM a;
+ INSERT INTO a SELECT * FROM a;
+ INSERT INTO a SELECT * FROM a;
+ INSERT INTO a SELECT * FROM a;
+ INSERT INTO a SELECT * FROM a;
+ INSERT INTO a SELECT * FROM a;
+ INSERT INTO a SELECT * FROM a;
+ INSERT INTO a SELECT * FROM a;
+ }
+ 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"
+}
+
+# Application_ID
+#
+do_test pragma-8.3.1 {
+ execsql {
+ PRAGMA application_id;
+ }
+} {0}
+do_test pragma-8.3.2 {
+ execsql {PRAGMA Application_ID(12345); PRAGMA application_id;}
+} {12345}
+
+# 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 [get_pwd]]]
+ execsql "
+ PRAGMA temp_store_directory='$pwd';
+ "
+ } {}
+ do_test pragma-9.6 {
+ execsql {
+ PRAGMA temp_store_directory;
+ }
+ } [list [file nativename [get_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 RTRIM seq 1 name NOCASE seq 2 name BINARY}
+ do_test pragma-11.2 {
+ db collate New_Collation blah...
+ execsql {
+ pragma collation_list;
+ }
+ } {0 New_Collation 1 RTRIM 2 NOCASE 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
+
+ # EVIDENCE-OF: R-15672-33611 PRAGMA schema.page_count; Return the total
+ # number of pages in the database file.
+ #
+ do_test pragma-14.1 {
+ execsql { pragma auto_vacuum = 0 }
+ execsql { pragma page_count; pragma main.page_count }
+ } {0 0}
+
+ do_test pragma-14.2 {
+ execsql {
+ CREATE TABLE abc(a, b, c);
+ PRAGMA page_count;
+ PRAGMA main.page_count;
+ PRAGMA temp.page_count;
+ }
+ } {2 2 0}
+ 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
+}
+
+# The SQLITE_FCNTL_PRAGMA logic, with error handling.
+#
+db close
+testvfs tvfs
+sqlite3 db test.db -vfs tvfs
+do_test pragma-19.1 {
+ catchsql {PRAGMA error}
+} {1 {SQL logic error}}
+do_test pragma-19.2 {
+ catchsql {PRAGMA error='This is the error message'}
+} {1 {This is the error message}}
+do_test pragma-19.3 {
+ catchsql {PRAGMA error='7 This is the error message'}
+} {1 {This is the error message}}
+do_test pragma-19.4 {
+ catchsql {PRAGMA error=7}
+} {1 {out of memory}}
+do_test pragma-19.5 {
+ file tail [lindex [execsql {PRAGMA filename}] 0]
+} {test.db}
+
+if {$tcl_platform(platform)=="windows"} {
+# Test data_store_directory pragma
+#
+db close
+sqlite3 db test.db
+file mkdir data_dir
+do_test pragma-20.1 {
+ catchsql {PRAGMA data_store_directory}
+} {0 {}}
+do_test pragma-20.2 {
+ set pwd [string map {' ''} [file nativename [get_pwd]]]
+ catchsql "PRAGMA data_store_directory='$pwd';"
+} {0 {}}
+do_test pragma-20.3 {
+ catchsql {PRAGMA data_store_directory}
+} [list 0 [list [file nativename [get_pwd]]]]
+do_test pragma-20.4 {
+ set pwd [string map {' ''} [file nativename \
+ [file join [get_pwd] data_dir]]]
+ catchsql "PRAGMA data_store_directory='$pwd';"
+} {0 {}}
+do_test pragma-20.5 {
+ sqlite3 db2 test2.db
+ catchsql "PRAGMA database_list;" db2
+} [list 0 [list 0 main [file nativename \
+ [file join [get_pwd] data_dir test2.db]]]]
+catch {db2 close}
+do_test pragma-20.6 {
+ sqlite3 db2 [file join [get_pwd] test2.db]
+ catchsql "PRAGMA database_list;" db2
+} [list 0 [list 0 main [file nativename \
+ [file join [get_pwd] test2.db]]]]
+catch {db2 close}
+do_test pragma-20.7 {
+ catchsql "PRAGMA data_store_directory='';"
+} {0 {}}
+do_test pragma-20.8 {
+ catchsql {PRAGMA data_store_directory}
+} {0 {}}
+
+forcedelete data_dir
+} ;# endif windows
+
+database_may_be_corrupt
+if {![nonzero_reserved_bytes]} {
+
+ do_test 21.1 {
+ # Create a corrupt database in testerr.db. And a non-corrupt at test.db.
+ #
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 1);
+ }
+ for {set i 0} {$i < 10} {incr i} {
+ execsql { INSERT INTO t1 SELECT a + (1 << $i), b + (1 << $i) FROM t1 }
+ }
+ db close
+ forcecopy test.db testerr.db
+ hexio_write testerr.db 15000 [string repeat 55 100]
+ } {100}
+
+ set mainerr {*** in database main ***
+Multiple uses for byte 672 of page 15}
+ set auxerr {*** in database aux ***
+Multiple uses for byte 672 of page 15}
+
+ set mainerr {/{\*\*\* in database main \*\*\*
+Multiple uses for byte 672 of page 15}.*/}
+ set auxerr {/{\*\*\* in database aux \*\*\*
+Multiple uses for byte 672 of page 15}.*/}
+
+ do_test 22.2 {
+ catch { db close }
+ sqlite3 db testerr.db
+ execsql { PRAGMA integrity_check }
+ } $mainerr
+
+ do_test 22.3.1 {
+ catch { db close }
+ sqlite3 db test.db
+ execsql {
+ ATTACH 'testerr.db' AS 'aux';
+ PRAGMA integrity_check;
+ }
+ } $auxerr
+ do_test 22.3.2 {
+ execsql { PRAGMA main.integrity_check; }
+ } {ok}
+ do_test 22.3.3 {
+ execsql { PRAGMA aux.integrity_check; }
+ } $auxerr
+
+ do_test 22.4.1 {
+ catch { db close }
+ sqlite3 db testerr.db
+ execsql {
+ ATTACH 'test.db' AS 'aux';
+ PRAGMA integrity_check;
+ }
+ } $mainerr
+ do_test 22.4.2 {
+ execsql { PRAGMA main.integrity_check; }
+ } $mainerr
+ do_test 22.4.3 {
+ execsql { PRAGMA aux.integrity_check; }
+ } {ok}
+}
+
+db close
+forcedelete test.db test.db-wal test.db-journal
+sqlite3 db test.db
+sqlite3 db2 test.db
+do_test 23.1 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);
+ CREATE INDEX i1 ON t1(b,c);
+ CREATE INDEX i2 ON t1(c,d);
+ CREATE INDEX i2x ON t1(d COLLATE nocase, c DESC);
+ CREATE INDEX i3 ON t1(d,b+c,c);
+ CREATE TABLE t2(x INTEGER REFERENCES t1);
+ }
+ db2 eval {SELECT name FROM sqlite_master}
+} {t1 i1 i2 i2x i3 t2}
+do_test 23.2a {
+ db eval {
+ DROP INDEX i2;
+ CREATE INDEX i2 ON t1(c,d,b);
+ }
+ capture_pragma db2 out {PRAGMA index_info(i2)}
+ db2 eval {SELECT cid, name, '|' FROM out ORDER BY seqno}
+} {2 c | 3 d | 1 b |}
+
+# EVIDENCE-OF: R-56143-29319 PRAGMA schema.index_xinfo(index-name); This
+# pragma returns information about every column in an index.
+#
+# EVIDENCE-OF: R-45970-35618 Unlike this index_info pragma, this pragma
+# returns information about every column in the index, not just the key
+# columns.
+#
+do_test 23.2b {
+ capture_pragma db2 out {PRAGMA index_xinfo(i2)}
+ db2 eval {SELECT cid, name, "desc", coll, "key", '|' FROM out ORDER BY seqno}
+} {2 c 0 BINARY 1 | 3 d 0 BINARY 1 | 1 b 0 BINARY 1 | -1 {} 0 BINARY 0 |}
+
+# (The first column of output from PRAGMA index_xinfo is...)
+# EVIDENCE-OF: R-00197-14279 The rank of the column within the index. (0
+# means left-most. Key columns come before auxiliary columns.)
+#
+# (The second column of output from PRAGMA index_xinfo is...)
+# EVIDENCE-OF: R-06603-49335 The rank of the column within the table
+# being indexed, or -1 if the index-column is the rowid of the table
+# being indexed and -2 if the index is on an expression.
+#
+# (The third column of output from PRAGMA index_xinfo is...)
+# EVIDENCE-OF: R-40641-22898 The name of the column being indexed, or
+# NULL if the index-column is the rowid of the table being indexed or an
+# expression.
+#
+# (The fourth column of output from PRAGMA index_xinfo is...)
+# EVIDENCE-OF: R-11847-09179 1 if the index-column is sorted in reverse
+# (DESC) order by the index and 0 otherwise.
+#
+# (The fifth column of output from PRAGMA index_xinfo is...)
+# EVIDENCE-OF: R-15313-19540 The name for the collating sequence used to
+# compare values in the index-column.
+#
+# (The sixth column of output from PRAGMA index_xinfo is...)
+# EVIDENCE-OF: R-14310-64553 1 if the index-column is a key column and 0
+# if the index-column is an auxiliary column.
+#
+do_test 23.2c {
+ db2 eval {PRAGMA index_xinfo(i2)}
+} {0 2 c 0 BINARY 1 1 3 d 0 BINARY 1 2 1 b 0 BINARY 1 3 -1 {} 0 BINARY 0}
+do_test 23.2d {
+ db2 eval {PRAGMA index_xinfo(i2x)}
+} {0 3 d 0 nocase 1 1 2 c 1 BINARY 1 2 -1 {} 0 BINARY 0}
+do_test 23.2e {
+ db2 eval {PRAGMA index_xinfo(i3)}
+} {0 3 d 0 BINARY 1 1 -2 {} 0 BINARY 1 2 2 c 0 BINARY 1 3 -1 {} 0 BINARY 0}
+
+# EVIDENCE-OF: R-64103-17776 PRAGMA schema.index_list(table-name); This
+# pragma returns one row for each index associated with the given table.
+#
+# (The first column of output from PRAGMA index_list is...)
+# EVIDENCE-OF: R-02753-24748 A sequence number assigned to each index
+# for internal tracking purposes.
+#
+# (The second column of output from PRAGMA index_list is...)
+# EVIDENCE-OF: R-35496-03635 The name of the index.
+#
+# (The third column of output from PRAGMA index_list is...)
+# EVIDENCE-OF: R-57301-64506 "1" if the index is UNIQUE and "0" if not.
+#
+# (The fourth column of output from PRAGMA index_list is...)
+# EVIDENCE-OF: R-36609-39554 "c" if the index was created by a CREATE
+# INDEX statement, "u" if the index was created by a UNIQUE constraint,
+# or "pk" if the index was created by a PRIMARY KEY constraint.
+#
+do_test 23.3 {
+ db eval {
+ DROP INDEX IF EXISTS i3;
+ CREATE INDEX i3 ON t1(d,b,c);
+ }
+ capture_pragma db2 out {PRAGMA index_list(t1)}
+ db2 eval {SELECT seq, name, "unique", origin, '|' FROM out ORDER BY seq}
+} {0 i3 0 c | 1 i2 0 c | 2 i2x 0 c | 3 i1 0 c |}
+ifcapable altertable {
+ do_test 23.4 {
+ db eval {
+ ALTER TABLE t1 ADD COLUMN e;
+ }
+ db2 eval {
+ PRAGMA table_info(t1);
+ }
+ } {/4 e {} 0 {} 0/}
+}
+do_test 23.5 {
+ db eval {
+ DROP TABLE t2;
+ CREATE TABLE t2(x, y INTEGER REFERENCES t1);
+ }
+ db2 eval {
+ PRAGMA foreign_key_list(t2);
+ }
+} {0 0 t1 y {} {NO ACTION} {NO ACTION} NONE}
+db2 close
+
+ifcapable !has_codec {
+ reset_db
+ do_execsql_test 24.0 {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(b);
+ INSERT INTO t1 VALUES('a', 'b', 'c');
+ PRAGMA integrity_check;
+ } {ok}
+
+ set r [db one {SELECT rootpage FROM sqlite_master WHERE name = 't1'}]
+ db close
+ hexio_write test.db [expr $r*1024 - 16] 000000000000000701040f0f1f616263
+
+ sqlite3 db test.db
+ do_catchsql_test 24.1 {
+ SELECT * FROM t1;
+ } {1 {database disk image is malformed}}
+ do_catchsql_test 24.2 {
+ PRAGMA integrity_check;
+ } {0 {{database disk image is malformed}}}
+}
+database_never_corrupt
+finish_test
diff --git a/test/pragma2.test b/test/pragma2.test
new file mode 100644
index 0000000..5896e52
--- /dev/null
+++ b/test/pragma2.test
@@ -0,0 +1,275 @@
+# 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.
+# pragma2-4.*: Tests for PRAGMA cache_spill
+#
+
+ifcapable !pragma||!schema_pragmas {
+ finish_test
+ return
+}
+
+test_set_config_pagecache 0 0
+
+# 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}
+
+
+# EVIDENCE-OF: R-11211-21323 PRAGMA schema.freelist_count; Return the
+# number of unused pages in the database file.
+#
+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}
+}
+
+# Default setting of PRAGMA cache_spill is always ON
+#
+# EVIDENCE-OF: R-63549-59887 PRAGMA cache_spill; PRAGMA
+# cache_spill=boolean; PRAGMA schema.cache_spill=N;
+#
+# EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default
+#
+db close
+delete_file test.db test.db-journal
+delete_file test2.db test2.db-journal
+sqlite3 db test.db
+do_execsql_test pragma2-4.1 {
+ PRAGMA main.cache_size=2000;
+ PRAGMA temp.cache_size=2000;
+ PRAGMA cache_spill;
+ PRAGMA main.cache_spill;
+ PRAGMA temp.cache_spill;
+} {2000 2000 2000}
+do_execsql_test pragma2-4.2 {
+ PRAGMA cache_spill=OFF;
+ PRAGMA cache_spill;
+ PRAGMA main.cache_spill;
+ PRAGMA temp.cache_spill;
+} {0 0 0}
+do_execsql_test pragma2-4.3 {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=50;
+ BEGIN;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);
+ INSERT INTO t1 VALUES(1, randomblob(400), 1, randomblob(400));
+ INSERT INTO t1 SELECT a+1, randomblob(400), a+1, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+2, randomblob(400), a+2, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+4, randomblob(400), a+4, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+8, randomblob(400), a+8, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+16, randomblob(400), a+16, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+32, randomblob(400), a+32, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+64, randomblob(400), a+64, randomblob(400) FROM t1;
+ COMMIT;
+ ATTACH 'test2.db' AS aux1;
+ CREATE TABLE aux1.t2(a INTEGER PRIMARY KEY, b, c, d);
+ INSERT INTO t2 SELECT * FROM t1;
+ DETACH aux1;
+ PRAGMA cache_spill=ON;
+} {}
+sqlite3_release_memory
+#
+# EVIDENCE-OF: R-07634-40532 The cache_spill pragma enables or disables
+# the ability of the pager to spill dirty cache pages to the database
+# file in the middle of a transaction.
+#
+do_test pragma2-4.4 {
+ db eval {
+ BEGIN;
+ UPDATE t1 SET c=c+1;
+ PRAGMA lock_status;
+ }
+} {main exclusive temp unknown} ;# EXCLUSIVE lock due to cache spill
+do_test pragma2-4.5.1 {
+ db eval {
+ ROLLBACK;
+ PRAGMA cache_spill=OFF;
+ PRAGMA Cache_Spill;
+ BEGIN;
+ UPDATE t1 SET c=c+1;
+ PRAGMA lock_status;
+ }
+} {0 main reserved temp unknown} ;# No cache spill, so no exclusive lock
+
+
+# EVIDENCE-OF: R-34657-61226 The "PRAGMA cache_spill=N" form of this
+# pragma sets a minimum cache size threshold required for spilling to
+# occur.
+do_test pragma2-4.5.2 {
+ db eval {
+ ROLLBACK;
+ PRAGMA cache_spill=100000;
+ PRAGMA cache_spill;
+ BEGIN;
+ UPDATE t1 SET c=c+1;
+ PRAGMA lock_status;
+ }
+} {100000 main reserved temp unknown} ;# Big spill threshold -> no excl lock
+ifcapable !memorymanage {
+ do_test pragma2-4.5.3 {
+ db eval {
+ ROLLBACK;
+ PRAGMA cache_spill=25;
+ PRAGMA main.cache_spill;
+ BEGIN;
+ UPDATE t1 SET c=c+1;
+ PRAGMA lock_status;
+ }
+ } {50 main exclusive temp unknown} ;# Small cache spill -> exclusive lock
+ do_test pragma2-4.5.4 {
+ db eval {
+ ROLLBACK;
+ PRAGMA cache_spill(-25);
+ PRAGMA main.cache_spill;
+ BEGIN;
+ UPDATE t1 SET c=c+1;
+ PRAGMA lock_status;
+ }
+ } {50 main exclusive temp unknown} ;# Small cache spill -> exclusive lock
+}
+
+
+# Verify that newly attached databases inherit the cache_spill=OFF
+# setting.
+#
+do_execsql_test pragma2-4.6 {
+ ROLLBACK;
+ PRAGMA cache_spill=OFF;
+ ATTACH 'test2.db' AS aux1;
+ PRAGMA aux1.cache_size=50;
+ BEGIN;
+ UPDATE t2 SET c=c+1;
+ PRAGMA lock_status;
+} {main unlocked temp unknown aux1 reserved}
+do_execsql_test pragma2-4.7 {
+ COMMIT;
+}
+sqlite3_release_memory
+do_execsql_test pragma2-4.8 {
+ PRAGMA cache_spill=ON; -- Applies to all databases
+ BEGIN;
+ UPDATE t2 SET c=c-1;
+ PRAGMA lock_status;
+} {main unlocked temp unknown aux1 exclusive}
+db close
+forcedelete test.db
+sqlite3 db test.db
+
+do_execsql_test pragma2-5.1 {
+ PRAGMA page_size=16384;
+ CREATE TABLE t1(x);
+ PRAGMA cache_size=2;
+ PRAGMA cache_spill=YES;
+ PRAGMA cache_spill;
+} {2}
+do_execsql_test pragma2-5.2 {
+ PRAGMA cache_spill=NO;
+ PRAGMA cache_spill;
+} {0}
+do_execsql_test pragma2-5.3 {
+ PRAGMA cache_spill(-51);
+ PRAGMA cache_spill;
+} {3}
+
+test_restore_config_pagecache
+finish_test
diff --git a/test/pragma3.test b/test/pragma3.test
new file mode 100644
index 0000000..c4794c7
--- /dev/null
+++ b/test/pragma3.test
@@ -0,0 +1,287 @@
+# 2014-12-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 PRAGMA data_version command.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {[sqlite3 -has-codec]} {
+ finish_test
+ return
+}
+
+do_execsql_test pragma3-100 {
+ PRAGMA data_version;
+} {1}
+do_execsql_test pragma3-101 {
+ PRAGMA temp.data_version;
+} {1}
+
+# Writing to the pragma is a no-op
+do_execsql_test pragma3-102 {
+ PRAGMA main.data_version=1234;
+ PRAGMA main.data_version;
+} {1 1}
+
+# EVIDENCE-OF: R-27726-60934 The "PRAGMA data_version" command provides
+# an indication that the database file has been modified.
+#
+# EVIDENCE-OF: R-47505-58569 The "PRAGMA data_version" value is
+# unchanged for commits made on the same database connection.
+#
+do_execsql_test pragma3-110 {
+ PRAGMA data_version;
+ BEGIN IMMEDIATE;
+ PRAGMA data_version;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(100),(200),(300);
+ PRAGMA data_version;
+ COMMIT;
+ SELECT * FROM t1;
+ PRAGMA data_version;
+} {1 1 1 100 200 300 1}
+
+sqlite3 db2 test.db
+do_test pragma3-120 {
+ db2 eval {
+ SELECT * FROM t1;
+ PRAGMA data_version;
+ }
+} {100 200 300 1}
+
+do_execsql_test pragma3-130 {
+ PRAGMA data_version;
+ BEGIN IMMEDIATE;
+ PRAGMA data_version;
+ INSERT INTO t1 VALUES(400),(500);
+ PRAGMA data_version;
+ COMMIT;
+ SELECT * FROM t1;
+ PRAGMA data_version;
+ PRAGMA shrink_memory;
+} {1 1 1 100 200 300 400 500 1}
+
+# EVIDENCE-OF: R-63005-41812 The integer values returned by two
+# invocations of "PRAGMA data_version" from the same connection will be
+# different if changes were committed to the database by any other
+# connection in the interim.
+#
+# Value went from 1 in pragma3-120 to 2 here.
+#
+do_test pragma3-140 {
+ db2 eval {
+ SELECT * FROM t1;
+ PRAGMA data_version;
+ BEGIN IMMEDIATE;
+ PRAGMA data_version;
+ UPDATE t1 SET a=a+1;
+ COMMIT;
+ SELECT * FROM t1;
+ PRAGMA data_version;
+ }
+} {100 200 300 400 500 2 2 101 201 301 401 501 2}
+do_execsql_test pragma3-150 {
+ SELECT * FROM t1;
+ PRAGMA data_version;
+} {101 201 301 401 501 2}
+
+#
+do_test pragma3-160 {
+ db eval {
+ BEGIN;
+ PRAGMA data_version;
+ UPDATE t1 SET a=555 WHERE a=501;
+ PRAGMA data_version;
+ SELECT * FROM t1 ORDER BY a;
+ PRAGMA data_version;
+ }
+} {2 2 101 201 301 401 555 2}
+do_test pragma3-170 {
+ db2 eval {
+ PRAGMA data_version;
+ }
+} {2}
+do_test pragma3-180 {
+ db eval {
+ COMMIT;
+ PRAGMA data_version;
+ }
+} {2}
+do_test pragma3-190 {
+ db2 eval {
+ PRAGMA data_version;
+ }
+} {3}
+
+# EVIDENCE-OF: R-19326-44825 The "PRAGMA data_version" value is a local
+# property of each database connection and so values returned by two
+# concurrent invocations of "PRAGMA data_version" on separate database
+# connections are often different even though the underlying database is
+# identical.
+#
+do_test pragma3-195 {
+ expr {[db eval {PRAGMA data_version}]!=[db2 eval {PRAGMA data_version}]}
+} {1}
+
+# EVIDENCE-OF: R-54562-06892 The behavior of "PRAGMA data_version" is
+# the same for all database connections, including database connections
+# in separate processes and shared cache database connections.
+#
+# The next block checks the behavior for separate processes.
+#
+do_test pragma3-200 {
+ db eval {PRAGMA data_version; SELECT * FROM t1;}
+} {2 101 201 301 401 555}
+do_test pragma3-201 {
+ set fd [open pragma3.txt wb]
+ puts $fd {
+ sqlite3 db test.db;
+ db eval {DELETE FROM t1 WHERE a>300};
+ db close;
+ exit;
+ }
+ close $fd
+ exec [info nameofexec] pragma3.txt
+ forcedelete pragma3.txt
+ db eval {
+ PRAGMA data_version;
+ SELECT * FROM t1;
+ }
+} {3 101 201}
+db2 close
+db close
+
+# EVIDENCE-OF: R-54562-06892 The behavior of "PRAGMA data_version" is
+# the same for all database connections, including database connections
+# in separate processes and shared cache database connections.
+#
+# The next block checks that behavior is the same for shared-cache.
+#
+ifcapable shared_cache {
+ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ do_test pragma3-300 {
+ db eval {
+ PRAGMA data_version;
+ BEGIN;
+ CREATE TABLE t3(a,b,c);
+ CREATE TABLE t4(x,y,z);
+ INSERT INTO t4 VALUES(123,456,789);
+ PRAGMA data_version;
+ COMMIT;
+ PRAGMA data_version;
+ }
+ } {1 1 1}
+ do_test pragma3-310 {
+ db2 eval {
+ PRAGMA data_version;
+ BEGIN;
+ INSERT INTO t3(a,b,c) VALUES('abc','def','ghi');
+ SELECT * FROM t3;
+ PRAGMA data_version;
+ }
+ } {2 abc def ghi 2}
+ # The transaction in db2 has not yet committed, so the data_version in
+ # db is unchanged.
+ do_test pragma3-320 {
+ db eval {
+ PRAGMA data_version;
+ SELECT * FROM t4;
+ }
+ } {1 123 456 789}
+ do_test pragma3-330 {
+ db2 eval {
+ COMMIT;
+ PRAGMA data_version;
+ SELECT * FROM t4;
+ }
+ } {2 123 456 789}
+ do_test pragma3-340 {
+ db eval {
+ PRAGMA data_version;
+ SELECT * FROM t3;
+ SELECT * FROM t4;
+ }
+ } {2 abc def ghi 123 456 789}
+ db2 close
+ db close
+ sqlite3_enable_shared_cache $::enable_shared_cache
+}
+
+# Make sure this also works in WAL mode
+#
+# This will not work with the in-memory journal permutation, as opening
+# [db2] switches the journal mode back to "memory"
+#
+if {[wal_is_capable]} {
+if {[permutation]!="inmemory_journal"} {
+
+ sqlite3 db test.db
+ db eval {PRAGMA journal_mode=WAL}
+ sqlite3 db2 test.db
+ do_test pragma3-400 {
+ db eval {
+ PRAGMA data_version;
+ PRAGMA journal_mode;
+ SELECT * FROM t1;
+ }
+ } {2 wal 101 201}
+ do_test pragma3-410 {
+ db2 eval {
+ PRAGMA data_version;
+ PRAGMA journal_mode;
+ SELECT * FROM t1;
+ }
+ } {2 wal 101 201}
+ do_test pragma3-420 {
+ db eval {UPDATE t1 SET a=111*(a/100); PRAGMA data_version; SELECT * FROM t1}
+ } {2 111 222}
+ do_test pragma3-430 {
+ db2 eval {PRAGMA data_version; SELECT * FROM t1;}
+ } {3 111 222}
+ db2 close
+}
+}
+
+#-------------------------------------------------------------------------
+# Check that empty write transactions do not cause the return of "PRAGMA
+# data_version" to be decremented with journal_mode=PERSIST and
+# locking_mode=EXCLUSIVE
+#
+foreach {tn sql} {
+ A {
+ }
+ B {
+ PRAGMA journal_mode = PERSIST;
+ PRAGMA locking_mode = EXCLUSIVE;
+ }
+} {
+ reset_db
+ execsql $sql
+
+ do_execsql_test pragma3-510$tn {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA data_version;
+ } {1}
+
+ do_execsql_test pragma3-520$tn {
+ BEGIN EXCLUSIVE;
+ COMMIT;
+ PRAGMA data_version;
+ } {1}
+}
+
+finish_test
diff --git a/test/pragma4.test b/test/pragma4.test
new file mode 100644
index 0000000..b82df81
--- /dev/null
+++ b/test/pragma4.test
@@ -0,0 +1,268 @@
+# 2017 Jan 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix pragma4
+
+proc do_pragma_ncol_test {tn sql nCol} {
+ set ::stmt 0
+ set ::stmt [sqlite3_prepare_v2 db $sql -1 dummy]
+ uplevel [list do_test $tn { sqlite3_column_count $::stmt } $nCol]
+ sqlite3_finalize $::stmt
+}
+
+# If there is no RHS argument, the following PRAGMA statements operate as
+# queries, returning a single row containing a single column.
+#
+# Or, if there is RHS argument, they return zero rows of zero columns.
+#
+foreach {tn sql} {
+ 1 "PRAGMA application_id = 10"
+ 2 "PRAGMA automatic_index = 1"
+ 3 "PRAGMA auto_vacuum = 1"
+ 4 "PRAGMA cache_size = -100"
+ 5 "PRAGMA cache_spill = 1"
+ 6 "PRAGMA cell_size_check = 1"
+ 7 "PRAGMA checkpoint_fullfsync = 1"
+ 8 "PRAGMA count_changes = 1"
+ 9 "PRAGMA default_cache_size = 100"
+ 10 "PRAGMA defer_foreign_keys = 1"
+ 11 "PRAGMA empty_result_callbacks = 1"
+ 12 "PRAGMA encoding = 'utf-8'"
+ 13 "PRAGMA foreign_keys = 1"
+ 14 "PRAGMA full_column_names = 1"
+ 15 "PRAGMA fullfsync = 1"
+ 16 "PRAGMA ignore_check_constraints = 1"
+ 18 "PRAGMA page_size = 511"
+ 19 "PRAGMA page_size = 512"
+ 20 "PRAGMA query_only = false"
+ 21 "PRAGMA read_uncommitted = true"
+ 22 "PRAGMA recursive_triggers = false"
+ 23 "PRAGMA reverse_unordered_selects = false"
+ 24 "PRAGMA schema_version = 211"
+ 25 "PRAGMA short_column_names = 1"
+ 26 "PRAGMA synchronous = full"
+ 29 "PRAGMA temp_store = memory"
+ 30 "PRAGMA user_version = 405"
+ 31 "PRAGMA writable_schema = 1"
+} {
+ reset_db
+
+ # Without RHS:
+ do_pragma_ncol_test 1.$tn.1 [lindex [split $sql =] 0] 1
+
+ # With RHS:
+ do_pragma_ncol_test 1.$tn.2 $sql 0
+}
+
+# These pragmas should never return any values.
+#
+foreach {tn sql} {
+ 1 "PRAGMA shrink_memory"
+ 2 "PRAGMA shrink_memory = 10"
+ 3 "PRAGMA case_sensitive_like = 0"
+ 4 "PRAGMA case_sensitive_like = 1"
+ 5 "PRAGMA case_sensitive_like"
+} {
+
+ do_pragma_ncol_test 1.$tn.1 $sql 0
+}
+
+# EXPLAIN on a PRAGMA integrity_check.
+# Verify that that P4_INTARRAY argument to OP_IntegrityCk is rendered
+# correctly.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_test pragma4-2.100 {
+ db eval {
+ PRAGMA page_size=512;
+ CREATE TABLE t1(x);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10000)
+ INSERT INTO t1(x) SELECT zeroblob(300) FROM c;
+ CREATE TABLE t2(y);
+ DROP TABLE t1;
+ }
+ string map {\[ x \] x \173 {} \175 {}} \
+ [db eval {EXPLAIN PRAGMA integrity_check}]
+} {/ IntegrityCk 2 2 1 x[0-9]+,1x /}
+
+
+#--------------------------------------------------------------------------
+#
+reset_db
+forcedelete test.db2
+do_execsql_test 4.1.1 {
+ CREATE TABLE t1(a, b, c);
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t2(d, e, f);
+}
+do_execsql_test 4.1.2 { PRAGMA table_info = t1 } {
+ 0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0
+}
+do_execsql_test 4.1.3 { PRAGMA table_info = t2 } {
+ 0 d {} 0 {} 0 1 e {} 0 {} 0 2 f {} 0 {} 0
+}
+do_test 4.1.4 {
+ sqlite3 db3 test.db
+ sqlite3 db2 test.db2
+ execsql { DROP TABLE t1 } db3
+ execsql { DROP TABLE t2 } db2
+} {}
+if {[permutation]=="prepare"} {
+ do_catchsql_test 4.1.5a {
+ PRAGMA table_info(t1)
+ } {1 {database schema has changed}}
+}
+do_execsql_test 4.1.5 {
+ PRAGMA table_info(t1)
+}
+do_execsql_test 4.1.6 { PRAGMA table_info(t2) }
+
+db2 close
+db3 close
+reset_db
+forcedelete test.db2
+do_execsql_test 4.2.1 {
+ CREATE TABLE t1(a, b, c);
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t2(d, e, f);
+}
+ifcapable vtab {
+ do_execsql_test 4.2.2 { SELECT * FROM pragma_table_info('t1') } {
+ 0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0
+ }
+ do_execsql_test 4.2.3 { SELECT * FROM pragma_table_info('t2') } {
+ 0 d {} 0 {} 0 1 e {} 0 {} 0 2 f {} 0 {} 0
+ }
+}
+do_test 4.2.4 {
+ sqlite3 db3 test.db
+ sqlite3 db2 test.db2
+ execsql { DROP TABLE t1 } db3
+ execsql { DROP TABLE t2 } db2
+} {}
+ifcapable vtab {
+ do_execsql_test 4.2.5 { SELECT * FROM pragma_table_info('t1') }
+ do_execsql_test 4.2.6 { SELECT * FROM pragma_table_info('t2') }
+}
+
+db2 close
+db3 close
+reset_db
+forcedelete test.db2
+do_execsql_test 4.3.1 {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(b);
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t2(d, e, f);
+ CREATE INDEX aux.i2 ON t2(e);
+}
+ifcapable vtab {
+ do_execsql_test 4.3.2 { SELECT * FROM pragma_index_info('i1') } {0 1 b}
+ do_execsql_test 4.3.3 { SELECT * FROM pragma_index_info('i2') } {0 1 e}
+}
+do_test 4.3.4 {
+ sqlite3 db3 test.db
+ sqlite3 db2 test.db2
+ execsql { DROP INDEX i1 } db3
+ execsql { DROP INDEX i2 } db2
+} {}
+if {[permutation]=="prepare"} { catchsql { SELECT * FROM sqlite_master } }
+ifcapable vtab {
+ do_execsql_test 4.3.5 { SELECT * FROM pragma_index_info('i1') }
+ do_execsql_test 4.3.6 { SELECT * FROM pragma_index_info('i2') }
+}
+
+execsql {SELECT * FROM main.sqlite_master, aux.sqlite_master}
+do_execsql_test 4.4.0 {
+ CREATE INDEX main.i1 ON t1(b, c);
+ CREATE INDEX aux.i2 ON t2(e, f);
+}
+ifcapable vtab {
+ do_execsql_test 4.4.1 { SELECT * FROM pragma_index_list('t1') } {0 i1 0 c 0}
+ do_execsql_test 4.4.2 { SELECT * FROM pragma_index_list('t2') } {0 i2 0 c 0}
+}
+do_test 4.4.3 {
+ execsql { DROP INDEX i1 } db3
+ execsql { DROP INDEX i2 } db2
+} {}
+if {[permutation]=="prepare"} {
+ catchsql { SELECT * FROM sqlite_master, aux.sqlite_master }
+}
+ifcapable vtab {
+ do_execsql_test 4.4.5 { SELECT * FROM pragma_index_list('t1') } {}
+ do_execsql_test 4.4.6 { SELECT * FROM pragma_index_list('t2') } {}
+}
+execsql {SELECT * FROM main.sqlite_master, aux.sqlite_master}
+
+do_execsql_test 4.5.0 {
+ CREATE UNIQUE INDEX main.i1 ON t1(a);
+ CREATE UNIQUE INDEX aux.i2 ON t2(d);
+ CREATE TABLE main.c1 (a, b, c REFERENCES t1(a));
+ CREATE TABLE aux.c2 (d, e, r REFERENCES t2(d));
+}
+ifcapable vtab {
+ do_execsql_test 4.5.1 { SELECT * FROM pragma_foreign_key_list('c1') } {
+ 0 0 t1 c a {NO ACTION} {NO ACTION} NONE
+ }
+ do_execsql_test 4.5.2 { SELECT * FROM pragma_foreign_key_list('c2') } {
+ 0 0 t2 r d {NO ACTION} {NO ACTION} NONE
+ }
+}
+do_test 4.5.3 {
+ execsql { DROP TABLE c1 } db3
+ execsql { DROP TABLE c2 } db2
+} {}
+if {[permutation]=="prepare"} {
+ catchsql { SELECT * FROM sqlite_master, aux.sqlite_master }
+}
+ifcapable vtab {
+ do_execsql_test 4.5.4 { SELECT * FROM pragma_foreign_key_list('c1') }
+ do_execsql_test 4.5.5 { SELECT * FROM pragma_foreign_key_list('c2') }
+}
+execsql {SELECT * FROM main.sqlite_master, aux.sqlite_master}
+
+do_execsql_test 4.6.0 {
+ CREATE TABLE main.c1 (a, b, c REFERENCES t1(a));
+ CREATE TABLE aux.c2 (d, e, r REFERENCES t2(d));
+ INSERT INTO main.c1 VALUES(1, 2, 3);
+ INSERT INTO aux.c2 VALUES(4, 5, 6);
+}
+do_execsql_test 4.6.1 { pragma foreign_key_check('c1') } {
+ c1 1 t1 0
+}
+do_execsql_test 4.6.2 { pragma foreign_key_check('c2') } {
+ c2 1 t2 0
+}
+do_test 4.6.3 {
+ execsql { DROP TABLE c2 } db2
+} {}
+do_execsql_test 4.6.4 { pragma foreign_key_check('c1') } {c1 1 t1 0}
+do_catchsql_test 4.6.5 {
+ pragma foreign_key_check('c2')
+} {1 {no such table: c2}}
+
+do_execsql_test 5.0 {
+ CREATE TABLE t4(a DEFAULT 'abc' /* comment */, b DEFAULT -1 -- comment
+ , c DEFAULT +4.0 /* another comment */
+ );
+ PRAGMA table_info = t4;
+} {
+ 0 a {} 0 'abc' 0 1 b {} 0 -1 0 2 c {} 0 +4.0 0
+}
+
+
+finish_test
diff --git a/test/pragma5.test b/test/pragma5.test
new file mode 100644
index 0000000..6d9b5bb
--- /dev/null
+++ b/test/pragma5.test
@@ -0,0 +1,70 @@
+# 2017 August 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 for the PRAGMA command. Specifically,
+# those pragmas that are not disabled at build time by setting:
+#
+# -DSQLITE_OMIT_INTROSPECTION_PRAGMAS
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix pragma5
+
+if { [catch {db one "SELECT count(*) FROM pragma_function_list"}] } {
+ finish_test
+ return
+}
+
+db function external external
+
+do_execsql_test 1.0 {
+ PRAGMA table_info(pragma_function_list)
+} {
+ 0 name {} 0 {} 0
+ 1 builtin {} 0 {} 0
+ 2 type {} 0 {} 0
+ 3 enc {} 0 {} 0
+ 4 narg {} 0 {} 0
+ 5 flags {} 0 {} 0
+}
+do_execsql_test 1.1 {
+ SELECT DISTINCT name, builtin
+ FROM pragma_function_list WHERE name='upper' AND builtin
+} {upper 1}
+do_execsql_test 1.2 {
+ SELECT DISTINCT name, builtin
+ FROM pragma_function_list WHERE name LIKE 'exter%';
+} {external 0}
+
+ifcapable fts5 {
+ do_execsql_test 2.0 {
+ PRAGMA table_info(pragma_module_list)
+ } {
+ 0 name {} 0 {} 0
+ }
+ do_execsql_test 2.1 {
+ SELECT * FROM pragma_module_list WHERE name='fts5'
+ } {fts5}
+}
+
+do_execsql_test 3.0 {
+ PRAGMA table_info(pragma_pragma_list)
+} {
+ 0 name {} 0 {} 0
+}
+do_execsql_test 3.1 {
+ SELECT * FROM pragma_pragma_list WHERE name='pragma_list'
+} {pragma_list}
+
+
+finish_test
diff --git a/test/pragmafault.test b/test/pragmafault.test
new file mode 100644
index 0000000..34718ae
--- /dev/null
+++ b/test/pragmafault.test
@@ -0,0 +1,39 @@
+# 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 testprefix pragmafault
+
+db close
+sqlite3 db test.db
+sqlite3_db_config_lookaside db 0 0 0
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, CHECK(a!=b));
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+}
+faultsim_save_and_close
+
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ catchsql { PRAGMA integrity_check }
+ set {} 0
+} -test {
+ faultsim_test_result {0 0}
+}
+
+
+finish_test
diff --git a/test/prefixes.test b/test/prefixes.test
new file mode 100644
index 0000000..2080905
--- /dev/null
+++ b/test/prefixes.test
@@ -0,0 +1,88 @@
+# 2018-01-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 prefixes.c extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix unionvtab
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+load_static_extension db prefixes
+
+foreach {tn zLeft zRight expected} {
+ 1 abcdxxx abcyy 3
+ 2 abcdxxx bcyyy 0
+ 3 abcdxxx ab 2
+ 4 ab abcd 2
+
+ 5 "xyz\u1234xz" "xyz\u1234xy" 5
+ 6 "xyz\u1234" "xyz\u1234xy" 4
+ 7 "xyz\u1234" "xyz\u1234" 4
+ 8 "xyz\u1234xy" "xyz\u1234" 4
+ 9 "xyz\u1234xy" "xyz\u1233" 3
+ 10 "xyz\u1234xy" "xyz\u1235" 3
+} {
+ do_execsql_test 1.$tn { SELECT prefix_length($zLeft, $zRight) } $expected
+}
+
+
+do_execsql_test 2.0 {
+ CREATE TABLE t1(k TEXT UNIQUE, v INTEGER);
+ INSERT INTO t1 VALUES
+ ('aback', 1),
+ ('abaft', 2),
+ ('abandon', 3),
+ ('abandoned', 4),
+ ('abandoning', 5),
+ ('abandonment', 6),
+ ('abandons', 7),
+ ('abase', 8),
+ ('abased', 9),
+ ('abasement', 10),
+ ('abasements', 11),
+ ('abases', 12),
+ ('abash', 13),
+ ('abashed', 14),
+ ('abashes', 15),
+ ('abashing', 16),
+ ('abasing', 17),
+ ('abate', 18),
+ ('abated', 19),
+ ('abatement', 20),
+ ('abatements', 21);
+}
+
+foreach {tn INPUT expected} {
+ 1 abatementt abatement
+ 2 abashet abash
+ 3 abandonio abandon
+ 4 abasemenu abase
+} {
+ do_execsql_test 2.$tn {
+ WITH finder(str) AS (
+ SELECT (SELECT max(k) FROM t1 WHERE k<=$INPUT)
+ UNION ALL
+ SELECT (
+ SELECT max(k) FROM t1
+ WHERE k<=substr($INPUT, 1, prefix_length(finder.str, $INPUT))
+ ) FROM finder WHERE length(finder.str)>0
+ )
+ SELECT str FROM finder WHERE length(str)==prefix_length(str, $INPUT) LIMIT 1
+ } $expected
+}
+
+finish_test
diff --git a/test/printf.test b/test/printf.test
new file mode 100644
index 0000000..445470f
--- /dev/null
+++ b/test/printf.test
@@ -0,0 +1,3789 @@
+# 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-1.17.1 {
+ sqlite3_mprintf_int {abd: %2147483647d %2147483647x %2147483647o} 1 1 1
+} {}
+do_test printf-1.17.2 {
+ sqlite3_mprintf_int {abd: %*d %x} 2147483647 1 1
+} {}
+do_test printf-1.17.3 {
+ sqlite3_mprintf_int {abd: %*d %x} -2147483648 1 1
+} {abd: 1 1}
+do_test printf-1.17.4 {
+ sqlite3_mprintf_int {abd: %.2147483648d %x %x} 1 1 1
+} {/.*/}
+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}
+if {$SQLITE_MAX_LENGTH<=[expr 1000*1000*1000]} {
+ do_test printf-2.1.2.10 {
+ sqlite3_mprintf_double {abc: %*.*f} 2000000000 1000000000 1.0e-20
+ } {}
+}
+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 printf-3.7 {
+ sqlite3_mprintf_str {%d A String: (%*s)} 1 2147483647 {This is the string}
+} []
+do_test printf-3.8 {
+ sqlite3_mprintf_str {%d A String: (%*s)} 1 -2147483648 {This is the string}
+} {1 A String: (This is the string)}
+do_test printf-3.9 {
+ sqlite3_mprintf_str {%d A String: (%.*s)} 1 -2147483648 {This is the string}
+} {1 A String: (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-13.7 {
+ sqlite3_mprintf_hexdouble %2147483648.10000f 4693b8b5b5056e17
+} {/100000000000000000000000000000000.00/}
+
+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():
+#
+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
+ }
+}
+
+# 2020-05-23
+# ticket 23439ea582241138
+#
+do_execsql_test printf-16.1 {
+ SELECT printf('%.*g',2147483647,0.01);
+} {0.01}
+
+finish_test
diff --git a/test/printf2.test b/test/printf2.test
new file mode 100644
index 0000000..2f6208b
--- /dev/null
+++ b/test/printf2.test
@@ -0,0 +1,213 @@
+# 2013-12-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 printf() SQL function.
+#
+#
+# EVIDENCE-OF: R-32560-14372 The format(FORMAT,...) SQL function works
+# like the sqlite3_mprintf() C-language function and the printf()
+# function from the standard C library.
+#
+# EVIDENCE-OF: R-64900-53159 The printf() SQL function is an alias for
+# the format() SQL function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# EVIDENCE-OF: R-40086-60101 If the FORMAT argument is missing or NULL
+# then the result is NULL.
+#
+do_execsql_test printf2-1.1 {
+ SELECT quote(format()), quote(format(NULL,1,2,3));
+} {NULL NULL}
+
+
+do_execsql_test printf2-1.2 {
+ SELECT printf('hello');
+} {hello}
+do_execsql_test printf2-1.3 {
+ SELECT format('%d,%d,%d',55,-11,3421);
+} {55,-11,3421}
+do_execsql_test printf2-1.4 {
+ SELECT printf('%d,%d,%d',55,'-11',3421);
+} {55,-11,3421}
+do_execsql_test printf2-1.5 {
+ SELECT format('%d,%d,%d,%d',55,'-11',3421);
+} {55,-11,3421,0}
+do_execsql_test printf2-1.6 {
+ SELECT printf('%.2f',3.141592653);
+} {3.14}
+do_execsql_test printf2-1.7 {
+ SELECT format('%.*f',2,3.141592653);
+} {3.14}
+do_execsql_test printf2-1.8 {
+ SELECT printf('%*.*f',5,2,3.141592653);
+} {{ 3.14}}
+do_execsql_test printf2-1.9 {
+ SELECT format('%d',314159.2653);
+} {314159}
+do_execsql_test printf2-1.10 {
+ SELECT printf('%lld',314159.2653);
+} {314159}
+do_execsql_test printf2-1.11 {
+ SELECT format('%lld%n',314159.2653,'hi');
+} {314159}
+do_execsql_test printf2-1.12 {
+ SELECT printf('%n',0);
+} {{}}
+
+# EVIDENCE-OF: R-17002-27534 The %z format is interchangeable with %s.
+#
+do_execsql_test printf2-1.12 {
+ SELECT format('%.*z',5,'abcdefghijklmnop');
+} {abcde}
+do_execsql_test printf2-1.13 {
+ SELECT printf('%c','abcdefghijklmnop');
+} {a}
+
+# EVIDENCE-OF: R-02347-27622 The %n format is silently ignored and does
+# not consume an argument.
+#
+do_execsql_test printf2-2.1 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(-1,-2,-3);
+ INSERT INTO t1 VALUES('abc','def','ghi');
+ INSERT INTO t1 VALUES(1.5,2.25,3.125);
+ SELECT printf('(%s)-%n-(%s)',a,b,c) FROM t1 ORDER BY rowid;
+} {(1)--(2) (-1)--(-2) (abc)--(def) (1.5)--(2.25)}
+
+# EVIDENCE-OF: R-56064-04001 The %p format is an alias for %X.
+#
+do_execsql_test printf2-2.2 {
+ SELECT printf('%s=(%p)',a,a) FROM t1 ORDER BY a;
+} {-1=(FFFFFFFFFFFFFFFF) 1=(1) 1.5=(1) abc=(0)}
+
+# EVIDENCE-OF: R-29410-53018 If there are too few arguments in the
+# argument list, missing arguments are assumed to have a NULL value,
+# which is translated into 0 or 0.0 for numeric formats or an empty
+# string for %s.
+#
+do_execsql_test printf2-2.3 {
+ SELECT printf('%s=(%d/%g/%s)',a) FROM t1 ORDER BY a;
+} {-1=(0/0/) 1=(0/0/) 1.5=(0/0/) abc=(0/0/)}
+
+# The precision of the %c conversion causes the character to repeat.
+#
+do_execsql_test printf2-3.1 {
+ SELECT printf('|%110.100c|','*');
+} {{| ****************************************************************************************************|}}
+do_execsql_test printf2-3.2 {
+ SELECT printf('|%-110.100c|','*');
+} {{|**************************************************************************************************** |}}
+do_execsql_test printf2-3.3 {
+ SELECT printf('|%9.8c|%-9.8c|','*','*');
+} {{| ********|******** |}}
+do_execsql_test printf2-3.4 {
+ SELECT printf('|%8.8c|%-8.8c|','*','*');
+} {|********|********|}
+do_execsql_test printf2-3.5 {
+ SELECT printf('|%7.8c|%-7.8c|','*','*');
+} {|********|********|}
+
+# The "," separator
+do_execsql_test printf2-4.1 {
+ SELECT printf('|%,d|%,d|',0,-1);
+} {|0|-1|}
+do_execsql_test printf2-4.2 {
+ SELECT printf('|%,d|%,d|',12,-12);
+} {|12|-12|}
+do_execsql_test printf2-4.3 {
+ SELECT printf('|%,d|%,d|',123,-123);
+} {|123|-123|}
+do_execsql_test printf2-4.4 {
+ SELECT printf('|%,d|%,d|',1234,-1234);
+} {|1,234|-1,234|}
+do_execsql_test printf2-4.5 {
+ SELECT printf('|%,d|%,d|',12345,-12345);
+} {|12,345|-12,345|}
+do_execsql_test printf2-4.6 {
+ SELECT printf('|%,d|%,d|',123456,-123456);
+} {|123,456|-123,456|}
+do_execsql_test printf2-4.7 {
+ SELECT printf('|%,d|%,d|',1234567,-1234567);
+} {|1,234,567|-1,234,567|}
+do_execsql_test printf2-4.8 {
+ SELECT printf('|%,d|%,d|',12345678,-12345678);
+} {|12,345,678|-12,345,678|}
+do_execsql_test printf2-4.9 {
+ SELECT printf('|%,d|%,d|',123456789,-123456789);
+} {|123,456,789|-123,456,789|}
+do_execsql_test printf2-4.10 {
+ SELECT printf('|%,d|%,d|',1234567890,-1234567890);
+} {|1,234,567,890|-1,234,567,890|}
+
+# 2018-02-19. Unicode characters with %c
+do_execsql_test printf2-5.100 {
+ SELECT printf('(%8c)',char(11106));
+} {{( ⭢)}}
+do_execsql_test printf2-5.101 {
+ SELECT printf('(%-8c)',char(11106));
+} {{(⭢ )}}
+do_execsql_test printf2-5.102 {
+ SELECT printf('(%5.3c)',char(1492));
+} {{( ההה)}}
+do_execsql_test printf2-5.103 {
+ SELECT printf('(%-5.3c)',char(1492));
+} {{(ההה )}}
+do_execsql_test printf2-5.104 {
+ SELECT printf('(%3.3c)',char(1492));
+} {{(ההה)}}
+do_execsql_test printf2-5.105 {
+ SELECT printf('(%-3.3c)',char(1492));
+} {{(ההה)}}
+do_execsql_test printf2-5.104 {
+ SELECT printf('(%2c)',char(1513));
+} {{( ש)}}
+do_execsql_test printf2-5.106 {
+ SELECT printf('(%-2c)',char(1513));
+} {{(ש )}}
+
+# 2018-02-19. Unicode characters with the "!" flag in %s and friends.
+do_execsql_test printf2-6.100 {
+ SELECT printf('(%!.3s)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {(הנה)}
+do_execsql_test printf2-6.101 {
+ SELECT printf('(%.6s)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {(הנה)}
+do_execsql_test printf2-6.102 {
+ SELECT printf('(%!5.3s)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {{( הנה)}}
+do_execsql_test printf2-6.103 {
+ SELECT printf('(%8.6s)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {{( הנה)}}
+do_execsql_test printf2-6.104 {
+ SELECT printf('(%!-5.3s)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {{(הנה )}}
+do_execsql_test printf2-6.105 {
+ SELECT printf('(%-8.6s)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {{(הנה )}}
+do_execsql_test printf2-6.106 {
+ SELECT printf('(%!.3Q)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {('הנה')}
+do_execsql_test printf2-6.107 {
+ SELECT printf('(%.6Q)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {('הנה')}
+do_execsql_test printf2-6.108 {
+ SELECT printf('(%!7.3Q)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {{( 'הנה')}}
+do_execsql_test printf2-6.109 {
+ SELECT printf('(%10.6Q)','הנה מה־טוב ומה־נעים שבת אחים גם־יחד');
+} {{( 'הנה')}}
+
+
+finish_test
diff --git a/test/progress.test b/test/progress.test
new file mode 100644
index 0000000..f6d7229
--- /dev/null
+++ b/test/progress.test
@@ -0,0 +1,178 @@
+# 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 5 "expr 1"
+ catch {db eval {SELECT a, b, c FROM abc} { }} msg
+ db progress 5 "expr 0"
+ 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/pushdown.test b/test/pushdown.test
new file mode 100644
index 0000000..af51624
--- /dev/null
+++ b/test/pushdown.test
@@ -0,0 +1,91 @@
+# 2017 April 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
+set testprefix pushdown
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 'b1', 'c1');
+ INSERT INTO t1 VALUES(2, 'b2', 'c2');
+ INSERT INTO t1 VALUES(3, 'b3', 'c3');
+ INSERT INTO t1 VALUES(4, 'b4', 'c4');
+ CREATE INDEX i1 ON t1(a, c);
+}
+
+proc f {val} {
+ lappend ::L $val
+ return 0
+}
+db func f f
+
+do_test 1.1 {
+ set L [list]
+ execsql { SELECT * FROM t1 WHERE a=2 AND f(b) AND f(c) }
+ set L
+} {c2}
+
+do_test 1.2 {
+ set L [list]
+ execsql { SELECT * FROM t1 WHERE a=3 AND f(c) AND f(b) }
+ set L
+} {c3}
+
+do_execsql_test 1.3 {
+ DROP INDEX i1;
+ CREATE INDEX i1 ON t1(a, b);
+}
+do_test 1.4 {
+ set L [list]
+ execsql { SELECT * FROM t1 WHERE a=2 AND f(b) AND f(c) }
+ set L
+} {b2}
+
+do_test 1.5 {
+ set L [list]
+ execsql { SELECT * FROM t1 WHERE a=3 AND f(c) AND f(b) }
+ set L
+} {b3}
+
+#-----------------------------------------------
+
+do_execsql_test 2.0 {
+ CREATE TABLE u1(a, b, c);
+ CREATE TABLE u2(x, y, z);
+
+ INSERT INTO u1 VALUES('a1', 'b1', 'c1');
+ INSERT INTO u2 VALUES('a1', 'b1', 'c1');
+}
+
+do_test 2.1 {
+ set L [list]
+ execsql {
+ SELECT * FROM u1 WHERE f('one')=123 AND 123=(
+ SELECT x FROM u2 WHERE x=a AND f('two')
+ )
+ }
+ set L
+} {one}
+
+do_test 2.2 {
+ set L [list]
+ execsql {
+ SELECT * FROM u1 WHERE 123=(
+ SELECT x FROM u2 WHERE x=a AND f('two')
+ ) AND f('three')=123
+ }
+ set L
+} {three}
+
+
+
+finish_test
diff --git a/test/queryonly.test b/test/queryonly.test
new file mode 100644
index 0000000..2774e5d
--- /dev/null
+++ b/test/queryonly.test
@@ -0,0 +1,72 @@
+# 2013-07-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 tests the "query_only" pragma.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test queryonly-1.1 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(123),(456);
+ SELECT a FROM t1 ORDER BY a;
+} {123 456}
+do_execsql_test queryonly-1.2 {
+ PRAGMA query_only;
+} {0}
+do_execsql_test queryonly-1.3 {
+ PRAGMA query_only=ON;
+ PRAGMA query_only;
+} {1}
+do_test queryonly-1.4 {
+ catchsql {INSERT INTO t1 VALUES(789);}
+} {1 {attempt to write a readonly database}}
+do_test queryonly-1.5 {
+ catchsql {DELETE FROM t1;}
+} {1 {attempt to write a readonly database}}
+do_test queryonly-1.6 {
+ catchsql {UPDATE t1 SET a=a+1;}
+} {1 {attempt to write a readonly database}}
+do_test queryonly-1.7 {
+ catchsql {CREATE TABLE t2(b);}
+} {1 {attempt to write a readonly database}}
+do_test queryonly-1.8 {
+ catchsql {CREATE INDEX t1a ON t1(a);}
+} {1 {attempt to write a readonly database}}
+do_test queryonly-1.9 {
+ catchsql {DROP TABLE t1;}
+} {1 {attempt to write a readonly database}}
+do_test queryonly-1.10 {
+ catchsql {ANALYZE;}
+} {1 {attempt to write a readonly database}}
+do_execsql_test queryonly-1.11 {
+ SELECT a FROM t1 ORDER BY a;
+} {123 456}
+
+do_execsql_test queryonly-2.2 {
+ PRAGMA query_only;
+} {1}
+do_execsql_test queryonly-2.3 {
+ PRAGMA query_only=OFF;
+ PRAGMA query_only;
+} {0}
+do_execsql_test queryonly-2.4 {
+ INSERT INTO t1 VALUES(789);
+ SELECT a FROM t1 ORDER BY a;
+} {123 456 789}
+do_execsql_test queryonly-2.5 {
+ UPDATE t1 SET a=a+1;
+ SELECT a FROM t1 ORDER BY a;
+} {124 457 790}
+
+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-glob.test b/test/quota-glob.test
new file mode 100644
index 0000000..28c813c
--- /dev/null
+++ b/test/quota-glob.test
@@ -0,0 +1,87 @@
+# 2011 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.
+#
+#***********************************************************************
+#
+# Tests for the glob-style string compare operator embedded in the
+# quota shim.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+catch { unset testnum }
+catch { unset pattern }
+catch { unset text }
+catch { unset ans }
+
+foreach {testnum pattern text ans} {
+ 1 abcdefg abcdefg 1
+ 2 abcdefG abcdefg 0
+ 3 abcdef abcdefg 0
+ 4 abcdefgh abcdefg 0
+ 5 abcdef? abcdefg 1
+ 6 abcdef? abcdef 0
+ 7 abcdef? abcdefgh 0
+ 8 abcdefg abcdef? 0
+ 9 abcdef? abcdef? 1
+ 10 abc/def abc/def 1
+ 11 abc//def abc/def 0
+ 12 */abc/* x/abc/y 1
+ 13 */abc/* /abc/ 1
+ 16 */abc/* x///a/ab/abc 0
+ 17 */abc/* x//a/ab/abc/ 1
+ 16 */abc/* x///a/ab/abc 0
+ 17 */abc/* x//a/ab/abc/ 1
+ 18 **/abc/** x//a/ab/abc/ 1
+ 19 *?/abc/*? x//a/ab/abc/y 1
+ 20 ?*/abc/?* x//a/ab/abc/y 1
+ 21 {abc[cde]efg} abcbefg 0
+ 22 {abc[cde]efg} abccefg 1
+ 23 {abc[cde]efg} abcdefg 1
+ 24 {abc[cde]efg} abceefg 1
+ 25 {abc[cde]efg} abcfefg 0
+ 26 {abc[^cde]efg} abcbefg 1
+ 27 {abc[^cde]efg} abccefg 0
+ 28 {abc[^cde]efg} abcdefg 0
+ 29 {abc[^cde]efg} abceefg 0
+ 30 {abc[^cde]efg} abcfefg 1
+ 31 {abc[c-e]efg} abcbefg 0
+ 32 {abc[c-e]efg} abccefg 1
+ 33 {abc[c-e]efg} abcdefg 1
+ 34 {abc[c-e]efg} abceefg 1
+ 35 {abc[c-e]efg} abcfefg 0
+ 36 {abc[^c-e]efg} abcbefg 1
+ 37 {abc[^c-e]efg} abccefg 0
+ 38 {abc[^c-e]efg} abcdefg 0
+ 39 {abc[^c-e]efg} abceefg 0
+ 40 {abc[^c-e]efg} abcfefg 1
+ 41 {abc[c-e]efg} abc-efg 0
+ 42 {abc[-ce]efg} abc-efg 1
+ 43 {abc[ce-]efg} abc-efg 1
+ 44 {abc[][*?]efg} {abc]efg} 1
+ 45 {abc[][*?]efg} {abc*efg} 1
+ 46 {abc[][*?]efg} {abc?efg} 1
+ 47 {abc[][*?]efg} {abc[efg} 1
+ 48 {abc[^][*?]efg} {abc]efg} 0
+ 49 {abc[^][*?]efg} {abc*efg} 0
+ 50 {abc[^][*?]efg} {abc?efg} 0
+ 51 {abc[^][*?]efg} {abc[efg} 0
+ 52 {abc[^][*?]efg} {abcdefg} 1
+ 53 {*[xyz]efg} {abcxefg} 1
+ 54 {*[xyz]efg} {abcwefg} 0
+} {
+ do_test quota-glob-$testnum.1 {
+ sqlite3_quota_glob $::pattern $::text
+ } $::ans
+ do_test quota-glob-$testnum.2 {
+ sqlite3_quota_glob $::pattern [string map {/ \\} $::text]
+ } $::ans
+}
+finish_test
diff --git a/test/quota.test b/test/quota.test
new file mode 100644
index 0000000..5d0bda3
--- /dev/null
+++ b/test/quota.test
@@ -0,0 +1,532 @@
+# 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
+
+# If SQLITE_CURDIR is not defined, omit this file.
+ifcapable !curdir {
+ finish_test
+ return
+}
+
+source $testdir/malloc_common.tcl
+
+forcedelete bak.db
+unset -nocomplain defaultVfs
+set defaultVfs [file_control_vfsname db]
+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
+
+unset -nocomplain quota_request_ok
+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.2.1 {
+ file_control_vfsname db
+} quota/$defaultVfs
+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 [get_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
+ forcedelete ./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 }
+catch { db close }
+forcedelete test.db
+finish_test
diff --git a/test/quota2.test b/test/quota2.test
new file mode 100644
index 0000000..8682bd8
--- /dev/null
+++ b/test/quota2.test
@@ -0,0 +1,302 @@
+# 2011 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If SQLITE_CURDIR is not defined, omit this file.
+ifcapable !curdir {
+ finish_test
+ return
+}
+
+source $testdir/malloc_common.tcl
+
+db close
+sqlite3_quota_initialize "" 1
+
+foreach dir {quota2a/x1 quota2a/x2 quota2a quota2b quota2c} {
+ forcedelete $dir
+}
+foreach dir {quota2a quota2a/x1 quota2a/x2 quota2b quota2c} {
+ file mkdir $dir
+}
+
+# The standard_path procedure converts a pathname into a standard format
+# that is the same across platforms.
+#
+unset -nocomplain ::quota_pwd ::quota_mapping
+set ::quota_pwd [string map {\\ /} [get_pwd]]
+set ::quota_mapping [list $::quota_pwd PWD]
+proc standard_path {x} {
+ set x [string map {\\ /} $x]
+ return [string map $::quota_mapping $x]
+}
+
+# The quota_check procedure is a callback from the quota handler.
+# It has three arguments which are (1) the full pathname of the file
+# that has gone over quota, (2) the quota limit, (3) the requested
+# new quota size to cover the last write. These three values are
+# appended to the global variable $::quota. The filename is processed
+# to convert every \ character into / and to change the name of the
+# working directory to PWD.
+#
+# The quota is increased to the request if the ::quota_request_ok
+# global variable is true.
+#
+set ::quota {}
+set ::quota_request_ok 0
+
+proc quota_check {filename limitvar size} {
+ upvar $limitvar limit
+ lappend ::quota [standard_path $filename] [set limit] $size
+ if {$::quota_request_ok} {set limit $size}
+}
+
+sqlite3_quota_set */quota2a/* 4000 quota_check
+sqlite3_quota_set */quota2b/* 5000 quota_check
+
+unset -nocomplain bigtext
+for {set i 1} {$i<=1000} {incr i} {
+ if {$i%10==0} {
+ append bigtext [format "%06d\n" $i]
+ } else {
+ append bigtext [format "%06d " $i]
+ }
+}
+
+catch { unset h1 }
+catch { unset x }
+do_test quota2-1.1 {
+ set ::h1 [sqlite3_quota_fopen quota2a/xyz.txt w+b]
+ sqlite3_quota_fwrite $::h1 1 7000 $bigtext
+} {4000}
+do_test quota2-1.2 {
+ set ::quota
+} {PWD/quota2a/xyz.txt 4000 7000}
+do_test quota2-1.2.1 {
+ sqlite3_quota_file_size $::h1
+} {4000}
+do_test quota2-1.2.2 {
+ sqlite3_quota_fflush $::h1 1
+ sqlite3_quota_file_truesize $::h1
+} {4000}
+do_test quota2-1.3 {
+ sqlite3_quota_rewind $::h1
+ set ::x [sqlite3_quota_fread $::h1 1001 7]
+ string length $::x
+} {3003}
+do_test quota2-1.4 {
+ string match $::x [string range $::bigtext 0 3002]
+} {1}
+do_test quota2-1.5 {
+ sqlite3_quota_fseek $::h1 0 SEEK_END
+ sqlite3_quota_ftell $::h1
+} {4000}
+do_test quota2-1.6 {
+ sqlite3_quota_fseek $::h1 -100 SEEK_END
+ sqlite3_quota_ftell $::h1
+} {3900}
+do_test quota2-1.7 {
+ sqlite3_quota_fseek $::h1 -100 SEEK_CUR
+ sqlite3_quota_ftell $::h1
+} {3800}
+do_test quota2-1.8 {
+ sqlite3_quota_fseek $::h1 50 SEEK_CUR
+ sqlite3_quota_ftell $::h1
+} {3850}
+do_test quota2-1.9 {
+ sqlite3_quota_fseek $::h1 50 SEEK_SET
+ sqlite3_quota_ftell $::h1
+} {50}
+do_test quota2-1.10 {
+ sqlite3_quota_rewind $::h1
+ sqlite3_quota_ftell $::h1
+} {0}
+do_test quota2-1.11 {
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 4000 {PWD/quota2a/xyz.txt 4000 1 0}}}
+do_test quota2-1.12 {
+ sqlite3_quota_ftruncate $::h1 3500
+ sqlite3_quota_file_size $::h1
+} {3500}
+do_test quota2-1.13 {
+ sqlite3_quota_file_truesize $::h1
+} {3500}
+do_test quota2-1.14 {
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 3500 {PWD/quota2a/xyz.txt 3500 1 0}}}
+do_test quota2-1.15 {
+ sqlite3_quota_fseek $::h1 0 SEEK_END
+ sqlite3_quota_ftell $::h1
+} {3500}
+do_test quota2-1.16 {
+ sqlite3_quota_fwrite $::h1 1 7000 $bigtext
+} {500}
+do_test quota2-1.17 {
+ sqlite3_quota_ftell $::h1
+} {4000}
+do_test quota2-1.18 {
+ sqlite3_quota_file_size $::h1
+} {4000}
+do_test quota2-1.19 {
+ sqlite3_quota_fflush $::h1 1
+ sqlite3_quota_file_truesize $::h1
+} {4000}
+do_test quota2-1.20 {
+ sqlite3_quota_fclose $::h1
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 4000 {PWD/quota2a/xyz.txt 4000 0 0}}}
+do_test quota2-1.21 {
+ sqlite3_quota_remove quota2a/xyz.txt
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}
+
+
+
+set quota {}
+do_test quota2-2.1 {
+ set ::h1 [sqlite3_quota_fopen quota2c/xyz.txt w+b]
+ sqlite3_quota_fwrite $::h1 1 7000 $bigtext
+} {7000}
+do_test quota2-2.2 {
+ set ::quota
+} {}
+do_test quota2-2.3.1 {
+ sqlite3_quota_rewind $::h1
+ sqlite3_quota_file_available $::h1
+} {7000}
+do_test quota2-2.3.2 {
+ set ::x [sqlite3_quota_fread $::h1 1001 7]
+ string length $::x
+} {6006}
+do_test quota2-2.3.3 {
+ sqlite3_quota_file_available $::h1
+} {0}
+do_test quota2-2.4 {
+ string match $::x [string range $::bigtext 0 6005]
+} {1}
+do_test quota2-2.5 {
+ sqlite3_quota_fseek $::h1 0 SEEK_END
+ sqlite3_quota_ftell $::h1
+} {7000}
+do_test quota2-2.6 {
+ sqlite3_quota_fseek $::h1 -100 SEEK_END
+ sqlite3_quota_ftell $::h1
+} {6900}
+do_test quota2-2.6.1 {
+ sqlite3_quota_file_available $::h1
+} {100}
+do_test quota2-2.7 {
+ sqlite3_quota_fseek $::h1 -100 SEEK_CUR
+ sqlite3_quota_ftell $::h1
+} {6800}
+do_test quota2-2.7.1 {
+ sqlite3_quota_file_available $::h1
+} {200}
+do_test quota2-2.8 {
+ sqlite3_quota_fseek $::h1 50 SEEK_CUR
+ sqlite3_quota_ftell $::h1
+} {6850}
+do_test quota2-2.8.1 {
+ sqlite3_quota_file_available $::h1
+} {150}
+do_test quota2-2.9 {
+ sqlite3_quota_fseek $::h1 50 SEEK_SET
+ sqlite3_quota_ftell $::h1
+} {50}
+do_test quota2-2.9.1 {
+ sqlite3_quota_file_available $::h1
+} {6950}
+do_test quota2-2.10 {
+ sqlite3_quota_rewind $::h1
+ sqlite3_quota_ftell $::h1
+} {0}
+do_test quota2-2.10.1 {
+ sqlite3_quota_file_available $::h1
+} {7000}
+do_test quota2-2.10.2 {
+ sqlite3_quota_ferror $::h1
+} {0}
+do_test quota2-2.11 {
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}
+do_test quota2-2.12 {
+ sqlite3_quota_fclose $::h1
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}
+
+do_test quota2-3.1 {
+ sqlite3_quota_set */quota2b/* 0 quota_check
+ set ::h1 [sqlite3_quota_fopen quota2a/x1/a.txt a]
+ sqlite3_quota_fwrite $::h1 10 10 $bigtext
+} {10}
+do_test quota2-3.2 {
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}
+do_test quota2-3.3a {
+ sqlite3_quota_fflush $::h1 0
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}
+do_test quota2-3.3b {
+ sqlite3_quota_fflush $::h1 1
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}
+do_test quota2-3.3c {
+ sqlite3_quota_fflush $::h1
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}
+do_test quota2-3.4 {
+ sqlite3_quota_fclose $::h1
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 0 0}}}
+do_test quota2-3.5 {
+ set ::h2 [sqlite3_quota_fopen quota2a/x2/b.txt a]
+ sqlite3_quota_fwrite $::h2 10 20 $bigtext
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 300 {PWD/quota2a/x2/b.txt 200 1 0} {PWD/quota2a/x1/a.txt 100 0 0}}}
+do_test quota2-3.6 {
+ set ::h3 [sqlite3_quota_fopen quota2a/x1/c.txt a]
+ sqlite3_quota_fwrite $::h3 10 50 $bigtext
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 800 {PWD/quota2a/x1/c.txt 500 1 0} {PWD/quota2a/x2/b.txt 200 1 0} {PWD/quota2a/x1/a.txt 100 0 0}}}
+do_test quota2-3.7 {
+ file exists quota2a/x1/a.txt
+} {1}
+do_test quota2-3.8 {
+ file exists quota2a/x2/b.txt
+} {1}
+do_test quota2-3.9 {
+ file exists quota2a/x1/c.txt
+} {1}
+do_test quota2-3.10 {
+ sqlite3_quota_remove quota2a/x1
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 700 {PWD/quota2a/x1/c.txt 500 1 1} {PWD/quota2a/x2/b.txt 200 1 0}}}
+do_test quota2-3.11 {
+ sqlite3_quota_fclose $::h2
+ sqlite3_quota_fclose $::h3
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 200 {PWD/quota2a/x2/b.txt 200 0 0}}}
+do_test quota2-3.12 {
+ file exists quota2a/x1/a.txt
+} {0}
+do_test quota2-3.13 {
+ file exists quota2a/x2/b.txt
+} {1}
+do_test quota2-3.14 {
+ file exists quota2a/x1/c.txt
+} {0}
+
+catch { sqlite3_quota_shutdown }
+catch { unset quota_request_ok }
+finish_test
diff --git a/test/quote.test b/test/quote.test
new file mode 100644
index 0000000..6d7b317
--- /dev/null
+++ b/test/quote.test
@@ -0,0 +1,186 @@
+# 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
+set testprefix quote
+
+# 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 {}}
+
+#-------------------------------------------------------------------------
+# Check that it is not possible to use double-quotes for a string
+# constant in a CHECK constraint or CREATE INDEX statement. However,
+# SQLite can load such a schema from disk.
+#
+reset_db
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 0
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+do_execsql_test 2.0 {
+ CREATE TABLE t1(x, y, z);
+}
+foreach {tn sql errname} {
+ 1 { CREATE TABLE xyz(a, b, c CHECK (c!="null") ) } null
+ 2 { CREATE INDEX i2 ON t1(x, y, z||"abc") } abc
+ 3 { CREATE INDEX i3 ON t1("w") } w
+ 4 { CREATE INDEX i4 ON t1(x) WHERE z="w" } w
+} {
+ do_catchsql_test 2.1.$tn $sql [list 1 "no such column: $errname"]
+}
+
+do_execsql_test 2.2 {
+ PRAGMA writable_schema = 1;
+ CREATE TABLE xyz(a, b, c CHECK (c!="null") );
+ CREATE INDEX i2 ON t1(x, y, z||"abc");
+ CREATE INDEX i3 ON t1("w"||"");
+ CREATE INDEX i4 ON t1(x) WHERE z="w";
+}
+
+db close
+sqlite3 db test.db
+
+do_execsql_test 2.3.1 {
+ INSERT INTO xyz VALUES(1, 2, 3);
+}
+do_catchsql_test 2.3.2 {
+ INSERT INTO xyz VALUES(1, 2, 'null');
+} {1 {CHECK constraint failed: c!="null"}}
+
+do_execsql_test 2.4 {
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 'w');
+ SELECT * FROM t1 WHERE z='w';
+} {4 5 w}
+do_execsql_test 2.5 {
+ SELECT sql FROM sqlite_master;
+} {
+ {CREATE TABLE t1(x, y, z)}
+ {CREATE TABLE xyz(a, b, c CHECK (c!="null") )}
+ {CREATE INDEX i2 ON t1(x, y, z||"abc")}
+ {CREATE INDEX i3 ON t1("w"||"")}
+ {CREATE INDEX i4 ON t1(x) WHERE z="w"}
+}
+
+# 2021-03-13
+# ticket 1c24a659e6d7f3a1
+ifcapable altertable {
+ reset_db
+ do_catchsql_test 3.0 {
+ CREATE TABLE t1(a,b);
+ CREATE INDEX x1 on t1("b");
+ ALTER TABLE t1 DROP COLUMN b;
+ } {1 {error in index x1 after drop column: no such column: b}}
+ do_catchsql_test 3.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,"b");
+ CREATE INDEX x1 on t1("b");
+ ALTER TABLE t1 DROP COLUMN b;
+ } {1 {error in index x1 after drop column: no such column: b}}
+ do_catchsql_test 3.2 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,'b');
+ CREATE INDEX x1 on t1("b");
+ ALTER TABLE t1 DROP COLUMN b;
+ } {1 {error in index x1 after drop column: no such column: b}}
+ do_catchsql_test 3.3 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,"b");
+ CREATE INDEX x1 on t1('b');
+ ALTER TABLE t1 DROP COLUMN b;
+ } {1 {error in index x1 after drop column: no such column: b}}
+ do_catchsql_test 3.4 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX x1 ON t1("a"||"b");
+ INSERT INTO t1 VALUES(1,2,3),(1,4,5);
+ ALTER TABLE t1 DROP COLUMN b;
+ } {1 {error in index x1 after drop column: no such column: b}}
+ sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
+ do_catchsql_test 3.5 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX x1 ON t1("a"||"x");
+ INSERT INTO t1 VALUES(1,2,3),(1,4,5);
+ ALTER TABLE t1 DROP COLUMN b;
+ } {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..7a98f0b
--- /dev/null
+++ b/test/randexpr1.test
@@ -0,0 +1,7837 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+# 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/rbu.test b/test/rbu.test
new file mode 100644
index 0000000..4054195
--- /dev/null
+++ b/test/rbu.test
@@ -0,0 +1,17 @@
+# 2014 September 20
+#
+# May you do good 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 RBU related tests.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/permutations.test
+
+ifcapable !rbu { finish_test ; return }
+
+run_test_suite rbu
+finish_test
diff --git a/test/rdonly.test b/test/rdonly.test
new file mode 100644
index 0000000..404c613
--- /dev/null
+++ b/test/rdonly.test
@@ -0,0 +1,95 @@
+# 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}
+
+# EVIDENCE-OF: R-29639-16887 The sqlite3_db_readonly(D,N) interface
+# returns 1 if the database N of connection D is read-only, 0 if it is
+# read/write, or -1 if N is not the name of a database on connection D.
+#
+do_test rdonly-1.1.1 {
+ sqlite3_db_readonly db main
+} {0}
+
+# 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.3.1 {
+ sqlite3_db_readonly db main
+} {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/recover.test b/test/recover.test
new file mode 100644
index 0000000..8d9ad01
--- /dev/null
+++ b/test/recover.test
@@ -0,0 +1,179 @@
+# 2019 April 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.
+#
+#***********************************************************************
+#
+# Test the shell tool ".ar" command.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix recover
+
+ifcapable !vtab {
+ finish_test; return
+}
+set CLI [test_find_cli]
+
+proc compare_result {db1 db2 sql} {
+ set r1 [$db1 eval $sql]
+ set r2 [$db2 eval $sql]
+ if {$r1 != $r2} {
+ puts "r1: $r1"
+ puts "r2: $r2"
+ error "mismatch for $sql"
+ }
+ return ""
+}
+
+proc compare_dbs {db1 db2} {
+ compare_result $db1 $db2 "SELECT sql FROM sqlite_master ORDER BY 1"
+ foreach tbl [$db1 eval {SELECT name FROM sqlite_master WHERE type='table'}] {
+ compare_result $db1 $db2 "SELECT * FROM $tbl"
+ }
+}
+
+proc recover_with_opts {opts} {
+ set cmd ".recover $opts"
+ set fd [open [list |$::CLI test.db $cmd]]
+ fconfigure $fd -encoding binary
+ fconfigure $fd -translation binary
+ set sql [read $fd]
+ close $fd
+
+ forcedelete test.db2
+ sqlite3 db2 test.db2
+ execsql $sql db2
+ db2 close
+}
+
+proc do_recover_test {tn {tsql {}} {res {}}} {
+ recover_with_opts ""
+
+ sqlite3 db2 test.db2
+ if {$tsql==""} {
+ uplevel [list do_test $tn [list compare_dbs db db2] {}]
+ } else {
+ uplevel [list do_execsql_test -db db2 $tn $tsql $res]
+ }
+ db2 close
+}
+
+set doc {
+ hello
+ world
+}
+do_execsql_test 1.1.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ INSERT INTO t1 VALUES(1, 4, X'1234567800');
+ INSERT INTO t1 VALUES(2, 'test', 8.1);
+ INSERT INTO t1 VALUES(3, $doc, 8.4);
+}
+do_recover_test 1.1.2
+
+do_execsql_test 1.2.1 "
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(13, 'hello\r\nworld', 13);
+"
+do_recover_test 1.2.2
+
+do_execsql_test 1.3.1 "
+ CREATE TABLE t2(i INTEGER PRIMARY KEY AUTOINCREMENT, b, c);
+ INSERT INTO t2 VALUES(NULL, 1, 2);
+ INSERT INTO t2 VALUES(NULL, 3, 4);
+ INSERT INTO t2 VALUES(NULL, 5, 6);
+ CREATE TABLE t3(i INTEGER PRIMARY KEY AUTOINCREMENT, b, c);
+ INSERT INTO t3 VALUES(NULL, 1, 2);
+ INSERT INTO t3 VALUES(NULL, 3, 4);
+ INSERT INTO t3 VALUES(NULL, 5, 6);
+ DELETE FROM t2;
+"
+do_recover_test 1.3.2
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.1.0 {
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ INSERT INTO t1 VALUES(7, 8, 9);
+}
+
+do_recover_test 2.1.1
+
+do_execsql_test 2.2.0 {
+ PRAGMA writable_schema = 1;
+ DELETE FROM sqlite_master WHERE name='t1';
+}
+do_recover_test 2.2.1 {
+ SELECT name FROM sqlite_master
+} {lost_and_found}
+
+do_execsql_test 2.3.0 {
+ CREATE TABLE lost_and_found(a, b, c);
+}
+do_recover_test 2.3.1 {
+ SELECT name FROM sqlite_master
+} {lost_and_found lost_and_found_0}
+
+do_execsql_test 2.4.0 {
+ CREATE TABLE lost_and_found_0(a, b, c);
+}
+do_recover_test 2.4.1 {
+ SELECT name FROM sqlite_master;
+ SELECT * FROM lost_and_found_1;
+} {lost_and_found lost_and_found_0 lost_and_found_1
+ 2 2 3 {} 2 3 1
+ 2 2 3 {} 5 6 4
+ 2 2 3 {} 8 9 7
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_recover_test 3.0
+
+#-------------------------------------------------------------------------
+reset_db
+execsql { PRAGMA secure_delete = 0 }
+execsql { PRAGMA auto_vacuum = 0 }
+do_execsql_test 4.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+ CREATE TABLE t3(g, h, i);
+
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES('a', 'b', 'c');
+
+ INSERT INTO t3 VALUES('one', 'two', 'three');
+ DROP TABLE t1;
+ DROP TABLE t2;
+}
+
+recover_with_opts ""
+sqlite3 db2 test.db2
+do_execsql_test -db db2 4.1.1 {
+ SELECT name FROM sqlite_schema
+} {t3 lost_and_found}
+do_execsql_test -db db2 4.1.2 {
+ SELECT id, c0, c1, c2 FROM lost_and_found
+} {1 1 2 3 2 a b c}
+db2 close
+
+recover_with_opts -ignore-freelist
+sqlite3 db2 test.db2
+do_execsql_test -db db2 4.2.1 {
+ SELECT name FROM sqlite_schema
+} {t3}
+do_execsql_test -db db2 4.2.2 {
+ SELECT * FROM t3
+} {one two three}
+db2 close
+
+finish_test
diff --git a/test/regexp1.test b/test/regexp1.test
new file mode 100644
index 0000000..0401b13
--- /dev/null
+++ b/test/regexp1.test
@@ -0,0 +1,335 @@
+# 2012 December 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 test for the REGEXP operator in test_regexp.c.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test regexp1-1.1 {
+ load_static_extension db regexp
+ db eval {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT);
+ INSERT INTO t1 VALUES(1, 'For since by man came death,');
+ INSERT INTO t1 VALUES(2, 'by man came also the resurrection of the dead.');
+ INSERT INTO t1 VALUES(3, 'For as in Adam all die,');
+ INSERT INTO t1 VALUES(4, 'even so in Christ shall all be made alive.');
+
+ SELECT x FROM t1 WHERE y REGEXP '^For ' ORDER BY x;
+ }
+} {1 3}
+
+do_execsql_test regexp1-1.1.2 {
+ SELECT regexpi('abc','ABC');
+} {1}
+do_execsql_test regexp1-1.1.3 {
+ SELECT regexpi('ABC','ABC');
+} {1}
+do_execsql_test regexp1-1.1.4 {
+ SELECT regexpi('ABC','abc');
+} {1}
+do_execsql_test regexp1-1.1.5 {
+ SELECT regexpi('ABC.','ABC');
+} {0}
+
+do_execsql_test regexp1-1.2 {
+ SELECT x FROM t1 WHERE y REGEXP 'by|in' ORDER BY x;
+} {1 2 3 4}
+do_execsql_test regexp1-1.3.1 {
+ SELECT x FROM t1 WHERE y REGEXP 'by|Christ' ORDER BY x;
+} {1 2 4}
+do_execsql_test regexp1-1.3.2 {
+ SELECT x FROM t1 WHERE regexp('by|christ',y) ORDER BY x;
+} {1 2}
+do_execsql_test regexp1-1.3.3 {
+ SELECT x FROM t1 WHERE regexpi('by|christ',y) ORDER BY x;
+} {1 2 4}
+do_execsql_test regexp1-1.3.4 {
+ SELECT x FROM t1 WHERE regexpi('BY|CHRIST',y) ORDER BY x;
+} {1 2 4}
+do_execsql_test regexp1-1.4 {
+ SELECT x FROM t1 WHERE y REGEXP 'shal+ al+' ORDER BY x;
+} {4}
+do_execsql_test regexp1-1.5.1 {
+ SELECT x FROM t1 WHERE y REGEXP 'shall x*y*z*all' ORDER BY x;
+} {4}
+do_execsql_test regexp1-1.5.2 {
+ SELECT x FROM t1 WHERE regexp('shall x*y*z*all',y) ORDER BY x;
+} {4}
+do_execsql_test regexp1-1.5.3 {
+ SELECT x FROM t1 WHERE regexp('SHALL x*y*z*all',y) ORDER BY x;
+} {}
+do_execsql_test regexp1-1.5.4 {
+ SELECT x FROM t1 WHERE regexpi('SHALL x*y*z*all',y) ORDER BY x;
+} {4}
+do_execsql_test regexp1-1.6 {
+ SELECT x FROM t1 WHERE y REGEXP 'shallx?y? ?z?all' ORDER BY x;
+} {4}
+do_execsql_test regexp1-1.7 {
+ SELECT x FROM t1 WHERE y REGEXP 'r{2}' ORDER BY x;
+} {2}
+do_execsql_test regexp1-1.8 {
+ SELECT x FROM t1 WHERE y REGEXP 'r{3}' ORDER BY x;
+} {}
+do_execsql_test regexp1-1.9 {
+ SELECT x FROM t1 WHERE y REGEXP 'r{1}' ORDER BY x;
+} {1 2 3 4}
+do_execsql_test regexp1-1.10 {
+ SELECT x FROM t1 WHERE y REGEXP 'ur{2,10}e' ORDER BY x;
+} {2}
+do_execsql_test regexp1-1.11 {
+ SELECT x FROM t1 WHERE y REGEXP '[Aa]dam' ORDER BY x;
+} {3}
+do_execsql_test regexp1-1.12 {
+ SELECT x FROM t1 WHERE y REGEXP '[^Aa]dam' ORDER BY x;
+} {}
+do_execsql_test regexp1-1.13 {
+ SELECT x FROM t1 WHERE y REGEXP '[^b-zB-Z]dam' ORDER BY x;
+} {3}
+do_execsql_test regexp1-1.14 {
+ SELECT x FROM t1 WHERE y REGEXP 'alive' ORDER BY x;
+} {4}
+do_execsql_test regexp1-1.15 {
+ SELECT x FROM t1 WHERE y REGEXP '^alive' ORDER BY x;
+} {}
+do_execsql_test regexp1-1.16 {
+ SELECT x FROM t1 WHERE y REGEXP 'alive$' ORDER BY x;
+} {}
+do_execsql_test regexp1-1.17 {
+ SELECT x FROM t1 WHERE y REGEXP 'alive.$' ORDER BY x;
+} {4}
+do_execsql_test regexp1-1.18 {
+ SELECT x FROM t1 WHERE y REGEXP 'alive\.$' ORDER BY x;
+} {4}
+do_execsql_test regexp1-1.19 {
+ SELECT x FROM t1 WHERE y REGEXP 'ma[nd]' ORDER BY x;
+} {1 2 4}
+do_execsql_test regexp1-1.20 {
+ SELECT x FROM t1 WHERE y REGEXP '\bma[nd]' ORDER BY x;
+} {1 2 4}
+do_execsql_test regexp1-1.21 {
+ SELECT x FROM t1 WHERE y REGEXP 'ma[nd]\b' ORDER BY x;
+} {1 2}
+do_execsql_test regexp1-1.22 {
+ SELECT x FROM t1 WHERE y REGEXP 'ma\w' ORDER BY x;
+} {1 2 4}
+do_execsql_test regexp1-1.23 {
+ SELECT x FROM t1 WHERE y REGEXP 'ma\W' ORDER BY x;
+} {}
+do_execsql_test regexp1-1.24 {
+ SELECT x FROM t1 WHERE y REGEXP '\sma\w' ORDER BY x;
+} {1 2 4}
+do_execsql_test regexp1-1.25 {
+ SELECT x FROM t1 WHERE y REGEXP '\Sma\w' ORDER BY x;
+} {}
+do_execsql_test regexp1-1.26 {
+ SELECT x FROM t1 WHERE y REGEXP 'alive\S$' ORDER BY x;
+} {4}
+do_execsql_test regexp1-1.27 {
+ SELECT x FROM t1 WHERE y REGEXP
+ '\b(unto|us|son|given|his|name|called|' ||
+ 'wonderful|councelor|mighty|god|everlasting|father|' ||
+ 'prince|peace|alive)\b';
+} {4}
+
+do_execsql_test regexp1-2.1 {
+ SELECT 'aaaabbbbcccc' REGEXP 'ab*c',
+ 'aaaacccc' REGEXP 'ab*c';
+} {1 1}
+do_execsql_test regexp1-2.2 {
+ SELECT 'aaaabbbbcccc' REGEXP 'ab+c',
+ 'aaaacccc' REGEXP 'ab+c';
+} {1 0}
+do_execsql_test regexp1-2.3 {
+ SELECT 'aaaabbbbcccc' REGEXP 'ab?c',
+ 'aaaacccc' REGEXP 'ab?c';
+} {0 1}
+do_execsql_test regexp1-2.4 {
+ SELECT 'aaaabbbbbbcccc' REGEXP 'ab{3,5}c',
+ 'aaaabbbbbcccc' REGEXP 'ab{3,5}c',
+ 'aaaabbbbcccc' REGEXP 'ab{3,5}c',
+ 'aaaabbbcccc' REGEXP 'ab{3,5}c',
+ 'aaaabbcccc' REGEXP 'ab{3,5}c',
+ 'aaaabcccc' REGEXP 'ab{3,5}c'
+} {0 1 1 1 0 0}
+do_execsql_test regexp1-2.5 {
+ SELECT 'aaaabbbbcccc' REGEXP 'a(a|b|c)+c',
+ 'aaaabbbbcccc' REGEXP '^a(a|b|c){11}c$',
+ 'aaaabbbbcccc' REGEXP '^a(a|b|c){10}c$',
+ 'aaaabbbbcccc' REGEXP '^a(a|b|c){9}c$'
+} {1 0 1 0}
+do_execsql_test regexp1-2.6 {
+ SELECT 'aaaabbbbcccc' REGEXP '^a(a|bb|c)+c$',
+ 'aaaabbbbcccc' REGEXP '^a(a|bbb|c)+c$',
+ 'aaaabbbbcccc' REGEXP '^a(a|bbbb|c)+c$'
+} {1 0 1}
+do_execsql_test regexp1-2.7 {
+ SELECT 'aaaabbbbcccc' REGEXP '^a([ac]+|bb){3}c$',
+ 'aaaabbbbcccc' REGEXP '^a([ac]+|bb){4}c$',
+ 'aaaabbbbcccc' REGEXP '^a([ac]+|bb){5}c$'
+} {0 1 1}
+
+do_execsql_test regexp1-2.8 {
+ SELECT 'abc*def+ghi.jkl[mno]pqr' REGEXP 'c.d',
+ 'abc*def+ghi.jkl[mno]pqr' REGEXP 'c\*d',
+ 'abc*def+ghi.jkl[mno]pqr' REGEXP 'f\+g',
+ 'abc*def+ghi.jkl[mno]pqr' REGEXP 'i\.j',
+ 'abc*def+ghi.jkl[mno]pqr' REGEXP 'l\[mno\]p'
+} {1 1 1 1 1}
+
+do_test regexp1-2.9 {
+ set v1 "abc\ndef"
+ db eval {SELECT $v1 REGEXP '^abc\ndef$'}
+} {1}
+do_test regexp1-2.10 {
+ set v1 "abc\adef"
+ db eval {SELECT $v1 REGEXP '^abc\adef$'}
+} {1}
+do_test regexp1-2.11 {
+ set v1 "abc\tdef"
+ db eval {SELECT $v1 REGEXP '^abc\tdef$'}
+} {1}
+do_test regexp1-2.12 {
+ set v1 "abc\rdef"
+ db eval {SELECT $v1 REGEXP '^abc\rdef$'}
+} {1}
+do_test regexp1-2.13 {
+ set v1 "abc\fdef"
+ db eval {SELECT $v1 REGEXP '^abc\fdef$'}
+} {1}
+do_test regexp1-2.14 {
+ set v1 "abc\vdef"
+ db eval {SELECT $v1 REGEXP '^abc\vdef$'}
+} {1}
+do_execsql_test regexp1-2.15 {
+ SELECT 'abc\def' REGEXP '^abc\\def',
+ 'abc(def' REGEXP '^abc\(def',
+ 'abc)def' REGEXP '^abc\)def',
+ 'abc*def' REGEXP '^abc\*def',
+ 'abc.def' REGEXP '^abc\.def',
+ 'abc+def' REGEXP '^abc\+def',
+ 'abc?def' REGEXP '^abc\?def',
+ 'abc[def' REGEXP '^abc\[def',
+ 'abc$def' REGEXP '^abc\$',
+ '^def' REGEXP '\^def',
+ 'abc{4}x' REGEXP '^abc\{4\}x$',
+ 'abc|def' REGEXP '^abc\|def$'
+} {1 1 1 1 1 1 1 1 1 1 1 1}
+
+do_execsql_test regexp1-2.20 {
+ SELECT 'abc$¢€xyz' REGEXP '^abc\u0024\u00a2\u20acxyz$',
+ 'abc$¢€xyz' REGEXP '^abc\u0024\u00A2\u20ACxyz$',
+ 'abc$¢€xyz' REGEXP '^abc\x24\xa2\u20acxyz$'
+} {1 1 1}
+do_execsql_test regexp1-2.21 {
+ SELECT 'abc$¢€xyz' REGEXP '^abc[\u0024][\u00a2][\u20ac]xyz$',
+ 'abc$¢€xyz' REGEXP '^abc[\u0024\u00A2\u20AC]{3}xyz$',
+ 'abc$¢€xyz' REGEXP '^abc[\x24][\xa2\u20ac]+xyz$'
+} {1 1 1}
+do_execsql_test regexp1-2.22 {
+ SELECT 'abc$¢€xyz' REGEXP '^abc[^\u0025-X][^ -\u007f][^\u20ab]xyz$'
+} {1}
+
+# 2022-07-03
+# https://sqlite.org/forum/forumpost/96692f8ba5
+# The REGEXP extension mishandles the prefix search optimization when
+# the prefix contains 3-byte UTF8 characters.
+#
+reset_db
+load_static_extension db regexp
+do_execsql_test regexp1-3.1 {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, a TEXT);
+ INSERT INTO t1(id, a) VALUES(1, '日本語');
+ SELECT a, hex(a), length(a) FROM t1;
+} {日本語 E697A5E69CACE8AA9E 3}
+do_execsql_test regexp1-3.2 {
+ SELECT * FROM t1 WHERE a='日本語';
+} {1 日本語}
+do_execsql_test regexp1-3.3 {
+ SELECT * FROM t1 WHERE a LIKE '日本語';
+} {1 日本語}
+do_execsql_test regexp1-3.4 {
+ SELECT * FROM t1 wHERE a REGEXP '日本語';
+} {1 日本語}
+
+# 2022-07-03
+# https://sqlite.org/forum/forumpost/96692f8ba5 Issue #2
+# The '$' token in REGEXP contained within other elements.
+#
+do_execsql_test regexp1-4.1 {SELECT 'xab' REGEXP 'a(b$|cd)';} {1}
+do_execsql_test regexp1-4.1b {SELECT 'xab' REGEXP '(b$|cd)';} {1}
+do_execsql_test regexp1-4.2 {SELECT 'xaby' REGEXP 'a(b$|cd)';} {0}
+do_execsql_test regexp1-4.3 {SELECT 'xacd' REGEXP 'a(b$|cd)';} {1}
+do_execsql_test regexp1-4.4 {SELECT 'xacdy' REGEXP 'a(b$|cd)';} {1}
+do_execsql_test regexp1-4.5 {SELECT 'xab' REGEXP 'a(cd|b$)';} {1}
+do_execsql_test regexp1-4.6 {SELECT 'xaby' REGEXP 'a(cd|b$)';} {0}
+do_execsql_test regexp1-4.7 {SELECT 'xacd' REGEXP 'a(cd|b$)';} {1}
+do_execsql_test regexp1-4.8 {SELECT 'xacdy' REGEXP 'a(cd|b$)';} {1}
+do_execsql_test regexp1-4.9 {SELECT 'xab' REGEXP 'a(cd|b$|e)';} {1}
+do_execsql_test regexp1-4.10 {SELECT 'xaby' REGEXP 'a(cd|b$|e)';} {0}
+do_execsql_test regexp1-4.11 {SELECT 'xacd' REGEXP 'a(cd|b$|e)';} {1}
+do_execsql_test regexp1-4.12 {SELECT 'xacdy' REGEXP 'a(cd|b$|e)';} {1}
+
+# 2022-07-18
+# https://sqlite.org/forum/forumpost/57cbaf1d0e
+# Incorrect bytecode for {M,N} when M is zero.
+#
+do_execsql_test regexp1-5.1 {SELECT 'fooX' REGEXP '^[a-z][a-z0-9]{0,30}$';} {0}
+do_execsql_test regexp1-5.2 {SELECT 'fooX' REGEXP '^[a-z][a-z0-9]{0,30}X$';} {1}
+do_execsql_test regexp1-5.3 {SELECT 'fooX' REGEXP '^[a-z][a-z0-9]{0,2}X$';} {1}
+do_execsql_test regexp1-5.4 {SELECT 'foooX' REGEXP '^[a-z][a-z0-9]{0,2}X$';} {0}
+do_execsql_test regexp1-5.5 {SELECT 'foooX' REGEXP '^[a-z][a-z0-9]{0,3}X$';} {1}
+
+# 2022-07-18
+# https://sqlite.org/forum/forumpost/18f87fdcdf
+# Allow "^" to occur inside of "(..)"
+#
+do_execsql_test regexp1-6.1 {SELECT 'foo' REGEXP '[a-z]';} {1}
+do_execsql_test regexp1-6.2 {SELECT 'foo' REGEXP '^[a-z]+$';} {1}
+do_execsql_test regexp1-6.3 {SELECT 'foo' REGEXP '^([a-z]+)$';} {1}
+do_execsql_test regexp1-6.4 {SELECT 'foo' REGEXP '(^[a-z]+)$';} {1}
+do_execsql_test regexp1-6.5 {SELECT 'foo' REGEXP '(^[a-z]+$)';} {1}
+do_execsql_test regexp1-6.6 {SELECT 'abc' REGEXP '(^abc|def)';} {1}
+do_execsql_test regexp1-6.7 {SELECT 'xabc' REGEXP '(^abc|def)';} {0}
+do_execsql_test regexp1-6.8 {SELECT 'def' REGEXP '(^abc|def)';} {1}
+do_execsql_test regexp1-6.9 {SELECT 'xdef' REGEXP '(^abc|def)';} {1}
+
+# 2022-11-17
+# https://sqlite.org/forum/forumpost/3ffe058b04
+#
+do_execsql_test regexp1-7.1 {
+ SELECT char(0x61,0x7ff,0x62) REGEXP char(0x7ff);
+} 1
+do_execsql_test regexp1-7.2 {
+ SELECT char(0x61,0x800,0x62) REGEXP char(0x800);
+} 1
+do_execsql_test regexp1-7.3 {
+ SELECT char(0x61,0xabc,0x62) REGEXP char(0xabc);
+} 1
+do_execsql_test regexp1-7.4 {
+ SELECT char(0x61,0xfff,0x62) REGEXP char(0xfff);
+} 1
+do_execsql_test regexp1-7.5 {
+ SELECT char(0x61,0x1000,0x62) REGEXP char(0x1000);
+} 1
+do_execsql_test regexp1-7.10 {
+ SELECT char(0x61,0xffff,0x62) REGEXP char(0xffff);
+} 1
+do_execsql_test regexp1-7.11 {
+ SELECT char(0x61,0x10000,0x62) REGEXP char(0x10000);
+} 1
+do_execsql_test regexp1-7.12 {
+ SELECT char(0x61,0x10ffff,0x62) REGEXP char(0x10ffff);
+} 1
+
+
+finish_test
diff --git a/test/regexp2.test b/test/regexp2.test
new file mode 100644
index 0000000..3e1da9f
--- /dev/null
+++ b/test/regexp2.test
@@ -0,0 +1,144 @@
+# 2016 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 tests for the REGEXP operator in ext/misc/regexp.c.
+# It focuses on the use of the sqlite3_set_auxdata()/get_auxdata() APIs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix regexp2
+
+load_static_extension db regexp
+
+#-------------------------------------------------------------------------
+# Test that triggers do not become confused and use aux-data created by
+# a different trigger for a different REGEXP invocation.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE x1(x, y, z);
+ CREATE TABLE x2(x, y, z);
+
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO x1 VALUES(
+ new.a REGEXP 'abc',
+ new.b REGEXP 'abc',
+ new.c REGEXP 'abc'
+ );
+ END;
+
+ CREATE TRIGGER tr2 AFTER INSERT ON t1 BEGIN
+ INSERT INTO x2 VALUES(
+ new.a REGEXP 'def',
+ new.b REGEXP 'def',
+ new.c REGEXP 'def'
+ );
+ END;
+
+ INSERT INTO t1 VALUES('abc', 'def', 'abc');
+ SELECT * FROM t1;
+} {abc def abc}
+
+do_execsql_test 1.1 { SELECT * FROM x1 } {1 0 1}
+do_execsql_test 1.2 { SELECT * FROM x2 } {0 1 0}
+
+#-------------------------------------------------------------------------
+# Test that if an exception is thrown several triggers deep, all aux-data
+# objects are cleaned up correctly.
+#
+proc sql_error {} {
+ error "SQL error!"
+}
+db func error sql_error
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(c, d);
+ CREATE TABLE t4(e, f);
+
+ CREATE TRIGGER t2_tr1 AFTER UPDATE ON t2 BEGIN
+ UPDATE t3 SET d = new.b WHERE c = old.a;
+ END;
+
+ CREATE TRIGGER t3_tr1 AFTER UPDATE ON t3 BEGIN
+ UPDATE t4 SET f = new.d WHERE e = old.c AND new.d REGEXP 'a.*';
+ END;
+
+ CREATE TRIGGER t4_tr1 AFTER UPDATE ON t4 BEGIN
+ SELECT CASE WHEN new.f REGEXP '.*y.*' THEN error() ELSE 1 END;
+ END;
+
+ INSERT INTO t2 VALUES(1, 'a_x_1');
+ INSERT INTO t2 VALUES(2, 'a_y_1');
+
+ INSERT INTO t3 VALUES(1, 'b1');
+ INSERT INTO t3 VALUES(2, 'b2');
+
+ INSERT INTO t4 VALUES(1, 'b1');
+ INSERT INTO t4 VALUES(2, 'b2');
+} {}
+
+do_catchsql_test 2.1 {
+ UPDATE t2 SET a=a+1 WHERE b REGEXP 'a.*' AND b REGEXP '.*1';
+} {1 {SQL error!}}
+
+# Test that the triggers used in the test above work as expected.
+#
+do_execsql_test 2.2 {
+ UPDATE t2 SET b = 'a_abc_1';
+} {}
+do_execsql_test 2.3 {
+ SELECT * FROM t2;
+ SELECT * FROM t3;
+ SELECT * FROM t4;
+} {1 a_abc_1 2 a_abc_1 1 a_abc_1 2 a_abc_1 1 a_abc_1 2 a_abc_1}
+
+#-------------------------------------------------------------------------
+# Test that trigger parameters (i.e. new.* and old.*) refs are not
+# considered to be constant across separate invocations of the trigger.
+#
+do_execsql_test 3.0 {
+ CREATE TABLE t5(a);
+ CREATE TABLE t6(x);
+
+ CREATE TRIGGER t5tr AFTER DELETE ON t5 BEGIN
+ DELETE FROM t6 WHERE t6.x REGEXP old.a;
+ END;
+
+ INSERT INTO t5 VALUES ('^a.*'), ('^b.*'), ('^c.*');
+ INSERT INTO t6 VALUES ('eab'), ('abc'), ('bcd'), ('cde'), ('dea');
+
+ DELETE FROM t5;
+ SELECT * FROM t6;
+} {eab dea}
+
+# 2021-06-04 Forum https://sqlite.org/forum/forumpost/9104f0d9e7
+#
+do_execsql_test 4.1 {SELECT 'abc' REGEXP '\W'} {0}
+do_execsql_test 4.2 {SELECT 'a c' REGEXP '\W'} {1}
+do_execsql_test 4.3 {SELECT ' ' REGEXP '\W'} {1}
+do_execsql_test 4.4 {SELECT 'abc' REGEXP '\w'} {1}
+do_execsql_test 4.5 {SELECT 'a c' REGEXP '\w'} {1}
+do_execsql_test 4.6 {SELECT ' ' REGEXP '\w'} {0}
+do_execsql_test 4.7 {SELECT 'abc' REGEXP '\D'} {1}
+do_execsql_test 4.8 {SELECT 'abc' REGEXP '[^a-z]'} {0}
+do_execsql_test 4.9 {SELECT 'a c' REGEXP '[^a-z]'} {1}
+do_execsql_test 4.10 {SELECT ' ' REGEXP '[^a-z]'} {1}
+do_execsql_test 4.11 {SELECT 'abc' REGEXP '[a-z]'} {1}
+do_execsql_test 4.12 {SELECT 'a c' REGEXP '[a-z]'} {1}
+do_execsql_test 4.13 {SELECT ' ' REGEXP '[a-z]'} {0}
+do_execsql_test 4.14 {SELECT 'abc' REGEXP '[^a-z]{2}'} {0}
+do_execsql_test 4.15 {SELECT 'a c' REGEXP '[^a-z]{2}'} {0}
+do_execsql_test 4.16 {SELECT ' ' REGEXP '[^a-z]{2}'} {1}
+do_execsql_test 4.17 {SELECT 'abc' REGEXP '\W{1,1}'} {0}
+do_execsql_test 4.18 {SELECT 'abc' REGEXP '\W{1}'} {0}
+
+finish_test
diff --git a/test/reindex.test b/test/reindex.test
new file mode 100644
index 0000000..88e489b
--- /dev/null
+++ b/test/reindex.test
@@ -0,0 +1,205 @@
+# 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
+set testprefix reindex
+
+# 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
+} {}
+
+#-------------------------------------------------------------------------
+foreach {tn wo} {1 "" 2 "WITHOUT ROWID"} {
+ reset_db
+ eval [string map [list %without_rowid% $wo] {
+ do_execsql_test 4.$tn.0 {
+ CREATE TABLE t0 (
+ c0 INTEGER PRIMARY KEY DESC,
+ c1 UNIQUE DEFAULT NULL
+ ) %without_rowid% ;
+ INSERT INTO t0(c0) VALUES (1), (2), (3), (4), (5);
+ SELECT c0 FROM t0 WHERE c1 IS NULL ORDER BY 1;
+ } {1 2 3 4 5}
+
+ do_execsql_test 4.$tn.1 {
+ REINDEX;
+ }
+
+ do_execsql_test 4.$tn.2 {
+ SELECT c0 FROM t0 WHERE c1 IS NULL ORDER BY 1;
+ } {1 2 3 4 5}
+
+ do_execsql_test 4.$tn.3 {
+ SELECT c0 FROM t0 WHERE c1 IS NULL AND c0 IN (1,2,3,4,5);
+ } {1 2 3 4 5}
+
+ do_execsql_test 4.$tn.4 {
+ PRAGMA integrity_check;
+ } {ok}
+ }]
+}
+
+
+
+finish_test
diff --git a/test/releasetest_data.tcl b/test/releasetest_data.tcl
new file mode 100644
index 0000000..6efc44b
--- /dev/null
+++ b/test/releasetest_data.tcl
@@ -0,0 +1,657 @@
+# 2019 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 file implements a program that produces scripts (either shell scripts
+# or batch files) to implement a particular test that is part of the SQLite
+# release testing procedure. For example, to run veryquick.test with a
+# specified set of -D compiler switches.
+#
+# A "configuration" is a set of options passed to [./configure] and [make]
+# to build the SQLite library in a particular fashion. A "platform" is a
+# list of tests; most platforms are named after the hardware/OS platform
+# that the tests will be run on as part of the release procedure. Each
+# "test" is a combination of a configuration and a makefile target (e.g.
+# "fulltest"). The program may be invoked as follows:
+#
+set USAGE {
+$argv0 script ?-msvc? CONFIGURATION TARGET
+ Given a configuration and make target, return a bash (or, if -msvc
+ is specified, batch) script to execute the test. The first argument
+ passed to the script must be a directory containing SQLite source code.
+
+$argv0 configurations
+ List available configurations.
+
+$argv0 platforms
+ List available platforms.
+
+$argv0 tests ?-nodebug? PLATFORM
+ List tests in a specified platform. If the -nodebug switch is
+ specified, synthetic debug/ndebug configurations are omitted. Each
+ test is a combination of a configuration and a makefile target.
+}
+
+# Omit comments (text between # and \n) in a long multi-line string.
+#
+proc strip_comments {in} {
+ regsub -all {#[^\n]*\n} $in {} out
+ return $out
+}
+
+array set ::Configs [strip_comments {
+ "Default" {
+ -O2
+ --disable-amalgamation --disable-shared
+ --enable-session
+ -DSQLITE_ENABLE_RBU
+ }
+ "Sanitize" {
+ CC=clang -fsanitize=address,undefined
+ -DSQLITE_ENABLE_STAT4
+ -DCONFIG_SLOWDOWN_FACTOR=5.0
+ --enable-debug
+ --enable-all
+ }
+ "Stdcall" {
+ -DUSE_STDCALL=1
+ -O2
+ }
+ "Have-Not" {
+ # The "Have-Not" configuration sets all possible -UHAVE_feature options
+ # in order to verify that the code works even on platforms that lack
+ # these support services.
+ -DHAVE_FDATASYNC=0
+ -DHAVE_GMTIME_R=0
+ -DHAVE_ISNAN=0
+ -DHAVE_LOCALTIME_R=0
+ -DHAVE_LOCALTIME_S=0
+ -DHAVE_MALLOC_USABLE_SIZE=0
+ -DHAVE_STRCHRNUL=0
+ -DHAVE_USLEEP=0
+ -DHAVE_UTIME=0
+ }
+ "Unlock-Notify" {
+ -O2
+ -DSQLITE_ENABLE_UNLOCK_NOTIFY
+ -DSQLITE_THREADSAFE
+ -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
+ }
+ "User-Auth" {
+ -O2
+ -DSQLITE_USER_AUTHENTICATION=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
+ -DSQLITE_ENABLE_STMT_SCANSTATUS
+ -DSQLITE_LIKE_DOESNT_MATCH_BLOBS
+ -DSQLITE_ENABLE_CURSOR_HINTS
+ }
+ "Check-Symbols" {
+ -DSQLITE_MEMDEBUG=1
+ -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
+ -DSQLITE_ENABLE_FTS3=1
+ -DSQLITE_ENABLE_RTREE=1
+ -DSQLITE_ENABLE_MEMSYS5=1
+ -DSQLITE_ENABLE_MEMSYS3=1
+ -DSQLITE_ENABLE_COLUMN_METADATA=1
+ -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
+ -DSQLITE_SECURE_DELETE=1
+ -DSQLITE_SOUNDEX=1
+ -DSQLITE_ENABLE_ATOMIC_WRITE=1
+ -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
+ -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
+ -DSQLITE_ENABLE_STAT4
+ -DSQLITE_ENABLE_STMT_SCANSTATUS
+ --enable-fts5 --enable-session
+ }
+ "Debug-One" {
+ --disable-shared
+ -O2 -funsigned-char
+ -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_COLUMN_METADATA=1
+ -DSQLITE_ENABLE_STAT4
+ -DSQLITE_ENABLE_HIDDEN_COLUMNS
+ -DSQLITE_MAX_ATTACHED=125
+ -DSQLITE_MUTATION_TEST
+ --enable-fts5
+ }
+ "Debug-Two" {
+ -DSQLITE_DEFAULT_MEMSTATUS=0
+ -DSQLITE_MAX_EXPR_DEPTH=0
+ --enable-debug
+ }
+ "Fast-One" {
+ -O6
+ -DSQLITE_ENABLE_FTS4=1
+ -DSQLITE_ENABLE_RTREE=1
+ -DSQLITE_ENABLE_STAT4
+ -DSQLITE_ENABLE_RBU
+ -DSQLITE_MAX_ATTACHED=125
+ -DSQLITE_MAX_MMAP_SIZE=12884901888
+ -DSQLITE_ENABLE_SORTER_MMAP=1
+ -DLONGDOUBLE_TYPE=double
+ --enable-session
+ }
+ "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_ENABLE_HIDDEN_COLUMNS
+ -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
+ --enable-fts5 --enable-session
+ }
+ "Locking-Style" {
+ -O2
+ -DSQLITE_ENABLE_LOCKING_STYLE=1
+ }
+ "Apple" {
+ -Os
+ -DHAVE_GMTIME_R=1
+ -DHAVE_ISNAN=1
+ -DHAVE_LOCALTIME_R=1
+ -DHAVE_PREAD=1
+ -DHAVE_PWRITE=1
+ -DHAVE_UTIME=1
+ -DSQLITE_DEFAULT_CACHE_SIZE=1000
+ -DSQLITE_DEFAULT_CKPTFULLFSYNC=1
+ -DSQLITE_DEFAULT_MEMSTATUS=1
+ -DSQLITE_DEFAULT_PAGE_SIZE=1024
+ -DSQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS=1
+ -DSQLITE_ENABLE_API_ARMOR=1
+ -DSQLITE_ENABLE_AUTO_PROFILE=1
+ -DSQLITE_ENABLE_FLOCKTIMEOUT=1
+ -DSQLITE_ENABLE_FTS3=1
+ -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
+ -DSQLITE_ENABLE_FTS3_TOKENIZER=1
+ -DSQLITE_ENABLE_PERSIST_WAL=1
+ -DSQLITE_ENABLE_PURGEABLE_PCACHE=1
+ -DSQLITE_ENABLE_RTREE=1
+ -DSQLITE_ENABLE_SNAPSHOT=1
+ # -DSQLITE_ENABLE_SQLLOG=1
+ -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
+ -DSQLITE_MAX_LENGTH=2147483645
+ -DSQLITE_MAX_VARIABLE_NUMBER=500000
+ # -DSQLITE_MEMDEBUG=1
+ -DSQLITE_NO_SYNC=1
+ -DSQLITE_OMIT_AUTORESET=1
+ -DSQLITE_OMIT_LOAD_EXTENSION=1
+ -DSQLITE_PREFER_PROXY_LOCKING=1
+ -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
+ -DSQLITE_THREADSAFE=2
+ -DSQLITE_USE_URI=1
+ -DSQLITE_WRITE_WALFRAME_PREBUFFERED=1
+ -DUSE_GUARDED_FD=1
+ -DUSE_PREAD=1
+ --enable-fts5
+ }
+ "Extra-Robustness" {
+ -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
+ -DSQLITE_MAX_ATTACHED=62
+ }
+ "Devkit" {
+ -DSQLITE_DEFAULT_FILE_FORMAT=4
+ -DSQLITE_MAX_ATTACHED=30
+ -DSQLITE_ENABLE_COLUMN_METADATA
+ -DSQLITE_ENABLE_FTS4
+ -DSQLITE_ENABLE_FTS5
+ -DSQLITE_ENABLE_FTS4_PARENTHESIS
+ -DSQLITE_DISABLE_FTS4_DEFERRED
+ -DSQLITE_ENABLE_RTREE
+ --enable-fts5
+ }
+ "No-lookaside" {
+ -DSQLITE_TEST_REALLOC_STRESS=1
+ -DSQLITE_OMIT_LOOKASIDE=1
+ }
+ "Valgrind" {
+ -DSQLITE_ENABLE_STAT4
+ -DSQLITE_ENABLE_FTS4
+ -DSQLITE_ENABLE_RTREE
+ -DSQLITE_ENABLE_HIDDEN_COLUMNS
+ -DCONFIG_SLOWDOWN_FACTOR=8.0
+ }
+
+ "Windows-Memdebug" {
+ MEMDEBUG=1
+ DEBUG=3
+ }
+ "Windows-Win32Heap" {
+ WIN32HEAP=1
+ DEBUG=4
+ }
+
+ # The next group of configurations are used only by the
+ # Failure-Detection platform. They are all the same, but we need
+ # different names for them all so that they results appear in separate
+ # subdirectories.
+ #
+ Fail0 {-O0}
+ Fail2 {-O0}
+ Fail3 {-O0}
+ Fail4 {-O0}
+ FuzzFail1 {-O0}
+ FuzzFail2 {-O0}
+}]
+if {$tcl_platform(os)=="Darwin"} {
+ lappend Configs(Apple) -DSQLITE_ENABLE_LOCKING_STYLE=1
+}
+
+array set ::Platforms [strip_comments {
+ Linux-x86_64 {
+ "Check-Symbols*" "" checksymbols
+ "Fast-One" QUICKTEST_INCLUDE=rbu.test "fuzztest test"
+ "Debug-One" "" "mptest test"
+ "Debug-Two" "" test
+ "Have-Not" "" test
+ "Secure-Delete" "" test
+ "Unlock-Notify" QUICKTEST_INCLUDE=notify2.test test
+ "User-Auth" "" tcltest
+ "Update-Delete-Limit" "" test
+ "Extra-Robustness" "" test
+ "Device-Two" "" "threadtest test"
+ "No-lookaside" "" test
+ "Devkit" "" test
+ "Apple" "" test
+ "Sanitize*" "" test
+ "Device-One" "" alltest
+ "Default" "" "threadtest fuzztest alltest"
+ "Valgrind*" "" valgrindtest
+ }
+ Linux-i686 {
+ "Devkit" "" test
+ "Have-Not" "" test
+ "Unlock-Notify" QUICKTEST_INCLUDE=notify2.test test
+ "Device-One" "" test
+ "Device-Two" "" test
+ "Default" "" "threadtest fuzztest alltest"
+ }
+ Darwin-i386 {
+ "Locking-Style" "" "mptest test"
+ "Have-Not" "" test
+ "Apple" "" "threadtest fuzztest alltest"
+ }
+ Darwin-x86_64 {
+ "Locking-Style" "" "mptest test"
+ "Have-Not" "" test
+ "Apple" "" "threadtest fuzztest alltest"
+ }
+ Darwin-arm64 {
+ "Locking-Style" "" "mptest test"
+ "Have-Not" "" test
+ "Apple" "" "threadtest fuzztest alltest"
+ }
+ "Windows NT-intel" {
+ "Stdcall" "" test
+ "Have-Not" "" test
+ "Windows-Memdebug*" "" test
+ "Windows-Win32Heap*" "" test
+ "Default" "" "mptest fulltestonly"
+ }
+ "Windows NT-amd64" {
+ "Stdcall" "" test
+ "Have-Not" "" test
+ "Windows-Memdebug*" "" test
+ "Windows-Win32Heap*" "" test
+ "Default" "" "mptest fulltestonly"
+ }
+
+ # The Failure-Detection platform runs various tests that deliberately
+ # fail. This is used as a test of this script to verify that this script
+ # correctly identifies failures.
+ #
+ Failure-Detection {
+ Fail0* "TEST_FAILURE=0" test
+ Sanitize* "TEST_FAILURE=1" test
+ Fail2* "TEST_FAILURE=2" valgrindtest
+ Fail3* "TEST_FAILURE=3" valgrindtest
+ Fail4* "TEST_FAILURE=4" test
+ FuzzFail1* "TEST_FAILURE=5" test
+ FuzzFail2* "TEST_FAILURE=5" valgrindtest
+ }
+}]
+
+#--------------------------------------------------------------------------
+#--------------------------------------------------------------------------
+#--------------------------------------------------------------------------
+# End of configuration section.
+#--------------------------------------------------------------------------
+#--------------------------------------------------------------------------
+#--------------------------------------------------------------------------
+
+# Configuration verification: Check that each entry in the list of configs
+# specified for each platforms exists.
+#
+foreach {key value} [array get ::Platforms] {
+ foreach {v vars t} $value {
+ if {[string range $v end end]=="*"} {
+ set v [string range $v 0 end-1]
+ }
+ if {0==[info exists ::Configs($v)]} {
+ puts stderr "No such configuration: \"$v\""
+ exit -1
+ }
+ }
+}
+
+proc usage {} {
+ global argv0
+ puts stderr [subst $::USAGE]
+ exit 1
+}
+
+proc is_prefix {p str min} {
+ set n [string length $p]
+ if {$n<$min} { return 0 }
+ if {[string range $str 0 [expr $n-1]]!=$p} { return 0 }
+ return 1
+}
+
+proc main_configurations {} {
+ foreach k [lsort [array names ::Configs]] {
+ puts $k
+ }
+}
+
+proc main_platforms {} {
+ foreach k [lsort [array names ::Platforms]] {
+ puts "\"$k\""
+ }
+}
+
+proc main_script {args} {
+ set bMsvc 0
+ set nArg [llength $args]
+ if {$nArg==3} {
+ if {![is_prefix [lindex $args 0] -msvc 2]} usage
+ set bMsvc 1
+ } elseif {$nArg<2 || $nArg>3} {
+ usage
+ }
+ set config [lindex $args end-1]
+ set target [lindex $args end]
+
+ set opts [list] ;# OPTS value
+ set cflags [expr {$bMsvc ? "-Zi" : "-g"}] ;# CFLAGS value
+ set makeOpts [list] ;# Extra args for [make]
+ set configOpts [list] ;# Extra args for [configure]
+
+ if {$::tcl_platform(platform)=="windows" || $bMsvc} {
+ lappend opts -DSQLITE_OS_WIN=1
+ } else {
+ lappend opts -DSQLITE_OS_UNIX=1
+ }
+
+ # Figure out if this is a synthetic ndebug or debug configuration.
+ #
+ set bRemoveDebug 0
+ if {[string match *-ndebug $config]} {
+ set bRemoveDebug 1
+ set config [string range $config 0 end-7]
+ }
+ if {[string match *-debug $config]} {
+ lappend opts -DSQLITE_DEBUG
+ lappend opts -DSQLITE_EXTRA_IFNULLROW
+ set config [string range $config 0 end-6]
+ }
+ regexp {^(.*)-[0-9]+} $config -> config
+
+ # Ensure that the named configuration exists.
+ #
+ if {![info exists ::Configs($config)]} {
+ puts stderr "No such config: $config"
+ exit 1
+ }
+
+ # Loop through the parameters of the nominated configuration, updating
+ # $opts, $cflags, $makeOpts and $configOpts along the way. Rules are as
+ # follows:
+ #
+ # 1. If the parameter begins with a "*", discard it.
+ #
+ # 2. If $bRemoveDebug is set and the parameter is -DSQLITE_DEBUG or
+ # -DSQLITE_DEBUG=1, discard it
+ #
+ # 3. If the parameter begins with "-D", add it to $opts.
+ #
+ # 4. If the parameter begins with "--" add it to $configOpts. Unless
+ # this command is preparing a script for MSVC - then add an
+ # equivalent to $makeOpts or $opts.
+ #
+ # 5. If the parameter begins with "-" add it to $cflags. If in MSVC
+ # mode and the parameter is an -O<integer> option, instead add
+ # an OPTIMIZATIONS=<integer> switch to $makeOpts.
+ #
+ # 6. If none of the above apply, add the parameter to $makeOpts
+ #
+ foreach param $::Configs($config) {
+ if {[string range $param 0 0]=="*"} continue
+
+ if {$bRemoveDebug} {
+ if {$param=="-DSQLITE_DEBUG" || $param=="-DSQLITE_DEBUG=1"
+ || $param=="-DSQLITE_MEMDEBUG" || $param=="-DSQLITE_MEMDEBUG=1"
+ || $param=="--enable-debug"
+ } {
+ continue
+ }
+ }
+
+ if {[string range $param 0 1]=="-D"} {
+ lappend opts $param
+ continue
+ }
+
+ if {[string range $param 0 1]=="--"} {
+ if {$bMsvc} {
+ switch -- $param {
+ --disable-amalgamation {
+ lappend makeOpts USE_AMALGAMATION=0
+ }
+ --disable-shared {
+ lappend makeOpts USE_CRT_DLL=0 DYNAMIC_SHELL=0
+ }
+ --enable-fts5 {
+ lappend opts -DSQLITE_ENABLE_FTS5
+ }
+ --enable-shared {
+ lappend makeOpts USE_CRT_DLL=1 DYNAMIC_SHELL=1
+ }
+ --enable-session {
+ lappend opts -DSQLITE_ENABLE_PREUPDATE_HOOK
+ lappend opts -DSQLITE_ENABLE_SESSION
+ }
+ default {
+ error "Cannot translate $param for MSVC"
+ }
+ }
+ } else {
+ lappend configOpts $param
+ }
+
+ continue
+ }
+
+ if {[string range $param 0 0]=="-"} {
+ if {$bMsvc && [regexp -- {^-O(\d+)$} $param -> level]} {
+ lappend makeOpts OPTIMIZATIONS=$level
+ } else {
+ lappend cflags $param
+ }
+ continue
+ }
+
+ lappend makeOpts $param
+ }
+
+ # Some configurations specify -DHAVE_USLEEP=0. For all others, add
+ # -DHAVE_USLEEP=1.
+ #
+ if {[lsearch $opts "-DHAVE_USLEEP=0"]<0} {
+ lappend opts -DHAVE_USLEEP=1
+ }
+
+ if {$bMsvc==0} {
+ puts {set -e}
+ puts {}
+ puts {if [ "$#" -ne 1 ] ; then}
+ puts { echo "Usage: $0 <sqlite-src-dir>" }
+ puts { exit -1 }
+ puts {fi }
+ puts {SRCDIR=$1}
+ puts {}
+ puts "TCL=\"[::tcl::pkgconfig get libdir,install]\""
+
+ puts "\$SRCDIR/configure --with-tcl=\$TCL $configOpts"
+ puts {}
+ puts {OPTS=" -DSQLITE_NO_SYNC=1"}
+ foreach o $opts {
+ puts "OPTS=\"\$OPTS $o\""
+ }
+ puts {}
+ puts "CFLAGS=\"$cflags\""
+ puts {}
+ puts "make $target \"CFLAGS=\$CFLAGS\" \"OPTS=\$OPTS\" $makeOpts"
+ } else {
+
+ puts {set SRCDIR=%1}
+ set makecmd "nmake /f %SRCDIR%\\Makefile.msc TOP=%SRCDIR% $target "
+ append makecmd "\"CFLAGS=$cflags\" \"OPTS=$opts\" $makeOpts"
+
+ puts "set TMP=%CD%"
+ puts $makecmd
+ }
+}
+
+proc main_tests {args} {
+ set bNodebug 0
+ set nArg [llength $args]
+ if {$nArg==2} {
+ if {[is_prefix [lindex $args 0] -nodebug 2]} {
+ set bNodebug 1
+ } elseif {[is_prefix [lindex $args 0] -debug 2]} {
+ set bNodebug 0
+ } else usage
+ } elseif {$nArg==0 || $nArg>2} {
+ usage
+ }
+ set p [lindex $args end]
+ if {![info exists ::Platforms($p)]} {
+ puts stderr "No such platform: $p"
+ exit 1
+ }
+
+ set lTest [list]
+
+ foreach {config vars target} $::Platforms($p) {
+ if {[string range $config end end]=="*"} {
+ set config [string range $config 0 end-1]
+ } elseif {$bNodebug==0} {
+ set dtarget test
+ if {[lsearch $target fuzztest]<0 && [lsearch $target test]<0} {
+ set dtarget tcltest
+ }
+ if {$vars!=""} { set dtarget "$vars $dtarget" }
+
+ if {[string first SQLITE_DEBUG $::Configs($config)]>=0
+ || [string first --enable-debug $::Configs($config)]>=0
+ } {
+ lappend lTest "$config-ndebug \"$dtarget\""
+ } else {
+ lappend lTest "$config-debug \"$dtarget\""
+ }
+ }
+
+ if {[llength $target]==1 && ([string match "*TEST_FAILURE*" $vars] || (
+ [lsearch $target "valgrindtest"]<0
+ && [lsearch $target "alltest"]<0
+ && [lsearch $target "fulltestonly"]<0
+ && ![string match Sanitize* $config]
+ ))} {
+ if {$vars!=""} { set target "$vars $target" }
+ lappend lTest "$config \"$target\""
+ } else {
+ set idir -1
+ foreach t $target {
+ if {$t=="valgrindtest" || $t=="alltest" || $t=="fulltestonly"
+ || [string match Sanitize* $config]
+ } {
+ if {$vars!=""} { set t "$vars $t" }
+ for {set ii 1} {$ii<=4} {incr ii} {
+ lappend lTest "$config-[incr idir] \"TCLTEST_PART=$ii/4 $t\""
+ }
+ } else {
+ if {$vars!=""} { set t "$vars $t" }
+ lappend lTest "$config-[incr idir] \"$t\""
+ }
+ }
+ }
+ }
+
+ foreach l $lTest {
+ puts $l
+ }
+
+}
+
+if {[llength $argv]==0} { usage }
+set cmd [lindex $argv 0]
+set n [expr [llength $argv]-1]
+if {[string match ${cmd}* configurations] && $n==0} {
+ main_configurations
+} elseif {[string match ${cmd}* script]} {
+ main_script {*}[lrange $argv 1 end]
+} elseif {[string match ${cmd}* platforms] && $n==0} {
+ main_platforms
+} elseif {[string match ${cmd}* tests]} {
+ main_tests {*}[lrange $argv 1 end]
+} else {
+ usage
+}
diff --git a/test/resetdb.test b/test/resetdb.test
new file mode 100644
index 0000000..bdb8354
--- /dev/null
+++ b/test/resetdb.test
@@ -0,0 +1,258 @@
+# 2018-04-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.
+#
+#***********************************************************************
+# Test cases for SQLITE_DBCONFIG_RESET_DATABASE
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix resetdb
+
+do_not_use_codec
+
+ifcapable !vtab||!compound {
+ finish_test
+ return
+}
+
+# In the "inmemory_journal" permutation, each new connection executes
+# "PRAGMA journal_mode = memory". This fails with SQLITE_BUSY if attempted
+# on a wal mode database with existing connections. For this and a few
+# other reasons, this test is not run as part of "inmemory_journal".
+#
+# Permutation "journaltest" does not support wal mode.
+#
+if {[permutation]=="inmemory_journal"
+ || [permutation]=="journaltest"
+} {
+ finish_test
+ return
+}
+
+# Create a sample database
+do_execsql_test 100 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size=4096;
+ CREATE TABLE t1(a,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)
+ INSERT INTO t1(a,b) SELECT x, randomblob(300) FROM c;
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ SELECT sum(a), sum(length(b)) FROM t1;
+ PRAGMA integrity_check;
+ PRAGMA journal_mode;
+ PRAGMA page_count;
+} {210 6000 ok delete 8}
+
+# Verify that the same content is seen from a separate database connection
+sqlite3 db2 test.db
+do_test 110 {
+ execsql {
+ SELECT sum(a), sum(length(b)) FROM t1;
+ PRAGMA integrity_check;
+ PRAGMA journal_mode;
+ PRAGMA page_count;
+ } db2
+} {210 6000 ok delete 8}
+
+do_test 200 {
+ # Thoroughly corrupt the database file by overwriting the first
+ # page with randomness.
+ sqlite3_db_config db DEFENSIVE 0
+ catchsql {
+ UPDATE sqlite_dbpage SET data=randomblob(4096) WHERE pgno=1;
+ PRAGMA quick_check;
+ }
+} {1 {file is not a database}}
+do_test 201 {
+ catchsql {
+ PRAGMA quick_check;
+ } db2
+} {1 {file is not a database}}
+
+do_test 210 {
+ # Reset the database file using SQLITE_DBCONFIG_RESET_DATABASE
+ sqlite3_db_config db RESET_DB 1
+ db eval VACUUM
+ sqlite3_db_config db RESET_DB 0
+
+ # If using sqlite3_prepare() instead of _v2() or _v3(), the block
+ # below raises an SQLITE_SCHEMA error. The following fixes this.
+ if {[permutation]=="prepare"} { catchsql "SELECT * FROM sqlite_master" db2 }
+
+ # Verify that the reset took, even on the separate database connection
+ catchsql {
+ PRAGMA page_count;
+ PRAGMA page_size;
+ PRAGMA quick_check;
+ PRAGMA journal_mode;
+ } db2
+} {0 {1 4096 ok delete}}
+
+# Delete the old connections and database and start over again
+# with a different page size and in WAL mode.
+#
+db close
+db2 close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 300 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size=8192;
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(a,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)
+ INSERT INTO t1(a,b) SELECT x, randomblob(1300) FROM c;
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ SELECT sum(a), sum(length(b)) FROM t1;
+ PRAGMA integrity_check;
+ PRAGMA journal_mode;
+ PRAGMA page_size;
+ PRAGMA page_count;
+} {wal 210 26000 ok wal 8192 12}
+sqlite3 db2 test.db
+do_test 310 {
+ execsql {
+ SELECT sum(a), sum(length(b)) FROM t1;
+ PRAGMA integrity_check;
+ PRAGMA journal_mode;
+ PRAGMA page_size;
+ PRAGMA page_count;
+ } db2
+} {210 26000 ok wal 8192 12}
+
+# Corrupt the database again
+sqlite3_db_config db DEFENSIVE 0
+do_catchsql_test 320 {
+ UPDATE sqlite_dbpage SET data=randomblob(8192) WHERE pgno=1;
+ PRAGMA quick_check
+} {1 {file is not a database}}
+
+do_test 330 {
+ catchsql {
+ PRAGMA quick_check
+ } db2
+} {1 {file is not a database}}
+
+db2 cache flush ;# Required by permutation "prepare".
+
+# Reset the database yet again. Verify that the page size and
+# journal mode are preserved.
+#
+do_test 400 {
+ sqlite3_db_config db RESET_DB 1
+ db eval VACUUM
+ sqlite3_db_config db RESET_DB 0
+ catchsql {
+ PRAGMA page_count;
+ PRAGMA page_size;
+ PRAGMA journal_mode;
+ PRAGMA quick_check;
+ } db2
+} {0 {1 8192 wal ok}}
+db2 close
+
+# Reset the database yet again. This time immediately after it is closed
+# and reopened. So that the VACUUM is the first statement run.
+#
+db close
+sqlite3 db test.db
+do_test 500 {
+ sqlite3_finalize [
+ sqlite3_prepare db "SELECT 1 FROM sqlite_master LIMIT 1" -1 tail
+ ]
+ sqlite3_db_config db RESET_DB 1
+ db eval VACUUM
+ sqlite3_db_config db RESET_DB 0
+ sqlite3 db2 test.db
+ catchsql {
+ PRAGMA page_count;
+ PRAGMA page_size;
+ PRAGMA journal_mode;
+ PRAGMA quick_check;
+ } db2
+} {0 {1 8192 wal ok}}
+db2 close
+
+#-------------------------------------------------------------------------
+reset_db
+sqlite3 db2 test.db
+do_execsql_test 600 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1), (2), (3), (4);
+} {wal}
+
+do_execsql_test -db db2 610 {
+ SELECT * FROM t1
+} {1 2 3 4}
+
+do_test 620 {
+ set res [list]
+ db2 eval {SELECT a FROM t1} {
+ lappend res $a
+ if {$a==3} {
+ sqlite3_db_config db RESET_DB 1
+ db eval VACUUM
+ sqlite3_db_config db RESET_DB 0
+ }
+ }
+
+ set res
+} {1 2 3 4}
+
+do_execsql_test -db db2 630 {
+ SELECT * FROM sqlite_master
+} {}
+
+#-------------------------------------------------------------------------
+db2 close
+reset_db
+
+do_execsql_test 700 {
+ PRAGMA page_size=512;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1bc ON t1(b,c);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10)
+ INSERT INTO t1(a,b,c) SELECT x, randomblob(100),randomblob(100) FROM c;
+ PRAGMA page_count;
+ PRAGMA integrity_check;
+} {19 ok}
+
+if {[nonzero_reserved_bytes]} {
+ finish_test
+ return
+}
+
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 710 {
+ UPDATE sqlite_dbpage SET data=
+ X'53514C69746520666F726D61742033000200030100402020000000000000001300000000000000000000000300000004000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000D00000003017C0001D801AC017C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002E03061715110145696E6465787431626374310443524541544520494E4445582074316263204F4E20743128622C63292A0206171311013F696E64657874316174310343524541544520494E44455820743161204F4E20743128612926010617111101397461626C657431743102435245415445205441424C4520743128612C622C6329' WHERE pgno=1;
+}
+
+do_execsql_test 720 {
+ PRAGMA integrity_check;
+} {ok}
+
+do_test 730 {
+ sqlite3_db_config db RESET_DB 1
+ db eval VACUUM
+ sqlite3_db_config db RESET_DB 0
+} {0}
+
+do_execsql_test 740 {
+ PRAGMA page_count;
+ PRAGMA integrity_check;
+} {1 ok}
+
+finish_test
diff --git a/test/resolver01.test b/test/resolver01.test
new file mode 100644
index 0000000..59bb3c0
--- /dev/null
+++ b/test/resolver01.test
@@ -0,0 +1,216 @@
+# 2013-04-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 features of the name resolver (the component that
+# figures out what identifiers in the SQL statement refer to) that
+# were fixed by ticket [2500cdb9be].
+#
+# See also tickets [1c69be2daf] and [f617ea3125] from 2013-08-14.
+#
+# Also a fuzzer-discovered problem on 2015-04-23.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# "ORDER BY y" binds to the output result-set column named "y"
+# if available. If no output column is named "y", then try to
+# bind against an input column named "y".
+#
+# This is classical SQL92 behavior.
+#
+do_test resolver01-1.1 {
+ catchsql {
+ CREATE TABLE t1(x, y); INSERT INTO t1 VALUES(11,22);
+ CREATE TABLE t2(y, z); INSERT INTO t2 VALUES(33,44);
+ SELECT 1 AS y FROM t1, t2 ORDER BY y;
+ }
+} {0 1}
+do_test resolver01-1.2 {
+ catchsql {
+ SELECT 1 AS yy FROM t1, t2 ORDER BY y;
+ }
+} {1 {ambiguous column name: y}}
+do_test resolver01-1.3 {
+ catchsql {
+ CREATE TABLE t3(x,y); INSERT INTO t3 VALUES(11,44),(33,22);
+ SELECT x AS y FROM t3 ORDER BY y;
+ }
+} {0 {11 33}}
+do_test resolver01-1.4 {
+ catchsql {
+ SELECT x AS yy FROM t3 ORDER BY y;
+ }
+} {0 {33 11}}
+
+# SQLite allows the WHERE clause to reference output columns if there is
+# no other way to resolve the name.
+#
+do_test resolver01-1.5 {
+ catchsql {
+ SELECT x AS yy FROM t3 ORDER BY yy;
+ }
+} {0 {11 33}}
+do_test resolver01-1.6 {
+ catchsql {
+ SELECT x AS yy FROM t3 ORDER BY 1;
+ }
+} {0 {11 33}}
+
+# The "ORDER BY y COLLATE nocase" form works the same as "ORDER BY y".
+# The "y" binds more tightly to output columns than to input columns.
+#
+# This is for compatibility with SQL92 and with historical SQLite behavior.
+# Note that PostgreSQL considers "y COLLATE nocase" to be an expression
+# and thus PostgreSQL treats this case as if it where the 3.x case below.
+#
+do_test resolver01-2.1 {
+ catchsql {
+ SELECT 2 AS y FROM t1, t2 ORDER BY y COLLATE nocase;
+ }
+} {0 2}
+do_test resolver01-2.2 {
+ catchsql {
+ SELECT 2 AS yy FROM t1, t2 ORDER BY y COLLATE nocase;
+ }
+} {1 {ambiguous column name: y}}
+do_test resolver01-2.3 {
+ catchsql {
+ SELECT x AS y FROM t3 ORDER BY y COLLATE nocase;
+ }
+} {0 {11 33}}
+do_test resolver01-2.4 {
+ catchsql {
+ SELECT x AS yy FROM t3 ORDER BY y COLLATE nocase;
+ }
+} {0 {33 11}}
+do_test resolver01-2.5 {
+ catchsql {
+ SELECT x AS yy FROM t3 ORDER BY yy COLLATE nocase;
+ }
+} {0 {11 33}}
+do_test resolver01-2.6 {
+ catchsql {
+ SELECT x AS yy FROM t3 ORDER BY 1 COLLATE nocase;
+ }
+} {0 {11 33}}
+
+# But if the form is "ORDER BY expr" then bind more tightly to the
+# the input column names and only use the output column names if no
+# input column name matches.
+#
+# This is SQL99 behavior, as implemented by PostgreSQL and MS-SQL.
+# Note that Oracle works differently.
+#
+do_test resolver01-3.1 {
+ catchsql {
+ SELECT 3 AS y FROM t1, t2 ORDER BY +y;
+ }
+} {1 {ambiguous column name: y}}
+do_test resolver01-3.2 {
+ catchsql {
+ SELECT 2 AS yy FROM t1, t2 ORDER BY +y;
+ }
+} {1 {ambiguous column name: y}}
+do_test resolver01-3.3 {
+ catchsql {
+ SELECT x AS y FROM t3 ORDER BY +y;
+ }
+} {0 {33 11}}
+do_test resolver01-3.4 {
+ catchsql {
+ SELECT x AS yy FROM t3 ORDER BY +y;
+ }
+} {0 {33 11}}
+do_test resolver01-3.5 {
+ catchsql {
+ SELECT x AS yy FROM t3 ORDER BY +yy
+ }
+} {0 {11 33}}
+
+# This is the test case given in ticket [f617ea3125e9] (with table name
+# changed from "t1" to "t4". The behavior of (1) and (3) match with
+# PostgreSQL, but we intentionally break with PostgreSQL to provide
+# SQL92 behavior for case (2).
+#
+do_execsql_test resolver01-4.1 {
+ CREATE TABLE t4(m CHAR(2));
+ INSERT INTO t4 VALUES('az');
+ INSERT INTO t4 VALUES('by');
+ INSERT INTO t4 VALUES('cx');
+ SELECT '1', substr(m,2) AS m FROM t4 ORDER BY m;
+ SELECT '2', substr(m,2) AS m FROM t4 ORDER BY m COLLATE binary;
+ SELECT '3', substr(m,2) AS m FROM t4 ORDER BY lower(m);
+} {1 x 1 y 1 z 2 x 2 y 2 z 3 z 3 y 3 x}
+
+##########################################################################
+# Test cases for ticket [1c69be2dafc28]: Make sure the GROUP BY binds
+# more tightly to the input tables in all cases.
+#
+# This first case case has been wrong in SQLite for time out of mind.
+# For SQLite version 3.7.17 the answer was two rows, which is wrong.
+#
+do_execsql_test resolver01-5.1 {
+ CREATE TABLE t5(m CHAR(2));
+ INSERT INTO t5 VALUES('ax');
+ INSERT INTO t5 VALUES('bx');
+ INSERT INTO t5 VALUES('cy');
+ SELECT count(*), substr(m,2,1) AS m FROM t5 GROUP BY m ORDER BY 1, 2;
+} {1 x 1 x 1 y}
+
+# This case is unambiguous and has always been correct.
+#
+do_execsql_test resolver01-5.2 {
+ SELECT count(*), substr(m,2,1) AS mx FROM t5 GROUP BY m ORDER BY 1, 2;
+} {1 x 1 x 1 y}
+
+# This case is not allowed in standard SQL, but SQLite allows and does
+# the sensible thing.
+#
+do_execsql_test resolver01-5.3 {
+ SELECT count(*), substr(m,2,1) AS mx FROM t5 GROUP BY mx ORDER BY 1, 2;
+} {1 y 2 x}
+do_execsql_test resolver01-5.4 {
+ SELECT count(*), substr(m,2,1) AS mx FROM t5
+ GROUP BY substr(m,2,1) ORDER BY 1, 2;
+} {1 y 2 x}
+
+# These test case weere provided in the 2013-08-14 email from Rob Golsteijn
+# that originally reported the problem of ticket [1c69be2dafc28].
+#
+do_execsql_test resolver01-6.1 {
+ CREATE TABLE t61(name);
+ SELECT min(name) FROM t61 GROUP BY lower(name);
+} {}
+do_execsql_test resolver01-6.2 {
+ SELECT min(name) AS name FROM t61 GROUP BY lower(name);
+} {}
+do_execsql_test resolver01-6.3 {
+ CREATE TABLE t63(name);
+ INSERT INTO t63 VALUES (NULL);
+ INSERT INTO t63 VALUES ('abc');
+ SELECT count(),
+ NULLIF(name,'abc') AS name
+ FROM t63
+ GROUP BY lower(name);
+} {1 {} 1 {}}
+
+do_execsql_test resolver01-7.1 {
+ SELECT 2 AS x WHERE (SELECT x AS y WHERE 3>y);
+} {2}
+do_execsql_test resolver01-7.2 {
+ SELECT 2 AS x WHERE (SELECT x AS y WHERE 1>y);
+} {}
+
+
+
+
+finish_test
diff --git a/test/returning1.test b/test/returning1.test
new file mode 100644
index 0000000..92e10ee
--- /dev/null
+++ b/test/returning1.test
@@ -0,0 +1,403 @@
+# 2021-01-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 the new RETURNING clause
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix returning1
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c DEFAULT 'pax');
+ INSERT INTO t1(b) VALUES(10),('happy'),(NULL) RETURNING a,b,c;
+} {1 10 pax 2 happy pax 3 {} pax}
+do_execsql_test 1.1 {
+ SELECT * FROM t1;
+} {1 10 pax 2 happy pax 3 {} pax}
+do_execsql_test 1.2 {
+ INSERT INTO t1(b,c) VALUES(5,99) RETURNING b,c,a,rowid;
+} {5 99 4 4}
+do_execsql_test 1.3 {
+ SELECT * FROM t1;
+} {1 10 pax 2 happy pax 3 {} pax 4 5 99}
+do_execsql_test 1.4 {
+ INSERT INTO t1 DEFAULT VALUES RETURNING *;
+} {5 {} pax}
+do_execsql_test 1.5 {
+ SELECT * FROM t1;
+} {1 10 pax 2 happy pax 3 {} pax 4 5 99 5 {} pax}
+do_execsql_test 1.6 {
+ CREATE TABLE t2(x,y,z);
+ INSERT INTO t2 VALUES(11,12,13),(21,'b','c'),(31,'b-value',4.75);
+}
+do_execsql_test 1.7 {
+ INSERT INTO t1 SELECT * FROM t2 RETURNING *;
+} {11 12 13 21 b c 31 b-value 4.75}
+do_execsql_test 1.8 {
+ SELECT *, '|' FROM t1;
+} {1 10 pax | 2 happy pax | 3 {} pax | 4 5 99 | 5 {} pax | 11 12 13 | 21 b c | 31 b-value 4.75 |}
+
+do_execsql_test 2.1 {
+ UPDATE t1 SET c='bellum' WHERE c='pax' RETURNING rowid, b, '|';
+} {1 10 | 2 happy | 3 {} | 5 {} |}
+do_execsql_test 2.2 {
+ SELECT *, '|' FROM t1;
+} {1 10 bellum | 2 happy bellum | 3 {} bellum | 4 5 99 | 5 {} bellum | 11 12 13 | 21 b c | 31 b-value 4.75 |}
+
+do_execsql_test 3.1 {
+ DELETE FROM t1 WHERE c='bellum' RETURNING rowid, *, '|';
+} {1 1 10 bellum | 2 2 happy bellum | 3 3 {} bellum | 5 5 {} bellum |}
+do_execsql_test 3.2 {
+ SELECT *, '|' FROM t1;
+} {4 5 99 | 11 12 13 | 21 b c | 31 b-value 4.75 |}
+
+do_execsql_test 4.1 {
+ CREATE TABLE t4(a INT, b INT DEFAULT 1234, c INT DEFAULT -16);
+ CREATE UNIQUE INDEX t4a ON t4(a);
+ INSERT INTO t4(a,b,c) VALUES(1,2,3);
+} {}
+do_execsql_test 4.2 {
+ INSERT INTO t4(a,b,c) VALUES(1,22,33)
+ ON CONFLICT(a) DO UPDATE SET b=44
+ RETURNING *;
+} {1 44 3}
+do_execsql_test 4.3 {
+ SELECT * FROM t4;
+} {1 44 3}
+do_execsql_test 4.4 {
+ DELETE FROM t4;
+ INSERT INTO t4 VALUES(1,2,3),(4,5,6),(7,8,9);
+} {}
+do_execsql_test 4.5 {
+ INSERT INTO t4(a,b,c) VALUES(2,3,4),(4,5,6),(5,6,7)
+ ON CONFLICT(a) DO UPDATE SET b=100
+ RETURNING *, '|';
+} {2 3 4 | 4 100 6 | 5 6 7 |}
+
+#-------------------------------------------------------------------------
+# Test RETURNING on a table with virtual columns.
+#
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(xyz);
+ CREATE TABLE t2(a as (1+1), b);
+}
+
+do_execsql_test 5.1 {
+ UPDATE t2 SET b='123' WHERE b='abc' RETURNING (SELECT b FROM t1);
+} {}
+
+do_execsql_test 5.2 {
+ INSERT INTO t2(b) VALUES('abc');
+}
+
+do_execsql_test 5.3 {
+ UPDATE t2 SET b='123' WHERE b='abc' RETURNING (SELECT b FROM t1);
+} {{}}
+
+do_execsql_test 5.4 {
+ INSERT INTO t2(b) VALUES('abc');
+ INSERT INTO t1(xyz) VALUES(1);
+ UPDATE t2 SET b='123' WHERE b='abc' RETURNING b;
+} {123}
+
+do_execsql_test 5.5 {
+ INSERT INTO t2(b) VALUES('abc');
+ UPDATE t2 SET b='123' WHERE b='abc' RETURNING (SELECT b FROM t1);
+} {123}
+
+# Ticket 132994c8b1063bfb
+reset_db
+do_catchsql_test 6.0 {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY);
+ CREATE TABLE t2(x INT, y INT);
+ INSERT INTO t1 VALUES(1),(2),(4),(9);
+ INSERT INTO t2 VALUES(3,7), (4,25), (5,99);
+ UPDATE t1 SET id=id+y FROM t2 WHERE t1.id=t2.x RETURNING t2.*;
+} {1 {RETURNING may not use "TABLE.*" wildcards}}
+do_catchsql_test 6.1 {
+ UPDATE t1 SET id=id+y FROM t2 WHERE t1.id=t2.x RETURNING *, '|';
+ SELECT * FROM t1 ORDER BY id;
+} {0 {29 | 1 2 9 29}}
+
+# Forum https://sqlite.org/forum/forumpost/85aef8bc01
+# Do not silently ignore nonsense table names in the RETURNING clause.
+# Raise an error.
+#
+reset_db
+do_execsql_test 7.1 {
+ CREATE TABLE t1(a INT, b INT);
+ CREATE TABLE t2(x INT, y INT);
+ INSERT INTO t1(a,b) VALUES(1,2);
+ INSERT INTO t2(x,y) VALUES(1,30);
+} {}
+do_catchsql_test 7.2 {
+ UPDATE t1 SET b=b+1 RETURNING new.b;
+} {1 {no such column: new.b}}
+do_catchsql_test 7.3 {
+ UPDATE t1 SET b=b+1 RETURNING old.b;
+} {1 {no such column: old.b}}
+do_catchsql_test 7.4 {
+ UPDATE t1 SET b=b+1 RETURNING another.b;
+} {1 {no such column: another.b}}
+do_catchsql_test 7.5 {
+ UPDATE t1 SET b=b+y FROM t2 WHERE t2.x=t1.a RETURNING t2.x;
+} {1 {no such column: t2.x}}
+do_catchsql_test 7.6 {
+ UPDATE t1 SET b=b+y FROM t2 WHERE t2.x=t1.a RETURNING t1.b;
+} {0 32}
+
+# This is goofy: The RETURNING clause does not honor the alias
+# for the table being modified. This might change in the future.
+#
+do_catchsql_test 7.7 {
+ UPDATE t1 AS alias SET b=123 RETURNING alias.b;
+} {1 {no such column: alias.b}}
+do_catchsql_test 7.8 {
+ UPDATE t1 AS alias SET b=alias.b+1000 RETURNING t1.b;
+} {0 1032}
+
+# Forum: https://sqlite.org/forum/info/34c81d83c9177f46
+reset_db
+do_execsql_test 8.1 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(b,c);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t2 VALUES(3,40);
+} {}
+do_catchsql_test 8.2 {
+ INSERT INTO t1 VALUES(3) RETURNING a, (SELECT c FROM t2 WHERE new.a=t2.b) AS x;
+} {1 {no such column: new.a}}
+do_catchsql_test 8.3 {
+ INSERT INTO t1 VALUES(3) RETURNING a, (SELECT c FROM t2 WHERE old.a=t2.b) AS x;
+} {1 {no such column: old.a}}
+do_catchsql_test 8.4 {
+ INSERT INTO t1 VALUES(3) RETURNING a, (SELECT c FROM t2 WHERE t1.a=t2.b) AS x;
+} {0 {3 40}}
+
+ifcapable vtab {
+# dbsqlfuzz finds/crash-486f791cbe2dc45839310073e71367a1d8ad22dd
+do_catchsql_test 9.1 {
+ UPDATE pragma_encoding SET encoding='UTF-8' RETURNING a, b, *;
+} {1 {table pragma_encoding may not be modified}}
+} ;# ifcapable vtab
+
+# dbsqlfuzz crash-0081f863d7b2002045ac2361879fc80dfebb98f1
+reset_db
+do_execsql_test 10.1 {
+ CREATE TABLE t1_a(a, b);
+ CREATE VIEW t1 AS SELECT a, b FROM t1_a;
+
+ INSERT INTO t1_a VALUES('x', 'y');
+ INSERT INTO t1_a VALUES('x', 'y');
+ INSERT INTO t1_a VALUES('x', 'y');
+
+ CREATE TABLE log(op, r, a, b);
+}
+do_execsql_test 10.2 {
+ CREATE TRIGGER tr1 INSTEAD OF INSERT ON t1 BEGIN
+ INSERT INTO log VALUES('insert', new.rowid, new.a, new.b);
+ END;
+ CREATE TRIGGER tr2 INSTEAD OF UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES('update', new.rowid, new.a, new.b);
+ END;
+}
+
+do_catchsql_test 10.3 {
+ INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid;
+} {1 {no such column: rowid}}
+
+do_catchsql_test 10.3 {
+ UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid;
+} {1 {no such column: rowid}}
+
+do_execsql_test 10.4 {
+ SELECT * FROM log;
+} {}
+
+# 2021-04-27 dbsqlfuzz 78b9400770ef8cc7d9427dfba26f4fcf46ea7dc2
+# Returning clauses on TEMP tables with triggers.
+#
+reset_db
+do_execsql_test 11.1 {
+ CREATE TEMP TABLE t1(a,b);
+ CREATE TEMP TABLE t2(c,d);
+ CREATE TEMP TABLE t3(e,f);
+ CREATE TEMP TABLE log(op,x,y);
+ CREATE TEMP TRIGGER t1r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO log(op,x,y) VALUES('I1',new.a,new.b);
+ END;
+ CREATE TEMP TRIGGER t1r2 BEFORE DELETE ON t1 BEGIN
+ INSERT INTO log(op,x,y) VALUES('D1',old.a,old.b);
+ END;
+ CREATE TEMP TRIGGER t2r3 AFTER UPDATE ON t1 BEGIN
+ INSERT INTO log(op,x,y) VALUES('U1',new.a,new.b);
+ END;
+ CREATE TEMP TRIGGER t2r1 BEFORE INSERT ON t2 BEGIN
+ INSERT INTO log(op,x,y) VALUES('I2',new.c,new.d);
+ END;
+ CREATE TEMP TRIGGER t3r1 AFTER DELETE ON t3 BEGIN
+ INSERT INTO log(op,x,y) VALUES('D3',old.e,old.f);
+ END;
+ CREATE TEMP TRIGGER t3r2 BEFORE UPDATE ON t3 BEGIN
+ INSERT INTO log(op,x,y) VALUES('U3',new.e,new.f);
+ END;
+ INSERT INTO t1(a,b) VALUES(1,2),('happy','glad') RETURNING a, b, '|';
+} {1 2 | happy glad |}
+do_execsql_test 11.2 {
+ UPDATE t1 SET b=9 WHERE a=1 RETURNING a, b, 'x';
+} {1 9 x}
+do_execsql_test 11.3 {
+ DELETE FROM t1 WHERE a<>'xray' RETURNING a, b, '@';
+} {1 9 @ happy glad @}
+do_execsql_test 11.4 {
+ SELECT * FROM log;
+ DELETE FROM log;
+} {I1 1 2 I1 happy glad U1 1 9 D1 1 9 D1 happy glad}
+do_execsql_test 11.5 {
+ INSERT INTO t2 VALUES('bravo','charlie') RETURNING d, c, 'z';
+} {charlie bravo z}
+do_execsql_test 11.6 {
+ SELECT * FROM log;
+ DELETE FROM log;
+} {I2 bravo charlie}
+do_execsql_test 11.7 {
+ INSERT INTO t3(e) VALUES(1),(2),(3) RETURNING 'I', e;
+ UPDATE t3 SET f=e+100 RETURNING 'U', e, f;
+ DELETE FROM t3 WHERE f>100 RETURNING 'D', e, f;
+} {I 1 I 2 I 3 U 1 101 U 2 102 U 3 103 D 1 101 D 2 102 D 3 103}
+do_execsql_test 11.6 {
+ SELECT * FROM log;
+ DELETE FROM log;
+} {U3 1 101 U3 2 102 U3 3 103 D3 1 101 D3 2 102 D3 3 103}
+
+reset_db
+do_execsql_test 11.11 {
+ CREATE TEMP TABLE t1(a,b);
+ CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN SELECT 1; END;
+ DELETE FROM t1 RETURNING *;
+ DROP TRIGGER r1;
+ INSERT INTO t1 VALUES(5,30);
+} {}
+do_execsql_test 11.12 {
+ SELECT * FROM t1;
+} {5 30}
+
+# RETURNING column names are dequoted.
+# https://sqlite.org/forum/forumpost/033daf0b32
+#
+reset_db
+do_test 12.1 {
+ db eval {CREATE TABLE t1(x INT, y INT)}
+ unset -nocomplain cname
+ db eval {INSERT INTO t1(x) VALUES(1) RETURNING "x";} cname {}
+ lsort [array names cname]
+} {* x}
+do_test 12.2 {
+ unset -nocomplain cname
+ db eval {INSERT INTO t1(x) VALUES(2) RETURNING [x];} cname {}
+ lsort [array names cname]
+} {* x}
+do_test 12.3 {
+ unset -nocomplain cname
+ db eval {INSERT INTO t1(x) VALUES(3) RETURNING x AS [xyz];} cname {}
+ lsort [array names cname]
+} {* xyz}
+do_test 12.4 {
+ unset -nocomplain cname
+ db eval {INSERT INTO t1(x,y) VALUES(4,5) RETURNING "x"+"y";} cname {}
+ lsort [array names cname]
+} {{"x"+"y"} *}
+
+ifcapable rtree {
+#-------------------------------------------------------------------------
+# Based on dbsqlfuzz find crash-ffbba524cac354b2a61bfd677cec9d2a4333f49a
+reset_db
+do_execsql_test 13.0 {
+ CREATE VIRTUAL TABLE t1 USING rtree(a, b, c);
+ CREATE TABLE t2(x);
+}
+
+do_execsql_test 13.1 {
+ INSERT INTO t1(a,b,c) VALUES(1,2,3)
+ RETURNING (SELECT b FROM t2);
+} {{}}
+} ;# end ifcapable rtree
+
+# 2021-12-01 Forum post https://sqlite.org/forum/forumpost/793beaf322
+# Need to report foreign key constraint errors prior to RETURNING
+#
+reset_db
+do_execsql_test 14.0 {
+ PRAGMA foreign_keys(1);
+ CREATE TABLE Parent(id INTEGER PRIMARY KEY);
+ CREATE TABLE Child(id INTEGER PRIMARY KEY, parent_id INTEGER REFERENCES Parent(id));
+} {}
+do_catchsql_test 14.1 {
+ INSERT INTO child(parent_id) VALUES(123) RETURNING id;
+} {1 {FOREIGN KEY constraint failed}}
+
+# 2021-12-28 Forum post https://sqlite.org/forum/forumpost/e0c7574ab2
+# Incorrect affinity for REAL values that can be represented as integers.
+#
+reset_db
+sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+do_execsql_test 15.0 {
+ CREATE TABLE t1(x REAL);
+ INSERT INTO t1(x) VALUES(5.0) RETURNING x, affinity(x);
+} {5.0 real}
+do_execsql_test 15.1 {
+ UPDATE t1 SET x=x+1 RETURNING x, affinity(x);
+} {6.0 real}
+do_execsql_test 15.2 {
+ DELETE FROM t1 RETURNING x, affinity(x);
+} {6.0 real}
+
+# 2022-02-28 Forum post https://sqlite.org/forum/forumpost/595e132f71
+# RETURNING with the xfer optimization
+#
+reset_db
+do_execsql_test 16.0 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3),('a','b','c');
+ CREATE TEMP TABLE t2(x,y,z);
+ INSERT INTO t2 SELECT * FROM t1 RETURNING *;
+} {1 2 3 a b c}
+do_execsql_test 16.1 {
+ SELECT * FROM t2;
+} {1 2 3 a b c}
+
+
+foreach {tn temp} {
+ 1 ""
+ 2 TEMP
+} {
+ reset_db
+ do_execsql_test 17.$tn.0 "
+ CREATE $temp TABLE foo (
+ fooid INTEGER PRIMARY KEY,
+ fooval INTEGER NOT NULL UNIQUE,
+ refcnt INTEGER NOT NULL DEFAULT 1
+ );
+ "
+ do_execsql_test 17.$tn.1 {
+ INSERT INTO foo (fooval) VALUES (17), (4711), (17)
+ ON CONFLICT DO
+ UPDATE SET refcnt = refcnt+1
+ RETURNING fooid;
+ } {
+ 1 2 1
+ }
+}
+
+
+finish_test
diff --git a/test/returningfault.test b/test/returningfault.test
new file mode 100644
index 0000000..8bf6fbf
--- /dev/null
+++ b/test/returningfault.test
@@ -0,0 +1,36 @@
+# 2022 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1 (b);
+} {}
+faultsim_save_and_close
+
+do_faultsim_test pagerfault-1 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ INSERT INTO t1(b) VALUES(65) RETURNING (
+ SELECT * FROM sqlite_temp_schema
+ ) AS aaa;
+ }
+} -test {
+ faultsim_test_result {1 {sub-select returns 5 columns - expected 1}}
+}
+
+
+finish_test
diff --git a/test/rollback.test b/test/rollback.test
new file mode 100644
index 0000000..423bf20
--- /dev/null
+++ b/test/rollback.test
@@ -0,0 +1,152 @@
+# 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 {UNIQUE constraint failed: t3.a}}
+
+ # Try to continue with the SELECT statement
+ #
+ do_test rollback-1.5 {
+ sqlite3_step $STMT
+ } {SQLITE_ROW}
+
+ # Restart the SELECT statement
+ #
+ do_test rollback-1.6 { sqlite3_reset $STMT } {SQLITE_OK}
+} 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"
+ && [permutation] ne "atomic-batch-write"
+ && [atomic_batch_write test.db]==0
+} {
+ 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/rollback2.test b/test/rollback2.test
new file mode 100644
index 0000000..21ebdea
--- /dev/null
+++ b/test/rollback2.test
@@ -0,0 +1,156 @@
+# 2014 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 containst tests to verify that ROLLBACK or ROLLBACK TO
+# operations interact correctly with ongoing SELECT statements.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix rollback2
+
+proc int2hex {i} { format %.2X $i }
+db func int2hex int2hex
+do_execsql_test 1.0 {
+ SELECT int2hex(0), int2hex(100), int2hex(255)
+} {00 64 FF}
+do_execsql_test 1.1 {
+ CREATE TABLE t1(i, h);
+ CREATE INDEX i1 ON t1(h);
+ WITH data(a, b) AS (
+ SELECT 1, int2hex(1)
+ UNION ALL
+ SELECT a+1, int2hex(a+1) FROM data WHERE a<40
+ )
+ INSERT INTO t1 SELECT * FROM data;
+} {}
+
+
+# do_rollback_test ID SWITCHES
+#
+# where SWITCHES are:
+#
+# -setup SQL script to open transaction and begin writing.
+# -select SELECT to execute after -setup script
+# -result Expected result of -select statement
+# -rollback Use this SQL command ("ROLLBACK" or "ROLLBACK TO ...") to
+# rollback the transaction in the middle of the -select statment
+# execution.
+#
+proc do_rollback_test {tn args} {
+ set A(-setup) ""
+ set A(-select) ""
+ set A(-result) ""
+ set A(-rollback) ROLLBACK
+
+ array set O $args
+ foreach k [array names O] {
+ if {[info exists A($k)]==0} { error "unknown option: $k" }
+ set A($k) $O($k)
+ }
+
+ for {set iRollback 0} 1 {incr iRollback} {
+ catch { db eval ROLLBACK }
+ set res [list]
+ db eval $A(-setup)
+
+ set i 0
+ db eval $A(-select) x {
+ if {$i==$iRollback} { db eval $A(-rollback) }
+ foreach k $x(*) { lappend res $x($k) }
+ incr i
+ }
+
+ do_test $tn.$iRollback [list set {} $res] [list {*}$A(-result)]
+ if {$i < $iRollback} break
+ }
+}
+
+do_rollback_test 2.1 -setup {
+ BEGIN;
+ DELETE FROM t1 WHERE (i%2)==1;
+} -select {
+ SELECT i FROM t1 WHERE (i%2)==0
+} -result {
+ 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
+}
+
+do_rollback_test 2.2 -setup {
+ BEGIN;
+ DELETE FROM t1 WHERE (i%4)==1;
+ SAVEPOINT one;
+ DELETE FROM t1 WHERE (i%2)==1;
+} -rollback {
+ ROLLBACK TO one;
+} -select {
+ SELECT i FROM t1 WHERE (i%2)==0
+} -result {
+ 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
+}
+
+#--------------------------------------------------------------------
+# Try with some index scans
+#
+do_eqp_test 3.1 {
+ SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h DESC;
+} {SCAN t1 USING INDEX i1}
+do_rollback_test 3.2 -setup {
+ BEGIN;
+ DELETE FROM t1 WHERE (i%2)==1;
+} -select {
+ SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h DESC;
+} -result {
+ 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2
+}
+do_rollback_test 3.3 -setup {
+ BEGIN;
+ DELETE FROM t1 WHERE (i%4)==1;
+ SAVEPOINT one;
+ DELETE FROM t1 WHERE (i%2)==1;
+} -rollback {
+ ROLLBACK TO one;
+} -select {
+ SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h DESC;
+} -result {
+ 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2
+}
+
+#--------------------------------------------------------------------
+# Now with some index scans that feature overflow keys.
+#
+set leader [string repeat "abcdefghij" 70]
+do_execsql_test 4.1 { UPDATE t1 SET h = $leader || h; }
+
+do_eqp_test 4.2 {
+ SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h ASC;
+} {SCAN t1 USING INDEX i1}
+do_rollback_test 4.3 -setup {
+ BEGIN;
+ DELETE FROM t1 WHERE (i%2)==1;
+} -select {
+ SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h ASC;
+} -result {
+ 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
+}
+do_rollback_test 4.4 -setup {
+ BEGIN;
+ DELETE FROM t1 WHERE (i%4)==1;
+ SAVEPOINT one;
+ DELETE FROM t1 WHERE (i%2)==1;
+} -rollback {
+ ROLLBACK TO one;
+} -select {
+ SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h ASC;
+} -result {
+ 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
+}
+
+finish_test
diff --git a/test/rollbackfault.test b/test/rollbackfault.test
new file mode 100644
index 0000000..4d060b4
--- /dev/null
+++ b/test/rollbackfault.test
@@ -0,0 +1,82 @@
+# 2014-11-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.
+#
+#***********************************************************************
+#
+# Test that errors encountered during a ROLLBACK operation correctly
+# affect ongoing SQL statements.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix rollbackfault
+
+
+proc int2hex {i} { format %.2X $i }
+db func int2hex int2hex
+do_execsql_test 1.0 {
+ SELECT int2hex(0), int2hex(100), int2hex(255)
+} {00 64 FF}
+do_execsql_test 1.1 {
+ CREATE TABLE t1(i, h);
+ CREATE INDEX i1 ON t1(h);
+ WITH data(a, b) AS (
+ SELECT 1, int2hex(1)
+ UNION ALL
+ SELECT a+1, int2hex(a+1) FROM data WHERE a<40
+ )
+ INSERT INTO t1 SELECT * FROM data;
+} {}
+
+foreach f {oom ioerr} {
+ do_faultsim_test 1.2 -faults $f* -prep {
+ set sql1 { SELECT i FROM t1 WHERE (i%2)==0 }
+ set sql2 { SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h }
+ set ::s1 [sqlite3_prepare db $sql1 -1 dummy]
+ set ::s2 [sqlite3_prepare db $sql2 -1 dummy]
+
+ for {set i 0} {$i < 10} {incr i} { sqlite3_step $::s1 }
+ for {set i 0} {$i < 3} {incr i} { sqlite3_step $::s2 }
+
+ execsql {
+ BEGIN; DELETE FROM t1 WHERE (i%2)
+ }
+ } -body {
+ execsql { ROLLBACK }
+ } -test {
+
+ set res1 [list]
+ set res2 [list]
+ while {"SQLITE_ROW" == [sqlite3_step $::s1]} {
+ lappend res1 [sqlite3_column_text $::s1 0]
+ }
+ while {"SQLITE_ROW" == [sqlite3_step $::s2]} {
+ lappend res2 [sqlite3_column_text $::s2 0]
+ }
+ set rc1 [sqlite3_finalize $::s1]
+ set rc2 [sqlite3_finalize $::s2]
+
+ catchsql { ROLLBACK }
+
+ if {$rc1=="SQLITE_OK" && $rc2=="SQLITE_OK"
+ && $res1=="22 24 26 28 30 32 34 36 38 40"
+ && $res2=="8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40"
+ } {
+ # This is Ok.
+ } elseif {$rc1!="SQLITE_OK" && $rc2!="SQLITE_OK" && $res1=="" &&$res2==""} {
+ # Also Ok.
+ } else {
+ error "statements don't look right"
+ }
+ }
+}
+
+
+finish_test
diff --git a/test/round1.test b/test/round1.test
new file mode 100644
index 0000000..2244a39
--- /dev/null
+++ b/test/round1.test
@@ -0,0 +1,42 @@
+# 2019-05-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.
+#
+#***********************************************************************
+# Test cases for rounding behavior of floating point values.
+#
+# TESTRUNNER: slow
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix round1
+
+expr srand(0)
+unset -nocomplain iTest
+for {set iTest 1} {$iTest<=50000} {incr iTest} {
+ set x1 [expr int(rand()*100000)]
+ set x2 [expr int(rand()*100000)+1000*int(rand()*10000)]
+ set n [expr int(rand()*8)+1]
+ set x3 [string range [format %09d $x2] [expr {9-$n}] end]
+ set r $x1.$x3
+ set ans [string trimright $r 0]
+ if {[string match *. $ans]} {set ans ${ans}0}
+ do_test $iTest/$n/${r}4=>$ans {
+ set x [db one "SELECT round(${r}4,$n)"]
+ } $ans
+ set x4 [string range [format %09d [expr {$x2+1}]] [expr {9-$n}] end]
+ if {[string trim $x3 9]==""} {incr x1}
+ set r2 $x1.$x4
+ set ans [string trimright $r2 0]
+ if {[string match *. $ans]} {set ans ${ans}0}
+ do_test $iTest/$n/${r}5=>$ans {
+ set x [db one "SELECT round(${r}5,$n)"]
+ } $ans
+}
+
+finish_test
diff --git a/test/rowallock.test b/test/rowallock.test
new file mode 100644
index 0000000..a1cab8d
--- /dev/null
+++ b/test/rowallock.test
@@ -0,0 +1,67 @@
+
+# 2015-05-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 locks on read-only WAL-mode databases.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+set testprefix rowallock
+
+set mmap_res 1000000
+ifcapable !mmap {
+ set mmap_res 0
+}
+
+do_multiclient_test tn {
+ code2 { db2 close }
+ code3 { db3 close }
+
+ do_execsql_test 1.$tn.1 {
+ PRAGMA page_size = 4096;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t1 VALUES(1, 2), (3, 4);
+ PRAGMA journal_mode = wal;
+ } {wal}
+
+ code1 {
+ db close
+ sqlite3 db test.db -readonly 1
+ }
+
+ do_execsql_test 1.$tn.2 {
+ PRAGMA mmap_size = 1000000;
+ } $mmap_res
+ do_execsql_test 1.$tn.2.1 {
+ SELECT * FROM t1;
+ } {1 2 3 4}
+
+ do_catchsql_test 1.$tn.3 {
+ INSERT INTO t1 VALUES(5, 6);
+ } {1 {attempt to write a readonly database}}
+
+ do_test 1.$tn.4 {
+ code2 { sqlite3 db2 test.db }
+ sql2 { INSERT INTO t1 VALUES(5, 6); }
+ code2 { db2 close }
+ file exists test.db-wal
+ } {1}
+
+ do_test 1.$tn.5 {
+ sql1 { SELECT * FROM t2 }
+ code1 { db close }
+ file exists test.db-wal
+ } {1}
+}
+
+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..4327004
--- /dev/null
+++ b/test/rowid.test
@@ -0,0 +1,820 @@
+# 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.
+#
+# EVIDENCE-OF: R-36924-43758 By default, every row in SQLite has a
+# special column, usually called the "rowid", that uniquely identifies
+# that row within the table.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix rowid
+
+# 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}
+
+if 0 { # With the index-on-expressions enhancement, creating
+ # an index on ROWID has become possible.
+# 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}
+
+do_test rowid-11.asc.1 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>'abc' ORDER BY 1 ASC}
+} {}
+do_test rowid-11.asc.2 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>='abc' ORDER BY 1 ASC}
+} {}
+do_test rowid-11.asc.3 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<'abc' ORDER BY 1 ASC}
+} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}
+do_test rowid-11.asc.4 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<='abc' ORDER BY 1 ASC}
+} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}
+
+do_test rowid-11.desc.1 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>'abc' ORDER BY 1 DESC}
+} {}
+do_test rowid-11.desc.2 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid>='abc' ORDER BY 1 DESC}
+} {}
+do_test rowid-11.desc.3 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<'abc' ORDER BY 1 DESC}
+} {8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1}
+do_test rowid-11.desc.4 {
+ execsql {SELECT rowid, a FROM t5 WHERE rowid<='abc' ORDER BY 1 DESC}
+} {8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1}
+
+# Test the automatic generation of rowids when the table already contains
+# a rowid with the maximum value.
+#
+# Once 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 ORDER BY x;
+ }
+} {/\d+ 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}}
+
+# INSERTs that happen inside of nested function calls are recorded
+# by last_insert_rowid.
+#
+proc rowid_addrow_func {n} {
+ db eval {INSERT INTO t13(rowid,x) VALUES($n,$n*$n)}
+ return [db last_insert_rowid]
+}
+db function addrow rowid_addrow_func
+do_execsql_test rowid-13.1 {
+ CREATE TABLE t13(x);
+ INSERT INTO t13(rowid,x) VALUES(1234,5);
+ SELECT rowid, x, addrow(rowid+1000), '|' FROM t13 LIMIT 3;
+ SELECT last_insert_rowid();
+} {1234 5 2234 | 2234 4990756 3234 | 3234 10458756 4234 | 4234}
+
+#-------------------------------------------------------------------------
+do_execsql_test rowid-14.0 {
+ CREATE TABLE t14(x INTEGER PRIMARY KEY);
+ INSERT INTO t14(x) VALUES (100);
+}
+do_execsql_test rowid-14.1 {
+ SELECT * FROM t14 WHERE x < 'a' ORDER BY rowid ASC;
+} {100}
+do_execsql_test rowid-14.2 {
+ SELECT * FROM t14 WHERE x < 'a' ORDER BY rowid DESC;
+} {100}
+
+do_execsql_test rowid-14.3 {
+ DELETE FROM t14;
+ SELECT * FROM t14 WHERE x < 'a' ORDER BY rowid ASC;
+} {}
+do_execsql_test rowid-14.4 {
+ SELECT * FROM t14 WHERE x < 'a' ORDER BY rowid DESC;
+} {}
+
+reset_db
+do_execsql_test rowid-15.0 {
+ PRAGMA reverse_unordered_selects=true;
+ CREATE TABLE t1 (c0, c1);
+ CREATE TABLE t2 (c0 INT UNIQUE);
+ INSERT INTO t1(c0, c1) VALUES (0, 0), (0, NULL);
+ INSERT INTO t2(c0) VALUES (1);
+}
+
+do_execsql_test rowid-15.1 {
+ SELECT t2.c0, t1.c1 FROM t1, t2
+ WHERE (t2.rowid <= 'a') OR (t1.c0 <= t2.c0) LIMIT 100
+} {1 {} 1 0}
+
+do_execsql_test rowid-15.2 {
+ SELECT 1, NULL INTERSECT SELECT * FROM (
+ SELECT t2.c0, t1.c1 FROM t1, t2
+ WHERE ((t2.rowid <= 'a')) OR (t1.c0 <= t2.c0) ORDER BY 'a' DESC LIMIT 100
+ );
+} {1 {}}
+
+#-------------------------------------------------------------------------
+# Check that an unqualified "rowid" can be used in join queries so long
+# as only one of the source objects has a rowid column.
+#
+reset_db
+do_execsql_test 16.0 {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(y PRIMARY KEY) WITHOUT ROWID;
+ CREATE VIEW v1 AS SELECT x FROM t1;
+ CREATE TABLE t3(z);
+
+ INSERT INTO t1(rowid, x) VALUES(1, 1);
+ INSERT INTO t2(y) VALUES(2);
+ INSERT INTO t3(rowid, z) VALUES(3, 3);
+}
+
+do_execsql_test 16.1 { SELECT rowid FROM t1, t2; } {1}
+do_execsql_test 16.2 { SELECT rowid FROM t1, v1; } {1}
+do_execsql_test 16.3 { SELECT rowid FROM t3, v1; } {3}
+do_execsql_test 16.4 { SELECT rowid FROM t3, (SELECT 123); } {3}
+
+do_execsql_test 16.5 { SELECT rowid FROM t2, t1; } {1}
+do_execsql_test 16.6 { SELECT rowid FROM v1, t1; } {1}
+do_execsql_test 16.7 { SELECT rowid FROM v1, t3; } {3}
+do_execsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } {3}
+
+do_catchsql_test 16.5 { SELECT rowid FROM t1, t3; } {1 {no such column: rowid}}
+
+
+
+finish_test
diff --git a/test/rowvalue.test b/test/rowvalue.test
new file mode 100644
index 0000000..59b44d9
--- /dev/null
+++ b/test/rowvalue.test
@@ -0,0 +1,785 @@
+# 2016 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.
+#
+#***********************************************************************
+# 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
+set ::testprefix rowvalue
+
+do_execsql_test 0.0 {
+ CREATE TABLE one(o);
+ INSERT INTO one VALUES(1);
+}
+
+foreach {tn v1 v2 eq ne is isnot} {
+ 1 "1, 2, 3" "1, 2, 3" 1 0 1 0
+ 2 "1, 0, 3" "1, 2, 3" 0 1 0 1
+ 3 "1, 2, NULL" "1, 2, 3" {} {} 0 1
+ 4 "1, 2, NULL" "1, 2, NULL" {} {} 1 0
+ 5 "NULL, NULL, NULL" "NULL, NULL, NULL" {} {} 1 0
+
+ 6 "1, NULL, 1" "1, 1, 1" {} {} 0 1
+ 7 "1, NULL, 1" "1, 1, 2" 0 1 0 1
+} {
+ do_execsql_test 1.$tn.eq "SELECT ($v1) == ($v2)" [list $eq]
+ do_execsql_test 1.$tn.ne "SELECT ($v1) != ($v2)" [list $ne]
+
+ do_execsql_test 1.$tn.is "SELECT ($v1) IS ($v2)" [list $is]
+ do_execsql_test 1.$tn.isnot "SELECT ($v1) IS NOT ($v2)" [list $isnot]
+
+ do_execsql_test 1.$tn.2.eq "SELECT (SELECT $v1) == (SELECT $v2)" [list $eq]
+ do_execsql_test 1.$tn.2.ne "SELECT (SELECT $v1) != (SELECT $v2)" [list $ne]
+}
+
+foreach {tn v1 v2 lt gt le ge} {
+ 1 "(1, 1, 3)" "(1, 2, 3)" 1 0 1 0
+ 2 "(1, 2, 3)" "(1, 2, 3)" 0 0 1 1
+ 3 "(1, 3, 3)" "(1, 2, 3)" 0 1 0 1
+
+ 4 "(1, NULL, 3)" "(1, 2, 3)" {} {} {} {}
+ 5 "(1, 3, 3)" "(1, NULL, 3)" {} {} {} {}
+ 6 "(1, NULL, 3)" "(1, NULL, 3)" {} {} {} {}
+} {
+ foreach {tn2 expr res} [list \
+ 2.$tn.lt "$v1 < $v2" $lt \
+ 2.$tn.gt "$v1 > $v2" $gt \
+ 2.$tn.le "$v1 <= $v2" $le \
+ 2.$tn.ge "$v1 >= $v2" $ge \
+ ] {
+ do_execsql_test $tn2 "SELECT $expr" [list $res]
+
+ set map(0) [list]
+ set map() [list]
+ set map(1) [list 1]
+ do_execsql_test $tn2.where1 "SELECT * FROM one WHERE $expr" $map($res)
+
+ set map(0) [list 1]
+ set map() [list]
+ set map(1) [list]
+ do_execsql_test $tn2.where2 "SELECT * FROM one WHERE NOT $expr" $map($res)
+ }
+}
+
+do_execsql_test 3.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(2, 3);
+ INSERT INTO t1 VALUES(2, 4);
+ INSERT INTO t1 VALUES(3, 5);
+ INSERT INTO t1 VALUES(3, 6);
+}
+
+foreach {tn r order} {
+ 1 "(1, 1)" "ORDER BY y"
+ 2 "(1, 1)" "ORDER BY x, y"
+ 3 "(1, 2)" "ORDER BY x, y DESC"
+ 4 "(3, 6)" "ORDER BY x DESC, y DESC"
+ 5 "((3, 5))" "ORDER BY x DESC, y"
+ 6 "(SELECT 3, 5)" "ORDER BY x DESC, y"
+} {
+ do_execsql_test 3.$tn.1 "SELECT $r == (SELECT x,y FROM t1 $order)" 1
+ do_execsql_test 3.$tn.2 "SELECT $r == (SELECT * FROM t1 $order)" 1
+
+ do_execsql_test 3.$tn.3 "
+ SELECT (SELECT * FROM t1 $order) == (SELECT * FROM t1 $order)
+ " 1
+ do_execsql_test 3.$tn.4 "
+ SELECT (SELECT 0, 0) == (SELECT * FROM t1 $order)
+ " 0
+}
+
+foreach {tn expr res} {
+ 1 {(2, 2) BETWEEN (2, 2) AND (3, 3)} 1
+ 2 {(2, 2) BETWEEN (2, NULL) AND (3, 3)} {}
+ 3 {(2, 2) BETWEEN (3, NULL) AND (3, 3)} 0
+} {
+ do_execsql_test 4.$tn "SELECT $expr" [list $res]
+}
+
+foreach {tn expr res} {
+ 1 {(2, 4) IN (SELECT * FROM t1)} 1
+ 2 {(3, 4) IN (SELECT * FROM t1)} 0
+
+ 3 {(NULL, 4) IN (SELECT * FROM t1)} {}
+ 4 {(NULL, 0) IN (SELECT * FROM t1)} 0
+
+ 5 {(NULL, 4) NOT IN (SELECT * FROM t1)} {}
+ 6 {(NULL, 0) NOT IN (SELECT * FROM t1)} 1
+} {
+ do_execsql_test 5.$tn "SELECT $expr" [list $res]
+}
+
+do_execsql_test 6.0 {
+ CREATE TABLE hh(a, b, c);
+ INSERT INTO hh VALUES('abc', 1, 'i');
+ INSERT INTO hh VALUES('ABC', 1, 'ii');
+ INSERT INTO hh VALUES('def', 2, 'iii');
+ INSERT INTO hh VALUES('DEF', 2, 'iv');
+ INSERT INTO hh VALUES('GHI', 3, 'v');
+ INSERT INTO hh VALUES('ghi', 3, 'vi');
+
+ CREATE INDEX hh_ab ON hh(a, b);
+}
+
+do_execsql_test 6.1 {
+ SELECT c FROM hh WHERE (a, b) = (SELECT 'abc', 1);
+} {i}
+do_execsql_test 6.2 {
+ SELECT c FROM hh WHERE (a, b) = (SELECT 'abc' COLLATE nocase, 1);
+} {i}
+do_execsql_test 6.3 {
+ SELECT c FROM hh WHERE a = (SELECT 'abc' COLLATE nocase) AND b = (SELECT 1);
+} {i}
+do_execsql_test 6.4 {
+ SELECT c FROM hh WHERE +a = (SELECT 'abc' COLLATE nocase) AND b = (SELECT 1);
+} {i}
+do_execsql_test 6.5 {
+ SELECT c FROM hh WHERE a = (SELECT 'abc') COLLATE nocase AND b = (SELECT 1);
+} {i ii}
+do_catchsql_test 6.6 {
+ SELECT c FROM hh WHERE (a, b) = (SELECT 'abc', 1) COLLATE nocase;
+} {1 {row value misused}}
+do_catchsql_test 6.7 {
+ SELECT c FROM hh WHERE (a, b) = 1;
+} {1 {row value misused}}
+do_execsql_test 6.8 {
+ SELECT c FROM hh WHERE (a COLLATE nocase, b) = (SELECT 'def', 2);
+} {iii iv}
+do_execsql_test 6.9 {
+ SELECT c FROM hh WHERE (a COLLATE nocase, b) IS NOT (SELECT 'def', 2);
+} {i ii v vi}
+do_execsql_test 6.10 {
+ SELECT c FROM hh WHERE (b, a) = (SELECT 2, 'def');
+} {iii}
+
+do_execsql_test 7.0 {
+ CREATE TABLE xy(i INTEGER PRIMARY KEY, j, k);
+ INSERT INTO xy VALUES(1, 1, 1);
+ INSERT INTO xy VALUES(2, 2, 2);
+ INSERT INTO xy VALUES(3, 3, 3);
+ INSERT INTO xy VALUES(4, 4, 4);
+}
+
+
+foreach {tn sql res eqp} {
+ 1 "SELECT * FROM xy WHERE (i, j) IS (2, 2)" {2 2 2}
+ "SEARCH xy USING INTEGER PRIMARY KEY (rowid=?)"
+
+ 2 "SELECT * FROM xy WHERE (k, j) < (2, 3)" {1 1 1 2 2 2}
+ "SCAN xy"
+
+ 3 "SELECT * FROM xy WHERE (i, j) < (2, 3)" {1 1 1 2 2 2}
+ "SEARCH xy USING INTEGER PRIMARY KEY (rowid<?)"
+
+ 4 "SELECT * FROM xy WHERE (i, j) > (2, 1)" {2 2 2 3 3 3 4 4 4}
+ "SEARCH xy USING INTEGER PRIMARY KEY (rowid>?)"
+
+ 5 "SELECT * FROM xy WHERE (i, j) > ('2', 1)" {2 2 2 3 3 3 4 4 4}
+ "SEARCH xy USING INTEGER PRIMARY KEY (rowid>?)"
+
+} {
+ do_eqp_test 7.$tn.1 $sql $eqp
+ do_execsql_test 7.$tn.2 $sql $res
+}
+
+do_execsql_test 8.0 {
+ CREATE TABLE j1(a);
+}
+do_execsql_test 8.1 {
+ SELECT * FROM j1 WHERE (select min(a) FROM j1) IN (?, ?, ?)
+}
+
+do_execsql_test 9.0 {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
+ INSERT INTO t2 VALUES(1, 1, 1);
+ INSERT INTO t2 VALUES(2, 2, 2);
+ INSERT INTO t2 VALUES(3, 3, 3);
+ INSERT INTO t2 VALUES(4, 4, 4);
+ INSERT INTO t2 VALUES(5, 5, 5);
+}
+
+foreach {tn q res} {
+ 1 "(a, b) > (2, 1)" {2 3 4 5}
+ 2 "(a, b) > (2, 2)" {3 4 5}
+ 3 "(a, b) < (4, 5)" {1 2 3 4}
+ 4 "(a, b) < (4, 3)" {1 2 3}
+} {
+ do_execsql_test 9.$tn "SELECT c FROM t2 WHERE $q" $res
+}
+
+do_execsql_test 10.0 {
+ CREATE TABLE dual(dummy); INSERT INTO dual(dummy) VALUES('X');
+ CREATE TABLE t3(a TEXT,b TEXT,c TEXT,d TEXT,e TEXT,f TEXT);
+ CREATE INDEX t3x ON t3(b,c,d,e,f);
+
+ SELECT a FROM t3
+ WHERE (c,d) IN (SELECT 'c','d' FROM dual)
+ AND (a,b,e) IN (SELECT 'a','b','d' FROM dual);
+}
+
+do_catchsql_test 11.1 {
+ CREATE TABLE t11(a);
+ SELECT * FROM t11 WHERE (a,a)<=1;
+} {1 {row value misused}}
+do_catchsql_test 11.2 {
+ SELECT * FROM t11 WHERE (a,a)<1;
+} {1 {row value misused}}
+do_catchsql_test 11.3 {
+ SELECT * FROM t11 WHERE (a,a)>=1;
+} {1 {row value misused}}
+do_catchsql_test 11.4 {
+ SELECT * FROM t11 WHERE (a,a)>1;
+} {1 {row value misused}}
+do_catchsql_test 11.5 {
+ SELECT * FROM t11 WHERE (a,a)==1;
+} {1 {row value misused}}
+do_catchsql_test 11.6 {
+ SELECT * FROM t11 WHERE (a,a)<>1;
+} {1 {row value misused}}
+do_catchsql_test 11.7 {
+ SELECT * FROM t11 WHERE (a,a) IS 1;
+} {1 {row value misused}}
+do_catchsql_test 11.8 {
+ SELECT * FROM t11 WHERE (a,a) IS NOT 1;
+} {1 {row value misused}}
+
+# 2016-10-27: https://www.sqlite.org/src/tktview/fef4bb4bd9185ec8f
+# Incorrect result from a LEFT JOIN with a row-value constraint
+#
+do_execsql_test 12.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INT,b INT); INSERT INTO t1 VALUES(1,2);
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x INT,y INT); INSERT INTO t2 VALUES(3,4);
+ SELECT *,'x' FROM t1 LEFT JOIN t2 ON (a,b)=(x,y);
+} {1 2 {} {} x}
+db null -
+do_execsql_test 12.2 {
+ SELECT t1.*, t2.* FROM t2 RIGHT JOIN t1 ON (a,b)=(x,y);
+} {1 2 - -}
+do_execsql_test 12.3 {
+ SELECT t1.*, t2.* FROM t1 FULL JOIN t2 ON (a,b)=(x,y)
+ ORDER BY coalesce(a,x);
+} {
+ 1 2 - -
+ - - 3 4
+}
+db null {}
+
+
+foreach {tn sql} {
+ 0 "SELECT (1,2) AS x WHERE x=3"
+ 1 "SELECT (1,2) BETWEEN 1 AND 2"
+ 2 "SELECT 1 BETWEEN (1,2) AND 2"
+ 3 "SELECT 2 BETWEEN 1 AND (1,2)"
+ 4 "SELECT (1,2) FROM (SELECT 1) ORDER BY 1"
+ 5 "SELECT (1,2) FROM (SELECT 1) GROUP BY 1"
+} {
+ do_catchsql_test 13.$tn $sql {1 {row value misused}}
+}
+
+do_execsql_test 14.0 {
+ CREATE TABLE t12(x);
+ INSERT INTO t12 VALUES(2), (4);
+}
+do_execsql_test 14.1 "SELECT 1 WHERE (2,2) BETWEEN (1,1) AND (3,3)" 1
+do_execsql_test 14.2 "SELECT CASE (2,2) WHEN (1, 1) THEN 2 ELSE 1 END" 1
+do_execsql_test 14.3 "SELECT CASE (SELECT 2,2) WHEN (1, 1) THEN 2 ELSE 1 END" 1
+do_execsql_test 14.4 "SELECT 1 WHERE (SELECT 2,2) BETWEEN (1,1) AND (3,3)" 1
+do_execsql_test 14.5 "SELECT 1 FROM t12 WHERE (x,1) BETWEEN (1,1) AND (3,3)" 1
+do_execsql_test 14.6 {
+ SELECT 1 FROM t12 WHERE (1,x) BETWEEN (1,1) AND (3,3)
+} {1 1}
+
+#-------------------------------------------------------------------------
+# Test that errors are not concealed by the SELECT flattening or
+# WHERE-clause push-down optimizations.
+do_execsql_test 14.1 {
+ CREATE TABLE x1(a PRIMARY KEY, b);
+ CREATE TABLE x2(a INTEGER PRIMARY KEY, b);
+}
+
+foreach {tn n sql} {
+ 1 0 "SELECT * FROM (SELECT (1, 1) AS c FROM x1) WHERE c=1"
+ 2 2 "SELECT * FROM (SELECT 1 AS x, (SELECT 8,9) AS y) WHERE y<1"
+ 3 3 "SELECT * FROM (SELECT 1 AS x, (SELECT 8,9,10) AS y) WHERE y<1"
+ 4 0 "SELECT * FROM (SELECT (a, b) AS c FROM x1), x2 WHERE c=a"
+ 5 0 "SELECT * FROM (SELECT a AS c, (1, 2, 3) FROM x1), x2 WHERE c=a"
+ 6 0 "SELECT * FROM (SELECT 1 AS c, (1, 2, 3) FROM x1) WHERE c=1"
+} {
+ if {$n==0} {
+ set err "row value misused"
+ } else {
+ set err "sub-select returns $n columns - expected 1"
+ }
+ do_catchsql_test 14.2.$tn $sql [list 1 $err]
+}
+
+#--------------------------------------------------------------------------
+# Test for vector size mismatches concealed by unexpanded subqueries.
+#
+do_catchsql_test 15.1 {
+ DETACH (SELECT * FROM (SELECT 1,2))<3;
+} {1 {row value misused}}
+do_catchsql_test 15.2 {
+ UPDATE x1 SET a=(SELECT * FROM (SELECT b,2))<3;
+} {1 {row value misused}}
+do_catchsql_test 15.3 {
+ UPDATE x1 SET a=NULL WHERE a<(SELECT * FROM (SELECT b,2));
+} {1 {sub-select returns 2 columns - expected 1}}
+do_catchsql_test 15.4 {
+ DELETE FROM x1 WHERE a<(SELECT * FROM (SELECT b,2));
+} {1 {sub-select returns 2 columns - expected 1}}
+do_catchsql_test 15.5 {
+ INSERT INTO x1(a,b) VALUES(1,(SELECT * FROM (SELECT 1,2))<3);
+} {1 {row value misused}}
+
+#-------------------------------------------------------------------------
+# Row-values used in UPDATE statements within TRIGGERs
+#
+# Ticket https://www.sqlite.org/src/info/8c9458e703666e1a
+#
+do_execsql_test 16.1 {
+ CREATE TABLE t16a(a,b,c);
+ INSERT INTO t16a VALUES(1,2,3);
+ CREATE TABLE t16b(x);
+ INSERT INTO t16b(x) VALUES(1);
+ CREATE TRIGGER t16r AFTER UPDATE ON t16b BEGIN
+ UPDATE t16a SET (a,b,c)=(SELECT new.x,new.x+1,new.x+2);
+ END;
+ UPDATE t16b SET x=7;
+ SELECT * FROM t16a;
+} {7 8 9}
+do_execsql_test 16.2 {
+ UPDATE t16b SET x=97;
+ SELECT * FROM t16a;
+} {97 98 99}
+
+do_execsql_test 16.3 {
+ CREATE TABLE t16c(a, b, c, d, e);
+ INSERT INTO t16c VALUES(1, 'a', 'b', 'c', 'd');
+ CREATE TRIGGER t16c1 AFTER INSERT ON t16c BEGIN
+ UPDATE t16c SET (c, d) = (SELECT 'A', 'B'), (e, b) = (SELECT 'C', 'D')
+ WHERE a = new.a-1;
+ END;
+
+ SELECT * FROM t16c;
+} {1 a b c d}
+
+do_execsql_test 16.4 {
+ INSERT INTO t16c VALUES(2, 'w', 'x', 'y', 'z');
+ SELECT * FROM t16c;
+} {
+ 1 D A B C
+ 2 w x y z
+}
+
+do_execsql_test 16.5 {
+ DROP TRIGGER t16c1;
+ PRAGMA recursive_triggers = 1;
+ INSERT INTO t16c VALUES(3, 'i', 'ii', 'iii', 'iv');
+ CREATE TRIGGER t16c1 AFTER UPDATE ON t16c WHEN new.a>1 BEGIN
+ UPDATE t16c SET (e, d) = (
+ SELECT b, c FROM t16c WHERE a = new.a-1
+ ), (c, b) = (
+ SELECT d, e FROM t16c WHERE a = new.a-1
+ ) WHERE a = new.a-1;
+ END;
+
+ UPDATE t16c SET a=a WHERE a=3;
+ SELECT * FROM t16c;
+} {
+ 1 C B A D
+ 2 z y x w
+ 3 i ii iii iv
+}
+
+do_execsql_test 17.0 {
+ CREATE TABLE b1(a, b);
+ CREATE TABLE b2(x);
+}
+
+do_execsql_test 17.1 {
+ SELECT * FROM b2 CROSS JOIN b1
+ WHERE b2.x=b1.a AND (b1.a, 2)
+ IN (VALUES(1, 2));
+} {}
+
+do_execsql_test 18.0 {
+ CREATE TABLE b3 ( a, b, PRIMARY KEY (a, b) );
+ CREATE TABLE b4 ( a );
+ CREATE TABLE b5 ( a, b );
+ INSERT INTO b3 VALUES (1, 1), (1, 2);
+ INSERT INTO b4 VALUES (1);
+ INSERT INTO b5 VALUES (1, 1), (1, 2);
+}
+
+do_execsql_test 18.1 {
+ SELECT * FROM b3 WHERE (SELECT b3.a, b3.b) IN ( SELECT a, b FROM b5 )
+} {1 1 1 2}
+do_execsql_test 18.2 {
+ SELECT * FROM b3 WHERE (VALUES(b3.a, b3.b)) IN ( SELECT a, b FROM b5 );
+} {1 1 1 2}
+do_execsql_test 18.3 {
+ SELECT * FROM b3 WHERE (b3.a, b3.b) IN ( SELECT a, b FROM b5 );
+} {1 1 1 2}
+do_execsql_test 18.4 {
+ SELECT * FROM b3 JOIN b4 ON b4.a = b3.a
+ WHERE (SELECT b3.a, b3.b) IN ( SELECT a, b FROM b5 );
+} {1 1 1 1 2 1}
+do_execsql_test 18.5 {
+ SELECT * FROM b3 JOIN b4 ON b4.a = b3.a
+ WHERE (VALUES(b3.a, b3.b)) IN ( SELECT a, b FROM b5 );
+} {1 1 1 1 2 1}
+do_execsql_test 18.6 {
+ SELECT * FROM b3 JOIN b4 ON b4.a = b3.a
+ WHERE (b3.a, b3.b) IN ( SELECT a, b FROM b5 );
+} {1 1 1 1 2 1}
+
+
+# 2018-02-13 Ticket https://www.sqlite.org/src/tktview/f484b65f3d6230593c3
+# Incorrect result from a row-value comparison in the WHERE clause.
+#
+do_execsql_test 19.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b);
+ INSERT INTO t1(a,b) VALUES(1,11),(2,22),(3,33),(4,44);
+ SELECT * FROM t1 WHERE (a,b)>(0,0) ORDER BY a;
+} {1 11 2 22 3 33 4 44}
+do_execsql_test 19.2 {
+ SELECT * FROM t1 WHERE (a,b)>=(0,0) ORDER BY a;
+} {1 11 2 22 3 33 4 44}
+do_execsql_test 19.3 {
+ SELECT * FROM t1 WHERE (a,b)<(5,0) ORDER BY a DESC;
+} {4 44 3 33 2 22 1 11}
+do_execsql_test 19.4 {
+ SELECT * FROM t1 WHERE (a,b)<=(5,0) ORDER BY a DESC;
+} {4 44 3 33 2 22 1 11}
+do_execsql_test 19.5 {
+ SELECT * FROM t1 WHERE (a,b)>(3,0) ORDER BY a;
+} {3 33 4 44}
+do_execsql_test 19.6 {
+ SELECT * FROM t1 WHERE (a,b)>=(3,0) ORDER BY a;
+} {3 33 4 44}
+do_execsql_test 19.7 {
+ SELECT * FROM t1 WHERE (a,b)<(3,0) ORDER BY a DESC;
+} {2 22 1 11}
+do_execsql_test 19.8 {
+ SELECT * FROM t1 WHERE (a,b)<=(3,0) ORDER BY a DESC;
+} {2 22 1 11}
+do_execsql_test 19.9 {
+ SELECT * FROM t1 WHERE (a,b)>(3,32) ORDER BY a;
+} {3 33 4 44}
+do_execsql_test 19.10 {
+ SELECT * FROM t1 WHERE (a,b)>(3,33) ORDER BY a;
+} {4 44}
+do_execsql_test 19.11 {
+ SELECT * FROM t1 WHERE (a,b)>=(3,33) ORDER BY a;
+} {3 33 4 44}
+do_execsql_test 19.12 {
+ SELECT * FROM t1 WHERE (a,b)>=(3,34) ORDER BY a;
+} {4 44}
+do_execsql_test 19.13 {
+ SELECT * FROM t1 WHERE (a,b)<(3,34) ORDER BY a DESC;
+} {3 33 2 22 1 11}
+do_execsql_test 19.14 {
+ SELECT * FROM t1 WHERE (a,b)<(3,33) ORDER BY a DESC;
+} {2 22 1 11}
+do_execsql_test 19.15 {
+ SELECT * FROM t1 WHERE (a,b)<=(3,33) ORDER BY a DESC;
+} {3 33 2 22 1 11}
+do_execsql_test 19.16 {
+ SELECT * FROM t1 WHERE (a,b)<=(3,32) ORDER BY a DESC;
+} {2 22 1 11}
+do_execsql_test 19.21 {
+ SELECT * FROM t1 WHERE (0,0)<(a,b) ORDER BY a;
+} {1 11 2 22 3 33 4 44}
+do_execsql_test 19.22 {
+ SELECT * FROM t1 WHERE (0,0)<=(a,b) ORDER BY a;
+} {1 11 2 22 3 33 4 44}
+do_execsql_test 19.23 {
+ SELECT * FROM t1 WHERE (5,0)>(a,b) ORDER BY a DESC;
+} {4 44 3 33 2 22 1 11}
+do_execsql_test 19.24 {
+ SELECT * FROM t1 WHERE (5,0)>=(a,b) ORDER BY a DESC;
+} {4 44 3 33 2 22 1 11}
+do_execsql_test 19.25 {
+ SELECT * FROM t1 WHERE (3,0)<(a,b) ORDER BY a;
+} {3 33 4 44}
+do_execsql_test 19.26 {
+ SELECT * FROM t1 WHERE (3,0)<=(a,b) ORDER BY a;
+} {3 33 4 44}
+do_execsql_test 19.27 {
+ SELECT * FROM t1 WHERE (3,0)>(a,b) ORDER BY a DESC;
+} {2 22 1 11}
+do_execsql_test 19.28 {
+ SELECT * FROM t1 WHERE (3,0)>=(a,b) ORDER BY a DESC;
+} {2 22 1 11}
+do_execsql_test 19.29 {
+ SELECT * FROM t1 WHERE (3,32)<(a,b) ORDER BY a;
+} {3 33 4 44}
+do_execsql_test 19.30 {
+ SELECT * FROM t1 WHERE (3,33)<(a,b) ORDER BY a;
+} {4 44}
+do_execsql_test 19.31 {
+ SELECT * FROM t1 WHERE (3,33)<=(a,b) ORDER BY a;
+} {3 33 4 44}
+do_execsql_test 19.32 {
+ SELECT * FROM t1 WHERE (3,34)<=(a,b) ORDER BY a;
+} {4 44}
+do_execsql_test 19.33 {
+ SELECT * FROM t1 WHERE (3,34)>(a,b) ORDER BY a DESC;
+} {3 33 2 22 1 11}
+do_execsql_test 19.34 {
+ SELECT * FROM t1 WHERE (3,33)>(a,b) ORDER BY a DESC;
+} {2 22 1 11}
+do_execsql_test 19.35 {
+ SELECT * FROM t1 WHERE (3,33)>=(a,b) ORDER BY a DESC;
+} {3 33 2 22 1 11}
+do_execsql_test 19.36 {
+ SELECT * FROM t1 WHERE (3,32)>=(a,b) ORDER BY a DESC;
+} {2 22 1 11}
+
+# 2018-02-18: Memory leak nested row-value. Detected by OSSFuzz.
+#
+do_catchsql_test 20.1 {
+ SELECT 1 WHERE (2,(2,0)) IS (2,(2,0));
+} {0 1}
+
+# 2018-11-03: Ticket https://www.sqlite.org/src/info/1a84668dcfdebaf1
+# Assertion fault when doing row-value operations on a primary key
+# containing duplicate columns.
+#
+do_execsql_test 21.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b,PRIMARY KEY(b,b));
+ INSERT INTO t1 VALUES(1,2),(3,4),(5,6);
+ SELECT * FROM t1 WHERE (a,b) IN (VALUES(1,2));
+} {1 2}
+
+# 2019-08-09: Multi-column subquery on the RHS of an IN operator.
+#
+do_execsql_test 22.100 {
+ SELECT (SELECT 3,4 UNION SELECT 5,6 ORDER BY 1) IN (SELECT 3,4);
+ SELECT (SELECT 3,4 UNION SELECT 5,6 ORDER BY 1) IN (SELECT 5,6);
+ SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1) IN (SELECT 3,4);
+ SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1) IN (SELECT 5,6);
+ SELECT (SELECT 3,4 UNION SELECT 5,6 ORDER BY 1 DESC) IN (SELECT 3,4);
+ SELECT (SELECT 3,4 UNION SELECT 5,6 ORDER BY 1 DESC) IN (SELECT 5,6);
+ SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1 DESC) IN (SELECT 3,4);
+ SELECT (SELECT 5,6 UNION SELECT 3,4 ORDER BY 1 DESC) IN (SELECT 5,6);
+} {1 0 1 0 0 1 0 1}
+
+# 2019-10-21 Ticket b47e3627ecaadbde
+#
+do_execsql_test 23.100 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(aa COLLATE NOCASE, bb);
+ INSERT INTO t0 VALUES('a', 'A');
+ SELECT (+bb,1) >= (aa, 1), (aa,1)<=(+bb,1) FROM t0;
+ SELECT 2 FROM t0 WHERE (+bb,1) >= (aa,1);
+ SELECT 3 FROM t0 WHERE (aa,1) <= (+bb,1);
+} {0 1 3}
+do_execsql_test 23.110 {
+ SELECT (SELECT +bb,1) >= (aa, 1), (aa,1)<=(SELECT +bb,1) FROM t0;
+ SELECT 2 FROM t0 WHERE (SELECT +bb,1) >= (aa,1);
+ SELECT 3 FROM t0 WHERE (aa,1) <= (SELECT +bb,1);
+} {0 1 3}
+
+# 2019-10-22 Ticket 6ef984af8972c2eb
+do_execsql_test 24.100 {
+ DROP TABLE t0;
+ CREATE TABLE t0(c0 TEXT PRIMARY KEY);
+ INSERT INTO t0(c0) VALUES ('');
+ SELECT (t0.c0, TRUE) > (CAST(0 AS REAL), FALSE) FROM t0;
+ SELECT 2 FROM t0 WHERE (t0.c0, TRUE) > (CAST('' AS REAL), FALSE);
+} {1 2}
+
+# 2019-10-23 Ticket 135c9da7513e5a97
+do_execsql_test 25.10 {
+ DROP TABLE t0;
+ CREATE TABLE t0(c0 UNIQUE);
+ INSERT INTO t0(c0) VALUES('a');
+ SELECT (t0.c0, 0) < ('B' COLLATE NOCASE, 0) FROM t0;
+ SELECT 2 FROM t0 WHERE (t0.c0, 0) < ('B' COLLATE NOCASE, 0);
+} {1 2}
+do_execsql_test 25.20 {
+ SELECT ('B' COLLATE NOCASE, 0)> (t0.c0, 0) FROM t0;
+ SELECT 2 FROM t0 WHERE ('B' COLLATE NOCASE, 0)> (t0.c0, 0);
+} {1 2}
+do_execsql_test 25.30 {
+ SELECT ('B', 0)> (t0.c0 COLLATE nocase, 0) FROM t0;
+ SELECT 2 FROM t0 WHERE ('B', 0)> (t0.c0 COLLATE nocase, 0);
+} {1 2}
+do_execsql_test 25.40 {
+ SELECT (t0.c0 COLLATE nocase, 0) < ('B', 0) FROM t0;
+ SELECT 2 FROM t0 WHERE (t0.c0 COLLATE nocase, 0) < ('B', 0);
+} {1 2}
+
+# 2019-11-04 Ticket 02aa2bd02f97d0f2
+# The TK_VECTOR operator messes up sqlite3ExprImpliesNonNull() which
+# causes incorrect LEFT JOIN strength reduction. TK_VECTOR should be
+# treated the same as TK_OR.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test 26.10 {
+ CREATE TABLE t0(c0);
+ CREATE TABLE t1(c1);
+ INSERT INTO t1(c1) VALUES (0);
+ SELECT (c0, x'') != (NULL, 0) FROM t1 LEFT JOIN t0;
+} {1}
+do_execsql_test 26.20 {
+ SELECT 2 FROM t1 LEFT JOIN t0 ON (c0, x'') != (NULL, 0);
+} {2}
+do_execsql_test 26.21 {
+ SELECT 21 FROM t0 RIGHT JOIN t1 ON (c0, x'') != (NULL, 0);
+} {21}
+do_execsql_test 26.30 {
+ SELECT 3 FROM t1 LEFT JOIN t0 WHERE (c0, x'') != (NULL, 0);
+} {3}
+do_execsql_test 26.31 {
+ SELECT 31 FROM t0 RIGHT JOIN t1 WHERE (c0, x'') != (NULL, 0);
+} {31}
+
+# 2019-12-30 ticket 892575cdba4e1e36
+#
+reset_db
+do_catchsql_test 27.10 {
+ CREATE TABLE t0(c0 CHECK(((0, 0) > (0, c0))));
+ INSERT INTO t0(c0) VALUES(0) ON CONFLICT(c0) DO UPDATE SET c0 = 3;
+} {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+
+# 2021-02-03
+# https://bugs.chromium.org/p/chromium/issues/detail?id=1173511
+# Faulty assert() statement.
+#
+reset_db
+do_catchsql_test 28.10 {
+ CREATE TABLE t0(c0 PRIMARY KEY, c1);
+ CREATE TRIGGER trigger0 BEFORE DELETE ON t0 BEGIN
+ SELECT (SELECT c0,c1 FROM t0) FROM t0;
+ END ;
+ DELETE FROM t0;
+} {1 {sub-select returns 2 columns - expected 1}}
+
+# 2021-03-19
+# dbsqlfuzz find of a NEVER().
+do_catchsql_test 29.1 {
+ SELECT (SELECT 1 WHERE ((SELECT 1 WHERE (2,(2,0)) IS (2,(20))),(2,0)) IS (2,(20))) WHERE (2,(2,0)) IS (2 IN(SELECT 1 WHERE (2,(2,2,0)) IS (2,(20))),(20));
+} {1 {row value misused}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 30.0 {
+ CREATE TABLE t1(x, y, z);
+ CREATE TABLE t2(a, b);
+
+ INSERT INTO t1 VALUES(1000, 2000, 3000);
+ INSERT INTO t2 VALUES(NULL, NULL);
+}
+
+do_execsql_test 30.1 {
+ UPDATE t2 SET (a,b)=(
+ SELECT max( t1.x ) OVER( PARTITION BY sum( (SELECT t1.y) ) ), 2
+ )
+ FROM t1;
+} {}
+
+do_execsql_test 30.2 {
+ SELECT * FROM t2
+} {1000 2}
+
+reset_db
+do_execsql_test 30.3 {
+ CREATE TABLE t1(x INT PRIMARY KEY, y, z);
+ CREATE TABLE t2(a,b,c,d,e,PRIMARY KEY(a,b))WITHOUT ROWID;
+
+ UPDATE t2 SET (d,d,a)=(SELECT EXISTS(SELECT 1 IN(SELECT max( 1 IN(SELECT x ORDER BY 1)) OVER(PARTITION BY sum((SELECT y FROM t1 UNION SELECT x ORDER BY 1)))INTERSECT SELECT EXISTS(SELECT 1 FROM t1 UNION SELECT x ORDER BY 1) ORDER BY 1) ORDERa)|9 AS blob, 2, 3) FROM t1 WHERE x<a;
+}
+
+# 2022-01-21 https://sqlite.org/forum/forumpost/ab95010d410a0a55
+reset_db
+do_execsql_test 31.1 {
+ CREATE TABLE a(a1 PRIMARY KEY,a2);
+ INSERT INTO a VALUES(1,5);
+ CREATE TABLE b(b1 UNIQUE,b2);
+ SELECT * FROM a LEFT JOIN b ON b2=NULL AND b2=5 WHERE (b1,substr(b.b1,1,1))==(SELECT 1024,'b');
+} {}
+do_execsql_test 31.1b {
+ SELECT * FROM b RIGHT JOIN a ON b2=NULL AND b2=5 WHERE (b1,substr(b.b1,1,1))==(SELECT 1024,'b');
+} {}
+do_execsql_test 31.2 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(0);
+ CREATE TABLE t2(b,c,d);
+ INSERT INTO t2 VALUES(NULL,123,456);
+ SELECT * FROM t1 LEFT JOIN t2 ON b=NULL WHERE (c,d)==(SELECT 123, 456+a);
+} {}
+do_execsql_test 31.2b {
+ SELECT * FROM t2 RIGHT JOIN t1 ON b=NULL WHERE (c,d)==(SELECT 123, 456+a);
+} {}
+
+# 2022-02-03 dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1
+reset_db
+do_execsql_test 32.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c INT);
+ CREATE TABLE t2(d INTEGER PRIMARY KEY);
+ INSERT INTO t1(a,b,c) VALUES(500,654,456);
+ INSERT INTO t1(a,b,c) VALUES(501,655,456);
+ INSERT INTO t1(a,b,c) VALUES(502,654,122);
+ INSERT INTO t1(a,b,c) VALUES(503,654,221);
+ INSERT INTO t1(a,b,c) VALUES(601,654,122);
+ INSERT INTO t2(d) VALUES(456);
+ INSERT INTO t2(d) VALUES(122);
+ SELECT a FROM (
+ SELECT t1.a FROM t2, t1
+ WHERE (987, t1.b) = ( SELECT 987, 654 ) AND t2.d=t1.c
+ ) AS t3
+ WHERE a=1234 OR a<=567;
+} {500 502}
+
+# 2022-07-15
+# https://sqlite.org/forum/forumpost/3607259d3c
+#
+reset_db
+do_execsql_test 33.1 {
+ CREATE TABLE t1(a INT, b INT PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t1(a, b) VALUES (0, 1),(15,-7),(3,100);
+ ANALYZE;
+} {}
+do_execsql_test 33.2 {
+ SELECT * FROM t1 WHERE (b,a) BETWEEN (0,5) AND (99,-2);
+} {0 1}
+do_execsql_test 33.3 {
+ SELECT * FROM t1 WHERE (b,a) BETWEEN (-8,5) AND (0,-2);
+} {15 -7}
+do_execsql_test 33.3 {
+ SELECT * FROM t1 WHERE (b,a) BETWEEN (3,5) AND (100,4);
+} {3 100}
+do_execsql_test 33.3 {
+ SELECT * FROM t1 WHERE (b,a) BETWEEN (3,5) AND (100,2);
+} {}
+do_execsql_test 33.3 {
+ SELECT * FROM t1 WHERE (a,b) BETWEEN (-2,99) AND (1,0);
+} {0 1}
+do_execsql_test 33.3 {
+ SELECT * FROM t1 WHERE (a,b) BETWEEN (14,99) AND (16,0);
+} {15 -7}
+do_execsql_test 33.3 {
+ SELECT * FROM t1 WHERE (a,b) BETWEEN (2,99) AND (4,0);
+} {3 100}
+
+finish_test
diff --git a/test/rowvalue2.test b/test/rowvalue2.test
new file mode 100644
index 0000000..1502e31
--- /dev/null
+++ b/test/rowvalue2.test
@@ -0,0 +1,279 @@
+# 2016 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.
+#
+#***********************************************************************
+# 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
+set ::testprefix rowvalue2
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(0, 0, 0);
+ INSERT INTO t1 VALUES(0, 1, 1);
+ INSERT INTO t1 VALUES(1, 0, 2);
+ INSERT INTO t1 VALUES(1, 1, 3);
+
+ CREATE INDEX i1 ON t1(a, b);
+}
+
+do_execsql_test 1.1.1 { SELECT c FROM t1 WHERE (a, b) >= (1, 0) } {2 3}
+do_execsql_test 1.1.2 { SELECT c FROM t1 WHERE (a, b) > (1, 0) } {3}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 2.0.1 {
+ CREATE TABLE t2(a INTEGER, b INTEGER, c INTEGER, d INTEGER);
+ CREATE INDEX i2 ON t2(a, b, c);
+}
+do_test 2.0.2 {
+ foreach a {0 1 2 3} {
+ foreach b {0 1 2 3} {
+ foreach c {0 1 2 3} {
+ execsql { INSERT INTO t2 VALUES($a, $b, $c, $c + $b*4 + $a*16); }
+ }}}
+} {}
+
+do_execsql_test 2.1 {
+ SELECT d FROM t2 WHERE (a, b) > (2, 2);
+} [db eval { SELECT d FROM t2 WHERE a>2 OR (a=2 AND b>2) }]
+
+do_execsql_test 2.2 {
+ SELECT d FROM t2 WHERE (a, b) >= (2, 2);
+} [db eval { SELECT d FROM t2 WHERE a>2 OR (a=2 AND b>=2) }]
+
+do_execsql_test 2.3 {
+ SELECT d FROM t2 WHERE a=1 AND (b, c) >= (1, 2);
+} [db eval { SELECT d FROM t2 WHERE +a=1 AND (b>1 OR (b==1 AND c>=2)) }]
+
+do_execsql_test 2.4 {
+ SELECT d FROM t2 WHERE a=1 AND (b, c) > (1, 2);
+} [db eval { SELECT d FROM t2 WHERE +a=1 AND (b>1 OR (b==1 AND c>2)) }]
+
+#-------------------------------------------------------------------------
+
+set words {
+airfare airfield airfields airflow airfoil
+airfoils airframe airframes airily airing
+airings airless airlift airlifts airline
+airliner airlines airlock airlocks airmail
+airmails airman airmen airplane airplanes
+
+arraignment arraignments arraigns arrange arranged
+arrangement arrangements arranger arrangers arranges
+arranging arrant array arrayed arrays
+arrears arrest arrested arrester arresters
+arresting arrestingly arrestor arrestors arrests
+
+edifices edit edited editing edition
+editions editor editorial editorially editorials
+editors edits educable educate educated
+educates educating education educational educationally
+educations educator educators eel eelgrass
+}
+
+do_test 3.0 {
+ execsql { CREATE TABLE t3(a, b, c, w); }
+ foreach w $words {
+ set a [string range $w 0 2]
+ set b [string range $w 3 5]
+ set c [string range $w 6 end]
+ execsql { INSERT INTO t3 VALUES($a, $b, $c, $w) }
+ }
+} {}
+
+
+foreach {tn idx} {
+ IDX1 {}
+ IDX2 { CREATE INDEX i3 ON t3(a, b, c); }
+ IDX3 { CREATE INDEX i3 ON t3(a, b); }
+ IDX4 { CREATE INDEX i3 ON t3(a); }
+} {
+ execsql { DROP INDEX IF EXISTS i3 }
+ execsql $idx
+
+ foreach w $words {
+ set a [string range $w 0 2]
+ set b [string range $w 3 5]
+ set c [string range $w 6 end]
+
+ foreach op [list > >= < <= == IS] {
+ do_execsql_test 3.1.$tn.$w.$op [subst -novar {
+ SELECT rowid FROM t3 WHERE (a, b, c) [set op] ($a, $b, $c)
+ ORDER BY +rowid
+ }] [db eval [subst -novar {
+ SELECT rowid FROM t3 WHERE w [set op] $w ORDER BY +rowid
+ }]]
+
+ do_execsql_test 3.1.$tn.$w.$op.subselect [subst -novar {
+ SELECT rowid FROM t3 WHERE (a, b, c) [set op] (
+ SELECT a, b, c FROM t3 WHERE w = $w
+ )
+ ORDER BY +rowid
+ }] [db eval [subst -novar {
+ SELECT rowid FROM t3 WHERE w [set op] $w ORDER BY +rowid
+ }]]
+ }
+
+ }
+}
+
+#-------------------------------------------------------------------------
+#
+
+do_execsql_test 4.0 {
+ CREATE TABLE t4(a, b, c);
+ INSERT INTO t4 VALUES(NULL, NULL, NULL);
+ INSERT INTO t4 VALUES(NULL, NULL, 0);
+ INSERT INTO t4 VALUES(NULL, NULL, 1);
+ INSERT INTO t4 VALUES(NULL, 0, NULL);
+ INSERT INTO t4 VALUES(NULL, 0, 0);
+ INSERT INTO t4 VALUES(NULL, 0, 1);
+ INSERT INTO t4 VALUES(NULL, 1, NULL);
+ INSERT INTO t4 VALUES(NULL, 1, 0);
+ INSERT INTO t4 VALUES(NULL, 1, 1);
+
+ INSERT INTO t4 VALUES( 0, NULL, NULL);
+ INSERT INTO t4 VALUES( 0, NULL, 0);
+ INSERT INTO t4 VALUES( 0, NULL, 1);
+ INSERT INTO t4 VALUES( 0, 0, NULL);
+ INSERT INTO t4 VALUES( 0, 0, 0);
+ INSERT INTO t4 VALUES( 0, 0, 1);
+ INSERT INTO t4 VALUES( 0, 1, NULL);
+ INSERT INTO t4 VALUES( 0, 1, 0);
+ INSERT INTO t4 VALUES( 0, 1, 1);
+
+ INSERT INTO t4 VALUES( 1, NULL, NULL);
+ INSERT INTO t4 VALUES( 1, NULL, 0);
+ INSERT INTO t4 VALUES( 1, NULL, 1);
+ INSERT INTO t4 VALUES( 1, 0, NULL);
+ INSERT INTO t4 VALUES( 1, 0, 0);
+ INSERT INTO t4 VALUES( 1, 0, 1);
+ INSERT INTO t4 VALUES( 1, 1, NULL);
+ INSERT INTO t4 VALUES( 1, 1, 0);
+ INSERT INTO t4 VALUES( 1, 1, 1);
+}
+
+proc make_expr1 {cList vList op} {
+ return "([join $cList ,]) $op ([join $vList ,])"
+}
+
+proc make_expr3 {cList vList op} {
+ set n [llength $cList]
+
+ set aList [list]
+ foreach c [lrange $cList 0 end-1] v [lrange $vList 0 end-1] {
+ lappend aList "$c == $v"
+ }
+ lappend aList "[lindex $cList end] $op [lindex $vList end]"
+
+ return "([join $aList { AND }])"
+}
+
+proc make_expr2 {cList vList op} {
+ set ret ""
+
+ switch -- $op {
+ == - IS {
+ set aList [list]
+ foreach c $cList v $vList { lappend aList "($c $op $v)" }
+ set ret [join $aList " AND "]
+ }
+
+ < - > {
+ set oList [list]
+ for {set i 0} {$i < [llength $cList]} {incr i} {
+ lappend oList [make_expr3 [lrange $cList 0 $i] [lrange $vList 0 $i] $op]
+ }
+ set ret [join $oList " OR "]
+ }
+
+ <= - >= {
+ set o2 [string range $op 0 0]
+ set oList [list]
+ for {set i 0} {$i < [llength $cList]-1} {incr i} {
+ lappend oList [make_expr3 [lrange $cList 0 $i] [lrange $vList 0 $i] $o2]
+ }
+ lappend oList [make_expr3 $cList $vList $op]
+ set ret [join $oList " OR "]
+ }
+
+
+ default {
+ error "Unknown op: $op"
+ }
+ }
+
+ set ret
+}
+
+foreach {tn idx} {
+ IDX1 {}
+ IDX2 { CREATE INDEX i4 ON t4(a, b, c); }
+ IDX3 { CREATE INDEX i4 ON t4(a, b); }
+ IDX4 { CREATE INDEX i4 ON t4(a); }
+} {
+ execsql { DROP INDEX IF EXISTS i4 }
+ execsql $idx
+
+ foreach {tn2 vector} {
+ 1 {0 0 0}
+ 2 {1 1 1}
+ 3 {0 0 NULL}
+ 4 {0 NULL 0}
+ 5 {NULL 0 0}
+ 6 {1 1 NULL}
+ 7 {1 NULL 1}
+ 8 {NULL 1 1}
+ } {
+ foreach op { IS == < <= > >= } {
+ set e1 [make_expr1 {a b c} $vector $op]
+ set e2 [make_expr2 {a b c} $vector $op]
+
+ do_execsql_test 4.$tn.$tn2.$op \
+ "SELECT rowid FROM t4 WHERE $e2 ORDER BY +rowid" [
+ db eval "SELECT rowid FROM t4 WHERE $e1 ORDER BY +rowid"
+ ]
+ }
+ }
+}
+
+do_execsql_test 5.0 {
+ CREATE TABLE r1(a TEXT, iB TEXT);
+ CREATE TABLE r2(x TEXT, zY INTEGER);
+ CREATE INDEX r1ab ON r1(a, iB);
+
+ INSERT INTO r1 VALUES(35, 35);
+ INSERT INTO r2 VALUES(35, 36);
+ INSERT INTO r2 VALUES(35, 4);
+ INSERT INTO r2 VALUES(35, 35);
+} {}
+
+foreach {tn lhs rhs} {
+ 1 {x +zY} {a iB}
+ 2 {x zY} {a iB}
+ 3 {x zY} {a +iB}
+ 4 {+x zY} {a iB}
+ 5 {x zY} {+a iB}
+} {
+ foreach op { IS == < <= > >= } {
+ set e1 [make_expr1 $lhs $rhs $op]
+ set e2 [make_expr2 $lhs $rhs $op]
+ do_execsql_test 5.$tn.$op \
+ "SELECT * FROM r1, r2 WHERE $e2 ORDER BY iB" [db eval \
+ "SELECT * FROM r1, r2 WHERE $e1 ORDER BY iB"
+ ]
+ }
+}
+
+
+finish_test
diff --git a/test/rowvalue3.test b/test/rowvalue3.test
new file mode 100644
index 0000000..80ebeb7
--- /dev/null
+++ b/test/rowvalue3.test
@@ -0,0 +1,221 @@
+# 2016 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing "(...) IN (SELECT ...)" expressions
+# where the SELECT statement returns more than one column.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix rowvalue3
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ INSERT INTO t1 VALUES(7, 8, 9);
+}
+
+foreach {tn sql res} {
+ 1 "SELECT 1 WHERE (4, 5) IN (SELECT a, b FROM t1)" 1
+ 2 "SELECT 1 WHERE (5, 5) IN (SELECT a, b FROM t1)" {}
+ 3 "SELECT 1 WHERE (5, 4) IN (SELECT a, b FROM t1)" {}
+ 4 "SELECT 1 WHERE (5, 4) IN (SELECT b, a FROM t1)" 1
+ 5 "SELECT 1 WHERE (SELECT a, b FROM t1 WHERE c=6) IN (SELECT a, b FROM t1)" 1
+ 6 "SELECT (5, 4) IN (SELECT a, b FROM t1)" 0
+ 7 "SELECT 1 WHERE (5, 4) IN (SELECT +b, +a FROM t1)" 1
+ 8 "SELECT (5, 4) IN (SELECT +b, +a FROM t1)" 1
+ 9 "SELECT (1, 2) IN (SELECT rowid, b FROM t1)" 1
+ 10 "SELECT 1 WHERE (1, 2) IN (SELECT rowid, b FROM t1)" 1
+ 11 "SELECT 1 WHERE (1, NULL) IN (SELECT rowid, b FROM t1)" {}
+ 12 "SELECT 1 FROM t1 WHERE (a, b) = (SELECT +a, +b FROM t1)" {1}
+} {
+ do_execsql_test 1.$tn $sql $res
+}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 2.0 {
+ CREATE TABLE z1(x, y, z);
+ CREATE TABLE kk(a, b);
+
+ INSERT INTO z1 VALUES('a', 'b', 'c');
+ INSERT INTO z1 VALUES('d', 'e', 'f');
+ INSERT INTO z1 VALUES('g', 'h', 'i');
+
+ -- INSERT INTO kk VALUES('y', 'y');
+ INSERT INTO kk VALUES('d', 'e');
+ -- INSERT INTO kk VALUES('x', 'x');
+
+}
+
+foreach {tn idx} {
+ 1 { }
+ 2 { CREATE INDEX z1idx ON z1(x, y) }
+ 3 { CREATE UNIQUE INDEX z1idx ON z1(x, y) }
+ 4 { CREATE INDEX z1idx ON kk(a, b) }
+} {
+ execsql "DROP INDEX IF EXISTS z1idx"
+ execsql $idx
+
+ do_execsql_test 2.$tn.1 {
+ SELECT * FROM z1 WHERE x IN (SELECT a FROM kk)
+ } {d e f}
+
+ do_execsql_test 2.$tn.2 {
+ SELECT * FROM z1 WHERE (x,y) IN (SELECT a, b FROM kk)
+ } {d e f}
+
+ do_execsql_test 2.$tn.3 {
+ SELECT * FROM z1 WHERE (x, +y) IN (SELECT a, b FROM kk)
+ } {d e f}
+
+ do_execsql_test 2.$tn.4 {
+ SELECT * FROM z1 WHERE (x, +y) IN (SELECT a, b||'x' FROM kk)
+ } {}
+
+ do_execsql_test 2.$tn.5 {
+ SELECT * FROM z1 WHERE (+x, y) IN (SELECT a, b FROM kk)
+ } {d e f}
+}
+
+#-------------------------------------------------------------------------
+#
+
+do_execsql_test 3.0 {
+ CREATE TABLE c1(a, b, c, d);
+ INSERT INTO c1(rowid, a, b) VALUES(1, NULL, 1);
+ INSERT INTO c1(rowid, a, b) VALUES(2, 2, NULL);
+ INSERT INTO c1(rowid, a, b) VALUES(3, 2, 2);
+ INSERT INTO c1(rowid, a, b) VALUES(4, 3, 3);
+
+ INSERT INTO c1(rowid, a, b, c, d) VALUES(101, 'a', 'b', 1, 1);
+ INSERT INTO c1(rowid, a, b, c, d) VALUES(102, 'a', 'b', 1, 2);
+ INSERT INTO c1(rowid, a, b, c, d) VALUES(103, 'a', 'b', 1, 3);
+ INSERT INTO c1(rowid, a, b, c, d) VALUES(104, 'a', 'b', 2, 1);
+ INSERT INTO c1(rowid, a, b, c, d) VALUES(105, 'a', 'b', 2, 2);
+ INSERT INTO c1(rowid, a, b, c, d) VALUES(106, 'a', 'b', 2, 3);
+ INSERT INTO c1(rowid, a, b, c, d) VALUES(107, 'a', 'b', 3, 1);
+ INSERT INTO c1(rowid, a, b, c, d) VALUES(108, 'a', 'b', 3, 2);
+ INSERT INTO c1(rowid, a, b, c, d) VALUES(109, 'a', 'b', 3, 3);
+}
+
+
+foreach {tn idx} {
+ 1 { }
+ 2 { CREATE INDEX c1ab ON c1(a, b); }
+ 3 { CREATE INDEX c1ba ON c1(b, a); }
+
+ 4 { CREATE INDEX c1cd ON c1(c, d); }
+ 5 { CREATE INDEX c1dc ON c1(d, c); }
+} {
+ drop_all_indexes
+
+ foreach {tn2 sql res} {
+ 1 "SELECT (1, 2) IN (SELECT a, b FROM c1)" {0}
+ 2 "SELECT (1, 1) IN (SELECT a, b FROM c1)" {{}}
+ 3 "SELECT (2, 1) IN (SELECT a, b FROM c1)" {{}}
+ 4 "SELECT (2, 2) IN (SELECT a, b FROM c1)" {1}
+ 5 "SELECT c, d FROM c1 WHERE (c, d) IN (SELECT d, c FROM c1)"
+ { 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 }
+
+ 6 "SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1) ORDER BY c DESC"
+ { 3 1 3 2 3 3 2 1 2 2 2 3 1 1 1 2 1 3 }
+
+ 7 {
+ SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1)
+ ORDER BY c DESC, d ASC
+ } { 3 1 3 2 3 3 2 1 2 2 2 3 1 1 1 2 1 3 }
+
+ 8 {
+ SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1)
+ ORDER BY c ASC, d DESC
+ } { 1 3 1 2 1 1 2 3 2 2 2 1 3 3 3 2 3 1 }
+
+ 9 {
+ SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1)
+ ORDER BY c ASC, d ASC
+ } { 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 }
+ 10 {
+ SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1)
+ ORDER BY c DESC, d DESC
+ } { 3 3 3 2 3 1 2 3 2 2 2 1 1 3 1 2 1 1 }
+
+ } {
+ do_execsql_test 3.$tn.$tn2 $sql $res
+ }
+}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 4.0 {
+ CREATE TABLE hh(a, b, c);
+
+ INSERT INTO hh VALUES('a', 'a', 1);
+ INSERT INTO hh VALUES('a', 'b', 2);
+ INSERT INTO hh VALUES('b', 'a', 3);
+ INSERT INTO hh VALUES('b', 'b', 4);
+
+ CREATE TABLE k1(x, y);
+ INSERT INTO k1 VALUES('a', 'a');
+ INSERT INTO k1 VALUES('b', 'b');
+ INSERT INTO k1 VALUES('a', 'b');
+ INSERT INTO k1 VALUES('b', 'a');
+}
+
+foreach {tn idx} {
+ 1 { }
+ 2 { CREATE INDEX h1 ON hh(a, b); }
+ 3 { CREATE UNIQUE INDEX k1idx ON k1(x, y) }
+ 4 { CREATE UNIQUE INDEX k1idx ON k1(x, y DESC) }
+ 5 {
+ CREATE INDEX h1 ON hh(a, b);
+ CREATE UNIQUE INDEX k1idx ON k1(x, y);
+ }
+ 6 {
+ CREATE INDEX h1 ON hh(a, b);
+ CREATE UNIQUE INDEX k1idx ON k1(x, y DESC);
+ }
+} {
+ drop_all_indexes
+ execsql $idx
+ foreach {tn2 orderby res} {
+ 1 "a ASC, b ASC" {1 2 3 4}
+ 2 "a ASC, b DESC" {2 1 4 3}
+ 3 "a DESC, b ASC" {3 4 1 2}
+ 4 "a DESC, b DESC" {4 3 2 1}
+ } {
+ do_execsql_test 4.$tn.$tn2 "
+ SELECT c FROM hh WHERE (a, b) in (SELECT x, y FROM k1) ORDER BY $orderby
+ " $res
+ }
+}
+
+#-------------------------------------------------------------------------
+
+# 2016-11-17. Query flattening in a vector SELECT on the RHS of an IN
+# operator. Ticket https://www.sqlite.org/src/info/da7841375186386c
+#
+do_execsql_test 5.0 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE T1(a TEXT);
+ INSERT INTO T1(a) VALUES ('aaa');
+ CREATE TABLE T2(a TEXT PRIMARY KEY,n INT);
+ INSERT INTO T2(a, n) VALUES('aaa',0);
+ SELECT * FROM T2
+ WHERE (a,n) IN (SELECT T1.a, V.n
+ FROM T1, (SELECT * FROM (SELECT 0 n) T3) V);
+} {aaa 0}
+
+
+finish_test
diff --git a/test/rowvalue4.test b/test/rowvalue4.test
new file mode 100644
index 0000000..784859c
--- /dev/null
+++ b/test/rowvalue4.test
@@ -0,0 +1,305 @@
+# 2016 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is syntax errors involving row-value constructors
+# and sub-selects that return multiple arguments.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix rowvalue4
+
+#-------------------------------------------------------------------------
+# Test some error conditions:
+#
+# * row values used where they are not supported,
+# * row values or sub-selects that contain/return the wrong number
+# of elements.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX t1bac ON t1(b, a, c);
+}
+
+foreach {tn e} {
+ 1 "(1, 2, 3)"
+ 2 "1 + (1, 2)"
+ 3 "(1,2,3) == (1, 2)"
+} {
+ do_catchsql_test 1.$tn "SELECT $e" {1 {row value misused}}
+}
+
+foreach {tn s error} {
+ 1 "SELECT * FROM t1 WHERE a = (1, 2)" {row value misused}
+ 2 "SELECT * FROM t1 WHERE b = (1, 2)" {row value misused}
+ 3 "SELECT * FROM t1 WHERE NOT (b = (1, 2))" {row value misused}
+ 4 "SELECT * FROM t1 LIMIT (1, 2)" {row value misused}
+ 5 "SELECT (a, b) IN (SELECT * FROM t1) FROM t1"
+ {sub-select returns 3 columns - expected 2}
+
+ 6 "SELECT * FROM t1 WHERE (a, b) IN (SELECT * FROM t1)"
+ {sub-select returns 3 columns - expected 2}
+ 7 "SELECT * FROM t1 WHERE (c, c) <= 1" {row value misused}
+ 8 "SELECT * FROM t1 WHERE (b, b) <= 1" {row value misused}
+} {
+ do_catchsql_test 2.$tn "$s" [list 1 $error]
+}
+
+#-------------------------------------------------------------------------
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a, b, c, d);
+ INSERT INTO t2 VALUES(1, 1, 1, 1);
+ INSERT INTO t2 VALUES(1, 1, 2, 2);
+ INSERT INTO t2 VALUES(1, 1, 3, 3);
+ INSERT INTO t2 VALUES(1, 2, 1, 4);
+ INSERT INTO t2 VALUES(1, 2, 2, 5);
+ INSERT INTO t2 VALUES(1, 2, 3, 6);
+ INSERT INTO t2 VALUES(1, 3, 1, 7);
+ INSERT INTO t2 VALUES(1, 3, 2, 8);
+ INSERT INTO t2 VALUES(1, 3, 3, 9);
+
+ INSERT INTO t2 VALUES(2, 1, 1, 10);
+ INSERT INTO t2 VALUES(2, 1, 2, 11);
+ INSERT INTO t2 VALUES(2, 1, 3, 12);
+ INSERT INTO t2 VALUES(2, 2, 1, 13);
+ INSERT INTO t2 VALUES(2, 2, 2, 14);
+ INSERT INTO t2 VALUES(2, 2, 3, 15);
+ INSERT INTO t2 VALUES(2, 3, 1, 16);
+ INSERT INTO t2 VALUES(2, 3, 2, 17);
+ INSERT INTO t2 VALUES(2, 3, 3, 18);
+
+ INSERT INTO t2 VALUES(3, 1, 1, 19);
+ INSERT INTO t2 VALUES(3, 1, 2, 20);
+ INSERT INTO t2 VALUES(3, 1, 3, 21);
+ INSERT INTO t2 VALUES(3, 2, 1, 22);
+ INSERT INTO t2 VALUES(3, 2, 2, 23);
+ INSERT INTO t2 VALUES(3, 2, 3, 24);
+ INSERT INTO t2 VALUES(3, 3, 1, 25);
+ INSERT INTO t2 VALUES(3, 3, 2, 26);
+ INSERT INTO t2 VALUES(3, 3, 3, 27);
+}
+
+foreach {nm idx} {
+ idx1 {}
+ idx2 { CREATE INDEX t2abc ON t2(a, b, c); }
+ idx3 { CREATE INDEX t2abc ON t2(a, b DESC, c); }
+ idx4 { CREATE INDEX t2abc ON t2(a DESC, b DESC, c DESC); }
+ idx5 { CREATE INDEX t2abc ON t2(a ASC, b ASC, c ASC); }
+ idx6 { CREATE INDEX t2abc ON t2(a DESC, b, c); }
+ idx7 { CREATE INDEX t2abc ON t2(a DESC, b DESC) }
+ idx8 { CREATE INDEX t2abc ON t2(c, b, a); }
+ idx9 { CREATE INDEX t2d ON t2(d); }
+ idx10 { CREATE INDEX t2abc ON t2(a DESC, b, c DESC); }
+} {
+ drop_all_indexes
+ execsql $idx
+
+ foreach {tn where res} {
+ 1 "(a, b, c) < (2, 2, 2)" {1 2 3 4 5 6 7 8 9 10 11 12 13}
+ 2 "(a, b, c) <= (2, 2, 2)" {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
+ 3 "(a, b, c) > (2, 2, 2)" {15 16 17 18 19 20 21 22 23 24 25 26 27}
+ 4 "(a, b, c) >= (2, 2, 2)" {14 15 16 17 18 19 20 21 22 23 24 25 26 27}
+ 5 "(a, b, c) >= (2, 2, NULL)" {16 17 18 19 20 21 22 23 24 25 26 27}
+ 6 "(a, b, c) <= (2, 2, NULL)" {1 2 3 4 5 6 7 8 9 10 11 12}
+ 7 "(a, b, c) >= (2, NULL, NULL)" {19 20 21 22 23 24 25 26 27}
+ 8 "(a, b, c) <= (2, NULL, NULL)" {1 2 3 4 5 6 7 8 9}
+
+ 9 "(a, b, c) < (SELECT a, b, c FROM t2 WHERE d=14)"
+ {1 2 3 4 5 6 7 8 9 10 11 12 13}
+
+ 10 "(a, b, c) = (SELECT a, b, c FROM t2 WHERE d=14)" 14
+
+ 11 "a = 2 AND (b, c) > (2, 2)" {15 16 17 18}
+ 12 "a = 2 AND (b, c) < (3, 3) AND (b, c) > (1, 1)" {11 12 13 14 15 16 17}
+ } {
+ set result [db eval "SELECT d FROM t2 WHERE $where"]
+ do_test 2.1.$nm.$tn { lsort -integer $result } $res
+ }
+
+ foreach {tn e res} {
+ 1 "(2, 1) IN (SELECT a, b FROM t2)" 1
+ 2 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d)" 1
+ 3 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 9)" 0
+ 4 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 10)" 1
+
+ 5 "(3, 3) = (SELECT a, b FROM t2 ORDER BY d DESC LIMIT 1)" 1
+ 6 "(3, 3) = (SELECT a, b FROM t2 ORDER BY d ASC LIMIT 1)" 0
+ 7 "(1, NULL) = (SELECT a, b FROM t2 ORDER BY d ASC LIMIT 1)" {{}}
+
+ 8 "(3, 1) = (SELECT b, c FROM t2 ORDER BY d DESC LIMIT 1 OFFSET 2)" 1
+ 9 "(3, 1) = (SELECT b, c FROM t2 ORDER BY d ASC LIMIT 1 OFFSET 2)" 0
+ 10 "(1, NULL) = (SELECT b, c FROM t2 ORDER BY d ASC LIMIT 1 OFFSET 2)" {{}}
+
+ 11 "(3, 3) = (SELECT max(a), max(b) FROM t2)" 1
+ 12 "(3, 1) = (SELECT max(a), min(b) FROM t2)" 1
+ 13 "(NULL, NULL) = (SELECT max(a), min(b) FROM t2)" {{}}
+
+ 14 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 5 OFFSET 11)" 1
+ 15 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 5 OFFSET 12)" 0
+ } {
+ do_execsql_test 2.2.$nm.$tn "SELECT $e" $res
+ }
+}
+
+ifcapable stat4 {
+ do_execsql_test 3.0 {
+ CREATE TABLE c1(a, b, c, d);
+ INSERT INTO c1(a, b) VALUES(1, 'a');
+ INSERT INTO c1(a, b) VALUES(1, 'b');
+ INSERT INTO c1(a, b) VALUES(1, 'c');
+ INSERT INTO c1(a, b) VALUES(1, 'd');
+ INSERT INTO c1(a, b) VALUES(1, 'e');
+ INSERT INTO c1(a, b) VALUES(1, 'f');
+ INSERT INTO c1(a, b) VALUES(1, 'g');
+ INSERT INTO c1(a, b) VALUES(1, 'h');
+ INSERT INTO c1(a, b) VALUES(1, 'i');
+ INSERT INTO c1(a, b) VALUES(1, 'j');
+ INSERT INTO c1(a, b) VALUES(1, 'k');
+ INSERT INTO c1(a, b) VALUES(1, 'l');
+ INSERT INTO c1(a, b) VALUES(1, 'm');
+ INSERT INTO c1(a, b) VALUES(1, 'n');
+ INSERT INTO c1(a, b) VALUES(1, 'o');
+ INSERT INTO c1(a, b) VALUES(1, 'p');
+ INSERT INTO c1(a, b) VALUES(2, 'a');
+ INSERT INTO c1(a, b) VALUES(2, 'b');
+ INSERT INTO c1(a, b) VALUES(2, 'c');
+ INSERT INTO c1(a, b) VALUES(2, 'd');
+ INSERT INTO c1(a, b) VALUES(2, 'e');
+ INSERT INTO c1(a, b) VALUES(2, 'f');
+ INSERT INTO c1(a, b) VALUES(2, 'g');
+ INSERT INTO c1(a, b) VALUES(2, 'h');
+
+ INSERT INTO c1(c, d) SELECT a, b FROM c1;
+
+ CREATE INDEX c1ab ON c1(a, b);
+ CREATE INDEX c1cd ON c1(c, d);
+ ANALYZE;
+ }
+
+ do_eqp_test 3.1.1 { SELECT * FROM c1 WHERE a=1 AND c=2 } \
+ {SEARCH c1 USING INDEX c1cd (c=?)}
+
+ do_eqp_test 3.1.2 { SELECT * FROM c1 WHERE a=1 AND b>'d' AND c=2 } \
+ {SEARCH c1 USING INDEX c1cd (c=?)}
+
+ do_eqp_test 3.1.3 { SELECT * FROM c1 WHERE a=1 AND b>'l' AND c=2 } \
+ {SEARCH c1 USING INDEX c1ab (a=? AND b>?)}
+
+ do_eqp_test 3.2.1 { SELECT * FROM c1 WHERE a=1 AND c>1 } \
+ {SEARCH c1 USING INDEX c1cd (c>?)}
+
+ do_eqp_test 3.2.2 { SELECT * FROM c1 WHERE a=1 AND c>0 } \
+ {SEARCH c1 USING INDEX c1ab (a=?)}
+
+ do_eqp_test 3.2.3 { SELECT * FROM c1 WHERE a=1 AND c>=1 } \
+ {SEARCH c1 USING INDEX c1ab (a=?)}
+
+ do_eqp_test 3.2.4 { SELECT * FROM c1 WHERE a=1 AND (c, d)>(1, 'c') } \
+ {SEARCH c1 USING INDEX c1ab (a=?)}
+
+ do_eqp_test 3.2.5 { SELECT * FROM c1 WHERE a=1 AND (c, d)>(1, 'o') } \
+ {SEARCH c1 USING INDEX c1cd ((c,d)>(?,?))}
+
+ do_eqp_test 3.2.6 { SELECT * FROM c1 WHERE a=1 AND (c, +b)>(1, 'c') } \
+ {SEARCH c1 USING INDEX c1ab (a=?)}
+
+}
+
+#------------------------------------------------------------------------
+
+do_execsql_test 5.0 {
+ CREATE TABLE d1(x, y);
+ CREATE TABLE d2(a, b, c);
+ CREATE INDEX d2ab ON d2(a, b);
+ CREATE INDEX d2c ON d2(c);
+
+ WITH i(i) AS (
+ VALUES(1) UNION ALL SELECT i+1 FROM i WHERE i<1000
+ )
+ INSERT INTO d2 SELECT i/100, i%100, i/100 FROM i;
+ ANALYZE;
+}
+
+do_eqp_test 5.1 {
+ SELECT * FROM d2 WHERE
+ (a, b) IN (SELECT x, y FROM d1) AND
+ (c) IN (SELECT y FROM d1)
+} {
+ QUERY PLAN
+ |--SEARCH d2 USING INDEX d2ab (a=? AND b=?)
+ |--LIST SUBQUERY xxxxxx
+ | `--SCAN d1
+ `--LIST SUBQUERY xxxxxx
+ `--SCAN d1
+}
+
+do_execsql_test 6.0 {
+ CREATE TABLE e1(a, b, c, d, e);
+ CREATE INDEX e1ab ON e1(a, b);
+ CREATE INDEX e1cde ON e1(c, d, e);
+}
+
+do_eqp_test 6.1 {
+ SELECT * FROM e1 WHERE (a, b) > (?, ?)
+} {SEARCH e1 USING INDEX e1ab ((a,b)>(?,?))}
+
+do_eqp_test 6.2 {
+ SELECT * FROM e1 WHERE (a, b) < (?, ?)
+} {SEARCH e1 USING INDEX e1ab ((a,b)<(?,?))}
+
+do_eqp_test 6.3 {
+ SELECT * FROM e1 WHERE c = ? AND (d, e) > (?, ?)
+} {SEARCH e1 USING INDEX e1cde (c=? AND (d,e)>(?,?))}
+
+do_eqp_test 6.4 {
+ SELECT * FROM e1 WHERE c = ? AND (d, e) < (?, ?)
+} {SEARCH e1 USING INDEX e1cde (c=? AND (d,e)<(?,?))}
+
+do_eqp_test 6.5 {
+ SELECT * FROM e1 WHERE (d, e) BETWEEN (?, ?) AND (?, ?) AND c = ?
+} {SEARCH e1 USING INDEX e1cde (c=? AND (d,e)>(?,?) AND (d,e)<(?,?))}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 7.1 {
+ CREATE TABLE f1(a, b, c);
+ CREATE INDEX f1ab ON f1(a, b);
+}
+
+do_catchsql_test 7.2 {
+ SELECT (a COLLATE nocase, b) IN (SELECT a, b FROM f1) FROM f1;
+} {0 {}}
+
+do_catchsql_test 7.3 {
+ SELECT (a COLLATE nose, b) IN (SELECT a, b FROM f1) FROM f1;
+} {1 {no such collation sequence: nose}}
+
+do_catchsql_test 7.4 {
+ SELECT * FROM f1 WHERE (?, ? COLLATE nose) > (a, b);
+} {1 {no such collation sequence: nose}}
+
+#-------------------------------------------------------------------------
+drop_all_tables
+do_execsql_test 8.1 {
+ CREATE TABLE c1(x, y);
+ CREATE TABLE c2(a, b, c);
+ CREATE INDEX c2ab ON c2(a, b);
+ CREATE INDEX c2c ON c2(c);
+
+ CREATE TABLE c3(d);
+}
+do_catchsql_test 8.2 {
+ SELECT * FROM c2 CROSS JOIN c3 WHERE
+ ( (a, b) == (SELECT x, y FROM c1) AND c3.d = c ) OR
+ ( c == (SELECT x, y FROM c1) AND c3.d = c )
+} {1 {row value misused}}
+
+finish_test
diff --git a/test/rowvalue5.test b/test/rowvalue5.test
new file mode 100644
index 0000000..b91dfa4
--- /dev/null
+++ b/test/rowvalue5.test
@@ -0,0 +1,117 @@
+# 2016 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is syntax errors involving row-values and
+# virtual tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix rowvalue5
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+proc vtab_command {method args} {
+ switch -- $method {
+ xConnect {
+ return "CREATE TABLE t1(a, b, c, d, expr)"
+ }
+
+ xBestIndex {
+ set COL(0) a
+ set COL(1) b
+ set COL(2) c
+ set COL(3) d
+ set COL(4) expr
+
+ set OP(eq) =
+ set OP(ne) !=
+ set OP(gt) >
+ set OP(le) <=
+ set OP(lt) <
+ set OP(ge) >=
+ set OP(match) MATCH
+ set OP(like) LIKE
+ set OP(glob) GLOB
+ set OP(regexp) REGEXP
+
+ set hdl [lindex $args 0]
+ set clist [$hdl constraints]
+
+ set ret [list]
+ set elist [list]
+ set i 0
+ foreach c $clist {
+ array set C $c
+ if {$C(usable)} {
+ lappend ret omit $i
+ lappend elist "$COL($C(column)) $OP($C(op)) %$i%"
+ }
+ incr i
+ }
+
+ lappend ret idxstr [join $elist " AND "]
+ #puts "xBestIndex: $ret"
+ return $ret
+ }
+
+ xFilter {
+ foreach {idxnum idxstr arglist} $args {}
+ set i 0
+ set ee $idxstr
+ foreach a $arglist {
+ if {[string is double $a]==0} {
+ set a "'[string map {' ''} $a]'"
+ }
+ set ee [string map [list "%$i%" $a] $ee]
+ incr i
+ }
+ set ee [string map [list "'" "''"] $ee]
+
+ set ret [list sql "SELECT 1, 'a', 'b', 'c', 'd', '$ee'"]
+ #puts "xFilter: $ret"
+ return $ret
+ }
+ }
+
+ return {}
+}
+
+register_tcl_module db
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
+} {}
+
+
+foreach {tn where res} {
+ 1 "1" {{}}
+ 2 "a=1" {{a = 1}}
+ 3 "a=1 AND 4 = b" {{a = 1 AND b = 4}}
+ 4 "c>'hello'" {{c > 'hello'}}
+ 5 "c<='hel''lo'" {{c <= 'hel''lo'}}
+ 6 "(a, b) = (SELECT 9, 10)" {{a = 9 AND b = 10}}
+ 7 "(+a, b) = (SELECT 'a', 'b')" {{b = 'b'}}
+ 8 "(a, +b) = (SELECT 'a', 'b')" {{a = 'a'}}
+ 11 "(+a, b) IN (SELECT 'a', 'b')" {{b = 'b'}}
+ 12 "(a, +b) IN (SELECT 'a', 'b')" {{a = 'a'}}
+
+ 13 "(a, b) < ('d', 'e')" {{a <= 'd'}}
+ 14 "(a, b) < ('a', 'c')" {{a <= 'a'}}
+ 15 "(a, b) <= ('a', 'b')" {{a <= 'a'}}
+ 16 "(a, b) < ('a', 'b')" {}
+} {
+ do_execsql_test 1.$tn "SELECT expr FROM x1 WHERE $where" $res
+}
+
+finish_test
diff --git a/test/rowvalue6.test b/test/rowvalue6.test
new file mode 100644
index 0000000..d90e61c
--- /dev/null
+++ b/test/rowvalue6.test
@@ -0,0 +1,36 @@
+# 2016-08-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 focus of this file is handling of NULL values in row-value IN
+# expressions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix rowvalue6
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1x1 ON t1(a,b);
+ INSERT INTO t1 VALUES(1,NULL,200);
+
+ CREATE TABLE t2(x,y,z);
+ INSERT INTO t2 VALUES(1,NULL,55);
+
+ SELECT c FROM t1 WHERE (a,b) IN (SELECT x,y FROM t2 WHERE z==55);
+} {}
+do_execsql_test 1.2 {
+ INSERT INTO t1 VALUES(2,3,400);
+ INSERT INTO t2 VALUES(2,3,55);
+
+ SELECT c FROM t1 WHERE (a,b) IN (SELECT x,y FROM t2 WHERE z==55);
+} {400}
+
+finish_test
diff --git a/test/rowvalue7.test b/test/rowvalue7.test
new file mode 100644
index 0000000..03591af
--- /dev/null
+++ b/test/rowvalue7.test
@@ -0,0 +1,68 @@
+# 2016-08-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 focus of this file is vector assignments in the SET clause of
+# an UPDATE statement.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix rowvalue7
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE INDEX t1x ON t1(a,b);
+ INSERT INTO t1(a,b,c,d) VALUES(1,2,0,0),(3,4,0,0),(5,6,0,0);
+ CREATE TABLE t2(w,x,y,z);
+ CREATE INDEX t2x ON t2(w,x);
+ INSERT INTO t2(w,x,y,z) VALUES(1,2,11,22),(8,9,88,99),(3,5,33,55),(5,6,55,66);
+
+ SELECT *,'|' FROM t1 ORDER BY a;
+} {1 2 0 0 | 3 4 0 0 | 5 6 0 0 |}
+
+do_execsql_test 1.2 {
+ UPDATE t1 SET (c,d) = (SELECT y,z FROM t2 WHERE (w,x)=(a,b));
+ SELECT *,'|' FROM t1 ORDER BY a;
+} {1 2 11 22 | 3 4 {} {} | 5 6 55 66 |}
+
+do_execsql_test 1.3 {
+ UPDATE t1 SET (c,d) = (SELECT y,z FROM t2 WHERE w=a);
+ SELECT *,'|' FROM t1 ORDER BY a;
+} {1 2 11 22 | 3 4 33 55 | 5 6 55 66 |}
+
+do_execsql_test 1.4 {
+ UPDATE t1 SET (c) = 99 WHERE a=3;
+ SELECT *,'|' FROM t1 ORDER BY a;
+} {1 2 11 22 | 3 4 99 55 | 5 6 55 66 |}
+
+do_execsql_test 1.5 {
+ UPDATE t1 SET b = 8, (c,d) = (SELECT 123,456) WHERE a=3;
+ SELECT *,'|' FROM t1 ORDER BY a;
+} {1 2 11 22 | 3 8 123 456 | 5 6 55 66 |}
+
+do_catchsql_test 2.1 {
+ UPDATE t1 SET (c,d) = (SELECT x,y,z FROM t2 WHERE w=a);
+} {1 {2 columns assigned 3 values}}
+
+do_catchsql_test 2.2 {
+ UPDATE t1 SET (b,c,d) = (SELECT x,y FROM t2 WHERE w=a);
+} {1 {3 columns assigned 2 values}}
+
+# 2019-08-26
+# ticket https://www.sqlite.org/src/info/78acc9d40f0786e8
+#
+do_catchsql_test 3.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ UPDATE t1 SET (a,a,a,b)=(SELECT 99,100);
+} {1 {4 columns assigned 2 values}}
+
+finish_test
diff --git a/test/rowvalue8.test b/test/rowvalue8.test
new file mode 100644
index 0000000..432dad1
--- /dev/null
+++ b/test/rowvalue8.test
@@ -0,0 +1,59 @@
+# 2016-08-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.
+#
+#***********************************************************************
+# Use of row values in CASE statements.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix rowvalue8
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);
+ INSERT INTO t1(a,b,c,d) VALUES
+ (1,1,2,3),
+ (2,2,3,4),
+ (3,1,2,4),
+ (4,2,3,5),
+ (5,3,4,6),
+ (6,4,5,9);
+ SELECT a, CASE (b,c) WHEN (1,2) THEN 'aleph'
+ WHEN (2,3) THEN 'bet'
+ WHEN (3,4) THEN 'gimel'
+ ELSE '-' END,
+ '|'
+ FROM t1
+ ORDER BY a;
+} {1 aleph | 2 bet | 3 aleph | 4 bet | 5 gimel | 6 - |}
+do_execsql_test 1.2 {
+ SELECT a, CASE (b,c,d) WHEN (1,2,3) THEN 'aleph'
+ WHEN (2,3,4) THEN 'bet'
+ WHEN (3,4,6) THEN 'gimel'
+ ELSE '-' END,
+ '|'
+ FROM t1
+ ORDER BY a;
+} {1 aleph | 2 bet | 3 - | 4 - | 5 gimel | 6 - |}
+
+do_execsql_test 2.1 {
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t2(x,y) VALUES(1,6),(2,5),(3,4),(4,3),(5,2),(6,1);
+ SELECT x, CASE (SELECT b,c FROM t1 WHERE a=y)
+ WHEN (1,2) THEN 'aleph'
+ WHEN (2,3) THEN 'bet'
+ WHEN (3,4) THEN 'gimel'
+ ELSE '-' END,
+ '|'
+ FROM t2
+ ORDER BY +x;
+} {1 - | 2 gimel | 3 bet | 4 aleph | 5 bet | 6 aleph |}
+
+
+finish_test
diff --git a/test/rowvalue9.test b/test/rowvalue9.test
new file mode 100644
index 0000000..611aa3f
--- /dev/null
+++ b/test/rowvalue9.test
@@ -0,0 +1,314 @@
+# 2016 September 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 SQL statements that use row value
+# constructors.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix rowvalue9
+
+# Tests:
+#
+# 1.*: Test that affinities are handled correctly by various row-value
+# operations without indexes.
+#
+# 2.*: Test an affinity bug that came up during testing.
+#
+# 3.*: Test a row-value version of the bug tested by 2.*.
+#
+# 4.*: Test that affinities are handled correctly by various row-value
+# operations with assorted indexes.
+#
+
+do_execsql_test 1.0.1 {
+ CREATE TABLE a1(c, b INTEGER, a TEXT, PRIMARY KEY(a, b));
+
+ INSERT INTO a1 (rowid, c, b, a) VALUES(3, '0x03', 1, 1);
+ INSERT INTO a1 (rowid, c, b, a) VALUES(14, '0x0E', 2, 2);
+ INSERT INTO a1 (rowid, c, b, a) VALUES(15, '0x0F', 3, 3);
+ INSERT INTO a1 (rowid, c, b, a) VALUES(92, '0x5C', 4, 4);
+
+ CREATE TABLE a2(x BLOB, y BLOB);
+ INSERT INTO a2(x, y) VALUES(1, 1);
+ INSERT INTO a2(x, y) VALUES(2, '2');
+ INSERT INTO a2(x, y) VALUES('3', 3);
+ INSERT INTO a2(x, y) VALUES('4', '4');
+}
+
+do_execsql_test 1.0.2 {
+ SELECT x, typeof(x), y, typeof(y) FROM a2 ORDER BY rowid
+} {
+ 1 integer 1 integer
+ 2 integer 2 text
+ 3 text 3 integer
+ 4 text 4 text
+}
+
+do_execsql_test 1.1.1 {
+ SELECT (SELECT rowid FROM a1 WHERE a=x AND b=y) FROM a2
+} {{} {} 15 92}
+do_execsql_test 1.1.2 {
+ SELECT (SELECT rowid FROM a1 WHERE (a, b) = (x, y)) FROM a2
+} {{} {} 15 92}
+
+do_execsql_test 1.2.3 {
+ SELECT a1.rowid FROM a1, a2 WHERE a=x AND b=y;
+} {15 92}
+do_execsql_test 1.2.4 {
+ SELECT a1.rowid FROM a1, a2 WHERE (a, b) = (x, y)
+} {15 92}
+
+
+do_execsql_test 1.3.1 {
+ SELECT a1.rowid FROM a1, a2 WHERE coalesce(NULL,x)=a AND coalesce(NULL,y)=b
+} {3 14 15 92}
+do_execsql_test 1.3.2 {
+ SELECT a1.rowid FROM a1, a2
+ WHERE (coalesce(NULL,x), coalesce(NULL,y)) = (a, b)
+} {3 14 15 92}
+
+do_execsql_test 1.4.1 {
+ SELECT a1.rowid FROM a1, a2 WHERE +x=a AND +y=b
+} {3 14 15 92}
+do_execsql_test 1.4.2 {
+ SELECT a1.rowid FROM a1, a2 WHERE (+x, +y) = (a, b)
+} {3 14 15 92}
+
+do_execsql_test 1.5.1 {
+ SELECT (SELECT rowid FROM a1 WHERE a=+x AND b=+y) FROM a2
+} {3 14 15 92}
+do_execsql_test 1.5.2 {
+ SELECT (SELECT rowid FROM a1 WHERE (a, b) = (+x, +y)) FROM a2
+} {3 14 15 92}
+do_execsql_test 1.5.3 {
+ SELECT (SELECT rowid FROM a1 WHERE (+x, +y) = (a, b)) FROM a2
+} {3 14 15 92}
+
+do_execsql_test 1.6.1 {
+ SELECT a1.rowid FROM a1 WHERE (a, b) IN (SELECT x, y FROM a2)
+} {15 92}
+do_execsql_test 1.6.2 {
+ SELECT a1.rowid FROM a1, a2 WHERE EXISTS (
+ SELECT 1 FROM a1 WHERE a=x AND b=y
+ )
+} {3 14 15 92 3 14 15 92}
+
+# Test that [199df416] is fixed.
+#
+do_execsql_test 2.1 {
+ CREATE TABLE b1(a TEXT);
+ CREATE TABLE b2(x BLOB);
+ INSERT INTO b1 VALUES(1);
+ INSERT INTO b2 VALUES(1);
+}
+do_execsql_test 2.2 { SELECT * FROM b1, b2 WHERE a=x; } {}
+do_execsql_test 2.3 { SELECT * FROM b1 WHERE a IN (SELECT x FROM b2) } {}
+do_execsql_test 2.4 { CREATE UNIQUE INDEX b1a ON b1(a); }
+do_execsql_test 2.5 { SELECT * FROM b1 WHERE a IN (SELECT x FROM b2) } {}
+
+# Test that a multi-column version of the query that revealed problem
+# [199df416] also works.
+#
+do_execsql_test 3.1 {
+ CREATE TABLE c1(a INTEGER, b TEXT);
+ INSERT INTO c1 VALUES(1, 1);
+ CREATE TABLE c2(x BLOB, y BLOB);
+ INSERT INTO c2 VALUES(1, 1);
+}
+do_execsql_test 3.2 {
+ SELECT * FROM c1 WHERE (a, b) IN (SELECT x, y FROM c2)
+} {}
+do_execsql_test 3.3 {
+ CREATE UNIQUE INDEX c1ab ON c1(a, b);
+ SELECT * FROM c1 WHERE (a, b) IN (SELECT x, y FROM c2)
+} {}
+do_execsql_test 3.4 {
+ SELECT * FROM c1 WHERE (a, +b) IN (SELECT x, y FROM c2)
+} {}
+
+do_execsql_test 3.5 {
+ SELECT c1.rowid FROM c1 WHERE b = (SELECT y FROM c2);
+} {}
+do_execsql_test 3.6 {
+ SELECT c1.rowid FROM c1 WHERE (a, b) = (SELECT x, y FROM c2);
+} {}
+
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 4.0 {
+ CREATE TABLE d1(a TEXT, b INTEGER, c NUMERIC);
+ CREATE TABLE d2(x BLOB, y BLOB);
+
+ INSERT INTO d1 VALUES(1, 1, 1);
+ INSERT INTO d1 VALUES(2, 2, 2);
+ INSERT INTO d1 VALUES(3, 3, 3);
+ INSERT INTO d1 VALUES(4, 4, 4);
+
+ INSERT INTO d2 VALUES (1, 1);
+ INSERT INTO d2 VALUES (2, '2');
+ INSERT INTO d2 VALUES ('3', 3);
+ INSERT INTO d2 VALUES ('4', '4');
+}
+
+foreach {tn idx} {
+ 1 {}
+ 2 { CREATE INDEX idx ON d1(a) }
+ 3 { CREATE INDEX idx ON d1(a, c) }
+ 4 { CREATE INDEX idx ON d1(c) }
+ 5 { CREATE INDEX idx ON d1(c, a) }
+
+ 6 {
+ CREATE INDEX idx ON d1(c, a) ;
+ CREATE INDEX idx1 ON d2(x, y);
+ }
+
+ 7 {
+ CREATE INDEX idx ON d1(c, a) ;
+ CREATE UNIQUE INDEX idx2 ON d2(x, y) ;
+ }
+
+ 8 {
+ CREATE INDEX idx ON d1(c) ;
+ CREATE UNIQUE INDEX idx2 ON d2(x);
+ }
+
+} {
+ execsql { DROP INDEX IF EXISTS idx }
+ execsql { DROP INDEX IF EXISTS idx2 }
+ execsql { DROP INDEX IF EXISTS idx3 }
+ execsql $idx
+
+ do_execsql_test 4.$tn.1 {
+ SELECT rowid FROM d1 WHERE (a, c) IN (SELECT x, y FROM d2);
+ } {3 4}
+
+ do_execsql_test 4.$tn.2 {
+ SELECT rowid FROM d1 WHERE (c, a) IN (SELECT x, y FROM d2);
+ } {2 4}
+
+ do_execsql_test 4.$tn.3 {
+ SELECT rowid FROM d1 WHERE (+c, a) IN (SELECT x, y FROM d2);
+ } {2}
+
+ do_execsql_test 4.$tn.4 {
+ SELECT rowid FROM d1 WHERE (c, a) = (
+ SELECT x, y FROM d2 WHERE d2.rowid=d1.rowid
+ );
+ } {2 4}
+
+ do_execsql_test 4.$tn.5 {
+ SELECT d1.rowid FROM d1, d2 WHERE a = y;
+ } {2 4}
+
+ do_execsql_test 4.$tn.6 {
+ SELECT d1.rowid FROM d1 WHERE a = (
+ SELECT y FROM d2 where d2.rowid=d1.rowid
+ );
+ } {2 4}
+}
+
+do_execsql_test 5.0 {
+ CREATE TABLE e1(a TEXT, c NUMERIC);
+ CREATE TABLE e2(x BLOB, y BLOB);
+
+ INSERT INTO e1 VALUES(2, 2);
+
+ INSERT INTO e2 VALUES ('2', 2);
+ INSERT INTO e2 VALUES ('2', '2');
+ INSERT INTO e2 VALUES ('2', '2.0');
+
+ CREATE INDEX e1c ON e1(c);
+}
+
+do_execsql_test 5.1 {
+ SELECT rowid FROM e1 WHERE (a, c) IN (SELECT x, y FROM e2);
+} {1}
+do_execsql_test 5.2 {
+ SELECT rowid FROM e2 WHERE rowid IN (SELECT +c FROM e1);
+} {2}
+do_execsql_test 5.3 {
+ SELECT rowid FROM e2 WHERE rowid IN (SELECT 0+c FROM e1);
+} {2}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 6.0 {
+ CREATE TABLE f1(a, b);
+ CREATE TABLE f2(c, d);
+ CREATE TABLE f3(e, f);
+}
+
+do_execsql_test 6.1 {
+ SELECT * FROM f3 WHERE (e, f) IN (
+ SELECT a, b FROM f1 UNION ALL SELECT c, d FROM f2
+ );
+}
+do_execsql_test 6.2 {
+ CREATE INDEX f3e ON f3(e);
+ SELECT * FROM f3 WHERE (e, f) IN (
+ SELECT a, b FROM f1 UNION ALL SELECT c, d FROM f2
+ );
+}
+
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 7.0 {
+ CREATE TABLE g1(a, b);
+ INSERT INTO g1 VALUES
+ (1, 1), (1, 2), (1, 3), (1, 'i'), (1, 'j'),
+ (1, 6), (1, 7), (1, 8), (1, 9), (1, 10),
+ (1, 4), (1, 5);
+
+ CREATE TABLE g2(x, y);
+ CREATE INDEX g2x ON g2(x);
+
+ INSERT INTO g2 VALUES(1, 4);
+ INSERT INTO g2 VALUES(1, 5);
+}
+
+do_execsql_test 7.1 {
+ SELECT * FROM g2 WHERE (x, y) IN (
+ SELECT a, b FROM g1 ORDER BY +a, +b LIMIT 10
+ );
+} { 1 4 1 5 }
+
+do_execsql_test 7.2 {
+ SELECT * FROM g2 WHERE (x, y) IN (
+ SELECT a, b FROM g1 ORDER BY a, b LIMIT 10
+ );
+} { 1 4 1 5 }
+
+do_execsql_test 7.3 {
+ SELECT * FROM g2 WHERE (x, y) IN (
+ SELECT a, b FROM g1 ORDER BY 1, 2 LIMIT 10
+ );
+} { 1 4 1 5 }
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 8.1 {
+ CREATE TABLE t1(a ,b FLOAT);
+ CREATE INDEX t1x1 ON t1(a,b,a,a,a,a,a,a,a,a,a,b);
+}
+
+do_catchsql_test 8.2 {
+ SELECT a FROM t1 NATURAL JOIN t1 WHERE (a,b)> (SELECT 2 IN (SELECT 2,2), 2);
+} {1 {sub-select returns 2 columns - expected 1}}
+
+
+finish_test
+
+
diff --git a/test/rowvalueA.test b/test/rowvalueA.test
new file mode 100644
index 0000000..dc5a7a0
--- /dev/null
+++ b/test/rowvalueA.test
@@ -0,0 +1,77 @@
+# 2021 July 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix rowvalueA
+
+do_execsql_test 1.0 {
+ SELECT (1, 2) IN ( (3, 4), (5, 6), (1, 3) );
+} {0}
+
+do_execsql_test 1.1 {
+ SELECT (1, 2) IN ( (3, 4), (5, 6), (1, 2) );
+} {1}
+
+do_execsql_test 1.2 {
+ SELECT (1, 2) IN ( (3, 2) );
+} {0}
+
+do_execsql_test 1.3 {
+ SELECT (1, 2) IN ( (1, 2) );
+} {1}
+
+do_execsql_test 1.4 {
+ SELECT (1, 2) IN ( );
+} {0}
+
+do_execsql_test 1.5 {
+ SELECT (1, 2) NOT IN ( );
+} {1}
+
+for {set ii 0} {$ii < 2000} {incr ii} {
+ lappend L "($ii, $ii)"
+}
+
+do_execsql_test 1.6.1 "
+ SELECT (400,400) IN ( [join $L ,] )
+" 1
+
+do_execsql_test 1.6.2 "
+ SELECT (1500,1500) IN ( [join $L ,] )
+" 1
+
+do_execsql_test 1.6.2 "
+ SELECT (1500,1499) IN ( [join $L ,] )
+" 0
+
+#-------------------------------------------------------------------------
+
+do_catchsql_test 2.0 {
+ SELECT (1, 2) IN ( (1, 2), (3, 4, 5), (5, 6) )
+} {1 {IN(...) element has 3 terms - expected 2}}
+
+do_catchsql_test 2.1 {
+ SELECT (1, 2) IN ( (1, 2), 4, (5, 6) )
+} {1 {IN(...) element has 1 term - expected 2}}
+
+do_catchsql_test 2.2 {
+ SELECT (1, 2, 3) IN ( (1, 2), (3, 4), (5, 6) )
+} {1 {IN(...) element has 2 terms - expected 3}}
+
+do_catchsql_test 2.3 {
+ SELECT 2 IN ( (1, 2), (3, 4), (5, 6) )
+} {1 {row value misused}}
+
+finish_test
+
diff --git a/test/rowvaluefault.test b/test/rowvaluefault.test
new file mode 100644
index 0000000..a06ef88
--- /dev/null
+++ b/test/rowvaluefault.test
@@ -0,0 +1,89 @@
+# 2016 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set ::testprefix rowvaluefault
+
+do_execsql_test 1.0 {
+ CREATE TABLE xyz(one, two, thr, fou);
+ INSERT INTO xyz VALUES('A', 'A', 'A', 1);
+ INSERT INTO xyz VALUES('B', 'B', 'B', 2);
+ INSERT INTO xyz VALUES('C', 'C', 'C', 3);
+ INSERT INTO xyz VALUES('D', 'D', 'D', 4);
+
+ CREATE UNIQUE INDEX xyz_one_two ON xyz(one, two);
+}
+
+do_faultsim_test 1 -faults oom* -body {
+ execsql { SELECT fou FROM xyz WHERE (one, two, thr) = ('B', 'B', 'B') }
+} -test {
+ faultsim_test_result {0 2}
+}
+
+do_faultsim_test 2 -faults oom* -body {
+ execsql { SELECT fou FROM xyz WHERE (two, thr) IS ('C', 'C') }
+} -test {
+ faultsim_test_result {0 3}
+}
+
+do_faultsim_test 3 -faults oom* -body {
+ execsql { SELECT fou FROM xyz WHERE (one, two, thr) > ('B', 'B', 'B') }
+} -test {
+ faultsim_test_result {0 {3 4}}
+}
+
+do_faultsim_test 4 -faults oom* -body {
+ execsql { SELECT fou FROM xyz WHERE (one, two) IN (SELECT one, two FROM xyz) }
+} -test {
+ faultsim_test_result {0 {1 2 3 4}}
+}
+
+do_faultsim_test 5 -faults oom* -body {
+ execsql {
+ SELECT fou FROM xyz
+ WHERE (one, two, thr) IN (SELECT one, two, thr FROM xyz)
+ }
+} -test {
+ faultsim_test_result {0 {1 2 3 4}}
+}
+
+do_faultsim_test 6 -faults oom* -body {
+ execsql {
+ SELECT fou FROM xyz
+ WHERE (one, two, thr) BETWEEN ('B', 'B', 'B') AND ('C', 'C', 'C') }
+} -test {
+ faultsim_test_result {0 {2 3}}
+}
+
+do_faultsim_test 7 -faults oom* -body {
+ execsql {
+ SELECT fou FROM xyz
+ WHERE (one, two, thr) IN ( ('a','b','c'), ('A','A','A'), (1,2,3) );
+ }
+} -test {
+ faultsim_test_result {0 1}
+}
+
+do_faultsim_test 8 -faults oom* -body {
+ execsql {
+ SELECT fou FROM xyz
+ WHERE (two, one) IN ( ('a','b','c'), ('A','A','A'), (1,2,3) );
+ }
+} -test {
+ faultsim_test_result {1 {IN(...) element has 3 terms - expected 2}}
+}
+
+finish_test
diff --git a/test/rowvaluevtab.test b/test/rowvaluevtab.test
new file mode 100644
index 0000000..d3e0ac7
--- /dev/null
+++ b/test/rowvaluevtab.test
@@ -0,0 +1,95 @@
+# 2018 October 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.
+#
+#***********************************************************************
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix rowvaluevtab
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_echo_module db
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX t1b ON t1(b);
+ INSERT INTO t1 VALUES('one', 1, 1);
+ INSERT INTO t1 VALUES('two', 1, 2);
+ INSERT INTO t1 VALUES('three', 1, 3);
+ INSERT INTO t1 VALUES('four', 2, 1);
+ INSERT INTO t1 VALUES('five', 2, 2);
+ INSERT INTO t1 VALUES('six', 2, 3);
+ INSERT INTO t1 VALUES('seven', 3, 1);
+ INSERT INTO t1 VALUES('eight', 3, 2);
+ INSERT INTO t1 VALUES('nine', 3, 3);
+
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000
+ ) INSERT INTO t1 SELECT NULL, NULL, NULL FROM s;
+ CREATE VIRTUAL TABLE e1 USING echo(t1);
+}
+
+proc do_vfilter4_test {tn sql expected} {
+ set res [list]
+ db eval "explain $sql" {
+ if {$opcode=="VFilter"} {
+ lappend res $p4
+ }
+ }
+ uplevel [list do_test $tn [list set {} $res] [list {*}$expected]]
+}
+
+do_execsql_test 1.1 {
+ SELECT a FROM e1 WHERE (b, c) = (2, 2)
+} {five}
+do_vfilter4_test 1.1f {
+ SELECT a FROM e1 WHERE (b, c) = (?, ?)
+} {{SELECT rowid, a, b, c FROM 't1' WHERE b = ?}}
+
+do_execsql_test 1.2 {
+ SELECT a FROM e1 WHERE (b, c) > (2, 2)
+} {six seven eight nine}
+do_vfilter4_test 1.2f {
+ SELECT a FROM e1 WHERE (b, c) > (2, 2)
+} {
+ {SELECT rowid, a, b, c FROM 't1' WHERE b >= ?}
+}
+
+do_execsql_test 1.3 {
+ SELECT a FROM e1 WHERE (b, c) >= (2, 2)
+} {five six seven eight nine}
+do_vfilter4_test 1.3f {
+ SELECT a FROM e1 WHERE (b, c) >= (2, 2)
+} {
+ {SELECT rowid, a, b, c FROM 't1' WHERE b >= ?}
+}
+
+do_execsql_test 1.3 {
+ SELECT a FROM e1 WHERE (b, c) BETWEEN (1, 2) AND (2, 3)
+} {two three four five six}
+do_vfilter4_test 1.3f {
+ SELECT a FROM e1 WHERE (b, c) BETWEEN (1, 2) AND (2, 3)
+} {
+ {SELECT rowid, a, b, c FROM 't1' WHERE b >= ? AND b <= ?}
+}
+
+do_execsql_test 1.4 {
+ SELECT a FROM e1 WHERE (b, c) IN ( VALUES(2, 2) )
+} {five}
+do_vfilter4_test 1.4f {
+ SELECT a FROM e1 WHERE (b, c) IN ( VALUES(2, 2) )
+} {{SELECT rowid, a, b, c FROM 't1' WHERE b = ?}}
+
+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/run-wordcount.sh b/test/run-wordcount.sh
new file mode 100644
index 0000000..1755d58
--- /dev/null
+++ b/test/run-wordcount.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# This script runs the wordcount program in different ways, comparing
+# the output from each.
+#
+
+# Select the source text to be analyzed.
+#
+if test "x$1" = "x";
+then echo "Usage: $0 FILENAME [ARGS...]"; exit 1;
+fi
+
+# Do test runs
+#
+rm -f wcdb1.db
+./wordcount --timer --summary wcdb1.db $* --insert >wc-out.txt
+mv wc-out.txt wc-baseline.txt
+rm -f wcdb2.db
+./wordcount --timer --summary wcdb2.db $* --insert --without-rowid >wc-out.txt
+ if cmp -s wc-out.txt wc-baseline.txt;
+ then echo hi >/dev/null;
+ else echo ERROR:;
+ diff -u wc-baseline.txt wc-out.txt;
+ fi
+
+rm -f wcdb1.db
+./wordcount --timer --summary wcdb1.db $* --replace >wc-out.txt
+ if cmp -s wc-out.txt wc-baseline.txt;
+ then echo hi >/dev/null;
+ else echo ERROR:;
+ diff -u wc-baseline.txt wc-out.txt;
+ fi
+rm -f wcdb2.db
+./wordcount --timer --summary wcdb2.db $* --replace --without-rowid >wc-out.txt
+ if cmp -s wc-out.txt wc-baseline.txt;
+ then echo hi >/dev/null;
+ else echo ERROR:;
+ diff -u wc-baseline.txt wc-out.txt;
+ fi
+
+rm -f wcdb1.db
+./wordcount --timer --summary wcdb1.db $* --select >wc-out.txt
+ if cmp -s wc-out.txt wc-baseline.txt;
+ then echo hi >/dev/null;
+ else echo ERROR:;
+ diff -u wc-baseline.txt wc-out.txt;
+ fi
+
+rm -f wcdb2.db
+./wordcount --timer --summary wcdb2.db $* --select --without-rowid >wc-out.txt
+ if cmp -s wc-out.txt wc-baseline.txt;
+ then echo hi >/dev/null;
+ else echo ERROR:;
+ diff -u wc-baseline.txt wc-out.txt;
+ fi
+
+./wordcount --timer --summary wcdb1.db $* --query >wc-out.txt
+mv wc-out.txt wc-baseline.txt
+./wordcount --timer --summary wcdb2.db $* --query --without-rowid >wc-out.txt
+ if cmp -s wc-out.txt wc-baseline.txt;
+ then echo hi >/dev/null;
+ else echo ERROR:;
+ diff -u wc-baseline.txt wc-out.txt;
+ fi
+
+./wordcount --timer --summary wcdb1.db $* --delete >wc-out.txt
+mv wc-out.txt wc-baseline.txt
+./wordcount --timer --summary wcdb2.db $* --delete --without-rowid >wc-out.txt
+ if cmp -s wc-out.txt wc-baseline.txt;
+ then echo hi >/dev/null;
+ else echo ERROR:;
+ diff -u wc-baseline.txt wc-out.txt;
+ fi
+
+
+# Clean up temporary files created.
+#
+rm -rf wcdb1.db wcdb2.db wc-out.txt wc-baseline.txt
diff --git a/test/savepoint.test b/test/savepoint.test
new file mode 100644
index 0000000..3952981
--- /dev/null
+++ b/test/savepoint.test
@@ -0,0 +1,1058 @@
+# 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
+
+forcedelete test2.db
+
+#----------------------------------------------------------------------
+# 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.1 {
+ execsql {SAVEPOINT def}
+ set fd [db incrblob -readonly blobs x 1]
+ set rc [catch {seek $fd 0;read $fd} res]
+ lappend rc $res
+ } {0 {hellontyeight character blob}}
+ do_test savepoint-5.3.2.2 {
+ catchsql {ROLLBACK TO def}
+ } {0 {}}
+ do_test savepoint-5.3.2.3 {
+ set rc [catch {seek $fd 0; read $fd} res]
+ set rc
+ } {0}
+ 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 [lrange $args 0 4]
+ 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 [lrange $args 0 4]
+ 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).
+#
+# UPDATE 2017-07-26: It is not possible to ATTACH and DETACH within a
+# a transaction.
+#
+do_test savepoint-10.1.1 {
+ catchsql {
+ SAVEPOINT one;
+ ATTACH 'test2.db' AS aux;
+ DETACH aux;
+ }
+} {0 {}}
+do_test savepoint-10.1.2 {
+ execsql {
+ RELEASE one;
+ ATTACH 'test2.db' AS aux;
+ }
+ catchsql {
+ SAVEPOINT one;
+ DETACH aux;
+ ATTACH 'test2.db' AS aux;
+ }
+} {0 {}}
+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;
+ SELECT name FROM aux1.sqlite_master;
+ 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 ; 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 {UNIQUE constraint failed: t4.a}}
+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/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/savepoint7.test b/test/savepoint7.test
new file mode 100644
index 0000000..59c3cd6
--- /dev/null
+++ b/test/savepoint7.test
@@ -0,0 +1,132 @@
+# 2012 March 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.
+#
+#***********************************************************************
+#
+# Focus on the interaction between RELEASE and ROLLBACK TO with
+# pending query aborts. See ticket [27ca74af3c083f787a1c44b11fbb7c53bdbbcf1e].
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# The RELEASE of an inner savepoint should not effect pending queries.
+#
+do_test savepoint7-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE t2(x,y,z);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(4,5,6);
+ INSERT INTO t1 VALUES(7,8,9);
+ SAVEPOINT x1;
+ }
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ CREATE TABLE IF NOT EXISTS t3(xyz);
+ INSERT INTO t2 VALUES($a,$b,$c);
+ RELEASE x2;
+ }
+ }
+ db eval {SELECT * FROM t2; RELEASE x1}
+} {1 2 3 4 5 6 7 8 9}
+
+do_test savepoint7-1.2 {
+ db eval {DELETE FROM t2;}
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ INSERT INTO t2 VALUES($a,$b,$c);
+ RELEASE x2;
+ }
+ }
+ db eval {SELECT * FROM t2;}
+} {1 2 3 4 5 6 7 8 9}
+
+do_test savepoint7-1.3 {
+ db eval {DELETE FROM t2; BEGIN;}
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ INSERT INTO t2 VALUES($a,$b,$c);
+ RELEASE x2;
+ }
+ }
+ db eval {SELECT * FROM t2; ROLLBACK;}
+} {1 2 3 4 5 6 7 8 9}
+
+# However, a ROLLBACK of an inner savepoint will abort all queries, including
+# queries in outer contexts.
+#
+do_test savepoint7-2.1 {
+ db eval {DELETE FROM t2; SAVEPOINT x1; CREATE TABLE t4(abc);}
+ set rc [catch {
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ INSERT INTO t2 VALUES($a,$b,$c);
+ ROLLBACK TO x2;
+ }
+ }
+ } msg]
+ db eval {RELEASE x1}
+ list $rc $msg [db eval {SELECT * FROM t2}]
+} {1 {abort due to ROLLBACK} {}}
+
+do_test savepoint7-2.2 {
+ db eval {DELETE FROM t2;}
+ set rc [catch {
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ CREATE TABLE t5(pqr);
+ INSERT INTO t2 VALUES($a,$b,$c);
+ ROLLBACK TO x2;
+ }
+ }
+ } msg]
+ list $rc $msg [db eval {SELECT * FROM t2}]
+} {1 {abort due to ROLLBACK} {}}
+
+# Ticket: https://www.sqlite.org/src/tktview/7f7f8026eda387d544b
+# Segfault in the in-memory journal logic triggered by a tricky
+# combination of SAVEPOINT operations.
+#
+unset -nocomplain i
+for {set i 248} {$i<=253} {incr i} {
+ do_test savepoint7-3.$i {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA page_size=1024;
+ PRAGMA temp_store=MEMORY;
+ BEGIN;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<$::i)
+ INSERT INTO t1(x,y) SELECT x*10, printf('%04d%.800c',x,'*') FROM c;
+ SAVEPOINT one;
+ SELECT count(*) FROM t1;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<$::i)
+ INSERT INTO t1(x,y) SELECT x*10+1, printf('%04d%.800c',x,'*') FROM c;
+ ROLLBACK TO one;
+ SELECT count(*) FROM t1;
+ SAVEPOINT twoB;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<10)
+ INSERT INTO t1(x,y) SELECT x*10+2, printf('%04d%.800c',x,'*') FROM c;
+ ROLLBACK TO twoB;
+ RELEASE one;
+ COMMIT;
+ }
+ } [list $i $i]
+}
+
+
+finish_test
diff --git a/test/savepointfault.test b/test/savepointfault.test
new file mode 100644
index 0000000..0329f8c
--- /dev/null
+++ b/test/savepointfault.test
@@ -0,0 +1,137 @@
+# 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+source $testdir/malloc_common.tcl
+
+set testprefix savepointfault
+
+do_malloc_test 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 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 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 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 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/scanstatus.test b/test/scanstatus.test
new file mode 100644
index 0000000..46249f6
--- /dev/null
+++ b/test/scanstatus.test
@@ -0,0 +1,400 @@
+# 2014 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix scanstatus
+
+ifcapable !scanstatus {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t2 VALUES('a', 'b');
+ INSERT INTO t2 VALUES('c', 'd');
+ INSERT INTO t2 VALUES('e', 'f');
+}
+
+proc do_scanstatus_test {tn res} {
+ set stmt [db version -last-stmt-ptr]
+ set idx 0
+ set ret [list]
+ while {1} {
+ set r [sqlite3_stmt_scanstatus $stmt $idx]
+ if {[llength $r]==0} break
+ lappend ret {*}$r
+ incr idx
+ }
+
+ uplevel [list do_test $tn [list set {} $ret] [list {*}$res]]
+}
+
+do_execsql_test 1.1 { SELECT count(*) FROM t1, t2; } 6
+do_scanstatus_test 1.2 {
+ nLoop 1 nVisit 2 nEst 1048576.0 zName t1 zExplain {SCAN t1}
+ nLoop 2 nVisit 6 nEst 1048576.0 zName t2 zExplain {SCAN t2}
+}
+
+do_execsql_test 1.3 {
+ ANALYZE;
+ SELECT count(*) FROM t1, t2;
+} 6
+do_scanstatus_test 1.4 {
+ nLoop 1 nVisit 2 nEst 2.0 zName t1 zExplain {SCAN t1}
+ nLoop 2 nVisit 6 nEst 3.0 zName t2 zExplain {SCAN t2}
+}
+
+do_execsql_test 1.5 { ANALYZE }
+do_execsql_test 1.6 {
+ SELECT count(*) FROM t1, t2 WHERE t2.rowid>1;
+} 4
+do_scanstatus_test 1.7 {
+ nLoop 1 nVisit 2 nEst 2.0 zName t2 zExplain
+ {SEARCH t2 USING INTEGER PRIMARY KEY (rowid>?)}
+ nLoop 2 nVisit 4 nEst 2.0 zName t1 zExplain {SCAN t1}
+}
+
+do_execsql_test 1.8 {
+ SELECT count(*) FROM t1, t2 WHERE t2.rowid>1;
+} 4
+
+do_scanstatus_test 1.9 {
+ nLoop 2 nVisit 4 nEst 2.0 zName t2 zExplain
+ {SEARCH t2 USING INTEGER PRIMARY KEY (rowid>?)}
+ nLoop 4 nVisit 8 nEst 2.0 zName t1 zExplain {SCAN t1}
+}
+
+do_test 1.9 {
+ sqlite3_stmt_scanstatus_reset [db version -last-stmt-ptr]
+} {}
+
+do_scanstatus_test 1.10 {
+ nLoop 0 nVisit 0 nEst 2.0 zName t2 zExplain
+ {SEARCH t2 USING INTEGER PRIMARY KEY (rowid>?)}
+ nLoop 0 nVisit 0 nEst 2.0 zName t1 zExplain {SCAN t1}
+}
+
+#-------------------------------------------------------------------------
+# Try a few different types of scans.
+#
+reset_db
+do_execsql_test 2.1 {
+ CREATE TABLE x1(i INTEGER PRIMARY KEY, j);
+ INSERT INTO x1 VALUES(1, 'one');
+ INSERT INTO x1 VALUES(2, 'two');
+ INSERT INTO x1 VALUES(3, 'three');
+ INSERT INTO x1 VALUES(4, 'four');
+ CREATE INDEX x1j ON x1(j);
+
+ SELECT * FROM x1 WHERE i=2;
+} {2 two}
+
+do_scanstatus_test 2.2 {
+ nLoop 1 nVisit 1 nEst 1.0 zName x1
+ zExplain {SEARCH x1 USING INTEGER PRIMARY KEY (rowid=?)}
+}
+
+do_execsql_test 2.3.1 {
+ SELECT * FROM x1 WHERE j='two'
+} {2 two}
+do_scanstatus_test 2.3.2 {
+ nLoop 1 nVisit 1 nEst 10.0 zName x1j
+ zExplain {SEARCH x1 USING COVERING INDEX x1j (j=?)}
+}
+
+do_execsql_test 2.4.1 {
+ SELECT * FROM x1 WHERE j<'two'
+} {4 four 1 one 3 three}
+do_scanstatus_test 2.4.2 {
+ nLoop 1 nVisit 3 nEst 262144.0 zName x1j
+ zExplain {SEARCH x1 USING COVERING INDEX x1j (j<?)}
+}
+
+do_execsql_test 2.5.1 {
+ SELECT * FROM x1 WHERE j>='two'
+} {2 two}
+do_scanstatus_test 2.5.2 {
+ nLoop 1 nVisit 1 nEst 262144.0 zName x1j
+ zExplain {SEARCH x1 USING COVERING INDEX x1j (j>?)}
+}
+
+do_execsql_test 2.6.1 {
+ SELECT * FROM x1 WHERE j BETWEEN 'three' AND 'two'
+} {3 three 2 two}
+do_scanstatus_test 2.6.2 {
+ nLoop 1 nVisit 2 nEst 16384.0 zName x1j
+ zExplain {SEARCH x1 USING COVERING INDEX x1j (j>? AND j<?)}
+}
+
+do_execsql_test 2.7.1 {
+ CREATE TABLE x2(i INTEGER, j, k);
+ INSERT INTO x2 SELECT i, j, i || ' ' || j FROM x1;
+ CREATE INDEX x2j ON x2(j);
+ CREATE INDEX x2ij ON x2(i, j);
+ SELECT * FROM x2 WHERE j BETWEEN 'three' AND 'two'
+} {3 three {3 three} 2 two {2 two}}
+
+do_scanstatus_test 2.7.2 {
+ nLoop 1 nVisit 2 nEst 16384.0 zName x2j
+ zExplain {SEARCH x2 USING INDEX x2j (j>? AND j<?)}
+}
+
+do_execsql_test 2.8.1 {
+ SELECT * FROM x2 WHERE i=1 AND j='two'
+}
+do_scanstatus_test 2.8.2 {
+ nLoop 1 nVisit 0 nEst 8.0 zName x2ij
+ zExplain {SEARCH x2 USING INDEX x2ij (i=? AND j=?)}
+}
+
+do_execsql_test 2.9.1 {
+ SELECT * FROM x2 WHERE i=5 AND j='two'
+}
+do_scanstatus_test 2.9.2 {
+ nLoop 1 nVisit 0 nEst 8.0 zName x2ij
+ zExplain {SEARCH x2 USING INDEX x2ij (i=? AND j=?)}
+}
+
+do_execsql_test 2.10.1 {
+ SELECT * FROM x2 WHERE i=3 AND j='three'
+} {3 three {3 three}}
+do_scanstatus_test 2.10.2 {
+ nLoop 1 nVisit 1 nEst 8.0 zName x2ij
+ zExplain {SEARCH x2 USING INDEX x2ij (i=? AND j=?)}
+}
+
+#-------------------------------------------------------------------------
+# Try with queries that use the OR optimization.
+#
+do_execsql_test 3.1 {
+ CREATE TABLE a1(a, b, c, d);
+ CREATE INDEX a1a ON a1(a);
+ CREATE INDEX a1bc ON a1(b, c);
+
+ WITH d(x) AS (SELECT 1 UNION ALL SELECT x+1 AS n FROM d WHERE n<=100)
+ INSERT INTO a1 SELECT x, x, x, x FROM d;
+}
+
+do_execsql_test 3.2.1 {
+ SELECT d FROM a1 WHERE (a=4 OR b=13)
+} {4 13}
+do_scanstatus_test 3.2.2 {
+ nLoop 1 nVisit 1 nEst 10.0 zName a1a
+ zExplain {SEARCH a1 USING INDEX a1a (a=?)}
+ nLoop 1 nVisit 1 nEst 10.0 zName a1bc
+ zExplain {SEARCH a1 USING INDEX a1bc (b=?)}
+}
+
+do_execsql_test 3.2.1 {
+ SELECT count(*) FROM a1 WHERE (a BETWEEN 4 AND 12) OR (b BETWEEN 40 AND 60)
+} {30}
+do_scanstatus_test 3.2.2 {
+ nLoop 1 nVisit 9 nEst 16384.0 zName a1a
+ zExplain {SEARCH a1 USING INDEX a1a (a>? AND a<?)}
+ nLoop 1 nVisit 21 nEst 16384.0 zName a1bc
+ zExplain {SEARCH a1 USING INDEX a1bc (b>? AND b<?)}
+}
+
+do_execsql_test 3.3.1 {
+ SELECT count(*) FROM a1 AS x, a1 AS y
+ WHERE (x.a BETWEEN 4 AND 12) AND (y.b BETWEEN 1 AND 10)
+} {90}
+do_scanstatus_test 3.2.2 {
+ nLoop 1 nVisit 10 nEst 16384.0 zName a1bc
+ zExplain {SEARCH y USING COVERING INDEX a1bc (b>? AND b<?)}
+ nLoop 10 nVisit 90 nEst 16384.0 zName a1a
+ zExplain {SEARCH x USING COVERING INDEX a1a (a>? AND a<?)}
+}
+
+do_execsql_test 3.4.1 {
+ SELECT count(*) FROM a1 WHERE a IN (1, 5, 10, 15);
+} {4}
+do_scanstatus_test 3.4.2 {
+ nLoop 1 nVisit 4 nEst 40.0 zName a1a
+ zExplain {SEARCH a1 USING COVERING INDEX a1a (a=?)}
+}
+
+do_execsql_test 3.4.1 {
+ SELECT count(*) FROM a1 WHERE rowid IN (1, 5, 10, 15);
+} {4}
+do_scanstatus_test 3.4.2 {
+ nLoop 1 nVisit 4 nEst 4.0 zName a1
+ zExplain {SEARCH a1 USING INTEGER PRIMARY KEY (rowid=?)}
+}
+
+#-------------------------------------------------------------------------
+# Test that scanstatus() data is not available for searches performed
+# by triggers.
+#
+# It is available for searches performed as part of FK processing, but
+# not FK action processing.
+#
+do_execsql_test 4.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(x PRIMARY KEY, y, z);
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ SELECT * FROM t2 WHERE x BETWEEN 20 AND 40;
+ END;
+ WITH d(x) AS (SELECT 1 UNION ALL SELECT x+1 AS n FROM d WHERE n<=100)
+ INSERT INTO t2 SELECT x, x*2, x*3 FROM d;
+}
+
+do_execsql_test 4.1.1 { INSERT INTO t1 VALUES(1, 2, 3); }
+do_scanstatus_test 4.1.2 {}
+
+do_execsql_test 4.2 {
+ CREATE TABLE p1(x PRIMARY KEY);
+ INSERT INTO p1 VALUES(1), (2), (3), (4);
+ CREATE TABLE c1(y REFERENCES p1);
+ INSERT INTO c1 VALUES(1), (2), (3);
+ PRAGMA foreign_keys=on;
+}
+do_execsql_test 4.2.1 { DELETE FROM p1 WHERE x=4 }
+do_scanstatus_test 4.2.2 {
+ nLoop 1 nVisit 1 nEst 1.0 zName sqlite_autoindex_p1_1
+ zExplain {SEARCH p1 USING INDEX sqlite_autoindex_p1_1 (x=?)}
+
+ nLoop 1 nVisit 3 nEst 262144.0 zName c1 zExplain {SCAN c1}
+}
+
+#-------------------------------------------------------------------------
+# Further tests of different scan types.
+#
+reset_db
+proc tochar {i} {
+ 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}
+ return [lindex $alphabet [expr $i % [llength $alphabet]]]
+}
+db func tochar tochar
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a PRIMARY KEY, b, c);
+ INSERT INTO t1 VALUES(0, 1, 'a');
+ INSERT INTO t1 VALUES(1, 0, 'b');
+ INSERT INTO t1 VALUES(2, 1, 'c');
+ INSERT INTO t1 VALUES(3, 0, 'd');
+ INSERT INTO t1 VALUES(4, 1, 'e');
+ INSERT INTO t1 VALUES(5, 0, 'a');
+ INSERT INTO t1 VALUES(6, 1, 'b');
+ INSERT INTO t1 VALUES(7, 0, 'c');
+ INSERT INTO t1 VALUES(8, 1, 'd');
+ INSERT INTO t1 VALUES(9, 0, 'e');
+ CREATE INDEX t1bc ON t1(b, c);
+
+ CREATE TABLE t2(x, y);
+ CREATE INDEX t2xy ON t2(x, y);
+ WITH data(i, x, y) AS (
+ SELECT 0, 0, tochar(0)
+ UNION ALL
+ SELECT i+1, (i+1)%2, tochar(i+1) FROM data WHERE i<500
+ ) INSERT INTO t2 SELECT x, y FROM data;
+
+ CREATE TABLE t3(x, y);
+ INSERT INTO t3 SELECT * FROM t2;
+
+ ANALYZE;
+}
+
+do_execsql_test 5.1.1 {
+ SELECT count(*) FROM t1 WHERE a IN (SELECT b FROM t1 AS ii)
+} {2}
+do_scanstatus_test 5.1.2 {
+ nLoop 1 nVisit 10 nEst 10.0 zName t1bc
+ zExplain {SCAN ii USING COVERING INDEX t1bc}
+ nLoop 1 nVisit 2 nEst 8.0 zName sqlite_autoindex_t1_1
+ zExplain {SEARCH t1 USING COVERING INDEX sqlite_autoindex_t1_1 (a=?)}
+}
+
+do_execsql_test 5.2.1 {
+ SELECT count(*) FROM t1 WHERE a IN (0, 1)
+} {2}
+do_scanstatus_test 5.2.2 {
+ nLoop 1 nVisit 2 nEst 2.0 zName sqlite_autoindex_t1_1
+ zExplain {SEARCH t1 USING COVERING INDEX sqlite_autoindex_t1_1 (a=?)}
+}
+
+do_eqp_test 5.3.1 {
+ SELECT count(*) FROM t2 WHERE y = 'j';
+} {SEARCH t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)}
+do_execsql_test 5.3.2 {
+ SELECT count(*) FROM t2 WHERE y = 'j';
+} {19}
+do_scanstatus_test 5.3.3 {
+ nLoop 1 nVisit 19 nEst 56.0 zName t2xy zExplain
+ {SEARCH t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)}
+}
+
+do_eqp_test 5.4.1 {
+ SELECT count(*) FROM t1, t2 WHERE y = c;
+} {
+ QUERY PLAN
+ |--SCAN t1 USING COVERING INDEX t1bc
+ `--SEARCH t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)
+}
+do_execsql_test 5.4.2 {
+ SELECT count(*) FROM t1, t2 WHERE y = c;
+} {200}
+do_scanstatus_test 5.4.3 {
+ nLoop 1 nVisit 10 nEst 10.0 zName t1bc
+ zExplain {SCAN t1 USING COVERING INDEX t1bc}
+ nLoop 10 nVisit 200 nEst 56.0 zName t2xy
+ zExplain {SEARCH t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)}
+}
+
+do_eqp_test 5.5.1 {
+ SELECT count(*) FROM t1, t3 WHERE y = c;
+} {
+ QUERY PLAN
+ |--SCAN t3
+ `--SEARCH t1 USING AUTOMATIC COVERING INDEX (c=?)
+}
+do_execsql_test 5.5.2 {
+ SELECT count(*) FROM t1, t3 WHERE y = c;
+} {200}
+do_scanstatus_test 5.5.3 {
+ nLoop 1 nVisit 501 nEst 480.0 zName t3 zExplain {SCAN t3}
+ nLoop 501 nVisit 200 nEst 20.0 zName auto-index zExplain
+ {SEARCH t1 USING AUTOMATIC COVERING INDEX (c=?)}
+}
+
+#-------------------------------------------------------------------------
+# Virtual table scans
+#
+ifcapable fts3 {
+ do_execsql_test 6.0 {
+ CREATE VIRTUAL TABLE ft1 USING fts4;
+ INSERT INTO ft1 VALUES('a d c f g h e i f c');
+ INSERT INTO ft1 VALUES('g c h b g b f f f g');
+ INSERT INTO ft1 VALUES('h h c c h f a e d d');
+ INSERT INTO ft1 VALUES('e j i j i e b c f g');
+ INSERT INTO ft1 VALUES('g f b g j c h a d f');
+ INSERT INTO ft1 VALUES('j i a e g f a i a c');
+ INSERT INTO ft1 VALUES('f d g g j j c a h g');
+ INSERT INTO ft1 VALUES('b d h a d j j j b i');
+ INSERT INTO ft1 VALUES('j e a b j e c b c i');
+ INSERT INTO ft1 VALUES('a d e f b j j c g d');
+ }
+ do_execsql_test 6.1.1 {
+ SELECT count(*) FROM ft1 WHERE ft1 MATCH 'd'
+ } {6}
+ do_scanstatus_test 6.1.2 {
+ nLoop 1 nVisit 6 nEst 24.0 zName ft1 zExplain
+ {SCAN ft1 VIRTUAL TABLE INDEX 3:}
+ }
+}
+
+
+finish_test
diff --git a/test/schema.test b/test/schema.test
new file mode 100644
index 0000000..c7daef2
--- /dev/null
+++ b/test/schema.test
@@ -0,0 +1,403 @@
+# 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 to a non-null function. Tests 8.11
+# and 8.12 verify that no invalidations occur when the authorizer is
+# cleared.
+#
+ifcapable auth {
+ proc noop_auth {args} {return SQLITE_OK}
+ do_test schema-8.1 {
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ db auth noop_auth
+ sqlite3_step $::STMT
+ } {SQLITE_ERROR}
+ do_test schema-8.2 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_SCHEMA}
+ do_test schema-8.11 {
+ set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]
+ db auth {}
+ sqlite3_step $::STMT
+ } {SQLITE_ROW}
+ do_test schema-8.12 {
+ sqlite3_finalize $::STMT
+ } {SQLITE_OK}
+
+}
+
+#---------------------------------------------------------------------
+# 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..39d4632
--- /dev/null
+++ b/test/schema3.test
@@ -0,0 +1,103 @@
+# 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
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+# 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..9b794ee
--- /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 temp.sqlite_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/schema5.test b/test/schema5.test
new file mode 100644
index 0000000..29df3f1
--- /dev/null
+++ b/test/schema5.test
@@ -0,0 +1,69 @@
+# 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 checks corner cases in the CREATE TABLE syntax to make
+# sure that legacy syntax (syntax that is disallowed according to the
+# syntax diagrams) is still accepted, so that older databases that use
+# that syntax can still be read.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Table constraints should be separated by commas, but they do not have
+# to be.
+#
+do_test schema5-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b,c, PRIMARY KEY(a) UNIQUE (a) CONSTRAINT one);
+ INSERT INTO t1 VALUES(1,2,3);
+ SELECT * FROM t1;
+ }
+} {1 2 3}
+do_test schema5-1.2 {
+ catchsql {INSERT INTO t1 VALUES(1,3,4);}
+} {1 {UNIQUE constraint failed: t1.a}}
+do_test schema5-1.3 {
+ db eval {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,
+ CONSTRAINT one PRIMARY KEY(a) CONSTRAINT two CHECK(b<10) UNIQUE(b)
+ CONSTRAINT three
+ );
+ INSERT INTO t1 VALUES(1,2,3);
+ SELECT * FROM t1;
+ }
+} {1 2 3}
+do_test schema5-1.4 {
+ catchsql {INSERT INTO t1 VALUES(10,11,12);}
+} {1 {CHECK constraint failed: two}}
+do_test schema5-1.5 {
+ db eval {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,
+ UNIQUE(a) CONSTRAINT one,
+ PRIMARY KEY(b,c) CONSTRAINT two
+ );
+ INSERT INTO t1 VALUES(1,2,3);
+ }
+} {}
+do_test schema5-1.6 {
+ catchsql {INSERT INTO t1 VALUES(1,3,4)}
+} {1 {UNIQUE constraint failed: t1.a}}
+do_test schema5-1.7 {
+ catchsql {INSERT INTO t1 VALUES(10,2,3)}
+} {1 {UNIQUE constraint failed: t1.b, t1.c}}
+
+
+
+
+
+finish_test
diff --git a/test/schema6.test b/test/schema6.test
new file mode 100644
index 0000000..0eb8a1c
--- /dev/null
+++ b/test/schema6.test
@@ -0,0 +1,164 @@
+# 2017-07-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 show that certain CREATE TABLE statements
+# generate identical database files. For example, changes in identifier
+# names, white-space, and formatting of the CREATE TABLE statement should
+# produce identical table content.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix schema6
+do_not_use_codec
+
+# Command: check_same_database_content TESTNAME SQL1 SQL2 SQL3 ...
+#
+# This command creates fresh databases using SQL1 and subsequent arguments
+# and checks to make sure the content of all database files is byte-for-byte
+# identical. Page 1 of the database files is allowed to be different, since
+# page 1 contains the sqlite_master table which is expected to vary.
+#
+proc check_same_database_content {basename args} {
+ set i 0
+ set hash {}
+ foreach sql $args {
+ catch {db close}
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval $sql
+ set pgsz [db one {PRAGMA page_size}]
+ db close
+ set sz [file size test.db]
+ set thishash [md5file test.db $pgsz [expr {$sz-$pgsz}]]
+ if {$i==0} {
+ set hash $thishash
+ } else {
+ do_test $basename-$i "set x $thishash" $hash
+ }
+ incr i
+ }
+}
+
+# Command: check_different_database_content TESTNAME SQL1 SQL2 SQL3 ...
+#
+# This command creates fresh databases using SQL1 and subsequent arguments
+# and checks to make sure the content of all database files is different
+# in ways other than on page 1.
+#
+proc check_different_database_content {basename args} {
+ set i 0
+ set hashes {}
+ foreach sql $args {
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval $sql
+ set pgsz [db one {PRAGMA page_size}]
+ db close
+ set sz [file size test.db]
+ set thishash [md5file test.db $pgsz [expr {$sz-$pgsz}]]
+ set j [lsearch $hashes $thishash]
+ if {$j>=0} {
+ do_test $basename-$i "set x {$i is the same as $j}" "All are different"
+ } else {
+ do_test $basename-$i "set x {All are different}" "All are different"
+ }
+ lappend hashes $thishash
+ incr i
+ }
+}
+
+check_same_database_content 100 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(xyz INTEGER, abc, PRIMARY KEY(xyz), UNIQUE(abc));
+ INSERT INTO t1(xyz,abc) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(xyz INTEGER, abc, UNIQUE(abc), PRIMARY KEY(xyz));
+ INSERT INTO t1(xyz,abc) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ASC, b UNIQUE);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE UNIQUE INDEX t1b ON t1(b);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+ CREATE UNIQUE INDEX t1b ON t1(b);
+}
+
+check_same_database_content 110 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY UNIQUE, b UNIQUE);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b UNIQUE, UNIQUE(a));
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b);
+ CREATE UNIQUE INDEX t1b ON t1(b);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+ CREATE UNIQUE INDEX t1b ON t1(b);
+}
+
+check_same_database_content 120 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE) WITHOUT ROWID;
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(xyz INTEGER, abc, PRIMARY KEY(xyz), UNIQUE(abc))WITHOUT ROWID;
+ INSERT INTO t1(xyz,abc) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(xyz INTEGER, abc, UNIQUE(abc), PRIMARY KEY(xyz))WITHOUT ROWID;
+ INSERT INTO t1(xyz,abc) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ASC, b UNIQUE) WITHOUT ROWID;
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY UNIQUE, b UNIQUE) WITHOUT ROWID;
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b UNIQUE) WITHOUT ROWID;
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b UNIQUE, UNIQUE(a))
+ WITHOUT ROWID;
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b) WITHOUT ROWID;
+ CREATE UNIQUE INDEX t1b ON t1(b);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b) WITHOUT ROWID;
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+ CREATE UNIQUE INDEX t1b ON t1(b);
+}
+
+check_different_database_content 130 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY UNIQUE, b UNIQUE);
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+} {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE) WITHOUT ROWID;
+ INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');
+}
+
+
+finish_test
diff --git a/test/schemafault.test b/test/schemafault.test
new file mode 100644
index 0000000..a04c78a
--- /dev/null
+++ b/test/schemafault.test
@@ -0,0 +1,31 @@
+# 2018-08-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.
+#
+#***********************************************************************
+# Test OOM injection in schema-related operations.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix schemafault
+
+do_execsql_test 1.0 {
+ CREATE TABLE t2(aaa INTTT);
+ CREATE VIEW v2(xxx , yyy) AS SELECT aaa, aaa+1 FROM t2;
+}
+
+do_faultsim_test 1 -faults oom-* -prep {
+} -body {
+ execsql { SELECT * FROM v2 }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/securedel.test b/test/securedel.test
new file mode 100644
index 0000000..8323a30
--- /dev/null
+++ b/test/securedel.test
@@ -0,0 +1,100 @@
+# 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 fast_secure_delete {
+ set DEFAULT_SECDEL 2
+} else {
+ 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 {
+ db eval {
+ PRAGMA secure_delete=ON;
+ PRAGMA db2.secure_delete;
+ }
+} {1 1}
+do_test securedel-1.5 {
+ db eval {
+ PRAGMA secure_delete=FAST;
+ PRAGMA db2.secure_delete;
+ }
+} {2 2}
+do_test securedel-1.6 {
+ db eval {
+ PRAGMA secure_delete=ON;
+ PRAGMA db2.secure_delete;
+ }
+} {1 1}
+do_test securedel-1.7 {
+ db eval {
+ PRAGMA main.secure_delete=FAST;
+ PRAGMA db2.secure_delete;
+ }
+} {2 1}
+do_test securedel-1.8 {
+ db eval {
+ PRAGMA main.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/securedel2.test b/test/securedel2.test
new file mode 100644
index 0000000..9badc56
--- /dev/null
+++ b/test/securedel2.test
@@ -0,0 +1,94 @@
+# 2012 August 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.
+#
+#*************************************************************************
+#
+# Tests for the secure_delete pragma.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix securedel2
+
+# Generate 1000 pseudo-random 64-bit blobs.
+#
+for {set i 1} {$i <= 1000} {incr i} {
+ set aBlob($i) [string range [db one {SELECT quote(randomblob(8))}] 2 end-1]
+}
+
+proc detect_blob_prepare {zFile} {
+ set nByte [file size $zFile]
+ set ::detect_blob_data [hexio_read $zFile 0 $nByte]
+}
+
+proc detect_blob {zFile iBlob} {
+ if {$zFile != ""} { detect_blob_prepare $zFile }
+ string match "*$::aBlob($iBlob)*" $::detect_blob_data
+}
+
+do_test 1.1 {
+ execsql { PRAGMA secure_delete = 1 }
+ execsql { PRAGMA auto_vacuum = 0 }
+ execsql { CREATE TABLE t1(x, y) }
+ for {set i 1} {$i <= 1000} {incr i} {
+ set x "X'[string repeat $aBlob($i) 1]'"
+ set y "X'[string repeat $aBlob($i) 500]'"
+ execsql "INSERT INTO t1 VALUES($x, $y)"
+ }
+} {}
+
+do_test 1.2 { detect_blob test.db 1 } {1}
+
+forcecopy test.db test.db.bak
+do_execsql_test 1.3.1 { PRAGMA secure_delete = 0 } {0}
+do_execsql_test 1.3.2 { DELETE FROM t1 WHERE rowid = 1 }
+do_test 1.3.3 { detect_blob test.db 1 } {1}
+
+db close
+forcecopy test.db.bak test.db
+sqlite3 db test.db
+do_execsql_test 1.4.1 { PRAGMA secure_delete = 1 } {1}
+do_execsql_test 1.4.2 { DELETE FROM t1 WHERE rowid = 1 }
+do_test 1.4.3 { detect_blob test.db 1 } {0}
+
+do_execsql_test 1.5.1 { DELETE FROM t1 WHERE rowid>850 } {}
+do_test 1.5.2 {
+ set n 0
+ detect_blob_prepare test.db
+ for {set i 851} {$i <= 1000} {incr i 5} {
+ incr n [detect_blob {} $i]
+ }
+ set n
+} {0}
+
+db close
+sqlite3 db test.db
+do_test 1.6.1 {
+ execsql {
+ PRAGMA cache_size = 200;
+ PRAGMA secure_delete = 1;
+ CREATE TABLE t2(x);
+ SELECT * FROM t1;
+ }
+ for {set i 100} {$i < 5000} {incr i} {
+ execsql { INSERT INTO t2 VALUES(randomblob($i)) }
+ }
+ execsql { DELETE FROM t1 }
+} {}
+
+do_test 1.6.2 {
+ set n 0
+ detect_blob_prepare test.db
+ for {set i 2} {$i <= 850} {incr i 5} {
+ incr n [detect_blob {} $i]
+ }
+ set n
+} {0}
+
+finish_test
diff --git a/test/seekscan1.test b/test/seekscan1.test
new file mode 100644
index 0000000..e68d714
--- /dev/null
+++ b/test/seekscan1.test
@@ -0,0 +1,63 @@
+# 2022 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix seekscan1
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a TEXT, b INT, c INT NOT NULL, PRIMARY KEY(a,b,c));
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<1997)
+ INSERT INTO t1(a,b,c) SELECT printf('xyz%d',x/10),x/6,x FROM c;
+ INSERT INTO t1 VALUES('abc',234,6);
+ INSERT INTO t1 VALUES('abc',345,7);
+ ANALYZE;
+}
+
+do_execsql_test 1.1 {
+ SELECT a,b,c FROM t1
+ WHERE b IN (234, 345) AND c BETWEEN 6 AND 6.5 AND a='abc'
+ ORDER BY a, b;
+} {
+ abc 234 6
+}
+
+do_execsql_test 1.2 {
+ SELECT a,b,c FROM t1
+ WHERE b IN (234, 345) AND c BETWEEN 6 AND 7 AND a='abc'
+ ORDER BY a, b;
+} {
+ abc 234 6
+ abc 345 7
+}
+
+do_execsql_test 1.3 {
+ SELECT a,b,c FROM t1
+ WHERE b IN (234, 345) AND c >=6 AND a='abc'
+ ORDER BY a, b;
+} {
+ abc 234 6
+ abc 345 7
+}
+
+do_execsql_test 1.4 {
+ SELECT a,b,c FROM t1
+ WHERE b IN (234, 345) AND c<=7 AND a='abc'
+ ORDER BY a, b;
+} {
+ abc 234 6
+ abc 345 7
+}
+
+
+finish_test
diff --git a/test/select1.test b/test/select1.test
new file mode 100644
index 0000000..44e63d2
--- /dev/null
+++ b/test/select1.test
@@ -0,0 +1,1213 @@
+# 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()}}
+do_catchsql_test select1-4.5 {
+ INSERT INTO test1(f1) SELECT f1 FROM test1 ORDER BY min(f1);
+} {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-\d+} $x {subquery-0} x
+ set x
+} {a.f1 11 a.f2 22 (subquery-0).5 5 (subquery-0).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-\d+} $x {subquery-0} 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 {incomplete input}}
+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}
+}
+
+# Crash bug reported on the mailing list on 2012-02-23
+#
+do_test select1-16.1 {
+ catchsql {SELECT 1 FROM (SELECT *)}
+} {1 {no tables specified}}
+
+# 2015-04-17: assertion fix.
+do_catchsql_test select1-16.2 {
+ SELECT 1 FROM sqlite_master LIMIT 1,#1;
+} {1 {near "#1": syntax error}}
+
+# 2019-01-16 Chromium bug 922312
+# Sorting with a LIMIT clause using SRT_EphemTab and SRT_Table
+#
+do_execsql_test select1-17.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(x); INSERT INTO t1 VALUES(1);
+ CREATE TABLE t2(y,z); INSERT INTO t2 VALUES(2,3);
+ CREATE INDEX t2y ON t2(y);
+ SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z);
+} {1 2 3}
+do_execsql_test select1-17.2 {
+ SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2 ORDER BY y,z LIMIT 4);
+} {1 2 3}
+do_execsql_test select1-17.3 {
+ SELECT * FROM t1,(SELECT * FROM t2 WHERE y=2
+ UNION ALL SELECT * FROM t2 WHERE y=3 ORDER BY y,z LIMIT 4);
+} {1 2 3}
+
+# 2019-07-24 Ticket https://sqlite.org/src/tktview/c52b09c7f38903b1311
+#
+do_execsql_test select1-18.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(c);
+ CREATE TABLE t2(x PRIMARY KEY, y);
+ INSERT INTO t1(c) VALUES(123);
+ INSERT INTO t2(x) VALUES(123);
+ SELECT x FROM t2, t1 WHERE x BETWEEN c AND null OR x AND
+ x IN ((SELECT x FROM (SELECT x FROM t2, t1
+ WHERE x BETWEEN (SELECT x FROM (SELECT x COLLATE rtrim
+ FROM t2, t1 WHERE x BETWEEN c AND null
+ OR x AND x IN (c)), t1 WHERE x BETWEEN c AND null
+ OR x AND x IN (c)) AND null
+ OR NOT EXISTS(SELECT -4.81 FROM t1, t2 WHERE x BETWEEN c AND null
+ OR x AND x IN ((SELECT x FROM (SELECT x FROM t2, t1
+ WHERE x BETWEEN (SELECT x FROM (SELECT x BETWEEN c AND null
+ OR x AND x IN (c)), t1 WHERE x BETWEEN c AND null
+ OR x AND x IN (c)) AND null
+ OR x AND x IN (c)), t1 WHERE x BETWEEN c AND null
+ OR x AND x IN (c)))) AND x IN (c)
+ ), t1 WHERE x BETWEEN c AND null
+ OR x AND x IN (c)));
+} {}
+do_execsql_test select1-18.2 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(c);
+ CREATE TABLE t2(x PRIMARY KEY, y);
+ INSERT INTO t1(c) VALUES(123);
+ INSERT INTO t2(x) VALUES(123);
+ SELECT x FROM t2, t1 WHERE x BETWEEN c AND (c+1) OR x AND
+ x IN ((SELECT x FROM (SELECT x FROM t2, t1
+ WHERE x BETWEEN (SELECT x FROM (SELECT x COLLATE rtrim
+ FROM t2, t1 WHERE x BETWEEN c AND (c+1)
+ OR x AND x IN (c)), t1 WHERE x BETWEEN c AND (c+1)
+ OR x AND x IN (c)) AND (c+1)
+ OR NOT EXISTS(SELECT -4.81 FROM t1, t2 WHERE x BETWEEN c AND (c+1)
+ OR x AND x IN ((SELECT x FROM (SELECT x FROM t2, t1
+ WHERE x BETWEEN (SELECT x FROM (SELECT x BETWEEN c AND (c+1)
+ OR x AND x IN (c)), t1 WHERE x BETWEEN c AND (c+1)
+ OR x AND x IN (c)) AND (c+1)
+ OR x AND x IN (c)), t1 WHERE x BETWEEN c AND (c+1)
+ OR x AND x IN (c)))) AND x IN (c)
+ ), t1 WHERE x BETWEEN c AND (c+1)
+ OR x AND x IN (c)));
+} {123}
+do_execsql_test select1-18.3 {
+ SELECT 1 FROM t1 WHERE (
+ SELECT 2 FROM t2 WHERE (
+ SELECT 3 FROM (
+ SELECT x FROM t2 WHERE x=c OR x=(SELECT x FROM (VALUES(0)))
+ ) WHERE x>c OR x=c
+ )
+ );
+} {1}
+do_execsql_test select1-18.4 {
+ SELECT 1 FROM t1, t2 WHERE (
+ SELECT 3 FROM (
+ SELECT x FROM t2 WHERE x=c OR x=(SELECT x FROM (VALUES(0)))
+ ) WHERE x>c OR x=c
+ );
+} {1}
+
+# 2019-12-17 gramfuzz find
+#
+do_execsql_test select1-19.10 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+} {}
+do_catchsql_test select1-19.20 {
+ INSERT INTO t1
+ SELECT 1,2,3,4,5,6,7
+ UNION ALL SELECT 1,2,3,4,5,6,7
+ ORDER BY 1;
+} {1 {table t1 has 1 columns but 7 values were supplied}}
+do_catchsql_test select1-19.21 {
+ INSERT INTO t1
+ SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+ UNION ALL SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+ ORDER BY 1;
+} {1 {table t1 has 1 columns but 15 values were supplied}}
+
+# 2020-01-01 Found by Yongheng's fuzzer
+#
+reset_db
+do_execsql_test select1-20.10 {
+ CREATE TABLE t1 (
+ a INTEGER PRIMARY KEY,
+ b AS('Y') UNIQUE
+ );
+ INSERT INTO t1(a) VALUES (10);
+ SELECT * FROM t1 JOIN t1 USING(a,b)
+ WHERE ((SELECT t1.a FROM t1 AS x GROUP BY b) AND b=0)
+ OR a = 10;
+} {10 Y}
+do_execsql_test select1-20.20 {
+ SELECT ifnull(a, max((SELECT 123))), count(a) FROM t1 ;
+} {10 1}
+
+# 2020-10-02 dbsqlfuzz find
+reset_db
+do_execsql_test select1-21.1 {
+ CREATE TABLE t1(a IMTEGES PRIMARY KEY,R);
+ CREATE TABLE t2(x UNIQUE);
+ CREATE VIEW v1a(z,y) AS SELECT x IS NULL, x FROM t2;
+ SELECT a,(+a)b,(+a)b,(+a)b,NOT EXISTS(SELECT null FROM t2),CASE z WHEN 487 THEN 992 WHEN 391 THEN 203 WHEN 10 THEN '?k<D Q' END,'' FROM t1 LEFT JOIN v1a ON z=b;
+} {}
+
+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..4c9d71b
--- /dev/null
+++ b/test/select3.test
@@ -0,0 +1,437 @@
+# 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
+#
+# Update: As of 3.39.0, you can.
+#
+do_execsql_test select3-3.1 {
+ SELECT log, count(*) FROM t1 HAVING log>=4
+} {}
+do_execsql_test select3-3.2 {
+ SELECT count(*) FROM t1 HAVING log>=4
+} {}
+do_execsql_test select3-3.3 {
+ SELECT count(*) FROM t1 HAVING log!=400
+} {31}
+
+# 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}
+
+# 2019-05-09 ticket https://www.sqlite.org/src/tktview/6c1d3febc00b22d457c7
+#
+unset -nocomplain x
+foreach {id x} {
+ 100 127
+ 101 128
+ 102 -127
+ 103 -128
+ 104 -129
+ 110 32767
+ 111 32768
+ 112 -32767
+ 113 -32768
+ 114 -32769
+ 120 2147483647
+ 121 2147483648
+ 122 -2147483647
+ 123 -2147483648
+ 124 -2147483649
+ 130 140737488355327
+ 131 140737488355328
+ 132 -140737488355327
+ 133 -140737488355328
+ 134 -140737488355329
+ 140 9223372036854775807
+ 141 -9223372036854775807
+ 142 -9223372036854775808
+ 143 9223372036854775806
+ 144 9223372036854775805
+ 145 -9223372036854775806
+ 146 -9223372036854775805
+
+} {
+ set x [expr {$x+0}]
+ do_execsql_test select3-8.$id {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1 (c0, c1 REAL PRIMARY KEY);
+ INSERT INTO t1(c0, c1) VALUES (0, $x), (0, 0);
+ UPDATE t1 SET c0 = NULL;
+ UPDATE OR REPLACE t1 SET c1 = 1;
+ SELECT DISTINCT * FROM t1 WHERE (t1.c0 IS NULL);
+ PRAGMA integrity_check;
+ } {{} 1.0 ok}
+}
+
+# 2020-03-10 ticket e0c2ad1aa8a9c691
+reset_db
+do_execsql_test select3-9.100 {
+ CREATE TABLE t0(c0 REAL, c1 REAL GENERATED ALWAYS AS (c0));
+ INSERT INTO t0(c0) VALUES (1);
+ SELECT * FROM t0 GROUP BY c0;
+} {1.0 1.0}
+
+reset_db
+do_execsql_test select3.10.100 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ SELECT max(t1.a),
+ (SELECT 'xyz' FROM (SELECT * FROM t2 WHERE 0) WHERE t1.b=1)
+ FROM t1;
+} {{} {}}
+
+#-------------------------------------------------------------------------
+# dbsqlfuzz crash-8e17857db2c5a9294c975123ac807156a6559f13.txt
+# Associated with the flatten-left-join branch circa 2022-06-23.
+#
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE t1(a TEXT);
+ CREATE TABLE t2(x INT);
+ CREATE INDEX t2x ON t2(x);
+ INSERT INTO t1 VALUES('abc');
+ }
+ 2 {
+ CREATE TABLE t1(a TEXT);
+ CREATE TABLE t2(x INT);
+ INSERT INTO t1 VALUES('abc');
+ }
+ 3 {
+ CREATE TABLE t1(a TEXT);
+ CREATE TABLE t2(x INT);
+ INSERT INTO t1 VALUES('abc');
+ PRAGMA automatic_index=OFF;
+ }
+} {
+ reset_db
+ do_execsql_test select3-11.$tn.1 $sql
+ do_execsql_test select3.11.$tn.2 {
+ SELECT max(a), val FROM t1 LEFT JOIN (
+ SELECT 'constant' AS val FROM t2 WHERE x=1234
+ )
+ } {abc {}}
+ do_execsql_test select3.11.$tn.3 {
+ INSERT INTO t2 VALUES(123);
+ SELECT max(a), val FROM t1 LEFT JOIN (
+ SELECT 'constant' AS val FROM t2 WHERE x=1234
+ )
+ } {abc {}}
+ do_execsql_test select3.11.$tn.4 {
+ INSERT INTO t2 VALUES(1234);
+ SELECT max(a), val FROM t1 LEFT JOIN (
+ SELECT 'constant' AS val FROM t2 WHERE x=1234
+ )
+ } {abc constant}
+}
+
+reset_db
+do_execsql_test 12.0 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(x);
+}
+do_execsql_test 12.1 {
+ SELECT count(x), m FROM t1 LEFT JOIN (SELECT x, 59 AS m FROM t2) GROUP BY a;
+}
+do_execsql_test 12.2 {
+ INSERT INTO t1 VALUES(1), (1), (2), (3);
+ SELECT count(x), m FROM t1 LEFT JOIN (SELECT x, 59 AS m FROM t2) GROUP BY a;
+} {
+ 0 {}
+ 0 {}
+ 0 {}
+}
+do_execsql_test 12.3 {
+ INSERT INTO t2 VALUES(45);
+ SELECT count(x), m FROM t1 LEFT JOIN (SELECT x, 59 AS m FROM t2) GROUP BY a;
+} {
+ 2 59
+ 1 59
+ 1 59
+}
+do_execsql_test 12.4 {
+ INSERT INTO t2 VALUES(210);
+ SELECT count(x), m FROM t1 LEFT JOIN (SELECT x, 59 AS m FROM t2) GROUP BY a;
+} {
+ 4 59
+ 2 59
+ 2 59
+}
+do_execsql_test 12.5 {
+ INSERT INTO t2 VALUES(NULL);
+ SELECT count(x), m FROM t1 LEFT JOIN (SELECT x, 59 AS m FROM t2) GROUP BY a;
+} {
+ 4 59
+ 2 59
+ 2 59
+}
+do_execsql_test 12.6 {
+ DELETE FROM t2;
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('value');
+ INSERT INTO t2 VALUES('hello');
+} {}
+do_execsql_test 12.7 {
+ SELECT group_concat(x), m FROM t1
+ LEFT JOIN (SELECT x, 59 AS m FROM t2) GROUP BY a;
+} {
+ hello 59
+}
+do_execsql_test 12.8 {
+ SELECT group_concat(x), m, n FROM t1
+ LEFT JOIN (SELECT x, 59 AS m, 60 AS n FROM t2) GROUP BY a;
+} {
+ hello 59 60
+}
+
+finish_test
+
diff --git a/test/select4.test b/test/select4.test
new file mode 100644
index 0000000..d49708e
--- /dev/null
+++ b/test/select4.test
@@ -0,0 +1,1043 @@
+# 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.
+#
+
+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}
+}
+
+# EVIDENCE-OF: R-02644-22131 In a compound SELECT statement, only the
+# last or right-most simple SELECT may have an ORDER BY clause.
+#
+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}}
+do_catchsql_test select4-1.4 {
+ SELECT (VALUES(0) INTERSECT SELECT(0) UNION SELECT(0) ORDER BY 1 UNION
+ SELECT 0 UNION SELECT 0 ORDER BY 1);
+} {1 {ORDER BY clause should come after UNION 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}}
+do_test select4-2.4 {
+ set v [catch {execsql {
+ SELECT 0 ORDER BY (SELECT 0) UNION SELECT 0;
+ }} msg]
+ lappend v $msg
+} {1 {ORDER BY clause should come after UNION not before}}
+do_execsql_test select4-2.5 {
+ SELECT 123 AS x ORDER BY (SELECT x ORDER BY 1);
+} {123}
+
+# 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}}
+do_catchsql_test select4-4.4 {
+ SELECT 3 IN (
+ SELECT 0 ORDER BY 1
+ INTERSECT
+ SELECT 1
+ INTERSECT
+ SELECT 2
+ ORDER BY 1
+ );
+} {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-11.16 {
+ catchsql {
+ INSERT INTO t2(rowid) VALUES(2) UNION SELECT 3,4 UNION SELECT 5,6 ORDER BY 1;
+ }
+} {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
+
+
+# Ticket [3557ad65a076c] - Incorrect DISTINCT processing with an
+# indexed query using IN.
+#
+do_test select4-13.1 {
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t13(a,b);
+ INSERT INTO t13 VALUES(1,1);
+ INSERT INTO t13 VALUES(2,1);
+ INSERT INTO t13 VALUES(3,1);
+ INSERT INTO t13 VALUES(2,2);
+ INSERT INTO t13 VALUES(3,2);
+ INSERT INTO t13 VALUES(4,2);
+ CREATE INDEX t13ab ON t13(a,b);
+ SELECT DISTINCT b from t13 WHERE a IN (1,2,3);
+ }
+} {1 2}
+
+# 2014-02-18: Make sure compound SELECTs work with VALUES clauses
+#
+do_execsql_test select4-14.1 {
+ CREATE TABLE t14(a,b,c);
+ INSERT INTO t14 VALUES(1,2,3),(4,5,6);
+ SELECT * FROM t14 INTERSECT VALUES(3,2,1),(2,3,1),(1,2,3),(2,1,3);
+} {1 2 3}
+do_execsql_test select4-14.2 {
+ SELECT * FROM t14 INTERSECT VALUES(1,2,3);
+} {1 2 3}
+do_execsql_test select4-14.3 {
+ SELECT * FROM t14
+ UNION VALUES(3,2,1),(2,3,1),(1,2,3),(7,8,9),(4,5,6)
+ UNION SELECT * FROM t14 ORDER BY 1, 2, 3
+} {1 2 3 2 3 1 3 2 1 4 5 6 7 8 9}
+do_execsql_test select4-14.4 {
+ SELECT * FROM t14
+ UNION VALUES(3,2,1)
+ UNION SELECT * FROM t14 ORDER BY 1, 2, 3
+} {1 2 3 3 2 1 4 5 6}
+do_execsql_test select4-14.5 {
+ SELECT * FROM t14 EXCEPT VALUES(3,2,1),(2,3,1),(1,2,3),(2,1,3);
+} {4 5 6}
+do_execsql_test select4-14.6 {
+ SELECT * FROM t14 EXCEPT VALUES(1,2,3)
+} {4 5 6}
+do_execsql_test select4-14.7 {
+ SELECT * FROM t14 EXCEPT VALUES(1,2,3) EXCEPT VALUES(4,5,6)
+} {}
+do_execsql_test select4-14.8 {
+ SELECT * FROM t14 EXCEPT VALUES('a','b','c') EXCEPT VALUES(4,5,6)
+} {1 2 3}
+do_execsql_test select4-14.9 {
+ SELECT * FROM t14 UNION ALL VALUES(3,2,1),(2,3,1),(1,2,3),(2,1,3);
+} {1 2 3 4 5 6 3 2 1 2 3 1 1 2 3 2 1 3}
+do_execsql_test select4-14.10 {
+ SELECT (VALUES(1),(2),(3),(4))
+} {1}
+do_execsql_test select4-14.11 {
+ SELECT (SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4)
+} {1}
+do_execsql_test select4-14.12 {
+ VALUES(1) UNION VALUES(2);
+} {1 2}
+do_execsql_test select4-14.13 {
+ VALUES(1),(2),(3) EXCEPT VALUES(2);
+} {1 3}
+do_execsql_test select4-14.14 {
+ VALUES(1),(2),(3) EXCEPT VALUES(1),(3);
+} {2}
+do_execsql_test select4-14.15 {
+ SELECT * FROM (SELECT 123), (SELECT 456) ON likely(0 OR 1) OR 0;
+} {123 456}
+do_execsql_test select4-14.16 {
+ VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 99;
+} {1 2 3 4 5}
+do_execsql_test select4-14.17 {
+ VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 3;
+} {1 2 3}
+
+# Ticket https://www.sqlite.org/src/info/d06a25c84454a372
+# Incorrect answer due to two co-routines using the same registers and expecting
+# those register values to be preserved across a Yield.
+#
+do_execsql_test select4-15.1 {
+ DROP TABLE IF EXISTS tx;
+ CREATE TABLE tx(id INTEGER PRIMARY KEY, a, b);
+ INSERT INTO tx(a,b) VALUES(33,456);
+ INSERT INTO tx(a,b) VALUES(33,789);
+
+ SELECT DISTINCT t0.id, t0.a, t0.b
+ FROM tx AS t0, tx AS t1
+ WHERE t0.a=t1.a AND t1.a=33 AND t0.b=456
+ UNION
+ SELECT DISTINCT t0.id, t0.a, t0.b
+ FROM tx AS t0, tx AS t1
+ WHERE t0.a=t1.a AND t1.a=33 AND t0.b=789
+ ORDER BY 1;
+} {1 33 456 2 33 789}
+
+# Enhancement (2016-03-15): Use a co-routine for subqueries if the
+# subquery is guaranteed to be the outer-most query
+#
+do_execsql_test select4-16.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(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,
+ PRIMARY KEY(a,b DESC)) WITHOUT ROWID;
+
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c,d)
+ SELECT x%10, x/10, x, printf('xyz%dabc',x) FROM c;
+
+ SELECT t3.c FROM
+ (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
+ JOIN t1 AS t3
+ WHERE t2.a=t3.a AND t2.m=t3.b
+ ORDER BY t3.a;
+} {95 96 97 98 99}
+do_execsql_test select4-16.2 {
+ SELECT t3.c FROM
+ (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
+ CROSS JOIN t1 AS t3
+ WHERE t2.a=t3.a AND t2.m=t3.b
+ ORDER BY t3.a;
+} {95 96 97 98 99}
+do_execsql_test select4-16.3 {
+ SELECT t3.c FROM
+ (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
+ LEFT JOIN t1 AS t3
+ WHERE t2.a=t3.a AND t2.m=t3.b
+ ORDER BY t3.a;
+} {95 96 97 98 99}
+
+# Ticket https://www.sqlite.org/src/tktview/f7f8c97e975978d45 on 2016-04-25
+#
+# The where push-down optimization from 2015-06-02 is suppose to disable
+# on aggregate subqueries. But if the subquery is a compound where the
+# last SELECT is non-aggregate but some other SELECT is an aggregate, the
+# test is incomplete and the optimization is not properly disabled.
+#
+# The following test cases verify that the fix works.
+#
+do_execsql_test select4-17.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a int, b int);
+ INSERT INTO t1 VALUES(1,2),(1,18),(2,19);
+ SELECT x, y FROM (
+ SELECT 98 AS x, 99 AS y
+ UNION
+ SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a
+ ) AS w WHERE y>=20
+ ORDER BY +x;
+} {1 20 98 99}
+do_execsql_test select4-17.2 {
+ SELECT x, y FROM (
+ SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a
+ UNION
+ SELECT 98 AS x, 99 AS y
+ ) AS w WHERE y>=20
+ ORDER BY +x;
+} {1 20 98 99}
+do_catchsql_test select4-17.3 {
+ SELECT x, y FROM (
+ SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a LIMIT 3
+ UNION
+ SELECT 98 AS x, 99 AS y
+ ) AS w WHERE y>=20
+ ORDER BY +x;
+} {1 {LIMIT clause should come after UNION not before}}
+
+# 2020-04-03 ticket 51166be0159fd2ce from Yong Heng.
+# Adverse interaction between the constant propagation and push-down
+# optimizations.
+#
+reset_db
+do_execsql_test select4-18.1 {
+ CREATE VIEW v0(v0) AS WITH v0 AS(SELECT 0 v0) SELECT(SELECT min(v0) OVER()) FROM v0 GROUP BY v0;
+ SELECT *FROM v0 v1 JOIN v0 USING(v0) WHERE datetime(v0) = (v0.v0)AND v0 = 10;
+} {}
+do_execsql_test select4-18.2 {
+ CREATE VIEW t1(aa) AS
+ WITH t2(bb) AS (SELECT 123)
+ SELECT (SELECT min(bb) OVER()) FROM t2 GROUP BY bb;
+ SELECT * FROM t1;
+} {123}
+do_execsql_test select4-18.3 {
+ SELECT * FROM t1 AS z1 JOIN t1 AS z2 USING(aa)
+ WHERE abs(z1.aa)=z2.aa AND z1.aa=123;
+} {123}
+
+# 2021-03-31 Fix an assert() problem in the logic at the end of sqlite3Select()
+# that validates AggInfo. The checks to ensure that AggInfo.aCol[].pCExpr
+# references a valid expression was looking at an expression that had been
+# deleted by the truth optimization in sqlite3ExprAnd() which was invoked by
+# the push-down optimization. This is harmless in delivery builds, as that code
+# only runs with SQLITE_DEBUG. But it should still be fixed. The problem
+# was discovered by dbsqlfuzz (crash-dece7b67a3552ed7e571a7bda903afd1f7bd9b21)
+#
+reset_db
+do_execsql_test select4-19.1 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(99);
+ SELECT sum((SELECT 1 FROM (SELECT 2 WHERE x IS NULL) WHERE 0)) FROM t1;
+} {{}}
+
+finish_test
diff --git a/test/select5.test b/test/select5.test
new file mode 100644
index 0000000..8de306c
--- /dev/null
+++ b/test/select5.test
@@ -0,0 +1,262 @@
+# 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.
+#
+
+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 2 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}
+
+# 2021-04-26 forum https://sqlite.org/forum/forumpost/74330094d8
+reset_db
+do_execsql_test select5-9.1 {
+ CREATE TABLE t1(a INT, b INT);
+ INSERT INTO t1(a,b) VALUES(1,null),(null,null),(1,null);
+ CREATE UNIQUE INDEX t1b ON t1(abs(b));
+ SELECT quote(a), quote(b), '|' FROM t1 GROUP BY a, abs(b);
+} {NULL NULL | 1 NULL |}
+
+finish_test
diff --git a/test/select6.test b/test/select6.test
new file mode 100644
index 0000000..612afef
--- /dev/null
+++ b/test/select6.test
@@ -0,0 +1,631 @@
+# 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.
+#
+
+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
+}
+set ::testprefix select6
+
+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)
+ }
+} {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}
+
+
+#-------------------------------------------------------------------------
+# Test that if a UNION ALL sub-query that would otherwise be eligible for
+# flattening consists of two or more SELECT statements that do not all
+# return the same number of result columns, the error is detected.
+#
+do_execsql_test 10.1 {
+ CREATE TABLE t(i,j,k);
+ CREATE TABLE j(l,m);
+ CREATE TABLE k(o);
+}
+
+set err [list 1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}]
+
+do_execsql_test 10.2 {
+ SELECT * FROM (SELECT * FROM t), j;
+}
+do_catchsql_test 10.3 {
+ SELECT * FROM t UNION ALL SELECT * FROM j
+} $err
+do_catchsql_test 10.4 {
+ SELECT * FROM (SELECT i FROM t UNION ALL SELECT l, m FROM j)
+} $err
+do_catchsql_test 10.5 {
+ SELECT * FROM (SELECT j FROM t UNION ALL SELECT * FROM j)
+} $err
+do_catchsql_test 10.6 {
+ SELECT * FROM (SELECT * FROM t UNION ALL SELECT * FROM j)
+} $err
+do_catchsql_test 10.7 {
+ SELECT * FROM (
+ SELECT * FROM t UNION ALL
+ SELECT l,m,l FROM j UNION ALL
+ SELECT * FROM k
+ )
+} $err
+do_catchsql_test 10.8 {
+ SELECT * FROM (
+ SELECT * FROM k UNION ALL
+ SELECT * FROM t UNION ALL
+ SELECT l,m,l FROM j
+ )
+} $err
+
+# 2015-02-09 Ticket [2f7170d73bf9abf80339187aa3677dce3dbcd5ca]
+# "misuse of aggregate" error if aggregate column from FROM
+# subquery is used in correlated subquery
+#
+do_execsql_test 11.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(w INT, x INT);
+ INSERT INTO t1(w,x)
+ VALUES(1,10),(2,20),(3,30),
+ (2,21),(3,31),
+ (3,32);
+ CREATE INDEX t1wx ON t1(w,x);
+
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(w INT, y VARCHAR(8));
+ INSERT INTO t2(w,y) VALUES(1,'one'),(2,'two'),(3,'three'),(4,'four');
+ CREATE INDEX t2wy ON t2(w,y);
+
+ SELECT cnt, xyz, (SELECT y FROM t2 WHERE w=cnt), '|'
+ FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)
+ ORDER BY cnt, xyz;
+} {1 1 one | 2 2 two | 3 3 three |}
+do_execsql_test 11.2 {
+ SELECT cnt, xyz, lower((SELECT y FROM t2 WHERE w=cnt)), '|'
+ FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)
+ ORDER BY cnt, xyz;
+} {1 1 one | 2 2 two | 3 3 three |}
+do_execsql_test 11.3 {
+ SELECT cnt, xyz, '|'
+ FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)
+ WHERE (SELECT y FROM t2 WHERE w=cnt)!='two'
+ ORDER BY cnt, xyz;
+} {1 1 | 3 3 |}
+do_execsql_test 11.4 {
+ SELECT cnt, xyz, '|'
+ FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)
+ ORDER BY lower((SELECT y FROM t2 WHERE w=cnt));
+} {1 1 | 3 3 | 2 2 |}
+do_execsql_test 11.5 {
+ SELECT cnt, xyz,
+ CASE WHEN (SELECT y FROM t2 WHERE w=cnt)=='two'
+ THEN 'aaa' ELSE 'bbb'
+ END, '|'
+ FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)
+ ORDER BY +cnt;
+} {1 1 bbb | 2 2 aaa | 3 3 bbb |}
+
+do_execsql_test 11.100 {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(y, z);
+ SELECT ( SELECT y FROM t2 WHERE z = cnt )
+ FROM ( SELECT count(*) AS cnt FROM t1 );
+} {{}}
+
+# 2019-05-29 ticket https://www.sqlite.org/src/info/c41afac34f15781f
+# A LIMIT clause in a subquery is incorrectly applied to a subquery.
+#
+do_execsql_test 12.100 {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ CREATE TABLE t2(b);
+ INSERT INTO t2 VALUES(3);
+ SELECT * FROM (
+ SELECT * FROM (SELECT * FROM t1 LIMIT 1)
+ UNION ALL
+ SELECT * from t2);
+} {1 3}
+
+finish_test
diff --git a/test/select7.test b/test/select7.test
new file mode 100644
index 0000000..d705ebf
--- /dev/null
+++ b/test/select7.test
@@ -0,0 +1,218 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find 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
+set testprefix select7
+
+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);
+ }
+ } {1 {sub-select returns 2 columns - expected 1}}
+ do_test select7-5.2 {
+ catchsql {
+ SELECT 5 IN (SELECT * FROM t2);
+ }
+ } {1 {sub-select returns 2 columns - expected 1}}
+ do_test select7-5.3 {
+ catchsql {
+ SELECT 5 IN (SELECT a,b FROM t2 UNION SELECT b,a FROM t2);
+ }
+ } {1 {sub-select returns 2 columns - expected 1}}
+ do_test select7-5.4 {
+ catchsql {
+ SELECT 5 IN (SELECT * FROM t2 UNION SELECT * FROM t2);
+ }
+ } {1 {sub-select returns 2 columns - expected 1}}
+}
+
+# Verify that an error occurs if you have too many terms on a
+# compound select statement.
+#
+if {[clang_sanitize_address]==0} {
+ 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}
+
+do_execsql_test 8.0 {
+ CREATE TABLE t01(x, y);
+ CREATE TABLE t02(x, y);
+}
+
+do_catchsql_test 8.1 {
+ SELECT * FROM (
+ SELECT * FROM t01 UNION SELECT x FROM t02
+ ) WHERE y=1
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+
+do_catchsql_test 8.2 {
+ CREATE VIEW v0 as SELECT x, y FROM t01 UNION SELECT x FROM t02;
+ EXPLAIN QUERY PLAN SELECT * FROM v0 WHERE x='0' OR y;
+} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}
+
+
+finish_test
diff --git a/test/select8.test b/test/select8.test
new file mode 100644
index 0000000..39b2739
--- /dev/null
+++ b/test/select8.test
@@ -0,0 +1,61 @@
+# 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)
+}]
+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..bbed8e1
--- /dev/null
+++ b/test/select9.test
@@ -0,0 +1,472 @@
+# 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;
+ }
+} {}
+
+# Testing to make sure that queries involving a view of a compound select
+# are planned efficiently. This detects a problem reported on the mailing
+# list on 2012-04-26. See
+#
+# http://www.mail-archive.com/sqlite-users%40sqlite.org/msg69746.html
+#
+# For additional information.
+#
+do_test select9-5.1 {
+ db eval {
+ CREATE TABLE t51(x, y);
+ CREATE TABLE t52(x, y);
+ CREATE VIEW v5 as
+ SELECT x, y FROM t51
+ UNION ALL
+ SELECT x, y FROM t52;
+ CREATE INDEX t51x ON t51(x);
+ CREATE INDEX t52x ON t52(x);
+ EXPLAIN QUERY PLAN
+ SELECT * FROM v5 WHERE x='12345' ORDER BY y;
+ }
+} {~/SCAN/} ;# Uses indices with "*"
+do_test select9-5.2 {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT x, y FROM v5 WHERE x='12345' ORDER BY y;
+ }
+} {~/SCAN/} ;# Uses indices with "x, y"
+do_test select9-5.3 {
+ db eval {
+ EXPLAIN QUERY PLAN
+ SELECT x, y FROM v5 WHERE +x='12345' ORDER BY y;
+ }
+} {/SCAN/} ;# Full table scan if the "+x" prevents index usage.
+
+# 2013-07-09: Ticket [490a4b7235624298]:
+# "WHERE 0" on the first element of a UNION causes an assertion fault
+#
+do_execsql_test select9-6.1 {
+ CREATE TABLE t61(a);
+ CREATE TABLE t62(b);
+ INSERT INTO t61 VALUES(111);
+ INSERT INTO t62 VALUES(222);
+ SELECT a FROM t61 WHERE 0 UNION SELECT b FROM t62;
+} {222}
+do_execsql_test select9-6.2 {
+ SELECT a FROM t61 WHERE 0 UNION ALL SELECT b FROM t62;
+} {222}
+do_execsql_test select9-6.3 {
+ SELECT a FROM t61 UNION SELECT b FROM t62 WHERE 0;
+} {111}
+
+
+
+finish_test
diff --git a/test/selectA.test b/test/selectA.test
new file mode 100644
index 0000000..7d72bb3
--- /dev/null
+++ b/test/selectA.test
@@ -0,0 +1,1510 @@
+# 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
+set testprefix selectA
+
+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 y COLLATE NOCASE,x,z
+ }
+} {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 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.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 z COLLATE BINARY DESC,x,y
+ }
+} {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 y COLLATE NOCASE,x,z
+ }
+} {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 z COLLATE BINARY DESC,x,y
+ }
+} {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 y COLLATE NOCASE,x,z
+ }
+} {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 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.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 z COLLATE BINARY DESC,x,y
+ }
+} {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 y COLLATE NOCASE,x,z
+ }
+} {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 z COLLATE BINARY DESC,x,y
+ }
+} {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}
+do_execsql_test selectA-3.98 {
+ WITH RECURSIVE
+ xyz(n) AS (
+ 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)))
+ UNION ALL
+ SELECT n || '+' FROM xyz WHERE length(n)<5
+ )
+ SELECT n FROM xyz ORDER BY +n;
+} {MAD MAD+ MAD++}
+
+#-------------------------------------------------------------------------
+# At one point the following code exposed a temp register reuse problem.
+#
+proc f {args} { return 1 }
+db func f f
+
+do_execsql_test 4.1.1 {
+ CREATE TABLE t4(a, b);
+ CREATE TABLE t5(c, d);
+
+ INSERT INTO t5 VALUES(1, 'x');
+ INSERT INTO t5 VALUES(2, 'x');
+ INSERT INTO t4 VALUES(3, 'x');
+ INSERT INTO t4 VALUES(4, 'x');
+
+ CREATE INDEX i1 ON t4(a);
+ CREATE INDEX i2 ON t5(c);
+}
+
+do_eqp_test 4.1.2 {
+ SELECT c, d FROM t5
+ UNION ALL
+ SELECT a, b FROM t4 WHERE f()==f()
+ ORDER BY 1,2
+} {
+ QUERY PLAN
+ `--MERGE (UNION ALL)
+ |--LEFT
+ | |--SCAN t5 USING INDEX i2
+ | `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY
+ `--RIGHT
+ |--SCAN t4 USING INDEX i1
+ `--USE TEMP B-TREE FOR RIGHT PART OF ORDER BY
+}
+
+do_execsql_test 4.1.3 {
+ SELECT c, d FROM t5
+ UNION ALL
+ SELECT a, b FROM t4 WHERE f()==f()
+ ORDER BY 1,2
+} {
+ 1 x 2 x 3 x 4 x
+}
+
+do_execsql_test 4.2.1 {
+ CREATE TABLE t6(a, b);
+ CREATE TABLE t7(c, d);
+
+ INSERT INTO t7 VALUES(2, 9);
+ INSERT INTO t6 VALUES(3, 0);
+ INSERT INTO t6 VALUES(4, 1);
+ INSERT INTO t7 VALUES(5, 6);
+ INSERT INTO t6 VALUES(6, 0);
+ INSERT INTO t7 VALUES(7, 6);
+
+ CREATE INDEX i6 ON t6(a);
+ CREATE INDEX i7 ON t7(c);
+}
+
+do_execsql_test 4.2.2 {
+ SELECT c, f(d,c,d,c,d) FROM t7
+ UNION ALL
+ SELECT a, b FROM t6
+ ORDER BY 1,2
+} {/2 . 3 . 4 . 5 . 6 . 7 ./}
+
+
+proc strip_rnd {explain} {
+ regexp -all {sqlite_sq_[0123456789ABCDEF]*} $explain sqlite_sq
+}
+
+proc do_same_test {tn q1 args} {
+ set r2 [strip_rnd [db eval "EXPLAIN $q1"]]
+ set i 1
+ foreach q $args {
+ set tst [subst -nocommands {strip_rnd [db eval "EXPLAIN $q"]}]
+ uplevel do_test $tn.$i [list $tst] [list $r2]
+ incr i
+ }
+}
+
+do_execsql_test 5.0 {
+ CREATE TABLE t8(a, b);
+ CREATE TABLE t9(c, d);
+} {}
+
+do_same_test 5.1 {
+ SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY a;
+} {
+ SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY t8.a;
+} {
+ SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY 1;
+} {
+ SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY c;
+} {
+ SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY t9.c;
+}
+
+do_same_test 5.2 {
+ SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY a COLLATE NOCASE
+} {
+ SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY t8.a COLLATE NOCASE
+} {
+ SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY 1 COLLATE NOCASE
+} {
+ SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY c COLLATE NOCASE
+} {
+ SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY t9.c COLLATE NOCASE
+}
+
+do_same_test 5.3 {
+ SELECT a, b FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY b, c COLLATE NOCASE
+} {
+ SELECT a, b FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY 2, 1 COLLATE NOCASE
+} {
+ SELECT a, b FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY d, a COLLATE NOCASE
+} {
+ SELECT a, b FROM t8 EXCEPT SELECT * FROM t9 ORDER BY t9.d, c COLLATE NOCASE
+} {
+ SELECT * FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY d, t8.a COLLATE NOCASE
+}
+
+do_catchsql_test 5.4 {
+ SELECT * FROM t8 UNION SELECT * FROM t9 ORDER BY a+b COLLATE NOCASE
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+do_execsql_test 6.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER);
+ CREATE TABLE t2(b TEXT);
+ INSERT INTO t2(b) VALUES('12345');
+ SELECT * FROM (SELECT a FROM t1 UNION SELECT b FROM t2) WHERE a=a;
+} {12345}
+
+# 2020-06-15 ticket 8f157e8010b22af0
+#
+reset_db
+do_execsql_test 7.1 {
+ CREATE TABLE t1(c1); INSERT INTO t1 VALUES(12),(123),(1234),(NULL),('abc');
+ CREATE TABLE t2(c2); INSERT INTO t2 VALUES(44),(55),(123);
+ CREATE TABLE t3(c3,c4); INSERT INTO t3 VALUES(66,1),(123,2),(77,3);
+ CREATE VIEW t4 AS SELECT c3 FROM t3;
+ CREATE VIEW t5 AS SELECT c3 FROM t3 ORDER BY c4;
+}
+do_execsql_test 7.2 {
+ SELECT * FROM t1, t2 WHERE c1=(SELECT 123 INTERSECT SELECT c2 FROM t4) AND c1=123;
+} {123 123}
+do_execsql_test 7.3 {
+ SELECT * FROM t1, t2 WHERE c1=(SELECT 123 INTERSECT SELECT c2 FROM t5) AND c1=123;
+} {123 123}
+do_execsql_test 7.4 {
+ CREATE TABLE a(b);
+ CREATE VIEW c(d) AS SELECT b FROM a ORDER BY b;
+ SELECT sum(d) OVER( PARTITION BY(SELECT 0 FROM c JOIN a WHERE b =(SELECT b INTERSECT SELECT d FROM c) AND b = 123)) FROM c;
+} {}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 8.0 {
+ CREATE TABLE x1(x);
+ CREATE TABLE t1(a, b, c, d);
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+}
+
+do_execsql_test 8.1 {
+ SELECT 'ABCD' FROM t1
+ WHERE (a=? OR b=?)
+ AND (0 OR (SELECT 'xyz' INTERSECT SELECT a ORDER BY 1))
+} {}
+
+#-------------------------------------------------------------------------
+# dbsqlfuzz a34f455c91ad75a0cf8cd9476841903f42930a7a
+#
+reset_db
+do_execsql_test 9.0 {
+ CREATE TABLE t1(a COLLATE nocase);
+ CREATE TABLE t2(b COLLATE nocase);
+
+ INSERT INTO t1 VALUES('ABC');
+ INSERT INTO t2 VALUES('abc');
+}
+
+do_execsql_test 9.1 {
+ SELECT a FROM t1 INTERSECT SELECT b FROM t2;
+} {ABC}
+
+do_execsql_test 9.2 {
+ SELECT * FROM (
+ SELECT a FROM t1 INTERSECT SELECT b FROM t2
+ ) WHERE a||'' = 'ABC';
+} {ABC}
+
+
+
+finish_test
diff --git a/test/selectB.test b/test/selectB.test
new file mode 100644
index 0000000..05ec9c6
--- /dev/null
+++ b/test/selectB.test
@@ -0,0 +1,426 @@
+# 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 <= 6} {incr ii} {
+
+ switch $ii {
+ 4 {
+ optimization_control db query-flattener off
+ }
+ 5 {
+ optimization_control db query-flattener on
+ do_test selectB-5.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);
+ }
+ } {}
+ }
+ 6 {
+ optimization_control db query-flattener off
+ }
+ }
+
+ 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.22 {
+ execsql {
+ SELECT * FROM (SELECT 345 UNION ALL SELECT d FROM t2) ORDER BY 1;
+ }
+ } {3 12 21 345}
+
+ do_test selectB-$ii.23 {
+ execsql {
+ SELECT x, y FROM (
+ SELECT a AS x, b AS y FROM t1
+ UNION ALL
+ SELECT a*10 + 0.1, f*10 + 0.1 FROM t1 JOIN t2 ON (c=d)
+ UNION ALL
+ SELECT a*100, b*100 FROM t1
+ ) ORDER BY 1;
+ }
+ } {2 4 8 10 14 16 80.1 180.1 200 400 800 1000 1400 1600}
+
+ do_test selectB-$ii.24 {
+ execsql {
+ SELECT x, y FROM (
+ SELECT a AS x, b AS y FROM t1
+ UNION ALL
+ SELECT a*10 + 0.1, f*10 + 0.1 FROM t1 LEFT JOIN t2 ON (c=d)
+ UNION ALL
+ SELECT a*100, b*100 FROM t1
+ ) ORDER BY 1;
+ }
+ } {2 4 8 10 14 16 20.1 {} 80.1 180.1 140.1 {} 200 400 800 1000 1400 1600}
+
+ do_test selectB-$ii.25 {
+ execsql {
+ SELECT x+y FROM (
+ SELECT a AS x, b AS y FROM t1
+ UNION ALL
+ SELECT a*10 + 0.1, f*10 + 0.1 FROM t1 LEFT JOIN t2 ON (c=d)
+ UNION ALL
+ SELECT a*100, b*100 FROM t1
+ ) WHERE y+x NOT NULL ORDER BY 1;
+ }
+ } {6 18 30 260.2 600 1800 3000}
+}
+
+finish_test
diff --git a/test/selectC.test b/test/selectC.test
new file mode 100644
index 0000000..63851ca
--- /dev/null
+++ b/test/selectC.test
@@ -0,0 +1,270 @@
+# 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
+set testprefix selectC
+
+# 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&&compound {
+ 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}
+
+#-------------------------------------------------------------------------
+# Test that the problem in ticket #190c2507 has been fixed.
+#
+do_execsql_test 5.0 {
+ CREATE TABLE x1(a);
+ CREATE TABLE x2(b);
+ CREATE TABLE x3(c);
+ CREATE VIEW vvv AS SELECT b FROM x2 ORDER BY 1;
+
+ INSERT INTO x1 VALUES('a'), ('b');
+ INSERT INTO x2 VALUES(22), (23), (25), (24), (21);
+ INSERT INTO x3 VALUES(302), (303), (301);
+}
+
+do_execsql_test 5.1 {
+ CREATE TABLE x4 AS SELECT b FROM vvv UNION ALL SELECT c from x3;
+ SELECT * FROM x4;
+} {21 22 23 24 25 302 303 301}
+
+do_execsql_test 5.2 {
+ SELECT * FROM x1, x4
+} {
+ a 21 a 22 a 23 a 24 a 25 a 302 a 303 a 301
+ b 21 b 22 b 23 b 24 b 25 b 302 b 303 b 301
+}
+
+do_execsql_test 5.3 {
+ SELECT * FROM x1, (SELECT b FROM vvv UNION ALL SELECT c from x3) ORDER BY 1,2;
+} {
+ a 21 a 22 a 23 a 24 a 25 a 301 a 302 a 303
+ b 21 b 22 b 23 b 24 b 25 b 301 b 302 b 303
+}
+
+finish_test
diff --git a/test/selectD.test b/test/selectD.test
new file mode 100644
index 0000000..818d8cc
--- /dev/null
+++ b/test/selectD.test
@@ -0,0 +1,174 @@
+# 2012 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 name resolution in SELECT
+# statements that have parenthesized FROM clauses.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+for {set i 1} {$i<=2} {incr i} {
+ db close
+ forcedelete test$i.db
+ sqlite3 db test$i.db
+ if {$i==2} {
+ optimization_control db query-flattener off
+ }
+ do_test selectD-$i.0 {
+ db eval {
+ ATTACH ':memory:' AS aux1;
+ CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(111,'x1');
+ CREATE TABLE t2(a,b); INSERT INTO t2 VALUES(222,'x2');
+ CREATE TEMP TABLE t3(a,b); INSERT INTO t3 VALUES(333,'x3');
+ CREATE TABLE main.t4(a,b); INSERT INTO main.t4 VALUES(444,'x4');
+ CREATE TABLE aux1.t4(a,b); INSERT INTO aux1.t4 VALUES(555,'x5');
+ }
+ } {}
+ do_test selectD-$i.1 {
+ db eval {
+ SELECT *
+ FROM (t1), (t2), (t3), (t4)
+ WHERE t4.a=t3.a+111
+ AND t3.a=t2.a+111
+ AND t2.a=t1.a+111;
+ }
+ } {111 x1 222 x2 333 x3 444 x4}
+ do_test selectD-$i.2.1 {
+ db eval {
+ SELECT *
+ FROM t1 JOIN (t2 JOIN (t3 JOIN t4 ON t4.a=t3.a+111)
+ ON t3.a=t2.a+111)
+ ON t2.a=t1.a+111;
+ }
+ } {111 x1 222 x2 333 x3 444 x4}
+ do_test selectD-$i.2.2 {
+ db eval {
+ SELECT t3.a
+ FROM t1 JOIN (t2 JOIN (t3 JOIN t4 ON t4.a=t3.a+111)
+ ON t3.a=t2.a+111)
+ ON t2.a=t1.a+111;
+ }
+ } {333}
+ do_test selectD-$i.2.3 {
+ db eval {
+ SELECT t3.*
+ FROM t1 JOIN (t2 JOIN (t3 JOIN t4 ON t4.a=t3.a+111)
+ ON t3.a=t2.a+111)
+ ON t2.a=t1.a+111;
+ }
+ } {333 x3}
+ do_test selectD-$i.2.3 {
+ db eval {
+ SELECT t3.*, t2.*
+ FROM t1 JOIN (t2 JOIN (t3 JOIN t4 ON t4.a=t3.a+111)
+ ON t3.a=t2.a+111)
+ ON t2.a=t1.a+111;
+ }
+ } {333 x3 222 x2}
+ do_test selectD-$i.2.4 {
+ db eval {
+ SELECT *
+ FROM t1 JOIN (t2 JOIN (main.t4 JOIN aux1.t4 ON aux1.t4.a=main.t4.a+111)
+ ON main.t4.a=t2.a+222)
+ ON t2.a=t1.a+111;
+ }
+ } {111 x1 222 x2 444 x4 555 x5}
+ do_test selectD-$i.2.5 {
+ db eval {
+ SELECT *
+ FROM t1 JOIN (t2 JOIN (main.t4 AS x JOIN aux1.t4 ON aux1.t4.a=x.a+111)
+ ON x.a=t2.a+222)
+ ON t2.a=t1.a+111;
+ }
+ } {111 x1 222 x2 444 x4 555 x5}
+ do_test selectD-$i.2.6 {
+ catchsql {
+ SELECT *
+ FROM t1 JOIN (t2 JOIN (main.t4 JOIN aux.t4 ON aux.t4.a=main.t4.a+111)
+ ON main.t4.a=t2.a+222)
+ ON t2.a=t1.a+111;
+ }
+ } {1 {no such table: aux.t4}}
+ do_test selectD-$i.2.7 {
+ db eval {
+ SELECT x.a, y.b
+ FROM t1 JOIN (t2 JOIN (main.t4 x JOIN aux1.t4 y ON y.a=x.a+111)
+ ON x.a=t2.a+222)
+ ON t2.a=t1.a+111;
+ }
+ } {444 x5}
+ do_test selectD-$i.3 {
+ db eval {
+ UPDATE t2 SET a=111;
+ UPDATE t3 SET a=111;
+ UPDATE t4 SET a=111;
+ SELECT *
+ FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING(a)) USING (a)) USING (a);
+ }
+ } {111 x1 x2 x3 x4}
+ do_test selectD-$i.4 {
+ db eval {
+ UPDATE t2 SET a=111;
+ UPDATE t3 SET a=111;
+ UPDATE t4 SET a=111;
+ SELECT *
+ FROM t1 LEFT JOIN (t2 LEFT JOIN (t3 LEFT JOIN t4 USING(a))
+ USING (a))
+ USING (a);
+ }
+ } {111 x1 x2 x3 x4}
+ do_test selectD-$i.5 {
+ db eval {
+ UPDATE t3 SET a=222;
+ UPDATE t4 SET a=222;
+ SELECT *
+ FROM (t1 LEFT JOIN t2 USING(a)) JOIN (t3 LEFT JOIN t4 USING(a))
+ ON t1.a=t3.a-111;
+ }
+ } {111 x1 x2 222 x3 x4}
+ do_test selectD-$i.6 {
+ db eval {
+ UPDATE t4 SET a=333;
+ SELECT *
+ FROM (t1 LEFT JOIN t2 USING(a)) JOIN (t3 LEFT JOIN t4 USING(a))
+ ON t1.a=t3.a-111;
+ }
+ } {111 x1 x2 222 x3 {}}
+ do_test selectD-$i.7 {
+ db eval {
+ SELECT t1.*, t2.*, t3.*, t4.b
+ FROM (t1 LEFT JOIN t2 USING(a)) JOIN (t3 LEFT JOIN t4 USING(a))
+ ON t1.a=t3.a-111;
+ }
+ } {111 x1 111 x2 222 x3 {}}
+}
+
+# The following test was added on 2013-04-24 in order to verify that
+# the datatypes and affinities of sub-sub-queries are set prior to computing
+# the datatypes and affinities of the parent sub-queries because the
+# latter computation depends on the former.
+#
+do_execsql_test selectD-4.1 {
+ CREATE TABLE t41(a INTEGER PRIMARY KEY, b INTEGER);
+ CREATE TABLE t42(d INTEGER PRIMARY KEY, e INTEGER);
+ CREATE TABLE t43(f INTEGER PRIMARY KEY, g INTEGER);
+ EXPLAIN QUERY PLAN
+ SELECT *
+ FROM t41
+ LEFT JOIN (SELECT count(*) AS cnt, x1.d
+ FROM (t42 INNER JOIN t43 ON d=g) AS x1
+ WHERE x1.d>5
+ GROUP BY x1.d) AS x2
+ ON t41.b=x2.d;
+} {/SEARCH x2 USING AUTOMATIC/}
+
+finish_test
diff --git a/test/selectE.test b/test/selectE.test
new file mode 100644
index 0000000..1cabeff
--- /dev/null
+++ b/test/selectE.test
@@ -0,0 +1,100 @@
+# 2013-05-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 compound SELECT statements
+# that have ORDER BY clauses with collating sequences that differ
+# from the collating sequence used for comparison in the compound.
+#
+# Ticket 6709574d2a8d8b9be3a9cb1afbf4ff2de48ea4e7:
+# drh added on 2013-05-06 15:21:16:
+#
+# In the code shown below (which is intended to be run from the
+# sqlite3.exe command-line tool) the three SELECT statements should all
+# generate the same answer. But the third one does not. It is as if the
+# COLLATE clause on the ORDER BY somehow got pulled into the EXCEPT
+# operator. Note that the ".print" commands are instructions to the
+# sqlite3.exe shell program to output delimiter lines so that you can more
+# easily tell where the output of one query ends and the next query
+# begins.
+#
+# CREATE TABLE t1(a);
+# INSERT INTO t1 VALUES('abc'),('def');
+# CREATE TABLE t2(a);
+# INSERT INTO t2 VALUES('DEF');
+#
+# SELECT a FROM t1 EXCEPT SELECT a FROM t2 ORDER BY a;
+# .print -----
+# SELECT a FROM (SELECT a FROM t1 EXCEPT SELECT a FROM t2)
+# ORDER BY a COLLATE nocase;
+# .print -----
+# SELECT a FROM t1 EXCEPT SELECT a FROM t2 ORDER BY a COLLATE nocase;
+#
+# Bisecting shows that this problem was introduced in SQLite version 3.6.0
+# by check-in [8bbfa97837a74ef] on 2008-06-15.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test selectE-1.0 {
+ db eval {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES('abc'),('def'),('ghi');
+ CREATE TABLE t2(a);
+ INSERT INTO t2 VALUES('DEF'),('abc');
+ CREATE TABLE t3(a);
+ INSERT INTO t3 VALUES('def'),('jkl');
+
+ SELECT a FROM t1 EXCEPT SELECT a FROM t2
+ ORDER BY a COLLATE nocase;
+ }
+} {def ghi}
+do_test selectE-1.1 {
+ db eval {
+ SELECT a FROM t2 EXCEPT SELECT a FROM t3
+ ORDER BY a COLLATE nocase;
+ }
+} {abc DEF}
+do_test selectE-1.2 {
+ db eval {
+ SELECT a FROM t2 EXCEPT SELECT a FROM t3
+ ORDER BY a COLLATE binary;
+ }
+} {DEF abc}
+do_test selectE-1.3 {
+ db eval {
+ SELECT a FROM t2 EXCEPT SELECT a FROM t3
+ ORDER BY a;
+ }
+} {DEF abc}
+
+do_test selectE-2.1 {
+ db eval {
+ DELETE FROM t2;
+ DELETE FROM t3;
+ INSERT INTO t2 VALUES('ABC'),('def'),('GHI'),('jkl');
+ INSERT INTO t3 SELECT lower(a) FROM t2;
+ SELECT a COLLATE nocase FROM t2 EXCEPT SELECT a FROM t3
+ ORDER BY 1
+ }
+} {}
+do_test selectE-2.2 {
+ db eval {
+ SELECT a COLLATE nocase FROM t2 EXCEPT SELECT a FROM t3
+ ORDER BY 1 COLLATE binary
+ }
+} {}
+
+do_catchsql_test selectE-3.1 {
+ SELECT 1 EXCEPT SELECT 2 ORDER BY 1 COLLATE nocase EXCEPT SELECT 3;
+} {1 {ORDER BY clause should come after EXCEPT not before}}
+
+
+finish_test
diff --git a/test/selectF.test b/test/selectF.test
new file mode 100644
index 0000000..3fb226e
--- /dev/null
+++ b/test/selectF.test
@@ -0,0 +1,49 @@
+# 2014-03-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 verifies that an OP_Copy operation is used instead of OP_SCopy
+# in a compound select in a case where the source register might be changed
+# before the copy is used.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix selectF
+
+do_execsql_test 1 {
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO "t1" VALUES(1,'one','I');
+ CREATE TABLE t2(d, e, f);
+ INSERT INTO "t2" VALUES(5,'ten','XX');
+ INSERT INTO "t2" VALUES(6,NULL,NULL);
+
+ CREATE INDEX i1 ON t1(b, a);
+ COMMIT;
+}
+
+#explain_i {
+# SELECT * FROM t2
+# UNION ALL
+# SELECT * FROM t1 WHERE a<5
+# ORDER BY 2, 1
+#}
+
+do_execsql_test 2 {
+ SELECT * FROM t2
+ UNION ALL
+ SELECT * FROM t1 WHERE a<5
+ ORDER BY 2, 1
+} {6 {} {} 1 one I 5 ten XX}
+
+
+
+finish_test
diff --git a/test/selectG.test b/test/selectG.test
new file mode 100644
index 0000000..fab4c4e
--- /dev/null
+++ b/test/selectG.test
@@ -0,0 +1,59 @@
+# 2015-01-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 verifies that INSERT operations with a very large number of
+# VALUE terms works and does not hit the SQLITE_LIMIT_COMPOUND_SELECT limit.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix selectG
+
+# Do an INSERT with a VALUES clause that contains 100,000 entries. Verify
+# that this insert happens quickly (in less than 10 seconds). Actually, the
+# insert will normally happen in less than 0.5 seconds on a workstation, but
+# we allow plenty of overhead for slower machines. The speed test checks
+# for an O(N*N) inefficiency that was once in the code and that would make
+# the insert run for over a minute.
+#
+do_test 100 {
+ set sql "CREATE TABLE t1(x);\nINSERT INTO t1(x) VALUES"
+ for {set i 1} {$i<100000} {incr i} {
+ append sql "($i),"
+ }
+ append sql "($i);"
+ set microsec [lindex [time {db eval $sql}] 0]
+ db eval {
+ SELECT count(x), sum(x), avg(x), $microsec<10000000 FROM t1;
+ }
+} {100000 5000050000 50000.5 1}
+
+# 2018-01-14. A 100K-entry VALUES clause within a scalar expression does
+# not cause processor stack overflow.
+#
+do_test 110 {
+ set sql "SELECT (VALUES"
+ for {set i 1} {$i<100000} {incr i} {
+ append sql "($i),"
+ }
+ append sql "($i));"
+ db eval $sql
+} {1}
+
+# Only the left-most term of a multi-valued VALUES within a scalar
+# expression is evaluated.
+#
+do_test 120 {
+ set n [llength [split [db eval "explain $sql"] \n]]
+ expr {$n<10}
+} {1}
+
+finish_test
diff --git a/test/server1.test b/test/server1.test
new file mode 100644
index 0000000..c809217
--- /dev/null
+++ b/test/server1.test
@@ -0,0 +1,180 @@
+# 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
+}
+
+# This test does not work on older PPC Macs due to problems in the
+# pthreads library. So skip it.
+#
+if {$tcl_platform(machine)=="Power Macintosh" &&
+ $tcl_platform(byteOrder)=="bigEndian"} {
+ 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/session.test b/test/session.test
new file mode 100644
index 0000000..4fd1ec0
--- /dev/null
+++ b/test/session.test
@@ -0,0 +1,22 @@
+# 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 session {
+ # First run tests with sqlite3_extended_error_codes() set, then
+ # again with it clear.
+ run_test_suite session_eec
+ run_test_suite session
+ run_test_suite session_strm
+}
+
+finish_test
diff --git a/test/sessionfuzz-data1.db b/test/sessionfuzz-data1.db
new file mode 100644
index 0000000..df10e10
--- /dev/null
+++ b/test/sessionfuzz-data1.db
Binary files differ
diff --git a/test/sessionfuzz.c b/test/sessionfuzz.c
new file mode 100644
index 0000000..d8cc1be
--- /dev/null
+++ b/test/sessionfuzz.c
@@ -0,0 +1,1023 @@
+/*
+** 2018-03-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 file implements a program used for fuzz-testing the session
+** module.
+**
+** Usage:
+**
+** sessionfuzz setup -- Generate starter test cases
+** sessionfuzz run FILE ... -- Run a test fuzz on FILE
+** sesssiofuzz run SQLAR ... -- Run all test cases in the SQL Archive
+**
+** Compiling:
+**
+** (1) Have a version of SQLite that supports SQLITE_ENABLE_MEMDB
+** in the local directory.
+** (2) Run:
+**
+** gcc -Wall -O3 -o sessionfuzz sessionfuzz.c -lz
+**
+** Use with AFL (American Fuzzy Lop - http://lcamtuf.coredump.cx/afl/)
+**
+** (1) ./afl-gcc -O3 -o sessionfuzz sessionfuzz.c -lz
+** (2) mkdir session-init session-run session-cases
+** (3) cd session-init; ../sessionfuzz setup; cd ..
+** (4) ./afl -i session-init -o session-run -- ./sessionfuzz run @@
+** ... let the previous step run for a while. Weeks, maybe.
+** (5) ./afl-cmin -i session-run -o session-cases
+**
+** The afl-cmin command on step (5) writes a minimal set of test cases
+** for coverage into the session-cases directory. Gather the cases written
+** there into an SQL Archive using a command like this:
+**
+** sqlite3 session-cases.db -Ac session-cases
+**
+** Then repeat the test using:
+**
+** ./sessionfuzz run session-cases.db
+*/
+
+/*
+** We will import the entire SQLite source file to make compiling easier
+*/
+#ifdef SQLITE_DEBUG
+#undef SQLITE_DEBUG
+#endif
+
+#ifdef SQLITE_THREADSAFE
+#undef SQLITE_THREADSAFE
+#endif
+
+#define SQLITE_DEBUG 1
+#define SQLITE_THREADSAFE 0
+#define SQLITE_OMIT_LOAD_EXTENSION 0
+#define SQLITE_ENABLE_SESSION 1
+#define SQLITE_ENABLE_PREUPDATE_HOOK 1
+#define SQLITE_ENABLE_DESERIALIZE 1
+#include "sqlite3.c"
+
+/* Create a test database. This will be an in-memory database */
+static const char zInitSql[] =
+ "CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);\n"
+ "CREATE TABLE t2(e TEXT PRIMARY KEY NOT NULL,f,g);\n"
+ "CREATE TABLE t3(w REAL PRIMARY KEY NOT NULL,x,y);\n"
+ "CREATE TABLE t4(z PRIMARY KEY) WITHOUT ROWID;\n"
+;
+
+/* Code to populate the database */
+static const char zFillSql[] =
+ "INSERT INTO t1(a,b,c,d) VALUES\n"
+ " (1,2,3,4),\n"
+ " (2,3.5,'four',x'556677'),\n"
+ " (3,null,'xyz',15),\n"
+ " (4,'bubba',0x80000000,0.0);\n"
+ "INSERT INTO t1 SELECT a+4,c,d,b FROM t1;\n"
+ "INSERT INTO t1 SELECT a+8,d,b,c FROM t1;\n"
+ "INSERT INTO t1 SELECT a+16,d,c,b FROM t1;\n"
+ "INSERT INTO t1 SELECT a+32,b,d,c FROM t1;\n"
+ "INSERT INTO t2 SELECT printf('x%dy',a),b,c FROM t1;\n"
+ "INSERT INTO t3 SELECT a*1.1,b,c FROM t1;\n"
+ "INSERT INTO t4 SELECT a||','||quote(b) FROM t1;\n"
+;
+
+/* A database file created by running the two scripts above */
+static const unsigned char aDbBytes[] = {
+ 83, 81, 76,105,116,101, 32,102,111,114,109, 97,116, 32, 51, 0, 2, 0, 1,
+ 1, 0, 64, 32, 32, 0, 0, 0, 13, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 13, 0, 46, 32,152, 13, 1,186, 0, 6, 0,176, 0, 1,194, 1, 84, 1,150,
+ 0,238, 1, 48, 0,176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 60, 6, 6, 23, 17, 17, 1,101,116, 97, 98,108,101,116,
+ 52,116, 52, 7, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 52,
+ 40,122, 32, 80, 82, 73, 77, 65, 82, 89, 32, 75, 69, 89, 41, 32, 87, 73, 84,
+ 72, 79, 85, 84, 32, 82, 79, 87, 73, 68, 64, 4, 6, 23, 17, 17, 1,109,116,
+ 97, 98,108,101,116, 51,116, 51, 5, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66,
+ 76, 69, 32,116, 51, 40,119, 32, 82, 69, 65, 76, 32, 80, 82, 73, 77, 65, 82,
+ 89, 32, 75, 69, 89, 32, 78, 79, 84, 32, 78, 85, 76, 76, 44,120, 44,121, 41,
+ 34, 5, 5, 23, 55, 17, 1,105,110,100,101,120,115,113,108,105,116,101, 95,
+ 97,117,116,111,105,110,100,101,120, 95,116, 51, 95, 49,116, 51, 6, 64, 2,
+ 6, 23, 17, 17, 1,109,116, 97, 98,108,101,116, 50,116, 50, 3, 67, 82, 69,
+ 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 50, 40,101, 32, 84, 69, 88, 84,
+ 32, 80, 82, 73, 77, 65, 82, 89, 32, 75, 69, 89, 32, 78, 79, 84, 32, 78, 85,
+ 76, 76, 44,102, 44,103, 41, 34, 3, 5, 23, 55, 17, 1,105,110,100,101,120,
+ 115,113,108,105,116,101, 95, 97,117,116,111,105,110,100,101,120, 95,116, 50,
+ 95, 49,116, 50, 4, 0, 0, 0, 8, 0, 0, 0, 0, 60, 1, 6, 23, 17, 17,
+ 1,101,116, 97, 98,108,101,116, 49,116, 49, 2, 67, 82, 69, 65, 84, 69, 32,
+ 84, 65, 66, 76, 69, 32,116, 49, 40, 97, 32, 73, 78, 84, 69, 71, 69, 82, 32,
+ 80, 82, 73, 77, 65, 82, 89, 32, 75, 69, 89, 44, 98, 44, 99, 44,100, 41, 5,
+ 0, 0, 0, 2, 1,246, 0, 0, 0, 0, 10, 1,251, 1,246, 1,177, 1,155,
+ 1,145, 1,119, 1,109, 1, 87, 1, 76, 1, 50, 1, 40, 1, 18, 1, 7, 0,
+ 237, 0,227, 0,205, 0,195, 0,169, 0,159, 0,137, 0,126, 0,100, 0, 90,
+ 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 20, 26, 5, 0, 21, 7, 18,102,111,
+ 117,114, 64, 12, 0, 0, 0, 0, 0, 0, 85,102,119, 8, 25, 5, 0, 1, 1,
+ 1, 3, 2, 4, 24, 24, 5, 0, 23, 7, 5, 98,117, 98, 98, 97, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 9, 23, 5, 0, 0, 1, 19, 15,
+ 120,121,122, 20, 22, 5, 0, 7, 18, 21, 64, 12, 0, 0, 0, 0, 0, 0, 85,
+ 102,119,102,111,117,114, 8, 21, 5, 0, 1, 1, 1, 2, 4, 3, 24, 20, 5,
+ 0, 7, 5, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 98,
+ 117, 98, 98, 97, 8, 19, 4, 0, 1, 19, 15,120,121,122, 20, 18, 5, 0, 18,
+ 21, 7, 85,102,119,102,111,117,114, 64, 12, 0, 0, 0, 0, 0, 0, 8, 17,
+ 5, 0, 1, 1, 1, 4, 3, 2, 24, 16, 5, 0, 23, 5, 7, 98,117, 98, 98,
+ 97, 0, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 15, 5, 0,
+ 0, 19, 1,120,121,122, 15, 20, 14, 5, 0, 7, 21, 18, 64, 12, 0, 0, 0,
+ 0, 0, 0,102,111,117,114, 85,102,119, 8, 13, 5, 0, 1, 1, 1, 2, 3,
+ 4, 24, 12, 5, 0, 7, 23, 5, 0, 0, 0, 0, 0, 0, 0, 0, 98,117, 98,
+ 98, 97, 0, 0,128, 0, 0, 0, 9, 11, 5, 0, 1, 0, 19, 15,120,121,122,
+ 20, 10, 5, 0, 18, 7, 21, 85,102,119, 64, 12, 0, 0, 0, 0, 0, 0,102,
+ 111,117,114, 8, 9, 5, 0, 1, 1, 1, 4, 2, 3, 24, 8, 5, 0, 5, 7,
+ 23, 0, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98,
+ 97, 8, 7, 4, 0, 19, 1,120,121,122, 15, 20, 6, 5, 0, 21, 18, 7,102,
+ 111,117,114, 85,102,119, 64, 12, 0, 0, 0, 0, 0, 0, 8, 5, 5, 0, 1,
+ 1, 1, 3, 4, 2, 24, 4, 5, 0, 23, 5, 7, 98,117, 98, 98, 97, 0, 0,
+ 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 3, 5, 0, 0, 19, 1,
+ 120,121,122, 15, 20, 2, 5, 0, 7, 21, 18, 64, 12, 0, 0, 0, 0, 0, 0,
+ 102,111,117,114, 85,102,119, 0, 0, 0, 9, 52, 0, 0, 0, 8, 26, 5, 0,
+ 0, 0, 2, 1,246, 0, 0, 0, 0, 13, 1,251, 1,246, 1,181, 1,165, 1,
+ 152, 1,129, 1,118, 1, 97, 1, 87, 1, 64, 1, 52, 1, 30, 1, 17, 0,252,
+ 0,240, 0,223, 0,209, 0,185, 0,173, 0,152, 0,141, 0,118, 0,106, 0,
+ 84, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 27, 3, 21, 19,120,
+ 50, 55,121,120,121,122, 20, 26, 4, 21, 21, 7,120, 50, 54,121,102,111,117,
+ 114, 64, 12, 0, 0, 0, 0, 0, 0, 10, 25, 4, 21, 1, 1,120, 50, 53,121,
+ 3, 2, 21, 24, 4, 21, 23, 7,120, 50, 52,121, 98,117, 98, 98, 97, 0, 0,
+ 0, 0, 0, 0, 0, 0, 9, 23, 4, 21, 0, 1,120, 50, 51,121, 15, 19, 22,
+ 4, 21, 7, 18,120, 50, 50,121, 64, 12, 0, 0, 0, 0, 0, 0, 85,102,119,
+ 10, 21, 4, 21, 1, 1,120, 50, 49,121, 2, 4, 22, 20, 4, 21, 7, 5,120,
+ 50, 48,121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 12, 19,
+ 4, 21, 1, 19,120, 49, 57,121, 15,120,121,122, 15, 18, 4, 21, 18, 21,120,
+ 49, 56,121, 85,102,119,102,111,117,114, 10, 17, 4, 21, 1, 1,120, 49, 55,
+ 121, 4, 3, 19, 16, 4, 21, 23, 5,120, 49, 54,121, 98,117, 98, 98, 97, 0,
+ 0,128, 0, 0, 0, 11, 15, 4, 21, 0, 19,120, 49, 53,121,120,121,122, 20,
+ 14, 4, 21, 7, 21,120, 49, 52,121, 64, 12, 0, 0, 0, 0, 0, 0,102,111,
+ 117,114, 10, 13, 4, 21, 1, 1,120, 49, 51,121, 2, 3, 21, 12, 4, 21, 7,
+ 23,120, 49, 50,121, 0, 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 8,
+ 11, 3, 21, 1,120, 49, 49,121, 15, 19, 10, 4, 21, 18, 7,120, 49, 48,121,
+ 85,102,119, 64, 12, 0, 0, 0, 0, 0, 0, 9, 9, 4, 19, 1, 1,120, 57,
+ 121, 4, 2, 21, 8, 4, 19, 5, 7,120, 56,121, 0, 0,128, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 11, 7, 4, 19, 19, 1,120, 55,121,120,121,122,
+ 15, 14, 6, 4, 19, 21, 18,120, 54,121,102,111,117,114, 85,102,119, 9, 5,
+ 4, 19, 1, 1,120, 53,121, 3, 4, 18, 4, 4, 19, 23, 5,120, 52,121, 98,
+ 117, 98, 98, 97, 0, 0,128, 0, 0, 0, 10, 3, 4, 19, 0, 19,120, 51,121,
+ 120,121,122, 19, 2, 4, 19, 7, 21,120, 50,121, 64, 12, 0, 0, 0, 0, 0,
+ 0,102,111,117,114, 9, 0, 0, 0, 12, 53, 0, 0, 0, 11, 27, 2, 0, 0,
+ 0, 1, 1,243, 0, 0, 0, 0, 15, 1,243, 1,220, 1,211, 1,202, 1,193,
+ 1,184, 1,175, 1,166, 1,159, 1,150, 1,141, 1,132, 1,123, 1,114, 1,
+ 105, 1, 96, 1, 87, 1, 78, 1, 69, 1, 61, 1, 52, 1, 43, 1, 34, 1, 25,
+ 1, 16, 1, 7, 0,254, 0,245, 0,236, 0,227, 0,219, 0,210, 0,201, 0,
+ 192, 0,183, 0,174, 0,165, 0,156, 0,147, 0,138, 0,129, 0,121, 0,112,
+ 0,103, 0, 0, 0, 8, 3, 21, 1,120, 53, 49,121, 51, 8, 3, 21, 1,120,
+ 53, 48,121, 50, 7, 3, 19, 1,120, 52,121, 4, 8, 3, 21, 1,120, 52, 57,
+ 121, 49, 8, 3, 21, 1,120, 52, 56,121, 48, 8, 3, 21, 1,120, 52, 55,121,
+ 47, 8, 3, 21, 1,120, 52, 54,121, 46, 8, 3, 21, 1,120, 52, 53,121, 45,
+ 8, 3, 21, 1,120, 52, 52,121, 44, 8, 3, 21, 1,120, 52, 51,121, 43, 8,
+ 3, 21, 1,120, 52, 50,121, 42, 8, 3, 21, 1,120, 52, 49,121, 41, 8, 3,
+ 21, 1,120, 52, 48,121, 40, 7, 3, 19, 1,120, 51,121, 3, 8, 3, 21, 1,
+ 120, 51, 57,121, 39, 8, 3, 21, 1,120, 51, 56,121, 38, 8, 3, 21, 1,120,
+ 51, 55,121, 37, 8, 3, 21, 1,120, 51, 54,121, 36, 8, 3, 21, 1,120, 51,
+ 53,121, 35, 8, 3, 21, 1,120, 51, 52,121, 34, 8, 3, 21, 1,120, 51, 51,
+ 121, 33, 8, 3, 21, 1,120, 51, 50,121, 32, 8, 3, 21, 1,120, 51, 49,121,
+ 31, 8, 3, 21, 1,120, 51, 48,121, 30, 7, 3, 19, 1,120, 50,121, 2, 8,
+ 3, 21, 1,120, 50, 57,121, 29, 8, 3, 21, 1,120, 50, 56,121, 28, 8, 3,
+ 21, 1,120, 50, 55,121, 27, 8, 3, 21, 1,120, 50, 54,121, 26, 8, 3, 21,
+ 1,120, 50, 53,121, 25, 8, 3, 21, 1,120, 50, 52,121, 24, 8, 3, 21, 1,
+ 120, 50, 51,121, 23, 8, 3, 21, 1,120, 50, 50,121, 22, 8, 3, 21, 1,120,
+ 50, 49,121, 21, 8, 3, 21, 1,120, 50, 48,121, 20, 6, 3, 19, 9,120, 49,
+ 121, 8, 3, 21, 1,120, 49, 57,121, 19, 8, 3, 21, 1,120, 49, 56,121, 18,
+ 8, 3, 21, 1,120, 49, 55,121, 17, 8, 3, 21, 1,120, 49, 54,121, 16, 8,
+ 3, 21, 1,120, 49, 53,121, 15, 8, 3, 21, 1,120, 49, 52,121, 14, 8, 3,
+ 21, 1,120, 49, 51,121, 13, 8, 3, 21, 1,120, 49, 50,121, 12, 8, 3, 21,
+ 1,120, 0, 0, 0, 14, 8, 3, 21, 1,120, 53, 49,121, 51, 5, 0, 0, 0,
+ 2, 1,246, 0, 0, 0, 0, 18, 1,251, 1,246, 1,156, 1,135, 1,117, 1,
+ 89, 1, 73, 1, 55, 1, 41, 1, 14, 0,254, 0,228, 0,211, 0,186, 0,170,
+ 0,149, 0,131, 0,110, 0, 94, 0, 69, 0, 54, 13, 23, 4, 7, 0, 1, 64,
+ 57, 76,204,204,204,204,205, 15, 23, 22, 4, 7, 7, 18, 64, 56, 51, 51, 51,
+ 51, 51, 52, 64, 12, 0, 0, 0, 0, 0, 0, 85,102,119, 14, 21, 4, 7, 1,
+ 1, 64, 55, 25,153,153,153,153,154, 2, 4, 19, 20, 4, 1, 7, 5, 22, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 16, 19, 4, 7, 1, 19,
+ 64, 52,230,102,102,102,102,103, 15,120,121,122, 19, 18, 4, 7, 18, 21, 64,
+ 51,204,204,204,204,204,205, 85,102,119,102,111,117,114, 14, 17, 4, 7, 1,
+ 1, 64, 50,179, 51, 51, 51, 51, 52, 4, 3, 23, 16, 4, 7, 23, 5, 64, 49,
+ 153,153,153,153,153,154, 98,117, 98, 98, 97, 0, 0,128, 0, 0, 0, 15, 15,
+ 4, 7, 0, 19, 64, 48,128, 0, 0, 0, 0, 0,120,121,122, 24, 14, 4, 7,
+ 7, 21, 64, 46,204,204,204,204,204,206, 64, 12, 0, 0, 0, 0, 0, 0,102,
+ 111,117,114, 14, 13, 4, 7, 1, 1, 64, 44,153,153,153,153,153,154, 2, 3,
+ 25, 12, 4, 7, 7, 23, 64, 42,102,102,102,102,102,103, 0, 0, 0, 0, 0,
+ 0, 0, 0, 98,117, 98, 98, 97, 12, 11, 3, 7, 1, 64, 40, 51, 51, 51, 51,
+ 51, 52, 15, 16, 10, 4, 1, 18, 7, 11, 85,102,119, 64, 12, 0, 0, 0, 0,
+ 0, 0, 14, 9, 4, 7, 1, 1, 64, 35,204,204,204,204,204,205, 4, 2, 26,
+ 8, 4, 7, 5, 7, 64, 33,153,153,153,153,153,154, 0, 0,128, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 16, 7, 4, 7, 19, 1, 64, 30,204,204,204,
+ 204,204,206,120,121,122, 15, 19, 6, 4, 7, 21, 18, 64, 26,102,102,102,102,
+ 102,103,102,111,117,114, 85,102,119, 14, 5, 4, 7, 1, 1, 64, 22, 0, 0,
+ 0, 0, 0, 0, 3, 4, 23, 4, 4, 7, 23, 5, 64, 17,153,153,153,153,153,
+ 154, 98,117, 98, 98, 97, 0, 0,128, 0, 0, 0, 15, 3, 4, 7, 0, 19, 64,
+ 10,102,102,102,102,102,103,120,121,122, 24, 2, 4, 7, 7, 21, 64, 1,153,
+ 153,153,153,153,154, 64, 12, 0, 0, 0, 0, 0, 0,102,111,117,114, 14, 1,
+ 4, 7, 1, 1, 0, 0, 0, 17, 45, 0, 0, 0, 16, 23, 2, 0, 0, 0, 1,
+ 1,239, 0, 0, 0, 0, 20, 1,239, 1,205, 1,192, 1,179, 1,166, 1,153,
+ 1,140, 1,134, 1,121, 1,108, 1, 95, 1, 82, 1, 69, 1, 56, 1, 43, 1,
+ 30, 1, 17, 1, 11, 0,254, 0,241, 0,228, 0,215, 0,202, 0,189, 0,176,
+ 0,163, 0,150, 0,144, 0,131, 0,118, 0,105, 0, 92, 0, 79, 0, 12, 3,
+ 7, 1, 64, 67, 64, 0, 0, 0, 0, 0, 35, 12, 3, 7, 1, 64, 66,179, 51,
+ 51, 51, 51, 52, 34, 12, 3, 7, 1, 64, 66, 38,102,102,102,102,103, 33, 12,
+ 3, 7, 1, 64, 65,153,153,153,153,153,154, 32, 12, 3, 7, 1, 64, 65, 12,
+ 204,204,204,204,205, 31, 5, 3, 1, 1, 33, 30, 12, 3, 7, 1, 64, 63,230,
+ 102,102,102,102,103, 29, 12, 3, 7, 1, 64, 62,204,204,204,204,204,206, 28,
+ 12, 3, 7, 1, 64, 61,179, 51, 51, 51, 51, 52, 27, 12, 3, 7, 1, 64, 60,
+ 153,153,153,153,153,154, 26, 12, 3, 7, 1, 64, 59,128, 0, 0, 0, 0, 1,
+ 25, 12, 3, 7, 1, 64, 58,102,102,102,102,102,103, 24, 12, 3, 7, 1, 64,
+ 57, 76,204,204,204,204,205, 23, 12, 3, 7, 1, 64, 56, 51, 51, 51, 51, 51,
+ 52, 22, 12, 3, 7, 1, 64, 55, 25,153,153,153,153,154, 21, 5, 3, 1, 1,
+ 22, 20, 12, 3, 7, 1, 64, 52,230,102,102,102,102,103, 19, 12, 3, 7, 1,
+ 64, 51,204,204,204,204,204,205, 18, 12, 3, 7, 1, 64, 50,179, 51, 51, 51,
+ 51, 52, 17, 12, 3, 7, 1, 64, 49,153,153,153,153,153,154, 16, 12, 3, 7,
+ 1, 64, 48,128, 0, 0, 0, 0, 0, 15, 12, 3, 7, 1, 64, 46,204,204,204,
+ 204,204,206, 14, 12, 3, 7, 1, 64, 44,153,153,153,153,153,154, 13, 12, 3,
+ 7, 1, 64, 42,102,102,102,102,102,103, 12, 12, 3, 7, 1, 64, 40, 51, 51,
+ 51, 51, 51, 52, 11, 5, 3, 1, 1, 11, 10, 12, 3, 7, 1, 64, 35,204,204,
+ 204,204,204,205, 9, 12, 3, 7, 1, 64, 33,153,153,153,153,153,154, 8, 12,
+ 3, 7, 1, 64, 30,204,204,204,204,204,206, 7, 12, 3, 7, 1, 64, 26,102,
+ 102,102,102,102,103, 6, 12, 3, 7, 1, 64, 22, 0, 0, 0, 0, 0, 0, 5,
+ 12, 3, 7, 1, 64, 17,153,153,153,153,153,154, 4, 12, 3, 7, 1, 64, 10,
+ 102,102,102,102,102,103, 3, 12, 3, 7, 1, 64, 1,153,153, 0, 0, 0, 19,
+ 12, 3, 7, 1, 64, 67, 64, 0, 0, 0, 0, 0, 35, 2, 0, 0, 0, 1, 1,
+ 242, 0, 0, 0, 0, 22, 1,242, 1,218, 1,211, 1,202, 1,192, 1,179, 1,
+ 172, 1,157, 1,149, 1,141, 1,132, 1,125, 1,116, 1,106, 1, 93, 1, 86,
+ 1, 74, 1, 63, 1, 47, 1, 40, 1, 31, 1, 16, 1, 8, 0,255, 0,248, 0,
+ 239, 0,229, 0,216, 0,209, 0,197, 0,186, 0,174, 0,158, 0,151, 0,136,
+ 0,128, 0,119, 0,112, 0,103, 0, 93, 0, 9, 2, 27, 52, 55, 44, 78, 85,
+ 76, 76, 8, 2, 25, 52, 54, 44, 51, 46, 53, 6, 2, 21, 52, 53, 44, 50, 8,
+ 2, 25, 52, 52, 44, 48, 46, 48, 7, 2, 23, 52, 51, 44, 49, 53, 14, 2, 37,
+ 52, 50, 44, 88, 39, 53, 53, 54, 54, 55, 55, 39, 6, 2, 21, 52, 49, 44, 52,
+ 15, 2, 39, 52, 48, 44, 50, 49, 52, 55, 52, 56, 51, 54, 52, 56, 11, 2, 31,
+ 52, 44, 39, 98,117, 98, 98, 97, 39, 10, 2, 29, 51, 57, 44, 39,120,121,122,
+ 39, 11, 2, 31, 51, 56, 44, 39,102,111,117,114, 39, 6, 2, 21, 51, 55, 44,
+ 51, 12, 2, 33, 51, 54, 44, 39, 98,117, 98, 98, 97, 39, 9, 2, 27, 51, 53,
+ 44, 78, 85, 76, 76, 8, 2, 25, 51, 52, 44, 51, 46, 53, 6, 2, 21, 51, 51,
+ 44, 50, 8, 2, 25, 51, 50, 44, 48, 46, 48, 7, 2, 23, 51, 49, 44, 49, 53,
+ 14, 2, 37, 51, 48, 44, 88, 39, 53, 53, 54, 54, 55, 55, 39, 8, 2, 25, 51,
+ 44, 78, 85, 76, 76, 6, 2, 21, 50, 57, 44, 52, 15, 2, 39, 50, 56, 44, 50,
+ 49, 52, 55, 52, 56, 51, 54, 52, 56, 10, 2, 29, 50, 55, 44, 39,120,121,122,
+ 39, 11, 2, 31, 50, 54, 44, 39,102,111,117,114, 39, 6, 2, 21, 50, 53, 44,
+ 51, 12, 2, 33, 50, 52, 44, 39, 98,117, 98, 98, 97, 39, 9, 2, 27, 50, 51,
+ 44, 78, 85, 76, 76, 8, 2, 25, 50, 50, 44, 51, 46, 53, 6, 2, 21, 50, 49,
+ 44, 50, 8, 2, 25, 50, 48, 44, 48, 46, 48, 7, 2, 23, 50, 44, 51, 46, 53,
+ 7, 2, 23, 49, 57, 44, 49, 53, 14, 2, 37, 49, 56, 44, 88, 39, 53, 53, 54,
+ 54, 55, 55, 39, 6, 2, 21, 49, 55, 44, 52, 12, 2, 33, 49, 54, 44, 39, 98,
+ 117, 98, 98, 97, 39, 9, 2, 27, 49, 53, 44, 78, 85, 76, 76, 8, 2, 25, 49,
+ 52, 44, 51, 46, 53, 6, 2, 21, 49, 51, 44, 50, 8, 2, 25, 49, 50, 44, 48,
+ 46, 48, 7, 2, 23, 49, 49, 44, 49, 53, 14, 2, 37, 49, 48, 44, 88, 0, 0,
+ 0, 21, 9, 2, 27, 52, 55, 44, 78, 85, 76, 76, 13, 0, 0, 0, 26, 0, 68,
+ 0, 1,246, 1,224, 1,213, 1,187, 1,177, 1,155, 1,145, 1,119, 1,109,
+ 1, 87, 1, 76, 1, 50, 1, 40, 1, 18, 1, 7, 0,237, 0,227, 0,205, 0,
+ 195, 0,169, 0,159, 0,137, 0,126, 0,100, 0, 90, 0, 68, 0, 0, 0, 0,
+ 0, 0, 0, 0, 20, 26, 5, 0, 21, 7, 18,102,111,117,114, 64, 12, 0, 0,
+ 0, 0, 0, 0, 85,102,119, 8, 25, 5, 0, 1, 1, 1, 3, 2, 4, 24, 24,
+ 5, 0, 23, 7, 5, 98,117, 98, 98, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0,128, 0, 0, 0, 9, 23, 5, 0, 0, 1, 19, 15,120,121,122, 20, 22, 5,
+ 0, 7, 18, 21, 64, 12, 0, 0, 0, 0, 0, 0, 85,102,119,102,111,117,114,
+ 8, 21, 5, 0, 1, 1, 1, 2, 4, 3, 24, 20, 5, 0, 7, 5, 23, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 98,117, 98, 98, 97, 8, 19,
+ 4, 0, 1, 19, 15,120,121,122, 20, 18, 5, 0, 18, 21, 7, 85,102,119,102,
+ 111,117,114, 64, 12, 0, 0, 0, 0, 0, 0, 8, 17, 5, 0, 1, 1, 1, 4,
+ 3, 2, 24, 16, 5, 0, 23, 5, 7, 98,117, 98, 98, 97, 0, 0,128, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 15, 5, 0, 0, 19, 1,120,121,122,
+ 15, 20, 14, 5, 0, 7, 21, 18, 64, 12, 0, 0, 0, 0, 0, 0,102,111,117,
+ 114, 85,102,119, 8, 13, 5, 0, 1, 1, 1, 2, 3, 4, 24, 12, 5, 0, 7,
+ 23, 5, 0, 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 0, 0,128, 0,
+ 0, 0, 9, 11, 5, 0, 1, 0, 19, 15,120,121,122, 20, 10, 5, 0, 18, 7,
+ 21, 85,102,119, 64, 12, 0, 0, 0, 0, 0, 0,102,111,117,114, 8, 9, 5,
+ 0, 1, 1, 1, 4, 2, 3, 24, 8, 5, 0, 5, 7, 23, 0, 0,128, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 8, 7, 4, 0, 19,
+ 1,120,121,122, 15, 20, 6, 5, 0, 21, 18, 7,102,111,117,114, 85,102,119,
+ 64, 12, 0, 0, 0, 0, 0, 0, 8, 5, 5, 0, 1, 1, 1, 3, 4, 2, 24,
+ 4, 5, 0, 23, 5, 7, 98,117, 98, 98, 97, 0, 0,128, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 9, 3, 5, 0, 0, 19, 1,120,121,122, 15, 20, 2,
+ 5, 0, 7, 21, 18, 64, 12, 0, 0, 0, 0, 0, 0,102,111,117,114, 85,102,
+ 119, 8, 1, 5, 0, 1, 1, 1, 2, 3, 4, 13, 0, 0, 0, 26, 0, 63, 0,
+ 1,245, 1,219, 1,209, 1,187, 1,177, 1,151, 1,141, 1,119, 1,108, 1,
+ 82, 1, 72, 1, 50, 1, 39, 1, 13, 1, 3, 0,237, 0,227, 0,201, 0,191,
+ 0,169, 0,158, 0,132, 0,122, 0,100, 0, 89, 0, 63, 0, 0, 0, 24, 52,
+ 5, 0, 7, 23, 5, 0, 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 0,
+ 0,128, 0, 0, 0, 9, 51, 5, 0, 1, 0, 19, 15,120,121,122, 20, 50, 5,
+ 0, 18, 7, 21, 85,102,119, 64, 12, 0, 0, 0, 0, 0, 0,102,111,117,114,
+ 8, 49, 5, 0, 1, 1, 1, 4, 2, 3, 24, 48, 5, 0, 23, 7, 5, 98,117,
+ 98, 98, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 9, 47,
+ 5, 0, 0, 1, 19, 15,120,121,122, 20, 46, 5, 0, 7, 18, 21, 64, 12, 0,
+ 0, 0, 0, 0, 0, 85,102,119,102,111,117,114, 8, 45, 5, 0, 1, 1, 1,
+ 2, 4, 3, 24, 44, 5, 0, 7, 5, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0,128, 0, 0, 0, 98,117, 98, 98, 97, 8, 43, 4, 0, 1, 19, 15,120,121,
+ 122, 20, 42, 5, 0, 18, 21, 7, 85,102,119,102,111,117,114, 64, 12, 0, 0,
+ 0, 0, 0, 0, 8, 41, 5, 0, 1, 1, 1, 4, 3, 2, 24, 40, 5, 0, 5,
+ 23, 7, 0, 0,128, 0, 0, 0, 98,117, 98, 98, 97, 0, 0, 0, 0, 0, 0,
+ 0, 0, 9, 39, 5, 0, 19, 0, 1,120,121,122, 15, 20, 38, 5, 0, 21, 7,
+ 18,102,111,117,114, 64, 12, 0, 0, 0, 0, 0, 0, 85,102,119, 8, 37, 5,
+ 0, 1, 1, 1, 3, 2, 4, 24, 36, 5, 0, 23, 7, 5, 98,117, 98, 98, 97,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 9, 35, 5, 0, 0,
+ 1, 19, 15,120,121,122, 20, 34, 5, 0, 7, 18, 21, 64, 12, 0, 0, 0, 0,
+ 0, 0, 85,102,119,102,111,117,114, 8, 33, 5, 0, 1, 1, 1, 2, 4, 3,
+ 24, 32, 5, 0, 7, 5, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0,
+ 0, 0, 98,117, 98, 98, 97, 8, 31, 4, 0, 1, 19, 15,120,121,122, 20, 30,
+ 5, 0, 18, 21, 7, 85,102,119,102,111,117,114, 64, 12, 0, 0, 0, 0, 0,
+ 0, 8, 29, 5, 0, 1, 1, 1, 4, 3, 2, 24, 28, 5, 0, 5, 23, 7, 0,
+ 0,128, 0, 0, 0, 98,117, 98, 98, 97, 0, 0, 0, 0, 0, 0, 0, 0, 9,
+ 27, 5, 0, 19, 0, 1,120,121,122, 15, 13, 0, 0, 0, 12, 1, 50, 0, 1,
+ 246, 1,224, 1,213, 1,187, 1,177, 1,155, 1,145, 1,119, 1,109, 1, 87,
+ 1, 76, 1, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 64, 5, 0, 7, 23, 5,
+ 0, 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 0, 0,128, 0, 0, 0,
+ 9, 63, 5, 0, 1, 0, 19, 15,120,121,122, 20, 62, 5, 0, 18, 7, 21, 85,
+ 102,119, 64, 12, 0, 0, 0, 0, 0, 0,102,111,117,114, 8, 61, 5, 0, 1,
+ 1, 1, 4, 2, 3, 24, 60, 5, 0, 5, 7, 23, 0, 0,128, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 8, 59, 4, 0, 19, 1,120,
+ 121,122, 15, 20, 58, 5, 0, 21, 18, 7,102,111,117,114, 85,102,119, 64, 12,
+ 0, 0, 0, 0, 0, 0, 8, 57, 5, 0, 1, 1, 1, 3, 4, 2, 24, 56, 5,
+ 0, 23, 5, 7, 98,117, 98, 98, 97, 0, 0,128, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 9, 55, 5, 0, 0, 19, 1,120,121,122, 15, 20, 54, 5, 0,
+ 7, 21, 18, 64, 12, 0, 0, 0, 0, 0, 0,102,111,117,114, 85,102,119, 8,
+ 53, 5, 0, 1, 1, 1, 2, 3, 4, 13, 0, 0, 0, 27, 0, 72, 0, 1,245,
+ 1,224, 1,212, 1,192, 1,181, 1,165, 1,152, 1,129, 1,118, 1, 97, 1,
+ 87, 1, 64, 1, 52, 1, 30, 1, 17, 0,252, 0,240, 0,223, 0,209, 0,185,
+ 0,173, 0,152, 0,141, 0,118, 0,106, 0, 84, 0, 72, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 10, 27, 3, 21, 19,120, 50, 55,121,120,121,122, 20, 26,
+ 4, 21, 21, 7,120, 50, 54,121,102,111,117,114, 64, 12, 0, 0, 0, 0, 0,
+ 0, 10, 25, 4, 21, 1, 1,120, 50, 53,121, 3, 2, 21, 24, 4, 21, 23, 7,
+ 120, 50, 52,121, 98,117, 98, 98, 97, 0, 0, 0, 0, 0, 0, 0, 0, 9, 23,
+ 4, 21, 0, 1,120, 50, 51,121, 15, 19, 22, 4, 21, 7, 18,120, 50, 50,121,
+ 64, 12, 0, 0, 0, 0, 0, 0, 85,102,119, 10, 21, 4, 21, 1, 1,120, 50,
+ 49,121, 2, 4, 22, 20, 4, 21, 7, 5,120, 50, 48,121, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,128, 0, 0, 0, 12, 19, 4, 21, 1, 19,120, 49, 57,121,
+ 15,120,121,122, 15, 18, 4, 21, 18, 21,120, 49, 56,121, 85,102,119,102,111,
+ 117,114, 10, 17, 4, 21, 1, 1,120, 49, 55,121, 4, 3, 19, 16, 4, 21, 23,
+ 5,120, 49, 54,121, 98,117, 98, 98, 97, 0, 0,128, 0, 0, 0, 11, 15, 4,
+ 21, 0, 19,120, 49, 53,121,120,121,122, 20, 14, 4, 21, 7, 21,120, 49, 52,
+ 121, 64, 12, 0, 0, 0, 0, 0, 0,102,111,117,114, 10, 13, 4, 21, 1, 1,
+ 120, 49, 51,121, 2, 3, 21, 12, 4, 21, 7, 23,120, 49, 50,121, 0, 0, 0,
+ 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 8, 11, 3, 21, 1,120, 49, 49,121,
+ 15, 19, 10, 4, 21, 18, 7,120, 49, 48,121, 85,102,119, 64, 12, 0, 0, 0,
+ 0, 0, 0, 9, 9, 4, 19, 1, 1,120, 57,121, 4, 2, 21, 8, 4, 19, 5,
+ 7,120, 56,121, 0, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11,
+ 7, 4, 19, 19, 1,120, 55,121,120,121,122, 15, 14, 6, 4, 19, 21, 18,120,
+ 54,121,102,111,117,114, 85,102,119, 9, 5, 4, 19, 1, 1,120, 53,121, 3,
+ 4, 18, 4, 4, 19, 23, 5,120, 52,121, 98,117, 98, 98, 97, 0, 0,128, 0,
+ 0, 0, 10, 3, 4, 19, 0, 19,120, 51,121,120,121,122, 19, 2, 4, 19, 7,
+ 21,120, 50,121, 64, 12, 0, 0, 0, 0, 0, 0,102,111,117,114, 9, 1, 4,
+ 19, 1, 1,120, 49,121, 2, 3, 13, 0, 0, 0, 26, 0, 78, 0, 1,235, 1,
+ 223, 1,206, 1,192, 1,168, 1,156, 1,135, 1,124, 1,101, 1, 89, 1, 67,
+ 1, 55, 1, 34, 1, 22, 1, 5, 0,247, 0,223, 0,211, 0,190, 0,179, 0,
+ 156, 0,144, 0,123, 0,113, 0, 90, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 53, 4, 21, 1, 1,120, 53, 51,
+ 121, 2, 3, 21, 52, 4, 21, 7, 23,120, 53, 50,121, 0, 0, 0, 0, 0, 0,
+ 0, 0, 98,117, 98, 98, 97, 8, 51, 3, 21, 1,120, 53, 49,121, 15, 19, 50,
+ 4, 21, 18, 7,120, 53, 48,121, 85,102,119, 64, 12, 0, 0, 0, 0, 0, 0,
+ 10, 49, 4, 21, 1, 1,120, 52, 57,121, 4, 2, 21, 48, 4, 21, 23, 7,120,
+ 52, 56,121, 98,117, 98, 98, 97, 0, 0, 0, 0, 0, 0, 0, 0, 9, 47, 4,
+ 21, 0, 1,120, 52, 55,121, 15, 19, 46, 4, 21, 7, 18,120, 52, 54,121, 64,
+ 12, 0, 0, 0, 0, 0, 0, 85,102,119, 10, 45, 4, 21, 1, 1,120, 52, 53,
+ 121, 2, 4, 22, 44, 4, 21, 7, 5,120, 52, 52,121, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0,128, 0, 0, 0, 12, 43, 4, 21, 1, 19,120, 52, 51,121, 15,
+ 120,121,122, 15, 42, 4, 21, 18, 21,120, 52, 50,121, 85,102,119,102,111,117,
+ 114, 10, 41, 4, 21, 1, 1,120, 52, 49,121, 4, 3, 19, 40, 4, 21, 5, 23,
+ 120, 52, 48,121, 0, 0,128, 0, 0, 0, 98,117, 98, 98, 97, 10, 39, 3, 21,
+ 19,120, 51, 57,121,120,121,122, 20, 38, 4, 21, 21, 7,120, 51, 56,121,102,
+ 111,117,114, 64, 12, 0, 0, 0, 0, 0, 0, 10, 37, 4, 21, 1, 1,120, 51,
+ 55,121, 3, 2, 21, 36, 4, 21, 23, 7,120, 51, 54,121, 98,117, 98, 98, 97,
+ 0, 0, 0, 0, 0, 0, 0, 0, 9, 35, 4, 21, 0, 1,120, 51, 53,121, 15,
+ 19, 34, 4, 21, 7, 18,120, 51, 52,121, 64, 12, 0, 0, 0, 0, 0, 0, 85,
+ 102,119, 10, 33, 4, 21, 1, 1,120, 51, 51,121, 2, 4, 22, 32, 4, 21, 7,
+ 5,120, 51, 50,121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0,
+ 12, 31, 4, 21, 1, 19,120, 51, 49,121, 15,120,121,122, 15, 30, 4, 21, 18,
+ 21,120, 51, 48,121, 85,102,119,102,111,117,114, 10, 29, 4, 21, 1, 1,120,
+ 50, 57,121, 4, 3, 19, 28, 4, 21, 5, 23,120, 50, 56,121, 0, 0,128, 0,
+ 0, 0, 98,117, 98, 98, 97, 13, 0, 0, 0, 11, 1, 67, 0, 1,234, 1,221,
+ 1,200, 1,188, 1,171, 1,157, 1,133, 1,121, 1,100, 1, 90, 1, 67, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 21, 64, 4, 21, 7, 23,120, 54, 52,121, 0, 0,
+ 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 8, 63, 3, 21, 1,120, 54, 51,
+ 121, 15, 19, 62, 4, 21, 18, 7,120, 54, 50,121, 85,102,119, 64, 12, 0, 0,
+ 0, 0, 0, 0, 10, 61, 4, 21, 1, 1,120, 54, 49,121, 4, 2, 22, 60, 4,
+ 21, 5, 7,120, 54, 48,121, 0, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 12, 59, 4, 21, 19, 1,120, 53, 57,121,120,121,122, 15, 15, 58, 4,
+ 21, 21, 18,120, 53, 56,121,102,111,117,114, 85,102,119, 10, 57, 4, 21, 1,
+ 1,120, 53, 55,121, 3, 4, 19, 56, 4, 21, 23, 5,120, 53, 54,121, 98,117,
+ 98, 98, 97, 0, 0,128, 0, 0, 0, 11, 55, 4, 21, 0, 19,120, 53, 53,121,
+ 120,121,122, 20, 54, 4, 21, 7, 21,120, 53, 52,121, 64, 12, 0, 0, 0, 0,
+ 0, 0,102,111,117,114, 10, 0, 0, 0, 45, 0,112, 0, 1,247, 1,238, 1,
+ 229, 1,220, 1,211, 1,202, 1,193, 1,184, 1,175, 1,166, 1,159, 1,150,
+ 1,141, 1,132, 1,123, 1,114, 1,105, 1, 96, 1, 87, 1, 78, 1, 69, 1,
+ 61, 1, 52, 1, 43, 1, 34, 1, 25, 1, 16, 1, 7, 0,254, 0,245, 0,236,
+ 0,227, 0,219, 0,210, 0,201, 0,192, 0,183, 0,174, 0,165, 0,156, 0,
+ 147, 0,138, 0,129, 0,121, 0,112, 0,103, 0, 0, 0, 0, 0, 0, 9,120,
+ 53, 49,121, 51, 8, 3, 21, 1,120, 53, 48,121, 50, 7, 3, 19, 1,120, 52,
+ 121, 4, 8, 3, 21, 1,120, 52, 57,121, 49, 8, 3, 21, 1,120, 52, 56,121,
+ 48, 8, 3, 21, 1,120, 52, 55,121, 47, 8, 3, 21, 1,120, 52, 54,121, 46,
+ 8, 3, 21, 1,120, 52, 53,121, 45, 8, 3, 21, 1,120, 52, 52,121, 44, 8,
+ 3, 21, 1,120, 52, 51,121, 43, 8, 3, 21, 1,120, 52, 50,121, 42, 8, 3,
+ 21, 1,120, 52, 49,121, 41, 8, 3, 21, 1,120, 52, 48,121, 40, 7, 3, 19,
+ 1,120, 51,121, 3, 8, 3, 21, 1,120, 51, 57,121, 39, 8, 3, 21, 1,120,
+ 51, 56,121, 38, 8, 3, 21, 1,120, 51, 55,121, 37, 8, 3, 21, 1,120, 51,
+ 54,121, 36, 8, 3, 21, 1,120, 51, 53,121, 35, 8, 3, 21, 1,120, 51, 52,
+ 121, 34, 8, 3, 21, 1,120, 51, 51,121, 33, 8, 3, 21, 1,120, 51, 50,121,
+ 32, 8, 3, 21, 1,120, 51, 49,121, 31, 8, 3, 21, 1,120, 51, 48,121, 30,
+ 7, 3, 19, 1,120, 50,121, 2, 8, 3, 21, 1,120, 50, 57,121, 29, 8, 3,
+ 21, 1,120, 50, 56,121, 28, 8, 3, 21, 1,120, 50, 55,121, 27, 8, 3, 21,
+ 1,120, 50, 54,121, 26, 8, 3, 21, 1,120, 50, 53,121, 25, 8, 3, 21, 1,
+ 120, 50, 52,121, 24, 8, 3, 21, 1,120, 50, 51,121, 23, 8, 3, 21, 1,120,
+ 50, 50,121, 22, 8, 3, 21, 1,120, 50, 49,121, 21, 8, 3, 21, 1,120, 50,
+ 48,121, 20, 6, 3, 19, 9,120, 49,121, 8, 3, 21, 1,120, 49, 57,121, 19,
+ 8, 3, 21, 1,120, 49, 56,121, 18, 8, 3, 21, 1,120, 49, 55,121, 17, 8,
+ 3, 21, 1,120, 49, 54,121, 16, 8, 3, 21, 1,120, 49, 53,121, 15, 8, 3,
+ 21, 1,120, 49, 52,121, 14, 8, 3, 21, 1,120, 49, 51,121, 13, 8, 3, 21,
+ 1,120, 49, 50,121, 12, 8, 3, 21, 1,120, 49, 49,121, 11, 8, 3, 21, 1,
+ 120, 49, 48,121, 10, 10, 0, 0, 0, 18, 1, 99, 0, 1,247, 1,238, 1,229,
+ 1,220, 1,211, 1,202, 1,193, 1,184, 1,176, 1,167, 1,158, 1,149, 1,
+ 140, 1,131, 1,123, 1,115, 1,107, 1, 99, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,
+ 3, 19, 1,120, 57,121, 9, 7, 3, 19, 1,120, 56,121, 8, 7, 3, 19, 1,
+ 120, 55,121, 7, 7, 3, 19, 1,120, 54,121, 6, 8, 3, 21, 1,120, 54, 52,
+ 121, 64, 8, 3, 21, 1,120, 54, 51,121, 63, 8, 3, 21, 1,120, 54, 50,121,
+ 62, 8, 3, 21, 1,120, 54, 49,121, 61, 8, 3, 21, 1,120, 54, 48,121, 60,
+ 7, 3, 19, 1,120, 53,121, 5, 8, 3, 21, 1,120, 53, 57,121, 59, 8, 3,
+ 21, 1,120, 53, 56,121, 58, 8, 3, 21, 1,120, 53, 55,121, 57, 8, 3, 21,
+ 1,120, 53, 54,121, 56, 8, 3, 21, 1,120, 53, 53,121, 55, 8, 3, 21, 1,
+ 120, 53, 52,121, 54, 8, 3, 21, 1,120, 53, 51,121, 53, 8, 3, 21, 1,120,
+ 53, 50,121, 52, 13, 0, 0, 0, 23, 0, 54, 0, 1,240, 1,214, 1,197, 1,
+ 172, 1,156, 1,135, 1,117, 1, 89, 1, 73, 1, 55, 1, 41, 1, 14, 0,254,
+ 0,228, 0,211, 0,186, 0,170, 0,149, 0,131, 0,110, 0, 94, 0, 69, 0,
+ 54, 13, 23, 4, 7, 0, 1, 64, 57, 76,204,204,204,204,205, 15, 23, 22, 4,
+ 7, 7, 18, 64, 56, 51, 51, 51, 51, 51, 52, 64, 12, 0, 0, 0, 0, 0, 0,
+ 85,102,119, 14, 21, 4, 7, 1, 1, 64, 55, 25,153,153,153,153,154, 2, 4,
+ 19, 20, 4, 1, 7, 5, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0,
+ 0, 0, 16, 19, 4, 7, 1, 19, 64, 52,230,102,102,102,102,103, 15,120,121,
+ 122, 19, 18, 4, 7, 18, 21, 64, 51,204,204,204,204,204,205, 85,102,119,102,
+ 111,117,114, 14, 17, 4, 7, 1, 1, 64, 50,179, 51, 51, 51, 51, 52, 4, 3,
+ 23, 16, 4, 7, 23, 5, 64, 49,153,153,153,153,153,154, 98,117, 98, 98, 97,
+ 0, 0,128, 0, 0, 0, 15, 15, 4, 7, 0, 19, 64, 48,128, 0, 0, 0, 0,
+ 0,120,121,122, 24, 14, 4, 7, 7, 21, 64, 46,204,204,204,204,204,206, 64,
+ 12, 0, 0, 0, 0, 0, 0,102,111,117,114, 14, 13, 4, 7, 1, 1, 64, 44,
+ 153,153,153,153,153,154, 2, 3, 25, 12, 4, 7, 7, 23, 64, 42,102,102,102,
+ 102,102,103, 0, 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 12, 11, 3,
+ 7, 1, 64, 40, 51, 51, 51, 51, 51, 52, 15, 16, 10, 4, 1, 18, 7, 11, 85,
+ 102,119, 64, 12, 0, 0, 0, 0, 0, 0, 14, 9, 4, 7, 1, 1, 64, 35,204,
+ 204,204,204,204,205, 4, 2, 26, 8, 4, 7, 5, 7, 64, 33,153,153,153,153,
+ 153,154, 0, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 7, 4,
+ 7, 19, 1, 64, 30,204,204,204,204,204,206,120,121,122, 15, 19, 6, 4, 7,
+ 21, 18, 64, 26,102,102,102,102,102,103,102,111,117,114, 85,102,119, 14, 5,
+ 4, 7, 1, 1, 64, 22, 0, 0, 0, 0, 0, 0, 3, 4, 23, 4, 4, 7, 23,
+ 5, 64, 17,153,153,153,153,153,154, 98,117, 98, 98, 97, 0, 0,128, 0, 0,
+ 0, 15, 3, 4, 7, 0, 19, 64, 10,102,102,102,102,102,103,120,121,122, 24,
+ 2, 4, 7, 7, 21, 64, 1,153,153,153,153,153,154, 64, 12, 0, 0, 0, 0,
+ 0, 0,102,111,117,114, 14, 1, 4, 7, 1, 1, 63,241,153,153,153,153,153,
+ 154, 2, 3, 13, 0, 0, 0, 22, 0, 68, 0, 1,229, 1,213, 1,187, 1,171,
+ 1,146, 1,130, 1,116, 1, 98, 1, 70, 1, 54, 1, 29, 1, 14, 0,243, 0,
+ 227, 0,201, 0,185, 0,167, 0,151, 0,130, 0,112, 0, 84, 0, 68, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 45, 4, 7, 1,
+ 1, 64, 72,192, 0, 0, 0, 0, 1, 2, 4, 26, 44, 4, 7, 7, 5, 64, 72,
+ 51, 51, 51, 51, 51, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0,
+ 0, 16, 43, 4, 7, 1, 19, 64, 71,166,102,102,102,102,103, 15,120,121,122,
+ 19, 42, 4, 7, 18, 21, 64, 71, 25,153,153,153,153,154, 85,102,119,102,111,
+ 117,114, 14, 41, 4, 7, 1, 1, 64, 70,140,204,204,204,204,205, 4, 3, 16,
+ 40, 4, 1, 5, 23, 44, 0, 0,128, 0, 0, 0, 98,117, 98, 98, 97, 14, 39,
+ 3, 7, 19, 64, 69,115, 51, 51, 51, 51, 52,120,121,122, 24, 38, 4, 7, 21,
+ 7, 64, 68,230,102,102,102,102,103,102,111,117,114, 64, 12, 0, 0, 0, 0,
+ 0, 0, 14, 37, 4, 7, 1, 1, 64, 68, 89,153,153,153,153,154, 3, 2, 25,
+ 36, 4, 7, 23, 7, 64, 67,204,204,204,204,204,205, 98,117, 98, 98, 97, 0,
+ 0, 0, 0, 0, 0, 0, 0, 13, 35, 4, 7, 0, 1, 64, 67, 64, 0, 0, 0,
+ 0, 0, 15, 23, 34, 4, 7, 7, 18, 64, 66,179, 51, 51, 51, 51, 52, 64, 12,
+ 0, 0, 0, 0, 0, 0, 85,102,119, 14, 33, 4, 7, 1, 1, 64, 66, 38,102,
+ 102,102,102,103, 2, 4, 26, 32, 4, 7, 7, 5, 64, 65,153,153,153,153,153,
+ 154, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 16, 31, 4, 7,
+ 1, 19, 64, 65, 12,204,204,204,204,205, 15,120,121,122, 12, 30, 4, 1, 18,
+ 21, 33, 85,102,119,102,111,117,114, 14, 29, 4, 7, 1, 1, 64, 63,230,102,
+ 102,102,102,103, 4, 3, 23, 28, 4, 7, 5, 23, 64, 62,204,204,204,204,204,
+ 206, 0, 0,128, 0, 0, 0, 98,117, 98, 98, 97, 14, 27, 3, 7, 19, 64, 61,
+ 179, 51, 51, 51, 51, 52,120,121,122, 24, 26, 4, 7, 21, 7, 64, 60,153,153,
+ 153,153,153,154,102,111,117,114, 64, 12, 0, 0, 0, 0, 0, 0, 14, 25, 4,
+ 7, 1, 1, 64, 59,128, 0, 0, 0, 0, 1, 3, 2, 25, 24, 4, 7, 23, 7,
+ 64, 58,102,102,102,102,102,103, 98,117, 98, 98, 97, 0, 0, 0, 0, 0, 0,
+ 0, 0, 13, 0, 0, 0, 19, 0,121, 0, 1,231, 1,216, 1,189, 1,173, 1,
+ 148, 1,134, 1,107, 1, 91, 1, 65, 1, 48, 1, 23, 1, 7, 0,242, 0,224,
+ 0,203, 0,187, 0,162, 0,148, 0,121, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 64, 4, 7, 7, 23, 64, 81,153,153,
+ 153,153,153,154, 0, 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 12, 63,
+ 3, 7, 1, 64, 81, 83, 51, 51, 51, 51, 52, 15, 23, 62, 4, 7, 18, 7, 64,
+ 81, 12,204,204,204,204,205, 85,102,119, 64, 12, 0, 0, 0, 0, 0, 0, 14,
+ 61, 4, 7, 1, 1, 64, 80,198,102,102,102,102,103, 4, 2, 19, 60, 4, 1,
+ 5, 7, 66, 0, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 59,
+ 4, 7, 19, 1, 64, 80, 57,153,153,153,153,154,120,121,122, 15, 19, 58, 4,
+ 7, 21, 18, 64, 79,230,102,102,102,102,103,102,111,117,114, 85,102,119, 14,
+ 57, 4, 7, 1, 1, 64, 79, 89,153,153,153,153,154, 3, 4, 23, 56, 4, 7,
+ 23, 5, 64, 78,204,204,204,204,204,206, 98,117, 98, 98, 97, 0, 0,128, 0,
+ 0, 0, 15, 55, 4, 7, 0, 19, 64, 78, 64, 0, 0, 0, 0, 1,120,121,122,
+ 24, 54, 4, 7, 7, 21, 64, 77,179, 51, 51, 51, 51, 52, 64, 12, 0, 0, 0,
+ 0, 0, 0,102,111,117,114, 14, 53, 4, 7, 1, 1, 64, 77, 38,102,102,102,
+ 102,103, 2, 3, 25, 52, 4, 7, 7, 23, 64, 76,153,153,153,153,153,154, 0,
+ 0, 0, 0, 0, 0, 0, 0, 98,117, 98, 98, 97, 12, 51, 3, 7, 1, 64, 76,
+ 12,204,204,204,204,205, 15, 23, 50, 4, 7, 18, 7, 64, 75,128, 0, 0, 0,
+ 0, 1, 85,102,119, 64, 12, 0, 0, 0, 0, 0, 0, 14, 49, 4, 7, 1, 1,
+ 64, 74,243, 51, 51, 51, 51, 52, 4, 2, 25, 48, 4, 7, 23, 7, 64, 74,102,
+ 102,102,102,102,103, 98,117, 98, 98, 97, 0, 0, 0, 0, 0, 0, 0, 0, 13,
+ 47, 4, 7, 0, 1, 64, 73,217,153,153,153,153,154, 15, 23, 46, 4, 7, 7,
+ 18, 64, 73, 76,204,204,204,204,205, 64, 12, 0, 0, 0, 0, 0, 0, 85,102,
+ 119, 10, 0, 0, 0, 34, 0, 92, 0, 1,244, 1,231, 1,218, 1,205, 1,192,
+ 1,179, 1,166, 1,153, 1,140, 1,134, 1,121, 1,108, 1, 95, 1, 82, 1,
+ 69, 1, 56, 1, 43, 1, 30, 1, 17, 1, 11, 0,254, 0,241, 0,228, 0,215,
+ 0,202, 0,189, 0,176, 0,163, 0,150, 0,144, 0,131, 0,118, 0,105, 0,
+ 92, 0, 79, 0, 0, 0, 0, 13, 64, 67, 64, 0, 0, 0, 0, 0, 35, 12, 3,
+ 7, 1, 64, 66,179, 51, 51, 51, 51, 52, 34, 12, 3, 7, 1, 64, 66, 38,102,
+ 102,102,102,103, 33, 12, 3, 7, 1, 64, 65,153,153,153,153,153,154, 32, 12,
+ 3, 7, 1, 64, 65, 12,204,204,204,204,205, 31, 5, 3, 1, 1, 33, 30, 12,
+ 3, 7, 1, 64, 63,230,102,102,102,102,103, 29, 12, 3, 7, 1, 64, 62,204,
+ 204,204,204,204,206, 28, 12, 3, 7, 1, 64, 61,179, 51, 51, 51, 51, 52, 27,
+ 12, 3, 7, 1, 64, 60,153,153,153,153,153,154, 26, 12, 3, 7, 1, 64, 59,
+ 128, 0, 0, 0, 0, 1, 25, 12, 3, 7, 1, 64, 58,102,102,102,102,102,103,
+ 24, 12, 3, 7, 1, 64, 57, 76,204,204,204,204,205, 23, 12, 3, 7, 1, 64,
+ 56, 51, 51, 51, 51, 51, 52, 22, 12, 3, 7, 1, 64, 55, 25,153,153,153,153,
+ 154, 21, 5, 3, 1, 1, 22, 20, 12, 3, 7, 1, 64, 52,230,102,102,102,102,
+ 103, 19, 12, 3, 7, 1, 64, 51,204,204,204,204,204,205, 18, 12, 3, 7, 1,
+ 64, 50,179, 51, 51, 51, 51, 52, 17, 12, 3, 7, 1, 64, 49,153,153,153,153,
+ 153,154, 16, 12, 3, 7, 1, 64, 48,128, 0, 0, 0, 0, 0, 15, 12, 3, 7,
+ 1, 64, 46,204,204,204,204,204,206, 14, 12, 3, 7, 1, 64, 44,153,153,153,
+ 153,153,154, 13, 12, 3, 7, 1, 64, 42,102,102,102,102,102,103, 12, 12, 3,
+ 7, 1, 64, 40, 51, 51, 51, 51, 51, 52, 11, 5, 3, 1, 1, 11, 10, 12, 3,
+ 7, 1, 64, 35,204,204,204,204,204,205, 9, 12, 3, 7, 1, 64, 33,153,153,
+ 153,153,153,154, 8, 12, 3, 7, 1, 64, 30,204,204,204,204,204,206, 7, 12,
+ 3, 7, 1, 64, 26,102,102,102,102,102,103, 6, 12, 3, 7, 1, 64, 22, 0,
+ 0, 0, 0, 0, 0, 5, 12, 3, 7, 1, 64, 17,153,153,153,153,153,154, 4,
+ 12, 3, 7, 1, 64, 10,102,102,102,102,102,103, 3, 12, 3, 7, 1, 64, 1,
+ 153,153,153,153,153,154, 2, 11, 3, 7, 9, 63,241,153,153,153,153,153,154,
+ 10, 0, 0, 0, 29, 0,149, 0, 1,243, 1,230, 1,217, 1,204, 1,198, 1,
+ 185, 1,172, 1,159, 1,146, 1,133, 1,120, 1,107, 1, 94, 1, 81, 1, 68,
+ 1, 55, 1, 42, 1, 29, 1, 16, 1, 3, 0,246, 0,233, 0,220, 0,207, 0,
+ 201, 0,188, 0,175, 0,162, 0,149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 3, 7,
+ 1, 64, 81,153,153,153,153,153,154, 64, 12, 3, 7, 1, 64, 81, 83, 51, 51,
+ 51, 51, 52, 63, 12, 3, 7, 1, 64, 81, 12,204,204,204,204,205, 62, 12, 3,
+ 7, 1, 64, 80,198,102,102,102,102,103, 61, 5, 3, 1, 1, 66, 60, 12, 3,
+ 7, 1, 64, 80, 57,153,153,153,153,154, 59, 12, 3, 7, 1, 64, 79,230,102,
+ 102,102,102,103, 58, 12, 3, 7, 1, 64, 79, 89,153,153,153,153,154, 57, 12,
+ 3, 7, 1, 64, 78,204,204,204,204,204,206, 56, 12, 3, 7, 1, 64, 78, 64,
+ 0, 0, 0, 0, 1, 55, 12, 3, 7, 1, 64, 77,179, 51, 51, 51, 51, 52, 54,
+ 12, 3, 7, 1, 64, 77, 38,102,102,102,102,103, 53, 12, 3, 7, 1, 64, 76,
+ 153,153,153,153,153,154, 52, 12, 3, 7, 1, 64, 76, 12,204,204,204,204,205,
+ 51, 12, 3, 7, 1, 64, 75,128, 0, 0, 0, 0, 1, 50, 12, 3, 7, 1, 64,
+ 74,243, 51, 51, 51, 51, 52, 49, 12, 3, 7, 1, 64, 74,102,102,102,102,102,
+ 103, 48, 12, 3, 7, 1, 64, 73,217,153,153,153,153,154, 47, 12, 3, 7, 1,
+ 64, 73, 76,204,204,204,204,205, 46, 12, 3, 7, 1, 64, 72,192, 0, 0, 0,
+ 0, 1, 45, 12, 3, 7, 1, 64, 72, 51, 51, 51, 51, 51, 52, 44, 12, 3, 7,
+ 1, 64, 71,166,102,102,102,102,103, 43, 12, 3, 7, 1, 64, 71, 25,153,153,
+ 153,153,154, 42, 12, 3, 7, 1, 64, 70,140,204,204,204,204,205, 41, 5, 3,
+ 1, 1, 44, 40, 12, 3, 7, 1, 64, 69,115, 51, 51, 51, 51, 52, 39, 12, 3,
+ 7, 1, 64, 68,230,102,102,102,102,103, 38, 12, 3, 7, 1, 64, 68, 89,153,
+ 153,153,153,154, 37, 12, 3, 7, 1, 64, 67,204,204,204,204,204,205, 36, 10,
+ 0, 0, 0, 41, 0,103, 0, 1,250, 1,235, 1,227, 1,218, 1,211, 1,202,
+ 1,192, 1,179, 1,172, 1,157, 1,149, 1,141, 1,132, 1,125, 1,116, 1,
+ 106, 1, 93, 1, 86, 1, 74, 1, 63, 1, 47, 1, 40, 1, 31, 1, 16, 1, 8,
+ 0,255, 0,248, 0,239, 0,229, 0,216, 0,209, 0,197, 0,186, 0,174, 0,
+ 158, 0,151, 0,136, 0,128, 0,119, 0,112, 0,103, 0, 93, 0, 0, 0, 0,
+ 10, 55, 44, 78, 85, 76, 76, 8, 2, 25, 52, 54, 44, 51, 46, 53, 6, 2, 21,
+ 52, 53, 44, 50, 8, 2, 25, 52, 52, 44, 48, 46, 48, 7, 2, 23, 52, 51, 44,
+ 49, 53, 14, 2, 37, 52, 50, 44, 88, 39, 53, 53, 54, 54, 55, 55, 39, 6, 2,
+ 21, 52, 49, 44, 52, 15, 2, 39, 52, 48, 44, 50, 49, 52, 55, 52, 56, 51, 54,
+ 52, 56, 11, 2, 31, 52, 44, 39, 98,117, 98, 98, 97, 39, 10, 2, 29, 51, 57,
+ 44, 39,120,121,122, 39, 11, 2, 31, 51, 56, 44, 39,102,111,117,114, 39, 6,
+ 2, 21, 51, 55, 44, 51, 12, 2, 33, 51, 54, 44, 39, 98,117, 98, 98, 97, 39,
+ 9, 2, 27, 51, 53, 44, 78, 85, 76, 76, 8, 2, 25, 51, 52, 44, 51, 46, 53,
+ 6, 2, 21, 51, 51, 44, 50, 8, 2, 25, 51, 50, 44, 48, 46, 48, 7, 2, 23,
+ 51, 49, 44, 49, 53, 14, 2, 37, 51, 48, 44, 88, 39, 53, 53, 54, 54, 55, 55,
+ 39, 8, 2, 25, 51, 44, 78, 85, 76, 76, 6, 2, 21, 50, 57, 44, 52, 15, 2,
+ 39, 50, 56, 44, 50, 49, 52, 55, 52, 56, 51, 54, 52, 56, 10, 2, 29, 50, 55,
+ 44, 39,120,121,122, 39, 11, 2, 31, 50, 54, 44, 39,102,111,117,114, 39, 6,
+ 2, 21, 50, 53, 44, 51, 12, 2, 33, 50, 52, 44, 39, 98,117, 98, 98, 97, 39,
+ 9, 2, 27, 50, 51, 44, 78, 85, 76, 76, 8, 2, 25, 50, 50, 44, 51, 46, 53,
+ 6, 2, 21, 50, 49, 44, 50, 8, 2, 25, 50, 48, 44, 48, 46, 48, 7, 2, 23,
+ 50, 44, 51, 46, 53, 7, 2, 23, 49, 57, 44, 49, 53, 14, 2, 37, 49, 56, 44,
+ 88, 39, 53, 53, 54, 54, 55, 55, 39, 6, 2, 21, 49, 55, 44, 52, 12, 2, 33,
+ 49, 54, 44, 39, 98,117, 98, 98, 97, 39, 9, 2, 27, 49, 53, 44, 78, 85, 76,
+ 76, 8, 2, 25, 49, 52, 44, 51, 46, 53, 6, 2, 21, 49, 51, 44, 50, 8, 2,
+ 25, 49, 50, 44, 48, 46, 48, 7, 2, 23, 49, 49, 44, 49, 53, 14, 2, 37, 49,
+ 48, 44, 88, 39, 53, 53, 54, 54, 55, 55, 39, 5, 2, 19, 49, 44, 50, 10, 0,
+ 0, 0, 22, 1, 32, 0, 1,243, 1,236, 1,230, 1,215, 1,207, 1,198, 1,
+ 191, 1,182, 1,172, 1,159, 1,152, 1,140, 1,129, 1,118, 1,102, 1, 95,
+ 1, 80, 1, 72, 1, 63, 1, 53, 1, 38, 1, 32, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 5, 2, 19, 57, 44, 52, 14, 2, 37, 56, 44, 50, 49, 52, 55, 52, 56, 51,
+ 54, 52, 56, 9, 2, 27, 55, 44, 39,120,121,122, 39, 8, 2, 25, 54, 52, 44,
+ 48, 46, 48, 7, 2, 23, 54, 51, 44, 49, 53, 14, 2, 37, 54, 50, 44, 88, 39,
+ 53, 53, 54, 54, 55, 55, 39, 6, 2, 21, 54, 49, 44, 52, 15, 2, 39, 54, 48,
+ 44, 50, 49, 52, 55, 52, 56, 51, 54, 52, 56, 10, 2, 29, 54, 44, 39,102,111,
+ 117,114, 39, 10, 2, 29, 53, 57, 44, 39,120,121,122, 39, 11, 2, 31, 53, 56,
+ 44, 39,102,111,117,114, 39, 6, 2, 21, 53, 55, 44, 51, 12, 2, 33, 53, 54,
+ 44, 39, 98,117, 98, 98, 97, 39, 9, 2, 27, 53, 53, 44, 78, 85, 76, 76, 8,
+ 2, 25, 53, 52, 44, 51, 46, 53, 6, 2, 21, 53, 51, 44, 50, 8, 2, 25, 53,
+ 50, 44, 48, 46, 48, 7, 2, 23, 53, 49, 44, 49, 53, 14, 2, 37, 53, 48, 44,
+ 88, 39, 53, 53, 54, 54, 55, 55, 39, 5, 2, 19, 53, 44, 51, 6, 2, 21, 52,
+ 57, 44, 52, 12, 2, 33, 52, 56, 44, 39, 98,117, 98, 98, 97, 39,
+};
+
+/* Help message */
+static const char zHelp[] =
+ "Usage:\n"
+ " sessionfuzz setup -- Generate seed files c1.txt, c2.txt, etc.\n"
+ " sessionfuzz run FILE ... -- Run against fuzzed changeset FILE\n"
+ " sessionfuzz run SQLAR ... -- Run against all files in the SQL Archive\n"
+;
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#ifndef OMIT_ZLIB
+#include "zlib.h"
+#endif
+
+/*
+** Implementation of the "sqlar_uncompress(X,SZ)" SQL function
+**
+** Parameter SZ is interpreted as an integer. If it is less than or
+** equal to zero, then this function returns a copy of X. Or, if
+** SZ is equal to the size of X when interpreted as a blob, also
+** return a copy of X. Otherwise, decompress blob X using zlib
+** utility function uncompress() and return the results (another
+** blob).
+*/
+static void sqlarUncompressFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+#ifdef OMIT_ZLIB
+ sqlite3_result_value(context, argv[0]);
+#else
+ uLong nData;
+ uLongf sz;
+
+ assert( argc==2 );
+ sz = sqlite3_value_int(argv[1]);
+
+ if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){
+ sqlite3_result_value(context, argv[0]);
+ }else{
+ const Bytef *pData= sqlite3_value_blob(argv[0]);
+ Bytef *pOut = sqlite3_malloc(sz);
+ if( Z_OK!=uncompress(pOut, &sz, pData, nData) ){
+ sqlite3_result_error(context, "error in uncompress()", -1);
+ }else{
+ sqlite3_result_blob(context, pOut, sz, SQLITE_TRANSIENT);
+ }
+ sqlite3_free(pOut);
+ }
+#endif
+}
+
+
+/* Run a chunk of SQL. If any errors happen, print an error message
+** and exit.
+*/
+static void runSql(sqlite3 *db, const char *zSql){
+ int rc;
+ char *zErr = 0;
+ rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
+ if( rc || zErr ){
+ fprintf(stderr, "SQL failed: rc=%d zErr=[%s]\n", rc, zErr);
+ fprintf(stderr, "SQL: [%s]\n", zSql);
+ exit(1);
+ }
+}
+
+/*
+** Write buffer to disk
+*/
+static void writeFile(const char *zFilename, const void *pData, int nData){
+ FILE *out;
+ int n;
+ out = fopen(zFilename, "wb");
+ if( out==0 ){
+ fprintf(stderr, "cannot open \"%s\" for writing\n", zFilename);
+ exit(1);
+ }
+ n = (int)fwrite(pData, 1, nData, out);
+ fclose(out);
+ if( n!=nData ){
+ fprintf(stderr, "only wrote %d of %d bytes to \"%s\"\n",n,nData,zFilename);
+ exit(1);
+ }
+}
+
+/*
+** Generate a changeset from session pSess and write it to zFile
+*/
+static void makeChangeset(const char *zFile, sqlite3_session *pSess){
+ void *pChg;
+ int nChg;
+ int rc;
+ rc = sqlite3session_changeset(pSess, &nChg, &pChg);
+ if( rc ){
+ fprintf(stderr, "sqlite3session_changeset() returned %d\n", rc);
+ exit(1);
+ }
+ writeFile(zFile, pChg, nChg);
+ sqlite3_free(pChg);
+}
+
+/*
+** Read a file from disk. Space to hold the answer is obtained from
+** sqlite3_malloc64().
+*/
+static void readFile(const char *zName, void **ppData, int *pnData){
+ FILE *in = fopen(zName, "rb");
+ long nIn;
+ size_t nRead;
+ char *pBuf;
+ *ppData = 0;
+ *pnData = 0;
+ if( in==0 ){
+ fprintf(stderr, "Cannot open \"%s\" for reading\n", zName);
+ exit(1);
+ }
+ fseek(in, 0, SEEK_END);
+ nIn = ftell(in);
+ rewind(in);
+ pBuf = sqlite3_malloc64( nIn+1 );
+ if( pBuf==0 ){
+ fprintf(stderr, "Failed to malloc %lld bytes\n", (sqlite3_int64)(nIn+1));
+ exit(1);
+ }
+ nRead = fread(pBuf, 1, nIn, in);
+ fclose(in);
+ if( nRead!=(size_t)nIn ){
+ fprintf(stderr, "Read only %d of %d bytes from %s\n", (int)nRead, (int)nIn,
+ zName);
+ exit(1);
+ }
+ pBuf[nIn] = 0;
+ *pnData = nIn;
+ *ppData = pBuf;
+}
+
+/*
+** The conflict callback
+*/
+static int conflictCall(
+ void *NotUsed,
+ int eConflict,
+ sqlite3_changeset_iter *p
+){
+ (void)NotUsed;
+ (void)p;
+ return SQLITE_CHANGESET_OMIT;
+}
+
+/*
+** Reset the database file
+*/
+static void db_reset(sqlite3 *db){
+ unsigned char *pData;
+ int nData;
+ int rc;
+
+ nData = sizeof(aDbBytes);
+ pData = sqlite3_malloc64( nData );
+ if( pData==0 ){
+ fprintf(stderr, "could not allocate %d bytes\n", nData);
+ exit(1);
+ }
+ memcpy(pData, aDbBytes, nData);
+ rc = sqlite3_deserialize(db, 0, pData, nData, nData,
+ SQLITE_DESERIALIZE_FREEONCLOSE | SQLITE_DESERIALIZE_RESIZEABLE);
+ if( rc ){
+ fprintf(stderr, "sqlite3_deserialize() failed with %d: %s\n",
+ rc, sqlite3_errmsg(db));
+ exit(1);
+ }
+}
+
+/*
+** Given a full file pathname, return a pointer to the tail.
+** Example:
+**
+** input: /home/drh/sqlite/abc.db
+** output: abc.db
+*/
+static const char *fileTail(const char *z){
+ const char *zOut = z;
+ while( z[0] ){
+ if( z[0]=='/' && z[1]!=0 ) zOut = &z[1];
+ z++;
+ }
+ return zOut;
+}
+
+int main(int argc, char **argv){
+ const char *zCmd;
+ sqlite3 *db;
+ int rc;
+ sqlite3_session *pSess;
+ sqlite3_stmt *pStmt;
+ void *pChgset;
+ int nChgset;
+ int bVerbose = 0;
+
+ if( argc<2 ){
+ fprintf(stderr, "%s", zHelp);
+ exit(1);
+ }
+ rc = sqlite3_open_v2(":memory:",&db,
+ SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "memdb");
+ if( rc ){
+ fprintf(stderr, "Failed to open :memory: database: %s\n",
+ sqlite3_errmsg(db));
+ exit(1);
+ }
+ db_reset(db);
+ zCmd = argv[1];
+ if( strcmp(zCmd, "setup")==0 ){
+ if( argc!=2 ){
+ fprintf(stdout, "Wrong number of arguments.\n%s", zHelp);
+ exit(1);
+ }
+ runSql(db, zFillSql);
+ rc = sqlite3session_create(db, "main", &pSess);
+ if( rc ){
+ fprintf(stderr, "sqlite3session_create() returns %d\n", rc);
+ exit(1);
+ }
+ rc = sqlite3session_attach(pSess, 0);
+ if( rc ){
+ fprintf(stderr, "sqlite3session_attach(db,0) returns %d\n", rc);
+ exit(1);
+ }
+ runSql(db, "INSERT INTO t4(z) VALUES('');");
+ makeChangeset("c1.txt", pSess);
+ runSql(db,
+ "UPDATE t1 SET b=c, c=b WHERE a IN (5,7);\n"
+ "DELETE FROM t2 WHERE rowid IN (8,2);\n"
+ "INSERT OR IGNORE INTO t4 SELECT b FROM t1 WHERE b IS TRUE LIMIT 2;");
+ makeChangeset("c2.txt", pSess);
+ runSql(db, "UPDATE t3 SET x=y, y=NULL WHERE rowid IN (1,3);");
+ makeChangeset("c3.txt", pSess);
+ sqlite3session_delete(pSess);
+ }else
+ if( strcmp(zCmd, "run")==0 ){
+ int i;
+ if( argc<3 ){
+ fprintf(stdout, "Wrong number of arguments.\n%s", zHelp);
+ exit(1);
+ }
+ for(i=2; i<argc; i++){
+ if( strcmp(argv[i],"-v")==0 ){
+ bVerbose = 1;
+ continue;
+ }
+ readFile(argv[i], &pChgset, &nChgset);
+ if( nChgset >= 512
+ && memcmp(pChgset, "SQLite format 3", 16)==0
+ ){
+ sqlite3 *db2;
+ sqlite3_stmt *pStmt2;
+ int nCase = 0;
+ /* This file is an SQL Archive containing many changesets */
+ if( !bVerbose ){ printf("%s: ", fileTail(argv[i])); fflush(stdout); }
+ sqlite3_open_v2(":memory:", &db2,
+ SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE, "memdb");
+ sqlite3_deserialize(db2, 0, pChgset, nChgset, nChgset,
+ SQLITE_DESERIALIZE_READONLY | SQLITE_DESERIALIZE_FREEONCLOSE);
+ sqlite3_create_function(db2, "sqlar_uncompress", 2, SQLITE_UTF8, 0,
+ sqlarUncompressFunc, 0, 0);
+ rc = sqlite3_prepare_v2(db2, "SELECT name, sqlar_uncompress(data,sz)"
+ " FROM sqlar", -1, &pStmt2, 0);
+ if( rc ){
+ fprintf(stderr, "SQL error: %s\n", sqlite3_errmsg(db2));
+ exit(1);
+ }
+ while( SQLITE_ROW==sqlite3_step(pStmt2) ){
+ if( bVerbose ){
+ printf("%s/%s:", fileTail(argv[i]), sqlite3_column_text(pStmt2,0));
+ fflush(stdout);
+ }
+ runSql(db, "BEGIN");
+ pChgset = (unsigned char*)sqlite3_column_blob(pStmt2, 1);
+ nChgset = sqlite3_column_bytes(pStmt2, 1);
+ rc = sqlite3changeset_apply(db, nChgset, pChgset, 0, conflictCall, 0);
+ if( bVerbose ){
+ printf(" Ok. rc=%d\n", rc);
+ fflush(stdout);
+ }
+ runSql(db, "ROLLBACK");
+ nCase++;
+ }
+ sqlite3_finalize(pStmt2);
+ sqlite3_close(db2);
+ if( bVerbose ) printf("%s: ", fileTail(argv[i]));
+ printf(" %d cases, 0 crashes\n", nCase);
+ fflush(stdout);
+ }else{
+ /* The named file is just an ordinary changeset */
+ printf("%s:", fileTail(argv[i]));
+ fflush(stdout);
+ runSql(db, "BEGIN");
+ rc = sqlite3changeset_apply(db, nChgset, pChgset, 0, conflictCall, 0);
+ printf(" %d\n", rc);
+ fflush(stdout);
+ runSql(db, "ROLLBACK");
+ sqlite3_free(pChgset);
+ }
+ }
+ }else
+ {
+ fprintf(stderr, "%s", zHelp);
+ exit(1);
+ }
+ rc = sqlite3_prepare_v2(db, "PRAGMA integrity_check;", -1, &pStmt, 0);
+ if( rc ){
+ fprintf(stderr, "SQL error: %s\n", sqlite3_errmsg(db));
+ exit(1);
+ }
+ if( sqlite3_step(pStmt)!=SQLITE_ROW
+ || strcmp((const char*)sqlite3_column_text(pStmt,0),"ok")!=0
+ ){
+ fprintf(stderr, "Integrity check failed!\n");
+ do{
+ fprintf(stderr, "%s\n", sqlite3_column_text(pStmt,0));
+ }while( sqlite3_step(pStmt)==SQLITE_ROW );
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_close(db);
+ if( sqlite3_memory_used()>0 ){
+ fprintf(stderr, "memory leak of %lld bytes\n",
+ sqlite3_memory_used());
+ exit(1);
+ }
+ return 0;
+}
diff --git a/test/shared.test b/test/shared.test
new file mode 100644
index 0000000..a0cd0a6
--- /dev/null
+++ b/test/shared.test
@@ -0,0 +1,1184 @@
+# 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.
+ if {$::tcl_platform(platform)=="unix"} {
+ sqlite3 db3 "file:test.db?cache=private" -uri 1
+ } 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 "file:test.db?cache=private" -uri 1
+ } 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} {
+ ifcapable curdir {
+ 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
+
+# Shared cache on a :memory: database. This only works for URI filenames.
+#
+do_test shared-$av-16.1 {
+ sqlite3 db1 file::memory: -uri 1
+ sqlite3 db2 file::memory: -uri 1
+ db1 eval {
+ CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(2),(3);
+ }
+ db2 eval {
+ SELECT x FROM t1 ORDER BY x;
+ }
+} {1 2 3}
+do_test shared-$av-16.2 {
+ db2 eval {
+ INSERT INTO t1 VALUES(99);
+ DELETE FROM t1 WHERE x=2;
+ }
+ db1 eval {
+ SELECT x FROM t1 ORDER BY x;
+ }
+} {1 3 99}
+
+# Verify that there is no cache sharing ordinary (non-URI) filenames are
+# used.
+#
+do_test shared-$av-16.3 {
+ db1 close
+ db2 close
+ sqlite3 db1 :memory:
+ sqlite3 db2 :memory:
+ db1 eval {
+ CREATE TABLE t1(x); INSERT INTO t1 VALUES(4),(5),(6);
+ }
+ catchsql {
+ SELECT * FROM t1;
+ } db2
+} {1 {no such table: t1}}
+
+# Shared cache on named memory databases.
+#
+do_test shared-$av-16.4 {
+ db1 close
+ db2 close
+ forcedelete test.db test.db-wal test.db-journal
+ sqlite3 db1 file:test.db?mode=memory -uri 1
+ sqlite3 db2 file:test.db?mode=memory -uri 1
+ db1 eval {
+ CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(2),(3);
+ }
+ db2 eval {
+ SELECT x FROM t1 ORDER BY x;
+ }
+} {1 2 3}
+do_test shared-$av-16.5 {
+ db2 eval {
+ INSERT INTO t1 VALUES(99);
+ DELETE FROM t1 WHERE x=2;
+ }
+ db1 eval {
+ SELECT x FROM t1 ORDER BY x;
+ }
+} {1 3 99}
+do_test shared-$av-16.6 {
+ file exists test.db
+} {0} ;# Verify that the database is in-memory
+
+# Shared cache on named memory databases with different names.
+#
+do_test shared-$av-16.7 {
+ db1 close
+ db2 close
+ forcedelete test1.db test2.db
+ sqlite3 db1 file:test1.db?mode=memory -uri 1
+ sqlite3 db2 file:test2.db?mode=memory -uri 1
+ db1 eval {
+ CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(2),(3);
+ }
+ catchsql {
+ SELECT x FROM t1 ORDER BY x;
+ } db2
+} {1 {no such table: t1}}
+do_test shared-$av-16.8 {
+ file exists test1.db
+} {0} ;# Verify that the database is in-memory
+
+# Shared cache on named memory databases attached to readonly connections.
+#
+if {![sqlite3 -has-codec]} {
+ do_test shared-$av-16.8.1 {
+ db1 close
+ db2 close
+
+ sqlite3 db test1.db
+ db eval {
+ CREATE TABLE yy(a, b);
+ INSERT INTO yy VALUES(77, 88);
+ }
+ db close
+
+ sqlite3 db1 test1.db -uri 1 -readonly 1
+ sqlite3 db2 test2.db -uri 1
+
+ db1 eval {
+ ATTACH 'file:mem?mode=memory&cache=shared' AS shared;
+ CREATE TABLE shared.xx(a, b);
+ INSERT INTO xx VALUES(55, 66);
+ }
+ db2 eval {
+ ATTACH 'file:mem?mode=memory&cache=shared' AS shared;
+ SELECT * FROM xx;
+ }
+ } {55 66}
+
+ do_test shared-$av-16.8.2 { db1 eval { SELECT * FROM yy } } {77 88}
+ do_test shared-$av-16.8.3 {
+ list [catch {db1 eval { INSERT INTO yy VALUES(1, 2) }} msg] $msg
+ } {1 {attempt to write a readonly database}}
+
+ db1 close
+ db2 close
+}
+
+} ;# end of autovacuum on/off loop
+
+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..5bde8cf
--- /dev/null
+++ b/test/shared2.test
@@ -0,0 +1,139 @@
+# 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}
+
+
+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..e313069
--- /dev/null
+++ b/test/shared3.test
@@ -0,0 +1,142 @@
+# 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
+set testprefix shared3
+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
+ sqlite3 db3 "file:./test.db?cache=private" -uri 1
+ 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 "file:./test.db?cache=private" -uri 1 }
+ catchsql {select count(*) from sqlite_master} db3
+} {1 {database is locked}}
+
+db1 close
+db2 close
+db3 close
+
+#-------------------------------------------------------------------------
+# At one point this was causing a faulty assert to fail.
+#
+forcedelete test.db
+sqlite3 db test.db
+sqlite3 db2 test.db
+do_execsql_test 3.1 {
+ PRAGMA auto_vacuum = 2;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(randomblob(500), randomblob(500));
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
+ INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
+}
+do_test 3.2 {
+ execsql { SELECT count(*) FROM sqlite_master } db2
+} {1}
+do_execsql_test 3.3 {
+ BEGIN;
+ DELETE FROM t1 WHERE 1;
+ PRAGMA incremental_vacuum;
+} {}
+do_test 3.4 {
+ execsql { SELECT count(*) FROM sqlite_master } db2
+} {1}
+do_test 3.5 {
+ execsql { COMMIT }
+} {}
+
+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..88959db
--- /dev/null
+++ b/test/shared4.test
@@ -0,0 +1,236 @@
+# 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
+
+# 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..9f4880f
--- /dev/null
+++ b/test/shared7.test
@@ -0,0 +1,58 @@
+# 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}
+
+# EVIDENCE-OF: R-05098-06501 In shared cache mode, attempting to attach
+# the same database file more than once results in an error.
+#
+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/shared8.test b/test/shared8.test
new file mode 100644
index 0000000..f960726
--- /dev/null
+++ b/test/shared8.test
@@ -0,0 +1,113 @@
+# 2012 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.
+#
+#***********************************************************************
+#
+# The tests in this file are intended to show that closing one database
+# connection to a shared-cache while there exist other connections (a)
+# does not cause the schema to be reloaded and (b) does not cause any
+# other problems.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !shared_cache { finish_test ; return }
+set testprefix shared8
+
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+do_test 0.0 { sqlite3_enable_shared_cache } {1}
+
+proc roman {n} {
+ array set R {1 i 2 ii 3 iii 4 iv 5 v 6 vi 7 vii 8 viii 9 ix 10 x}
+ set R($n)
+}
+
+#-------------------------------------------------------------------------
+# The following tests work as follows:
+#
+# 1.0: Open connection [db1] and populate the database.
+#
+# 1.1: Using "PRAGMA writable_schema", destroy the database schema on
+# disk. The schema is still in memory, so it is possible to keep
+# using it, but any attempt to reload it from disk will fail.
+#
+# 1.3-4: Open connection db2. Check that it can see the db schema. Then
+# close db1 and check that db2 still works. This shows that closing
+# db1 did not reset the in-memory schema.
+#
+# 1.5-7: Similar to 1.3-4.
+#
+# 1.8: Close all database connections (deleting the in-memory schema).
+# Then open a new connection and check that it cannot read the db.
+#
+do_test 1.0 {
+ sqlite3 db1 test.db
+ db1 func roman roman
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 2);
+ INSERT INTO t1 VALUES(3, 3);
+ INSERT INTO t1 VALUES(4, 4);
+ CREATE VIEW v1 AS SELECT a, roman(b) FROM t1;
+ SELECT * FROM v1;
+ } db1
+} {1 i 2 ii 3 iii 4 iv}
+
+do_test 1.1 {
+ sqlite3_db_config db1 DEFENSIVE 0
+ execsql {
+ PRAGMA writable_schema = 1;
+ DELETE FROM sqlite_master WHERE 1;
+ PRAGMA writable_schema = 0;
+ SELECT * FROM sqlite_master;
+ } db1
+} {}
+
+do_test 1.2 {
+ execsql { SELECT * FROM v1 } db1
+} {1 i 2 ii 3 iii 4 iv}
+
+do_test 1.3 {
+ sqlite3 db2 test.db
+ db2 func roman roman
+ execsql { SELECT * FROM v1 } db2
+} {1 i 2 ii 3 iii 4 iv}
+
+do_test 1.4 {
+ db1 close
+ execsql { SELECT * FROM v1 } db2
+} {1 i 2 ii 3 iii 4 iv}
+
+do_test 1.5 {
+ sqlite3 db3 test.db
+ db3 func roman roman
+ execsql { SELECT * FROM v1 } db3
+} {1 i 2 ii 3 iii 4 iv}
+
+do_test 1.6 {
+ execsql { SELECT * FROM v1 } db2
+} {1 i 2 ii 3 iii 4 iv}
+
+do_test 1.7 {
+ db2 close
+ execsql { SELECT * FROM v1 } db3
+} {1 i 2 ii 3 iii 4 iv}
+
+do_test 1.8 {
+ db3 close
+ sqlite3 db4 test.db
+ catchsql { SELECT * FROM v1 } db4
+} {1 {no such table: v1}}
+
+
+foreach db {db1 db2 db3 db4} { catch { $db close } }
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/shared9.test b/test/shared9.test
new file mode 100644
index 0000000..5bb46c2
--- /dev/null
+++ b/test/shared9.test
@@ -0,0 +1,230 @@
+# 2012 October 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 tests in this file are intended to show if two connections attach
+# to the same shared cache using different database names, views and
+# virtual tables may still be accessed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+set testprefix shared9
+
+ifcapable !view||!trigger||!shared_cache {
+ finish_test
+ return
+}
+
+db close
+set enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+sqlite3 db1 test.db
+sqlite3 db2 test.db
+forcedelete test.db2
+
+do_test 1.1 {
+ db1 eval {
+ ATTACH 'test.db2' AS 'fred';
+ CREATE TABLE fred.t1(a, b, c);
+ CREATE VIEW fred.v1 AS SELECT * FROM t1;
+
+ CREATE TABLE fred.t2(a, b);
+ CREATE TABLE fred.t3(a, b);
+ CREATE TRIGGER fred.trig AFTER INSERT ON t2 BEGIN
+ DELETE FROM t3;
+ INSERT INTO t3 SELECT * FROM t2;
+ END;
+ INSERT INTO t2 VALUES(1, 2);
+ SELECT * FROM t3;
+ }
+} {1 2}
+
+do_test 1.2 { db2 eval "ATTACH 'test.db2' AS 'jones'" } {}
+do_test 1.3 { db2 eval "SELECT * FROM v1" } {}
+do_test 1.4 { db2 eval "INSERT INTO t2 VALUES(3, 4)" } {}
+
+ifcapable fts3 {
+ do_test 1.5 {
+ db1 eval {
+ CREATE VIRTUAL TABLE fred.t4 USING fts4;
+ INSERT INTO t4 VALUES('hello world');
+ }
+ } {}
+
+ do_test 1.6 {
+ db2 eval {
+ INSERT INTO t4 VALUES('shared cache');
+ SELECT * FROM t4 WHERE t4 MATCH 'hello';
+ }
+ } {{hello world}}
+
+ do_test 1.7 {
+ db1 eval {
+ SELECT * FROM t4 WHERE t4 MATCH 'c*';
+ }
+ } {{shared cache}}
+}
+
+db1 close
+db2 close
+
+#-------------------------------------------------------------------------
+# The following tests attempt to find a similar problem with collation
+# sequence names - pointers to database handle specific allocations leaking
+# into schema objects and being used after the original handle has been
+# closed.
+#
+forcedelete test.db test.db2
+sqlite3 db1 test.db
+sqlite3 db2 test.db
+foreach x {collate1 collate2 collate3} {
+ proc $x {a b} { string compare $a $b }
+ db1 collate $x $x
+ db2 collate $x $x
+}
+do_test 2.1 {
+ db1 eval {
+ CREATE TABLE t1(a, b, c COLLATE collate1);
+ CREATE INDEX i1 ON t1(a COLLATE collate2, c, b);
+ }
+} {}
+do_test 2.2 {
+ db1 close
+ db2 eval "INSERT INTO t1 VALUES('abc', 'def', 'ghi')"
+} {}
+db2 close
+
+#-------------------------------------------------------------------------
+# At one point, the following would cause a collation sequence belonging
+# to connection [db1] to be invoked by a call to [db2 eval]. Which is a
+# problem if [db1] has already been closed.
+#
+forcedelete test.db test.db2
+sqlite3 db1 test.db
+sqlite3 db2 test.db
+
+proc mycollate_db1 {a b} {set ::invoked_mycollate_db1 1 ; string compare $a $b}
+proc mycollate_db2 {a b} {string compare $a $b}
+
+db1 collate mycollate mycollate_db1
+db2 collate mycollate mycollate_db2
+
+do_test 2.3 {
+ set ::invoked_mycollate_db1 0
+ db1 eval {
+ CREATE TABLE t1(a COLLATE mycollate, CHECK (a IN ('one', 'two', 'three')));
+ INSERT INTO t1 VALUES('one');
+ }
+ db1 close
+ set ::invoked_mycollate_db1
+} {1}
+do_test 2.4 {
+ set ::invoked_mycollate_db1 0
+ db2 eval {
+ INSERT INTO t1 VALUES('two');
+ }
+ db2 close
+ set ::invoked_mycollate_db1
+} {0}
+
+forcedelete test.db test.db2
+sqlite3 db1 test.db
+sqlite3 db2 test.db
+db1 collate mycollate mycollate_db1
+db2 collate mycollate mycollate_db2
+
+do_test 2.13 {
+ set ::invoked_mycollate_db1 0
+ db1 eval {
+ CREATE TABLE t1(a, CHECK (a COLLATE mycollate IN ('one', 'two', 'three')));
+ INSERT INTO t1 VALUES('one');
+ }
+ db1 close
+ set ::invoked_mycollate_db1
+} {1}
+do_test 2.14 {
+ set ::invoked_mycollate_db1 0
+ db2 eval {
+ INSERT INTO t1 VALUES('two');
+ }
+ db2 close
+ set ::invoked_mycollate_db1
+} {0}
+
+#-------------------------------------------------------------------------
+# This test verifies that a bug causing a busy-handler belonging to one
+# shared-cache connection to be executed as a result of an sqlite3_step()
+# on another has been fixed.
+#
+forcedelete test.db test.db2
+sqlite3 db1 test.db
+sqlite3 db2 test.db
+
+proc busyhandler {handle args} {
+ set ::busyhandler_invoked_for $handle
+ return 1
+}
+db1 busy [list busyhandler db1]
+db2 busy [list busyhandler db2]
+
+do_test 3.1 {
+ db1 eval {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(1, 2);
+ }
+ # Keep this next COMMIT as a separate statement. This ensures that COMMIT
+ # has already been compiled and loaded into the tcl interface statement
+ # cache when it is attempted below.
+ db1 eval COMMIT
+ db1 eval {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+} {}
+
+do_test 3.2 {
+ set ::tf [launch_testfixture]
+ testfixture $::tf {
+ sqlite3 db test.db
+ db eval {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ }
+} {1 2}
+
+do_test 3.3 {
+ db2 eval { SELECT * FROM t2 }
+} {1 2}
+
+do_test 3.4 {
+ list [catch { db1 eval COMMIT } msg] $msg
+} {1 {database is locked}}
+
+# At one point the following would fail, showing that the busy-handler
+# belonging to [db2] was invoked instead.
+do_test 3.5 {
+ set ::busyhandler_invoked_for
+} {db1}
+do_test 3.6 {
+ close $::tf
+ db1 eval COMMIT
+} {}
+
+db1 close
+db2 close
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/sharedA.test b/test/sharedA.test
new file mode 100644
index 0000000..ef57c89
--- /dev/null
+++ b/test/sharedA.test
@@ -0,0 +1,198 @@
+# 2013 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.
+#
+#***********************************************************************
+#
+# Test some specific circumstances to do with shared cache mode.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+if {[run_thread_tests]==0} { finish_test ; return }
+db close
+set ::testprefix sharedA
+
+ifcapable !shared_cache {
+ finish_test
+ return
+}
+
+if {[atomic_batch_write test.db]} {
+ finish_test
+ return
+}
+
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+#-------------------------------------------------------------------------
+#
+do_test 0.1 {
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+
+ db1 eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(100));
+ INSERT INTO t1 SELECT randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100) FROM t1;
+ CREATE INDEX i1 ON t1(x);
+ }
+
+ db1 eval {
+ BEGIN;
+ DROP INDEX i1;
+ }
+
+ db2 close
+
+ db1 eval {
+ INSERT INTO t1 SELECT randomblob(100) FROM t1;
+ ROLLBACK;
+ PRAGMA integrity_check;
+ }
+} {ok}
+
+db1 close
+forcedelete test.db
+
+
+#-------------------------------------------------------------------------
+#
+do_test 1.1 {
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+ db2 eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(123);
+ }
+ db1 eval {
+ SELECT * FROM t1;
+ CREATE INDEX i1 ON t1(x);
+ }
+} {123}
+
+do_test 1.2 {
+ db2 eval { SELECT * FROM t1 ORDER BY x; }
+
+ db1 eval {
+ BEGIN; DROP INDEX i1;
+ }
+ db1 close
+
+ db2 eval { SELECT * FROM t1 ORDER BY x; }
+} {123}
+
+do_test 1.3 {
+ db2 close
+} {}
+
+#-------------------------------------------------------------------------
+#
+# sqlite3RollbackAll() loops through all attached b-trees and rolls
+# back each one separately. Then if the SQLITE_InternChanges flag is
+# set, it resets the schema. Both of the above steps must be done
+# while holding a mutex, otherwise another thread might slip in and
+# try to use the new schema with the old data.
+#
+# The following sequence of tests attempt to verify that the actions
+# taken by sqlite3RollbackAll() are thread-atomic (that they cannot be
+# interrupted by a separate thread.)
+#
+# Note that a TCL interpreter can only be used within the thread in which
+# it was originally created (because it uses thread-local-storage).
+# The tvfs callbacks must therefore only run on the main thread.
+# There is some trickery in the read_callback procedure to ensure that
+# this is the case.
+#
+testvfs tvfs
+
+# Set up two databases and two database connections.
+#
+# db1: main(test.db), two(test2.db)
+# db2: main(test.db)
+#
+# The cache for test.db is shared between db1 and db2.
+#
+do_test 2.1 {
+ forcedelete test.db test.db2
+ sqlite3 db1 test.db -vfs tvfs
+ db1 eval { ATTACH 'test.db2' AS two }
+
+ db1 eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ CREATE TABLE two.t2(x);
+ INSERT INTO t2 SELECT * FROM t1;
+ }
+
+ sqlite3 db2 test.db -vfs tvfs
+ db2 eval { SELECT * FROM t1 }
+} {1 2 3}
+
+# Create a prepared statement on db2 that will attempt a schema change
+# in test.db. Meanwhile, start a transaction on db1 that changes
+# the schema of test.db and that creates a rollback journal on test2.db
+#
+do_test 2.2 {
+ set ::STMT [sqlite3_prepare db2 "CREATE INDEX i1 ON t1(x)" -1 tail]
+ db1 eval {
+ BEGIN;
+ CREATE INDEX i1 ON t1(x);
+ INSERT INTO t2 VALUES('value!');
+ }
+} {}
+
+# Set up a callback that will cause db2 to try to execute its
+# schema change when db1 accesses the journal file of test2.db.
+#
+# This callback will be invoked after the content of test.db has
+# be rolled back but before the schema has been reset. If the
+# sqlite3RollbackAll() operation is not thread-atomic, then the
+# db2 statement in the callback will see old content with the newer
+# schema, which is wrong.
+#
+tvfs filter xRead
+tvfs script read_callback
+unset -nocomplain ::some_time_laster
+unset -nocomplain ::thread_result
+proc read_callback {call file args} {
+ if {[string match *test.db2-journal $file]} {
+ tvfs filter {} ;# Ensure that tvfs callbacks to do run on the
+ # child thread
+ sqlthread spawn ::thread_result [subst -nocommands {
+ sqlite3_step $::STMT
+ set rc [sqlite3_finalize $::STMT]
+ }]
+ after 1000 { set ::some_time_later 1 }
+ vwait ::some_time_later
+ }
+}
+do_test 2.3 { db1 eval ROLLBACK } {}
+
+# Verify that the db2 statement invoked by the callback detected the
+# schema change.
+#
+if {[info exists ::thread_result]==0} { vwait ::thread_result }
+do_test 2.4 {
+ list $::thread_result [sqlite3_errmsg db2]
+} {SQLITE_SCHEMA {database schema has changed}}
+
+db1 close
+db2 close
+tvfs delete
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/sharedB.test b/test/sharedB.test
new file mode 100644
index 0000000..2a7e49c
--- /dev/null
+++ b/test/sharedB.test
@@ -0,0 +1,65 @@
+# 2014-12-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.
+#
+#***********************************************************************
+#
+# Open two database connections on the same database in shared cache
+# mode. Hold one open while repeatedly closing, reopening, and using
+# the second.
+#
+# This test is designed to demostrate that the fix for ticket
+# [e4a18565a36884b00edf66541f38c693827968ab] works.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+if {[run_thread_tests]==0} { finish_test ; return }
+db close
+set ::testprefix sharedB
+
+ifcapable !shared_cache {
+ finish_test
+ return
+}
+
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+#-------------------------------------------------------------------------
+#
+do_test 1.1 {
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+
+ db1 eval {
+ CREATE TABLE t1(x,y TEXT COLLATE nocase);
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)
+ INSERT INTO t1(x,y) SELECT i, printf('x%03dy',i) FROM c;
+ CREATE INDEX t1yx ON t1(y,x);
+ }
+ db2 eval {
+ SELECT x FROM t1 WHERE y='X014Y';
+ }
+} {14}
+
+for {set j 1} {$j<=100} {incr j} {
+ do_test 1.2.$j {
+ db2 close
+ sqlite3 db2 test.db
+ db2 eval {
+ SELECT x FROM t1 WHERE y='X014Y';
+ }
+ } {14}
+}
+
+db1 close
+db2 close
+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..fdc1c13
--- /dev/null
+++ b/test/shared_err.test
@@ -0,0 +1,528 @@
+# 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
+#} {bad parameter or other API misuse}
+
+# 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
+ execsql BEGIN
+ execsql ROLLBACK
+ 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
+}
+
+# When this test case was written, OOM errors in write statements would
+# cause transaction rollback, which would trip cursors in other statements,
+# aborting them. This no longer happens.
+#
+do_test shared_malloc-8.X {
+ # Test that one or more queries were aborted due to the malloc() failure.
+ # expr $::aborted>=1
+ expr $::aborted==0
+} {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..caa48f5
--- /dev/null
+++ b/test/sharedlock.test
@@ -0,0 +1,82 @@
+# 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
+set testprefix sharedlock
+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}
+
+
+#-------------------------------------------------------------------------
+# Test that a write-lock is taken on a table when its entire contents
+# are deleted using the OP_Clear optimization.
+#
+foreach {tn delete_sql} {
+ 1 { DELETE FROM t2 WHERE 1 }
+ 2 { DELETE FROM t2 }
+} {
+ do_execsql_test 2.1 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ }
+
+ do_test 2.2 { execsql { SELECT * FROM t2 } db2 } {1 2 3 4}
+
+ do_execsql_test 2.3 " BEGIN; $delete_sql; "
+
+ do_test 2.4 {
+ catchsql { SELECT * FROM t2 } db2
+ } {1 {database table is locked: t2}}
+
+ do_execsql_test 2.5 COMMIT
+}
+
+
+db close
+db2 close
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
diff --git a/test/shell1.test b/test/shell1.test
new file mode 100644
index 0000000..2642653
--- /dev/null
+++ b/test/shell1.test
@@ -0,0 +1,1260 @@
+# 2009 Nov 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.
+#
+#***********************************************************************
+#
+# The focus of this file is testing the CLI shell tool.
+#
+#
+
+# Test plan:
+#
+# shell1-1.*: Basic command line option handling.
+# shell1-2.*: Basic "dot" command token parsing.
+# shell1-3.*: Basic test that "dot" command can be called.
+# shell1-{4-8}.*: Test various "dot" commands's functionality.
+# shell1-9.*: Basic test that "dot" commands and SQL intermix ok.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set CLI [test_cli_invocation]
+db close
+forcedelete test.db test.db-journal test.db-wal
+sqlite3 db test.db
+
+#----------------------------------------------------------------------------
+# Test cases shell1-1.*: Basic command line option handling.
+#
+
+# invalid option
+do_test shell1-1.1.1 {
+ set res [catchcmd "-bad test.db" ""]
+ set rc [lindex $res 0]
+ list $rc \
+ [regexp {Error: unknown option: -bad} $res]
+} {1 1}
+do_test shell1-1.1.1b {
+ set res [catchcmd "test.db -bad" ""]
+ set rc [lindex $res 0]
+ list $rc \
+ [regexp {Error: unknown option: -bad} $res]
+} {1 1}
+# error on extra options
+do_test shell1-1.1.2 {
+ catchcmd "test.db \"select+3\" \"select+4\"" ""
+} {0 {3
+4}}
+# error on extra options
+do_test shell1-1.1.3 {
+ catchcmd "test.db FOO test.db BAD" ".quit"
+} {/1 .Error: in prepare, near "FOO": syntax error*/}
+
+# -help
+do_test shell1-1.2.1 {
+ set res [catchcmd "-help test.db" ""]
+ set rc [lindex $res 0]
+ list $rc \
+ [regexp {Usage} $res] \
+ [regexp {\-init} $res] \
+ [regexp {\-version} $res]
+} {1 1 1 1}
+
+# -init filename read/process named file
+forcedelete FOO
+set out [open FOO w]
+puts $out ""
+close $out
+do_test shell1-1.3.1 {
+ catchcmd "-init FOO test.db" ""
+} {0 {}}
+do_test shell1-1.3.2 {
+ catchcmd "-init FOO test.db .quit BAD" ""
+} {0 {}}
+do_test shell1-1.3.3 {
+ catchcmd "-init FOO test.db BAD .quit" ""
+} {/1 .Error: in prepare, near "BAD": syntax error*/}
+
+# -echo print commands before execution
+do_test shell1-1.4.1 {
+ catchcmd "-echo test.db" ""
+} {0 {}}
+
+# -[no]header turn headers on or off
+do_test shell1-1.5.1 {
+ catchcmd "-header test.db" ""
+} {0 {}}
+do_test shell1-1.5.2 {
+ catchcmd "-noheader test.db" ""
+} {0 {}}
+
+# -bail stop after hitting an error
+do_test shell1-1.6.1 {
+ catchcmd "-bail test.db" ""
+} {0 {}}
+
+# -interactive force interactive I/O
+do_test shell1-1.7.1 {
+ set res [catchcmd "-interactive test.db" ".quit"]
+ set rc [lindex $res 0]
+ list $rc \
+ [regexp {SQLite version} $res] \
+ [regexp {Enter ".help" for usage hints} $res]
+} {0 1 1}
+
+# -batch force batch I/O
+do_test shell1-1.8.1 {
+ catchcmd "-batch test.db" ""
+} {0 {}}
+
+# -column set output mode to 'column'
+do_test shell1-1.9.1 {
+ catchcmd "-column test.db" ""
+} {0 {}}
+
+# -csv set output mode to 'csv'
+do_test shell1-1.10.1 {
+ catchcmd "-csv test.db" ""
+} {0 {}}
+
+# -html set output mode to HTML
+do_test shell1-1.11.1 {
+ catchcmd "-html test.db" ""
+} {0 {}}
+
+# -line set output mode to 'line'
+do_test shell1-1.12.1 {
+ catchcmd "-line test.db" ""
+} {0 {}}
+
+# -list set output mode to 'list'
+do_test shell1-1.13.1 {
+ catchcmd "-list test.db" ""
+} {0 {}}
+
+# -separator 'x' set output field separator (|)
+do_test shell1-1.14.1 {
+ catchcmd "-separator 'x' test.db" ""
+} {0 {}}
+do_test shell1-1.14.2 {
+ catchcmd "-separator x test.db" ""
+} {0 {}}
+do_test shell1-1.14.3 {
+ set res [catchcmd "-separator" ""]
+ set rc [lindex $res 0]
+ list $rc \
+ [regexp {Error: missing argument to -separator} $res]
+} {1 1}
+
+# -stats print memory stats before each finalize
+do_test shell1-1.14b.1 {
+ catchcmd "-stats test.db" ""
+} {0 {}}
+
+# -nullvalue 'text' set text string for NULL values
+do_test shell1-1.15.1 {
+ catchcmd "-nullvalue 'x' test.db" ""
+} {0 {}}
+do_test shell1-1.15.2 {
+ catchcmd "-nullvalue x test.db" ""
+} {0 {}}
+do_test shell1-1.15.3 {
+ set res [catchcmd "-nullvalue" ""]
+ set rc [lindex $res 0]
+ list $rc \
+ [regexp {Error: missing argument to -nullvalue} $res]
+} {1 1}
+
+# -version show SQLite version
+do_test shell1-1.16.1 {
+ set x [catchcmd "-version test.db" ""]
+} {/3.[0-9.]+ 20\d\d-[01]\d-\d\d \d\d:\d\d:\d\d [0-9a-f]+/}
+
+#----------------------------------------------------------------------------
+# Test cases shell1-2.*: Basic "dot" command token parsing.
+#
+
+# check first token handling
+do_test shell1-2.1.1 {
+ catchcmd "test.db" ".foo"
+} {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}}
+do_test shell1-2.1.2 {
+ catchcmd "test.db" ".\"foo OFF\""
+} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
+do_test shell1-2.1.3 {
+ catchcmd "test.db" ".\'foo OFF\'"
+} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
+
+# unbalanced quotes
+do_test shell1-2.2.1 {
+ catchcmd "test.db" ".\"foo OFF"
+} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
+do_test shell1-2.2.2 {
+ catchcmd "test.db" ".\'foo OFF"
+} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
+do_test shell1-2.2.3 {
+ catchcmd "test.db" ".explain \"OFF"
+} {0 {}}
+do_test shell1-2.2.4 {
+ catchcmd "test.db" ".explain \'OFF"
+} {0 {}}
+do_test shell1-2.2.5 {
+ catchcmd "test.db" ".mode \"insert FOO"
+} {1 {Error: mode should be one of: ascii box column csv html insert json line list markdown qbox quote table tabs tcl}}
+do_test shell1-2.2.6 {
+ catchcmd "test.db" ".mode \'insert FOO"
+} {1 {Error: mode should be one of: ascii box column csv html insert json line list markdown qbox quote table tabs tcl}}
+
+# check multiple tokens, and quoted tokens
+do_test shell1-2.3.1 {
+ catchcmd "test.db" ".explain 1"
+} {0 {}}
+do_test shell1-2.3.2 {
+ catchcmd "test.db" ".explain on"
+} {0 {}}
+do_test shell1-2.3.3 {
+ catchcmd "test.db" ".explain \"1 2 3\""
+} {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}}
+do_test shell1-2.3.4 {
+ catchcmd "test.db" ".explain \"OFF\""
+} {0 {}}
+do_test shell1-2.3.5 {
+ catchcmd "test.db" ".\'explain\' \'OFF\'"
+} {0 {}}
+do_test shell1-2.3.6 {
+ catchcmd "test.db" ".explain \'OFF\'"
+} {0 {}}
+do_test shell1-2.3.7 {
+ catchcmd "test.db" ".\'explain\' \'OFF\'"
+} {0 {}}
+
+# check quoted args are unquoted
+do_test shell1-2.4.1 {
+ catchcmd "test.db" ".mode FOO"
+} {1 {Error: mode should be one of: ascii box column csv html insert json line list markdown qbox quote table tabs tcl}}
+do_test shell1-2.4.2 {
+ catchcmd "test.db" ".mode csv"
+} {0 {}}
+do_test shell1-2.4.2 {
+ catchcmd "test.db" ".mode \"csv\""
+} {0 {}}
+
+
+#----------------------------------------------------------------------------
+# Test cases shell1-3.*: Basic test that "dot" command can be called.
+#
+
+# .backup ?DB? FILE Backup DB (default "main") to FILE
+do_test shell1-3.1.1 {
+ catchcmd "test.db" ".backup"
+} {1 {missing FILENAME argument on .backup}}
+forcedelete FOO
+do_test shell1-3.1.2 {
+ catchcmd "test.db" ".backup FOO"
+} {0 {}}
+do_test shell1-3.1.3 {
+ catchcmd "test.db" ".backup FOO BAR"
+} {1 {Error: unknown database FOO}}
+do_test shell1-3.1.4 {
+ # too many arguments
+ catchcmd "test.db" ".backup FOO BAR BAD"
+} {1 {Usage: .backup ?DB? ?OPTIONS? FILENAME}}
+
+# .bail ON|OFF Stop after hitting an error. Default OFF
+do_test shell1-3.2.1 {
+ catchcmd "test.db" ".bail"
+} {1 {Usage: .bail on|off}}
+do_test shell1-3.2.2 {
+ catchcmd "test.db" ".bail ON"
+} {0 {}}
+do_test shell1-3.2.3 {
+ catchcmd "test.db" ".bail OFF"
+} {0 {}}
+do_test shell1-3.2.4 {
+ # too many arguments
+ catchcmd "test.db" ".bail OFF BAD"
+} {1 {Usage: .bail on|off}}
+
+ifcapable vtab {
+# .databases List names and files of attached databases
+do_test shell1-3.3.1 {
+ catchcmd "-csv test.db" ".databases"
+} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
+do_test shell1-3.3.2 {
+ # extra arguments ignored
+ catchcmd "test.db" ".databases BAD"
+} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
+}
+
+# .dump ?TABLE? ... Dump the database in an SQL text format
+# If TABLE specified, only dump tables matching
+# LIKE pattern TABLE.
+do_test shell1-3.4.1 {
+ set res [catchcmd "test.db" ".dump"]
+ list [regexp {BEGIN TRANSACTION;} $res] \
+ [regexp {COMMIT;} $res]
+} {1 1}
+do_test shell1-3.4.2 {
+ set res [catchcmd "test.db" ".dump FOO"]
+ list [regexp {BEGIN TRANSACTION;} $res] \
+ [regexp {COMMIT;} $res]
+} {1 1}
+# The .dump command now accepts multiple arguments
+#do_test shell1-3.4.3 {
+# # too many arguments
+# catchcmd "test.db" ".dump FOO BAD"
+#} {1 {Usage: .dump ?--preserve-rowids? ?--newlines? ?LIKE-PATTERN?}}
+
+# .echo ON|OFF Turn command echo on or off
+do_test shell1-3.5.1 {
+ catchcmd "test.db" ".echo"
+} {1 {Usage: .echo on|off}}
+do_test shell1-3.5.2 {
+ catchcmd "test.db" ".echo ON"
+} {0 {}}
+do_test shell1-3.5.3 {
+ catchcmd "test.db" ".echo OFF"
+} {0 {}}
+do_test shell1-3.5.4 {
+ # too many arguments
+ catchcmd "test.db" ".echo OFF BAD"
+} {1 {Usage: .echo on|off}}
+
+# .exit Exit this program
+do_test shell1-3.6.1 {
+ catchcmd "test.db" ".exit"
+} {0 {}}
+
+# .explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
+do_test shell1-3.7.1 {
+ catchcmd "test.db" ".explain"
+ # explain is the exception to the booleans. without an option, it turns it on.
+} {0 {}}
+do_test shell1-3.7.2 {
+ catchcmd "test.db" ".explain ON"
+} {0 {}}
+do_test shell1-3.7.3 {
+ catchcmd "test.db" ".explain OFF"
+} {0 {}}
+do_test shell1-3.7.4 {
+ # extra arguments ignored
+ catchcmd "test.db" ".explain OFF BAD"
+} {0 {}}
+
+
+# .header(s) ON|OFF Turn display of headers on or off
+do_test shell1-3.9.1 {
+ catchcmd "test.db" ".header"
+} {1 {Usage: .headers on|off}}
+do_test shell1-3.9.2 {
+ catchcmd "test.db" ".header ON"
+} {0 {}}
+do_test shell1-3.9.3 {
+ catchcmd "test.db" ".header OFF"
+} {0 {}}
+do_test shell1-3.9.4 {
+ # too many arguments
+ catchcmd "test.db" ".header OFF BAD"
+} {1 {Usage: .headers on|off}}
+
+do_test shell1-3.9.5 {
+ catchcmd "test.db" ".headers"
+} {1 {Usage: .headers on|off}}
+do_test shell1-3.9.6 {
+ catchcmd "test.db" ".headers ON"
+} {0 {}}
+do_test shell1-3.9.7 {
+ catchcmd "test.db" ".headers OFF"
+} {0 {}}
+do_test shell1-3.9.8 {
+ # too many arguments
+ catchcmd "test.db" ".headers OFF BAD"
+} {1 {Usage: .headers on|off}}
+
+# .help Show this message
+do_test shell1-3.10.1 {
+ set res [catchcmd "test.db" ".help"]
+ # look for a few of the possible help commands
+ list [regexp {.help} $res] \
+ [regexp {.quit} $res] \
+ [regexp {.show} $res]
+} {1 1 1}
+do_test shell1-3.10.2 {
+ # we allow .help to take extra args (it is help after all)
+ set res [catchcmd "test.db" ".help *"]
+ # look for a few of the possible help commands
+ list [regexp {.help} $res] \
+ [regexp {.quit} $res] \
+ [regexp {.show} $res]
+} {1 1 1}
+
+# .import FILE TABLE Import data from FILE into TABLE
+do_test shell1-3.11.1 {
+ catchcmd "test.db" ".import"
+} {/1 .ERROR: missing FILE argument.*/}
+do_test shell1-3.11.2 {
+ catchcmd "test.db" ".import FOO"
+} {/1 .ERROR: missing TABLE argument.*/}
+do_test shell1-3.11.3 {
+ # too many arguments
+ catchcmd "test.db" ".import FOO BAR BAD"
+} {/1 .ERROR: extra argument: "BAD".*./}
+
+# .indexes ?TABLE? Show names of all indexes
+# If TABLE specified, only show indexes for tables
+# matching LIKE pattern TABLE.
+do_test shell1-3.12.1 {
+ catchcmd "test.db" ".indexes"
+} {0 {}}
+do_test shell1-3.12.2 {
+ catchcmd "test.db" ".indexes FOO"
+} {0 {}}
+do_test shell1-3.12.2-legacy {
+ catchcmd "test.db" ".indices FOO"
+} {0 {}}
+do_test shell1-3.12.3 {
+ # too many arguments
+ catchcmd "test.db" ".indexes FOO BAD"
+} {1 {Usage: .indexes ?LIKE-PATTERN?}}
+
+# .mode MODE ?TABLE? Set output mode where MODE is one of:
+# ascii Columns/rows delimited by 0x1F and 0x1E
+# csv Comma-separated values
+# column Left-aligned columns. (See .width)
+# html HTML <table> code
+# insert SQL insert statements for TABLE
+# line One value per line
+# list Values delimited by .separator strings
+# tabs Tab-separated values
+# tcl TCL list elements
+do_test shell1-3.13.1 {
+ catchcmd "test.db" ".mode"
+} {0 {current output mode: list}}
+do_test shell1-3.13.2 {
+ catchcmd "test.db" ".mode FOO"
+} {1 {Error: mode should be one of: ascii box column csv html insert json line list markdown qbox quote table tabs tcl}}
+do_test shell1-3.13.3 {
+ catchcmd "test.db" ".mode csv"
+} {0 {}}
+do_test shell1-3.13.4 {
+ catchcmd "test.db" ".mode column"
+} {0 {}}
+do_test shell1-3.13.5 {
+ catchcmd "test.db" ".mode html"
+} {0 {}}
+do_test shell1-3.13.6 {
+ catchcmd "test.db" ".mode insert"
+} {0 {}}
+do_test shell1-3.13.7 {
+ catchcmd "test.db" ".mode line"
+} {0 {}}
+do_test shell1-3.13.8 {
+ catchcmd "test.db" ".mode list"
+} {0 {}}
+do_test shell1-3.13.9 {
+ catchcmd "test.db" ".mode tabs"
+} {0 {}}
+do_test shell1-3.13.10 {
+ catchcmd "test.db" ".mode tcl"
+} {0 {}}
+do_test shell1-3.13.11 {
+ # extra arguments ignored
+ catchcmd "test.db" ".mode tcl BAD"
+} {0 {}}
+
+# .nullvalue STRING Print STRING in place of NULL values
+do_test shell1-3.14.1 {
+ catchcmd "test.db" ".nullvalue"
+} {1 {Usage: .nullvalue STRING}}
+do_test shell1-3.14.2 {
+ catchcmd "test.db" ".nullvalue FOO"
+} {0 {}}
+do_test shell1-3.14.3 {
+ # too many arguments
+ catchcmd "test.db" ".nullvalue FOO BAD"
+} {1 {Usage: .nullvalue STRING}}
+
+# .output FILENAME Send output to FILENAME
+do_test shell1-3.15.1 {
+ catchcmd "test.db" ".output"
+} {0 {}}
+do_test shell1-3.15.2 {
+ catchcmd "test.db" ".output FOO"
+} {0 {}}
+do_test shell1-3.15.3 {
+ # too many arguments
+ catchcmd "test.db" ".output FOO BAD"
+} {1 {ERROR: extra parameter: "BAD". Usage:
+.output ?FILE? Send output to FILE or stdout if FILE is omitted
+ If FILE begins with '|' then open it as a pipe.
+ Options:
+ --bom Prefix output with a UTF8 byte-order mark
+ -e Send output to the system text editor
+ -x Send output as CSV to a spreadsheet
+child process exited abnormally}}
+
+# .output stdout Send output to the screen
+do_test shell1-3.16.1 {
+ catchcmd "test.db" ".output stdout"
+} {0 {}}
+do_test shell1-3.16.2 {
+ # too many arguments
+ catchcmd "test.db" ".output stdout BAD"
+} {1 {ERROR: extra parameter: "BAD". Usage:
+.output ?FILE? Send output to FILE or stdout if FILE is omitted
+ If FILE begins with '|' then open it as a pipe.
+ Options:
+ --bom Prefix output with a UTF8 byte-order mark
+ -e Send output to the system text editor
+ -x Send output as CSV to a spreadsheet
+child process exited abnormally}}
+
+# .prompt MAIN CONTINUE Replace the standard prompts
+do_test shell1-3.17.1 {
+ catchcmd "test.db" ".prompt"
+} {0 {}}
+do_test shell1-3.17.2 {
+ catchcmd "test.db" ".prompt FOO"
+} {0 {}}
+do_test shell1-3.17.3 {
+ catchcmd "test.db" ".prompt FOO BAR"
+} {0 {}}
+do_test shell1-3.17.4 {
+ # too many arguments
+ catchcmd "test.db" ".prompt FOO BAR BAD"
+} {0 {}}
+
+# .quit Exit this program
+do_test shell1-3.18.1 {
+ catchcmd "test.db" ".quit"
+} {0 {}}
+do_test shell1-3.18.2 {
+ # too many arguments
+ catchcmd "test.db" ".quit BAD"
+} {0 {}}
+
+# .read FILENAME Execute SQL in FILENAME
+do_test shell1-3.19.1 {
+ catchcmd "test.db" ".read"
+} {1 {Usage: .read FILE}}
+do_test shell1-3.19.2 {
+ forcedelete FOO
+ catchcmd "test.db" ".read FOO"
+} {1 {Error: cannot open "FOO"}}
+do_test shell1-3.19.3 {
+ # too many arguments
+ catchcmd "test.db" ".read FOO BAD"
+} {1 {Usage: .read FILE}}
+
+# .restore ?DB? FILE Restore content of DB (default "main") from FILE
+do_test shell1-3.20.1 {
+ catchcmd "test.db" ".restore"
+} {1 {Usage: .restore ?DB? FILE}}
+do_test shell1-3.20.2 {
+ catchcmd "test.db" ".restore FOO"
+} {0 {}}
+do_test shell1-3.20.3 {
+ catchcmd "test.db" ".restore FOO BAR"
+} {1 {Error: unknown database FOO}}
+do_test shell1-3.20.4 {
+ # too many arguments
+ catchcmd "test.db" ".restore FOO BAR BAD"
+} {1 {Usage: .restore ?DB? FILE}}
+
+ifcapable vtab {
+# .schema ?TABLE? Show the CREATE statements
+# If TABLE specified, only show tables matching
+# LIKE pattern TABLE.
+do_test shell1-3.21.1 {
+ catchcmd "test.db" ".schema"
+} {0 {}}
+do_test shell1-3.21.2 {
+ catchcmd "test.db" ".schema FOO"
+} {0 {}}
+do_test shell1-3.21.3 {
+ # too many arguments
+ catchcmd "test.db" ".schema FOO BAD"
+} {1 {Usage: .schema ?--indent? ?--nosys? ?LIKE-PATTERN?}}
+
+do_test shell1-3.21.4 {
+ catchcmd "test.db" {
+ CREATE TABLE t1(x);
+ CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
+ CREATE VIEW v1 AS SELECT y+1 FROM v2;
+ }
+ catchcmd "test.db" ".schema"
+} {0 {CREATE TABLE t1(x);
+CREATE VIEW v2 AS SELECT x+1 AS y FROM t1
+/* v2(y) */;
+CREATE VIEW v1 AS SELECT y+1 FROM v2
+/* v1("y+1") */;}}
+
+ catch {db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;}}
+}
+
+# .separator STRING Change column separator used by output and .import
+do_test shell1-3.22.1 {
+ catchcmd "test.db" ".separator"
+} {1 {Usage: .separator COL ?ROW?}}
+do_test shell1-3.22.2 {
+ catchcmd "test.db" ".separator FOO"
+} {0 {}}
+do_test shell1-3.22.3 {
+ catchcmd "test.db" ".separator ABC XYZ"
+} {0 {}}
+do_test shell1-3.22.4 {
+ # too many arguments
+ catchcmd "test.db" ".separator FOO BAD BAD2"
+} {1 {Usage: .separator COL ?ROW?}}
+
+# .show Show the current values for various settings
+do_test shell1-3.23.1 {
+ set res [catchcmd "test.db" ".show"]
+ list [regexp {echo:} $res] \
+ [regexp {explain:} $res] \
+ [regexp {headers:} $res] \
+ [regexp {mode:} $res] \
+ [regexp {nullvalue:} $res] \
+ [regexp {output:} $res] \
+ [regexp {colseparator:} $res] \
+ [regexp {rowseparator:} $res] \
+ [regexp {stats:} $res] \
+ [regexp {width:} $res]
+} {1 1 1 1 1 1 1 1 1 1}
+do_test shell1-3.23.2 {
+ # too many arguments
+ catchcmd "test.db" ".show BAD"
+} {1 {Usage: .show}}
+
+# .stats ON|OFF Turn stats on or off
+#do_test shell1-3.23b.1 {
+# catchcmd "test.db" ".stats"
+#} {1 {Usage: .stats on|off|stmt|vmstep}}
+do_test shell1-3.23b.2 {
+ catchcmd "test.db" ".stats ON"
+} {0 {}}
+do_test shell1-3.23b.3 {
+ catchcmd "test.db" ".stats OFF"
+} {0 {}}
+do_test shell1-3.23b.4 {
+ # too many arguments
+ catchcmd "test.db" ".stats OFF BAD"
+} {1 {Usage: .stats ?on|off|stmt|vmstep?}}
+
+# Ticket 7be932dfa60a8a6b3b26bcf7623ec46e0a403ddb 2018-06-07
+# Adverse interaction between .stats and .eqp
+#
+do_test shell1-3.23b.5 {
+ catchcmd "test.db" [string map {"\n " "\n"} {
+ CREATE TEMP TABLE t1(x);
+ INSERT INTO t1 VALUES(1),(2);
+ .stats on
+ .eqp full
+ SELECT * FROM t1;
+ }]
+} {/1\n2\n/}
+
+# .tables ?TABLE? List names of tables
+# If TABLE specified, only list tables matching
+# LIKE pattern TABLE.
+do_test shell1-3.24.1 {
+ catchcmd "test.db" ".tables"
+} {0 {}}
+do_test shell1-3.24.2 {
+ catchcmd "test.db" ".tables FOO"
+} {0 {}}
+do_test shell1-3.24.3 {
+ # too many arguments
+ catchcmd "test.db" ".tables FOO BAD"
+} {0 {}}
+
+# .timeout MS Try opening locked tables for MS milliseconds
+do_test shell1-3.25.1 {
+ catchcmd "test.db" ".timeout"
+} {0 {}}
+do_test shell1-3.25.2 {
+ catchcmd "test.db" ".timeout zzz"
+ # this should be treated the same as a '0' timeout
+} {0 {}}
+do_test shell1-3.25.3 {
+ catchcmd "test.db" ".timeout 1"
+} {0 {}}
+do_test shell1-3.25.4 {
+ # too many arguments
+ catchcmd "test.db" ".timeout 1 BAD"
+} {0 {}}
+
+# .width NUM NUM ... Set column widths for "column" mode
+do_test shell1-3.26.1 {
+ catchcmd "test.db" ".width"
+} {0 {}}
+do_test shell1-3.26.2 {
+ catchcmd "test.db" ".width xxx"
+ # this should be treated the same as a '0' width for col 1
+} {0 {}}
+do_test shell1-3.26.3 {
+ catchcmd "test.db" ".width xxx yyy"
+ # this should be treated the same as a '0' width for col 1 and 2
+} {0 {}}
+do_test shell1-3.26.4 {
+ catchcmd "test.db" ".width 1 1"
+ # this should be treated the same as a '1' width for col 1 and 2
+} {0 {}}
+do_test shell1-3.26.5 {
+ catchcmd "test.db" ".mode column\n.header off\n.width 10 -10\nSELECT 'abcdefg', 123456;"
+ # this should be treated the same as a '1' width for col 1 and 2
+} {0 {abcdefg 123456}}
+do_test shell1-3.26.6 {
+ catchcmd "test.db" ".mode column\n.header off\n.width -10 10\nSELECT 'abcdefg', 123456;"
+ # this should be treated the same as a '1' width for col 1 and 2
+} {0 { abcdefg 123456 }}
+
+
+# .timer ON|OFF Turn the CPU timer measurement on or off
+do_test shell1-3.27.1 {
+ catchcmd "test.db" ".timer"
+} {1 {Usage: .timer on|off}}
+do_test shell1-3.27.2 {
+ catchcmd "test.db" ".timer ON"
+} {0 {}}
+do_test shell1-3.27.3 {
+ catchcmd "test.db" ".timer OFF"
+} {0 {}}
+do_test shell1-3.27.4 {
+ # too many arguments
+ catchcmd "test.db" ".timer OFF BAD"
+} {1 {Usage: .timer on|off}}
+
+do_test shell1-3-28.1 {
+ catchcmd test.db \
+ ".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');"
+} "0 {(123) hello\n456}"
+
+do_test shell1-3-29.1 {
+ catchcmd "test.db" ".print this is a test"
+} {0 {this is a test}}
+
+# dot-command argument quoting
+do_test shell1-3-30.1 {
+ catchcmd {test.db} {.print "this\"is'a\055test" 'this\"is\\a\055test'}
+} {0 {this"is'a-test this\"is\\a\055test}}
+do_test shell1-3-31.1 {
+ catchcmd {test.db} {.print "this\nis\ta\\test" 'this\nis\ta\\test'}
+} [list 0 "this\nis\ta\\test this\\nis\\ta\\\\test"]
+
+
+# Test the output of the ".dump" command
+#
+do_test shell1-4.1 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA encoding=UTF16;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
+ CREATE TABLE t3(x,y);
+ INSERT INTO t3 VALUES(1,null), (2,''), (3,1),
+ (4,2.25), (5,'hello'), (6,x'807f');
+ }
+ catchcmd test.db {.dump}
+} {0 {PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE t1(x);
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES('');
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2.25);
+INSERT INTO t1 VALUES('hello');
+INSERT INTO t1 VALUES(X'807f');
+CREATE TABLE t3(x,y);
+INSERT INTO t3 VALUES(1,NULL);
+INSERT INTO t3 VALUES(2,'');
+INSERT INTO t3 VALUES(3,1);
+INSERT INTO t3 VALUES(4,2.25);
+INSERT INTO t3 VALUES(5,'hello');
+INSERT INTO t3 VALUES(6,X'807f');
+COMMIT;}}
+
+
+ifcapable vtab {
+
+# The --preserve-rowids option to .dump
+#
+do_test shell1-4.1.1 {
+ catchcmd test.db {.dump --preserve-rowids}
+} {0 {PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE t1(x);
+INSERT INTO t1(rowid,x) VALUES(1,NULL);
+INSERT INTO t1(rowid,x) VALUES(2,'');
+INSERT INTO t1(rowid,x) VALUES(3,1);
+INSERT INTO t1(rowid,x) VALUES(4,2.25);
+INSERT INTO t1(rowid,x) VALUES(5,'hello');
+INSERT INTO t1(rowid,x) VALUES(6,X'807f');
+CREATE TABLE t3(x,y);
+INSERT INTO t3(rowid,x,y) VALUES(1,1,NULL);
+INSERT INTO t3(rowid,x,y) VALUES(2,2,'');
+INSERT INTO t3(rowid,x,y) VALUES(3,3,1);
+INSERT INTO t3(rowid,x,y) VALUES(4,4,2.25);
+INSERT INTO t3(rowid,x,y) VALUES(5,5,'hello');
+INSERT INTO t3(rowid,x,y) VALUES(6,6,X'807f');
+COMMIT;}}
+
+# If the table contains an INTEGER PRIMARY KEY, do not record a separate
+# rowid column in the output.
+#
+do_test shell1-4.1.2 {
+ db close
+ forcedelete test2.db
+ sqlite3 db test2.db
+ db eval {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(1,null), (2,''), (3,1),
+ (4,2.25), (5,'hello'), (6,x'807f');
+ }
+ catchcmd test2.db {.dump --preserve-rowids}
+} {0 {PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+INSERT INTO t1 VALUES(1,NULL);
+INSERT INTO t1 VALUES(2,'');
+INSERT INTO t1 VALUES(3,1);
+INSERT INTO t1 VALUES(4,2.25);
+INSERT INTO t1 VALUES(5,'hello');
+INSERT INTO t1 VALUES(6,X'807f');
+COMMIT;}}
+
+# Verify that the table named [table] is correctly quoted and that
+# an INTEGER PRIMARY KEY DESC is not an alias for the rowid.
+#
+do_test shell1-4.1.3 {
+ db close
+ forcedelete test2.db
+ sqlite3 db test2.db
+ db eval {
+ CREATE TABLE [table](x INTEGER PRIMARY KEY DESC, y);
+ INSERT INTO [table] VALUES(1,null), (12,''), (23,1),
+ (34,2.25), (45,'hello'), (56,x'807f');
+ }
+ catchcmd test2.db {.dump --preserve-rowids}
+} {0 {PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE [table](x INTEGER PRIMARY KEY DESC, y);
+INSERT INTO "table"(rowid,x,y) VALUES(1,1,NULL);
+INSERT INTO "table"(rowid,x,y) VALUES(2,12,'');
+INSERT INTO "table"(rowid,x,y) VALUES(3,23,1);
+INSERT INTO "table"(rowid,x,y) VALUES(4,34,2.25);
+INSERT INTO "table"(rowid,x,y) VALUES(5,45,'hello');
+INSERT INTO "table"(rowid,x,y) VALUES(6,56,X'807f');
+COMMIT;}}
+
+# Do not record rowids for a WITHOUT ROWID table. Also check correct quoting
+# of table names that contain odd characters.
+#
+do_test shell1-4.1.4 {
+ db close
+ forcedelete test2.db
+ sqlite3 db test2.db
+ db eval {
+ CREATE TABLE [ta<>ble](x INTEGER PRIMARY KEY, y) WITHOUT ROWID;
+ INSERT INTO [ta<>ble] VALUES(1,null), (12,''), (23,1),
+ (34,2.25), (45,'hello'), (56,x'807f');
+ }
+ catchcmd test2.db {.dump --preserve-rowids}
+} {0 {PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE [ta<>ble](x INTEGER PRIMARY KEY, y) WITHOUT ROWID;
+INSERT INTO "ta<>ble" VALUES(1,NULL);
+INSERT INTO "ta<>ble" VALUES(12,'');
+INSERT INTO "ta<>ble" VALUES(23,1);
+INSERT INTO "ta<>ble" VALUES(34,2.25);
+INSERT INTO "ta<>ble" VALUES(45,'hello');
+INSERT INTO "ta<>ble" VALUES(56,X'807f');
+COMMIT;}}
+
+# Do not record rowids if the rowid is inaccessible
+#
+do_test shell1-4.1.5 {
+ db close
+ forcedelete test2.db
+ sqlite3 db test2.db
+ db eval {
+ CREATE TABLE t1(_ROWID_,rowid,oid);
+ INSERT INTO t1 VALUES(1,null,'alpha'), (12,'',99), (23,1,x'b0b1b2');
+ }
+ catchcmd test2.db {.dump --preserve-rowids}
+} {0 {PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE t1(_ROWID_,rowid,oid);
+INSERT INTO t1 VALUES(1,NULL,'alpha');
+INSERT INTO t1 VALUES(12,'',99);
+INSERT INTO t1 VALUES(23,1,X'b0b1b2');
+COMMIT;}}
+
+} else {
+
+do_test shell1-4.1.6 {
+ db close
+ forcedelete test2.db
+ sqlite3 db test2.db
+ db eval {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(1,null), (2,''), (3,1),
+ (4,2.25), (5,'hello'), (6,x'807f');
+ }
+ catchcmd test2.db {.dump --preserve-rowids}
+} {1 {The --preserve-rowids option is not compatible with SQLITE_OMIT_VIRTUALTABLE}}
+
+}
+
+
+# Test the output of ".mode insert"
+#
+do_test shell1-4.2.1 {
+ catchcmd test.db ".mode insert t1\nselect * from t1;"
+} {0 {INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES('');
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2.25);
+INSERT INTO t1 VALUES('hello');
+INSERT INTO t1 VALUES(X'807f');}}
+
+# Test the output of ".mode insert" with headers
+#
+do_test shell1-4.2.2 {
+ catchcmd test.db ".mode insert t1\n.headers on\nselect * from t1;"
+} {0 {INSERT INTO t1(x) VALUES(NULL);
+INSERT INTO t1(x) VALUES('');
+INSERT INTO t1(x) VALUES(1);
+INSERT INTO t1(x) VALUES(2.25);
+INSERT INTO t1(x) VALUES('hello');
+INSERT INTO t1(x) VALUES(X'807f');}}
+
+# Test the output of ".mode insert"
+#
+do_test shell1-4.2.3 {
+ catchcmd test.db ".mode insert t3\nselect * from t3;"
+} {0 {INSERT INTO t3 VALUES(1,NULL);
+INSERT INTO t3 VALUES(2,'');
+INSERT INTO t3 VALUES(3,1);
+INSERT INTO t3 VALUES(4,2.25);
+INSERT INTO t3 VALUES(5,'hello');
+INSERT INTO t3 VALUES(6,X'807f');}}
+
+# Test the output of ".mode insert" with headers
+#
+do_test shell1-4.2.4 {
+ catchcmd test.db ".mode insert t3\n.headers on\nselect * from t3;"
+} {0 {INSERT INTO t3(x,y) VALUES(1,NULL);
+INSERT INTO t3(x,y) VALUES(2,'');
+INSERT INTO t3(x,y) VALUES(3,1);
+INSERT INTO t3(x,y) VALUES(4,2.25);
+INSERT INTO t3(x,y) VALUES(5,'hello');
+INSERT INTO t3(x,y) VALUES(6,X'807f');}}
+
+# Test the output of ".mode tcl"
+#
+do_test shell1-4.3 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA encoding=UTF8;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
+ }
+ catchcmd test.db ".mode tcl\nselect * from t1;"
+} {0 {""
+""
+"1"
+"2.25"
+"hello"
+"\200\177"}}
+
+# Test the output of ".mode tcl" with multiple columns
+#
+do_test shell1-4.4 {
+ db eval {
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(null, ''), (1, 2.25), ('hello', x'807f');
+ }
+ catchcmd test.db ".mode tcl\nselect * from t2;"
+} {0 {"" ""
+"1" "2.25"
+"hello" "\200\177"}}
+
+# Test the output of ".mode tcl" with ".nullvalue"
+#
+do_test shell1-4.5 {
+ catchcmd test.db ".mode tcl\n.nullvalue NULL\nselect * from t2;"
+} {0 {"NULL" ""
+"1" "2.25"
+"hello" "\200\177"}}
+
+# Test the output of ".mode tcl" with Tcl reserved characters
+#
+do_test shell1-4.6 {
+ db eval {
+ CREATE TABLE tcl1(x);
+ INSERT INTO tcl1 VALUES('"'), ('['), (']'), ('\{'), ('\}'), (';'), ('$');
+ }
+ foreach {x y} [catchcmd test.db ".mode tcl\nselect * from tcl1;"] break
+ list $x $y [llength $y]
+} {0 {"\""
+"["
+"]"
+"\\{"
+"\\}"
+";"
+"$"} 7}
+
+# Test the output of ".mode quote"
+#
+do_test shell1-4.7 {
+ catchcmd test.db ".mode quote\nselect x'0123456789ABCDEF';"
+} {0 X'0123456789abcdef'}
+
+# Test using arbitrary byte data with the shell via standard input/output.
+#
+do_test shell1-5.0 {
+ #
+ # NOTE: Skip NUL byte because it appears to be incompatible with command
+ # shell argument parsing.
+ #
+ for {set i 1} {$i < 256} {incr i} {
+ #
+ # NOTE: Due to how the Tcl [exec] command works (i.e. where it treats
+ # command channels opened for it as textual ones), the carriage
+ # return character (and on Windows, the end-of-file character)
+ # cannot be used here.
+ #
+ if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} {
+ continue
+ }
+ # Tcl 8.7 maps 0x80 through 0x9f into valid UTF8. So skip those tests.
+ if {$i>=0x80 && $i<=0x9f} continue
+ if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue
+ if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"} continue
+ set hex [format %02X $i]
+ set char [subst \\x$hex]; set oldChar $char
+ set escapes [list]
+ if {$tcl_platform(platform)=="windows"} {
+ #
+ # NOTE: On Windows, we need to escape all the whitespace characters,
+ # the alarm (\a) character, and those with special meaning to
+ # the SQLite shell itself.
+ #
+ set escapes [list \
+ \a \\a \b \\b \t \\t \n \\n \v \\v \f \\f \r \\r \
+ " " "\" \"" \" \\\" ' \"'\" \\ \\\\]
+ } else {
+ #
+ # NOTE: On Unix, we need to escape most of the whitespace characters
+ # and those with special meaning to the SQLite shell itself.
+ # The alarm (\a), backspace (\b), and carriage-return (\r)
+ # characters do not appear to require escaping on Unix. For
+ # the alarm and backspace characters, this is probably due to
+ # differences in the command shell. For the carriage-return,
+ # it is probably due to differences in how Tcl handles command
+ # channel end-of-line translations.
+ #
+ set escapes [list \
+ \t \\t \n \\n \v \\v \f \\f \
+ " " "\" \"" \" \\\" ' \"'\" \\ \\\\]
+ }
+ set char [string map $escapes $char]
+ set x [catchcmdex test.db ".print $char\n"]
+ set code [lindex $x 0]
+ set res [lindex $x 1]
+ if {$code ne "0"} {
+ error "failed with error: $res"
+ }
+ if {$res ne "$oldChar\n"} {
+ if {[llength $res] > 0} {
+ set got [format %02X [scan $res %c]]
+ } else {
+ set got <empty>
+ }
+ error "failed with byte $hex mismatch, got $got"
+ }
+ }
+} {}
+
+# These test cases do not work on MinGW
+if 0 {
+
+# The string used here is the word "test" in Chinese.
+# In UTF-8, it is encoded as: \xE6\xB5\x8B\xE8\xAF\x95
+set test \u6D4B\u8BD5
+
+do_test shell1-6.0 {
+ set fileName $test; append fileName .db
+ catch {forcedelete $fileName}
+ set x [catchcmdex $fileName "CREATE TABLE t1(x);\n.schema\n"]
+ set code [lindex $x 0]
+ set res [string trim [lindex $x 1]]
+ if {$code ne "0"} {
+ error "failed with error: $res"
+ }
+ if {$res ne "CREATE TABLE t1(x);"} {
+ error "failed with mismatch: $res"
+ }
+ if {![file exists $fileName]} {
+ error "file \"$fileName\" (Unicode) does not exist"
+ }
+ forcedelete $fileName
+} {}
+
+do_test shell1-6.1 {
+ catch {forcedelete test3.db}
+ set x [catchcmdex test3.db \
+ "CREATE TABLE [encoding convertto utf-8 $test](x);\n.schema\n"]
+ set code [lindex $x 0]
+ set res [string trim [lindex $x 1]]
+ if {$code ne "0"} {
+ error "failed with error: $res"
+ }
+ if {$res ne "CREATE TABLE ${test}(x);"} {
+ error "failed with mismatch: $res"
+ }
+ forcedelete test3.db
+} {}
+}
+
+db close
+forcedelete test.db test.db-journal test.db-wal
+sqlite3 db test.db
+
+# The shell tool ".schema" command uses virtual table "pragma_database_list"
+#
+ifcapable vtab {
+
+do_test shell1-7.1.1 {
+ db eval {
+ CREATE TABLE Z (x TEXT PRIMARY KEY);
+ CREATE TABLE _ (x TEXT PRIMARY KEY);
+ CREATE TABLE YY (x TEXT PRIMARY KEY);
+ CREATE TABLE __ (x TEXT PRIMARY KEY);
+ CREATE TABLE WWW (x TEXT PRIMARY KEY);
+ CREATE TABLE ___ (x TEXT PRIMARY KEY);
+ }
+} {}
+do_test shell1-7.1.2 {
+ catchcmd "test.db" ".schema _"
+} {0 {CREATE TABLE Z (x TEXT PRIMARY KEY);
+CREATE TABLE _ (x TEXT PRIMARY KEY);}}
+do_test shell1-7.1.3 {
+ catchcmd "test.db" ".schema \\\\_"
+} {0 {CREATE TABLE _ (x TEXT PRIMARY KEY);}}
+do_test shell1-7.1.4 {
+ catchcmd "test.db" ".schema __"
+} {0 {CREATE TABLE YY (x TEXT PRIMARY KEY);
+CREATE TABLE __ (x TEXT PRIMARY KEY);}}
+do_test shell1-7.1.5 {
+ catchcmd "test.db" ".schema \\\\_\\\\_"
+} {0 {CREATE TABLE __ (x TEXT PRIMARY KEY);}}
+do_test shell1-7.1.6 {
+ catchcmd "test.db" ".schema ___"
+} {0 {CREATE TABLE WWW (x TEXT PRIMARY KEY);
+CREATE TABLE ___ (x TEXT PRIMARY KEY);}}
+do_test shell1-7.1.7 {
+ catchcmd "test.db" ".schema \\\\_\\\\_\\\\_"
+} {0 {CREATE TABLE ___ (x TEXT PRIMARY KEY);}}
+
+}
+
+# Test case for the ieee754 and decimal extensions in the shell.
+# See the "floatingpoint.html" file in the documentation for more
+# information.
+#
+do_test shell1-8.1 {
+ catchcmd ":memory:" {
+ -- The pow2 table will hold all the necessary powers of two.
+ CREATE TABLE pow2(x INTEGER PRIMARY KEY, v TEXT);
+ WITH RECURSIVE c(x,v) AS (
+ VALUES(0,'1')
+ UNION ALL
+ SELECT x+1, decimal_mul(v,'2') FROM c WHERE x+1<=971
+ ) INSERT INTO pow2(x,v) SELECT x, v FROM c;
+ WITH RECURSIVE c(x,v) AS (
+ VALUES(-1,'0.5')
+ UNION ALL
+ SELECT x-1, decimal_mul(v,'0.5') FROM c WHERE x-1>=-1075
+ ) INSERT INTO pow2(x,v) SELECT x, v FROM c;
+
+ -- This query finds the decimal representation of each value in the "c" table.
+ WITH c(n) AS (VALUES(47.49))
+ ----XXXXX----------- Replace with whatever you want
+ SELECT decimal_mul(ieee754_mantissa(c.n),pow2.v)
+ FROM pow2, c WHERE pow2.x=ieee754_exponent(c.n);
+ }
+} {0 47.49000000000000198951966012828052043914794921875}
+do_test shell1-8.2 {
+ catchcmd :memory: {
+.mode box
+SELECT ieee754(47.49) AS x;
+ }
+} {0 {┌───────────────────────────────┐
+│ x │
+├───────────────────────────────┤
+│ ieee754(6683623321994527,-47) │
+└───────────────────────────────┘}}
+do_test shell1-8.3 {
+ catchcmd ":memory: --box" {
+ select ieee754(6683623321994527,-47) as x;
+ }
+} {0 {┌───────┐
+│ x │
+├───────┤
+│ 47.49 │
+└───────┘}}
+do_test shell1-8.4 {
+ catchcmd ":memory: --table" {SELECT ieee754_mantissa(47.49) AS M, ieee754_exponent(47.49) AS E;}
+} {0 {+------------------+-----+
+| M | E |
++------------------+-----+
+| 6683623321994527 | -47 |
++------------------+-----+}}
+do_test shell1-8.5 {
+ catchcmd ":memory: --box" {
+create table t(a text, b int);
+insert into t values ('too long for one line', 1), ('shorter', NULL);
+.header on
+.width 10 10
+.nullvalue NADA
+select * from t;}
+} {0 {┌────────────┬────────────┐
+│ a │ b │
+├────────────┼────────────┤
+│ too long f │ 1 │
+│ or one lin │ │
+│ e │ │
+├────────────┼────────────┤
+│ shorter │ NADA │
+└────────────┴────────────┘}}
+
+#----------------------------------------------------------------------------
+# Test cases shell1-9.*: Basic test that "dot" commands and SQL intermix ok.
+#
+do_test shell1-9.1 {
+ catchcmd :memory: {
+.mode csv
+/*
+x */ select 1,2; --x
+ -- .nada
+;
+.mode csv
+--x
+select 2,1; select 3,4;
+}
+} {0 {1,2
+2,1
+3,4}}
+
+finish_test
diff --git a/test/shell2.test b/test/shell2.test
new file mode 100644
index 0000000..6b5c2bc
--- /dev/null
+++ b/test/shell2.test
@@ -0,0 +1,206 @@
+# 2009 Nov 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.
+#
+#***********************************************************************
+#
+# The focus of this file is testing the CLI shell tool.
+#
+# $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
+#
+
+# Test plan:
+#
+# shell2-1.*: Misc. test of various tickets and reported errors.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set CLI [test_find_cli]
+db close
+forcedelete test.db test.db-journal test.db-wal
+sqlite3 db test.db
+
+
+#----------------------------------------------------------------------------
+# shell2-1.*: Misc. test of various tickets and reported errors.
+#
+
+# Batch mode not creating databases.
+# Reported on mailing list by Ken Zalewski.
+# Ticket [aeff892c57].
+do_test shell2-1.1.1 {
+ forcedelete foo.db
+ set rc [ catchcmd "-batch foo.db" "CREATE TABLE t1(a);" ]
+ set fexist [file exist foo.db]
+ list $rc $fexist
+} {{0 {}} 1}
+
+# Shell silently ignores extra parameters.
+# Ticket [f5cb008a65].
+do_test shell2-1.2.1 {
+ catchcmdex {:memory: "select+3" "select+4"}
+} {0 {3
+4
+}}
+
+# Test a problem reported on the mailing list. The shell was at one point
+# returning the generic SQLITE_ERROR message ("SQL error or missing database")
+# instead of the "too many levels..." message in the test below.
+#
+do_test shell2-1.3 {
+ catchcmd "-batch test.db" {
+ PRAGMA recursive_triggers = ON;
+ CREATE TABLE t5(a PRIMARY KEY, b, c);
+ INSERT INTO t5 VALUES(1, 2, 3);
+ CREATE TRIGGER au_tble AFTER UPDATE ON t5 BEGIN
+ UPDATE OR IGNORE t5 SET a = new.a, c = 10;
+ END;
+
+ UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1;
+ }
+} {1 {Runtime error near line 9: too many levels of trigger recursion}}
+
+
+
+# Shell not echoing all commands with echo on.
+# Ticket [eb620916be].
+
+# Test with echo off
+# NB. whitespace is important
+do_test shell2-1.4.1 {
+ forcedelete foo.db
+ catchcmd "foo.db" {CREATE TABLE foo(a);
+INSERT INTO foo(a) VALUES(1);
+SELECT * FROM foo;}
+} {0 1}
+
+# Test with echo on using command line option
+# NB. whitespace is important
+do_test shell2-1.4.2 {
+ forcedelete foo.db
+ catchcmd "-echo foo.db" {CREATE TABLE foo(a);
+INSERT INTO foo(a) VALUES(1);
+SELECT * FROM foo;}
+} {0 {CREATE TABLE foo(a);
+INSERT INTO foo(a) VALUES(1);
+SELECT * FROM foo;
+1}}
+
+# Test with echo on using dot command
+# NB. whitespace is important
+do_test shell2-1.4.3 {
+ forcedelete foo.db
+ catchcmd "foo.db" {.echo ON
+CREATE TABLE foo(a);
+INSERT INTO foo(a) VALUES(1);
+SELECT * FROM foo;}
+} {0 {CREATE TABLE foo(a);
+INSERT INTO foo(a) VALUES(1);
+SELECT * FROM foo;
+1}}
+
+# Test with echo on using dot command and
+# turning off mid- processing.
+# NB. whitespace is important
+do_test shell2-1.4.4 {
+ forcedelete foo.db
+ catchcmd "foo.db" {.echo ON
+CREATE TABLE foo(a);
+.echo OFF
+INSERT INTO foo(a) VALUES(1);
+SELECT * FROM foo;}
+} {0 {CREATE TABLE foo(a);
+.echo OFF
+1}}
+
+# Test with echo on using dot command and
+# multiple commands per line.
+# NB. whitespace is important
+do_test shell2-1.4.5 {
+ forcedelete foo.db
+ catchcmdex "foo.db" {.echo ON
+CREATE TABLE foo1(a);
+INSERT INTO foo1(a) VALUES(1);
+CREATE TABLE foo2(b);
+INSERT INTO foo2(b) VALUES(1);
+SELECT * FROM foo1; SELECT * FROM foo2;
+INSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);
+SELECT * FROM foo1; SELECT * FROM foo2;
+}
+} {0 {CREATE TABLE foo1(a);
+INSERT INTO foo1(a) VALUES(1);
+CREATE TABLE foo2(b);
+INSERT INTO foo2(b) VALUES(1);
+SELECT * FROM foo1; SELECT * FROM foo2;
+1
+1
+INSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);
+SELECT * FROM foo1; SELECT * FROM foo2;
+1
+2
+1
+2
+}}
+
+# Test with echo on and headers on using dot command and
+# multiple commands per line.
+# NB. whitespace is important
+do_test shell2-1.4.6 {
+ forcedelete foo.db
+ catchcmdex "foo.db" {.echo ON
+.headers ON
+CREATE TABLE foo1(a);
+INSERT INTO foo1(a) VALUES(1);
+CREATE TABLE foo2(b);
+INSERT INTO foo2(b) VALUES(1);
+SELECT * FROM foo1; SELECT * FROM foo2;
+INSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);
+SELECT * FROM foo1; SELECT * FROM foo2;
+}
+} {0 {.headers ON
+CREATE TABLE foo1(a);
+INSERT INTO foo1(a) VALUES(1);
+CREATE TABLE foo2(b);
+INSERT INTO foo2(b) VALUES(1);
+SELECT * FROM foo1; SELECT * FROM foo2;
+a
+1
+b
+1
+INSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);
+SELECT * FROM foo1; SELECT * FROM foo2;
+a
+1
+2
+b
+1
+2
+}}
+
+# Test for rejection of incomplete input at EOF.
+# Reported at https://sqlite.org/forum/forumpost/718f489a43be3197
+do_test shell2-1.4.7 {
+ catchcmd ":memory:" {
+ SELECT 'unclosed;}
+} {1 {Parse error near line 2: unrecognized token: "'unclosed;"
+ SELECT 'unclosed;
+ ^--- error here}}
+
+# Verify that safe mode rejects certain UDFs
+# Reported at https://sqlite.org/forum/forumpost/07beac8056151b2f
+do_test shell2-1.4.8 {
+ catchcmd "-safe :memory:" {
+ SELECT edit('DoNotCare');}
+} {1 {line 2: cannot use the edit() function in safe mode}}
+do_test shell2-1.4.9 {
+ catchcmd "-safe :memory:" {
+ SELECT writefile('DoNotCare', x'');}
+} {1 {line 2: cannot use the writefile() function in safe mode}}
+
+
+finish_test
diff --git a/test/shell3.test b/test/shell3.test
new file mode 100644
index 0000000..f8d6994
--- /dev/null
+++ b/test/shell3.test
@@ -0,0 +1,138 @@
+# 2009 Dec 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.
+#
+#***********************************************************************
+#
+# The focus of this file is testing the CLI shell tool.
+#
+# $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
+#
+
+# Test plan:
+#
+# shell3-1.*: Basic tests for running SQL statments from command line.
+# shell3-2.*: Basic tests for running SQL file from command line.
+# shell3-3.*: Basic tests for processing odd SQL constructs.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set CLI [test_cli_invocation]
+db close
+forcedelete test.db test.db-journal test.db-wal
+sqlite3 db test.db
+
+
+# There are inconsistencies in command-line argument quoting on Windows.
+# In particular, individual applications are responsible for command-line
+# parsing in Windows, not the shell. Depending on whether the sqlite3.exe
+# program is compiled with MinGW or MSVC, the command-line parsing is
+# different. This causes problems for the tests below. To avoid
+# issues, these tests are disabled for windows.
+#
+if {$::tcl_platform(platform)=="windows"} {
+ finish_test
+ return
+}
+
+#----------------------------------------------------------------------------
+# shell3-1.*: Basic tests for running SQL statments from command line.
+#
+
+# Run SQL statement from command line
+do_test shell3-1.1 {
+ forcedelete foo.db
+ set rc [ catchcmd "foo.db \"CREATE TABLE t1(a);\"" ]
+ set fexist [file exist foo.db]
+ list $rc $fexist
+} {{0 {}} 1}
+do_test shell3-1.2 {
+ catchcmd "foo.db" ".tables"
+} {0 t1}
+do_test shell3-1.3 {
+ catchcmd "foo.db \"DROP TABLE t1;\""
+} {0 {}}
+do_test shell3-1.4 {
+ catchcmd "foo.db" ".tables"
+} {0 {}}
+do_test shell3-1.5 {
+ catchcmd "foo.db \"CREATE TABLE t1(a); DROP TABLE t1;\""
+} {0 {}}
+do_test shell3-1.6 {
+ catchcmd "foo.db" ".tables"
+} {0 {}}
+do_test shell3-1.7 {
+ catchcmd "foo.db \"CREATE TABLE\""
+} {1 {Error: in prepare, incomplete input}}
+
+#----------------------------------------------------------------------------
+# shell3-2.*: Basic tests for running SQL file from command line.
+#
+
+# Run SQL file from command line
+do_test shell3-2.1 {
+ forcedelete foo.db
+ set rc [ catchcmd "foo.db" "CREATE TABLE t1(a);" ]
+ set fexist [file exist foo.db]
+ list $rc $fexist
+} {{0 {}} 1}
+do_test shell3-2.2 {
+ catchcmd "foo.db" ".tables"
+} {0 t1}
+do_test shell3-2.3 {
+ catchcmd "foo.db" "DROP TABLE t1;"
+} {0 {}}
+do_test shell3-2.4 {
+ catchcmd "foo.db" ".tables"
+} {0 {}}
+do_test shell3-2.5 {
+ catchcmd "foo.db" "CREATE TABLE t1(a); DROP TABLE t1;"
+} {0 {}}
+do_test shell3-2.6 {
+ catchcmd "foo.db" ".tables"
+} {0 {}}
+do_test shell3-2.7 {
+ catchcmd "foo.db" "CREATE TABLE"
+} {1 {Parse error near line 1: incomplete input}}
+
+
+#----------------------------------------------------------------------------
+# shell3-3.*: Basic tests for processing odd SQL constructs.
+#
+
+# Run combinations of odd identifiers, comments, semicolon placement
+do_test shell3-3.1 {
+ forcedelete foo.db
+ set rc [ catchcmd "foo.db" {CREATE TABLE t1("
+a--.
+" --x
+); CREATE TABLE t2("a[""b""]");
+.header on
+INSERT INTO t1 VALUES ('
+x''y');
+INSERT INTO t2 VALUES ('
+/*.
+.*/ x
+''y');
+SELECT * from t1 limit 1;
+SELECT * from t2 limit 1;
+} ]
+ set fexist [file exist foo.db]
+ list $rc $fexist
+} {{0 {
+a--.
+
+
+x'y
+a["b"]
+
+/*.
+.*/ x
+'y}} 1}
+
+finish_test
diff --git a/test/shell4.test b/test/shell4.test
new file mode 100644
index 0000000..0680722
--- /dev/null
+++ b/test/shell4.test
@@ -0,0 +1,150 @@
+# 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.
+#
+#***********************************************************************
+#
+# The focus of this file is testing the CLI shell tool.
+# These tests are specific to the .stats command.
+#
+# 2015-03-19: Added tests for .trace
+
+# Test plan:
+#
+# shell4-1.*: Basic tests specific to the "stats" command.
+# shell4-2.*: Basic tests for ".trace"
+# shell4-3.*: The ".read" command takes the shell out of interactive mode
+# shell4-4.*: Input redirects cannot recurse too much
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set CLI [test_cli_invocation]
+set CLI_ONLY [test_find_cli]
+db close
+forcedelete test.db test.db-journal test.db-wal
+sqlite3 db test.db
+
+#----------------------------------------------------------------------------
+# Test cases shell4-1.*: Tests specific to the "stats" command.
+#
+
+# should default to off
+do_test shell4-1.1.1 {
+ set res [catchcmd "test.db" ".show"]
+ list [regexp {stats: off} $res]
+} {1}
+
+do_test shell4-1.1.2 {
+ set res [catchcmd "test.db" ".show"]
+ list [regexp {stats: on} $res]
+} {0}
+
+# -stats should turn it on
+do_test shell4-1.2.1 {
+ set res [catchcmd "-stats test.db" ".show"]
+ list [regexp {stats: on} $res]
+} {1}
+
+do_test shell4-1.2.2 {
+ set res [catchcmd "-stats test.db" ".show"]
+ list [regexp {stats: off} $res]
+} {0}
+
+# .stats ON|OFF Turn stats on or off
+#do_test shell4-1.3.1 {
+# catchcmd "test.db" ".stats"
+#} {1 {Usage: .stats on|off}}
+do_test shell4-1.3.2 {
+ catchcmd "test.db" ".stats ON"
+} {0 {}}
+do_test shell4-1.3.3 {
+ catchcmd "test.db" ".stats OFF"
+} {0 {}}
+do_test shell4-1.3.4 {
+ # too many arguments
+ catchcmd "test.db" ".stats OFF BAD"
+} {1 {Usage: .stats ?on|off|stmt|vmstep?}}
+
+# NB. whitespace is important
+do_test shell4-1.4.1 {
+ set res [catchcmd "test.db" {.show}]
+ list [regexp {stats: off} $res]
+} {1}
+
+do_test shell4-1.4.2 {
+ set res [catchcmd "test.db" {.stats ON
+.show
+}]
+ list [regexp {stats: on} $res]
+} {1}
+
+do_test shell4-1.4.3 {
+ set res [catchcmd "test.db" {.stats OFF
+.show
+}]
+ list [regexp {stats: off} $res]
+} {1}
+
+# make sure stats not present when off
+do_test shell4-1.5.1 {
+ set res [catchcmd "test.db" {SELECT 1;}]
+ list [regexp {Memory Used} $res] \
+ [regexp {Heap Usage} $res] \
+ [regexp {Autoindex Inserts} $res]
+} {0 0 0}
+
+# make sure stats are present when on
+do_test shell4-1.5.2 {
+ set res [catchcmd "test.db" {.stats ON
+SELECT 1;
+}]
+ list [regexp {Memory Used} $res] \
+ [regexp {Heap Usage} $res] \
+ [regexp {Autoindex Inserts} $res]
+} {1 1 1}
+
+ifcapable trace {
+do_test shell4-2.1 {
+ catchcmd ":memory:" "CREATE TABLE t1(x);\n.trace --unknown"
+} {1 {Unknown option "--unknown" on ".trace"}}
+do_test shell4-2.2 {
+ catchcmd ":memory:" "CREATE TABLE t1(x);\n.trace off\n.trace off\n"
+} {0 {}}
+do_test shell4-2.3 {
+ catchcmd ":memory:" ".trace stdout\n.dump\n.trace off\n"
+} {/^0 {PRAGMA.*}$/}
+do_test shell4-2.4 {
+ catchcmd ":memory:" ".trace stdout\nCREATE TABLE t1(x);SELECT * FROM t1;"
+} {0 {CREATE TABLE t1(x);
+SELECT * FROM t1;}}
+do_test shell4-2.5 {
+ catchcmd ":memory:" "CREATE TABLE t1(x);\n.trace stdout\nSELECT * FROM t1;"
+} {0 {SELECT * FROM t1;}}
+}
+
+do_test shell4-3.1 {
+ set fd [open t1.txt wb]
+ puts $fd "SELECT 'squirrel';"
+ close $fd
+ exec $::CLI_ONLY :memory: --interactive ".read t1.txt"
+} {squirrel}
+do_test shell4-3.2 {
+ set fd [open t1.txt wb]
+ puts $fd "SELECT 'pound: \302\243';"
+ close $fd
+ exec $::CLI_ONLY :memory: --interactive ".read t1.txt"
+} {pound: £}
+
+do_test shell4-4.1 {
+ set fd [open t1.txt wb]
+ puts $fd ".read t1.txt"
+ close $fd
+ catchcmd ":memory:" ".read t1.txt"
+} {1 {Input nesting limit (25) reached at line 1. Check recursion.}}
+
+finish_test
diff --git a/test/shell5.test b/test/shell5.test
new file mode 100644
index 0000000..39018a0
--- /dev/null
+++ b/test/shell5.test
@@ -0,0 +1,573 @@
+# 2010 August 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.
+#
+#***********************************************************************
+#
+# The focus of this file is testing the CLI shell tool.
+# These tests are specific to the .import command.
+#
+# $Id: shell5.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
+#
+
+# Test plan:
+#
+# shell5-1.*: Basic tests specific to the ".import" command.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set CLI [test_cli_invocation]
+db close
+forcedelete test.db test.db-journal test.db-wal
+
+#----------------------------------------------------------------------------
+# Test cases shell5-1.*: Basic handling of the .import and .separator commands.
+#
+
+# .import FILE TABLE Import data from FILE into TABLE
+do_test shell5-1.1.1 {
+ catchcmd "test.db" ".import"
+} {/1 .ERROR: missing FILE argument.*/}
+do_test shell5-1.1.2 {
+ catchcmd "test.db" ".import FOO"
+} {/1 .ERROR: missing TABLE argument.*/}
+do_test shell5-1.1.3 {
+ # too many arguments
+ catchcmd "test.db" ".import FOO BAR BAD"
+} {/1 .ERROR: extra argument.*/}
+
+# .separator STRING Change separator used by output mode and .import
+do_test shell5-1.2.1 {
+ catchcmd "test.db" ".separator"
+} {1 {Usage: .separator COL ?ROW?}}
+do_test shell5-1.2.2 {
+ catchcmd "test.db" ".separator ONE"
+} {0 {}}
+do_test shell5-1.2.3 {
+ catchcmd "test.db" ".separator ONE TWO"
+} {0 {}}
+do_test shell5-1.2.4 {
+ # too many arguments
+ catchcmd "test.db" ".separator ONE TWO THREE"
+} {1 {Usage: .separator COL ?ROW?}}
+
+# column separator should default to "|"
+do_test shell5-1.3.1.1 {
+ set res [catchcmd "test.db" ".show"]
+ list [regexp {colseparator: \"\|\"} $res]
+} {1}
+
+# row separator should default to "\n"
+do_test shell5-1.3.1.2 {
+ set res [catchcmd "test.db" ".show"]
+ list [regexp {rowseparator: \"\\n\"} $res]
+} {1}
+
+# set separator to different value.
+# check that .show reports new value
+do_test shell5-1.3.2 {
+ set res [catchcmd "test.db" {.separator ,
+.show}]
+ list [regexp {separator: \",\"} $res]
+} {1}
+
+# import file doesn't exist
+do_test shell5-1.4.1 {
+ forcedelete FOO
+ set res [catchcmd "test.db" {CREATE TABLE t1(a, b);
+.import FOO t1}]
+} {1 {Error: cannot open "FOO"}}
+
+# empty import file
+do_test shell5-1.4.2 {
+ forcedelete shell5.csv
+ set in [open shell5.csv w]
+ close $in
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.import -schema test shell5.csv t1
+SELECT COUNT(*) FROM test.t1;}]
+} {0 0}
+
+# import file with 1 row, 1 column (expecting 2 cols)
+do_test shell5-1.4.3 {
+ set in [open shell5.csv w]
+ puts $in "1"
+ close $in
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.import -schema test shell5.csv t1}]
+} {1 {shell5.csv:1: expected 2 columns but found 1 - filling the rest with NULL}}
+
+# import file with 1 row, 3 columns (expecting 2 cols)
+do_test shell5-1.4.4 {
+ set in [open shell5.csv w]
+ puts $in "1|2|3"
+ close $in
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.import --schema test shell5.csv t1}]
+} {1 {shell5.csv:1: expected 2 columns but found 3 - extras ignored}}
+
+# import file with 1 row, 2 columns
+do_test shell5-1.4.5 {
+ set in [open shell5.csv w]
+ puts $in "1|2"
+ close $in
+ set res [catchcmd "test.db" {DELETE FROM t1;
+.import shell5.csv t1
+SELECT COUNT(*) FROM t1;}]
+} {0 1}
+
+# import file with 2 rows, 2 columns
+# note we end up with 3 rows because of the 1 row
+# imported above.
+do_test shell5-1.4.6 {
+ set in [open shell5.csv w]
+ puts $in "2|3"
+ puts $in "3|4"
+ close $in
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.import -schema test shell5.csv t1
+SELECT COUNT(*) FROM test.t1;}]
+} {0 3}
+
+# import file with 1 row, 2 columns, using a comma
+do_test shell5-1.4.7 {
+ set in [open shell5.csv w]
+ puts $in "4,5"
+ close $in
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.separator ,
+.import --schema test shell5.csv t1
+SELECT COUNT(*) FROM test.t1;}]
+} {0 4}
+
+# import file with 1 row, 2 columns, text data
+do_test shell5-1.4.8.1 {
+ set in [open shell5.csv w]
+ puts $in "5|Now is the time for all good men to come to the aid of their country."
+ close $in
+ set res [catchcmd "test.db" {.import shell5.csv t1
+SELECT COUNT(*) FROM t1;}]
+} {0 5}
+
+do_test shell5-1.4.8.2 {
+ catchcmd "test.db" {SELECT b FROM t1 WHERE a='5';}
+} {0 {Now is the time for all good men to come to the aid of their country.}}
+
+# import file with 1 row, 2 columns, quoted text data
+# note that currently sqlite doesn't support quoted fields, and
+# imports the entire field, quotes and all.
+do_test shell5-1.4.9.1 {
+ set in [open shell5.csv w]
+ puts $in "6|'Now is the time for all good men to come to the aid of their country.'"
+ close $in
+ set res [catchcmd "test.db" {.import shell5.csv t1
+SELECT COUNT(*) FROM t1;}]
+} {0 6}
+
+do_test shell5-1.4.9.2 {
+ catchcmd "test.db" {SELECT b FROM t1 WHERE a='6';}
+} {0 {'Now is the time for all good men to come to the aid of their country.'}}
+
+# import file with 1 row, 2 columns, quoted text data
+do_test shell5-1.4.10.1 {
+ set in [open shell5.csv w]
+ puts $in "7|\"Now is the time for all good men to come to the aid of their country.\""
+ close $in
+ set res [catchcmd "test.db" {.import shell5.csv t1
+SELECT COUNT(*) FROM t1;}]
+} {0 7}
+
+do_test shell5-1.4.10.2 {
+ catchcmd "test.db" {SELECT b FROM t1 WHERE a='7';}
+} {0 {Now is the time for all good men to come to the aid of their country.}}
+
+# import file with 2 rows, 2 columns and an initial BOM
+#
+do_test shell5-1.4.11 {
+ set in [open shell5.csv wb]
+ puts -nonewline $in "\xef\xbb\xbf"
+ puts $in "2|3"
+ puts $in "4|5"
+ close $in
+ set res [catchcmd "test.db" {CREATE TABLE t2(x INT, y INT);
+.import shell5.csv t2
+.mode quote
+.header on
+SELECT * FROM t2;}]
+ string map {\n | \n\r |} $res
+} {0 {'x','y'|2,3|4,5}}
+
+# import file with 2 rows, 2 columns or text with an initial BOM
+#
+do_test shell5-1.4.12 {
+ set in [open shell5.csv wb]
+ puts $in "\xef\xbb\xbf\"two\"|3"
+ puts $in "4|5"
+ close $in
+ set res [catchcmd "test.db" {DELETE FROM t2;
+.import shell5.csv t2
+.mode quote
+.header on
+SELECT * FROM t2;}]
+ string map {\n | \n\r |} $res
+} {0 {'x','y'|'two',3|4,5}}
+
+# check importing very long field
+do_test shell5-1.5.1 {
+ set str [string repeat X 999]
+ set in [open shell5.csv w]
+ puts $in "8|$str"
+ close $in
+ set res [catchcmd "test.db" {.import shell5.csv t1
+SELECT length(b) FROM t1 WHERE a='8';}]
+} {0 999}
+
+# try importing into a table with a large number of columns.
+# This is limited by SQLITE_MAX_VARIABLE_NUMBER, which defaults to 999.
+set cols 999
+do_test shell5-1.6.1 {
+ set data {}
+ for {set i 1} {$i<$cols} {incr i} {
+ append data "c$i|"
+ }
+ append data "c$cols\n";
+ for {set i 1} {$i<$cols} {incr i} {
+ append data "$i|"
+ }
+ append data "$cols"
+ set in [open shell5.csv w]
+ puts $in $data
+ close $in
+ set res [catchcmd "test.db" {DROP TABLE IF EXISTS t2;
+.import shell5.csv t2
+SELECT COUNT(*) FROM t2;}]
+} {0 1}
+
+# try importing a large number of rows
+set rows 9999
+do_test shell5-1.7.1 {
+ set in [open shell5.csv w]
+ puts $in a
+ for {set i 1} {$i<=$rows} {incr i} {
+ puts $in $i
+ }
+ close $in
+ set res [catchcmd "test.db" {.mode csv
+.import shell5.csv t3
+SELECT COUNT(*) FROM t3;}]
+} [list 0 $rows]
+
+# Import from a pipe. (Unix only, as it requires "awk")
+if {$tcl_platform(platform)=="unix"} {
+ do_test shell5-1.8 {
+ forcedelete test.db
+ catchcmd test.db {.mode csv
+.import "|awk 'END{print \"x,y\";for(i=1;i<=5;i++){print i \",this is \" i}}'" t1
+SELECT * FROM t1;}
+ } {0 {1,"this is 1"
+2,"this is 2"
+3,"this is 3"
+4,"this is 4"
+5,"this is 5"}}
+}
+
+# Import columns containing quoted strings
+do_test shell5-1.9 {
+ set out [open shell5.csv w]
+ fconfigure $out -translation lf
+ puts $out {1,"",11}
+ puts $out {2,"x",22}
+ puts $out {3,"""",33}
+ puts $out {4,"hello",44}
+ puts $out "5,55,\"\"\r"
+ puts $out {6,66,"x"}
+ puts $out {7,77,""""}
+ puts $out {8,88,"hello"}
+ puts $out {"",9,99}
+ puts $out {"x",10,110}
+ puts $out {"""",11,121}
+ puts $out {"hello",12,132}
+ close $out
+ forcedelete test.db
+ catchcmd test.db {.mode csv
+ CREATE TABLE t1(a,b,c);
+.import shell5.csv t1
+ }
+ sqlite3 db test.db
+ db eval {SELECT *, '|' FROM t1 ORDER BY rowid}
+} {1 {} 11 | 2 x 22 | 3 {"} 33 | 4 hello 44 | 5 55 {} | 6 66 x | 7 77 {"} | 8 88 hello | {} 9 99 | x 10 110 | {"} 11 121 | hello 12 132 |}
+db close
+
+# Import columns containing quoted strings
+do_test shell5-1.10 {
+ set out [open shell5.csv w]
+ fconfigure $out -translation lf
+ puts $out {column1,column2,column3,column4}
+ puts $out "field1,field2,\"x3 \"\"\r\ndata\"\" 3\",field4"
+ puts $out "x1,x2,\"x3 \"\"\ndata\"\" 3\",x4"
+ close $out
+ forcedelete test.db
+ catchcmd test.db {.mode csv
+ CREATE TABLE t1(a,b,c,d);
+.import shell5.csv t1
+ }
+ sqlite3 db test.db
+ db eval {SELECT hex(c) FROM t1 ORDER BY rowid}
+} {636F6C756D6E33 783320220D0A64617461222033 783320220A64617461222033}
+
+# Blank last column with \r\n line endings.
+do_test shell5-1.11 {
+ set out [open shell5.csv w]
+ fconfigure $out -translation binary
+ puts $out "column1,column2,column3\r"
+ puts $out "a,b, \r"
+ puts $out "x,y,\r"
+ puts $out "p,q,r\r"
+ close $out
+ catch {db close}
+ forcedelete test.db
+ catchcmd test.db {.mode csv
+.import shell5.csv t1
+ }
+ sqlite3 db test.db
+ db eval {SELECT *, '|' FROM t1}
+} {a b { } | x y {} | p q r |}
+db close
+
+#----------------------------------------------------------------------------
+#
+reset_db
+sqlite3 db test.db
+do_test shell5-2.1 {
+ set fd [open shell5.csv w]
+ puts $fd ",hello"
+ close $fd
+ catchcmd test.db [string trim {
+.mode csv
+CREATE TABLE t1(a, b);
+.import shell5.csv t1
+ }]
+ db eval { SELECT * FROM t1 }
+} {{} hello}
+
+do_test shell5-2.2 {
+ set fd [open shell5.csv w]
+ puts $fd {"",hello}
+ close $fd
+ catchcmd test.db [string trim {
+.mode csv
+CREATE TABLE t2(a, b);
+.import shell5.csv t2
+ }]
+ db eval { SELECT * FROM t2 }
+} {{} hello}
+
+do_test shell5-2.3 {
+ set fd [open shell5.csv w]
+ puts $fd {"x""y",hello}
+ close $fd
+ catchcmd test.db [string trim {
+.mode csv
+CREATE TABLE t3(a, b);
+.import shell5.csv t3
+ }]
+ db eval { SELECT * FROM t3 }
+} {x\"y hello}
+
+do_test shell5-2.4 {
+ set fd [open shell5.csv w]
+ puts $fd {"xy""",hello}
+ close $fd
+ catchcmd test.db [string trim {
+.mode csv
+CREATE TABLE t4(a, b);
+.import shell5.csv t4
+ }]
+ db eval { SELECT * FROM t4 }
+} {xy\" hello}
+
+do_test shell5-2.5 {
+ set fd [open shell5.csv w]
+ puts $fd {"one","2"}
+ puts $fd {}
+ close $fd
+ catchcmd test.db [string trim {
+.mode csv
+CREATE TABLE t4(a, b);
+.import shell5.csv t4
+ }]
+ db eval { SELECT * FROM t4 }
+} {xy\" hello one 2 {} {}}
+
+#----------------------------------------------------------------------------
+# Tests for the shell "ascii" import/export mode.
+#
+do_test shell5-3.1 {
+ set fd [open shell5.csv w]
+ fconfigure $fd -encoding binary -translation binary
+ puts -nonewline $fd "\"test 1\"\x1F,test 2\r\n\x1E"
+ puts -nonewline $fd "test 3\x1Ftest 4\n"
+ close $fd
+ catchcmd test.db {
+.mode ascii
+CREATE TABLE t5(a, b);
+.import shell5.csv t5
+ }
+ db eval { SELECT * FROM t5 }
+} "\{\"test 1\"} \{,test 2\r\n\} \{test 3\} \{test 4\n\}"
+
+do_test shell5-3.2 {
+ set x [catchcmd test.db {
+.mode ascii
+SELECT * FROM t5;
+ }]
+ # Handle platform end-of-line differences
+ regsub -all {[\n\r]?\n} $x <EOL> x
+ set x
+} "0 \{\"test 1\"\x1F,test 2<EOL>\x1Etest 3\x1Ftest 4<EOL>\x1E\}"
+
+do_test shell5-4.1 {
+ forcedelete shell5.csv
+ set fd [open shell5.csv w]
+ puts $fd "1,2,3"
+ puts $fd "4,5"
+ puts $fd "6,7,8"
+ close $fd
+ catchcmd test.db [string trim {
+.mode csv
+CREATE TABLE t6(a, b, c);
+.import shell5.csv t6
+ }]
+ db eval { SELECT * FROM t6 ORDER BY a }
+} {1 2 3 4 5 {} 6 7 8}
+
+do_test shell5-4.2 {
+ forcedelete shell5.csv
+ set fd [open shell5.csv w]
+ puts $fd "1,2,3"
+ puts $fd "4,5"
+ puts $fd "6,7,8,9"
+ close $fd
+ catchcmd test.db [string trim {
+.mode csv
+CREATE TABLE t7(a, b, c);
+.import shell5.csv t7
+ }]
+ db eval { SELECT * FROM t7 ORDER BY a }
+} {1 2 3 4 5 {} 6 7 8}
+
+do_test shell5-4.3 {
+ forcedelete shell5.csv
+ set fd [open shell5.csv w]
+ puts $fd ",,"
+ puts $fd "1,2,3"
+ close $fd
+ catchcmd test.db [string trim {
+.mode csv
+CREATE TABLE t8(a, b, c);
+.import -skip 1 shell5.csv t8
+.nullvalue #
+ }]
+ db eval { SELECT * FROM t8 }
+} {1 2 3}
+
+do_test shell5-4.4 {
+ forcedelete shell5.csv
+ set fd [open shell5.csv w]
+ puts $fd "1,2,3"
+ close $fd
+ catchcmd test.db [string trim {
+.mode csv
+CREATE TEMP TABLE t8(a, b, c);
+.import shell5.csv t8
+.nullvalue #
+SELECT * FROM temp.t8
+ }]
+} {0 1,2,3}
+
+#----------------------------------------------------------------------------
+# Tests for the shell automatic column rename.
+#
+db close
+
+# Import columns containing duplicates
+do_test shell5-5.1 {
+ set out [open shell5.csv w]
+ fconfigure $out -translation lf
+ puts $out {"","x","x","y","z","z_0","z_5","z"}
+ puts $out {0,"x2","x3","y4","z5","z6","z7","z8"}
+ close $out
+ forcedelete test.db
+ catchcmd test.db {.import -csv shell5.csv t1
+.mode line
+SELECT * FROM t1;}
+} {1 { ? = 0
+ x_02 = x2
+ x_03 = x3
+ y = y4
+ z_05 = z5
+ z_0 = z6
+ z_5 = z7
+ z_08 = z8
+Columns renamed during .import shell5.csv due to duplicates:
+"x" to "x_02",
+"x" to "x_03",
+"z" to "z_05",
+"z" to "z_08"}}
+
+do_test shell5-5.1 {
+ set out [open shell5.csv w]
+ fconfigure $out -translation lf
+ puts $out {"COW","cow","CoW","cOw"}
+ puts $out {"uuu","lll","ulu","lul"}
+ close $out
+ forcedelete test.db
+ catchcmd test.db {.import -csv shell5.csv t1
+.mode line
+SELECT * FROM t1;}
+} {1 {COW_1 = uuu
+cow_2 = lll
+CoW_3 = ulu
+cOw_4 = lul
+Columns renamed during .import shell5.csv due to duplicates:
+"COW" to "COW_1",
+"cow" to "cow_2",
+"CoW" to "CoW_3",
+"cOw" to "cOw_4"}}
+
+#----------------------------------------------------------------------------
+# Tests for preserving utf-8 that is not also ASCII.
+#
+
+do_test shell5-6.1 {
+ set out [open shell5.csv w]
+ fconfigure $out -translation lf
+ puts $out {あい,うえお}
+ puts $out {1,2}
+ close $out
+ forcedelete test.db
+ catchcmd test.db {.import -csv shell5.csv t1
+.mode line
+SELECT * FROM t1;}
+} {0 { あい = 1
+うえお = 2}}
+
+do_test shell5-6.2 {
+ set out [open shell5.csv w]
+ fconfigure $out -translation lf
+ puts $out {1,2}
+ puts $out {あい,うえお}
+ close $out
+ forcedelete test.db
+ catchcmd test.db {.import -csv shell5.csv t1
+.mode line
+SELECT * FROM t1;}
+} {0 { 1 = あい
+ 2 = うえお}}
+
+finish_test
diff --git a/test/shell6.test b/test/shell6.test
new file mode 100644
index 0000000..49b4cc3
--- /dev/null
+++ b/test/shell6.test
@@ -0,0 +1,129 @@
+# 2016 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.
+#
+#***********************************************************************
+#
+# Test the shell tool ".lint fkey-indexes" command.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !vtab {finish_test; return}
+set testprefix shell6
+set CLI [test_find_cli]
+db close
+forcedelete test.db test.db-journal test.db-wal
+
+foreach {tn schema output} {
+ 1 {
+ CREATE TABLE p1(a PRIMARY KEY, b);
+ CREATE TABLE c1(x, y REFERENCES p1);
+ } {
+ CREATE INDEX 'c1_y' ON 'c1'('y'); --> p1(a)
+ }
+
+ 2 {
+ CREATE TABLE p1(a PRIMARY KEY, b);
+ CREATE TABLE c2(x REFERENCES p1, y REFERENCES p1);
+ } {
+ CREATE INDEX 'c2_y' ON 'c2'('y'); --> p1(a)
+ CREATE INDEX 'c2_x' ON 'c2'('x'); --> p1(a)
+ }
+
+ 3 {
+ CREATE TABLE 'p 1'(a, b, c, PRIMARY KEY(c, b));
+ CREATE TABLE 'c 1'(x, y, z, FOREIGN KEY (z, y) REFERENCES 'p 1');
+ } {
+ CREATE INDEX 'c 1_z_y' ON 'c 1'('z', 'y'); --> p 1(c,b)
+ }
+
+ 4 {
+ CREATE TABLE p1(a, 'b b b' PRIMARY KEY);
+ CREATE TABLE c1('x y z' REFERENCES p1);
+ CREATE INDEX i1 ON c1('x y z') WHERE "x y z" IS NOT NULL;
+ } {
+ }
+
+ 5 {
+ CREATE TABLE p1(a, 'b b b' PRIMARY KEY);
+ CREATE TABLE c1('x y z' REFERENCES p1);
+ CREATE INDEX i1 ON c1('x y z') WHERE "x y z" IS NOT 12;
+ } {
+ CREATE INDEX 'c1_x y z' ON 'c1'('x y z'); --> p1(b b b)
+ }
+
+ 6 {
+ CREATE TABLE x1(a, b, c, UNIQUE(a, b));
+ CREATE TABLE y1(a, b, c, FOREIGN KEY(b, a) REFERENCES x1(a, b));
+ CREATE INDEX y1i ON y1(a, c, b);
+ } {
+ CREATE INDEX 'y1_b_a' ON 'y1'('b', 'a'); --> x1(a,b)
+ }
+
+ 6 {
+ CREATE TABLE x1(a COLLATE nocase, b, UNIQUE(a));
+ CREATE TABLE y1(a COLLATE rtrim REFERENCES x1(a));
+ } {
+ CREATE INDEX 'y1_a' ON 'y1'('a' COLLATE nocase); --> x1(a)
+ }
+
+ 7 {
+ CREATE TABLE x1(a PRIMARY KEY COLLATE nocase, b);
+ CREATE TABLE y1(a REFERENCES x1);
+ } {
+ CREATE INDEX 'y1_a' ON 'y1'('a' COLLATE nocase); --> x1(a)
+ }
+
+ 8 {
+ CREATE TABLE x1(a, b COLLATE nocase, c COLLATE rtrim, PRIMARY KEY(c, b, a));
+ CREATE TABLE y1(d, e, f, FOREIGN KEY(d, e, f) REFERENCES x1);
+ } {
+ CREATE INDEX 'y1_d_e_f' ON 'y1'('d' COLLATE rtrim, 'e' COLLATE nocase, 'f'); --> x1(c,b,a)
+ }
+
+ 9 {
+ CREATE TABLE p1(a, b UNIQUE);
+ CREATE TABLE c1(x INTEGER PRIMARY KEY REFERENCES p1(b));
+ } {
+ }
+
+ 10 {
+ CREATE TABLE parent (id INTEGER PRIMARY KEY);
+ CREATE TABLE child2 (id INT PRIMARY KEY, parentID INT REFERENCES parent)
+ WITHOUT ROWID;
+ } {
+ CREATE INDEX 'child2_parentID' ON 'child2'('parentID'); --> parent(id)
+ }
+
+} {
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql $schema
+
+ set expected ""
+ foreach line [split $output "\n"] {
+ set line [string trim $line]
+ if {$line!=""} {
+ append expected "$line\n"
+ }
+ }
+
+ do_test 1.$tn.1 {
+ set RES [catchcmd test.db [list .lint fkey-indexes]]
+ } [list 0 [string trim $expected]]
+
+ do_test 1.$tn.2 {
+ execsql [lindex $RES 1]
+ catchcmd test.db [list .lint fkey-indexes]
+ } {0 {}}
+
+ db close
+}
+
+finish_test
diff --git a/test/shell7.test b/test/shell7.test
new file mode 100644
index 0000000..898018d
--- /dev/null
+++ b/test/shell7.test
@@ -0,0 +1,52 @@
+# 2016 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.
+#
+#***********************************************************************
+#
+# Test the readfile() function built into the shell tool. Specifically,
+# that it does not truncate the blob read at the first embedded 0x00
+# byte.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix shell7
+set CLI [test_find_cli]
+
+
+do_execsql_test 1.0 {
+ CREATE TABLE f1(tn INTEGER PRIMARY KEY, x BLOB);
+ CREATE TABLE f2(tn INTEGER PRIMARY KEY, x BLOB);
+
+ INSERT INTO f1 VALUES(1, X'01020304');
+ INSERT INTO f1 VALUES(2, X'01000304');
+ INSERT INTO f1 VALUES(3, randomblob(200));
+}
+
+foreach {tn l x} [db eval { SELECT tn, length(x) AS l, x FROM f1 }] {
+ forcedelete shell7_test.bin
+ set fd [open shell7_test.bin w]
+ fconfigure $fd -encoding binary
+ fconfigure $fd -translation binary
+ puts -nonewline $fd $x
+ close $fd
+
+ do_test 1.$tn.1 { file size shell7_test.bin } $l
+ do_test 1.$tn.2 {
+ catchcmd test.db "INSERT INTO f2 VALUES($tn, readfile('shell7_test.bin'));"
+ } {0 {}}
+
+ do_execsql_test 1.$tn.3 {
+ SELECT (SELECT x FROM f1 WHERE tn=1)==(SELECT x FROM f2 WHERE tn=1)
+ } {1}
+}
+
+
+
+finish_test
diff --git a/test/shell8.test b/test/shell8.test
new file mode 100644
index 0000000..bee6039
--- /dev/null
+++ b/test/shell8.test
@@ -0,0 +1,196 @@
+# 2017 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.
+#
+#***********************************************************************
+#
+# Test the shell tool ".ar" command.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix shell8
+
+ifcapable !vtab {
+ finish_test; return
+}
+set CLI [test_cli_invocation]
+
+# Check to make sure the shell has been compiled with ".archive" support.
+#
+if {[string match {*unknown command*} [catchcmd :memory: .archive]]} {
+ finish_test; return
+}
+
+proc populate_dir {dirname spec} {
+ # First delete the current tree, if one exists.
+ file delete -force $dirname
+
+ # Recreate the root of the new tree.
+ file mkdir $dirname
+
+ # Add each file to the new tree.
+ foreach {f d} $spec {
+ set path [file join $dirname $f]
+ file mkdir [file dirname $path]
+ set fd [open $path w]
+ puts -nonewline $fd $d
+ close $fd
+ }
+}
+
+proc dir_content {dirname} {
+ lsort [glob -nocomplain $dirname/*]
+}
+
+proc dir_to_list {dirname {n -1}} {
+ if {$n<0} {set n [llength [file split $dirname]]}
+
+ set res [list]
+ foreach f [glob -nocomplain $dirname/*] {
+ set mtime [file mtime $f]
+ if {$::tcl_platform(platform)!="windows"} {
+ set perm [file attributes $f -perm]
+ } else {
+ set perm 0
+ }
+ set relpath [file join {*}[lrange [file split $f] $n end]]
+ lappend res
+ if {[file isdirectory $f]} {
+ lappend res [list $relpath / $mtime $perm]
+ lappend res {*}[dir_to_list $f]
+ } else {
+ set fd [open $f]
+ set data [read $fd]
+ close $fd
+ lappend res [list $relpath $data $mtime $perm]
+ }
+ }
+ lsort $res
+}
+
+proc dir_compare {d1 d2} {
+ set l1 [dir_to_list $d1]
+ set l2 [dir_to_list $d1]
+ string compare $l1 $l2
+}
+
+foreach {tn tcl} {
+ 1 {
+ set c1 ".ar c ar1"
+ set x1 ".ar x"
+
+ set c2 ".ar cC ar1 ."
+ set x2 ".ar Cx ar3"
+
+ set c3 ".ar cCf ar1 test_xyz.db ."
+ set x3 ".ar Cfx ar3 test_xyz.db"
+ }
+
+ 2 {
+ set c1 ".ar -c ar1"
+ set x1 ".ar -x"
+
+ set c2 ".ar -cC ar1 ."
+ set x2 ".ar -xC ar3"
+
+ set c3 ".ar -cCar1 -ftest_xyz.db ."
+ set x3 ".ar -x -C ar3 -f test_xyz.db"
+ }
+
+ 3 {
+ set c1 ".ar --create ar1"
+ set x1 ".ar --extract"
+
+ set c2 ".ar --directory ar1 --create ."
+ set x2 ".ar --extract --dir ar3"
+
+ set c3 ".ar --creat --dir ar1 --file test_xyz.db ."
+ set x3 ".ar --e --dir ar3 --f test_xyz.db"
+ }
+
+ 4 {
+ set c1 ".ar --cr ar1"
+ set x1 ".ar --e"
+
+ set c2 ".ar -C ar1 -c ."
+ set x2 ".ar -x -C ar3"
+
+ set c3 ".ar -c --directory ar1 --file test_xyz.db ."
+ set x3 ".ar -x --directory ar3 --file test_xyz.db"
+ }
+} {
+ eval $tcl
+
+ # Populate directory "ar1" with some files.
+ #
+ populate_dir ar1 {
+ file1 "abcd"
+ file2 "efgh"
+ dir1/file3 "ijkl"
+ }
+ set expected [dir_to_list ar1]
+
+ do_test 1.$tn.1 {
+ catchcmd test_ar.db $c1
+ file delete -force ar1
+ catchcmd test_ar.db $x1
+ dir_to_list ar1
+ } $expected
+
+ do_test 1.$tn.2 {
+ file delete -force ar3
+ catchcmd test_ar.db $c2
+ catchcmd test_ar.db $x2
+ dir_to_list ar3
+ } $expected
+
+ do_test 1.$tn.3 {
+ file delete -force ar3
+ file delete -force test_xyz.db
+ catchcmd ":memory:" $c3
+ catchcmd ":memory:" $x3
+ dir_to_list ar3
+ } $expected
+
+ # This is a repeat of test 1.$tn.1, except that there is a 2 second
+ # pause between creating the archive and extracting its contents.
+ # This is to test that timestamps are set correctly.
+ #
+ # Because it is slow, only do this for $tn==1.
+ if {$tn==1} {
+ do_test 1.$tn.1 {
+ catchcmd test_ar.db $c1
+ file delete -force ar1
+ after 2000
+ catchcmd test_ar.db $x1
+ dir_to_list ar1
+ } $expected
+ }
+}
+
+do_test 2.1.1 {
+ populate_dir ar2 {
+ file1 "abcd"
+ file2 "efgh"
+ junk1 "j1"
+ junk2 "j2"
+ dir1/file3 "ijkl"
+ }
+ populate_dir ar4 {
+ file2 "efgh"
+ }
+ catchcmd shell8.db {.ar -c}
+ catchcmd shell8.db {.ar -C ar2 -i .}
+ catchcmd shell8.db {.ar -r ./file2 ./dir1}
+ catchcmd shell8.db {.ar -g -r ./ju*2}
+ catchcmd shell8.db {.ar -C ar4 -x .}
+ regsub -all {ar4} [dir_content ar4] ar2
+} {ar2/file1 ar2/file2 ar2/junk1}
+
+finish_test
diff --git a/test/shmlock.test b/test/shmlock.test
new file mode 100644
index 0000000..89b29fd
--- /dev/null
+++ b/test/shmlock.test
@@ -0,0 +1,180 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix shmlock
+
+ifcapable !wal {finish_test ; return }
+
+sqlite3 db2 test.db
+sqlite3 db3 test.db
+
+do_execsql_test 1.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+} {wal}
+do_test 1.1 { execsql { SELECT * FROM t1 } db2 } {1 2}
+do_test 1.2 { execsql { SELECT * FROM t1 } db3 } {1 2}
+
+foreach {tn dbhandle cmd res} {
+ 1 db {shared lock 7 1} OK
+ 2 db2 {exclusive lock 7 1} BUSY
+ 3 db {shared unlock 7 1} OK
+ 4 db2 {exclusive lock 7 1} OK
+ 5 db {shared lock 7 1} BUSY
+ 6 db {exclusive lock 7 1} BUSY
+ 7 db2 {exclusive unlock 7 1} OK
+
+ 8 db {exclusive lock 0 8} OK
+ 9 db {exclusive unlock 0 8} OK
+ 10 db2 {exclusive lock 0 8} OK
+ 11 db2 {exclusive unlock 0 8} OK
+
+ 12 db {shared lock 0 1} OK
+ 13 db2 {shared lock 0 1} OK
+ 14 db3 {shared lock 0 1} OK
+ 15 db3 {shared unlock 0 1} OK
+ 16 db3 {exclusive lock 0 1} BUSY
+ 17 db2 {shared unlock 0 1} OK
+ 18 db3 {exclusive lock 0 1} BUSY
+ 19 db {shared unlock 0 1} OK
+ 20 db3 {exclusive lock 0 1} OK
+ 21 db3 {exclusive unlock 0 1} OK
+
+ 22 db {shared lock 3 1} OK
+ 23 db2 {exclusive lock 2 2} BUSY
+ 24 db {shared lock 2 1} OK
+ 25 db2 {exclusive lock 0 5} BUSY
+ 26 db2 {exclusive lock 0 4} BUSY
+ 27 db2 {exclusive lock 0 3} BUSY
+ 28 db {shared unlock 3 1} OK
+ 29 db2 {exclusive lock 2 2} BUSY
+ 28 db {shared unlock 2 1} OK
+ 29 db2 {exclusive lock 2 2} OK
+ 29 db2 {exclusive unlock 2 2} OK
+} {
+ do_test 1.3.$tn [list vfs_shmlock $dbhandle main {*}$cmd] "SQLITE_$res"
+}
+
+db close
+db2 close
+db3 close
+
+if {[permutation]=="unix-excl"} {
+ do_test 2.0 {
+ for {set i 0} {$i < 256} {incr i} {
+ sqlite3 db$i test.db
+ execsql { SELECT * FROM t1 } db$i
+ }
+ for {set i 0} {$i < 255} {incr i} {
+ set rc [vfs_shmlock db$i main shared lock 4 1]
+ if {$rc != "SQLITE_OK"} { error $rc }
+ }
+
+ vfs_shmlock db255 main shared lock 4 1
+ } {SQLITE_BUSY}
+
+ do_test 2.1 { vfs_shmlock db255 main exclusive lock 4 1 } SQLITE_BUSY
+ do_test 2.2 { vfs_shmlock db0 main shared unlock 4 1 } SQLITE_OK
+ do_test 2.3 { vfs_shmlock db255 main shared lock 4 1 } SQLITE_OK
+ do_test 2.4 { vfs_shmlock db255 main shared unlock 4 1 } SQLITE_OK
+ do_test 2.5 { vfs_shmlock db255 main exclusive lock 4 1 } SQLITE_BUSY
+
+ do_test 2.6 {
+ for {set i 1} {$i < 255} {incr i} {
+ set rc [vfs_shmlock db255 main exclusive lock 4 1]
+ if {$rc != "SQLITE_BUSY"} { error $rc }
+ set rc [vfs_shmlock db$i main shared unlock 4 1]
+ if {$rc != "SQLITE_OK"} { error $rc }
+ }
+
+ vfs_shmlock db255 main exclusive lock 4 1
+ } {SQLITE_OK}
+
+ vfs_shmlock db255 main exclusive unlock 4 1
+
+ for {set i 0} {$i < 256} {incr i} {
+ db$i close
+ }
+}
+
+sqlite3 db0 test.db
+sqlite3 db1 test.db
+do_test 3.1 { execsql { SELECT * FROM t1 } db0 } {1 2}
+do_test 3.2 { execsql { SELECT * FROM t1 } db1 } {1 2}
+if {$tcl_platform(platform)=="windows"} {
+ set isWindows 1
+} else {
+ set isWindows 0
+}
+
+set L(0) {n n n n n n n n}
+set L(1) {n n n n n n n n}
+proc random_lock_test {idx} {
+ global L
+ set iSlot [expr int(rand()*8)]
+ if {[expr int(rand()*2)]} {
+ # Unlock operation
+ if {[lindex $L($idx) $iSlot]!="n"} {
+ vfs_shmlock db$idx main [lindex $L($idx) $iSlot] unlock $iSlot 1
+ lset L($idx) $iSlot n
+ }
+ } else {
+ # Lock operation
+ if {[lindex $L($idx) $iSlot]=="n"} {
+ set locktype [lindex {e s} [expr int(rand()*2)]]
+ set n 1
+ if {$locktype=="e"} {
+ for {set l $iSlot} {$l<8 && [lindex $L($idx) $l]=="n"} {incr l} {}
+ set n [expr int(rand()*($l-$iSlot))+1]
+ # The LockFile() and UnlockFile() apis on windows require that
+ # every unlock correspond exactly to a prior lock. Hence, we cannot
+ # lock arbitrary ranges in this test on windows.
+ if {$::isWindows} {set n 1}
+ # puts "iSlot=$iSlot l=$l L=$L($idx)"
+ # puts "$iSlot $n"
+ }
+ set res [vfs_shmlock db$idx main $locktype lock $iSlot $n]
+
+ set bBusy 0
+ for {set i $iSlot} {$i<($iSlot+$n)} {incr i} {
+ set other [lindex $L([expr ($idx+1)%2]) $i]
+ if {($other!="n" && $locktype=="e")||($other=="e" && $locktype=="s")} {
+ if {$res != "SQLITE_BUSY"} { error "BUSY not detected" }
+ set bBusy 1
+ break
+ }
+ }
+
+ if {$bBusy==0} {
+ if {$res != "SQLITE_OK"} { error "BUSY false-positive" }
+ for {set i $iSlot} {$i<($iSlot+$n)} {incr i} {
+ lset L($idx) $i $locktype
+ }
+ }
+ }
+ }
+}
+
+set nStep 100000
+for {set i 0} {$i < $nStep} {incr i} {
+ random_lock_test 0
+ random_lock_test 1
+}
+
+db0 close
+db1 close
+
+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/show_speedtest1_rtree.tcl b/test/show_speedtest1_rtree.tcl
new file mode 100644
index 0000000..3faa168
--- /dev/null
+++ b/test/show_speedtest1_rtree.tcl
@@ -0,0 +1,57 @@
+#!/usr/bin/tclsh
+#
+# This script displays the field of rectangles used by --testset rtree
+# of speedtest1. Run this script as follows:
+#
+# rm test.db
+# ./speedtest1 --testset rtree --size 25 test.db
+# sqlite3 --separator ' ' test.db 'SELECT * FROM rt1' >data.txt
+# wish show_speedtest1_rtree.tcl
+#
+# The filename "data.txt" is hard coded into this script and so that name
+# must be used on lines 3 and 4 above. Elsewhere, different filenames can
+# be used. The --size N parameter can be adjusted as desired.
+#
+package require Tk
+set f [open data.txt rb]
+set data [read $f]
+close $f
+canvas .c
+frame .b
+button .b.b1 -text X-Y -command refill-xy
+button .b.b2 -text X-Z -command refill-xz
+button .b.b3 -text Y-Z -command refill-yz
+pack .b.b1 .b.b2 .b.b3 -side left
+pack .c -side top -fill both -expand 1
+pack .b -side top
+proc resize_canvas_to_fit {} {
+ foreach {x0 y0 x1 y1} [.c bbox all] break
+ set w [expr {$x1-$x0}]
+ set h [expr {$y1-$y0}]
+ .c config -width $w -height $h
+}
+proc refill-xy {} {
+ .c delete all
+ foreach {id x0 x1 y0 y1 z0 z1} $::data {
+ .c create rectangle $x0 $y0 $x1 $y1
+ }
+ .c scale all 0 0 0.05 0.05
+ resize_canvas_to_fit
+}
+proc refill-xz {} {
+ .c delete all
+ foreach {id x0 x1 y0 y1 z0 z1} $::data {
+ .c create rectangle $x0 $z0 $x1 $z1
+ }
+ .c scale all 0 0 0.05 0.05
+ resize_canvas_to_fit
+}
+proc refill-yz {} {
+ .c delete all
+ foreach {id x0 x1 y0 y1 z0 z1} $::data {
+ .c create rectangle $y0 $z0 $y1 $z1
+ }
+ .c scale all 0 0 0.05 0.05
+ resize_canvas_to_fit
+}
+refill-xy
diff --git a/test/shrink.test b/test/shrink.test
new file mode 100644
index 0000000..bc4a707
--- /dev/null
+++ b/test/shrink.test
@@ -0,0 +1,48 @@
+# 2011 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 contains test cases for sqlite3_db_release_memory and
+# the PRAGMA shrink_memory statement.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+test_set_config_pagecache 0 0
+
+unset -nocomplain baseline
+do_test shrink-1.1 {
+ db eval {
+ PRAGMA cache_size = 2000;
+ CREATE TABLE t1(x,y);
+ INSERT INTO t1 VALUES(randomblob(1000000),1);
+ }
+ set ::baseline [sqlite3_memory_used]
+ # EVIDENCE-OF: R-58814-63508 The sqlite3_db_release_memory(D) interface
+ # attempts to free as much heap memory as possible from database
+ # connection D.
+ sqlite3_db_release_memory db
+ expr {$::baseline > [sqlite3_memory_used]+500000}
+} {1}
+do_test shrink-1.2 {
+ set baseline [sqlite3_memory_used]
+ db eval {
+ UPDATE t1 SET y=y+1;
+ }
+ expr {$::baseline+500000 < [sqlite3_memory_used]}
+} {1}
+do_test shrink-1.3 {
+ set baseline [sqlite3_memory_used]
+ db eval {PRAGMA shrink_memory}
+ expr {$::baseline > [sqlite3_memory_used]+500000}
+} {1}
+
+test_restore_config_pagecache
+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/skipscan1.test b/test/skipscan1.test
new file mode 100644
index 0000000..94062fb
--- /dev/null
+++ b/test/skipscan1.test
@@ -0,0 +1,422 @@
+# 2013-11-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 of the "skip-scan" query strategy.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test skipscan1-1.1 {
+ CREATE TABLE t1(a TEXT, b INT, c INT, d INT);
+ CREATE INDEX t1abc ON t1(a,b,c);
+ INSERT INTO t1 VALUES('abc',123,4,5);
+ INSERT INTO t1 VALUES('abc',234,5,6);
+ INSERT INTO t1 VALUES('abc',234,6,7);
+ INSERT INTO t1 VALUES('abc',345,7,8);
+ INSERT INTO t1 VALUES('def',567,8,9);
+ INSERT INTO t1 VALUES('def',345,9,10);
+ INSERT INTO t1 VALUES('bcd',100,6,11);
+
+ /* Fake the sqlite_stat1 table so that the query planner believes
+ ** the table contains thousands of rows and that the first few
+ ** columns are not selective. */
+ ANALYZE;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1 VALUES('t1','t1abc','10000 5000 2000 10');
+ ANALYZE sqlite_master;
+} {}
+
+# Simple queries that leave the first one or two columns of the
+# index unconstrainted.
+#
+do_execsql_test skipscan1-1.2 {
+ SELECT a,b,c,d,'|' FROM t1 WHERE b=345 ORDER BY a;
+} {abc 345 7 8 | def 345 9 10 |}
+do_execsql_test skipscan1-1.2eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a;
+} {/* USING INDEX t1abc (ANY(a) AND b=?)*/}
+do_execsql_test skipscan1-1.2sort {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a;
+} {~/*ORDER BY*/}
+
+do_execsql_test skipscan1-1.3 {
+ SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a DESC;
+} {def 345 9 10 | abc 345 7 8 |}
+do_execsql_test skipscan1-1.3eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a DESC;
+} {/* USING INDEX t1abc (ANY(a) AND b=?)*/}
+do_execsql_test skipscan1-1.3sort {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a DESC;
+} {~/*ORDER BY*/}
+
+do_execsql_test skipscan1-1.4 {
+ SELECT a,b,c,d,'|' FROM t1 WHERE c=6 ORDER BY a, b, c;
+} {abc 234 6 7 | bcd 100 6 11 |}
+do_execsql_test skipscan1-1.4eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE c=6 ORDER BY a, b, c;
+} {/* USING INDEX t1abc (ANY(a) AND ANY(b) AND c=?)*/}
+do_execsql_test skipscan1-1.4sort {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE c=6 ORDER BY a, b, c;
+} {~/*ORDER BY*/}
+
+do_execsql_test skipscan1-1.5 {
+ SELECT a,b,c,d,'|' FROM t1 WHERE c IN (6,7) ORDER BY a, b, c;
+} {abc 234 6 7 | abc 345 7 8 | bcd 100 6 11 |}
+do_execsql_test skipscan1-1.5eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE c IN (6,7) ORDER BY a, b, c;
+} {/* USING INDEX t1abc (ANY(a) AND ANY(b) AND c=?)*/}
+do_execsql_test skipscan1-1.5sort {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE c IN (6,7) ORDER BY a, b, c;
+} {~/*ORDER BY*/}
+
+do_execsql_test skipscan1-1.6 {
+ SELECT a,b,c,d,'|' FROM t1 WHERE c BETWEEN 6 AND 7 ORDER BY a, b, c;
+} {abc 234 6 7 | abc 345 7 8 | bcd 100 6 11 |}
+do_execsql_test skipscan1-1.6eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE c BETWEEN 6 AND 7 ORDER BY a, b, c;
+} {/* USING INDEX t1abc (ANY(a) AND ANY(b) AND c>? AND c<?)*/}
+do_execsql_test skipscan1-1.6sort {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE c BETWEEN 6 AND 7 ORDER BY a, b, c;
+} {~/*ORDER BY*/}
+
+do_execsql_test skipscan1-1.7 {
+ SELECT a,b,c,d,'|' FROM t1 WHERE b IN (234, 345) AND c BETWEEN 6 AND 7
+ ORDER BY a, b;
+} {abc 234 6 7 | abc 345 7 8 |}
+do_execsql_test skipscan1-1.7eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE b IN (234, 345) AND c BETWEEN 6 AND 7
+ ORDER BY a, b;
+} {/* USING INDEX t1abc (ANY(a) AND b=? AND c>? AND c<?)*/}
+do_execsql_test skipscan1-1.7sort {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t1 WHERE b IN (234, 345) AND c BETWEEN 6 AND 7
+ ORDER BY a, b;
+} {~/*ORDER BY*/}
+
+
+# Joins
+#
+do_execsql_test skipscan1-1.51 {
+ CREATE TABLE t1j(x TEXT, y INTEGER);
+ INSERT INTO t1j VALUES('one',1),('six',6),('ninty-nine',99);
+ INSERT INTO sqlite_stat1 VALUES('t1j',null,'3');
+ ANALYZE sqlite_master;
+ SELECT x, a, b, c, d, '|' FROM t1j, t1 WHERE c=y ORDER BY +a;
+} {six abc 234 6 7 | six bcd 100 6 11 |}
+do_execsql_test skipscan1-1.51eqp {
+ EXPLAIN QUERY PLAN
+ SELECT x, a, b, c, d, '|' FROM t1j, t1 WHERE c=y ORDER BY +a;
+} {/* INDEX t1abc (ANY(a) AND ANY(b) AND c=?)*/}
+
+do_execsql_test skipscan1-1.52 {
+ SELECT x, a, b, c, d, '|' FROM t1j LEFT JOIN t1 ON c=y ORDER BY +y, +a;
+} {one {} {} {} {} | six abc 234 6 7 | six bcd 100 6 11 | ninty-nine {} {} {} {} |}
+do_execsql_test skipscan1-1.52eqp {
+ EXPLAIN QUERY PLAN
+ SELECT x, a, b, c, d, '|' FROM t1j LEFT JOIN t1 ON c=y ORDER BY +y, +a;
+} {/* INDEX t1abc (ANY(a) AND ANY(b) AND c=?)*/}
+
+do_execsql_test skipscan1-2.1 {
+ CREATE TABLE t2(a TEXT, b INT, c INT, d INT,
+ PRIMARY KEY(a,b,c));
+ INSERT INTO t2 SELECT * FROM t1;
+
+ /* Fake the sqlite_stat1 table so that the query planner believes
+ ** the table contains thousands of rows and that the first few
+ ** columns are not selective. */
+ ANALYZE;
+ UPDATE sqlite_stat1 SET stat='10000 5000 2000 10' WHERE idx NOT NULL;
+ ANALYZE sqlite_master;
+} {}
+
+do_execsql_test skipscan1-2.2 {
+ SELECT a,b,c,d,'|' FROM t2 WHERE d<>99 AND b=345 ORDER BY a;
+} {abc 345 7 8 | def 345 9 10 |}
+do_execsql_test skipscan1-2.2eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t2 WHERE d<>99 AND b=345 ORDER BY a;
+} {/* USING INDEX sqlite_autoindex_t2_1 (ANY(a) AND b=?)*/}
+do_execsql_test skipscan1-2.2sort {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t2 WHERE d<>99 AND b=345 ORDER BY a;
+} {~/*ORDER BY*/}
+
+
+do_execsql_test skipscan1-3.1 {
+ CREATE TABLE t3(a TEXT, b INT, c INT, d INT,
+ PRIMARY KEY(a,b,c)) WITHOUT ROWID;
+ INSERT INTO t3 SELECT * FROM t1;
+
+ /* Fake the sqlite_stat1 table so that the query planner believes
+ ** the table contains thousands of rows and that the first few
+ ** columns are not selective. */
+ ANALYZE;
+ UPDATE sqlite_stat1 SET stat='10000 5000 2000 10' WHERE idx NOT NULL;
+ ANALYZE sqlite_master;
+} {}
+
+do_execsql_test skipscan1-3.2 {
+ SELECT a,b,c,d,'|' FROM t3 WHERE b=345 ORDER BY a;
+} {abc 345 7 8 | def 345 9 10 |}
+do_execsql_test skipscan1-3.2eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t3 WHERE b=345 ORDER BY a;
+} {/* PRIMARY KEY (ANY(a) AND b=?)*/}
+do_execsql_test skipscan1-3.2sort {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t3 WHERE b=345 ORDER BY a;
+} {~/*ORDER BY*/}
+
+# Ticket 520070ec7fbaac: Array overrun in the skip-scan optimization
+# 2013-12-22
+#
+do_execsql_test skipscan1-4.1 {
+ CREATE TABLE t4(a,b,c,d,e,f,g,h,i);
+ CREATE INDEX t4all ON t4(a,b,c,d,e,f,g,h);
+ INSERT INTO t4 VALUES(1,2,3,4,5,6,7,8,9);
+ ANALYZE;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1
+ VALUES('t4','t4all','655360 163840 40960 10240 2560 640 160 40 10');
+ ANALYZE sqlite_master;
+ SELECT i FROM t4 WHERE a=1;
+ SELECT i FROM t4 WHERE b=2;
+ SELECT i FROM t4 WHERE c=3;
+ SELECT i FROM t4 WHERE d=4;
+ SELECT i FROM t4 WHERE e=5;
+ SELECT i FROM t4 WHERE f=6;
+ SELECT i FROM t4 WHERE g=7;
+ SELECT i FROM t4 WHERE h=8;
+} {9 9 9 9 9 9 9 9}
+
+# Make sure skip-scan cost computation in the query planner takes into
+# account the fact that the seek must occur multiple times.
+#
+# Prior to 2014-03-10, the costs were computed incorrectly which would
+# cause index t5i2 to be used instead of t5i1 on the skipscan1-5.3.
+#
+do_execsql_test skipscan1-5.1 {
+ CREATE TABLE t5(
+ id INTEGER PRIMARY KEY,
+ loc TEXT,
+ lang INTEGER,
+ utype INTEGER,
+ xa INTEGER,
+ xd INTEGER,
+ xh INTEGER
+ );
+ CREATE INDEX t5i1 on t5(loc, xh, xa, utype, lang);
+ CREATE INDEX t5i2 ON t5(xd,loc,utype,lang);
+ EXPLAIN QUERY PLAN
+ SELECT xh, loc FROM t5 WHERE loc >= 'M' AND loc < 'N';
+} {/.*COVERING INDEX t5i1 .*/}
+do_execsql_test skipscan1-5.2 {
+ ANALYZE;
+ DELETE FROM sqlite_stat1;
+ DROP TABLE IF EXISTS sqlite_stat4;
+ INSERT INTO sqlite_stat1 VALUES('t5','t5i1','2702931 3 2 2 2 2');
+ INSERT INTO sqlite_stat1 VALUES('t5','t5i2','2702931 686 2 2 2');
+ ANALYZE sqlite_master;
+} {}
+db cache flush
+do_execsql_test skipscan1-5.3 {
+ EXPLAIN QUERY PLAN
+ SELECT xh, loc FROM t5 WHERE loc >= 'M' AND loc < 'N';
+} {/.*COVERING INDEX t5i1 .*/}
+
+# The column used by the skip-scan needs to be sufficiently selective.
+# See the private email from Adi Zaimi to drh@sqlite.org on 2014-09-22.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test skipscan1-6.1 {
+ CREATE TABLE t1(a,b,c,d,e,f,g,h varchar(300));
+ CREATE INDEX t1ab ON t1(a,b);
+ ANALYZE sqlite_master;
+ -- Only two distinct values for the skip-scan column. Skip-scan is not used.
+ INSERT INTO sqlite_stat1 VALUES('t1','t1ab','500000 250000 125000');
+ ANALYZE sqlite_master;
+ EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;
+} {~/ANY/}
+do_execsql_test skipscan1-6.2 {
+ -- Four distinct values for the skip-scan column. Skip-scan is used.
+ UPDATE sqlite_stat1 SET stat='500000 250000 62500';
+ ANALYZE sqlite_master;
+ EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;
+} {/ANY.a. AND b=/}
+do_execsql_test skipscan1-6.3 {
+ -- Two distinct values for the skip-scan column again. Skip-scan is not used.
+ UPDATE sqlite_stat1 SET stat='500000 125000 62500';
+ ANALYZE sqlite_master;
+ EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;
+} {~/ANY/}
+
+# If the sqlite_stat1 entry includes the "noskipscan" token, then never use
+# skipscan with that index.
+#
+do_execsql_test skipscan1-7.1 {
+ UPDATE sqlite_stat1 SET stat='500000 125000 1 sz=100';
+ ANALYZE sqlite_master;
+ EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;
+} {/ANY/}
+do_execsql_test skipscan1-7.2 {
+ UPDATE sqlite_stat1 SET stat='500000 125000 1 noskipscan sz=100';
+ ANALYZE sqlite_master;
+ EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;
+} {~/ANY/}
+do_execsql_test skipscan1-7.3 {
+ UPDATE sqlite_stat1 SET stat='500000 125000 1 sz=100 noskipscan';
+ ANALYZE sqlite_master;
+ EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;
+} {~/ANY/}
+
+# Ticket 8fd39115d8f46ece70e7d4b3c481d1bd86194746 2015-07-23
+# Incorrect code generated for a skipscan within an OR optimization
+# on a WITHOUT ROWID table.
+#
+do_execsql_test skipscan1-8.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x, y, PRIMARY KEY(x,y)) WITHOUT ROWID;
+ INSERT INTO t1(x,y) VALUES(1,'AB');
+ INSERT INTO t1(x,y) VALUES(2,'CD');
+ ANALYZE;
+ DROP TABLE IF EXISTS sqlite_stat4;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1','1000000 100 1');
+ ANALYZE sqlite_master;
+ SELECT * FROM t1
+ WHERE (y = 'AB' AND x <= 4)
+ OR (y = 'EF' AND x = 5);
+} {1 AB}
+do_execsql_test skipscan1-8.1eqp {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1
+ WHERE (y = 'AB' AND x <= 4)
+ OR (y = 'EF' AND x = 5);
+} {/ANY/}
+do_execsql_test skipscan1-8.2 {
+ SELECT * FROM t1
+ WHERE y = 'AB' OR (y = 'CD' AND x = 2)
+ ORDER BY +x;
+} {1 AB 2 CD}
+
+# Segfault reported on the mailing list by Keith Medcalf on 2016-09-18.
+# A skip-scan with a "column IN (SELECT ...)" on the second term of the
+# index.
+#
+do_execsql_test skipscan1-9.2 {
+ CREATE TABLE t9a(a,b,c);
+ CREATE INDEX t9a_ab ON t9a(a,b);
+ CREATE TABLE t9b(x,y);
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1 VALUES('t9a','t9a_ab','1000000 250000 1');
+ ANALYZE sqlite_master;
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t9a WHERE b IN (SELECT x FROM t9b WHERE y!=5);
+} {/USING INDEX t9a_ab .ANY.a. AND b=./}
+
+
+optimization_control db skip-scan 0
+do_execsql_test skipscan1-9.3 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t9a WHERE b IN (SELECT x FROM t9b WHERE y!=5);
+} {/{SCAN t9a}/}
+optimization_control db skip-scan 1
+
+do_execsql_test skipscan1-2.1 {
+ CREATE TABLE t6(a TEXT, b INT, c INT, d INT);
+ CREATE INDEX t6abc ON t6(a,b,c);
+ INSERT INTO t6 VALUES('abc',123,4,5);
+
+ ANALYZE;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1 VALUES('t6','t6abc','10000 5000 2000 10');
+ ANALYZE sqlite_master;
+ DELETE FROM t6;
+} {}
+
+do_execsql_test skipscan1-2.2eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t6 WHERE d<>99 AND b=345 ORDER BY a;
+} {/* USING INDEX t6abc (ANY(a) AND b=?)*/}
+do_execsql_test skipscan1-2.2 {
+ SELECT a,b,c,d,'|' FROM t6 WHERE d<>99 AND b=345 ORDER BY a;
+} {}
+
+do_execsql_test skipscan1-2.3eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a,b,c,d,'|' FROM t6 WHERE d<>99 AND b=345 ORDER BY a DESC;
+} {/* USING INDEX t6abc (ANY(a) AND b=?)*/}
+do_execsql_test skipscan1-2.3 {
+ SELECT a,b,c,d,'|' FROM t6 WHERE d<>99 AND b=345 ORDER BY a DESC;
+} {}
+
+# 2019-07-29 Ticket ced41c7c7d6b4d36
+# A skipscan query is not order-distinct
+#
+db close
+sqlite3 db :memory:
+do_execsql_test skipscan1-3.1 {
+ CREATE TABLE t1 (c1, c2, c3, c4, PRIMARY KEY(c4, c3));
+ INSERT INTO t1 VALUES(3,0,1,NULL);
+ INSERT INTO t1 VALUES(0,4,1,NULL);
+ INSERT INTO t1 VALUES(5,6,1,NULL);
+ INSERT INTO t1 VALUES(0,4,1,NULL);
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1 VALUES('t1','sqlite_autoindex_t1_1','18 18 6');
+ ANALYZE sqlite_master;
+ SELECT DISTINCT quote(c1), quote(c2), quote(c3), quote(c4), '|'
+ FROM t1 WHERE t1.c3 = 1;
+} {3 0 1 NULL | 0 4 1 NULL | 5 6 1 NULL |}
+do_eqp_test skipscan1-3.2 {
+ SELECT DISTINCT quote(c1), quote(c2), quote(c3), quote(c4), '|'
+ FROM t1 WHERE t1.c3 = 1;
+} {
+ QUERY PLAN
+ |--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (ANY(c4) AND c3=?)
+ `--USE TEMP B-TREE FOR DISTINCT
+}
+
+# 2020-01-06 ticket 304017f5f04a0035
+#
+reset_db
+do_execsql_test skipscan1-4.10 {
+ CREATE TABLE t1(a,b INT);
+ INSERT INTO t1(a,b) VALUES(1,2),(3,3),(4,5);
+ CREATE UNIQUE INDEX i1 ON t1(b,b,a,a,a,a,a,b,a);
+ ANALYZE;
+ DROP TABLE IF EXISTS sqlite_stat4;
+ INSERT INTO sqlite_stat1 VALUES('t1','i1','30 30 30 2 2 2 2 2 2 2');
+ ANALYZE sqlite_master;
+
+ SELECT DISTINCT a
+ FROM t1
+ WHERE a = b
+ AND a = 3
+ AND b IN (1,3,2,4)
+ AND b >= 0
+ AND a <= 10;
+} {3}
+
+finish_test
diff --git a/test/skipscan2.test b/test/skipscan2.test
new file mode 100644
index 0000000..aa870d4
--- /dev/null
+++ b/test/skipscan2.test
@@ -0,0 +1,205 @@
+# 2013-11-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 tests of the "skip-scan" query strategy.
+#
+# The test cases in this file are derived from the description of
+# the skip-scan query strategy in the "optoverview.html" document.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test skipscan2-1.1 {
+ CREATE TABLE people(
+ name TEXT PRIMARY KEY,
+ role TEXT NOT NULL,
+ height INT NOT NULL, -- in cm
+ CHECK( role IN ('student','teacher') )
+ );
+ CREATE INDEX people_idx1 ON people(role, height);
+} {}
+do_execsql_test skipscan2-1.2 {
+ INSERT INTO people VALUES('Alice','student',156);
+ INSERT INTO people VALUES('Bob','student',161);
+ INSERT INTO people VALUES('Cindy','student',155);
+ INSERT INTO people VALUES('David','student',181);
+ INSERT INTO people VALUES('Emily','teacher',158);
+ INSERT INTO people VALUES('Fred','student',163);
+ INSERT INTO people VALUES('Ginny','student',169);
+ INSERT INTO people VALUES('Harold','student',172);
+ INSERT INTO people VALUES('Imma','student',179);
+ INSERT INTO people VALUES('Jack','student',181);
+ INSERT INTO people VALUES('Karen','student',163);
+ INSERT INTO people VALUES('Logan','student',177);
+ INSERT INTO people VALUES('Megan','teacher',159);
+ INSERT INTO people VALUES('Nathan','student',163);
+ INSERT INTO people VALUES('Olivia','student',161);
+ INSERT INTO people VALUES('Patrick','teacher',180);
+ INSERT INTO people VALUES('Quiana','student',182);
+ INSERT INTO people VALUES('Robert','student',159);
+ INSERT INTO people VALUES('Sally','student',166);
+ INSERT INTO people VALUES('Tom','student',171);
+ INSERT INTO people VALUES('Ursula','student',170);
+ INSERT INTO people VALUES('Vance','student',179);
+ INSERT INTO people VALUES('Willma','student',175);
+ INSERT INTO people VALUES('Xavier','teacher',185);
+ INSERT INTO people VALUES('Yvonne','student',149);
+ INSERT INTO people VALUES('Zach','student',170);
+}
+
+# Without ANALYZE, a skip-scan is not used
+#
+do_execsql_test skipscan2-1.3 {
+ SELECT name FROM people WHERE height>=180 ORDER BY +name;
+} {David Jack Patrick Quiana Xavier}
+do_execsql_test skipscan2-1.3eqp {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM people WHERE height>=180 ORDER BY +name;
+} {~/*INDEX people_idx1 */}
+
+# Now do an ANALYZE. A skip-scan can be used after ANALYZE.
+#
+do_execsql_test skipscan2-1.4 {
+ ANALYZE;
+ -- We do not have enough people above to actually force the use
+ -- of a skip-scan. So make a manual adjustment to the stat1 table
+ -- to make it seem like there are many more.
+ UPDATE sqlite_stat1 SET stat='10000 5000 20' WHERE idx='people_idx1';
+ UPDATE sqlite_stat1 SET stat='10000 1' WHERE idx='sqlite_autoindex_people_1';
+ ANALYZE sqlite_master;
+}
+db cache flush
+do_execsql_test skipscan2-1.5 {
+ SELECT name FROM people WHERE height>=180 ORDER BY +name;
+} {David Jack Patrick Quiana Xavier}
+do_execsql_test skipscan2-1.5eqp {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM people WHERE height>=180 ORDER BY +name;
+} {/*INDEX people_idx1 */}
+
+# Same answer with other formulations of the same query
+#
+do_execsql_test skipscan2-1.6 {
+ SELECT name FROM people
+ WHERE role IN (SELECT DISTINCT role FROM people)
+ AND height>=180 ORDER BY +name;
+} {David Jack Patrick Quiana Xavier}
+do_execsql_test skipscan2-1.7 {
+ SELECT name FROM people WHERE role='teacher' AND height>=180
+ UNION ALL
+ SELECT name FROM people WHERE role='student' AND height>=180
+ ORDER BY 1;
+} {David Jack Patrick Quiana Xavier}
+
+# Add 8 more people, bringing the total to 34. Then the number of
+# duplicates in the left-column of the index will be 17 and
+# skip-scan should not be used after an (unfudged) ANALYZE.
+#
+do_execsql_test skipscan2-1.8 {
+ INSERT INTO people VALUES('Angie','student',166);
+ INSERT INTO people VALUES('Brad','student',176);
+ INSERT INTO people VALUES('Claire','student',168);
+ INSERT INTO people VALUES('Donald','student',162);
+ INSERT INTO people VALUES('Elaine','student',177);
+ INSERT INTO people VALUES('Frazier','student',159);
+ INSERT INTO people VALUES('Grace','student',179);
+ INSERT INTO people VALUES('Horace','student',166);
+ ANALYZE;
+ SELECT stat FROM sqlite_stat1 WHERE idx='people_idx1';
+} {{34 17 2}}
+db cache flush
+do_execsql_test skipscan2-1.9 {
+ SELECT name FROM people WHERE height>=180 ORDER BY +name;
+} {David Jack Patrick Quiana Xavier}
+do_execsql_test skipscan2-1.9eqp {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM people WHERE height>=180 ORDER BY +name;
+} {~/*INDEX people_idx1 */}
+
+# Add 2 more people, bringing the total to 36. Then the number of
+# duplicates in the left-column of the index will be 18 and
+# skip-scan will be used after an (unfudged) ANALYZE.
+#
+do_execsql_test skipscan2-1.10 {
+ INSERT INTO people VALUES('Ingrad','student',155);
+ INSERT INTO people VALUES('Jacob','student',179);
+ ANALYZE;
+ SELECT stat FROM sqlite_stat1 WHERE idx='people_idx1';
+} {{36 18 2}}
+db cache flush
+do_execsql_test skipscan2-1.11 {
+ SELECT name FROM people WHERE height>=180 ORDER BY +name;
+} {David Jack Patrick Quiana Xavier}
+do_execsql_test skipscan2-1.11eqp {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM people WHERE height>=180 ORDER BY +name;
+} {/*INDEX people_idx1 */}
+
+
+# Repeat using a WITHOUT ROWID table.
+#
+do_execsql_test skipscan2-2.1 {
+ CREATE TABLE peoplew(
+ name TEXT PRIMARY KEY,
+ role TEXT NOT NULL,
+ height INT NOT NULL, -- in cm
+ CHECK( role IN ('student','teacher') )
+ ) WITHOUT ROWID;
+ CREATE INDEX peoplew_idx1 ON peoplew(role, height);
+ INSERT INTO peoplew(name,role,height)
+ SELECT name, role, height FROM people;
+ SELECT name FROM peoplew WHERE height>=180 ORDER BY +name;
+} {David Jack Patrick Quiana Xavier}
+do_execsql_test skipscan2-2.2 {
+ SELECT name FROM peoplew
+ WHERE role IN (SELECT DISTINCT role FROM peoplew)
+ AND height>=180 ORDER BY +name;
+} {David Jack Patrick Quiana Xavier}
+do_execsql_test skipscan2-2.2 {
+ SELECT name FROM peoplew WHERE role='teacher' AND height>=180
+ UNION ALL
+ SELECT name FROM peoplew WHERE role='student' AND height>=180
+ ORDER BY 1;
+} {David Jack Patrick Quiana Xavier}
+
+# Now do an ANALYZE. A skip-scan can be used after ANALYZE.
+#
+do_execsql_test skipscan2-2.4 {
+ ANALYZE;
+}
+db cache flush
+do_execsql_test skipscan2-2.5 {
+ SELECT name FROM peoplew WHERE height>=180 ORDER BY +name;
+} {David Jack Patrick Quiana Xavier}
+do_execsql_test skipscan2-2.5eqp {
+ EXPLAIN QUERY PLAN
+ SELECT name FROM peoplew WHERE height>=180 ORDER BY +name;
+} {/*INDEX peoplew_idx1 */}
+
+# A skip-scan on a PK index of a WITHOUT ROWID table.
+#
+do_execsql_test skipscan2-3.1 {
+ CREATE TABLE t3(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID;
+}
+do_test skipscan2-3.2 {
+ for {set i 0} {$i < 1000} {incr i} {
+ execsql { INSERT INTO t3 VALUES($i%2, $i, 'xyz') }
+ }
+ execsql { ANALYZE }
+} {}
+do_eqp_test skipscan2-3.3eqp {
+ SELECT * FROM t3 WHERE b=42;
+} {SEARCH t3 USING PRIMARY KEY (ANY(a) AND b=?)}
+
+
+
+finish_test
diff --git a/test/skipscan3.test b/test/skipscan3.test
new file mode 100644
index 0000000..260d11c
--- /dev/null
+++ b/test/skipscan3.test
@@ -0,0 +1,73 @@
+# 2014-08-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 of the "skip-scan" query strategy.
+# In particular, this file looks at skipping intermediate terms
+# in an index. For example, if (a,b,c) are indexed, and we have
+# "WHERE a=?1 AND c=?2" - verify that skip-scan can still be used.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test skipscan3-1.1 {
+ CREATE TABLE t1(a,b,c,d,PRIMARY KEY(a,b,c));
+ WITH RECURSIVE
+ c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t1(a,b,c,d)
+ SELECT 1, 1, x, printf('x%04d',x) FROM c;
+ ANALYZE;
+} {}
+
+# This version has long used skip-scan because of the "+a"
+#
+do_execsql_test skipscan3-1.2eqp {
+ EXPLAIN QUERY PLAN SELECT d FROM t1 WHERE +a=1 AND c=32;
+} {/*ANY(a) AND ANY(b)*/}
+do_execsql_test skipscan3-1.2 {
+ SELECT d FROM t1 WHERE +a=1 AND c=32;
+} {x0032}
+
+# This version (with "a" instead of "+a") should use skip-scan but
+# did not prior to changes implemented on 2014-08-20
+#
+do_execsql_test skipscan3-1.3eqp {
+ EXPLAIN QUERY PLAN SELECT d FROM t1 WHERE a=1 AND c=32;
+} {/*ANY(a) AND ANY(b)*/}
+do_execsql_test skipscan3-1.3 {
+ SELECT d FROM t1 WHERE a=1 AND c=32;
+} {x0032}
+
+# Repeat the test on a WITHOUT ROWID table
+#
+do_execsql_test skipscan3-2.1 {
+ CREATE TABLE t2(a,b,c,d,PRIMARY KEY(a,b,c)) WITHOUT ROWID;
+ WITH RECURSIVE
+ c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t2(a,b,c,d)
+ SELECT 1, 1, x, printf('x%04d',x) FROM c;
+ ANALYZE;
+} {}
+do_execsql_test skipscan3-2.2eqp {
+ EXPLAIN QUERY PLAN SELECT d FROM t2 WHERE +a=1 AND c=32;
+} {/*ANY(a) AND ANY(b)*/}
+do_execsql_test skipscan3-2.2 {
+ SELECT d FROM t2 WHERE +a=1 AND c=32;
+} {x0032}
+do_execsql_test skipscan3-2.3eqp {
+ EXPLAIN QUERY PLAN SELECT d FROM t2 WHERE a=1 AND c=32;
+} {/*ANY(a) AND ANY(b)*/}
+do_execsql_test skipscan3-2.3 {
+ SELECT d FROM t2 WHERE a=1 AND c=32;
+} {x0032}
+
+
+finish_test
diff --git a/test/skipscan5.test b/test/skipscan5.test
new file mode 100644
index 0000000..026356e
--- /dev/null
+++ b/test/skipscan5.test
@@ -0,0 +1,182 @@
+# 2013-11-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 of the "skip-scan" query strategy. In
+# particular it tests that stat4 data can be used by a range query
+# that uses the skip-scan approach.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix skipscan5
+
+ifcapable !stat4 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a INT, b INT, c INT);
+ CREATE INDEX i1 ON t1(a, b);
+} {}
+
+expr srand(4)
+do_test 1.2 {
+ for {set i 0} {$i < 1000} {incr i} {
+ set a [expr int(rand()*4.0) + 1]
+ set b [expr int(rand()*20.0) + 1]
+ execsql { INSERT INTO t1 VALUES($a, $b, NULL) }
+ }
+ execsql ANALYZE
+} {}
+
+foreach {tn q res} {
+ 1 "b = 5" {/*ANY(a) AND b=?*/}
+ 2 "b > 12 AND b < 16" {/*ANY(a) AND b>? AND b<?*/}
+ 3 "b > 2 AND b < 16" {/*SCAN t1*/}
+ 4 "b > 18 AND b < 25" {/*ANY(a) AND b>? AND b<?*/}
+ 5 "b > 16" {/*ANY(a) AND b>?*/}
+ 6 "b > 5" {/*SCAN t1*/}
+ 7 "b < 15" {/*SCAN t1*/}
+ 8 "b < 5" {/*ANY(a) AND b<?*/}
+ 9 "5 > b" {/*ANY(a) AND b<?*/}
+ 10 "b = '5'" {/*ANY(a) AND b=?*/}
+ 11 "b > '12' AND b < '16'" {/*ANY(a) AND b>? AND b<?*/}
+ 12 "b > '2' AND b < '16'" {/*SCAN t1*/}
+ 13 "b > '18' AND b < '25'" {/*ANY(a) AND b>? AND b<?*/}
+ 14 "b > '16'" {/*ANY(a) AND b>?*/}
+ 15 "b > '5'" {/*SCAN t1*/}
+ 16 "b < '15'" {/*SCAN t1*/}
+ 17 "b < '5'" {/*ANY(a) AND b<?*/}
+ 18 "'5' > b" {/*ANY(a) AND b<?*/}
+} {
+ set sql "EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE $q"
+ do_execsql_test 1.3.$tn $sql $res
+}
+
+
+#-------------------------------------------------------------------------
+# Test that range-query/skip-scan estimation works with text values.
+# And on UTF-16 databases when there is no UTF-16 collation sequence
+# available.
+#
+
+proc test_collate {enc lhs rhs} {
+ string compare $lhs $rhs
+}
+
+foreach {tn dbenc coll} {
+ 1 UTF-8 { add_test_collate db 0 0 1 }
+ 2 UTF-16 { add_test_collate db 1 0 0 }
+ 3 UTF-8 { add_test_collate db 0 1 0 }
+} {
+ reset_db
+ eval $coll
+
+ do_execsql_test 2.$tn.1 " PRAGMA encoding = '$dbenc' "
+ do_execsql_test 2.$tn.2 {
+ CREATE TABLE t2(a TEXT, b TEXT, c TEXT COLLATE test_collate, d TEXT);
+ CREATE INDEX i2 ON t2(a, b, c);
+ }
+
+ set vocab(d) { :) }
+ set vocab(c) { a b c d e f g h i j k l m n o p q r s t }
+ set vocab(b) { one two three }
+ set vocab(a) { sql }
+
+ do_test 2.$tn.3 {
+ for {set i 0} {$i < 100} {incr i} {
+ foreach var {a b c d} {
+ set $var [lindex $vocab($var) [expr $i % [llength $vocab($var)]]]
+ }
+ execsql { INSERT INTO t2 VALUES($a, $b, $c, $d) }
+ }
+ execsql ANALYZE
+ } {}
+
+ foreach {tn2 q res} {
+ 1 { c BETWEEN 'd' AND 'e' } {/*ANY(a) AND ANY(b) AND c>? AND c<?*/}
+ 2 { c BETWEEN 'b' AND 'r' } {/*SCAN t2*/}
+ 3 { c > 'q' } {/*ANY(a) AND ANY(b) AND c>?*/}
+ 4 { c > 'e' } {/*SCAN t2*/}
+ 5 { c < 'q' } {/*SCAN t2*/}
+ 6 { c < 'b' } {/*ANY(a) AND ANY(b) AND c<?*/}
+ } {
+ set sql "EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE $q"
+ do_execsql_test 2.$tn.$tn2 $sql $res
+ }
+
+}
+
+#-------------------------------------------------------------------------
+# Test that range-query/skip-scan estimation works on columns that contain
+# a variety of types.
+#
+
+reset_db
+do_execsql_test 3.1 {
+ CREATE TABLE t3(a, b, c);
+ CREATE INDEX i3 ON t3(a, b);
+}
+
+set values {
+ NULL NULL NULL
+ NULL -9567 -9240
+ -8725 -8659 -8248.340244520614
+ -8208 -7939 -7746.985758536954
+ -7057 -6550 -5916
+ -5363 -4935.781822975623 -4935.063633571875
+ -3518.4554911770183 -2537 -2026
+ -1511.2603881914456 -1510.4195994839156 -1435
+ -1127.4210136045804 -1045 99
+ 1353 1457 1563.2908193223611
+ 2245 2286 2552
+ 2745.18831295203 2866.279926554429 3075.0468527316334
+ 3447 3867 4237.892420141907
+ 4335 5052.9775000424015 5232.178240656935
+ 5541.784919585003 5749.725576373621 5758
+ 6005 6431 7263.477992854769
+ 7441 7541 8667.279760663994
+ 8857 9199.638673662972 'dl'
+ 'dro' 'h' 'igprfq'
+ 'jnbd' 'k' 'kordee'
+ 'lhwcv' 'mzlb' 'nbjked'
+ 'nufpo' 'nxqkdq' 'shelln'
+ 'tvzn' 'wpnt' 'wylf'
+ 'ydkgu' 'zdb' X''
+ X'0a' X'203f6429f1f33f' X'23858e324545e0362b'
+ X'3f9f8a' X'516f7ddd4b' X'68f1df0930ac6b'
+ X'9ea60d' X'a06f' X'aefd342a39ce36df'
+ X'afaa020fe2' X'be201c' X'c47d97b209601e45'
+}
+
+do_test 3.2 {
+ set c 0
+ foreach v $values {
+ execsql "INSERT INTO t3 VALUES($c % 2, $v, $c)"
+ incr c
+ }
+ execsql ANALYZE
+} {}
+
+foreach {tn q res} {
+ 1 "b BETWEEN -10000 AND -8000" {/*ANY(a) AND b>? AND b<?*/}
+ 2 "b BETWEEN -10000 AND 'qqq'" {/*SCAN t3*/}
+ 3 "b < X'5555'" {/*SCAN t3*/}
+ 4 "b > X'5555'" {/*ANY(a) AND b>?*/}
+ 5 "b > 'zzz'" {/*ANY(a) AND b>?*/}
+ 6 "b < 'zzz'" {/*SCAN t3*/}
+} {
+ set sql "EXPLAIN QUERY PLAN SELECT * FROM t3 WHERE $q"
+ do_execsql_test 3.3.$tn $sql $res
+}
+
+finish_test
diff --git a/test/skipscan6.test b/test/skipscan6.test
new file mode 100644
index 0000000..4f592bc
--- /dev/null
+++ b/test/skipscan6.test
@@ -0,0 +1,191 @@
+# 2014-10-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 of the "skip-scan" query strategy. In
+# particular, this file verifies that use of all columns of an index
+# is always preferred over the use of a skip-scan on some columns of
+# the same index. Because of difficulties in scoring a skip-scan,
+# the skip-scan can sometimes come out with a lower raw score when
+# using STAT4. But the query planner should detect this and use the
+# full index rather than the skip-scan.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix skipscan6
+
+ifcapable !stat4 {
+ finish_test
+ return
+}
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(
+ aa int,
+ bb int,
+ cc int,
+ dd int,
+ ee int
+ );
+ CREATE INDEX ix on t1(aa, bb, cc, dd DESC);
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1 VALUES('t1','ix','2695116 1347558 264 18 2');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 196859 196859 32 1','0 15043 15043 92468 92499','0 19 286 81846 92499',X'0609010804031552977BD725BD28');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 14687 161 1 1','0 289067 299306 299457 299457','0 199 6772 273984 299457',X'060902020403013406314D67456415B819');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 19313 19308 22 1','0 325815 325815 343725 343746','0 261 9545 315009 343746',X'060902080403018A49B0A3AD1ED931');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 25047 9051 15 1','0 350443 350443 356590 356604','0 266 9795 325519 356604',X'06090208040301914C2DD2E91F93CF');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 42327 9906 7 1','0 376381 376381 380291 380297','0 268 10100 344232 380297',X'06090208040301934BF672511F7ED3');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 24513 2237 1 1','0 455150 467779 470015 470015','0 286 10880 425401 470015',X'06090202040301A703464A28F2611EF1EE');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 18730 18724 15 1','0 479663 479663 498271 498285','0 287 10998 450793 498285',X'06090208040301A8494AF3A41EC50C');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 119603 47125 1 1','0 572425 572425 598915 598915','0 404 14230 546497 598915',X'06090208040302474FD1929A03194F');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 1454 1454 1 1','0 898346 898346 898373 898373','0 952 31165 827562 898373',X'06090208040304FD53F6A2A2097F64');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 57138 7069 1 1','0 1122389 1122389 1129457 1129457','0 1967 46801 1045943 1129457',X'06090208040309884BC4C52F1F6EB7');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 285 11 1 1','0 1197683 1197824 1197831 1197831','0 2033 50990 1112280 1197831',X'06090202040309D80346503FE2A9038E4F');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 25365 9773 1 1','0 1301013 1301013 1310785 1310785','0 2561 58806 1217877 1310785',X'0609020804030C5F4C8F88AB0AF2A2');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 45180 7222 1 1','0 1326378 1326378 1333599 1333599','0 2562 59921 1240187 1333599',X'0609020804030C604CAB75490B0351');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 8537 41 1 1','0 1496959 1497288 1497289 1497289','0 3050 68246 1394126 1497289',X'0609020204030EA0057F527459B0257C4B');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 26139 26131 17 1','0 1507977 1507977 1520578 1520594','0 3074 69188 1416111 1520594',X'0609020804030EB95169453423D4EA');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 102894 29678 1 1','0 1537421 1550467 1564894 1564894','0 3109 69669 1459820 1564894',X'0609020204030EE3183652A6ED3006EBCB');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 319 3 1 1','0 1796728 1796746 1796747 1796747','0 3650 86468 1682243 1796747',X'0609020204031163033550D0C41018C28D');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 127 127 1 1','0 2096194 2096194 2096205 2096205','0 5145 106437 1951535 2096205',X'060902080403180F53BB1AF727EE50');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 66574 5252 1 1','0 2230524 2265961 2271212 2271212','0 5899 114976 2085829 2271212',X'0609020204031B8A05195009976D223B90');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 19440 19440 1 1','0 2391680 2391680 2395663 2395663','0 6718 123714 2184781 2395663',X'0609020804031F7452E00A7B07431A');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 18321 2177 1 1','0 2522928 2523231 2525407 2525407','0 7838 139084 2299958 2525407',X'06090201040324A7475231103B1AA7B8');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 22384 1361 1 1','0 2541249 2544834 2546194 2546194','0 7839 139428 2308416 2546194',X'06090202040324A8011652323D4B1AA9EB');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 18699 855 1 1','0 2563633 2578178 2579032 2579032','0 7840 139947 2321671 2579032',X'06090202040324A9077452323D7D1052C5');
+ INSERT INTO sqlite_stat4 VALUES('t1','ix','17965 1579 1579 1 1','2677151 2690666 2690666 2692244 2692244','1 9870 153959 2418294 2692244',X'060102080403021B8A4FE1AB84032B35');
+ ANALYZE sqlite_master;
+} {}
+do_execsql_test 1.2 {
+ EXPLAIN QUERY PLAN
+ SELECT COUNT(*)
+ FROM t1
+ WHERE bb=21
+ AND aa=1
+ AND dd BETWEEN 1413833728 and 1413837331;
+} {/INDEX ix .aa=. AND bb=../}
+
+do_execsql_test 2.1 {
+ DROP INDEX ix;
+ CREATE INDEX good on t1(bb, aa, dd DESC);
+ CREATE INDEX bad on t1(aa, bb, cc, dd DESC);
+ DELETE FROM sqlite_stat1;
+ DELETE FROM sqlite_stat4;
+ INSERT INTO sqlite_stat1 VALUES('t1','good','2695116 299 264 2');
+ INSERT INTO sqlite_stat1 VALUES('t1','bad','2695116 1347558 264 18 2');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','197030 196859 32 1','15086 15086 92511 92536','19 25 81644 92536',X'05010904031552977BD725BD22');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','14972 14687 1 1','289878 289878 299457 299457','199 244 267460 299457',X'050209040301344F7E569402C419');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','19600 19313 22 1','327127 327127 346222 346243','261 319 306884 346243',X'0502090403018A49503BC01EC577');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','25666 25047 15 1','352087 352087 372692 372706','266 327 325601 372706',X'050209040301914C2DD2E91F93CF');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','42392 42327 26 1','378657 378657 382547 382572','268 331 333529 382572',X'05020904030193533B2FE326ED48');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','24619 24513 11 1','457872 457872 461748 461758','286 358 399322 461758',X'050209040301A752B1557825EA7C');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','18969 18730 15 1','482491 482491 501105 501119','287 360 433605 501119',X'050209040301A8494AF3A41EC50C');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','119710 119603 1 1','576500 576500 598915 598915','404 505 519877 598915',X'05020904030247539A7A7912F617');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','11955 11946 1 1','889796 889796 898373 898373','938 1123 794694 898373',X'050209040304EF4DF9C4150BBB28');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','57197 57138 24 1','1129865 1129865 1151492 1151515','1967 2273 1027048 1151515',X'05020904030988533510BC26E20A');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','3609 3543 1 1','1196265 1196265 1197831 1197831','2002 2313 1070108 1197831',X'050209040309B050E95CD718D94D');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','25391 25365 13 1','1309378 1309378 1315567 1315579','2561 2936 1178358 1315579',X'05020904030C5F53DF9E13283570');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','45232 45180 17 1','1334769 1334769 1337946 1337962','2562 2938 1198998 1337962',X'05020904030C60541CACEE28BCAC');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','5496 5493 1 1','1495882 1495882 1497289 1497289','3043 3479 1348695 1497289',X'05020904030E99515C62AD0F0B34');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','26348 26139 17 1','1517381 1517381 1529990 1530006','3074 3519 1378320 1530006',X'05020904030EB95169453423D4EA');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','102927 102894 10 1','1547088 1547088 1649950 1649959','3109 3559 1494260 1649959',X'05020904030EE34D309F671FFA47');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','3602 3576 1 1','1793873 1793873 1796747 1796747','3601 4128 1630783 1796747',X'050209040311294FE88B432219B9');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','154 154 1 1','2096059 2096059 2096205 2096205','5037 5779 1893039 2096205',X'050209040317994EFF05A016DCED');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','68153 66574 60 1','2244039 2244039 2268892 2268951','5899 6749 2027553 2268951',X'05020904031B8A532DBC5A26D2BA');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','321 321 1 1','2395618 2395618 2395663 2395663','6609 7528 2118435 2395663',X'05020904031EFA54078EEE1E2D65');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','19449 19440 22 1','2407769 2407769 2426049 2426070','6718 7651 2146904 2426070',X'05020904031F7450E6118C2336BD');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','18383 18321 56 1','2539949 2539949 2551080 2551135','7838 8897 2245459 2551135',X'050209040324A752EA2E1E2642B2');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','22479 22384 60 1','2558332 2558332 2565233 2565292','7839 8899 2251202 2565292',X'050209040324A853926538279A5F');
+ INSERT INTO sqlite_stat4 VALUES('t1','good','18771 18699 63 1','2580811 2580811 2596914 2596976','7840 8901 2263572 2596976',X'050209040324A9526C1DE9256E72');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 196859 196859 32 1','0 15043 15043 92468 92499','0 19 286 81846 92499',X'0609010804031552977BD725BD28');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 14687 161 1 1','0 289067 299306 299457 299457','0 199 6772 273984 299457',X'060902020403013406314D67456415B819');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 19313 19308 22 1','0 325815 325815 343725 343746','0 261 9545 315009 343746',X'060902080403018A49B0A3AD1ED931');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 25047 9051 15 1','0 350443 350443 356590 356604','0 266 9795 325519 356604',X'06090208040301914C2DD2E91F93CF');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 42327 9906 7 1','0 376381 376381 380291 380297','0 268 10100 344232 380297',X'06090208040301934BF672511F7ED3');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 24513 2237 1 1','0 455150 467779 470015 470015','0 286 10880 425401 470015',X'06090202040301A703464A28F2611EF1EE');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 18730 18724 15 1','0 479663 479663 498271 498285','0 287 10998 450793 498285',X'06090208040301A8494AF3A41EC50C');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 119603 47125 1 1','0 572425 572425 598915 598915','0 404 14230 546497 598915',X'06090208040302474FD1929A03194F');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 1454 1454 1 1','0 898346 898346 898373 898373','0 952 31165 827562 898373',X'06090208040304FD53F6A2A2097F64');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 57138 7069 1 1','0 1122389 1122389 1129457 1129457','0 1967 46801 1045943 1129457',X'06090208040309884BC4C52F1F6EB7');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 285 11 1 1','0 1197683 1197824 1197831 1197831','0 2033 50990 1112280 1197831',X'06090202040309D80346503FE2A9038E4F');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 25365 9773 1 1','0 1301013 1301013 1310785 1310785','0 2561 58806 1217877 1310785',X'0609020804030C5F4C8F88AB0AF2A2');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 45180 7222 1 1','0 1326378 1326378 1333599 1333599','0 2562 59921 1240187 1333599',X'0609020804030C604CAB75490B0351');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 8537 41 1 1','0 1496959 1497288 1497289 1497289','0 3050 68246 1394126 1497289',X'0609020204030EA0057F527459B0257C4B');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 26139 26131 17 1','0 1507977 1507977 1520578 1520594','0 3074 69188 1416111 1520594',X'0609020804030EB95169453423D4EA');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 102894 29678 1 1','0 1537421 1550467 1564894 1564894','0 3109 69669 1459820 1564894',X'0609020204030EE3183652A6ED3006EBCB');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 319 3 1 1','0 1796728 1796746 1796747 1796747','0 3650 86468 1682243 1796747',X'0609020204031163033550D0C41018C28D');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 127 127 1 1','0 2096194 2096194 2096205 2096205','0 5145 106437 1951535 2096205',X'060902080403180F53BB1AF727EE50');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 66574 5252 1 1','0 2230524 2265961 2271212 2271212','0 5899 114976 2085829 2271212',X'0609020204031B8A05195009976D223B90');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 19440 19440 1 1','0 2391680 2391680 2395663 2395663','0 6718 123714 2184781 2395663',X'0609020804031F7452E00A7B07431A');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 18321 2177 1 1','0 2522928 2523231 2525407 2525407','0 7838 139084 2299958 2525407',X'06090201040324A7475231103B1AA7B8');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 22384 1361 1 1','0 2541249 2544834 2546194 2546194','0 7839 139428 2308416 2546194',X'06090202040324A8011652323D4B1AA9EB');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 18699 855 1 1','0 2563633 2578178 2579032 2579032','0 7840 139947 2321671 2579032',X'06090202040324A9077452323D7D1052C5');
+ INSERT INTO sqlite_stat4 VALUES('t1','bad','17965 1579 1579 1 1','2677151 2690666 2690666 2692244 2692244','1 9870 153959 2418294 2692244',X'060102080403021B8A4FE1AB84032B35');
+ ANALYZE sqlite_master;
+} {}
+do_execsql_test 2.2 {
+ EXPLAIN QUERY PLAN
+ SELECT COUNT(*)
+ FROM t1
+ WHERE bb=21
+ AND aa=1
+ AND dd BETWEEN 1413833728 and 1413837331;
+} {/INDEX good .bb=. AND aa=. AND dd>. AND dd<../}
+
+
+# Create a table containing 100 rows. Column "a" contains a copy of the
+# rowid value - sequentially increasing integers from 1 to 100. Column
+# "b" contains the value of (a % 5). Columns "c" and "d" both contain
+# constant values (i.e. the same for every row).
+#
+# Then create a second table t2. t2 is the same as t3 except for the
+# order in which the indexes are created.
+#
+do_execsql_test 3.0 {
+ CREATE TABLE t3(a, b, c, d);
+ CREATE INDEX t3_ba ON t3(b, a, c);
+ CREATE INDEX t3_a ON t3(a);
+
+ WITH d(a, b) AS (
+ SELECT 1, 1
+ UNION ALL
+ SELECT a+1, (a+1) % 5 FROM d WHERE a<100
+ )
+ INSERT INTO t3 SELECT a, b, 'c', 'd' FROM d;
+
+ CREATE TABLE t2(a, b, c, d);
+ CREATE INDEX t2_a ON t2(a);
+ CREATE INDEX t2_ba ON t2(b, a, c);
+ INSERT INTO t2 SELECT * FROM t3;
+
+ ANALYZE;
+ SELECT * FROM sqlite_stat1;
+} {
+ t2 t2_ba {100 20 1 1}
+ t2 t2_a {100 1}
+ t3 t3_a {100 1}
+ t3 t3_ba {100 20 1 1}
+}
+
+# Use index "t3_a", as (a=?) is expected to match only a single row.
+#
+do_eqp_test 3.1 {
+ SELECT * FROM t3 WHERE a = ? AND c = ?
+} {SEARCH t3 USING INDEX t3_a (a=?)}
+
+# The same query on table t2. This should use index "t2_a", for the
+# same reason. At one point though, it was mistakenly using a skip-scan.
+#
+do_eqp_test 3.2 {
+ SELECT * FROM t2 WHERE a = ? AND c = ?
+} {SEARCH t2 USING INDEX t2_a (a=?)}
+
+finish_test
diff --git a/test/snapshot.test b/test/snapshot.test
new file mode 100644
index 0000000..75a8af2
--- /dev/null
+++ b/test/snapshot.test
@@ -0,0 +1,497 @@
+# 2015 December 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 file is the sqlite3_snapshot_xxx() APIs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !snapshot {finish_test; return}
+set testprefix snapshot
+
+# This test does not work with the inmemory_journal permutation. The reason
+# is that each connection opened as part of this permutation executes
+# "PRAGMA journal_mode=memory", which fails if the database is in wal mode
+# and there are one or more existing connections.
+if {[permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+foreach {tn tcl} {
+ 1 {
+ proc snapshot_get {DB DBNAME} {
+ uplevel [list sqlite3_snapshot_get $DB $DBNAME]
+ }
+ proc snapshot_open {DB DBNAME SNAPSHOT} {
+ uplevel [list sqlite3_snapshot_open $DB $DBNAME $SNAPSHOT]
+ }
+ proc snapshot_free {SNAPSHOT} {
+ uplevel [list sqlite3_snapshot_free $SNAPSHOT]
+ }
+ proc snapshot_cmp {SNAPSHOT1 SNAPSHOT2} {
+ uplevel [list sqlite3_snapshot_cmp $SNAPSHOT1 $SNAPSHOT2]
+ }
+ }
+
+ 2 {
+ proc snapshot_get {DB DBNAME} {
+ uplevel [list sqlite3_snapshot_get_blob $DB $DBNAME]
+ }
+ proc snapshot_open {DB DBNAME SNAPSHOT} {
+ uplevel [list sqlite3_snapshot_open_blob $DB $DBNAME $SNAPSHOT]
+ }
+ proc snapshot_free {SNAPSHOT} {
+ }
+ proc snapshot_cmp {SNAPSHOT1 SNAPSHOT2} {
+ uplevel [list sqlite3_snapshot_cmp_blob $SNAPSHOT1 $SNAPSHOT2]
+ }
+ }
+} {
+
+ reset_db
+ eval $tcl
+
+ #-------------------------------------------------------------------------
+ # Check some error conditions in snapshot_get(). It is an error if:
+ #
+ # 1) snapshot_get() is called on a non-WAL database, or
+ # 2) there is an open write transaction on the database.
+ # 3) the database handle is in auto-commit mode
+ #
+ do_execsql_test $tn.1.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+
+ do_test $tn.1.1.1 {
+ execsql { BEGIN; SELECT * FROM t1; }
+ list [catch { snapshot_get db main } msg] $msg
+ } {1 SQLITE_ERROR}
+ do_execsql_test $tn.1.1.2 COMMIT
+
+ do_test $tn.1.2.1 {
+ execsql {
+ PRAGMA journal_mode = WAL;
+ BEGIN;
+ INSERT INTO t1 VALUES(5, 6);
+ INSERT INTO t1 VALUES(7, 8);
+ }
+ list [catch { snapshot_get db main } msg] $msg
+ } {1 SQLITE_ERROR}
+ do_execsql_test $tn.1.2.2 COMMIT
+
+ do_test $tn.1.3.1 {
+ list [catch { snapshot_get db main } msg] $msg
+ } {1 SQLITE_ERROR}
+ do_test $tn.1.3.2 {
+ db trans { set snap [snapshot_get db main] }
+ snapshot_free $snap
+ } {}
+
+ #-------------------------------------------------------------------------
+ # Check that a simple case works. Reuse the database created by the
+ # block of tests above.
+ #
+ do_execsql_test $tn.2.1.0 {
+ BEGIN;
+ SELECT * FROM t1;
+ } {1 2 3 4 5 6 7 8}
+
+ do_test $tn.2.1.1 {
+ set snapshot [snapshot_get db main]
+ execsql {
+ COMMIT;
+ INSERT INTO t1 VALUES(9, 10);
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ do_test $tn.2.1.2 {
+ execsql BEGIN
+ snapshot_open db main $snapshot
+ execsql {
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4 5 6 7 8}
+
+ do_test $tn.2.1.3 {
+ snapshot_free $snapshot
+ execsql COMMIT
+ } {}
+
+ do_test $tn.2.2.0 {
+ sqlite3 db2 test.db
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ } db2
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ do_test $tn.2.2.1 {
+ set snapshot [snapshot_get db2 main]
+ execsql {
+ INSERT INTO t1 VALUES(11, 12);
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4 5 6 7 8 9 10 11 12}
+
+ do_test $tn.2.2.2 {
+ execsql BEGIN
+ snapshot_open db main $snapshot
+ execsql {
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ do_test $tn.2.2.3 {
+ snapshot_free $snapshot
+ execsql COMMIT
+ execsql COMMIT db2
+ db2 close
+ } {}
+
+ do_test $tn.2.3.1 {
+ execsql { DELETE FROM t1 WHERE a>6 }
+ db trans { set snapshot [snapshot_get db main] }
+ execsql {
+ INSERT INTO t1 VALUES('a', 'b');
+ INSERT INTO t1 VALUES('c', 'd');
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4 5 6 a b c d}
+ do_test $tn.2.3.2 {
+ execsql BEGIN
+ snapshot_open db main $snapshot
+ execsql { SELECT * FROM t1 }
+ } {1 2 3 4 5 6}
+
+ do_test $tn.2.3.3 {
+ catchsql {
+ INSERT INTO t1 VALUES('x','y')
+ }
+ } {1 {database is locked}}
+ do_test $tn.2.3.4 {
+ execsql COMMIT
+ snapshot_free $snapshot
+ } {}
+
+ #-------------------------------------------------------------------------
+ # Check some errors in snapshot_open(). It is an error if:
+ #
+ # 1) the db is in auto-commit mode,
+ # 2) the db has an open (read or write) transaction,
+ # 3) the db is not a wal database,
+ #
+ # Reuse the database created by earlier tests.
+ #
+ do_execsql_test $tn.3.0.0 {
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES('a', 'b');
+ INSERT INTO t2 VALUES('c', 'd');
+ BEGIN;
+ SELECT * FROM t2;
+ } {a b c d}
+ do_test $tn.3.0.1 {
+ set snapshot [snapshot_get db main]
+ execsql { COMMIT }
+ execsql { INSERT INTO t2 VALUES('e', 'f'); }
+ } {}
+
+ do_test $tn.3.1 {
+ list [catch {snapshot_open db main $snapshot } msg] $msg
+ } {1 SQLITE_ERROR}
+
+ do_test $tn.3.2.1 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t2;
+ }
+ } {a b c d e f}
+
+ # Update - it is no longer an error to have a read-transaction open,
+ # provided there are no active SELECT statements.
+ do_test $tn.3.2.2a {
+ db eval "SELECT * FROM t2" {
+ set res [list [catch {snapshot_open db main $snapshot } msg] $msg]
+ break
+ }
+ set res
+ } {1 SQLITE_ERROR}
+ do_test $tn.3.2.2b {
+ snapshot_open db main $snapshot
+ } {}
+
+ do_test $tn.3.2.3 {
+ execsql {
+ COMMIT;
+ BEGIN;
+ INSERT INTO t2 VALUES('g', 'h');
+ }
+ list [catch {snapshot_open db main $snapshot } msg] $msg
+ } {1 SQLITE_ERROR}
+ do_execsql_test $tn.3.2.4 COMMIT
+
+ do_test $tn.3.3.1a {
+ execsql { PRAGMA journal_mode = DELETE }
+ execsql { BEGIN }
+ list [catch {snapshot_open db main $snapshot } msg] $msg
+ } {1 SQLITE_ERROR}
+
+ do_test $tn.3.3.1b {
+ execsql { COMMIT ; BEGIN ; SELECT * FROM t2 }
+ list [catch {snapshot_open db main $snapshot } msg] $msg
+ } {1 SQLITE_ERROR}
+
+ do_test $tn.$tn.3.3.2 {
+ snapshot_free $snapshot
+ execsql COMMIT
+ } {}
+
+ #-------------------------------------------------------------------------
+ # Check that SQLITE_ERROR_SNAPSHOT is returned if the specified snapshot
+ # no longer exists because the wal file has been checkpointed.
+ #
+ # 1. Reading a snapshot from the middle of a wal file is not possible
+ # after the wal file has been checkpointed.
+ #
+ # 2. That a snapshot from the end of a wal file can not be read once
+ # the wal file has been wrapped.
+ #
+ do_execsql_test $tn.4.1.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t3(i, j);
+ INSERT INTO t3 VALUES('o', 't');
+ INSERT INTO t3 VALUES('t', 'f');
+ BEGIN;
+ SELECT * FROM t3;
+ } {wal o t t f}
+
+ do_test $tn.4.1.1 {
+ set snapshot [snapshot_get db main]
+ execsql COMMIT
+ } {}
+ do_test $tn.4.1.2 {
+ execsql {
+ INSERT INTO t3 VALUES('f', 's');
+ BEGIN;
+ }
+ snapshot_open db main $snapshot
+ execsql { SELECT * FROM t3 }
+ } {o t t f}
+
+ do_test $tn.4.1.3 {
+ execsql {
+ COMMIT;
+ PRAGMA wal_checkpoint;
+ BEGIN;
+ }
+ list [catch {snapshot_open db main $snapshot} msg] $msg
+ } {1 SQLITE_ERROR_SNAPSHOT}
+ do_test $tn.4.1.4 {
+ snapshot_free $snapshot
+ execsql COMMIT
+ } {}
+
+ do_test $tn.4.2.1 {
+ execsql {
+ INSERT INTO t3 VALUES('s', 'e');
+ INSERT INTO t3 VALUES('n', 't');
+ BEGIN;
+ SELECT * FROM t3;
+ }
+ } {o t t f f s s e n t}
+ do_test $tn.4.2.2 {
+ set snapshot [snapshot_get db main]
+ execsql {
+ COMMIT;
+ PRAGMA wal_checkpoint;
+ BEGIN;
+ }
+ snapshot_open db main $snapshot
+ execsql { SELECT * FROM t3 }
+ } {o t t f f s s e n t}
+ do_test $tn.4.2.3 {
+ execsql {
+ COMMIT;
+ INSERT INTO t3 VALUES('e', 't');
+ BEGIN;
+ }
+ list [catch {snapshot_open db main $snapshot} msg] $msg
+ } {1 SQLITE_ERROR_SNAPSHOT}
+ do_test $tn.4.2.4 {
+ snapshot_free $snapshot
+ } {}
+
+ #-------------------------------------------------------------------------
+ # Check that SQLITE_BUSY is returned if a checkpoint is running when
+ # sqlite3_snapshot_open() is called.
+ #
+ reset_db
+ db close
+ testvfs tvfs
+ sqlite3 db test.db -vfs tvfs
+
+ do_execsql_test $tn.5.1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE x1(x, xx, xxx);
+ INSERT INTO x1 VALUES('z', 'zz', 'zzz');
+ BEGIN;
+ SELECT * FROM x1;
+ } {wal z zz zzz}
+
+ do_test $tn.5.2 {
+ set ::snapshot [snapshot_get db main]
+ sqlite3 db2 test.db -vfs tvfs
+ execsql {
+ INSERT INTO x1 VALUES('a', 'aa', 'aaa');
+ COMMIT;
+ }
+ } {}
+
+ set t53 0
+ proc write_callback {args} {
+ do_test $tn.5.3.[incr ::t53] {
+ execsql BEGIN
+ list [catch { snapshot_open db main $::snapshot } msg] $msg
+ } {1 SQLITE_BUSY}
+ catchsql COMMIT
+ }
+
+ tvfs filter xWrite
+ tvfs script write_callback
+ db2 eval { PRAGMA wal_checkpoint }
+ db close
+ db2 close
+ tvfs delete
+ snapshot_free $snapshot
+
+ #-------------------------------------------------------------------------
+ # Test that sqlite3_snapshot_get() may be called immediately after
+ # "BEGIN; PRAGMA user_version;". And that sqlite3_snapshot_open() may
+ # be called after opening the db handle and running the script
+ # "PRAGMA user_version; BEGIN".
+ reset_db
+ do_execsql_test $tn.6.1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE x1(x, xx, xxx);
+ INSERT INTO x1 VALUES('z', 'zz', 'zzz');
+ BEGIN;
+ PRAGMA user_version;
+ } {wal 0}
+ do_test $tn.6.2 {
+ set ::snapshot [snapshot_get db main]
+ execsql {
+ INSERT INTO x1 VALUES('a', 'aa', 'aaa');
+ COMMIT;
+ }
+ } {}
+ do_test $tn.6.3 {
+ sqlite3 db2 test.db
+ db2 eval "PRAGMA user_version ; BEGIN"
+ snapshot_open db2 main $::snapshot
+ db2 eval { SELECT * FROM x1 }
+ } {z zz zzz}
+ do_test $tn.6.4 {
+ db2 close
+ sqlite3 db2 test.db
+ db2 eval "PRAGMA application_id"
+ db2 eval "BEGIN"
+ snapshot_open db2 main $::snapshot
+ db2 eval { SELECT * FROM x1 }
+ } {z zz zzz}
+
+ do_test $tn.6.5 {
+ db2 close
+ sqlite3 db2 test.db
+ db2 eval "BEGIN"
+ list [catch {snapshot_open db2 main $::snapshot} msg] $msg
+ } {1 SQLITE_ERROR}
+
+ snapshot_free $snapshot
+
+ #-------------------------------------------------------------------------
+ # The following tests investigate the sqlite3_snapshot_cmp() API.
+ #
+
+ # Compare snapshots $p1 and $p2, checking that the result is $r.
+ #
+ proc do_snapshot_cmp_test {tn p1 p2 r} {
+ uplevel [list do_test $tn.1 [list snapshot_cmp $p1 $p2] $r]
+ uplevel [list do_test $tn.2 [list snapshot_cmp $p2 $p1] [expr $r*-1]]
+ uplevel [list do_test $tn.3 [list snapshot_cmp $p1 $p1] 0]
+ uplevel [list do_test $tn.4 [list snapshot_cmp $p2 $p2] 0]
+ }
+
+ catch { db2 close }
+ reset_db
+
+ do_execsql_test $tn.7.1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x);
+ } wal
+
+ do_test $tn.7.1.2 {
+ execsql { BEGIN ; PRAGMA application_id }
+ set p1 [snapshot_get db main]
+ execsql {
+ INSERT INTO t1 VALUES(10);
+ COMMIT;
+ }
+ execsql { BEGIN ; PRAGMA application_id }
+ set p2 [snapshot_get db main]
+ execsql COMMIT
+ } {}
+
+ do_snapshot_cmp_test $tn.7.1.3 $p1 $p2 -1
+ snapshot_free $p1
+ snapshot_free $p2
+
+ do_execsql_test $tn.7.2.1 {
+ INSERT INTO t1 VALUES(11);
+ INSERT INTO t1 VALUES(12);
+ INSERT INTO t1 VALUES(13);
+ BEGIN;
+ PRAGMA application_id;
+ } {0}
+ do_test $tn.7.2.2 {
+ set p1 [snapshot_get db main]
+ execsql {
+ COMMIT;
+ INSERT INTO t1 VALUES(14);
+ PRAGMA wal_checkpoint;
+ BEGIN;
+ PRAGMA application_id;
+ }
+ set p2 [snapshot_get db main]
+ execsql COMMIT
+ } {}
+
+ do_snapshot_cmp_test $tn.7.2.3 $p1 $p2 -1
+ snapshot_free $p2
+
+ do_test $tn.7.3.1 {
+ execsql {
+ INSERT INTO t1 VALUES(14);
+ BEGIN;
+ PRAGMA application_id;
+ }
+ set p2 [snapshot_get db main]
+ execsql COMMIT
+ } {}
+
+ do_snapshot_cmp_test $tn.7.3.2 $p1 $p2 -1
+ snapshot_free $p1
+ snapshot_free $p2
+}
+
+finish_test
diff --git a/test/snapshot2.test b/test/snapshot2.test
new file mode 100644
index 0000000..0f4f177
--- /dev/null
+++ b/test/snapshot2.test
@@ -0,0 +1,240 @@
+# 2016 November 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 the sqlite3_snapshot_xxx() APIs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !snapshot {finish_test; return}
+set testprefix snapshot2
+
+# This test does not work with the inmemory_journal permutation. The reason
+# is that each connection opened as part of this permutation executes
+# "PRAGMA journal_mode=memory", which fails if the database is in wal mode
+# and there are one or more existing connections.
+if {[permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Check that it is not possible to obtain a snapshot immediately after
+# a wal mode database with an empty wal file is opened. But it is after
+# the file has been written, even by some other connection.
+#
+do_execsql_test 1.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+} {wal}
+
+db close
+do_test 1.1.1 { list [file exists test.db] [file exists test.db-wal] } {1 0}
+
+sqlite3 db test.db
+do_execsql_test 1.1.2 { SELECT * FROM t1 } {1 2 3 4 5 6}
+
+do_test 1.1.3 {
+ execsql BEGIN
+ list [catch { sqlite3_snapshot_get_blob db main } msg] $msg
+} {1 SQLITE_ERROR}
+execsql COMMIT
+
+do_test 1.1.4 {
+ execsql { INSERT INTO t1 VALUES(7, 8, 9) }
+ execsql BEGIN
+ string length [sqlite3_snapshot_get_blob db main]
+} 48
+execsql COMMIT
+
+db close
+do_test 1.2.1 { list [file exists test.db] [file exists test.db-wal] } {1 0}
+
+sqlite3 db test.db
+do_execsql_test 1.2.2 { SELECT * FROM t1 } {1 2 3 4 5 6 7 8 9}
+
+do_test 1.2.3 {
+ execsql BEGIN
+ list [catch { sqlite3_snapshot_get_blob db main } msg] $msg
+} {1 SQLITE_ERROR}
+execsql COMMIT
+
+do_test 1.2.4 {
+ sqlite3 db2 test.db
+ execsql { INSERT INTO t1 VALUES(10, 11, 12) } db2
+ execsql BEGIN
+ string length [sqlite3_snapshot_get_blob db main]
+} 48
+execsql COMMIT
+db2 close
+
+#-------------------------------------------------------------------------
+# Simple tests for sqlite3_snapshot_recover().
+#
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+} {wal}
+
+do_test 2.1 {
+ db trans { set snap [sqlite3_snapshot_get_blob db main] }
+ sqlite3_db_config db NO_CKPT_ON_CLOSE 1
+ db close
+ sqlite3 db test.db
+
+ execsql {SELECT * FROM sqlite_master}
+ execsql BEGIN
+ sqlite3_snapshot_open_blob db main $snap
+ execsql COMMIT;
+ execsql { INSERT INTO t1 VALUES(3); }
+} {}
+
+do_test 2.2 {
+ sqlite3_db_config db NO_CKPT_ON_CLOSE 1
+ db close
+ sqlite3 db test.db
+
+ execsql {SELECT * FROM sqlite_master}
+ execsql BEGIN
+ list [catch { sqlite3_snapshot_open_blob db main $snap } msg] $msg
+} {1 SQLITE_ERROR_SNAPSHOT}
+
+do_test 2.3 {
+ execsql COMMIT
+ sqlite3_snapshot_recover db main
+ execsql BEGIN
+ sqlite3_snapshot_open_blob db main $snap
+ execsql { SELECT * FROM t1 }
+} {1 2}
+
+do_test 2.4 {
+ execsql COMMIT
+ execsql { SELECT * FROM t1 }
+} {1 2 3}
+
+do_test 2.5 {
+ execsql { PRAGMA wal_checkpoint }
+ sqlite3_db_config db NO_CKPT_ON_CLOSE 1
+ db close
+ sqlite3 db test.db
+
+ sqlite3_snapshot_recover db main
+ execsql BEGIN
+ list [catch { sqlite3_snapshot_open_blob db main $snap } msg] $msg
+} {1 SQLITE_ERROR_SNAPSHOT}
+
+#-------------------------------------------------------------------------
+# Check that calling sqlite3_snapshot_recover() does not confuse the
+# pager cache.
+reset_db
+do_execsql_test 3.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('a', 'b');
+ INSERT INTO t1 VALUES('c', 'd');
+} {wal}
+do_test 3.1 {
+ sqlite3 db2 test.db
+ execsql { INSERT INTO t1 VALUES('e', 'f') } db2
+ db2 close
+ sqlite3_snapshot_recover db main
+} {}
+do_execsql_test 3.2 {
+ SELECT * FROM t1;
+} {a b c d e f}
+
+#-------------------------------------------------------------------------
+# Check that sqlite3_snapshot_recover() returns an error if it is called
+# with an open read-transaction. Or on a database that does not exist. Or
+# on the temp database. Or on a db that is not in wal mode.
+#
+do_test 4.1 {
+ sqlite3_snapshot_recover db main
+} {}
+do_test 4.2 {
+ execsql {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ }
+ list [catch { sqlite3_snapshot_recover db main } msg] $msg
+} {1 SQLITE_ERROR}
+do_test 4.3 {
+ execsql COMMIT
+ sqlite3_snapshot_recover db main
+} {}
+do_test 4.4 {
+ list [catch { sqlite3_snapshot_recover db aux } msg] $msg
+} {1 SQLITE_ERROR}
+do_test 4.5 {
+ forcedelete test.db2
+ execsql {
+ ATTACH 'test.db2' AS aux;
+ PRAGMA aux.journal_mode = wal;
+ CREATE TABLE aux.t2(x, y);
+ }
+ list [catch { sqlite3_snapshot_recover db aux } msg] $msg
+} {0 {}}
+do_test 4.6 {
+ list [catch { sqlite3_snapshot_recover db temp } msg] $msg
+} {1 SQLITE_ERROR}
+do_test 4.7 {
+ execsql {
+ PRAGMA aux.journal_mode = delete;
+ }
+ list [catch { sqlite3_snapshot_recover db aux } msg] $msg
+} {1 SQLITE_ERROR}
+
+#-------------------------------------------------------------------------
+reset_db
+sqlite3 db2 test.db
+do_execsql_test 5.0 {
+ CREATE TABLE t2(x);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t2 VALUES('abc');
+ INSERT INTO t2 VALUES('def');
+ INSERT INTO t2 VALUES('ghi');
+} {wal}
+
+do_test 5.1 {
+ execsql {
+ SELECT * FROM t2;
+ BEGIN;
+ } db2
+ set snap [sqlite3_snapshot_get_blob db2 main]
+ db2 eval END
+} {}
+
+do_test 5.2 {
+ execsql BEGIN db2
+ sqlite3_snapshot_open_blob db2 main $snap
+ db2 eval { SELECT * FROM t2 ; END }
+} {abc def ghi}
+
+do_test 5.3 {
+ execsql { PRAGMA wal_checkpoint = RESTART }
+ execsql BEGIN db2
+ sqlite3_snapshot_open_blob db2 main $snap
+ db2 eval { SELECT * FROM t2 ; END }
+} {abc def ghi}
+
+do_test 5.4 {
+ execsql { INSERT INTO t2 VALUES('jkl') }
+ execsql BEGIN db2
+ list [catch { sqlite3_snapshot_open_blob db2 main $snap } msg] $msg
+} {1 SQLITE_ERROR_SNAPSHOT}
+
+
+finish_test
diff --git a/test/snapshot3.test b/test/snapshot3.test
new file mode 100644
index 0000000..4dca202
--- /dev/null
+++ b/test/snapshot3.test
@@ -0,0 +1,99 @@
+# 2016 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 the sqlite3_snapshot_xxx() APIs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !snapshot {finish_test; return}
+set testprefix snapshot3
+
+# This test does not work with the inmemory_journal permutation. The reason
+# is that each connection opened as part of this permutation executes
+# "PRAGMA journal_mode=memory", which fails if the database is in wal mode
+# and there are one or more existing connections.
+if {[permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# This block of tests verifies that it is not possible to wrap the wal
+# file - using a writer or a "PRAGMA wal_checkpoint = TRUNCATE" - while
+# there is an open snapshot transaction (transaction opened using
+# sqlite3_snapshot_open()).
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(y);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+} {wal}
+
+do_test 1.1 {
+ sqlite3 db2 test.db
+ sqlite3 db3 test.db
+
+ execsql {SELECT * FROM sqlite_master} db2
+ execsql {SELECT * FROM sqlite_master} db3
+
+ db2 trans { set snap [sqlite3_snapshot_get_blob db2 main] }
+ db2 eval { SELECT * FROM t1 }
+} {1 2 3 4}
+
+do_test 1.2 {
+ execsql BEGIN db2
+ sqlite3_snapshot_open_blob db2 main $snap
+ db2 eval { SELECT * FROM t1 }
+} {1 2 3 4}
+
+do_test 1.2 {
+ execsql END db2
+ execsql { PRAGMA wal_checkpoint }
+
+ execsql BEGIN db2
+ sqlite3_snapshot_open_blob db2 main $snap
+ db2 eval { SELECT * FROM t1 }
+} {1 2 3 4}
+
+set sz [file size test.db-wal]
+do_test 1.3 {
+ execsql { PRAGMA wal_checkpoint = truncate }
+ file size test.db-wal
+} $sz
+
+do_test 1.4 {
+ execsql BEGIN db3
+ list [catch { sqlite3_snapshot_open_blob db3 main $snap } msg] $msg
+} {0 {}}
+
+do_test 1.5 {
+ db3 eval { SELECT * FROM t1; END }
+} {1 2 3 4}
+
+do_test 1.6 {
+ db2 eval { SELECT * FROM t1; END }
+} {1 2 3 4}
+
+do_test 1.7 {
+ execsql { PRAGMA wal_checkpoint = truncate }
+ file size test.db-wal
+} 0
+
+do_test 1.8 {
+ execsql BEGIN db3
+ list [catch { sqlite3_snapshot_open_blob db3 main $snap } msg] $msg
+} {1 SQLITE_ERROR_SNAPSHOT}
+
+finish_test
diff --git a/test/snapshot4.test b/test/snapshot4.test
new file mode 100644
index 0000000..ac7f6ad
--- /dev/null
+++ b/test/snapshot4.test
@@ -0,0 +1,74 @@
+# 2018 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 file is the sqlite3_snapshot_xxx() APIs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !snapshot {finish_test; return}
+set testprefix snapshot4
+
+# This test does not work with the inmemory_journal permutation. The reason
+# is that each connection opened as part of this permutation executes
+# "PRAGMA journal_mode=memory", which fails if the database is in wal mode
+# and there are one or more existing connections.
+if {[permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+sqlite3 db2 test.db
+
+do_execsql_test 1.0 {
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, randomblob(400));
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS (
+ SELECT 2 UNION ALL SELECT i+1 FROM s WHERE i<100
+ )
+ INSERT INTO t1 SELECT i, randomblob(400) FROM s;
+} {wal}
+
+do_test 1.1 {
+ execsql {
+ BEGIN;
+ SELECT count(*) FROM t1;
+ }
+} {100}
+
+do_test 1.2 {
+ db2 eval {
+ SELECT count(*) FROM t1;
+ CREATE TABLE t2(x);
+ }
+} {100}
+
+do_test 1.3 {
+ set ::snap [sqlite3_snapshot_get_blob db main]
+ db2 eval { PRAGMA wal_checkpoint }
+} {0 54 52}
+
+do_test 1.4 {
+ execsql {
+ COMMIT;
+ SELECT * FROM sqlite_master;
+ BEGIN;
+ }
+ sqlite3_snapshot_open_blob db main $::snap
+ execsql {
+ SELECT count(*) FROM t1
+ }
+} {100}
+
+
+finish_test
diff --git a/test/snapshot_fault.test b/test/snapshot_fault.test
new file mode 100644
index 0000000..2adb793
--- /dev/null
+++ b/test/snapshot_fault.test
@@ -0,0 +1,251 @@
+# 2015 December 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 sqlite3_snapshot_xxx() APIs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !snapshot {finish_test; return}
+set testprefix snapshot_fault
+
+#-------------------------------------------------------------------------
+# Check that an sqlite3_snapshot_open() client cannot be tricked into
+# reading a corrupt snapshot even if a second client fails while
+# checkpointing the db.
+#
+do_faultsim_test 1.0 -prep {
+ faultsim_delete_and_reopen
+ sqlite3 db2 test.db
+ db2 eval {
+ CREATE TABLE t1(a, b UNIQUE, c UNIQUE);
+ INSERT INTO t1 VALUES(1, randomblob(500), randomblob(500));
+ INSERT INTO t1 VALUES(2, randomblob(500), randomblob(500));
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(3, randomblob(500), randomblob(500));
+ BEGIN;
+ SELECT a FROM t1;
+ }
+ set ::snapshot [sqlite3_snapshot_get db2 main]
+ db2 eval COMMIT
+ db2 eval {
+ UPDATE t1 SET b=randomblob(501), c=randomblob(501) WHERE a=1;
+ INSERT INTO t1 VALUES(4, randomblob(500), randomblob(500));
+ INSERT INTO t1 VALUES(5, randomblob(500), randomblob(500));
+ INSERT INTO t1 VALUES(6, randomblob(500), randomblob(500));
+ }
+} -body {
+ db eval { PRAGMA wal_checkpoint }
+} -test {
+ db2 eval BEGIN
+ if {[catch { sqlite3_snapshot_open db2 main $::snapshot } msg]} {
+ if {$msg != "SQLITE_ERROR_SNAPSHOT" && $msg != "SQLITE_BUSY"} {
+ error "error is $msg"
+ }
+ } else {
+ set res [db2 eval {
+ SELECT a FROM t1;
+ PRAGMA integrity_check;
+ }]
+ if {$res != "1 2 3 ok"} { error "res is $res" }
+ }
+
+ sqlite3_snapshot_free $::snapshot
+}
+
+#-------------------------------------------------------------------------
+# This test is similar to the previous one. Except, after the
+# "PRAGMA wal_checkpoint" command fails the db is closed and reopened
+# so as to require wal file recovery. It should not be possible to open
+# a snapshot that is part of the body of a recovered wal file.
+#
+do_faultsim_test 2.0 -prep {
+ faultsim_delete_and_reopen
+ db eval {
+ CREATE TABLE t1(a, b UNIQUE, c UNIQUE);
+ INSERT INTO t1 VALUES(1, randomblob(500), randomblob(500));
+ INSERT INTO t1 VALUES(2, randomblob(500), randomblob(500));
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(3, randomblob(500), randomblob(500));
+ BEGIN;
+ SELECT a FROM t1;
+ }
+ set ::snapshot [sqlite3_snapshot_get db main]
+ db eval COMMIT
+
+ db eval {
+ UPDATE t1 SET b=randomblob(501), c=randomblob(501) WHERE a=1;
+ INSERT INTO t1 VALUES(4, randomblob(500), randomblob(500));
+ INSERT INTO t1 VALUES(5, randomblob(500), randomblob(500));
+ INSERT INTO t1 VALUES(6, randomblob(500), randomblob(500));
+ }
+} -body {
+ db eval { PRAGMA wal_checkpoint }
+} -test {
+
+ db_save
+ db close
+ db_restore_and_reopen
+ db eval { SELECT * FROM t1 }
+
+ db eval BEGIN
+ if {[catch { sqlite3_snapshot_open db main $::snapshot } msg]} {
+ if {$msg != "SQLITE_ERROR_SNAPSHOT" && $msg != "SQLITE_BUSY"} {
+ error "error is $msg"
+ }
+ } else {
+ # This branch should actually never be taken. But it was useful in
+ # determining whether or not this test was actually working (by
+ # running a modified version of SQLite that allowed snapshots to be
+ # opened following a recovery).
+ error "TEST HAS FAILED"
+
+ set res [db eval {
+ SELECT a FROM t1;
+ PRAGMA integrity_check;
+ }]
+ if {$res != "1 2 3 ok"} { error "res is $res" }
+ }
+
+ sqlite3_snapshot_free $::snapshot
+}
+
+#-------------------------------------------------------------------------
+# Test the handling of faults that occur within sqlite3_snapshot_open().
+#
+do_faultsim_test 3.0 -prep {
+ faultsim_delete_and_reopen
+ db eval {
+ CREATE TABLE t1(a, b UNIQUE, c UNIQUE);
+ INSERT INTO t1 VALUES(1, randomblob(500), randomblob(500));
+ INSERT INTO t1 VALUES(2, randomblob(500), randomblob(500));
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(3, randomblob(500), randomblob(500));
+ BEGIN;
+ SELECT a FROM t1;
+ }
+ set ::snapshot [sqlite3_snapshot_get db main]
+ db eval COMMIT
+ db eval {
+ UPDATE t1 SET b=randomblob(501), c=randomblob(501) WHERE a=1;
+ INSERT INTO t1 VALUES(4, randomblob(500), randomblob(500));
+ INSERT INTO t1 VALUES(5, randomblob(500), randomblob(500));
+ INSERT INTO t1 VALUES(6, randomblob(500), randomblob(500));
+ BEGIN;
+ }
+} -body {
+ if { [catch { sqlite3_snapshot_open db main $::snapshot } msg] } {
+ error $msg
+ }
+} -test {
+ faultsim_test_result {0 {}} {1 SQLITE_IOERR} {1 SQLITE_NOMEM} \
+ {1 SQLITE_IOERR_NOMEM} {1 SQLITE_IOERR_READ}
+ if {$testrc==0} {
+ set res [db eval {
+ SELECT a FROM t1;
+ PRAGMA integrity_check;
+ }]
+ if {$res != "1 2 3 ok"} { error "res is $res" }
+ }
+
+ sqlite3_snapshot_free $::snapshot
+}
+
+#-------------------------------------------------------------------------
+# Test the handling of faults that occur within sqlite3_snapshot_recover().
+#
+reset_db
+do_execsql_test 4.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(zzz);
+ INSERT INTO t1 VALUES('abc');
+ INSERT INTO t1 VALUES('def');
+} {wal}
+faultsim_save_and_close
+
+do_test 4.0.1 {
+ faultsim_restore_and_reopen
+ db eval { SELECT * FROM sqlite_master }
+ sqlite3_snapshot_recover db main
+} {}
+db close
+
+do_faultsim_test 4.0 -faults oom* -prep {
+ faultsim_restore_and_reopen
+ db eval { SELECT * FROM sqlite_master }
+} -body {
+ sqlite3_snapshot_recover db main
+} -test {
+ faultsim_test_result {0 {}} {1 SQLITE_NOMEM} {1 SQLITE_IOERR_NOMEM}
+}
+
+# The following test cases contrive to call sqlite3_snapshot_recover()
+# before all pages of the *-shm file have been mapped. This tests an
+# extra branch of error handling logic in snapshot_recover().
+#
+reset_db
+do_execsql_test 4.1.0 {
+ PRAGMA page_size = 512;
+ PRAGMA journal_mode = wal;
+ PRAGMA wal_autocheckpoint = 0;
+ CREATE TABLE t1(zzz);
+ INSERT INTO t1 VALUES(randomblob( 500 * 9500 ));
+ PRAGMA user_version = 211;
+} {wal 0}
+
+do_test 4.1.1 {
+ list [file size test.db-shm] [file size test.db]
+} {98304 512}
+
+faultsim_save_and_close
+do_faultsim_test 4.1 -faults shm* -prep {
+ catch { db2 close }
+ catch { db close }
+ faultsim_restore_and_reopen
+ sqlite3 db2 test.db
+ db2 eval { SELECT * FROM sqlite_master }
+ db eval BEGIN
+ sqlite3_snapshot_get_blob db main
+ db eval COMMIT
+} -body {
+ sqlite3_snapshot_recover db main
+} -test {
+ faultsim_test_result {0 {}} {1 SQLITE_IOERR}
+}
+
+#-------------------------------------------------------------------------
+# Test the handling of faults that occur within sqlite3_snapshot_get().
+#
+reset_db
+do_execsql_test 5.0 {
+ PRAGMA page_size = 512;
+ PRAGMA journal_mode = wal;
+ PRAGMA wal_autocheckpoint = 0;
+ CREATE TABLE t1(zzz);
+ INSERT INTO t1 VALUES(randomblob( 5000 ));
+ PRAGMA user_version = 211;
+} {wal 0}
+faultsim_save_and_close
+
+do_faultsim_test 5 -prep {
+ faultsim_restore_and_reopen
+ execsql { SELECT count(*) FROM sqlite_master }
+ execsql BEGIN
+} -body {
+ sqlite3_snapshot_get_blob db main
+ set {} {}
+} -test {
+ execsql END
+ faultsim_test_result {0 {}} {1 SQLITE_IOERR} {1 SQLITE_NOMEM}
+}
+
+
+finish_test
diff --git a/test/snapshot_up.test b/test/snapshot_up.test
new file mode 100644
index 0000000..de8e5af
--- /dev/null
+++ b/test/snapshot_up.test
@@ -0,0 +1,183 @@
+# 2018 August 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.
+#
+#***********************************************************************
+#
+# Tests for calling sqlite3_snapshot_open() when there is already
+# a read transaction open on the database.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !snapshot {finish_test; return}
+set testprefix snapshot_up
+
+# This test does not work with the inmemory_journal permutation. The reason
+# is that each connection opened as part of this permutation executes
+# "PRAGMA journal_mode=memory", which fails if the database is in wal mode
+# and there are one or more existing connections.
+if {[permutation]=="inmemory_journal"} {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ INSERT INTO t1 VALUES(7, 8, 9);
+} {wal}
+
+do_test 1.1 {
+ execsql BEGIN
+ set ::snap1 [sqlite3_snapshot_get db main]
+ execsql COMMIT
+ execsql { INSERT INTO t1 VALUES(10, 11, 12); }
+ execsql BEGIN
+ set ::snap2 [sqlite3_snapshot_get db main]
+ execsql COMMIT
+ execsql { INSERT INTO t1 VALUES(13, 14, 15); }
+ execsql BEGIN
+ set ::snap3 [sqlite3_snapshot_get db main]
+ execsql COMMIT
+} {}
+
+do_execsql_test 1.2 {
+ BEGIN;
+ SELECT * FROM t1
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}
+
+do_test 1.3 {
+ sqlite3_snapshot_open db main $::snap1
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6 7 8 9}
+
+do_test 1.4 {
+ sqlite3_snapshot_open db main $::snap2
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+
+do_test 1.5 {
+ sqlite3 db2 test.db
+ execsql { PRAGMA wal_checkpoint } db2
+} {0 5 4}
+
+do_execsql_test 1.6 {
+ SELECT * FROM t1
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+
+do_test 1.7 {
+ list [catch { sqlite3_snapshot_open db main $::snap1 } msg] $msg
+} {1 SQLITE_ERROR_SNAPSHOT}
+
+do_execsql_test 1.8 {
+ SELECT * FROM t1
+} {1 2 3 4 5 6 7 8 9 10 11 12}
+
+do_test 1.9 {
+ execsql { COMMIT ; BEGIN }
+ list [catch { sqlite3_snapshot_open db main $::snap1 } msg] $msg
+} {1 SQLITE_ERROR_SNAPSHOT}
+
+do_test 1.10 {
+ execsql { COMMIT }
+ execsql {
+ PRAGMA wal_checkpoint;
+ DELETE FROM t1 WHERE a = 1;
+ } db2
+ execsql BEGIN
+ set ::snap4 [sqlite3_snapshot_get db main]
+ execsql COMMIT
+ execsql {
+ DELETE FROM t1 WHERE a = 4;
+ } db2
+} {}
+
+do_test 1.11 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t1
+ }
+} {7 8 9 10 11 12 13 14 15}
+do_test 1.12 {
+ sqlite3_snapshot_open db main $::snap4
+ execsql { SELECT * FROM t1 }
+} {4 5 6 7 8 9 10 11 12 13 14 15}
+
+do_test 1.13 {
+ list [catch { sqlite3_snapshot_open db main $::snap3 } msg] $msg
+} {1 SQLITE_ERROR_SNAPSHOT}
+do_test 1.14 {
+ execsql { SELECT * FROM t1 }
+} {4 5 6 7 8 9 10 11 12 13 14 15}
+
+db close
+db2 close
+sqlite3 db test.db
+do_execsql_test 1.15 {
+ BEGIN;
+ SELECT * FROM t1
+} {7 8 9 10 11 12 13 14 15}
+do_test 1.16 {
+ list [catch { sqlite3_snapshot_open db main $::snap4 } msg] $msg
+} {1 SQLITE_ERROR_SNAPSHOT}
+do_execsql_test 1.17 { COMMIT }
+
+sqlite3_snapshot_free $::snap1
+sqlite3_snapshot_free $::snap2
+sqlite3_snapshot_free $::snap3
+sqlite3_snapshot_free $::snap4
+
+#-------------------------------------------------------------------------
+catch { db close }
+sqlite3 db test.db
+sqlite3 db2 test.db
+sqlite3 db3 test.db
+
+proc xBusy {args} { return 1 }
+db3 busy xBusy
+
+do_test 2.1 {
+ execsql { INSERT INTO t1 VALUES(16, 17, 18) } db2
+ execsql BEGIN
+ set ::snap1 [sqlite3_snapshot_get db main]
+ execsql COMMIT
+ execsql { INSERT INTO t1 VALUES(19, 20, 21) } db2
+ execsql BEGIN
+ set ::snap2 [sqlite3_snapshot_get db main]
+ execsql COMMIT
+ set {} {}
+} {}
+
+do_execsql_test -db db2 2.2 {
+ BEGIN;
+ INSERT INTO t1 VALUES(19, 20, 21);
+}
+
+do_test 2.3 {
+ execsql BEGIN
+ sqlite3_snapshot_open db main $::snap1
+ execsql { SELECT * FROM t1 }
+} {7 8 9 10 11 12 13 14 15 16 17 18}
+
+proc xBusy {args} {
+ set ::res [list [catch { sqlite3_snapshot_open db main $::snap2 } msg] $msg]
+ return 1
+}
+db3 busy xBusy
+do_test 2.4 {
+ execsql {PRAGMA wal_checkpoint = restart} db3
+ set ::res
+} {1 SQLITE_BUSY}
+
+sqlite3_snapshot_free $::snap1
+sqlite3_snapshot_free $::snap2
+
+finish_test
diff --git a/test/soak.test b/test/soak.test
new file mode 100644
index 0000000..e8535a1
--- /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..07f981e
--- /dev/null
+++ b/test/softheap1.test
@@ -0,0 +1,74 @@
+# 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
+}
+
+# EVIDENCE-OF: R-26343-45930 This pragma invokes the
+# sqlite3_soft_heap_limit64() interface with the argument N, if N is
+# specified and is a non-negative integer.
+#
+# EVIDENCE-OF: R-64451-07163 The soft_heap_limit pragma always returns
+# the same integer that would be returned by the
+# sqlite3_soft_heap_limit64(-1) C-language function.
+#
+do_test softheap1-1.0 {
+ execsql {PRAGMA soft_heap_limit}
+} [sqlite3_soft_heap_limit -1]
+do_test softheap1-1.1 {
+ execsql {PRAGMA soft_heap_limit=123456; PRAGMA soft_heap_limit;}
+} {123456 123456}
+do_test softheap1-1.2 {
+ sqlite3_soft_heap_limit -1
+} {123456}
+do_test softheap1-1.3 {
+ execsql {PRAGMA soft_heap_limit(-1); PRAGMA soft_heap_limit;}
+} {123456 123456}
+do_test softheap1-1.4 {
+ execsql {PRAGMA soft_heap_limit(0); PRAGMA soft_heap_limit;}
+} {0 0}
+
+sqlite3_soft_heap_limit 5000
+do_test softheap1-2.0 {
+ execsql {PRAGMA soft_heap_limit}
+} {5000}
+do_test softheap1-2.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..d73ecea
--- /dev/null
+++ b/test/sort.test
@@ -0,0 +1,598 @@
+# 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 sorter (code in vdbesort.c).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix sort
+db close
+sqlite3_shutdown
+sqlite3_config_pmasz 10
+sqlite3_initialize
+sqlite3 db test.db
+
+# 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}
+
+#-------------------------------------------------------------------------
+# Check that the sorter in vdbesort.c sorts in a stable fashion.
+#
+do_execsql_test sort-13.0 {
+ CREATE TABLE t10(a, b);
+}
+do_test sort-13.1 {
+ db transaction {
+ for {set i 0} {$i < 100000} {incr i} {
+ execsql { INSERT INTO t10 VALUES( $i/10, $i%10 ) }
+ }
+ }
+} {}
+do_execsql_test sort-13.2 {
+ SELECT a, b FROM t10 ORDER BY a;
+} [db eval {SELECT a, b FROM t10 ORDER BY a, b}]
+do_execsql_test sort-13.3 {
+ PRAGMA cache_size = 5;
+ SELECT a, b FROM t10 ORDER BY a;
+} [db eval {SELECT a, b FROM t10 ORDER BY a, b}]
+
+#-------------------------------------------------------------------------
+#
+foreach {tn mmap_limit nWorker tmpstore coremutex fakeheap softheaplimit} {
+ 1 0 3 file true false 0
+ 2 0 3 file true true 0
+ 3 0 0 file true false 0
+ 4 1000000 3 file true false 0
+ 5 0 0 memory false true 0
+ 6 0 0 file false true 1000000
+ 7 0 0 file false true 10000
+} {
+ db close
+ sqlite3_shutdown
+ if {$coremutex} {
+ sqlite3_config multithread
+ } else {
+ sqlite3_config singlethread
+ }
+ sqlite3_initialize
+ sorter_test_fakeheap $fakeheap
+ sqlite3_soft_heap_limit $softheaplimit
+
+ reset_db
+ sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit
+ execsql "PRAGMA temp_store = $tmpstore; PRAGMA threads = $nWorker"
+
+
+ set ten [string repeat X 10300]
+ set one [string repeat y 200]
+
+ if {$softheaplimit} {
+ execsql { PRAGMA cache_size = 20 };
+ } else {
+ execsql { PRAGMA cache_size = 5 };
+ }
+
+ do_execsql_test 15.$tn.1 {
+ WITH rr AS (
+ SELECT 4, $ten UNION ALL
+ SELECT 2, $one UNION ALL
+ SELECT 1, $ten UNION ALL
+ SELECT 3, $one
+ )
+ SELECT * FROM rr ORDER BY 1;
+ } [list 1 $ten 2 $one 3 $one 4 $ten]
+
+ do_execsql_test 15.$tn.2 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(4);
+ INSERT INTO t1 VALUES(5);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(6);
+ INSERT INTO t1 VALUES(1);
+ CREATE INDEX i1 ON t1(a);
+ SELECT * FROM t1 ORDER BY a;
+ } {1 2 3 4 5 6}
+
+ do_execsql_test 15.$tn.3 {
+ WITH rr AS (
+ SELECT 4, $ten UNION ALL
+ SELECT 2, $one
+ )
+ SELECT * FROM rr ORDER BY 1;
+ } [list 2 $one 4 $ten]
+
+ sorter_test_fakeheap 0
+}
+
+db close
+sqlite3_shutdown
+set t(0) singlethread
+set t(1) multithread
+set t(2) serialized
+sqlite3_config $t($sqlite_options(threadsafe))
+sqlite3_initialize
+sqlite3_soft_heap_limit 0
+
+reset_db
+do_catchsql_test 16.1 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(1, NULL, 3);
+ INSERT INTO t1 VALUES(NULL, 2, 3);
+ INSERT INTO t1 VALUES(1, 2, NULL);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ CREATE UNIQUE INDEX i1 ON t1(b, a, c);
+} {0 {}}
+reset_db
+do_catchsql_test 16.2 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(1, NULL, 3);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(1, 2, NULL);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ CREATE UNIQUE INDEX i1 ON t1(b, a, c);
+} {1 {UNIQUE constraint failed: t1.b, t1.a, t1.c}}
+
+reset_db
+do_execsql_test 17.1 {
+ SELECT * FROM sqlite_master ORDER BY sql;
+} {}
+
+finish_test
diff --git a/test/sort2.test b/test/sort2.test
new file mode 100644
index 0000000..f686654
--- /dev/null
+++ b/test/sort2.test
@@ -0,0 +1,88 @@
+# 2014 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 SQLite library.
+#
+# Specifically, the tests in this file attempt to verify that
+# multi-threaded sorting works.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix sort2
+db close
+sqlite3_shutdown
+sqlite3_config_pmasz 10
+sqlite3_initialize
+sqlite3 db test.db
+
+foreach {tn script} {
+ 1 { }
+ 2 {
+ catch { db close }
+ reset_db
+ catch { db eval {PRAGMA threads=7} }
+ }
+} {
+ eval $script
+
+ do_execsql_test $tn.1 {
+ PRAGMA cache_size = 5;
+ WITH r(x,y) AS (
+ SELECT 1, randomblob(100)
+ UNION ALL
+ SELECT x+1, randomblob(100) FROM r
+ LIMIT 100000
+ )
+ SELECT count(x), length(y) FROM r GROUP BY (x%5)
+ } {
+ 20000 100 20000 100 20000 100 20000 100 20000 100
+ }
+
+ do_execsql_test $tn.2.1 {
+ CREATE TABLE t1(a, b);
+ WITH r(x,y) AS (
+ SELECT 1, randomblob(100)
+ UNION ALL
+ SELECT x+1, randomblob(100) FROM r
+ LIMIT 10000
+ ) INSERT INTO t1 SELECT * FROM r;
+ }
+
+ do_execsql_test $tn.2.2 {
+ CREATE UNIQUE INDEX i1 ON t1(b, a);
+ }
+
+ do_execsql_test $tn.2.3 {
+ CREATE UNIQUE INDEX i2 ON t1(a);
+ }
+
+ do_execsql_test $tn.2.4 { PRAGMA integrity_check } {ok}
+
+ # Because it uses so much data, this test can take 12-13 seconds even on
+ # a modern workstation. So it is omitted from "veryquick" and other
+ # permutations.test tests.
+ if {[isquick]==0} {
+ do_execsql_test $tn.3 {
+ PRAGMA cache_size = 5;
+ WITH r(x,y) AS (
+ SELECT 1, randomblob(100)
+ UNION ALL
+ SELECT x+1, randomblob(100) FROM r
+ LIMIT 1000000
+ )
+ SELECT count(x), length(y) FROM r GROUP BY (x%5)
+ } {
+ 200000 100 200000 100 200000 100 200000 100 200000 100
+ }
+ }
+}
+
+finish_test
diff --git a/test/sort3.test b/test/sort3.test
new file mode 100644
index 0000000..088ae16
--- /dev/null
+++ b/test/sort3.test
@@ -0,0 +1,113 @@
+# 2014 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 SQLite library.
+#
+# The tests in this file verify that sorting works when the library is
+# configured to use mmap(), but the temporary files generated by the
+# sorter are too large to be completely mapped.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix sort3
+
+#-------------------------------------------------------------------------
+# Sort some large ( > 4KiB) records.
+#
+proc cksum {x} {
+ set i1 1
+ set i2 2
+ binary scan $x c* L
+ foreach {a b} $L {
+ set i1 [expr (($i2<<3) + $a) & 0x7FFFFFFF]
+ set i2 [expr (($i1<<3) + $b) & 0x7FFFFFFF]
+ }
+ list $i1 $i2
+}
+db func cksum cksum
+
+do_execsql_test 1.0 {
+ PRAGMA cache_size = 5;
+ CREATE TABLE t11(a, b);
+ INSERT INTO t11 VALUES(randomblob(5000), NULL);
+ INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --2
+ INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --3
+ INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --4
+ INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --5
+ INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --6
+ INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --7
+ INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --8
+ INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --9
+ UPDATE t11 SET b = cksum(a);
+}
+
+foreach {tn mmap_limit} {
+ 1 0
+ 2 1000000
+} {
+ do_test 1.$tn {
+ sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit
+ set prev ""
+ db eval { SELECT * FROM t11 ORDER BY b } {
+ if {$b != [cksum $a]} {error "checksum failed"}
+ if {[string compare $b $prev] < 0} {error "sort failed"}
+ set prev $b
+ }
+ set {} {}
+ } {}
+}
+
+
+# Sort roughly 20MB of data. Once with a mmap limit of 5MB and once without.
+#
+foreach {itest limit} {
+ 1 5000000
+ 2 0x7FFFFFFF
+} {
+ sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $limit
+ do_execsql_test 2.$itest {
+ WITH r(x,y) AS (
+ SELECT 1, randomblob(1000)
+ UNION ALL
+ SELECT x+1, randomblob(1000) FROM r
+ LIMIT 20000
+ )
+ SELECT count(*), sum(length(y)) FROM r GROUP BY (x%5);
+ } {
+ 4000 4000000
+ 4000 4000000
+ 4000 4000000
+ 4000 4000000
+ 4000 4000000
+ }
+}
+
+# Sort more than 2GB of data. At one point this was causing a problem.
+# This test might take one minute or more to run.
+#
+do_execsql_test 3 {
+ PRAGMA cache_size = 20000;
+ WITH r(x,y) AS (
+ SELECT 1, randomblob(1000)
+ UNION ALL
+ SELECT x+1, randomblob(1000) FROM r
+ LIMIT 2200000
+ )
+ SELECT count(*), sum(length(y)) FROM r GROUP BY (x%5);
+} {
+ 440000 440000000
+ 440000 440000000
+ 440000 440000000
+ 440000 440000000
+ 440000 440000000
+}
+
+finish_test
diff --git a/test/sort4.test b/test/sort4.test
new file mode 100644
index 0000000..13d9a59
--- /dev/null
+++ b/test/sort4.test
@@ -0,0 +1,208 @@
+# 2014 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.
+#
+# The tests in this file are brute force tests of the multi-threaded
+# sorter.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix sort4
+db close
+sqlite3_shutdown
+sqlite3_config_pmasz 10
+sqlite3_initialize
+sqlite3 db test.db
+
+
+# Configure the sorter to use 3 background threads.
+#
+# EVIDENCE-OF: R-19249-32353 SQLITE_LIMIT_WORKER_THREADS The maximum
+# number of auxiliary worker threads that a single prepared statement
+# may start.
+#
+do_test sort4-init001 {
+ db eval {PRAGMA threads=5}
+ sqlite3_limit db SQLITE_LIMIT_WORKER_THREADS -1
+} {5}
+do_test sort4-init002 {
+ sqlite3_limit db SQLITE_LIMIT_WORKER_THREADS 3
+ db eval {PRAGMA threads}
+} {3}
+
+
+# Minimum number of seconds to run for. If the value is 0, each test
+# is run exactly once. Otherwise, tests are repeated until the timeout
+# expires.
+set SORT4TIMEOUT 0
+if {[permutation] == "multithread"} { set SORT4TIMEOUT 300 }
+
+#--------------------------------------------------------------------
+# Set up a table "t1" containing $nRow rows. Each row contains also
+# contains blob fields that collectively contain at least $nPayload
+# bytes of content. The table schema is as follows:
+#
+# CREATE TABLE t1(a INTEGER, <extra-columns>, b INTEGER);
+#
+# For each row, the values of columns "a" and "b" are set to the same
+# pseudo-randomly selected integer. The "extra-columns", of which there
+# are at most eight, are named c0, c1, c2 etc. Column c0 contains a 4
+# byte string. Column c1 an 8 byte string. Field c2 16 bytes, and so on.
+#
+# This table is intended to be used for testing queries of the form:
+#
+# SELECT a, <cols>, b FROM t1 ORDER BY a;
+#
+# The test code checks that rows are returned in order, and that the
+# values of "a" and "b" are the same for each row (the idea being that
+# if field "b" at the end of the sorter record has not been corrupted,
+# the rest of the record is probably Ok as well).
+#
+proc populate_table {nRow nPayload} {
+ set nCol 0
+
+ set n 0
+ for {set nCol 0} {$n < $nPayload} {incr nCol} {
+ incr n [expr (4 << $nCol)]
+ }
+
+ set cols [lrange [list xxx c0 c1 c2 c3 c4 c5 c6 c7] 1 $nCol]
+ set data [lrange [list xxx \
+ randomblob(4) randomblob(8) randomblob(16) randomblob(32) \
+ randomblob(64) randomblob(128) randomblob(256) randomblob(512) \
+ ] 1 $nCol]
+
+ execsql { DROP TABLE IF EXISTS t1 }
+
+ db transaction {
+ execsql "CREATE TABLE t1(a, [join $cols ,], b);"
+ set insert "INSERT INTO t1 VALUES(:k, [join $data ,], :k)"
+ for {set i 0} {$i < $nRow} {incr i} {
+ set k [expr int(rand()*1000000000)]
+ execsql $insert
+ }
+ }
+}
+
+# Helper for [do_sorter_test]
+#
+proc sorter_test {nRow nRead nPayload} {
+ set res [list]
+
+ set nLoad [expr ($nRow > $nRead) ? $nRead : $nRow]
+
+ set nPayload [expr (($nPayload+3)/4) * 4]
+ set cols [list]
+ foreach {mask col} {
+ 0x04 c0 0x08 c1 0x10 c2 0x20 c3
+ 0x40 c4 0x80 c5 0x100 c6 0x200 c7
+ } {
+ if {$nPayload & $mask} { lappend cols $col }
+ }
+
+ # Create two SELECT statements. Statement $sql1 uses the sorter to sort
+ # $nRow records of a bit over $nPayload bytes each read from the "t1"
+ # table created by [populate_table] proc above. Rows are sorted in order
+ # of the integer field in each "t1" record.
+ #
+ # The second SQL statement sorts the same set of rows as the first, but
+ # uses a LIMIT clause, causing SQLite to use a temp table instead of the
+ # sorter for sorting.
+ #
+ set sql1 "SELECT a, [join $cols ,], b FROM t1 WHERE rowid<=$nRow ORDER BY a"
+ set sql2 "SELECT a FROM t1 WHERE rowid<=$nRow ORDER BY a LIMIT $nRead"
+
+ # Pass the two SQL statements to a helper command written in C. This
+ # command steps statement $sql1 $nRead times and compares the integer
+ # values in the rows returned with the results of executing $sql2. If
+ # the comparison fails (indicating some bug in the sorter), a Tcl
+ # exception is thrown.
+ #
+ sorter_test_sort4_helper db $sql1 $nRead $sql2
+ set {} {}
+}
+
+# Usage:
+#
+# do_sorter_test <testname> <args>...
+#
+# where <args> are any of the following switches:
+#
+# -rows N (number of rows to have sorter sort)
+# -read N (number of rows to read out of sorter)
+# -payload N (bytes of payload to read with each row)
+# -cachesize N (Value for "PRAGMA cache_size = ?")
+# -repeats N (number of times to repeat test)
+# -fakeheap BOOL (true to use separate allocations for in-memory records)
+#
+proc do_sorter_test {tn args} {
+ set a(-rows) 1000
+ set a(-repeats) 1
+ set a(-read) 100
+ set a(-payload) 100
+ set a(-cachesize) 100
+ set a(-fakeheap) 0
+
+ foreach {s val} $args {
+ if {[info exists a($s)]==0} {
+ unset a(-cachesize)
+ set optlist "[join [array names a] ,] or -cachesize"
+ error "Unknown option $s, expected $optlist"
+ }
+ set a($s) $val
+ }
+ if {[permutation] == "memsys3" || [permutation] == "memsys5"} {
+ set a(-fakeheap) 0
+ }
+ if {$a(-fakeheap)} { sorter_test_fakeheap 1 }
+
+
+ db eval "PRAGMA cache_size = $a(-cachesize)"
+ do_test $tn [subst -nocommands {
+ for {set i 0} {[set i] < $a(-repeats)} {incr i} {
+ sorter_test $a(-rows) $a(-read) $a(-payload)
+ }
+ }] {}
+
+ if {$a(-fakeheap)} { sorter_test_fakeheap 0 }
+}
+
+proc clock_seconds {} {
+ db one {SELECT strftime('%s')}
+}
+
+#-------------------------------------------------------------------------
+# Begin tests here.
+
+# Create a test database.
+do_test 1 {
+ execsql "PRAGMA page_size = 4096"
+ populate_table 100000 500
+} {}
+
+set iTimeLimit [expr [clock_seconds] + $SORT4TIMEOUT]
+
+for {set t 2} {1} {incr tn} {
+ do_sorter_test $t.2 -repeats 10 -rows 1000 -read 100
+ do_sorter_test $t.3 -repeats 10 -rows 100000 -read 1000
+ do_sorter_test $t.4 -repeats 10 -rows 100000 -read 1000 -payload 500
+ do_sorter_test $t.5 -repeats 10 -rows 100000 -read 100000 -payload 8
+ do_sorter_test $t.6 -repeats 10 -rows 100000 -read 10 -payload 8
+ do_sorter_test $t.7 -repeats 10 -rows 10000 -read 10000 -payload 8 -fakeheap 1
+ do_sorter_test $t.8 -repeats 10 -rows 100000 -read 10000 -cachesize 250
+
+ set iNow [clock_seconds]
+ if {$iNow>=$iTimeLimit} break
+ do_test "$testprefix-([expr $iTimeLimit-$iNow] seconds remain)" {} {}
+}
+
+finish_test
diff --git a/test/sort5.test b/test/sort5.test
new file mode 100644
index 0000000..80dce01
--- /dev/null
+++ b/test/sort5.test
@@ -0,0 +1,122 @@
+# 2014 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix sort5
+
+
+#-------------------------------------------------------------------------
+# Verify that sorting works with a version 1 sqlite3_io_methods structure.
+#
+testvfs tvfs -iversion 1 -default true
+reset_db
+do_execsql_test 1.0 {
+ PRAGMA mmap_size = 10000000;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+} {0}
+
+do_test 1.1 {
+ execsql BEGIN
+ for {set i 0} {$i < 2000} {incr i} {
+ execsql { INSERT INTO t1 VALUES($i, randomblob(2000)) }
+ }
+ execsql COMMIT
+} {}
+
+do_execsql_test 1.2 {
+ CREATE INDEX i1 ON t1(b);
+}
+
+db close
+tvfs delete
+
+#-------------------------------------------------------------------------
+# Test that the PMA size is determined correctly. The PMA size should be
+# roughly the same amount of memory allocated to the main pager cache, or
+# 250 pages if this is larger.
+#
+testvfs tvfs
+tvfs script tv_callback
+tvfs filter {xOpen xWrite}
+
+proc tv_callback {method args} {
+ global iTemp
+ global F
+ switch $method {
+ xOpen {
+ if {[lindex $args 0]==""} { return "temp[incr iTemp]" }
+ return "SQLITE_OK"
+ }
+
+ xWrite {
+ foreach {filename id off amt} $args {}
+ if {[info exists F($id)]==0 || $F($id)<($off + $amt)} {
+ set F($id) [expr $off+$amt]
+ }
+ }
+ }
+}
+
+catch { db close }
+forcedelete test.db
+sqlite3 db test.db -vfs tvfs
+execsql { CREATE TABLE t1(x) }
+execsql { PRAGMA temp_store = 1 }
+
+# Each iteration of the following loop attempts to sort 10001 records
+# each a bit over 100 bytes in size. In total a little more than 1MiB
+# of data.
+#
+foreach {tn pgsz cachesz bTemp} {
+ 1 4096 1000 0
+ 2 1024 1000 1
+
+ 3 4096 -1000 1
+ 4 1024 -1000 1
+
+ 5 4096 -9000 0
+ 6 1024 -9000 0
+} {
+ if {$::TEMP_STORE>2} {
+ set bTemp 0
+ }
+ do_execsql_test 2.$tn.0 "
+ PRAGMA page_size = $pgsz;
+ VACUUM;
+ PRAGMA cache_size = $cachesz;
+ "
+
+ if {[db one {PRAGMA page_size}]!=$pgsz} {
+ # SEE is not able to change page sizes and that messes up the
+ # results that follow.
+ continue
+ }
+
+ do_test 2.$tn.1 {
+ set ::iTemp 0
+ catch { array unset F }
+ execsql {
+ WITH x(i, j) AS (
+ SELECT 1, randomblob(100)
+ UNION ALL
+ SELECT i+1, randomblob(100) FROM x WHERE i<10000
+ )
+ SELECT * FROM x ORDER BY j;
+ }
+ expr {[array names F]!=""}
+ } $bTemp
+}
+
+finish_test
diff --git a/test/sorterref.test b/test/sorterref.test
new file mode 100644
index 0000000..adf1cf5
--- /dev/null
+++ b/test/sorterref.test
@@ -0,0 +1,56 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix sorterref
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t1 VALUES(4, 5, 6);
+ ALTER TABLE t1 ADD COLUMN d DEFAULT 'string';
+ INSERT INTO t1 VALUES(7, 8, 9, 'text');
+}
+
+do_execsql_test 1.1 {
+ SELECT * FROM t1 ORDER BY b;
+} {
+ 1 2 3 string 4 5 6 string 7 8 9 text
+}
+
+do_execsql_test 2.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d, PRIMARY KEY(c)) WITHOUT ROWID;
+
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(2, 3);
+ INSERT INTO t1 VALUES(3, 4);
+
+ INSERT INTO t2 VALUES(1, 'one');
+ INSERT INTO t2 VALUES(3, 'three');
+}
+
+do_execsql_test 2.1 {
+ SELECT * FROM t1 LEFT JOIN t2 ON (a=c) ORDER BY b;
+} {1 2 1 one 2 3 {} {} 3 4 3 three}
+
+
+
+finish_test
diff --git a/test/sortfault.test b/test/sortfault.test
new file mode 100644
index 0000000..f9fe2be
--- /dev/null
+++ b/test/sortfault.test
@@ -0,0 +1,171 @@
+# 2014 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 SQLite library.
+#
+# Specifically, it tests the effects of fault injection on the sorter
+# module (code in vdbesort.c).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix sortfault
+db close
+sqlite3_shutdown
+sqlite3_config_pmasz 10
+sqlite3_initialize
+sqlite3 db test.db
+
+
+do_execsql_test 1.0 {
+ PRAGMA cache_size = 5;
+}
+
+foreach {tn mmap_limit nWorker tmpstore threadsmode fakeheap lookaside} {
+ 1 0 0 file multithread false false
+ 2 100000 0 file multithread false false
+ 3 100000 1 file multithread false false
+ 4 2000000 0 file singlethread false true
+} {
+ if {$sqlite_options(threadsafe)} { set threadsmode singlethread }
+
+ db eval "PRAGMA threads=$nWorker"
+ sqlite3_config $threadsmode
+ if { $lookaside } {
+ sqlite3_config_lookaside 100 500
+ } else {
+ sqlite3_config_lookaside 0 0
+ }
+ sqlite3_initialize
+ sorter_test_fakeheap $fakeheap
+
+ set str [string repeat a 1000]
+ puts $threadsmode
+
+ do_faultsim_test 1.$tn -prep {
+ sqlite3 db test.db
+ sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit
+ execsql { PRAGMA cache_size = 5 }
+ } -body {
+ execsql {
+ WITH r(x,y) AS (
+ SELECT 1, $::str
+ UNION ALL
+ SELECT x+1, $::str FROM r
+ LIMIT 200
+ )
+ SELECT count(x), length(y) FROM r GROUP BY (x%5)
+ }
+ } -test {
+ faultsim_test_result {0 {40 1000 40 1000 40 1000 40 1000 40 1000}}
+ }
+
+ do_faultsim_test 2.$tn -faults oom* -prep {
+ sqlite3 db test.db
+ sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit
+ add_test_utf16bin_collate db
+ execsql { PRAGMA cache_size = 5 }
+ } -body {
+ execsql {
+ WITH r(x,y) AS (
+ SELECT 100, $::str
+ UNION ALL
+ SELECT x-1, $::str FROM r
+ LIMIT 100
+ )
+ SELECT count(x), length(y) FROM r GROUP BY y COLLATE utf16bin, (x%5)
+ }
+ } -test {
+ faultsim_test_result {0 {20 1000 20 1000 20 1000 20 1000 20 1000}}
+ }
+
+ if {$mmap_limit > 1000000} {
+ set str2 [string repeat $str 10]
+
+ sqlite3_memdebug_vfs_oom_test 0
+ sqlite3 db test.db
+ sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit
+ execsql { PRAGMA cache_size = 5 }
+
+ do_faultsim_test 3.$tn -faults oom-trans* -body {
+ execsql {
+ WITH r(x,y) AS (
+ SELECT 300, $::str2
+ UNION ALL
+ SELECT x-1, $::str2 FROM r
+ LIMIT 300
+ )
+ SELECT count(x), length(y) FROM r GROUP BY y, (x%5)
+ }
+ } -test {
+ faultsim_test_result {0 {60 10000 60 10000 60 10000 60 10000 60 10000}}
+ }
+
+ sqlite3_memdebug_vfs_oom_test 1
+ }
+}
+
+catch { db close }
+sqlite3_shutdown
+set t(0) singlethread
+set t(1) multithread
+set t(2) serialized
+sqlite3_config $t($sqlite_options(threadsafe))
+sqlite3_config_lookaside 100 500
+sqlite3_initialize
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+}
+do_test 4.1 {
+ for {set i 0} {$i < 256} {incr i} {
+ execsql {
+ INSERT INTO t1 SELECT
+ ((a<<3) + b) & 2147483647,
+ ((b<<3) + c) & 2147483647,
+ ((c<<3) + a) & 2147483647
+ FROM t1 ORDER BY rowid DESC LIMIT 1;
+ }
+ }
+} {}
+
+faultsim_save_and_close
+
+do_faultsim_test 4.2 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { CREATE UNIQUE INDEX i1 ON t1(a,b,c) }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+set a [string repeat a 500]
+set b [string repeat b 500]
+set c [string repeat c 500]
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES($a, $b, $c);
+ INSERT INTO t1 VALUES($c, $b, $a);
+}
+
+do_faultsim_test 5.1 -faults oom* -body {
+ execsql { SELECT * FROM t1 ORDER BY a }
+} -test {
+ faultsim_test_result [list 0 [list $::a $::b $::c $::c $::b $::a]]
+}
+
+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..6bf7b10
--- /dev/null
+++ b/test/speed1p.test
@@ -0,0 +1,347 @@
+# 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
+
+sqlite3_memdebug_vfs_oom_test 0
+
+# 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..4aa9094
--- /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 speed3_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
+speed3_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
+speed3_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
+speed3_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..78ff913
--- /dev/null
+++ b/test/speed4p.test
@@ -0,0 +1,291 @@
+# 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} {
+ 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/speedtest1.c b/test/speedtest1.c
new file mode 100644
index 0000000..12c8d69
--- /dev/null
+++ b/test/speedtest1.c
@@ -0,0 +1,2658 @@
+/*
+** A program for performance testing.
+**
+** The available command-line options are described below:
+*/
+static const char zHelp[] =
+ "Usage: %s [--options] DATABASE\n"
+ "Options:\n"
+ " --autovacuum Enable AUTOVACUUM mode\n"
+ " --big-transactions Add BEGIN/END around all large tests\n"
+ " --cachesize N Set PRAGMA cache_size=N. Note: N is pages, not bytes\n"
+ " --checkpoint Run PRAGMA wal_checkpoint after each test case\n"
+ " --exclusive Enable locking_mode=EXCLUSIVE\n"
+ " --explain Like --sqlonly but with added EXPLAIN keywords\n"
+ " --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n"
+ " --incrvacuum Enable incremenatal vacuum mode\n"
+ " --journal M Set the journal_mode to M\n"
+ " --key KEY Set the encryption key to KEY\n"
+ " --lookaside N SZ Configure lookaside for N slots of SZ bytes each\n"
+ " --memdb Use an in-memory database\n"
+ " --mmap SZ MMAP the first SZ bytes of the database file\n"
+ " --multithread Set multithreaded mode\n"
+ " --nomemstat Disable memory statistics\n"
+ " --nomutex Open db with SQLITE_OPEN_NOMUTEX\n"
+ " --nosync Set PRAGMA synchronous=OFF\n"
+ " --notnull Add NOT NULL constraints to table columns\n"
+ " --output FILE Store SQL output in FILE\n"
+ " --pagesize N Set the page size to N\n"
+ " --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n"
+ " --primarykey Use PRIMARY KEY instead of UNIQUE where appropriate\n"
+ " --repeat N Repeat each SELECT N times (default: 1)\n"
+ " --reprepare Reprepare each statement upon every invocation\n"
+ " --reserve N Reserve N bytes on each database page\n"
+ " --script FILE Write an SQL script for the test into FILE\n"
+ " --serialized Set serialized threading mode\n"
+ " --singlethread Set single-threaded mode - disables all mutexing\n"
+ " --sqlonly No-op. Only show the SQL that would have been run.\n"
+ " --shrink-memory Invoke sqlite3_db_release_memory() frequently.\n"
+ " --size N Relative test size. Default=100\n"
+ " --strict Use STRICT table where appropriate\n"
+ " --stats Show statistics at the end\n"
+ " --temp N N from 0 to 9. 0: no temp table. 9: all temp tables\n"
+ " --testset T Run test-set T (main, cte, rtree, orm, fp, debug)\n"
+ " --trace Turn on SQL tracing\n"
+ " --threads N Use up to N threads for sorting\n"
+ " --utf16be Set text encoding to UTF-16BE\n"
+ " --utf16le Set text encoding to UTF-16LE\n"
+ " --verify Run additional verification steps\n"
+ " --vfs NAME Use the given (preinstalled) VFS\n"
+ " --without-rowid Use WITHOUT ROWID where appropriate\n"
+;
+
+#include "sqlite3.h"
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <ctype.h>
+#ifndef _WIN32
+# include <unistd.h>
+#else
+# include <io.h>
+#endif
+#define ISSPACE(X) isspace((unsigned char)(X))
+#define ISDIGIT(X) isdigit((unsigned char)(X))
+
+#if SQLITE_VERSION_NUMBER<3005000
+# define sqlite3_int64 sqlite_int64
+#endif
+
+typedef sqlite3_uint64 u64;
+
+/*
+** State structure for a Hash hash in progress
+*/
+typedef struct HashContext HashContext;
+struct HashContext {
+ unsigned char isInit; /* True if initialized */
+ unsigned char i, j; /* State variables */
+ unsigned char s[256]; /* State variables */
+ unsigned char r[32]; /* Result */
+};
+
+
+/* All global state is held in this structure */
+static struct Global {
+ sqlite3 *db; /* The open database connection */
+ sqlite3_stmt *pStmt; /* Current SQL statement */
+ sqlite3_int64 iStart; /* Start-time for the current test */
+ sqlite3_int64 iTotal; /* Total time */
+ int bWithoutRowid; /* True for --without-rowid */
+ int bReprepare; /* True to reprepare the SQL on each rerun */
+ int bSqlOnly; /* True to print the SQL once only */
+ int bExplain; /* Print SQL with EXPLAIN prefix */
+ int bVerify; /* Try to verify that results are correct */
+ int bMemShrink; /* Call sqlite3_db_release_memory() often */
+ int eTemp; /* 0: no TEMP. 9: always TEMP. */
+ int szTest; /* Scale factor for test iterations */
+ int nRepeat; /* Repeat selects this many times */
+ int doCheckpoint; /* Run PRAGMA wal_checkpoint after each trans */
+ int nReserve; /* Reserve bytes */
+ int doBigTransactions; /* Enable transactions on tests 410 and 510 */
+ const char *zWR; /* Might be WITHOUT ROWID */
+ const char *zNN; /* Might be NOT NULL */
+ const char *zPK; /* Might be UNIQUE or PRIMARY KEY */
+ unsigned int x, y; /* Pseudo-random number generator state */
+ u64 nResByte; /* Total number of result bytes */
+ int nResult; /* Size of the current result */
+ char zResult[3000]; /* Text of the current result */
+ FILE *pScript; /* Write an SQL script into this file */
+#ifndef SPEEDTEST_OMIT_HASH
+ FILE *hashFile; /* Store all hash results in this file */
+ HashContext hash; /* Hash of all output */
+#endif
+} g;
+
+/* Return " TEMP" or "", as appropriate for creating a table.
+*/
+static const char *isTemp(int N){
+ return g.eTemp>=N ? " TEMP" : "";
+}
+
+/* Print an error message and exit */
+static void fatal_error(const char *zMsg, ...){
+ va_list ap;
+ va_start(ap, zMsg);
+ vfprintf(stderr, zMsg, ap);
+ va_end(ap);
+ exit(1);
+}
+
+#ifndef SPEEDTEST_OMIT_HASH
+/****************************************************************************
+** Hash algorithm used to verify that compilation is not miscompiled
+** in such a was as to generate an incorrect result.
+*/
+
+/*
+** Initialize a new hash. iSize determines the size of the hash
+** in bits and should be one of 224, 256, 384, or 512. Or iSize
+** can be zero to use the default hash size of 256 bits.
+*/
+static void HashInit(void){
+ unsigned int k;
+ g.hash.i = 0;
+ g.hash.j = 0;
+ for(k=0; k<256; k++) g.hash.s[k] = k;
+}
+
+/*
+** Make consecutive calls to the HashUpdate function to add new content
+** to the hash
+*/
+static void HashUpdate(
+ const unsigned char *aData,
+ unsigned int nData
+){
+ unsigned char t;
+ unsigned char i = g.hash.i;
+ unsigned char j = g.hash.j;
+ unsigned int k;
+ if( g.hashFile ) fwrite(aData, 1, nData, g.hashFile);
+ for(k=0; k<nData; k++){
+ j += g.hash.s[i] + aData[k];
+ t = g.hash.s[j];
+ g.hash.s[j] = g.hash.s[i];
+ g.hash.s[i] = t;
+ i++;
+ }
+ g.hash.i = i;
+ g.hash.j = j;
+}
+
+/*
+** After all content has been added, invoke HashFinal() to compute
+** the final hash. The hash result is stored in g.hash.r[].
+*/
+static void HashFinal(void){
+ unsigned int k;
+ unsigned char t, i, j;
+ i = g.hash.i;
+ j = g.hash.j;
+ for(k=0; k<32; k++){
+ i++;
+ t = g.hash.s[i];
+ j += t;
+ g.hash.s[i] = g.hash.s[j];
+ g.hash.s[j] = t;
+ t += g.hash.s[i];
+ g.hash.r[k] = g.hash.s[t];
+ }
+}
+
+/* End of the Hash hashing logic
+*****************************************************************************/
+#endif /* SPEEDTEST_OMIT_HASH */
+
+/*
+** Return the value of a hexadecimal digit. Return -1 if the input
+** is not a hex digit.
+*/
+static int hexDigitValue(char c){
+ if( c>='0' && c<='9' ) return c - '0';
+ if( c>='a' && c<='f' ) return c - 'a' + 10;
+ if( c>='A' && c<='F' ) return c - 'A' + 10;
+ return -1;
+}
+
+/* Provide an alternative to sqlite3_stricmp() in older versions of
+** SQLite */
+#if SQLITE_VERSION_NUMBER<3007011
+# define sqlite3_stricmp strcmp
+#endif
+
+/*
+** Interpret zArg as an integer value, possibly with suffixes.
+*/
+static int integerValue(const char *zArg){
+ sqlite3_int64 v = 0;
+ static const struct { char *zSuffix; int iMult; } aMult[] = {
+ { "KiB", 1024 },
+ { "MiB", 1024*1024 },
+ { "GiB", 1024*1024*1024 },
+ { "KB", 1000 },
+ { "MB", 1000000 },
+ { "GB", 1000000000 },
+ { "K", 1000 },
+ { "M", 1000000 },
+ { "G", 1000000000 },
+ };
+ int i;
+ int isNeg = 0;
+ if( zArg[0]=='-' ){
+ isNeg = 1;
+ zArg++;
+ }else if( zArg[0]=='+' ){
+ zArg++;
+ }
+ if( zArg[0]=='0' && zArg[1]=='x' ){
+ int x;
+ zArg += 2;
+ while( (x = hexDigitValue(zArg[0]))>=0 ){
+ v = (v<<4) + x;
+ zArg++;
+ }
+ }else{
+ while( isdigit(zArg[0]) ){
+ v = v*10 + zArg[0] - '0';
+ zArg++;
+ }
+ }
+ for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
+ if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
+ v *= aMult[i].iMult;
+ break;
+ }
+ }
+ if( v>0x7fffffff ) fatal_error("parameter too large - max 2147483648");
+ return (int)(isNeg? -v : v);
+}
+
+/* Return the current wall-clock time, in milliseconds */
+sqlite3_int64 speedtest1_timestamp(void){
+#if SQLITE_VERSION_NUMBER<3005000
+ return 0;
+#else
+ static sqlite3_vfs *clockVfs = 0;
+ sqlite3_int64 t;
+ if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
+#if SQLITE_VERSION_NUMBER>=3007000
+ if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
+ clockVfs->xCurrentTimeInt64(clockVfs, &t);
+ }else
+#endif
+ {
+ double r;
+ clockVfs->xCurrentTime(clockVfs, &r);
+ t = (sqlite3_int64)(r*86400000.0);
+ }
+ return t;
+#endif
+}
+
+/* Return a pseudo-random unsigned integer */
+unsigned int speedtest1_random(void){
+ g.x = (g.x>>1) ^ ((1+~(g.x&1)) & 0xd0000001);
+ g.y = g.y*1103515245 + 12345;
+ return g.x ^ g.y;
+}
+
+/* Map the value in within the range of 1...limit into another
+** number in a way that is chatic and invertable.
+*/
+unsigned swizzle(unsigned in, unsigned limit){
+ unsigned out = 0;
+ while( limit ){
+ out = (out<<1) | (in&1);
+ in >>= 1;
+ limit >>= 1;
+ }
+ return out;
+}
+
+/* Round up a number so that it is a power of two minus one
+*/
+unsigned roundup_allones(unsigned limit){
+ unsigned m = 1;
+ while( m<limit ) m = (m<<1)+1;
+ return m;
+}
+
+/* The speedtest1_numbername procedure below converts its argment (an integer)
+** into a string which is the English-language name for that number.
+** The returned string should be freed with sqlite3_free().
+**
+** Example:
+**
+** speedtest1_numbername(123) -> "one hundred twenty three"
+*/
+int speedtest1_numbername(unsigned int n, char *zOut, int nOut){
+ static const char *ones[] = { "zero", "one", "two", "three", "four", "five",
+ "six", "seven", "eight", "nine", "ten", "eleven", "twelve",
+ "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
+ "eighteen", "nineteen" };
+ static const char *tens[] = { "", "ten", "twenty", "thirty", "forty",
+ "fifty", "sixty", "seventy", "eighty", "ninety" };
+ int i = 0;
+
+ if( n>=1000000000 ){
+ i += speedtest1_numbername(n/1000000000, zOut+i, nOut-i);
+ sqlite3_snprintf(nOut-i, zOut+i, " billion");
+ i += (int)strlen(zOut+i);
+ n = n % 1000000000;
+ }
+ if( n>=1000000 ){
+ if( i && i<nOut-1 ) zOut[i++] = ' ';
+ i += speedtest1_numbername(n/1000000, zOut+i, nOut-i);
+ sqlite3_snprintf(nOut-i, zOut+i, " million");
+ i += (int)strlen(zOut+i);
+ n = n % 1000000;
+ }
+ if( n>=1000 ){
+ if( i && i<nOut-1 ) zOut[i++] = ' ';
+ i += speedtest1_numbername(n/1000, zOut+i, nOut-i);
+ sqlite3_snprintf(nOut-i, zOut+i, " thousand");
+ i += (int)strlen(zOut+i);
+ n = n % 1000;
+ }
+ if( n>=100 ){
+ if( i && i<nOut-1 ) zOut[i++] = ' ';
+ sqlite3_snprintf(nOut-i, zOut+i, "%s hundred", ones[n/100]);
+ i += (int)strlen(zOut+i);
+ n = n % 100;
+ }
+ if( n>=20 ){
+ if( i && i<nOut-1 ) zOut[i++] = ' ';
+ sqlite3_snprintf(nOut-i, zOut+i, "%s", tens[n/10]);
+ i += (int)strlen(zOut+i);
+ n = n % 10;
+ }
+ if( n>0 ){
+ if( i && i<nOut-1 ) zOut[i++] = ' ';
+ sqlite3_snprintf(nOut-i, zOut+i, "%s", ones[n]);
+ i += (int)strlen(zOut+i);
+ }
+ if( i==0 ){
+ sqlite3_snprintf(nOut-i, zOut+i, "zero");
+ i += (int)strlen(zOut+i);
+ }
+ return i;
+}
+
+
+/* Start a new test case */
+#define NAMEWIDTH 60
+static const char zDots[] =
+ ".......................................................................";
+static int iTestNumber = 0; /* Current test # for begin/end_test(). */
+void speedtest1_begin_test(int iTestNum, const char *zTestName, ...){
+ int n = (int)strlen(zTestName);
+ char *zName;
+ va_list ap;
+ iTestNumber = iTestNum;
+ va_start(ap, zTestName);
+ zName = sqlite3_vmprintf(zTestName, ap);
+ va_end(ap);
+ n = (int)strlen(zName);
+ if( n>NAMEWIDTH ){
+ zName[NAMEWIDTH] = 0;
+ n = NAMEWIDTH;
+ }
+ if( g.pScript ){
+ fprintf(g.pScript,"-- begin test %d %.*s\n", iTestNumber, n, zName)
+ /* maintenance reminder: ^^^ code in ext/wasm expects %d to be
+ ** field #4 (as in: cut -d' ' -f4). */;
+ }
+ if( g.bSqlOnly ){
+ printf("/* %4d - %s%.*s */\n", iTestNum, zName, NAMEWIDTH-n, zDots);
+ }else{
+ printf("%4d - %s%.*s ", iTestNum, zName, NAMEWIDTH-n, zDots);
+ fflush(stdout);
+ }
+ sqlite3_free(zName);
+ g.nResult = 0;
+ g.iStart = speedtest1_timestamp();
+ g.x = 0xad131d0b;
+ g.y = 0x44f9eac8;
+}
+
+/* Forward reference */
+void speedtest1_exec(const char*,...);
+
+/* Complete a test case */
+void speedtest1_end_test(void){
+ sqlite3_int64 iElapseTime = speedtest1_timestamp() - g.iStart;
+ if( g.doCheckpoint ) speedtest1_exec("PRAGMA wal_checkpoint;");
+ assert( iTestNumber > 0 );
+ if( g.pScript ){
+ fprintf(g.pScript,"-- end test %d\n", iTestNumber);
+ }
+ if( !g.bSqlOnly ){
+ g.iTotal += iElapseTime;
+ printf("%4d.%03ds\n", (int)(iElapseTime/1000), (int)(iElapseTime%1000));
+ }
+ if( g.pStmt ){
+ sqlite3_finalize(g.pStmt);
+ g.pStmt = 0;
+ }
+ iTestNumber = 0;
+}
+
+/* Report end of testing */
+void speedtest1_final(void){
+ if( !g.bSqlOnly ){
+ printf(" TOTAL%.*s %4d.%03ds\n", NAMEWIDTH-5, zDots,
+ (int)(g.iTotal/1000), (int)(g.iTotal%1000));
+ }
+ if( g.bVerify ){
+#ifndef SPEEDTEST_OMIT_HASH
+ int i;
+#endif
+ printf("Verification Hash: %llu ", g.nResByte);
+#ifndef SPEEDTEST_OMIT_HASH
+ HashUpdate((const unsigned char*)"\n", 1);
+ HashFinal();
+ for(i=0; i<24; i++){
+ printf("%02x", g.hash.r[i]);
+ }
+ if( g.hashFile && g.hashFile!=stdout ) fclose(g.hashFile);
+#endif
+ printf("\n");
+ }
+}
+
+/* Print an SQL statement to standard output */
+static void printSql(const char *zSql){
+ int n = (int)strlen(zSql);
+ while( n>0 && (zSql[n-1]==';' || ISSPACE(zSql[n-1])) ){ n--; }
+ if( g.bExplain ) printf("EXPLAIN ");
+ printf("%.*s;\n", n, zSql);
+ if( g.bExplain
+#if SQLITE_VERSION_NUMBER>=3007017
+ && ( sqlite3_strglob("CREATE *", zSql)==0
+ || sqlite3_strglob("DROP *", zSql)==0
+ || sqlite3_strglob("ALTER *", zSql)==0
+ )
+#endif
+ ){
+ printf("%.*s;\n", n, zSql);
+ }
+}
+
+/* Shrink memory used, if appropriate and if the SQLite version is capable
+** of doing so.
+*/
+void speedtest1_shrink_memory(void){
+#if SQLITE_VERSION_NUMBER>=3007010
+ if( g.bMemShrink ) sqlite3_db_release_memory(g.db);
+#endif
+}
+
+/* Run SQL */
+void speedtest1_exec(const char *zFormat, ...){
+ va_list ap;
+ char *zSql;
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ if( g.bSqlOnly ){
+ printSql(zSql);
+ }else{
+ char *zErrMsg = 0;
+ int rc;
+ if( g.pScript ){
+ fprintf(g.pScript,"%s;\n",zSql);
+ }
+ rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg);
+ if( zErrMsg ) fatal_error("SQL error: %s\n%s\n", zErrMsg, zSql);
+ if( rc!=SQLITE_OK ) fatal_error("exec error: %s\n", sqlite3_errmsg(g.db));
+ }
+ sqlite3_free(zSql);
+ speedtest1_shrink_memory();
+}
+
+/* Run SQL and return the first column of the first row as a string. The
+** returned string is obtained from sqlite_malloc() and must be freed by
+** the caller.
+*/
+char *speedtest1_once(const char *zFormat, ...){
+ va_list ap;
+ char *zSql;
+ sqlite3_stmt *pStmt;
+ char *zResult = 0;
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ if( g.bSqlOnly ){
+ printSql(zSql);
+ }else{
+ int rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt, 0);
+ if( rc ){
+ fatal_error("SQL error: %s\n", sqlite3_errmsg(g.db));
+ }
+ if( g.pScript ){
+ char *z = sqlite3_expanded_sql(pStmt);
+ fprintf(g.pScript,"%s\n",z);
+ sqlite3_free(z);
+ }
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ const char *z = (const char*)sqlite3_column_text(pStmt, 0);
+ if( z ) zResult = sqlite3_mprintf("%s", z);
+ }
+ sqlite3_finalize(pStmt);
+ }
+ sqlite3_free(zSql);
+ speedtest1_shrink_memory();
+ return zResult;
+}
+
+/* Prepare an SQL statement */
+void speedtest1_prepare(const char *zFormat, ...){
+ va_list ap;
+ char *zSql;
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ if( g.bSqlOnly ){
+ printSql(zSql);
+ }else{
+ int rc;
+ if( g.pStmt ) sqlite3_finalize(g.pStmt);
+ rc = sqlite3_prepare_v2(g.db, zSql, -1, &g.pStmt, 0);
+ if( rc ){
+ fatal_error("SQL error: %s\n", sqlite3_errmsg(g.db));
+ }
+ }
+ sqlite3_free(zSql);
+}
+
+/* Run an SQL statement previously prepared */
+void speedtest1_run(void){
+ int i, n, len;
+ if( g.bSqlOnly ) return;
+ assert( g.pStmt );
+ g.nResult = 0;
+ if( g.pScript ){
+ char *z = sqlite3_expanded_sql(g.pStmt);
+ fprintf(g.pScript,"%s\n",z);
+ sqlite3_free(z);
+ }
+ while( sqlite3_step(g.pStmt)==SQLITE_ROW ){
+ n = sqlite3_column_count(g.pStmt);
+ for(i=0; i<n; i++){
+ const char *z = (const char*)sqlite3_column_text(g.pStmt, i);
+ if( z==0 ) z = "nil";
+ len = (int)strlen(z);
+#ifndef SPEEDTEST_OMIT_HASH
+ if( g.bVerify ){
+ int eType = sqlite3_column_type(g.pStmt, i);
+ unsigned char zPrefix[2];
+ zPrefix[0] = '\n';
+ zPrefix[1] = "-IFTBN"[eType];
+ if( g.nResByte ){
+ HashUpdate(zPrefix, 2);
+ }else{
+ HashUpdate(zPrefix+1, 1);
+ }
+ if( eType==SQLITE_FLOAT ){
+ /* Omit the value of floating-point results from the verification
+ ** hash. The only thing we record is the fact that the result was
+ ** a floating-point value. */
+ g.nResByte += 2;
+ }else if( eType==SQLITE_BLOB ){
+ int nBlob = sqlite3_column_bytes(g.pStmt, i);
+ int iBlob;
+ unsigned char zChar[2];
+ const unsigned char *aBlob = sqlite3_column_blob(g.pStmt, i);
+ for(iBlob=0; iBlob<nBlob; iBlob++){
+ zChar[0] = "0123456789abcdef"[aBlob[iBlob]>>4];
+ zChar[1] = "0123456789abcdef"[aBlob[iBlob]&15];
+ HashUpdate(zChar,2);
+ }
+ g.nResByte += nBlob*2 + 2;
+ }else{
+ HashUpdate((unsigned char*)z, len);
+ g.nResByte += len + 2;
+ }
+ }
+#endif
+ if( g.nResult+len<sizeof(g.zResult)-2 ){
+ if( g.nResult>0 ) g.zResult[g.nResult++] = ' ';
+ memcpy(g.zResult + g.nResult, z, len+1);
+ g.nResult += len;
+ }
+ }
+ }
+#if SQLITE_VERSION_NUMBER>=3006001
+ if( g.bReprepare ){
+ sqlite3_stmt *pNew;
+ sqlite3_prepare_v2(g.db, sqlite3_sql(g.pStmt), -1, &pNew, 0);
+ sqlite3_finalize(g.pStmt);
+ g.pStmt = pNew;
+ }else
+#endif
+ {
+ sqlite3_reset(g.pStmt);
+ }
+ speedtest1_shrink_memory();
+}
+
+#ifndef SQLITE_OMIT_DEPRECATED
+/* The sqlite3_trace() callback function */
+static void traceCallback(void *NotUsed, const char *zSql){
+ int n = (int)strlen(zSql);
+ while( n>0 && (zSql[n-1]==';' || ISSPACE(zSql[n-1])) ) n--;
+ fprintf(stderr,"%.*s;\n", n, zSql);
+}
+#endif /* SQLITE_OMIT_DEPRECATED */
+
+/* Substitute random() function that gives the same random
+** sequence on each run, for repeatability. */
+static void randomFunc(
+ sqlite3_context *context,
+ int NotUsed,
+ sqlite3_value **NotUsed2
+){
+ sqlite3_result_int64(context, (sqlite3_int64)speedtest1_random());
+}
+
+/* Estimate the square root of an integer */
+static int est_square_root(int x){
+ int y0 = x/2;
+ int y1;
+ int n;
+ for(n=0; y0>0 && n<10; n++){
+ y1 = (y0 + x/y0)/2;
+ if( y1==y0 ) break;
+ y0 = y1;
+ }
+ return y0;
+}
+
+
+#if SQLITE_VERSION_NUMBER<3005004
+/*
+** An implementation of group_concat(). Used only when testing older
+** versions of SQLite that lack the built-in group_concat().
+*/
+struct groupConcat {
+ char *z;
+ int nAlloc;
+ int nUsed;
+};
+static void groupAppend(struct groupConcat *p, const char *z, int n){
+ if( p->nUsed+n >= p->nAlloc ){
+ int n2 = (p->nAlloc+n+1)*2;
+ char *z2 = sqlite3_realloc(p->z, n2);
+ if( z2==0 ) return;
+ p->z = z2;
+ p->nAlloc = n2;
+ }
+ memcpy(p->z+p->nUsed, z, n);
+ p->nUsed += n;
+}
+static void groupStep(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ const char *zVal;
+ struct groupConcat *p;
+ const char *zSep;
+ int nVal, nSep;
+ assert( argc==1 || argc==2 );
+ if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
+ p= (struct groupConcat*)sqlite3_aggregate_context(context, sizeof(*p));
+
+ if( p ){
+ int firstTerm = p->nUsed==0;
+ if( !firstTerm ){
+ if( argc==2 ){
+ zSep = (char*)sqlite3_value_text(argv[1]);
+ nSep = sqlite3_value_bytes(argv[1]);
+ }else{
+ zSep = ",";
+ nSep = 1;
+ }
+ if( nSep ) groupAppend(p, zSep, nSep);
+ }
+ zVal = (char*)sqlite3_value_text(argv[0]);
+ nVal = sqlite3_value_bytes(argv[0]);
+ if( zVal ) groupAppend(p, zVal, nVal);
+ }
+}
+static void groupFinal(sqlite3_context *context){
+ struct groupConcat *p;
+ p = sqlite3_aggregate_context(context, 0);
+ if( p && p->z ){
+ p->z[p->nUsed] = 0;
+ sqlite3_result_text(context, p->z, p->nUsed, sqlite3_free);
+ }
+}
+#endif
+
+/*
+** The main and default testset
+*/
+void testset_main(void){
+ int i; /* Loop counter */
+ int n; /* iteration count */
+ int sz; /* Size of the tables */
+ int maxb; /* Maximum swizzled value */
+ unsigned x1 = 0, x2 = 0; /* Parameters */
+ int len = 0; /* Length of the zNum[] string */
+ char zNum[2000]; /* A number name */
+
+ sz = n = g.szTest*500;
+ zNum[0] = 0;
+ maxb = roundup_allones(sz);
+ speedtest1_begin_test(100, "%d INSERTs into table with no index", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_exec("CREATE%s TABLE z1(a INTEGER %s, b INTEGER %s, c TEXT %s);",
+ isTemp(9), g.zNN, g.zNN, g.zNN);
+ speedtest1_prepare("INSERT INTO z1 VALUES(?1,?2,?3); -- %d times", n);
+ for(i=1; i<=n; i++){
+ x1 = swizzle(i,maxb);
+ speedtest1_numbername(x1, zNum, sizeof(zNum));
+ sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1);
+ sqlite3_bind_int(g.pStmt, 2, i);
+ sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ n = sz;
+ speedtest1_begin_test(110, "%d ordered INSERTS with one index/PK", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_exec(
+ "CREATE%s TABLE z2(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s",
+ isTemp(5), g.zNN, g.zPK, g.zNN, g.zNN, g.zWR);
+ speedtest1_prepare("INSERT INTO z2 VALUES(?1,?2,?3); -- %d times", n);
+ for(i=1; i<=n; i++){
+ x1 = swizzle(i,maxb);
+ speedtest1_numbername(x1, zNum, sizeof(zNum));
+ sqlite3_bind_int(g.pStmt, 1, i);
+ sqlite3_bind_int64(g.pStmt, 2, (sqlite3_int64)x1);
+ sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ n = sz;
+ speedtest1_begin_test(120, "%d unordered INSERTS with one index/PK", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_exec(
+ "CREATE%s TABLE t3(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s",
+ isTemp(3), g.zNN, g.zPK, g.zNN, g.zNN, g.zWR);
+ speedtest1_prepare("INSERT INTO t3 VALUES(?1,?2,?3); -- %d times", n);
+ for(i=1; i<=n; i++){
+ x1 = swizzle(i,maxb);
+ speedtest1_numbername(x1, zNum, sizeof(zNum));
+ sqlite3_bind_int(g.pStmt, 2, i);
+ sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1);
+ sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+#if SQLITE_VERSION_NUMBER<3005004
+ sqlite3_create_function(g.db, "group_concat", 1, SQLITE_UTF8, 0,
+ 0, groupStep, groupFinal);
+#endif
+
+ n = 25;
+ speedtest1_begin_test(130, "%d SELECTS, numeric BETWEEN, unindexed", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM z1\n"
+ " WHERE b BETWEEN ?1 AND ?2; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ if( (i-1)%g.nRepeat==0 ){
+ x1 = speedtest1_random()%maxb;
+ x2 = speedtest1_random()%10 + sz/5000 + x1;
+ }
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ sqlite3_bind_int(g.pStmt, 2, x2);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ n = 10;
+ speedtest1_begin_test(140, "%d SELECTS, LIKE, unindexed", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM z1\n"
+ " WHERE c LIKE ?1; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ if( (i-1)%g.nRepeat==0 ){
+ x1 = speedtest1_random()%maxb;
+ zNum[0] = '%';
+ len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2);
+ zNum[len] = '%';
+ zNum[len+1] = 0;
+ }
+ sqlite3_bind_text(g.pStmt, 1, zNum, len+1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ n = 10;
+ speedtest1_begin_test(142, "%d SELECTS w/ORDER BY, unindexed", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "SELECT a, b, c FROM z1 WHERE c LIKE ?1\n"
+ " ORDER BY a; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ if( (i-1)%g.nRepeat==0 ){
+ x1 = speedtest1_random()%maxb;
+ zNum[0] = '%';
+ len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2);
+ zNum[len] = '%';
+ zNum[len+1] = 0;
+ }
+ sqlite3_bind_text(g.pStmt, 1, zNum, len+1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+ n = 10; /* g.szTest/5; */
+ speedtest1_begin_test(145, "%d SELECTS w/ORDER BY and LIMIT, unindexed", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "SELECT a, b, c FROM z1 WHERE c LIKE ?1\n"
+ " ORDER BY a LIMIT 10; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ if( (i-1)%g.nRepeat==0 ){
+ x1 = speedtest1_random()%maxb;
+ zNum[0] = '%';
+ len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2);
+ zNum[len] = '%';
+ zNum[len+1] = 0;
+ }
+ sqlite3_bind_text(g.pStmt, 1, zNum, len+1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ speedtest1_begin_test(150, "CREATE INDEX five times");
+ speedtest1_exec("BEGIN;");
+ speedtest1_exec("CREATE UNIQUE INDEX t1b ON z1(b);");
+ speedtest1_exec("CREATE INDEX t1c ON z1(c);");
+ speedtest1_exec("CREATE UNIQUE INDEX t2b ON z2(b);");
+ speedtest1_exec("CREATE INDEX t2c ON z2(c DESC);");
+ speedtest1_exec("CREATE INDEX t3bc ON t3(b,c);");
+ speedtest1_exec("COMMIT;");
+ speedtest1_end_test();
+
+
+ n = sz/5;
+ speedtest1_begin_test(160, "%d SELECTS, numeric BETWEEN, indexed", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM z1\n"
+ " WHERE b BETWEEN ?1 AND ?2; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ if( (i-1)%g.nRepeat==0 ){
+ x1 = speedtest1_random()%maxb;
+ x2 = speedtest1_random()%10 + sz/5000 + x1;
+ }
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ sqlite3_bind_int(g.pStmt, 2, x2);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ n = sz/5;
+ speedtest1_begin_test(161, "%d SELECTS, numeric BETWEEN, PK", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM z2\n"
+ " WHERE a BETWEEN ?1 AND ?2; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ if( (i-1)%g.nRepeat==0 ){
+ x1 = speedtest1_random()%maxb;
+ x2 = speedtest1_random()%10 + sz/5000 + x1;
+ }
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ sqlite3_bind_int(g.pStmt, 2, x2);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ n = sz/5;
+ speedtest1_begin_test(170, "%d SELECTS, text BETWEEN, indexed", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM z1\n"
+ " WHERE c BETWEEN ?1 AND (?1||'~'); -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ if( (i-1)%g.nRepeat==0 ){
+ x1 = swizzle(i, maxb);
+ len = speedtest1_numbername(x1, zNum, sizeof(zNum)-1);
+ }
+ sqlite3_bind_text(g.pStmt, 1, zNum, len, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+ n = sz;
+ speedtest1_begin_test(180, "%d INSERTS with three indexes", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_exec(
+ "CREATE%s TABLE t4(\n"
+ " a INTEGER %s %s,\n"
+ " b INTEGER %s,\n"
+ " c TEXT %s\n"
+ ") %s",
+ isTemp(1), g.zNN, g.zPK, g.zNN, g.zNN, g.zWR);
+ speedtest1_exec("CREATE INDEX t4b ON t4(b)");
+ speedtest1_exec("CREATE INDEX t4c ON t4(c)");
+ speedtest1_exec("INSERT INTO t4 SELECT * FROM z1");
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+ n = sz;
+ speedtest1_begin_test(190, "DELETE and REFILL one table", n);
+ speedtest1_exec("DELETE FROM z2;");
+ speedtest1_exec("INSERT INTO z2 SELECT * FROM z1;");
+ speedtest1_end_test();
+
+
+ speedtest1_begin_test(200, "VACUUM");
+ speedtest1_exec("VACUUM");
+ speedtest1_end_test();
+
+
+ speedtest1_begin_test(210, "ALTER TABLE ADD COLUMN, and query");
+ speedtest1_exec("ALTER TABLE z2 ADD COLUMN d INT DEFAULT 123");
+ speedtest1_exec("SELECT sum(d) FROM z2");
+ speedtest1_end_test();
+
+
+ n = sz/5;
+ speedtest1_begin_test(230, "%d UPDATES, numeric BETWEEN, indexed", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "UPDATE z2 SET d=b*2 WHERE b BETWEEN ?1 AND ?2; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ x1 = speedtest1_random()%maxb;
+ x2 = speedtest1_random()%10 + sz/5000 + x1;
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ sqlite3_bind_int(g.pStmt, 2, x2);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ n = sz;
+ speedtest1_begin_test(240, "%d UPDATES of individual rows", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "UPDATE z2 SET d=b*3 WHERE a=?1; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ x1 = speedtest1_random()%sz + 1;
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+ speedtest1_begin_test(250, "One big UPDATE of the whole %d-row table", sz);
+ speedtest1_exec("UPDATE z2 SET d=b*4");
+ speedtest1_end_test();
+
+
+ speedtest1_begin_test(260, "Query added column after filling");
+ speedtest1_exec("SELECT sum(d) FROM z2");
+ speedtest1_end_test();
+
+
+
+ n = sz/5;
+ speedtest1_begin_test(270, "%d DELETEs, numeric BETWEEN, indexed", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "DELETE FROM z2 WHERE b BETWEEN ?1 AND ?2; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ x1 = speedtest1_random()%maxb + 1;
+ x2 = speedtest1_random()%10 + sz/5000 + x1;
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ sqlite3_bind_int(g.pStmt, 2, x2);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ n = sz;
+ speedtest1_begin_test(280, "%d DELETEs of individual rows", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "DELETE FROM t3 WHERE a=?1; -- %d times", n
+ );
+ for(i=1; i<=n; i++){
+ x1 = speedtest1_random()%sz + 1;
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+
+ speedtest1_begin_test(290, "Refill two %d-row tables using REPLACE", sz);
+ speedtest1_exec("REPLACE INTO z2(a,b,c) SELECT a,b,c FROM z1");
+ speedtest1_exec("REPLACE INTO t3(a,b,c) SELECT a,b,c FROM z1");
+ speedtest1_end_test();
+
+ speedtest1_begin_test(300, "Refill a %d-row table using (b&1)==(a&1)", sz);
+ speedtest1_exec("DELETE FROM z2;");
+ speedtest1_exec("INSERT INTO z2(a,b,c)\n"
+ " SELECT a,b,c FROM z1 WHERE (b&1)==(a&1);");
+ speedtest1_exec("INSERT INTO z2(a,b,c)\n"
+ " SELECT a,b,c FROM z1 WHERE (b&1)<>(a&1);");
+ speedtest1_end_test();
+
+
+ n = sz/5;
+ speedtest1_begin_test(310, "%d four-ways joins", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare(
+ "SELECT z1.c FROM z1, z2, t3, t4\n"
+ " WHERE t4.a BETWEEN ?1 AND ?2\n"
+ " AND t3.a=t4.b\n"
+ " AND z2.a=t3.b\n"
+ " AND z1.c=z2.c;"
+ );
+ for(i=1; i<=n; i++){
+ x1 = speedtest1_random()%sz + 1;
+ x2 = speedtest1_random()%10 + x1 + 4;
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ sqlite3_bind_int(g.pStmt, 2, x2);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+ speedtest1_begin_test(320, "subquery in result set", n);
+ speedtest1_prepare(
+ "SELECT sum(a), max(c),\n"
+ " avg((SELECT a FROM z2 WHERE 5+z2.b=z1.b) AND rowid<?1), max(c)\n"
+ " FROM z1 WHERE rowid<?1;"
+ );
+ sqlite3_bind_int(g.pStmt, 1, est_square_root(g.szTest)*50);
+ speedtest1_run();
+ speedtest1_end_test();
+
+ sz = n = g.szTest*700;
+ zNum[0] = 0;
+ maxb = roundup_allones(sz/3);
+ speedtest1_begin_test(400, "%d REPLACE ops on an IPK", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_exec("CREATE%s TABLE t5(a INTEGER PRIMARY KEY, b %s);",
+ isTemp(9), g.zNN);
+ speedtest1_prepare("REPLACE INTO t5 VALUES(?1,?2); -- %d times",n);
+ for(i=1; i<=n; i++){
+ x1 = swizzle(i,maxb);
+ speedtest1_numbername(i, zNum, sizeof(zNum));
+ sqlite3_bind_int(g.pStmt, 1, (sqlite3_int64)x1);
+ sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+ speedtest1_begin_test(410, "%d SELECTS on an IPK", n);
+ if( g.doBigTransactions ){
+ /* Historical note: tests 410 and 510 have historically not used
+ ** explicit transactions. The --big-transactions flag was added
+ ** 2022-09-08 to support the WASM/OPFS build, as the run-times
+ ** approach 1 minute for each of these tests if they're not in an
+ ** explicit transaction. The run-time effect of --big-transaciions
+ ** on native builds is negligible. */
+ speedtest1_exec("BEGIN");
+ }
+ speedtest1_prepare("SELECT b FROM t5 WHERE a=?1; -- %d times",n);
+ for(i=1; i<=n; i++){
+ x1 = swizzle(i,maxb);
+ sqlite3_bind_int(g.pStmt, 1, (sqlite3_int64)x1);
+ speedtest1_run();
+ }
+ if( g.doBigTransactions ){
+ speedtest1_exec("COMMIT");
+ }
+ speedtest1_end_test();
+
+ sz = n = g.szTest*700;
+ zNum[0] = 0;
+ maxb = roundup_allones(sz/3);
+ speedtest1_begin_test(500, "%d REPLACE on TEXT PK", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_exec("CREATE%s TABLE t6(a TEXT PRIMARY KEY, b %s)%s;",
+ isTemp(9), g.zNN,
+ sqlite3_libversion_number()>=3008002 ? "WITHOUT ROWID" : "");
+ speedtest1_prepare("REPLACE INTO t6 VALUES(?1,?2); -- %d times",n);
+ for(i=1; i<=n; i++){
+ x1 = swizzle(i,maxb);
+ speedtest1_numbername(x1, zNum, sizeof(zNum));
+ sqlite3_bind_int(g.pStmt, 2, i);
+ sqlite3_bind_text(g.pStmt, 1, zNum, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+ speedtest1_begin_test(510, "%d SELECTS on a TEXT PK", n);
+ if( g.doBigTransactions ){
+ /* See notes for test 410. */
+ speedtest1_exec("BEGIN");
+ }
+ speedtest1_prepare("SELECT b FROM t6 WHERE a=?1; -- %d times",n);
+ for(i=1; i<=n; i++){
+ x1 = swizzle(i,maxb);
+ speedtest1_numbername(x1, zNum, sizeof(zNum));
+ sqlite3_bind_text(g.pStmt, 1, zNum, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ if( g.doBigTransactions ){
+ speedtest1_exec("COMMIT");
+ }
+ speedtest1_end_test();
+ speedtest1_begin_test(520, "%d SELECT DISTINCT", n);
+ speedtest1_exec("SELECT DISTINCT b FROM t5;");
+ speedtest1_exec("SELECT DISTINCT b FROM t6;");
+ speedtest1_end_test();
+
+
+ speedtest1_begin_test(980, "PRAGMA integrity_check");
+ speedtest1_exec("PRAGMA integrity_check");
+ speedtest1_end_test();
+
+
+ speedtest1_begin_test(990, "ANALYZE");
+ speedtest1_exec("ANALYZE");
+ speedtest1_end_test();
+}
+
+/*
+** A testset for common table expressions. This exercises code
+** for views, subqueries, co-routines, etc.
+*/
+void testset_cte(void){
+ static const char *azPuzzle[] = {
+ /* Easy */
+ "534...9.."
+ "67.195..."
+ ".98....6."
+ "8...6...3"
+ "4..8.3..1"
+ "....2...6"
+ ".6....28."
+ "...419..5"
+ "...28..79",
+
+ /* Medium */
+ "53....9.."
+ "6..195..."
+ ".98....6."
+ "8...6...3"
+ "4..8.3..1"
+ "....2...6"
+ ".6....28."
+ "...419..5"
+ "....8..79",
+
+ /* Hard */
+ "53......."
+ "6..195..."
+ ".98....6."
+ "8...6...3"
+ "4..8.3..1"
+ "....2...6"
+ ".6....28."
+ "...419..5"
+ "....8..79",
+ };
+ const char *zPuz;
+ double rSpacing;
+ int nElem;
+
+ if( g.szTest<25 ){
+ zPuz = azPuzzle[0];
+ }else if( g.szTest<70 ){
+ zPuz = azPuzzle[1];
+ }else{
+ zPuz = azPuzzle[2];
+ }
+ speedtest1_begin_test(100, "Sudoku with recursive 'digits'");
+ speedtest1_prepare(
+ "WITH RECURSIVE\n"
+ " input(sud) AS (VALUES(?1)),\n"
+ " digits(z,lp) AS (\n"
+ " VALUES('1', 1)\n"
+ " UNION ALL\n"
+ " SELECT CAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9\n"
+ " ),\n"
+ " x(s, ind) AS (\n"
+ " SELECT sud, instr(sud, '.') FROM input\n"
+ " UNION ALL\n"
+ " SELECT\n"
+ " substr(s, 1, ind-1) || z || substr(s, ind+1),\n"
+ " instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )\n"
+ " FROM x, digits AS z\n"
+ " WHERE ind>0\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM digits AS lp\n"
+ " WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)\n"
+ " OR z.z = substr(s, ((ind-1)%%9) + (lp-1)*9 + 1, 1)\n"
+ " OR z.z = substr(s, (((ind-1)/3) %% 3) * 3\n"
+ " + ((ind-1)/27) * 27 + lp\n"
+ " + ((lp-1) / 3) * 6, 1)\n"
+ " )\n"
+ " )\n"
+ "SELECT s FROM x WHERE ind=0;"
+ );
+ sqlite3_bind_text(g.pStmt, 1, zPuz, -1, SQLITE_STATIC);
+ speedtest1_run();
+ speedtest1_end_test();
+
+ speedtest1_begin_test(200, "Sudoku with VALUES 'digits'");
+ speedtest1_prepare(
+ "WITH RECURSIVE\n"
+ " input(sud) AS (VALUES(?1)),\n"
+ " digits(z,lp) AS (VALUES('1',1),('2',2),('3',3),('4',4),('5',5),\n"
+ " ('6',6),('7',7),('8',8),('9',9)),\n"
+ " x(s, ind) AS (\n"
+ " SELECT sud, instr(sud, '.') FROM input\n"
+ " UNION ALL\n"
+ " SELECT\n"
+ " substr(s, 1, ind-1) || z || substr(s, ind+1),\n"
+ " instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )\n"
+ " FROM x, digits AS z\n"
+ " WHERE ind>0\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM digits AS lp\n"
+ " WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)\n"
+ " OR z.z = substr(s, ((ind-1)%%9) + (lp-1)*9 + 1, 1)\n"
+ " OR z.z = substr(s, (((ind-1)/3) %% 3) * 3\n"
+ " + ((ind-1)/27) * 27 + lp\n"
+ " + ((lp-1) / 3) * 6, 1)\n"
+ " )\n"
+ " )\n"
+ "SELECT s FROM x WHERE ind=0;"
+ );
+ sqlite3_bind_text(g.pStmt, 1, zPuz, -1, SQLITE_STATIC);
+ speedtest1_run();
+ speedtest1_end_test();
+
+ rSpacing = 5.0/g.szTest;
+ speedtest1_begin_test(300, "Mandelbrot Set with spacing=%f", rSpacing);
+ speedtest1_prepare(
+ "WITH RECURSIVE \n"
+ " xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+?1 FROM xaxis WHERE x<1.2),\n"
+ " yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+?2 FROM yaxis WHERE y<1.0),\n"
+ " m(iter, cx, cy, x, y) AS (\n"
+ " SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis\n"
+ " UNION ALL\n"
+ " SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m \n"
+ " WHERE (x*x + y*y) < 4.0 AND iter<28\n"
+ " ),\n"
+ " m2(iter, cx, cy) AS (\n"
+ " SELECT max(iter), cx, cy FROM m GROUP BY cx, cy\n"
+ " ),\n"
+ " a(t) AS (\n"
+ " SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '') \n"
+ " FROM m2 GROUP BY cy\n"
+ " )\n"
+ "SELECT group_concat(rtrim(t),x'0a') FROM a;"
+ );
+ sqlite3_bind_double(g.pStmt, 1, rSpacing*.05);
+ sqlite3_bind_double(g.pStmt, 2, rSpacing);
+ speedtest1_run();
+ speedtest1_end_test();
+
+ nElem = 10000*g.szTest;
+ speedtest1_begin_test(400, "EXCEPT operator on %d-element tables", nElem);
+ speedtest1_prepare(
+ "WITH RECURSIVE \n"
+ " z1(x) AS (VALUES(2) UNION ALL SELECT x+2 FROM z1 WHERE x<%d),\n"
+ " z2(y) AS (VALUES(3) UNION ALL SELECT y+3 FROM z2 WHERE y<%d)\n"
+ "SELECT count(x), avg(x) FROM (\n"
+ " SELECT x FROM z1 EXCEPT SELECT y FROM z2 ORDER BY 1\n"
+ ");",
+ nElem, nElem
+ );
+ speedtest1_run();
+ speedtest1_end_test();
+}
+
+/*
+** Compute a pseudo-random floating point ascii number.
+*/
+void speedtest1_random_ascii_fp(char *zFP){
+ int x = speedtest1_random();
+ int y = speedtest1_random();
+ int z;
+ z = y%10;
+ if( z<0 ) z = -z;
+ y /= 10;
+ sqlite3_snprintf(100,zFP,"%d.%de%d",y,z,x%200);
+}
+
+/*
+** A testset for floating-point numbers.
+*/
+void testset_fp(void){
+ int n;
+ int i;
+ char zFP1[100];
+ char zFP2[100];
+
+ n = g.szTest*5000;
+ speedtest1_begin_test(100, "Fill a table with %d FP values", n*2);
+ speedtest1_exec("BEGIN");
+ speedtest1_exec("CREATE%s TABLE z1(a REAL %s, b REAL %s);",
+ isTemp(1), g.zNN, g.zNN);
+ speedtest1_prepare("INSERT INTO z1 VALUES(?1,?2); -- %d times", n);
+ for(i=1; i<=n; i++){
+ speedtest1_random_ascii_fp(zFP1);
+ speedtest1_random_ascii_fp(zFP2);
+ sqlite3_bind_text(g.pStmt, 1, zFP1, -1, SQLITE_STATIC);
+ sqlite3_bind_text(g.pStmt, 2, zFP2, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+ n = g.szTest/25 + 2;
+ speedtest1_begin_test(110, "%d range queries", n);
+ speedtest1_prepare("SELECT sum(b) FROM z1 WHERE a BETWEEN ?1 AND ?2");
+ for(i=1; i<=n; i++){
+ speedtest1_random_ascii_fp(zFP1);
+ speedtest1_random_ascii_fp(zFP2);
+ sqlite3_bind_text(g.pStmt, 1, zFP1, -1, SQLITE_STATIC);
+ sqlite3_bind_text(g.pStmt, 2, zFP2, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+
+ speedtest1_begin_test(120, "CREATE INDEX three times");
+ speedtest1_exec("BEGIN;");
+ speedtest1_exec("CREATE INDEX t1a ON z1(a);");
+ speedtest1_exec("CREATE INDEX t1b ON z1(b);");
+ speedtest1_exec("CREATE INDEX t1ab ON z1(a,b);");
+ speedtest1_exec("COMMIT;");
+ speedtest1_end_test();
+
+ n = g.szTest/3 + 2;
+ speedtest1_begin_test(130, "%d indexed range queries", n);
+ speedtest1_prepare("SELECT sum(b) FROM z1 WHERE a BETWEEN ?1 AND ?2");
+ for(i=1; i<=n; i++){
+ speedtest1_random_ascii_fp(zFP1);
+ speedtest1_random_ascii_fp(zFP2);
+ sqlite3_bind_text(g.pStmt, 1, zFP1, -1, SQLITE_STATIC);
+ sqlite3_bind_text(g.pStmt, 2, zFP2, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+
+ n = g.szTest*5000;
+ speedtest1_begin_test(140, "%d calls to round()", n);
+ speedtest1_exec("SELECT sum(round(a,2)+round(b,4)) FROM z1;");
+ speedtest1_end_test();
+
+
+ speedtest1_begin_test(150, "%d printf() calls", n*4);
+ speedtest1_exec(
+ "WITH c(fmt) AS (VALUES('%%g'),('%%e'),('%%!g'),('%%.20f'))"
+ "SELECT sum(printf(fmt,a)) FROM z1, c"
+ );
+ speedtest1_end_test();
+}
+
+#ifdef SQLITE_ENABLE_RTREE
+/* Generate two numbers between 1 and mx. The first number is less than
+** the second. Usually the numbers are near each other but can sometimes
+** be far apart.
+*/
+static void twoCoords(
+ int p1, int p2, /* Parameters adjusting sizes */
+ unsigned mx, /* Range of 1..mx */
+ unsigned *pX0, unsigned *pX1 /* OUT: write results here */
+){
+ unsigned d, x0, x1, span;
+
+ span = mx/100 + 1;
+ if( speedtest1_random()%3==0 ) span *= p1;
+ if( speedtest1_random()%p2==0 ) span = mx/2;
+ d = speedtest1_random()%span + 1;
+ x0 = speedtest1_random()%(mx-d) + 1;
+ x1 = x0 + d;
+ *pX0 = x0;
+ *pX1 = x1;
+}
+#endif
+
+#ifdef SQLITE_ENABLE_RTREE
+/* The following routine is an R-Tree geometry callback. It returns
+** true if the object overlaps a slice on the Y coordinate between the
+** two values given as arguments. In other words
+**
+** SELECT count(*) FROM rt1 WHERE id MATCH xslice(10,20);
+**
+** Is the same as saying:
+**
+** SELECT count(*) FROM rt1 WHERE y1>=10 AND y0<=20;
+*/
+static int xsliceGeometryCallback(
+ sqlite3_rtree_geometry *p,
+ int nCoord,
+ double *aCoord,
+ int *pRes
+){
+ *pRes = aCoord[3]>=p->aParam[0] && aCoord[2]<=p->aParam[1];
+ return SQLITE_OK;
+}
+#endif /* SQLITE_ENABLE_RTREE */
+
+#ifdef SQLITE_ENABLE_RTREE
+/*
+** A testset for the R-Tree virtual table
+*/
+void testset_rtree(int p1, int p2){
+ unsigned i, n;
+ unsigned mxCoord;
+ unsigned x0, x1, y0, y1, z0, z1;
+ unsigned iStep;
+ unsigned mxRowid;
+ int *aCheck = sqlite3_malloc( sizeof(int)*g.szTest*500 );
+
+ mxCoord = 15000;
+ mxRowid = n = g.szTest*500;
+ speedtest1_begin_test(100, "%d INSERTs into an r-tree", n);
+ speedtest1_exec("BEGIN");
+ speedtest1_exec("CREATE VIRTUAL TABLE rt1 USING rtree(id,x0,x1,y0,y1,z0,z1)");
+ speedtest1_prepare("INSERT INTO rt1(id,x0,x1,y0,y1,z0,z1)"
+ "VALUES(?1,?2,?3,?4,?5,?6,?7)");
+ for(i=1; i<=n; i++){
+ twoCoords(p1, p2, mxCoord, &x0, &x1);
+ twoCoords(p1, p2, mxCoord, &y0, &y1);
+ twoCoords(p1, p2, mxCoord, &z0, &z1);
+ sqlite3_bind_int(g.pStmt, 1, i);
+ sqlite3_bind_int(g.pStmt, 2, x0);
+ sqlite3_bind_int(g.pStmt, 3, x1);
+ sqlite3_bind_int(g.pStmt, 4, y0);
+ sqlite3_bind_int(g.pStmt, 5, y1);
+ sqlite3_bind_int(g.pStmt, 6, z0);
+ sqlite3_bind_int(g.pStmt, 7, z1);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+ speedtest1_begin_test(101, "Copy from rtree to a regular table");
+ speedtest1_exec("CREATE TABLE z1(id INTEGER PRIMARY KEY,x0,x1,y0,y1,z0,z1)");
+ speedtest1_exec("INSERT INTO z1 SELECT * FROM rt1");
+ speedtest1_end_test();
+
+ n = g.szTest*200;
+ speedtest1_begin_test(110, "%d one-dimensional intersect slice queries", n);
+ speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x0>=?1 AND x1<=?2");
+ iStep = mxCoord/n;
+ for(i=0; i<n; i++){
+ sqlite3_bind_int(g.pStmt, 1, i*iStep);
+ sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
+ speedtest1_run();
+ aCheck[i] = atoi(g.zResult);
+ }
+ speedtest1_end_test();
+
+ if( g.bVerify ){
+ n = g.szTest*200;
+ speedtest1_begin_test(111, "Verify result from 1-D intersect slice queries");
+ speedtest1_prepare("SELECT count(*) FROM z1 WHERE x0>=?1 AND x1<=?2");
+ iStep = mxCoord/n;
+ for(i=0; i<n; i++){
+ sqlite3_bind_int(g.pStmt, 1, i*iStep);
+ sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
+ speedtest1_run();
+ if( aCheck[i]!=atoi(g.zResult) ){
+ fatal_error("Count disagree step %d: %d..%d. %d vs %d",
+ i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult));
+ }
+ }
+ speedtest1_end_test();
+ }
+
+ n = g.szTest*200;
+ speedtest1_begin_test(120, "%d one-dimensional overlap slice queries", n);
+ speedtest1_prepare("SELECT count(*) FROM rt1 WHERE y1>=?1 AND y0<=?2");
+ iStep = mxCoord/n;
+ for(i=0; i<n; i++){
+ sqlite3_bind_int(g.pStmt, 1, i*iStep);
+ sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
+ speedtest1_run();
+ aCheck[i] = atoi(g.zResult);
+ }
+ speedtest1_end_test();
+
+ if( g.bVerify ){
+ n = g.szTest*200;
+ speedtest1_begin_test(121, "Verify result from 1-D overlap slice queries");
+ speedtest1_prepare("SELECT count(*) FROM z1 WHERE y1>=?1 AND y0<=?2");
+ iStep = mxCoord/n;
+ for(i=0; i<n; i++){
+ sqlite3_bind_int(g.pStmt, 1, i*iStep);
+ sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
+ speedtest1_run();
+ if( aCheck[i]!=atoi(g.zResult) ){
+ fatal_error("Count disagree step %d: %d..%d. %d vs %d",
+ i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult));
+ }
+ }
+ speedtest1_end_test();
+ }
+
+
+ n = g.szTest*200;
+ speedtest1_begin_test(125, "%d custom geometry callback queries", n);
+ sqlite3_rtree_geometry_callback(g.db, "xslice", xsliceGeometryCallback, 0);
+ speedtest1_prepare("SELECT count(*) FROM rt1 WHERE id MATCH xslice(?1,?2)");
+ iStep = mxCoord/n;
+ for(i=0; i<n; i++){
+ sqlite3_bind_int(g.pStmt, 1, i*iStep);
+ sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
+ speedtest1_run();
+ if( aCheck[i]!=atoi(g.zResult) ){
+ fatal_error("Count disagree step %d: %d..%d. %d vs %d",
+ i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult));
+ }
+ }
+ speedtest1_end_test();
+
+ n = g.szTest*400;
+ speedtest1_begin_test(130, "%d three-dimensional intersect box queries", n);
+ speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x1>=?1 AND x0<=?2"
+ " AND y1>=?1 AND y0<=?2 AND z1>=?1 AND z0<=?2");
+ iStep = mxCoord/n;
+ for(i=0; i<n; i++){
+ sqlite3_bind_int(g.pStmt, 1, i*iStep);
+ sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
+ speedtest1_run();
+ aCheck[i] = atoi(g.zResult);
+ }
+ speedtest1_end_test();
+
+ n = g.szTest*500;
+ speedtest1_begin_test(140, "%d rowid queries", n);
+ speedtest1_prepare("SELECT * FROM rt1 WHERE id=?1");
+ for(i=1; i<=n; i++){
+ sqlite3_bind_int(g.pStmt, 1, i);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+
+ n = g.szTest*50;
+ speedtest1_begin_test(150, "%d UPDATEs using rowid", n);
+ speedtest1_prepare("UPDATE rt1 SET x0=x0+100, x1=x1+100 WHERE id=?1");
+ for(i=1; i<=n; i++){
+ sqlite3_bind_int(g.pStmt, 1, (i*251)%mxRowid + 1);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+
+ n = g.szTest*5;
+ speedtest1_begin_test(155, "%d UPDATEs using one-dimensional overlap", n);
+ speedtest1_prepare("UPDATE rt1 SET x0=x0-100, x1=x1-100"
+ " WHERE y1>=?1 AND y0<=?1+5");
+ iStep = mxCoord/n;
+ for(i=0; i<n; i++){
+ sqlite3_bind_int(g.pStmt, 1, i*iStep);
+ speedtest1_run();
+ aCheck[i] = atoi(g.zResult);
+ }
+ speedtest1_end_test();
+
+ n = g.szTest*50;
+ speedtest1_begin_test(160, "%d DELETEs using rowid", n);
+ speedtest1_prepare("DELETE FROM rt1 WHERE id=?1");
+ for(i=1; i<=n; i++){
+ sqlite3_bind_int(g.pStmt, 1, (i*257)%mxRowid + 1);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+
+
+ n = g.szTest*5;
+ speedtest1_begin_test(165, "%d DELETEs using one-dimensional overlap", n);
+ speedtest1_prepare("DELETE FROM rt1 WHERE y1>=?1 AND y0<=?1+5");
+ iStep = mxCoord/n;
+ for(i=0; i<n; i++){
+ sqlite3_bind_int(g.pStmt, 1, i*iStep);
+ speedtest1_run();
+ aCheck[i] = atoi(g.zResult);
+ }
+ speedtest1_end_test();
+
+ speedtest1_begin_test(170, "Restore deleted entries using INSERT OR IGNORE");
+ speedtest1_exec("INSERT OR IGNORE INTO rt1 SELECT * FROM z1");
+ speedtest1_end_test();
+}
+#endif /* SQLITE_ENABLE_RTREE */
+
+/*
+** A testset that does key/value storage on tables with many columns.
+** This is the kind of workload generated by ORMs such as CoreData.
+*/
+void testset_orm(void){
+ unsigned i, j, n;
+ unsigned nRow;
+ unsigned x1, len;
+ char zNum[2000]; /* A number name */
+ static const char zType[] = /* Types for all non-PK columns, in order */
+ "IBBIIITIVVITBTBFBFITTFBTBVBVIFTBBFITFFVBIFIVBVVVBTVTIBBFFIVIBTB"
+ "TVTTFTVTVFFIITIFBITFTTFFFVBIIBTTITFTFFVVVFIIITVBBVFFTVVB";
+
+ nRow = n = g.szTest*250;
+ speedtest1_begin_test(100, "Fill %d rows", n);
+ speedtest1_exec(
+ "BEGIN;"
+ "CREATE TABLE ZLOOKSLIKECOREDATA ("
+ " ZPK INTEGER PRIMARY KEY,"
+ " ZTERMFITTINGHOUSINGCOMMAND INTEGER,"
+ " ZBRIEFGOBYDODGERHEIGHT BLOB,"
+ " ZCAPABLETRIPDOORALMOND BLOB,"
+ " ZDEPOSITPAIRCOLLEGECOMET INTEGER,"
+ " ZFRAMEENTERSIMPLEMOUTH INTEGER,"
+ " ZHOPEFULGATEHOLECHALK INTEGER,"
+ " ZSLEEPYUSERGRANDBOWL TIMESTAMP,"
+ " ZDEWPEACHCAREERCELERY INTEGER,"
+ " ZHANGERLITHIUMDINNERMEET VARCHAR,"
+ " ZCLUBRELEASELIZARDADVICE VARCHAR,"
+ " ZCHARGECLICKHUMANEHIRE INTEGER,"
+ " ZFINGERDUEPIZZAOPTION TIMESTAMP,"
+ " ZFLYINGDOCTORTABLEMELODY BLOB,"
+ " ZLONGFINLEAVEIMAGEOIL TIMESTAMP,"
+ " ZFAMILYVISUALOWNERMATTER BLOB,"
+ " ZGOLDYOUNGINITIALNOSE FLOAT,"
+ " ZCAUSESALAMITERMCYAN BLOB,"
+ " ZSPREADMOTORBISCUITBACON FLOAT,"
+ " ZGIFTICEFISHGLUEHAIR INTEGER,"
+ " ZNOTICEPEARPOLICYJUICE TIMESTAMP,"
+ " ZBANKBUFFALORECOVERORBIT TIMESTAMP,"
+ " ZLONGDIETESSAYNATURE FLOAT,"
+ " ZACTIONRANGEELEGANTNEUTRON BLOB,"
+ " ZCADETBRIGHTPLANETBANK TIMESTAMP,"
+ " ZAIRFORGIVEHEADFROG BLOB,"
+ " ZSHARKJUSTFRUITMOVIE VARCHAR,"
+ " ZFARMERMORNINGMIRRORCONCERN BLOB,"
+ " ZWOODPOETRYCOBBLERBENCH VARCHAR,"
+ " ZHAFNIUMSCRIPTSALADMOTOR INTEGER,"
+ " ZPROBLEMCLUBPOPOVERJELLY FLOAT,"
+ " ZEIGHTLEADERWORKERMOST TIMESTAMP,"
+ " ZGLASSRESERVEBARIUMMEAL BLOB,"
+ " ZCLAMBITARUGULAFAJITA BLOB,"
+ " ZDECADEJOYOUSWAVEHABIT FLOAT,"
+ " ZCOMPANYSUMMERFIBERELF INTEGER,"
+ " ZTREATTESTQUILLCHARGE TIMESTAMP,"
+ " ZBROWBALANCEKEYCHOWDER FLOAT,"
+ " ZPEACHCOPPERDINNERLAKE FLOAT,"
+ " ZDRYWALLBEYONDBROWNBOWL VARCHAR,"
+ " ZBELLYCRASHITEMLACK BLOB,"
+ " ZTENNISCYCLEBILLOFFICER INTEGER,"
+ " ZMALLEQUIPTHANKSGLUE FLOAT,"
+ " ZMISSREPLYHUMANLIVING INTEGER,"
+ " ZKIWIVISUALPRIDEAPPLE VARCHAR,"
+ " ZWISHHITSKINMOTOR BLOB,"
+ " ZCALMRACCOONPROGRAMDEBIT VARCHAR,"
+ " ZSHINYASSISTLIVINGCRAB VARCHAR,"
+ " ZRESOLVEWRISTWRAPAPPLE VARCHAR,"
+ " ZAPPEALSIMPLESECONDHOUSING BLOB,"
+ " ZCORNERANCHORTAPEDIVER TIMESTAMP,"
+ " ZMEMORYREQUESTSOURCEBIG VARCHAR,"
+ " ZTRYFACTKEEPMILK TIMESTAMP,"
+ " ZDIVERPAINTLEATHEREASY INTEGER,"
+ " ZSORTMISTYQUOTECABBAGE BLOB,"
+ " ZTUNEGASBUFFALOCAPITAL BLOB,"
+ " ZFILLSTOPLAWJOYFUL FLOAT,"
+ " ZSTEELCAREFULPLATENUMBER FLOAT,"
+ " ZGIVEVIVIDDIVINEMEANING INTEGER,"
+ " ZTREATPACKFUTURECONVERT VARCHAR,"
+ " ZCALMLYGEMFINISHEFFECT INTEGER,"
+ " ZCABBAGESOCKEASEMINUTE BLOB,"
+ " ZPLANETFAMILYPUREMEMORY TIMESTAMP,"
+ " ZMERRYCRACKTRAINLEADER BLOB,"
+ " ZMINORWAYPAPERCLASSY TIMESTAMP,"
+ " ZEAGLELINEMINEMAIL VARCHAR,"
+ " ZRESORTYARDGREENLET TIMESTAMP,"
+ " ZYARDOREGANOVIVIDJEWEL TIMESTAMP,"
+ " ZPURECAKEVIVIDNEATLY FLOAT,"
+ " ZASKCONTACTMONITORFUN TIMESTAMP,"
+ " ZMOVEWHOGAMMAINCH VARCHAR,"
+ " ZLETTUCEBIRDMEETDEBATE TIMESTAMP,"
+ " ZGENENATURALHEARINGKITE VARCHAR,"
+ " ZMUFFINDRYERDRAWFORTUNE FLOAT,"
+ " ZGRAYSURVEYWIRELOVE FLOAT,"
+ " ZPLIERSPRINTASKOREGANO INTEGER,"
+ " ZTRAVELDRIVERCONTESTLILY INTEGER,"
+ " ZHUMORSPICESANDKIDNEY TIMESTAMP,"
+ " ZARSENICSAMPLEWAITMUON INTEGER,"
+ " ZLACEADDRESSGROUNDCAREFUL FLOAT,"
+ " ZBAMBOOMESSWASABIEVENING BLOB,"
+ " ZONERELEASEAVERAGENURSE INTEGER,"
+ " ZRADIANTWHENTRYCARD TIMESTAMP,"
+ " ZREWARDINSIDEMANGOINTENSE FLOAT,"
+ " ZNEATSTEWPARTIRON TIMESTAMP,"
+ " ZOUTSIDEPEAHENCOUNTICE TIMESTAMP,"
+ " ZCREAMEVENINGLIPBRANCH FLOAT,"
+ " ZWHALEMATHAVOCADOCOPPER FLOAT,"
+ " ZLIFEUSELEAFYBELL FLOAT,"
+ " ZWEALTHLINENGLEEFULDAY VARCHAR,"
+ " ZFACEINVITETALKGOLD BLOB,"
+ " ZWESTAMOUNTAFFECTHEARING INTEGER,"
+ " ZDELAYOUTCOMEHORNAGENCY INTEGER,"
+ " ZBIGTHINKCONVERTECONOMY BLOB,"
+ " ZBASEGOUDAREGULARFORGIVE TIMESTAMP,"
+ " ZPATTERNCLORINEGRANDCOLBY TIMESTAMP,"
+ " ZCYANBASEFEEDADROIT INTEGER,"
+ " ZCARRYFLOORMINNOWDRAGON TIMESTAMP,"
+ " ZIMAGEPENCILOTHERBOTTOM FLOAT,"
+ " ZXENONFLIGHTPALEAPPLE TIMESTAMP,"
+ " ZHERRINGJOKEFEATUREHOPEFUL FLOAT,"
+ " ZCAPYEARLYRIVETBRUSH FLOAT,"
+ " ZAGEREEDFROGBASKET VARCHAR,"
+ " ZUSUALBODYHALIBUTDIAMOND VARCHAR,"
+ " ZFOOTTAPWORDENTRY VARCHAR,"
+ " ZDISHKEEPBLESTMONITOR FLOAT,"
+ " ZBROADABLESOLIDCASUAL INTEGER,"
+ " ZSQUAREGLEEFULCHILDLIGHT INTEGER,"
+ " ZHOLIDAYHEADPONYDETAIL INTEGER,"
+ " ZGENERALRESORTSKYOPEN TIMESTAMP,"
+ " ZGLADSPRAYKIDNEYGUPPY VARCHAR,"
+ " ZSWIMHEAVYMENTIONKIND BLOB,"
+ " ZMESSYSULFURDREAMFESTIVE BLOB,"
+ " ZSKYSKYCLASSICBRIEF VARCHAR,"
+ " ZDILLASKHOKILEMON FLOAT,"
+ " ZJUNIORSHOWPRESSNOVA FLOAT,"
+ " ZSIZETOEAWARDFRESH TIMESTAMP,"
+ " ZKEYFAILAPRICOTMETAL VARCHAR,"
+ " ZHANDYREPAIRPROTONAIRPORT VARCHAR,"
+ " ZPOSTPROTEINHANDLEACTOR BLOB"
+ ");"
+ );
+ speedtest1_prepare(
+ "INSERT INTO ZLOOKSLIKECOREDATA(ZPK,ZAIRFORGIVEHEADFROG,"
+ "ZGIFTICEFISHGLUEHAIR,ZDELAYOUTCOMEHORNAGENCY,ZSLEEPYUSERGRANDBOWL,"
+ "ZGLASSRESERVEBARIUMMEAL,ZBRIEFGOBYDODGERHEIGHT,"
+ "ZBAMBOOMESSWASABIEVENING,ZFARMERMORNINGMIRRORCONCERN,"
+ "ZTREATPACKFUTURECONVERT,ZCAUSESALAMITERMCYAN,ZCALMRACCOONPROGRAMDEBIT,"
+ "ZHOLIDAYHEADPONYDETAIL,ZWOODPOETRYCOBBLERBENCH,ZHAFNIUMSCRIPTSALADMOTOR,"
+ "ZUSUALBODYHALIBUTDIAMOND,ZOUTSIDEPEAHENCOUNTICE,ZDIVERPAINTLEATHEREASY,"
+ "ZWESTAMOUNTAFFECTHEARING,ZSIZETOEAWARDFRESH,ZDEWPEACHCAREERCELERY,"
+ "ZSTEELCAREFULPLATENUMBER,ZCYANBASEFEEDADROIT,ZCALMLYGEMFINISHEFFECT,"
+ "ZHANDYREPAIRPROTONAIRPORT,ZGENENATURALHEARINGKITE,ZBROADABLESOLIDCASUAL,"
+ "ZPOSTPROTEINHANDLEACTOR,ZLACEADDRESSGROUNDCAREFUL,ZIMAGEPENCILOTHERBOTTOM,"
+ "ZPROBLEMCLUBPOPOVERJELLY,ZPATTERNCLORINEGRANDCOLBY,ZNEATSTEWPARTIRON,"
+ "ZAPPEALSIMPLESECONDHOUSING,ZMOVEWHOGAMMAINCH,ZTENNISCYCLEBILLOFFICER,"
+ "ZSHARKJUSTFRUITMOVIE,ZKEYFAILAPRICOTMETAL,ZCOMPANYSUMMERFIBERELF,"
+ "ZTERMFITTINGHOUSINGCOMMAND,ZRESORTYARDGREENLET,ZCABBAGESOCKEASEMINUTE,"
+ "ZSQUAREGLEEFULCHILDLIGHT,ZONERELEASEAVERAGENURSE,ZBIGTHINKCONVERTECONOMY,"
+ "ZPLIERSPRINTASKOREGANO,ZDECADEJOYOUSWAVEHABIT,ZDRYWALLBEYONDBROWNBOWL,"
+ "ZCLUBRELEASELIZARDADVICE,ZWHALEMATHAVOCADOCOPPER,ZBELLYCRASHITEMLACK,"
+ "ZLETTUCEBIRDMEETDEBATE,ZCAPABLETRIPDOORALMOND,ZRADIANTWHENTRYCARD,"
+ "ZCAPYEARLYRIVETBRUSH,ZAGEREEDFROGBASKET,ZSWIMHEAVYMENTIONKIND,"
+ "ZTRAVELDRIVERCONTESTLILY,ZGLADSPRAYKIDNEYGUPPY,ZBANKBUFFALORECOVERORBIT,"
+ "ZFINGERDUEPIZZAOPTION,ZCLAMBITARUGULAFAJITA,ZLONGFINLEAVEIMAGEOIL,"
+ "ZLONGDIETESSAYNATURE,ZJUNIORSHOWPRESSNOVA,ZHOPEFULGATEHOLECHALK,"
+ "ZDEPOSITPAIRCOLLEGECOMET,ZWEALTHLINENGLEEFULDAY,ZFILLSTOPLAWJOYFUL,"
+ "ZTUNEGASBUFFALOCAPITAL,ZGRAYSURVEYWIRELOVE,ZCORNERANCHORTAPEDIVER,"
+ "ZREWARDINSIDEMANGOINTENSE,ZCADETBRIGHTPLANETBANK,ZPLANETFAMILYPUREMEMORY,"
+ "ZTREATTESTQUILLCHARGE,ZCREAMEVENINGLIPBRANCH,ZSKYSKYCLASSICBRIEF,"
+ "ZARSENICSAMPLEWAITMUON,ZBROWBALANCEKEYCHOWDER,ZFLYINGDOCTORTABLEMELODY,"
+ "ZHANGERLITHIUMDINNERMEET,ZNOTICEPEARPOLICYJUICE,ZSHINYASSISTLIVINGCRAB,"
+ "ZLIFEUSELEAFYBELL,ZFACEINVITETALKGOLD,ZGENERALRESORTSKYOPEN,"
+ "ZPURECAKEVIVIDNEATLY,ZKIWIVISUALPRIDEAPPLE,ZMESSYSULFURDREAMFESTIVE,"
+ "ZCHARGECLICKHUMANEHIRE,ZHERRINGJOKEFEATUREHOPEFUL,ZYARDOREGANOVIVIDJEWEL,"
+ "ZFOOTTAPWORDENTRY,ZWISHHITSKINMOTOR,ZBASEGOUDAREGULARFORGIVE,"
+ "ZMUFFINDRYERDRAWFORTUNE,ZACTIONRANGEELEGANTNEUTRON,ZTRYFACTKEEPMILK,"
+ "ZPEACHCOPPERDINNERLAKE,ZFRAMEENTERSIMPLEMOUTH,ZMERRYCRACKTRAINLEADER,"
+ "ZMEMORYREQUESTSOURCEBIG,ZCARRYFLOORMINNOWDRAGON,ZMINORWAYPAPERCLASSY,"
+ "ZDILLASKHOKILEMON,ZRESOLVEWRISTWRAPAPPLE,ZASKCONTACTMONITORFUN,"
+ "ZGIVEVIVIDDIVINEMEANING,ZEIGHTLEADERWORKERMOST,ZMISSREPLYHUMANLIVING,"
+ "ZXENONFLIGHTPALEAPPLE,ZSORTMISTYQUOTECABBAGE,ZEAGLELINEMINEMAIL,"
+ "ZFAMILYVISUALOWNERMATTER,ZSPREADMOTORBISCUITBACON,ZDISHKEEPBLESTMONITOR,"
+ "ZMALLEQUIPTHANKSGLUE,ZGOLDYOUNGINITIALNOSE,ZHUMORSPICESANDKIDNEY)"
+ "VALUES(?1,?26,?20,?93,?8,?33,?3,?81,?28,?60,?18,?47,?109,?29,?30,?104,?86,"
+ "?54,?92,?117,?9,?58,?97,?61,?119,?73,?107,?120,?80,?99,?31,?96,?85,?50,?71,"
+ "?42,?27,?118,?36,?2,?67,?62,?108,?82,?94,?76,?35,?40,?11,?88,?41,?72,?4,"
+ "?83,?102,?103,?112,?77,?111,?22,?13,?34,?15,?23,?116,?7,?5,?90,?57,?56,"
+ "?75,?51,?84,?25,?63,?37,?87,?114,?79,?38,?14,?10,?21,?48,?89,?91,?110,"
+ "?69,?45,?113,?12,?101,?68,?105,?46,?95,?74,?24,?53,?39,?6,?64,?52,?98,"
+ "?65,?115,?49,?70,?59,?32,?44,?100,?55,?66,?16,?19,?106,?43,?17,?78);"
+ );
+ for(i=0; i<n; i++){
+ x1 = speedtest1_random();
+ speedtest1_numbername(x1%1000, zNum, sizeof(zNum));
+ len = (int)strlen(zNum);
+ sqlite3_bind_int(g.pStmt, 1, i^0xf);
+ for(j=0; zType[j]; j++){
+ switch( zType[j] ){
+ case 'I':
+ case 'T':
+ sqlite3_bind_int64(g.pStmt, j+2, x1);
+ break;
+ case 'F':
+ sqlite3_bind_double(g.pStmt, j+2, (double)x1);
+ break;
+ case 'V':
+ case 'B':
+ sqlite3_bind_text64(g.pStmt, j+2, zNum, len,
+ SQLITE_STATIC, SQLITE_UTF8);
+ break;
+ }
+ }
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT;");
+ speedtest1_end_test();
+
+ n = g.szTest*250;
+ speedtest1_begin_test(110, "Query %d rows by rowid", n);
+ speedtest1_prepare(
+ "SELECT ZCYANBASEFEEDADROIT,ZJUNIORSHOWPRESSNOVA,ZCAUSESALAMITERMCYAN,"
+ "ZHOPEFULGATEHOLECHALK,ZHUMORSPICESANDKIDNEY,ZSWIMHEAVYMENTIONKIND,"
+ "ZMOVEWHOGAMMAINCH,ZAPPEALSIMPLESECONDHOUSING,ZHAFNIUMSCRIPTSALADMOTOR,"
+ "ZNEATSTEWPARTIRON,ZLONGFINLEAVEIMAGEOIL,ZDEWPEACHCAREERCELERY,"
+ "ZXENONFLIGHTPALEAPPLE,ZCALMRACCOONPROGRAMDEBIT,ZUSUALBODYHALIBUTDIAMOND,"
+ "ZTRYFACTKEEPMILK,ZWEALTHLINENGLEEFULDAY,ZLONGDIETESSAYNATURE,"
+ "ZLIFEUSELEAFYBELL,ZTREATPACKFUTURECONVERT,ZMEMORYREQUESTSOURCEBIG,"
+ "ZYARDOREGANOVIVIDJEWEL,ZDEPOSITPAIRCOLLEGECOMET,ZSLEEPYUSERGRANDBOWL,"
+ "ZBRIEFGOBYDODGERHEIGHT,ZCLUBRELEASELIZARDADVICE,ZCAPABLETRIPDOORALMOND,"
+ "ZDRYWALLBEYONDBROWNBOWL,ZASKCONTACTMONITORFUN,ZKIWIVISUALPRIDEAPPLE,"
+ "ZNOTICEPEARPOLICYJUICE,ZPEACHCOPPERDINNERLAKE,ZSTEELCAREFULPLATENUMBER,"
+ "ZGLADSPRAYKIDNEYGUPPY,ZCOMPANYSUMMERFIBERELF,ZTENNISCYCLEBILLOFFICER,"
+ "ZIMAGEPENCILOTHERBOTTOM,ZWESTAMOUNTAFFECTHEARING,ZDIVERPAINTLEATHEREASY,"
+ "ZSKYSKYCLASSICBRIEF,ZMESSYSULFURDREAMFESTIVE,ZMERRYCRACKTRAINLEADER,"
+ "ZBROADABLESOLIDCASUAL,ZGLASSRESERVEBARIUMMEAL,ZTUNEGASBUFFALOCAPITAL,"
+ "ZBANKBUFFALORECOVERORBIT,ZTREATTESTQUILLCHARGE,ZBAMBOOMESSWASABIEVENING,"
+ "ZREWARDINSIDEMANGOINTENSE,ZEAGLELINEMINEMAIL,ZCALMLYGEMFINISHEFFECT,"
+ "ZKEYFAILAPRICOTMETAL,ZFINGERDUEPIZZAOPTION,ZCADETBRIGHTPLANETBANK,"
+ "ZGOLDYOUNGINITIALNOSE,ZMISSREPLYHUMANLIVING,ZEIGHTLEADERWORKERMOST,"
+ "ZFRAMEENTERSIMPLEMOUTH,ZBIGTHINKCONVERTECONOMY,ZFACEINVITETALKGOLD,"
+ "ZPOSTPROTEINHANDLEACTOR,ZHERRINGJOKEFEATUREHOPEFUL,ZCABBAGESOCKEASEMINUTE,"
+ "ZMUFFINDRYERDRAWFORTUNE,ZPROBLEMCLUBPOPOVERJELLY,ZGIVEVIVIDDIVINEMEANING,"
+ "ZGENENATURALHEARINGKITE,ZGENERALRESORTSKYOPEN,ZLETTUCEBIRDMEETDEBATE,"
+ "ZBASEGOUDAREGULARFORGIVE,ZCHARGECLICKHUMANEHIRE,ZPLANETFAMILYPUREMEMORY,"
+ "ZMINORWAYPAPERCLASSY,ZCAPYEARLYRIVETBRUSH,ZSIZETOEAWARDFRESH,"
+ "ZARSENICSAMPLEWAITMUON,ZSQUAREGLEEFULCHILDLIGHT,ZSHINYASSISTLIVINGCRAB,"
+ "ZCORNERANCHORTAPEDIVER,ZDECADEJOYOUSWAVEHABIT,ZTRAVELDRIVERCONTESTLILY,"
+ "ZFLYINGDOCTORTABLEMELODY,ZSHARKJUSTFRUITMOVIE,ZFAMILYVISUALOWNERMATTER,"
+ "ZFARMERMORNINGMIRRORCONCERN,ZGIFTICEFISHGLUEHAIR,ZOUTSIDEPEAHENCOUNTICE,"
+ "ZSPREADMOTORBISCUITBACON,ZWISHHITSKINMOTOR,ZHOLIDAYHEADPONYDETAIL,"
+ "ZWOODPOETRYCOBBLERBENCH,ZAIRFORGIVEHEADFROG,ZBROWBALANCEKEYCHOWDER,"
+ "ZDISHKEEPBLESTMONITOR,ZCLAMBITARUGULAFAJITA,ZPLIERSPRINTASKOREGANO,"
+ "ZRADIANTWHENTRYCARD,ZDELAYOUTCOMEHORNAGENCY,ZPURECAKEVIVIDNEATLY,"
+ "ZPATTERNCLORINEGRANDCOLBY,ZHANDYREPAIRPROTONAIRPORT,ZAGEREEDFROGBASKET,"
+ "ZSORTMISTYQUOTECABBAGE,ZFOOTTAPWORDENTRY,ZRESOLVEWRISTWRAPAPPLE,"
+ "ZDILLASKHOKILEMON,ZFILLSTOPLAWJOYFUL,ZACTIONRANGEELEGANTNEUTRON,"
+ "ZRESORTYARDGREENLET,ZCREAMEVENINGLIPBRANCH,ZWHALEMATHAVOCADOCOPPER,"
+ "ZGRAYSURVEYWIRELOVE,ZBELLYCRASHITEMLACK,ZHANGERLITHIUMDINNERMEET,"
+ "ZCARRYFLOORMINNOWDRAGON,ZMALLEQUIPTHANKSGLUE,ZTERMFITTINGHOUSINGCOMMAND,"
+ "ZONERELEASEAVERAGENURSE,ZLACEADDRESSGROUNDCAREFUL"
+ " FROM ZLOOKSLIKECOREDATA WHERE ZPK=?1;"
+ );
+ for(i=0; i<n; i++){
+ x1 = speedtest1_random()%nRow;
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+}
+
+/*
+*/
+void testset_trigger(void){
+ int jj, ii;
+ char zNum[2000]; /* A number name */
+
+ const int NROW = 500*g.szTest;
+ const int NROW2 = 100*g.szTest;
+
+ speedtest1_exec(
+ "BEGIN;"
+ "CREATE TABLE z1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
+ "CREATE TABLE z2(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 z1;"
+ "CREATE VIEW v2 AS SELECT rowid, i, t FROM z2;"
+ "CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;"
+ );
+ for(jj=1; jj<=3; jj++){
+ speedtest1_prepare("INSERT INTO t%d VALUES(NULL,?1,?2)", jj);
+ for(ii=0; ii<NROW; ii++){
+ int x1 = speedtest1_random() % NROW;
+ speedtest1_numbername(x1, zNum, sizeof(zNum));
+ sqlite3_bind_int(g.pStmt, 1, x1);
+ sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ }
+ speedtest1_exec(
+ "CREATE INDEX i1 ON z1(t);"
+ "CREATE INDEX i2 ON z2(t);"
+ "CREATE INDEX i3 ON t3(t);"
+ "COMMIT;"
+ );
+
+ speedtest1_begin_test(100, "speed4p-join1");
+ speedtest1_prepare(
+ "SELECT * FROM z1, z2, t3 WHERE z1.oid = z2.oid AND z2.oid = t3.oid"
+ );
+ speedtest1_run();
+ speedtest1_end_test();
+
+ speedtest1_begin_test(110, "speed4p-join2");
+ speedtest1_prepare(
+ "SELECT * FROM z1, z2, t3 WHERE z1.t = z2.t AND z2.t = t3.t"
+ );
+ speedtest1_run();
+ speedtest1_end_test();
+
+ speedtest1_begin_test(120, "speed4p-view1");
+ for(jj=1; jj<=3; jj++){
+ speedtest1_prepare("SELECT * FROM v%d WHERE rowid = ?", jj);
+ for(ii=0; ii<NROW2; ii+=3){
+ sqlite3_bind_int(g.pStmt, 1, ii*3);
+ speedtest1_run();
+ }
+ }
+ speedtest1_end_test();
+
+ speedtest1_begin_test(130, "speed4p-table1");
+ for(jj=1; jj<=3; jj++){
+ speedtest1_prepare("SELECT * FROM t%d WHERE rowid = ?", jj);
+ for(ii=0; ii<NROW2; ii+=3){
+ sqlite3_bind_int(g.pStmt, 1, ii*3);
+ speedtest1_run();
+ }
+ }
+ speedtest1_end_test();
+
+ speedtest1_begin_test(140, "speed4p-table1");
+ for(jj=1; jj<=3; jj++){
+ speedtest1_prepare("SELECT * FROM t%d WHERE rowid = ?", jj);
+ for(ii=0; ii<NROW2; ii+=3){
+ sqlite3_bind_int(g.pStmt, 1, ii*3);
+ speedtest1_run();
+ }
+ }
+ speedtest1_end_test();
+
+ speedtest1_begin_test(150, "speed4p-subselect1");
+ speedtest1_prepare("SELECT "
+ "(SELECT t FROM z1 WHERE rowid = ?1),"
+ "(SELECT t FROM z2 WHERE rowid = ?1),"
+ "(SELECT t FROM t3 WHERE rowid = ?1)"
+ );
+ for(jj=0; jj<NROW2; jj++){
+ sqlite3_bind_int(g.pStmt, 1, jj*3);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+
+ speedtest1_begin_test(160, "speed4p-rowid-update");
+ speedtest1_exec("BEGIN");
+ speedtest1_prepare("UPDATE z1 SET i=i+1 WHERE rowid=?1");
+ for(jj=0; jj<NROW2; jj++){
+ sqlite3_bind_int(g.pStmt, 1, jj);
+ speedtest1_run();
+ }
+ speedtest1_exec("COMMIT");
+ speedtest1_end_test();
+
+ speedtest1_exec("CREATE TABLE t5(t TEXT PRIMARY KEY, i INTEGER);");
+ speedtest1_begin_test(170, "speed4p-insert-ignore");
+ speedtest1_exec("INSERT OR IGNORE INTO t5 SELECT t, i FROM z1");
+ speedtest1_end_test();
+
+ speedtest1_exec(
+ "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;"
+ );
+
+ speedtest1_begin_test(180, "speed4p-trigger1");
+ speedtest1_prepare("INSERT INTO t4 VALUES(NULL, ?1, ?2)");
+ for(jj=0; jj<NROW2; jj++){
+ speedtest1_numbername(jj, zNum, sizeof(zNum));
+ sqlite3_bind_int(g.pStmt, 1, jj);
+ sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+
+ /*
+ ** Note: Of the queries, only half actually update a row. This property
+ ** was copied over from speed4p.test, where it was probably introduced
+ ** inadvertantly.
+ */
+ speedtest1_begin_test(190, "speed4p-trigger2");
+ speedtest1_prepare("UPDATE t4 SET i = ?1, t = ?2 WHERE rowid = ?3");
+ for(jj=1; jj<=NROW2*2; jj+=2){
+ speedtest1_numbername(jj*2, zNum, sizeof(zNum));
+ sqlite3_bind_int(g.pStmt, 1, jj*2);
+ sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
+ sqlite3_bind_int(g.pStmt, 3, jj);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+
+ /*
+ ** Note: Same again.
+ */
+ speedtest1_begin_test(200, "speed4p-trigger3");
+ speedtest1_prepare("DELETE FROM t4 WHERE rowid = ?1");
+ for(jj=1; jj<=NROW2*2; jj+=2){
+ sqlite3_bind_int(g.pStmt, 1, jj*2);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+ speedtest1_exec("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.
+ */
+ speedtest1_exec(
+ "DROP TABLE t4;"
+ "DROP TABLE log;"
+ "VACUUM;"
+ "CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);"
+ "BEGIN;"
+ );
+ speedtest1_begin_test(210, "speed4p-notrigger1");
+ speedtest1_prepare("INSERT INTO t4 VALUES(NULL, ?1, ?2)");
+ for(jj=0; jj<NROW2; jj++){
+ speedtest1_numbername(jj, zNum, sizeof(zNum));
+ sqlite3_bind_int(g.pStmt, 1, jj);
+ sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+ speedtest1_begin_test(210, "speed4p-notrigger2");
+ speedtest1_prepare("UPDATE t4 SET i = ?1, t = ?2 WHERE rowid = ?3");
+ for(jj=1; jj<=NROW2*2; jj+=2){
+ speedtest1_numbername(jj*2, zNum, sizeof(zNum));
+ sqlite3_bind_int(g.pStmt, 1, jj*2);
+ sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);
+ sqlite3_bind_int(g.pStmt, 3, jj);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+ speedtest1_begin_test(220, "speed4p-notrigger3");
+ speedtest1_prepare("DELETE FROM t4 WHERE rowid = ?1");
+ for(jj=1; jj<=NROW2*2; jj+=2){
+ sqlite3_bind_int(g.pStmt, 1, jj*2);
+ speedtest1_run();
+ }
+ speedtest1_end_test();
+ speedtest1_exec("COMMIT");
+}
+
+/*
+** A testset used for debugging speedtest1 itself.
+*/
+void testset_debug1(void){
+ unsigned i, n;
+ unsigned x1, x2;
+ char zNum[2000]; /* A number name */
+
+ n = g.szTest;
+ for(i=1; i<=n; i++){
+ x1 = swizzle(i, n);
+ x2 = swizzle(x1, n);
+ speedtest1_numbername(x1, zNum, sizeof(zNum));
+ printf("%5d %5d %5d %s\n", i, x1, x2, zNum);
+ }
+}
+
+#ifdef __linux__
+#include <sys/types.h>
+#include <unistd.h>
+
+/*
+** Attempt to display I/O stats on Linux using /proc/PID/io
+*/
+static void displayLinuxIoStats(FILE *out){
+ FILE *in;
+ char z[200];
+ sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid());
+ in = fopen(z, "rb");
+ if( in==0 ) return;
+ while( fgets(z, sizeof(z), in)!=0 ){
+ static const struct {
+ const char *zPattern;
+ const char *zDesc;
+ } aTrans[] = {
+ { "rchar: ", "Bytes received by read():" },
+ { "wchar: ", "Bytes sent to write():" },
+ { "syscr: ", "Read() system calls:" },
+ { "syscw: ", "Write() system calls:" },
+ { "read_bytes: ", "Bytes rcvd from storage:" },
+ { "write_bytes: ", "Bytes sent to storage:" },
+ { "cancelled_write_bytes: ", "Cancelled write bytes:" },
+ };
+ int i;
+ for(i=0; i<sizeof(aTrans)/sizeof(aTrans[0]); i++){
+ int n = (int)strlen(aTrans[i].zPattern);
+ if( strncmp(aTrans[i].zPattern, z, n)==0 ){
+ fprintf(out, "-- %-28s %s", aTrans[i].zDesc, &z[n]);
+ break;
+ }
+ }
+ }
+ fclose(in);
+}
+#endif
+
+#if SQLITE_VERSION_NUMBER<3006018
+# define sqlite3_sourceid(X) "(before 3.6.18)"
+#endif
+
+#if SQLITE_CKSUMVFS_STATIC
+int sqlite3_register_cksumvfs(const char*);
+#endif
+
+static int xCompileOptions(void *pCtx, int nVal, char **azVal, char **azCol){
+ printf("-- Compile option: %s\n", azVal[0]);
+ return SQLITE_OK;
+}
+int main(int argc, char **argv){
+ int doAutovac = 0; /* True for --autovacuum */
+ int cacheSize = 0; /* Desired cache size. 0 means default */
+ int doExclusive = 0; /* True for --exclusive */
+ int nHeap = 0, mnHeap = 0; /* Heap size from --heap */
+ int doIncrvac = 0; /* True for --incrvacuum */
+ const char *zJMode = 0; /* Journal mode */
+ const char *zKey = 0; /* Encryption key */
+ int nLook = -1, szLook = 0; /* --lookaside configuration */
+ int noSync = 0; /* True for --nosync */
+ int pageSize = 0; /* Desired page size. 0 means default */
+ int nPCache = 0, szPCache = 0;/* --pcache configuration */
+ int doPCache = 0; /* True if --pcache is seen */
+ int showStats = 0; /* True for --stats */
+ int nThread = 0; /* --threads value */
+ int mmapSize = 0; /* How big of a memory map to use */
+ int memDb = 0; /* --memdb. Use an in-memory database */
+ int openFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
+ ; /* SQLITE_OPEN_xxx flags. */
+ char *zTSet = "main"; /* Which --testset torun */
+ const char * zVfs = 0; /* --vfs NAME */
+ int doTrace = 0; /* True for --trace */
+ const char *zEncoding = 0; /* --utf16be or --utf16le */
+ const char *zDbName = 0; /* Name of the test database */
+
+ void *pHeap = 0; /* Allocated heap space */
+ void *pLook = 0; /* Allocated lookaside space */
+ void *pPCache = 0; /* Allocated storage for pcache */
+ int iCur, iHi; /* Stats values, current and "highwater" */
+ int i; /* Loop counter */
+ int rc; /* API return code */
+
+#ifdef SQLITE_SPEEDTEST1_WASM
+ /* Resetting all state is important for the WASM build, which may
+ ** call main() multiple times. */
+ memset(&g, 0, sizeof(g));
+ iTestNumber = 0;
+#endif
+#ifdef SQLITE_CKSUMVFS_STATIC
+ sqlite3_register_cksumvfs(0);
+#endif
+ /*
+ ** Confirms that argc has at least N arguments following argv[i]. */
+#define ARGC_VALUE_CHECK(N) \
+ if( i>=argc-(N) ) fatal_error("missing argument on %s\n", argv[i])
+ /* Display the version of SQLite being tested */
+ printf("-- Speedtest1 for SQLite %s %.48s\n",
+ sqlite3_libversion(), sqlite3_sourceid());
+
+ /* Process command-line arguments */
+ g.zWR = "";
+ g.zNN = "";
+ g.zPK = "UNIQUE";
+ g.szTest = 100;
+ g.nRepeat = 1;
+ for(i=1; i<argc; i++){
+ const char *z = argv[i];
+ if( z[0]=='-' ){
+ do{ z++; }while( z[0]=='-' );
+ if( strcmp(z,"autovacuum")==0 ){
+ doAutovac = 1;
+ }else if( strcmp(z,"big-transactions")==0 ){
+ g.doBigTransactions = 1;
+ }else if( strcmp(z,"cachesize")==0 ){
+ ARGC_VALUE_CHECK(1);
+ cacheSize = integerValue(argv[++i]);
+ }else if( strcmp(z,"exclusive")==0 ){
+ doExclusive = 1;
+ }else if( strcmp(z,"checkpoint")==0 ){
+ g.doCheckpoint = 1;
+ }else if( strcmp(z,"explain")==0 ){
+ g.bSqlOnly = 1;
+ g.bExplain = 1;
+ }else if( strcmp(z,"heap")==0 ){
+ ARGC_VALUE_CHECK(2);
+ nHeap = integerValue(argv[i+1]);
+ mnHeap = integerValue(argv[i+2]);
+ i += 2;
+ }else if( strcmp(z,"incrvacuum")==0 ){
+ doIncrvac = 1;
+ }else if( strcmp(z,"journal")==0 ){
+ ARGC_VALUE_CHECK(1);
+ zJMode = argv[++i];
+ }else if( strcmp(z,"key")==0 ){
+ ARGC_VALUE_CHECK(1);
+ zKey = argv[++i];
+ }else if( strcmp(z,"lookaside")==0 ){
+ ARGC_VALUE_CHECK(2);
+ nLook = integerValue(argv[i+1]);
+ szLook = integerValue(argv[i+2]);
+ i += 2;
+ }else if( strcmp(z,"memdb")==0 ){
+ memDb = 1;
+#if SQLITE_VERSION_NUMBER>=3006000
+ }else if( strcmp(z,"multithread")==0 ){
+ sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
+ }else if( strcmp(z,"nomemstat")==0 ){
+ sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0);
+#endif
+#if SQLITE_VERSION_NUMBER>=3007017
+ }else if( strcmp(z, "mmap")==0 ){
+ ARGC_VALUE_CHECK(1);
+ mmapSize = integerValue(argv[++i]);
+ #endif
+ }else if( strcmp(z,"nomutex")==0 ){
+ openFlags |= SQLITE_OPEN_NOMUTEX;
+ }else if( strcmp(z,"nosync")==0 ){
+ noSync = 1;
+ }else if( strcmp(z,"notnull")==0 ){
+ g.zNN = "NOT NULL";
+ }else if( strcmp(z,"output")==0 ){
+#ifdef SPEEDTEST_OMIT_HASH
+ fatal_error("The --output option is not supported with"
+ " -DSPEEDTEST_OMIT_HASH\n");
+#else
+ ARGC_VALUE_CHECK(1);
+ i++;
+ if( strcmp(argv[i],"-")==0 ){
+ g.hashFile = stdout;
+ }else{
+ g.hashFile = fopen(argv[i], "wb");
+ if( g.hashFile==0 ){
+ fatal_error("cannot open \"%s\" for writing\n", argv[i]);
+ }
+ }
+#endif
+ }else if( strcmp(z,"pagesize")==0 ){
+ ARGC_VALUE_CHECK(1);
+ pageSize = integerValue(argv[++i]);
+ }else if( strcmp(z,"pcache")==0 ){
+ ARGC_VALUE_CHECK(2);
+ nPCache = integerValue(argv[i+1]);
+ szPCache = integerValue(argv[i+2]);
+ doPCache = 1;
+ i += 2;
+ }else if( strcmp(z,"primarykey")==0 ){
+ g.zPK = "PRIMARY KEY";
+ }else if( strcmp(z,"repeat")==0 ){
+ ARGC_VALUE_CHECK(1);
+ g.nRepeat = integerValue(argv[++i]);
+ }else if( strcmp(z,"reprepare")==0 ){
+ g.bReprepare = 1;
+#if SQLITE_VERSION_NUMBER>=3006000
+ }else if( strcmp(z,"serialized")==0 ){
+ sqlite3_config(SQLITE_CONFIG_SERIALIZED);
+ }else if( strcmp(z,"singlethread")==0 ){
+ sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
+#endif
+ }else if( strcmp(z,"script")==0 ){
+ ARGC_VALUE_CHECK(1);
+ if( g.pScript ) fclose(g.pScript);
+ g.pScript = fopen(argv[++i], "wb");
+ if( g.pScript==0 ){
+ fatal_error("unable to open output file \"%s\"\n", argv[i]);
+ }
+ }else if( strcmp(z,"sqlonly")==0 ){
+ g.bSqlOnly = 1;
+ }else if( strcmp(z,"shrink-memory")==0 ){
+ g.bMemShrink = 1;
+ }else if( strcmp(z,"size")==0 ){
+ ARGC_VALUE_CHECK(1);
+ g.szTest = integerValue(argv[++i]);
+ }else if( strcmp(z,"stats")==0 ){
+ showStats = 1;
+ }else if( strcmp(z,"temp")==0 ){
+ ARGC_VALUE_CHECK(1);
+ i++;
+ if( argv[i][0]<'0' || argv[i][0]>'9' || argv[i][1]!=0 ){
+ fatal_error("argument to --temp should be integer between 0 and 9");
+ }
+ g.eTemp = argv[i][0] - '0';
+ }else if( strcmp(z,"testset")==0 ){
+ ARGC_VALUE_CHECK(1);
+ zTSet = argv[++i];
+ }else if( strcmp(z,"trace")==0 ){
+ doTrace = 1;
+ }else if( strcmp(z,"threads")==0 ){
+ ARGC_VALUE_CHECK(1);
+ nThread = integerValue(argv[++i]);
+ }else if( strcmp(z,"utf16le")==0 ){
+ zEncoding = "utf16le";
+ }else if( strcmp(z,"utf16be")==0 ){
+ zEncoding = "utf16be";
+ }else if( strcmp(z,"verify")==0 ){
+ g.bVerify = 1;
+#ifndef SPEEDTEST_OMIT_HASH
+ HashInit();
+#endif
+ }else if( strcmp(z,"vfs")==0 ){
+ ARGC_VALUE_CHECK(1);
+ zVfs = argv[++i];
+ }else if( strcmp(z,"reserve")==0 ){
+ ARGC_VALUE_CHECK(1);
+ g.nReserve = atoi(argv[++i]);
+ }else if( strcmp(z,"without-rowid")==0 ){
+ if( strstr(g.zWR,"WITHOUT")!=0 ){
+ /* no-op */
+ }else if( strstr(g.zWR,"STRICT")!=0 ){
+ g.zWR = "WITHOUT ROWID,STRICT";
+ }else{
+ g.zWR = "WITHOUT ROWID";
+ }
+ g.zPK = "PRIMARY KEY";
+ }else if( strcmp(z,"strict")==0 ){
+ if( strstr(g.zWR,"STRICT")!=0 ){
+ /* no-op */
+ }else if( strstr(g.zWR,"WITHOUT")!=0 ){
+ g.zWR = "WITHOUT ROWID,STRICT";
+ }else{
+ g.zWR = "STRICT";
+ }
+ }else if( strcmp(z, "help")==0 || strcmp(z,"?")==0 ){
+ printf(zHelp, argv[0]);
+ exit(0);
+ }else{
+ fatal_error("unknown option: %s\nUse \"%s -?\" for help\n",
+ argv[i], argv[0]);
+ }
+ }else if( zDbName==0 ){
+ zDbName = argv[i];
+ }else{
+ fatal_error("surplus argument: %s\nUse \"%s -?\" for help\n",
+ argv[i], argv[0]);
+ }
+ }
+#undef ARGC_VALUE_CHECK
+#if SQLITE_VERSION_NUMBER>=3006001
+ if( nHeap>0 ){
+ pHeap = malloc( nHeap );
+ if( pHeap==0 ) fatal_error("cannot allocate %d-byte heap\n", nHeap);
+ rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, mnHeap);
+ if( rc ) fatal_error("heap configuration failed: %d\n", rc);
+ }
+ if( doPCache ){
+ if( nPCache>0 && szPCache>0 ){
+ pPCache = malloc( nPCache*(sqlite3_int64)szPCache );
+ if( pPCache==0 ) fatal_error("cannot allocate %lld-byte pcache\n",
+ nPCache*(sqlite3_int64)szPCache);
+ }
+ rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, pPCache, szPCache, nPCache);
+ if( rc ) fatal_error("pcache configuration failed: %d\n", rc);
+ }
+ if( nLook>=0 ){
+ sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0);
+ }
+#endif
+ sqlite3_initialize();
+
+ if( zDbName!=0 ){
+ sqlite3_vfs *pVfs = sqlite3_vfs_find(zVfs);
+ /* For some VFSes, e.g. opfs, unlink() is not sufficient. Use the
+ ** selected (or default) VFS's xDelete method to delete the
+ ** database. This is specifically important for the "opfs" VFS
+ ** when running from a WASM build of speedtest1, so that the db
+ ** can be cleaned up properly. For historical compatibility, we'll
+ ** also simply unlink(). */
+ if( pVfs!=0 ){
+ pVfs->xDelete(pVfs, zDbName, 1);
+ }
+ unlink(zDbName);
+ }
+
+ /* Open the database and the input file */
+ if( sqlite3_open_v2(memDb ? ":memory:" : zDbName, &g.db,
+ openFlags, zVfs) ){
+ fatal_error("Cannot open database file: %s\n", zDbName);
+ }
+#if SQLITE_VERSION_NUMBER>=3006001
+ if( nLook>0 && szLook>0 ){
+ pLook = malloc( nLook*szLook );
+ rc = sqlite3_db_config(g.db, SQLITE_DBCONFIG_LOOKASIDE,pLook,szLook,nLook);
+ if( rc ) fatal_error("lookaside configuration failed: %d\n", rc);
+ }
+#endif
+ if( g.nReserve>0 ){
+ sqlite3_file_control(g.db, 0, SQLITE_FCNTL_RESERVE_BYTES, &g.nReserve);
+ }
+
+ /* Set database connection options */
+ sqlite3_create_function(g.db, "random", 0, SQLITE_UTF8, 0, randomFunc, 0, 0);
+#ifndef SQLITE_OMIT_DEPRECATED
+ if( doTrace ) sqlite3_trace(g.db, traceCallback, 0);
+#endif
+ if( memDb>0 ){
+ speedtest1_exec("PRAGMA temp_store=memory");
+ }
+ if( mmapSize>0 ){
+ speedtest1_exec("PRAGMA mmap_size=%d", mmapSize);
+ }
+ speedtest1_exec("PRAGMA threads=%d", nThread);
+ if( zKey ){
+ speedtest1_exec("PRAGMA key('%s')", zKey);
+ }
+ if( zEncoding ){
+ speedtest1_exec("PRAGMA encoding=%s", zEncoding);
+ }
+ if( doAutovac ){
+ speedtest1_exec("PRAGMA auto_vacuum=FULL");
+ }else if( doIncrvac ){
+ speedtest1_exec("PRAGMA auto_vacuum=INCREMENTAL");
+ }
+ if( pageSize ){
+ speedtest1_exec("PRAGMA page_size=%d", pageSize);
+ }
+ if( cacheSize ){
+ speedtest1_exec("PRAGMA cache_size=%d", cacheSize);
+ }
+ if( noSync ) speedtest1_exec("PRAGMA synchronous=OFF");
+ if( doExclusive ){
+ speedtest1_exec("PRAGMA locking_mode=EXCLUSIVE");
+ }
+ if( zJMode ){
+ speedtest1_exec("PRAGMA journal_mode=%s", zJMode);
+ }
+
+ if( g.bExplain ) printf(".explain\n.echo on\n");
+ do{
+ char *zThisTest = zTSet;
+ char *zComma = strchr(zThisTest,',');
+ if( zComma ){
+ *zComma = 0;
+ zTSet = zComma+1;
+ }else{
+ zTSet = "";
+ }
+ if( g.iTotal>0 || zComma!=0 ){
+ printf(" Begin testset \"%s\"\n", zThisTest);
+ }
+ if( strcmp(zThisTest,"main")==0 ){
+ testset_main();
+ }else if( strcmp(zThisTest,"debug1")==0 ){
+ testset_debug1();
+ }else if( strcmp(zThisTest,"orm")==0 ){
+ testset_orm();
+ }else if( strcmp(zThisTest,"cte")==0 ){
+ testset_cte();
+ }else if( strcmp(zThisTest,"fp")==0 ){
+ testset_fp();
+ }else if( strcmp(zThisTest,"trigger")==0 ){
+ testset_trigger();
+ }else if( strcmp(zThisTest,"rtree")==0 ){
+#ifdef SQLITE_ENABLE_RTREE
+ testset_rtree(6, 147);
+#else
+ fatal_error("compile with -DSQLITE_ENABLE_RTREE to enable "
+ "the R-Tree tests\n");
+#endif
+ }else{
+ fatal_error("unknown testset: \"%s\"\n"
+ "Choices: cte debug1 fp main orm rtree trigger\n",
+ zThisTest);
+ }
+ if( zTSet[0] ){
+ char *zSql, *zObj;
+ speedtest1_begin_test(999, "Reset the database");
+ while( 1 ){
+ zObj = speedtest1_once(
+ "SELECT name FROM main.sqlite_master"
+ " WHERE sql LIKE 'CREATE %%TABLE%%'");
+ if( zObj==0 ) break;
+ zSql = sqlite3_mprintf("DROP TABLE main.\"%w\"", zObj);
+ speedtest1_exec(zSql);
+ sqlite3_free(zSql);
+ sqlite3_free(zObj);
+ }
+ while( 1 ){
+ zObj = speedtest1_once(
+ "SELECT name FROM temp.sqlite_master"
+ " WHERE sql LIKE 'CREATE %%TABLE%%'");
+ if( zObj==0 ) break;
+ zSql = sqlite3_mprintf("DROP TABLE main.\"%w\"", zObj);
+ speedtest1_exec(zSql);
+ sqlite3_free(zSql);
+ sqlite3_free(zObj);
+ }
+ speedtest1_end_test();
+ }
+ }while( zTSet[0] );
+ speedtest1_final();
+
+ if( showStats ){
+ sqlite3_exec(g.db, "PRAGMA compile_options", xCompileOptions, 0, 0);
+ }
+
+ /* Database connection statistics printed after both prepared statements
+ ** have been finalized */
+#if SQLITE_VERSION_NUMBER>=3007009
+ if( showStats ){
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHi, 0);
+ printf("-- Lookaside Slots Used: %d (max %d)\n", iCur,iHi);
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHi, 0);
+ printf("-- Successful lookasides: %d\n", iHi);
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur,&iHi,0);
+ printf("-- Lookaside size faults: %d\n", iHi);
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur,&iHi,0);
+ printf("-- Lookaside OOM faults: %d\n", iHi);
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHi, 0);
+ printf("-- Pager Heap Usage: %d bytes\n", iCur);
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHi, 1);
+ printf("-- Page cache hits: %d\n", iCur);
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHi, 1);
+ printf("-- Page cache misses: %d\n", iCur);
+#if SQLITE_VERSION_NUMBER>=3007012
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHi, 1);
+ printf("-- Page cache writes: %d\n", iCur);
+#endif
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHi, 0);
+ printf("-- Schema Heap Usage: %d bytes\n", iCur);
+ sqlite3_db_status(g.db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHi, 0);
+ printf("-- Statement Heap Usage: %d bytes\n", iCur);
+ }
+#endif
+
+ sqlite3_close(g.db);
+
+#if SQLITE_VERSION_NUMBER>=3006001
+ /* Global memory usage statistics printed after the database connection
+ ** has closed. Memory usage should be zero at this point. */
+ if( showStats ){
+ sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHi, 0);
+ printf("-- Memory Used (bytes): %d (max %d)\n", iCur,iHi);
+#if SQLITE_VERSION_NUMBER>=3007000
+ sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHi, 0);
+ printf("-- Outstanding Allocations: %d (max %d)\n", iCur,iHi);
+#endif
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHi, 0);
+ printf("-- Pcache Overflow Bytes: %d (max %d)\n", iCur,iHi);
+ sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHi, 0);
+ printf("-- Largest Allocation: %d bytes\n",iHi);
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHi, 0);
+ printf("-- Largest Pcache Allocation: %d bytes\n",iHi);
+ }
+#endif
+
+#ifdef __linux__
+ if( showStats ){
+ displayLinuxIoStats(stdout);
+ }
+#endif
+ if( g.pScript ){
+ fclose(g.pScript);
+ }
+
+ /* Release memory */
+ free( pLook );
+ free( pPCache );
+ free( pHeap );
+ return 0;
+}
+
+#ifdef SQLITE_SPEEDTEST1_WASM
+/*
+** A workaround for some inconsistent behaviour with how
+** main() does (or does not) get exported to WASM.
+*/
+int wasm_main(int argc, char **argv){
+ return main(argc, argv);
+}
+#endif
diff --git a/test/spellfix.test b/test/spellfix.test
new file mode 100644
index 0000000..68bcfd5
--- /dev/null
+++ b/test/spellfix.test
@@ -0,0 +1,405 @@
+# 2012 July 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix spellfix
+
+ifcapable !vtab { finish_test ; return }
+
+load_static_extension db spellfix nextchar
+
+set vocab {
+rabbi rabbit rabbits rabble rabid rabies raccoon raccoons race raced racer
+racers races racetrack racial racially racing rack racked racket racketeer
+racketeering racketeers rackets racking racks radar radars radial radially
+radian radiance radiant radiantly radiate radiated radiates radiating radiation
+radiations radiator radiators radical radically radicals radices radii radio
+radioactive radioastronomy radioed radiography radioing radiology radios radish
+radishes radium radius radix radon raft rafter rafters rafts rag rage raged
+rages ragged raggedly raggedness raging rags ragweed raid raided raider raiders
+raiding raids rail railed railer railers railing railroad railroaded railroader
+railroaders railroading railroads rails railway railways raiment rain rainbow
+raincoat raincoats raindrop raindrops rained rainfall rainier rainiest raining
+rains rainstorm rainy raise raised raiser raisers raises raisin raising rake
+raked rakes raking rallied rallies rally rallying ram ramble rambler rambles
+rambling ramblings ramification ramifications ramp rampage rampant rampart
+ramps ramrod rams ran ranch ranched rancher ranchers ranches ranching rancid
+random randomization randomize randomized randomizes randomly randomness randy
+rang range ranged rangeland ranger rangers ranges ranging rangy rank ranked
+ranker rankers rankest ranking rankings rankle rankly rankness ranks ransack
+ransacked ransacking ransacks ransom ransomer ransoming ransoms rant ranted
+ranter ranters ranting rants rap rapacious rape raped raper rapes rapid
+rapidity rapidly rapids rapier raping rapport rapprochement raps rapt raptly
+rapture raptures rapturous rare rarely rareness rarer rarest rarity rascal
+rascally rascals rash rasher rashly rashness rasp raspberry rasped rasping
+rasps raster rat rate rated rater raters rates rather ratification ratified
+ratifies ratify ratifying rating ratings ratio ration rational rationale
+rationales rationalities rationality rationalization rationalizations
+rationalize rationalized rationalizes rationalizing rationally rationals
+rationing rations ratios rats rattle rattled rattler rattlers rattles
+rattlesnake rattlesnakes rattling raucous ravage ravaged ravager ravagers
+ravages ravaging rave raved raven ravening ravenous ravenously ravens raves
+ravine ravines raving ravings raw rawer rawest rawly rawness ray rays raze
+razor razors re reabbreviate reabbreviated reabbreviates reabbreviating reach
+reachability reachable reachably reached reacher reaches reaching reacquired
+react reacted reacting reaction reactionaries reactionary reactions reactivate
+reactivated reactivates reactivating reactivation reactive reactively
+reactivity reactor reactors reacts read readability readable reader readers
+readied readier readies readiest readily readiness reading readings readjusted
+readout readouts reads ready readying real realest realign realigned realigning
+realigns realism realist realistic realistically realists realities reality
+}
+
+do_test 1.1 {
+ execsql { CREATE VIRTUAL TABLE t1 USING spellfix1 }
+ foreach word $vocab {
+ execsql { INSERT INTO t1(word) VALUES($word) }
+ }
+} {}
+
+foreach {tn word res} {
+ 1 raxpi* {rasping 5 rasped 5 ragweed 5 raspberry 6 rasp 4}
+ 2 ril* {rail 4 railed 4 railer 4 railers 4 railing 4}
+ 3 rilis* {realism 6 realist 6 realistic 6 realistically 6 realists 6}
+ 4 reail* {real 3 realest 3 realign 3 realigned 3 realigning 3}
+ 5 ras* {rascal 3 rascally 3 rascals 3 rash 3 rasher 3}
+ 6 realistss* {realists 8 realigns 8 realistic 9 realistically 9 realest 7}
+ 7 realistss {realists 8 realist 7 realigns 8 realistic 9 realest 7}
+ 8 rllation* {realities 9 reality 7 rallied 7 railed 4}
+ 9 renstom* {rainstorm 8 ransom 6 ransomer 6 ransoming 6 ransoms 6}
+} {
+ do_execsql_test 1.2.$tn {
+ SELECT word, matchlen FROM t1 WHERE word MATCH $word
+ ORDER BY score, word LIMIT 5
+ } $res
+}
+
+# Tests of the next_char function.
+#
+do_test 1.10 {
+ db eval {
+ CREATE TABLE vocab(w TEXT PRIMARY KEY);
+ INSERT INTO vocab SELECT word FROM t1;
+ }
+} {}
+do_execsql_test 1.11 {
+ SELECT next_char('re','vocab','w');
+} {a}
+do_execsql_test 1.11sub {
+ SELECT next_char('re','(SELECT w AS x FROM vocab)','x');
+} {a}
+do_execsql_test 1.12 {
+ SELECT next_char('r','vocab','w');
+} {ae}
+do_execsql_test 1.13 {
+ SELECT next_char('','vocab','w');
+} {r}
+do_test 1.14 {
+ catchsql {SELECT next_char('','xyzzy','a')}
+} {1 {no such table: xyzzy}}
+
+do_execsql_test 1.20 {
+ CREATE TABLE vocab2(w TEXT);
+ CREATE INDEX vocab2w ON vocab2(w COLLATE nocase);
+ INSERT INTO vocab2 VALUES('abc'), ('ABD'), ('aBe'), ('AbF');
+ SELECT next_char('ab', 'vocab2', 'w', null, 'nocase');
+} {cDeF}
+do_execsql_test 1.21 {
+ SELECT next_char('ab','vocab2','w',null,null);
+} {c}
+do_execsql_test 1.22 {
+ SELECT next_char('AB','vocab2','w',null,'NOCASE');
+} {cDeF}
+do_execsql_test 1.23 {
+ SELECT next_char('ab','vocab2','w',null,'binary');
+} {c}
+
+do_execsql_test 1.30 {
+ SELECT rowid FROM t1 WHERE word='rabbit';
+} {2}
+do_execsql_test 1.31 {
+ UPDATE t1 SET rowid=2000 WHERE word='rabbit';
+ SELECT rowid FROM t1 WHERE word='rabbit';
+} {2000}
+do_execsql_test 1.32 {
+ INSERT INTO t1(rowid, word) VALUES(3000,'melody');
+ SELECT rowid, word, matchlen FROM t1 WHERE word MATCH 'melotti'
+ ORDER BY score LIMIT 3;
+} {3000 melody 6}
+do_test 1.33 {
+ catchsql {INSERT INTO t1(rowid, word) VALUES(3000,'garden');}
+} {1 {constraint failed}}
+
+do_execsql_test 2.1 {
+ CREATE VIRTUAL TABLE t2 USING spellfix1;
+ INSERT INTO t2 (word, soundslike) VALUES('school', 'skuul');
+ INSERT INTO t2 (word, soundslike) VALUES('psalm', 'sarm');
+ SELECT word, matchlen FROM t2 WHERE word MATCH 'sar*' LIMIT 5;
+} {psalm 4}
+
+do_execsql_test 2.2 {
+ SELECT word, matchlen FROM t2 WHERE word MATCH 'skol*' LIMIT 5;
+} {school 6}
+
+set vocab {
+kangaroo kanji kappa karate keel keeled keeling keels keen keener keenest
+keenly keenness keep keeper keepers keeping keeps ken kennel kennels kept
+kerchief kerchiefs kern kernel kernels kerosene ketchup kettle
+kettles key keyboard keyboards keyed keyhole keying keynote keypad keypads keys
+keystroke keystrokes keyword keywords kick kicked kicker kickers kicking
+kickoff kicks kid kidded kiddie kidding kidnap kidnapper kidnappers kidnapping
+kidnappings kidnaps kidney kidneys kids kill killed killer killers killing
+killingly killings killjoy kills kilobit kilobits kiloblock kilobyte kilobytes
+kilogram kilograms kilohertz kilohm kilojoule kilometer kilometers kiloton
+kilovolt kilowatt kiloword kimono kin kind kinder kindergarten kindest
+kindhearted kindle kindled kindles kindling kindly kindness kindred kinds
+kinetic king kingdom kingdoms kingly kingpin kings kink kinky kinship kinsman
+kiosk kiss kissed kisser kissers kisses kissing kit kitchen kitchenette
+kitchens kite kited kites kiting kits kitten kittenish kittens kitty klaxon
+kludge kludges klystron knack knapsack knapsacks knave knaves knead kneads knee
+kneecap kneed kneeing kneel kneeled kneeling kneels knees knell knells knelt
+knew knife knifed knifes knifing knight knighted knighthood knighting knightly
+knights knit knits knives knob knobs knock knockdown knocked knocker knockers
+knocking knockout knocks knoll knolls knot knots knotted knotting know knowable
+knower knowhow knowing knowingly knowledge knowledgeable known knows knuckle
+knuckled knuckles koala kosher kudo
+}
+
+do_execsql_test 3.1 {
+ CREATE TABLE costs(iLang, cFrom, cTo, iCost);
+ INSERT INTO costs VALUES(0, 'a', 'e', 1);
+ INSERT INTO costs VALUES(0, 'e', 'i', 1);
+ INSERT INTO costs VALUES(0, 'i', 'o', 1);
+ INSERT INTO costs VALUES(0, 'o', 'u', 1);
+ INSERT INTO costs VALUES(0, 'u', 'a', 1);
+ CREATE VIRTUAL TABLE t3 USING spellfix1(edit_cost_table=costs);
+}
+
+do_test 3.2 {
+ foreach w $vocab {
+ execsql { INSERT INTO t3(word) VALUES($w) }
+ }
+} {}
+
+foreach {tn word res} {
+ 1 kos* {kosher 3 kiosk 4 kudo 2 kiss 3 kissed 3}
+ 2 kellj* {killjoy 5 kill 4 killed 4 killer 4 killers 4}
+ 3 kellj {kill 4 kills 5 killjoy 7 keel 4 killed 6}
+} {
+ do_execsql_test 3.2.$tn {
+ SELECT word, matchlen FROM t3 WHERE word MATCH $word
+ ORDER BY score, word LIMIT 5
+ } $res
+}
+
+do_execsql_test 4.0 {
+ INSERT INTO t3(command) VALUES('edit_cost_table=NULL');
+}
+foreach {tn word res} {
+ 1 kosher {kosher 0 kisser 51 kissers 76 kissed 126 kisses 126}
+ 2 kellj {keels 60 killjoy 68 kills 80 keel 120 kill 125}
+ 3 kashar {kosher 80 kisser 91 kissers 116 kissed 166 kisses 166}
+} {
+ do_execsql_test 4.1.$tn {
+ SELECT word, distance FROM t3 WHERE word MATCH $word
+ ORDER BY score, word LIMIT 5
+ } $res
+}
+do_execsql_test 5.0 {
+ CREATE TABLE costs2(iLang, cFrom, cTo, iCost);
+ INSERT INTO costs2 VALUES(0, 'a', 'o', 1);
+ INSERT INTO costs2 VALUES(0, 'e', 'o', 4);
+ INSERT INTO costs2 VALUES(0, 'i', 'o', 8);
+ INSERT INTO costs2 VALUES(0, 'u', 'o', 16);
+ INSERT INTO t3(command) VALUES('edit_cost_table="costs2"');
+}
+
+foreach {tn word res} {
+ 1 kasher {kosher 1}
+ 2 kesher {kosher 4}
+ 3 kisher {kosher 8}
+ 4 kosher {kosher 0}
+ 5 kusher {kosher 16}
+} {
+ do_execsql_test 5.1.$tn {
+ SELECT word, distance FROM t3 WHERE word MATCH $word
+ ORDER BY score, word LIMIT 1
+ } $res
+}
+
+#-------------------------------------------------------------------------
+# Try some queries by rowid.
+#
+do_execsql_test 6.1.1 {
+ SELECT word FROM t3 WHERE rowid = 10;
+} {keener}
+do_execsql_test 6.1.2 {
+ SELECT word, distance FROM t3 WHERE rowid = 10;
+} {keener {}}
+do_execsql_test 6.1.3 {
+ SELECT word, distance FROM t3 WHERE rowid = 10 AND word MATCH 'kiiner';
+} {keener 300}
+
+ifcapable trace {
+ proc trace_callback {sql} {
+ if {[string range $sql 0 2] == "-- "} {
+ lappend ::trace [string range $sql 3 end]
+ }
+ }
+
+ proc do_tracesql_test {tn sql {res {}}} {
+ set ::trace [list]
+ uplevel [list do_test $tn [subst -nocommands {
+ set vals [execsql {$sql}]
+ concat [set vals] [set ::trace]
+ }] [list {*}$res]]
+ }
+
+ db trace trace_callback
+ do_tracesql_test 6.2.1 {
+ SELECT word FROM t3 WHERE rowid = 10;
+ } {keener
+ {SELECT word, rank, NULL, langid, id FROM "main"."t3_vocab" WHERE rowid=?}
+ }
+ do_tracesql_test 6.2.2 {
+ SELECT word, distance FROM t3 WHERE rowid = 10;
+ } {keener {}
+ {SELECT word, rank, NULL, langid, id FROM "main"."t3_vocab" WHERE rowid=?}
+ }
+ do_tracesql_test 6.2.3 {
+ SELECT word, distance FROM t3 WHERE rowid = 10 AND word MATCH 'kiiner';
+ } {keener 300
+ {SELECT id, word, rank, coalesce(k1,word) FROM "main"."t3_vocab" WHERE langid=0 AND k2>=?1 AND k2<?2}
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test that the spellfix1 table supports conflict handling (OR REPLACE
+# and so on).
+#
+do_execsql_test 7.1 {
+ CREATE VIRTUAL TABLE t4 USING spellfix1;
+ PRAGMA table_info = t4;
+} {
+ 0 word {} 0 {} 0
+ 1 rank {} 0 {} 0
+ 2 distance {} 0 {} 0
+ 3 langid {} 0 {} 0
+ 4 score {} 0 {} 0
+ 5 matchlen {} 0 {} 0
+}
+
+do_execsql_test 7.2.1 {
+ INSERT INTO t4(rowid, word) VALUES(1, 'Archilles');
+ INSERT INTO t4(rowid, word) VALUES(2, 'Pluto');
+ INSERT INTO t4(rowid, word) VALUES(3, 'Atrides');
+ INSERT OR REPLACE INTO t4(rowid, word) VALUES(2, 'Apollo');
+ SELECT rowid, word FROM t4;
+} {
+ 1 Archilles 2 Apollo 3 Atrides
+}
+do_catchsql_test 7.2.2 {
+ INSERT OR ABORT INTO t4(rowid, word) VALUES(1, 'Leto');
+} {1 {constraint failed}}
+do_catchsql_test 7.2.3 {
+ INSERT OR ROLLBACK INTO t4(rowid, word) VALUES(3, 'Zeus');
+} {1 {constraint failed}}
+do_catchsql_test 7.2.4 {
+ INSERT OR FAIL INTO t4(rowid, word) VALUES(3, 'Zeus');
+} {1 {constraint failed}}
+do_execsql_test 7.2.5 {
+ INSERT OR IGNORE INTO t4(rowid, word) VALUES(3, 'Zeus');
+ SELECT rowid, word FROM t4;
+} {
+ 1 Archilles 2 Apollo 3 Atrides
+}
+
+do_execsql_test 7.3.1 {
+ UPDATE OR REPLACE t4 SET rowid=3 WHERE rowid=1;
+ SELECT rowid, word FROM t4;
+} {2 Apollo 3 Archilles}
+do_catchsql_test 7.3.2 {
+ UPDATE OR ABORT t4 SET rowid=3 WHERE rowid=2;
+} {1 {constraint failed}}
+do_catchsql_test 7.3.3 {
+ UPDATE OR ROLLBACK t4 SET rowid=3 WHERE rowid=2;
+} {1 {constraint failed}}
+do_catchsql_test 7.3.4 {
+ UPDATE OR FAIL t4 SET rowid=3 WHERE rowid=2;
+} {1 {constraint failed}}
+do_execsql_test 7.3.5 {
+ UPDATE OR IGNORE t4 SET rowid=3 WHERE rowid=2;
+ SELECT rowid, word FROM t4;
+} {2 Apollo 3 Archilles}
+
+do_execsql_test 7.4.1 {
+ DELETE FROM t4;
+ INSERT INTO t4(rowid, word) VALUES(10, 'Agamemnon');
+ INSERT INTO t4(rowid, word) VALUES(20, 'Patroclus');
+ INSERT INTO t4(rowid, word) VALUES(30, 'Chryses');
+
+ CREATE TABLE t5(i, w);
+ INSERT INTO t5 VALUES(5, 'Poseidon');
+ INSERT INTO t5 VALUES(20, 'Chronos');
+ INSERT INTO t5 VALUES(30, 'Hera');
+}
+
+db_save_and_close
+foreach {tn conflict err bRollback res} {
+ 0 "" {1 {constraint failed}} 0
+ {10 Agamemnon 20 Patroclus 30 Chryses}
+ 1 "OR REPLACE" {0 {}} 0
+ {5 Poseidon 10 Agamemnon 20 Chronos 30 Hera}
+ 2 "OR ABORT" {1 {constraint failed}} 0
+ {10 Agamemnon 20 Patroclus 30 Chryses}
+ 3 "OR ROLLBACK" {1 {constraint failed}} 1
+ {10 Agamemnon 20 Patroclus 30 Chryses}
+ 5 "OR IGNORE" {0 {}} 0
+ {5 Poseidon 10 Agamemnon 20 Patroclus 30 Chryses}
+} {
+ db_restore_and_reopen
+ load_static_extension db spellfix nextchar
+
+ execsql BEGIN
+ set sql "INSERT $conflict INTO t4(rowid, word) SELECT i, w FROM t5"
+ do_catchsql_test 7.4.2.$tn.1 $sql $err
+ do_execsql_test 7.4.2.$tn.2 { SELECT rowid, word FROM t4 } $res
+
+ do_test 7.4.2.$tn.3 { sqlite3_get_autocommit db } $bRollback
+ catchsql ROLLBACK
+}
+
+foreach {tn conflict err bRollback res} {
+ 0 "" {1 {constraint failed}} 0
+ {10 Agamemnon 20 Patroclus 30 Chryses}
+ 1 "OR REPLACE" {0 {}} 0
+ {15 Agamemnon 45 Chryses}
+ 2 "OR ABORT" {1 {constraint failed}} 0
+ {10 Agamemnon 20 Patroclus 30 Chryses}
+ 3 "OR ROLLBACK" {1 {constraint failed}} 1
+ {10 Agamemnon 20 Patroclus 30 Chryses}
+ 5 "OR IGNORE" {0 {}} 0
+ {15 Agamemnon 20 Patroclus 45 Chryses}
+} {
+ db_restore_and_reopen
+ load_static_extension db spellfix nextchar
+
+ execsql BEGIN
+ set sql "UPDATE $conflict t4 SET rowid=rowid + (rowid/2)"
+ do_catchsql_test 7.5.2.$tn.1 $sql $err
+ do_execsql_test 7.5.2.$tn.2 { SELECT rowid, word FROM t4 } $res
+ do_test 7.5.2.$tn.3 { sqlite3_get_autocommit db } $bRollback
+ catchsql ROLLBACK
+}
+
+finish_test
diff --git a/test/spellfix2.test b/test/spellfix2.test
new file mode 100644
index 0000000..d1a1328
--- /dev/null
+++ b/test/spellfix2.test
@@ -0,0 +1,118 @@
+# 2012 July 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix spellfix2
+
+ifcapable !vtab { finish_test ; return }
+load_static_extension db spellfix nextchar
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE demo USING spellfix1;
+ INSERT INTO demo(word) VALUES ('amsterdam');
+ INSERT INTO demo(word) VALUES ('amsterdammetje');
+ INSERT INTO demo(word) VALUES ('amsterdamania');
+ INSERT INTO demo(word) VALUES ('amsterdamweg');
+ INSERT INTO demo(word) VALUES ('amsterdamsestraat');
+ INSERT INTO demo(word) VALUES ('amsterdamlaan');
+}
+
+do_execsql_test 1.1 {
+ SELECT word, distance, matchlen FROM demo
+ WHERE word MATCH 'amstedam*' AND top=3
+ ORDER BY +word;
+} {
+ amsterdam 100 9
+ amsterdamania 100 9
+ amsterdammetje 100 9
+}
+
+do_execsql_test 1.2 {
+ SELECT word, distance, matchlen FROM demo WHERE
+ word MATCH 'amstedam*' AND top=3 AND distance <= 100
+ ORDER BY +word;
+} {
+ amsterdam 100 9
+ amsterdamania 100 9
+ amsterdammetje 100 9
+}
+
+do_execsql_test 1.3 {
+ SELECT word, distance, matchlen FROM demo WHERE
+ word MATCH 'amstedam*' AND distance <= 100
+ ORDER BY +word;
+} {
+ amsterdam 100 9
+ amsterdamania 100 9
+ amsterdamlaan 100 9
+ amsterdammetje 100 9
+ amsterdamsestraat 100 9
+ amsterdamweg 100 9
+}
+
+do_test 1.4 {
+ foreach l {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} {
+ execsql { INSERT INTO demo(word) VALUES ('amsterdam' || $l) }
+ }
+} {}
+
+do_execsql_test 1.5 {
+ SELECT count(*) FROM demo WHERE word MATCH 'amstedam*' AND distance <= 100;
+ SELECT count(*) FROM demo
+ WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20;
+} {
+ 32 20
+}
+
+do_execsql_test 1.6 {
+ SELECT word, distance, matchlen FROM demo
+ WHERE word MATCH 'amstedam*' AND distance <= 100
+ ORDER BY distance, word;
+} {
+ amsterdam 100 9 amsterdama 100 9
+ amsterdamania 100 9 amsterdamb 100 9
+ amsterdamc 100 9 amsterdamd 100 9
+ amsterdame 100 9 amsterdamf 100 9
+ amsterdamg 100 9 amsterdamh 100 9
+ amsterdami 100 9 amsterdamj 100 9
+ amsterdamk 100 9 amsterdaml 100 9
+ amsterdamlaan 100 9 amsterdamm 100 9
+ amsterdammetje 100 9 amsterdamn 100 9
+ amsterdamo 100 9 amsterdamp 100 9
+ amsterdamq 100 9 amsterdamr 100 9
+ amsterdams 100 9 amsterdamsestraat 100 9
+ amsterdamt 100 9 amsterdamu 100 9
+ amsterdamv 100 9 amsterdamw 100 9
+ amsterdamweg 100 9 amsterdamx 100 9
+ amsterdamy 100 9 amsterdamz 100 9
+}
+
+do_execsql_test 1.7 {
+ SELECT word, distance, matchlen FROM demo
+ WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20
+ ORDER BY distance, word;
+} {
+ amsterdam 100 9 amsterdama 100 9
+ amsterdamania 100 9 amsterdamb 100 9
+ amsterdamc 100 9 amsterdame 100 9
+ amsterdamf 100 9 amsterdamg 100 9
+ amsterdamh 100 9 amsterdami 100 9
+ amsterdamm 100 9 amsterdammetje 100 9
+ amsterdamn 100 9 amsterdamo 100 9
+ amsterdamp 100 9 amsterdamu 100 9
+ amsterdamv 100 9 amsterdamw 100 9
+ amsterdamweg 100 9 amsterdamy 100 9
+}
+
+
+finish_test
diff --git a/test/spellfix3.test b/test/spellfix3.test
new file mode 100644
index 0000000..e24ea31
--- /dev/null
+++ b/test/spellfix3.test
@@ -0,0 +1,52 @@
+# 2015-12-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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix spellfix3
+
+ifcapable !vtab { finish_test ; return }
+
+load_static_extension db spellfix
+
+do_execsql_test 100 {
+ SELECT spellfix1_scriptcode('And God said, “Let there be light”');
+} {215}
+do_execsql_test 110 {
+ SELECT spellfix1_scriptcode('Бог сказал: "Да будет свет"');
+} {220}
+do_execsql_test 120 {
+ SELECT spellfix1_scriptcode('και ειπεν ο θεος γενηθητω φως και εγενετο φως');
+} {200}
+do_execsql_test 130 {
+ SELECT spellfix1_scriptcode('וַיֹּ֥אמֶר אֱלֹהִ֖ים יְהִ֣י א֑וֹר וַֽיְהִי־אֽוֹר׃');
+} {125}
+do_execsql_test 140 {
+ SELECT spellfix1_scriptcode('فِي ذَلِكَ الوَقتِ، قالَ اللهُ: لِيَكُنْ نُورٌ. فَصَارَ نُورٌ.');
+} {160}
+do_execsql_test 200 {
+ SELECT spellfix1_scriptcode('+3.14159');
+} {215}
+do_execsql_test 210 {
+ SELECT spellfix1_scriptcode('And God said: "Да будет свет"');
+} {998}
+do_execsql_test 220 {
+ SELECT spellfix1_scriptcode('+3.14159 light');
+} {215}
+do_execsql_test 230 {
+ SELECT spellfix1_scriptcode('+3.14159 свет');
+} {220}
+do_execsql_test 240 {
+ SELECT spellfix1_scriptcode('וַיֹּ֥אמֶר +3.14159');
+} {125}
+
+finish_test
diff --git a/test/spellfix4.test b/test/spellfix4.test
new file mode 100644
index 0000000..caf6d51
--- /dev/null
+++ b/test/spellfix4.test
@@ -0,0 +1,353 @@
+# 2018-02-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 cases for the editdist3() function in the spellfix extension.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix spellfix4
+
+ifcapable !vtab { finish_test ; return }
+
+load_static_extension db spellfix
+
+do_execsql_test 100 {
+ CREATE TABLE cost1(iLang, cFrom, cTo, iCost);
+ INSERT INTO cost1 VALUES
+ (0, '', '?', 97),
+ (0, '?', '', 98),
+ (0, '?', '?', 99),
+ (0, 'm', 'n', 50),
+ (0, 'n', 'm', 50)
+ ;
+ SELECT editdist3('cost1');
+ SELECT editdist3('anchor','amchor');
+} {{} 50}
+do_execsql_test 110 {
+ SELECT editdist3('anchor','anchoxr');
+} {97}
+do_execsql_test 111 {
+ SELECT editdist3('anchor','xanchor');
+} {97}
+do_execsql_test 112 {
+ SELECT editdist3('anchor','anchorx');
+} {97}
+do_execsql_test 120 {
+ SELECT editdist3('anchor','anchr');
+} {98}
+do_execsql_test 121 {
+ SELECT editdist3('anchor','ancho');
+} {98}
+do_execsql_test 122 {
+ SELECT editdist3('anchor','nchor');
+} {98}
+do_execsql_test 130 {
+ SELECT editdist3('anchor','anchur');
+} {99}
+do_execsql_test 131 {
+ SELECT editdist3('anchor','onchor');
+} {99}
+do_execsql_test 132 {
+ SELECT editdist3('anchor','anchot');
+} {99}
+do_execsql_test 140 {
+ SELECT editdist3('anchor','omchor');
+} {149}
+
+do_execsql_test 200 {
+ INSERT INTO cost1 VALUES
+ (0, 'a', 'ä', 5),
+ (0, 'ss', 'ß', 8)
+ ;
+ SELECT editdist3('cost1');
+ SELECT editdist3('strasse','straße');
+ SELECT editdist3('straße','strasse');
+} {{} 8 196}
+do_execsql_test 210 {
+ SELECT editdist3('baume','bäume');
+} {5}
+do_execsql_test 220 {
+ SELECT editdist3('baum','bäume');
+} {102}
+do_execsql_test 230 {
+ INSERT INTO cost1 VALUES
+ (0, 'ä', 'a', 5),
+ (0, 'ß', 'ss', 8)
+ ;
+ SELECT editdist3('cost1');
+ SELECT editdist3('strasse','straße');
+ SELECT editdist3('straße','strasse');
+} {{} 8 8}
+
+do_execsql_test 300 {
+ DELETE FROM cost1;
+ INSERT INTO cost1 VALUES
+ (0, '', '?', 97),
+ (0, '?', '', 98),
+ (0, '?', '?', 99),
+ (0, 'a', 'e', 50),
+ (0, 'a', 'i', 70),
+ (0, 'a', 'o', 75),
+ (0, 'a', 'u', 81),
+ (0, 'e', 'a', 50),
+ (0, 'e', 'i', 52),
+ (0, 'e', 'o', 72),
+ (0, 'e', 'u', 82),
+ (0, 'i', 'a', 70),
+ (0, 'i', 'e', 52),
+ (0, 'i', 'o', 75),
+ (0, 'i', 'u', 83),
+ (0, 'o', 'a', 75),
+ (0, 'o', 'e', 72),
+ (0, 'o', 'i', 75),
+ (0, 'o', 'u', 40),
+ (0, 'u', 'a', 81),
+ (0, 'u', 'e', 82),
+ (0, 'u', 'i', 83),
+ (0, 'u', 'o', 40),
+ (0, 'm', 'n', 45),
+ (0, 'n', 'm', 45)
+ ;
+ CREATE TABLE words(x TEXT);
+ INSERT INTO words VALUES
+ ('abraham'),
+ ('action'),
+ ('africa'),
+ ('aladdin'),
+ ('alert'),
+ ('alien'),
+ ('amazon'),
+ ('analog'),
+ ('animal'),
+ ('apollo'),
+ ('archive'),
+ ('arnold'),
+ ('aspirin'),
+ ('august'),
+ ('average'),
+ ('bahama'),
+ ('bambino'),
+ ('barcode'),
+ ('bazooka'),
+ ('belgium'),
+ ('between'),
+ ('biology'),
+ ('blonde'),
+ ('border'),
+ ('brave'),
+ ('british'),
+ ('bucket'),
+ ('button'),
+ ('caesar'),
+ ('camilla'),
+ ('cannon'),
+ ('caramel'),
+ ('carpet'),
+ ('catalog'),
+ ('century'),
+ ('chaos'),
+ ('chef'),
+ ('china'),
+ ('circus'),
+ ('classic'),
+ ('clinic'),
+ ('coconut'),
+ ('combine'),
+ ('complex'),
+ ('congo'),
+ ('convert'),
+ ('cosmos'),
+ ('crack'),
+ ('crown'),
+ ('cyclone'),
+ ('deal'),
+ ('delete'),
+ ('denver'),
+ ('detail'),
+ ('diana'),
+ ('direct'),
+ ('dolby'),
+ ('double'),
+ ('dublin'),
+ ('echo'),
+ ('edition'),
+ ('electra'),
+ ('emotion'),
+ ('enjoy'),
+ ('escape'),
+ ('everest'),
+ ('exile'),
+ ('express'),
+ ('family'),
+ ('ferrari'),
+ ('filter'),
+ ('fish'),
+ ('florida'),
+ ('ford'),
+ ('forum'),
+ ('frank'),
+ ('frozen'),
+ ('gallery'),
+ ('garlic'),
+ ('geneva'),
+ ('gibson'),
+ ('gloria'),
+ ('gordon'),
+ ('gravity'),
+ ('ground'),
+ ('habitat'),
+ ('harlem'),
+ ('hazard'),
+ ('herbert'),
+ ('hobby'),
+ ('house'),
+ ('icon'),
+ ('immune'),
+ ('india'),
+ ('inside'),
+ ('isotope'),
+ ('jamaica'),
+ ('jazz'),
+ ('joker'),
+ ('juliet'),
+ ('jupiter'),
+ ('kevin'),
+ ('korea'),
+ ('latin'),
+ ('legal'),
+ ('lexicon'),
+ ('limbo'),
+ ('lithium'),
+ ('logo'),
+ ('lucas'),
+ ('madrid'),
+ ('major'),
+ ('manual'),
+ ('mars'),
+ ('maximum'),
+ ('medical'),
+ ('mental'),
+ ('meter'),
+ ('miguel'),
+ ('mimosa'),
+ ('miranda'),
+ ('modern'),
+ ('money'),
+ ('morgan'),
+ ('motor'),
+ ('mystic'),
+ ('nebula'),
+ ('network'),
+ ('nice'),
+ ('nitro'),
+ ('norway'),
+ ('nurse'),
+ ('octavia'),
+ ('olympic'),
+ ('opus'),
+ ('orient'),
+ ('othello'),
+ ('pacific'),
+ ('panama'),
+ ('paper'),
+ ('parking'),
+ ('pasta'),
+ ('paul'),
+ ('people'),
+ ('permit'),
+ ('phrase'),
+ ('pilgrim'),
+ ('planet'),
+ ('pocket'),
+ ('police'),
+ ('popular'),
+ ('prefer'),
+ ('presto'),
+ ('private'),
+ ('project'),
+ ('proxy'),
+ ('python'),
+ ('quota'),
+ ('rainbow'),
+ ('raymond'),
+ ('region'),
+ ('report'),
+ ('reward'),
+ ('risk'),
+ ('robot'),
+ ('rose'),
+ ('russian'),
+ ('sailor'),
+ ('salt'),
+ ('saturn'),
+ ('scorpio'),
+ ('second'),
+ ('seminar'),
+ ('shadow'),
+ ('shave'),
+ ('shock'),
+ ('silence'),
+ ('sinatra'),
+ ('sleep'),
+ ('social'),
+ ('sonata'),
+ ('spain'),
+ ('sphere'),
+ ('spray'),
+ ('state'),
+ ('stone'),
+ ('strong'),
+ ('sugar'),
+ ('supreme'),
+ ('swing'),
+ ('talent'),
+ ('telecom'),
+ ('thermos'),
+ ('tina'),
+ ('tommy'),
+ ('torso'),
+ ('trade'),
+ ('trick'),
+ ('tropic'),
+ ('turtle'),
+ ('uniform'),
+ ('user'),
+ ('vega'),
+ ('vertigo'),
+ ('village'),
+ ('visible'),
+ ('vocal'),
+ ('voyage'),
+ ('weekend'),
+ ('winter'),
+ ('year'),
+ ('zipper')
+ ;
+ SELECT editdist3('cost1');
+} {{}}
+do_execsql_test 310 {
+ SELECT editdist3(a.x,b.x), a.x, b.x
+ FROM words a, words b
+ WHERE a.x<b.x
+ ORDER BY 1, 2
+ LIMIT 20
+} {139 bucket pocket 144 meter motor 149 manual mental 169 crack trick 173 sinatra sonata 174 edition emotion 174 major motor 174 risk rose 174 state stone 194 deal detail 196 alert talent 196 analog catalog 196 deal legal 196 ford forum 196 risk trick 196 stone strong 197 china tina 197 congo logo 197 diana tina 197 florida gloria}
+do_execsql_test 320 {
+ SELECT md5sum(ed||'/'||sx||'/'||sy||',') FROM (
+ SELECT editdist3(a.x,b.x) AS ed, a.x AS sx, b.x AS sy
+ FROM words a, words b
+ WHERE a.x<b.x
+ ORDER BY 1, 2
+ )
+} {69d0a31872203a775e19325ea98cd053}
+
+finish_test
diff --git a/test/sqldiff1.test b/test/sqldiff1.test
new file mode 100644
index 0000000..4ea5efb
--- /dev/null
+++ b/test/sqldiff1.test
@@ -0,0 +1,66 @@
+# 2015-05-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.
+#
+#***********************************************************************
+#
+# Quick tests for the sqldiff tool
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set PROG [test_find_sqldiff]
+
+db close
+forcedelete test.db test2.db
+sqlite3 db test.db
+
+do_test sqldiff-1.0 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID;
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b) SELECT x, printf('abc-%d-xyz',x) FROM c;
+ INSERT INTO t2(a,b) SELECT a, b FROM t1;
+ }
+ db backup test2.db
+ db eval {
+ ATTACH 'test2.db' AS x2;
+ DELETE FROM x2.t1 WHERE a=49;
+ DELETE FROM x2.t2 WHERE a=48;
+ INSERT INTO x2.t1(a,b) VALUES(1234,'hello');
+ INSERT INTO x2.t2(a,b) VALUES(50.5,'xyzzy');
+ INSERT INTO x2.t2(a,b) VALUES(51.5,'');
+ INSERT INTO x2.t2(a,b) VALUES(52.5,''||X'0d0a');
+ INSERT INTO x2.t2(a,b) VALUES(53.5,'one'||X'0a0d');
+ INSERT INTO x2.t2(a,b) VALUES(54.5,'one'||X'0a'||'two');
+ CREATE TABLE x2.t3(a,b,c);
+ INSERT INTO x2.t3 VALUES(111,222,333);
+ CREATE TABLE main.t4(x,y,z);
+ INSERT INTO t4 SELECT * FROM t3;
+ }
+ set line "exec $PROG test.db test2.db"
+ unset -nocomplain ::MSG
+ catch {eval $line} ::MSG
+} {0}
+do_test sqldiff-1.1 {
+ set ::MSG
+} {DELETE FROM t1 WHERE a=49;
+INSERT INTO t1(a,b) VALUES(1234,'hello');
+DELETE FROM t2 WHERE a=48;
+INSERT INTO t2(a,b) VALUES(50.5,'xyzzy');
+INSERT INTO t2(a,b) VALUES(51.5,'');
+INSERT INTO t2(a,b) VALUES(52.5,''||X'0d0a');
+INSERT INTO t2(a,b) VALUES(53.5,'one'||X'0a0d');
+INSERT INTO t2(a,b) VALUES(54.5,'one'||X'0a'
+||'two');
+CREATE TABLE t3(a,b,c);
+INSERT INTO t3(rowid,a,b,c) VALUES(1,111,222,333);
+DROP TABLE t4;}
+
+finish_test
diff --git a/test/sqllimits1.test b/test/sqllimits1.test
new file mode 100644
index 0000000..1c3f66b
--- /dev/null
+++ b/test/sqllimits1.test
@@ -0,0 +1,926 @@
+# 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
+do_test sqllimits1-1.11 {
+ sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH -1
+} $SQLITE_MAX_TRIGGER_DEPTH
+do_test sqllimits1-1.12 {
+ sqlite3_limit db SQLITE_LIMIT_WORKER_THREADS 99999
+ sqlite3_limit db SQLITE_LIMIT_WORKER_THREADS -1
+} $SQLITE_MAX_WORKER_THREADS
+
+# 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.
+#
+# EVIDENCE-OF: R-61987-00541 SQLITE_LIMIT_LENGTH The maximum size of any
+# string or BLOB or table row, in bytes.
+#
+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 {
+ # Prior to 3.37.0 strftime() allocated a large static buffer into
+ # which to format its output. Using that strategy, 2100 repeats was
+ # enough to exceed 100KiB and provoke the error. As of 3.37.0 strftime()
+ # uses the StrAccum functions, so it requires 12100 to fail.
+ #
+ # set ::str [string repeat %J 2100]
+ set ::str [string repeat %J 12100]
+ catchsql { SELECT length(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' AS x"
+} [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' AS x"
+} [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-11}]]
+ 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.
+#
+# EVIDENCE-OF: R-09808-17554 SQLITE_LIMIT_SQL_LENGTH The maximum length
+# of an SQL statement, in bytes.
+#
+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.
+#
+# EVIDENCE-OF: R-43996-29471 SQLITE_LIMIT_COLUMN The maximum number of
+# columns in a table definition or in the result set of a SELECT or the
+# maximum number of columns in an index or in an ORDER BY or GROUP BY
+# clause.
+#
+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"
+ }
+ execsql "CREATE VIEW v1 AS SELECT [join $cols ,] FROM t1;"
+ catchsql {SELECT * FROM v1}
+} {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"
+ }
+ execsql {DROP VIEW IF EXISTS v1}
+ catchsql "CREATE TABLE t2([join $cols ,])"
+ catchsql "CREATE VIEW v1 AS SELECT *, c1 AS o FROM t2;"
+ catchsql "SELECT * FROM v1"
+} {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.
+#
+# EVIDENCE-OF: R-12723-08526 SQLITE_LIMIT_EXPR_DEPTH The maximum depth
+# of the parse tree on any 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.*".
+#
+# EVIDENCE-OF: R-59001-45278 SQLITE_LIMIT_FUNCTION_ARG The maximum
+# number of arguments on a function.
+#
+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.
+#
+# EVIDENCE-OF: R-41778-26203 SQLITE_LIMIT_ATTACHED The maximum number of
+# attached databases.
+#
+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.
+#
+# EVIDENCE-OF: R-42363-29104 SQLITE_LIMIT_VARIABLE_NUMBER The maximum
+# index number of any parameter in an SQL statement.
+#
+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.
+#
+# EVIDENCE-OF: R-12940-37052 SQLITE_LIMIT_LIKE_PATTERN_LENGTH The
+# maximum length of the pattern argument to the LIKE or GLOB operators.
+#
+# 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.
+#
+# Update for 3.37.0: strftime() used to allocate a large static buffer
+# into which it would write its result. With that implementation, the
+# following would trigger an SQLITE_TOOBIG error. But strftime() now
+# uses the StrAccum functions, causing this test to fail.
+#
+#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}}
+
+do_catchsql_test sqllimits1.17.0 {
+ SELECT *,*,*,*,*,*,*,* FROM (
+ SELECT *,*,*,*,*,*,*,* FROM (
+ SELECT *,*,*,*,*,*,*,* FROM (
+ SELECT *,*,*,*,*,*,*,* FROM (
+ SELECT *,*,*,*,*,*,*,* FROM (
+ SELECT 1,2,3,4,5,6,7,8,9,10
+ )
+ ))))
+} "1 {too many columns in result set}"
+
+
+foreach {key value} [array get saved] {
+ catch {set $key $value}
+}
+
+#-------------------------------------------------------------------------
+# At one point the following caused an assert() to fail.
+#
+sqlite3_limit db SQLITE_LIMIT_LENGTH 10000
+set nm [string repeat x 10000]
+do_catchsql_test sqllimits1-17.1 "
+ CREATE TABLE $nm (x PRIMARY KEY)
+" {1 {string or blob too big}}
+
+#-------------------------------------------------------------------------
+#
+sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 10
+do_catchsql_test sqllimits1-18.1 {
+ CREATE TABLE b1(x);
+ INSERT INTO b1 VALUES(1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
+} {0 {}}
+
+do_catchsql_test sqllimits1-18.2 {
+ INSERT INTO b1 VALUES(1), (2), (3), (4), (5), (6), (7), (8), (9), (10)
+ UNION VALUES(11);
+} {1 {too many terms in compound SELECT}}
+
+finish_test
diff --git a/test/sqllog.test b/test/sqllog.test
new file mode 100644
index 0000000..53d8d87
--- /dev/null
+++ b/test/sqllog.test
@@ -0,0 +1,113 @@
+# 2015 November 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 test_sqllog.c module.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix sqllog
+
+ifcapable !sqllog {
+ finish_test
+ return
+}
+
+proc readfile {f} {
+ set fd [open $f]
+ set txt [read $fd]
+ close $fd
+ set txt
+}
+
+proc delete_all_sqllog_files {} {
+ forcedelete {*}[glob -nocomplain sqllog_*.sql]
+ forcedelete {*}[glob -nocomplain sqllog_*.db]
+ forcedelete {*}[glob -nocomplain sqllog_*.idx]
+}
+
+proc touch {f} {
+ set fd [open $f w+]
+ close $fd
+}
+
+db close
+sqlite3_shutdown
+set ::env(SQLITE_SQLLOG_DIR) [pwd]
+
+delete_all_sqllog_files
+
+sqlite3 db test.db
+set a a
+set b b
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES($a, $b);
+ SELECT * FROM t1;
+} {1 2 a b}
+db close
+
+do_test 1.1 {
+ readfile [lindex [glob sqllog_*.sql] 0]
+} [string trimleft {
+/-- Main database is '.*/sqllog_.*_0.db'
+CREATE TABLE t1\(x, y\);; -- clock=0
+INSERT INTO t1 VALUES\(1, 2\);; -- clock=1
+INSERT INTO t1 VALUES\('a', 'b'\);; -- clock=2
+SELECT . FROM t1;; -- clock=3
+/}]
+
+do_test 1.2 {
+ file size [lindex [glob sqllog_*_0.db] 0]
+} 1024
+
+#-------------------------------------------------------------------------
+catch { db close }
+sqlite3_shutdown
+delete_all_sqllog_files
+forcedelete test.db-sqllog
+
+set ::env(SQLITE_SQLLOG_CONDITIONAL) 1
+sqlite3 db test.db
+do_execsql_test 2.1 {
+ INSERT INTO t1 VALUES(4, 5);
+ SELECT * FROM t1;
+} {1 2 a b 4 5}
+
+do_test 2.2 {
+ glob -nocomplain sqllog_*
+} {}
+
+db close
+touch test.db-sqllog
+sqlite3 db test.db
+do_execsql_test 2.3 {
+ INSERT INTO t1 VALUES(6, 7);
+ SELECT * FROM t1;
+} {1 2 a b 4 5 6 7}
+db close
+
+do_test 2.4 {
+ readfile [lindex [glob sqllog_*.sql] 0]
+} [string trimleft {
+/-- Main database is '.*/sqllog_.*_0.db'
+INSERT INTO t1 VALUES\(6, 7\);; -- clock=0
+SELECT . FROM t1;; -- clock=1
+/}]
+
+catch { db close }
+sqlite3_shutdown
+unset ::env(SQLITE_SQLLOG_DIR)
+unset ::env(SQLITE_SQLLOG_CONDITIONAL)
+sqlite3_config_sqllog
+sqlite3_initialize
+finish_test
diff --git a/test/startup.c b/test/startup.c
new file mode 100644
index 0000000..7262189
--- /dev/null
+++ b/test/startup.c
@@ -0,0 +1,628 @@
+/*
+** 2021-01-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 file implements a program used to measure the start-up performance
+** of SQLite.
+**
+** To use:
+**
+** ./startup init
+** valgrind --tool=cachegrind ./startup run
+**
+**
+** The "./startup init" command creates the test database file named
+** "startup.db". The performance test is run by the "./startup run"
+** command. That command does nothing but open the database file and
+** parse the entire schema.
+*/
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "sqlite3.h"
+
+static const char zHelp[] =
+ "Usage: %s COMMAND\n"
+ "Commands:\n"
+ " init Initialized the startup.db database file\n"
+ " run Run the startup performance test\n"
+ "Options:\n"
+ " --dbname NAME Set the name of the test database file\n"
+ " --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n"
+ " --stats Show statistics at the end\n"
+/* TBD
+ " --journal M Set the journal_mode to M\n"
+ " --lookaside N SZ Configure lookaside for N slots of SZ bytes each\n"
+ " --mmap SZ MMAP the first SZ bytes of the database file\n"
+ " --multithread Set multithreaded mode\n"
+ " --nomemstat Disable memory statistics\n"
+ " --pagesize N Set the page size to N\n"
+ " --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n"
+ " --serialized Set serialized threading mode\n"
+ " --singlethread Set single-threaded mode - disables all mutexing\n"
+ " --utf16be Set text encoding to UTF-16BE\n"
+ " --utf16le Set text encoding to UTF-16LE\n"
+ " --utf8 Set text encoding to UTF-8\n"
+*/
+;
+
+static void usage(const char *argv0){
+ printf(zHelp, argv0);
+ exit(1);
+}
+
+/*
+** The test schema is derived from the Fossil repository for SQLite itself.
+** The schema covers the repository, the local checkout database, and
+** the global configuration database.
+*/
+static const char zTestSchema[] =
+ "CREATE TABLE repo_blob(\n"
+ " rid INTEGER PRIMARY KEY,\n"
+ " rcvid INTEGER,\n"
+ " size INTEGER,\n"
+ " uuid TEXT UNIQUE NOT NULL,\n"
+ " content BLOB,\n"
+ " CHECK( length(uuid)>=40 AND rid>0 )\n"
+ ");\n"
+ "CREATE TABLE repo_delta(\n"
+ " rid INTEGER PRIMARY KEY,\n"
+ " srcid INTEGER NOT NULL REFERENCES blob\n"
+ ");\n"
+ "CREATE TABLE repo_rcvfrom(\n"
+ " rcvid INTEGER PRIMARY KEY,\n"
+ " uid INTEGER REFERENCES user,\n"
+ " mtime DATETIME,\n"
+ " nonce TEXT UNIQUE,\n"
+ " ipaddr TEXT\n"
+ ");\n"
+ "CREATE TABLE repo_private(rid INTEGER PRIMARY KEY);\n"
+ "CREATE TABLE repo_accesslog(\n"
+ " uname TEXT,\n"
+ " ipaddr TEXT,\n"
+ " success BOOLEAN,\n"
+ " mtime TIMESTAMP);\n"
+ "CREATE TABLE repo_user(\n"
+ " uid INTEGER PRIMARY KEY,\n"
+ " login TEXT UNIQUE,\n"
+ " pw TEXT,\n"
+ " cap TEXT,\n"
+ " cookie TEXT,\n"
+ " ipaddr TEXT,\n"
+ " cexpire DATETIME,\n"
+ " info TEXT,\n"
+ " mtime DATE,\n"
+ " photo BLOB\n"
+ ");\n"
+ "CREATE TABLE repo_reportfmt(\n"
+ " rn INTEGER PRIMARY KEY,\n"
+ " owner TEXT,\n"
+ " title TEXT UNIQUE,\n"
+ " mtime INTEGER,\n"
+ " cols TEXT,\n"
+ " sqlcode TEXT\n"
+ ");\n"
+ "CREATE TABLE repo_sqlite_stat2(tbl,idx,sampleno,sample);\n"
+ "CREATE TABLE repo_sqlite_stat1(tbl,idx,stat);\n"
+ "CREATE TABLE repo_sqlite_stat3(tbl,idx,neq,nlt,ndlt,sample);\n"
+ "CREATE TABLE repo_config(\n"
+ " name TEXT PRIMARY KEY NOT NULL,\n"
+ " value CLOB, mtime INTEGER,\n"
+ " CHECK( typeof(name)='text' AND length(name)>=1 )\n"
+ ") WITHOUT ROWID;\n"
+ "CREATE TABLE repo_shun(uuid PRIMARY KEY,\n"
+ " mtime INTEGER,\n"
+ " scom TEXT) WITHOUT ROWID;\n"
+ "CREATE TABLE repo_concealed(\n"
+ " hash TEXT PRIMARY KEY,\n"
+ " content TEXT\n"
+ ", mtime INTEGER) WITHOUT ROWID;\n"
+ "CREATE TABLE repo_admin_log(\n"
+ " id INTEGER PRIMARY KEY,\n"
+ " time INTEGER, -- Seconds since 1970\n"
+ " page TEXT, -- path of page\n"
+ " who TEXT, -- User who made the change\n"
+ " what TEXT -- What changed\n"
+ ");\n"
+ "CREATE TABLE repo_unversioned(\n"
+ " name TEXT PRIMARY KEY,\n"
+ " rcvid INTEGER,\n"
+ " mtime DATETIME,\n"
+ " hash TEXT,\n"
+ " sz INTEGER,\n"
+ " encoding INT,\n"
+ " content BLOB\n"
+ ") WITHOUT ROWID;\n"
+ "CREATE TABLE repo_subscriber(\n"
+ " subscriberId INTEGER PRIMARY KEY,\n"
+ " subscriberCode BLOB DEFAULT (randomblob(32)) UNIQUE,\n"
+ " semail TEXT UNIQUE COLLATE nocase,\n"
+ " suname TEXT,\n"
+ " sverified BOOLEAN DEFAULT true,\n"
+ " sdonotcall BOOLEAN,\n"
+ " sdigest BOOLEAN,\n"
+ " ssub TEXT,\n"
+ " sctime INTDATE,\n"
+ " mtime INTDATE,\n"
+ " smip TEXT\n"
+ ");\n"
+ "CREATE TABLE repo_pending_alert(\n"
+ " eventid TEXT PRIMARY KEY,\n"
+ " sentSep BOOLEAN DEFAULT false,\n"
+ " sentDigest BOOLEAN DEFAULT false\n"
+ ", sentMod BOOLEAN DEFAULT false) WITHOUT ROWID;\n"
+ "CREATE INDEX repo_delta_i1 ON repo_delta(srcid);\n"
+ "CREATE INDEX repo_blob_rcvid ON repo_blob(rcvid);\n"
+ "CREATE INDEX repo_subscriberUname\n"
+ " ON repo_subscriber(suname) WHERE suname IS NOT NULL;\n"
+ "CREATE VIEW repo_artifact(rid,rcvid,size,atype,srcid,hash,content) AS\n"
+ " SELECT blob.rid,rcvid,size,1,srcid,uuid,content\n"
+ " FROM repo_blob LEFT JOIN repo_delta ON (blob.rid=delta.rid);\n"
+ "CREATE TABLE repo_filename(\n"
+ " fnid INTEGER PRIMARY KEY,\n"
+ " name TEXT UNIQUE\n"
+ ");\n"
+ "CREATE TABLE repo_mlink(\n"
+ " mid INTEGER,\n"
+ " fid INTEGER,\n"
+ " pmid INTEGER,\n"
+ " pid INTEGER,\n"
+ " fnid INTEGER REFERENCES filename,\n"
+ " pfnid INTEGER,\n"
+ " mperm INTEGER,\n"
+ " isaux BOOLEAN DEFAULT 0\n"
+ ");\n"
+ "CREATE INDEX repo_mlink_i1 ON repo_mlink(mid);\n"
+ "CREATE INDEX repo_mlink_i2 ON repo_mlink(fnid);\n"
+ "CREATE INDEX repo_mlink_i3 ON repo_mlink(fid);\n"
+ "CREATE INDEX repo_mlink_i4 ON repo_mlink(pid);\n"
+ "CREATE TABLE repo_plink(\n"
+ " pid INTEGER REFERENCES blob,\n"
+ " cid INTEGER REFERENCES blob,\n"
+ " isprim BOOLEAN,\n"
+ " mtime DATETIME,\n"
+ " baseid INTEGER REFERENCES blob,\n"
+ " UNIQUE(pid, cid)\n"
+ ");\n"
+ "CREATE INDEX repo_plink_i2 ON repo_plink(cid,pid);\n"
+ "CREATE TABLE repo_leaf(rid INTEGER PRIMARY KEY);\n"
+ "CREATE TABLE repo_event(\n"
+ " type TEXT,\n"
+ " mtime DATETIME,\n"
+ " objid INTEGER PRIMARY KEY,\n"
+ " tagid INTEGER,\n"
+ " uid INTEGER REFERENCES user,\n"
+ " bgcolor TEXT,\n"
+ " euser TEXT,\n"
+ " user TEXT,\n"
+ " ecomment TEXT,\n"
+ " comment TEXT,\n"
+ " brief TEXT,\n"
+ " omtime DATETIME\n"
+ ");\n"
+ "CREATE INDEX repo_event_i1 ON repo_event(mtime);\n"
+ "CREATE TABLE repo_phantom(\n"
+ " rid INTEGER PRIMARY KEY\n"
+ ");\n"
+ "CREATE TABLE repo_orphan(\n"
+ " rid INTEGER PRIMARY KEY,\n"
+ " baseline INTEGER\n"
+ ");\n"
+ "CREATE INDEX repo_orphan_baseline ON repo_orphan(baseline);\n"
+ "CREATE TABLE repo_unclustered(\n"
+ " rid INTEGER PRIMARY KEY\n"
+ ");\n"
+ "CREATE TABLE repo_unsent(\n"
+ " rid INTEGER PRIMARY KEY\n"
+ ");\n"
+ "CREATE TABLE repo_tag(\n"
+ " tagid INTEGER PRIMARY KEY,\n"
+ " tagname TEXT UNIQUE\n"
+ ");\n"
+ "CREATE TABLE repo_tagxref(\n"
+ " tagid INTEGER REFERENCES tag,\n"
+ " tagtype INTEGER,\n"
+ " srcid INTEGER REFERENCES blob,\n"
+ " origid INTEGER REFERENCES blob,\n"
+ " value TEXT,\n"
+ " mtime TIMESTAMP,\n"
+ " rid INTEGER REFERENCE blob,\n"
+ " UNIQUE(rid, tagid)\n"
+ ");\n"
+ "CREATE INDEX repo_tagxref_i1 ON repo_tagxref(tagid, mtime);\n"
+ "CREATE TABLE repo_backlink(\n"
+ " target TEXT,\n"
+ " srctype INT,\n"
+ " srcid INT,\n"
+ " mtime TIMESTAMP,\n"
+ " UNIQUE(target, srctype, srcid)\n"
+ ");\n"
+ "CREATE INDEX repo_backlink_src ON repo_backlink(srcid, srctype);\n"
+ "CREATE TABLE repo_attachment(\n"
+ " attachid INTEGER PRIMARY KEY,\n"
+ " isLatest BOOLEAN DEFAULT 0,\n"
+ " mtime TIMESTAMP,\n"
+ " src TEXT,\n"
+ " target TEXT,\n"
+ " filename TEXT,\n"
+ " comment TEXT,\n"
+ " user TEXT\n"
+ ");\n"
+ "CREATE INDEX repo_attachment_idx1\n"
+ " ON repo_attachment(target, filename, mtime);\n"
+ "CREATE INDEX repo_attachment_idx2 ON repo_attachment(src);\n"
+ "CREATE TABLE repo_cherrypick(\n"
+ " parentid INT,\n"
+ " childid INT,\n"
+ " isExclude BOOLEAN DEFAULT false,\n"
+ " PRIMARY KEY(parentid, childid)\n"
+ ") WITHOUT ROWID;\n"
+ "CREATE INDEX repo_cherrypick_cid ON repo_cherrypick(childid);\n"
+ "CREATE TABLE repo_ticket(\n"
+ " -- Do not change any column that begins with tkt_\n"
+ " tkt_id INTEGER PRIMARY KEY,\n"
+ " tkt_uuid TEXT UNIQUE,\n"
+ " tkt_mtime DATE,\n"
+ " tkt_ctime DATE,\n"
+ " -- Add as many fields as required below this line\n"
+ " type TEXT,\n"
+ " status TEXT,\n"
+ " subsystem TEXT,\n"
+ " priority TEXT,\n"
+ " severity TEXT,\n"
+ " foundin TEXT,\n"
+ " private_contact TEXT,\n"
+ " resolution TEXT,\n"
+ " title TEXT,\n"
+ " comment TEXT\n"
+ ");\n"
+ "CREATE TABLE repo_ticketchng(\n"
+ " -- Do not change any column that begins with tkt_\n"
+ " tkt_id INTEGER REFERENCES ticket,\n"
+ " tkt_rid INTEGER REFERENCES blob,\n"
+ " tkt_mtime DATE,\n"
+ " -- Add as many fields as required below this line\n"
+ " login TEXT,\n"
+ " username TEXT,\n"
+ " mimetype TEXT,\n"
+ " icomment TEXT\n"
+ ");\n"
+ "CREATE INDEX repo_ticketchng_idx1 ON repo_ticketchng(tkt_id, tkt_mtime);\n"
+ "CREATE TRIGGER repo_alert_trigger1\n"
+ "AFTER INSERT ON repo_event BEGIN\n"
+ " INSERT INTO repo_pending_alert(eventid)\n"
+ " SELECT printf('%.1c%d',new.type,new.objid) WHERE true\n"
+ " ON CONFLICT(eventId) DO NOTHING;\n"
+ "END;\n"
+ "CREATE TABLE repo_vcache(\n"
+ " vid INTEGER, -- check-in ID\n"
+ " fname TEXT, -- filename\n"
+ " rid INTEGER, -- artifact ID\n"
+ " PRIMARY KEY(vid,fname)\n"
+ ") WITHOUT ROWID;\n"
+ "CREATE TABLE localdb_vvar(\n"
+ " name TEXT PRIMARY KEY NOT NULL,\n"
+ " value CLOB,\n"
+ " CHECK( typeof(name)='text' AND length(name)>=1 )\n"
+ ");\n"
+ "CREATE TABLE localdb_vfile(\n"
+ " id INTEGER PRIMARY KEY,\n"
+ " vid INTEGER REFERENCES blob,\n"
+ " chnged INT DEFAULT 0,\n"
+ " deleted BOOLEAN DEFAULT 0,\n"
+ " isexe BOOLEAN,\n"
+ " islink BOOLEAN,\n"
+ " rid INTEGER,\n"
+ " mrid INTEGER,\n"
+ " mtime INTEGER,\n"
+ " pathname TEXT,\n"
+ " origname TEXT, mhash,\n"
+ " UNIQUE(pathname,vid)\n"
+ ");\n"
+ "CREATE TABLE localdb_sqlite_stat1(tbl,idx,stat);\n"
+ "CREATE TABLE localdb_vcache(\n"
+ " vid INTEGER, -- check-in ID\n"
+ " fname TEXT, -- filename\n"
+ " rid INTEGER, -- artifact ID\n"
+ " PRIMARY KEY(vid,fname)\n"
+ ") WITHOUT ROWID;\n"
+ "CREATE TABLE localdb_stash(\n"
+ " stashid INTEGER PRIMARY KEY,\n"
+ " vid INTEGER,\n"
+ " hash TEXT,\n"
+ " comment TEXT,\n"
+ " ctime TIMESTAMP\n"
+ ");\n"
+ "CREATE TABLE localdb_stashfile(\n"
+ " stashid INTEGER REFERENCES stash,\n"
+ " isAdded BOOLEAN,\n"
+ " isRemoved BOOLEAN,\n"
+ " isExec BOOLEAN,\n"
+ " isLink BOOLEAN,\n"
+ " rid INTEGER,\n"
+ " hash TEXT,\n"
+ " origname TEXT,\n"
+ " newname TEXT,\n"
+ " delta BLOB,\n"
+ " PRIMARY KEY(newname, stashid)\n"
+ ");\n"
+ "CREATE TABLE localdb_vmerge(\n"
+ " id INTEGER REFERENCES vfile,\n"
+ " merge INTEGER,\n"
+ " mhash TEXT\n"
+ ");\n"
+ "CREATE UNIQUE INDEX localdb_vmergex1 ON localdb_vmerge(id,mhash);\n"
+ "CREATE TRIGGER localdb_vmerge_ck1 AFTER INSERT ON localdb_vmerge\n"
+ "WHEN new.mhash IS NULL BEGIN\n"
+ " SELECT raise(FAIL,\n"
+ " 'trying to update a newer checkout with an older version of Fossil');\n"
+ "END;\n"
+ "CREATE TABLE configdb_global_config(\n"
+ " name TEXT PRIMARY KEY,\n"
+ " value TEXT\n"
+ ");\n"
+ "CREATE TABLE configdb_sqlite_stat1(tbl,idx,stat);\n"
+;
+
+#ifdef __linux__
+#include <sys/types.h>
+#include <unistd.h>
+
+/*
+** Attempt to display I/O stats on Linux using /proc/PID/io
+*/
+static void displayLinuxIoStats(FILE *out){
+ FILE *in;
+ char z[200];
+ sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid());
+ in = fopen(z, "rb");
+ if( in==0 ) return;
+ while( fgets(z, sizeof(z), in)!=0 ){
+ static const struct {
+ const char *zPattern;
+ const char *zDesc;
+ } aTrans[] = {
+ { "rchar: ", "Bytes received by read():" },
+ { "wchar: ", "Bytes sent to write():" },
+ { "syscr: ", "Read() system calls:" },
+ { "syscw: ", "Write() system calls:" },
+ { "read_bytes: ", "Bytes rcvd from storage:" },
+ { "write_bytes: ", "Bytes sent to storage:" },
+ { "cancelled_write_bytes: ", "Cancelled write bytes:" },
+ };
+ int i;
+ for(i=0; i<sizeof(aTrans)/sizeof(aTrans[0]); i++){
+ int n = (int)strlen(aTrans[i].zPattern);
+ if( strncmp(aTrans[i].zPattern, z, n)==0 ){
+ fprintf(out, "-- %-28s %s", aTrans[i].zDesc, &z[n]);
+ break;
+ }
+ }
+ }
+ fclose(in);
+}
+#endif
+
+/*
+** Return the value of a hexadecimal digit. Return -1 if the input
+** is not a hex digit.
+*/
+static int hexDigitValue(char c){
+ if( c>='0' && c<='9' ) return c - '0';
+ if( c>='a' && c<='f' ) return c - 'a' + 10;
+ if( c>='A' && c<='F' ) return c - 'A' + 10;
+ return -1;
+}
+
+/*
+** Interpret zArg as an integer value, possibly with suffixes.
+*/
+static int integerValue(const char *zArg){
+ sqlite3_int64 v = 0;
+ static const struct { char *zSuffix; int iMult; } aMult[] = {
+ { "KiB", 1024 },
+ { "MiB", 1024*1024 },
+ { "GiB", 1024*1024*1024 },
+ { "KB", 1000 },
+ { "MB", 1000000 },
+ { "GB", 1000000000 },
+ { "K", 1000 },
+ { "M", 1000000 },
+ { "G", 1000000000 },
+ };
+ int i;
+ int isNeg = 0;
+ if( zArg[0]=='-' ){
+ isNeg = 1;
+ zArg++;
+ }else if( zArg[0]=='+' ){
+ zArg++;
+ }
+ if( zArg[0]=='0' && zArg[1]=='x' ){
+ int x;
+ zArg += 2;
+ while( (x = hexDigitValue(zArg[0]))>=0 ){
+ v = (v<<4) + x;
+ zArg++;
+ }
+ }else{
+ while( isdigit(zArg[0]) ){
+ v = v*10 + zArg[0] - '0';
+ zArg++;
+ }
+ }
+ for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
+ if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
+ v *= aMult[i].iMult;
+ break;
+ }
+ }
+ if( v>0x7fffffff ){
+ printf("ERROR: parameter too large - max 2147483648\n");
+ exit(1);
+ }
+ return (int)(isNeg? -v : v);
+}
+
+
+int main(int argc, char **argv){
+ const char *zCmd = 0;
+ int i;
+ int bAutovac = 0;
+ int showStats = 0;
+ const char *zDbName = "./startup.db";
+ int nHeap = 0;
+ int mnHeap = 0;
+
+ for(i=1; i<argc; i++){
+ const char *z = argv[i];
+ if( z[0]!='-' ){
+ if( zCmd ){
+ usage(argv[0]);
+ }
+ zCmd = z;
+ continue;
+ }
+ if( z[1]=='-' ) z++;
+ if( strcmp(z, "-autovacuum")==0 ){
+ bAutovac = 1;
+ }else
+ if( strcmp(z, "-dbname")==0 ){
+ if( i==argc-1 ){
+ printf("ERROR: missing argument on \"%s\"\n", argv[0]);
+ exit(1);
+ }
+ zDbName = argv[++i];
+ }else
+ if( strcmp(z,"-heap")==0 ){
+ if( i>=argc-2 ){
+ printf("ERROR: missing arguments on %s\n", argv[i]);
+ exit(1);
+ }
+ nHeap = integerValue(argv[i+1]);
+ mnHeap = integerValue(argv[i+2]);
+ i += 2;
+ }else
+ if( strcmp(z,"-stats")==0 ){
+ showStats = 1;
+ }else
+ {
+ printf("ERROR: unknown option \"%s\"\n", argv[i]);
+ usage(argv[0]);
+ }
+ }
+ if( zCmd==0 ){
+ printf("ERROR: no COMMAND specified\n");
+ usage(argv[0]);
+ }
+ if( strcmp(zCmd, "run")==0 ){
+ sqlite3 *db;
+ int rc;
+ char *zErr = 0;
+ void *pHeap = 0;
+ if( nHeap>0 ){
+ pHeap = malloc( nHeap );
+ if( pHeap==0 ){
+ printf("ERROR: cannot allocate %d-byte heap\n", nHeap);
+ exit(1);
+ }
+ rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, mnHeap);
+ if( rc ){
+ printf("ERROR: heap configuration failed: %d\n", rc);
+ exit(1);
+ }
+ }
+ rc = sqlite3_open(zDbName, &db);
+ if( rc ){
+ printf("SQLite error: %s\n", sqlite3_errmsg(db));
+ }else{
+ sqlite3_exec(db, "PRAGMA synchronous", 0, 0, &zErr);
+ }
+ if( zErr ){
+ printf("ERROR: %s\n", zErr);
+ sqlite3_free(zErr);
+ }
+ if( showStats ){
+ int iCur, iHi;
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHi, 0);
+ printf("-- Lookaside Slots Used: %d (max %d)\n", iCur,iHi);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHi, 0);
+ printf("-- Successful lookasides: %d\n", iHi);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur,&iHi,0);
+ printf("-- Lookaside size faults: %d\n", iHi);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur,&iHi,0);
+ printf("-- Lookaside OOM faults: %d\n", iHi);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHi, 0);
+ printf("-- Pager Heap Usage: %d bytes\n", iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHi, 1);
+ printf("-- Page cache hits: %d\n", iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHi, 1);
+ printf("-- Page cache misses: %d\n", iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHi, 1);
+ printf("-- Page cache writes: %d\n", iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHi, 0);
+ printf("-- Schema Heap Usage: %d bytes\n", iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHi, 0);
+ printf("-- Statement Heap Usage: %d bytes\n", iCur);
+ }
+ sqlite3_close(db);
+ free(pHeap);
+ /* Global memory usage statistics printed after the database connection
+ ** has closed. Memory usage should be zero at this point. */
+ if( showStats ){
+ int iCur, iHi;
+ sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHi, 0);
+ printf("-- Memory Used (bytes): %d (max %d)\n", iCur,iHi);
+ sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHi, 0);
+ printf("-- Outstanding Allocations: %d (max %d)\n", iCur,iHi);
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHi, 0);
+ printf("-- Pcache Overflow Bytes: %d (max %d)\n", iCur,iHi);
+ sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHi, 0);
+ printf("-- Largest Allocation: %d bytes\n",iHi);
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHi, 0);
+ printf("-- Largest Pcache Allocation: %d bytes\n",iHi);
+#ifdef __linux__
+ displayLinuxIoStats(stdout);
+#endif
+ }
+ return 0;
+ }
+ if( strcmp(zCmd, "init")==0 ){
+ sqlite3 *db;
+ char *zAux;
+ char *zErr = 0;
+ int rc;
+ unlink(zDbName);
+ zAux = sqlite3_mprintf("%s-journal", zDbName);
+ unlink(zAux);
+ sqlite3_free(zAux);
+ zAux = sqlite3_mprintf("%s-wal", zDbName);
+ unlink(zAux);
+ sqlite3_free(zAux);
+ rc = sqlite3_open(zDbName, &db);
+ if( rc ){
+ printf("SQLite error: %s\n", sqlite3_errmsg(db));
+ }else{
+ sqlite3_exec(db, "BEGIN", 0, 0, 0);
+ sqlite3_exec(db, zTestSchema, 0, 0, &zErr);
+ sqlite3_exec(db, "COMMIT", 0, 0, 0);
+ }
+ if( zErr ){
+ printf("ERROR: %s\n", zErr);
+ sqlite3_free(zErr);
+ }
+ sqlite3_close(db);
+ return 0;
+
+ }
+}
diff --git a/test/stat.test b/test/stat.test
new file mode 100644
index 0000000..4705844
--- /dev/null
+++ b/test/stat.test
@@ -0,0 +1,328 @@
+# 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
+set testprefix stat
+
+ifcapable !vtab||!compound {
+ finish_test
+ return
+}
+
+# This module uses hard-coded results that depend on exact measurements of
+# pages sizes at the byte level, and hence will not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {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 table_info(dbstat);
+} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}
+
+# Attempts to drop an eponymous virtual table are a no-op.
+do_catchsql_test stat-0.1a {
+ DROP TABLE dbstat;
+} {1 {table dbstat may not be dropped}}
+do_execsql_test stat-0.1b {
+ PRAGMA table_info=dbstat;
+} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+db func a_string a_string
+register_dbstat_vtab db
+do_execsql_test stat-0.2 {
+ PRAGMA auto_vacuum = OFF;
+ CREATE VIRTUAL TABLE temp.stat USING dbstat;
+ SELECT * FROM stat;
+} {}
+
+
+if {[wal_is_capable]} {
+ 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_schema / 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_schema';
+ }
+} {sqlite_schema / 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
+ ORDER BY rowid;
+ INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3
+ ORDER BY rowid;
+ INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3
+ ORDER BY rowid;
+ INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3
+ ORDER BY rowid;
+ INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3
+ ORDER BY rowid;
+ SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
+ FROM stat WHERE name != 'sqlite_schema' ORDER BY name;
+} [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.1agg {
+ SELECT * FROM dbstat WHERE aggregate=TRUE ORDER BY name;
+} [list \
+ sqlite_autoindex_t3_1 {} 5 {} 32 3898 1065 132 {} 5120 \
+ sqlite_schema {} 1 {} 2 84 824 49 {} 1024 \
+ t3 {} 17 {} 47 11188 5815 370 {} 17408 \
+]
+
+# With every index entry overflowing, make sure no pages are missed
+# (other than the locking page which is 64 in this test build.)
+#
+do_execsql_test stat-2.2 {
+ UPDATE t3 SET a=a||hex(randomblob(700));
+ VACUUM;
+ SELECT pageno FROM stat EXCEPT SELECT pageno-1 FROM stat;
+} {64 136}
+
+do_execsql_test stat-2.3 { DROP TABLE t3; VACUUM; } {}
+
+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_schema' ORDER BY name;
+} [list \
+ i4 / 3 leaf 1 103 905 7782 \
+ i4 /000+000000 4 overflow 0 1020 0 0 \
+ i4 /000+000001 5 overflow 0 1020 0 0 \
+ i4 /000+000002 6 overflow 0 1020 0 0 \
+ i4 /000+000003 7 overflow 0 1020 0 0 \
+ i4 /000+000004 8 overflow 0 1020 0 0 \
+ i4 /000+000005 9 overflow 0 1020 0 0 \
+ i4 /000+000006 10 overflow 0 1020 0 0 \
+ i4 /000+000007 11 overflow 0 539 481 0 \
+ t4 / 2 leaf 1 640 367 7780 \
+ t4 /000+000000 12 overflow 0 1020 0 0 \
+ t4 /000+000001 13 overflow 0 1020 0 0 \
+ t4 /000+000002 14 overflow 0 1020 0 0 \
+ t4 /000+000003 15 overflow 0 1020 0 0 \
+ t4 /000+000004 16 overflow 0 1020 0 0 \
+ t4 /000+000005 17 overflow 0 1020 0 0 \
+ t4 /000+000006 18 overflow 0 1020 0 0 \
+]
+
+do_execsql_test stat-3.2 {
+ SELECT *, '|' FROM dbstat WHERE aggregate=TRUE ORDER BY name;
+} [list \
+ i4 {} 9 {} 1 7782 1386 7782 {} 9216 | \
+ sqlite_schema {} 1 {} 2 74 834 40 {} 1024 | \
+ t4 {} 8 {} 1 7780 367 7780 {} 8192 | \
+]
+
+
+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 / 20 leaf 0 0 1016 0 \
+ t5 / 19 leaf 0 0 1016 0 \
+]
+
+db close
+forcedelete test.db
+sqlite3 db test.db
+register_dbstat_vtab db
+do_execsql_test stat-5.1 {
+ PRAGMA auto_vacuum = OFF;
+ CREATE TABLE tx(y);
+ ATTACH ':memory:' AS aux1;
+ CREATE VIRTUAL TABLE temp.stat USING dbstat(aux1);
+ CREATE TABLE aux1.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 \
+]
+
+do_execsql_test stat-5.20 {
+ SELECT name, quote(path), pageno, quote(pagetype), ncell, payload,
+ unused, mx_payload, '|' FROM dbstat('main',1);
+} {sqlite_schema NULL 1 NULL 1 34 878 34 | tx NULL 1 NULL 0 0 1016 0 |}
+do_execsql_test stat-5.21 {
+ SELECT name, quote(path), pageno, quote(pagetype), ncell, payload,
+ unused, mx_payload, '|' FROM dbstat('aux1',1);
+} {sqlite_schema NULL 1 NULL 1 34 878 34 | t1 NULL 3 NULL 2 3033 5 1517 |}
+
+
+do_catchsql_test stat-6.1 {
+ CREATE VIRTUAL TABLE temp.s2 USING dbstat(mainx);
+} {1 {no such database: mainx}}
+
+#-------------------------------------------------------------------------
+# Test that the argument passed to the dbstat constructor is dequoted
+# before it is matched against the names of attached databases.
+#
+forcedelete test.db2
+do_execsql_test 7.1 {
+ ATTACH 'test.db2' AS '123';
+ PRAGMA "123".auto_vacuum = OFF;
+ CREATE TABLE "123".x1(a, b);
+ INSERT INTO x1 VALUES(1, 2);
+}
+
+do_execsql_test 7.1.1 {
+ SELECT * FROM dbstat('123');
+} {
+ sqlite_schema / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_execsql_test 7.1.2 {
+ SELECT * FROM dbstat(123);
+} {
+ sqlite_schema / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_execsql_test 7.1.3 {
+ CREATE VIRTUAL TABLE x2 USING dbstat('123');
+ SELECT * FROM x2;
+} {
+ sqlite_schema / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_execsql_test 7.1.4 {
+ CREATE VIRTUAL TABLE x3 USING dbstat(123);
+ SELECT * FROM x3;
+} {
+ sqlite_schema / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+
+do_execsql_test 7.2 {
+ DETACH 123;
+ DROP TABLE x2;
+ DROP TABLE x3;
+ ATTACH 'test.db2' AS '123corp';
+}
+do_execsql_test 7.2.1 {
+ SELECT * FROM dbstat('123corp');
+} {
+ sqlite_schema / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_catchsql_test 7.2.2 {
+ SELECT * FROM dbstat(123corp);
+} {1 {unrecognized token: "123corp"}}
+do_execsql_test 7.2.3 {
+ CREATE VIRTUAL TABLE x2 USING dbstat('123corp');
+ SELECT * FROM x2;
+} {
+ sqlite_schema / 1 leaf 1 37 875 37 0 1024
+ x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_catchsql_test 7.2.4 {
+ CREATE VIRTUAL TABLE x3 USING dbstat(123corp);
+ SELECT * FROM x3;
+} {1 {unrecognized token: "123corp"}}
+
+
+do_execsql_test 8.1 {
+ CREATE VIRTUAL TABLE st4 USING dbstat;
+}
+do_execsql_test 8.2 {
+ SELECT * FROM st4 WHERE st4.aggregate = NULL;
+}
+do_execsql_test 8.3 {
+ SELECT aggregate=1 FROM st4 WHERE aggregate = 5
+}
+do_execsql_test 8.4 {
+ SELECT * FROM st4 WHERE name = NULL;
+} {}
+do_execsql_test 8.5 {
+ SELECT * FROM st4 WHERE schema = NULL;
+} {}
+
+#-------------------------------------------------------------------------
+reset_db
+breakpoint
+do_catchsql_test 9.1 {
+ CREATE TABLE dbstat(x, y);
+ DROP TABLE nosuchdb.dbstat;
+} {/1 {(no such table: nosuchdb.dbstat|table dbstat may not be dropped)}/}
+
+finish_test
diff --git a/test/statfault.test b/test/statfault.test
new file mode 100644
index 0000000..b5980d4
--- /dev/null
+++ b/test/statfault.test
@@ -0,0 +1,55 @@
+# 2015 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix statfault
+
+ifcapable !vtab||!compound {
+ finish_test
+ return
+}
+
+register_dbstat_vtab db
+do_execsql_test statfault-1 {
+ CREATE TABLE t1(a, b UNIQUE);
+ INSERT INTO t1 VALUES(1, randomblob(500));
+ INSERT INTO t1 VALUES(randomblob(500), 1);
+ INSERT INTO t1 VALUES(2, randomblob(250));
+ INSERT INTO t1 VALUES(randomblob(250), 2);
+ CREATE VIRTUAL TABLE sss USING dbstat;
+} {}
+faultsim_save_and_close
+
+do_faultsim_test 1 -faults * -prep {
+ faultsim_restore_and_reopen
+ register_dbstat_vtab db
+ execsql { SELECT 1 FROM sqlite_master LIMIT 1 }
+} -body {
+ execsql { SELECT count(*) FROM sss }
+} -test {
+ faultsim_test_result {0 8}
+}
+
+do_faultsim_test 2 -faults * -prep {
+ faultsim_restore_and_reopen
+ register_dbstat_vtab db
+ execsql { SELECT 1 FROM sqlite_master LIMIT 1 }
+} -body {
+ db eval { SELECT * FROM sss } { db eval { SELECT randomblob(5000) } }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
+
diff --git a/test/stmt.test b/test/stmt.test
new file mode 100644
index 0000000..138ce19
--- /dev/null
+++ b/test/stmt.test
@@ -0,0 +1,104 @@
+# 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
+
+if {[atomic_batch_write test.db]} {
+ finish_test
+ return
+}
+
+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
+ # 2016-03-04: statement-journal open deferred
+} {2}
+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
+ # 2016-03-04: statement-journal open deferred
+} {2}
+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;
+} 2
+
+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);
+} 2
+
+finish_test
diff --git a/test/stmtvtab1.test b/test/stmtvtab1.test
new file mode 100644
index 0000000..e8a79fd
--- /dev/null
+++ b/test/stmtvtab1.test
@@ -0,0 +1,82 @@
+# 2017-06-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.
+#
+#***********************************************************************
+#
+# Testing of the STMT virtual table.
+#
+# This also validates the SQLITE_STMTSTATUS_REPREPARE and
+# SQLITE_STMTSTATUS_RUN values for sqlite3_stmt_status().
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !stmtvtab {
+ finish_test
+ return
+}
+
+db cache flush
+db cache size 20
+unset -nocomplain x y z
+set x giraffe
+set y mango
+set z alabama
+do_execsql_test stmtvtab1-100 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES($a,$b,$c);
+ CREATE INDEX t1a ON t1(a);
+ SELECT run, sql FROM sqlite_stmt ORDER BY 1;
+} {1 {SELECT run, sql FROM sqlite_stmt ORDER BY 1;} 1 {CREATE INDEX t1a ON t1(a);} 1 {INSERT INTO t1 VALUES($a,$b,$c);} 1 {CREATE TABLE t1(a,b,c);}}
+set x neon
+set y event
+set z future
+do_execsql_test stmtvtab1-110 {
+ INSERT INTO t1 VALUES($a,$b,$c);
+ SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy;
+} {1 2 {INSERT INTO t1 VALUES($a,$b,$c);}}
+set x network
+set y fit
+set z metal
+do_execsql_test stmtvtab1-120 {
+ INSERT INTO t1 VALUES($a,$b,$c);
+ SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy;
+} {1 3 {INSERT INTO t1 VALUES($a,$b,$c);}}
+set x history
+set y detail
+set z grace
+do_execsql_test stmtvtab1-130 {
+ CREATE INDEX t1b ON t1(b);
+ INSERT INTO t1 VALUES($a,$b,$c);
+ SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy;
+} {2 4 {INSERT INTO t1 VALUES($a,$b,$c);}}
+
+# All statements are still in cache
+#
+do_execsql_test stmtvtab1-140 {
+ SELECT count(*) FROM sqlite_stmt WHERE NOT busy;
+} {6}
+
+# None of the prepared statements should use more than a couple thousand
+# bytes of memory
+#
+#db eval {SELECT mem, sql FROM sqlite_stmt} {puts [format {%5d %s} $mem $sql]}
+do_execsql_test stmtvtab1-150 {
+ SELECT count(*) FROM sqlite_stmt WHERE mem>5000;
+} {0}
+
+# Flushing the cache clears all of the prepared statements.
+#
+db cache flush
+do_execsql_test stmtvtab1-160 {
+ SELECT * FROM sqlite_stmt WHERE NOT busy;
+} {}
+
+finish_test
diff --git a/test/strict1.test b/test/strict1.test
new file mode 100644
index 0000000..fc64388
--- /dev/null
+++ b/test/strict1.test
@@ -0,0 +1,165 @@
+# 2021-08-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 STRICT tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix strict1
+
+# STRICT tables have on a limited number of allowed datatypes.
+#
+do_catchsql_test strict1-1.1 {
+ CREATE TABLE t1(a) STRICT;
+} {1 {missing datatype for t1.a}}
+do_catchsql_test strict1-1.2 {
+ CREATE TABLE t1(a PRIMARY KEY) STRICT, WITHOUT ROWID;
+} {1 {missing datatype for t1.a}}
+do_catchsql_test strict1-1.3 {
+ CREATE TABLE t1(a PRIMARY KEY) WITHOUT ROWID, STRICT;
+} {1 {missing datatype for t1.a}}
+do_catchsql_test strict1-1.4 {
+ CREATE TABLE t1(a BANJO PRIMARY KEY) WITHOUT ROWID, STRICT;
+} {1 {unknown datatype for t1.a: "BANJO"}}
+do_catchsql_test strict1-1.5 {
+ CREATE TABLE t1(a TEXT PRIMARY KEY, b INT, c INTEGER, d REAL, e BLOB, f DATE) strict;
+} {1 {unknown datatype for t1.f: "DATE"}}
+do_catchsql_test strict1-1.6 {
+ CREATE TABLE t1(a TEXT PRIMARY KEY, b INT, c INTEGER, d REAL, e BLOB, f TEXT(50)) WITHOUT ROWID, STRICT;
+} {1 {unknown datatype for t1.f: "TEXT(50)"}}
+
+do_execsql_test strict1-2.0 {
+ CREATE TABLE t1(
+ a INT,
+ b INTEGER,
+ c BLOB,
+ d TEXT,
+ e REAL
+ ) STRICT;
+} {}
+ifcapable vtab {
+ do_execsql_test strict1-2.0a {
+ SELECT strict FROM pragma_table_list('t1');
+ } {1}
+}
+do_catchsql_test strict1-2.1 {
+ INSERT INTO t1(a) VALUES('xyz');
+} {1 {cannot store TEXT value in INT column t1.a}}
+do_catchsql_test strict1-2.2 {
+ INSERT INTO t1(b) VALUES('xyz');
+} {1 {cannot store TEXT value in INTEGER column t1.b}}
+do_catchsql_test strict1-2.3 {
+ INSERT INTO t1(c) VALUES('xyz');
+} {1 {cannot store TEXT value in BLOB column t1.c}}
+do_catchsql_test strict1-2.4 {
+ INSERT INTO t1(d) VALUES(x'3142536475');
+} {1 {cannot store BLOB value in TEXT column t1.d}}
+do_catchsql_test strict1-2.5 {
+ INSERT INTO t1(e) VALUES('xyz');
+} {1 {cannot store TEXT value in REAL column t1.e}}
+
+
+do_execsql_test strict1-3.1 {
+ INSERT INTO t1(a, b) VALUES(1,2),('3','4'),(5.0, 6.0),(null,null);
+ SELECT a, b, '|' FROM t1;
+} {1 2 | 3 4 | 5 6 | {} {} |}
+do_catchsql_test strict1-3.2 {
+ INSERT INTO t1(a) VALUES(1.2);
+} {1 {cannot store REAL value in INT column t1.a}}
+do_catchsql_test strict1-3.3 {
+ INSERT INTO t1(a) VALUES(x'313233');
+} {1 {cannot store BLOB value in INT column t1.a}}
+do_catchsql_test strict1-3.4 {
+ INSERT INTO t1(b) VALUES(1.2);
+} {1 {cannot store REAL value in INTEGER column t1.b}}
+do_catchsql_test strict1-3.5 {
+ INSERT INTO t1(b) VALUES(x'313233');
+} {1 {cannot store BLOB value in INTEGER column t1.b}}
+
+do_execsql_test strict1-4.1 {
+ DELETE FROM t1;
+ INSERT INTO t1(c) VALUES(x'313233'), (NULL);
+ SELECT typeof(c), c FROM t1;
+} {blob 123 null {}}
+do_catchsql_test strict1-4.2 {
+ INSERT INTO t1(c) VALUES('456');
+} {1 {cannot store TEXT value in BLOB column t1.c}}
+
+do_execsql_test strict1-5.1 {
+ DELETE FROM t1;
+ INSERT INTO t1(d) VALUES('xyz'),(4),(5.5),(NULL);
+ SELECT typeof(d), d FROM t1;
+} {text xyz text 4 text 5.5 null {}}
+do_catchsql_test strict1-5.2 {
+ INSERT INTO t1(d) VALUES(x'4567');
+} {1 {cannot store BLOB value in TEXT column t1.d}}
+
+do_execsql_test strict1-6.1 {
+ DELETE FROM t1;
+ INSERT INTO t1(e) VALUES(1),(2.5),('3'),('4.5'),(6.0),(NULL);
+ SELECT typeof(e), e FROM t1;
+} {real 1.0 real 2.5 real 3.0 real 4.5 real 6.0 null {}}
+do_catchsql_test strict1-6.2 {
+ INSERT INTO t1(e) VALUES('xyz');
+} {1 {cannot store TEXT value in REAL column t1.e}}
+do_catchsql_test strict1-6.3 {
+ INSERT INTO t1(e) VALUES(x'3456');
+} {1 {cannot store BLOB value in REAL column t1.e}}
+
+ifcapable altertable {
+ do_execsql_test strict1-7.1 {
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(
+ a INT AS (b*2) VIRTUAL,
+ b INT AS (c*2) STORED,
+ c INT PRIMARY KEY
+ ) STRICT;
+ INSERT INTO t4(c) VALUES(1);
+ SELECT * FROM t4;
+ } {4 2 1}
+ do_catchsql_test strict1-7.2 {
+ ALTER TABLE t4 ADD COLUMN d VARCHAR;
+ } {1 {error in table t4 after add column: unknown datatype for t4.d: "VARCHAR"}}
+ do_catchsql_test strict1-7.3 {
+ ALTER TABLE t4 ADD COLUMN d;
+ } {1 {error in table t4 after add column: missing datatype for t4.d}}
+}
+
+# 2022-01-17 https://sqlite.org/forum/forumpost/fa012c77796d9399
+#
+reset_db
+do_execsql_test strict1-8.1 {
+ CREATE TABLE csv_import_table (
+ "debit" TEXT,
+ "credit" TEXT
+ );
+ INSERT INTO csv_import_table VALUES ('', '250.00');
+ CREATE TABLE IF NOT EXISTS transactions (
+ debit REAL,
+ credit REAL,
+ amount REAL GENERATED ALWAYS AS (ifnull(credit, 0.0) - ifnull(debit, 0.0))
+ ) STRICT;
+ INSERT INTO transactions
+ SELECT
+ nullif(debit, '') AS debit,
+ nullif(credit, '') AS credit
+ FROM csv_import_table;
+ SELECT * FROM transactions;
+} {{} 250.0 250.0}
+do_execsql_test strict1-8.2 {
+ CREATE TABLE t1(x REAL, y REAL AS (x)) STRICT;
+ INSERT INTO t1 VALUES(5),(4611686018427387904);
+ SELECT *, '|' FROM t1;
+} {/5.0 5.0 4.6116\d*e\+18 4.6116\d+e\+18 |/}
+
+finish_test
diff --git a/test/strict2.test b/test/strict2.test
new file mode 100644
index 0000000..be59522
--- /dev/null
+++ b/test/strict2.test
@@ -0,0 +1,158 @@
+# 2021-08-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 STRICT tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix strict2
+
+# PRAGMA integrity_check on a STRICT table should verify that
+# all of the values are of the correct type.
+#
+do_execsql_test strict2-1.1 {
+ CREATE TABLE t1(
+ a INT,
+ b INTEGER,
+ c TEXT,
+ d REAL,
+ e BLOB
+ ) STRICT;
+ CREATE TABLE t1nn(
+ a INT NOT NULL,
+ b INTEGER NOT NULL,
+ c TEXT NOT NULL,
+ d REAL NOT NULL,
+ e BLOB NOT NULL
+ ) STRICT;
+ CREATE TABLE t2(a,b,c,d,e);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,1,'one',1.0,x'b1'),(2,2,'two',2.25,x'b2b2b2');
+ PRAGMA writable_schema=on;
+ UPDATE sqlite_schema SET rootpage=(SELECT rootpage FROM sqlite_schema WHERE name='t1');
+} {}
+db close
+sqlite3 db test.db
+do_execsql_test strict2-1.2 {
+ PRAGMA quick_check('t1');
+} {ok}
+do_execsql_test strict2-1.3 {
+ UPDATE t2 SET a=2.5 WHERE b=2;
+ PRAGMA quick_check('t1');
+} {{non-INT value in t1.a}}
+do_execsql_test strict2-1.4 {
+ UPDATE t2 SET a='xyz' WHERE b=2;
+ PRAGMA quick_check('t1');
+} {{non-INT value in t1.a}}
+do_execsql_test strict2-1.5 {
+ UPDATE t2 SET a=x'445566' WHERE b=2;
+ PRAGMA quick_check('t1');
+} {{non-INT value in t1.a}}
+do_execsql_test strict2-1.6 {
+ UPDATE t2 SET a=2.5 WHERE b=2;
+ PRAGMA quick_check('t1nn');
+} {{non-INT value in t1nn.a}}
+do_execsql_test strict2-1.7 {
+ UPDATE t2 SET a='xyz' WHERE b=2;
+ PRAGMA quick_check('t1nn');
+} {{non-INT value in t1nn.a}}
+do_execsql_test strict2-1.8 {
+ UPDATE t2 SET a=x'445566' WHERE b=2;
+ PRAGMA quick_check('t1nn');
+} {{non-INT value in t1nn.a}}
+
+do_execsql_test strict2-1.13 {
+ UPDATE t2 SET a=2 WHERE b=2;
+ UPDATE t2 SET b=2.5 WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-INTEGER value in t1.b}}
+do_execsql_test strict2-1.14 {
+ UPDATE t2 SET b='two' WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-INTEGER value in t1.b}}
+do_execsql_test strict2-1.15 {
+ UPDATE t2 SET b=x'b0b1b2b3b4' WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-INTEGER value in t1.b}}
+do_execsql_test strict2-1.16 {
+ UPDATE t2 SET b=NULL WHERE a=2;
+ PRAGMA quick_check('t1');
+} {ok}
+do_execsql_test strict2-1.17 {
+ UPDATE t2 SET b=2.5 WHERE a=2;
+ PRAGMA quick_check('t1nn');
+} {{non-INTEGER value in t1nn.b}}
+do_execsql_test strict2-1.18 {
+ UPDATE t2 SET b=NULL WHERE a=2;
+ PRAGMA quick_check('t1nn');
+} {{NULL value in t1nn.b}}
+
+do_execsql_test strict2-1.23 {
+ UPDATE t2 SET b=2 WHERE a=2;
+ UPDATE t2 SET c=9 WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-TEXT value in t1.c}}
+do_execsql_test strict2-1.24 {
+ UPDATE t2 SET c=9.5 WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-TEXT value in t1.c}}
+do_execsql_test strict2-1.25 {
+ UPDATE t2 SET c=x'b0b1b2b3b4' WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-TEXT value in t1.c}}
+
+do_execsql_test strict2-1.33 {
+ UPDATE t2 SET c='two' WHERE a=2;
+ UPDATE t2 SET d=9 WHERE a=2;
+ PRAGMA quick_check('t1');
+} {ok}
+do_execsql_test strict2-1.34 {
+ UPDATE t2 SET d='nine' WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-REAL value in t1.d}}
+do_execsql_test strict2-1.35 {
+ UPDATE t2 SET d=x'b0b1b2b3b4' WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-REAL value in t1.d}}
+
+do_execsql_test strict2-1.43 {
+ UPDATE t2 SET d=2.5 WHERE a=2;
+ UPDATE t2 SET e=9 WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-BLOB value in t1.e}}
+do_execsql_test strict2-1.44 {
+ UPDATE t2 SET e=9.5 WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-BLOB value in t1.e}}
+do_execsql_test strict2-1.45 {
+ UPDATE t2 SET e='hello' WHERE a=2;
+ PRAGMA quick_check('t1');
+} {{non-BLOB value in t1.e}}
+
+do_execsql_test strict2-2.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INT, b ANY) STRICT;
+ INSERT INTO t2(a,b) VALUES(1,2),(3,4.5),(5,'six'),(7,x'8888'),(9,NULL);
+ PRAGMA integrity_check(t2);
+} {ok}
+
+do_execsql_test strict2-3.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(id ANY PRIMARY KEY, x TEXT);
+ INSERT INTO t1 VALUES(1,2),('three','four'),(x'5555','six'),(NULL,'eight');
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_schema SET sql=(sql||'STRICT') WHERE name='t1';
+ PRAGMA writable_schema=RESET;
+ PRAGMA integrity_check(t1);
+} {{NULL value in t1.id}}
+
+finish_test
diff --git a/test/subjournal.test b/test/subjournal.test
new file mode 100644
index 0000000..8d4c449
--- /dev/null
+++ b/test/subjournal.test
@@ -0,0 +1,69 @@
+# 2017 May 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix subjournal
+
+do_execsql_test 1.0 {
+ PRAGMA temp_store = memory;
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+} {}
+do_execsql_test 1.1 {
+ BEGIN;
+ INSERT INTO t1 VALUES(4, 5, 6);
+ SAVEPOINT one;
+ INSERT INTO t1 VALUES(7, 8, 9);
+ ROLLBACK TO one;
+ SELECT * FROM t1;
+} {1 2 3 4 5 6}
+do_execsql_test 1.2 {
+ COMMIT;
+}
+
+do_execsql_test 2.0 {
+ PRAGMA cache_size = 5;
+ CREATE TABLE t2(a BLOB);
+ CREATE INDEX i2 ON t2(a);
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
+ ) INSERT INTO t2 SELECT randomblob(500) FROM s;
+}
+
+do_test 2.1 {
+ forcedelete test.db2
+ sqlite3 db2 test2.db
+ sqlite3_backup B db2 main db main
+ set nPage [db one {PRAGMA page_count}]
+ B step [expr $nPage-10]
+} {SQLITE_OK}
+
+do_execsql_test 2.2 {
+ BEGIN;
+ UPDATE t2 SET a=randomblob(499);
+ SAVEPOINT two;
+ UPDATE t2 SET a=randomblob(498);
+ ROLLBACK TO two;
+ COMMIT;
+ PRAGMA integrity_check;
+} {ok}
+
+do_test 2.3 {
+ B step 1000
+} {SQLITE_DONE}
+do_test 2.4 {
+ B finish
+ execsql { PRAGMA integrity_check } db2
+} {ok}
+
+finish_test
diff --git a/test/subquery.test b/test/subquery.test
new file mode 100644
index 0000000..a048f9e
--- /dev/null
+++ b/test/subquery.test
@@ -0,0 +1,616 @@
+# 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
+ execsql {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t4 WHERE x IN (SELECT a FROM t3);
+ }
+} {~/t4i/}
+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}
+
+# The following tests check for aggregate subqueries in an aggregate
+# query.
+#
+do_test subquery-3.4.1 {
+ execsql {
+ CREATE TABLE t34(x,y);
+ INSERT INTO t34 VALUES(106,4), (107,3), (106,5), (107,5);
+ SELECT a.x, avg(a.y)
+ FROM t34 AS a
+ GROUP BY a.x
+ HAVING NOT EXISTS( SELECT b.x, avg(b.y)
+ FROM t34 AS b
+ GROUP BY b.x
+ HAVING avg(a.y) > avg(b.y));
+ }
+} {107 4.0}
+do_test subquery-3.4.2 {
+ execsql {
+ SELECT a.x, avg(a.y) AS avg1
+ FROM t34 AS a
+ GROUP BY a.x
+ HAVING NOT EXISTS( SELECT b.x, avg(b.y) AS avg2
+ FROM t34 AS b
+ GROUP BY b.x
+ HAVING avg1 > avg2);
+ }
+} {107 4.0}
+do_test subquery-3.4.3 {
+ execsql {
+ SELECT
+ a.x,
+ avg(a.y),
+ NOT EXISTS ( SELECT b.x, avg(b.y)
+ FROM t34 AS b
+ GROUP BY b.x
+ HAVING avg(a.y) > avg(b.y)),
+ EXISTS ( SELECT c.x, avg(c.y)
+ FROM t34 AS c
+ GROUP BY c.x
+ HAVING avg(a.y) > avg(c.y))
+ FROM t34 AS a
+ GROUP BY a.x
+ ORDER BY a.x;
+ }
+} {106 4.5 0 1 107 4.0 1 0}
+
+do_test subquery-3.5.1 {
+ execsql {
+ CREATE TABLE t35a(x); INSERT INTO t35a VALUES(1),(2),(3);
+ CREATE TABLE t35b(y); INSERT INTO t35b VALUES(98), (99);
+ SELECT max((SELECT avg(y) FROM t35b)) FROM t35a;
+ }
+} {98.5}
+do_test subquery-3.5.2 {
+ execsql {
+ SELECT max((SELECT count(y) FROM t35b)) FROM t35a;
+ }
+} {2}
+do_test subquery-3.5.3 {
+ execsql {
+ SELECT max((SELECT count() FROM t35b)) FROM t35a;
+ }
+} {2}
+do_test subquery-3.5.4 {
+ catchsql {
+ SELECT max((SELECT count(x) FROM t35b)) FROM t35a;
+ }
+} {1 {misuse of aggregate: count()}}
+do_test subquery-3.5.5 {
+ catchsql {
+ SELECT max((SELECT count(x) FROM t35b)) FROM t35a;
+ }
+} {1 {misuse of aggregate: count()}}
+do_test subquery-3.5.6 {
+ catchsql {
+ SELECT max((SELECT a FROM (SELECT count(x) AS a FROM t35b))) FROM t35a;
+ }
+} {1 {misuse of aggregate: count()}}
+do_test subquery-3.5.7 {
+ execsql {
+ SELECT max((SELECT a FROM (SELECT count(y) AS a FROM t35b))) FROM t35a;
+ }
+} {2}
+
+
+#------------------------------------------------------------------
+# 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 initialized
+# 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
+
+# 2015-04-21.
+# Verify that a memory leak in the table column type and collation analysis
+# is plugged.
+#
+do_execsql_test subquery-8.1 {
+ CREATE TABLE t8(a TEXT, b INT);
+ SELECT (SELECT 0 FROM (SELECT * FROM t1)) AS x WHERE x;
+ SELECT (SELECT 0 FROM (SELECT * FROM (SELECT 0))) AS x WHERE x;
+} {}
+
+# 2022-01-12 https://sqlite.org/forum/forumpost/0ec80f12d02acb3f
+#
+reset_db
+do_execsql_test subquery-9.1 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1),(1),(1);
+ SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 100) FROM t1;
+} {{} {} {}}
+do_execsql_test subquery-9.2 {
+ SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 0) FROM t1;
+} {1 1 1}
+do_execsql_test subquery-9.3 {
+ INSERT INTO t1 VALUES(2);
+ SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 1) FROM t1;
+} {2 2 2 2}
+do_execsql_test subquery-9.4 {
+ SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 2) FROM t1;
+} {{} {} {} {}}
+
+finish_test
diff --git a/test/subquery2.test b/test/subquery2.test
new file mode 100644
index 0000000..0c1bdc6
--- /dev/null
+++ b/test/subquery2.test
@@ -0,0 +1,218 @@
+# 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
+set ::testprefix subquery2
+
+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}
+
+#-------------------------------------------------------------------------
+# Test that ticket d6b36be38a has been fixed.
+do_execsql_test 2.1 {
+ CREATE TABLE t4(a, b);
+ CREATE TABLE t5(a, b);
+ INSERT INTO t5 VALUES(3, 5);
+
+ INSERT INTO t4 VALUES(1, 1);
+ INSERT INTO t4 VALUES(2, 3);
+ INSERT INTO t4 VALUES(3, 6);
+ INSERT INTO t4 VALUES(4, 10);
+ INSERT INTO t4 VALUES(5, 15);
+}
+
+do_execsql_test 2.2 {
+ SELECT *
+ FROM (SELECT * FROM t4 ORDER BY a LIMIT -1 OFFSET 1)
+ LIMIT (SELECT a FROM t5)
+} {2 3 3 6 4 10}
+
+############################################################################
+# Ticket http://www.sqlite.org/src/info/d11a6e908f (2014-09-20)
+# Query planner fault on three-way nested join with compound inner SELECT
+#
+do_execsql_test 3.0 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1 (id INTEGER PRIMARY KEY, data TEXT);
+ INSERT INTO t1(id,data) VALUES(9,'nine-a');
+ INSERT INTO t1(id,data) VALUES(10,'ten-a');
+ INSERT INTO t1(id,data) VALUES(11,'eleven-a');
+ CREATE TABLE t2 (id INTEGER PRIMARY KEY, data TEXT);
+ INSERT INTO t2(id,data) VALUES(9,'nine-b');
+ INSERT INTO t2(id,data) VALUES(10,'ten-b');
+ INSERT INTO t2(id,data) VALUES(11,'eleven-b');
+
+ SELECT id FROM (
+ SELECT id,data FROM (
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2
+ )
+ WHERE id=10 ORDER BY data
+ );
+} {10 10}
+do_execsql_test 3.1 {
+ SELECT data FROM (
+ SELECT 'dummy', data FROM (
+ SELECT data FROM t1 UNION ALL SELECT data FROM t1
+ ) ORDER BY data
+ );
+} {eleven-a eleven-a nine-a nine-a ten-a ten-a}
+do_execsql_test 3.2 {
+ DROP TABLE IF EXISTS t3;
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t3(id INTEGER, data TEXT);
+ CREATE TABLE t4(id INTEGER, data TEXT);
+ INSERT INTO t3 VALUES(4, 'a'),(2,'c');
+ INSERT INTO t4 VALUES(3, 'b'),(1,'d');
+
+ SELECT data, id FROM (
+ SELECT id, data FROM (
+ SELECT * FROM t3 UNION ALL SELECT * FROM t4
+ ) ORDER BY data
+ );
+} {a 4 b 3 c 2 d 1}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 4.0 {
+ CREATE TABLE t6(x);
+}
+
+foreach {tn sql} {
+ 1 {
+ SELECT 'abc' FROM (
+ SELECT x FROM t6 ORDER BY 1
+ UNION ALL
+ SELECT x FROM t6
+ )
+ }
+ 2 {
+ SELECT 'abc' FROM (
+ SELECT x FROM t6
+ UNION ALL
+ SELECT x FROM t6 ORDER BY 1
+ UNION ALL
+ SELECT x FROM t6
+ )
+ }
+ 3 {
+ SELECT 'abc' FROM (
+ SELECT x FROM t6 ORDER BY 1
+ UNION ALL
+ SELECT x FROM t6 ORDER BY 1
+ UNION ALL
+ SELECT x FROM t6
+ )
+ }
+ 4 {
+ SELECT 'abc' FROM (
+ SELECT x FROM t6
+ UNION ALL
+ SELECT x FROM t6 ORDER BY 1
+ UNION ALL
+ SELECT x FROM t6 ORDER BY 1
+ UNION ALL
+ SELECT x FROM t6
+ )
+ }
+} {
+ do_catchsql_test 4.$tn $sql [list {*}{
+ 1 {ORDER BY clause should come after UNION ALL not before}
+ }]
+}
+
+#-------------------------------------------------------------------------
+# Test that ticket [9cdc5c46] is fixed.
+#
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('ALFKI');
+ INSERT INTO t1 VALUES('ANATR');
+
+ CREATE TABLE t2(y, z);
+ CREATE INDEX t2y ON t2 (y);
+ INSERT INTO t2 VALUES('ANATR', '1997-08-08 00:00:00');
+ INSERT INTO t2 VALUES('ALFKI', '1997-08-25 00:00:00');
+}
+do_execsql_test 5.1 {
+ SELECT ( SELECT y FROM t2 WHERE x = y ORDER BY y, z) FROM t1;
+} {ALFKI ANATR}
+
+finish_test
diff --git a/test/subselect.test b/test/subselect.test
new file mode 100644
index 0000000..4d0efde
--- /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 {row value misused}}
+
+# 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..16ce080
--- /dev/null
+++ b/test/substr.test
@@ -0,0 +1,158 @@
+# 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.
+#
+
+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 substring($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(substring(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(substring('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 substring($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/subtype1.test b/test/subtype1.test
new file mode 100644
index 0000000..d15f737
--- /dev/null
+++ b/test/subtype1.test
@@ -0,0 +1,59 @@
+# 2015-09-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 tests for sqlite3_value_subtype() and
+# sqlite3_result_subtype() interfaces.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test subtype1-100 {
+ SELECT test_getsubtype('hello');
+} {0}
+do_execsql_test subtype1-110 {
+ SELECT test_getsubtype(test_setsubtype('hello',123));
+} {123}
+do_execsql_test subtype1-120 {
+ SELECT typeof(test_setsubtype('hello',123));
+} {text}
+do_execsql_test subtype1-130 {
+ SELECT test_setsubtype('hello',123);
+} {hello}
+
+# 2022-06-09
+# https://sqlite.org/forum/forumpost/3d9caa45cbe38c78
+#
+# Avoid carrying subtypes through into a subquery that has been flattened
+# or to which the outer WHERE clause has been pushed down.
+#
+reset_db
+do_execsql_test subtype1-200 {
+ CREATE TABLE t1(a); INSERT INTO t1 VALUES ('x');
+ CREATE VIEW t2(b) AS SELECT json(TRUE);
+ CREATE TABLE t3(b); INSERT INTO t3 VALUES(json(TRUE));
+}
+do_execsql_test subtype1-210 {
+ SELECT * FROM t3, t1 WHERE NOT json_quote(b);
+} {1 x}
+do_execsql_test subtype1-220 {
+ SELECT * FROM t2, t1 WHERE NOT json_quote(b);
+} {1 x}
+do_execsql_test subtype1-230 {
+ WITH t4(a) AS MATERIALIZED (SELECT json(1)) SELECT subtype(a) FROM t4;
+} {0}
+do_execsql_test subtype1-231 {
+ WITH t4(a) AS NOT MATERIALIZED (SELECT json(1)) SELECT subtype(a) FROM t4;
+} {0}
+
+
+
+
+finish_test
diff --git a/test/superlock.test b/test/superlock.test
new file mode 100644
index 0000000..704b067
--- /dev/null
+++ b/test/superlock.test
@@ -0,0 +1,268 @@
+# 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
+do_not_use_codec
+
+# 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 } {}
+
+# At this point the WAL file consists of a single frame only - written
+# by test case 3.1. If the ZERO_DAMAGE flag were not set, it would consist
+# of two frames - the frame written by 3.1 and a padding frame.
+do_execsql_test 4.1 { PRAGMA wal_checkpoint } {0 1 1}
+
+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}}
+
+if {[nonzero_reserved_bytes]} {
+ # Vacuum with a size change is not allowed with the codec
+ do_execsql_test 6.11codec {
+ PRAGMA journal_mode = delete;
+ VACUUM;
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(5, 6);
+ } {delete wal}
+} else {
+ 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/swarmvtab.test b/test/swarmvtab.test
new file mode 100644
index 0000000..b4b9448
--- /dev/null
+++ b/test/swarmvtab.test
@@ -0,0 +1,246 @@
+# 2017-07-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 "swarmvtab" extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix swarmvtab
+do_not_use_codec
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+load_static_extension db unionvtab
+
+set nFile $sqlite_open_file_count
+
+do_execsql_test 1.0 {
+ CREATE TABLE t0(a INTEGER PRIMARY KEY, b TEXT);
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<400)
+ INSERT INTO t0 SELECT i, hex(randomblob(50)) FROM s;
+
+ CREATE TABLE dir(f, t, imin, imax);
+}
+
+do_test 1.1 {
+ for {set i 0} {$i < 40} {incr i} {
+ set iMin [expr $i*10 + 1]
+ set iMax [expr $iMin+9]
+
+ forcedelete "test.db$i"
+ execsql [subst {
+ ATTACH 'test.db$i' AS aux;
+ CREATE TABLE aux.t$i (a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO aux.t$i SELECT * FROM t0 WHERE a BETWEEN $iMin AND $iMax;
+ DETACH aux;
+ INSERT INTO dir VALUES('test.db$i', 't$i', $iMin, $iMax);
+ }]
+ }
+
+ execsql {
+ CREATE VIRTUAL TABLE temp.s1 USING swarmvtab('SELECT * FROM dir');
+ }
+} {}
+
+do_execsql_test 1.2 {
+ DROP TABLE s1;
+} {}
+
+do_execsql_test 1.3 {
+ CREATE VIRTUAL TABLE temp.s1 USING swarmvtab('SELECT * FROM dir');
+ SELECT count(*) FROM s1 WHERE rowid<50;
+} {49}
+
+proc do_compare_test {tn where} {
+ set sql [subst {
+ SELECT (SELECT group_concat(a || ',' || b, ',') FROM t0 WHERE $where)
+ IS
+ (SELECT group_concat(a || ',' || b, ',') FROM s1 WHERE $where)
+ }]
+
+ uplevel [list do_execsql_test $tn $sql 1]
+}
+
+do_compare_test 1.4.1 "rowid = 700"
+do_compare_test 1.4.2 "rowid = -1"
+do_compare_test 1.4.3 "rowid = 0"
+do_compare_test 1.4.4 "rowid = 55"
+do_compare_test 1.4.5 "rowid BETWEEN 20 AND 100"
+do_compare_test 1.4.6 "rowid > 350"
+do_compare_test 1.4.7 "rowid >= 350"
+do_compare_test 1.4.8 "rowid >= 200"
+do_compare_test 1.4.9 "1"
+
+# Multiple simultaneous cursors.
+#
+do_execsql_test 1.5.1.(5-seconds-or-so) {
+ SELECT count(*) FROM s1 a, s1 b WHERE b.rowid<=200;
+} {80000}
+do_execsql_test 1.5.2 {
+ SELECT count(*) FROM s1 a, s1 b, s1 c
+ WHERE a.rowid=b.rowid AND b.rowid=c.rowid;
+} {400}
+
+# Empty source tables.
+#
+do_test 1.6.0 {
+ for {set i 0} {$i < 20} {incr i} {
+ sqlite3 db2 test.db$i
+ db2 eval " DELETE FROM t$i "
+ db2 close
+ }
+ db eval { DELETE FROM t0 WHERE rowid<=200 }
+} {}
+
+do_compare_test 1.6.1 "rowid = 700"
+do_compare_test 1.6.2 "rowid = -1"
+do_compare_test 1.6.3 "rowid = 0"
+do_compare_test 1.6.4 "rowid = 55"
+do_compare_test 1.6.5 "rowid BETWEEN 20 AND 100"
+do_compare_test 1.6.6 "rowid > 350"
+do_compare_test 1.6.7 "rowid >= 350"
+do_compare_test 1.6.8 "rowid >= 200"
+do_compare_test 1.6.9 "1"
+do_compare_test 1.6.10 "rowid >= 5"
+
+do_test 1.x {
+ set sqlite_open_file_count
+} [expr $nFile+9]
+
+do_test 1.y { db close } {}
+
+# Delete all the database files created above.
+#
+for {set i 0} {$i < 40} {incr i} { forcedelete "test.db$i" }
+
+#-------------------------------------------------------------------------
+# Test some error conditions:
+#
+# 2.1: Database file does not exist.
+# 2.2: Table does not exist.
+# 2.3: Table schema does not match.
+# 2.4: Syntax error in SELECT statement.
+#
+reset_db
+load_static_extension db unionvtab
+do_test 2.0.1 {
+ db eval {
+ CREATE TABLE t0(a INTEGER PRIMARY KEY, b TEXT);
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<400)
+ INSERT INTO t0 SELECT i, hex(randomblob(50)) FROM s;
+ CREATE TABLE dir(f, t, imin, imax);
+ }
+
+ for {set i 0} {$i < 40} {incr i} {
+ set iMin [expr $i*10 + 1]
+ set iMax [expr $iMin+9]
+
+ forcedelete "test.db$i"
+ db eval [subst {
+ ATTACH 'test.db$i' AS aux;
+ CREATE TABLE aux.t$i (a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO aux.t$i SELECT * FROM t0 WHERE a BETWEEN $iMin AND $iMax;
+ DETACH aux;
+ INSERT INTO dir VALUES('test.db$i', 't$i', $iMin, $iMax);
+ }]
+ }
+ execsql {
+ CREATE VIRTUAL TABLE temp.s1 USING swarmvtab('SELECT * FROM dir');
+ }
+} {}
+
+do_test 2.0.2 {
+ forcedelete test.db5
+
+ sqlite3 db2 test.db15
+ db2 eval { DROP TABLE t15 }
+ db2 close
+
+ sqlite3 db2 test.db25
+ db2 eval {
+ DROP TABLE t25;
+ CREATE TABLE t25(x, y, z PRIMARY KEY);
+ }
+ db2 close
+} {}
+
+do_catchsql_test 2.1 {
+ SELECT * FROM s1 WHERE rowid BETWEEN 1 AND 100;
+} {1 {unable to open database file}}
+do_catchsql_test 2.2 {
+ SELECT * FROM s1 WHERE rowid BETWEEN 101 AND 200;
+} {1 {no such rowid table: t15}}
+do_catchsql_test 2.3 {
+ SELECT * FROM s1 WHERE rowid BETWEEN 201 AND 300;
+} {1 {source table schema mismatch}}
+
+do_catchsql_test 2.4 {
+ CREATE VIRTUAL TABLE temp.x1 USING swarmvtab('SELECT * FROMdir');
+} {1 {sql error: near "FROMdir": syntax error}}
+do_catchsql_test 2.5 {
+ CREATE VIRTUAL TABLE temp.x1 USING swarmvtab('SELECT * FROMdir', 'fetchdb');
+} {1 {sql error: near "FROMdir": syntax error}}
+
+for {set i 0} {$i < 40} {incr i} {
+ forcedelete "test.db$i"
+}
+
+#-------------------------------------------------------------------------
+# Test the outcome of the fetch function throwing an exception.
+#
+proc fetch_db {file} {
+ error "fetch_db error!"
+}
+
+db func fetch_db fetch_db
+
+do_catchsql_test 3.1 {
+ CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
+ 'VALUES
+ (''test.db1'', ''t1'', 1, 10),
+ (''test.db2'', ''t1'', 11, 20)
+ ', 'fetch_db_no_such_function'
+ );
+} {1 {sql error: no such function: fetch_db_no_such_function}}
+
+do_catchsql_test 3.2 {
+ CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
+ 'VALUES
+ (''test.db1'', ''t1'', 1, 10),
+ (''test.db2'', ''t1'', 11, 20)
+ ', 'fetch_db'
+ );
+} {1 {fetch_db error!}}
+
+do_execsql_test 3.3.1 {
+ ATTACH 'test.db1' AS aux;
+ CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO aux.t1 VALUES(1, NULL);
+ INSERT INTO aux.t1 VALUES(2, NULL);
+ INSERT INTO aux.t1 VALUES(9, NULL);
+ DETACH aux;
+ CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
+ 'VALUES
+ (''test.db1'', ''t1'', 1, 10),
+ (''test.db2'', ''t1'', 11, 20)
+ ', 'fetch_db'
+ );
+} {}
+
+do_catchsql_test 3.3.2 { SELECT * FROM xyz } {1 {fetch_db error!}}
+
+
+
+finish_test
diff --git a/test/swarmvtab2.test b/test/swarmvtab2.test
new file mode 100644
index 0000000..1cc7fbb
--- /dev/null
+++ b/test/swarmvtab2.test
@@ -0,0 +1,75 @@
+# 2017-07-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 "swarmvtab" extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix swarmvtab2
+do_not_use_codec
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+
+db close
+foreach name [glob -nocomplain test*.db] {
+ forcedelete $name
+}
+sqlite3 db test.db
+load_static_extension db unionvtab
+proc create_database {filename} {
+ sqlite3 dbx $filename
+ set num [regsub -all {[^0-9]+} $filename {}]
+ set num [string trimleft $num 0]
+ set start [expr {$num*1000}]
+ set end [expr {$start+999}]
+ dbx eval {
+ CREATE TABLE t2(a INTEGER PRIMARY KEY,b);
+ WITH RECURSIVE c(x) AS (
+ VALUES($start) UNION ALL SELECT x+1 FROM c WHERE x<$end
+ )
+ INSERT INTO t2(a,b) SELECT x, printf('**%05d**',x) FROM c;
+ }
+ dbx close
+}
+db func create_database create_database
+do_execsql_test 100 {
+ CREATE TABLE t1(filename, tablename, istart, iend);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<99)
+ INSERT INTO t1 SELECT printf('test%03d.db',x),'t2',x*1000,x*1000+999 FROM c;
+ CREATE VIRTUAL TABLE temp.v1 USING swarmvtab(
+ 'SELECT * FROM t1', 'create_database'
+ );
+} {}
+do_execsql_test 110 {
+ SELECT b FROM v1 WHERE a=3875;
+} {**03875**}
+do_test 120 {
+ lsort [glob -nocomplain test?*.db]
+} {test001.db test003.db}
+do_execsql_test 130 {
+ SELECT b FROM v1 WHERE a BETWEEN 3999 AND 4000 ORDER BY a;
+} {**03999** **04000**}
+do_test 140 {
+ lsort [glob -nocomplain test?*.db]
+} {test001.db test003.db test004.db}
+do_execsql_test 150 {
+ SELECT b FROM v1 WHERE a>=99998;
+} {**99998** **99999**}
+do_test 160 {
+ lsort -dictionary [glob -nocomplain test?*.db]
+} {test001.db test003.db test004.db test099.db}
+
+finish_test
diff --git a/test/swarmvtab3.test b/test/swarmvtab3.test
new file mode 100644
index 0000000..8ca2471
--- /dev/null
+++ b/test/swarmvtab3.test
@@ -0,0 +1,235 @@
+# 2017-07-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 "swarmvtab" extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix swarmvtab3
+do_not_use_codec
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+load_static_extension db unionvtab
+
+set nFile $sqlite_open_file_count
+
+do_execsql_test 1.0 {
+ CREATE TEMP TABLE swarm(id, tbl, minval, maxval);
+}
+
+# Set up 100 databases with filenames "remote_test.dbN", where N is between
+# 0 and 99.
+do_test 1.1 {
+ for {set i 0} {$i < 100} {incr i} {
+ set file remote_test.db$i
+ forcedelete $file
+ forcedelete test.db$i
+ sqlite3 rrr $file
+ rrr eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES($i, $i);
+ }
+ rrr close
+ db eval {
+ INSERT INTO swarm VALUES($i, 't1', $i, $i);
+ }
+ set ::dbcache(test.db$i) 0
+ }
+} {}
+
+proc missing_db {filename} {
+ set remote "remote_$filename"
+ forcedelete $filename
+ file copy $remote $filename
+}
+db func missing_db missing_db
+
+proc openclose_db {filename bClose} {
+ if {$bClose} {
+ incr ::dbcache($filename) -1
+ } else {
+ incr ::dbcache($filename) 1
+ }
+ if {$::dbcache($filename)==0} {
+ forcedelete $filename
+ }
+}
+db func openclose_db openclose_db
+
+proc check_dbcache {} {
+ set n 0
+ for {set i 0} {$i<100} {incr i} {
+ set exists [file exists test.db$i]
+ if {$exists!=($::dbcache(test.db$i)!=0)} {
+ error "inconsistent ::dbcache and disk ($i) - $exists"
+ }
+ incr n $exists
+ }
+ return $n
+}
+
+foreach {tn nMaxOpen cvt} {
+ 1 5 {
+ CREATE VIRTUAL TABLE temp.s USING swarmvtab(
+ 'SELECT :prefix || id, tbl, minval, minval FROM swarm',
+ :prefix='test.db',
+ missing=missing_db,
+ openclose=openclose_db,
+ maxopen=5
+ )
+ }
+
+ 2 3 {
+ CREATE VIRTUAL TABLE temp.s USING swarmvtab(
+ 'SELECT :prefix || id, tbl, minval, minval FROM swarm',
+ :prefix='test.db',
+ missing = 'missing_db',
+ openclose=[openclose_db],
+ maxopen = 3
+ )
+ }
+
+ 3 1 {
+ CREATE VIRTUAL TABLE temp.s USING swarmvtab(
+ 'SELECT :prefix||''.''||:suffix||id, tbl, minval, minval FROM swarm',
+ :prefix=test, :suffix=db,
+ missing = 'missing_db',
+ openclose=[openclose_db],
+ maxopen = 1
+ )
+ }
+
+} {
+ execsql { DROP TABLE IF EXISTS s }
+
+ do_execsql_test 1.$tn.1 $cvt
+
+ do_execsql_test 1.$tn.2 {
+ SELECT b FROM s WHERE a<10;
+ } {0 1 2 3 4 5 6 7 8 9}
+
+ do_test 1.$tn.3 { check_dbcache } $nMaxOpen
+
+ do_execsql_test 1.$tn.4 {
+ SELECT b FROM s WHERE (b%10)=0;
+ } {0 10 20 30 40 50 60 70 80 90}
+
+ do_test 1.$tn.5 { check_dbcache } $nMaxOpen
+}
+
+execsql { DROP TABLE IF EXISTS s }
+for {set i 0} {$i < 100} {incr i} {
+ forcedelete remote_test.db$i
+}
+
+#----------------------------------------------------------------------------
+#
+do_execsql_test 2.0 {
+ DROP TABLE IF EXISTS swarm;
+ CREATE TEMP TABLE swarm(file, tbl, minval, maxval, ctx);
+}
+
+catch { array unset ::dbcache }
+
+# Set up 100 databases with filenames "remote_test.dbN", where N is a
+# random integer between 0 and 1,000,000
+# 0 and 99.
+do_test 2.1 {
+ catch { array unset ctx_used }
+ for {set i 0} {$i < 100} {incr i} {
+ while 1 {
+ set ctx [expr abs(int(rand() *1000000))]
+ if {[info exists ctx_used($ctx)]==0} break
+ }
+ set ctx_used($ctx) 1
+
+ set file test_remote.db$ctx
+ forcedelete $file
+ forcedelete test.db$i
+ sqlite3 rrr $file
+ rrr eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES($i, $i);
+ }
+ rrr close
+ db eval {
+ INSERT INTO swarm VALUES('test.db' || $i, 't1', $i, $i, $file)
+ }
+ set ::dbcache(test.db$i) 0
+ }
+} {}
+
+proc missing_db {filename ctx} {
+ file copy $ctx $filename
+}
+db func missing_db missing_db
+
+proc openclose_db {filename ctx bClose} {
+ if {$bClose} {
+ incr ::dbcache($filename) -1
+ } else {
+ incr ::dbcache($filename) 1
+ }
+ if {$::dbcache($filename)==0} {
+ forcedelete $filename
+ }
+}
+db func openclose_db openclose_db
+
+proc check_dbcache {} {
+ set n 0
+ foreach k [array names ::dbcache] {
+ set exists [file exists $k]
+ if {$exists!=($::dbcache($k)!=0)} {
+ error "inconsistent ::dbcache and disk ($k) - $exists"
+ }
+ incr n $exists
+ }
+ return $n
+}
+
+foreach {tn nMaxOpen cvt} {
+ 2 5 {
+ CREATE VIRTUAL TABLE temp.s USING swarmvtab(
+ 'SELECT file, tbl, minval, minval, ctx FROM swarm',
+ missing=missing_db,
+ openclose=openclose_db,
+ maxopen=5
+ )
+ }
+} {
+ execsql { DROP TABLE IF EXISTS s }
+
+ do_execsql_test 3.$tn.1 $cvt
+
+ do_execsql_test 3.$tn.2 {
+ SELECT b FROM s WHERE a<10;
+ } {0 1 2 3 4 5 6 7 8 9}
+
+ do_test 3.$tn.3 { check_dbcache } $nMaxOpen
+
+ do_execsql_test 3.$tn.4 {
+ SELECT b FROM s WHERE (b%10)=0;
+ } {0 10 20 30 40 50 60 70 80 90}
+
+ do_test 3.$tn.5 { check_dbcache } $nMaxOpen
+}
+
+db close
+forcedelete {*}[glob test.db*]
+forcedelete {*}[glob test_remote.db*]
+
+finish_test
diff --git a/test/swarmvtabfault.test b/test/swarmvtabfault.test
new file mode 100644
index 0000000..8cca3b2
--- /dev/null
+++ b/test/swarmvtabfault.test
@@ -0,0 +1,65 @@
+# 2017-07-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 error handling in the swarmvtab extension.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix swarmvtabfault
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+proc fetch_db {file} {
+ forcedelete $file
+ sqlite3 dbX $file
+ set rc [catch {
+ dbX eval { CREATE TABLE t1(a INTEGER PRIMARY KEY, b) }
+ } res]
+ dbX close
+ if {$rc!=0} {error $res}
+}
+
+forcedelete test.db1
+forcedelete test.db2
+
+do_execsql_test 1.0 {
+ ATTACH 'test.db1' AS aux;
+ CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO aux.t1 VALUES(1, NULL);
+ INSERT INTO aux.t1 VALUES(2, NULL);
+ INSERT INTO aux.t1 VALUES(9, NULL);
+ DETACH aux;
+} {}
+
+faultsim_save_and_close
+do_faultsim_test 1.1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+ db func fetch_db fetch_db
+ load_static_extension db unionvtab
+ db eval {
+ CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
+ 'VALUES
+ ("test.db1", "t1", 1, 10),
+ ("test.db2", "t1", 11, 20)
+ ', 'fetch_db'
+ );
+ }
+} -body {
+ execsql { SELECT a FROM xyz }
+} -test {
+ faultsim_test_result {0 {1 2 9}} {1 {sql error: out of memory}}
+}
+
+finish_test
diff --git a/test/symlink.test b/test/symlink.test
new file mode 100644
index 0000000..98b2a32
--- /dev/null
+++ b/test/symlink.test
@@ -0,0 +1,210 @@
+# 2015 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 that SQLite can follow symbolic links.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix symlink
+
+# This only runs on unix.
+if {$::tcl_platform(platform)!="unix"} {
+ finish_test
+ return
+}
+
+# Ensure that test.db has been created.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+}
+
+# Test that SQLite follows symlinks when opening files.
+#
+forcedelete test.db2
+do_test 1.1 {
+ file link test.db2 test.db
+ sqlite3 db2 test.db2
+ sqlite3_db_filename db2 main
+} [file join [pwd] test.db]
+
+# But not with the -nofollow flag
+#
+do_test 1.1.2 {
+ db2 close
+ set rc [catch {sqlite3 db2 test.db2 -nofollow 1} msg]
+ lappend rc $msg
+} {1 {unable to open database file}}
+
+# If the main database is successfully opened with -nofollow, then -nofollow
+# is also used for ATTACH.
+#
+do_test 1.1.3 {
+ catch {db2 close}
+ sqlite3 db2 test.db -nofollow 1
+} {}
+do_test 1.1.4 {
+ catchsql {ATTACH 'test.db2' AS aux1;} db2
+} {1 {unable to open database: test.db2}}
+
+# Test that if the symlink points to a file that does not exists, it is
+# created when it is opened.
+#
+do_test 1.2.1 {
+ catch {db2 close}
+ db close
+ forcedelete test.db
+ file exists test.db
+} 0
+do_test 1.2.2 {
+ sqlite3 db2 test.db2
+ file exists test.db
+} 1
+do_test 1.2.3 {
+ sqlite3_db_filename db2 main
+} [file join [pwd] test.db]
+db2 close
+
+# Test that a loop of symlinks cannot be opened.
+#
+do_test 1.3 {
+ forcedelete test.db
+ # Note: Tcl [file link] command is too smart to create loops of symlinks.
+ exec ln -s test.db2 test.db
+ list [catch { sqlite3 db test.db } msg] $msg
+} {1 {unable to open database file}}
+
+# Test that overly large paths cannot be opened.
+#
+do_test 1.4 {
+ set name "test.db[string repeat x 502]"
+ list [catch { sqlite3 db $name } msg] $msg
+} {1 {unable to open database file}}
+do_test 1.5 {
+ set r [expr 510 - [string length test.db] - [string length [pwd]]]
+ set name "test.db[string repeat x $r]"
+ list [catch { sqlite3 db $name } msg] $msg
+} {1 {unable to open database file}}
+
+#-------------------------------------------------------------------------
+# Test that journal and wal files are created next to the real file,
+# not the symlink.
+#
+do_test 2.0 {
+ catch { db close }
+ catch { db2 close }
+ forcedelete test.db test.db2 test.db3
+ sqlite3 db test.db
+ execsql { CREATE TABLE t1(x) }
+ file link test.db2 test.db
+ file link test.db3 test.db2
+ set {} {}
+} {}
+
+foreach {tn f} {1 test.db2 2 test.db3} {
+ do_test 2.$tn.1 {
+ sqlite3 db2 $f
+ file exists test.db-journal
+ } 0
+ do_test 2.$tn.2 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(1);
+ } db2
+ file exists test.db-journal
+ } [expr [atomic_batch_write test.db]==0]
+ do_test 2.$tn.3 {
+ list [file exists test2.db-journal] [file exists test3.db-journal]
+ } {0 0}
+ do_test 2.$tn.4 {
+ execsql {
+ COMMIT;
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(2);
+ } db2
+ file exists test.db-wal
+ } 1
+ do_test 2.$tn.5 {
+ list [file exists test2.db-wal] [file exists test3.db-wal]
+ } {0 0}
+ do_execsql_test 2.$tn.6 {
+ SELECT * FROM t1;
+ } {1 2}
+ db2 close
+ do_execsql_test 2.$tn.7 {
+ DELETE FROM t1;
+ PRAGMA journal_mode = delete;
+ } delete
+}
+
+# Try to open a ridiculously long pathname. Bug found by
+# Kostya Serebryany using libFuzzer on 2015-11-30.
+#
+do_test 3.1 {
+ db close
+ catch {sqlite3 db [string repeat [string repeat x 100]/ 6]} res
+ set res
+} {unable to open database file}
+
+#-------------------------------------------------------------------------
+# Test that relative symlinks that are not located in the cwd work.
+#
+do_test 4.1 {
+ forcedelete x y z
+ file mkdir x
+ file mkdir y
+ file mkdir z
+ sqlite3 db x/test.db
+ file link y/test.db ../x/test.db
+ file link z/test.db ../y/test.db
+ execsql {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('hello', 'world');
+ }
+} {wal}
+
+do_test 4.2.1 {
+ db close
+ sqlite3 db y/test.db
+ db eval { SELECT * FROM t1 }
+} {hello world}
+do_test 4.2.2 {
+ list [file exists x/test.db-wal] [file exists y/test.db-wal]
+} {1 0}
+
+do_test 4.3.1 {
+ db close
+ sqlite3 db z/test.db
+ db eval { SELECT * FROM t1 }
+} {hello world}
+do_test 4.3.2 {
+ list [file exists x/test.db-wal] [file exists y/test.db-wal] \
+ [file exists z/test.db-wal]
+} {1 0 0}
+
+do_test 4.4.0 {
+ forcedelete w
+ file mkdir w
+ file link w/test.db [file join [pwd] x/test.db]
+ set {} {}
+} {}
+do_test 4.4.1 {
+ db close
+ sqlite3 db w/test.db
+ db eval { SELECT * FROM t1 }
+} {hello world}
+do_test 4.4.2 {
+ list [file exists x/test.db-wal] [file exists w/test.db-wal]
+} {1 0}
+
+finish_test
diff --git a/test/symlink2.test b/test/symlink2.test
new file mode 100644
index 0000000..4123092
--- /dev/null
+++ b/test/symlink2.test
@@ -0,0 +1,116 @@
+# 2019 November 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 that SQLite can follow symbolic links.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix symlink2
+
+# This only runs on Windows.
+if {$::tcl_platform(platform)!="windows"} {
+ finish_test
+ return
+}
+
+proc createWin32Symlink { link target } {
+ exec -- $::env(ComSpec) /c mklink \
+ [file nativename $link] [file nativename $target]
+ return ""
+}
+
+proc deleteWin32Symlink { link } {
+ exec -- $::env(ComSpec) /c del [file nativename $link]
+ return ""
+}
+
+proc canCreateWin32Symlink {} {
+ set link [file join $::testdir lnk[pid].sym]
+ if {[file exists $link]} { return 0 }
+ set target [info nameofexecutable]
+ if {[catch {createWin32Symlink $link $target}] == 0} {
+ deleteWin32Symlink $link
+ return 1
+ }
+ return 0
+}
+
+# Creating symlinks may require administrator privileges on Windows.
+if {![canCreateWin32Symlink]} {
+ finish_test
+ return
+}
+
+# Ensure that test.db has been created.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1,9999);
+}
+
+do_test 2.0 {
+ createWin32Symlink link.db test.db
+} {}
+
+do_test 2.1 {
+ file exists test.db
+} {1}
+
+do_test 2.2 {
+ file exists link.db
+} {1}
+
+do_test 3.1 {
+ execsql { SELECT x, y FROM t1; } db
+} {1 9999}
+
+do_test 3.2 {
+ sqlite3 db2 link.db
+ execsql { SELECT x, y FROM t1; } db2
+} {1 9999}
+
+do_test 3.3 {
+ sqlite3 db3 test.db -nofollow true
+ execsql { SELECT x, y FROM t1; } db3
+} {1 9999}
+
+do_test 3.4 {
+ db3 close
+} {}
+
+do_test 3.5 {
+ list [catch {
+ sqlite3 db4 link.db -nofollow true
+ execsql { SELECT x, y FROM t1; } db4
+ } res] $res
+} {1 {unable to open database file}}
+
+catch {db4 close}
+
+do_test 4.0 {
+ db2 close
+ deleteWin32Symlink link.db
+} {}
+
+do_test 4.1 {
+ file exists test.db
+} {1}
+
+do_test 4.2 {
+ file exists link.db
+} {0}
+
+do_test 5.1 {
+ execsql { SELECT x, y FROM t1; } db
+} {1 9999}
+
+finish_test
diff --git a/test/sync.test b/test/sync.test
new file mode 100644
index 0000000..023425e
--- /dev/null
+++ b/test/sync.test
@@ -0,0 +1,105 @@
+# 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.
+#
+
+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
+}
+if {[atomic_batch_write test.db]} {
+ 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
+ } else {
+ 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 4
+ set sqlite_sync_count
+ } 9
+}
+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 4
+ set sqlite_sync_count
+} 11
+ifcapable pager_pragmas {
+if {[permutation]!="journaltest"} {
+ 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/sync2.test b/test/sync2.test
new file mode 100644
index 0000000..89e66c8
--- /dev/null
+++ b/test/sync2.test
@@ -0,0 +1,161 @@
+# 2017 March 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.
+#
+# Specificly, it tests that "PRAGMA synchronous" appears to work.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix sync2
+
+#
+# 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||!dirsync {
+ finish_test
+ return
+}
+if {$::tcl_platform(platform)!="unix"
+ || [permutation] == "journaltest"
+ || [permutation] == "inmemory_journal"
+ || [atomic_batch_write test.db]
+} {
+ finish_test
+ return
+}
+
+proc execsql_sync {sql} {
+ set s $::sqlite_sync_count
+ set res [execsql $sql]
+ concat [expr $::sqlite_sync_count-$s] $res
+}
+
+proc do_execsql_sync_test {tn sql res} {
+ uplevel [list do_test $tn [list execsql_sync $sql] [list {*}$res]]
+}
+
+#-----------------------------------------------------------------------
+# Tests for journal mode.
+#
+sqlite3 db test.db
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+}
+
+do_execsql_sync_test 1.1 { INSERT INTO t1 VALUES(3, 4) } 4
+
+# synchronous=normal. So, 1 sync on the directory, 1 on the journal, 1
+# on the db file. 3 in total.
+do_execsql_test 1.2.1 { PRAGMA main.synchronous = NORMAL }
+do_execsql_test 1.2.2 { PRAGMA main.synchronous } 1
+do_execsql_sync_test 1.2.3 { INSERT INTO t1 VALUES(5, 6) } 3
+
+# synchronous=off. No syncs.
+do_execsql_test 1.3.1 { PRAGMA main.synchronous = OFF }
+do_execsql_test 1.3.2 { PRAGMA main.synchronous } 0
+do_execsql_sync_test 1.3.3 { INSERT INTO t1 VALUES(7, 8) } 0
+
+# synchronous=full, journal_mode=delete. So, 1 sync on the directory,
+# 2 on the journal, 1 on the db file. 4 in total.
+do_execsql_test 1.4.1 { PRAGMA main.synchronous = FULL }
+do_execsql_test 1.4.2 { PRAGMA main.synchronous } 2
+do_execsql_sync_test 1.4.3 { INSERT INTO t1 VALUES(9, 10) } 4
+
+#-----------------------------------------------------------------------
+# Tests for wal mode.
+#
+do_execsql_test 1.5 { PRAGMA journal_mode = wal } {wal}
+
+# sync=full, journal_mode=wal. One sync on the directory, two on the
+# wal file.
+do_execsql_sync_test 1.6 { INSERT INTO t1 VALUES(11, 12) } 3
+
+# One sync on the wal file.
+do_execsql_sync_test 1.7 { INSERT INTO t1 VALUES(13, 14) } 1
+
+# No syncs.
+do_execsql_test 1.8.1 { PRAGMA main.synchronous = NORMAL }
+do_execsql_test 1.8.2 { PRAGMA main.synchronous } 1
+do_execsql_sync_test 1.8.3 { INSERT INTO t1 VALUES(15, 16) } 0
+
+# One sync on wal file, one on the db file.
+do_execsql_sync_test 1.9 { PRAGMA wal_checkpoint } {2 0 3 3}
+
+# No syncs.
+do_execsql_test 1.10.1 { PRAGMA main.synchronous = OFF }
+do_execsql_test 1.10.2 { PRAGMA main.synchronous } 0
+do_execsql_sync_test 1.10.3 { INSERT INTO t1 VALUES(17, 18) } 0
+
+#-----------------------------------------------------------------------
+# Tests for the compile time settings SQLITE_DEFAULT_SYNCHRONOUS and
+# SQLITE_DEFAULT_WAL_SYNCHRONOUS. These tests only run if the former
+# is set to "2" and the latter to "1". This is not the default, but
+# it is currently the recommended configuration.
+#
+# https://sqlite.org/compile.html#recommended_compile_time_options
+#
+if {$SQLITE_DEFAULT_SYNCHRONOUS==2 && $SQLITE_DEFAULT_WAL_SYNCHRONOUS==1} {
+
+ db close
+ sqlite3 db test.db
+
+ # Wal mode, sync=normal. The first transaction does one sync on directory,
+ # one on the wal file. The second does no syncs.
+ do_execsql_sync_test 1.11.1 { INSERT INTO t1 VALUES(19, 20) } 2
+ do_execsql_sync_test 1.11.2 { INSERT INTO t1 VALUES(21, 22) } 0
+ do_execsql_test 1.11.3 { PRAGMA main.synchronous } 1
+
+ # One sync on wal file, one on the db file.
+ do_execsql_sync_test 1.12 { PRAGMA wal_checkpoint } {2 0 2 2}
+
+ # First transaction syncs the wal file once, the second not at all.
+ # one on the wal file. The second does no syncs.
+ do_execsql_sync_test 1.13.1 { INSERT INTO t1 VALUES(22, 23) } 1
+ do_execsql_sync_test 1.13.2 { INSERT INTO t1 VALUES(24, 25) } 0
+
+ do_execsql_test 1.14 { PRAGMA journal_mode = delete } {delete}
+
+ # Delete mode, sync=full. The first transaction does one sync on
+ # directory, two on the journal file, one on the db. The second does
+ # the same.
+ do_execsql_sync_test 1.15.1 { INSERT INTO t1 VALUES(26, 27) } 4
+ do_execsql_sync_test 1.15.2 { INSERT INTO t1 VALUES(28, 29) } 4
+ do_execsql_test 1.15.3 { PRAGMA main.synchronous } 2
+
+ # Switch back to wal mode.
+ do_execsql_test 1.16 { PRAGMA journal_mode = wal } {wal}
+
+ do_execsql_sync_test 1.17.1 { INSERT INTO t1 VALUES(30, 31) } 2
+ do_execsql_sync_test 1.17.2 { INSERT INTO t1 VALUES(32, 33) } 0
+ do_execsql_test 1.17.3 { PRAGMA main.synchronous } 1
+
+ # Now set synchronous=off, then switch back to delete mode. Check
+ # that the db handle is still using synchronous=off.
+ do_execsql_test 1.18.3 { PRAGMA main.synchronous=off }
+ do_execsql_test 1.18 { PRAGMA journal_mode = delete } {delete}
+
+ do_execsql_sync_test 1.19.1 { INSERT INTO t1 VALUES(34, 35) } 0
+ do_execsql_sync_test 1.19.2 { INSERT INTO t1 VALUES(36, 37) } 0
+ do_execsql_test 1.19.3 { PRAGMA main.synchronous } 0
+
+ # Close and reopen the db. Back to synchronous=normal.
+ db close
+ sqlite3 db test.db
+ do_execsql_sync_test 1.20.1 { INSERT INTO t1 VALUES(38, 39) } 4
+ do_execsql_sync_test 1.20.2 { INSERT INTO t1 VALUES(40, 41) } 4
+ do_execsql_test 1.20.3 { PRAGMA main.synchronous } 2
+}
+
+finish_test
diff --git a/test/syscall.test b/test/syscall.test
new file mode 100644
index 0000000..19313a5
--- /dev/null
+++ b/test/syscall.test
@@ -0,0 +1,278 @@
+# 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 mkdir rmdir
+ statvfs fchown geteuid umask mmap munmap mremap
+ getpagesize readlink lstat ioctl
+} {
+ 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 not a database}}
+ 3 {1 {file 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..4c3d34d
--- /dev/null
+++ b/test/sysfault.test
@@ -0,0 +1,278 @@
+# 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 {
+ PRAGMA synchronous=OFF;
+ 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}
+}
+
+#-------------------------------------------------------------------------
+# Test errors in mmap().
+#
+proc vfsfault_install {} {
+ test_syscall reset
+ test_syscall install {mmap}
+}
+
+faultsim_delete_and_reopen
+execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+}
+faultsim_save_and_close
+
+do_faultsim_test 4 -faults vfsfault-* -prep {
+ faultsim_restore_and_reopen
+ file_control_chunksize_test db main 8192
+ execsql {
+ PRAGMA mmap_size = 1000000;
+ }
+} -body {
+ test_syscall errno mmap EACCES
+
+ execsql {
+ SELECT * FROM t1;
+ }
+} -test {
+ faultsim_test_result {0 {1 2}} {1 {disk I/O error}}
+}
+
+finish_test
diff --git a/test/tabfunc01.test b/test/tabfunc01.test
new file mode 100644
index 0000000..0a7e3bc
--- /dev/null
+++ b/test/tabfunc01.test
@@ -0,0 +1,331 @@
+# 2015-08-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 table-valued-functions implemented using
+# eponymous virtual tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tabfunc01
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+load_static_extension db series
+load_static_extension db carray
+load_static_extension db remember
+
+do_execsql_test tabfunc01-1.1 {
+ SELECT *, '|' FROM generate_series WHERE start=1 AND stop=9 AND step=2;
+} {1 | 3 | 5 | 7 | 9 |}
+do_execsql_test tabfunc01-1.1b {
+ PRAGMA table_xinfo(generate_series);
+} {0 value {} 0 {} 0 0 1 start {} 0 {} 0 1 2 stop {} 0 {} 0 1 3 step {} 0 {} 0 1}
+do_execsql_test tabfunc01-1.2 {
+ SELECT *, '|' FROM generate_series(0) LIMIT 5;
+} {0 | 1 | 2 | 3 | 4 |}
+do_catchsql_test tabfunc01-1.2b {
+ SELECT *, '|' FROM generate_series LIMIT 5;
+} {1 {first argument to "generate_series()" missing or unusable}}
+do_catchsql_test tabfunc01-1.2c {
+ SELECT *, '|' FROM generate_series(value) LIMIT 5;
+} {1 {first argument to "generate_series()" missing or unusable}}
+do_catchsql_test tabfunc01-1.3 {
+ CREATE VIRTUAL TABLE t1 USING generate_series;
+} {1 {no such module: generate_series}}
+do_execsql_test tabfunc01-1.4 {
+ SELECT * FROM generate_series(1,9,2);
+} {1 3 5 7 9}
+do_execsql_test tabfunc01-1.5 {
+ SELECT * FROM generate_series(1,9);
+} {1 2 3 4 5 6 7 8 9}
+do_execsql_test tabfunc01-1.6 {
+ SELECT * FROM generate_series(1,10) WHERE step=3;
+} {1 4 7 10}
+do_catchsql_test tabfunc01-1.7 {
+ SELECT * FROM generate_series(1,9,2,11);
+} {1 {too many arguments on generate_series() - max 3}}
+
+do_execsql_test tabfunc01-1.8 {
+ SELECT * FROM generate_series(0,32,5) ORDER BY rowid DESC;
+} {30 25 20 15 10 5 0}
+do_execsql_test tabfunc01-1.9 {
+ SELECT rowid, * FROM generate_series(0,32,5) ORDER BY value DESC;
+} {1 30 2 25 3 20 4 15 5 10 6 5 7 0}
+do_execsql_test tabfunc01-1.10 {
+ SELECT rowid, * FROM generate_series(0,32,5) ORDER BY +value DESC;
+} {7 30 6 25 5 20 4 15 3 10 2 5 1 0}
+
+do_execsql_test tabfunc01-1.20 {
+ CREATE VIEW v1(a,b) AS VALUES(1,2),(3,4);
+ SELECT * FROM v1;
+} {1 2 3 4}
+do_catchsql_test tabfunc01-1.21.1 {
+ SELECT * FROM v1(55);
+} {1 {'v1' is not a function}}
+do_catchsql_test tabfunc01-1.21.2 {
+ SELECT * FROM v1();
+} {1 {'v1' is not a function}}
+do_execsql_test tabfunc01-1.22 {
+ CREATE VIEW v2(x) AS SELECT value FROM generate_series(1,5);
+ SELECT * FROM v2;
+} {1 2 3 4 5}
+do_catchsql_test tabfunc01-1.23.1 {
+ SELECT * FROM v2(55);
+} {1 {'v2' is not a function}}
+do_catchsql_test tabfunc01-1.23.2 {
+ SELECT * FROM v2();
+} {1 {'v2' is not a function}}
+do_execsql_test tabfunc01-1.24 {
+ CREATE TABLE t0(x);
+ INSERT INTO t0(x) VALUES(123),(456),(789);
+ SELECT * FROM t0 ORDER BY x;
+} {123 456 789}
+do_catchsql_test tabfunc01-1.25 {
+ SELECT * FROM t0(55) ORDER BY x;
+} {1 {'t0' is not a function}}
+do_catchsql_test tabfunc01-1.26 {
+ WITH w0 AS (SELECT * FROM t0)
+ INSERT INTO t0(x) SELECT * FROM w0()
+} {1 {'w0' is not a function}}
+
+do_execsql_test tabfunc01-2.1 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(2),(3);
+ SELECT *, '|' FROM t1, generate_series(1,x) ORDER BY 1, 2
+} {2 1 | 2 2 | 3 1 | 3 2 | 3 3 |}
+do_execsql_test tabfunc01-2.2 {
+ SELECT *, '|' FROM (SELECT x FROM t1) AS y, generate_series(1,y.x)
+ ORDER BY 1, 2;
+} {2 1 | 2 2 | 3 1 | 3 2 | 3 3 |}
+
+do_execsql_test tabfunc01-2.50 {
+ SELECT * FROM generate_series(0) LIMIT 5;
+} {0 1 2 3 4}
+
+do_execsql_test tabfunc01-3.1 {
+ SELECT DISTINCT value FROM generate_series(1,x), t1 ORDER BY 1;
+} {1 2 3}
+
+do_eqp_test tabfunc01-3.10 {
+ SELECT value FROM generate_series(1,10) ORDER BY value;
+} {
+ QUERY PLAN
+ `--SCAN generate_series VIRTUAL TABLE INDEX 19:
+}
+do_eqp_test tabfunc01-3.11 {
+ SELECT value FROM generate_series(1,10) ORDER BY +value;
+} {
+ QUERY PLAN
+ |--SCAN generate_series VIRTUAL TABLE INDEX 3:
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_eqp_test tabfunc01-3.12 {
+ SELECT value FROM generate_series(1,10) ORDER BY value, stop;
+} {
+ QUERY PLAN
+ `--SCAN generate_series VIRTUAL TABLE INDEX 19:
+}
+do_eqp_test tabfunc01-3.13 {
+ SELECT value FROM generate_series(1,10) ORDER BY stop, value;
+} {
+ QUERY PLAN
+ |--SCAN generate_series VIRTUAL TABLE INDEX 3:
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+
+do_eqp_test tabfunc01-3.20 {
+ WITH t1(a) AS (
+ SELECT value FROM generate_series(0,10,2)
+ UNION ALL
+ SELECT value FROM generate_series(9,18,3)
+ )
+ SELECT * FROM t1 ORDER BY a;
+} {
+ QUERY PLAN
+ `--MERGE (UNION ALL)
+ |--LEFT
+ | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+ `--RIGHT
+ `--SCAN generate_series VIRTUAL TABLE INDEX 23:
+}
+
+
+# Eponymous virtual table exists in all schemas.
+#
+do_execsql_test tabfunc01-4.1 {
+ SELECT * FROM main.generate_series(1,4)
+} {1 2 3 4}
+do_execsql_test tabfunc01-4.2 {
+ SELECT * FROM temp.generate_series(1,4)
+} {1 2 3 4}
+do_execsql_test tabfunc01-4.3 {
+ ATTACH ':memory:' AS aux1;
+ CREATE TABLE aux1.t1(a,b,c);
+ SELECT * FROM aux1.generate_series(1,4)
+} {1 2 3 4}
+
+# 2018-12-03: Fix bug reported by by private email.
+do_execsql_test tabfunc01-4.4 {
+ SELECT * FROM (generate_series(1,5,2)) AS x LIMIT 10;
+} {1 3 5}
+
+# The next series of tests is verifying that virtual table are able
+# to optimize the IN operator, even on terms that are not marked "omit".
+# When the generate_series virtual table is compiled for the testfixture,
+# the special -DSQLITE_SERIES_CONSTRAINT_VERIFY=1 option is used, which
+# causes the xBestIndex method of generate_series to leave the
+# sqlite3_index_constraint_usage.omit flag set to 0, which should cause
+# the SQLite core to verify the start=, stop=, and step= constraints on
+# each step of output. At one point, the IN operator could not be used
+# by virtual tables unless omit was set.
+#
+do_execsql_test tabfunc01-500 {
+ SELECT * FROM generate_series WHERE start IN (1,7) AND stop=20 AND step=10
+ ORDER BY +1;
+} {1 7 11 17}
+
+# Table-valued functions on the RHS of an IN operator
+#
+do_execsql_test tabfunc01-600 {
+ CREATE TABLE t600(a INTEGER PRIMARY KEY, b TEXT);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t600(a,b) SELECT x, printf('(%03d)',x) FROM c;
+ SELECT b FROM t600 WHERE a IN generate_series(2,52,10);
+} {(002) (012) (022) (032) (042) (052)}
+
+
+do_test tabfunc01-700 {
+ set PTR1 [intarray_addr 5 7 13 17 23]
+ db eval {
+ SELECT b FROM t600, carray(inttoptr($PTR1),5) WHERE a=value;
+ }
+} {(005) (007) (013) (017) (023)}
+do_test tabfunc01-701 {
+ db eval {
+ SELECT b FROM t600 WHERE a IN carray(inttoptr($PTR1),5,'int32');
+ }
+} {(005) (007) (013) (017) (023)}
+do_test tabfunc01-702 {
+ db eval {
+ SELECT b FROM t600 WHERE a IN carray(inttoptr($PTR1),4,'int32');
+ }
+} {(005) (007) (013) (017)}
+do_catchsql_test tabfunc01-710 {
+ SELECT b FROM t600 WHERE a IN carray(inttoptr($PTR1),5,'int33');
+} {1 {unknown datatype: 'int33'}}
+
+do_test tabfunc01-720 {
+ set PTR2 [int64array_addr 5 7 13 17 23]
+ db eval {
+ SELECT b FROM t600, carray(inttoptr($PTR2),5,'int64') WHERE a=value;
+ }
+} {(005) (007) (013) (017) (023)}
+do_test tabfunc01-721 {
+ db eval {
+ SELECT remember(123,inttoptr($PTR2));
+ SELECT value FROM carray(inttoptr($PTR2),5,'int64');
+ }
+} {123 123 7 13 17 23}
+do_test tabfunc01-722 {
+ set PTR3 [expr {$PTR2+16}]
+ db eval {
+ SELECT remember(987,inttoptr($PTR3));
+ SELECT value FROM carray(inttoptr($PTR2),5,'int64');
+ }
+} {987 123 7 987 17 23}
+
+do_test tabfunc01-730 {
+ set PTR4 [doublearray_addr 5.0 7.0 13.0 17.0 23.0]
+ db eval {
+ SELECT b FROM t600, carray(inttoptr($PTR4),5,'double') WHERE a=value;
+ }
+} {(005) (007) (013) (017) (023)}
+
+do_test tabfunc01-740 {
+ set PTR5 [textarray_addr x5 x7 x13 x17 x23]
+ db eval {
+ SELECT b FROM t600, carray(inttoptr($PTR5),5,'char*')
+ WHERE a=trim(value,'x');
+ }
+} {(005) (007) (013) (017) (023)}
+
+do_test tabfunc01-750 {
+ db eval {
+ SELECT aa.value, bb.value, '|'
+ FROM carray(inttoptr($PTR4),5,'double') AS aa
+ JOIN carray(inttoptr($PTR5),5,'char*') AS bb ON aa.rowid=bb.rowid;
+ }
+} {5.0 x5 | 7.0 x7 | 13.0 x13 | 17.0 x17 | 23.0 x23 |}
+
+# ticket https://www.sqlite.org/src/info/2ae0c599b735d59e
+do_test tabfunc01-751 {
+ db eval {
+ SELECT aa.value, bb.value, '|'
+ FROM carray(inttoptr($PTR4),5,'double') AS aa
+ LEFT JOIN carray(inttoptr($PTR5),5,'char*') AS bb ON aa.rowid=bb.rowid;
+ }
+} {5.0 x5 | 7.0 x7 | 13.0 x13 | 17.0 x17 | 23.0 x23 |}
+
+ifcapable altertable {
+ do_test tabfunc01-800 {
+ catchsql {
+ ALTER TABLE generate_series ADD COLUMN col2;
+ }
+ } {1 {virtual tables may not be altered}}
+ do_test tabfunc01-810 {
+ catchsql {
+ ALTER TABLE generate_series RENAME TO flubber;
+ }
+ } {1 {table generate_series may not be altered}}
+ do_test tabfunc01-820 {
+ catchsql {
+ ALTER TABLE generate_series RENAME start TO flubber;
+ }
+ } {1 {table generate_series may not be altered}}
+ do_test tabfunc01-830 {
+ catchsql {
+ ALTER TABLE generate_series DROP COLUMN start;
+ }
+ } {1 {table generate_series may not be altered}}
+ do_test tabfunc01-900 {
+ catchsql {
+ ALTER TABLE pragma_compile_options ADD COLUMN col2;
+ }
+ } {1 {virtual tables may not be altered}}
+ do_test tabfunc01-910 {
+ catchsql {
+ ALTER TABLE pragma_compile_options RENAME TO flubber;
+ }
+ } {1 {table pragma_compile_options may not be altered}}
+ do_test tabfunc01-920 {
+ catchsql {
+ ALTER TABLE pragma_compile_options RENAME start TO flubber;
+ }
+ } {1 {table pragma_compile_options may not be altered}}
+ do_test tabfunc01-930 {
+ catchsql {
+ ALTER TABLE pragma_compile_options DROP COLUMN start;
+ }
+ } {1 {table pragma_compile_options may not be altered}}
+}
+
+
+# Free up memory allocations
+intarray_addr
+int64array_addr
+doublearray_addr
+textarray_addr
+
+finish_test
diff --git a/test/table.test b/test/table.test
new file mode 100644
index 0000000..7be6b37
--- /dev/null
+++ b/test/table.test
@@ -0,0 +1,840 @@
+# 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.
+#
+
+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;
+ DROP TABLE IF EXISTS sqlite_stat4;
+ SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_stat*';
+ }
+} {}
+
+do_test table-5.2.2 {
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ sqlite3_db_config db DEFENSIVE 0
+ db eval {
+ CREATE TABLE t0(a,b);
+ CREATE INDEX t ON t0(a);
+ PRAGMA writable_schema=ON;
+ UPDATE sqlite_master SET sql='CREATE TABLE a.b(a UNIQUE';
+ BEGIN;
+ CREATE TABLE t1(x);
+ ROLLBACK;
+ DROP TABLE IF EXISTS t99;
+ }
+} {}
+db close
+forcedelete test.db
+sqlite3 db test.db
+
+# 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 {NOT NULL constraint failed: t6.a}}
+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}
+} {}
+
+# Ticket 3a88d85f36704eebe134f7f48aebf00cd6438c1a (2014-08-05)
+# The following SQL script segfaults while running the INSERT statement:
+#
+# CREATE TABLE t1(x DEFAULT(max(1)));
+# INSERT INTO t1(rowid) VALUES(1);
+#
+# The problem appears to be the use of an aggregate function as part of
+# the default value for a column. This problem has been in the code since
+# at least 2006-01-01 and probably before that. This problem was detected
+# and reported on the sqlite-users@sqlite.org mailing list by Zsbán Ambrus.
+#
+do_execsql_test table-16.1 {
+ CREATE TABLE t16(x DEFAULT(max(1)));
+ INSERT INTO t16(x) VALUES(123);
+ SELECT rowid, x FROM t16;
+} {1 123}
+do_catchsql_test table-16.2 {
+ INSERT INTO t16(rowid) VALUES(4);
+} {1 {unknown function: max()}}
+do_execsql_test table-16.3 {
+ DROP TABLE t16;
+ CREATE TABLE t16(x DEFAULT(abs(1)));
+ INSERT INTO t16(rowid) VALUES(4);
+ SELECT rowid, x FROM t16;
+} {4 1}
+do_catchsql_test table-16.4 {
+ DROP TABLE t16;
+ CREATE TABLE t16(x DEFAULT(avg(1)));
+ INSERT INTO t16(rowid) VALUES(123);
+ SELECT rowid, x FROM t16;
+} {1 {unknown function: avg()}}
+do_catchsql_test table-16.5 {
+ DROP TABLE t16;
+ CREATE TABLE t16(x DEFAULT(count()));
+ INSERT INTO t16(rowid) VALUES(123);
+ SELECT rowid, x FROM t16;
+} {1 {unknown function: count()}}
+do_catchsql_test table-16.6 {
+ DROP TABLE t16;
+ CREATE TABLE t16(x DEFAULT(group_concat('x',',')));
+ INSERT INTO t16(rowid) VALUES(123);
+ SELECT rowid, x FROM t16;
+} {1 {unknown function: group_concat()}}
+do_catchsql_test table-16.7 {
+ INSERT INTO t16 DEFAULT VALUES;
+} {1 {unknown function: group_concat()}}
+
+# Ticket [https://www.sqlite.org/src/info/094d39a4c95ee4abbc417f04214617675ba15c63]
+# describes a assertion fault that occurs on a CREATE TABLE .. AS SELECT statement.
+# the following test verifies that the problem has been fixed.
+#
+do_execsql_test table-17.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a TEXT);
+ INSERT INTO t1(a) VALUES(1),(2);
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x TEXT, y TEXT);
+ INSERT INTO t2(x,y) VALUES(3,4);
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3 AS
+ SELECT a AS p, coalesce(y,a) AS q FROM t1 LEFT JOIN t2 ON a=x;
+ SELECT p, q, '|' FROM t3 ORDER BY p;
+} {1 1 | 2 2 |}
+
+# 2015-06-16
+# Ticket [https://www.sqlite.org/src/tktview/873cae2b6e25b1991ce5e9b782f9cd0409b96063]
+# Make sure a CREATE TABLE AS statement correctly rolls back partial changes to the
+# sqlite_master table when the SELECT on the right-hand side aborts.
+#
+do_catchsql_test table-18.1 {
+ DROP TABLE IF EXISTS t1;
+ BEGIN;
+ CREATE TABLE t1 AS SELECT zeroblob(2e20);
+} {1 {string or blob too big}}
+do_execsql_test table-18.2 {
+ COMMIT;
+ PRAGMA integrity_check;
+} {ok}
+
+# 2015-09-09
+# Ticket [https://www.sqlite.org/src/info/acd12990885d9276]
+# "CREATE TABLE ... AS SELECT ... FROM sqlite_master" fails because the row
+# in the sqlite_master table for the next table is initially populated
+# with a NULL instead of a record created by OP_Record.
+#
+do_execsql_test table-19.1 {
+ CREATE TABLE t19 AS SELECT * FROM sqlite_master;
+ SELECT name FROM t19 ORDER BY name;
+} {{} savepoint t10 t11 t12 t13 t16 t2 t3 t3\"xyz t4\"abc t7 t8 t9 tablet8 test1 weird}
+
+
+
+finish_test
diff --git a/test/tableapi.test b/test/tableapi.test
new file mode 100644
index 0000000..02633cd
--- /dev/null
+++ b/test/tableapi.test
@@ -0,0 +1,252 @@
+# 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
+}
+
+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}
+
+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/tableopts.test b/test/tableopts.test
new file mode 100644
index 0000000..0b2457e
--- /dev/null
+++ b/test/tableopts.test
@@ -0,0 +1,76 @@
+# 2013-10-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.
+#
+#***********************************************************************
+#
+# Test the operation of table-options in the WITH clause of the
+# CREATE TABLE statement.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tableopt-1.1 {
+ catchsql {
+ CREATE TABLE t1(a,b) WITHOUT rowid;
+ }
+} {1 {PRIMARY KEY missing on table t1}}
+do_test tableopt-1.1b {
+ catchsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT,b) WITHOUT rowid;
+ }
+} {1 {AUTOINCREMENT not allowed on WITHOUT ROWID tables}}
+do_test tableopt-1.2 {
+ catchsql {
+ CREATE TABLE t1(a,b) WITHOUT unknown2;
+ }
+} {1 {unknown table option: unknown2}}
+
+do_execsql_test tableopt-2.1 {
+ CREATE TABLE t1(a, b, c, PRIMARY KEY(a,b)) WITHOUT rowid;
+ INSERT INTO t1 VALUES(1,2,3),(2,3,4);
+ SELECT c FROM t1 WHERE a IN (1,2) ORDER BY b;
+} {3 4}
+do_test tableopt-2.1.1 {
+ catchsql {
+ SELECT rowid, * FROM t1;
+ }
+} {1 {no such column: rowid}}
+do_test tableopt-2.1.2 {
+ catchsql {
+ SELECT _rowid_, * FROM t1;
+ }
+} {1 {no such column: _rowid_}}
+do_test tableopt-2.1.3 {
+ catchsql {
+ SELECT oid, * FROM t1;
+ }
+} {1 {no such column: oid}}
+do_execsql_test tableopt-2.2 {
+ VACUUM;
+ SELECT c FROM t1 WHERE a IN (1,2) ORDER BY b;
+} {3 4}
+do_test tableopt-2.3 {
+ sqlite3 db2 test.db
+ db2 eval {SELECT c FROM t1 WHERE a IN (1,2) ORDER BY b;}
+} {3 4}
+db2 close
+
+# Make sure the "without" keyword is still usable as a table or
+# column name.
+#
+do_execsql_test tableopt-3.1 {
+ CREATE TABLE without(x INTEGER PRIMARY KEY, without TEXT);
+ INSERT INTO without VALUES(1, 'xyzzy'), (2, 'fizzle');
+ SELECT * FROM without WHERE without='xyzzy';
+} {1 xyzzy}
+
+
+finish_test
diff --git a/test/tclsqlite.test b/test/tclsqlite.test
new file mode 100644
index 0000000..0758abd
--- /dev/null
+++ b/test/tclsqlite.test
@@ -0,0 +1,892 @@
+# 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 $
+
+catch {sqlite3}
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tcl
+
+# Check the error messages generated by tclsqlite
+#
+set r "sqlite_orig HANDLE ?FILENAME? ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nofollow BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?"
+if {[sqlite3 -has-codec]} {
+ append r " ?-key CODECKEY?"
+}
+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.1.1 {
+ set v [catch {sqlite3} 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, bind_fallback, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, config, copy, deserialize, enable_load_extension, errorcode, erroroffset, eval, exists, function, incrblob, interrupt, last_insert_rowid, nullvalue, onecolumn, preupdate, profile, progress, rekey, restore, rollback_hook, serialize, status, timeout, total_changes, trace, trace_v2, 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 ?OPTIONS? 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 ?SWITCHES? 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.22 {
+ 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.23 {
+ 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}
+proc concatFunc args {return [join $args {}]}
+do_test tcl-8.2 {
+ db function concat concatFunc
+ db eval {SELECT concat('a', b, 'z') FROM t1 WHERE b is NULL}
+} {aNaNz}
+do_test tcl-8.3 {
+ db nullvalue NULL
+ db nullvalue
+} {NULL}
+do_test tcl-8.4 {
+ db nullvalue {}
+ db eval {SELECT * FROM t1 WHERE b IS NULL}
+} {30 {}}
+do_test tcl-8.5 {
+ db function concat concatFunc
+ db eval {SELECT concat('a', b, 'z') FROM t1 WHERE b is NULL}
+} {az}
+
+# 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}
+ # Fails under -fsanitize=address,undefined due to stack overflow
+ # 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'}
+} {}
+
+# Verify that the "exists" and "onecolumn" methods work when
+# a "profile" is registered.
+#
+catch {db close}
+sqlite3 db :memory:
+proc noop-profile {args} {
+ return
+}
+do_test tcl-15.0 {
+ db eval {CREATE TABLE t1(a); INSERT INTO t1 VALUES(1),(2),(3);}
+ db onecolumn {SELECT a FROM t1 WHERE a>2}
+} {3}
+do_test tcl-15.1 {
+ db exists {SELECT a FROM t1 WHERE a>2}
+} {1}
+do_test tcl-15.2 {
+ db exists {SELECT a FROM t1 WHERE a>3}
+} {0}
+db profile noop-profile
+do_test tcl-15.3 {
+ db onecolumn {SELECT a FROM t1 WHERE a>2}
+} {3}
+do_test tcl-15.4 {
+ db exists {SELECT a FROM t1 WHERE a>2}
+} {1}
+do_test tcl-15.5 {
+ db exists {SELECT a FROM t1 WHERE a>3}
+} {0}
+
+
+# 2017-06-26: The --withoutnulls flag to "db eval".
+#
+# In the "db eval --withoutnulls SQL ARRAY" form, NULL results cause the
+# corresponding array entry to be unset. The default behavior (without
+# the -withoutnulls flags) is for the corresponding array value to get
+# the [db nullvalue] string.
+#
+catch {db close}
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test tcl-16.100 {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2),(2,NULL),(3,'xyz');
+}
+do_test tcl-16.101 {
+ set res {}
+ unset -nocomplain x
+ db eval {SELECT * FROM t1} x {
+ lappend res $x(a) [array names x]
+ }
+ set res
+} {1 {a b *} 2 {a b *} 3 {a b *}}
+do_test tcl-16.102 {
+ set res [catch {
+ db eval -unknown {SELECT * FROM t1} x {
+ lappend res $x(a) [array names x]
+ }
+ } rc]
+ lappend res $rc
+} {1 {unknown option: "-unknown"}}
+do_test tcl-16.103 {
+ set res {}
+ unset -nocomplain x
+ db eval -withoutnulls {SELECT * FROM t1} x {
+ lappend res $x(a) [array names x]
+ }
+ set res
+} {1 {a b *} 2 {a *} 3 {a b *}}
+
+#-------------------------------------------------------------------------
+# Test the -type option to [db function].
+#
+reset_db
+proc add {a b} { return [expr $a + $b] }
+proc ret {a} { return $a }
+
+db function add_i -returntype integer add
+db function add_r -ret real add
+db function add_t -return text add
+db function add_b -returntype blob add
+db function add_a -returntype any add
+
+db function ret_i -returntype int ret
+db function ret_r -returntype real ret
+db function ret_t -returntype text ret
+db function ret_b -returntype blob ret
+db function ret_a -r any ret
+
+do_execsql_test 17.0 {
+ SELECT quote( add_i(2, 3) );
+ SELECT quote( add_r(2, 3) );
+ SELECT quote( add_t(2, 3) );
+ SELECT quote( add_b(2, 3) );
+ SELECT quote( add_a(2, 3) );
+} {5 5.0 '5' X'35' 5}
+
+do_execsql_test 17.1 {
+ SELECT quote( add_i(2.2, 3.3) );
+ SELECT quote( add_r(2.2, 3.3) );
+ SELECT quote( add_t(2.2, 3.3) );
+ SELECT quote( add_b(2.2, 3.3) );
+ SELECT quote( add_a(2.2, 3.3) );
+} {5.5 5.5 '5.5' X'352E35' 5.5}
+
+do_execsql_test 17.2 {
+ SELECT quote( ret_i(2.5) );
+ SELECT quote( ret_r(2.5) );
+ SELECT quote( ret_t(2.5) );
+ SELECT quote( ret_b(2.5) );
+ SELECT quote( ret_a(2.5) );
+} {2.5 2.5 '2.5' X'322E35' 2.5}
+
+do_execsql_test 17.3 {
+ SELECT quote( ret_i('2.5') );
+ SELECT quote( ret_r('2.5') );
+ SELECT quote( ret_t('2.5') );
+ SELECT quote( ret_b('2.5') );
+ SELECT quote( ret_a('2.5') );
+} {2.5 2.5 '2.5' X'322E35' '2.5'}
+
+do_execsql_test 17.4 {
+ SELECT quote( ret_i('abc') );
+ SELECT quote( ret_r('abc') );
+ SELECT quote( ret_t('abc') );
+ SELECT quote( ret_b('abc') );
+ SELECT quote( ret_a('abc') );
+} {'abc' 'abc' 'abc' X'616263' 'abc'}
+
+do_execsql_test 17.5 {
+ SELECT quote( ret_i(X'616263') );
+ SELECT quote( ret_r(X'616263') );
+ SELECT quote( ret_t(X'616263') );
+ SELECT quote( ret_b(X'616263') );
+ SELECT quote( ret_a(X'616263') );
+} {'abc' 'abc' 'abc' X'616263' X'616263'}
+
+do_test 17.6.1 {
+ list [catch { db function xyz -return object ret } msg] $msg
+} {1 {bad type "object": must be integer, real, text, blob, or any}}
+
+do_test 17.6.2 {
+ list [catch { db function xyz -return ret } msg] $msg
+} {1 {option requires an argument: -return}}
+
+do_test 17.6.3 {
+ list [catch { db function xyz -n object ret } msg] $msg
+} {1 {bad option "-n": must be -argcount, -deterministic, -directonly, -innocuous, or -returntype}}
+
+# 2019-02-28: The "bind_fallback" command.
+#
+do_test 18.100 {
+ unset -nocomplain bindings abc def ghi jkl mno e01 e02
+ set bindings(abc) [expr {1+2}]
+ set bindings(def) {hello}
+ set bindings(ghi) [expr {3.1415926*1.0}]
+ proc bind_callback {nm} {
+ global bindings
+ set n2 [string range $nm 1 end]
+ if {[info exists bindings($n2)]} {
+ return $bindings($n2)
+ }
+ if {[string match e* $n2]} {
+ error "no such variable: $nm"
+ }
+ return -code return {}
+ }
+ db bind_fallback bind_callback
+ db eval {SELECT $abc, typeof($abc), $def, typeof($def), $ghi, typeof($ghi)}
+} {3 integer hello text 3.1415926 real}
+do_test 18.110 {
+ db eval {SELECT quote(@def), typeof(@def)}
+} {X'68656C6C6F' blob}
+do_execsql_test 18.120 {
+ SELECT typeof($mno);
+} {null}
+do_catchsql_test 18.130 {
+ SELECT $e01;
+} {1 {no such variable: $e01}}
+do_test 18.140 {
+ db bind_fallback
+} {bind_callback}
+do_test 18.200 {
+ db bind_fallback {}
+ db eval {SELECT $abc, typeof($abc), $def, typeof($def), $ghi, typeof($ghi)}
+} {{} null {} null {} null}
+do_test 18.300 {
+ unset -nocomplain bindings
+ proc bind_callback {nm} {lappend ::bindings $nm}
+ db bind_fallback bind_callback
+ db eval {SELECT $abc, @def, $ghi(123), :mno}
+ set bindings
+} {{$abc} @def {$ghi(123)} :mno}
+do_test 18.900 {
+ set rc [catch {db bind_fallback a b} msg]
+ lappend rc $msg
+} {1 {wrong # args: should be "db bind_fallback ?CALLBACK?"}}
+do_test 18.910 {
+ db bind_fallback bind_fallback_does_not_exist
+} {}
+do_catchsql_test 19.911 {
+ SELECT $abc, typeof($abc), $def, typeof($def), $ghi, typeof($ghi);
+} {1 {invalid command name "bind_fallback_does_not_exist"}}
+db bind_fallback {}
+
+#-------------------------------------------------------------------------
+do_test 20.0 {
+ db transaction {
+ db close
+ }
+} {}
+
+do_test 20.1 {
+ sqlite3 db test.db
+ set rc [catch {
+ db eval {SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3} { db close }
+ } msg]
+ list $rc $msg
+} {1 {invalid command name "db"}}
+
+
+proc closedb {} {
+ db close
+ return 10
+}
+proc func1 {} { return 1 }
+
+sqlite3 db test.db
+db func closedb closedb
+db func func1 func1
+
+do_test 20.2 {
+ set rc [catch {
+ db eval {
+ SELECT closedb(),func1() UNION ALL SELECT 20,30 UNION ALL SELECT 30,40
+ }
+ } msg]
+ list $rc $msg
+} {0 {10 1 20 30 30 40}}
+
+sqlite3 db :memory:
+do_test 21.1 {
+ catch {db eval {SELECT 1 2 3;}} msg
+ db erroroffset
+} {9}
+
+finish_test
diff --git a/test/tempdb.test b/test/tempdb.test
new file mode 100644
index 0000000..a32ef06
--- /dev/null
+++ b/test/tempdb.test
@@ -0,0 +1,98 @@
+# 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
+
+if {[atomic_batch_write test.db]} {
+ finish_test
+ return
+}
+
+# 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)]
+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/tempdb2.test b/test/tempdb2.test
new file mode 100644
index 0000000..37cb4b3
--- /dev/null
+++ b/test/tempdb2.test
@@ -0,0 +1,99 @@
+# 2016 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.
+#
+#***********************************************************************
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tempdb2
+
+db close
+sqlite3 db ""
+
+set unlocked unlocked
+if {$::TEMP_STORE>=2} { set unlocked unknown }
+
+proc int2str {i} { string range [string repeat "$i." 450] 0 899 }
+db func int2str int2str
+
+#-------------------------------------------------------------------------
+#
+# 1.1: Write a big transaction to the db. One so large that it forces
+# the file to be created and the cache flushed to disk on COMMIT.
+#
+# 1.2: Write a small transaction - one small enough that it remains in
+# memory on COMMIT. All the pages of table [t1] are now dirty.
+#
+# 1.3: Delete the contents of [t1]. This moves all of its leaves to the
+# free-list and causes the btree layer to call PagerDontWrite() on
+# each of them.
+#
+# Then do a big update on table [t2]. So big that the former leaves
+# of [t1] are forced out of the cache. Then roll back the transaction.
+# If the PagerDontWrite() calls are honoured and the data is not written
+# to disk, the update made in test 1.2 will be lost at this point. Or, if
+# they are ignored (as they should be for temp databases), the update
+# will be safely written out to disk before the cache entries are
+# discarded.
+#
+do_execsql_test 1.1 {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=50;
+
+ BEGIN;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, int2str(1));
+ INSERT INTO t1 VALUES(2, int2str(1));
+ INSERT INTO t1 VALUES(3, int2str(1));
+
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ WITH c(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100 )
+ INSERT INTO t2 SELECT x, int2str(x) FROM c;
+ COMMIT;
+
+ PRAGMA lock_status;
+} [list main $unlocked temp closed]
+
+do_execsql_test 1.2 {
+ UPDATE t1 SET b=int2str(2);
+ SELECT b=int2str(2) FROM t1
+} {1 1 1}
+
+do_execsql_test 1.3 {
+ BEGIN;
+ DELETE FROM t1;
+ UPDATE t2 SET b=int2str(a+1);
+ ROLLBACK;
+}
+
+do_execsql_test 1.4 {
+ SELECT b=int2str(2) FROM t1
+} {1 1 1}
+
+#-------------------------------------------------------------------------
+db close
+sqlite3 db ""
+db func int2str int2str
+
+do_execsql_test 2.0 {
+ PRAGMA cache_size = -100;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ WITH c(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100 )
+ INSERT INTO t1 SELECT x, int2str(x) FROM c;
+}
+
+do_execsql_test 2.1 {
+ INSERT INTO t1 VALUES(10001, int2str(1001) || int2str(1001) || int2str(1001));
+}
+
+do_execsql_test 2.2 {
+ SELECT b FROM t1 WHERE a = 10001;
+} "[int2str 1001][int2str 1001][int2str 1001]"
+
+finish_test
diff --git a/test/tempfault.test b/test/tempfault.test
new file mode 100644
index 0000000..4eae116
--- /dev/null
+++ b/test/tempfault.test
@@ -0,0 +1,134 @@
+# 2016 April 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 contains tests for fault-injection when SQLite is used with
+# a temp file database.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix tempfault
+
+# sqlite3_memdebug_vfs_oom_test 0
+
+do_faultsim_test 1 -faults * -prep {
+ sqlite3 db ""
+ db eval {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+} -body {
+ execsql { INSERT INTO t1 VALUES(5, 6) }
+} -test {
+ faultsim_test_result {0 {}}
+ set rc [catch { execsql { SELECT * FROM t1 } } msg]
+ if {$rc==0 && $msg != "1 2 3 4 5 6" && $msg != "1 2 3 4"} {
+ error "data mismatch 1: $msg"
+ }
+ if {$testrc==0 && $msg != "1 2 3 4 5 6"} {
+ error "data mismatch 2: $msg"
+ }
+ faultsim_integrity_check
+}
+
+do_faultsim_test 2 -faults * -prep {
+ sqlite3 db ""
+ db eval {
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b, a);
+ WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100)
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+ }
+} -body {
+ execsql { UPDATE t1 SET a = randomblob(99) }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check db
+}
+
+catch { db close }
+do_faultsim_test 2.1 -faults * -prep {
+ if {[info commands db]==""} {
+ sqlite3 db ""
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b, a);
+ WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100)
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+ }
+ }
+} -body {
+ execsql { UPDATE t1 SET a = randomblob(99) }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check db
+}
+
+do_faultsim_test 3 -faults * -prep {
+ sqlite3 db ""
+ db eval {
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b, a);
+ WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<50)
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+ }
+} -body {
+ execsql {
+ BEGIN;
+ UPDATE t1 SET a = randomblob(99);
+ SAVEPOINT abc;
+ UPDATE t1 SET a = randomblob(98) WHERE (rowid%10)==0;
+ ROLLBACK TO abc;
+ UPDATE t1 SET a = randomblob(97) WHERE (rowid%5)==0;
+ ROLLBACK TO abc;
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check db
+}
+
+do_faultsim_test 4 -faults * -prep {
+ sqlite3 db ""
+ db eval {
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b, a);
+ WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<50)
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+ }
+} -body {
+ execsql {
+ BEGIN;
+ UPDATE t1 SET a = randomblob(99);
+ SAVEPOINT abc;
+ UPDATE t1 SET a = randomblob(98) WHERE (rowid%10)==0;
+ ROLLBACK TO abc;
+ UPDATE t1 SET a = randomblob(97) WHERE (rowid%5)==0;
+ ROLLBACK TO abc;
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+sqlite3_memdebug_vfs_oom_test 1
+finish_test
diff --git a/test/temptable.test b/test/temptable.test
new file mode 100644
index 0000000..6a1e2b9
--- /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 existence 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/temptable2.test b/test/temptable2.test
new file mode 100644
index 0000000..2ee4adb
--- /dev/null
+++ b/test/temptable2.test
@@ -0,0 +1,360 @@
+# 2016 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.
+#
+#***********************************************************************
+#
+# TESTRUNNER: slow
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix temptable2
+
+do_execsql_test 1.1 {
+ CREATE TEMP TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+}
+
+do_execsql_test 1.2 {
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100000 )
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM X;
+} {}
+
+do_execsql_test 1.3 {
+ PRAGMA temp.integrity_check;
+} {ok}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 2.1 {
+ CREATE TEMP TABLE t2(a, b);
+ INSERT INTO t2 VALUES(1, 2);
+} {}
+
+do_execsql_test 2.2 {
+ BEGIN;
+ INSERT INTO t2 VALUES(3, 4);
+ SELECT * FROM t2;
+} {1 2 3 4}
+
+do_execsql_test 2.3 {
+ ROLLBACK;
+ SELECT * FROM t2;
+} {1 2}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 3.1.1 {
+ PRAGMA main.cache_size = 10;
+ PRAGMA temp.cache_size = 10;
+
+ CREATE TEMP TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<1000 )
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+
+ SELECT count(*) FROM t1;
+} {1000}
+do_execsql_test 3.1.2 {
+ BEGIN;
+ UPDATE t1 SET b=randomblob(100) WHERE (rowid%10)==0;
+ ROLLBACK;
+}
+do_execsql_test 3.1.3 {
+ SELECT count(*) FROM t1;
+} {1000}
+do_execsql_test 3.1.4 { PRAGMA temp.integrity_check } {ok}
+
+do_execsql_test 3.2.1 {
+ BEGIN;
+ UPDATE t1 SET b=randomblob(100) WHERE (rowid%10)==0;
+ SAVEPOINT abc;
+ UPDATE t1 SET b=randomblob(100) WHERE (rowid%10)==1;
+ ROLLBACK TO abc;
+ UPDATE t1 SET b=randomblob(100) WHERE (rowid%10)==2;
+ COMMIT;
+}
+do_execsql_test 3.2.2 { PRAGMA temp.integrity_check } {ok}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 4.1.1 {
+ PRAGMA main.cache_size = 10;
+ PRAGMA temp.cache_size = 10;
+
+ CREATE TEMP TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<10 )
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+
+ SELECT count(*) FROM t1;
+ PRAGMA temp.page_count;
+} {10 9}
+
+do_execsql_test 4.1.2 {
+ BEGIN;
+ UPDATE t1 SET b=randomblob(100);
+ ROLLBACK;
+}
+
+do_execsql_test 4.1.3 {
+ CREATE TEMP TABLE t2(a, b);
+ CREATE INDEX i2 ON t2(a, b);
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )
+ INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x;
+
+ SELECT count(*) FROM t2;
+ SELECT count(*) FROM t1;
+} {500 10}
+
+do_test 4.1.4 {
+ set n [db one { PRAGMA temp.page_count }]
+ expr ($n >280 && $n < 300)
+} 1
+
+do_execsql_test 4.1.4 { PRAGMA temp.integrity_check } {ok}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 5.1.1 {
+ PRAGMA main.cache_size = 10;
+ PRAGMA temp.cache_size = 10;
+
+ CREATE TEMP TABLE t2(a, b);
+ CREATE INDEX i2 ON t2(a, b);
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )
+ INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x;
+
+ CREATE TEMP TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+}
+
+# Test that the temp database is now much bigger than the configured
+# cache size (10 pages).
+do_test 5.1.2 {
+ set n [db one { PRAGMA temp.page_count }]
+ expr ($n > 270 && $n < 290)
+} {1}
+
+do_execsql_test 5.1.3 {
+ BEGIN;
+ UPDATE t1 SET a=2;
+ UPDATE t2 SET a=randomblob(100);
+ SELECT count(*) FROM t1;
+ ROLLBACK;
+} {1}
+
+do_execsql_test 5.1.4 {
+ UPDATE t2 SET a=randomblob(100);
+
+ SELECT * FROM t1;
+} {1 2}
+
+do_execsql_test 5.1.5 { PRAGMA temp.integrity_check } {ok}
+
+#-------------------------------------------------------------------------
+# Test this:
+#
+# 1. Page is DIRTY at the start of a transaction.
+# 2. Page is written out as part of the transaction.
+# 3. Page is then read back in.
+# 4. Transaction is rolled back. Is the page now clean or dirty?
+#
+# This actually does work. Step 4 marks the page as clean. But it also
+# writes to the database file itself. So marking it clean is correct -
+# the page does match the contents of the db file.
+#
+reset_db
+
+do_execsql_test 6.1 {
+ PRAGMA main.cache_size = 10;
+ PRAGMA temp.cache_size = 10;
+
+ CREATE TEMP TABLE t1(x);
+ INSERT INTO t1 VALUES('one');
+
+ CREATE TEMP TABLE t2(a, b);
+ CREATE INDEX i2 ON t2(a, b);
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )
+ INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x;
+}
+
+do_execsql_test 6.2 {
+ UPDATE t1 SET x='two'; -- step 1
+ BEGIN;
+ UPDATE t2 SET a=randomblob(100); -- step 2
+ SELECT * FROM t1; -- step 3
+ ROLLBACK; -- step 4
+
+ SELECT count(*) FROM t2;
+ SELECT * FROM t1;
+} {two 500 two}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+sqlite3 db ""
+do_execsql_test 7.1 {
+ 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;
+ PRAGMA integrity_check;
+} {ok}
+
+#-------------------------------------------------------------------------
+# Try changing the page size using a backup operation when pages are
+# stored in main-memory only.
+#
+reset_db
+do_execsql_test 8.1 {
+ PRAGMA auto_vacuum = OFF;
+ CREATE TABLE t2(a, b);
+ CREATE INDEX i2 ON t2(a, b);
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<20 )
+ INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x ORDER BY 1, 2;
+ PRAGMA page_count;
+} {13}
+
+do_test 8.2 {
+ sqlite3 tmp ""
+ execsql {
+ PRAGMA auto_vacuum = OFF;
+ PRAGMA page_size = 8192;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100 )
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x ORDER BY 1, 2;
+ PRAGMA page_count;
+ } tmp
+} {10}
+
+do_test 8.3 {
+ sqlite3_backup B tmp main db main
+ B step 5
+ B finish
+} {SQLITE_READONLY}
+
+do_test 8.4 {
+ execsql {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ PRAGMA page_size;
+ } tmp
+} {100 ok 8192}
+
+do_test 8.5 {
+ tmp eval { UPDATE t1 SET a=randomblob(100) }
+} {}
+
+do_test 8.6 {
+ sqlite3_backup B tmp main db main
+ B step 1000
+ B finish
+} {SQLITE_READONLY}
+
+tmp close
+
+#-------------------------------------------------------------------------
+# Try inserts and deletes with a large db in auto-vacuum mode. Check
+#
+foreach {tn mode} {
+ 1 delete
+ 2 wal
+} {
+ reset_db
+ sqlite3 db ""
+ do_execsql_test 9.$tn.1.1 {
+ PRAGMA cache_size = 15;
+ PRAGMA auto_vacuum = 1;
+ }
+ execsql "PRAGMA journal_mode = $mode"
+
+ do_execsql_test 9.$tn.1.2 {
+ CREATE TABLE tx(a, b);
+ CREATE INDEX i1 ON tx(a);
+ CREATE INDEX i2 ON tx(b);
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<1000 )
+ INSERT INTO tx SELECT randomblob(100), randomblob(100) FROM x;
+ }
+
+ for {set i 2} {$i<20} {incr i} {
+ do_execsql_test 9.$tn.$i.1 { DELETE FROM tx WHERE (random()%3)==0 }
+
+ do_execsql_test 9.$tn.$i.2 { PRAGMA integrity_check } ok
+
+ do_execsql_test 9.$tn.$i.3 {
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<400 )
+ INSERT INTO tx SELECT randomblob(100), randomblob(100) FROM x;
+ }
+
+ do_execsql_test 9.$tn.$i.4 { PRAGMA integrity_check } ok
+
+ do_execsql_test 9.$tn.$i.5 {
+ BEGIN;
+ DELETE FROM tx WHERE (random()%3)==0;
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )
+ INSERT INTO tx SELECT randomblob(100), randomblob(100) FROM x;
+ COMMIT;
+ }
+
+ do_execsql_test 9.$tn.$i.6 { PRAGMA integrity_check } ok
+ }
+}
+
+#-------------------------------------------------------------------------
+# When using mmap mode with a temp file, SQLite must search the cache
+# before using a mapped page even when there is no write transaction
+# open. For a temp file, the on-disk version may not be up to date.
+#
+sqlite3 db ""
+do_execsql_test 10.0 {
+ PRAGMA cache_size = 50;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b, PRIMARY KEY(a)) WITHOUT ROWID;
+ CREATE INDEX i1 ON t1(a);
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES(1, 2);
+}
+
+do_execsql_test 10.1 {
+ BEGIN;
+ WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+ COMMIT;
+ INSERT INTO t2 VALUES(3, 4);
+}
+
+ifcapable mmap {
+ if {[permutation]!="journaltest" && $::TEMP_STORE<2} {
+ # The journaltest permutation does not support mmap, so this part of
+ # the test is omitted.
+ do_execsql_test 10.2 { PRAGMA mmap_size = 512000 } 512000
+ }
+}
+
+do_execsql_test 10.3 { SELECT * FROM t2 } {1 2 3 4}
+do_execsql_test 10.4 { PRAGMA integrity_check } ok
+
+finish_test
diff --git a/test/temptable3.test b/test/temptable3.test
new file mode 100644
index 0000000..16f51d7
--- /dev/null
+++ b/test/temptable3.test
@@ -0,0 +1,41 @@
+# 2016-05-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.
+#
+#***********************************************************************
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix temptable3
+
+db close
+sqlite3 db {}
+do_execsql_test 1.1 {
+ PRAGMA cache_size = 1;
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 2;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES( randomblob(800) );
+ INSERT INTO t1 VALUES( randomblob(800) );
+ CREATE TABLE t2(x);
+ PRAGMA integrity_check;
+} {ok}
+
+db close
+sqlite3 db {}
+do_execsql_test 1.2 {
+ PRAGMA cache_size = 1;
+ PRAGMA auto_vacuum = 2;
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(x UNIQUE);
+ INSERT INTO t2 VALUES(1), (2), (3);
+ DROP TABLE t1;
+ PRAGMA integrity_check;
+} {ok}
+
+finish_test
diff --git a/test/temptrigger.test b/test/temptrigger.test
new file mode 100644
index 0000000..e4277ad
--- /dev/null
+++ b/test/temptrigger.test
@@ -0,0 +1,279 @@
+# 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
+set testprefix temptrigger
+
+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 }
+
+
+#-------------------------------------------------------------------------
+# Test that creating a temp table after a temp trigger on the same name
+# has been created is an error.
+#
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1(x);
+ CREATE TEMP TRIGGER tr1 BEFORE INSERT ON t1 BEGIN
+ SELECT 1,2,3;
+ END;
+}
+
+do_execsql_test 4.1 {
+ CREATE TEMP TABLE t1(x);
+}
+
+#-------------------------------------------------------------------------
+# Test that no harm is done if the table a temp trigger is attached to is
+# deleted by an external connection.
+#
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(x);
+ CREATE TEMP TRIGGER tr1 BEFORE INSERT ON t1 BEGIN SELECT 1,2,3; END;
+}
+
+do_test 5.1 {
+ sqlite3 db2 test.db
+ execsql { DROP TABLE t1 } db2
+} {}
+
+do_execsql_test 5.2 {
+ SELECT * FROM sqlite_master;
+ SELECT * FROM temp.sqlite_master;
+} {
+ trigger tr1 t1 0
+ {CREATE TRIGGER tr1 BEFORE INSERT ON t1 BEGIN SELECT 1,2,3; END}
+}
+db2 close
+
+#-------------------------------------------------------------------------
+# Check that if a second connection creates a table in an attached database
+# with the same name as a table in the main database that has a temp
+# trigger attached to it nothing goes awry.
+#
+reset_db
+forcedelete test.db2
+
+do_execsql_test 6.0 {
+ CREATE TABLE t1(x);
+ CREATE TEMP TRIGGER tr1 BEFORE INSERT ON t1 BEGIN
+ SELECT raise(ABORT, 'error');
+ END;
+ ATTACH 'test.db2' AS aux;
+}
+
+do_test 6.1 {
+ sqlite3 db2 test.db2
+ execsql { CREATE TABLE t1(a, b, c); } db2
+} {}
+
+do_execsql_test 6.2 {
+ SELECT type,name,tbl_name,sql FROM aux.sqlite_master;
+ INSERT INTO aux.t1 VALUES(1,2,3);
+} {
+ table t1 t1 {CREATE TABLE t1(a, b, c)}
+}
+
+do_catchsql_test 6.3 {
+ INSERT INTO main.t1 VALUES(1);
+} {1 error}
+db2 close
+
+finish_test
diff --git a/test/tester.tcl b/test/tester.tcl
new file mode 100644
index 0000000..9353b91
--- /dev/null
+++ b/test/tester.tcl
@@ -0,0 +1,2600 @@
+# 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:
+#
+# is_relative_file
+# test_pwd
+# get_pwd
+# copy_file FROM TO
+# delete_file FILENAME
+# drop_all_tables ?DB?
+# drop_all_indexes ?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:
+#
+# capable EXPR
+# ifcapable EXPR
+#
+# Calulate checksums based on database contents:
+#
+# dbcksum DB DBNAME
+# allcksum ?DB?
+# cksum ?DB?
+#
+# Commands to execute/explain SQL statements:
+#
+# memdbsql SQL
+# 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?
+# verify_ex_errcode TESTNAME EXPECTED ?DB?
+# do_test TESTNAME SCRIPT EXPECTED
+# do_execsql_test TESTNAME SQL EXPECTED
+# do_catchsql_test TESTNAME SQL EXPECTED
+# do_timed_execsql_test TESTNAME SQL EXPECTED
+#
+# Commands providing a lower level interface to the global test counters:
+#
+# set_test_counter COUNTER ?VALUE?
+# omit_test TESTNAME REASON ?APPEND?
+# 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
+#
+# Command to test whether or not --verbose=1 was specified on the command
+# line (returns 0 for not-verbose, 1 for verbose and 2 for "verbose in the
+# output file only").
+#
+# verbose
+#
+
+# Only run this script once. If sourced a second time, make it a no-op
+if {[info exists ::tester_tcl_has_run]} return
+
+# 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)
+ }
+ [lindex $args 0] cache size 3
+ set res
+ } else {
+ # This command is not opening a new database connection. Pass the
+ # arguments through to the C implementation 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" ? 50 : 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)
+}
+
+# Return the string representing the name of the current directory. On
+# Windows, the result is "normalized" to whatever our parent command shell
+# is using to prevent case-mismatch issues.
+#
+proc get_pwd {} {
+ if {$::tcl_platform(platform) eq "windows"} {
+ #
+ # NOTE: Cannot use [file normalize] here because it would alter the
+ # case of the result to what Tcl considers canonical, which would
+ # defeat the purpose of this procedure.
+ #
+ if {[info exists ::env(ComSpec)]} {
+ set comSpec $::env(ComSpec)
+ } else {
+ # NOTE: Hard-code the typical default value.
+ set comSpec {C:\Windows\system32\cmd.exe}
+ }
+ return [string map [list \\ /] \
+ [string trim [exec -- $comSpec /c CD]]]
+ } else {
+ return [pwd]
+ }
+}
+
+# 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
+ }
+ }
+}
+
+# Check if a file name is relative
+#
+proc is_relative_file { file } {
+ return [expr {[file pathtype $file] != "absolute"}]
+}
+
+# If the VFS supports using the current directory, returns [pwd];
+# otherwise, it returns only the provided suffix string (which is
+# empty by default).
+#
+proc test_pwd { args } {
+ if {[llength $args] > 0} {
+ set suffix1 [lindex $args 0]
+ if {[llength $args] > 1} {
+ set suffix2 [lindex $args 1]
+ } else {
+ set suffix2 $suffix1
+ }
+ } else {
+ set suffix1 ""; set suffix2 ""
+ }
+ ifcapable curdir {
+ return "[get_pwd]$suffix1"
+ } else {
+ return $suffix2
+ }
+}
+
+# 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
+ }
+ }
+ }
+}
+
+if {$::tcl_platform(platform) eq "windows"} {
+ proc do_remove_win32_dir {args} {
+ set nRetry [getFileRetries] ;# Maximum number of retries.
+ set nDelay [getFileRetryDelay] ;# Delay in ms before retrying.
+
+ foreach dirName $args {
+ # On windows, sometimes even a [remove_win32_dir] can fail just after
+ # a directory is emptied. 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
+ # removal.
+ #
+ if {$nRetry > 0} {
+ for {set i 0} {$i < $nRetry} {incr i} {
+ set rc [catch {
+ remove_win32_dir $dirName
+ } msg]
+ if {$rc == 0} break
+ if {$nDelay > 0} { after $nDelay }
+ }
+ if {$rc} { error $msg }
+ } else {
+ remove_win32_dir $dirName
+ }
+ }
+ }
+
+ proc do_delete_win32_file {args} {
+ set nRetry [getFileRetries] ;# Maximum number of retries.
+ set nDelay [getFileRetryDelay] ;# Delay in ms before retrying.
+
+ foreach fileName $args {
+ # On windows, sometimes even a [delete_win32_file] 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 {
+ delete_win32_file $fileName
+ } msg]
+ if {$rc == 0} break
+ if {$nDelay > 0} { after $nDelay }
+ }
+ if {$rc} { error $msg }
+ } else {
+ delete_win32_file $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
+}
+unset -nocomplain do_not_use_codec
+
+# Return true if the "reserved_bytes" integer on database files is non-zero.
+#
+proc nonzero_reserved_bytes {} {
+ return [sqlite3 -has-codec]
+}
+
+# Print a HELP message and exit
+#
+proc print_help_and_quit {} {
+ puts {Options:
+ --pause Wait for user input before continuing
+ --soft-heap-limit=N Set the soft-heap-limit to N
+ --hard-heap-limit=N Set the hard-heap-limit to N
+ --maxerror=N Quit after N errors
+ --verbose=(0|1) Control the amount of output. Default '1'
+ --output=FILE set --verbose=2 and output to FILE. Implies -q
+ -q Shorthand for --verbose=0
+ --help This message
+}
+ exit 1
+}
+
+# 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
+ # --hard-heap-limit=NN
+ # --maxerror=NN
+ # --malloctrace=N
+ # --backtrace=N
+ # --binarylog=N
+ # --soak=N
+ # --file-retries=N
+ # --file-retry-delay=N
+ # --start=[$permutation:]$testfile
+ # --match=$pattern
+ # --verbose=$val
+ # --output=$filename
+ # -q Reduce output
+ # --testdir=$dir Run tests in subdirectory $dir
+ # --help
+ #
+ set cmdlinearg(soft-heap-limit) 0
+ set cmdlinearg(hard-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 cmdlinearg(match) ""
+ set cmdlinearg(verbose) ""
+ set cmdlinearg(output) ""
+ set cmdlinearg(testdir) "testdir"
+
+ 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
+ }
+ {^-+hard-heap-limit=.+$} {
+ foreach {dummy cmdlinearg(hard-heap-limit)} [split $a =] break
+ }
+ {^-+maxerror=.+$} {
+ foreach {dummy cmdlinearg(maxerror)} [split $a =] break
+ }
+ {^-+malloctrace=.+$} {
+ foreach {dummy cmdlinearg(malloctrace)} [split $a =] break
+ if {$cmdlinearg(malloctrace)} {
+ if {0==$::sqlite_options(memdebug)} {
+ set err "Error: --malloctrace=1 requires an SQLITE_MEMDEBUG build"
+ puts stderr $err
+ exit 1
+ }
+ sqlite3_memdebug_log start
+ }
+ }
+ {^-+backtrace=.+$} {
+ foreach {dummy cmdlinearg(backtrace)} [split $a =] break
+ sqlite3_memdebug_backtrace $cmdlinearg(backtrace)
+ }
+ {^-+binarylog=.+$} {
+ foreach {dummy cmdlinearg(binarylog)} [split $a =] break
+ set cmdlinearg(binarylog) [file normalize $cmdlinearg(binarylog)]
+ }
+ {^-+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)}
+ }
+ {^-+match=.+$} {
+ foreach {dummy cmdlinearg(match)} [split $a =] break
+
+ set ::G(match) $cmdlinearg(match)
+ if {$::G(match) == ""} {unset ::G(match)}
+ }
+
+ {^-+output=.+$} {
+ foreach {dummy cmdlinearg(output)} [split $a =] break
+ set cmdlinearg(output) [file normalize $cmdlinearg(output)]
+ if {$cmdlinearg(verbose)==""} {
+ set cmdlinearg(verbose) 2
+ }
+ }
+ {^-+verbose=.+$} {
+ foreach {dummy cmdlinearg(verbose)} [split $a =] break
+ if {$cmdlinearg(verbose)=="file"} {
+ set cmdlinearg(verbose) 2
+ } elseif {[string is boolean -strict $cmdlinearg(verbose)]==0} {
+ error "option --verbose= must be set to a boolean or to \"file\""
+ }
+ }
+ {^-+testdir=.*$} {
+ foreach {dummy cmdlinearg(testdir)} [split $a =] break
+ }
+ {.*help.*} {
+ print_help_and_quit
+ }
+ {^-q$} {
+ set cmdlinearg(output) test-out.txt
+ set cmdlinearg(verbose) 2
+ }
+
+ default {
+ if {[file tail $a]==$a} {
+ lappend leftover $a
+ } else {
+ lappend leftover [file normalize $a]
+ }
+ }
+ }
+ }
+ set testdir [file normalize $testdir]
+ set cmdlinearg(TESTFIXTURE_HOME) [pwd]
+ set cmdlinearg(INFO_SCRIPT) [file normalize [info script]]
+ set argv0 [file normalize $argv0]
+ if {$cmdlinearg(testdir)!=""} {
+ file mkdir $cmdlinearg(testdir)
+ cd $cmdlinearg(testdir)
+ }
+ 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)
+ }
+
+ if {$cmdlinearg(output)!=""} {
+ puts "Copying output to file $cmdlinearg(output)"
+ set ::G(output_fd) [open $cmdlinearg(output) w]
+ fconfigure $::G(output_fd) -buffering line
+ }
+
+ if {$cmdlinearg(verbose)==""} {
+ set cmdlinearg(verbose) 1
+ }
+
+ if {[info commands vdbe_coverage]!=""} {
+ vdbe_coverage start
+ }
+}
+
+# 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_limit64 $cmdlinearg(soft-heap-limit)
+sqlite3_hard_heap_limit64 $cmdlinearg(hard-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]
+ set TC(warn_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 {append 1}} {
+ set omitList [set_test_counter omit_list]
+ if {$append} {
+ 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)} {
+ output2 "*** Giving up..."
+ finalize_testing
+ }
+}
+
+# Remember a warning message to be displayed at the conclusion of all testing
+#
+proc warning {msg {append 1}} {
+ output2 "Warning: $msg"
+ set warnList [set_test_counter warn_list]
+ if {$append} {
+ lappend warnList $msg
+ }
+ set_test_counter warn_list $warnList
+}
+
+
+# Increment the number of tests run
+#
+proc incr_ntest {} {
+ set_test_counter count [expr [set_test_counter count] + 1]
+}
+
+# Return true if --verbose=1 was specified on the command line. Otherwise,
+# return false.
+#
+proc verbose {} {
+ return $::cmdlinearg(verbose)
+}
+
+# Use the following commands instead of [puts] for test output within
+# this file. Test scripts can still use regular [puts], which is directed
+# to stdout and, if one is open, the --output file.
+#
+# output1: output that should be printed if --verbose=1 was specified.
+# output2: output that should be printed unconditionally.
+# output2_if_no_verbose: output that should be printed only if --verbose=0.
+#
+proc output1 {args} {
+ set v [verbose]
+ if {$v==1} {
+ uplevel output2 $args
+ } elseif {$v==2} {
+ uplevel puts [lrange $args 0 end-1] $::G(output_fd) [lrange $args end end]
+ }
+}
+proc output2 {args} {
+ set nArg [llength $args]
+ uplevel puts $args
+}
+proc output2_if_no_verbose {args} {
+ set v [verbose]
+ if {$v==0} {
+ uplevel output2 $args
+ } elseif {$v==2} {
+ uplevel puts [lrange $args 0 end-1] stdout [lrange $args end end]
+ }
+}
+
+# Override the [puts] command so that if no channel is explicitly
+# specified the string is written to both stdout and to the file
+# specified by "--output=", if any.
+#
+proc puts_override {args} {
+ set nArg [llength $args]
+ if {$nArg==1 || ($nArg==2 && [string first [lindex $args 0] -nonewline]==0)} {
+ uplevel puts_original $args
+ if {[info exists ::G(output_fd)]} {
+ uplevel puts [lrange $args 0 end-1] $::G(output_fd) [lrange $args end end]
+ }
+ } else {
+ # A channel was explicitly specified.
+ uplevel puts_original $args
+ }
+}
+rename puts puts_original
+proc puts {args} { uplevel puts_override $args }
+
+
+# Invoke the do_test procedure to run a single test
+#
+# The $expected parameter is the expected result. The result is the return
+# value from the last TCL command in $cmd.
+#
+# Normally, $expected must match exactly. But if $expected is of the form
+# "/regexp/" then regular expression matching is used. If $expected is
+# "~/regexp/" then the regular expression must NOT match. If $expected is
+# of the form "#/value-list/" then each term in value-list must be numeric
+# and must approximately match the corresponding numeric term in $result.
+# Values must match within 10%. Or if the $expected term is A..B then the
+# $result term must be in between A and B.
+#
+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
+ output1 -nonewline $name...
+ flush stdout
+
+ if {![info exists ::G(match)] || [string match $::G(match) $name]} {
+ if {[catch {uplevel #0 "$cmd;\n"} result]} {
+ output2_if_no_verbose -nonewline $name...
+ output2 "\nError: $result"
+ fail_test $name
+ } else {
+ if {[permutation]=="maindbname"} {
+ set result [string map [list [string tolower ICECUBE] main] $result]
+ }
+ if {[regexp {^[~#]?/.*/$} $expected]} {
+ # "expected" is of the form "/PATTERN/" then the result if correct if
+ # regular expression PATTERN matches the result. "~/PATTERN/" means
+ # the regular expression must not match.
+ if {[string index $expected 0]=="~"} {
+ set re [string range $expected 2 end-1]
+ if {[string index $re 0]=="*"} {
+ # If the regular expression begins with * then treat it as a glob instead
+ set ok [string match $re $result]
+ } else {
+ set re [string map {# {[-0-9.]+}} $re]
+ set ok [regexp $re $result]
+ }
+ set ok [expr {!$ok}]
+ } elseif {[string index $expected 0]=="#"} {
+ # Numeric range value comparison. Each term of the $result is matched
+ # against one term of $expect. Both $result and $expected terms must be
+ # numeric. The values must match within 10%. Or if $expected is of the
+ # form A..B then the $result term must be between A and B.
+ set e2 [string range $expected 2 end-1]
+ foreach i $result j $e2 {
+ if {[regexp {^(-?\d+)\.\.(-?\d)$} $j all A B]} {
+ set ok [expr {$i+0>=$A && $i+0<=$B}]
+ } else {
+ set ok [expr {$i+0>=0.9*$j && $i+0<=1.1*$j}]
+ }
+ if {!$ok} break
+ }
+ if {$ok && [llength $result]!=[llength $e2]} {set ok 0}
+ } else {
+ set re [string range $expected 1 end-1]
+ if {[string index $re 0]=="*"} {
+ # If the regular expression begins with * then treat it as a glob instead
+ set ok [string match $re $result]
+ } else {
+ set re [string map {# {[-0-9.]+}} $re]
+ set ok [regexp $re $result]
+ }
+ }
+ } elseif {[regexp {^~?\*.*\*$} $expected]} {
+ # "expected" is of the form "*GLOB*" then the result if correct if
+ # glob pattern GLOB matches the result. "~/GLOB/" means
+ # the glob must not match.
+ if {[string index $expected 0]=="~"} {
+ set e [string range $expected 1 end]
+ set ok [expr {![string match $e $result]}]
+ } else {
+ set ok [string match $expected $result]
+ }
+ } else {
+ set ok [expr {[string compare $result $expected]==0}]
+ }
+ if {!$ok} {
+ # if {![info exists ::testprefix] || $::testprefix eq ""} {
+ # error "no test prefix"
+ # }
+ output1 ""
+ output2 "! $name expected: \[$expected\]\n! $name got: \[$result\]"
+ fail_test $name
+ } else {
+ output1 " Ok"
+ }
+ }
+ } else {
+ output1 " Omitted"
+ omit_test $name "pattern mismatch" 0
+ }
+ flush stdout
+}
+
+proc dumpbytes {s} {
+ set r ""
+ for {set i 0} {$i < [string length $s]} {incr i} {
+ if {$i > 0} {append r " "}
+ append r [format %02X [scan [string index $s $i] %c]]
+ }
+ return $r
+}
+
+proc catchcmd {db {cmd ""}} {
+ global CLI
+ set out [open cmds.txt w]
+ puts $out $cmd
+ close $out
+ set line "exec $CLI $db < cmds.txt"
+ set rc [catch { eval $line } msg]
+ list $rc $msg
+}
+
+proc catchcmdex {db {cmd ""}} {
+ global CLI
+ set out [open cmds.txt w]
+ fconfigure $out -encoding binary -translation binary
+ puts -nonewline $out $cmd
+ close $out
+ set line "exec -keepnewline -- $CLI $db < cmds.txt"
+ set chans [list stdin stdout stderr]
+ foreach chan $chans {
+ catch {
+ set modes($chan) [fconfigure $chan]
+ fconfigure $chan -encoding binary -translation binary -buffering none
+ }
+ }
+ set rc [catch { eval $line } msg]
+ foreach chan $chans {
+ catch {
+ eval fconfigure [list $chan] $modes($chan)
+ }
+ }
+ # puts [dumpbytes $msg]
+ list $rc $msg
+}
+
+proc filepath_normalize {p} {
+ # test cases should be written to assume "unix"-like file paths
+ if {$::tcl_platform(platform)!="unix"} {
+ string map [list \\ / \{/ / .db\} .db] \
+ [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 normalize_list {L} {
+ set L2 [list]
+ foreach l $L {lappend L2 $l}
+ set L2
+}
+
+# Either:
+#
+# do_execsql_test TESTNAME SQL ?RES?
+# do_execsql_test -db DB TESTNAME SQL ?RES?
+#
+proc do_execsql_test {args} {
+ set db db
+ if {[lindex $args 0]=="-db"} {
+ set db [lindex $args 1]
+ set args [lrange $args 2 end]
+ }
+
+ if {[llength $args]==2} {
+ foreach {testname sql} $args {}
+ set result ""
+ } elseif {[llength $args]==3} {
+ foreach {testname sql result} $args {}
+
+ # With some versions of Tcl on windows, if $result is all whitespace but
+ # contains some CR/LF characters, the [list {*}$result] below returns a
+ # copy of $result instead of a zero length string. Not clear exactly why
+ # this is. The following is a workaround.
+ if {[llength $result]==0} { set result "" }
+ } else {
+ error [string trim {
+ wrong # args: should be "do_execsql_test ?-db DB? testname sql ?result?"
+ }]
+ }
+
+ fix_testname testname
+
+ uplevel do_test \
+ [list $testname] \
+ [list "execsql {$sql} $db"] \
+ [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_timed_execsql_test {testname sql {result {}}} {
+ fix_testname testname
+ uplevel do_test [list $testname] [list "execsql_timed {$sql}"]\
+ [list [list {*}$result]]
+}
+
+# Run an EXPLAIN QUERY PLAN $sql in database "db". Then rewrite the output
+# as an ASCII-art graph and return a string that is that graph.
+#
+# Hexadecimal literals in the output text are converted into "xxxxxx" since those
+# literals are pointer values that might very from one run of the test to the
+# next, yet we want the output to be consistent.
+#
+proc query_plan_graph {sql} {
+ db eval "EXPLAIN QUERY PLAN $sql" {
+ set dx($id) $detail
+ lappend cx($parent) $id
+ }
+ set a "\n QUERY PLAN\n"
+ append a [append_graph " " dx cx 0]
+ regsub -all { 0x[A-F0-9]+\y} $a { xxxxxx} a
+ regsub -all {(MATERIALIZE|CO-ROUTINE|SUBQUERY) \d+\y} $a {\1 xxxxxx} a
+ regsub -all {\((join|subquery)-\d+\)} $a {(\1-xxxxxx)} a
+ return $a
+}
+
+# Helper routine for [query_plan_graph SQL]:
+#
+# Output rows of the graph that are children of $level.
+#
+# prefix: Prepend to every output line
+#
+# dxname: Name of an array variable that stores text describe
+# The description for $id is $dx($id)
+#
+# cxname: Name of an array variable holding children of item.
+# Children of $id are $cx($id)
+#
+# level: Render all lines that are children of $level
+#
+proc append_graph {prefix dxname cxname level} {
+ upvar $dxname dx $cxname cx
+ set a ""
+ set x $cx($level)
+ set n [llength $x]
+ for {set i 0} {$i<$n} {incr i} {
+ set id [lindex $x $i]
+ if {$i==$n-1} {
+ set p1 "`--"
+ set p2 " "
+ } else {
+ set p1 "|--"
+ set p2 "| "
+ }
+ append a $prefix$p1$dx($id)\n
+ if {[info exists cx($id)]} {
+ append a [append_graph "$prefix$p2" dx cx $id]
+ }
+ }
+ return $a
+}
+
+# Do an EXPLAIN QUERY PLAN test on input $sql with expected results $res
+#
+# If $res begins with a "\s+QUERY PLAN\n" then it is assumed to be the
+# complete graph which must match the output of [query_plan_graph $sql]
+# exactly.
+#
+# If $res does not begin with "\s+QUERY PLAN\n" then take it is a string
+# that must be found somewhere in the query plan output.
+#
+proc do_eqp_test {name sql res} {
+ if {[regexp {^\s+QUERY PLAN\n} $res]} {
+ uplevel do_test $name [list [list query_plan_graph $sql]] [list $res]
+ } else {
+ if {[string index $res 0]!="/"} {
+ set res "/*$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} {
+ output2 -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
+ output2 [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} {
+ output2 -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
+ output2 [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
+ output2 "SQLite $vers"
+}
+proc speed_trial_summary {name} {
+ global total_time
+ output2 [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
+ output2 "CREATE TABLE IF NOT EXISTS time(version, script, test, us);"
+ foreach {test us} $::speed_trial_times {
+ output2 "INSERT INTO time VALUES('$vers', '$name', '$test', $us);"
+ }
+ }
+}
+
+# Clear out left-over configuration setup from the end of a test
+#
+proc finish_test_precleanup {} {
+ catch {db1 close}
+ catch {db2 close}
+ catch {db3 close}
+ catch {unregister_devsim}
+ catch {unregister_jt_vfs}
+ catch {unregister_demovfs}
+}
+
+# Run this routine last
+#
+proc finish_test {} {
+ global argv
+ finish_test_precleanup
+ if {[llength $argv]>0} {
+ # If additional test scripts are specified on the command-line,
+ # run them also, before quitting.
+ proc finish_test {} {
+ finish_test_precleanup
+ return
+ }
+ foreach extra $argv {
+ puts "Running \"$extra\""
+ db_delete_and_reopen
+ uplevel #0 source $extra
+ }
+ }
+ catch {db 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_limit64 0
+ sqlite3_hard_heap_limit64 0
+ set nTest [incr_ntest]
+ set nErr [set_test_counter errors]
+
+ set nKnown 0
+ if {[file readable known-problems.txt]} {
+ set fd [open known-problems.txt]
+ set content [read $fd]
+ close $fd
+ foreach x $content {set known_error($x) 1}
+ foreach x [set_test_counter fail_list] {
+ if {[info exists known_error($x)]} {incr nKnown}
+ }
+ }
+ if {$nKnown>0} {
+ output2 "[expr {$nErr-$nKnown}] new errors and $nKnown known errors\
+ out of $nTest tests"
+ } else {
+ set cpuinfo {}
+ if {[catch {exec hostname} hname]==0} {set cpuinfo [string trim $hname]}
+ append cpuinfo " $::tcl_platform(os)"
+ append cpuinfo " [expr {$::tcl_platform(pointerSize)*8}]-bit"
+ append cpuinfo " [string map {E -e} $::tcl_platform(byteOrder)]"
+ output2 "SQLite [sqlite3 -sourceid]"
+ output2 "$nErr errors out of $nTest tests on $cpuinfo"
+ }
+ if {$nErr>$nKnown} {
+ output2 -nonewline "!Failures on these tests:"
+ foreach x [set_test_counter fail_list] {
+ if {![info exists known_error($x)]} {output2 -nonewline " $x"}
+ }
+ output2 ""
+ }
+ foreach warning [set_test_counter warn_list] {
+ output2 "Warning: $warning"
+ }
+ run_thread_tests 1
+ if {[llength $omitList]>0} {
+ output2 "Omitted test cases:"
+ set prec {}
+ foreach {rec} [lsort $omitList] {
+ if {$rec==$prec} continue
+ set prec $rec
+ output2 [format {. %-12s %s} [lindex $rec 0] [lindex $rec 1]]
+ }
+ }
+ if {$nErr>0 && ![working_64bit_int]} {
+ output2 "******************************************************************"
+ output2 "N.B.: The version of TCL that you used to build this test harness"
+ output2 "is defective in that it does not support 64-bit integers. Some or"
+ output2 "all of the test failures above might be a result from this defect"
+ output2 "in your TCL build."
+ output2 "******************************************************************"
+ }
+ if {$::cmdlinearg(binarylog)} {
+ vfslog finalize binarylog
+ }
+ if {$sqlite_open_file_count} {
+ output2 "$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} {
+ output2 "Unfreed memory: [sqlite3_memory_used] bytes in\
+ [lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1] allocations"
+ incr nErr
+ ifcapable mem5||(mem3&&debug) {
+ output2 "Writing unfreed memory log to \"./memleak.txt\""
+ sqlite3_memdebug_dump ./memleak.txt
+ }
+ } else {
+ output2 "All memory allocations freed - no leaks"
+ ifcapable mem5 {
+ sqlite3_memdebug_dump ./memusage.txt
+ }
+ }
+ show_memstats
+ output2 "Maximum memory usage: [sqlite3_memory_highwater 1] bytes"
+ output2 "Current memory usage: [sqlite3_memory_highwater] bytes"
+ if {[info commands sqlite3_memdebug_malloc_count] ne ""} {
+ output2 "Number of malloc() : [sqlite3_memdebug_malloc_count] calls"
+ }
+ if {$::cmdlinearg(malloctrace)} {
+ output2 "Writing mallocs.tcl..."
+ memdebug_log_sql mallocs.tcl
+ sqlite3_memdebug_log stop
+ sqlite3_memdebug_log clear
+ if {[sqlite3_memory_used]>0} {
+ output2 "Writing leaks.tcl..."
+ sqlite3_memdebug_log sync
+ memdebug_log_sql leaks.tcl
+ }
+ }
+ if {[info commands vdbe_coverage]!=""} {
+ vdbe_coverage_report
+ }
+ foreach f [glob -nocomplain test.db-*-journal] {
+ forcedelete $f
+ }
+ foreach f [glob -nocomplain test.db-mj*] {
+ forcedelete $f
+ }
+ exit [expr {$nErr>0}]
+}
+
+proc vdbe_coverage_report {} {
+ puts "Writing vdbe coverage report to vdbe_coverage.txt"
+ set lSrc [list]
+ set iLine 0
+ if {[file exists ../sqlite3.c]} {
+ set fd [open ../sqlite3.c]
+ set iLine
+ while { ![eof $fd] } {
+ set line [gets $fd]
+ incr iLine
+ if {[regexp {^/\** Begin file (.*\.c) \**/} $line -> file]} {
+ lappend lSrc [list $iLine $file]
+ }
+ }
+ close $fd
+ }
+ set fd [open vdbe_coverage.txt w]
+ foreach miss [vdbe_coverage report] {
+ foreach {line branch never} $miss {}
+ set nextfile ""
+ while {[llength $lSrc]>0 && [lindex $lSrc 0 0] < $line} {
+ set nextfile [lindex $lSrc 0 1]
+ set lSrc [lrange $lSrc 1 end]
+ }
+ if {$nextfile != ""} {
+ puts $fd ""
+ puts $fd "### $nextfile ###"
+ }
+ puts $fd "Vdbe branch $line: never $never (path $branch)"
+ }
+ close $fd
+}
+
+# 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]]
+ output1 "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]]
+ output1 "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]]
+ output1 "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]]
+ output1 "Page-cache overflow: $val"
+ ifcapable yytrackmaxstackdepth {
+ set x [sqlite3_status SQLITE_STATUS_PARSER_STACK 0]
+ set val [format { max %10d} [lindex $x 2]]
+ output2 "Parser stack depth: $val"
+ }
+}
+
+# A procedure to execute SQL
+#
+proc execsql {sql {db db}} {
+ # puts "SQL = $sql"
+ uplevel [list $db eval $sql]
+}
+proc execsql_timed {sql {db db}} {
+ set tm [time {
+ set x [uplevel [list $db eval $sql]]
+ } 1]
+ set tm [lindex $tm 0]
+ output1 -nonewline " ([expr {$tm*0.001}]ms) "
+ set x
+}
+
+# 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}} {
+ output2 ""
+ output2 "addr opcode p1 p2 p3 p4 p5 #"
+ output2 "---- ------------ ------ ------ ------ --------------- -- -"
+ $db eval "explain $sql" {} {
+ output2 [format {%-4d %-12.12s %-6d %-6d %-6d % -17s %s %s} \
+ $addr $opcode $p1 $p2 $p3 $p4 $p5 $comment
+ ]
+ }
+}
+
+proc explain_i {sql {db db}} {
+ output2 ""
+ output2 "addr opcode p1 p2 p3 p4 p5 #"
+ output2 "---- ------------ ------ ------ ------ ---------------- -- -"
+
+
+ # Set up colors for the different opcodes. Scheme is as follows:
+ #
+ # Red: Opcodes that write to a b-tree.
+ # Blue: Opcodes that reposition or seek a cursor.
+ # Green: The ResultRow opcode.
+ #
+ if { [catch {fconfigure stdout -mode}]==0 } {
+ set R "\033\[31;1m" ;# Red fg
+ set G "\033\[32;1m" ;# Green fg
+ set B "\033\[34;1m" ;# Red fg
+ set D "\033\[39;0m" ;# Default fg
+ } else {
+ set R ""
+ set G ""
+ set B ""
+ set D ""
+ }
+ foreach opcode {
+ Seek SeekGE SeekGT SeekLE SeekLT NotFound Last Rewind
+ NoConflict Next Prev VNext VPrev VFilter
+ SorterSort SorterNext NextIfOpen
+ } {
+ set color($opcode) $B
+ }
+ foreach opcode {ResultRow} {
+ set color($opcode) $G
+ }
+ foreach opcode {IdxInsert Insert Delete IdxDelete} {
+ set color($opcode) $R
+ }
+
+ set bSeenGoto 0
+ $db eval "explain $sql" {} {
+ set x($addr) 0
+ set op($addr) $opcode
+
+ if {$opcode == "Goto" && ($bSeenGoto==0 || ($p2 > $addr+10))} {
+ set linebreak($p2) 1
+ set bSeenGoto 1
+ }
+
+ if {$opcode=="Once"} {
+ for {set i $addr} {$i<$p2} {incr i} {
+ set star($i) $addr
+ }
+ }
+
+ if {$opcode=="Next" || $opcode=="Prev"
+ || $opcode=="VNext" || $opcode=="VPrev"
+ || $opcode=="SorterNext" || $opcode=="NextIfOpen"
+ } {
+ for {set i $p2} {$i<$addr} {incr i} {
+ incr x($i) 2
+ }
+ }
+
+ if {$opcode == "Goto" && $p2<$addr && $op($p2)=="Yield"} {
+ for {set i [expr $p2+1]} {$i<$addr} {incr i} {
+ incr x($i) 2
+ }
+ }
+
+ if {$opcode == "Halt" && $comment == "End of coroutine"} {
+ set linebreak([expr $addr+1]) 1
+ }
+ }
+
+ $db eval "explain $sql" {} {
+ if {[info exists linebreak($addr)]} {
+ output2 ""
+ }
+ set I [string repeat " " $x($addr)]
+
+ if {[info exists star($addr)]} {
+ set ii [expr $x($star($addr))]
+ append I " "
+ set I [string replace $I $ii $ii *]
+ }
+
+ set col ""
+ catch { set col $color($opcode) }
+
+ output2 [format {%-4d %s%s%-12.12s%s %-6d %-6d %-6d % -17s %s %s} \
+ $addr $I $col $opcode $D $p1 $p2 $p3 $p4 $p5 $comment
+ ]
+ }
+ output2 "---- ------------ ------ ------ ------ ---------------- -- -"
+}
+
+proc execsql_pp {sql {db db}} {
+ set nCol 0
+ $db eval $sql A {
+ if {$nCol==0} {
+ set nCol [llength $A(*)]
+ foreach c $A(*) {
+ set aWidth($c) [string length $c]
+ lappend data $c
+ }
+ }
+ foreach c $A(*) {
+ set n [string length $A($c)]
+ if {$n > $aWidth($c)} {
+ set aWidth($c) $n
+ }
+ lappend data $A($c)
+ }
+ }
+ if {$nCol>0} {
+ set nTotal 0
+ foreach e [array names aWidth] { incr nTotal $aWidth($e) }
+ incr nTotal [expr ($nCol-1) * 3]
+ incr nTotal 4
+
+ set fmt ""
+ foreach c $A(*) {
+ lappend fmt "% -$aWidth($c)s"
+ }
+ set fmt "| [join $fmt { | }] |"
+
+ puts [string repeat - $nTotal]
+ for {set i 0} {$i < [llength $data]} {incr i $nCol} {
+ set vals [lrange $data $i [expr $i+$nCol-1]]
+ puts [format $fmt {*}$vals]
+ if {$i==0} { puts [string repeat - $nTotal] }
+ }
+ puts [string repeat - $nTotal]
+ }
+}
+
+
+# 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 a temporary in-memory database to execute SQL statements
+#
+proc memdbsql {sql} {
+ sqlite3 memdb :memory:
+ set result [memdb eval $sql]
+ memdb close
+ 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}
+ }
+}
+
+# Check the extended error code
+#
+proc verify_ex_errcode {name expected {db db}} {
+ do_test $name [list sqlite3_extended_errcode $db] $expected
+}
+
+
+# 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
+}
+
+# Returns non-zero if the capabilities are present; zero otherwise.
+#
+proc capable {expr} {
+ set e [fix_ifcapable_expr $expr]; return [expr ($e)]
+}
+
+# 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
+# occurred.
+#
+# crashsql -delay CRASHDELAY -file CRASHFILE ?-blocksize BLOCKSIZE? $sql
+#
+proc crashsql {args} {
+
+ set blocksize ""
+ set crashdelay 1
+ set prngseed 0
+ set opendb { sqlite3 db test.db -vfs crash }
+ set tclbody {}
+ set crashfile ""
+ set dc ""
+ set dfltvfs 0
+ 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 -opendb]==0} {set opendb $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}" }\
+ elseif {$n>1 && [string first $z -dfltvfs]==0} {set dfltvfs $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 [get_pwd] $crashfile]]]
+
+ set f [open crash.tcl w]
+ puts $f "sqlite3_initialize ; sqlite3_shutdown"
+ puts $f "catch { install_malloc_faultsim 1 }"
+ puts $f "sqlite3_crash_enable 1 $dfltvfs"
+ puts $f "sqlite3_crashparams $blocksize $dc $crashdelay $cfile"
+ puts $f "sqlite3_test_control_pending_byte $::sqlite_pending_byte"
+ puts $f "autoinstall_test_functions"
+
+ # 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".
+ if {$opendb!=""} {
+ puts $f $opendb
+ 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 2>@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"
+ }
+ }
+ if {$r && [string match {*ERROR: LeakSanitizer*} $msg]} {
+ set msg "child process exited abnormally"
+ }
+
+ lappend r $msg
+}
+
+# crash_on_write ?-devchar DEVCHAR? CRASHDELAY SQL
+#
+proc crash_on_write {args} {
+
+ set nArg [llength $args]
+ if {$nArg<2 || $nArg%2} {
+ error "bad args: $args"
+ }
+ set zSql [lindex $args end]
+ set nDelay [lindex $args end-1]
+
+ set devchar {}
+ for {set ii 0} {$ii < $nArg-2} {incr ii 2} {
+ set opt [lindex $args $ii]
+ switch -- [lindex $args $ii] {
+ -devchar {
+ set devchar [lindex $args [expr $ii+1]]
+ }
+
+ default { error "unrecognized option: $opt" }
+ }
+ }
+
+ set f [open crash.tcl w]
+ puts $f "sqlite3_crash_on_write $nDelay"
+ puts $f "sqlite3_test_control_pending_byte $::sqlite_pending_byte"
+ puts $f "sqlite3 db test.db -vfs writecrash"
+ puts $f "db eval {$zSql}"
+ puts $f "set {} {}"
+
+ 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
+}
+
+proc run_ioerr_prep {} {
+ 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
+}
+
+# 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
+
+ # 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)}"
+ }
+
+ save_prng_state
+ if {$::ioerropts(-cksum)} {
+ run_ioerr_prep
+ eval $::ioerrorbody
+ set ::goodcksum [cksum]
+ }
+
+ set ::go 1
+ #reset_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 {
+ run_ioerr_prep
+ } {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
+
+ # Execute the TCL script created for the body of this test. If
+ # 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
+ if {[info commands db]!=""} {
+ 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 occurred, 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]
+ set nowcksum [cksum]
+ set res [expr {$nowcksum==$::checksum || $nowcksum==$::goodcksum}]
+ if {$res==0} {
+ output2 "now=$nowcksum"
+ output2 "the=$::checksum"
+ output2 "fwd=$::goodcksum"
+ }
+ set res
+ } 1
+ }
+
+ 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} {
+
+ 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"
+
+ set pid [pid]
+
+ foreach f [array names frames] {
+ set addr [format %x $f]
+ set cmd "eu-addr2line --pid=$pid $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 escaped "BEGIN; ${tbl}${tbl2}${tbl3}${sql} ; COMMIT;"
+ set escaped [string map [list "{" "\\{" "}" "\\}" "\\" "\\\\"] $escaped]
+
+ set fd [open $filename w]
+ puts $fd "set BUILTIN {"
+ puts $fd $escaped
+ puts $fd "}"
+ puts $fd {set BUILTIN [string map [list "\\{" "{" "\\}" "}" "\\\\" "\\"] $BUILTIN]}
+ set mtv [open $::testdir/malloctraceviewer.tcl]
+ set txt [read $mtv]
+ close $mtv
+ puts $fd $txt
+ 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"
+ }
+}
+
+# Drop all auxiliary indexes from the main database opened by handle [db].
+#
+proc drop_all_indexes {{db db}} {
+ set L [$db eval {
+ SELECT name FROM sqlite_master WHERE type='index' AND sql LIKE 'create%'
+ }]
+ foreach idx $L { $db eval "DROP INDEX $idx" }
+}
+
+
+#-------------------------------------------------------------------------
+# 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 wal_is_capable {} {
+ ifcapable !wal { return 0 }
+ if {[permutation]=="journaltest"} { return 0 }
+ return 1
+}
+
+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 isquick {} {
+ set ret 0
+ catch {set ret $::G(isquick)}
+ set ret
+}
+
+#-------------------------------------------------------------------------
+#
+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]
+ }
+
+ # If output is being copied into a file, share the file-descriptor with
+ # the interpreter.
+ if {[info exists ::G(output_fd)]} {
+ interp share {} $::G(output_fd) tinterp
+ }
+
+ # 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.
+ #
+ output2 "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
+}
+
+# Close any connections named [db], [db2] or [db3]. Then use sqlite3_config
+# to configure the size of the PAGECACHE allocation using the parameters
+# provided to this command. Save the old PAGECACHE parameters in a global
+# variable so that [test_restore_config_pagecache] can restore the previous
+# configuration.
+#
+# Before returning, reopen connection [db] on file test.db.
+#
+proc test_set_config_pagecache {sz nPg} {
+ catch {db close}
+ catch {db2 close}
+ catch {db3 close}
+
+ sqlite3_shutdown
+ set ::old_pagecache_config [sqlite3_config_pagecache $sz $nPg]
+ sqlite3_initialize
+ autoinstall_test_functions
+ reset_db
+}
+
+# Close any connections named [db], [db2] or [db3]. Then use sqlite3_config
+# to configure the size of the PAGECACHE allocation to the size saved in
+# the global variable by an earlier call to [test_set_config_pagecache].
+#
+# Before returning, reopen connection [db] on file test.db.
+#
+proc test_restore_config_pagecache {} {
+ catch {db close}
+ catch {db2 close}
+ catch {db3 close}
+
+ sqlite3_shutdown
+ eval sqlite3_config_pagecache $::old_pagecache_config
+ unset ::old_pagecache_config
+ sqlite3_initialize
+ autoinstall_test_functions
+ sqlite3 db test.db
+}
+
+proc test_binary_name {nm} {
+ if {$::tcl_platform(platform)=="windows"} {
+ set ret "$nm.exe"
+ } else {
+ set ret $nm
+ }
+ file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $ret]
+}
+
+proc test_find_binary {nm} {
+ set ret [test_binary_name $nm]
+ if {![file executable $ret]} {
+ finish_test
+ return ""
+ }
+ return $ret
+}
+
+# Find the name of the 'shell' executable (e.g. "sqlite3.exe") to use for
+# the tests in shell*.test. If no such executable can be found, invoke
+# [finish_test ; return] in the callers context.
+#
+proc test_find_cli {} {
+ set prog [test_find_binary sqlite3]
+ if {$prog==""} { return -code return }
+ return $prog
+}
+
+# Find invocation of the 'shell' executable (e.g. "sqlite3.exe") to use
+# for the tests in shell*.test with optional valgrind prefix when the
+# environment variable SQLITE_CLI_VALGRIND_OPT is set. The set value
+# operates as follows:
+# empty or 0 => no valgrind prefix;
+# 1 => valgrind options for memory leak check;
+# other => use value as valgrind options.
+# If shell not found, invoke [finish_test ; return] in callers context.
+#
+proc test_cli_invocation {} {
+ set prog [test_find_binary sqlite3]
+ if {$prog==""} { return -code return }
+ set vgrun [expr {[permutation]=="valgrind"}]
+ if {$vgrun || [info exists ::env(SQLITE_CLI_VALGRIND_OPT)]} {
+ if {$vgrun} {
+ set vgo "--quiet"
+ } else {
+ set vgo $::env(SQLITE_CLI_VALGRIND_OPT)
+ }
+ if {$vgo == 0 || $vgo eq ""} {
+ return $prog
+ } elseif {$vgo == 1} {
+ return "valgrind --quiet --leak-check=yes $prog"
+ } else {
+ return "valgrind $vgo $prog"
+ }
+ } else {
+ return $prog
+ }
+}
+
+# Find the name of the 'sqldiff' executable (e.g. "sqlite3.exe") to use for
+# the tests in sqldiff tests. If no such executable can be found, invoke
+# [finish_test ; return] in the callers context.
+#
+proc test_find_sqldiff {} {
+ set prog [test_find_binary sqldiff]
+ if {$prog==""} { return -code return }
+ return $prog
+}
+
+# Call sqlite3_expanded_sql() on all statements associated with database
+# connection $db. This sometimes finds use-after-free bugs if run with
+# valgrind or address-sanitizer.
+proc expand_all_sql {db} {
+ set stmt ""
+ while {[set stmt [sqlite3_next_stmt $db $stmt]]!=""} {
+ sqlite3_expanded_sql $stmt
+ }
+}
+
+
+# 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)
+
+# Make sure the FTS enhanced query syntax is disabled.
+set sqlite_fts3_enable_parentheses 0
+
+# During testing, assume that all database files are well-formed. The
+# few test cases that deliberately corrupt database files should rescind
+# this setting by invoking "database_can_be_corrupt"
+#
+database_never_corrupt
+extra_schema_checks 1
+
+source $testdir/thread_common.tcl
+source $testdir/malloc_common.tcl
+
+set tester_tcl_has_run 1
diff --git a/test/testrunner.tcl b/test/testrunner.tcl
new file mode 100644
index 0000000..da4efde
--- /dev/null
+++ b/test/testrunner.tcl
@@ -0,0 +1,705 @@
+
+#-------------------------------------------------------------------------
+# Usage:
+#
+proc usage {} {
+ set a0 testrunner.tcl
+
+ set ::argv [list]
+ uplevel [list source $::testdir/permutations.test]
+
+ puts stderr "Usage: $a0 ?SWITCHES? ?PERMUTATION? ?PATTERNS?"
+ puts stderr ""
+ puts stderr "where SWITCHES are:"
+ puts stderr " --jobs NUMBER-OF-JOBS"
+ puts stderr ""
+ puts stderr "available PERMUTATION values are:"
+ set ii 0
+ foreach name [lsort [array names ::testspec]] {
+ if {($ii % 3)==0} { puts -nonewline stderr " " }
+ puts -nonewline stderr [format "% -22s" $name]
+ if {($ii % 3)==2} { puts stderr "" }
+ incr ii
+ }
+ puts stderr ""
+ puts stderr ""
+ puts stderr "Examples:"
+ puts stderr " 1) Run the veryquick tests:"
+ puts stderr " $a0"
+ puts stderr " 2) Run all test scripts in the source tree:"
+ puts stderr " $a0 full"
+ puts stderr " 2) Run the 'memsubsys1' permutation:"
+ puts stderr " $a0 memsubsys1"
+ puts stderr " 3) Run all permutations usually run by \[make fulltest\]"
+ puts stderr " $a0 release"
+ puts stderr " 4) Run all scripts that match the pattern 'select%':"
+ puts stderr " $a0 select%"
+ puts stderr " $a0 all select%"
+ puts stderr " $a0 full select%"
+ puts stderr " 5) Run all scripts that are part of the veryquick permutation and match the pattern 'select%':"
+ puts stderr " $a0 veryquick select%"
+ puts stderr " 6) Run the 'memsubsys1' permutation, but just those scripts that match 'window%':"
+ puts stderr " $a0 memsubsys1 window%"
+ puts stderr " 7) Run all the permutations, but only the scripts that match either 'fts5%' or 'rtree%':"
+ puts stderr " $a0 release fts5% rtree%"
+
+ exit 1
+}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# The database schema used by the testrunner.db database.
+#
+set R(schema) {
+ DROP TABLE IF EXISTS script;
+ DROP TABLE IF EXISTS msg;
+ DROP TABLE IF EXISTS malloc;
+
+ CREATE TABLE script(
+ config TEXT,
+ filename TEXT, -- full path to test script
+ slow BOOLEAN, -- true if script is "slow"
+ state TEXT CHECK( state IN ('ready', 'running', 'done') ),
+ testfixtureid, -- Id of process that ran script
+ time INTEGER, -- Time in ms
+ nerr INTEGER, -- if 'done', the number of errors
+ ntest INTEGER, -- if 'done', the number of tests
+ output TEXT, -- full output of test script
+ PRIMARY KEY(config, filename)
+ );
+
+ CREATE TABLE malloc(
+ id INTEGER PRIMARY KEY,
+ nmalloc INTEGER,
+ nbyte INTEGER,
+ leaker TEXT
+ );
+
+ CREATE TABLE msg(
+ id INTEGER PRIMARY KEY,
+ msg TEXT
+ );
+}
+#-------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------
+# Try to estimate a the number of processes to use.
+#
+# Command [guess_number_of_cores] attempts to glean the number of logical
+# cores. Command [default_njob] returns the default value for the --jobs
+# switch.
+#
+proc guess_number_of_cores {} {
+ set ret 4
+
+ if {$::tcl_platform(os)=="Darwin"} {
+ set cmd "sysctl -n hw.logicalcpu"
+ } else {
+ set cmd "nproc"
+ }
+ catch {
+ set fd [open "|$cmd" r]
+ set ret [gets $fd]
+ close $fd
+ set ret [expr $ret]
+ }
+ return $ret
+}
+
+proc default_njob {} {
+ set nCore [guess_number_of_cores]
+ set nHelper [expr int($nCore*0.75)]
+ expr $nHelper>0 ? $nHelper : 1
+}
+#-------------------------------------------------------------------------
+
+
+set R(dbname) [file normalize testrunner.db]
+set R(logname) [file normalize testrunner.log]
+set R(info_script) [file normalize [info script]]
+set R(timeout) 10000 ;# Default busy-timeout for testrunner.
+set R(nJob) [default_njob] ;# Default number of helper processes
+set R(leaker) "" ;# Name of first script to leak memory
+
+set R(patternlist) [list]
+
+set testdir [file dirname $argv0]
+
+# Parse the command line options. There are two ways to invoke this
+# script - to create a helper or coordinator process. If there are
+# no helper processes, the coordinator runs test scripts.
+#
+# To create a helper process:
+#
+# testrunner.tcl helper ID
+#
+# where ID is an integer greater than 0. The process will create and
+# run tests in the "testdir$ID" directory. Helper processes are only
+# created by coordinators - there is no need for a user to create
+# helper processes manually.
+#
+# If the first argument is anything other than "helper", then a coordinator
+# process is started. See the implementation of the [usage] proc above for
+# details.
+#
+switch -- [lindex $argv 0] {
+ helper {
+ set R(helper) 1
+ set R(helper_id) [lindex $argv 1]
+ set argv [list --testdir=testdir$R(helper_id)]
+ }
+
+ default {
+ set R(helper) 0
+ set R(helper_id) 0
+
+ }
+}
+if {$R(helper)==0} {
+ for {set ii 0} {$ii < [llength $argv]} {incr ii} {
+ set a [lindex $argv $ii]
+ set n [string length $a]
+
+ if {[string range $a 0 0]=="-"} {
+ if {($n>2 && [string match "$a*" --jobs]) || $a=="-j"} {
+ incr ii
+ set R(nJob) [lindex $argv $ii]
+ } else {
+ usage
+ }
+ } else {
+ lappend R(patternlist) [string map {% *} $a]
+ }
+ }
+
+ set argv [list]
+}
+source $testdir/permutations.test
+
+#-------------------------------------------------------------------------
+# Return a list of tests to run. Each element of the list is itself a
+# list of two elements - the name of a permuations.test configuration
+# followed by the full path to a test script. i.e.:
+#
+# {CONFIG FILENAME} {CONFIG FILENAME} ...
+#
+proc testset_patternlist {patternlist} {
+
+ set first [lindex $patternlist 0]
+ if {$first=="all"} { set first "full" }
+
+ if {$first=="release"} {
+
+ # The following mirrors the set of test suites invoked by "all.test".
+ #
+ set clist {
+ full
+ no_optimization memsubsys1 memsubsys2 singlethread
+ multithread onefile utf16 exclusive persistent_journal
+ persistent_journal_error no_journal no_journal_error
+ autovacuum_ioerr no_mutex_try fullmutex journaltest
+ inmemory_journal pcache0 pcache10 pcache50 pcache90
+ pcache100 prepare mmap
+ }
+ ifcapable rbu { lappend clist rbu }
+ if {$::tcl_platform(platform)=="unix"} {
+ ifcapable !default_autovacuum {
+ lappend clist autovacuum_crash
+ }
+ }
+ set patternlist [lrange $patternlist 1 end]
+
+ } elseif {[info exists ::testspec($first)]} {
+ set clist $first
+ set patternlist [lrange $patternlist 1 end]
+ } elseif { [llength $patternlist]==0 } {
+ set clist veryquick
+ } else {
+ set clist full
+ }
+
+ set testset [list]
+
+ foreach config $clist {
+ catch { array unset O }
+ array set O $::testspec($config)
+ foreach f $O(-files) {
+ if {[file pathtype $f]!="absolute"} {
+ set f [file join $::testdir $f]
+ }
+ lappend testset [list $config [file normalize $f]]
+ }
+ }
+
+ if {[llength $patternlist]>0} {
+ foreach t $testset {
+ set tail [file tail [lindex $t 1]]
+ foreach p $patternlist {
+ if {[string match $p $tail]} {
+ lappend ret $t
+ break;
+ }
+ }
+ }
+ } else {
+ set ret $testset
+ }
+
+ set ret
+}
+#--------------------------------------------------------------------------
+
+
+proc r_write_db {tcl} {
+ global R
+
+ sqlite3_test_control_pending_byte 0x010000
+ sqlite3 db $R(dbname)
+ db timeout $R(timeout)
+ db eval { BEGIN EXCLUSIVE }
+
+ uplevel $tcl
+
+ db eval { COMMIT }
+ db close
+}
+
+proc make_new_testset {} {
+ global R
+
+ set tests [testset_patternlist $R(patternlist)]
+ r_write_db {
+ db eval $R(schema)
+ foreach t $tests {
+ foreach {c s} $t {}
+ set slow 0
+
+ set fd [open $s]
+ for {set ii 0} {$ii<100 && ![eof $fd]} {incr ii} {
+ set line [gets $fd]
+ if {[string match -nocase *testrunner:* $line]} {
+ regexp -nocase {.*testrunner:(.*)} $line -> properties
+ foreach p $properties {
+ if {$p=="slow"} { set slow 1 }
+ }
+ }
+ }
+ close $fd
+
+ db eval {
+ INSERT INTO script(config, filename, slow, state)
+ VALUES ($c, $s, $slow, 'ready')
+ }
+ }
+ }
+}
+
+# Find the next job in the database and mark it as 'running'. Then return
+# a list consisting of the
+#
+# CONFIG FILENAME
+#
+# pair for the test.
+#
+proc get_next_test {} {
+ global R
+ set myid $R(helper_id)
+
+ r_write_db {
+ set f ""
+ set c ""
+ db eval {
+ SELECT config, filename FROM script WHERE state='ready'
+ ORDER BY
+ (slow * (($myid+1) % 2)) DESC,
+ config!='full',
+ config,
+ filename
+ LIMIT 1
+ } {
+ set c $config
+ set f $filename
+ }
+ if {$f!=""} {
+ db eval {
+ UPDATE script SET state='running', testfixtureid=$myid
+ WHERE (config, filename) = ($c, $f)
+ }
+ }
+ }
+
+ if {$f==""} { return "" }
+ list $c $f
+}
+
+proc r_testname {config filename} {
+ set name [file tail $filename]
+ if {$config!="" && $config!="full" && $config!="veryquick"} {
+ set name "$config-$name"
+ }
+ return $name
+}
+
+proc r_set_test_result {config filename ms nerr ntest output} {
+ global R
+
+ set f [r_testname $config $filename]
+ if {$nerr==0} {
+ set msg "$f... Ok"
+ } else {
+ set msg "$f... FAILED - $nerr errors of $ntest tests"
+ }
+ append msg " (${ms}ms)"
+ if {$R(helper)} {
+ append msg " (helper $R(helper_id))"
+ }
+
+ sqlite3_shutdown
+ set nMalloc [lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1]
+ set nByte [sqlite3_memory_used]
+ if {($nByte>0 || $nMalloc>0) && $R(leaker)==""} {
+ set R(leaker) $f
+ }
+
+ r_write_db {
+ db eval {
+ UPDATE script
+ SET state='done', output=$output, nerr=$nerr, ntest=$ntest, time=$ms
+ WHERE (config, filename)=($config, $filename);
+
+ INSERT INTO msg(msg) VALUES ($msg);
+ }
+ }
+}
+
+set R(iNextMsg) 1
+proc r_get_messages {{db ""}} {
+ global R
+
+ sqlite3_test_control_pending_byte 0x010000
+
+ if {$db==""} {
+ sqlite3 rgmhandle $R(dbname)
+ set dbhandle rgmhandle
+ $dbhandle timeout $R(timeout)
+ } else {
+ set dbhandle $db
+ }
+
+ $dbhandle transaction {
+ set next $R(iNextMsg)
+ set ret [$dbhandle eval {SELECT msg FROM msg WHERE id>=$next}]
+ set R(iNextMsg) [$dbhandle one {SELECT COALESCE(max(id), 0)+1 FROM msg}]
+ }
+
+ if {$db==""} {
+ rgmhandle close
+ }
+
+ set ret
+}
+
+# This is called after all tests have been run to write the leaked memory
+# report into the malloc table of testrunner.db.
+#
+proc r_memory_report {} {
+ global R
+
+ sqlite3_shutdown
+
+ set nMalloc [lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1]
+ set nByte [sqlite3_memory_used]
+ set id $R(helper_id)
+ set leaker $R(leaker)
+
+ r_write_db {
+ db eval {
+ INSERT INTO malloc(id, nMalloc, nByte, leaker)
+ VALUES($id, $nMalloc, $nByte, $leaker)
+ }
+ }
+}
+
+
+#--------------------------------------------------------------------------
+#
+set ::R_INSTALL_PUTS_WRAPPER {
+ proc puts_sts_wrapper {args} {
+ set n [llength $args]
+ if {$n==1 || ($n==2 && [string first [lindex $args 0] -nonewline]==0)} {
+ uplevel puts_into_caller $args
+ } else {
+ # A channel was explicitly specified.
+ uplevel puts_sts_original $args
+ }
+ }
+ rename puts puts_sts_original
+ proc puts {args} { uplevel puts_sts_wrapper $args }
+}
+
+proc r_install_puts_wrapper {} $::R_INSTALL_PUTS_WRAPPER
+proc r_uninstall_puts_wrapper {} {
+ rename puts ""
+ rename puts_sts_original puts
+}
+
+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 an empty ::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]]
+ interp eval tinterp [list set ::G(runner.tcl) 1]
+
+ interp eval tinterp $::R_INSTALL_PUTS_WRAPPER
+ tinterp alias puts_into_caller puts_into_caller
+
+ # Load the various test interfaces implemented in C.
+ load_testfixture_extensions tinterp
+
+ # Run the test script.
+ set rc [catch { interp eval tinterp $script } msg opt]
+ if {$rc} {
+ puts_into_caller $msg
+ puts_into_caller [dict get $opt -errorinfo]
+ incr ::TC(errors)
+ }
+
+ # 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]
+
+ # 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]
+
+ r_install_puts_wrapper
+
+ # 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.
+ #
+ output2 "Time: $tail $ms ms"
+ show_memstats
+
+ r_uninstall_puts_wrapper
+ return $ms
+}
+
+proc puts_into_caller {args} {
+ global R
+ if {[llength $args]==1} {
+ append R(output) [lindex $args 0]
+ append R(output) "\n"
+ } else {
+ append R(output) [lindex $args 1]
+ }
+}
+
+#-------------------------------------------------------------------------
+#
+proc r_final_report {} {
+ global R
+
+ sqlite3_test_control_pending_byte 0x010000
+ sqlite3 db $R(dbname)
+
+ db timeout $R(timeout)
+
+ set errcode 0
+
+ # Create the text log file. This is just the concatenation of the
+ # 'output' column of the database for every script that was run.
+ set fd [open $R(logname) w]
+ db eval {SELECT output FROM script ORDER BY config!='full',config,filename} {
+ puts $fd $output
+ }
+ close $fd
+
+ # Check if any scripts reported errors. If so, print one line noting
+ # how many errors, and another identifying the scripts in which they
+ # occured. Or, if no errors occurred, print out "no errors at all!".
+ sqlite3 db $R(dbname)
+ db timeout $R(timeout)
+ db eval { SELECT sum(nerr) AS nerr, sum(ntest) AS ntest FROM script } { }
+ puts "$nerr errors from $ntest tests."
+ if {$nerr>0} {
+ db eval { SELECT config, filename FROM script WHERE nerr>0 } {
+ lappend errlist [r_testname $config $filename]
+ }
+ puts "Errors in: $errlist"
+ set errcode 1
+ }
+
+ # Check if any scripts were not run or did not finish. Print out a
+ # line identifying them if there are any.
+ set errlist [list]
+ db eval { SELECT config, filename FROM script WHERE state!='done' } {
+ lappend errlist [r_testname $config $filename]
+ }
+ if {$errlist!=[list]} {
+ puts "Tests DID NOT FINISH (crashed?): $errlist"
+ set errcode 1
+ }
+
+ set bLeak 0
+ db eval {
+ SELECT id, nmalloc, nbyte, leaker FROM malloc
+ WHERE nmalloc>0 OR nbyte>0
+ } {
+ if {$id==0} {
+ set line "This process "
+ } else {
+ set line "Helper $id "
+ }
+ append line "leaked $nbyte byte in $nmalloc allocations"
+ if {$leaker!=""} { append line " (perhaps in [file tail $leaker])" }
+ puts $line
+ set bLeak 1
+ }
+ if {$bLeak==0} {
+ puts "No leaks - all allocations freed."
+ }
+
+ db close
+
+ puts "Test database is $R(dbname)"
+ puts "Test log file is $R(logname)"
+ if {$errcode} {
+ puts "This test has FAILED."
+ }
+ return $errcode
+}
+
+
+if {$R(helper)==0} {
+ make_new_testset
+}
+
+set R(nHelperRunning) 0
+if {$R(helper)==0 && $R(nJob)>1} {
+ cd $cmdlinearg(TESTFIXTURE_HOME)
+ for {set ii 1} {$ii <= $R(nJob)} {incr ii} {
+ set cmd "[info nameofexec] $R(info_script) helper $ii 2>@1"
+ puts "Launching helper $ii ($cmd)"
+ set chan [open "|$cmd" r]
+ fconfigure $chan -blocking false
+ fileevent $chan readable [list r_helper_readable $ii $chan]
+ incr R(nHelperRunning)
+ }
+ cd $cmdlinearg(testdir)
+}
+
+proc r_helper_readable {id chan} {
+ set data [gets $chan]
+ if {$data!=""} { puts "helper $id:$data" }
+ if {[eof $chan]} {
+ puts "helper $id is finished"
+ incr ::R(nHelperRunning) -1
+ close $chan
+ }
+}
+
+if {$R(nHelperRunning)==0} {
+ while { ""!=[set t [get_next_test]] } {
+ set R(output) ""
+ set TC(count) 0
+ set TC(errors) 0
+
+ foreach {config filename} $t {}
+
+ array set O $::testspec($config)
+ set ::G(perm:name) $config
+ set ::G(perm:prefix) $O(-prefix)
+ set ::G(isquick) 1
+ set ::G(perm:dbconfig) $O(-dbconfig)
+ set ::G(perm:presql) $O(-presql)
+
+ eval $O(-initialize)
+ set ms [slave_test_file $filename]
+ eval $O(-shutdown)
+
+ unset -nocomplain ::G(perm:sqlite3_args)
+ unset ::G(perm:name)
+ unset ::G(perm:prefix)
+ unset ::G(perm:dbconfig)
+ unset ::G(perm:presql)
+
+ r_set_test_result $config $filename $ms $TC(errors) $TC(count) $R(output)
+
+ if {$R(helper)==0} {
+ foreach msg [r_get_messages] { puts $msg }
+ }
+ }
+
+ # Tests are finished - write a record into testrunner.db describing
+ # any memory leaks.
+ r_memory_report
+
+} else {
+ set TTT 0
+ sqlite3 db $R(dbname)
+ db timeout $R(timeout)
+ while {$R(nHelperRunning)>0} {
+ after 250 { incr TTT }
+ vwait TTT
+ foreach msg [r_get_messages db] { puts $msg }
+ }
+ db close
+}
+
+set errcode 0
+if {$R(helper)==0} {
+ set errcode [r_final_report]
+}
+
+exit $errcode
+
diff --git a/test/thread001.test b/test/thread001.test
new file mode 100644
index 0000000..1390f0d
--- /dev/null
+++ b/test/thread001.test
@@ -0,0 +1,147 @@
+# 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 }
+ifcapable !shared_cache { 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
+catch { db close }
+set sqlite_open_file_count 0
+finish_test
diff --git a/test/thread002.test b/test/thread002.test
new file mode 100644
index 0000000..3e9439e
--- /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 }
+ifcapable !shared_cache { 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..b7a67c5
--- /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,"%d: %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..3a12c58
--- /dev/null
+++ b/test/threadtest3.c
@@ -0,0 +1,1584 @@
+/*
+** 2010-07-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.
+**
+*************************************************************************
+**
+** 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
+**
+** Even though threadtest3.c is the only C source code file mentioned on
+** the compiler command-line, #include macros are used to pull in additional
+** C code files named "tt3_*.c".
+**
+** After compiling, run this program with an optional argument telling
+** which test to run. All tests are run if no argument is given. The
+** argument can be a glob pattern to match multiple tests. Examples:
+**
+** ./a.out -- Run all tests
+** ./a.out walthread3 -- Run the "walthread3" test
+** ./a.out 'wal*' -- Run all of the wal* tests
+** ./a.out --help -- List all available tests
+**
+** The exit status is non-zero if any test fails.
+*/
+
+/*
+** The "Set Error Line" macro.
+*/
+#define SEL(e) ((e)->iLine = ((e)->rc ? (e)->iLine : __LINE__))
+
+/* 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__))
+#define sql_script_printf(x,y,z,...) ( \
+ SEL(x), sql_script_printf_x(x,y,z,__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))
+
+#define PTR2INT(x) ((int)((intptr_t)x))
+#define INT2PTR(x) ((void*)((intptr_t)x))
+
+/*
+** End of test code/infrastructure interface macros.
+*************************************************************************/
+
+
+
+
+#include <sqlite3.h>
+
+#ifdef _WIN32
+# include <stdio.h>
+# include <string.h>
+# include <assert.h>
+# include <process.h>
+# include <windows.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <errno.h>
+# include <fcntl.h>
+# include <io.h>
+#else
+# 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>
+
+# define O_BINARY 0
+#endif
+
+#include "test_multiplex.h"
+
+/* Required to link test_multiplex.c */
+#ifndef SQLITE_OMIT_WSD
+int sqlite3PendingByte = 0x40000000;
+#endif
+
+/*
+ * 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];
+ union {
+ unsigned char in[64];
+ uint32 in32[16];
+ } u;
+};
+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->u.in + t;
+
+ t = 64-t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ byteReverse(ctx->u.in, 16);
+ MD5Transform(ctx->buf, (uint32 *)ctx->u.in);
+ buf += t;
+ len -= t;
+ }
+
+ /* Process data in 64-byte chunks */
+
+ while (len >= 64) {
+ memcpy(ctx->u.in, buf, 64);
+ byteReverse(ctx->u.in, 16);
+ MD5Transform(ctx->buf, (uint32 *)ctx->u.in);
+ buf += 64;
+ len -= 64;
+ }
+
+ /* Handle any remaining bytes of data. */
+
+ memcpy(ctx->u.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->u.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->u.in, 16);
+ MD5Transform(ctx->buf, (uint32 *)ctx->u.in);
+
+ /* Now fill the next block with 56 bytes */
+ memset(ctx->u.in, 0, 56);
+ } else {
+ /* Pad block to 56 bytes */
+ memset(p, 0, count-8);
+ }
+ byteReverse(ctx->u.in, 14);
+
+ /* Append length in bits and transform */
+ ctx->u.in32[14] = ctx->bits[0];
+ ctx->u.in32[15] = ctx->bits[1];
+
+ MD5Transform(ctx->buf, (uint32 *)ctx->u.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;
+
+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 */
+ void* pArg; /* Pointer argument passed by caller */
+
+#ifdef _WIN32
+ uintptr_t winTid; /* Thread handle */
+#else
+ pthread_t tid; /* Thread id */
+#endif
+ char *(*xProc)(int, void*); /* Thread main proc */
+ char *zRes; /* Value returned by xProc */
+ 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 ){
+ int isWarn = 0;
+ if( p->rc==SQLITE_SCHEMA ) isWarn = 1;
+ if( sqlite3_strglob("* - no such table: *",p->zErr)==0 ) isWarn = 1;
+ printf("%s: (%d) \"%s\" at line %d\n", isWarn ? "Warning" : "Error",
+ p->rc, p->zErr, p->iLine);
+ if( !isWarn ) nGlobalErr++;
+ fflush(stdout);
+ }
+}
+
+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;
+#if _WIN32
+ pErr->zErr = sqlite3_mprintf("%s", strerror(iSys));
+#else
+ pErr->zErr = (char *)sqlite3_malloc(512);
+ strerror_r(iSys, pErr->zErr, 512);
+ pErr->zErr[511] = '\0';
+#endif
+}
+
+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){
+ sqlite3_sleep(10);
+ 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;
+ int flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI;
+ if( bDelete ) unlink(zFile);
+ rc = sqlite3_open_v2(zFile, &pDb->db, flags, 0);
+ 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 void sql_script_printf_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Sqlite *pDb, /* Database handle */
+ const char *zFormat, /* SQL printf format string */
+ ... /* Printf args */
+){
+ va_list ap; /* ... printf arguments */
+ va_start(ap, zFormat);
+ if( pErr->rc==SQLITE_OK ){
+ char *zSql = sqlite3_vmprintf(zFormat, ap);
+ pErr->rc = sqlite3_exec(pDb->db, zSql, 0, 0, &pErr->zErr);
+ sqlite3_free(zSql);
+ }
+ va_end(ap);
+}
+
+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 */
+ va_start(ap, pDb);
+ pStmt = getAndBindSqlStatement(pErr, pDb, ap);
+ if( pStmt ){
+ 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 */
+ va_start(ap, iSlot);
+ pStmt = getAndBindSqlStatement(pErr, pDb, ap);
+ if( pStmt ){
+ 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 */
+ 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 = (const char*)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;
+ }
+ }
+ }
+}
+
+#ifdef _WIN32
+static unsigned __stdcall launch_thread_main(void *pArg){
+ Thread *p = (Thread *)pArg;
+ p->zRes = p->xProc(p->iTid, p->pArg);
+ _endthreadex(0);
+ return 0; /* NOT REACHED */
+}
+#else
+static void *launch_thread_main(void *pArg){
+ Thread *p = (Thread *)pArg;
+ p->zRes = p->xProc(p->iTid, p->pArg);
+ return 0;
+}
+#endif
+
+static void launch_thread_x(
+ Error *pErr, /* IN/OUT: Error code */
+ Threadset *pThreads, /* Thread set */
+ char *(*xProc)(int, void*), /* Proc to run */
+ void *pArg /* 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->pArg = pArg;
+ p->xProc = xProc;
+
+#ifdef _WIN32
+ rc = SQLITE_OK;
+ p->winTid = _beginthreadex(0, 0, launch_thread_main, (void*)p, 0, 0);
+ if( p->winTid==0 ) rc = errno ? errno : rc;
+#else
+ rc = pthread_create(&p->tid, NULL, launch_thread_main, (void *)p);
+#endif
+ 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){
+#ifndef _WIN32
+ void *ret;
+#endif
+ int rc;
+ pNext = p->pNext;
+
+#ifdef _WIN32
+ do {
+ rc = WaitForSingleObjectEx((HANDLE)p->winTid, INFINITE, TRUE);
+ }while( rc==WAIT_IO_COMPLETION );
+ CloseHandle((HANDLE)p->winTid);
+#else
+ rc = pthread_join(p->tid, &ret);
+#endif
+
+ if( rc!=0 ){
+ if( pErr->rc==SQLITE_OK ) system_error(pErr, rc);
+ }else{
+ printf("Thread %d says: %s\n", p->iTid, (p->zRes==0 ? "..." : p->zRes));
+ fflush(stdout);
+ }
+ sqlite3_free(p->zRes);
+ sqlite3_free(p);
+ }
+ pThreads->pThread = 0;
+}
+
+#ifdef _WIN32
+# define THREADTEST3_STAT _stat
+#else
+# define THREADTEST3_STAT stat
+#endif
+
+static i64 filesize_x(
+ Error *pErr,
+ const char *zFile
+){
+ i64 iRet = 0;
+ if( pErr->rc==SQLITE_OK ){
+ struct THREADTEST3_STAT sStat;
+ if( THREADTEST3_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|O_BINARY);
+ if( fd1<0 ){
+ system_error(pErr, errno);
+ return;
+ }
+ fd2 = open(zTo, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 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 double currentTime(void){
+ double t;
+ static sqlite3_vfs *pTimelimitVfs = 0;
+ if( pTimelimitVfs==0 ) pTimelimitVfs = sqlite3_vfs_find(0);
+ if( pTimelimitVfs->iVersion>=2 && pTimelimitVfs->xCurrentTimeInt64!=0 ){
+ sqlite3_int64 tm;
+ pTimelimitVfs->xCurrentTimeInt64(pTimelimitVfs, &tm);
+ t = tm/86400000.0;
+ }else{
+ pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t);
+ }
+ return t;
+}
+
+static void setstoptime_x(
+ Error *pErr, /* IN/OUT: Error code */
+ int nMs /* Milliseconds until "stop time" */
+){
+ if( pErr->rc==SQLITE_OK ){
+ double t = currentTime();
+ 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 = currentTime();
+ ret = (t >= timelimit);
+ }
+ return ret;
+}
+
+
+/*************************************************************************
+**************************************************************************
+**************************************************************************
+** End infrastructure. Begin tests.
+*/
+
+#define WALTHREAD1_NTHREAD 10
+#define WALTHREAD3_NTHREAD 6
+
+static char *walthread1_thread(int iTid, void *pArg){
+ 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, void *pArg){
+ 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) ){
+ sqlite3_sleep(500);
+ 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;"
+ );
+ closedb(&err, &db);
+
+ 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, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ int anTrans[2] = {0, 0}; /* Number of WAL and Rollback transactions */
+ int iArg = PTR2INT(pArg);
+
+ 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, (void*)1);
+ launch_thread(&err, &threads, walthread2_thread, (void*)1);
+ join_all_threads(&err, &threads);
+
+ print_and_free_err(&err);
+}
+
+static char *walthread3_thread(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ i64 iNextWrite; /* Next value this thread will write */
+ int iArg = PTR2INT(pArg);
+
+ 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, INT2PTR(i));
+ }
+ join_all_threads(&err, &threads);
+
+ print_and_free_err(&err);
+}
+
+static char *walthread4_reader_thread(int iTid, void *pArg){
+ 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, void *pArg){
+ 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, void *pArg){
+ 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, void *pArg){
+ 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++;
+ }
+ }
+ closedb(&err, &db);
+
+ print_and_free_err(&err);
+ return sqlite3_mprintf("%d created, %d dropped", nCreate, nDrop);
+}
+
+static char *dynamic_triggers_2(int iTid, void *pArg){
+ 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 );
+ }
+ closedb(&err, &db);
+
+ 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);"
+ );
+ closedb(&err, &db);
+
+ 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_sleep(2*1000);
+ sqlite3_enable_shared_cache(0);
+
+ 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"
+#include "tt3_index.c"
+#include "tt3_lookaside1.c"
+#include "tt3_vacuum.c"
+#include "tt3_stress.c"
+#include "tt3_shared.c"
+
+int main(int argc, char **argv){
+ struct ThreadTest {
+ void (*xTest)(int); /* Routine for running this test */
+ const char *zTest; /* Name of this test */
+ int nMs; /* How long to run this test, in milliseconds */
+ } aTest[] = {
+ { walthread1, "walthread1", 20000 },
+ { walthread2, "walthread2", 20000 },
+ { walthread3, "walthread3", 20000 },
+ { walthread4, "walthread4", 20000 },
+ { 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 },
+
+ { create_drop_index_1, "create_drop_index_1", 10000 },
+ { lookaside1, "lookaside1", 10000 },
+ { vacuum1, "vacuum1", 10000 },
+ { stress1, "stress1", 10000 },
+ { stress2, "stress2", 60000 },
+ { shared1, "shared1", 10000 },
+ };
+ static char *substArgv[] = { 0, "*", 0 };
+ int i, iArg;
+ int nTestfound = 0;
+
+ sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
+ if( argc<2 ){
+ argc = 2;
+ argv = substArgv;
+ }
+
+ /* Loop through the command-line arguments to ensure that each argument
+ ** selects at least one test. If not, assume there is a typo on the
+ ** command-line and bail out with the usage message. */
+ for(iArg=1; iArg<argc; iArg++){
+ const char *zArg = argv[iArg];
+ if( zArg[0]=='-' ){
+ if( sqlite3_stricmp(zArg, "-multiplexor")==0 ){
+ /* Install the multiplexor VFS as the default */
+ int rc = sqlite3_multiplex_initialize(0, 1);
+ if( rc!=SQLITE_OK ){
+ fprintf(stderr, "Failed to install multiplexor VFS (%d)\n", rc);
+ return 253;
+ }
+ }
+ else {
+ goto usage;
+ }
+
+ continue;
+ }
+
+ for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){
+ if( sqlite3_strglob(zArg, aTest[i].zTest)==0 ) break;
+ }
+ if( i>=sizeof(aTest)/sizeof(aTest[0]) ) goto usage;
+ }
+
+ for(iArg=1; iArg<argc; iArg++){
+ if( argv[iArg][0]=='-' ) continue;
+ for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){
+ char const *z = aTest[i].zTest;
+ if( sqlite3_strglob(argv[iArg],z)==0 ){
+ printf("Running %s for %d seconds...\n", z, aTest[i].nMs/1000);
+ fflush(stdout);
+ aTest[i].xTest(aTest[i].nMs);
+ nTestfound++;
+ }
+ }
+ }
+ if( nTestfound==0 ) goto usage;
+
+ printf("%d errors out of %d tests\n", nGlobalErr, nTestfound);
+ return (nGlobalErr>0 ? 255 : 0);
+
+ usage:
+ printf("Usage: %s [-multiplexor] [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/threadtest4.c b/test/threadtest4.c
new file mode 100644
index 0000000..da5ce75
--- /dev/null
+++ b/test/threadtest4.c
@@ -0,0 +1,484 @@
+/*
+** 2014-12-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 a simple standalone program used to stress the
+** SQLite library when accessing the same set of databases simultaneously
+** from multiple threads in shared-cache mode.
+**
+** This test program runs on unix-like systems only. It uses pthreads.
+** To compile:
+**
+** gcc -g -Wall -I. threadtest4.c sqlite3.c -ldl -lpthread
+**
+** To run:
+**
+** ./a.out 10
+**
+** The argument is the number of threads. There are also options, such
+** as -wal and -multithread and -serialized.
+**
+** Consider also compiling with clang instead of gcc and adding the
+** -fsanitize=thread option.
+*/
+#include "sqlite3.h"
+#include <pthread.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+/*
+** An instance of the following structure is passed into each worker
+** thread.
+*/
+typedef struct WorkerInfo WorkerInfo;
+struct WorkerInfo {
+ int tid; /* Thread ID */
+ int nWorker; /* Total number of workers */
+ unsigned wkrFlags; /* Flags */
+ sqlite3 *mainDb; /* Database connection of the main thread */
+ sqlite3 *db; /* Database connection of this thread */
+ int nErr; /* Number of errors seen by this thread */
+ int nTest; /* Number of tests run by this thread */
+ char *zMsg; /* Message returned by this thread */
+ pthread_t id; /* Thread id */
+ pthread_mutex_t *pWrMutex; /* Hold this mutex while writing */
+};
+
+/*
+** Allowed values for WorkerInfo.wkrFlags
+*/
+#define TT4_SERIALIZED 0x0000001 /* The --serialized option is used */
+#define TT4_WAL 0x0000002 /* WAL mode in use */
+#define TT4_TRACE 0x0000004 /* Trace activity */
+
+
+/*
+** Report an OOM error and die if the argument is NULL
+*/
+static void check_oom(void *x){
+ if( x==0 ){
+ fprintf(stderr, "out of memory\n");
+ exit(1);
+ }
+}
+
+/*
+** Allocate memory. If the allocation fails, print an error message and
+** kill the process.
+*/
+static void *safe_malloc(int sz){
+ void *x = sqlite3_malloc(sz>0?sz:1);
+ check_oom(x);
+ return x;
+}
+
+/*
+** Print a trace message for a worker
+*/
+static void worker_trace(WorkerInfo *p, const char *zFormat, ...){
+ va_list ap;
+ char *zMsg;
+ if( (p->wkrFlags & TT4_TRACE)==0 ) return;
+ va_start(ap, zFormat);
+ zMsg = sqlite3_vmprintf(zFormat, ap);
+ check_oom(zMsg);
+ va_end(ap);
+ fprintf(stderr, "TRACE(%02d): %s\n", p->tid, zMsg);
+ sqlite3_free(zMsg);
+}
+
+/*
+** Prepare a single SQL query
+*/
+static sqlite3_stmt *prep_sql(sqlite3 *db, const char *zFormat, ...){
+ va_list ap;
+ char *zSql;
+ int rc;
+ sqlite3_stmt *pStmt = 0;
+
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ check_oom(zSql);
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ if( rc!=SQLITE_OK ){
+ fprintf(stderr, "SQL error (%d,%d): %s\nWhile preparing: [%s]\n",
+ rc, sqlite3_extended_errcode(db), sqlite3_errmsg(db), zSql);
+ exit(1);
+ }
+ sqlite3_free(zSql);
+ return pStmt;
+}
+
+/*
+** Run a SQL statements. Panic if unable.
+*/
+static void run_sql(WorkerInfo *p, const char *zFormat, ...){
+ va_list ap;
+ char *zSql;
+ int rc;
+ sqlite3_stmt *pStmt = 0;
+ int nRetry = 0;
+
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ check_oom(zSql);
+ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
+ if( rc!=SQLITE_OK ){
+ fprintf(stderr, "SQL error (%d,%d): %s\nWhile preparing: [%s]\n",
+ rc, sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zSql);
+ exit(1);
+ }
+ worker_trace(p, "running [%s]", zSql);
+ while( (rc = sqlite3_step(pStmt))!=SQLITE_DONE ){
+ if( (rc&0xff)==SQLITE_BUSY || (rc&0xff)==SQLITE_LOCKED ){
+ sqlite3_reset(pStmt);
+ nRetry++;
+ if( nRetry<10 ){
+ worker_trace(p, "retry %d for [%s]", nRetry, zSql);
+ sched_yield();
+ continue;
+ }else{
+ fprintf(stderr, "Deadlock in thread %d while running [%s]\n",
+ p->tid, zSql);
+ exit(1);
+ }
+ }
+ if( rc!=SQLITE_ROW ){
+ fprintf(stderr, "SQL error (%d,%d): %s\nWhile running [%s]\n",
+ rc, sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zSql);
+ exit(1);
+ }
+ }
+ sqlite3_free(zSql);
+ sqlite3_finalize(pStmt);
+}
+
+
+/*
+** Open the database connection for WorkerInfo. The order in which
+** the files are opened is a function of the tid value.
+*/
+static void worker_open_connection(WorkerInfo *p, int iCnt){
+ char *zFile;
+ int x;
+ int rc;
+ static const unsigned char aOrder[6][3] = {
+ { 1, 2, 3},
+ { 1, 3, 2},
+ { 2, 1, 3},
+ { 2, 3, 1},
+ { 3, 1, 2},
+ { 3, 2, 1}
+ };
+ x = (p->tid + iCnt) % 6;
+ zFile = sqlite3_mprintf("tt4-test%d.db", aOrder[x][0]);
+ check_oom(zFile);
+ worker_trace(p, "open %s", zFile);
+ rc = sqlite3_open_v2(zFile, &p->db,
+ SQLITE_OPEN_READWRITE|SQLITE_OPEN_SHAREDCACHE, 0);
+ if( rc!=SQLITE_OK ){
+ fprintf(stderr, "sqlite_open_v2(%s) failed on thread %d\n",
+ zFile, p->tid);
+ exit(1);
+ }
+ sqlite3_free(zFile);
+ run_sql(p, "PRAGMA read_uncommitted=ON;");
+ sqlite3_busy_timeout(p->db, 10000);
+ run_sql(p, "PRAGMA synchronous=OFF;");
+ run_sql(p, "ATTACH 'tt4-test%d.db' AS aux1", aOrder[x][1]);
+ run_sql(p, "ATTACH 'tt4-test%d.db' AS aux2", aOrder[x][2]);
+}
+
+/*
+** Close the worker database connection
+*/
+static void worker_close_connection(WorkerInfo *p){
+ if( p->db ){
+ worker_trace(p, "close");
+ sqlite3_close(p->db);
+ p->db = 0;
+ }
+}
+
+/*
+** Delete all content in the three databases associated with a
+** single thread. Make this happen all in a single transaction if
+** inTrans is true, or separately for each database if inTrans is
+** false.
+*/
+static void worker_delete_all_content(WorkerInfo *p, int inTrans){
+ if( inTrans ){
+ pthread_mutex_lock(p->pWrMutex);
+ run_sql(p, "BEGIN");
+ run_sql(p, "DELETE FROM t1 WHERE tid=%d", p->tid);
+ run_sql(p, "DELETE FROM t2 WHERE tid=%d", p->tid);
+ run_sql(p, "DELETE FROM t3 WHERE tid=%d", p->tid);
+ run_sql(p, "COMMIT");
+ pthread_mutex_unlock(p->pWrMutex);
+ p->nTest++;
+ }else{
+ pthread_mutex_lock(p->pWrMutex);
+ run_sql(p, "DELETE FROM t1 WHERE tid=%d", p->tid);
+ pthread_mutex_unlock(p->pWrMutex);
+ p->nTest++;
+ pthread_mutex_lock(p->pWrMutex);
+ run_sql(p, "DELETE FROM t2 WHERE tid=%d", p->tid);
+ pthread_mutex_unlock(p->pWrMutex);
+ p->nTest++;
+ pthread_mutex_lock(p->pWrMutex);
+ run_sql(p, "DELETE FROM t3 WHERE tid=%d", p->tid);
+ pthread_mutex_unlock(p->pWrMutex);
+ p->nTest++;
+ }
+}
+
+/*
+** Create rows mn through mx in table iTab for the given worker
+*/
+static void worker_add_content(WorkerInfo *p, int mn, int mx, int iTab){
+ char *zTabDef;
+ switch( iTab ){
+ case 1: zTabDef = "t1(tid,sp,a,b,c)"; break;
+ case 2: zTabDef = "t2(tid,sp,d,e,f)"; break;
+ case 3: zTabDef = "t3(tid,sp,x,y,z)"; break;
+ }
+ pthread_mutex_lock(p->pWrMutex);
+ run_sql(p,
+ "WITH RECURSIVE\n"
+ " c(i) AS (VALUES(%d) UNION ALL SELECT i+1 FROM c WHERE i<%d)\n"
+ "INSERT INTO %s SELECT %d, zeroblob(3000), i, printf('%%d',i), i FROM c;",
+ mn, mx, zTabDef, p->tid
+ );
+ pthread_mutex_unlock(p->pWrMutex);
+ p->nTest++;
+}
+
+/*
+** Set an error message on a worker
+*/
+static void worker_error(WorkerInfo *p, const char *zFormat, ...){
+ va_list ap;
+ p->nErr++;
+ sqlite3_free(p->zMsg);
+ va_start(ap, zFormat);
+ p->zMsg = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+}
+
+/*
+** Each thread runs the following function.
+*/
+static void *worker_thread(void *pArg){
+ WorkerInfo *p = (WorkerInfo*)pArg;
+ int iOuter;
+ int i;
+ int rc;
+ sqlite3_stmt *pStmt;
+
+ printf("worker %d startup\n", p->tid); fflush(stdout);
+ for(iOuter=1; iOuter<=p->nWorker; iOuter++){
+ worker_open_connection(p, iOuter);
+ for(i=0; i<4; i++){
+ worker_add_content(p, i*100+1, (i+1)*100, (p->tid+iOuter)%3 + 1);
+ worker_add_content(p, i*100+1, (i+1)*100, (p->tid+iOuter+1)%3 + 1);
+ worker_add_content(p, i*100+1, (i+1)*100, (p->tid+iOuter+2)%3 + 1);
+ }
+
+ pStmt = prep_sql(p->db, "SELECT count(a) FROM t1 WHERE tid=%d", p->tid);
+ worker_trace(p, "query [%s]", sqlite3_sql(pStmt));
+ rc = sqlite3_step(pStmt);
+ if( rc!=SQLITE_ROW ){
+ worker_error(p, "Failed to step: %s", sqlite3_sql(pStmt));
+ }else if( sqlite3_column_int(pStmt, 0)!=400 ){
+ worker_error(p, "Wrong result: %d", sqlite3_column_int(pStmt,0));
+ }
+ sqlite3_finalize(pStmt);
+ if( p->nErr ) break;
+
+ if( ((iOuter+p->tid)%3)==0 ){
+ sqlite3_db_release_memory(p->db);
+ p->nTest++;
+ }
+
+ pthread_mutex_lock(p->pWrMutex);
+ run_sql(p, "BEGIN;");
+ run_sql(p, "UPDATE t1 SET c=NULL WHERE a=55");
+ run_sql(p, "UPDATE t2 SET f=NULL WHERE d=42");
+ run_sql(p, "UPDATE t3 SET z=NULL WHERE x=31");
+ run_sql(p, "ROLLBACK;");
+ p->nTest++;
+ pthread_mutex_unlock(p->pWrMutex);
+
+
+ if( iOuter==p->tid ){
+ pthread_mutex_lock(p->pWrMutex);
+ run_sql(p, "VACUUM");
+ pthread_mutex_unlock(p->pWrMutex);
+ }
+
+ pStmt = prep_sql(p->db,
+ "SELECT t1.rowid, t2.rowid, t3.rowid"
+ " FROM t1, t2, t3"
+ " WHERE t1.tid=%d AND t2.tid=%d AND t3.tid=%d"
+ " AND t1.a<>t2.d AND t2.d<>t3.x"
+ " ORDER BY 1, 2, 3"
+ ,p->tid, p->tid, p->tid);
+ worker_trace(p, "query [%s]", sqlite3_sql(pStmt));
+ for(i=0; i<p->nWorker; i++){
+ rc = sqlite3_step(pStmt);
+ if( rc!=SQLITE_ROW ){
+ worker_error(p, "Failed to step: %s", sqlite3_sql(pStmt));
+ break;
+ }
+ sched_yield();
+ }
+ sqlite3_finalize(pStmt);
+ if( p->nErr ) break;
+
+ worker_delete_all_content(p, (p->tid+iOuter)%2);
+ worker_close_connection(p);
+ p->db = 0;
+ }
+ worker_close_connection(p);
+ printf("worker %d finished\n", p->tid); fflush(stdout);
+ return 0;
+}
+
+int main(int argc, char **argv){
+ int nWorker = 0; /* Number of worker threads */
+ int i; /* Loop counter */
+ WorkerInfo *aInfo; /* Information for each worker */
+ unsigned wkrFlags = 0; /* Default worker flags */
+ int nErr = 0; /* Number of errors */
+ int nTest = 0; /* Number of tests */
+ int rc; /* Return code */
+ sqlite3 *db = 0; /* Main database connection */
+ pthread_mutex_t wrMutex; /* The write serialization mutex */
+ WorkerInfo infoTop; /* WorkerInfo for the main thread */
+ WorkerInfo *p; /* Pointer to infoTop */
+
+ sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
+ for(i=1; i<argc; i++){
+ const char *z = argv[i];
+ if( z[0]=='-' ){
+ if( z[1]=='-' && z[2]!=0 ) z++;
+ if( strcmp(z,"-multithread")==0 ){
+ sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
+ wkrFlags &= ~TT4_SERIALIZED;
+ }else if( strcmp(z,"-serialized")==0 ){
+ sqlite3_config(SQLITE_CONFIG_SERIALIZED);
+ wkrFlags |= TT4_SERIALIZED;
+ }else if( strcmp(z,"-wal")==0 ){
+ wkrFlags |= TT4_WAL;
+ }else if( strcmp(z,"-trace")==0 ){
+ wkrFlags |= TT4_TRACE;
+ }else{
+ fprintf(stderr, "unknown command-line option: %s\n", argv[i]);
+ exit(1);
+ }
+ }else if( z[0]>='1' && z[0]<='9' && nWorker==0 ){
+ nWorker = atoi(z);
+ if( nWorker<2 ){
+ fprintf(stderr, "minimum of 2 threads\n");
+ exit(1);
+ }
+ }else{
+ fprintf(stderr, "extra command-line argument: \"%s\"\n", argv[i]);
+ exit(1);
+ }
+ }
+ if( nWorker==0 ){
+ fprintf(stderr,
+ "usage: %s ?OPTIONS? N\n"
+ "N is the number of threads and must be at least 2.\n"
+ "Options:\n"
+ " --serialized\n"
+ " --multithread\n"
+ " --wal\n"
+ " --trace\n"
+ ,argv[0]
+ );
+ exit(1);
+ }
+ if( !sqlite3_threadsafe() ){
+ fprintf(stderr, "requires a threadsafe build of SQLite\n");
+ exit(1);
+ }
+ sqlite3_initialize();
+ sqlite3_enable_shared_cache(1);
+ pthread_mutex_init(&wrMutex, 0);
+
+ /* Initialize the test database files */
+ (void)unlink("tt4-test1.db");
+ (void)unlink("tt4-test2.db");
+ (void)unlink("tt4-test3.db");
+ rc = sqlite3_open("tt4-test1.db", &db);
+ if( rc!=SQLITE_OK ){
+ fprintf(stderr, "Unable to open test database: tt4-test2.db\n");
+ exit(1);
+ }
+ memset(&infoTop, 0, sizeof(infoTop));
+ infoTop.db = db;
+ infoTop.wkrFlags = wkrFlags;
+ p = &infoTop;
+ if( wkrFlags & TT4_WAL ){
+ run_sql(p, "PRAGMA journal_mode=WAL");
+ }
+ run_sql(p, "PRAGMA synchronous=OFF");
+ run_sql(p, "CREATE TABLE IF NOT EXISTS t1(tid INTEGER, sp, a, b, c)");
+ run_sql(p, "CREATE INDEX t1tid ON t1(tid)");
+ run_sql(p, "CREATE INDEX t1ab ON t1(a,b)");
+ run_sql(p, "ATTACH 'tt4-test2.db' AS 'test2'");
+ run_sql(p, "CREATE TABLE IF NOT EXISTS test2.t2(tid INTEGER, sp, d, e, f)");
+ run_sql(p, "CREATE INDEX test2.t2tid ON t2(tid)");
+ run_sql(p, "CREATE INDEX test2.t2de ON t2(d,e)");
+ run_sql(p, "ATTACH 'tt4-test3.db' AS 'test3'");
+ run_sql(p, "CREATE TABLE IF NOT EXISTS test3.t3(tid INTEGER, sp, x, y, z)");
+ run_sql(p, "CREATE INDEX test3.t3tid ON t3(tid)");
+ run_sql(p, "CREATE INDEX test3.t3xy ON t3(x,y)");
+ aInfo = safe_malloc( sizeof(*aInfo)*nWorker );
+ memset(aInfo, 0, sizeof(*aInfo)*nWorker);
+ for(i=0; i<nWorker; i++){
+ aInfo[i].tid = i+1;
+ aInfo[i].nWorker = nWorker;
+ aInfo[i].wkrFlags = wkrFlags;
+ aInfo[i].mainDb = db;
+ aInfo[i].pWrMutex = &wrMutex;
+ rc = pthread_create(&aInfo[i].id, 0, worker_thread, &aInfo[i]);
+ if( rc!=0 ){
+ fprintf(stderr, "thread creation failed for thread %d\n", i+1);
+ exit(1);
+ }
+ sched_yield();
+ }
+ for(i=0; i<nWorker; i++){
+ pthread_join(aInfo[i].id, 0);
+ printf("Joined thread %d: %d errors in %d tests",
+ aInfo[i].tid, aInfo[i].nErr, aInfo[i].nTest);
+ if( aInfo[i].zMsg ){
+ printf(": %s\n", aInfo[i].zMsg);
+ }else{
+ printf("\n");
+ }
+ nErr += aInfo[i].nErr;
+ nTest += aInfo[i].nTest;
+ fflush(stdout);
+ }
+ sqlite3_close(db);
+ sqlite3_free(aInfo);
+ printf("Total %d errors in %d tests\n", nErr, nTest);
+ return nErr;
+}
diff --git a/test/threadtest5.c b/test/threadtest5.c
new file mode 100644
index 0000000..6e6610f
--- /dev/null
+++ b/test/threadtest5.c
@@ -0,0 +1,339 @@
+/*
+** 2021-05-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.
+**
+*************************************************************************
+**
+** Testing threading behavior when multiple database connections in separate
+** threads of the same process are all talking to the same database file.
+**
+** For best results, ensure that SQLite is compiled with HAVE_USLEEP=1
+**
+** Only works on unix platforms.
+**
+** Usage:
+**
+** ./threadtest5 ?DATABASE?
+**
+** If DATABASE is omitted, it defaults to using file:/mem?vfs=memdb.
+*/
+#include "sqlite3.h"
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+/* Name of the in-memory database */
+static char *zDbName = 0;
+
+/* True for debugging */
+static int eVerbose = 0;
+
+/* If rc is not SQLITE_OK, then print an error message and stop
+** the test.
+*/
+static void error_out(int rc, const char *zCtx, int lineno){
+ if( rc!=SQLITE_OK ){
+ fprintf(stderr, "error %d at %d in \"%s\"\n", rc, lineno, zCtx);
+ exit(-1);
+ }
+}
+
+#if 0
+/* Return the number of milliseconds since the Julian epoch (-4714-11-24).
+*/
+static sqlite3_int64 gettime(void){
+ sqlite3_int64 tm;
+ sqlite3_vfs *pVfs = sqlite3_vfs_find(0);
+ pVfs->xCurrentTimeInt64(pVfs, &tm);
+ return tm;
+}
+#endif
+
+/* Run the SQL in the second argument.
+*/
+static int exec(
+ sqlite3 *db,
+ const char *zId,
+ int lineno,
+ const char *zFormat,
+ ...
+){
+ int rc;
+ va_list ap;
+ char *zSql;
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ if( eVerbose){
+ printf("%s:%d: [%s]\n", zId, lineno, zSql);
+ fflush(stdout);
+ }
+ rc = sqlite3_exec(db, zSql, 0, 0, 0);
+ if( rc && eVerbose ){
+ printf("%s:%d: return-code %d\n", zId, lineno, rc);
+ fflush(stdout);
+ }
+ sqlite3_free(zSql);
+ return rc;
+}
+
+/* Generate a perpared statement from the input SQL
+*/
+static sqlite3_stmt *prepare(
+ sqlite3 *db,
+ const char *zId,
+ int lineno,
+ const char *zFormat,
+ ...
+){
+ int rc;
+ va_list ap;
+ char *zSql;
+ sqlite3_stmt *pStmt = 0;
+ va_start(ap, zFormat);
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+ if( eVerbose){
+ printf("%s:%d: [%s]\n", zId, lineno, zSql);
+ fflush(stdout);
+ }
+
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ if( rc ){
+ printf("%s:%d: ERROR - %s\n", zId, lineno, sqlite3_errmsg(db));
+ exit(-1);
+ }
+ sqlite3_free(zSql);
+ return pStmt;
+}
+
+/*
+** Wait for table zTable to exist in the schema.
+*/
+static void waitOnTable(sqlite3 *db, const char *zWorker, const char *zTable){
+ while(1){
+ int eFound = 0;
+ sqlite3_stmt *q = prepare(db, zWorker, __LINE__,
+ "SELECT 1 FROM sqlite_schema WHERE name=%Q", zTable);
+ if( sqlite3_step(q)==SQLITE_ROW && sqlite3_column_int(q,0)!=0 ){
+ eFound = 1;
+ }
+ sqlite3_finalize(q);
+ if( eFound ) return;
+ sqlite3_sleep(1);
+ }
+}
+
+/*
+** Return true if x is a prime number
+*/
+static int isPrime(int x){
+ int i;
+ if( x<2 ) return 1;
+ for(i=2; i*i<=x; i++){
+ if( (x%i)==0 ) return 0;
+ }
+ return 1;
+}
+
+/* Each worker thread runs an instance of the following */
+static void *worker(void *pArg){
+ int rc;
+ const char *zName = (const char*)pArg;
+ sqlite3 *db = 0;
+
+ if( eVerbose ){
+ printf("%s: startup\n", zName);
+ fflush(stdout);
+ }
+
+ rc = sqlite3_open(zDbName, &db);
+ error_out(rc, "sqlite3_open", __LINE__);
+ sqlite3_busy_timeout(db, 2000);
+
+ while( 1 ){
+ sqlite3_stmt *q1;
+ int tid = -1;
+ q1 = prepare(db, zName, __LINE__,
+ "UPDATE task SET doneby=%Q"
+ " WHERE tid=(SELECT tid FROM task WHERE doneby IS NULL LIMIT 1)"
+ "RETURNING tid", zName
+ );
+ if( sqlite3_step(q1)==SQLITE_ROW ){
+ tid = sqlite3_column_int(q1,0);
+ }
+ sqlite3_finalize(q1);
+ if( tid<0 ) break;
+ if( eVerbose ){
+ printf("%s: starting task %d\n", zName, tid);
+ fflush(stdout);
+ }
+ if( tid==1 ){
+ exec(db, zName, __LINE__,
+ "CREATE TABLE IF NOT EXISTS p1(x INTEGER PRIMARY KEY);"
+ );
+ }else if( tid>=2 && tid<=51 ){
+ int a, b, i;
+ waitOnTable(db, zName, "p1");
+ a = (tid-2)*200 + 1;
+ b = a+200;
+ for(i=a; i<b; i++){
+ if( isPrime(i) ){
+ exec(db, zName, __LINE__,
+ "INSERT INTO p1(x) VALUES(%d)", i);
+ }
+ }
+ }else if( tid==52 ){
+ exec(db, zName, __LINE__,
+ "CREATE TABLE IF NOT EXISTS p2(x INTEGER PRIMARY KEY);"
+ "WITH RECURSIVE"
+ " c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10000)"
+ "INSERT INTO p2(x) SELECT x FROM c;"
+ );
+ }else if( tid>=53 && tid<=62 ){
+ int a, b, i;
+ waitOnTable(db, zName, "p2");
+ a = (tid-53)*10 + 2;
+ b = a+9;
+ for(i=a; i<=b; i++){
+ exec(db, zName, __LINE__,
+ "DELETE FROM p2 WHERE x>%d AND (x %% %d)==0", i, i);
+ }
+ }
+ if( eVerbose ){
+ printf("%s: completed task %d\n", zName, tid);
+ fflush(stdout);
+ }
+ sqlite3_sleep(1);
+ }
+
+ sqlite3_close(db);
+
+ if( eVerbose ){
+ printf("%s: exit\n", zName);
+ fflush(stdout);
+ }
+ return 0;
+}
+
+/* Print a usage comment and die */
+static void usage(const char *argv0){
+ printf("Usage: %s [options]\n", argv0);
+ printf(
+ " -num-workers N Run N worker threads\n"
+ " -v Debugging output\n"
+ );
+ exit(1);
+}
+
+/* Maximum number of threads */
+#define MX_WORKER 100
+
+/*
+** Main routine
+*/
+int main(int argc, char **argv){
+ int i;
+ int nWorker = 4;
+ int rc;
+ sqlite3 *db = 0;
+ sqlite3_stmt *q;
+ pthread_t aWorker[MX_WORKER];
+ char aWorkerName[MX_WORKER][8];
+
+ for(i=1; i<argc; i++){
+ const char *zArg = argv[i];
+ if( zArg[0]!='-' ){
+ if( zDbName==0 ){
+ zDbName = argv[i];
+ continue;
+ }
+ printf("unknown argument: %s\n", zArg);
+ usage(argv[0]);
+ }
+ if( zArg[1]=='-' ) zArg++;
+ if( strcmp(zArg, "-v")==0 ){
+ eVerbose = 1;
+ continue;
+ }
+ if( strcmp(zArg, "-num-workers")==0 && i+1<argc ){
+ nWorker = atoi(argv[++i]);
+ if( nWorker<1 || nWorker>MX_WORKER ){
+ printf("number of threads must be between 1 and %d\n", MX_WORKER);
+ exit(1);
+ }
+ continue;
+ }
+ printf("unknown option: %s\n", argv[i]);
+ usage(argv[0]);
+ }
+ if( zDbName==0 ) zDbName = "file:/mem?vfs=memdb";
+
+ sqlite3_config(SQLITE_CONFIG_URI, (int)1);
+ rc = sqlite3_open(zDbName, &db);
+ error_out(rc, "sqlite3_open", __LINE__);
+
+ rc = exec(db, "SETUP", __LINE__,
+ "DROP TABLE IF EXISTS task;\n"
+ "DROP TABLE IF EXISTS p1;\n"
+ "DROP TABLE IF EXISTS p2;\n"
+ "DROP TABLE IF EXISTS verify;\n"
+ "CREATE TABLE IF NOT EXISTS task(\n"
+ " tid INTEGER PRIMARY KEY,\n"
+ " doneby TEXT\n"
+ ");\n"
+ "WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)"
+ "INSERT INTO task(tid) SELECT x FROM c;\n"
+ );
+ error_out(rc, "sqlite3_exec", __LINE__);
+
+ for(i=0; i<nWorker; i++){
+ sqlite3_snprintf(sizeof(aWorkerName[i]), aWorkerName[i],
+ "W%02d", i);
+ pthread_create(&aWorker[i], 0, worker, aWorkerName[i]);
+ }
+ for(i=0; i<nWorker; i++){
+ pthread_join(aWorker[i], 0);
+ }
+
+ for(i=0; i<nWorker; i++){
+ q = prepare(db, "MAIN", __LINE__,
+ "SELECT group_concat(tid,',') FROM task WHERE doneby=%Q",
+ aWorkerName[i]);
+ if( sqlite3_step(q)==SQLITE_ROW ){
+ printf("%s: %s\n", aWorkerName[i], sqlite3_column_text(q,0));
+ }
+ sqlite3_finalize(q);
+ }
+ q = prepare(db, "MAIN", __LINE__, "SELECT count(*) FROM p2");
+ if( sqlite3_step(q)!=SQLITE_ROW || sqlite3_column_int(q,0)<10 ){
+ printf("incorrect result\n");
+ exit(-1);
+ }
+ sqlite3_finalize(q);
+ q = prepare(db, "MAIN", __LINE__, "SELECT x FROM p1 EXCEPT SELECT x FROM p2");
+ if( sqlite3_step(q)==SQLITE_ROW ){
+ printf("incorrect result\n");
+ exit(-1);
+ }
+ sqlite3_finalize(q);
+ q = prepare(db, "MAIN", __LINE__, "SELECT x FROM p2 EXCEPT SELECT x FROM p1");
+ if( sqlite3_step(q)==SQLITE_ROW ){
+ printf("incorrect result\n");
+ exit(-1);
+ }
+ sqlite3_finalize(q);
+ printf("OK\n");
+
+ sqlite3_close(db);
+ return 0;
+}
diff --git a/test/time-wordcount.sh b/test/time-wordcount.sh
new file mode 100644
index 0000000..df9edc6
--- /dev/null
+++ b/test/time-wordcount.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# This script runs the wordcount program in different ways and generates
+# an output useful for performance comparisons.
+#
+
+# Select the source text to be analyzed.
+#
+if test "x$1" = "x";
+then echo "Usage: $0 FILENAME [ARGS...]"; exit 1;
+fi
+
+# Do test runs
+#
+rm -f wcdb1.db
+./wordcount --tag A: --timer --summary wcdb1.db $* --insert
+rm -f wcdb2.db
+./wordcount --tag B: --timer --summary wcdb2.db $* --insert --without-rowid
+rm -f wcdb1.db
+./wordcount --tag C: --timer --summary wcdb1.db $* --replace
+rm -f wcdb2.db
+./wordcount --tag D: --timer --summary wcdb2.db $* --replace --without-rowid
+rm -f wcdb1.db
+./wordcount --tag E: --timer --summary wcdb1.db $* --select
+rm -f wcdb2.db
+./wordcount --tag F: --timer --summary wcdb2.db $* --select --without-rowid
+./wordcount --tag G: --timer --summary wcdb1.db $* --query
+./wordcount --tag H: --timer --summary wcdb1.db $* --query --without-rowid
+./wordcount --tag I: --timer --summary wcdb1.db $* --delete
+./wordcount --tag J: --timer --summary wcdb2.db $* --delete --without-rowid
+
+# Clean up temporary files created.
+#
+rm -f wcdb1.db wcdb2.db
diff --git a/test/tkt-02a8e81d44.test b/test/tkt-02a8e81d44.test
new file mode 100644
index 0000000..7ca9866
--- /dev/null
+++ b/test/tkt-02a8e81d44.test
@@ -0,0 +1,36 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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-18458b1a.test b/test/tkt-18458b1a.test
new file mode 100644
index 0000000..4a61274
--- /dev/null
+++ b/test/tkt-18458b1a.test
@@ -0,0 +1,52 @@
+# 2019 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 implements regression tests for SQLite library. In particular,
+# that problems related to ticket [18458b1a] have been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-18458b1a
+
+foreach tn {1 2} {
+ reset_db
+ if {$tn==1} {
+ # Disable the flattener and push-down optimizations
+ optimization_control db query-flattener 0
+ optimization_control db push-down 0
+ } else {
+ # Enable them
+ optimization_control db query-flattener 1
+ optimization_control db push-down 1
+ }
+
+ db cache size 0
+
+ do_execsql_test $tn.1.1 {
+ CREATE TABLE t0(c0 COLLATE NOCASE);
+ INSERT INTO t0(c0) VALUES ('B');
+ CREATE VIEW v0(c0, c1) AS SELECT DISTINCT t0.c0, 'a' FROM t0;
+ }
+
+ do_execsql_test $tn.1.2 {
+ SELECT count(*) FROM v0 WHERE c1 >= c0;
+ } 1
+
+ do_execsql_test $tn.1.3 {
+ SELECT count(*) FROM v0 WHERE NOT NOT (c1 >= c0);
+ } 1
+
+ do_execsql_test $tn.1.4 {
+ SELECT count(*) FROM v0 WHERE ((c1 >= c0) OR 0+0);
+ } 1
+}
+
+finish_test
diff --git a/test/tkt-26ff0c2d1e.test b/test/tkt-26ff0c2d1e.test
new file mode 100644
index 0000000..d7c5c6b
--- /dev/null
+++ b/test/tkt-26ff0c2d1e.test
@@ -0,0 +1,35 @@
+# 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
+
+finish_test
diff --git a/test/tkt-2a5629202f.test b/test/tkt-2a5629202f.test
new file mode 100644
index 0000000..8f09c31
--- /dev/null
+++ b/test/tkt-2a5629202f.test
@@ -0,0 +1,76 @@
+# 2012 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.
+#
+#***********************************************************************
+# The tests in this file were used while developing the SQLite 4 code.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-2a5629202f
+
+# 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
+}
+
+do_execsql_test 1.1 {
+ CREATE TABLE t8(b TEXT, c TEXT);
+ INSERT INTO t8 VALUES('a', 'one');
+ INSERT INTO t8 VALUES('b', 'two');
+ INSERT INTO t8 VALUES(NULL, 'three');
+ INSERT INTO t8 VALUES(NULL, 'four');
+}
+
+do_execsql_test 1.2 {
+ SELECT coalesce(b, 'null') || '/' || c FROM t8 x ORDER BY x.b, x.c
+} {null/four null/three a/one b/two}
+
+do_execsql_test 1.3 {
+ CREATE UNIQUE INDEX i1 ON t8(b);
+ SELECT coalesce(b, 'null') || '/' || c FROM t8 x ORDER BY x.b, x.c
+} {null/four null/three a/one b/two}
+
+do_execsql_test 1.4 {
+ DROP INDEX i1;
+ CREATE UNIQUE INDEX i1 ON t8(b, c);
+ SELECT coalesce(b, 'null') || '/' || c FROM t8 x ORDER BY x.b, x.c
+} {null/four null/three a/one b/two}
+
+#-------------------------------------------------------------------------
+#
+
+do_execsql_test 2.1 {
+ CREATE TABLE t2(a, b NOT NULL, c);
+ CREATE UNIQUE INDEX t2ab ON t2(a, b);
+ CREATE UNIQUE INDEX t2ba ON t2(b, a);
+}
+
+do_test 2.2 {
+ cksort { SELECT * FROM t2 WHERE a = 10 ORDER BY a, b, c }
+} {nosort}
+
+do_test 2.3 {
+ cksort { SELECT * FROM t2 WHERE b = 10 ORDER BY a, b, c }
+} {sort}
+
+do_test 2.4 {
+ cksort { SELECT * FROM t2 WHERE a IS NULL ORDER BY a, b, c }
+} {sort}
+
+finish_test
diff --git a/test/tkt-2d1a5c67d.test b/test/tkt-2d1a5c67d.test
new file mode 100644
index 0000000..1f79768
--- /dev/null
+++ b/test/tkt-2d1a5c67d.test
@@ -0,0 +1,128 @@
+# 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 {!vtab || !incrblob} {finish_test; return}
+if {[wal_is_capable]==0} {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
+load_static_extension db wholenumber
+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..41dd9d3
--- /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..5325fd2
--- /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
+
+if {![wal_is_capable]} { 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-385a5b56b9.test b/test/tkt-385a5b56b9.test
new file mode 100644
index 0000000..4451389
--- /dev/null
+++ b/test/tkt-385a5b56b9.test
@@ -0,0 +1,50 @@
+# 2012 April 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.
+#
+#***********************************************************************
+# The tests in this file were used while developing the SQLite 4 code.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-385a5b56b9
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, NULL);
+ INSERT INTO t1 VALUES(2, NULL);
+ INSERT INTO t1 VALUES(1, NULL);
+}
+
+do_execsql_test 1.1 { SELECT DISTINCT x, y FROM t1 } {1 {} 2 {}}
+do_execsql_test 1.2 { CREATE UNIQUE INDEX i1 ON t1(x, y) }
+do_execsql_test 1.3 { SELECT DISTINCT x, y FROM t1 } {1 {} 2 {}}
+
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 2.0 {
+ CREATE TABLE t2(x, y NOT NULL);
+ CREATE UNIQUE INDEX t2x ON t2(x);
+ CREATE UNIQUE INDEX t2y ON t2(y);
+}
+
+do_eqp_test 2.1 { SELECT DISTINCT x FROM t2 } \
+ {SCAN t2 USING COVERING INDEX t2x}
+
+do_eqp_test 2.2 { SELECT DISTINCT y FROM t2 } \
+ {SCAN t2 USING COVERING INDEX t2y}
+
+do_eqp_test 2.3 { SELECT DISTINCT x, y FROM t2 WHERE y=10 } \
+ {SEARCH t2 USING INDEX t2y (y=?)}
+
+do_eqp_test 2.4 { SELECT DISTINCT x, y FROM t2 WHERE x=10 } \
+ {SEARCH t2 USING INDEX t2x (x=?)}
+
+
+finish_test
diff --git a/test/tkt-38cb5df375.test b/test/tkt-38cb5df375.test
new file mode 100644
index 0000000..e5e0267
--- /dev/null
+++ b/test/tkt-38cb5df375.test
@@ -0,0 +1,326 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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-3a77c9714e.test b/test/tkt-3a77c9714e.test
new file mode 100644
index 0000000..734dff3
--- /dev/null
+++ b/test/tkt-3a77c9714e.test
@@ -0,0 +1,86 @@
+# 2011-12-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 to verify that ticket [3a77c9714e] has been
+# fixed.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+set testprefix "tkt-3a77c9714e"
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(t1_id INTEGER PRIMARY KEY, t1_title TEXT);
+ CREATE TABLE t2(t2_id INTEGER PRIMARY KEY, t2_title TEXT);
+ CREATE TABLE t3(t3_id INTEGER PRIMARY KEY, t3_title TEXT);
+
+ INSERT INTO t1 (t1_id, t1_title) VALUES (888, 'ABCDEF');
+ INSERT INTO t2 (t2_id, t2_title) VALUES (999, 'ABCDEF');
+ INSERT INTO t3 (t3_id, t3_title) VALUES (999, 'ABCDEF');
+}
+
+do_execsql_test 1.2 {
+ SELECT t1_title, t2_title
+ FROM t1 LEFT JOIN t2
+ WHERE
+ t2_id = (SELECT t3_id FROM
+ ( SELECT t3_id FROM t3 WHERE t3_title=t1_title LIMIT 500 )
+ )
+} {ABCDEF ABCDEF}
+
+do_execsql_test 2.1 {
+ CREATE TABLE [Beginnings] (
+ [Id] INTEGER PRIMARY KEY AUTOINCREMENT,[Title] TEXT, [EndingId] INTEGER
+ );
+ CREATE TABLE [Endings] (Id INT,Title TEXT,EndingId INT);
+ INSERT INTO Beginnings (Id, Title, EndingId) VALUES (1, 'FACTOR', 18);
+ INSERT INTO Beginnings (Id, Title, EndingId) VALUES (2, 'SWIMM', 18);
+ INSERT INTO Endings (Id, Title, EndingId) VALUES (1, 'ING', 18);
+}
+
+do_execsql_test 2.2 {
+ SELECT
+ SrcWord, Beginnings.Title
+ FROM
+ (SELECT 'FACTORING' AS SrcWord UNION SELECT 'SWIMMING' AS SrcWord )
+ LEFT JOIN
+ Beginnings
+ WHERE Beginnings.Id= (
+ SELECT BeginningId FROM (
+ SELECT SrcWord, B.Id as BeginningId, B.Title || E.Title As Connected
+ FROM Beginnings B LEFT JOIN Endings E ON B.EndingId=E.EndingId
+ WHERE Connected=SrcWord LIMIT 1
+ )
+ )
+} {FACTORING FACTOR SWIMMING SWIMM}
+
+# Similar problem discovered by dbsqlfuzz on 2019-09-18
+#
+do_execsql_test 3.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(i INT PRIMARY KEY, a, b);
+ INSERT INTO t1 VALUES(NULL,'one','i');
+ CREATE INDEX i1a ON t1(a);
+ CREATE INDEX i1b ON t1(b);
+ SELECT (SELECT 1
+ FROM (SELECT 1 FROM t1 WHERE a=1 OR b='i')
+ WHERE a='o'
+ OR b IN (SELECT a=('b' IN (SELECT 'a'))))
+ FROM t1;
+} {{}}
+
+finish_test
diff --git a/test/tkt-3fe897352e.test b/test/tkt-3fe897352e.test
new file mode 100644
index 0000000..bc2b203
--- /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..1908bcd
--- /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 {UNIQUE constraint failed: t1.b}}
+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-4c86b126f2.test b/test/tkt-4c86b126f2.test
new file mode 100644
index 0000000..3c5177e
--- /dev/null
+++ b/test/tkt-4c86b126f2.test
@@ -0,0 +1,49 @@
+# 2014-02-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. Specifically,
+# it tests that ticket [4c86b126f22ad548fee0125337bdc9366912d9ac].
+#
+# When SQLite is compiled using SQLITE_ENABLE_STAT3 or SQLITE_ENABLE_STAT4,
+# it gets the wrong answer...
+#
+# The problem was introduced in SQLite 3.8.1.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test tkt-4c86b126f2-1.1 {
+ CREATE TABLE nodes(
+ local_relpath TEXT PRIMARY KEY,
+ moved_to TEXT
+ );
+ INSERT INTO nodes VALUES('A',NULL);
+ INSERT INTO nodes VALUES('A/B',NULL);
+ INSERT INTO nodes VALUES('',NULL);
+ INSERT INTO nodes VALUES('A/B/C-move',NULL);
+ INSERT INTO nodes VALUES('A/B/C','A/B/C-move');
+ INSERT INTO nodes VALUES('A/B-move',NULL);
+ INSERT INTO nodes VALUES('A/B-move/C-move',NULL);
+ INSERT INTO nodes VALUES('A/B-move/C','x');
+ SELECT local_relpath, moved_to
+ FROM nodes
+ WHERE (local_relpath = 'A/B' OR
+ ((local_relpath > 'A/B/') AND (local_relpath < 'A/B0')))
+ AND moved_to IS NOT NULL;
+} {A/B/C A/B/C-move}
+
+do_execsql_test tkt-4c86b126f2-2.1 {
+ CREATE TABLE t1(x TEXT UNIQUE, y TEXT UNIQUE, z);
+ INSERT INTO t1 VALUES('ghi','jkl','y');
+ SELECT * FROM t1 WHERE (x='ghi' OR y='jkl') AND z IS NOT NULL;
+} {ghi jkl y}
+
+
+finish_test
diff --git a/test/tkt-4dd95f6943.test b/test/tkt-4dd95f6943.test
new file mode 100644
index 0000000..353031e
--- /dev/null
+++ b/test/tkt-4dd95f6943.test
@@ -0,0 +1,151 @@
+# 2013 March 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix tkt-4dd95f6943
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES (3), (4), (2), (1), (5), (6);
+}
+
+foreach {tn1 idx} {
+ 1 { CREATE INDEX i1 ON t1(x ASC) }
+ 2 { CREATE INDEX i1 ON t1(x DESC) }
+} {
+ do_execsql_test 1.$tn1.1 { DROP INDEX IF EXISTS i1; }
+ do_execsql_test 1.$tn1.2 $idx
+
+ do_execsql_test 1.$tn1.3 {
+ SELECT x FROM t1 WHERE x IN(2, 4, 5) ORDER BY x ASC;
+ } {2 4 5}
+
+ do_execsql_test 1.$tn1.4 {
+ SELECT x FROM t1 WHERE x IN(2, 4, 5) ORDER BY x DESC;
+ } {5 4 2}
+}
+
+
+do_execsql_test 2.0 {
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES (5, 3), (5, 4), (5, 2), (5, 1), (5, 5), (5, 6);
+ INSERT INTO t2 VALUES (1, 3), (1, 4), (1, 2), (1, 1), (1, 5), (1, 6);
+ INSERT INTO t2 VALUES (3, 3), (3, 4), (3, 2), (3, 1), (3, 5), (3, 6);
+ INSERT INTO t2 VALUES (2, 3), (2, 4), (2, 2), (2, 1), (2, 5), (2, 6);
+ INSERT INTO t2 VALUES (4, 3), (4, 4), (4, 2), (4, 1), (4, 5), (4, 6);
+ INSERT INTO t2 VALUES (6, 3), (6, 4), (6, 2), (6, 1), (6, 5), (6, 6);
+
+ CREATE TABLE t3(a, b);
+ INSERT INTO t3 VALUES (2, 2), (4, 4), (5, 5);
+ CREATE UNIQUE INDEX t3i1 ON t3(a ASC);
+ CREATE UNIQUE INDEX t3i2 ON t3(b DESC);
+}
+
+foreach {tn1 idx} {
+ 1 { CREATE INDEX i1 ON t2(x ASC, y ASC) }
+ 2 { CREATE INDEX i1 ON t2(x ASC, y DESC) }
+ 3 { CREATE INDEX i1 ON t2(x DESC, y ASC) }
+ 4 { CREATE INDEX i1 ON t2(x DESC, y DESC) }
+
+ 5 { CREATE INDEX i1 ON t2(y ASC, x ASC) }
+ 6 { CREATE INDEX i1 ON t2(y ASC, x DESC) }
+ 7 { CREATE INDEX i1 ON t2(y DESC, x ASC) }
+ 8 { CREATE INDEX i1 ON t2(y DESC, x DESC) }
+} {
+ do_execsql_test 2.$tn1.1 { DROP INDEX IF EXISTS i1; }
+ do_execsql_test 2.$tn1.2 $idx
+
+ foreach {tn2 inexpr} {
+ 3 "(2, 4, 5)"
+ 4 "(SELECT a FROM t3)"
+ 5 "(SELECT b FROM t3)"
+ } {
+ do_execsql_test 2.$tn1.$tn2.1 "
+ SELECT x, y FROM t2 WHERE x = 1 AND y IN $inexpr ORDER BY x ASC, y ASC;
+ " {1 2 1 4 1 5}
+
+ do_execsql_test 2.$tn1.$tn2.2 "
+ SELECT x, y FROM t2 WHERE x = 2 AND y IN $inexpr ORDER BY x ASC, y DESC;
+ " {2 5 2 4 2 2}
+
+ do_execsql_test 2.$tn1.$tn2.3 "
+ SELECT x, y FROM t2 WHERE x = 3 AND y IN $inexpr ORDER BY x DESC, y ASC;
+ " {3 2 3 4 3 5}
+
+ do_execsql_test 2.$tn1.$tn2.4 "
+ SELECT x, y FROM t2 WHERE x = 4 AND y IN $inexpr ORDER BY x DESC, y DESC;
+ " {4 5 4 4 4 2}
+
+ do_execsql_test 2.$tn1.$tn2.5 "
+ SELECT a, x, y FROM t2, t3 WHERE a = 4 AND x = 1 AND y IN $inexpr
+ ORDER BY a, x ASC, y ASC;
+ " {4 1 2 4 1 4 4 1 5}
+ do_execsql_test 2.$tn1.$tn2.6 "
+ SELECT a, x, y FROM t2, t3 WHERE a = 2 AND x = 1 AND y IN $inexpr
+ ORDER BY x ASC, y ASC;
+ " {2 1 2 2 1 4 2 1 5}
+
+ do_execsql_test 2.$tn1.$tn2.7 "
+ SELECT a, x, y FROM t2, t3 WHERE a = 4 AND x = 1 AND y IN $inexpr
+ ORDER BY a, x ASC, y DESC;
+ " {4 1 5 4 1 4 4 1 2}
+ do_execsql_test 2.$tn1.8 "
+ SELECT a, x, y FROM t2, t3 WHERE a = 2 AND x = 1 AND y IN $inexpr
+ ORDER BY x ASC, y DESC;
+ " {2 1 5 2 1 4 2 1 2}
+
+ do_execsql_test 2.$tn1.$tn2.9 "
+ SELECT a, x, y FROM t2, t3 WHERE a = 4 AND x = 1 AND y IN $inexpr
+ ORDER BY a, x DESC, y ASC;
+ " {4 1 2 4 1 4 4 1 5}
+ do_execsql_test 2.$tn1.10 "
+ SELECT a, x, y FROM t2, t3 WHERE a = 2 AND x = 1 AND y IN $inexpr
+ ORDER BY x DESC, y ASC;
+ " {2 1 2 2 1 4 2 1 5}
+
+ do_execsql_test 2.$tn1.$tn2.11 "
+ SELECT a, x, y FROM t2, t3 WHERE a = 4 AND x = 1 AND y IN $inexpr
+ ORDER BY a, x DESC, y DESC;
+ " {4 1 5 4 1 4 4 1 2}
+ do_execsql_test 2.$tn1.$tn2.12 "
+ SELECT a, x, y FROM t2, t3 WHERE a = 2 AND x = 1 AND y IN $inexpr
+ ORDER BY x DESC, y DESC;
+ " {2 1 5 2 1 4 2 1 2}
+ }
+}
+
+do_execsql_test 3.0 {
+ CREATE TABLE t7(x);
+ INSERT INTO t7 VALUES (1), (2), (3);
+ CREATE INDEX i7 ON t7(x);
+
+ CREATE TABLE t8(y);
+ INSERT INTO t8 VALUES (1), (2), (3);
+}
+
+foreach {tn idxdir sortdir sortdata} {
+ 1 ASC ASC {1 2 3}
+ 2 ASC DESC {3 2 1}
+ 3 DESC ASC {1 2 3}
+ 4 ASC DESC {3 2 1}
+} {
+
+ do_execsql_test 3.$tn "
+ DROP INDEX IF EXISTS i8;
+ CREATE UNIQUE INDEX i8 ON t8(y $idxdir);
+ SELECT x FROM t7 WHERE x IN (SELECT y FROM t8) ORDER BY x $sortdir;
+ " $sortdata
+}
+
+finish_test
diff --git a/test/tkt-4ef7e3cfca.test b/test/tkt-4ef7e3cfca.test
new file mode 100644
index 0000000..fc1efde
--- /dev/null
+++ b/test/tkt-4ef7e3cfca.test
@@ -0,0 +1,68 @@
+# 2014-03-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 tests to verify that ticket [4ef7e3cfca] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-4ef7e3cfca
+
+do_catchsql_test 1.1 {
+ CREATE TABLE x(a);
+ CREATE TRIGGER t AFTER INSERT ON x BEGIN
+ SELECT * FROM x WHERE abc.a = 1;
+ END;
+ INSERT INTO x VALUES('assert');
+} {1 {no such column: abc.a}}
+
+reset_db
+do_execsql_test 2.1 {
+ CREATE TABLE w(a);
+ CREATE TABLE x(a);
+ CREATE TABLE y(a);
+ CREATE TABLE z(a);
+
+ INSERT INTO x(a) VALUES(5);
+ INSERT INTO y(a) VALUES(10);
+
+ CREATE TRIGGER t AFTER INSERT ON w BEGIN
+ INSERT INTO z
+ SELECT (SELECT x.a + y.a FROM y) FROM x;
+ END;
+ INSERT INTO w VALUES('incorrect');
+}
+do_execsql_test 2.2 {
+ SELECT * FROM z;
+} {15}
+
+reset_db
+do_execsql_test 3.1 {
+ CREATE TABLE w(a);
+ CREATE TABLE x(b);
+ CREATE TABLE y(a);
+ CREATE TABLE z(a);
+
+ INSERT INTO x(b) VALUES(5);
+ INSERT INTO y(a) VALUES(10);
+
+ CREATE TRIGGER t AFTER INSERT ON w BEGIN
+ INSERT INTO z
+ SELECT (SELECT x.b + y.a FROM y) FROM x;
+ END;
+ INSERT INTO w VALUES('assert');
+}
+do_execsql_test 3.2 {
+ SELECT * FROM z;
+} {15}
+
+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..9a2fa3f
--- /dev/null
+++ b/test/tkt-5d863f876e.test
@@ -0,0 +1,55 @@
+# 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
+set ::testprefix tkt-5d863f876e
+if {![wal_is_capable]} {finish_test ; return }
+
+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-6bfb98dfc0.test b/test/tkt-6bfb98dfc0.test
new file mode 100644
index 0000000..675a3fc
--- /dev/null
+++ b/test/tkt-6bfb98dfc0.test
@@ -0,0 +1,61 @@
+# 2013 March 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. Specifically,
+# it tests that ticket [6bfb98dfc0]
+#
+# The final INSERT in the script below reports that the database is
+# corrupt (SQLITE_CORRUPT) and aborts even though the database is not
+# corrupt.
+#
+# PRAGMA page_size=512;
+# CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+# INSERT INTO t1 VALUES(1,randomblob(400));
+# INSERT INTO t1 VALUES(2,randomblob(400));
+# INSERT INTO t1 SELECT x+2, randomblob(400) FROM t1;
+# INSERT INTO t1 SELECT x+4, randomblob(400) FROM t1;
+# INSERT INTO t1 SELECT x+8, randomblob(400) FROM t1;
+# INSERT INTO t1 SELECT x+16, randomblob(400) FROM t1;
+# INSERT INTO t1 SELECT x+32, randomblob(400) FROM t1;
+# INSERT INTO t1 SELECT x+64, randomblob(400) FROM t1 WHERE x<10;
+# CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.x=74 BEGIN
+# DELETE FROM t1;
+# INSERT INTO t1 VALUES(75, randomblob(400));
+# INSERT INTO t1 VALUES(76, randomblob(400));
+# END;
+# INSERT INTO t1 VALUES(74, randomblob(400));
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-6bfb98dfc0.100 {
+ db eval {
+ PRAGMA page_size=512;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(1,randomblob(400));
+ INSERT INTO t1 VALUES(2,randomblob(400));
+ INSERT INTO t1 SELECT x+2, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT x+4, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT x+8, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT x+16, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT x+32, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT x+64, randomblob(400) FROM t1 WHERE x<10;
+ CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.x=74 BEGIN
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(75, randomblob(400));
+ INSERT INTO t1 VALUES(76, randomblob(400));
+ END;
+ INSERT INTO t1 VALUES(74, randomblob(400));
+ SELECT x, length(y) FROM t1 ORDER BY x;
+ }
+} {75 400 76 400}
+
+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..1b49f5d
--- /dev/null
+++ b/test/tkt-78e04e52ea.test
@@ -0,0 +1,66 @@
+# 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, x CHAR(100));
+ 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 {UNIQUE constraint failed: .}}
+do_test tkt-78e04-1.2 {
+ execsql {
+ PRAGMA table_info("");
+ }
+} {0 {} {} 0 {} 0 1 x CHAR(100) 0 {} 0}
+do_test tkt-78e04-1.3 {
+ execsql {
+ CREATE INDEX i1 ON ""("" COLLATE nocase);
+ }
+} {}
+do_test tkt-78e04-1.4 {
+ db eval {EXPLAIN QUERY PLAN SELECT "" FROM "" WHERE "" LIKE '1e5%';}
+} {/*SCAN USING COVERING INDEX i1*/}
+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;
+ }
+} {/*SEARCH t2 USING COVERING INDEX (x=?)*/}
+do_test tkt-78e04-2.2 {
+ execsql {
+ DROP INDEX "";
+ EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=2;
+ }
+} {/*SCAN t2*/}
+
+finish_test
diff --git a/test/tkt-7a31705a7e6.test b/test/tkt-7a31705a7e6.test
new file mode 100644
index 0000000..fd86248
--- /dev/null
+++ b/test/tkt-7a31705a7e6.test
@@ -0,0 +1,27 @@
+# 2013 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. Specifically,
+# it tests that ticket [7a31705a7e6c95d514e6f20a6900f436bbc9fed8] in the
+# name resolver has been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test tkt-7a31705a7e6-1.1 {
+ CREATE TABLE t1 (a INTEGER PRIMARY KEY);
+ CREATE TABLE t2 (a INTEGER PRIMARY KEY, b INTEGER);
+ CREATE TABLE t2x (b INTEGER PRIMARY KEY);
+ SELECT t1.a FROM ((t1 JOIN t2 ON t1.a=t2.a) AS x JOIN t2x ON x.b=t2x.b) as y;
+} {}
+
+finish_test
diff --git a/test/tkt-7bbfb7d442.test b/test/tkt-7bbfb7d442.test
new file mode 100644
index 0000000..c020b51
--- /dev/null
+++ b/test/tkt-7bbfb7d442.test
@@ -0,0 +1,154 @@
+# 2011 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 to verify that ticket [7bbfb7d442] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-7bbfb7d442
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+
+ CREATE TABLE t2(c, d);
+ INSERT INTO t2 VALUES('one', 'I');
+ INSERT INTO t2 VALUES('two', 'II');
+ INSERT INTO t2 VALUES('three', 'III');
+
+ CREATE TABLE t3(t3_a PRIMARY KEY, t3_d);
+ CREATE TRIGGER t3t AFTER INSERT ON t3 WHEN new.t3_d IS NULL BEGIN
+ UPDATE t3 SET t3_d = (
+ SELECT d FROM
+ (SELECT * FROM t2 WHERE (new.t3_a%2)=(rowid%2) LIMIT 10),
+ (SELECT * FROM t1 WHERE (new.t3_a%2)=(rowid%2) LIMIT 10)
+ WHERE a = new.t3_a AND b = c
+ ) WHERE t3_a = new.t3_a;
+ END;
+}
+
+do_execsql_test 1.2 {
+ INSERT INTO t3(t3_a) VALUES(1);
+ INSERT INTO t3(t3_a) VALUES(2);
+ INSERT INTO t3(t3_a) VALUES(3);
+ SELECT * FROM t3;
+} {1 I 2 II 3 III}
+
+do_execsql_test 1.3 { DELETE FROM t3 }
+
+ifcapable compound {
+ do_execsql_test 1.4 {
+ INSERT INTO t3(t3_a) SELECT 1 UNION SELECT 2 UNION SELECT 3;
+ SELECT * FROM t3;
+ } {1 I 2 II 3 III}
+}
+
+
+
+#-------------------------------------------------------------------------
+# The following test case - 2.* - is from the original bug report as
+# posted to the mailing list.
+#
+do_execsql_test 2.1 {
+ CREATE TABLE InventoryControl (
+ InventoryControlId INTEGER PRIMARY KEY AUTOINCREMENT,
+ SKU INTEGER NOT NULL,
+ Variant INTEGER NOT NULL DEFAULT 0,
+ ControlDate DATE NOT NULL,
+ ControlState INTEGER NOT NULL DEFAULT -1,
+ DeliveredQty VARCHAR(30)
+ );
+
+ CREATE TRIGGER TGR_InventoryControl_AfterInsert
+ AFTER INSERT ON InventoryControl
+ FOR EACH ROW WHEN NEW.ControlState=-1 BEGIN
+
+ INSERT OR REPLACE INTO InventoryControl(
+ InventoryControlId,SKU,Variant,ControlDate,ControlState,DeliveredQty
+ ) SELECT
+ T1.InventoryControlId AS InventoryControlId,
+ T1.SKU AS SKU,
+ T1.Variant AS Variant,
+ T1.ControlDate AS ControlDate,
+ 1 AS ControlState,
+ COALESCE(T2.DeliveredQty,0) AS DeliveredQty
+ FROM (
+ SELECT
+ NEW.InventoryControlId AS InventoryControlId,
+ II.SKU AS SKU,
+ II.Variant AS Variant,
+ COALESCE(LastClosedIC.ControlDate,NEW.ControlDate) AS ControlDate
+ FROM
+ InventoryItem II
+ LEFT JOIN
+ InventoryControl LastClosedIC
+ ON LastClosedIC.InventoryControlId IN ( SELECT 99999 )
+ WHERE
+ II.SKU=NEW.SKU AND
+ II.Variant=NEW.Variant
+ ) T1
+ LEFT JOIN (
+ SELECT
+ TD.SKU AS SKU,
+ TD.Variant AS Variant,
+ 10 AS DeliveredQty
+ FROM
+ TransactionDetail TD
+ WHERE
+ TD.SKU=NEW.SKU AND
+ TD.Variant=NEW.Variant
+ ) T2
+ ON T2.SKU=T1.SKU AND
+ T2.Variant=T1.Variant;
+ END;
+
+ CREATE TABLE InventoryItem (
+ SKU INTEGER NOT NULL,
+ Variant INTEGER NOT NULL DEFAULT 0,
+ DeptCode INTEGER NOT NULL,
+ GroupCode INTEGER NOT NULL,
+ ItemDescription VARCHAR(120) NOT NULL,
+ PRIMARY KEY(SKU, Variant)
+ );
+
+ INSERT INTO InventoryItem VALUES(220,0,1,170,'Scoth Tampon Recurer');
+ INSERT INTO InventoryItem VALUES(31,0,1,110,'Fromage');
+
+ CREATE TABLE TransactionDetail (
+ TransactionId INTEGER NOT NULL,
+ SKU INTEGER NOT NULL,
+ Variant INTEGER NOT NULL DEFAULT 0,
+ PRIMARY KEY(TransactionId, SKU, Variant)
+ );
+ INSERT INTO TransactionDetail(TransactionId, SKU, Variant) VALUES(44, 31, 0);
+
+
+ INSERT INTO InventoryControl(SKU, Variant, ControlDate) SELECT
+ II.SKU AS SKU, II.Variant AS Variant, '2011-08-30' AS ControlDate
+ FROM InventoryItem II;
+}
+
+do_execsql_test 2.2 {
+ SELECT SKU, DeliveredQty FROM InventoryControl WHERE SKU=31
+} {31 10}
+
+do_execsql_test 2.3 {
+ SELECT CASE WHEN DeliveredQty=10 THEN 'TEST PASSED!' ELSE 'TEST FAILED!' END
+ FROM InventoryControl WHERE SKU=31;
+} {{TEST PASSED!}}
+
+
+finish_test
diff --git a/test/tkt-80ba201079.test b/test/tkt-80ba201079.test
new file mode 100644
index 0000000..ea0799b
--- /dev/null
+++ b/test/tkt-80ba201079.test
@@ -0,0 +1,195 @@
+# 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-80ba201079
+
+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}
+
+ifcapable compound {
+ 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}
+
+ifcapable compound {
+ 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..56449db
--- /dev/null
+++ b/test/tkt-80e031a00f.test
@@ -0,0 +1,205 @@
+# 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-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-64309-54027 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 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
+do_execsql_test tkt-80e031a00f.326 {SELECT 'a' IN (NULL,'a')} 1
+do_execsql_test tkt-80e031a00f.327 {SELECT 'a' IN (NULL,'b')} {{}}
+do_execsql_test tkt-80e031a00f.328 {SELECT 'a' NOT IN (NULL,'a')} 0
+do_execsql_test tkt-80e031a00f.329 {SELECT 'a' NOT IN (NULL,'b')} {{}}
+#
+# 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..20e1420
--- /dev/null
+++ b/test/tkt-8454a207b9.test
@@ -0,0 +1,73 @@
+# 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
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+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-868145d012.test b/test/tkt-868145d012.test
new file mode 100644
index 0000000..145d159
--- /dev/null
+++ b/test/tkt-868145d012.test
@@ -0,0 +1,64 @@
+# 2013 March 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. Specifically,
+# it tests that ticket [868145d012a1] is fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test tkt-868145d012.100 {
+ CREATE TABLE p (
+ id INTEGER PRIMARY KEY,
+ uid VARCHAR(36),
+ t INTEGER
+ );
+
+ CREATE TABLE pa (
+ id INTEGER PRIMARY KEY,
+ a_uid VARCHAR(36)
+ );
+
+ CREATE TABLE a (
+ id INTEGER PRIMARY KEY,
+ uid VARCHAR(36),
+ t INTEGER
+ );
+
+ INSERT INTO pa VALUES(1,'1234');
+ INSERT INTO pa VALUES(2,'2345');
+ INSERT INTO p VALUES(3,'1234',97);
+ INSERT INTO p VALUES(4,'1234',98);
+ INSERT INTO a VALUES(5,'1234',98);
+ INSERT INTO a VALUES(6,'1234',99);
+} {}
+do_execsql_test tkt-868145d012.110 {
+ SELECT DISTINCT pa.id, p.id, a.id
+ FROM
+ pa
+ LEFT JOIN p ON p.uid='1234'
+ LEFT JOIN a ON a.uid=pa.a_uid
+ WHERE
+ a.t=p.t
+ ;
+} {1 4 5}
+do_execsql_test tkt-868145d012.120 {
+ SELECT DISTINCT pa.id, p.id, a.id
+ FROM
+ pa
+ LEFT JOIN p ON p.uid='1234'
+ LEFT JOIN a ON a.uid=pa.a_uid AND a.t=p.t
+ ORDER BY 1, 2, 3
+ ;
+} {1 3 {} 1 4 5 2 3 {} 2 4 {}}
+
+
+finish_test
diff --git a/test/tkt-8c63ff0ec.test b/test/tkt-8c63ff0ec.test
new file mode 100644
index 0000000..d4aaefd
--- /dev/null
+++ b/test/tkt-8c63ff0ec.test
@@ -0,0 +1,48 @@
+# 2014-02-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.
+#
+#***********************************************************************
+#
+# Test cases to show that ticket [8c63ff0eca81a9132d8d67b31cd6ae9712a2cc6f]
+# "Incorrect query result on a UNION ALL" which was caused by using the same
+# temporary register in concurrent co-routines, as been fixed.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix tkt-8c63ff0ec
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d, e);
+ INSERT INTO t1 VALUES(1,20,30,40,50),(3,60,70,80,90);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY);
+ INSERT INTO t2 VALUES(2);
+ CREATE TABLE t3(z);
+ INSERT INTO t3 VALUES(2),(2),(2),(2);
+
+ SELECT a, b+c FROM t1
+ UNION ALL
+ SELECT x, 5 FROM t2 JOIN t3 ON z=x WHERE x=2
+ ORDER BY a;
+} {1 50 2 5 2 5 2 5 2 5 3 130}
+do_execsql_test 1.2 {
+ SELECT a, b+c+d FROM t1
+ UNION ALL
+ SELECT x, 5 FROM t2 JOIN t3 ON z=x WHERE x=2
+ ORDER BY a;
+} {1 90 2 5 2 5 2 5 2 5 3 210}
+do_execsql_test 1.3 {
+ SELECT a, b+c+d+e FROM t1
+ UNION ALL
+ SELECT x, 5 FROM t2 JOIN t3 ON z=x WHERE x=2
+ ORDER BY a;
+} {1 140 2 5 2 5 2 5 2 5 3 300}
+
+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..9de8aea
--- /dev/null
+++ b/test/tkt-94c04eaadb.test
@@ -0,0 +1,72 @@
+# 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 [get_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 {
+ 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-9a8b09f8e6.test b/test/tkt-9a8b09f8e6.test
new file mode 100644
index 0000000..d6b22ef
--- /dev/null
+++ b/test/tkt-9a8b09f8e6.test
@@ -0,0 +1,323 @@
+# 2014 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.
+#
+# This file implements tests to verify that ticket [9a8b09f8e6] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-9a8b09f8e6
+
+do_test 1.1 {
+ execsql {
+ CREATE TABLE t1(x TEXT);
+ INSERT INTO t1 VALUES('1');
+ }
+} {}
+
+do_test 1.2 {
+ execsql {
+ CREATE TABLE t2(x INTEGER);
+ INSERT INTO t2 VALUES(1);
+ }
+} {}
+
+do_test 1.3 {
+ execsql {
+ CREATE TABLE t3(x REAL);
+ INSERT INTO t3 VALUES(1.0);
+ }
+} {}
+
+do_test 1.4 {
+ execsql {
+ CREATE TABLE t4(x REAL);
+ INSERT INTO t4 VALUES(1.11);
+ }
+} {}
+
+do_test 1.5 {
+ execsql {
+ CREATE TABLE t5(x, y);
+ INSERT INTO t5 VALUES('1', 'one');
+ INSERT INTO t5 VALUES(1, 'two');
+ INSERT INTO t5 VALUES('1.0', 'three');
+ INSERT INTO t5 VALUES(1.0, 'four');
+ }
+} {}
+
+do_test 2.1 {
+ execsql {
+ SELECT x FROM t1 WHERE x IN (1);
+ }
+} {1}
+
+do_test 2.2 {
+ execsql {
+ SELECT x FROM t1 WHERE x IN (1.0);
+ }
+} {}
+
+do_test 2.3 {
+ execsql {
+ SELECT x FROM t1 WHERE x IN ('1');
+ }
+} {1}
+
+do_test 2.4 {
+ execsql {
+ SELECT x FROM t1 WHERE x IN ('1.0');
+ }
+} {}
+
+do_test 2.5 {
+ execsql {
+ SELECT x FROM t1 WHERE 1 IN (x);
+ }
+} {}
+
+do_test 2.6 {
+ execsql {
+ SELECT x FROM t1 WHERE 1.0 IN (x);
+ }
+} {}
+
+do_test 2.7 {
+ execsql {
+ SELECT x FROM t1 WHERE '1' IN (x);
+ }
+} {1}
+
+do_test 2.8 {
+ execsql {
+ SELECT x FROM t1 WHERE '1.0' IN (x);
+ }
+} {}
+
+do_test 3.1 {
+ execsql {
+ SELECT x FROM t2 WHERE x IN (1);
+ }
+} {1}
+
+do_test 3.2 {
+ execsql {
+ SELECT x FROM t2 WHERE x IN (1.0);
+ }
+} {1}
+
+do_test 3.3 {
+ execsql {
+ SELECT x FROM t2 WHERE x IN ('1');
+ }
+} {1}
+
+do_test 3.4 {
+ execsql {
+ SELECT x FROM t2 WHERE x IN ('1.0');
+ }
+} {1}
+
+do_test 3.5 {
+ execsql {
+ SELECT x FROM t2 WHERE 1 IN (x);
+ }
+} {1}
+
+do_test 3.6 {
+ execsql {
+ SELECT x FROM t2 WHERE 1.0 IN (x);
+ }
+} {1}
+
+do_test 3.7 {
+ execsql {
+ SELECT x FROM t2 WHERE '1' IN (x);
+ }
+} {}
+
+do_test 3.8 {
+ execsql {
+ SELECT x FROM t2 WHERE '1.0' IN (x);
+ }
+} {}
+
+do_test 4.1 {
+ execsql {
+ SELECT x FROM t3 WHERE x IN (1);
+ }
+} {1.0}
+
+do_test 4.2 {
+ execsql {
+ SELECT x FROM t3 WHERE x IN (1.0);
+ }
+} {1.0}
+
+do_test 4.3 {
+ execsql {
+ SELECT x FROM t3 WHERE x IN ('1');
+ }
+} {1.0}
+
+do_test 4.4 {
+ execsql {
+ SELECT x FROM t3 WHERE x IN ('1.0');
+ }
+} {1.0}
+
+do_test 4.5 {
+ execsql {
+ SELECT x FROM t3 WHERE 1 IN (x);
+ }
+} {1.0}
+
+do_test 4.6 {
+ execsql {
+ SELECT x FROM t3 WHERE 1.0 IN (x);
+ }
+} {1.0}
+
+do_test 4.7 {
+ execsql {
+ SELECT x FROM t3 WHERE '1' IN (x);
+ }
+} {}
+
+do_test 4.8 {
+ execsql {
+ SELECT x FROM t3 WHERE '1.0' IN (x);
+ }
+} {}
+
+do_test 5.1 {
+ execsql {
+ SELECT x FROM t4 WHERE x IN (1);
+ }
+} {}
+
+do_test 5.2 {
+ execsql {
+ SELECT x FROM t4 WHERE x IN (1.0);
+ }
+} {}
+
+do_test 5.3 {
+ execsql {
+ SELECT x FROM t4 WHERE x IN ('1');
+ }
+} {}
+
+do_test 5.4 {
+ execsql {
+ SELECT x FROM t4 WHERE x IN ('1.0');
+ }
+} {}
+
+do_test 5.5 {
+ execsql {
+ SELECT x FROM t4 WHERE x IN (1.11);
+ }
+} {1.11}
+
+do_test 5.6 {
+ execsql {
+ SELECT x FROM t4 WHERE x IN ('1.11');
+ }
+} {1.11}
+
+do_test 5.7 {
+ execsql {
+ SELECT x FROM t4 WHERE 1 IN (x);
+ }
+} {}
+
+do_test 5.8 {
+ execsql {
+ SELECT x FROM t4 WHERE 1.0 IN (x);
+ }
+} {}
+
+do_test 5.9 {
+ execsql {
+ SELECT x FROM t4 WHERE '1' IN (x);
+ }
+} {}
+
+do_test 5.10 {
+ execsql {
+ SELECT x FROM t4 WHERE '1.0' IN (x);
+ }
+} {}
+
+do_test 5.11 {
+ execsql {
+ SELECT x FROM t4 WHERE 1.11 IN (x);
+ }
+} {1.11}
+
+do_test 5.12 {
+ execsql {
+ SELECT x FROM t4 WHERE '1.11' IN (x);
+ }
+} {}
+
+do_test 6.1 {
+ execsql {
+ SELECT x, y FROM t5 WHERE x IN (1);
+ }
+} {1 two 1.0 four}
+
+do_test 6.2 {
+ execsql {
+ SELECT x, y FROM t5 WHERE x IN (1.0);
+ }
+} {1 two 1.0 four}
+
+do_test 6.3 {
+ execsql {
+ SELECT x, y FROM t5 WHERE x IN ('1');
+ }
+} {1 one}
+
+do_test 6.4 {
+ execsql {
+ SELECT x, y FROM t5 WHERE x IN ('1.0');
+ }
+} {1.0 three}
+
+do_test 6.5 {
+ execsql {
+ SELECT x, y FROM t5 WHERE 1 IN (x);
+ }
+} {1 two 1.0 four}
+
+do_test 6.6 {
+ execsql {
+ SELECT x, y FROM t5 WHERE 1.0 IN (x);
+ }
+} {1 two 1.0 four}
+
+do_test 6.7 {
+ execsql {
+ SELECT x, y FROM t5 WHERE '1' IN (x);
+ }
+} {1 one}
+
+do_test 6.8 {
+ execsql {
+ SELECT x, y FROM t5 WHERE '1.0' IN (x);
+ }
+} {1.0 three}
+
+finish_test
diff --git a/test/tkt-9d68c883.test b/test/tkt-9d68c883.test
new file mode 100644
index 0000000..ba91b39
--- /dev/null
+++ b/test/tkt-9d68c883.test
@@ -0,0 +1,55 @@
+# 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}
+}
+
+catch { db close }
+unregister_devsim
+finish_test
diff --git a/test/tkt-9f2eb3abac.test b/test/tkt-9f2eb3abac.test
new file mode 100644
index 0000000..8411654
--- /dev/null
+++ b/test/tkt-9f2eb3abac.test
@@ -0,0 +1,78 @@
+
+# 2013 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set ::testprefix tkt-9f2eb3abac
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a,b,c,d,e, PRIMARY KEY(a,b,c,d,e));
+ SELECT * FROM t1 WHERE a=? AND b=? AND c=? AND d=? AND e=?;
+} {}
+
+do_execsql_test 1.2 {
+ CREATE TABLE "a" (
+ "b" integer NOT NULL,
+ "c" integer NOT NULL,
+ PRIMARY KEY ("b", "c")
+ );
+
+ CREATE TABLE "d" (
+ "e" integer NOT NULL,
+ "g" integer NOT NULL,
+ "f" integer NOT NULL,
+ "h" integer NOT NULL,
+ "i" character(10) NOT NULL,
+ "j" int,
+ PRIMARY KEY ("e", "g", "f", "h")
+ );
+
+ CREATE TABLE "d_to_a" (
+ "f_e" integer NOT NULL,
+ "f_g" integer NOT NULL,
+ "f_f" integer NOT NULL,
+ "f_h" integer NOT NULL,
+ "t_b" integer NOT NULL,
+ "t_c" integer NOT NULL,
+ "r" character NOT NULL,
+ "s" integer,
+ PRIMARY KEY ("f_e", "f_g", "f_f", "f_h", "t_b", "t_c")
+ );
+
+ INSERT INTO d (g, e, h, f, j, i) VALUES ( 1, 1, 1, 1, 1, 1 );
+ INSERT INTO a (b, c) VALUES ( 1, 1 );
+ INSERT INTO d_to_a VALUES (1, 1, 1, 1, 1, 1, 1, 1);
+
+ DELETE FROM d_to_a
+ WHERE f_g = 1 AND f_e = 1 AND f_h = 1 AND f_f = 1 AND t_b = 1 AND t_c = 1;
+
+ SELECT * FROM d_to_a;
+} {}
+
+faultsim_delete_and_reopen
+do_execsql_test 2.0 { CREATE TABLE t1(a,b,c,d,e, PRIMARY KEY(a,b,c,d,e)) }
+do_execsql_test 2.1 { CREATE TABLE t2(x) }
+faultsim_save_and_close
+
+do_faultsim_test 3 -faults oom* -prep {
+ faultsim_restore_and_reopen
+ execsql { SELECT 1 FROM sqlite_master }
+} -body {
+ execsql { SELECT * FROM t1,t2 WHERE a=? AND b=? AND c=? AND d=? AND e=? }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/tkt-a7b7803e.test b/test/tkt-a7b7803e.test
new file mode 100644
index 0000000..b617cf6
--- /dev/null
+++ b/test/tkt-a7b7803e.test
@@ -0,0 +1,84 @@
+# 2012 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. Specifically,
+# it tests that ticket [a7b7803e8d1e8699cd8a460a38133b98892d2e17] has
+# been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+do_test tkt-a7b7803e.1 {
+ db eval {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(0,'first'),(99,'fuzzy');
+ SELECT (t1.a==0) AS x, b
+ FROM t1
+ WHERE a=0 OR x;
+ }
+} {1 first}
+do_test tkt-a7b7803e.2 {
+ db eval {
+ SELECT a, (t1.b='fuzzy') AS x
+ FROM t1
+ WHERE x
+ }
+} {99 1}
+do_test tkt-a7b7803e.3 {
+ db eval {
+ SELECT (a=99) AS x, (t1.b='fuzzy') AS y, *
+ FROM t1
+ WHERE x AND y
+ }
+} {1 1 99 fuzzy}
+do_test tkt-a7b7803e.4 {
+ db eval {
+ SELECT (a=99) AS x, (t1.b='first') AS y, *
+ FROM t1
+ WHERE x OR y
+ ORDER BY a
+ }
+} {0 1 0 first 1 0 99 fuzzy}
+do_test tkt-a7b7803e.5 {
+ db eval {
+ SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b
+ FROM t1 M, t1 N
+ WHERE x OR y
+ ORDER BY M.a, N.a
+ }
+} {0 first 1 first 1 fuzzy 1 first 1 fuzzy 0 fuzzy}
+do_test tkt-a7b7803e.6 {
+ db eval {
+ SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b
+ FROM t1 M, t1 N
+ WHERE x AND y
+ ORDER BY M.a, N.a
+ }
+} {1 fuzzy 1 first}
+do_test tkt-a7b7803e.7 {
+ db eval {
+ SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b
+ FROM t1 M JOIN t1 N ON x AND y
+ ORDER BY M.a, N.a
+ }
+} {1 fuzzy 1 first}
+do_test tkt-a7b7803e.8 {
+ db eval {
+ SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b
+ FROM t1 M JOIN t1 N ON x
+ ORDER BY M.a, N.a
+ }
+} {1 fuzzy 1 first 1 fuzzy 0 fuzzy}
+
+
+finish_test
diff --git a/test/tkt-a7debbe0.test b/test/tkt-a7debbe0.test
new file mode 100644
index 0000000..cc72eb7
--- /dev/null
+++ b/test/tkt-a7debbe0.test
@@ -0,0 +1,102 @@
+# 2019 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 implements regression tests for SQLite library. In particular,
+# that problems related to ticket a7debbe0ad1 have been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-a7debbe0
+
+foreach tn {1 2} {
+ reset_db
+ if {$tn==1} {
+ # Disable the flattener
+ optimization_control db query-flattener 0
+ } else {
+ # Enable the flattener
+ optimization_control db query-flattener 1
+ }
+
+ do_execsql_test $tn.1.0 {
+ CREATE TABLE t0(xyz INTEGER);
+ INSERT INTO t0(xyz) VALUES(456);
+ CREATE VIEW v2(a, B) AS
+ SELECT 'a', 'B' COLLATE NOCASE FROM t0;
+ CREATE TABLE t2(a, B COLLATE NOCASE);
+ INSERT INTO t2 VALUES('a', 'B');
+ CREATE VIEW v3(a, B) AS
+ SELECT 'a' COLLATE BINARY, 'B' COLLATE NOCASE FROM t0;
+
+ CREATE VIEW v4(a, B) AS
+ SELECT 'a', +CAST('B' COLLATE NOCASE AS TEXT) FROM t0;
+
+ CREATE VIEW v5(a, B) AS
+ SELECT 'a', ('B' COLLATE NOCASE) || '' FROM t0;
+ }
+
+ # Table t2 and views v2 through v5 should all be equivalent.
+ do_execsql_test $tn.1.1.1 { SELECT a >= B FROM t2; } 1
+ do_execsql_test $tn.1.1.2 { SELECT 'a' >= 'B' COLLATE NOCASE } 0
+ do_execsql_test $tn.1.1.3 { SELECT a >= B FROM v2 } 1
+ do_execsql_test $tn.1.1.4 { SELECT a >= B FROM v3 } 1
+ do_execsql_test $tn.1.1.5 { SELECT a >= B FROM v4 } 1
+ do_execsql_test $tn.1.1.6 { SELECT a >= B FROM v5 } 1
+
+ do_execsql_test $tn.1.2.1 { SELECT B < a FROM t2 } 0
+ do_execsql_test $tn.1.2.2 { SELECT 'B' COLLATE NOCASE < 'a' } 0
+ do_execsql_test $tn.1.2.3 { SELECT B < a FROM v2 } 0
+ do_execsql_test $tn.1.2.4 { SELECT B < a FROM v3 } 0
+ do_execsql_test $tn.1.2.5 { SELECT a < B FROM v4 } 0
+ do_execsql_test $tn.1.2.6 { SELECT a < B FROM v5 } 0
+
+ #-------------------------------------------------------------------------
+ do_execsql_test $tn.2.0 {
+ CREATE TABLE t5(a, b COLLATE NOCASE);
+ INSERT INTO t5 VALUES(1, 'XYZ');
+ }
+
+ # Result should be 0, as column "xyz" from the sub-query has implicit
+ # collation sequence BINARY.
+ do_execsql_test $tn.2.1 {
+ SELECT xyz==b FROM ( SELECT a, 'xyz' AS xyz FROM t5 ), t5;
+ } {0}
+
+ # Result should be 1, as literal 'xyz' has no collation sequence, so
+ # the comparison uses the implicit collation sequence of the RHS - NOCASE.
+ do_execsql_test $tn.2.2 {
+ SELECT 'xyz'==b FROM ( SELECT a, 'xyz' AS xyz FROM t5 ), t5;
+ } {1}
+
+ #-----------------------------------------------------------------------
+ # The test case submitted with the ticket.
+ #
+ do_execsql_test $tn.3.0 {
+ DROP TABLE t0;
+ DROP VIEW v2;
+
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES('');
+ CREATE VIEW v2(c0, c1) AS
+ SELECT 'B' COLLATE NOCASE, 'a' FROM t0 ORDER BY t0.c0;
+ SELECT SUM(count) FROM (
+ SELECT v2.c1 BETWEEN v2.c0 AND v2.c1 as count FROM v2
+ );
+ } 1
+
+ # The result is 1, as the collation used is the implicit collation sequence
+ # of v2.c1 - BINARY.
+ do_execsql_test $tn.3.1 {
+ SELECT v2.c1 BETWEEN v2.c0 AND v2.c1 as count FROM v2;
+ } 1
+}
+
+finish_test
diff --git a/test/tkt-a8a0d2996a.test b/test/tkt-a8a0d2996a.test
new file mode 100644
index 0000000..2644937
--- /dev/null
+++ b/test/tkt-a8a0d2996a.test
@@ -0,0 +1,95 @@
+# 2014-03-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.
+#
+#***********************************************************************
+#
+# Tests to verify that arithmetic operators do not change the type of
+# input operands. Ticket [a8a0d2996a]
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-a8a0d2996a
+
+do_execsql_test 1.0 {
+ CREATE TABLE t(x,y);
+ INSERT INTO t VALUES('1','1');
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1';
+} {text text}
+do_execsql_test 1.1 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1';
+} {text text}
+do_execsql_test 1.2 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1';
+} {text text}
+do_execsql_test 1.3 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1';
+} {text text}
+do_execsql_test 1.4 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1';
+} {text text}
+
+do_execsql_test 2.0 {
+ UPDATE t SET x='1xyzzy';
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1';
+} {text text}
+do_execsql_test 2.1 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1';
+} {text text}
+do_execsql_test 2.2 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1';
+} {text text}
+do_execsql_test 2.3 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1';
+} {text text}
+do_execsql_test 2.4 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1';
+} {text text}
+
+
+do_execsql_test 3.0 {
+ UPDATE t SET x='1.0';
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1';
+} {text text}
+do_execsql_test 3.1 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1';
+} {text text}
+do_execsql_test 3.2 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1';
+} {text text}
+do_execsql_test 3.3 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1';
+} {text text}
+do_execsql_test 3.4 {
+ SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1';
+} {text text}
+
+do_execsql_test 4.0 {
+ SELECT 1+1.;
+} {2.0}
+do_execsql_test 4.1 {
+ SELECT '1.23e64'/'1.0000e+62';
+} {123.0}
+do_execsql_test 4.2 {
+ SELECT '100x'+'-2y';
+} {98}
+do_execsql_test 4.3 {
+ SELECT '100x'+'4.5y';
+} {104.5}
+do_execsql_test 4.4 {
+ SELECT '-9223372036854775807x'-'1x';
+} {-9223372036854775808}
+do_execsql_test 4.5 {
+ SELECT '9223372036854775806x'+'1x';
+} {9223372036854775807}
+do_execsql_test 4.6 {
+ SELECT '1234x'/'10y', '1234x'/'10.y', '1234x'/'1e1y';
+} {123 123.4 123.4}
+
+finish_test
diff --git a/test/tkt-b1d3a2e531.test b/test/tkt-b1d3a2e531.test
new file mode 100644
index 0000000..745bbe8
--- /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..dea3f49
--- /dev/null
+++ b/test/tkt-b72787b1.test
@@ -0,0 +1,82 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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-b75a9ca6b0.test b/test/tkt-b75a9ca6b0.test
new file mode 100644
index 0000000..f5c8804
--- /dev/null
+++ b/test/tkt-b75a9ca6b0.test
@@ -0,0 +1,77 @@
+# 2014-04-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.
+#
+#*************************************************************************
+#
+# Test that ticket [b75a9ca6b0] has been fixed.
+#
+# Ticket [b75a9ca6b0] concerns queries that have both a GROUP BY
+# and an ORDER BY. This code verifies that SQLite is able to
+# optimize out the ORDER BY in some circumstances, but retains the
+# ORDER BY when necessary.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-b75a9ca6b0
+
+do_execsql_test 1 {
+ CREATE TABLE t1 (x, y);
+ INSERT INTO t1 VALUES (1, 3);
+ INSERT INTO t1 VALUES (2, 2);
+ INSERT INTO t1 VALUES (3, 1);
+}
+
+do_execsql_test 1.1 {
+ CREATE INDEX i1 ON t1(x, y);
+}
+
+set idxscan {SCAN t1 USING COVERING INDEX i1}
+set tblscan {SCAN t1}
+set grpsort {USE TEMP B-TREE FOR GROUP BY}
+set sort {USE TEMP B-TREE FOR ORDER BY}
+
+foreach {tn q res eqp} [subst -nocommands {
+ 1 "SELECT * FROM t1 GROUP BY x, y ORDER BY x,y"
+ {1 3 2 2 3 1} {$idxscan}
+
+ 2 "SELECT * FROM t1 GROUP BY x, y ORDER BY x"
+ {1 3 2 2 3 1} {$idxscan*$sort}
+
+ 3 "SELECT * FROM t1 GROUP BY y, x ORDER BY y, x"
+ {3 1 2 2 1 3} {$idxscan*$sort}
+
+ 4 "SELECT * FROM t1 GROUP BY x ORDER BY x"
+ {1 3 2 2 3 1} {$idxscan}
+
+ 5 "SELECT * FROM t1 GROUP BY y ORDER BY y"
+ {3 1 2 2 1 3} {$tblscan*$grpsort}
+
+ 6 "SELECT * FROM t1 GROUP BY y ORDER BY x"
+ {1 3 2 2 3 1} {$tblscan*$grpsort*$sort}
+
+ 7 "SELECT * FROM t1 GROUP BY x, y ORDER BY x, y DESC"
+ {1 3 2 2 3 1} {$idxscan*$sort}
+
+ 8 "SELECT * FROM t1 GROUP BY x, y ORDER BY x DESC, y DESC"
+ {3 1 2 2 1 3} {$idxscan}
+
+ 9 "SELECT * FROM t1 GROUP BY x, y ORDER BY x ASC, y ASC"
+ {1 3 2 2 3 1} {$idxscan}
+
+ 10 "SELECT * FROM t1 GROUP BY x, y ORDER BY x COLLATE nocase, y"
+ {1 3 2 2 3 1} {$idxscan*$sort}
+
+}] {
+ do_execsql_test 1.$tn.1 $q $res
+ do_eqp_test 1.$tn.2 $q $eqp
+}
+
+
+finish_test
diff --git a/test/tkt-ba7cbfaedc.test b/test/tkt-ba7cbfaedc.test
new file mode 100644
index 0000000..f83f8a3
--- /dev/null
+++ b/test/tkt-ba7cbfaedc.test
@@ -0,0 +1,63 @@
+# 2014-10-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 that ticket [ba7cbfaedc] has been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-ba7cbfaedc
+
+do_execsql_test 1 {
+ CREATE TABLE t1 (x, y);
+ INSERT INTO t1 VALUES (3, 'a');
+ INSERT INTO t1 VALUES (1, 'a');
+ INSERT INTO t1 VALUES (2, 'b');
+ INSERT INTO t1 VALUES (2, 'a');
+ INSERT INTO t1 VALUES (3, 'b');
+ INSERT INTO t1 VALUES (1, 'b');
+}
+
+do_execsql_test 1.1 {
+ CREATE INDEX i1 ON t1(x, y);
+}
+
+foreach {n idx} {
+ 1 { CREATE INDEX i1 ON t1(x, y) }
+ 2 { CREATE INDEX i1 ON t1(x DESC, y) }
+ 3 { CREATE INDEX i1 ON t1(x, y DESC) }
+ 4 { CREATE INDEX i1 ON t1(x DESC, y DESC) }
+} {
+ catchsql { DROP INDEX i1 }
+ execsql $idx
+ foreach {tn q res} {
+ 1 "GROUP BY x, y ORDER BY x, y" {1 a 1 b 2 a 2 b 3 a 3 b}
+ 2 "GROUP BY x, y ORDER BY x DESC, y" {3 a 3 b 2 a 2 b 1 a 1 b}
+ 3 "GROUP BY x, y ORDER BY x, y DESC" {1 b 1 a 2 b 2 a 3 b 3 a}
+ 4 "GROUP BY x, y ORDER BY x DESC, y DESC" {3 b 3 a 2 b 2 a 1 b 1 a}
+ } {
+ do_execsql_test 1.$n.$tn "SELECT * FROM t1 $q" $res
+ }
+}
+
+do_execsql_test 2.0 {
+ drop table if exists t1;
+ create table t1(id int);
+ insert into t1(id) values(1),(2),(3),(4),(5);
+ create index t1_idx_id on t1(id asc);
+ select * from t1 group by id order by id;
+ select * from t1 group by id order by id asc;
+ select * from t1 group by id order by id desc;
+} {
+ 1 2 3 4 5 1 2 3 4 5 5 4 3 2 1
+}
+
+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-bdc6bbbb38.test b/test/tkt-bdc6bbbb38.test
new file mode 100644
index 0000000..8b0d55d
--- /dev/null
+++ b/test/tkt-bdc6bbbb38.test
@@ -0,0 +1,90 @@
+# 2012 May 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 verify that ticket [bdc6bbbb38] has been
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-bdc6bbbb38
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 { finish_test ; return }
+set sqlite_fts3_enable_parentheses 1
+
+foreach {tn idxdir} {1 ASC 2 DESC} {
+ execsql { DROP TABLE IF EXISTS t2 }
+
+ do_execsql_test $tn.1.1 "CREATE VIRTUAL TABLE t2 USING fts4(x, order=$idxdir)"
+ do_execsql_test $tn.1.2 { INSERT INTO t2 VALUES('a b c') }
+
+ do_execsql_test $tn.1.3 {
+ SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC
+ } {
+ {0 0 0 1 0 2 2 1}
+ }
+ do_execsql_test $tn.1.4 {
+ SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b'
+ ORDER BY docid ASC
+ } {
+ {[a] [b] c}
+ }
+ do_execsql_test $tn.1.5 { INSERT INTO t2 VALUES('a c d') }
+ do_execsql_test $tn.1.6 {
+ SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC
+ } {
+ {0 0 0 1 0 2 2 1}
+ {0 0 0 1 0 1 4 1}
+ }
+ do_execsql_test $tn.1.7 {
+ SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b'
+ ORDER BY docid ASC
+ } {
+ {[a] [b] c}
+ {[a] c [d]}
+ }
+
+ execsql { DROP TABLE IF EXISTS t3 }
+ do_execsql_test $tn.2.1 "CREATE VIRTUAL TABLE t3 USING fts4(x, order=$idxdir)"
+ do_execsql_test $tn.2.2 { INSERT INTO t3 VALUES('a c d') }
+ do_execsql_test $tn.2.3 {
+ SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC
+ } {
+ {0 0 0 1 0 1 4 1}
+ }
+ do_execsql_test $tn.2.4 {
+ SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b'
+ ORDER BY docid DESC
+ } {
+ {[a] c [d]}
+ }
+ do_execsql_test $tn.2.5 {
+ INSERT INTO t3 VALUES('a b c');
+ }
+ do_execsql_test $tn.2.6 {
+ SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC
+ } {
+ {0 0 0 1 0 2 2 1}
+ {0 0 0 1 0 1 4 1}
+ }
+ do_execsql_test $tn.2.7 {
+ SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b'
+ ORDER BY docid DESC
+ } {
+ {[a] [b] c}
+ {[a] c [d]}
+ }
+}
+
+set sqlite_fts3_enable_parentheses 0
+finish_test
diff --git a/test/tkt-c48d99d690.test b/test/tkt-c48d99d690.test
new file mode 100644
index 0000000..6d1b9db
--- /dev/null
+++ b/test/tkt-c48d99d690.test
@@ -0,0 +1,25 @@
+
+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-c694113d5.test b/test/tkt-c694113d5.test
new file mode 100644
index 0000000..bac91fc
--- /dev/null
+++ b/test/tkt-c694113d5.test
@@ -0,0 +1,36 @@
+# 2018-07-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. Specifically,
+# it tests that ticket [c694113e50321afdf952e2d1235b08ba663f8399]:
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-c694113d5.100 {
+ sqlite3 db :memory:
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY);
+ CREATE TABLE t2(d INTEGER PRIMARY KEY,e,f);
+ INSERT INTO t1(a) VALUES(1),(2),(3),(4);
+ }
+ set answer {}
+ db eval {SELECT a FROM t1 WHERE NOT EXISTS(SELECT 1 FROM t2 WHERE d=a)} {
+ if {$a==3} {
+ lappend answer "CREATE INDEX"
+ db eval {CREATE INDEX t2e ON t2(e);}
+ }
+ lappend answer "a=$a"
+ }
+ set answer
+} {a=1 a=2 {CREATE INDEX} a=3 a=4}
+
+finish_test
diff --git a/test/tkt-cbd054fa6b.test b/test/tkt-cbd054fa6b.test
new file mode 100644
index 0000000..86248ca
--- /dev/null
+++ b/test/tkt-cbd054fa6b.test
@@ -0,0 +1,107 @@
+# 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 !stat4 {
+ finish_test
+ return
+}
+
+proc s {blob} {
+ set ret ""
+ binary scan $blob c* bytes
+ foreach b $bytes {
+ set t [binary format c $b]
+ if {[string is print $t]} {
+ append ret $t
+ } else {
+ append ret .
+ }
+ }
+ return $ret
+}
+db function s s
+
+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; }
+ db eval {
+ PRAGMA writable_schema = 1;
+ CREATE VIEW vvv AS
+ SELECT tbl,idx,neq,nlt,ndlt,test_extract(sample,0) AS sample
+ FROM sqlite_stat4;
+ PRAGMA writable_schema = 0;
+ }
+} {}
+do_test tkt-cbd05-1.3 {
+ execsql {
+ SELECT tbl,idx,group_concat(s(sample),' ')
+ FROM vvv
+ 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(s(sample),' ')
+ FROM vvv
+ 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..ffd3d21
--- /dev/null
+++ b/test/tkt-d11f09d36e.test
@@ -0,0 +1,61 @@
+# 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..da932d1
--- /dev/null
+++ b/test/tkt-d82e3f3721.test
@@ -0,0 +1,85 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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..3c793d4
--- /dev/null
+++ b/test/tkt-f3e5abed55.test
@@ -0,0 +1,116 @@
+# 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-f67b41381a.test b/test/tkt-f67b41381a.test
new file mode 100644
index 0000000..43e5cc7
--- /dev/null
+++ b/test/tkt-f67b41381a.test
@@ -0,0 +1,58 @@
+# 2014 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.
+#
+#***********************************************************************
+# Test that ticket f67b41381a has been resolved.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tkt-f67b41381a
+
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ ALTER TABLE t1 ADD COLUMN b DEFAULT 2;
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 SELECT * FROM t1;
+ SELECT * FROM t2;
+} {1 2}
+
+db cache size 0
+foreach {tn tbls xfer} {
+ 1 { CREATE TABLE t1(a, b); CREATE TABLE t2(a, b) } 1
+ 2 { CREATE TABLE t1(a, b DEFAULT 'x'); CREATE TABLE t2(a, b) } 0
+ 3 { CREATE TABLE t1(a, b DEFAULT 'x'); CREATE TABLE t2(a, b DEFAULT 'x') } 1
+ 4 { CREATE TABLE t1(a, b DEFAULT NULL); CREATE TABLE t2(a, b) } 0
+ 5 { CREATE TABLE t1(a DEFAULT 2, b); CREATE TABLE t2(a DEFAULT 1, b) } 1
+ 6 { CREATE TABLE t1(a DEFAULT 1, b); CREATE TABLE t2(a DEFAULT 1, b) } 1
+ 7 { CREATE TABLE t1(a DEFAULT 1, b DEFAULT 1);
+ CREATE TABLE t2(a DEFAULT 3, b DEFAULT 1) } 1
+ 8 { CREATE TABLE t1(a DEFAULT 1, b DEFAULT 1);
+ CREATE TABLE t2(a DEFAULT 3, b DEFAULT 3) } 0
+
+} {
+
+ execsql { DROP TABLE t1; DROP TABLE t2 }
+ execsql $tbls
+
+ set res 1
+ db eval { EXPLAIN INSERT INTO t1 SELECT * FROM t2 } {
+ if {$opcode == "Column"} { set res 0 }
+ }
+
+ do_test 2.$tn [list set res] $xfer
+}
+
+finish_test
diff --git a/test/tkt-f777251dc7a.test b/test/tkt-f777251dc7a.test
new file mode 100644
index 0000000..b91e438
--- /dev/null
+++ b/test/tkt-f777251dc7a.test
@@ -0,0 +1,105 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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;
+ CREATE TABLE xyzzy(abc);
+ SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2;
+ }
+} {1 {abort due to ROLLBACK}}
+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 {abort due to ROLLBACK}}
+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..d21da31
--- /dev/null
+++ b/test/tkt-f7b4edec.test
@@ -0,0 +1,75 @@
+# 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
+ifcapable !shared_cache { finish_test ; return }
+
+# 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..4543090
--- /dev/null
+++ b/test/tkt-f973c7ac31.test
@@ -0,0 +1,86 @@
+# 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/tkt-fc7bd6358f.test b/test/tkt-fc7bd6358f.test
new file mode 100644
index 0000000..a1b13c4
--- /dev/null
+++ b/test/tkt-fc7bd6358f.test
@@ -0,0 +1,78 @@
+# 2013 March 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. Specifically,
+# it tests that ticket [fc7bd6358f]:
+#
+# The following SQL yields an incorrect result (zero rows) in all
+# versions of SQLite between 3.6.14 and 3.7.15.2:
+#
+# CREATE TABLE t(textid TEXT);
+# INSERT INTO t VALUES('12');
+# INSERT INTO t VALUES('34');
+# CREATE TABLE i(intid INTEGER PRIMARY KEY);
+# INSERT INTO i VALUES(12);
+# INSERT INTO i VALUES(34);
+#
+# SELECT t1.textid AS a, i.intid AS b, t2.textid AS c
+# FROM t t1, i, t t2
+# WHERE t1.textid = i.intid
+# AND t1.textid = t2.textid;
+#
+# The correct result should be two rows, one with 12|12|12 and the other
+# with 34|34|34. With this bug, no rows are returned. Bisecting shows that
+# this bug was introduced with check-in [dd4d67a67454] on 2009-04-23.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt-fc7bd6358f.100 {
+ db eval {
+ CREATE TABLE t(textid TEXT);
+ INSERT INTO t VALUES('12');
+ INSERT INTO t VALUES('34');
+ CREATE TABLE i(intid INTEGER PRIMARY KEY);
+ INSERT INTO i VALUES(12);
+ INSERT INTO i VALUES(34);
+ }
+} {}
+unset -nocomplain from
+unset -nocomplain where
+unset -nocomplain a
+unset -nocomplain b
+foreach {a from} {
+ 1 {FROM t t1, i, t t2}
+ 2 {FROM i, t t1, t t2}
+ 3 {FROM t t1, t t2, i}
+} {
+ foreach {b where} {
+ 1 {WHERE t1.textid=i.intid AND t1.textid=t2.textid}
+ 2 {WHERE i.intid=t1.textid AND t1.textid=t2.textid}
+ 3 {WHERE t1.textid=i.intid AND i.intid=t2.textid}
+ 4 {WHERE t1.textid=i.intid AND t2.textid=i.intid}
+ 5 {WHERE i.intid=t1.textid AND i.intid=t2.textid}
+ 6 {WHERE i.intid=t1.textid AND t2.textid=i.intid}
+ 7 {WHERE t1.textid=t2.textid AND i.intid=t2.textid}
+ 8 {WHERE t1.textid=t2.textid AND t2.textid=i.intid}
+ } {
+ do_test tkt-fc7bd6358f.110.$a.$b.1 {
+ db eval {PRAGMA automatic_index=ON}
+ db eval "SELECT t1.textid, i.intid, t2.textid $from $where"
+ } {12 12 12 34 34 34}
+ do_test tkt-fc7bd6358f.110.$a.$b.2 {
+ db eval {PRAGMA automatic_index=OFF}
+ db eval "SELECT t1.textid, i.intid, t2.textid $from $where"
+ } {12 12 12 34 34 34}
+ }
+}
+
+
+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..cb1a6be
--- /dev/null
+++ b/test/tkt1567.test
@@ -0,0 +1,82 @@
+# 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 {UNIQUE constraint failed: t1.a}}
+do_test tkt1567-1.5 {
+ execsql {
+ COMMIT;
+ }
+} {}
+integrity_check tkt1567-1.6
+
+do_test tkt1567-2.1 {
+ execsql {
+ CREATE TABLE t2(a TEXT PRIMARY KEY, rowid INT) WITHOUT rowid;
+ }
+ set bigstr abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
+ for {set i 0} {$i<100} {incr i} {
+ set x [format %5d [expr $i*2]]
+ set sql "INSERT INTO t2 VALUES('$x-$bigstr', $i+1)"
+ execsql $sql
+ }
+} {}
+integrity_check tkt1567-2.2
+
+do_test tkt1567-2.3 {
+ execsql {
+ BEGIN;
+ UPDATE t2 SET a = a||'x' WHERE rowid%2==0;
+ }
+} {}
+do_test tkt1567-2.4 {
+ catchsql {
+ UPDATE t2 SET a = CASE WHEN rowid<90 THEN substr(a,1,10) ELSE '9999' END;
+ }
+} {1 {UNIQUE constraint failed: t2.a}}
+do_test tkt1567-2.5 {
+ execsql {
+ COMMIT;
+ }
+} {}
+integrity_check tkt1567-2.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..936f57c
--- /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" occurred 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" occurred 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..d0b1633
--- /dev/null
+++ b/test/tkt2822.test
@@ -0,0 +1,346 @@
+# 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.1 {
+ 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.2.2 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 26;
+ }
+} {1 {2nd ORDER BY term out of range - should be between 1 and 25}}
+do_test tkt2822-7.2.3 {
+ catchsql {
+ SELECT * FROM t7 ORDER BY 1, 65536;
+ }
+} {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..e5ef2da
--- /dev/null
+++ b/test/tkt2854.test
@@ -0,0 +1,139 @@
+# 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
+ sqlite3 db3 "file:test.db?cache=private" -uri 1
+
+ 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..717a29c
--- /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 {
+ sqlite3_db_config db LEGACY_FILE_FORMAT 0
+ 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 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..3527932
--- /dev/null
+++ b/test/tkt3334.test
@@ -0,0 +1,86 @@
+# 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}
+
+finish_test
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..aaf2662
--- /dev/null
+++ b/test/tkt3442.test
@@ -0,0 +1,62 @@
+# 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);
+ }
+} {}
+
+# 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.
+#
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+do_eqp_test tkt3442-1.2 {
+ SELECT node FROM listhash WHERE id='5000' LIMIT 1;
+} {SEARCH listhash USING INDEX ididx (id=?)}
+do_eqp_test tkt3442-1.3 {
+ SELECT node FROM listhash WHERE id="5000" LIMIT 1;
+} {SEARCH listhash USING INDEX ididx (id=?)}
+
+
+# Some extra tests testing other permutations of 5000.
+#
+do_eqp_test tkt3442-1.4 {
+ SELECT node FROM listhash WHERE id=5000 LIMIT 1;
+} {SEARCH listhash USING INDEX ididx (id=?)}
+
+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..24b4f0e
--- /dev/null
+++ b/test/tkt3457.test
@@ -0,0 +1,105 @@
+# 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
+}
+if {[atomic_batch_write test.db]} {
+ 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
+} {}
+
+# Disable fchmod to make sure SQLite itself does not try to change the
+# permission bits on us
+#
+catch {
+ test_syscall install fchmod
+ test_syscall fault 1 1
+}
+
+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}}
+
+# Reenable fchmod
+catch {
+ test_syscall uninstall
+ test_syscall fault 0 0
+}
+
+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..da3d05a
--- /dev/null
+++ b/test/tkt3527.test
@@ -0,0 +1,123 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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,'a','b','c');
+ INSERT INTO ElemAnd VALUES(1,2,'x','y','z');
+
+ 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 x y z 0 0 1 1 Elem1 3 a b c 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 x y z 0 0 1 1 Elem1 3 a b c 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..3b911c1
--- /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 {UNIQUE constraint failed: t3.a}}
+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..1fe7ce7
--- /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 temp.sqlite_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 temp.sqlite_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..424b1e6
--- /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 if a pointer-map page is eliminated
+# it 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..3f5a1a3
--- /dev/null
+++ b/test/tkt3773.test
@@ -0,0 +1,43 @@
+# 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
+
+ifcapable !compound {
+ finish_test
+ return
+}
+
+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..07e47eb
--- /dev/null
+++ b/test/tkt3793.test
@@ -0,0 +1,112 @@
+# 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.
+#
+
+
+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 {
+ db close
+ sqlite3 db "file:test.db" -uri 1
+ sqlite3 db1 "file:test.db?cache=private" -uri 1
+ sqlite3 db2 "file:test.db?cache=shared" -uri 1
+ 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..e0798aa
--- /dev/null
+++ b/test/tkt3810.test
@@ -0,0 +1,103 @@
+# 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 temp.sqlite_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
+
+# 2020-11-06 forum post https://sqlite.org/forum/forumpost/157dc791df
+#
+reset_db
+do_test tkt3810-100 {
+ db eval {
+ ATTACH ':memory:' AS aux1;
+ CREATE TABLE aux1.t1(x);
+ CREATE TEMP TRIGGER r1 DELETE ON t1 BEGIN SELECT *; END;
+ CREATE VIEW t1 AS SELECT *;
+ }
+ catch {db eval {
+ CREATE VIRTUAL TABLE t2 USING nosuchmodule;
+ }}
+ db eval {CREATE TABLE t3(z);}
+} {}
+
+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..fa937ac
--- /dev/null
+++ b/test/tkt3838.test
@@ -0,0 +1,58 @@
+# 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}
+
+ifcapable trigger {
+ do_test tkt3838-1.2 {
+ db eval {
+ CREATE TABLE log(y);
+ CREATE TRIGGER r1 AFTER INSERT ON T1 BEGIN
+ INSERT INTO log VALUES(new.x);
+ END;
+ INSERT INTO t1(x) VALUES(123);
+ ALTER TABLE T1 RENAME TO XYZ2;
+ INSERT INTO xyz2(x) VALUES(456);
+ ALTER TABLE xyz2 RENAME TO pqr3;
+ INSERT INTO pqr3(x) VALUES(789);
+ SELECT * FROM log;
+ }
+ } {123 456 789}
+}
+
+finish_test
diff --git a/test/tkt3841.test b/test/tkt3841.test
new file mode 100644
index 0000000..542c1bb
--- /dev/null
+++ b/test/tkt3841.test
@@ -0,0 +1,49 @@
+# 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
+}
+
+sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+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..d587910
--- /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, a, b FROM 't1' WHERE a = ?} 1 \
+ xFilter {SELECT rowid, a, b 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, a, b FROM 't1' WHERE a = ?} 1 \
+ xFilter {SELECT rowid, a, b FROM 't1' WHERE a = ?} 2 \
+ xFilter {SELECT rowid, a, b 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..e20ee15
--- /dev/null
+++ b/test/tkt3918.test
@@ -0,0 +1,59 @@
+# 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..db02bb8
--- /dev/null
+++ b/test/tkt3929.test
@@ -0,0 +1,52 @@
+# 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..a4f1f61
--- /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 {near "USING": syntax error}}
+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 {near "USING": syntax error}}
+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 {near "USING": syntax error}}
+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..77582a5
--- /dev/null
+++ b/test/tkt4018.test
@@ -0,0 +1,90 @@
+# 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
+do_not_use_codec
+
+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/tpch01.test b/test/tpch01.test
new file mode 100644
index 0000000..338ac48
--- /dev/null
+++ b/test/tpch01.test
@@ -0,0 +1,200 @@
+# 2013-09-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.
+#
+#***********************************************************************
+#
+# TPC-H test queries.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix tpch01
+
+do_execsql_test tpch01-1.0 {
+ CREATE TABLE NATION ( N_NATIONKEY INTEGER NOT NULL,
+ N_NAME CHAR(25) NOT NULL,
+ N_REGIONKEY INTEGER NOT NULL,
+ N_COMMENT VARCHAR(152));
+ CREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL,
+ R_NAME CHAR(25) NOT NULL,
+ R_COMMENT VARCHAR(152));
+ CREATE TABLE PART ( P_PARTKEY INTEGER NOT NULL,
+ P_NAME VARCHAR(55) NOT NULL,
+ P_MFGR CHAR(25) NOT NULL,
+ P_BRAND CHAR(10) NOT NULL,
+ P_TYPE VARCHAR(25) NOT NULL,
+ P_SIZE INTEGER NOT NULL,
+ P_CONTAINER CHAR(10) NOT NULL,
+ P_RETAILPRICE DECIMAL(15,2) NOT NULL,
+ P_COMMENT VARCHAR(23) NOT NULL );
+ CREATE TABLE SUPPLIER ( S_SUPPKEY INTEGER NOT NULL,
+ S_NAME CHAR(25) NOT NULL,
+ S_ADDRESS VARCHAR(40) NOT NULL,
+ S_NATIONKEY INTEGER NOT NULL,
+ S_PHONE CHAR(15) NOT NULL,
+ S_ACCTBAL DECIMAL(15,2) NOT NULL,
+ S_COMMENT VARCHAR(101) NOT NULL);
+ CREATE TABLE PARTSUPP ( PS_PARTKEY INTEGER NOT NULL,
+ PS_SUPPKEY INTEGER NOT NULL,
+ PS_AVAILQTY INTEGER NOT NULL,
+ PS_SUPPLYCOST DECIMAL(15,2) NOT NULL,
+ PS_COMMENT VARCHAR(199) NOT NULL );
+ CREATE TABLE CUSTOMER ( C_CUSTKEY INTEGER NOT NULL,
+ C_NAME VARCHAR(25) NOT NULL,
+ C_ADDRESS VARCHAR(40) NOT NULL,
+ C_NATIONKEY INTEGER NOT NULL,
+ C_PHONE CHAR(15) NOT NULL,
+ C_ACCTBAL DECIMAL(15,2) NOT NULL,
+ C_MKTSEGMENT CHAR(10) NOT NULL,
+ C_COMMENT VARCHAR(117) NOT NULL);
+ CREATE TABLE ORDERS ( O_ORDERKEY INTEGER NOT NULL,
+ O_CUSTKEY INTEGER NOT NULL,
+ O_ORDERSTATUS CHAR(1) NOT NULL,
+ O_TOTALPRICE DECIMAL(15,2) NOT NULL,
+ O_ORDERDATE DATE NOT NULL,
+ O_ORDERPRIORITY CHAR(15) NOT NULL,
+ O_CLERK CHAR(15) NOT NULL,
+ O_SHIPPRIORITY INTEGER NOT NULL,
+ O_COMMENT VARCHAR(79) NOT NULL);
+ CREATE TABLE LINEITEM ( L_ORDERKEY INTEGER NOT NULL,
+ L_PARTKEY INTEGER NOT NULL,
+ L_SUPPKEY INTEGER NOT NULL,
+ L_LINENUMBER INTEGER NOT NULL,
+ L_QUANTITY DECIMAL(15,2) NOT NULL,
+ L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,
+ L_DISCOUNT DECIMAL(15,2) NOT NULL,
+ L_TAX DECIMAL(15,2) NOT NULL,
+ L_RETURNFLAG CHAR(1) NOT NULL,
+ L_LINESTATUS CHAR(1) NOT NULL,
+ L_SHIPDATE DATE NOT NULL,
+ L_COMMITDATE DATE NOT NULL,
+ L_RECEIPTDATE DATE NOT NULL,
+ L_SHIPINSTRUCT CHAR(25) NOT NULL,
+ L_SHIPMODE CHAR(10) NOT NULL,
+ L_COMMENT VARCHAR(44) NOT NULL);
+ CREATE INDEX npki on nation(N_NATIONKEY);
+ CREATE INDEX rpki on region(R_REGIONKEY);
+ CREATE INDEX ppki on part(P_PARTKEY);
+ CREATE INDEX spki on supplier(S_SUPPKEY);
+ CREATE INDEX pspki on partsupp(PS_PARTKEY, PS_SUPPKEY);
+ CREATE INDEX cpki on customer(C_CUSTKEY);
+ CREATE INDEX opki on orders(O_ORDERKEY);
+ CREATE INDEX lpki on lineitem(L_ORDERKEY, L_LINENUMBER);
+ CREATE INDEX nrki on nation(n_regionkey);
+ CREATE INDEX snki on supplier(s_nationkey);
+ CREATE INDEX cnki on customer(c_nationkey);
+ CREATE INDEX ocki on orders(O_CUSTKEY);
+ CREATE INDEX odi on orders(O_ORDERDATE);
+ CREATE INDEX lpki2 on lineitem(L_PARTKEY);
+ CREATE INDEX lski on lineitem(L_SUPPKEY);
+ CREATE INDEX lsdi on lineitem(L_SHIPDATE);
+ CREATE INDEX lcdi on lineitem(L_COMMITDATE);
+ CREATE INDEX lrdi on lineitem(L_RECEIPTDATE);
+ CREATE INDEX bootleg_nni on nation(N_NAME);
+ CREATE INDEX bootleg_psi on part(p_size);
+ CREATE INDEX bootleg_pti on part(p_type);
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1 VALUES('LINEITEM','lrdi','600572 236');
+ INSERT INTO sqlite_stat1 VALUES('LINEITEM','lcdi','600572 244');
+ INSERT INTO sqlite_stat1 VALUES('LINEITEM','lsdi','600572 238');
+ INSERT INTO sqlite_stat1 VALUES('LINEITEM','lski','600572 601');
+ INSERT INTO sqlite_stat1 VALUES('LINEITEM','lpki2','600572 31');
+ INSERT INTO sqlite_stat1 VALUES('LINEITEM','lpki','600572 5 1');
+ INSERT INTO sqlite_stat1 VALUES('ORDERS','odi','150000 63');
+ INSERT INTO sqlite_stat1 VALUES('ORDERS','ocki','150000 15');
+ INSERT INTO sqlite_stat1 VALUES('ORDERS','opki','150000 1');
+ INSERT INTO sqlite_stat1 VALUES('CUSTOMER','cnki','15000 600');
+ INSERT INTO sqlite_stat1 VALUES('CUSTOMER','cpki','15000 1');
+ INSERT INTO sqlite_stat1 VALUES('PARTSUPP','pspki','80000 4 1');
+ INSERT INTO sqlite_stat1 VALUES('SUPPLIER','snki','1000 40');
+ INSERT INTO sqlite_stat1 VALUES('SUPPLIER','spki','1000 1');
+ INSERT INTO sqlite_stat1 VALUES('PART','bootleg_pti','20000 134');
+ INSERT INTO sqlite_stat1 VALUES('PART','bootleg_psi','20000 400');
+ INSERT INTO sqlite_stat1 VALUES('PART','ppki','20000 1');
+ INSERT INTO sqlite_stat1 VALUES('REGION','rpki','5 1');
+ INSERT INTO sqlite_stat1 VALUES('NATION','bootleg_nni','25 1');
+ INSERT INTO sqlite_stat1 VALUES('NATION','nrki','25 5');
+ INSERT INTO sqlite_stat1 VALUES('NATION','npki','25 1');
+ ANALYZE sqlite_master;
+} {}
+
+do_test tpch01-1.1 {
+ unset -nocomplain ::eqpres
+ set ::eqpres [db eval {EXPLAIN QUERY PLAN
+ select
+ o_year,
+ sum(case
+ when nation = 'EGYPT' then volume
+ else 0
+ end) / sum(volume) as mkt_share
+ from
+ (
+ select
+ strftime('%Y', o_orderdate) as o_year,
+ l_extendedprice * (1 - l_discount) as volume,
+ n2.n_name as nation
+ from
+ part,
+ supplier,
+ lineitem,
+ orders,
+ customer,
+ nation n1,
+ nation n2,
+ region
+ where
+ p_partkey = l_partkey
+ and s_suppkey = l_suppkey
+ and l_orderkey = o_orderkey
+ and o_custkey = c_custkey
+ and c_nationkey = n1.n_nationkey
+ and n1.n_regionkey = r_regionkey
+ and r_name = 'MIDDLE EAST'
+ and s_nationkey = n2.n_nationkey
+ and o_orderdate between '1995-01-01' and '1996-12-31'
+ and p_type = 'LARGE PLATED STEEL'
+ ) as all_nations
+ group by
+ o_year
+ order by
+ o_year;}]
+ set ::eqpres
+} {/*SEARCH part USING INDEX bootleg_pti *SEARCH lineitem USING INDEX lpki2*/}
+do_test tpch01-1.1b {
+ set ::eqpres
+} {/.* customer .* n1 .*/}
+do_test tpch01-1.1c {
+ set ::eqpres
+} {/.* supplier .* n2 .*/}
+
+do_eqp_test tpch01-1.2 {
+select
+ c_custkey, c_name, sum(l_extendedprice * (1 - l_discount)) as revenue,
+ c_acctbal, n_name, c_address, c_phone, c_comment
+from
+ customer, orders, lineitem, nation
+where
+ c_custkey = o_custkey and l_orderkey = o_orderkey
+ and o_orderdate >= '1994-08-01' and o_orderdate < date('1994-08-01', '+3 month')
+ and l_returnflag = 'R' and c_nationkey = n_nationkey
+group by
+ c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment
+order by
+ revenue desc;
+} {
+ QUERY PLAN
+ |--SEARCH orders USING INDEX odi (O_ORDERDATE>? AND O_ORDERDATE<?)
+ |--SEARCH customer USING INDEX cpki (C_CUSTKEY=?)
+ |--SEARCH nation USING INDEX npki (N_NATIONKEY=?)
+ |--SEARCH lineitem USING INDEX lpki (L_ORDERKEY=?)
+ |--USE TEMP B-TREE FOR GROUP BY
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+finish_test
diff --git a/test/trace.test b/test/trace.test
new file mode 100644
index 0000000..3791485
--- /dev/null
+++ b/test/trace.test
@@ -0,0 +1,269 @@
+# 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
+} {}
+do_test trace-1.6 {
+ db eval {
+ CREATE TABLE t1b(x TEXT PRIMARY KEY, y);
+ INSERT INTO t1b VALUES('abc','def'),('ghi','jkl'),('mno','pqr');
+ }
+ set ::stmtlist {}
+ set xyzzy a*
+ db trace trace_proc
+ db eval {
+ SELECT y FROM t1b WHERE x GLOB $xyzzy
+ }
+} {def}
+do_test trace-1.7 {
+ set ::stmtlist
+} {{SELECT y FROM t1b WHERE x GLOB 'a*'}}
+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}
+
+# 3.8.11: Profile output even if the statement is not run to completion.
+do_test trace-4.6 {
+ set TRACE_OUT {}
+ db eval {SELECT * FROM t1} {} {if {$a>=1} break}
+ set TRACE_OUT
+} {{SELECT * FROM t1}}
+
+
+# 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} {-- UPDATE t2 SET a=new.a WHERE rowid=new.rowid} {-- TRIGGER r1t2} {-- SELECT 'hello'} {-- TRIGGER r1t1} {-- UPDATE t2 SET a=new.a WHERE rowid=new.rowid} {-- TRIGGER r1t2} {-- SELECT 'hello'} {-- TRIGGER r1t1} {-- UPDATE t2 SET a=new.a WHERE rowid=new.rowid} {-- TRIGGER r1t2} {-- SELECT 'hello'}}
+}
+
+# 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..a3f0aeb
--- /dev/null
+++ b/test/trace2.test
@@ -0,0 +1,155 @@
+# 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');"
+ "-- DELETE FROM 'main'.'x1_segdir' WHERE level = ?"
+ "-- INSERT INTO 'main'.'x1_content' VALUES(?,(?))"
+ "-- REPLACE INTO 'main'.'x1_docsize' VALUES(?,?)"
+ "-- SELECT value FROM 'main'.'x1_stat' WHERE id=?"
+ "-- REPLACE INTO 'main'.'x1_stat' VALUES(?,?)"
+ "-- SELECT (SELECT max(idx) FROM 'main'.'x1_segdir' WHERE level = ?) + 1"
+ "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)"
+ "-- REPLACE INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
+ "-- SELECT level, idx, end_block FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ? ORDER BY level DESC, idx ASC"
+ }
+
+ do_trace_test 2.3 {
+ INSERT INTO x1(x1) VALUES('optimize');
+ } {
+ "INSERT INTO x1(x1) VALUES('optimize');"
+ "-- SELECT ? UNION SELECT level / (1024 * ?) FROM 'main'.'x1_segdir'"
+ "-- 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 ?"
+ "-- REPLACE INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
+ }
+}
+
+finish_test
diff --git a/test/trace3.test b/test/trace3.test
new file mode 100644
index 0000000..e9935ac
--- /dev/null
+++ b/test/trace3.test
@@ -0,0 +1,333 @@
+# 2016 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 test file is the "sqlite3_trace_v2()" and "sqlite3_expanded_sql()"
+# APIs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !trace { finish_test ; return }
+set ::testprefix trace3
+
+proc trace_v2_error { args } {
+ lappend ::stmtlist(error) [string trim $args]
+ error "trace error"; # this will be ignored.
+}
+proc trace_v2_record { args } {
+ lappend ::stmtlist(record) [string trim $args]
+}
+proc trace_v2_nop { args } {}; # do nothing.
+
+do_test trace3-1.0 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,NULL);
+ INSERT INTO t1 VALUES(2,-1);
+ INSERT INTO t1 VALUES(3,0);
+ INSERT INTO t1 VALUES(4,1);
+ INSERT INTO t1 VALUES(5,-2147483648);
+ INSERT INTO t1 VALUES(6,2147483647);
+ INSERT INTO t1 VALUES(7,-9223372036854775808);
+ INSERT INTO t1 VALUES(8,9223372036854775807);
+ INSERT INTO t1 VALUES(9,-1.0);
+ INSERT INTO t1 VALUES(10,0.0);
+ INSERT INTO t1 VALUES(11,1.0);
+ INSERT INTO t1 VALUES(12,'');
+ INSERT INTO t1 VALUES(13,'1');
+ INSERT INTO t1 VALUES(14,'one');
+ INSERT INTO t1 VALUES(15,x'abcd0123');
+ INSERT INTO t1 VALUES(16,x'4567cdef');
+ }
+} {}
+
+do_test trace3-1.1 {
+ set rc [catch {db trace_v2 1 2 3} msg]
+ lappend rc $msg
+} {1 {wrong # args: should be "db trace_v2 ?CALLBACK? ?MASK?"}}
+do_test trace3-1.2 {
+ set rc [catch {db trace_v2 1 bad} msg]
+ lappend rc $msg
+} {1 {bad trace type "bad": must be statement, profile, row, or close}}
+
+do_test trace3-2.1 {
+ db trace_v2 trace_v2_nop
+ db trace_v2
+} {trace_v2_nop}
+
+do_test trace3-3.1 {
+ unset -nocomplain ::stmtlist
+ db trace_v2 trace_v2_nop
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ array get ::stmtlist
+} {}
+do_test trace3-3.2 {
+ set ::stmtlist(error) {}
+ db trace_v2 trace_v2_error
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(error)
+} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
+do_test trace3-3.3 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
+do_test trace3-3.4 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record statement
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
+do_test trace3-3.5 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record 1
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
+
+do_test trace3-4.1 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record profile
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ -?\d+\}$/}
+do_test trace3-4.2 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record 2
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ -?\d+\}$/}
+
+do_test trace3-4.3 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record profile
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set stmt [lindex [lindex $::stmtlist(record) 0] 0]
+ set ns [lindex [lindex $::stmtlist(record) 0] 1]
+ list $stmt [expr {$ns >= 0 && $ns <= 9999999}]; # less than 0.010 seconds
+} {/^-?\d+ 1$/}
+do_test trace3-4.4 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record 2
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set stmt [lindex [lindex $::stmtlist(record) 0] 0]
+ set ns [lindex [lindex $::stmtlist(record) 0] 1]
+ list $stmt [expr {$ns >= 0 && $ns <= 9999999}]; # less than 0.010 seconds
+} {/^-?\d+ 1$/}
+
+do_test trace3-5.1 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record row
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} "/^[string trim [string repeat {-?\d+ } 16]]\$/"
+do_test trace3-5.2 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record 4
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} "/^[string trim [string repeat {-?\d+ } 16]]\$/"
+
+do_test trace3-6.1 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record {profile row}
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} "/^[string trim [string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/"
+do_test trace3-6.2 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record {statement profile row}
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} "/^\\\{-?\\d+ \\\{SELECT a, b FROM t1 ORDER BY a;\\\}\\\} [string trim \
+[string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/"
+
+do_test trace3-7.1 {
+ set DB [sqlite3_connection_pointer db]
+
+ set STMT [sqlite3_prepare_v2 $DB \
+ "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 TAIL]
+} {/^[0-9A-Fa-f]+$/}
+
+do_test trace3-8.1 {
+ list [sqlite3_bind_null $STMT 1] [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = NULL ORDER BY a;}}
+do_test trace3-8.2 {
+ list [sqlite3_bind_int $STMT 1 123] [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}}
+do_test trace3-8.3 {
+ list [sqlite3_bind_int64 $STMT 1 123] [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}}
+do_test trace3-8.4 {
+ list [sqlite3_bind_text $STMT 1 "some string" 11] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 'some string' ORDER BY a;}}
+do_test trace3-8.5 {
+ list [sqlite3_bind_text $STMT 1 "some 'bad' string" 17] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 'some ''bad'' string' ORDER BY a;}}
+do_test trace3-8.6 {
+ list [sqlite3_bind_double $STMT 1 123] [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 123.0 ORDER BY a;}}
+do_test trace3-8.7 {
+ list [sqlite3_bind_text16 $STMT 1 \
+ [encoding convertto unicode hi\000yall\000] 16] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 'hi' ORDER BY a;}}
+do_test trace3-8.8 {
+ list [sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}}
+do_test trace3-8.9 {
+ list [sqlite3_bind_blob $STMT 1 "\xAB\xCD\xEF" 3] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = x'abcdef' ORDER BY a;}}
+
+do_test trace3-9.1 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test trace3-10.1 {
+ db trace_v2 ""
+ db trace_v2
+} {}
+do_test trace3-10.2 {
+ unset -nocomplain ::stmtlist
+ db trace_v2 "" {statement profile row}
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ array get ::stmtlist
+} {}
+
+do_test trace3-11.1 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record close
+ db close
+ set ::stmtlist(record)
+} {/^-?\d+$/}
+
+reset_db
+
+do_test trace3-11.2 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record 8
+ db close
+ set ::stmtlist(record)
+} {/^-?\d+$/}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 12.1.0 {
+ set ::STMT [sqlite3_prepare_v2 $DB \
+ "SELECT ?1 || ?1 || ?1 || ?2 || ?3 || ?4 || ? || ?1 || ?" -1 TAIL
+ ]
+ sqlite3_bind_parameter_count $::STMT
+} {6}
+
+do_test 12.1.1 {
+ sqlite3_bind_text $STMT 1 "A" 1
+ sqlite3_bind_text $STMT 2 "B" 1
+ sqlite3_bind_text $STMT 3 "C" 1
+ sqlite3_bind_text $STMT 4 "D" 1
+ sqlite3_bind_text $STMT 5 "E" 1
+ sqlite3_bind_text $STMT 6 "F" 1
+ sqlite3_expanded_sql $STMT
+} {SELECT 'A' || 'A' || 'A' || 'B' || 'C' || 'D' || 'E' || 'A' || 'F'}
+
+do_test 12.1.2 {
+ sqlite3_step $STMT
+ sqlite3_column_text $STMT 0
+} {AAABCDEAF}
+
+do_test 12.1.3 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test 12.2.0 {
+ execsql {
+ CREATE TABLE nameFtsFuzzySearchTable(
+ word, distance, langid, score, top, scope
+ );
+ }
+ set ::STMT [sqlite3_prepare_v2 $DB {
+ SELECT
+ substr(word,1,length(?1)-1) AS term,
+ distance,
+ langid,
+ score
+ FROM
+ nameFtsFuzzySearchTable
+ WHERE
+ word MATCH (?1) AND abs(?1) = abs(term)
+ AND top = ?2 AND distance > ?3 AND scope = ?4 AND langid = ?
+ GROUP BY term, langid
+ HAVING (1.0 - ((distance / 100.0) / CAST( length(?1) - 1 AS REAL ))) >= ?
+ } -1 TAIL]
+ sqlite3_bind_parameter_count $::STMT
+} {6}
+
+do_test 12.1.1 {
+ sqlite3_bind_text $STMT 1 "A" 1
+ sqlite3_bind_text $STMT 2 "B" 1
+ sqlite3_bind_text $STMT 3 "C" 1
+ sqlite3_bind_text $STMT 4 "D" 1
+ sqlite3_bind_text $STMT 5 "E" 1
+ sqlite3_bind_text $STMT 6 "F" 1
+ sqlite3_expanded_sql $STMT
+} {
+ SELECT
+ substr(word,1,length('A')-1) AS term,
+ distance,
+ langid,
+ score
+ FROM
+ nameFtsFuzzySearchTable
+ WHERE
+ word MATCH ('A') AND abs('A') = abs(term)
+ AND top = 'B' AND distance > 'C' AND scope = 'D' AND langid = 'E'
+ GROUP BY term, langid
+ HAVING (1.0 - ((distance / 100.0) / CAST( length('A') - 1 AS REAL ))) >= 'F'
+ }
+
+do_test 12.1.2 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+
+finish_test
diff --git a/test/trans.test b/test/trans.test
new file mode 100644
index 0000000..6b8ad21
--- /dev/null
+++ b/test/trans.test
@@ -0,0 +1,994 @@
+# 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.
+#
+
+
+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.2.1 {
+ sqlite3_txn_state db
+} {0}
+do_test trans-1.2.2 {
+ sqlite3_txn_state db main
+} {0}
+do_test trans-1.2.3 {
+ sqlite3_txn_state db temp
+} {0}
+do_test trans-1.2.4 {
+ sqlite3_txn_state db no-such-schema
+} {-1}
+
+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.1b {
+ sqlite3_txn_state db
+} {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.1b {
+ sqlite3_txn_state db
+} {2}
+do_test trans-3.1c {
+ sqlite3_txn_state db main
+} {2}
+do_test trans-3.1d {
+ sqlite3_txn_state db temp
+} {0}
+
+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.10b {
+ sqlite3_txn_state db
+} {0}
+
+
+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.2b {
+ sqlite3_txn_state db
+} {1}
+do_test trans-5.2c {
+ sqlite3_txn_state db main
+} {1}
+do_test trans-5.2d {
+ sqlite3_txn_state db temp
+} {0}
+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..36a2f99
--- /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 {NOT NULL constraint failed: t1.z}}
+ 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 {NOT NULL constraint failed: t1.z}}
+ 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..e828442
--- /dev/null
+++ b/test/trans3.test
@@ -0,0 +1,76 @@
+# 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; CREATE TABLE xyzzy(abc);}
+ 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 {abort due to ROLLBACK}}
+do_test trans3-1.6 {
+ set ::ecode
+} {}
+do_test trans3-1.7 {
+ db eval {SELECT * FROM t1}
+} {1 2 3 4}
+unset -nocomplain ecode
+
+finish_test
diff --git a/test/transitive1.test b/test/transitive1.test
new file mode 100644
index 0000000..80c53e8
--- /dev/null
+++ b/test/transitive1.test
@@ -0,0 +1,429 @@
+# 2013 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 script is testing of transitive WHERE clause constraints
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test transitive1-100 {
+ CREATE TABLE t1(a TEXT, b TEXT, c TEXT COLLATE NOCASE);
+ INSERT INTO t1 VALUES('abc','abc','Abc');
+ INSERT INTO t1 VALUES('def','def','def');
+ INSERT INTO t1 VALUES('ghi','ghi','GHI');
+ CREATE INDEX t1a1 ON t1(a);
+ CREATE INDEX t1a2 ON t1(a COLLATE nocase);
+
+ SELECT * FROM t1 WHERE a=b AND c=b AND c='DEF';
+} {def def def}
+do_execsql_test transitive1-110 {
+ SELECT * FROM t1 WHERE a=b AND c=b AND c>='DEF' ORDER BY +a;
+} {def def def ghi ghi GHI}
+do_execsql_test transitive1-120 {
+ SELECT * FROM t1 WHERE a=b AND c=b AND c<='DEF' ORDER BY +a;
+} {abc abc Abc def def def}
+
+do_execsql_test transitive1-200 {
+ CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);
+ INSERT INTO t2 VALUES(100,100,100);
+ INSERT INTO t2 VALUES(20,20,20);
+ INSERT INTO t2 VALUES(3,3,3);
+
+ SELECT * FROM t2 WHERE a=b AND c=b AND c=20;
+} {20 20 20}
+do_execsql_test transitive1-210 {
+ SELECT * FROM t2 WHERE a=b AND c=b AND c>=20 ORDER BY +a;
+} {3 3 3 20 20 20}
+do_execsql_test transitive1-220 {
+ SELECT * FROM t2 WHERE a=b AND c=b AND c<=20 ORDER BY +a;
+} {20 20 20 100 100 100}
+
+# Test cases for ticket [[d805526eae253103] 2013-07-08
+# "Incorrect join result or assertion fault due to transitive constraints"
+#
+do_execsql_test transitive1-300 {
+ CREATE TABLE t301(w INTEGER PRIMARY KEY, x);
+ CREATE TABLE t302(y INTEGER UNIQUE, z);
+ INSERT INTO t301 VALUES(1,2),(3,4),(5,6);
+ INSERT INTO t302 VALUES(1,3),(3,6),(5,7);
+ SELECT *
+ FROM t301 CROSS JOIN t302
+ WHERE w=y AND y IS NOT NULL
+ ORDER BY +w;
+} {1 2 1 3 3 4 3 6 5 6 5 7}
+do_execsql_test transitive1-301 {
+ SELECT *
+ FROM t301 CROSS JOIN t302
+ WHERE w=y AND y IS NOT NULL
+ ORDER BY w;
+} {1 2 1 3 3 4 3 6 5 6 5 7}
+do_execsql_test transitive1-302 {
+ SELECT *
+ FROM t301 CROSS JOIN t302
+ WHERE w IS y AND y IS NOT NULL
+ ORDER BY w;
+} {1 2 1 3 3 4 3 6 5 6 5 7}
+do_execsql_test transitive1-310 {
+ SELECT *
+ FROM t301 CROSS JOIN t302 ON w=y
+ WHERE y>1
+ ORDER BY +w
+} {3 4 3 6 5 6 5 7}
+do_execsql_test transitive1-311 {
+ SELECT *
+ FROM t301 CROSS JOIN t302 ON w=y
+ WHERE y>1
+ ORDER BY w
+} {3 4 3 6 5 6 5 7}
+do_execsql_test transitive1-312 {
+ SELECT *
+ FROM t301 CROSS JOIN t302 ON w=y
+ WHERE y>1
+ ORDER BY w DESC
+} {5 6 5 7 3 4 3 6}
+do_execsql_test transitive1-320 {
+ SELECT *
+ FROM t301 CROSS JOIN t302 ON w=y
+ WHERE y BETWEEN 2 AND 4;
+} {3 4 3 6}
+do_execsql_test transitive1-331 {
+ SELECT *
+ FROM t301 CROSS JOIN t302 ON w=y
+ WHERE y BETWEEN 1 AND 4
+ ORDER BY w;
+} {1 2 1 3 3 4 3 6}
+do_execsql_test transitive1-332 {
+ SELECT *
+ FROM t301 CROSS JOIN t302 ON w=y
+ WHERE y BETWEEN 1 AND 4
+ ORDER BY w DESC;
+} {3 4 3 6 1 2 1 3}
+
+# Ticket [c620261b5b5dc] circa 2013-10-28.
+# Make sure constraints are not used with LEFT JOINs.
+#
+# The next case is from the ticket report. It outputs no rows in 3.8.1
+# prior to the bug-fix.
+#
+do_execsql_test transitive1-400 {
+ CREATE TABLE t401(a);
+ CREATE TABLE t402(b);
+ CREATE TABLE t403(c INTEGER PRIMARY KEY);
+ INSERT INTO t401 VALUES(1);
+ INSERT INTO t403 VALUES(1);
+ SELECT '1-row' FROM t401 LEFT JOIN t402 ON b=a JOIN t403 ON c=a;
+} {1-row}
+do_execsql_test transitive1-401 {
+ SELECT '1-row' FROM t401 LEFT JOIN t402 ON b IS a JOIN t403 ON c=a;
+} {1-row}
+do_execsql_test transitive1-402 {
+ SELECT '1-row' FROM t401 LEFT JOIN t402 ON b=a JOIN t403 ON c IS a;
+} {1-row}
+do_execsql_test transitive1-403 {
+ SELECT '1-row' FROM t401 LEFT JOIN t402 ON b IS a JOIN t403 ON c IS a;
+} {1-row}
+
+
+# The following is a script distilled from the XBMC project where the
+# bug was originally encountered. The correct answer is a single row
+# of output. Before the bug was fixed, zero rows were generated.
+#
+do_execsql_test transitive1-410 {
+ CREATE TABLE bookmark ( idBookmark integer primary key, idFile integer, timeInSeconds double, totalTimeInSeconds double, thumbNailImage text, player text, playerState text, type integer);
+ CREATE TABLE path ( idPath integer primary key, strPath text, strContent text, strScraper text, strHash text, scanRecursive integer, useFolderNames bool, strSettings text, noUpdate bool, exclude bool, dateAdded text);
+ INSERT INTO "path" VALUES(1,'/tmp/tvshows/','tvshows','metadata.tvdb.com','989B1CE5680A14F5F86123F751169B49',0,0,'<settings><setting id="absolutenumber" value="false" /><setting id="dvdorder" value="false" /><setting id="fanart" value="true" /><setting id="language" value="en" /></settings>',0,0,NULL);
+ INSERT INTO "path" VALUES(2,'/tmp/tvshows/The.Big.Bang.Theory/','','','85E1DAAB2F5FF6EAE8AEDF1B5C882D1E',NULL,NULL,NULL,NULL,NULL,'2013-10-23 18:58:43');
+ CREATE TABLE files ( idFile integer primary key, idPath integer, strFilename text, playCount integer, lastPlayed text, dateAdded text);
+ INSERT INTO "files" VALUES(1,2,'The.Big.Bang.Theory.S01E01.WEB-DL.AAC2.0.H264.mkv',NULL,NULL,'2013-10-23 18:57:36');
+ CREATE TABLE tvshow ( idShow integer primary key,c00 text,c01 text,c02 text,c03 text,c04 text,c05 text,c06 text,c07 text,c08 text,c09 text,c10 text,c11 text,c12 text,c13 text,c14 text,c15 text,c16 text,c17 text,c18 text,c19 text,c20 text,c21 text,c22 text,c23 text);
+ INSERT INTO "tvshow" VALUES(1,'The Big Bang Theory','Leonard Hofstadter and Sheldon Cooper are brilliant physicists, the kind of "beautiful minds" that understand how the universe works. But none of that genius helps them interact with people, especially women. All this begins to change when a free-spirited beauty named Penny moves in next door. Sheldon, Leonard''s roommate, is quite content spending his nights playing Klingon Boggle with their socially dysfunctional friends, fellow CalTech scientists Howard Wolowitz and Raj Koothrappali. However, Leonard sees in Penny a whole new universe of possibilities... including love.','','','9.200000','2007-09-24','<thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g13.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g23.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g18.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g17.jpg</thumb><thumb aspect="banner">http://
+ thetvdb.com/banners/graphical/80379-g6.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g5.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g2.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g11.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g12.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g19.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g3.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g4.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g15.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g22.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g7.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g10.jpg</thumb><thumb
+ aspect="banner">http://thetvdb.com/banners/graphical/80379-g24.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g8.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g9.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g14.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g16.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g21.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/text/80379-4.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/text/80379-2.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/text/80379-3.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/text/80379-5.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-8.jpg</thumb><thumb aspect="poster" type="season" season="0">http://thetvdb.com/banners/seasons/80379-0-4.jpg</thumb><thumb aspect="poster" type="season"
+ season="1">http://thetvdb.com/banners/seasons/80379-1-12.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-9.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-11.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-9.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-8.jpg</thumb><thumb aspect="poster" type="season" season="7">http://thetvdb.com/banners/seasons/80379-7-3.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-4.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-5.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-9.jpg</thumb><thumb aspect="poster" type="season" season="0">http://thetvdb.com/banners/seasons/80379-0-2.jpg</thumb><thumb aspect="
+ poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-6.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-4.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-2.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-9.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-4.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-2.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-7.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-10.jpg</
+ thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-5.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-5.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-4.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-3.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-6.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2.jpg</thumb><thumb aspect="poster" type="season" season="7">http://thetvdb.com/banners/seasons/80379-7.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-
+ 1-7.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-2.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-3.jpg</thumb><thumb aspect="poster" type="season" season="7">http://thetvdb.com/banners/seasons/80379-7-2.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-2.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-5.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-3.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-5.jpg</thumb><thumb aspect="poster" type="season" season="0">http://thetvdb.com/banners/seasons/80379-0.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-5.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/
+ seasons/80379-1-6.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-3.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-8.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-7.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-8.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-7.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-6.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-8.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-11.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-10.jpg</thumb><thumb aspect="poster" type="season" season="1">http://
+ thetvdb.com/banners/seasons/80379-1-8.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-7.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-4.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-3.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-4.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-3.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-7.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-2.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-6.jpg</thumb><thumb aspect="poster" type="season"
+ season="3">http://thetvdb.com/banners/seasons/80379-3-2.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-6.jpg</thumb><thumb aspect="banner" type="season" season="5">http://thetvdb.com/banners/seasonswide/80379-5.jpg</thumb><thumb aspect="banner" type="season" season="3">http://thetvdb.com/banners/seasonswide/80379-3-2.jpg</thumb><thumb aspect="banner" type="season" season="1">http://thetvdb.com/banners/seasonswide/80379-1-2.jpg</thumb><thumb aspect="banner" type="season" season="2">http://thetvdb.com/banners/seasonswide/80379-2-2.jpg</thumb><thumb aspect="banner" type="season" season="4">http://thetvdb.com/banners/seasonswide/80379-4-2.jpg</thumb><thumb aspect="banner" type="season" season="0">http://thetvdb.com/banners/seasonswide/80379-0.jpg</thumb><thumb aspect="banner" type="season" season="0">http://thetvdb.com/banners/seasonswide/80379-0-2.jpg</thumb><thumb aspect="banner" type="season" season="1">http://thetvdb.com/banners/seasonswide/80379-1.jpg</
+ thumb><thumb aspect="banner" type="season" season="2">http://thetvdb.com/banners/seasonswide/80379-2.jpg</thumb><thumb aspect="banner" type="season" season="4">http://thetvdb.com/banners/seasonswide/80379-4.jpg</thumb><thumb aspect="banner" type="season" season="3">http://thetvdb.com/banners/seasonswide/80379-3.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-22.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-18.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-13.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-10.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-16.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-1.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-9.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-2.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-19.jpg</
+ thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-8.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-4.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-20.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-23.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-7.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-3.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-12.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-11.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-15.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-21.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-14.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-17.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-6.jpg</thumb><thumb
+ aspect="poster">http://thetvdb.com/banners/posters/80379-5.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-22.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-18.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-13.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-10.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-16.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-1.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-9.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-2.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-19.jpg</thumb><thumb aspect="
+ poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-8.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-4.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-20.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-23.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-7.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-3.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-12.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-11.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-15.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-21.jpg</
+ thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-14.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-17.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-6.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-5.jpg</thumb>','','Comedy','','<episodeguide><url cache="80379-en.xml">http://thetvdb.com/api/1D62F2F90030C444/series/80379/all/en.zip</url></episodeguide>','<fanart url="http://thetvdb.com/banners/"><thumb dim="1920x1080" colors="|192,185,169|19,20,25|57,70,89|" preview="_cache/fanart/original/80379-2.jpg">fanart/original/80379-2.jpg</thumb><thumb dim="1920x1080" colors="|94,28,16|194,18,38|0,0,8|" preview="_cache/fanart/original/80379-34.jpg">fanart/original/80379-34.jpg</thumb><thumb dim="1280x720" colors="|254,157,210|11,12,7|191,152,111|" preview="_cache/fanart/original/80379-4.jpg">fanart/original/80379-
+ 4.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-42.jpg">fanart/original/80379-42.jpg</thumb><thumb dim="1920x1080" colors="|236,187,155|136,136,128|254,254,252|" preview="_cache/fanart/original/80379-37.jpg">fanart/original/80379-37.jpg</thumb><thumb dim="1920x1080" colors="|112,102,152|116,109,116|235,152,146|" preview="_cache/fanart/original/80379-14.jpg">fanart/original/80379-14.jpg</thumb><thumb dim="1920x1080" colors="|150,158,161|174,75,121|150,98,58|" preview="_cache/fanart/original/80379-16.jpg">fanart/original/80379-16.jpg</thumb><thumb dim="1280x720" colors="|224,200,176|11,1,28|164,96,0|" preview="_cache/fanart/original/80379-1.jpg">fanart/original/80379-1.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-35.jpg">fanart/original/80379-35.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-40.jpg">fanart/original/80379-40.jpg</thumb><thumb dim="1920x1080" colors="|255,255,255|30,19,13|155,112,70|"
+ preview="_cache/fanart/original/80379-31.jpg">fanart/original/80379-31.jpg</thumb><thumb dim="1920x1080" colors="|241,195,172|84,54,106|254,221,206|" preview="_cache/fanart/original/80379-29.jpg">fanart/original/80379-29.jpg</thumb><thumb dim="1280x720" colors="|197,167,175|219,29,39|244,208,192|" preview="_cache/fanart/original/80379-11.jpg">fanart/original/80379-11.jpg</thumb><thumb dim="1280x720" colors="|195,129,97|244,192,168|219,148,118|" preview="_cache/fanart/original/80379-24.jpg">fanart/original/80379-24.jpg</thumb><thumb dim="1920x1080" colors="|14,10,11|255,255,255|175,167,164|" preview="_cache/fanart/original/80379-30.jpg">fanart/original/80379-30.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-19.jpg">fanart/original/80379-19.jpg</thumb><thumb dim="1920x1080" colors="|246,199,69|98,55,38|161,127,82|" preview="_cache/fanart/original/80379-9.jpg">fanart/original/80379-9.jpg</thumb><thumb dim="1280x720" colors="|129,22,14|48,50,39|223,182,64|" preview="_cache/
+ fanart/original/80379-13.jpg">fanart/original/80379-13.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-45.jpg">fanart/original/80379-45.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-33.jpg">fanart/original/80379-33.jpg</thumb><thumb dim="1280x720" colors="|103,77,60|224,180,153|129,100,84|" preview="_cache/fanart/original/80379-10.jpg">fanart/original/80379-10.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-23.jpg">fanart/original/80379-23.jpg</thumb><thumb dim="1280x720" colors="|219,29,39|0,4,10|88,117,135|" preview="_cache/fanart/original/80379-12.jpg">fanart/original/80379-12.jpg</thumb><thumb dim="1920x1080" colors="|226,209,165|51,18,9|89,54,24|" preview="_cache/fanart/original/80379-5.jpg">fanart/original/80379-5.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-26.jpg">fanart/original/80379-26.jpg</thumb><thumb dim="1280x720" colors="|249,251,229|126,47,53|251,226,
+ 107|" preview="_cache/fanart/original/80379-27.jpg">fanart/original/80379-27.jpg</thumb><thumb dim="1920x1080" colors="|233,218,65|30,27,46|173,53,18|" preview="_cache/fanart/original/80379-32.jpg">fanart/original/80379-32.jpg</thumb><thumb dim="1280x720" colors="|248,248,248|64,54,78|188,193,196|" preview="_cache/fanart/original/80379-3.jpg">fanart/original/80379-3.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-25.jpg">fanart/original/80379-25.jpg</thumb><thumb dim="1280x720" colors="|159,150,133|59,39,32|168,147,104|" preview="_cache/fanart/original/80379-7.jpg">fanart/original/80379-7.jpg</thumb><thumb dim="1920x1080" colors="|221,191,157|11,7,6|237,146,102|" preview="_cache/fanart/original/80379-21.jpg">fanart/original/80379-21.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-28.jpg">fanart/original/80379-28.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-36.jpg">fanart/original/80379-36.jpg</thumb><thumb
+ dim="1920x1080" colors="|253,237,186|33,25,22|245,144,38|" preview="_cache/fanart/original/80379-38.jpg">fanart/original/80379-38.jpg</thumb><thumb dim="1920x1080" colors="|174,111,68|243,115,50|252,226,45|" preview="_cache/fanart/original/80379-20.jpg">fanart/original/80379-20.jpg</thumb><thumb dim="1920x1080" colors="|63,56,123|87,59,47|63,56,123|" preview="_cache/fanart/original/80379-17.jpg">fanart/original/80379-17.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-43.jpg">fanart/original/80379-43.jpg</thumb><thumb dim="1280x720" colors="|69,68,161|142,118,142|222,191,137|" preview="_cache/fanart/original/80379-22.jpg">fanart/original/80379-22.jpg</thumb><thumb dim="1280x720" colors="|1,108,206|242,209,192|250,197,163|" preview="_cache/fanart/original/80379-15.jpg">fanart/original/80379-15.jpg</thumb><thumb dim="1280x720" colors="|239,229,237|0,0,0|167,136,115|" preview="_cache/fanart/original/80379-18.jpg">fanart/original/80379-18.jpg</thumb><thumb dim="1280x720" colors=""
+ preview="_cache/fanart/original/80379-6.jpg">fanart/original/80379-6.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-8.jpg">fanart/original/80379-8.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-41.jpg">fanart/original/80379-41.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-44.jpg">fanart/original/80379-44.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-39.jpg">fanart/original/80379-39.jpg</thumb></fanart>','80379','TV-PG','CBS','','/tmp/tvshows/The.Big.Bang.Theory/','1',NULL,NULL,NULL,NULL,NULL,NULL);
+ CREATE TABLE episode ( idEpisode integer primary key, idFile integer,c00 text,c01 text,c02 text,c03 text,c04 text,c05 text,c06 text,c07 text,c08 text,c09 text,c10 text,c11 text,c12 varchar(24),c13 varchar(24),c14 text,c15 text,c16 text,c17 varchar(24),c18 text,c19 text,c20 text,c21 text,c22 text,c23 text, idShow integer);
+ INSERT INTO "episode" VALUES(1,1,'Pilot','Brilliant physicist roommates Leonard and Sheldon meet their new neighbor Penny, who begins showing them that as much as they know about science, they know little about actual living.','','7.700000','Chuck Lorre / Bill Prady','2007-09-24','<thumb>http://thetvdb.com/banners/episodes/80379/332484.jpg</thumb>','',NULL,'1800','James Burrows','','1','1','','-1','-1','-1','/tmp/tvshows/The.Big.Bang.Theory/The.Big.Bang.Theory.S01E01.WEB-DL.AAC2.0.H264.mkv','2','332484',NULL,NULL,NULL,1);
+ CREATE TABLE tvshowlinkpath (idShow integer, idPath integer);
+ INSERT INTO "tvshowlinkpath" VALUES(1,2);
+ CREATE TABLE seasons ( idSeason integer primary key, idShow integer, season integer);
+ INSERT INTO "seasons" VALUES(1,1,-1);
+ INSERT INTO "seasons" VALUES(2,1,0);
+ INSERT INTO "seasons" VALUES(3,1,1);
+ INSERT INTO "seasons" VALUES(4,1,2);
+ INSERT INTO "seasons" VALUES(5,1,3);
+ INSERT INTO "seasons" VALUES(6,1,4);
+ INSERT INTO "seasons" VALUES(7,1,5);
+ INSERT INTO "seasons" VALUES(8,1,6);
+ INSERT INTO "seasons" VALUES(9,1,7);
+ CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, type TEXT, url TEXT);
+ INSERT INTO "art" VALUES(1,1,'actor','thumb','http://thetvdb.com/banners/actors/73597.jpg');
+ INSERT INTO "art" VALUES(2,2,'actor','thumb','http://thetvdb.com/banners/actors/73596.jpg');
+ INSERT INTO "art" VALUES(3,3,'actor','thumb','http://thetvdb.com/banners/actors/73595.jpg');
+ INSERT INTO "art" VALUES(4,4,'actor','thumb','http://thetvdb.com/banners/actors/73599.jpg');
+ INSERT INTO "art" VALUES(5,5,'actor','thumb','http://thetvdb.com/banners/actors/73598.jpg');
+ INSERT INTO "art" VALUES(6,6,'actor','thumb','http://thetvdb.com/banners/actors/283158.jpg');
+ INSERT INTO "art" VALUES(7,7,'actor','thumb','http://thetvdb.com/banners/actors/283157.jpg');
+ INSERT INTO "art" VALUES(8,8,'actor','thumb','http://thetvdb.com/banners/actors/91271.jpg');
+ INSERT INTO "art" VALUES(9,9,'actor','thumb','http://thetvdb.com/banners/actors/294178.jpg');
+ INSERT INTO "art" VALUES(10,10,'actor','thumb','http://thetvdb.com/banners/actors/283159.jpg');
+ INSERT INTO "art" VALUES(11,1,'tvshow','banner','http://thetvdb.com/banners/graphical/80379-g13.jpg');
+ INSERT INTO "art" VALUES(12,1,'tvshow','fanart','http://thetvdb.com/banners/fanart/original/80379-2.jpg');
+ INSERT INTO "art" VALUES(13,1,'tvshow','poster','http://thetvdb.com/banners/posters/80379-22.jpg');
+ INSERT INTO "art" VALUES(14,1,'season','poster','http://thetvdb.com/banners/posters/80379-22.jpg');
+ INSERT INTO "art" VALUES(15,2,'season','banner','http://thetvdb.com/banners/seasonswide/80379-0.jpg');
+ INSERT INTO "art" VALUES(16,2,'season','poster','http://thetvdb.com/banners/seasons/80379-0-4.jpg');
+ INSERT INTO "art" VALUES(17,3,'season','banner','http://thetvdb.com/banners/seasonswide/80379-1-2.jpg');
+ INSERT INTO "art" VALUES(18,3,'season','poster','http://thetvdb.com/banners/seasons/80379-1-12.jpg');
+ INSERT INTO "art" VALUES(19,4,'season','banner','http://thetvdb.com/banners/seasonswide/80379-2-2.jpg');
+ INSERT INTO "art" VALUES(20,4,'season','poster','http://thetvdb.com/banners/seasons/80379-2-11.jpg');
+ INSERT INTO "art" VALUES(21,5,'season','banner','http://thetvdb.com/banners/seasonswide/80379-3-2.jpg');
+ INSERT INTO "art" VALUES(22,5,'season','poster','http://thetvdb.com/banners/seasons/80379-3-9.jpg');
+ INSERT INTO "art" VALUES(23,6,'season','banner','http://thetvdb.com/banners/seasonswide/80379-4-2.jpg');
+ INSERT INTO "art" VALUES(24,6,'season','poster','http://thetvdb.com/banners/seasons/80379-4-8.jpg');
+ INSERT INTO "art" VALUES(25,7,'season','banner','http://thetvdb.com/banners/seasonswide/80379-5.jpg');
+ INSERT INTO "art" VALUES(26,7,'season','poster','http://thetvdb.com/banners/seasons/80379-5-9.jpg');
+ INSERT INTO "art" VALUES(27,8,'season','poster','http://thetvdb.com/banners/seasons/80379-6-8.jpg');
+ INSERT INTO "art" VALUES(28,9,'season','poster','http://thetvdb.com/banners/seasons/80379-7-3.jpg');
+ INSERT INTO "art" VALUES(29,1,'episode','thumb','http://thetvdb.com/banners/episodes/80379/332484.jpg');
+ CREATE INDEX ix_bookmark ON bookmark (idFile, type);
+ CREATE INDEX ix_path ON path ( strPath );
+ CREATE INDEX ix_files ON files ( idPath, strFilename );
+ CREATE UNIQUE INDEX ix_episode_file_1 on episode (idEpisode, idFile);
+ CREATE UNIQUE INDEX id_episode_file_2 on episode (idFile, idEpisode);
+ CREATE INDEX ix_episode_season_episode on episode (c12, c13);
+ CREATE INDEX ix_episode_bookmark on episode (c17);
+ CREATE INDEX ix_episode_show1 on episode(idEpisode,idShow);
+ CREATE INDEX ix_episode_show2 on episode(idShow,idEpisode);
+ CREATE UNIQUE INDEX ix_tvshowlinkpath_1 ON tvshowlinkpath ( idShow, idPath );
+ CREATE UNIQUE INDEX ix_tvshowlinkpath_2 ON tvshowlinkpath ( idPath, idShow );
+ CREATE INDEX ixEpisodeBasePath ON episode ( c19 );
+ CREATE INDEX ixTVShowBasePath on tvshow ( c17 );
+ CREATE INDEX ix_seasons ON seasons (idShow, season);
+ CREATE INDEX ix_art ON art(media_id, media_type, type);
+ CREATE VIEW episodeview
+ AS
+ SELECT episode.*,
+ files.strfilename AS strFileName,
+ path.strpath AS strPath,
+ files.playcount AS playCount,
+ files.lastplayed AS lastPlayed,
+ files.dateadded AS dateAdded,
+ tvshow.c00 AS strTitle,
+ tvshow.c14 AS strStudio,
+ tvshow.c05 AS premiered,
+ tvshow.c13 AS mpaa,
+ tvshow.c16 AS strShowPath,
+ bookmark.timeinseconds AS resumeTimeInSeconds,
+ bookmark.totaltimeinseconds AS totalTimeInSeconds,
+ seasons.idseason AS idSeason
+ FROM episode
+ JOIN files
+ ON files.idfile = episode.idfile
+ JOIN tvshow
+ ON tvshow.idshow = episode.idshow
+ LEFT JOIN seasons
+ ON seasons.idshow = episode.idshow
+ AND seasons.season = episode.c12
+ JOIN path
+ ON files.idpath = path.idpath
+ LEFT JOIN bookmark
+ ON bookmark.idfile = episode.idfile
+ AND bookmark.type = 1;
+ CREATE VIEW tvshowview
+ AS
+ SELECT tvshow.*,
+ path.strpath AS strPath,
+ path.dateadded AS dateAdded,
+ Max(files.lastplayed) AS lastPlayed,
+ NULLIF(Count(episode.c12), 0) AS totalCount,
+ Count(files.playcount) AS watchedcount,
+ NULLIF(Count(DISTINCT( episode.c12 )), 0) AS totalSeasons
+ FROM tvshow
+ LEFT JOIN tvshowlinkpath
+ ON tvshowlinkpath.idshow = tvshow.idshow
+ LEFT JOIN path
+ ON path.idpath = tvshowlinkpath.idpath
+ LEFT JOIN episode
+ ON episode.idshow = tvshow.idshow
+ LEFT JOIN files
+ ON files.idfile = episode.idfile
+ GROUP BY tvshow.idshow;
+ SELECT
+ episodeview.c12,
+ path.strPath,
+ tvshowview.c00,
+ tvshowview.c01,
+ tvshowview.c05,
+ tvshowview.c08,
+ tvshowview.c14,
+ tvshowview.c13,
+ seasons.idSeason,
+ count(1),
+ count(files.playCount)
+ FROM episodeview
+ JOIN tvshowview ON tvshowview.idShow = episodeview.idShow
+ JOIN seasons ON (seasons.idShow = tvshowview.idShow
+ AND seasons.season = episodeview.c12)
+ JOIN files ON files.idFile = episodeview.idFile
+ JOIN tvshowlinkpath ON tvshowlinkpath.idShow = tvshowview.idShow
+ JOIN path ON path.idPath = tvshowlinkpath.idPath
+ WHERE tvshowview.idShow = 1
+ GROUP BY episodeview.c12;
+} {1 /tmp/tvshows/The.Big.Bang.Theory/ {The Big Bang Theory} {Leonard Hofstadter and Sheldon Cooper are brilliant physicists, the kind of "beautiful minds" that understand how the universe works. But none of that genius helps them interact with people, especially women. All this begins to change when a free-spirited beauty named Penny moves in next door. Sheldon, Leonard's roommate, is quite content spending his nights playing Klingon Boggle with their socially dysfunctional friends, fellow CalTech scientists Howard Wolowitz and Raj Koothrappali. However, Leonard sees in Penny a whole new universe of possibilities... including love.} 2007-09-24 Comedy CBS TV-PG 3 1 0}
+
+##############################################################################
+# 2015-05-18. Make sure transitive constraints are avoided when column
+# affinities and collating sequences get in the way.
+#
+db close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test transitive1-500 {
+ CREATE TABLE x(i INTEGER PRIMARY KEY, y TEXT);
+ INSERT INTO x VALUES(10, '10');
+ SELECT * FROM x WHERE x.y>='1' AND x.y<'2' AND x.i=x.y;
+} {10 10}
+do_execsql_test transitive1-510 {
+ CREATE TABLE t1(x TEXT);
+ CREATE TABLE t2(y TEXT);
+ INSERT INTO t1 VALUES('abc');
+ INSERT INTO t2 VALUES('ABC');
+ SELECT * FROM t1 CROSS JOIN t2 WHERE (x=y COLLATE nocase) AND y='ABC';
+} {abc ABC}
+do_execsql_test transitive1-520 {
+ CREATE TABLE t3(i INTEGER PRIMARY KEY, t TEXT);
+ INSERT INTO t3 VALUES(10, '10');
+ SELECT * FROM t3 WHERE i=t AND t = '10 ';
+} {}
+do_execsql_test transitive1-530 {
+ CREATE TABLE u1(x TEXT, y INTEGER, z TEXT);
+ CREATE INDEX i1 ON u1(x);
+ INSERT INTO u1 VALUES('00013', 13, '013');
+ SELECT * FROM u1 WHERE x=y AND y=z AND z='013';
+} {00013 13 013}
+do_execsql_test transitive1-540 {
+ CREATE TABLE b1(x, y);
+ INSERT INTO b1 VALUES('abc', 'ABC');
+ CREATE INDEX b1x ON b1(x);
+ SELECT * FROM b1 WHERE (x=y COLLATE nocase) AND y='ABC';
+} {abc ABC}
+do_execsql_test transitive1-550 {
+ CREATE TABLE c1(x, y COLLATE nocase, z);
+ INSERT INTO c1 VALUES('ABC', 'ABC', 'abc');
+ SELECT * FROM c1 WHERE x=y AND y=z AND z='abc';
+} {ABC ABC abc}
+do_execsql_test transitive1-560 {
+ CREATE INDEX c1x ON c1(x);
+ SELECT * FROM c1 WHERE x=y AND y=z AND z='abc';
+} {ABC ABC abc}
+do_execsql_test transitive1-560eqp {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM c1 WHERE x=y AND y=z AND z='abc';
+} {/SCAN c1/}
+do_execsql_test transitive1-570 {
+ SELECT * FROM c1 WHERE x=y AND z=y AND z='abc';
+} {}
+do_execsql_test transitive1-570eqp {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM c1 WHERE x=y AND z=y AND z='abc';
+} {/SEARCH c1 USING INDEX c1x/}
+
+# 2021-05-04 forum https://sqlite.org/forum/forumpost/eb8613976a
+reset_db
+do_execsql_test transitive1-600 {
+ CREATE TABLE t0(a0 INT, b1 INT);
+ CREATE INDEX t0b1 ON t0(b1);
+ CREATE TABLE t1(w,x,y,z3 INT);
+ INSERT INTO t0(a0, b1) VALUES (0,1);
+ INSERT INTO t1(w,x,y,z3) VALUES (7,8,9,1);
+} {}
+do_execsql_test transitive1-610 {
+ SELECT ALL * FROM t0,t1 WHERE b1=z3 AND a0=z3;
+} {}
+do_execsql_test transitive1-620 {
+ SELECT ALL * FROM t0,t1 WHERE likely(b1=z3) AND a0=z3;
+} {}
+do_execsql_test transitive1-630 {
+ DROP TABLE t0;
+ DROP TABLE t1;
+ CREATE TABLE t0(c0 INT, c1 INT UNIQUE);
+ CREATE TABLE t1(c0 INT);
+ INSERT INTO t0(c0, c1) VALUES (0, 1);
+ INSERT INTO t1(c0) VALUES (1);
+ SELECT ALL * FROM t1 NATURAL JOIN t0 WHERE (t1.c0=t0.c1);
+ SELECT ALL * FROM t1 NATURAL JOIN t0 WHERE (likely(t1.c0=t0.c1));
+ SELECT ALL * FROM t1,t0 WHERE (likely(t1.c0=t0.c1) AND t1.c0=t0.c0);
+} {}
+
+#-------------------------------------------------------------------------
+# 2021-08-31 forum https://sqlite.org/forum/forumpost/8d1b58f112
+reset_db
+do_execsql_test transitive1-700 {
+ CREATE TABLE t1(a INT PRIMARY KEY);
+ INSERT INTO t1(a) VALUES(1),(2),(3);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY,y INT);
+ INSERT INTO t2(y) VALUES(2),(3);
+}
+
+do_execsql_test transitive1-710 {
+ SELECT * FROM t1 CROSS JOIN t2 WHERE t2.y=t1.a AND t1.a=t2.x
+} {}
+
+do_execsql_test transitive1-720 {
+ SELECT * FROM t1 CROSS JOIN t2 WHERE likely(t2.y=t1.a) AND unlikely(t1.a=t2.x)
+} {}
+
+# 2021-10-04 forum https://sqlite.org/forum/forumpost/a65cacbf5e1c41ba
+#
+reset_db
+do_execsql_test transitive1-800 {
+ CREATE TABLE t1(a INT);
+ INSERT INTO t1 VALUES(0),(3);
+ CREATE TABLE t2(b INT UNIQUE, c INT);
+ INSERT INTO t2 VALUES(1,4) ,(0,5);
+ SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE c=a AND b IS a);
+ SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE a=c AND a IS b);
+ SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE a=c AND b IS a);
+ SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE c=a AND a IS b);
+} {}
+do_execsql_test transitive1-810 {
+ CREATE TABLE t3(a INTEGER PRIMARY KEY,b);
+ INSERT INTO t3(a,b) VALUES(1,2),(5,5),(7,11);
+ SELECT * FROM t3 WHERE a=b AND a='5';
+} {5 5}
+do_execsql_test transitive1-811 {
+ SELECT * FROM t3 WHERE a=b AND a='4';
+} {}
+do_execsql_test transitive1-812 {
+ SELECT * FROM t3 WHERE a=b AND a='7';
+} {}
+do_execsql_test transitive1-813 {
+ SELECT * FROM t3 WHERE a=b AND a='5x';
+} {}
+
+finish_test
diff --git a/test/trigger1.test b/test/trigger1.test
new file mode 100644
index 0000000..6de121f
--- /dev/null
+++ b/test/trigger1.test
@@ -0,0 +1,841 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good 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
+# trigger1-1.1: Error if table does not exist
+# trigger1-1.2: Error if trigger already exists
+# trigger1-1.3: Created triggers are deleted if the transaction is rolled back
+# trigger1-1.4: DROP TRIGGER removes trigger
+# trigger1-1.5: Dropped triggers are restored if the transaction is rolled back
+# trigger1-1.6: Error if dropped trigger doesn't exist
+# trigger1-1.7: Dropping the table automatically drops all triggers
+# trigger1-1.8: A trigger created on a TEMP table is not inserted into sqlite_master
+# trigger1-1.9: Ensure that we cannot create a trigger on sqlite_master
+# trigger1-1.10:
+# trigger1-1.11:
+# trigger1-1.12: Ensure that INSTEAD OF triggers cannot be created on tables
+# trigger1-1.13: Ensure that AFTER triggers cannot be created on views
+# trigger1-1.14: Ensure that BEFORE triggers cannot be created on views
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !trigger||!compound {
+ 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: 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: 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: 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 trigger1-3.2 {
+ catchsql {
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+ } {1 {no such table: main.t2}}
+ do_test trigger1-3.3 {
+ db close
+ set rc [catch {sqlite3 db test.db} err]
+ if {$rc} {lappend rc $err}
+ set rc
+ } {0}
+ do_test trigger1-3.4 {
+ catchsql {
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+ } {1 {no such table: main.t2}}
+ do_test trigger1-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 trigger1-3.6.1 {
+ catchsql {
+ DROP TRIGGER r1;
+ CREATE TEMP TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(NEW.a,NEW.b), (NEW.b*100, NEW.a*100);
+ END;
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t2;
+ }
+ } {0 {1 2 200 100}}
+ do_test trigger1-3.6.2 {
+ catchsql {
+ DROP TRIGGER r1;
+ DELETE FROM t1;
+ DELETE FROM t2;
+ 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 trigger1-3.7 {
+ execsql {
+ DROP TABLE t2;
+ CREATE TABLE t2(x,y);
+ SELECT * FROM t2;
+ }
+ } {}
+
+ # There are two versions of trigger1-3.8 and trigger1-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}}
+verify_ex_errcode trigger1-6.3b SQLITE_CONSTRAINT_TRIGGER
+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 trigger1-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 trigger1-9.1 and trigger1-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.9 {
+ # 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}}
+
+#-------------------------------------------------------------------------
+# Test that bug [34cd55d68e0e6e7c] has been fixed.
+#
+do_execsql_test trigger1-17.0 {
+ CREATE TABLE t17a(ii INT);
+ CREATE TABLE t17b(tt TEXT PRIMARY KEY, ss);
+ CREATE TRIGGER t17a_ai AFTER INSERT ON t17a BEGIN
+ INSERT INTO t17b(tt) VALUES(new.ii);
+ END;
+ CREATE TRIGGER t17b_ai AFTER INSERT ON t17b BEGIN
+ UPDATE t17b SET ss = 4;
+ END;
+ INSERT INTO t17a(ii) VALUES('1');
+ PRAGMA integrity_check;
+} {ok}
+
+# 2018-04-26
+# When a BEFORE UPDATE trigger changes a column value in a row being
+# updated, and that column value is used by the UPDATE to change other
+# column, the value used to compute the update is from before the trigger.
+# In the example that follows, the value of "b" in "c=b" is 2 (the value
+# prior to running the BEFORE UPDATE trigger) not 1000.
+#
+do_execsql_test trigger1-18.0 {
+ CREATE TABLE t18(a PRIMARY KEY,b,c);
+ INSERT INTO t18(a,b,c) VALUES(1,2,3);
+ CREATE TRIGGER t18r1 BEFORE UPDATE ON t18 BEGIN
+ UPDATE t18 SET b=1000 WHERE a=old.a;
+ END;
+ UPDATE t18 SET c=b WHERE a=1;
+ SELECT * FROM t18;
+} {1 1000 2} ;# Not: 1 1000 1000
+do_execsql_test trigger1-18.1 {
+ DELETE FROM t18;
+ INSERT INTO t18(a,b,c) VALUES(1,2,3);
+ UPDATE t18 SET c=b, b=b+1 WHERE a=1;
+ SELECT * FROM t18;
+} {1 3 2} ;# Not: 1 1001 1000
+
+# 2018-04-26 ticket [https://www.sqlite.org/src/tktview/d85fffd6ffe856092e]
+# VDBE Program uses an expired value.
+#
+do_execsql_test trigger1-19.0 {
+ CREATE TABLE t19(a INT PRIMARY KEY, b, c)WITHOUT ROWID;
+ INSERT INTO t19(a,b,c) VALUES(1,2,3);
+ CREATE TRIGGER t19r3 BEFORE UPDATE ON t19 BEGIN SELECT new.b; END;
+ UPDATE t19 SET c=b WHERE a=1;
+ SELECT * FROM t19;
+} {1 2 2}
+do_execsql_test trigger1-19.1 {
+ DELETE FROM t19;
+ INSERT INTO t19(a,b,c) VALUES(1,2,3);
+ UPDATE t19 SET c=CASE WHEN b=2 THEN b ELSE b+99 END WHERE a=1;
+ SELECT * FROM t19;
+} {1 2 2}
+
+# 2019-08-26 Chromium sqlite3_fts3_lpm_fuzzer find.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test trigger1-20.1 {
+ CREATE TABLE t20_1(x);
+ ATTACH ':memory:' AS aux;
+ CREATE TABLE aux.t20_2(y);
+ CREATE TABLE aux.t20_3(z);
+ CREATE TEMP TRIGGER r20_3 AFTER INSERT ON t20_2 BEGIN UPDATE t20_3 SET z=z+1; END;
+ DETACH aux;
+ DROP TRIGGER r20_3;
+} {}
+
+# 2019-10-24 ticket 50c09fc2cf0d91ce
+#
+db close
+sqlite3 db :memory:
+do_execsql_test trigger1-21.1 {
+ PRAGMA recursive_triggers = true;
+ CREATE TABLE t0(a, b, c UNIQUE);
+ CREATE UNIQUE INDEX i0 ON t0(b) WHERE a;
+ CREATE TRIGGER tr0 AFTER DELETE ON t0 BEGIN
+ DELETE FROM t0;
+ END;
+ INSERT INTO t0(a,b,c) VALUES(0,0,9),(1,1,1);
+ REPLACE INTO t0(a,b,c) VALUES(2,0,9);
+ SELECT * FROM t0;
+} {2 0 9}
+
+# 2020-01-04 From Yongheng
+# The test case below caused problems for the register validity
+# tracking logic. There was no bug in the release build. The
+# only problem was a false-positive in the register validity
+# tracking.
+#
+reset_db
+do_execsql_test trigger1-22.10 {
+ CREATE TABLE t1(
+ a INTEGER PRIMARY KEY,
+ b DOUBLE
+ );
+ CREATE TRIGGER x AFTER UPDATE ON t1 BEGIN
+ SELECT sum(b)OVER(ORDER BY (SELECT b FROM t1 AS x
+ WHERE b IN (t1.a,127,t1.b)
+ GROUP BY b))
+ FROM t1
+ GROUP BY a;
+ END;
+ CREATE TEMP TRIGGER x BEFORE INSERT ON t1 BEGIN
+ UPDATE t1
+ SET b=randomblob(10)
+ WHERE b >= 'E'
+ AND a < (SELECT a FROM t1 WHERE a<22 GROUP BY b);
+ END;
+ INSERT INTO t1(b) VALUES('Y'),('X'),('Z');
+ SELECT a, CASE WHEN typeof(b)='text' THEN quote(b) ELSE '<blob>' END, '|' FROM t1;
+} {1 <blob> | 2 'X' | 3 'Z' |}
+
+# 2022-03-06 https://sqlite.org/forum/forumpost/2024e94071
+# Harmless assertion fault following a syntax error.
+#
+reset_db
+do_catchsql_test trigger1-23.1 {
+ CREATE TABLE t1(a INT);
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t1 SELECT e_master LIMIT 1,#1;
+ END;
+} {1 {near "#1": syntax error}}
+
+finish_test
diff --git a/test/trigger2.test b/test/trigger2.test
new file mode 100644
index 0000000..6e007e9
--- /dev/null
+++ b/test/trigger2.test
@@ -0,0 +1,793 @@
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you 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
+set testprefix trigger2
+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 {UNIQUE constraint failed: tbl.a}}
+ 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 {UNIQUE constraint failed: tbl.a}}
+ 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 {UNIQUE constraint failed: tbl.a}}
+ 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 {UNIQUE constraint failed: tbl.a}}
+ 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 {UNIQUE constraint failed: tbl.a}}
+ 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 {UNIQUE constraint failed: tbl.a}}
+ 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;
+ }
+} {}
+
+integrity_check trigger2-9.99
+
+# 2019-11-02 Problem found by TH3, related to generated column support.
+db close
+sqlite3 db :memory:
+do_execsql_test trigger2-10.1 {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE VIEW v2(a,b,c,d) AS SELECT * FROM t1;
+ CREATE TRIGGER v2ins INSTEAD OF INSERT ON v2 BEGIN
+ INSERT INTO t1(a,b,c,d) VALUES(new.a, new.b, new.c, new.d);
+ END;
+ INSERT INTO v2(a,d) VALUES(11,14);
+ SELECT * FROM t1;
+} {11 {} {} 14}
+
+} ;# ifcapable view
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 11.1 {
+ CREATE TABLE t1(a INT PRIMARY KEY, b, c REAL, d, e);
+ CREATE TABLE t2(a INT, b, c REAL, d, e, PRIMARY KEY(a,b)) WITHOUT ROWID;
+ CREATE UNIQUE INDEX t2c ON t2(c);
+ CREATE UNIQUE INDEX t2d ON t2(d);
+ CREATE UNIQUE INDEX t2e ON t2(e);
+}
+
+do_catchsql_test 11.2 {
+ CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO t2(a,b,c,d,e) VALUES(91,NULL,93,94,?1)
+ ON CONFLICT(b,a) DO NOTHING
+ ON CONFLICT DO UPDATE SET b=?1;
+ END;
+} {1 {trigger cannot use variables}}
+
+
+finish_test
+
diff --git a/test/trigger3.test b/test/trigger3.test
new file mode 100644
index 0000000..fe91b9d
--- /dev/null
+++ b/test/trigger3.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 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}}
+verify_ex_errcode trigger3-1.1b SQLITE_CONSTRAINT_TRIGGER
+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}}
+verify_ex_errcode trigger3-2.1b SQLITE_CONSTRAINT_TRIGGER
+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}}
+verify_ex_errcode trigger3-3.1b SQLITE_CONSTRAINT_TRIGGER
+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}}
+verify_ex_errcode trigger3-3.3b SQLITE_CONSTRAINT_TRIGGER
+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}}
+verify_ex_errcode trigger3-7.1b SQLITE_CONSTRAINT_TRIGGER
+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}}
+verify_ex_errcode trigger3-7.3b SQLITE_CONSTRAINT_TRIGGER
+
+} ;# 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..ecc86db
--- /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 {
+ sqlite3_db_config db DEFENSIVE 0
+ 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 .*}/}
+
+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..6e31d1a
--- /dev/null
+++ b/test/trigger9.test
@@ -0,0 +1,253 @@
+# 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
+}
+set ::testprefix trigger9
+
+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}
+}
+
+reset_db
+do_execsql_test 4.1 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE log(x);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ CREATE VIEW v1 AS SELECT a, b FROM t1;
+
+ CREATE TRIGGER tr1 INSTEAD OF DELETE ON v1 BEGIN
+ INSERT INTO log VALUES('delete');
+ END;
+
+ CREATE TRIGGER tr2 INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO log VALUES('update');
+ END;
+
+ CREATE TRIGGER tr3 INSTEAD OF INSERT ON v1 BEGIN
+ INSERT INTO log VALUES('insert');
+ END;
+}
+
+do_catchsql_test 4.2 {
+ DELETE FROM v1 WHERE rowid=1;
+} {1 {no such column: rowid}}
+
+do_catchsql_test 4.3 {
+ UPDATE v1 SET a=b WHERE rowid=2;
+} {1 {no such column: rowid}}
+
+finish_test
diff --git a/test/triggerA.test b/test/triggerA.test
new file mode 100644
index 0000000..598d291
--- /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}
+do_test triggerA-2.11 {
+ db eval {
+ DELETE FROM result4;
+ UPDATE v5 SET b = main.v5.b+9900000 WHERE main.v5.x BETWEEN 3 AND 5;
+ SELECT * FROM result4 ORDER BY a;
+ }
+} {3 305 3 9900305 4 404 4 9900404 5 504 5 9900504}
+
+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..a2a0603
--- /dev/null
+++ b/test/triggerC.test
@@ -0,0 +1,1074 @@
+# 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
+set testprefix triggerC
+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 {UNIQUE constraint failed: t1.a}}
+
+
+#-------------------------------------------------------------------------
+# 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 ORDER BY rowid;
+ }
+ } $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 ORDER BY rowid;
+ "]
+ } [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 ORDER BY rowid;
+ SELECT * FROM t5 ORDER BY rowid;
+ 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 ORDER BY rowid;
+ SELECT * FROM t5 ORDER BY rowid;
+ 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 ORDER BY rowid;
+ SELECT * FROM t5 ORDER BY rowid;
+ 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}}
+
+#-------------------------------------------------------------------------
+# The following tests seek to verify that constant values (i.e. literals)
+# are not factored out of loops within trigger programs. SQLite does
+# not factor constants out of loops within trigger programs as it may only
+# do so in code generated before the first table or index is opened. And
+# by the time a trigger program is coded, at least one table or index has
+# always been opened.
+#
+# At one point, due to a bug allowing constant factoring within triggers,
+# the following SQL would produce the wrong result.
+#
+set SQL {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a, c);
+ CREATE INDEX i2 ON t1(b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+
+ CREATE TABLE t2(e, f);
+ CREATE INDEX i3 ON t2(e);
+ INSERT INTO t2 VALUES(1234567, 3);
+
+ CREATE TABLE empty(x);
+ CREATE TABLE not_empty(x);
+ INSERT INTO not_empty VALUES(2);
+
+ CREATE TABLE t4(x);
+ CREATE TABLE t5(g, h, i);
+
+ CREATE TRIGGER trig BEFORE INSERT ON t4 BEGIN
+ INSERT INTO t5 SELECT * FROM t1 WHERE
+ (a IN (SELECT x FROM empty) OR b IN (SELECT x FROM not_empty))
+ AND c IN (SELECT f FROM t2 WHERE e=1234567);
+ END;
+
+ INSERT INTO t4 VALUES(0);
+ SELECT * FROM t5;
+}
+
+reset_db
+do_execsql_test triggerC-14.1 $SQL {1 2 3}
+reset_db
+optimization_control db factor-constants 0
+do_execsql_test triggerC-14.2 $SQL {1 2 3}
+
+#-------------------------------------------------------------------------
+# Check that table names used by trigger programs are dequoted exactly
+# once.
+#
+do_execsql_test 15.1.1 {
+ PRAGMA recursive_triggers = 1;
+ CREATE TABLE node(
+ id int not null primary key,
+ pid int not null default 0 references node,
+ key varchar not null,
+ path varchar default '',
+ unique(pid, key)
+ );
+ CREATE TRIGGER node_delete_referencing AFTER DELETE ON "node"
+ BEGIN
+ DELETE FROM "node" WHERE pid = old."id";
+ END;
+}
+do_execsql_test 15.1.2 {
+ INSERT INTO node(id, pid, key) VALUES(9, 0, 'test');
+ INSERT INTO node(id, pid, key) VALUES(90, 9, 'test1');
+ INSERT INTO node(id, pid, key) VALUES(900, 90, 'test2');
+ DELETE FROM node WHERE id=9;
+ SELECT * FROM node;
+}
+
+do_execsql_test 15.2.1 {
+ CREATE TABLE x1 (x);
+
+ CREATE TABLE x2 (a, b);
+ CREATE TABLE '"x2"'(a, b);
+
+ INSERT INTO x2 VALUES(1, 2);
+ INSERT INTO x2 VALUES(3, 4);
+ INSERT INTO '"x2"' SELECT * FROM x2;
+
+ CREATE TRIGGER x1ai AFTER INSERT ON x1 BEGIN
+ INSERT INTO """x2""" VALUES('x', 'y');
+ DELETE FROM """x2""" WHERE a=1;
+ UPDATE """x2""" SET b = 11 WHERE a = 3;
+ END;
+
+ INSERT INTO x1 VALUES('go!');
+}
+
+do_execsql_test 15.2.2 { SELECT * FROM x2; } {1 2 3 4}
+do_execsql_test 15.2.3 { SELECT * FROM """x2"""; } {3 11 x y}
+
+#-------------------------------------------------------------------------
+# At one point queries such as the following were causing segfaults.
+#
+do_catchsql_test 16.1 {
+ SELECT raise(ABORT, 'msg') FROM sqlite_master
+ UNION SELECT 1
+ ORDER BY raise(IGNORE);
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+do_catchsql_test 16.2 {
+ SELECT count(*) FROM sqlite_master
+ GROUP BY raise(IGNORE)
+ HAVING raise(ABORT, 'msg');
+} {1 {RAISE() may only be used within a trigger-program}}
+
+#-------------------------------------------------------------------------
+# Datatype mismatch on IPK when there are BEFORE triggers.
+#
+do_execsql_test 17.0 {
+ CREATE TABLE xyz(x INTEGER PRIMARY KEY, y, z);
+ CREATE TRIGGER xyz_tr BEFORE INSERT ON xyz BEGIN
+ SELECT new.x;
+ END;
+}
+do_catchsql_test 17.1 {
+ INSERT INTO xyz VALUES('hello', 2, 3);
+} {1 {datatype mismatch}}
+
+
+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/triggerE.test b/test/triggerE.test
new file mode 100644
index 0000000..de4b068
--- /dev/null
+++ b/test/triggerE.test
@@ -0,0 +1,114 @@
+# 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.
+#
+#***********************************************************************
+#
+# This file tests the effects of SQL variable references embedded in
+# triggers. If the user attempts to create such a trigger, it is an
+# error. However, if an existing trigger definition is read from
+# the sqlite_master table, the variable reference always evaluates
+# to NULL.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+set testprefix triggerE
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ CREATE TABLE t3(e, f);
+}
+
+# forcedelete test.db2
+# do_execsql_test 1.1 {
+# ATTACH 'test.db2' AS aux;
+# CREATE TABLE aux.t4(x);
+# INSERT INTO aux.t4 VALUES(5);
+#
+# CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN new.a IN (SELECT x FROM aux.t4)
+# BEGIN
+# SELECT 1;
+# END;
+# }
+# do_execsql_test 1.2 { INSERT INTO t1 VALUES(1,1); }
+# do_execsql_test 1.3 { INSERT INTO t1 VALUES(5,5); }
+
+#-------------------------------------------------------------------------
+# Attempt to create various triggers that use bound variables.
+#
+set errmsg "trigger cannot use variables"
+foreach {tn defn} {
+ 1 { AFTER INSERT ON t1 WHEN new.a = ? BEGIN SELECT 1; END; }
+ 2 { BEFORE DELETE ON t1 BEGIN SELECT ?; END; }
+ 3 { BEFORE DELETE ON t1 BEGIN SELECT * FROM (SELECT * FROM (SELECT ?)); END; }
+ 5 { BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 GROUP BY ?; END; }
+ 6 { BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 LIMIT ?; END; }
+ 7 { BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 ORDER BY ?; END; }
+ 8 { BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET c = ?; END; }
+ 9 { BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET c = 1 WHERE d = ?; END; }
+ 10 { AFTER INSERT ON t1 BEGIN SELECT * FROM pragma_stats(?); END; }
+ 11 { BEFORE INSERT ON t1 BEGIN
+ INSERT INTO t1 SELECT max(b) OVER(ORDER BY $1) FROM t1; END }
+} {
+ catchsql {drop trigger tr1}
+ do_catchsql_test 1.1.$tn "CREATE TRIGGER tr1 $defn" [list 1 $errmsg]
+ do_catchsql_test 1.2.$tn "CREATE TEMP TRIGGER tr1 $defn" [list 1 $errmsg]
+}
+
+#-------------------------------------------------------------------------
+# Test that variable references within trigger definitions loaded from
+# the sqlite_master table are automatically converted to NULL.
+#
+sqlite3_db_config db DEFENSIVE 0
+do_execsql_test 2.1 {
+ PRAGMA writable_schema = 1;
+ INSERT INTO sqlite_master VALUES('trigger', 'tr1', 't1', 0,
+ 'CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(?1, ?2);
+ END'
+ );
+
+ INSERT INTO sqlite_master VALUES('trigger', 'tr2', 't3', 0,
+ 'CREATE TRIGGER tr2 AFTER INSERT ON t3 WHEN ?1 IS NULL BEGIN
+ UPDATE t2 SET c=d WHERE c IS ?2;
+ END'
+ );
+}
+db close
+sqlite3 db test.db
+
+do_execsql_test 2.2.1 {
+ INSERT INTO t1 VALUES(1, 2);
+ SELECT * FROM t2;
+} {{} {}}
+do_test 2.2.2 {
+ set one 3
+ execsql {
+ DELETE FROM t2;
+ INSERT INTO t1 VALUES($one, ?1);
+ SELECT * FROM t2;
+ }
+} {{} {}}
+do_execsql_test 2.2.3 { SELECT * FROM t1 } {1 2 3 3}
+
+do_execsql_test 2.3 {
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES('x', 'y');
+ INSERT INTO t2 VALUES(NULL, 'z');
+ INSERT INTO t3 VALUES(1, 2);
+ SELECT * FROM t3;
+ SELECT * FROM t2;
+} {1 2 x y z z}
+
+finish_test
diff --git a/test/triggerF.test b/test/triggerF.test
new file mode 100644
index 0000000..2e3e35e
--- /dev/null
+++ b/test/triggerF.test
@@ -0,0 +1,71 @@
+# 2017 January 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix triggerF
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+
+foreach {tn sql log} {
+ 1 {} {}
+
+ 2 {
+ CREATE TRIGGER trd AFTER DELETE ON t1 BEGIN
+ INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
+ END;
+ } {1one2 2two1 3three1}
+
+ 3 {
+ CREATE TRIGGER trd BEFORE DELETE ON t1 BEGIN
+ INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
+ END;
+ } {1one3 2two2 3three2}
+
+ 4 {
+ CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN
+ INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
+ END;
+ CREATE TRIGGER tr2 BEFORE DELETE ON t1 BEGIN
+ INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
+ END;
+ } {1one3 1one2 2two2 2two1 3three2 3three1}
+
+} {
+ reset_db
+ do_execsql_test 1.$tn.0 {
+ PRAGMA recursive_triggers = on;
+ CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
+ CREATE TABLE log(t);
+ }
+
+ execsql $sql
+
+ do_execsql_test 1.$tn.1 {
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(3, 'three');
+
+ DELETE FROM t1 WHERE a=1;
+ INSERT OR REPLACE INTO t1 VALUES(2, 'three');
+ UPDATE OR REPLACE t1 SET a=3 WHERE a=2;
+ }
+
+ do_execsql_test 1.$tn.2 {
+ SELECT * FROM log ORDER BY rowid;
+ } $log
+}
+
+finish_test
diff --git a/test/triggerG.test b/test/triggerG.test
new file mode 100644
index 0000000..8cf20b5
--- /dev/null
+++ b/test/triggerG.test
@@ -0,0 +1,94 @@
+# 2017-03-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
+set testprefix triggerG
+ifcapable {!trigger} {
+ finish_test
+ return
+}
+
+# Test cases for ticket
+# https://www.sqlite.org/src/tktview/06796225f59c057cd120f
+#
+# The OP_Once opcode was not working correctly for recursive triggers.
+#
+do_execsql_test 100 {
+ PRAGMA recursive_triggers = 1;
+
+ CREATE TABLE t1(a);
+ CREATE INDEX i1 ON t1(a);
+ INSERT INTO t1(a) VALUES(0),(2),(3),(8),(9);
+ CREATE TABLE t2(b);
+ CREATE TABLE t3(c);
+
+ CREATE TRIGGER tr AFTER INSERT ON t3 BEGIN
+ INSERT INTO t3 SELECT new.c+1 WHERE new.c<5;
+ INSERT INTO t2 SELECT new.c*100+a FROM t1 WHERE a IN (1, 2, 3, 4);
+ END;
+
+ INSERT INTO t3 VALUES(2);
+ SELECT c FROM t3 ORDER BY c;;
+} {2 3 4 5}
+do_execsql_test 110 {
+ SELECT b FROM t2 ORDER BY b;
+} {202 203 302 303 402 403 502 503}
+
+do_execsql_test 200 {
+ DELETE FROM t1;
+ INSERT INTO t1(a) VALUES(0),(2),(3),(8),(9);
+ DELETE FROM t2;
+ DELETE FROM t3;
+ DROP TRIGGER tr;
+ CREATE TRIGGER tr AFTER INSERT ON t3 BEGIN
+ INSERT INTO t3 SELECT new.c+1 WHERE new.c<5;
+ INSERT INTO t2 SELECT new.c*10000+xx.a*100+yy.a
+ FROM t1 AS xx, t1 AS yy
+ WHERE xx.a IN (1,2,3,4)
+ AND yy.a IN (2,3,4,5);
+ END;
+
+ INSERT INTO t3 VALUES(2);
+ SELECT b FROM t2 ORDER BY b;
+} {20202 20203 20302 20303 30202 30203 30302 30303 40202 40203 40302 40303 50202 50203 50302 50303}
+
+# At one point the following was causing an assert() to fail.
+#
+do_execsql_test 300 {
+ CREATE TABLE t4(x);
+ CREATE TRIGGER tr4 AFTER INSERT ON t4 BEGIN
+ SELECT 0x2147483648e0e0099 AS y WHERE y;
+ END;
+}
+
+do_catchsql_test 310 {
+ INSERT INTO t4 VALUES(1);
+} {1 {hex literal too big: 0x2147483648e0e0099}}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 400 {
+ CREATE VIEW v0(a) AS SELECT 1234;
+ CREATE TRIGGER t0001 INSTEAD OF DELETE ON v0 BEGIN
+ SELECT old.a;
+ END;
+}
+do_execsql_test 405 {
+ SELECT a FROM v0;
+} {1234}
+do_execsql_test 410 {
+ DELETE FROM v0;
+}
+
+
+finish_test
diff --git a/test/triggerupfrom.test b/test/triggerupfrom.test
new file mode 100644
index 0000000..a731045
--- /dev/null
+++ b/test/triggerupfrom.test
@@ -0,0 +1,173 @@
+# 2020 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix triggerupfrom
+
+do_execsql_test 1.0 {
+ CREATE TABLE map(k, v);
+ INSERT INTO map VALUES(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four');
+
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+
+ CREATE TRIGGER tr AFTER INSERT ON t1 BEGIN
+ UPDATE t1 SET c = v FROM map WHERE k=new.a AND a=new.a;
+ END;
+}
+
+do_execsql_test 1.1 {
+ INSERT INTO t1(a) VALUES(1);
+}
+
+do_execsql_test 1.2 {
+ SELECT a, c FROM t1 ORDER BY a;
+} {1 one}
+
+do_execsql_test 1.3 {
+ INSERT INTO t1(a) VALUES(2), (3), (4), (5);
+ SELECT a, c FROM t1 ORDER BY a;
+} {1 one 2 two 3 three 4 four 5 {}}
+
+forcedelete test.db2
+do_execsql_test 2.0 {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t3(x, y);
+ INSERT INTO aux.t3 VALUES('x', 'y');
+}
+
+do_catchsql_test 2.1 {
+ CREATE TRIGGER tr2 AFTER INSERT ON t1 BEGIN
+ UPDATE t1 SET b = y FROM aux.t3 WHERE k=new.a;
+ END;
+} {1 {trigger tr2 cannot reference objects in database aux}}
+
+do_execsql_test 2.2 {
+ CREATE TEMP TRIGGER tr2 AFTER INSERT ON t1 BEGIN
+ UPDATE t1 SET b = y FROM aux.t3 WHERE a=new.a;
+ END;
+ INSERT INTO t1(a) VALUES(10), (20);
+ SELECT * FROM t1;
+} {
+ 1 {} one
+ 2 {} two
+ 3 {} three
+ 4 {} four
+ 5 {} {}
+ 10 y {}
+ 20 y {}
+}
+
+do_execsql_test 2.3 {
+ CREATE TABLE link(f, t);
+ INSERT INTO link VALUES(5, 2), (20, 10), (2, 1);
+ CREATE TRIGGER tr3 BEFORE DELETE ON t1 BEGIN
+ UPDATE t1 SET b=coalesce(old.b,old.c) FROM main.link WHERE a=t AND old.a=f;
+ END;
+ DELETE FROM t1 WHERE a=2;
+ SELECT * FROM t1;
+} {
+ 1 two one
+ 3 {} three
+ 4 {} four
+ 5 {} {}
+ 10 y {}
+ 20 y {}
+}
+
+db close
+sqlite3 db ""
+do_catchsql_test 2.4 {
+ ATTACH 'test.db' AS yyy;
+ SELECT * FROM t1;
+} {1 {malformed database schema (tr3) - trigger tr3 cannot reference objects in database main}}
+
+#-------------------------------------------------------------------------
+reset_db
+forcedelete test.db2
+do_execsql_test 3.0 {
+ CREATE TABLE mmm(x, y);
+ INSERT INTO mmm VALUES(1, 'one');
+ INSERT INTO mmm VALUES(2, 'two');
+ INSERT INTO mmm VALUES(3, 'three');
+
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.t1(a, b);
+ CREATE TABLE aux.mmm(x, y);
+ INSERT INTO aux.mmm VALUES(1, 'ONE');
+ INSERT INTO aux.mmm VALUES(2, 'TWO');
+ INSERT INTO aux.mmm VALUES(3, 'THREE');
+
+ CREATE TRIGGER aux.ttt AFTER INSERT ON t1 BEGIN
+ UPDATE t1 SET b=y FROM mmm WHERE x=new.a AND a=new.a;
+ END;
+
+ INSERT INTO t1(a) VALUES (2);
+ SELECT * FROM t1;
+} {2 TWO}
+
+#-------------------------------------------------------------------------
+# Test that INSTEAD OF UPDATE triggers on views work with UPDATE...FROM
+# statements. Including, if the library is built with ENABLE_HIDDEN_COLUMNS,
+# that they work correctly on views with hidden columns.
+#
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1(k, a, b);
+ INSERT INTO t1 VALUES('a', 1, 'one');
+ INSERT INTO t1 VALUES('b', 2, 'two');
+ INSERT INTO t1 VALUES('c', 3, 'three');
+ INSERT INTO t1 VALUES('d', 4, 'four');
+
+ CREATE TABLE log(x);
+ CREATE VIEW v1 AS SELECT k, a, b AS __hidden__b FROM t1;
+ CREATE TRIGGER tr1 INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO log VALUES(
+ '('||old.a||','||old.__hidden__b||')->('||new.a||','||new.__hidden__b||')'
+ );
+ END;
+}
+
+ifcapable hiddencolumns {
+ do_execsql_test 4.1-hc-enabled {
+ SELECT * FROM v1
+ } {a 1 b 2 c 3 d 4}
+} else {
+ do_execsql_test 4.1-hc-disabled {
+ SELECT * FROM v1
+ } {a 1 one b 2 two c 3 three d 4 four}
+}
+
+do_execsql_test 4.2 {
+ UPDATE v1 SET a='xyz' WHERE k IN ('a', 'c');
+ SELECT * FROM log;
+ DELETE FROM log;
+} {
+ (1,one)->(xyz,one)
+ (3,three)->(xyz,three)
+}
+
+do_execsql_test 4.3 {
+ CREATE TABLE map(k, v);
+ INSERT INTO map VALUES('b', 'twelve');
+ INSERT INTO map VALUES('d', 'fourteen');
+ UPDATE v1 SET a=map.v FROM map WHERE v1.k=map.k;
+ SELECT * FROM log;
+ DELETE FROM log;
+} {
+ (2,two)->(twelve,two)
+ (4,four)->(fourteen,four)
+}
+
+
+
+finish_test
diff --git a/test/trustschema1.test b/test/trustschema1.test
new file mode 100644
index 0000000..dba954f
--- /dev/null
+++ b/test/trustschema1.test
@@ -0,0 +1,251 @@
+# 2020-01-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.
+#
+#***********************************************************************
+#
+# Test cases for managing execution of code snippets found in untrusted
+# schemas.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix trustschema1
+
+# edgy functions used in generated columns
+#
+proc f1 {x} {return $x}
+do_test 1.100 {
+ db function f1 -innocuous -deterministic f1
+ db function f2 -deterministic f1
+ db function f3 -directonly -deterministic f1
+ db eval {
+ CREATE TABLE t1(a, b AS (f1(a+1)), c AS (f2(a+2)));
+ INSERT INTO t1 VALUES(100),(200);
+ }
+} {}
+do_catchsql_test 1.110 {
+ SELECT a, b, c FROM t1;
+} {0 {100 101 102 200 201 202}}
+do_execsql_test 1.120 {
+ PRAGMA trusted_schema=OFF;
+} {}
+do_catchsql_test 1.130 {
+ SELECT a, b FROM t1;
+} {0 {100 101 200 201}}
+do_catchsql_test 1.140 {
+ SELECT a, b, c FROM t1;
+} {1 {unsafe use of f2()}}
+do_catchsql_test 1.150 {
+ PRAGMA trusted_schema=ON;
+ DROP TABLE t1;
+ CREATE TABLE t1(a, b AS (f3(a+1)));
+} {1 {unsafe use of f3()}}
+do_execsql_test 1.160 {
+ PRAGMA trusted_schema=OFF;
+ CREATE TEMP TABLE temp1(a,b AS (f3(a+1)));
+ INSERT INTO temp1(a) VALUES(100),(900);
+ SELECT * FROM temp1;
+} {100 101 900 901}
+
+# edgy functions used in CHECK constraints
+#
+do_catchsql_test 1.200 {
+ PRAGMA trusted_schema=ON;
+ CREATE TABLE t2(a,b,c,CHECK(f3(c)==c));
+} {1 {unsafe use of f3()}}
+do_catchsql_test 1.210 {
+ PRAGMA trusted_schema=Off;
+ CREATE TABLE t2(a,b,c,CHECK(f2(c)==c));
+} {1 {unsafe use of f2()}}
+do_catchsql_test 1.211 {
+ PRAGMA trusted_schema=On;
+ CREATE TABLE t2(a,b,c,CHECK(f2(c)==c));
+} {0 {}}
+do_catchsql_test 1.220 {
+ INSERT INTO t2 VALUES(1,2,3);
+ SELECT * FROM t2;
+} {0 {1 2 3}}
+do_catchsql_test 1.230 {
+ PRAGMA trusted_schema=off;
+ INSERT INTO t2 VALUES(4,5,6);
+} {1 {unsafe use of f2()}}
+do_execsql_test 1.231 {
+ SELECT * FROM t2;
+} {1 2 3}
+# Ok to put as many edgy functions as you want in a
+# TEMP table.
+do_execsql_test 1.240 {
+ PRAGMA trusted_schema=OFF;
+ CREATE TEMP TABLE temp2(a, b, CHECK(f3(b)==b));
+ INSERT INTO temp2(a,b) VALUES(1,2),('x','y');
+ SELECT * FROM temp2;
+} {1 2 x y}
+
+# edgy functions used in DEFAULT constraints
+#
+do_catchsql_test 1.300 {
+ CREATE TABLE t3(a,b DEFAULT(f2(25)));
+} {0 {}}
+do_catchsql_test 1.310 {
+ PRAGMA trusted_schema=Off;
+ INSERT INTO t3(a) VALUES(1);
+} {1 {unsafe use of f2()}}
+do_catchsql_test 1.311 {
+ INSERT INTO t3(a,b) VALUES(1,2);
+} {0 {}}
+do_execsql_test 1.320 {
+ CREATE TEMP TABLE temp3(a, b DEFAULT(f3(31)));
+ INSERT INTO temp3(a) VALUES(22);
+ SELECT * FROM temp3;
+} {22 31}
+
+# edgy functions used in partial indexes.
+#
+do_execsql_test 1.400 {
+ CREATE TABLE t4(a,b,c);
+ INSERT INTO t4 VALUES(1,2,3),('a','b','c'),(4,'d',0);
+ SELECT * FROM t4;
+ CREATE TEMP TABLE temp4(a,b,c);
+ INSERT INTO temp4 SELECT * FROM t4;
+} {1 2 3 a b c 4 d 0}
+do_catchsql_test 1.410 {
+ CREATE INDEX t4a ON t4(a) WHERE f3(c);
+} {1 {unsafe use of f3()}}
+do_catchsql_test 1.420 {
+ PRAGMA trusted_schema=OFF;
+ CREATE INDEX t4a ON t4(a) WHERE f2(c);
+} {1 {unsafe use of f2()}}
+do_execsql_test 1.421 {
+ CREATE INDEX t4a ON t4(a) WHERE f1(c);
+ SELECT a FROM t4 WHERE f1(c) ORDER BY a;
+} {1}
+do_execsql_test 1.430 {
+ PRAGMA trusted_schema=ON;
+ CREATE INDEX t4b ON t4(b) WHERE f2(c);
+ SELECT b FROM t4 WHERE f2(c) ORDER BY b;
+} {2}
+do_execsql_test 1.440 {
+ PRAGMA trusted_schema=OFF;
+ CREATE INDEX temp4a ON temp4(a) WHERE f3(c);
+ SELECT a FROM temp4 WHERE f2(c) ORDER BY a;
+} {1}
+
+# edgy functions used in index expressions
+#
+do_execsql_test 1.500 {
+ CREATE TABLE t5(a,b,c);
+ INSERT INTO t5 VALUES(1,2,3),(4,5,6),(7,0,-3);
+ SELECT * FROM t5;
+ CREATE TEMP TABLE temp5(a,b,c);
+ INSERT INTO temp5 SELECT * FROM t5;
+} {1 2 3 4 5 6 7 0 -3}
+do_catchsql_test 1.510 {
+ CREATE INDEX t5x1 ON t5(a+f3(b));
+} {1 {unsafe use of f3()}}
+do_catchsql_test 1.520 {
+ PRAGMA trusted_schema=OFF;
+ CREATE INDEX t5x1 ON t5(a+f2(b));
+} {1 {unsafe use of f2()}}
+do_execsql_test 1.521 {
+ CREATE INDEX t5x1 ON t5(a+f1(b));
+ SELECT * FROM t5 INDEXED BY t5x1 WHERE a+f1(b)=3;
+} {1 2 3}
+do_execsql_test 1.530 {
+ PRAGMA trusted_schema=ON;
+ CREATE INDEX t5x2 ON t5(b+f2(c));
+ SELECT * FROM t5 INDEXED BY t5x2 WHERE b+f2(c)=11;
+} {4 5 6}
+do_execsql_test 1.540 {
+ PRAGMA trusted_schema=OFF;
+ CREATE INDEX temp5x1 ON temp5(a+f3(b));
+ SELECT * FROM temp5 INDEXED BY temp5x1 WHERE a+f3(b)=7;
+} {7 0 -3}
+
+# edgy functions in VIEWs
+#
+reset_db
+db function f1 -innocuous -deterministic f1
+db function f2 -deterministic f1
+db function f3 -directonly -deterministic f1
+do_execsql_test 2.100 {
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1 VALUES(1,2,3),(100,50,75),(-11,22,-33);
+ CREATE VIEW v1a AS SELECT f3(a+b) FROM t1;
+ SELECT f3(a+b) FROM t1;
+} {3 150 11}
+do_catchsql_test 2.110 {
+ PRAGMA trusted_schema=ON;
+ SELECT * FROM v1a;
+} {1 {unsafe use of f3()}}
+do_catchsql_test 2.111 {
+ PRAGMA trusted_schema=OFF;
+ SELECT * FROM v1a;
+} {1 {unsafe use of f3()}}
+do_execsql_test 2.120 {
+ DROP VIEW v1a;
+ CREATE TEMP VIEW v1a AS SELECT f3(a+b) FROM t1;
+ SELECT * FROM v1a;
+} {3 150 11}
+do_execsql_test 2.130 {
+ CREATE VIEW v1b AS SELECT f2(b+c) FROM t1;
+ SELECT f2(b+c) FROM t1;
+} {5 125 -11}
+do_catchsql_test 2.140 {
+ PRAGMA trusted_schema=ON;
+ SELECT * FROM v1b;
+} {0 {5 125 -11}}
+do_catchsql_test 2.141 {
+ PRAGMA trusted_schema=OFF;
+ SELECT * FROM v1b;
+} {1 {unsafe use of f2()}}
+do_execsql_test 2.150 {
+ DROP VIEW v1b;
+ CREATE TEMP VIEW v1b AS SELECT f2(b+c) FROM t1;
+ SELECT * FROM v1b;
+} {5 125 -11}
+
+# edgy functions inside of triggers
+#
+do_execsql_test 3.100 {
+ DELETE FROM t1;
+ CREATE TABLE t2(x);
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2(x) SELECT f3(new.a);
+ END;
+} {}
+do_catchsql_test 3.110 {
+ INSERT INTO t1 VALUES(7,6,5);
+} {1 {unsafe use of f3()}}
+do_execsql_test 3.111 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {}
+
+do_execsql_test 3.120 {
+ DROP TRIGGER r1;
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2(x) SELECT f2(new.a)+100;
+ END;
+ PRAGMA trusted_schema=ON;
+ INSERT INTO t1 VALUES(7,6,5);
+ SELECT * FROM t1, t2;
+} {7 6 5 107}
+do_catchsql_test 3.130 {
+ DELETE FROM t1;
+ DELETE FROM t2;
+ PRAGMA trusted_schema=OFF;
+ INSERT INTO t1 VALUES(7,6,5);
+} {1 {unsafe use of f2()}}
+do_execsql_test 3.131 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {}
+
+
+finish_test
diff --git a/test/tt3_checkpoint.c b/test/tt3_checkpoint.c
new file mode 100644
index 0000000..ec9d072
--- /dev/null
+++ b/test/tt3_checkpoint.c
@@ -0,0 +1,148 @@
+/*
+** 2011-02-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 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, void *pArg){
+ 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");
+ sqlite3_sleep(CHECKPOINT_STARVATION_READMS);
+ 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);
+ sqlite3_sleep(CHECKPOINT_STARVATION_READMS/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/tt3_index.c b/test/tt3_index.c
new file mode 100644
index 0000000..62f06ad
--- /dev/null
+++ b/test/tt3_index.c
@@ -0,0 +1,74 @@
+/*
+** 2014 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.
+**
+*************************************************************************
+**
+** create_drop_index_1
+*/
+
+
+static char *create_drop_index_thread(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+
+ while( !timetostop(&err) ){
+ opendb(&err, &db, "test.db", 0);
+
+ sql_script(&err, &db,
+ "DROP INDEX IF EXISTS i1;"
+ "DROP INDEX IF EXISTS i2;"
+ "DROP INDEX IF EXISTS i3;"
+ "DROP INDEX IF EXISTS i4;"
+
+ "CREATE INDEX IF NOT EXISTS i1 ON t11(a);"
+ "CREATE INDEX IF NOT EXISTS i2 ON t11(b);"
+ "CREATE INDEX IF NOT EXISTS i3 ON t11(c);"
+ "CREATE INDEX IF NOT EXISTS i4 ON t11(d);"
+
+ "SELECT * FROM t11 ORDER BY a;"
+ "SELECT * FROM t11 ORDER BY b;"
+ "SELECT * FROM t11 ORDER BY c;"
+ "SELECT * FROM t11 ORDER BY d;"
+ );
+ clear_error(&err, SQLITE_LOCKED);
+
+ closedb(&err, &db);
+ }
+
+ print_and_free_err(&err);
+ return sqlite3_mprintf("ok");
+}
+
+static void create_drop_index_1(int nMs){
+ Error err = {0};
+ Sqlite db = {0};
+ Threadset threads = {0};
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db,
+ "CREATE TABLE t11(a, b, c, d);"
+ "WITH data(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM data WHERE x<100) "
+ "INSERT INTO t11 SELECT x,x,x,x FROM data;"
+ );
+ closedb(&err, &db);
+
+ setstoptime(&err, nMs);
+
+ sqlite3_enable_shared_cache(1);
+ launch_thread(&err, &threads, create_drop_index_thread, 0);
+ launch_thread(&err, &threads, create_drop_index_thread, 0);
+ launch_thread(&err, &threads, create_drop_index_thread, 0);
+ launch_thread(&err, &threads, create_drop_index_thread, 0);
+ launch_thread(&err, &threads, create_drop_index_thread, 0);
+
+ join_all_threads(&err, &threads);
+ sqlite3_enable_shared_cache(0);
+ print_and_free_err(&err);
+}
diff --git a/test/tt3_lookaside1.c b/test/tt3_lookaside1.c
new file mode 100644
index 0000000..e785e79
--- /dev/null
+++ b/test/tt3_lookaside1.c
@@ -0,0 +1,99 @@
+/*
+** 2014 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.
+**
+*************************************************************************
+**
+** lookaside1
+*/
+
+/*
+** The test in this file attempts to expose a specific race condition
+** that is suspected to exist at time of writing.
+*/
+
+static char *lookaside1_thread_reader(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+
+ opendb(&err, &db, "test.db", 0);
+
+ while( !timetostop(&err) ){
+ sqlite3_stmt *pStmt = 0;
+ int rc;
+
+ sqlite3_prepare_v2(db.db, "SELECT 1 FROM t1", -1, &pStmt, 0);
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ execsql(&err, &db, "SELECT length(x||y||z) FROM t2");
+ }
+ rc = sqlite3_finalize(pStmt);
+ if( err.rc==SQLITE_OK && rc!=SQLITE_OK ){
+ sqlite_error(&err, &db, "finalize");
+ }
+ }
+
+ closedb(&err, &db);
+ print_and_free_err(&err);
+ return sqlite3_mprintf("ok");
+}
+
+static char *lookaside1_thread_writer(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+
+ opendb(&err, &db, "test.db", 0);
+
+ do{
+ sql_script(&err, &db,
+ "BEGIN;"
+ "UPDATE t3 SET i=i+1 WHERE x=1;"
+ "ROLLBACK;"
+ );
+ }while( !timetostop(&err) );
+
+ closedb(&err, &db);
+ print_and_free_err(&err);
+ return sqlite3_mprintf("ok");
+}
+
+
+static void lookaside1(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 PRIMARY KEY) WITHOUT ROWID;"
+ "WITH data(x,y) AS ("
+ " SELECT 1, quote(randomblob(750)) UNION ALL "
+ " SELECT x*2, y||y FROM data WHERE x<5) "
+ "INSERT INTO t1 SELECT y FROM data;"
+
+ "CREATE TABLE t3(x PRIMARY KEY,i) WITHOUT ROWID;"
+ "INSERT INTO t3 VALUES(1, 1);"
+
+ "CREATE TABLE t2(x,y,z);"
+ "INSERT INTO t2 VALUES(randomblob(50), randomblob(50), randomblob(50));"
+ );
+ closedb(&err, &db);
+
+ setstoptime(&err, nMs);
+
+ sqlite3_enable_shared_cache(1);
+ launch_thread(&err, &threads, lookaside1_thread_reader, 0);
+ launch_thread(&err, &threads, lookaside1_thread_reader, 0);
+ launch_thread(&err, &threads, lookaside1_thread_reader, 0);
+ launch_thread(&err, &threads, lookaside1_thread_reader, 0);
+ launch_thread(&err, &threads, lookaside1_thread_reader, 0);
+ launch_thread(&err, &threads, lookaside1_thread_writer, 0);
+ join_all_threads(&err, &threads);
+ sqlite3_enable_shared_cache(0);
+ print_and_free_err(&err);
+}
diff --git a/test/tt3_shared.c b/test/tt3_shared.c
new file mode 100644
index 0000000..5bdadd1
--- /dev/null
+++ b/test/tt3_shared.c
@@ -0,0 +1,55 @@
+/*
+** 2020 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.
+**
+*************************************************************************
+**
+**
+*/
+
+
+/*
+*/
+static char *shared_thread1(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+
+ while( !timetostop(&err) ){
+ Sqlite db = {0}; /* SQLite database connection */
+ opendb(&err, &db, "test.db", 0);
+ sql_script(&err, &db, "SELECT * FROM t1");
+ closedb(&err, &db);
+ }
+ print_and_free_err(&err);
+ return sqlite3_mprintf("done!");
+}
+
+
+static void shared1(int nMs){
+ Error err = {0};
+ Sqlite db = {0}; /* SQLite database connection */
+ Threadset threads = {0};
+ int ii;
+
+ opendb(&err, &db, "test.db", 1);
+ sql_script(&err, &db, "CREATE TABLE t1(x)");
+ closedb(&err, &db);
+
+ setstoptime(&err, nMs);
+ sqlite3_enable_shared_cache(1);
+
+ for(ii=0; ii<5; ii++){
+ launch_thread(&err, &threads, shared_thread1, 0);
+ }
+
+ join_all_threads(&err, &threads);
+ sqlite3_enable_shared_cache(0);
+
+ print_and_free_err(&err);
+}
+
diff --git a/test/tt3_stress.c b/test/tt3_stress.c
new file mode 100644
index 0000000..be917b7
--- /dev/null
+++ b/test/tt3_stress.c
@@ -0,0 +1,364 @@
+/*
+** 2014 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.
+**
+*************************************************************************
+**
+**
+*/
+
+
+/*
+** Thread 1. CREATE and DROP a table.
+*/
+static char *stress_thread_1(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ sql_script(&err, &db, "CREATE TABLE IF NOT EXISTS t1(a PRIMARY KEY, b)");
+ clear_error(&err, SQLITE_LOCKED);
+ sql_script(&err, &db, "DROP TABLE IF EXISTS t1");
+ clear_error(&err, SQLITE_LOCKED);
+ }
+ closedb(&err, &db);
+ print_and_free_err(&err);
+ return sqlite3_mprintf("ok");
+}
+
+/*
+** Thread 2. Open and close database connections.
+*/
+static char *stress_thread_2(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ while( !timetostop(&err) ){
+ opendb(&err, &db, "test.db", 0);
+ sql_script(&err, &db, "SELECT * FROM sqlite_schema;");
+ clear_error(&err, SQLITE_LOCKED);
+ closedb(&err, &db);
+ }
+ print_and_free_err(&err);
+ return sqlite3_mprintf("ok");
+}
+
+/*
+** Thread 3. Attempt many small SELECT statements.
+*/
+static char *stress_thread_3(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+
+ int i1 = 0;
+ int i2 = 0;
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ sql_script(&err, &db, "SELECT * FROM t1 ORDER BY a;");
+ i1++;
+ if( err.rc ) i2++;
+ clear_error(&err, SQLITE_LOCKED);
+ clear_error(&err, SQLITE_ERROR);
+ }
+ closedb(&err, &db);
+ print_and_free_err(&err);
+ return sqlite3_mprintf("read t1 %d/%d attempts", i2, i1);
+}
+
+/*
+** Thread 5. Attempt INSERT statements.
+*/
+static char *stress_thread_4(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ int i1 = 0;
+ int i2 = 0;
+ int iArg = PTR2INT(pArg);
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ if( iArg ){
+ closedb(&err, &db);
+ opendb(&err, &db, "test.db", 0);
+ }
+ sql_script(&err, &db,
+ "WITH loop(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM loop LIMIT 200) "
+ "INSERT INTO t1 VALUES(randomblob(60), randomblob(60));"
+ );
+ i1++;
+ if( err.rc ) i2++;
+ clear_error(&err, SQLITE_LOCKED);
+ clear_error(&err, SQLITE_ERROR);
+ }
+ closedb(&err, &db);
+ print_and_free_err(&err);
+ return sqlite3_mprintf("wrote t1 %d/%d attempts", i2, i1);
+}
+
+/*
+** Thread 6. Attempt DELETE operations.
+*/
+static char *stress_thread_5(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ int iArg = PTR2INT(pArg);
+
+ int i1 = 0;
+ int i2 = 0;
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ i64 i = (i1 % 4);
+ if( iArg ){
+ closedb(&err, &db);
+ opendb(&err, &db, "test.db", 0);
+ }
+ execsql(&err, &db, "DELETE FROM t1 WHERE (rowid % 4)==:i", &i);
+ i1++;
+ if( err.rc ) i2++;
+ clear_error(&err, SQLITE_LOCKED);
+ }
+ closedb(&err, &db);
+ print_and_free_err(&err);
+ return sqlite3_mprintf("deleted from t1 %d/%d attempts", i2, i1);
+}
+
+
+static void stress1(int nMs){
+ Error err = {0};
+ Threadset threads = {0};
+
+ setstoptime(&err, nMs);
+ sqlite3_enable_shared_cache(1);
+
+ launch_thread(&err, &threads, stress_thread_1, 0);
+ launch_thread(&err, &threads, stress_thread_1, 0);
+
+ launch_thread(&err, &threads, stress_thread_2, 0);
+ launch_thread(&err, &threads, stress_thread_2, 0);
+
+ launch_thread(&err, &threads, stress_thread_3, 0);
+ launch_thread(&err, &threads, stress_thread_3, 0);
+
+ launch_thread(&err, &threads, stress_thread_4, 0);
+ launch_thread(&err, &threads, stress_thread_4, 0);
+
+ launch_thread(&err, &threads, stress_thread_5, 0);
+ launch_thread(&err, &threads, stress_thread_5, (void*)1);
+
+ join_all_threads(&err, &threads);
+ sqlite3_enable_shared_cache(0);
+
+ print_and_free_err(&err);
+}
+
+/**************************************************************************
+***************************************************************************
+** Start of test case "stress2"
+*/
+
+
+
+/*
+** 1. CREATE TABLE statements.
+** 2. DROP TABLE statements.
+** 3. Small SELECT statements.
+** 4. Big SELECT statements.
+** 5. Small INSERT statements.
+** 6. Big INSERT statements.
+** 7. Small UPDATE statements.
+** 8. Big UPDATE statements.
+** 9. Small DELETE statements.
+** 10. Big DELETE statements.
+** 11. VACUUM.
+** 14. Integrity-check.
+** 17. Switch the journal mode from delete to wal and back again.
+** 19. Open and close database connections rapidly.
+*/
+
+#define STRESS2_TABCNT 5 /* count1 in SDS test */
+
+#define STRESS2_COUNT2 200 /* count2 in SDS test */
+#define STRESS2_COUNT3 57 /* count2 in SDS test */
+
+static void stress2_workload1(Error *pErr, Sqlite *pDb, int i){
+ int iTab = (i % (STRESS2_TABCNT-1)) + 1;
+ sql_script_printf(pErr, pDb,
+ "CREATE TABLE IF NOT EXISTS t%d(x PRIMARY KEY, y, z);", iTab
+ );
+}
+
+static void stress2_workload2(Error *pErr, Sqlite *pDb, int i){
+ int iTab = (i % (STRESS2_TABCNT-1)) + 1;
+ sql_script_printf(pErr, pDb, "DROP TABLE IF EXISTS t%d;", iTab);
+}
+
+static void stress2_workload3(Error *pErr, Sqlite *pDb, int i){
+ sql_script(pErr, pDb, "SELECT * FROM t0 WHERE z = 'small'");
+}
+
+static void stress2_workload4(Error *pErr, Sqlite *pDb, int i){
+ sql_script(pErr, pDb, "SELECT * FROM t0 WHERE z = 'big'");
+}
+
+static void stress2_workload5(Error *pErr, Sqlite *pDb, int i){
+ sql_script(pErr, pDb,
+ "INSERT INTO t0 VALUES(hex(random()), hex(randomblob(200)), 'small');"
+ );
+}
+
+static void stress2_workload6(Error *pErr, Sqlite *pDb, int i){
+ sql_script(pErr, pDb,
+ "INSERT INTO t0 VALUES(hex(random()), hex(randomblob(57)), 'big');"
+ );
+}
+
+static void stress2_workload7(Error *pErr, Sqlite *pDb, int i){
+ sql_script_printf(pErr, pDb,
+ "UPDATE t0 SET y = hex(randomblob(200)) "
+ "WHERE x LIKE hex((%d %% 5)) AND z='small';"
+ ,i
+ );
+}
+static void stress2_workload8(Error *pErr, Sqlite *pDb, int i){
+ sql_script_printf(pErr, pDb,
+ "UPDATE t0 SET y = hex(randomblob(57)) "
+ "WHERE x LIKE hex(%d %% 5) AND z='big';"
+ ,i
+ );
+}
+
+static void stress2_workload9(Error *pErr, Sqlite *pDb, int i){
+ sql_script_printf(pErr, pDb,
+ "DELETE FROM t0 WHERE x LIKE hex(%d %% 5) AND z='small';", i
+ );
+}
+static void stress2_workload10(Error *pErr, Sqlite *pDb, int i){
+ sql_script_printf(pErr, pDb,
+ "DELETE FROM t0 WHERE x LIKE hex(%d %% 5) AND z='big';", i
+ );
+}
+
+static void stress2_workload11(Error *pErr, Sqlite *pDb, int i){
+ sql_script(pErr, pDb, "VACUUM");
+}
+
+static void stress2_workload14(Error *pErr, Sqlite *pDb, int i){
+ sql_script(pErr, pDb, "PRAGMA integrity_check");
+}
+
+static void stress2_workload17(Error *pErr, Sqlite *pDb, int i){
+ sql_script_printf(pErr, pDb,
+ "PRAGMA journal_mode = %q", (i%2) ? "delete" : "wal"
+ );
+}
+
+static char *stress2_workload19(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ const char *zDb = (const char*)pArg;
+ while( !timetostop(&err) ){
+ opendb(&err, &db, zDb, 0);
+ sql_script(&err, &db, "SELECT * FROM sqlite_schema;");
+ clear_error(&err, SQLITE_LOCKED);
+ closedb(&err, &db);
+ }
+ print_and_free_err(&err);
+ return sqlite3_mprintf("ok");
+}
+
+
+typedef struct Stress2Ctx Stress2Ctx;
+struct Stress2Ctx {
+ const char *zDb;
+ void (*xProc)(Error*, Sqlite*, int);
+};
+
+static char *stress2_thread_wrapper(int iTid, void *pArg){
+ Stress2Ctx *pCtx = (Stress2Ctx*)pArg;
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ int i1 = 0;
+ int i2 = 0;
+
+ while( !timetostop(&err) ){
+ int cnt;
+ opendb(&err, &db, pCtx->zDb, 0);
+ for(cnt=0; err.rc==SQLITE_OK && cnt<STRESS2_TABCNT; cnt++){
+ pCtx->xProc(&err, &db, i1);
+ i2 += (err.rc==SQLITE_OK);
+ clear_error(&err, SQLITE_LOCKED);
+ i1++;
+ }
+ closedb(&err, &db);
+ }
+
+ print_and_free_err(&err);
+ return sqlite3_mprintf("ok %d/%d", i2, i1);
+}
+
+static void stress2_launch_thread_loop(
+ Error *pErr, /* IN/OUT: Error code */
+ Threadset *pThreads, /* Thread set */
+ const char *zDb, /* Database name */
+ void (*x)(Error*,Sqlite*,int) /* Run this until error or timeout */
+){
+ Stress2Ctx *pCtx = sqlite3_malloc(sizeof(Stress2Ctx));
+ pCtx->zDb = zDb;
+ pCtx->xProc = x;
+ launch_thread(pErr, pThreads, stress2_thread_wrapper, (void*)pCtx);
+}
+
+static void stress2(int nMs){
+ struct Stress2Task {
+ void (*x)(Error*,Sqlite*,int);
+ } aTask[] = {
+ { stress2_workload1 },
+ { stress2_workload2 },
+ { stress2_workload3 },
+ { stress2_workload4 },
+ { stress2_workload5 },
+ { stress2_workload6 },
+ { stress2_workload7 },
+ { stress2_workload8 },
+ { stress2_workload9 },
+ { stress2_workload10 },
+ { stress2_workload11 },
+ { stress2_workload14 },
+ { stress2_workload17 },
+ };
+ const char *zDb = "test.db";
+
+ int i;
+ Error err = {0};
+ Sqlite db = {0};
+ Threadset threads = {0};
+
+ /* To make sure the db file is empty before commencing */
+ opendb(&err, &db, zDb, 1);
+ sql_script(&err, &db,
+ "CREATE TABLE IF NOT EXISTS t0(x PRIMARY KEY, y, z);"
+ "CREATE INDEX IF NOT EXISTS i0 ON t0(y);"
+ );
+ closedb(&err, &db);
+
+ setstoptime(&err, nMs);
+ sqlite3_enable_shared_cache(1);
+
+ for(i=0; i<sizeof(aTask)/sizeof(aTask[0]); i++){
+ stress2_launch_thread_loop(&err, &threads, zDb, aTask[i].x);
+ }
+ launch_thread(&err, &threads, stress2_workload19, (void*)zDb);
+ launch_thread(&err, &threads, stress2_workload19, (void*)zDb);
+
+ join_all_threads(&err, &threads);
+ sqlite3_enable_shared_cache(0);
+ print_and_free_err(&err);
+}
diff --git a/test/tt3_vacuum.c b/test/tt3_vacuum.c
new file mode 100644
index 0000000..c41a6b4
--- /dev/null
+++ b/test/tt3_vacuum.c
@@ -0,0 +1,90 @@
+/*
+** 2014 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 contains multi-threaded tests that use shared-cache and
+** the VACUUM command.
+**
+** Tests:
+**
+** vacuum1
+**
+*/
+
+
+static char *vacuum1_thread_writer(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ i64 i = 0;
+
+ opendb(&err, &db, "test.db", 0);
+ while( !timetostop(&err) ){
+ i++;
+
+ /* Insert lots of rows. Then delete some. */
+ execsql(&err, &db,
+ "WITH loop(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM loop WHERE i<100) "
+ "INSERT INTO t1 SELECT randomblob(50), randomblob(2500) FROM loop"
+ );
+
+ /* Delete lots of rows */
+ execsql(&err, &db, "DELETE FROM t1 WHERE rowid = :i", &i);
+ clear_error(&err, SQLITE_LOCKED);
+
+ /* Select the rows */
+ execsql(&err, &db, "SELECT * FROM t1 ORDER BY x");
+ clear_error(&err, SQLITE_LOCKED);
+ }
+
+ closedb(&err, &db);
+ print_and_free_err(&err);
+ return sqlite3_mprintf("ok");
+}
+
+static char *vacuum1_thread_vacuumer(int iTid, void *pArg){
+ Error err = {0}; /* Error code and message */
+ Sqlite db = {0}; /* SQLite database connection */
+ opendb(&err, &db, "test.db", 0);
+
+ do{
+ sql_script(&err, &db, "VACUUM");
+ clear_error(&err, SQLITE_LOCKED);
+ }while( !timetostop(&err) );
+
+ closedb(&err, &db);
+ print_and_free_err(&err);
+ return sqlite3_mprintf("ok");
+}
+
+static void vacuum1(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 PRIMARY KEY, y BLOB);"
+ "CREATE INDEX i1 ON t1(y);"
+ );
+ closedb(&err, &db);
+
+ setstoptime(&err, nMs);
+
+ sqlite3_enable_shared_cache(1);
+ launch_thread(&err, &threads, vacuum1_thread_writer, 0);
+ launch_thread(&err, &threads, vacuum1_thread_writer, 0);
+ launch_thread(&err, &threads, vacuum1_thread_writer, 0);
+ launch_thread(&err, &threads, vacuum1_thread_vacuumer, 0);
+ join_all_threads(&err, &threads);
+ sqlite3_enable_shared_cache(0);
+
+ 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..d6d84e6
--- /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)} {}
+ 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/unionall.test b/test/unionall.test
new file mode 100644
index 0000000..7783c04
--- /dev/null
+++ b/test/unionall.test
@@ -0,0 +1,444 @@
+# 2020-12-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 flattening UNION ALL sub-queries.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix unionall
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1_a(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE TABLE t1_b(c INTEGER PRIMARY KEY, d TEXT);
+ CREATE TABLE t1_c(e INTEGER PRIMARY KEY, f TEXT);
+
+ INSERT INTO t1_a VALUES(1, 'one'), (4, 'four');
+ INSERT INTO t1_b VALUES(2, 'two'), (5, 'five');
+ INSERT INTO t1_c VALUES(3, 'three'), (6, 'six');
+
+ CREATE VIEW t1 AS
+ SELECT a, b FROM t1_a UNION ALL
+ SELECT c, d FROM t1_b UNION ALL
+ SELECT e, f FROM t1_c;
+
+ CREATE TABLE i1(x);
+ INSERT INTO i1 VALUES(2), (5), (6), (1);
+}
+
+do_execsql_test 1.1 {
+ SELECT a, b FROM (
+ SELECT a, b FROM t1_a UNION ALL
+ SELECT c, d FROM t1_b UNION ALL
+ SELECT e, f FROM t1_c
+ ) ORDER BY a
+} {
+ 1 one 2 two 3 three 4 four 5 five 6 six
+}
+
+do_execsql_test 1.2 {
+ SELECT a, b FROM t1 ORDER BY a
+} {
+ 1 one 2 two 3 three 4 four 5 five 6 six
+}
+
+do_execsql_test 1.3 {
+ SELECT a, b FROM i1, t1 WHERE a=x ORDER BY a
+} {1 one 2 two 5 five 6 six}
+
+
+# 2022-10-31 part of ticket 57c47526c34f01e8
+# The queries below were causing an assertion fault in
+# the comparison operators of the VDBE.
+#
+reset_db
+database_never_corrupt
+optimization_control db all 0
+do_execsql_test 1.10 {
+ CREATE TABLE t0(c0 INT);
+ INSERT INTO t0 VALUES(0);
+ CREATE TABLE t1_a(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t1_a VALUES(1,'one');
+ CREATE TABLE t1_b(c INTEGER PRIMARY KEY, d TEXT);
+ INSERT INTO t1_b VALUES(2,'two');
+ CREATE VIEW t1 AS SELECT a, b FROM t1_a UNION ALL SELECT c, c FROM t1_b;
+ SELECT * FROM (SELECT t1.a, t1.b AS b, t0.c0 FROM t0, t1);
+} {1 one 0 2 2 0}
+do_execsql_test 1.11 {
+ SELECT * FROM (SELECT t1.a, t1.b AS b, t0.c0 FROM t0, t1) WHERE b=2;
+} {2 2 0}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 2.1.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(1, 'ONE');
+ INSERT INTO t1 VALUES(2, 'two');
+ INSERT INTO t1 VALUES(2, 'TWO');
+ INSERT INTO t1 VALUES(3, 'three');
+ INSERT INTO t1 VALUES(3, 'THREE');
+}
+
+do_execsql_test 2.1.1 {
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<3
+ )
+ SELECT * FROM (
+ SELECT 0 AS i UNION ALL SELECT i FROM s UNION ALL SELECT 0
+ ), t1 WHERE x=i;
+} {
+ 1 1 one 1 1 ONE 2 2 two 2 2 TWO 3 3 three 3 3 THREE
+}
+
+do_catchsql_test 2.1.2 {
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<3 UNION ALL SELECT 4
+ )
+ SELECT * FROM s, t1 WHERE x=i;
+} {1 {circular reference: s}}
+
+do_execsql_test 2.2.0 {
+ CREATE TABLE t2_a(k INTEGER PRIMARY KEY, v TEXT);
+ CREATE TABLE t2_b(k INTEGER PRIMARY KEY, v TEXT);
+
+ CREATE VIEW t2 AS
+ SELECT * FROM t2_a
+ UNION ALL
+ SELECT * FROM t2_b;
+
+ CREATE TRIGGER t2_insert INSTEAD OF INSERT ON t2 BEGIN
+ INSERT INTO t2_a SELECT new.k, new.v WHERE (new.k%2)==0;
+ INSERT INTO t2_b SELECT new.k, new.v WHERE (new.k%2)==1;
+ END;
+
+ INSERT INTO t2 VALUES(5, 'v'), (4, 'iv'), (3, 'iii'), (2, 'ii');
+}
+
+do_execsql_test 2.2.1 {
+ SELECT * FROM t1, t2 WHERE x=k;
+} {
+ 2 two 2 ii 2 TWO 2 ii 3 three 3 iii 3 THREE 3 iii
+}
+
+do_execsql_test 2.2.2 {
+ SELECT * FROM t1 LEFT JOIN t2 ON (x=k);
+} {
+ 1 one {} {}
+ 1 ONE {} {}
+ 2 two 2 ii 2 TWO 2 ii 3 three 3 iii 3 THREE 3 iii
+}
+
+do_execsql_test 2.2.3 {
+ SELECT x1.*, x2.* FROM t2 AS x1, t2 AS x2 WHERE x1.k=x2.k+1
+} {
+ 4 iv 3 iii
+ 3 iii 2 ii
+ 5 v 4 iv
+}
+
+do_execsql_test 2.2.4 {
+ SELECT * FROM t1, t2 WHERE x=k ORDER BY y;
+} {
+ 3 THREE 3 iii
+ 2 TWO 2 ii
+ 3 three 3 iii
+ 2 two 2 ii
+}
+do_execsql_test 2.2.5 {
+ SELECT * FROM t1, t2 WHERE x=k ORDER BY y||'';
+} {
+ 3 THREE 3 iii
+ 2 TWO 2 ii
+ 3 three 3 iii
+ 2 two 2 ii
+}
+do_execsql_test 2.2.6 {
+ SELECT * FROM t1, t2 WHERE x=k ORDER BY v
+} {
+ 2 two 2 ii
+ 2 TWO 2 ii
+ 3 three 3 iii
+ 3 THREE 3 iii
+}
+do_execsql_test 2.2.7 {
+ SELECT * FROM t1, t2 WHERE x=k ORDER BY v||''
+} {
+ 2 two 2 ii
+ 2 TWO 2 ii
+ 3 three 3 iii
+ 3 THREE 3 iii
+}
+do_execsql_test 2.2.8 {
+ SELECT * FROM t1, t2 WHERE x=k ORDER BY k,v||''
+} {
+ 2 two 2 ii
+ 2 TWO 2 ii
+ 3 three 3 iii
+ 3 THREE 3 iii
+}
+do_execsql_test 2.2.9a {
+ SELECT * FROM t1, t2 ORDER BY +k
+} {
+ 1 one 2 ii 1 ONE 2 ii 2 two 2 ii
+ 2 TWO 2 ii 3 three 2 ii 3 THREE 2 ii
+
+ 1 one 3 iii 1 ONE 3 iii 2 two 3 iii
+ 2 TWO 3 iii 3 three 3 iii 3 THREE 3 iii
+
+ 1 one 4 iv 1 ONE 4 iv 2 two 4 iv
+ 2 TWO 4 iv 3 three 4 iv 3 THREE 4 iv
+
+ 1 one 5 v 1 ONE 5 v 2 two 5 v
+ 2 TWO 5 v 3 three 5 v 3 THREE 5 v
+}
+
+do_execsql_test 2.2.9b {
+ SELECT * FROM t1, t2 ORDER BY k
+} {
+ 1 one 2 ii 1 ONE 2 ii 2 two 2 ii
+ 2 TWO 2 ii 3 three 2 ii 3 THREE 2 ii
+
+ 1 one 3 iii 1 ONE 3 iii 2 two 3 iii
+ 2 TWO 3 iii 3 three 3 iii 3 THREE 3 iii
+
+ 1 one 4 iv 1 ONE 4 iv 2 two 4 iv
+ 2 TWO 4 iv 3 three 4 iv 3 THREE 4 iv
+
+ 1 one 5 v 1 ONE 5 v 2 two 5 v
+ 2 TWO 5 v 3 three 5 v 3 THREE 5 v
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(c INTEGER PRIMARY KEY, d TEXT);
+ INSERT INTO t1 VALUES(1,2);
+ CREATE TABLE t3_a(k INTEGER PRIMARY KEY, v TEXT);
+ INSERT INTO t3_a VALUES(2,'ii');
+ CREATE TABLE t3_b(k INTEGER PRIMARY KEY, v TEXT);
+ CREATE VIEW t3 AS
+ SELECT * FROM t3_a
+ UNION ALL
+ SELECT * FROM t3_b;
+} {}
+
+do_execsql_test 3.1 {
+ SELECT * FROM t1, t3 ORDER BY k;
+} {1 2 2 ii}
+
+reset_db
+do_execsql_test 4.0 {
+
+ CREATE TABLE t1_a(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t1_a VALUES(123, 't1_a');
+ CREATE TABLE t1_b(c INTEGER PRIMARY KEY, d TEXT);
+
+ CREATE VIEW t1 AS
+ SELECT a, b FROM t1_a
+ UNION ALL
+ SELECT c, d FROM t1_b;
+
+ CREATE TABLE t3_a(k INTEGER PRIMARY KEY, v TEXT);
+ INSERT INTO t3_a VALUES(456, 't3_a');
+ CREATE TABLE t3_b(k INTEGER PRIMARY KEY, v TEXT);
+
+ CREATE VIEW t3 AS
+ SELECT * FROM t3_a
+ UNION ALL
+ SELECT * FROM t3_b;
+}
+
+do_execsql_test 4.1 {
+ SELECT * FROM t1, t3 ORDER BY k;
+} {123 t1_a 456 t3_a}
+
+do_execsql_test 4.2 {
+ SELECT * FROM (SELECT * FROM t1, t3) ORDER BY k;
+} {123 t1_a 456 t3_a}
+
+do_execsql_test 4.3 {
+ SELECT * FROM (SELECT * FROM t1, t3), (
+ SELECT max(a) OVER () FROM t1
+ UNION ALL
+ SELECT min(a) OVER () FROM t1
+ )
+ ORDER BY k;
+} {
+ 123 t1_a 456 t3_a 123
+ 123 t1_a 456 t3_a 123
+}
+
+do_execsql_test 4.3 {
+ SELECT * FROM (SELECT * FROM t1, t3), (
+ SELECT group_concat(a) OVER (ORDER BY a),
+ group_concat(a) OVER (ORDER BY a),
+ group_concat(a) OVER (ORDER BY a),
+ group_concat(a) OVER (ORDER BY a),
+ group_concat(a) OVER (ORDER BY a),
+ group_concat(a) OVER (ORDER BY a),
+ group_concat(a) OVER (ORDER BY a),
+ group_concat(a) OVER (ORDER BY a),
+ group_concat(a) OVER (ORDER BY a)
+ FROM t1
+ )
+ ORDER BY k;
+} {
+ 123 t1_a 456 t3_a 123 123 123 123 123 123 123 123 123
+}
+
+do_execsql_test 4.3 {
+ SELECT * FROM (SELECT * FROM t1, t3) AS o, (
+ SELECT * FROM t1 LEFT JOIN t3 ON a=k
+ );
+} {
+ 123 t1_a 456 t3_a 123 t1_a {} {}
+}
+
+# 2020-12-30: dbsqlfuzz find
+reset_db
+do_execsql_test 5.1 {
+ CREATE TABLE t1_a(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t1_a VALUES(1,'one');
+ INSERT INTO t1_a VALUES(0,NULL);
+ CREATE TABLE t1_b(c INTEGER PRIMARY KEY, d TEXT);
+ INSERT INTO t1_b VALUES(2,'two');
+ INSERT INTO t1_b VALUES(5,'five');
+ CREATE TABLE t1_c(e INTEGER PRIMARY KEY, f TEXT);
+ INSERT INTO t1_c VALUES(3,'three');
+ INSERT INTO t1_c VALUES(6,'six');
+ CREATE TABLE t2(k,v);
+ INSERT INTO t2 VALUES(5,'v');
+ INSERT INTO t2 VALUES(4,'iv');
+ INSERT INTO t2 VALUES(3,'iii');
+ INSERT INTO t2 VALUES(2,'ii');
+ CREATE TABLE t3_a(k INTEGER PRIMARY KEY, v TEXT);
+ INSERT INTO t3_a VALUES(2,'ii');
+ INSERT INTO t3_a VALUES(4,'iv');
+ CREATE TABLE t3_b(k INTEG5R PRIMARY KEY, v TEXT);
+ INSERT INTO t3_b VALUES(NULL,'iii');
+ INSERT INTO t3_b VALUES(NULL,'v');
+ CREATE VIEW t1 AS
+ SELECT a, b FROM t1_a UNION ALL
+ SELECT c, d FROM t1_b UNION ALL
+ SELECT e, f FROM t1_c;
+ CREATE VIEW t3 AS
+ SELECT * FROM t3_a
+ UNION ALL
+ SELECT * FROM t3_b;
+ CREATE TRIGGER t3_insert INSTEAD OF INSERT ON t3 BEGIN
+ INSERT INTO t3_a SELECT new.k, new.v WHERE (new.k%2)==0;
+ INSERT INTO t3_b SELECT new.k, new.v WHERE (new.k%2)==1;
+ END;
+} {}
+do_execsql_test 5.10 {
+ SELECT *, '+' FROM t1 LEFT JOIN t2 ON (a NOT IN(SELECT v FROM t1, t3 WHERE a=k)=NOT EXISTS(SELECT 1 FROM t1 LEFT JOIN t3 ON (a=k)));
+} {0 {} {} {} + 1 one {} {} + 2 two {} {} + 5 five {} {} + 3 three {} {} + 6 six {} {} +}
+do_execsql_test 5.20 {
+ SELECT *, '+' FROM t1 LEFT JOIN t3 ON (a NOT IN(SELECT v FROM t1 LEFT JOIN t2 ON (a=k))=k);
+} {0 {} {} {} + 1 one {} {} + 2 two {} {} + 5 five {} {} + 3 three {} {} + 6 six {} {} +}
+
+reset_db
+do_execsql_test 6.0 {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ CREATE TABLE t2(a,b);
+ INSERT INTO t2 VALUES(3,4);
+
+ CREATE TABLE t3(a,b);
+ INSERT INTO t3 VALUES(5,6);
+ CREATE TABLE t4(a,b);
+ INSERT INTO t4 VALUES(7,8);
+
+ CREATE TABLE t5(a,b);
+ INSERT INTO t5 VALUES(9,10);
+}
+
+do_execsql_test 6.1 {
+ WITH x(c) AS (
+ SELECT 1000 FROM t1 UNION ALL SELECT 800 FROM t2
+ ),
+ y(d) AS (
+ SELECT 100 FROM t3 UNION ALL SELECT 400 FROM t4
+ )
+ SELECT * FROM t5, x, y;
+} {
+ 9 10 1000 100 9 10 1000 400
+ 9 10 800 100 9 10 800 400
+}
+
+# 2021-04-26 dbsqlfuzz 88ed5c66789fced139d148aed823cba7c0926dd7
+reset_db
+do_execsql_test 7.1 {
+ WITH c1(x) AS (VALUES(0) UNION ALL SELECT 100+x FROM c1 WHERE x<100 UNION ALL SELECT 1+x FROM c1 WHERE x<1)
+ SELECT x, y, '|'
+ FROM c1 AS x1, (SELECT x+1 AS y FROM c1 WHERE x<1 UNION ALL SELECT 1+x FROM c1 WHERE 1<x) AS x2
+ ORDER BY x, y;
+} {0 1 | 0 101 | 0 102 | 1 1 | 1 101 | 1 102 | 100 1 | 100 101 | 100 102 | 101 1 | 101 101 | 101 102 |}
+
+# 2022-10-31 ticket https://sqlite.org/src/info/57c47526c34f01e8
+# dbsqlfuzz 37230460b46b3b6049f0d768eb801f3428189382
+# UNION ALL subqueries or views which have arms with different
+# affinities should not be flattened.
+#
+reset_db
+do_execsql_test 8.1 {
+ CREATE TABLE t0(c0 INT);
+ INSERT INTO t0 VALUES(0);
+ CREATE TABLE t1_a(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t1_a VALUES(1,'one');
+ INSERT INTO t1_a VALUES(4,'four');
+ CREATE TABLE t1_b(c INTEGER PRIMARY KEY, d TEXT);
+ INSERT INTO t1_b VALUES(2,'two');
+ INSERT INTO t1_b VALUES(5,'five');
+ CREATE TABLE t1_c(e INTEGER PRIMARY KEY, f TEXT);
+ INSERT INTO t1_c VALUES(3,'three');
+ INSERT INTO t1_c VALUES(6,'six');
+ CREATE VIEW v0(c0) AS SELECT CAST(t0.c0 AS INTEGER) FROM t0;
+ CREATE VIEW t1 AS
+ SELECT a, b FROM t1_a UNION ALL
+ SELECT c, c FROM t1_b UNION ALL
+ SELECT e, f FROM t1_c;
+}
+optimization_control db all 1
+do_execsql_test 8.2 {
+ SELECT * FROM (SELECT t1.a, t1.b, t0.c0 AS c, v0.c0 AS d FROM t0 LEFT JOIN v0 ON v0.c0>'0',t1) WHERE b=2;
+} {2 2 0 {}}
+do_execsql_test 8.3 {
+ SELECT * FROM (SELECT t1.a, t1.b, t0.c0 AS c, v0.c0 AS d FROM t0 LEFT JOIN v0 ON v0.c0>'0',t1) WHERE b=2.0;
+} {}
+do_execsql_test 8.4 {
+ SELECT * FROM (SELECT t1.a, t1.b, t0.c0 AS c, v0.c0 AS d FROM t0 LEFT JOIN v0 ON v0.c0>'0',t1) WHERE b='2';
+} {2 2 0 {}}
+optimization_control db query-flattener,push-down 0
+do_execsql_test 8.5 {
+ SELECT * FROM (SELECT t1.a, t1.b, t0.c0 AS c, v0.c0 AS d FROM t0 LEFT JOIN v0 ON v0.c0>'0',t1) WHERE b=2;
+} {2 2 0 {}}
+do_execsql_test 8.6 {
+ SELECT * FROM (SELECT t1.a, t1.b, t0.c0 AS c, v0.c0 AS d FROM t0 LEFT JOIN v0 ON v0.c0>'0',t1) WHERE b=2.0;
+} {}
+do_execsql_test 8.7 {
+ SELECT * FROM (SELECT t1.a, t1.b, t0.c0 AS c, v0.c0 AS d FROM t0 LEFT JOIN v0 ON v0.c0>'0',t1) WHERE b='2';
+} {2 2 0 {}}
+optimization_control db all 0
+do_execsql_test 8.8 {
+ SELECT * FROM (SELECT t1.a, t1.b, t0.c0 AS c, v0.c0 AS d FROM t0 LEFT JOIN v0 ON v0.c0>'0',t1) WHERE b=2;
+} {2 2 0 {}}
+do_execsql_test 8.9 {
+ SELECT * FROM (SELECT t1.a, t1.b, t0.c0 AS c, v0.c0 AS d FROM t0 LEFT JOIN v0 ON v0.c0>'0',t1) WHERE b=2.0;
+} {}
+do_execsql_test 8.10 {
+ SELECT * FROM (SELECT t1.a, t1.b, t0.c0 AS c, v0.c0 AS d FROM t0 LEFT JOIN v0 ON v0.c0>'0',t1) WHERE b='2';
+} {2 2 0 {}}
+
+
+finish_test
diff --git a/test/unionall2.test b/test/unionall2.test
new file mode 100644
index 0000000..5f095e4
--- /dev/null
+++ b/test/unionall2.test
@@ -0,0 +1,58 @@
+# 2020-12-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 flattening UNION ALL sub-queries.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix unionall2
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+
+ CREATE VIEW v1 AS SELECT * FROM t1, t2;
+ CREATE VIEW v2 AS SELECT * FROM t1, t2;
+
+ CREATE VIEW vA AS
+ SELECT * FROM v1, (
+ SELECT * FROM t1 LEFT JOIN t2 ON (a=c)
+ )
+ UNION ALL
+ SELECT * FROM v1, v2
+}
+
+do_execsql_test 1.1 {
+ SELECT 1 FROM vA, vA, vA, vA, vA, vA, vA, vA, vA, vA
+}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 2.1 {
+ CREATE TABLE y1(a INTEGER, b);
+ CREATE TABLE y2(c INTEGER, d);
+
+ CREATE TABLE x3_a(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE TABLE x3_b(c INTEGER PRIMARY KEY, d TEXT);
+}
+
+do_execsql_test 2.2 {
+
+ SELECT * FROM y1 CROSS JOIN y2 WHERE y1.a=y2.c AND y2.c IN (
+ SELECT a FROM x3_a UNION ALL
+ SELECT c FROM x3_b ORDER BY 1
+ )
+}
+
+
+
+finish_test
diff --git a/test/unionallfault.test b/test/unionallfault.test
new file mode 100644
index 0000000..c78abe5
--- /dev/null
+++ b/test/unionallfault.test
@@ -0,0 +1,36 @@
+# 2020-12-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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix unionallfault
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x,y,z);
+ CREATE TABLE t3(x,y,z);
+}
+faultsim_save_and_close
+
+
+do_faultsim_test 1 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT * FROM t1, (
+ SELECT x FROM t1 UNION ALL SELECT y FROM t1
+ ), t3
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/unionvtab.test b/test/unionvtab.test
new file mode 100644
index 0000000..ac5ecb7
--- /dev/null
+++ b/test/unionvtab.test
@@ -0,0 +1,457 @@
+# 2017-07-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 percentile.c extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix unionvtab
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+load_static_extension db unionvtab
+
+#-------------------------------------------------------------------------
+# Warm body tests.
+#
+forcedelete test.db2
+do_execsql_test 1.0 {
+ ATTACH 'test.db2' AS aux;
+
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b TEXT);
+
+
+ INSERT INTO t1 VALUES(1, 'one'), (2, 'two'), (3, 'three');
+ INSERT INTO t2 VALUES(10, 'ten'), (11, 'eleven'), (12, 'twelve');
+ INSERT INTO t3 VALUES(20, 'twenty'), (21, 'twenty-one'), (22, 'twenty-two');
+}
+
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE temp.uuu USING unionvtab(
+ "VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)"
+ );
+ SELECT * FROM uuu;
+} {
+ 1 one 2 two 3 three
+ 10 ten 11 eleven 12 twelve
+ 20 twenty 21 twenty-one 22 twenty-two
+}
+
+do_execsql_test 1.2 {
+ PRAGMA table_info(uuu);
+} {
+ 0 a INTEGER 0 {} 0
+ 1 b TEXT 0 {} 0
+}
+
+do_execsql_test 1.3 {
+ SELECT * FROM uuu WHERE rowid = 3;
+ SELECT * FROM uuu WHERE rowid = 11;
+} {3 three 11 eleven}
+
+do_execsql_test 1.4 {
+ SELECT * FROM uuu WHERE rowid IN (12, 10, 2);
+} {2 two 10 ten 12 twelve}
+
+do_execsql_test 1.5 {
+ SELECT * FROM uuu WHERE rowid BETWEEN 3 AND 11;
+} {3 three 10 ten 11 eleven}
+
+do_execsql_test 1.6 {
+ SELECT * FROM uuu WHERE rowid BETWEEN 11 AND 15;
+} {11 eleven 12 twelve}
+
+do_execsql_test 1.7 {
+ SELECT * FROM uuu WHERE rowid BETWEEN -46 AND 1500;
+} {
+ 1 one 2 two 3 three
+ 10 ten 11 eleven 12 twelve
+ 20 twenty 21 twenty-one 22 twenty-two
+}
+
+do_execsql_test 1.8 {
+ CREATE TABLE src(db, tbl, min, max);
+ INSERT INTO src VALUES(NULL, 't1', 1, 9);
+ INSERT INTO src VALUES('main', 't2', 10, 19);
+ INSERT INTO src VALUES('aux', 't3', 20, 29);
+ CREATE VIRTUAL TABLE temp.opp USING unionvtab(src);
+ SELECT * FROM opp;
+} {
+ 1 one 2 two 3 three
+ 10 ten 11 eleven 12 twelve
+ 20 twenty 21 twenty-one 22 twenty-two
+}
+
+do_execsql_test 1.9 {
+ CREATE VIRTUAL TABLE temp.qll USING unionvtab(
+ 'SELECT * FROM src WHERE db!=''xyz'''
+ );
+ SELECT * FROM qll WHERE rowid BETWEEN 10 AND 21;
+} {
+ 10 ten 11 eleven 12 twelve
+ 20 twenty 21 twenty-one
+}
+
+#-------------------------------------------------------------------------
+# Error conditions.
+#
+# 2.1.*: Attempt to create a unionvtab table outside of the TEMP schema.
+# 2.2.*: Tables that do not exist.
+# 2.3.*: Non rowid tables.
+# 2.4.*: Tables with mismatched schemas.
+# 2.5.*: A unionvtab table with zero source tables.
+#
+do_catchsql_test 2.1.1 {
+ CREATE VIRTUAL TABLE u1 USING unionvtab("VALUES(NULL, 't1', 1, 100)");
+} {1 {unionvtab tables must be created in TEMP schema}}
+do_catchsql_test 2.1.2 {
+ CREATE VIRTUAL TABLE main.u1 USING unionvtab("VALUES('', 't1', 1, 100)");
+} {1 {unionvtab tables must be created in TEMP schema}}
+do_catchsql_test 2.1.3 {
+ CREATE VIRTUAL TABLE aux.u1 USING unionvtab("VALUES('', 't1', 1, 100)");
+} {1 {unionvtab tables must be created in TEMP schema}}
+
+do_catchsql_test 2.2.1 {
+ CREATE VIRTUAL TABLE temp.u1 USING unionvtab("VALUES(NULL, 't555', 1, 100)");
+} {1 {no such rowid table: t555}}
+do_catchsql_test 2.2.2 {
+ CREATE VIRTUAL TABLE temp.u1 USING unionvtab("VALUES('aux', 't555', 1, 100)");
+} {1 {no such rowid table: aux.t555}}
+do_catchsql_test 2.2.3 {
+ CREATE VIRTUAL TABLE temp.u1 USING unionvtab("VALUES('xua', 't555', 1, 100)");
+} {1 {no such rowid table: xua.t555}}
+
+do_execsql_test 2.3.0 {
+ CREATE TABLE wr1(a, b, c PRIMARY KEY) WITHOUT ROWID;
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE VIEW v2 AS SELECT _rowid_, * FROM t1;
+
+ CREATE TABLE wr2(a, _rowid_ INTEGER, c PRIMARY KEY) WITHOUT ROWID;
+ CREATE TABLE wr3(a, b, _rowid_ PRIMARY KEY) WITHOUT ROWID;
+}
+do_catchsql_test 2.3.1 {
+ CREATE VIRTUAL TABLE temp.u1 USING unionvtab("VALUES('main', 'wr1', 1, 2)");
+} {1 {no such rowid table: main.wr1}}
+do_catchsql_test 2.3.2 {
+ CREATE VIRTUAL TABLE temp.u1 USING unionvtab("VALUES(NULL, 'v1', 1, 2)");
+} {1 {no such rowid table: v1}}
+do_catchsql_test 2.3.3 {
+ CREATE VIRTUAL TABLE temp.u1 USING unionvtab("VALUES(NULL, 'v2', 1, 2)");
+} {1 {no such rowid table: v2}}
+do_catchsql_test 2.3.4 {
+ CREATE VIRTUAL TABLE temp.u1 USING unionvtab("VALUES(NULL, 'wr2', 1, 2)");
+} {1 {no such rowid table: wr2}}
+do_catchsql_test 2.3.5 {
+ CREATE VIRTUAL TABLE temp.u1 USING unionvtab("VALUES(NULL, 'wr3', 1, 2)");
+} {1 {no such rowid table: wr3}}
+
+do_execsql_test 2.4.0 {
+ CREATE TABLE x1(a BLOB, b);
+ CREATE TABLE x2(a BLOB, b);
+ CREATE TEMP TABLE x3(a BLOB, b);
+
+ CREATE TABLE aux.y1(one, two, three INTEGER PRIMARY KEY);
+ CREATE TEMP TABLE y2(one, two, three INTEGER PRIMARY KEY);
+ CREATE TABLE y3(one, two, three INTEGER PRIMARY KEY);
+}
+
+foreach {tn dbs res} {
+ 1 {x1 x2 x3} {0 {}}
+ 2 {y1 y2 y3} {0 {}}
+ 3 {x1 y2 y3} {1 {source table schema mismatch}}
+ 4 {x1 y2 x3} {1 {source table schema mismatch}}
+ 5 {x1 x2 y3} {1 {source table schema mismatch}}
+} {
+ set L [list]
+ set iMin 0
+ foreach e $dbs {
+ set E [split $e .]
+ if {[llength $E]>1} {
+ lappend L "('[lindex $E 0]', '[lindex $E 1]', $iMin, $iMin)"
+ } else {
+ lappend L "(NULL, '$e', $iMin, $iMin)"
+ }
+ incr iMin
+ }
+
+ set sql "CREATE VIRTUAL TABLE temp.a1 USING unionvtab(\"VALUES [join $L ,]\")"
+ do_catchsql_test 2.4.$tn "
+ DROP TABLE IF EXISTS temp.a1;
+ CREATE VIRTUAL TABLE temp.a1 USING unionvtab(\"VALUES [join $L ,]\");
+ " $res
+}
+
+do_catchsql_test 2.5 {
+ CREATE VIRTUAL TABLE temp.b1 USING unionvtab(
+ [SELECT 'main', 'b1', 0, 100 WHERE 0]
+ )
+} {1 {no source tables configured}}
+
+foreach {tn sql} {
+ 1 { VALUES('main', 't1', 10, 20), ('main', 't2', 30, 29) }
+ 2 { VALUES('main', 't1', 10, 20), ('main', 't2', 15, 30) }
+} {
+ do_catchsql_test 2.6.$tn "
+ CREATE VIRTUAL TABLE temp.a1 USING unionvtab(`$sql`)
+ " {1 {rowid range mismatch error}}
+}
+
+do_catchsql_test 2.7.1 {
+ CREATE VIRTUAL TABLE temp.b1 USING unionvtab(1, 2, 3, 4)
+} {1 {wrong number of arguments for unionvtab}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+load_static_extension db unionvtab
+do_execsql_test 3.0 {
+ CREATE TABLE tbl1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE tbl2(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE tbl3(a INTEGER PRIMARY KEY, b);
+
+ WITH ss(ii) AS ( SELECT 1 UNION ALL SELECT ii+1 FROM ss WHERE ii<100 )
+ INSERT INTO tbl1 SELECT ii, '1.' || ii FROM ss;
+
+ WITH ss(ii) AS ( SELECT 1 UNION ALL SELECT ii+1 FROM ss WHERE ii<100 )
+ INSERT INTO tbl2 SELECT ii, '2.' || ii FROM ss;
+
+ WITH ss(ii) AS ( SELECT 1 UNION ALL SELECT ii+1 FROM ss WHERE ii<100 )
+ INSERT INTO tbl3 SELECT ii, '3.' || ii FROM ss;
+
+ CREATE VIRTUAL TABLE temp.uu USING unionvtab(
+ "VALUES(NULL,'tbl2', 26, 74), (NULL,'tbl3', 75, 100), (NULL,'tbl1', 1, 25)"
+ );
+}
+
+do_execsql_test 3.1 {
+ SELECT * FROM uu WHERE rowid = 10;
+} {10 {1.10}}
+do_execsql_test 3.2 {
+ SELECT * FROM uu WHERE rowid = 25;
+} {25 {1.25}}
+
+do_execsql_test 3.3 { SELECT count(*) FROM uu WHERE rowid <= 24 } {24}
+
+# The following queries get the "wrong" answers. This is because the
+# module assumes that each source table contains rowids from only within
+# the range specified. For example, (rowid <= 25) matches 100 rows. This
+# is because the module implements (rowid <= 25) as a full table scan
+# of tbl1 only.
+do_execsql_test 3.4.1 { SELECT count(*) FROM uu WHERE rowid <= 25 } {100}
+do_execsql_test 3.4.2 { SELECT count(*) FROM uu WHERE rowid <= 26 } {126}
+do_execsql_test 3.4.3 { SELECT count(*) FROM uu WHERE rowid <= 73 } {173}
+do_execsql_test 3.4.4 { SELECT count(*) FROM uu WHERE rowid <= 74 } {200}
+do_execsql_test 3.4.5 { SELECT count(*) FROM uu WHERE rowid <= 75 } {275}
+do_execsql_test 3.4.6 { SELECT count(*) FROM uu WHERE rowid <= 99 } {299}
+do_execsql_test 3.4.7 { SELECT count(*) FROM uu WHERE rowid <= 100 } {300}
+do_execsql_test 3.4.8 { SELECT count(*) FROM uu WHERE rowid <= 101 } {300}
+
+do_execsql_test 3.5.1 { SELECT count(*) FROM uu WHERE rowid < 25 } {24}
+do_execsql_test 3.5.2 { SELECT count(*) FROM uu WHERE rowid < 26 } {100}
+do_execsql_test 3.5.3 { SELECT count(*) FROM uu WHERE rowid < 27 } {126}
+do_execsql_test 3.5.4 { SELECT count(*) FROM uu WHERE rowid < 73 } {172}
+do_execsql_test 3.5.5 { SELECT count(*) FROM uu WHERE rowid < 74 } {173}
+do_execsql_test 3.5.6 { SELECT count(*) FROM uu WHERE rowid < 75 } {200}
+do_execsql_test 3.5.7 { SELECT count(*) FROM uu WHERE rowid < 76 } {275}
+do_execsql_test 3.5.8 { SELECT count(*) FROM uu WHERE rowid < 99 } {298}
+do_execsql_test 3.5.9 { SELECT count(*) FROM uu WHERE rowid < 100 } {299}
+do_execsql_test 3.5.10 { SELECT count(*) FROM uu WHERE rowid < 101 } {300}
+
+do_execsql_test 3.6.1 { SELECT count(*) FROM uu WHERE rowid > 24 } {276}
+do_execsql_test 3.6.1 { SELECT count(*) FROM uu WHERE rowid > 25 } {200}
+do_execsql_test 3.6.2 { SELECT count(*) FROM uu WHERE rowid > 26 } {174}
+do_execsql_test 3.6.3 { SELECT count(*) FROM uu WHERE rowid > 27 } {173}
+do_execsql_test 3.6.4 { SELECT count(*) FROM uu WHERE rowid > 73 } {127}
+do_execsql_test 3.6.5 { SELECT count(*) FROM uu WHERE rowid > 74 } {100}
+do_execsql_test 3.6.6 { SELECT count(*) FROM uu WHERE rowid > 75 } {25}
+do_execsql_test 3.6.7 { SELECT count(*) FROM uu WHERE rowid > 76 } {24}
+do_execsql_test 3.6.8 { SELECT count(*) FROM uu WHERE rowid > 99 } {1}
+do_execsql_test 3.6.9 { SELECT count(*) FROM uu WHERE rowid > 100 } {0}
+do_execsql_test 3.6.10 { SELECT count(*) FROM uu WHERE rowid > 101 } {0}
+
+do_execsql_test 3.7.1 { SELECT count(*) FROM uu WHERE rowid >= 24 } {277}
+do_execsql_test 3.7.1 { SELECT count(*) FROM uu WHERE rowid >= 25 } {276}
+do_execsql_test 3.7.2 { SELECT count(*) FROM uu WHERE rowid >= 26 } {200}
+do_execsql_test 3.7.3 { SELECT count(*) FROM uu WHERE rowid >= 27 } {174}
+do_execsql_test 3.7.4 { SELECT count(*) FROM uu WHERE rowid >= 73 } {128}
+do_execsql_test 3.7.5 { SELECT count(*) FROM uu WHERE rowid >= 74 } {127}
+do_execsql_test 3.7.6 { SELECT count(*) FROM uu WHERE rowid >= 75 } {100}
+do_execsql_test 3.7.7 { SELECT count(*) FROM uu WHERE rowid >= 76 } {25}
+do_execsql_test 3.7.8 { SELECT count(*) FROM uu WHERE rowid >= 99 } {2}
+do_execsql_test 3.7.9 { SELECT count(*) FROM uu WHERE rowid >= 100 } {1}
+do_execsql_test 3.7.10 { SELECT count(*) FROM uu WHERE rowid >= 101 } {0}
+
+set L [expr 9223372036854775807]
+set S [expr -9223372036854775808]
+
+do_execsql_test 3.8.1 { SELECT count(*) FROM uu WHERE rowid >= $S } {300}
+do_execsql_test 3.8.2 { SELECT count(*) FROM uu WHERE rowid > $S } {300}
+do_execsql_test 3.8.3 { SELECT count(*) FROM uu WHERE rowid <= $S } {0}
+do_execsql_test 3.8.4 { SELECT count(*) FROM uu WHERE rowid < $S } {0}
+
+do_execsql_test 3.9.1 { SELECT count(*) FROM uu WHERE rowid >= $L } {0}
+do_execsql_test 3.9.2 { SELECT count(*) FROM uu WHERE rowid > $L } {0}
+do_execsql_test 3.9.3 { SELECT count(*) FROM uu WHERE rowid <= $L } {300}
+do_execsql_test 3.9.4 { SELECT count(*) FROM uu WHERE rowid < $L } {300}
+
+do_execsql_test 3.10.1 { SELECT count(*) FROM uu WHERE a < 25 } {24}
+do_execsql_test 3.10.2 { SELECT count(*) FROM uu WHERE a < 26 } {100}
+do_execsql_test 3.10.3 { SELECT count(*) FROM uu WHERE a < 27 } {126}
+do_execsql_test 3.10.4 { SELECT count(*) FROM uu WHERE a < 73 } {172}
+do_execsql_test 3.10.5 { SELECT count(*) FROM uu WHERE a < 74 } {173}
+do_execsql_test 3.10.6 { SELECT count(*) FROM uu WHERE a < 75 } {200}
+do_execsql_test 3.10.7 { SELECT count(*) FROM uu WHERE a < 76 } {275}
+do_execsql_test 3.10.8 { SELECT count(*) FROM uu WHERE a < 99 } {298}
+do_execsql_test 3.10.9 { SELECT count(*) FROM uu WHERE a < 100 } {299}
+do_execsql_test 3.10.10 { SELECT count(*) FROM uu WHERE a < 101 } {300}
+
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 4.0 {
+ CREATE TABLE s1(k INTEGER PRIMARY KEY, v);
+ INSERT INTO s1 VALUES($S, 'one');
+ INSERT INTO s1 VALUES($S+1, 'two');
+ INSERT INTO s1 VALUES($S+2, 'three');
+
+ CREATE TABLE l1(k INTEGER PRIMARY KEY, v);
+ INSERT INTO l1 VALUES($L, 'six');
+ INSERT INTO l1 VALUES($L-1, 'five');
+ INSERT INTO l1 VALUES($L-2, 'four');
+
+ CREATE VIRTUAL TABLE temp.sl USING unionvtab(
+ "SELECT NULL, 'l1', 0, 9223372036854775807
+ UNION ALL
+ SELECT NULL, 's1', -9223372036854775808, -1"
+ );
+}
+
+do_execsql_test 4.1 {
+ SELECT * FROM sl;
+} {
+ -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three
+ 9223372036854775805 four 9223372036854775806 five 9223372036854775807 six
+}
+
+foreach {k v} {
+ -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three
+ 9223372036854775805 four 9223372036854775806 five 9223372036854775807 six
+} {
+ do_execsql_test 4.2.$v { SELECT * FROM sl WHERE rowid=$k } [list $k $v]
+}
+
+do_execsql_test 4.3.1 {
+ SELECT * FROM sl WHERE rowid>-9223372036854775808
+} {
+ -9223372036854775807 two -9223372036854775806 three
+ 9223372036854775805 four 9223372036854775806 five 9223372036854775807 six
+}
+do_execsql_test 4.3.2 {
+ SELECT * FROM sl WHERE rowid>=-9223372036854775808
+} {
+ -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three
+ 9223372036854775805 four 9223372036854775806 five 9223372036854775807 six
+}
+do_execsql_test 4.3.3 {
+ SELECT * FROM sl WHERE rowid<=-9223372036854775808
+} {
+ -9223372036854775808 one
+}
+do_execsql_test 4.3.4 {
+ SELECT * FROM sl WHERE rowid<-9223372036854775808
+} {}
+
+do_execsql_test 4.4.1 {
+ SELECT * FROM sl WHERE rowid<9223372036854775807
+} {
+ -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three
+ 9223372036854775805 four 9223372036854775806 five
+}
+do_execsql_test 4.4.2 {
+ SELECT * FROM sl WHERE rowid<=9223372036854775807
+} {
+ -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three
+ 9223372036854775805 four 9223372036854775806 five 9223372036854775807 six
+}
+do_execsql_test 4.4.3 {
+ SELECT * FROM sl WHERE rowid>=9223372036854775807
+} {
+ 9223372036854775807 six
+}
+do_execsql_test 4.4.4 {
+ SELECT * FROM sl WHERE rowid>9223372036854775807
+} {}
+
+#-------------------------------------------------------------------------
+# More than 8 source tables.
+#
+do_execsql_test 5.0 {
+ CREATE TABLE c0(one, two INTEGER PRIMARY KEY);
+ CREATE TABLE c1(one, two INTEGER PRIMARY KEY);
+ CREATE TABLE c2(one, two INTEGER PRIMARY KEY);
+ CREATE TABLE c3(one, two INTEGER PRIMARY KEY);
+ CREATE TABLE c4(one, two INTEGER PRIMARY KEY);
+ CREATE TABLE c5(one, two INTEGER PRIMARY KEY);
+ CREATE TABLE c6(one, two INTEGER PRIMARY KEY);
+ CREATE TABLE c7(one, two INTEGER PRIMARY KEY);
+ CREATE TABLE c8(one, two INTEGER PRIMARY KEY);
+ CREATE TABLE c9(one, two INTEGER PRIMARY KEY);
+
+ INSERT INTO c0 VALUES('zero', 0);
+ INSERT INTO c1 VALUES('one', 1);
+ INSERT INTO c2 VALUES('two', 2);
+ INSERT INTO c3 VALUES('three', 3);
+ INSERT INTO c4 VALUES('four', 4);
+ INSERT INTO c5 VALUES('five', 5);
+ INSERT INTO c6 VALUES('six', 6);
+ INSERT INTO c7 VALUES('seven', 7);
+ INSERT INTO c8 VALUES('eight', 8);
+ INSERT INTO c9 VALUES('nine', 9);
+
+ CREATE VIRTUAL TABLE temp.cc USING unionvtab([
+ SELECT 'main', 'c9', 9, 9 UNION ALL
+ SELECT 'main', 'c8', 8, 8 UNION ALL
+ SELECT 'main', 'c7', 7, 7 UNION ALL
+ SELECT 'main', 'c6', 6, 6 UNION ALL
+ SELECT 'main', 'c5', 5, 5 UNION ALL
+ SELECT 'main', 'c4', 4, 4 UNION ALL
+ SELECT 'main', 'c3', 3, 3 UNION ALL
+ SELECT 'main', 'c2', 2, 2 UNION ALL
+ SELECT 'main', 'c1', 1, 1 UNION ALL
+ SELECT 'main', 'c0', 0, 0
+ ]);
+
+ SELECT sum(two) FROM cc;
+} {45}
+
+do_execsql_test 5.1 {
+ SELECT one FROM cc WHERE one>='seven'
+} {zero two three six seven}
+
+do_execsql_test 5.2 {
+ SELECT y.one FROM cc AS x, cc AS y WHERE x.one=y.one AND x.rowid>5
+} {six seven eight nine}
+
+do_execsql_test 5.3 {
+ SELECT cc.one FROM c4, cc WHERE cc.rowid>c4.rowid
+} {five six seven eight nine}
+
+do_execsql_test 5.4 {
+ SELECT * FROM cc WHERE two LIKE '6'
+} {six 6}
+
+finish_test
diff --git a/test/unionvtabfault.test b/test/unionvtabfault.test
new file mode 100644
index 0000000..f66c9ac
--- /dev/null
+++ b/test/unionvtabfault.test
@@ -0,0 +1,83 @@
+# 2017-07-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 percentile.c extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix unionvtabfault
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+forcedelete test.db2
+do_execsql_test 1.0 {
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b TEXT);
+
+ INSERT INTO t1 VALUES(1, 'one'), (2, 'two'), (3, 'three');
+ INSERT INTO t2 VALUES(10, 'ten'), (11, 'eleven'), (12, 'twelve');
+ INSERT INTO t3 VALUES(20, 'twenty'), (21, 'twenty-one'), (22, 'twenty-two');
+}
+faultsim_save_and_close
+
+do_faultsim_test 1.1 -faults * -prep {
+ faultsim_restore_and_reopen
+ load_static_extension db unionvtab
+ execsql { ATTACH 'test.db2' AS aux; }
+ execsql { CREATE TEMP TABLE xyz(x); }
+} -body {
+ execsql {
+ CREATE VIRTUAL TABLE temp.uuu USING unionvtab(
+ "VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)"
+ );
+ }
+} -test {
+ faultsim_test_result {0 {}} \
+ {1 {vtable constructor failed: uuu}} \
+ {1 {sql error: interrupted}}
+}
+
+faultsim_restore_and_reopen
+load_static_extension db unionvtab
+execsql { ATTACH 'test.db2' AS aux; }
+execsql { CREATE TEMP TABLE xyz(x); }
+execsql {
+ CREATE VIRTUAL TABLE temp.uuu USING unionvtab(
+ "VALUES(NULL, 't1', 1, 9), ('main', 't2', 10, 19), ('aux', 't3', 20, 29)"
+ );
+}
+do_faultsim_test 1.2 -faults oom* -prep {
+} -body {
+ execsql { SELECT * FROM uuu }
+} -test {
+ faultsim_test_result {0 {1 one 2 two 3 three 10 ten 11 eleven 12 twelve 20 twenty 21 twenty-one 22 twenty-two}}
+}
+
+#-------------------------------------------------------------------------
+# Error while registering the two vtab modules.
+do_faultsim_test 2.0 -faults * -prep {
+ catch { db close }
+ sqlite3 db :memory:
+} -body {
+ load_static_extension db unionvtab
+} -test {
+ faultsim_test_result {0 {}} {1 {initialization of unionvtab failed: }}
+}
+
+
+
+finish_test
diff --git a/test/unique.test b/test/unique.test
new file mode 100644
index 0000000..04581c2
--- /dev/null
+++ b/test/unique.test
@@ -0,0 +1,261 @@
+# 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 {UNIQUE constraint failed: t1.a}}
+verify_ex_errcode unique-1.3b SQLITE_CONSTRAINT_PRIMARYKEY
+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 {UNIQUE constraint failed: t1.b}}
+verify_ex_errcode unique-1.5b SQLITE_CONSTRAINT_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 {UNIQUE constraint failed: t2.a}}
+verify_ex_errcode unique-2.3b SQLITE_CONSTRAINT_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 {UNIQUE constraint failed: t2.a}}
+verify_ex_errcode unique-2.8b SQLITE_CONSTRAINT_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 {UNIQUE constraint failed: t3.a, t3.c, t3.d}}
+verify_ex_errcode unique-3.4b SQLITE_CONSTRAINT_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 {UNIQUE constraint failed: t4.b}}
+verify_ex_errcode unique-4.10b SQLITE_CONSTRAINT_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 {UNIQUE constraint failed: t5.first_column_with_long_name, t5.second_column_with_long_name, t5.third_column_with_long_name, t5.fourth_column_with_long_name, t5.fifth_column_with_long_name, t5.sixth_column_with_long_name}}
+verify_ex_errcode unique-5.2b SQLITE_CONSTRAINT_UNIQUE
+
+
+finish_test
diff --git a/test/unique2.test b/test/unique2.test
new file mode 100644
index 0000000..0ec0dd3
--- /dev/null
+++ b/test/unique2.test
@@ -0,0 +1,86 @@
+# 2014-07-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 CREATE UNIQUE INDEX statement
+# to verify that ticket 9a6daf340df99ba93c53bcf8fa83d9f28040d2a8
+# has been fixed:
+#
+# drh added on 2014-07-30 12:33:04:
+#
+# The CREATE UNIQUE INDEX on the third line below does not fail even
+# though the x column values are not all unique.
+#
+# CREATE TABLE t1(x NOT NULL);
+# INSERT INTO t1 VALUES(1),(2),(2),(3);
+# CREATE UNIQUE INDEX t1x ON t1(x);
+#
+# If the index is created before the INSERT, then uniqueness is enforced
+# at the point of the INSERT. Note that the NOT NULL on the indexed column
+# seems to be required in order to exhibit this bug.
+#
+# "PRAGMA integrity_check" does not detect the resulting malformed database.
+# That might be considered a separate issue.
+#
+# Bisecting shows that this problem was introduced by the addition of
+# WITHOUT ROWID support in version 3.8.2, specifically in check-in
+# [c80e229dd9c1230] on 2013-11-07. This problem was reported on the mailing
+# list by Pavel Pimenov. and primary keys, and the UNIQUE constraint
+# on table columns
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+foreach {id sql} {
+ 1 {CREATE TABLE t1(x TEXT PRIMARY KEY, y NOT NULL) WITHOUT ROWID}
+ 2 {CREATE TABLE t1(x TEXT PRIMARY KEY, y NOT NULL)}
+ 3 {CREATE TABLE t1(x TEXT PRIMARY KEY, y) WITHOUT ROWID}
+ 4 {CREATE TABLE t1(x TEXT PRIMARY KEY, y)}
+} {
+ do_test $id.1 {
+ db eval {DROP TABLE IF EXISTS t1}
+ db eval $sql
+ db eval {INSERT INTO t1(x,y) VALUES(1,1),(2,2),(3,2),(4,3)}
+ } {}
+ do_test $id.2 {
+ catchsql {CREATE UNIQUE INDEX t1y ON t1(y)}
+ } {1 {UNIQUE constraint failed: t1.y}}
+}
+
+foreach {id sql} {
+ 5 {CREATE TABLE t1(w,x,y NOT NULL,z NOT NULL,PRIMARY KEY(w,x)) WITHOUT ROWID}
+ 6 {CREATE TABLE t1(w,x,y NOT NULL,z NOT NULL,PRIMARY KEY(w,x))}
+ 7 {CREATE TABLE t1(w,x,y NOT NULL,z,PRIMARY KEY(w,x)) WITHOUT ROWID}
+ 8 {CREATE TABLE t1(w,x,y NOT NULL,z,PRIMARY KEY(w,x))}
+ 9 {CREATE TABLE t1(w,x,y,z NOT NULL,PRIMARY KEY(w,x)) WITHOUT ROWID}
+ 10 {CREATE TABLE t1(w,x,y,z NOT NULL,PRIMARY KEY(w,x))}
+ 11 {CREATE TABLE t1(w,x,y,z,PRIMARY KEY(w,x)) WITHOUT ROWID}
+ 12 {CREATE TABLE t1(w,x,y,z,PRIMARY KEY(w,x))}
+} {
+ do_test $id.1 {
+ db eval {DROP TABLE IF EXISTS t1}
+ db eval $sql
+ db eval {INSERT INTO t1(w,x,y,z) VALUES(1,2,3,4),(2,3,3,4)}
+ } {}
+ do_test $id.2 {
+ catchsql {CREATE UNIQUE INDEX t1yz ON t1(y,z)}
+ } {1 {UNIQUE constraint failed: t1.y, t1.z}}
+}
+
+do_catchsql_test 13.1 {
+ CREATE TABLE err1(a,b,c,UNIQUE(rowid));
+} {1 {no such column: rowid}}
+do_catchsql_test 13.2 {
+ CREATE TABLE err1(a,b,c,PRIMARY KEY(rowid));
+} {1 {no such column: rowid}}
+
+
+finish_test
diff --git a/test/unixexcl.test b/test/unixexcl.test
new file mode 100644
index 0000000..8e9c464
--- /dev/null
+++ b/test/unixexcl.test
@@ -0,0 +1,129 @@
+# 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}}
+}
+
+do_multiclient_test tn {
+ do_test unixexcl-3.$tn.1 {
+ code1 { db close; sqlite3 db file:test.db?psow=0 -vfs unix-excl -uri 1 }
+ code2 { db2 close; sqlite3 db2 file:test.db?psow=0 -vfs unix-excl -uri 1 }
+ sql1 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ PRAGMA synchronous = FULL;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ } {wal}
+
+ if {$tn==1} {
+ do_test unixexcl-3.$tn.1.multiproc {
+ csql2 { SELECT * FROM t1; }
+ } {1 {database is locked}}
+ } else {
+ do_test unixexcl-3.$tn.1.singleproc {
+ sql2 { SELECT * FROM t1; }
+ } {1 2}
+
+ do_test unixexcl-3.$tn.2 {
+ sql2 {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {1 2}
+ do_test unixexcl-3.$tn.3 {
+ sql1 { PRAGMA wal_checkpoint; INSERT INTO t1 VALUES(3, 4); }
+ } {0 5 5}
+ do_test unixexcl-3.$tn.4 {
+ sql2 { SELECT * FROM t1; }
+ } {1 2}
+ do_test unixexcl-3.$tn.5 {
+ sql1 { SELECT * FROM t1; }
+ } {1 2 3 4}
+ do_test unixexcl-3.$tn.6 {
+ sql2 { COMMIT; SELECT * FROM t1; }
+ } {1 2 3 4}
+ do_test unixexcl-3.$tn.7 {
+ sql1 { PRAGMA wal_checkpoint; }
+ } {0 7 7}
+ }
+}
+
+finish_test
diff --git a/test/unordered.test b/test/unordered.test
new file mode 100644
index 0000000..80595d9
--- /dev/null
+++ b/test/unordered.test
@@ -0,0 +1,69 @@
+# 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"
+ {SCAN t1 USING INDEX i1}
+ {SCAN t1*USE TEMP B-TREE FOR ORDER BY}
+ 2 "SELECT * FROM t1 WHERE a > 100"
+ {SEARCH t1 USING INDEX i1 (a>?)}
+ {SCAN t1}
+ 3 "SELECT * FROM t1 WHERE a = ? ORDER BY rowid"
+ {SEARCH t1 USING INDEX i1 (a=?)}
+ {SEARCH t1 USING INDEX i1 (a=?)*USE TEMP B-TREE FOR ORDER BY}
+ 4 "SELECT max(a) FROM t1"
+ {SEARCH t1 USING COVERING INDEX i1}
+ {SEARCH t1}
+ 5 "SELECT group_concat(b) FROM t1 GROUP BY a"
+ {SCAN t1 USING INDEX i1}
+ {SCAN t1*USE TEMP B-TREE FOR GROUP BY}
+
+ 6 "SELECT * FROM t1 WHERE a = ?"
+ {SEARCH t1 USING INDEX i1 (a=?)}
+ {SEARCH t1 USING INDEX i1 (a=?)}
+ 7 "SELECT count(*) FROM t1"
+ {SCAN t1 USING COVERING INDEX i1}
+ {SCAN t1}
+ } {
+ 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..66efd10
--- /dev/null
+++ b/test/update.test
@@ -0,0 +1,735 @@
+# 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 {UNIQUE constraint failed: t1.a}}
+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 {UNIQUE constraint failed: t1.b}}
+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 {UNIQUE constraint failed: t1.c, t1.d}}
+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}
+ do_test update-11.3 {
+ execsql {
+ UPDATE t1 AS xyz SET e=e+1 WHERE xyz.a IN (SELECT a FROM t1);
+ SELECT a,e FROM t1;
+ }
+ } {1 16 2 9}
+ do_test update-11.4 {
+ execsql {
+ UPDATE t1 AS xyz SET e=e+1 WHERE EXISTS(SELECT 1 FROM t1 WHERE t1.a<xyz.a);
+ SELECT a,e FROM t1;
+ }
+ } {1 16 2 10}
+}
+
+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}
+
+# Ticket [https://www.sqlite.org/src/tktview/43107840f1c02] on 2014-10-29
+# An assertion fault on UPDATE
+#
+ifcapable altertable {
+ do_execsql_test update-15.1 {
+ CREATE TABLE t15(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t15(a,b) VALUES(10,'abc'),(20,'def'),(30,'ghi');
+ ALTER TABLE t15 ADD COLUMN c;
+ CREATE INDEX t15c ON t15(c);
+ INSERT INTO t15(a,b)
+ VALUES(5,'zyx'),(15,'wvu'),(25,'tsr'),(35,'qpo');
+ UPDATE t15 SET c=printf('y%d',a) WHERE c IS NULL;
+ SELECT a,b,c,'|' FROM t15 ORDER BY a;
+ } {5 zyx y5 | 10 abc y10 | 15 wvu y15 | 20 def y20 | 25 tsr y25 | 30 ghi y30 | 35 qpo y35 |}
+}
+
+# Unreleased bug in UPDATE caused by the UPSERT changes.
+# Found by OSSFuzz as soon as the UPSERT changes landed on trunk.
+# Never released into the wild. 2018-04-19.
+#
+do_execsql_test update-16.1 {
+ CREATE TABLE t16(a INTEGER PRIMARY KEY ON CONFLICT REPLACE, b UNIQUE);
+ INSERT INTO t16(a,b) VALUES(1,2),(3,4),(5,6);
+ UPDATE t16 SET a=a;
+ SELECT * FROM t16 ORDER BY +a;
+} {1 2 3 4 5 6}
+
+# 2019-12-09 gramfuzz find
+# If a partial index that does not reference any column of its table (which is you
+# must admit is a very strange index, but one that is allowed) is used by an UPDATE
+# statement, void the use of OP_DeferredSeek on the main loop, as the seek will not
+# be resolved prior to the OP_Delete.
+#
+do_execsql_test update-17.10 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x,y);
+ INSERT INTO t1(x) VALUES(1);
+ CREATE INDEX t1x1 ON t1(1) WHERE 3;
+ UPDATE t1 SET x=2, y=3 WHERE 3;
+ SELECT * FROM t1;
+} {2 3}
+
+# 2019-12-22 ticket 5ad2aa6921faa1ee
+# Make a hard-copy of values that need to be run through OP_RealAffinity
+# rather than a soft-copy. This is not strictly necessary, but it avoids
+# a memory-accounting assert().
+#
+reset_db
+do_execsql_test update-18.10 {
+ PRAGMA encoding = 'UTF16';
+ CREATE TABLE t0(c0 REAL, c1);
+ INSERT INTO t0(c0,c1) VALUES('xyz',11),('uvw',22);
+ CREATE INDEX i0 ON t0(c1) WHERE c0 GLOB 3;
+ CREATE INDEX i1 ON t0(c0,c1) WHERE typeof(c0)='text' AND typeof(c1)='integer';
+ UPDATE t0 SET c1=345;
+ SELECT * FROM t0;
+} {xyz 345 uvw 345}
+
+# 2019-12-22 ticket c62c5e58524b204d
+# This is really the same underlying problem as 5ad2aa6921faa1ee
+#
+reset_db
+do_execsql_test update-18.20 {
+ PRAGMA encoding = 'utf16';
+ CREATE TABLE t0(c0 TEXT);
+ CREATE INDEX i0 ON t0(0 LIKE COALESCE(c0, 0));
+ INSERT INTO t0(c0) VALUES (0), (0);
+ SELECT * FROM t0;
+} {0 0}
+
+# 2019-12-28 assertion fault reported by Yongheng
+# Similar to ticket ec8abb025e78f40c
+# An UPDATE was reaching the OP_Delete after running OP_DeferredSeek
+# without ever hitting an OP_Column. The enhanced solution is to
+# fix OP_Delete so that it can do the seek itself.
+#
+reset_db
+do_execsql_test update-19.10 {
+ CREATE TABLE t1(
+ a TEXT,
+ b INTEGER PRIMARY KEY UNIQUE
+ );
+ INSERT INTO t1 VALUES(1,2);
+ UPDATE t1 SET a = quote(b) WHERE b>=2;
+ SELECT * FROM t1;
+} {2 2}
+
+# 2019-12-29 ticket https://www.sqlite.org/src/info/314cc133e5ada126
+# REPLACE conflict resolution during an UPDATE causes a DELETE trigger
+# to fire. If that DELETE trigger subsequently modifies the row
+# being updated, bad things can happen. Prevent this by prohibiting
+# triggers from making changes to the table being updated while doing
+# REPLACE conflict resolution on the UPDATE.
+#
+# See also tickets:
+# https://www.sqlite.org/src/info/c1e19e12046d23fe 2019-10-25
+# https://www.sqlite.org/src/info/a8a4847a2d96f5de 2019-10-16
+#
+reset_db
+do_execsql_test update-20.10 {
+ PRAGMA recursive_triggers = true;
+ CREATE TABLE t1(a UNIQUE ON CONFLICT REPLACE, b);
+ INSERT INTO t1(a,b) VALUES(4,12),(9,13);
+ CREATE INDEX i0 ON t1(b);
+ CREATE TRIGGER tr0 DELETE ON t1 BEGIN
+ UPDATE t1 SET b = a;
+ END;
+ PRAGMA integrity_check;
+} {ok}
+do_catchsql_test update-20.20 {
+ UPDATE t1 SET a=0;
+} {1 {constraint failed}}
+do_execsql_test update-20.30 {
+ PRAGMA integrity_check;
+} {ok}
+
+finish_test
diff --git a/test/update2.test b/test/update2.test
new file mode 100644
index 0000000..41a7224
--- /dev/null
+++ b/test/update2.test
@@ -0,0 +1,235 @@
+# 2017 January 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix update2
+
+db func repeat [list string repeat]
+
+#-------------------------------------------------------------------------
+# 1.1.* A one-pass UPDATE that does balance() operations on the IPK index
+# that it is scanning.
+#
+# 1.2.* Same again, but with a WITHOUT ROWID table.
+#
+set nrow [expr 10]
+do_execsql_test 1.1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
+ WITH s(i) AS ( SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<$nrow )
+ INSERT INTO t1(b) SELECT char((i % 26) + 65) FROM s;
+ INSERT INTO t2 SELECT * FROM t1;
+}
+
+do_execsql_test 1.1.1 {
+ UPDATE t1 SET b = repeat(b, 100)
+}
+
+do_execsql_test 1.1.2 {
+ SELECT * FROM t1;
+} [db eval { SELECT a, repeat(b, 100) FROM t2 }]
+
+do_execsql_test 1.2.0 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
+ WITH s(i) AS ( SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<$nrow )
+ INSERT INTO t1(a, b) SELECT i+1, char((i % 26) + 65) FROM s;
+}
+
+#explain_i { UPDATE t1 SET b = repeat(b, 100) }
+do_execsql_test 1.2.1 {
+ UPDATE t1 SET b = repeat(b, 100)
+}
+
+do_execsql_test 1.2.2 {
+ SELECT * FROM t1;
+} [db eval { SELECT a, repeat(b, 100) FROM t2 }]
+
+
+#-------------------------------------------------------------------------
+# A one-pass UPDATE that does balance() operations on the IPK index
+# that it is scanning.
+#
+do_execsql_test 2.1 {
+ CREATE TABLE t3(a PRIMARY KEY, b, c);
+ CREATE INDEX t3i ON t3(b);
+} {}
+do_execsql_test 2.2 { UPDATE t3 SET c=1 WHERE b=? } {}
+do_execsql_test 2.3 { UPDATE t3 SET c=1 WHERE rowid=? } {}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 3.0 {
+ CREATE TABLE t4(a PRIMARY KEY, b, c) WITHOUT ROWID;
+ CREATE INDEX t4c ON t4(c);
+ INSERT INTO t4 VALUES(1, 2, 3);
+ INSERT INTO t4 VALUES(2, 3, 4);
+}
+
+do_execsql_test 3.1 {
+ UPDATE t4 SET c=c+2 WHERE c>2;
+ SELECT a, c FROM t4 ORDER BY a;
+} {1 5 2 6}
+
+#-------------------------------------------------------------------------
+#
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE b1(a INTEGER PRIMARY KEY, b, c);
+ CREATE TABLE c1(a INTEGER PRIMARY KEY, b, c, d)
+ }
+ 2 {
+ CREATE TABLE b1(a INT PRIMARY KEY, b, c) WITHOUT ROWID;
+ CREATE TABLE c1(a INT PRIMARY KEY, b, c, d) WITHOUT ROWID;
+ }
+} {
+ execsql { DROP TABLE IF EXISTS b1; DROP TABLE IF EXISTS c1; }
+ execsql $sql
+
+ do_execsql_test 4.$tn.0 {
+ CREATE UNIQUE INDEX b1c ON b1(c);
+ INSERT INTO b1 VALUES(1, 'a', 1);
+ INSERT INTO b1 VALUES(2, 'b', 15);
+ INSERT INTO b1 VALUES(3, 'c', 3);
+ INSERT INTO b1 VALUES(4, 'd', 4);
+ INSERT INTO b1 VALUES(5, 'e', 5);
+ INSERT INTO b1 VALUES(6, 'f', 6);
+ INSERT INTO b1 VALUES(7, 'g', 7);
+ }
+
+ do_execsql_test 4.$tn.1 {
+ UPDATE OR REPLACE b1 SET c=c+10 WHERE a BETWEEN 4 AND 7;
+ SELECT * FROM b1 ORDER BY a;
+ } {
+ 1 a 1
+ 3 c 3
+ 4 d 14
+ 5 e 15
+ 6 f 16
+ 7 g 17
+ }
+
+ do_execsql_test 4.$tn.2 {
+ CREATE INDEX c1d ON c1(d, b);
+ CREATE UNIQUE INDEX c1c ON c1(c, b);
+
+ INSERT INTO c1 VALUES(1, 'a', 1, 1);
+ INSERT INTO c1 VALUES(2, 'a', 15, 2);
+ INSERT INTO c1 VALUES(3, 'a', 3, 3);
+ INSERT INTO c1 VALUES(4, 'a', 4, 4);
+ INSERT INTO c1 VALUES(5, 'a', 5, 5);
+ INSERT INTO c1 VALUES(6, 'a', 6, 6);
+ INSERT INTO c1 VALUES(7, 'a', 7, 7);
+ }
+
+ do_execsql_test 4.$tn.3 {
+ UPDATE OR REPLACE c1 SET c=c+10 WHERE d BETWEEN 4 AND 7;
+ SELECT * FROM c1 ORDER BY a;
+ } {
+ 1 a 1 1
+ 3 a 3 3
+ 4 a 14 4
+ 5 a 15 5
+ 6 a 16 6
+ 7 a 17 7
+ }
+
+ do_execsql_test 4.$tn.4 { PRAGMA integrity_check } ok
+
+ do_execsql_test 4.$tn.5 {
+ DROP INDEX c1d;
+ DROP INDEX c1c;
+ DELETE FROM c1;
+
+ INSERT INTO c1 VALUES(1, 'a', 1, 1);
+ INSERT INTO c1 VALUES(2, 'a', 15, 2);
+ INSERT INTO c1 VALUES(3, 'a', 3, 3);
+ INSERT INTO c1 VALUES(4, 'a', 4, 4);
+ INSERT INTO c1 VALUES(5, 'a', 5, 5);
+ INSERT INTO c1 VALUES(6, 'a', 6, 6);
+ INSERT INTO c1 VALUES(7, 'a', 7, 7);
+
+ CREATE INDEX c1d ON c1(d);
+ CREATE UNIQUE INDEX c1c ON c1(c);
+ }
+
+ do_execsql_test 4.$tn.6 {
+ UPDATE OR REPLACE c1 SET c=c+10 WHERE d BETWEEN 4 AND 7;
+ SELECT * FROM c1 ORDER BY a;
+ } {
+ 1 a 1 1
+ 3 a 3 3
+ 4 a 14 4
+ 5 a 15 5
+ 6 a 16 6
+ 7 a 17 7
+ }
+}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 5.0 {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c);
+ CREATE INDEX x1c ON x1(b, c);
+ INSERT INTO x1 VALUES(1, 'a', 1);
+ INSERT INTO x1 VALUES(2, 'a', 2);
+ INSERT INTO x1 VALUES(3, 'a', 3);
+}
+
+do_execsql_test 5.1.1 {
+ UPDATE x1 SET c=c+1 WHERE b='a';
+}
+
+do_execsql_test 5.1.2 {
+ SELECT * FROM x1;
+} {1 a 2 2 a 3 3 a 4}
+
+do_test 5.2 {
+ catch { array unset A }
+ db eval { EXPLAIN UPDATE x1 SET c=c+1 WHERE b='a' } { incr A($opcode) }
+ set A(NotExists)
+} {1}
+
+#-------------------------------------------------------------------------
+do_execsql_test 6.0 {
+ CREATE TABLE d1(a,b);
+ CREATE INDEX d1b ON d1(a);
+ CREATE INDEX d1c ON d1(b);
+ INSERT INTO d1 VALUES(1,2);
+}
+
+do_execsql_test 6.1 {
+ UPDATE d1 SET a = a+2 WHERE a>0 OR b>0;
+}
+
+do_execsql_test 6.2 {
+ SELECT * FROM d1;
+} {3 2}
+
+# 2019-01-22 Bug in UPDATE OR REPLACE discovered by the
+# Matt Denton's LPM fuzzer
+#
+do_execsql_test 7.100 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x,y);
+ CREATE UNIQUE INDEX t1x1 ON t1(x) WHERE x IS NOT NULL;
+ INSERT INTO t1(x) VALUES(NULL),(NULL);
+ CREATE INDEX t1x2 ON t1(y);
+ SELECT quote(x), quote(y), '|' FROM t1;
+} {NULL NULL | NULL NULL |}
+do_execsql_test 7.110 {
+ UPDATE OR REPLACE t1 SET x=1;
+ SELECT quote(x), quote(y), '|' FROM t1;
+} {1 NULL |}
+
+finish_test
diff --git a/test/upfrom1.tcl b/test/upfrom1.tcl
new file mode 100644
index 0000000..22fc68a
--- /dev/null
+++ b/test/upfrom1.tcl
@@ -0,0 +1,115 @@
+# 2020 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.
+#
+#***********************************************************************
+#
+
+source [file join [file dirname $argv0] pg_common.tcl]
+
+#=========================================================================
+
+start_test upfrom1 "2020 April 22"
+
+foreach {tn wo} {
+ 1 "WITHOUT ROWID"
+ 2 ""
+} {
+eval [string map [list %TN% $tn %WITHOUT_ROWID% $wo] {
+execsql_test 1.%TN%.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER, c INTEGER) %WITHOUT_ROWID%;
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(4, 5, 6);
+ INSERT INTO t2 VALUES(7, 8, 9);
+
+ DROP TABLE IF EXISTS chng;
+ CREATE TABLE chng(a INTEGER, b INTEGER, c INTEGER);
+ INSERT INTO chng VALUES(1, 100, 1000);
+ INSERT INTO chng VALUES(7, 700, 7000);
+}
+
+execsql_test 1.%TN%.1 {
+ SELECT * FROM t2;
+}
+
+execsql_test 1.%TN%.2 {
+ UPDATE t2 SET b = chng.b, c = chng.c FROM chng WHERE chng.a = t2.a;
+ SELECT * FROM t2 ORDER BY a;
+}
+
+execsql_test 1.%TN%.3 {
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(4, 5, 6);
+ INSERT INTO t2 VALUES(7, 8, 9);
+}
+
+execsql_test 1.%TN%.4 {
+ UPDATE t2 SET (b, c) = (SELECT b, c FROM chng WHERE a=t2.a)
+ WHERE a IN (SELECT a FROM chng);
+ SELECT * FROM t2 ORDER BY a;
+}
+
+execsql_test 1.%TN%.5 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b INTEGER, c TEXT) %WITHOUT_ROWID%;
+ INSERT INTO t3 VALUES(1, 1, 'one');
+ INSERT INTO t3 VALUES(2, 2, 'two');
+ INSERT INTO t3 VALUES(3, 3, 'three');
+
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(x TEXT);
+ INSERT INTO t4 VALUES('five');
+
+ SELECT * FROM t3 ORDER BY a;
+}
+
+execsql_test 1.%TN%.6 {
+ UPDATE t3 SET c=x FROM t4;
+ SELECT * FROM t3 ORDER BY a;
+}
+}]}
+
+execsql_test 2.1 {
+ DROP TABLE IF EXISTS t5;
+ DROP TABLE IF EXISTS m1;
+ DROP TABLE IF EXISTS m2;
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT, c TEXT);
+ CREATE TABLE m1(x INTEGER PRIMARY KEY, y TEXT);
+ CREATE TABLE m2(u INTEGER PRIMARY KEY, v TEXT);
+
+ INSERT INTO t5 VALUES(1, 'one', 'ONE');
+ INSERT INTO t5 VALUES(2, 'two', 'TWO');
+ INSERT INTO t5 VALUES(3, 'three', 'THREE');
+ INSERT INTO t5 VALUES(4, 'four', 'FOUR');
+
+ INSERT INTO m1 VALUES(1, 'i');
+ INSERT INTO m1 VALUES(2, 'ii');
+ INSERT INTO m1 VALUES(3, 'iii');
+
+ INSERT INTO m2 VALUES(1, 'I');
+ INSERT INTO m2 VALUES(3, 'II');
+ INSERT INTO m2 VALUES(4, 'III');
+}
+
+execsql_test 2.2 {
+ UPDATE t5 SET b=y, c=v FROM m1 LEFT JOIN m2 ON (x=u) WHERE x=a;
+ SELECT * FROM t5 ORDER BY a;
+}
+
+errorsql_test 2.3.1 {
+ UPDATE t5 SET b=1 FROM t5;
+}
+errorsql_test 2.3.2 {
+ UPDATE t5 AS apples SET b=1 FROM t5 AS apples;
+}
+
+
+finish_test
+
diff --git a/test/upfrom1.test b/test/upfrom1.test
new file mode 100644
index 0000000..204f351
--- /dev/null
+++ b/test/upfrom1.test
@@ -0,0 +1,210 @@
+# 2020 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.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix upfrom1
+
+do_execsql_test 1.1.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER, c INTEGER) WITHOUT ROWID;
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(4, 5, 6);
+ INSERT INTO t2 VALUES(7, 8, 9);
+
+ DROP TABLE IF EXISTS chng;
+ CREATE TABLE chng(a INTEGER, b INTEGER, c INTEGER);
+ INSERT INTO chng VALUES(1, 100, 1000);
+ INSERT INTO chng VALUES(7, 700, 7000);
+} {}
+
+do_execsql_test 1.1.1 {
+ SELECT * FROM t2;
+} {1 2 3 4 5 6 7 8 9}
+
+do_execsql_test 1.1.2 {
+ UPDATE t2 SET b = chng.b, c = chng.c FROM chng WHERE chng.a = t2.a;
+ SELECT * FROM t2 ORDER BY a;
+} {1 100 1000 4 5 6 7 700 7000}
+
+do_execsql_test 1.1.3 {
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(4, 5, 6);
+ INSERT INTO t2 VALUES(7, 8, 9);
+} {}
+
+do_execsql_test 1.1.4 {
+ UPDATE t2 SET (b, c) = (SELECT b, c FROM chng WHERE a=t2.a)
+ WHERE a IN (SELECT a FROM chng);
+ SELECT * FROM t2 ORDER BY a;
+} {1 100 1000 4 5 6 7 700 7000}
+
+do_execsql_test 1.1.5 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b INTEGER, c TEXT) WITHOUT ROWID;
+ INSERT INTO t3 VALUES(1, 1, 'one');
+ INSERT INTO t3 VALUES(2, 2, 'two');
+ INSERT INTO t3 VALUES(3, 3, 'three');
+
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(x TEXT);
+ INSERT INTO t4 VALUES('five');
+
+ SELECT * FROM t3 ORDER BY a;
+} {1 1 one 2 2 two 3 3 three}
+
+do_execsql_test 1.1.6 {
+ UPDATE t3 SET c=x FROM t4;
+ SELECT * FROM t3 ORDER BY a;
+} {1 1 five 2 2 five 3 3 five}
+
+do_execsql_test 1.2.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER, c INTEGER) ;
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(4, 5, 6);
+ INSERT INTO t2 VALUES(7, 8, 9);
+
+ DROP TABLE IF EXISTS chng;
+ CREATE TABLE chng(a INTEGER, b INTEGER, c INTEGER);
+ INSERT INTO chng VALUES(1, 100, 1000);
+ INSERT INTO chng VALUES(7, 700, 7000);
+} {}
+
+do_execsql_test 1.2.1 {
+ SELECT * FROM t2;
+} {1 2 3 4 5 6 7 8 9}
+
+do_execsql_test 1.2.2 {
+ UPDATE t2 SET b = chng.b, c = chng.c FROM chng WHERE chng.a = t2.a;
+ SELECT * FROM t2 ORDER BY a;
+} {1 100 1000 4 5 6 7 700 7000}
+
+do_execsql_test 1.2.3 {
+ DELETE FROM t2;
+ INSERT INTO t2 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(4, 5, 6);
+ INSERT INTO t2 VALUES(7, 8, 9);
+} {}
+
+do_execsql_test 1.2.4 {
+ UPDATE t2 SET (b, c) = (SELECT b, c FROM chng WHERE a=t2.a)
+ WHERE a IN (SELECT a FROM chng);
+ SELECT * FROM t2 ORDER BY a;
+} {1 100 1000 4 5 6 7 700 7000}
+
+do_execsql_test 1.2.5 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a INTEGER PRIMARY KEY, b INTEGER, c TEXT) ;
+ INSERT INTO t3 VALUES(1, 1, 'one');
+ INSERT INTO t3 VALUES(2, 2, 'two');
+ INSERT INTO t3 VALUES(3, 3, 'three');
+
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(x TEXT);
+ INSERT INTO t4 VALUES('five');
+
+ SELECT * FROM t3 ORDER BY a;
+} {1 1 one 2 2 two 3 3 three}
+
+do_execsql_test 1.2.6 {
+ UPDATE t3 SET c=x FROM t4;
+ SELECT * FROM t3 ORDER BY a;
+} {1 1 five 2 2 five 3 3 five}
+
+do_execsql_test 2.1 {
+ DROP TABLE IF EXISTS t5;
+ DROP TABLE IF EXISTS m1;
+ DROP TABLE IF EXISTS m2;
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT, c TEXT);
+ CREATE TABLE m1(x INTEGER PRIMARY KEY, y TEXT);
+ CREATE TABLE m2(u INTEGER PRIMARY KEY, v TEXT);
+
+ INSERT INTO t5 VALUES(1, 'one', 'ONE');
+ INSERT INTO t5 VALUES(2, 'two', 'TWO');
+ INSERT INTO t5 VALUES(3, 'three', 'THREE');
+ INSERT INTO t5 VALUES(4, 'four', 'FOUR');
+
+ INSERT INTO m1 VALUES(1, 'i');
+ INSERT INTO m1 VALUES(2, 'ii');
+ INSERT INTO m1 VALUES(3, 'iii');
+
+ INSERT INTO m2 VALUES(1, 'I');
+ INSERT INTO m2 VALUES(3, 'II');
+ INSERT INTO m2 VALUES(4, 'III');
+} {}
+
+do_execsql_test 2.2 {
+ UPDATE t5 SET b=y, c=v FROM m1 LEFT JOIN m2 ON (x=u) WHERE x=a;
+ SELECT * FROM t5 ORDER BY a;
+} {1 i I 2 ii {} 3 iii II 4 four FOUR}
+
+# PG says ERROR: table name "t5" specified more than once
+do_test 2.3.1 { catch { execsql {
+ UPDATE t5 SET b=1 FROM t5;
+} } } 1
+
+# PG says ERROR: table name "apples" specified more than once
+do_test 2.3.2 { catch { execsql {
+ UPDATE t5 AS apples SET b=1 FROM t5 AS apples;
+} } } 1
+
+# Problem found by OSSFuzz on 2020-07-20
+# https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24282
+#
+reset_db
+do_execsql_test 3.1 {
+ CREATE TABLE t0(a);
+ CREATE TABLE t1(b);
+ UPDATE t1 SET b=sum(a) FROM t0;
+ SELECT * FROM t0, t1;
+} {}
+
+# Problem described by forum post https://sqlite.org/forum/forumpost/a274248080
+#
+reset_db
+do_execsql_test 4.1 {
+ CREATE TABLE t1(x INT); INSERT INTO t1 VALUES(1);
+ CREATE TABLE t2(y INT); INSERT INTO t2 VALUES(2);
+ WITH t1 AS (SELECT y+100 AS x FROM t2)
+ UPDATE t1 SET x=(SELECT x FROM t1);
+ SELECT x, y FROM t1, t2;
+} {102 2}
+do_execsql_test 4.2 {
+ WITH t1 AS (SELECT y+100 AS x FROM t2)
+ UPDATE t1 SET x=x+y FROM t2;
+ SELECT x, y FROM t1, t2;
+} {104 2}
+
+# 2021-05-20
+# Forum https://sqlite.org/forum/forumpost/339f487de5 by Yu Liang
+# A bad assert()
+#
+reset_db
+do_execsql_test 5.1 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1(a) VALUES(5);
+ CREATE VIEW t2 AS SELECT a FROM t1 UNION ALL SELECT a FROM t1;
+ CREATE TABLE t3(b,c);
+ INSERT INTO t3(b,c) VALUES(1,2);
+ UPDATE t3 SET (c,b) = (SELECT 3,4) FROM t1, t2;
+ SELECT * FROM t3;
+} {4 3}
+
+
+finish_test
diff --git a/test/upfrom2.test b/test/upfrom2.test
new file mode 100644
index 0000000..600fa05
--- /dev/null
+++ b/test/upfrom2.test
@@ -0,0 +1,405 @@
+# 2020 April 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
+set testprefix upfrom2
+
+# Test cases:
+#
+# 1.*: Test that triggers are fired correctly for UPDATE FROM statements,
+# and only once for each row. Except for INSTEAD OF triggers on
+# views - these are fired once for each row returned by the join,
+# including duplicates.
+#
+# 2.*: Test adding ORDER BY and LIMIT clauses with UPDATE FROM statements.
+#
+# 5.*: Test that specifying the target table name or alias in the FROM
+# clause of an UPDATE statement is an error.
+#
+
+foreach {tn wo} {
+ 1 ""
+ 2 "WITHOUT ROWID"
+} {
+ reset_db
+
+ eval [string map [list %WO% $wo %TN% $tn] {
+ do_execsql_test 1.%TN%.0 {
+ CREATE TABLE log(t TEXT);
+ CREATE TABLE t1(x PRIMARY KEY, y, z UNIQUE) %WO%;
+ CREATE INDEX t1y ON t1(y);
+
+ INSERT INTO t1 VALUES(1, 'i', 'one');
+ INSERT INTO t1 VALUES(2, 'ii', 'two');
+ INSERT INTO t1 VALUES(3, 'iii', 'three');
+ INSERT INTO t1 VALUES(4, 'iv', 'four');
+
+ CREATE TRIGGER tr1 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES(old.z || '->' || new.z);
+ END;
+ CREATE TRIGGER tr2 AFTER UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES(old.y || '->' || new.y);
+ END;
+ }
+
+ do_execsql_test 1.%TN%.1 {
+ WITH data(k, v) AS (
+ VALUES(3, 'thirty'), (1, 'ten')
+ )
+ UPDATE t1 SET z=v FROM data WHERE x=k;
+
+ SELECT * FROM t1;
+ SELECT * FROM log;
+ } {
+ 1 i ten 2 ii two 3 iii thirty 4 iv four
+ one->ten i->i
+ three->thirty iii->iii
+ }
+
+ do_execsql_test 1.%TN%.2 {
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(k, v);
+
+ INSERT INTO t3 VALUES(5, 'v');
+ INSERT INTO t3 VALUES(12, 'xii');
+
+ INSERT INTO t2 VALUES(2, 12);
+ INSERT INTO t2 VALUES(3, 5);
+
+ DELETE FROM log;
+ UPDATE t1 SET y=v FROM t2, t3 WHERE t1.x=t2.a AND t3.k=t2.b;
+
+ SELECT * FROM t1;
+ SELECT * FROM log;
+ } {
+ 1 i ten 2 xii two 3 v thirty 4 iv four
+ two->two ii->xii
+ thirty->thirty iii->v
+ }
+
+ do_execsql_test 1.%TN%.3 {
+ DELETE FROM log;
+ WITH data(k, v) AS (
+ VALUES(1, 'seven'), (1, 'eight'), (2, 'eleven'), (2, 'twelve')
+ )
+ UPDATE t1 SET z=v FROM data WHERE x=k;
+
+ SELECT * FROM t1;
+ SELECT * FROM log;
+ } {
+ 1 i eight 2 xii twelve 3 v thirty 4 iv four
+ ten->eight i->i
+ two->twelve xii->xii
+ }
+
+ do_test 1.%TN%.4 { db changes } {2}
+
+ do_execsql_test 1.%TN%.5 {
+ CREATE VIEW v1 AS SELECT * FROM t1;
+ CREATE TRIGGER v1tr INSTEAD OF UPDATE ON v1 BEGIN
+ UPDATE t1 SET y=new.y, z=new.z WHERE x=new.x;
+ END;
+
+ DELETE FROM log;
+ WITH data(k, v) AS (
+ VALUES(3, 'thirteen'), (3, 'fourteen'), (4, 'fifteen'), (4, 'sixteen')
+ )
+ UPDATE v1 SET z=v FROM data WHERE x=k;
+ }
+
+ do_execsql_test 1.%TN%.6 {
+ SELECT * FROM v1;
+ SELECT * FROM log;
+ } {
+ 1 i eight 2 xii twelve 3 v fourteen 4 iv sixteen
+ thirty->thirteen v->v
+ thirteen->fourteen v->v
+ four->fifteen iv->iv
+ fifteen->sixteen iv->iv
+ }
+
+ #--------------------------------------------------------------
+
+ do_execsql_test 1.%TN%.7 {
+ CREATE TABLE o1(w, x, y, z UNIQUE, PRIMARY KEY(w, x)) %WO%;
+ CREATE INDEX o1y ON t1(y);
+
+ INSERT INTO o1 VALUES(0, 0, 'i', 'one');
+ INSERT INTO o1 VALUES(0, 1, 'ii', 'two');
+ INSERT INTO o1 VALUES(1, 0, 'iii', 'three');
+ INSERT INTO o1 VALUES(1, 1, 'iv', 'four');
+
+ CREATE TRIGGER tro1 BEFORE UPDATE ON o1 BEGIN
+ INSERT INTO log VALUES(old.z || '->' || new.z);
+ END;
+ CREATE TRIGGER tro2 AFTER UPDATE ON o1 BEGIN
+ INSERT INTO log VALUES(old.y || '->' || new.y);
+ END;
+ }
+
+ do_execsql_test 1.%TN%.8 {
+ DELETE FROM log;
+ WITH data(k, v) AS (
+ VALUES(3, 'thirty'), (1, 'ten')
+ )
+ UPDATE o1 SET z=v FROM data WHERE (1+x+w*2)=k;
+
+ SELECT * FROM o1;
+ SELECT * FROM log;
+ } {
+ 0 0 i ten 0 1 ii two 1 0 iii thirty 1 1 iv four
+ one->ten i->i
+ three->thirty iii->iii
+ }
+
+ do_execsql_test 1.%TN%.9 {
+ DELETE FROM log;
+ UPDATE o1 SET y=v FROM t2, t3 WHERE (1+o1.w*2+o1.x)=t2.a AND t3.k=t2.b;
+
+ SELECT * FROM o1;
+ SELECT * FROM log;
+ } {
+ 0 0 i ten 0 1 xii two 1 0 v thirty 1 1 iv four
+ two->two ii->xii
+ thirty->thirty iii->v
+ }
+
+ do_execsql_test 1.%TN%.10 {
+ DELETE FROM log;
+ WITH data(k, v) AS (
+ VALUES(1, 'seven'), (1, 'eight'), (2, 'eleven'), (2, 'twelve')
+ )
+ UPDATE o1 SET z=v FROM data WHERE (1+w*2+x)=k;
+
+ SELECT * FROM o1;
+ SELECT * FROM log;
+ } {
+ 0 0 i eight 0 1 xii twelve 1 0 v thirty 1 1 iv four
+ ten->eight i->i
+ two->twelve xii->xii
+ }
+
+ do_test 1.%TN%.11 { db changes } {2}
+
+ do_execsql_test 1.%TN%.12 {
+ CREATE VIEW w1 AS SELECT * FROM o1;
+ CREATE TRIGGER w1tr INSTEAD OF UPDATE ON w1 BEGIN
+ UPDATE o1 SET y=new.y, z=new.z WHERE w=new.w AND x=new.x;
+ END;
+
+ DELETE FROM log;
+ WITH data(k, v) AS (
+ VALUES(3, 'thirteen'), (3, 'fourteen'), (4, 'fifteen'), (4, 'sixteen')
+ )
+ UPDATE w1 SET z=v FROM data WHERE (1+w*2+x)=k;
+ }
+
+ do_execsql_test 1.%TN%.13 {
+ SELECT * FROM w1;
+ SELECT * FROM log;
+ } {
+ 0 0 i eight 0 1 xii twelve 1 0 v fourteen 1 1 iv sixteen
+ thirty->thirteen v->v
+ thirteen->fourteen v->v
+ four->fifteen iv->iv
+ fifteen->sixteen iv->iv
+ }
+
+}]
+}
+
+ifcapable update_delete_limit {
+foreach {tn wo} {
+ 1 ""
+ 2 "WITHOUT ROWID"
+} {
+ reset_db
+
+eval [string map [list %WO% $wo %TN% $tn] {
+ do_execsql_test 2.%TN%.1 {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b) %WO%;
+ INSERT INTO x1 VALUES
+ (1, 'one'), (2, 'two'), (3, 'three'), (4, 'four'),
+ (5, 'five'), (6, 'six'), (7, 'seven'), (8, 'eight');
+ }
+
+ do_execsql_test 2.%TN%.2 {
+ CREATE TABLE data1(x, y);
+ INSERT INTO data1 VALUES
+ (1, 'eleven'), (1, 'twenty-one'), (2, 'twelve'), (2, 'twenty-two'),
+ (3, 'thirteen'), (3, 'twenty-three'), (4, 'fourteen'), (4, 'twenty-four');
+ }
+
+ do_execsql_test 2.%TN%.3 {
+ UPDATE x1 SET b=y FROM data1 WHERE a=x ORDER BY a LIMIT 3;
+ SELECT * FROM x1;
+ } {
+ 1 eleven 2 twelve 3 thirteen 4 four 5 five 6 six 7 seven 8 eight
+ }
+
+ do_execsql_test 2.%TN%.4 {
+ UPDATE x1 SET b=b||y FROM data1 WHERE a=x ORDER BY b LIMIT 3;
+ SELECT * FROM x1;
+ } {
+ 1 eleveneleven 2 twelve 3 thirteenthirteen 4 fourfourteen
+ 5 five 6 six 7 seven 8 eight
+ }
+
+ do_catchsql_test 2.%TN%.5 {
+ UPDATE x1 SET b=b||b ORDER BY b;
+ } {1 {ORDER BY without LIMIT on UPDATE}}
+ do_catchsql_test 2.%TN%.6 {
+ UPDATE x1 SET b=b||y FROM data1 WHERE a=x ORDER BY b;
+ } {1 {ORDER BY without LIMIT on UPDATE}}
+
+ #-----------------------------------------------------------------------
+
+ do_execsql_test 2.%TN%.6 {
+ DROP TABLE x1;
+ CREATE TABLE x1(u, v, b, PRIMARY KEY(u, v)) %WO%;
+ INSERT INTO x1 VALUES
+ (0, 1, 'one'), (1, 0, 'two'), (1, 1, 'three'), (2, 0, 'four'),
+ (2, 1, 'five'), (3, 0, 'six'), (3, 1, 'seven'), (4, 0, 'eight');
+ }
+
+ do_execsql_test 2.%TN%.7 {
+ UPDATE x1 SET b=y FROM data1 WHERE (u*2+v)=x ORDER BY u, v LIMIT 3;
+ SELECT * FROM x1;
+ } {
+ 0 1 eleven 1 0 twelve 1 1 thirteen 2 0 four
+ 2 1 five 3 0 six 3 1 seven 4 0 eight
+ }
+
+ do_execsql_test 2.%TN%.8 {
+ UPDATE x1 SET b=b||y FROM data1 WHERE (u*2+v)=x ORDER BY b LIMIT 3;
+ SELECT * FROM x1;
+ } {
+ 0 1 eleveneleven 1 0 twelve 1 1 thirteenthirteen 2 0 fourfourteen
+ 2 1 five 3 0 six 3 1 seven 4 0 eight
+ }
+
+
+}]
+}}
+
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE data(x, y, z);
+ CREATE VIEW t1 AS SELECT * FROM data;
+ CREATE TRIGGER t1_insert INSTEAD OF INSERT ON t1 BEGIN
+ INSERT INTO data VALUES(new.x, new.y, new.z);
+ END;
+ CREATE TRIGGER t1_update INSTEAD OF UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES(old.z || '->' || new.z);
+ END;
+
+ CREATE TABLE log(t TEXT);
+
+ INSERT INTO t1 VALUES(1, 'i', 'one');
+ INSERT INTO t1 VALUES(2, 'ii', 'two');
+ INSERT INTO t1 VALUES(3, 'iii', 'three');
+ INSERT INTO t1 VALUES(4, 'iv', 'four');
+}
+
+do_execsql_test 3.1 {
+ WITH input(k, v) AS (
+ VALUES(3, 'thirty'), (1, 'ten')
+ )
+ UPDATE t1 SET z=v FROM input WHERE x=k;
+}
+
+foreach {tn sql} {
+ 2 {
+ CREATE TABLE x1(a INT PRIMARY KEY, b, c) WITHOUT ROWID;
+ }
+ 1 {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c);
+ }
+ 3 {
+ CREATE TABLE x1(a INT PRIMARY KEY, b, c);
+ }
+} {
+
+ reset_db
+ execsql $sql
+
+ do_execsql_test 4.$tn.0 {
+ INSERT INTO x1 VALUES(1, 1, 1);
+ INSERT INTO x1 VALUES(2, 2, 2);
+ INSERT INTO x1 VALUES(3, 3, 3);
+ INSERT INTO x1 VALUES(4, 4, 4);
+ INSERT INTO x1 VALUES(5, 5, 5);
+ CREATE TABLE map(o, t);
+ INSERT INTO map VALUES(3, 30), (4, 40), (1, 10);
+ }
+
+ do_execsql_test 4.$tn.1 {
+ UPDATE x1 SET a=t FROM map WHERE a=o;
+ SELECT * FROM x1 ORDER BY a;
+ } {2 2 2 5 5 5 10 1 1 30 3 3 40 4 4}
+}
+
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE x1(a, b, c);
+ CREATE TABLE x2(a, b, c);
+}
+
+foreach {tn update nm} {
+ 1 "UPDATE x1 SET a=5 FROM x1" x1
+ 2 "UPDATE x1 AS grapes SET a=5 FROM x1 AS grapes" grapes
+ 3 "UPDATE x1 SET a=5 FROM x2, x1" x1
+ 4 "UPDATE x1 AS grapes SET a=5 FROM x2, x1 AS grapes" grapes
+} {
+ do_catchsql_test 5.$tn $update \
+ "1 {target object/alias may not appear in FROM clause: $nm}"
+}
+
+#--------------------------------------------------------------------------
+reset_db
+do_execsql_test 6.0 {
+ CREATE TABLE t1(a);
+}
+
+do_execsql_test 6.1 {
+ UPDATE t1 SET a = 1 FROM (
+ SELECT * FROM t1
+ )
+} {}
+do_execsql_test 6.2 {
+ UPDATE t1 SET a = 1 FROM (
+ SELECT * FROM t1 UNION ALL SELECT * FROM t1
+ )
+} {}
+
+# 2022-03-21
+# https://sqlite.org/forum/forumpost/929168fdd6
+#
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1(a) VALUES(11),(22),(33),(44),(55);
+ CREATE VIEW t2(b,c) AS SELECT a, COUNT(*) OVER () FROM t1;
+ CREATE TABLE t3(x,y);
+ CREATE TRIGGER t2r1 INSTEAD OF UPDATE ON t2 BEGIN
+ INSERT INTO t3(x,y) VALUES(new.b,new.c);
+ END;
+ SELECT * FROM t2;
+} {11 5 22 5 33 5 44 5 55 5}
+do_execsql_test 7.1 {
+ UPDATE t2 SET c=t1.a FROM t1 WHERE t2.b=t1.a;
+ SELECT * FROM t3;
+} {11 11 22 22 33 33 44 44 55 55}
+
+
+finish_test
diff --git a/test/upfrom3.test b/test/upfrom3.test
new file mode 100644
index 0000000..9936716
--- /dev/null
+++ b/test/upfrom3.test
@@ -0,0 +1,261 @@
+# 2020 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix upfrom3
+
+# Test plan:
+#
+# 1.*: Test UPDATE ... FROM statements that modify IPK fields. And that
+# modify "INTEGER PRIMARY KEY" fields on WITHOUT ROWID tables.
+#
+# 2.*: Test UPDATE ... FROM statements that modify PK fields of WITHOUT
+# ROWID tables.
+#
+# 3.*: Test that UPDATE ... FROM statements are not confused if there
+# are multiple tables of the same name in attached databases.
+#
+# 4.*: Tests for UPDATE ... FROM statements and foreign keys.
+#
+
+foreach {tn wo} {
+ 1 ""
+ 2 "WITHOUT ROWID"
+} {
+ reset_db
+ eval [string map [list %WO% $wo %TN% $tn] {
+
+ do_execsql_test 1.%TN%.0 {
+ CREATE TABLE log(t TEXT);
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z UNIQUE) %WO%;
+ CREATE INDEX t1y ON t1(y);
+
+ INSERT INTO t1 VALUES(1, 'i', 'one');
+ INSERT INTO t1 VALUES(2, 'ii', 'two');
+ INSERT INTO t1 VALUES(3, 'iii', 'three');
+ INSERT INTO t1 VALUES(4, 'iv', 'four');
+ }
+
+ do_execsql_test 1.%TN%.1 {
+ CREATE TABLE x1(o, n);
+ INSERT INTO x1 VALUES(1, 11);
+ INSERT INTO x1 VALUES(2, 12);
+ INSERT INTO x1 VALUES(3, 13);
+ INSERT INTO x1 VALUES(4, 14);
+ UPDATE t1 SET x=n FROM x1 WHERE x=o;
+ SELECT x, y, z FROM t1 ORDER BY 1;
+ } {
+ 11 i one
+ 12 ii two
+ 13 iii three
+ 14 iv four
+ }
+
+ do_test 1.%TN%.2 { db changes } 4
+
+ do_execsql_test 1.%TN%.3 {
+ INSERT INTO x1 VALUES(11, 21);
+ INSERT INTO x1 VALUES(12, 22);
+ INSERT INTO x1 VALUES(13, 23);
+ INSERT INTO x1 VALUES(14, 24);
+
+ INSERT INTO x1 VALUES(21, 31);
+ INSERT INTO x1 VALUES(22, 32);
+ INSERT INTO x1 VALUES(23, 33);
+ INSERT INTO x1 VALUES(24, 34);
+ UPDATE t1 SET x=n FROM x1 WHERE x=o;
+ SELECT x, y, z FROM t1 ORDER BY 1;
+ } {
+ 21 i one
+ 22 ii two
+ 23 iii three
+ 24 iv four
+ }
+
+ do_execsql_test 1.%TN%.4 {
+ UPDATE t1 SET x=n FROM x1 WHERE x=o;
+ SELECT x, y, z FROM t1 ORDER BY 1;
+ } {
+ 31 i one
+ 32 ii two
+ 33 iii three
+ 34 iv four
+ }
+
+ do_execsql_test 1.%TN%.5 {
+ INSERT INTO x1 VALUES(31, 32);
+ INSERT INTO x1 VALUES(33, 34);
+ UPDATE OR REPLACE t1 SET x=n FROM x1 WHERE x=o;
+ SELECT x, y, z FROM t1 ORDER BY 1;
+ } {
+ 32 i one
+ 34 iii three
+ }
+
+ do_execsql_test 1.%TN%.6 {
+ INSERT INTO t1 VALUES(33, 'ii', 'two');
+ INSERT INTO t1 VALUES(35, 'iv', 'four');
+ }
+
+ do_execsql_test 1.%TN%.7 {
+ CREATE TABLE x2(o, n, zz);
+ INSERT INTO x2 VALUES(32, 41, 'four');
+ INSERT INTO x2 VALUES(33, 42, 'three');
+ UPDATE OR IGNORE t1 SET x=n, z=zz FROM x2 WHERE x=o;
+ SELECT x, y, z FROM t1 ORDER BY 1;
+ } {
+ 32 i one
+ 33 ii two
+ 34 iii three
+ 35 iv four
+ }
+
+ do_execsql_test 1.%TN%.8 {
+ UPDATE OR REPLACE t1 SET x=n, z=zz FROM x2 WHERE x=o;
+ SELECT x, y, z FROM t1 ORDER BY 1;
+ } {
+ 41 i four
+ 42 ii three
+ }
+
+ }]
+}
+
+do_execsql_test 2.1.1 {
+ CREATE TABLE u1(a, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID;
+ INSERT INTO u1 VALUES(0, 0, 0);
+ INSERT INTO u1 VALUES(1, 0, 1);
+ INSERT INTO u1 VALUES(2, 1, 0);
+ INSERT INTO u1 VALUES(3, 1, 1);
+}
+
+do_execsql_test 2.1.2 {
+ CREATE TABLE map(f, t);
+ INSERT INTO map VALUES(0, 10);
+ INSERT INTO map VALUES(1, 11);
+ UPDATE u1 SET c=t FROM map WHERE c=f;
+ SELECT * FROM u1 ORDER BY a;
+} {
+ 0 0 10
+ 1 0 11
+ 2 1 10
+ 3 1 11
+}
+
+do_execsql_test 2.1.3 {
+ UPDATE u1 SET b=t FROM map WHERE b=f;
+ SELECT * FROM u1 ORDER BY a;
+} {
+ 0 10 10
+ 1 10 11
+ 2 11 10
+ 3 11 11
+}
+
+do_execsql_test 2.1.4 {
+ CREATE TABLE map2(o1, o2, n1, n2);
+ INSERT INTO map2 VALUES
+ (10, 10, 50, 50), (10, 11, 50, 60),
+ (11, 10, 60, 50), (11, 11, 60, 60);
+ UPDATE u1 SET b=n1, c=n2 FROM map2 WHERE b=o1 AND c=o2;
+ SELECT * FROM u1 ORDER BY a;
+} {
+ 0 50 50
+ 1 50 60
+ 2 60 50
+ 3 60 60
+}
+
+#-------------------------------------------------------------------------
+foreach {tn wo} {
+ 1 ""
+ 2 "WITHOUT ROWID"
+} {
+ reset_db
+ forcedelete test.db2
+ eval [string map [list %WO% $wo %TN% $tn] {
+ do_execsql_test 3.$tn.1 {
+ CREATE TABLE g1(a, b, c, PRIMARY KEY(a, b)) %WO%;
+ INSERT INTO g1 VALUES(1, 1, 1);
+
+ ATTACH 'test.db2' AS aux;
+ CREATE TABLE aux.g1(a, b, c, PRIMARY KEY(a, b)) %WO%;
+ INSERT INTO aux.g1 VALUES(10, 1, 10);
+ INSERT INTO aux.g1 VALUES(20, 2, 20);
+ INSERT INTO aux.g1 VALUES(30, 3, 30);
+ }
+
+ do_execsql_test 3.$tn.2 {
+ UPDATE aux.g1 SET c=101 FROM main.g1;
+ }
+ do_execsql_test 3.$tn.3 {
+ SELECT * FROM aux.g1;
+ } {10 1 101 20 2 101 30 3 101}
+
+ do_execsql_test 3.$tn.4 {
+ UPDATE g1 SET c=101 FROM g1 AS g2;
+ }
+ do_execsql_test 3.$tn.5 {
+ SELECT * FROM g1;
+ } {1 1 101}
+ }]
+}
+
+#-------------------------------------------------------------------------
+reset_db
+foreach {tn wo} {
+ 1 ""
+ 2 "WITHOUT ROWID"
+} {
+ reset_db
+ forcedelete test.db2
+ eval [string map [list %WO% $wo %TN% $tn] {
+
+ do_execsql_test 4.$tn.1 {
+ CREATE TABLE p1(a INTEGER PRIMARY KEY, b) %WO%;
+ CREATE TABLE c1(x PRIMARY KEY, y REFERENCES p1 ON UPDATE CASCADE) %WO%;
+ PRAGMA foreign_keys = 1;
+
+ INSERT INTO p1 VALUES(1, 'one');
+ INSERT INTO p1 VALUES(11, 'eleven');
+ INSERT INTO p1 VALUES(111, 'eleventyone');
+
+ INSERT INTO c1 VALUES('a', 1);
+ INSERT INTO c1 VALUES('b', 11);
+ INSERT INTO c1 VALUES('c', 111);
+ }
+
+ do_execsql_test 4.$tn.2 {
+ CREATE TABLE map(f, t);
+ INSERT INTO map VALUES('a', 111);
+ INSERT INTO map VALUES('c', 112);
+ }
+
+ do_catchsql_test 4.$tn.3 {
+ UPDATE c1 SET y=t FROM map WHERE x=f;
+ } {1 {FOREIGN KEY constraint failed}}
+
+ do_execsql_test 4.$tn.4 {
+ INSERT INTO map VALUES('eleven', 12);
+ INSERT INTO map VALUES('eleventyone', 112);
+ UPDATE p1 SET a=t FROM map WHERE b=f;
+ }
+
+ do_execsql_test 4.$tn.5 {
+ SELECT * FROM c1
+ } {a 1 b 12 c 112}
+
+ }]
+}
+
+finish_test
diff --git a/test/upfrom4.test b/test/upfrom4.test
new file mode 100644
index 0000000..b20e963
--- /dev/null
+++ b/test/upfrom4.test
@@ -0,0 +1,130 @@
+# 2022-05-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
+set testprefix upfrom4
+
+do_execsql_test 100 {
+ DROP TABLE IF EXISTS t5;
+ DROP TABLE IF EXISTS m1;
+ DROP TABLE IF EXISTS m2;
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT, c TEXT);
+ CREATE TABLE m1(x INTEGER PRIMARY KEY, y TEXT);
+ CREATE TABLE m2(u INTEGER PRIMARY KEY, v TEXT);
+
+ INSERT INTO t5 VALUES(1, 'one', 'ONE');
+ INSERT INTO t5 VALUES(2, 'two', 'TWO');
+ INSERT INTO t5 VALUES(3, 'three', 'THREE');
+ INSERT INTO t5 VALUES(4, 'four', 'FOUR');
+
+ INSERT INTO m1 VALUES(1, 'i');
+ INSERT INTO m1 VALUES(2, 'ii');
+ INSERT INTO m1 VALUES(3, 'iii');
+
+ INSERT INTO m2 VALUES(1, 'I');
+ INSERT INTO m2 VALUES(3, 'II');
+ INSERT INTO m2 VALUES(4, 'III');
+ SELECT * FROM t5;
+} {1 one ONE 2 two TWO 3 three THREE 4 four FOUR}
+
+do_execsql_test 110 {
+ BEGIN;
+ UPDATE t5 SET b=y, c=v FROM m1 LEFT JOIN m2 ON (x=u) WHERE x=a;
+ SELECT * FROM t5 ORDER BY a;
+ ROLLBACK;
+} {1 i I 2 ii {} 3 iii II 4 four FOUR}
+
+do_execsql_test 120 {
+ BEGIN;
+ UPDATE t5 SET b=y, c=v FROM m2 RIGHT JOIN m1 ON (x=u) WHERE x=a;
+ SELECT * FROM t5 ORDER BY a;
+ ROLLBACK;
+} {1 i I 2 ii {} 3 iii II 4 four FOUR}
+
+
+reset_db
+db null -
+do_execsql_test 200 {
+ CREATE TABLE t1(a INT PRIMARY KEY, b INT, c INT);
+ INSERT INTO t1(a) VALUES(1),(2),(8),(19);
+ CREATE TABLE c1(x INTEGER PRIMARY KEY, b INT);
+ INSERT INTO c1(x,b) VALUES(1,1),(8,8),(17,17),(NULL,NULL);
+ CREATE TABLE c2(x INT,c INT);
+ INSERT INTO c2(x,c) VALUES(2,2),(8,8),(NULL,NULL);
+ CREATE TABLE dual(dummy TEXT);
+ INSERT INTO dual VALUES('X');
+} {}
+do_execsql_test 210 {
+ BEGIN;
+ SELECT * FROM t1 ORDER BY a;
+ UPDATE t1 SET b=c1.b, c=c2.c
+ FROM dual, c1 NATURAL RIGHT JOIN c2
+ WHERE x=a;
+ SELECT * FROM t1 ORDER BY a;
+ ROLLBACK;
+} {
+ 1 - -
+ 2 - -
+ 8 - -
+ 19 - -
+ 1 - -
+ 2 - 2
+ 8 8 8
+ 19 - -
+}
+do_execsql_test 300 {
+ CREATE TABLE t2(x);
+ CREATE TRIGGER AFTER INSERT ON t2 BEGIN
+ UPDATE t1 SET b=c1.b, c=c2.c
+ FROM dual, c1 NATURAL RIGHT JOIN c2
+ WHERE x=a;
+ END;
+} {}
+do_execsql_test 310 {
+ BEGIN;
+ SELECT * FROM t1 ORDER BY a;
+ INSERT INTO t2(x) VALUES(1);
+ SELECT * FROM t1 ORDER BY a;
+ ROLLBACK;
+} {
+ 1 - -
+ 2 - -
+ 8 - -
+ 19 - -
+ 1 - -
+ 2 - 2
+ 8 8 8
+ 19 - -
+}
+
+# 2022-05-26 dbsqlfuzz crash-9401d6ba699f1257d352a657de236286bf2b14da
+#
+reset_db
+db null -
+do_execsql_test 400 {
+ CREATE TABLE t2(x,y,z PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t2 VALUES(89,-89,6);
+ CREATE TABLE t1(a INT,b TEXT,c TEXT,d REAL) STRICT;
+ INSERT INTO t1 VALUES(1,'xyz','def',4.5);
+ CREATE TRIGGER t1tr BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO t1(a,b) VALUES(1000,'uvw');
+ UPDATE t1 SET b=NULL FROM (SELECT CAST(a AS varchar) FROM t1 ORDER BY b) NATURAL LEFT FULL JOIN t1 AS text;
+ END;
+ UPDATE t1 SET b=b|100;
+ SELECT * FROM t1 ORDER BY a;
+} {
+ 1 100 def 4.5
+ 1000 - - -
+}
+
+finish_test
diff --git a/test/upfromfault.test b/test/upfromfault.test
new file mode 100644
index 0000000..e876c07
--- /dev/null
+++ b/test/upfromfault.test
@@ -0,0 +1,139 @@
+# 2020 April 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
+set testprefix upfromfault
+
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE t1(x PRIMARY KEY, y, z UNIQUE);
+ CREATE INDEX t1y ON t1(y);
+ }
+ 2 {
+ CREATE TABLE t1(x PRIMARY KEY, y, z UNIQUE) WITHOUT ROWID;
+ CREATE INDEX t1y ON t1(y);
+ }
+ 3 {
+ CREATE TABLE t1(x, y, z UNIQUE, PRIMARY KEY(x,y)) WITHOUT ROWID;
+ }
+ 4 {
+ CREATE VIRTUAL TABLE t1 USING fts5(x, y, z);
+ }
+ 5 {
+ CREATE TABLE real(x, y, z);
+ CREATE VIEW t1 AS SELECT * FROM real;
+ CREATE TRIGGER t1_insert INSTEAD OF INSERT ON t1 BEGIN
+ INSERT INTO real VALUES(new.x, new.y, new.z);
+ END;
+ CREATE TRIGGER t1_update INSTEAD OF UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES(old.z || '->' || new.z);
+ UPDATE real SET y=new.y, z=new.z WHERE x=old.x;
+ END;
+ }
+} {
+if {$tn<5} continue
+ reset_db
+
+ ifcapable !fts5 { if {$tn==4} continue }
+
+ execsql $sql
+ do_execsql_test 1.$tn.0 {
+ CREATE TABLE log(t TEXT);
+
+ INSERT INTO t1 VALUES(1, 'i', 'one');
+ INSERT INTO t1 VALUES(2, 'ii', 'two');
+ INSERT INTO t1 VALUES(3, 'iii', 'three');
+ INSERT INTO t1 VALUES(4, 'iv', 'four');
+ }
+ if {$tn!=4 && $tn!=5} {
+ do_execsql_test 1.$tn.0b {
+ CREATE TRIGGER tr1 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES(old.z || '->' || new.z);
+ END;
+ CREATE TRIGGER tr2 AFTER UPDATE ON t1 BEGIN
+ INSERT INTO log VALUES(old.y || '->' || new.y);
+ END;
+ }
+ }
+
+ faultsim_save_and_close
+
+ do_faultsim_test 1.$tn -prep {
+ faultsim_restore_and_reopen
+ execsql { SELECT * FROM t1 }
+ } -body {
+ execsql {
+ WITH data(k, v) AS (
+ VALUES(3, 'thirty'), (1, 'ten')
+ )
+ UPDATE t1 SET z=v FROM data WHERE x=k;
+ }
+ } -test {
+ faultsim_test_result {0 {}} {1 {vtable constructor failed: t1}}
+ if {$testrc==0} {
+ set res [execsql { SELECT * FROM t1 }]
+ if {$res!="1 i ten 2 ii two 3 iii thirty 4 iv four"} {
+ error "unexpected result: $res"
+ }
+ }
+ }
+}
+
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(x, y, z);
+}
+faultsim_save_and_close
+do_faultsim_test 2.1 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ UPDATE t2 SET x=a FROM t1 WHERE c=z;
+ END;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+faultsim_restore_and_reopen
+do_execsql_test 2.2 {
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ UPDATE t1 SET a=x FROM t2 WHERE c=z;
+ END;
+
+ INSERT INTO t2 VALUES(1, 1, 1);
+ INSERT INTO t2 VALUES(2, 2, 2);
+ INSERT INTO t2 VALUES(3, 3, 3);
+}
+faultsim_save_and_close
+
+do_faultsim_test 2.3 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ INSERT INTO t1 VALUES(NULL, NULL, 1), (NULL, NULL, 3);
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ if {$testrc==0} {
+ set res [execsql { SELECT * FROM t1 }]
+ if {$res!="1 {} 1 3 {} 3"} {
+ error "unexpected result: $res"
+ }
+ }
+}
+
+
+finish_test
diff --git a/test/upsert1.test b/test/upsert1.test
new file mode 100644
index 0000000..a321d61
--- /dev/null
+++ b/test/upsert1.test
@@ -0,0 +1,258 @@
+# 2018-04-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.
+#
+#***********************************************************************
+#
+# Test cases for UPSERT
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix zipfile
+
+do_execsql_test upsert1-100 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c DEFAULT 0);
+ CREATE UNIQUE INDEX t1x1 ON t1(b);
+ INSERT INTO t1(a,b) VALUES(1,2) ON CONFLICT DO NOTHING;
+ INSERT INTO t1(a,b) VALUES(1,99),(99,2) ON CONFLICT DO NOTHING;
+ SELECT * FROM t1;
+} {1 2 0}
+do_execsql_test upsert1-101 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b) VALUES(2,3) ON CONFLICT(a) DO NOTHING;
+ INSERT INTO t1(a,b) VALUES(2,99) ON CONFLICT(a) DO NOTHING;
+ SELECT * FROM t1;
+} {2 3 0}
+do_execsql_test upsert1-102 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b) VALUES(3,4) ON CONFLICT(b) DO NOTHING;
+ INSERT INTO t1(a,b) VALUES(99,4) ON CONFLICT(b) DO NOTHING;
+ SELECT * FROM t1;
+} {3 4 0}
+do_catchsql_test upsert1-110 {
+ INSERT INTO t1(a,b) VALUES(5,6) ON CONFLICT(x) DO NOTHING;
+ SELECT * FROM t1;
+} {1 {no such column: x}}
+do_catchsql_test upsert1-120 {
+ INSERT INTO t1(a,b) VALUES(5,6) ON CONFLICT(c) DO NOTHING;
+ SELECT * FROM t1;
+} {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+breakpoint
+do_catchsql_test upsert1-130 {
+ INSERT INTO t1(a,b) VALUES(5,6) ON CONFLICT(b COLLATE nocase) DO NOTHING;
+ SELECT * FROM t1;
+} {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+do_execsql_test upsert1-140 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b) VALUES(5,6) ON CONFLICT(b COLLATE binary) DO NOTHING;
+ SELECT * FROM t1;
+} {5 6 0}
+
+do_catchsql_test upsert1-200 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c DEFAULT 0);
+ CREATE UNIQUE INDEX t1x1 ON t1(a+b);
+ INSERT INTO t1(a,b) VALUES(7,8) ON CONFLICT(a+b) DO NOTHING;
+ INSERT INTO t1(a,b) VALUES(8,7),(9,6) ON CONFLICT(a+b) DO NOTHING;
+ SELECT * FROM t1;
+} {0 {7 8 0}}
+do_catchsql_test upsert1-201 {
+ INSERT INTO t1(a,b) VALUES(8,7),(9,6) ON CONFLICT(a) DO NOTHING;
+} {1 {UNIQUE constraint failed: index 't1x1'}}
+do_catchsql_test upsert1-210 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b) VALUES(9,10) ON CONFLICT(a+(+b)) DO NOTHING;
+ SELECT * FROM t1;
+} {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+
+do_catchsql_test upsert1-300 {
+ DROP INDEX t1x1;
+ DELETE FROM t1;
+ CREATE UNIQUE INDEX t1x1 ON t1(b) WHERE b>10;
+ INSERT INTO t1(a,b) VALUES(1,2),(3,2) ON CONFLICT(b) DO NOTHING;
+ SELECT * FROM t1;
+} {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+do_catchsql_test upsert1-310 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b) VALUES(1,2),(3,2) ON CONFLICT(b) WHERE b!=10 DO NOTHING;
+ SELECT * FROM t1;
+} {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+do_execsql_test upsert1-320 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b) VALUES(1,2),(3,2),(4,20),(5,20)
+ ON CONFLICT(b) WHERE b>10 DO NOTHING;
+ SELECT *, 'x' FROM t1 ORDER BY b, a;
+} {1 2 0 x 3 2 0 x 4 20 0 x}
+
+# Upsert works with count_changes=on;
+do_execsql_test upsert1-400 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a TEXT UNIQUE, b INT DEFAULT 1);
+ INSERT INTO t2(a) VALUES('one'),('two'),('three');
+ PRAGMA count_changes=ON;
+ INSERT INTO t2(a) VALUES('one'),('one'),('three'),('four')
+ ON CONFLICT(a) DO UPDATE SET b=b+1;
+} {1}
+do_execsql_test upsert1-410 {
+ PRAGMA count_changes=OFF;
+ SELECT a, b FROM t2 ORDER BY a;
+} {four 1 one 3 three 2 two 1}
+
+# Problem found by AFL prior to any release
+do_execsql_test upsert1-500 {
+ DROP TABLE t1;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y INT UNIQUE);
+ INSERT INTO t1(x,y) SELECT 1,2 WHERE true
+ ON CONFLICT(x) DO UPDATE SET y=max(t1.y,excluded.y) AND true;
+ SELECT * FROM t1;
+} {1 2}
+
+# 2018-07-11
+# Ticket https://sqlite.org/src/tktview/79cad5e4b2e219dd197242e9e5f4
+# UPSERT leads to a corrupt index.
+#
+do_execsql_test upsert1-600 {
+ DROP TABLE t1;
+ CREATE TABLE t1(b UNIQUE, a INT PRIMARY KEY) WITHOUT ROWID;
+ INSERT OR IGNORE INTO t1(a) VALUES('1') ON CONFLICT(a) DO NOTHING;
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test upsert1-610 {
+ DELETE FROM t1;
+ INSERT OR IGNORE INTO t1(a) VALUES('1'),(1) ON CONFLICT(a) DO NOTHING;
+ PRAGMA integrity_check;
+} {ok}
+
+# 2018-08-14
+# Ticket https://www.sqlite.org/src/info/908f001483982c43
+# If there are multiple uniqueness contraints, the UPSERT should fire
+# if the one constraint it targets fails, regardless of whether or not
+# the other constraints pass or fail. In other words, the UPSERT constraint
+# should be tested first.
+#
+do_execsql_test upsert1-700 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c INT, d INT, e INT);
+ CREATE UNIQUE INDEX t1b ON t1(b);
+ CREATE UNIQUE INDEX t1e ON t1(e);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,33,44,5)
+ ON CONFLICT(e) DO UPDATE SET c=excluded.c;
+ SELECT * FROM t1;
+} {1 2 33 4 5}
+do_execsql_test upsert1-710 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,33,44,5)
+ ON CONFLICT(a) DO UPDATE SET c=excluded.c;
+ SELECT * FROM t1;
+} {1 2 33 4 5}
+do_execsql_test upsert1-720 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,33,44,5)
+ ON CONFLICT(b) DO UPDATE SET c=excluded.c;
+ SELECT * FROM t1;
+} {1 2 33 4 5}
+do_execsql_test upsert1-730 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INT, b INT, c INT, d INT, e INT);
+ CREATE UNIQUE INDEX t1a ON t1(a);
+ CREATE UNIQUE INDEX t1b ON t1(b);
+ CREATE UNIQUE INDEX t1e ON t1(e);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,33,44,5)
+ ON CONFLICT(e) DO UPDATE SET c=excluded.c;
+ SELECT * FROM t1;
+} {1 2 33 4 5}
+do_execsql_test upsert1-740 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,33,44,5)
+ ON CONFLICT(a) DO UPDATE SET c=excluded.c;
+ SELECT * FROM t1;
+} {1 2 33 4 5}
+do_execsql_test upsert1-750 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,33,44,5)
+ ON CONFLICT(b) DO UPDATE SET c=excluded.c;
+ SELECT * FROM t1;
+} {1 2 33 4 5}
+do_execsql_test upsert1-760 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INT PRIMARY KEY, b INT, c INT, d INT, e INT) WITHOUT ROWID;
+ CREATE UNIQUE INDEX t1a ON t1(a);
+ CREATE UNIQUE INDEX t1b ON t1(b);
+ CREATE UNIQUE INDEX t1e ON t1(e);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,33,44,5)
+ ON CONFLICT(e) DO UPDATE SET c=excluded.c;
+ SELECT * FROM t1;
+} {1 2 33 4 5}
+do_execsql_test upsert1-770 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,33,44,5)
+ ON CONFLICT(a) DO UPDATE SET c=excluded.c;
+ SELECT * FROM t1;
+} {1 2 33 4 5}
+do_execsql_test upsert1-780 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,33,44,5)
+ ON CONFLICT(b) DO UPDATE SET c=excluded.c;
+ SELECT * FROM t1;
+} {1 2 33 4 5}
+
+# 2019-08-30 ticket https://sqlite.org/src/info/5a3dba8104421320
+do_execsql_test upsert1-800 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 REAL UNIQUE, c1);
+ CREATE UNIQUE INDEX test800i0 ON t0(0 || c1);
+ INSERT INTO t0(c0, c1) VALUES (1, 2), (2, 1);
+ INSERT INTO t0(c0) VALUES (1) ON CONFLICT(c0) DO UPDATE SET c1=excluded.c0;
+ PRAGMA integrity_check;
+ REINDEX;
+} {ok}
+
+# 2019-12-06 gramfuzz find
+sqlite3 db :memory:
+do_execsql_test upsert1-900 {
+ CREATE VIEW t1(a) AS SELECT 1;
+ CREATE TRIGGER t1r1 INSTEAD OF INSERT ON t1 BEGIN
+ SELECT 2;
+ END;
+}
+do_catchsql_test upsert1-910 {
+ INSERT INTO t1 VALUES(3) ON CONFLICT(x) DO NOTHING;
+} {1 {cannot UPSERT a view}}
+
+# 2019-12-26 ticket 7c13db5c3bf74001
+reset_db
+do_catchsql_test upsert1-1000 {
+ CREATE TABLE t0(c0 PRIMARY KEY, c1, c2 UNIQUE) WITHOUT ROWID;
+ INSERT OR FAIL INTO t0(c2) VALUES (0), (NULL)
+ ON CONFLICT(c2) DO UPDATE SET c1 = c0;
+} {1 {NOT NULL constraint failed: t0.c0}}
+
+# 2021-12-29 forum post https://sqlite.org/forum/forumpost/06b16b8b29f8c8c3
+# By Jingzhou Fu. When there is both an INTEGER PRIMARY KEY ON CONFLICT REPLACE
+# and an upsert on a constraint other than the INTEGER PRIMARY KEY, the
+# constraint checking logic generates invalid bytecode which might result
+# in a NULL pointer dereference.
+#
+reset_db
+do_execsql_test upsert1-1100 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT REPLACE, b UNIQUE);
+ INSERT INTO t1(b) VALUES(22);
+ INSERT INTO t1 VALUES(2,22) ON CONFLICT (b) DO NOTHING;
+ SELECT * FROM t1;
+} {1 22}
+
+finish_test
diff --git a/test/upsert2.test b/test/upsert2.test
new file mode 100644
index 0000000..5cbc465
--- /dev/null
+++ b/test/upsert2.test
@@ -0,0 +1,170 @@
+# 2018-04-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 UPSERT
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix zipfile
+
+do_execsql_test upsert2-100 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b int, c DEFAULT 0);
+ INSERT INTO t1(a,b) VALUES(1,2),(3,4);
+ INSERT INTO t1(a,b) VALUES(1,8),(2,11),(3,1)
+ ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=c+1 WHERE t1.b<excluded.b;
+ SELECT *, 'x' FROM t1 ORDER BY a;
+} {1 8 1 x 2 11 0 x 3 4 0 x}
+do_execsql_test upsert2-110 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INT PRIMARY KEY, b int, c DEFAULT 0) WITHOUT ROWID;
+ INSERT INTO t1(a,b) VALUES(1,2),(3,4);
+ INSERT INTO t1(a,b) VALUES(1,8),(2,11),(3,1)
+ ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=c+1 WHERE t1.b<excluded.b;
+ SELECT *, 'x' FROM t1 ORDER BY a;
+} {1 8 1 x 2 11 0 x 3 4 0 x}
+
+do_execsql_test upsert2-200 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b int, c DEFAULT 0);
+ INSERT INTO t1(a,b) VALUES(1,2),(3,4);
+ WITH nx(a,b) AS (VALUES(1,8),(2,11),(3,1),(2,15),(1,4),(1,99))
+ INSERT INTO t1(a,b) SELECT a, b FROM nx WHERE true
+ ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=c+1 WHERE t1.b<excluded.b;
+ SELECT *, 'x' FROM t1 ORDER BY a;
+} {1 99 2 x 2 15 1 x 3 4 0 x}
+do_execsql_test upsert2-201 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b) VALUES(1,2),(3,4);
+ WITH nx(a,b) AS (VALUES(1,8),(2,11),(3,1),(2,15),(1,4),(1,99))
+ INSERT INTO main.t1 AS t2(a,b) SELECT a, b FROM nx WHERE true
+ ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=t2.c+1 WHERE t2.b<excluded.b;
+ SELECT *, 'x' FROM t1 ORDER BY a;
+} {1 99 2 x 2 15 1 x 3 4 0 x}
+do_catchsql_test upsert2-202 {
+ WITH nx(a,b) AS (VALUES(1,8),(2,11),(3,1),(2,15),(1,4),(1,99))
+ INSERT INTO t1 AS t2(a,b) SELECT a, b FROM nx WHERE true
+ ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=t1.c+1 WHERE t1.b<excluded.b;
+} {1 {no such column: t1.c}}
+do_execsql_test upsert2-210 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INT PRIMARY KEY, b int, c DEFAULT 0) WITHOUT ROWID;
+ INSERT INTO t1(a,b) VALUES(1,2),(3,4);
+ WITH nx(a,b) AS (VALUES(1,8),(2,11),(3,1),(2,15),(1,4),(1,99))
+ INSERT INTO t1(a,b) SELECT a, b FROM nx WHERE true
+ ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=c+1 WHERE t1.b<excluded.b;
+ SELECT *, 'x' FROM t1 ORDER BY a;
+} {1 99 2 x 2 15 1 x 3 4 0 x}
+
+# On an ON CONFLICT DO UPDATE, the before-insert, before-update, and
+# after-update triggers fire.
+#
+do_execsql_test upsert2-300 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b int, c DEFAULT 0);
+ CREATE TABLE record(x TEXT, y TEXT);
+ CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO record(x,y)
+ VALUES('before-insert',format('%d,%d,%d',new.a,new.b,new.c));
+ END;
+ CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN
+ INSERT INTO record(x,y)
+ VALUES('after-insert',printf('%d,%d,%d',new.a,new.b,new.c));
+ END;
+ CREATE TRIGGER r3 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO record(x,y)
+ VALUES('before-update',format('%d,%d,%d/%d,%d,%d',
+ old.a,old.b,old.c,new.a,new.b,new.c));
+ END;
+ CREATE TRIGGER r4 AFTER UPDATE ON t1 BEGIN
+ INSERT INTO record(x,y)
+ VALUES('after-update',printf('%d,%d,%d/%d,%d,%d',
+ old.a,old.b,old.c,new.a,new.b,new.c));
+ END;
+ INSERT INTO t1(a,b) VALUES(1,2);
+ DELETE FROM record;
+ INSERT INTO t1(a,b) VALUES(1,2)
+ ON CONFLICT(a) DO UPDATE SET c=t1.c+1;
+ SELECT * FROM record
+} {before-insert 1,2,0 before-update 1,2,0/1,2,1 after-update 1,2,0/1,2,1}
+
+# On an ON CONFLICT DO NOTHING, only the before-insert trigger fires.
+#
+do_execsql_test upsert2-310 {
+ DELETE FROM record;
+ INSERT INTO t1(a,b) VALUES(1,2) ON CONFLICT DO NOTHING;
+ SELECT * FROM record;
+} {before-insert 1,2,0}
+
+# With ON CONFLICT DO UPDATE and a failed WHERE, only the before-insert
+# trigger fires.
+#
+do_execsql_test upsert2-320 {
+ DELETE FROM record;
+ INSERT INTO t1(a,b) VALUES(1,2)
+ ON CONFLICT(a) DO UPDATE SET c=c+1 WHERE c<0;
+ SELECT * FROM record;
+} {before-insert 1,2,0}
+do_execsql_test upsert2-321 {
+ SELECT * FROM t1;
+} {1 2 1}
+
+# Trigger tests repeated for a WITHOUT ROWID table.
+#
+do_execsql_test upsert2-400 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a INT PRIMARY KEY, b int, c DEFAULT 0) WITHOUT ROWID;
+ CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
+ INSERT INTO record(x,y)
+ VALUES('before-insert',format('%d,%d,%d',new.a,new.b,new.c));
+ END;
+ CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN
+ INSERT INTO record(x,y)
+ VALUES('after-insert',printf('%d,%d,%d',new.a,new.b,new.c));
+ END;
+ CREATE TRIGGER r3 BEFORE UPDATE ON t1 BEGIN
+ INSERT INTO record(x,y)
+ VALUES('before-update',format('%d,%d,%d/%d,%d,%d',
+ old.a,old.b,old.c,new.a,new.b,new.c));
+ END;
+ CREATE TRIGGER r4 AFTER UPDATE ON t1 BEGIN
+ INSERT INTO record(x,y)
+ VALUES('after-update',printf('%d,%d,%d/%d,%d,%d',
+ old.a,old.b,old.c,new.a,new.b,new.c));
+ END;
+ INSERT INTO t1(a,b) VALUES(1,2);
+ DELETE FROM record;
+ INSERT INTO t1(a,b) VALUES(1,2)
+ ON CONFLICT(a) DO UPDATE SET c=t1.c+1;
+ SELECT * FROM record
+} {before-insert 1,2,0 before-update 1,2,0/1,2,1 after-update 1,2,0/1,2,1}
+
+# On an ON CONFLICT DO NOTHING, only the before-insert trigger fires.
+#
+do_execsql_test upsert2-410 {
+ DELETE FROM record;
+ INSERT INTO t1(a,b) VALUES(1,2) ON CONFLICT DO NOTHING;
+ SELECT * FROM record;
+} {before-insert 1,2,0}
+
+# With ON CONFLICT DO UPDATE and a failed WHERE, only the before-insert
+# trigger fires.
+#
+do_execsql_test upsert2-420 {
+ DELETE FROM record;
+ INSERT INTO t1(a,b) VALUES(1,2)
+ ON CONFLICT(a) DO UPDATE SET c=c+1 WHERE c<0;
+ SELECT * FROM record;
+} {before-insert 1,2,0}
+do_execsql_test upsert2-421 {
+ SELECT * FROM t1;
+} {1 2 1}
+
+finish_test
diff --git a/test/upsert3.test b/test/upsert3.test
new file mode 100644
index 0000000..b6242e9
--- /dev/null
+++ b/test/upsert3.test
@@ -0,0 +1,58 @@
+# 2018-04-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 UPSERT
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix zipfile
+
+do_execsql_test upsert3-100 {
+ CREATE TABLE t1(k int, v text);
+ CREATE UNIQUE INDEX x1 ON t1(k, v);
+} {}
+do_catchsql_test upsert3-110 {
+ INSERT INTO t1 VALUES(0,'abcdefghij')
+ ON CONFLICT(k) DO NOTHING;
+} {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+do_catchsql_test upsert3-120 {
+ INSERT INTO t1 VALUES(0,'abcdefghij')
+ ON CONFLICT(v) DO NOTHING;
+} {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+
+do_execsql_test upsert3-130 {
+ INSERT INTO t1 VALUES(0, 'abcdefghij')
+ ON CONFLICT(k,v) DO NOTHING;
+ SELECT * FROM t1;
+} {0 abcdefghij}
+do_execsql_test upsert3-140 {
+ INSERT INTO t1 VALUES(0, 'abcdefghij')
+ ON CONFLICT(v,k) DO NOTHING;
+ SELECT * FROM t1;
+} {0 abcdefghij}
+
+do_execsql_test upsert3-200 {
+ CREATE TABLE excluded(a INT, b INT, c INT DEFAULT 0);
+ CREATE UNIQUE INDEX excludedab ON excluded(a,b);
+ INSERT INTO excluded(a,b) VALUES(1,2),(1,2),(3,4),(1,2),(5,6),(3,4)
+ ON CONFLICT(b,a) DO UPDATE SET c=excluded.c+1;
+ SELECT *, 'x' FROM excluded ORDER BY a;
+} {1 2 2 x 3 4 1 x 5 6 0 x}
+do_execsql_test upsert3-210 {
+ INSERT INTO excluded AS base(a,b,c) VALUES(1,2,8),(1,2,3)
+ ON CONFLICT(b,a) DO UPDATE SET c=excluded.c+1 WHERE base.c<excluded.c;
+ SELECT *, 'x' FROM excluded ORDER BY a;
+} {1 2 9 x 3 4 1 x 5 6 0 x}
+
+
+
+finish_test
diff --git a/test/upsert4.test b/test/upsert4.test
new file mode 100644
index 0000000..c4bcc03
--- /dev/null
+++ b/test/upsert4.test
@@ -0,0 +1,407 @@
+# 2018-04-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 UPSERT
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix upsert4
+
+foreach {tn sql} {
+ 1 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c UNIQUE) }
+ 2 { CREATE TABLE t1(a INT PRIMARY KEY, b, c UNIQUE) }
+ 3 { CREATE TABLE t1(a INT PRIMARY KEY, b, c UNIQUE) WITHOUT ROWID}
+} {
+ reset_db
+ execsql $sql
+
+ do_execsql_test 1.$tn.0 {
+ INSERT INTO t1 VALUES(1, NULL, 'one');
+ INSERT INTO t1 VALUES(2, NULL, 'two');
+ INSERT INTO t1 VALUES(3, NULL, 'three');
+ }
+
+ do_execsql_test 1.$tn.1 {
+ INSERT INTO t1 VALUES(1, NULL, 'xyz') ON CONFLICT DO NOTHING;
+ SELECT * FROM t1;
+ } {
+ 1 {} one 2 {} two 3 {} three
+ }
+
+ do_execsql_test 1.$tn.2 {
+ INSERT INTO t1 VALUES(4, NULL, 'two') ON CONFLICT DO NOTHING;
+ SELECT * FROM t1;
+ } {
+ 1 {} one 2 {} two 3 {} three
+ }
+
+ do_execsql_test 1.$tn.3 {
+ INSERT INTO t1 VALUES(4, NULL, 'two') ON CONFLICT (c) DO UPDATE SET b = 1;
+ SELECT * FROM t1;
+ } {
+ 1 {} one 2 1 two 3 {} three
+ }
+
+ do_execsql_test 1.$tn.4 {
+ INSERT INTO t1 VALUES(2, NULL, 'zero') ON CONFLICT (a) DO UPDATE SET b=2;
+ SELECT * FROM t1;
+ } {1 {} one 2 2 two 3 {} three}
+
+ do_catchsql_test 1.$tn.5 {
+ INSERT INTO t1 VALUES(2, NULL, 'zero') ON CONFLICT (a)
+ DO UPDATE SET c = 'one';
+ } {1 {UNIQUE constraint failed: t1.c}}
+
+ do_execsql_test 1.$tn.6 {
+ SELECT * FROM t1;
+ } {1 {} one 2 2 two 3 {} three}
+
+ do_execsql_test 1.$tn.7 {
+ INSERT INTO t1 VALUES(2, NULL, 'zero') ON CONFLICT (a)
+ DO UPDATE SET (b, c) = (SELECT 'x', 'y');
+ SELECT * FROM t1;
+ } {1 {} one 2 x y 3 {} three}
+
+ do_execsql_test 1.$tn.8 {
+ INSERT INTO t1 VALUES(1, NULL, NULL) ON CONFLICT (a)
+ DO UPDATE SET (c, a) = ('four', 4);
+ SELECT * FROM t1 ORDER BY 1;
+ } {2 x y 3 {} three 4 {} four}
+}
+
+#-------------------------------------------------------------------------
+# Test target analysis.
+#
+set rtbl(0) {0 {}}
+set rtbl(1) {/1 .*failed.*/}
+set rtbl(2) {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE xyz(a INTEGER PRIMARY KEY, b, c, d);
+ CREATE UNIQUE INDEX xyz1 ON xyz(d, c, b COLLATE nocase);
+ }
+
+ 2 {
+ CREATE TABLE xyz(a INT PRIMARY KEY, b, c, d);
+ CREATE UNIQUE INDEX xyz1 ON xyz(d, c, b COLLATE nocase);
+ }
+
+ 3 {
+ CREATE TABLE xyz(a INT PRIMARY KEY, b, c, d) WITHOUT ROWID;
+ CREATE UNIQUE INDEX xyz1 ON xyz(d, c, b COLLATE nocase);
+ }
+} {
+ reset_db
+ execsql $sql
+ do_execsql_test 2.$tn.1 {
+ INSERT INTO xyz VALUES(10, 1, 1, 'one');
+ }
+
+
+ foreach {tn2 oc res} {
+ 1 "ON CONFLICT (b COLLATE nocase, c, d) DO NOTHING" 0
+ 2 "ON CONFLICT (b, c, d) DO NOTHING" 0
+ 3 "ON CONFLICT (b, c COLLATE nocase, d) DO NOTHING" 2
+ 4 "ON CONFLICT (a) DO NOTHING" 1
+ 5 "ON CONFLICT DO NOTHING" 0
+ 6 "ON CONFLICT (b, c, d) WHERE a!=0 DO NOTHING" 0
+ 7 "ON CONFLICT (d, c, c) WHERE a!=0 DO NOTHING" 2
+ 8 "ON CONFLICT (b COLLATE nocase, c COLLATE nocase, d) DO NOTHING" 2
+ 9 "ON CONFLICT (b, c, d) WHERE b==45 DO NOTHING" 0
+ } {
+
+ do_catchsql_test 2.$tn.2.$tn2 "
+ INSERT INTO xyz VALUES(11, 1, 1, 'one') $oc
+ " $rtbl($res)
+ }
+
+ do_execsql_test 2.$tn.3 {
+ SELECT * FROM xyz;
+ } {10 1 1 one}
+}
+
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE abc(a INTEGER PRIMARY KEY, x, y);
+ CREATE UNIQUE INDEX abc1 ON abc(('x' || x) COLLATE nocase);
+ }
+ 2 {
+ CREATE TABLE abc(a INT PRIMARY KEY, x, y);
+ CREATE UNIQUE INDEX abc1 ON abc(('x' || x) COLLATE nocase);
+ }
+ 3 {
+ CREATE TABLE abc(a INT PRIMARY KEY, x, y) WITHOUT ROWID;
+ CREATE UNIQUE INDEX abc1 ON abc(('x' || x) COLLATE nocase);
+ }
+} {
+ reset_db
+ execsql $sql
+ do_execsql_test 3.$tn.1 {
+ INSERT INTO abc VALUES(1, 'one', 'two');
+ }
+
+ foreach {tn2 oc res} {
+ 1 "ON CONFLICT DO NOTHING" 0
+ 2 "ON CONFLICT ('x' || x) DO NOTHING" 0
+ 3 "ON CONFLICT (('x' || x) COLLATE nocase) DO NOTHING" 0
+ 4 "ON CONFLICT (('x' || x) COLLATE binary) DO NOTHING" 2
+ 5 "ON CONFLICT (x || 'x') DO NOTHING" 2
+ 6 "ON CONFLICT ((('x' || x))) DO NOTHING" 0
+ } {
+ do_catchsql_test 3.$tn.2.$tn2 "
+ INSERT INTO abc VALUES(2, 'one', NULL) $oc;
+ " $rtbl($res)
+ }
+
+ do_execsql_test 3.$tn.3 {
+ SELECT * FROM abc
+ } {1 one two}
+}
+
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE abc(a INTEGER PRIMARY KEY, x, y);
+ CREATE UNIQUE INDEX abc1 ON abc(x) WHERE y>0;
+ CREATE UNIQUE INDEX abc2 ON abc(y) WHERE x='xyz' COLLATE nocase;
+ }
+} {
+ reset_db
+ execsql $sql
+ do_execsql_test 4.$tn.1 {
+ INSERT INTO abc VALUES(1, 'one', 1);
+ INSERT INTO abc VALUES(2, 'two', 2);
+ INSERT INTO abc VALUES(3, 'xyz', 3);
+ INSERT INTO abc VALUES(4, 'XYZ', 4);
+ }
+
+ foreach {tn2 oc res} {
+ 1 "ON CONFLICT DO NOTHING" 0
+ 2 "ON CONFLICT(x) WHERE y>0 DO NOTHING" 0
+ 3 "ON CONFLICT(x) DO NOTHING" 2
+ 4 "ON CONFLICT(x) WHERE y>=0 DO NOTHING" 2
+ 5 "ON CONFLICT(y) WHERE x='xyz' COLLATE nocase DO NOTHING" 1
+ } {
+ do_catchsql_test 4.$tn.2.$tn2 "
+ INSERT INTO abc VALUES(5, 'one', 10) $oc
+ " $rtbl($res)
+ }
+
+ do_execsql_test 4.$tn.3 {
+ SELECT * FROM abc
+ } {1 one 1 2 two 2 3 xyz 3 4 XYZ 4}
+
+ foreach {tn2 oc res} {
+ 1 "ON CONFLICT DO NOTHING" 0
+ 2 "ON CONFLICT(y) WHERE x='xyz' COLLATE nocase DO NOTHING" 0
+ 3 "ON CONFLICT(y) WHERE x='xyz' COLLATE binary DO NOTHING" 2
+ 4 "ON CONFLICT(x) WHERE y>0 DO NOTHING" 1
+ } {
+ do_catchsql_test 4.$tn.2.$tn2 "
+ INSERT INTO abc VALUES(5, 'xYz', 3) $oc
+ " $rtbl($res)
+ }
+}
+
+do_catchsql_test 5.0 {
+ CREATE TABLE w1(a INT PRIMARY KEY, x, y);
+ CREATE UNIQUE INDEX w1expr ON w1(('x' || x));
+ INSERT INTO w1 VALUES(2, 'one', NULL)
+ ON CONFLICT (('x' || x) COLLATE nocase) DO NOTHING;
+} {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+
+#-------------------------------------------------------------------------
+# Test that ON CONFLICT constraint processing occurs before any REPLACE
+# constraint processing.
+#
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c);
+ }
+ 2 {
+ CREATE TABLE t1(a INT PRIMARY KEY, b UNIQUE, c);
+ }
+ 3 {
+ CREATE TABLE t1(a INT PRIMARY KEY, b UNIQUE, c) WITHOUT ROWID;
+ }
+} {
+ reset_db
+ execsql $sql
+ do_execsql_test 6.1.$tn {
+ INSERT INTO t1 VALUES(1, 1, 'one');
+ INSERT INTO t1 VALUES(2, 2, 'two');
+ INSERT OR REPLACE INTO t1 VALUES(1, 2, 'two') ON CONFLICT(b) DO NOTHING;
+ PRAGMA integrity_check;
+ } {ok}
+}
+
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c UNIQUE);
+ }
+} {
+ reset_db
+ execsql $sql
+
+ do_execsql_test 6.2.$tn.1 {
+ INSERT INTO t1 VALUES(1, 1, 1);
+ INSERT INTO t1 VALUES(2, 2, 2);
+ }
+
+ do_execsql_test 6.2.$tn.2 {
+ INSERT OR REPLACE INTO t1 VALUES(3, 1, 1) ON CONFLICT(b) DO NOTHING;
+ SELECT * FROM t1;
+ PRAGMA integrity_check;
+ } {1 1 1 2 2 2 ok}
+
+ do_execsql_test 6.2.$tn.3 {
+ INSERT OR REPLACE INTO t1 VALUES(3, 2, 2) ON CONFLICT(c) DO NOTHING;
+ SELECT * FROM t1;
+ PRAGMA integrity_check;
+ } {1 1 1 2 2 2 ok}
+
+ do_execsql_test 6.2.$tn.2 {
+ INSERT OR REPLACE INTO t1 VALUES(3, 1, 1) ON CONFLICT(b)
+ DO UPDATE SET b=b||'x';
+ SELECT * FROM t1;
+ PRAGMA integrity_check;
+ } {1 1x 1 2 2 2 ok}
+
+ do_execsql_test 6.2.$tn.2 {
+ INSERT OR REPLACE INTO t1 VALUES(3, 2, 2) ON CONFLICT(c)
+ DO UPDATE SET c=c||'x';
+ SELECT * FROM t1;
+ PRAGMA integrity_check;
+ } {1 1x 1 2 2 2x ok}
+}
+
+#-------------------------------------------------------------------------
+# Test references to "excluded". And using an alias in an INSERT
+# statement.
+#
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE t1(w, x, y, z, PRIMARY KEY(x, y));
+ CREATE UNIQUE INDEX zz ON t1(z);
+ }
+ 2 {
+ CREATE TABLE t1(w, x, y, z, PRIMARY KEY(x, y)) WITHOUT ROWID;
+ CREATE UNIQUE INDEX zz ON t1(z);
+ }
+} {
+ reset_db
+ execsql $sql
+ do_execsql_test 7.$tn.0 {
+ INSERT INTO t1 VALUES('a', 1, 1, 1);
+ INSERT INTO t1 VALUES('b', 2, 2, 2);
+ }
+
+ do_execsql_test 7.$tn.1 {
+ INSERT INTO t1 VALUES('c', 3, 3, 1) ON CONFLICT(z)
+ DO UPDATE SET w = excluded.w;
+ SELECT * FROM t1;
+ } {c 1 1 1 b 2 2 2}
+
+ do_execsql_test 7.$tn.2 {
+ INSERT INTO t1 VALUES('c', 2, 2, 3) ON CONFLICT(y, x)
+ DO UPDATE SET w = w||w;
+ SELECT * FROM t1;
+ } {c 1 1 1 bb 2 2 2}
+
+ do_execsql_test 7.$tn.3 {
+ INSERT INTO t1 VALUES('c', 2, 2, 3) ON CONFLICT(y, x)
+ DO UPDATE SET w = w||t1.w;
+ SELECT * FROM t1;
+ } {c 1 1 1 bbbb 2 2 2}
+
+ do_execsql_test 7.$tn.4 {
+ INSERT INTO t1 AS tbl VALUES('c', 2, 2, 3) ON CONFLICT(y, x)
+ DO UPDATE SET w = w||tbl.w;
+ SELECT * FROM t1;
+ } {c 1 1 1 bbbbbbbb 2 2 2}
+}
+
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE excluded(w, x INTEGER, 'a b', z, PRIMARY KEY(x, 'a b'));
+ CREATE UNIQUE INDEX zz ON excluded(z);
+ CREATE INDEX zz2 ON excluded(z);
+ }
+ 2 {
+ CREATE TABLE excluded(w, x, 'a b', z, PRIMARY KEY(x, 'a b')) WITHOUT ROWID;
+ CREATE UNIQUE INDEX zz ON excluded(z);
+ CREATE INDEX zz2 ON excluded(z);
+ }
+} {
+ reset_db
+ execsql $sql
+ do_execsql_test 8.$tn.0 {
+ INSERT INTO excluded VALUES('a', 1, 1, 1);
+ INSERT INTO excluded VALUES('b', 2, 2, 2);
+ }
+
+ # Note: An error in Postgres: "table reference "excluded" is ambiguous".
+ #
+ do_execsql_test 8.$tn.1 {
+ INSERT INTO excluded VALUES('hello', 1, 1, NULL) ON CONFLICT(x, "a b")
+ DO UPDATE SET w=excluded.w;
+ SELECT * FROM excluded;
+ } {a 1 1 1 b 2 2 2}
+
+ do_execsql_test 8.$tn.2 {
+ INSERT INTO excluded AS x1 VALUES('hello', 1, 1, NULL) ON CONFLICT(x, [a b])
+ DO UPDATE SET w=excluded.w;
+ SELECT * FROM excluded;
+ } {hello 1 1 1 b 2 2 2}
+
+ do_execsql_test 8.$tn.3 {
+ INSERT INTO excluded AS x1 VALUES('hello', 1, 1, NULL) ON CONFLICT(x, [a b])
+ DO UPDATE SET w=w||w WHERE excluded.w!='hello';
+ SELECT * FROM excluded;
+ } {hello 1 1 1 b 2 2 2}
+
+ do_execsql_test 8.$tn.4 {
+ INSERT INTO excluded AS x1 VALUES('hello', 1, 1, NULL) ON CONFLICT(x, [a b])
+ DO UPDATE SET w=w||w WHERE excluded.x=1;
+ SELECT * FROM excluded;
+ } {hellohello 1 1 1 b 2 2 2}
+
+ do_catchsql_test 8.$tn.5 {
+ INSERT INTO excluded AS x1 VALUES('hello', 1, 1, NULL)
+ ON CONFLICT(x, [a b]) WHERE y=1
+ DO UPDATE SET w=w||w WHERE excluded.x=1;
+ } {1 {no such column: y}}
+}
+
+#--------------------------------------------------------------------------
+#
+do_execsql_test 9.0 {
+ CREATE TABLE v(x INTEGER);
+ CREATE TABLE hist(x INTEGER PRIMARY KEY, cnt INTEGER);
+ CREATE TRIGGER vt AFTER INSERT ON v BEGIN
+ INSERT INTO hist VALUES(new.x, 1) ON CONFLICT(x) DO
+ UPDATE SET cnt=cnt+1;
+ END;
+}
+
+do_execsql_test 9.1 {
+ INSERT INTO v VALUES(1), (4), (1), (5), (5), (8), (9), (1);
+ SELECT * FROM hist;
+} {
+ 1 3
+ 4 1
+ 5 2
+ 8 1
+ 9 1
+}
+
+
+finish_test
diff --git a/test/upsert5.test b/test/upsert5.test
new file mode 100644
index 0000000..3161abf
--- /dev/null
+++ b/test/upsert5.test
@@ -0,0 +1,411 @@
+# 2020-12-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 cases for generalized UPSERT
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix upsert5
+
+foreach {tn sql} {
+ 1 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c UNIQUE, d UNIQUE, e UNIQUE) }
+ 2 { CREATE TABLE t1(a INT PRIMARY KEY, b, c UNIQUE, d UNIQUE, e UNIQUE) }
+ 3 { CREATE TABLE t1(a INT PRIMARY KEY, b, c UNIQUE, d UNIQUE, e UNIQUE) WITHOUT ROWID}
+ 4 { CREATE TABLE t1(e UNIQUE, d UNIQUE, c UNIQUE, a INTEGER PRIMARY KEY, b) }
+ 5 { CREATE TABLE t1(e UNIQUE, d UNIQUE, c UNIQUE, a INT PRIMARY KEY, b) }
+ 6 { CREATE TABLE t1(e UNIQUE, d UNIQUE, c UNIQUE, a INT PRIMARY KEY, b) WITHOUT ROWID}
+} {
+ reset_db
+ execsql $sql
+
+ do_execsql_test 1.$tn.100 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,3,4,5)
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 a 3 4 5}
+ do_execsql_test 1.$tn.101 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,3,4,5)
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 c 3 4 5}
+ do_execsql_test 1.$tn.102 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,4,5)
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 d 3 4 5}
+ do_execsql_test 1.$tn.103 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,94,5)
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 e 3 4 5}
+ do_execsql_test 1.$tn.200 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 a 3 4 5}
+ do_execsql_test 1.$tn.201 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,3,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 c 3 4 5}
+ do_execsql_test 1.$tn.202 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,3,4,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 c 3 4 5}
+ do_execsql_test 1.$tn.203 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 a 3 4 5}
+ do_execsql_test 1.$tn.204 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,4,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 a 3 4 5}
+ do_execsql_test 1.$tn.210 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 a 3 4 5}
+ do_execsql_test 1.$tn.211 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,4,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 d 3 4 5}
+ do_execsql_test 1.$tn.212 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 a 3 4 5}
+ do_execsql_test 1.$tn.213 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,94,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(a) DO UPDATE SET b='a'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 e 3 4 5}
+ do_execsql_test 1.$tn.214 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,94,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e'
+ ON CONFLICT(a) DO UPDATE SET b='a';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 e 3 4 5}
+ do_execsql_test 1.$tn.215 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e'
+ ON CONFLICT(a) DO UPDATE SET b='a';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 e 3 4 5}
+ do_execsql_test 1.$tn.216 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(e) DO UPDATE SET b='e'
+ ON CONFLICT(a) DO UPDATE SET b='a';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 a 3 4 5}
+
+ do_execsql_test 1.$tn.300 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(a) DO UPDATE SET b='a1'
+ ON CONFLICT(a) DO UPDATE SET b='a2'
+ ON CONFLICT(a) DO UPDATE SET b='a3'
+ ON CONFLICT(a) DO UPDATE SET b='a4'
+ ON CONFLICT(a) DO UPDATE SET b='a5'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 a1 3 4 5}
+ do_execsql_test 1.$tn.301 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,94,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT(a) DO UPDATE SET b='a1'
+ ON CONFLICT(a) DO UPDATE SET b='a2'
+ ON CONFLICT(a) DO UPDATE SET b='a3'
+ ON CONFLICT(a) DO UPDATE SET b='a4'
+ ON CONFLICT(a) DO UPDATE SET b='a5'
+ ON CONFLICT(e) DO UPDATE SET b='e';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 e 3 4 5}
+
+ do_execsql_test 1.$tn.400 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 x 3 4 5}
+ do_execsql_test 1.$tn.401 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,94,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 x 3 4 5}
+ do_execsql_test 1.$tn.402 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 x 3 4 5}
+ do_execsql_test 1.$tn.403 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,3,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 c 3 4 5}
+ do_execsql_test 1.$tn.404 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,3,4,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 c 3 4 5}
+ do_execsql_test 1.$tn.405 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,4,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 d 3 4 5}
+
+ do_execsql_test 1.$tn.410 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 x 3 4 5}
+ do_execsql_test 1.$tn.411 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,94,5)
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 x 3 4 5}
+ do_execsql_test 1.$tn.412 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,4,95)
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 x 3 4 5}
+ do_execsql_test 1.$tn.413 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,3,94,95)
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 x 3 4 5}
+
+ do_execsql_test 1.$tn.420 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT(c) DO NOTHING
+ ON CONFLICT(d) DO NOTHING
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 x 3 4 5}
+ do_execsql_test 1.$tn.421 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,94,5)
+ ON CONFLICT(c) DO NOTHING
+ ON CONFLICT(d) DO NOTHING
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 x 3 4 5}
+ do_execsql_test 1.$tn.422 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,4,95)
+ ON CONFLICT(c) DO NOTHING
+ ON CONFLICT(d) DO NOTHING
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 2 3 4 5}
+ do_execsql_test 1.$tn.423 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,3,94,95)
+ ON CONFLICT(c) DO NOTHING
+ ON CONFLICT(d) DO NOTHING
+ ON CONFLICT DO UPDATE set b='x';
+ SELECT a,b,c,d,e FROM t1;
+ } {1 2 3 4 5}
+
+ do_execsql_test 1.$tn.500 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO NOTHING;
+ SELECT a,b,c,d,e FROM t1;
+ } {1 2 3 4 5}
+ do_execsql_test 1.$tn.501 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,93,94,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO NOTHING;
+ SELECT a,b,c,d,e FROM t1;
+ } {1 2 3 4 5}
+ do_execsql_test 1.$tn.502 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO NOTHING;
+ SELECT a,b,c,d,e FROM t1;
+ } {1 2 3 4 5}
+ do_execsql_test 1.$tn.503 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,3,94,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO NOTHING;
+ SELECT a,b,c,d,e FROM t1;
+ } {1 c 3 4 5}
+ do_execsql_test 1.$tn.504 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(91,NULL,3,4,95)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO NOTHING;
+ SELECT a,b,c,d,e FROM t1;
+ } {1 c 3 4 5}
+ do_execsql_test 1.$tn.505 {
+ DELETE FROM t1;
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
+ INSERT INTO t1(a,b,c,d,e) VALUES(1,NULL,93,4,5)
+ ON CONFLICT(c) DO UPDATE SET b='c'
+ ON CONFLICT(d) DO UPDATE SET b='d'
+ ON CONFLICT DO NOTHING;
+ SELECT a,b,c,d,e FROM t1;
+ } {1 d 3 4 5}
+
+}
+
+#--------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a, b, c REAL, d, e, PRIMARY KEY(a,b)) WITHOUT ROWID;
+ CREATE UNIQUE INDEX t2c ON t2(c);
+}
+
+do_catchsql_test 2.1 {
+ INSERT INTO t2(a,b,c,e,d) VALUES(1,2,3,4,5)
+ ON CONFLICT(c) DO UPDATE SET b=''
+ ON CONFLICT((SELECT t2 FROM nosuchtable)) DO NOTHING;
+
+} {1 {no such table: nosuchtable}}
+
+finish_test
diff --git a/test/upsertfault.test b/test/upsertfault.test
new file mode 100644
index 0000000..52bb4a5
--- /dev/null
+++ b/test/upsertfault.test
@@ -0,0 +1,38 @@
+# 2018-04-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 UPSERT
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix upsertfault
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a PRIMARY KEY, b, c, d, UNIQUE(b, c));
+ INSERT INTO t1 VALUES(1, 1, 1, 1);
+ INSERT INTO t1 VALUES(2, 2, 2, 2);
+}
+faultsim_save_and_close
+
+do_faultsim_test 1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+ db eval { SELECT * FROM sqlite_master }
+} -body {
+ execsql {
+ INSERT INTO t1 VALUES(3, 2, 2, NULL) ON CONFLICT(b, c) DO
+ UPDATE SET d=d+1;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+finish_test
diff --git a/test/uri.test b/test/uri.test
new file mode 100644
index 0000000..2b388c4
--- /dev/null
+++ b/test/uri.test
@@ -0,0 +1,345 @@
+# 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
+} {
+
+
+ ifcapable !curdir { if {$tn==3} break }
+
+ ifcapable uri_00_error {
+ if {[string first %00 $uri]>=0} continue
+ }
+
+ if {$tcl_platform(platform)=="windows"} {
+ #
+ # NOTE: Due to limits on legal characters for file names imposed by
+ # Windows, we must skip the final two tests here (i.e. the
+ # question mark is illegal in a file name on Windows).
+ #
+ if {$tn>14} break
+
+ #
+ # NOTE: When running on Tcl 8.6 (or higher?) on Windows, a colon within
+ # the file name no longer tries to access an alternate data stream
+ # (ADS) named "test.db" for the "http" file, causing some spurious
+ # failures of this test.
+ #
+ if {$tn==12 && $::tcl_version>=8.6} continue
+
+ #
+ # NOTE: On Windows, we need to account for the fact that the current
+ # directory does not start with a forward slash.
+ #
+ set uri [string map [list PWD/ /[test_pwd /]] $uri]
+ } else {
+ set uri [string map [list PWD/ [test_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 {}
+} {
+
+ ifcapable uri_00_error {
+ if {[string first %00 $uri]>=0} continue
+ }
+
+ 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)
+}
+
+ifcapable shared_cache {
+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
+}
+} ;# end ifcapable shared_cache
+
+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
+ return SQLITE_OK
+ }
+ testvfs tvfs2
+ tvfs2 filter {xOpen xDelete xAccess xFullPathname}
+ tvfs2 script tvfs2_callback
+ proc tvfs2_callback {method filename args} {
+ set ::T2([file tail $filename]) 1
+ return SQLITE_OK
+ }
+
+ 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 [get_pwd] 3 end]] $uri]
+ } else {
+ set uri [string map [list PWD [string range [get_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/uri2.test b/test/uri2.test
new file mode 100644
index 0000000..52feb7b
--- /dev/null
+++ b/test/uri2.test
@@ -0,0 +1,63 @@
+# 2016 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.
+#
+#***********************************************************************
+#
+# Tests for SQLITE_ENABLE_URI_00_ERROR builds.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !uri_00_error {
+ finish_test
+ return
+}
+
+set testprefix uri2
+db close
+sqlite3_shutdown
+sqlite3_config_uri 1
+
+foreach {tn uri} {
+ 1 file:test.db%00trailing
+ 2 file:test.db?%00trailing=1
+ 3 file:test.db?trailing=1%00
+ 4 file:test.db?trailing=1&abc%00def
+ 5 file:test.db?trailing=1&abc%00def
+} {
+ do_test 1.$tn.1 {
+ set rc [catch { sqlite3 db $uri } msg]
+ list $rc $msg
+ } {1 {unexpected %00 in uri}}
+
+ do_test 1.$tn.2 {
+ set DB2 [sqlite3_open $uri]
+ sqlite3_errcode $DB2
+ } {SQLITE_ERROR}
+
+ catch { sqlite3_close $DB2 }
+
+ do_test 1.$tn.2 {
+ sqlite3 db ""
+ catchsql { ATTACH $uri AS aux }
+ } {1 {unexpected %00 in uri}}
+
+ do_test 1.$tn.3 {
+ sqlite3_errcode db
+ } {SQLITE_ERROR}
+
+ catch { db close }
+}
+
+reset_db
+do_test 2.0 {
+ expr {[lsearch [execsql {PRAGMA compile_options}] ENABLE_URI_00_ERROR] >= 0}
+} 1
+
+finish_test
diff --git a/test/userauth01.test b/test/userauth01.test
new file mode 100644
index 0000000..644937b
--- /dev/null
+++ b/test/userauth01.test
@@ -0,0 +1,257 @@
+# 2014-09-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 tests of the SQLITE_USER_AUTHENTICATION extension.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix userauth01
+
+ifcapable !userauth {
+ finish_test
+ return
+}
+
+# Create a no-authentication-required database
+#
+do_execsql_test userauth01-1.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1),(2.5),('three'),(x'4444'),(NULL);
+ SELECT quote(x) FROM t1 ORDER BY x;
+ SELECT name FROM sqlite_master;
+} {NULL 1 2.5 'three' X'4444' t1}
+
+# Calling sqlite3_user_authenticate() on a no-authentication-required
+# database connection is a harmless no-op.
+#
+do_test userauth01-1.1 {
+ sqlite3_user_authenticate db alice pw-4-alice
+ execsql {
+ SELECT quote(x) FROM t1 ORDER BY x;
+ SELECT name FROM sqlite_master;
+ }
+} {NULL 1 2.5 'three' X'4444' t1}
+
+# If sqlite3_user_add(D,U,P,N,A) is called on a no-authentication-required
+# database and A is false, then the call fails with an SQLITE_AUTH error.
+#
+do_test userauth01-1.2 {
+ sqlite3_user_add db bob pw-4-bob 0
+} {SQLITE_AUTH}
+do_test userauth01-1.3 {
+ execsql {
+ SELECT quote(x) FROM t1 ORDER BY x;
+ SELECT name FROM sqlite_master;
+ }
+} {NULL 1 2.5 'three' X'4444' t1}
+
+# When called on a no-authentication-required
+# database and when A is true, the sqlite3_user_add(D,U,P,N,A) routine
+# converts the database into an authentication-required database and
+# logs the database connection D in using user U with password P,N.
+#
+do_test userauth01-1.4 {
+ sqlite3_user_add db alice pw-4-alice 1
+} {SQLITE_OK}
+do_test userauth01-1.5 {
+ execsql {
+ SELECT quote(x) FROM t1 ORDER BY x;
+ SELECT uname, isadmin FROM sqlite_user ORDER BY uname;
+ SELECT name FROM sqlite_master ORDER BY name;
+ }
+} {NULL 1 2.5 'three' X'4444' alice 1 sqlite_user t1}
+
+# The sqlite3_user_add() interface can be used (by an admin user only)
+# to create a new user.
+#
+do_test userauth01-1.6 {
+ sqlite3_user_add db bob pw-4-bob 0
+ sqlite3_user_add db cindy pw-4-cindy 0
+ sqlite3_user_add db david pw-4-david 0
+ execsql {
+ SELECT uname, isadmin FROM sqlite_user ORDER BY uname;
+ }
+} {alice 1 bob 0 cindy 0 david 0}
+
+# The sqlite_user table is inaccessible (unreadable and unwriteable) to
+# non-admin users and is read-only for admin users. However, if the same
+#
+do_test userauth01-1.7 {
+ sqlite3 db2 test.db
+ sqlite3_user_authenticate db2 cindy pw-4-cindy
+ db2 eval {
+ SELECT quote(x) FROM t1 ORDER BY x;
+ SELECT name FROM sqlite_master ORDER BY name;
+ }
+} {NULL 1 2.5 'three' X'4444' sqlite_user t1}
+do_test userauth01-1.8 {
+ catchsql {
+ SELECT uname, isadmin FROM sqlite_user ORDER BY uname;
+ } db2
+} {1 {no such table: sqlite_user}}
+
+# Any user can change their own password.
+#
+do_test userauth01-1.9 {
+ sqlite3_user_change db2 cindy xyzzy-cindy 0
+} {SQLITE_OK}
+do_test userauth01-1.10 {
+ sqlite3_user_authenticate db2 cindy pw-4-cindy
+} {SQLITE_AUTH}
+do_test userauth01-1.11 {
+ sqlite3_user_authenticate db2 cindy xyzzy-cindy
+} {SQLITE_OK}
+do_test userauth01-1.12 {
+ sqlite3_user_change db alice xyzzy-alice 1
+} {SQLITE_OK}
+do_test userauth01-1.13 {
+ sqlite3_user_authenticate db alice pw-4-alice
+} {SQLITE_AUTH}
+do_test userauth01-1.14 {
+ sqlite3_user_authenticate db alice xyzzy-alice
+} {SQLITE_OK}
+
+# No user may change their own admin privilege setting.
+#
+do_test userauth01-1.15 {
+ sqlite3_user_change db alice xyzzy-alice 0
+} {SQLITE_AUTH}
+do_test userauth01-1.16 {
+ db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
+} {alice 1 bob 0 cindy 0 david 0}
+do_test userauth01-1.17 {
+ sqlite3_user_change db2 cindy xyzzy-cindy 1
+} {SQLITE_AUTH}
+do_test userauth01-1.18 {
+ db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
+} {alice 1 bob 0 cindy 0 david 0}
+
+# The sqlite3_user_change() interface can be used to change a users
+# login credentials or admin privilege.
+#
+do_test userauth01-1.20 {
+ sqlite3_user_change db david xyzzy-david 1
+} {SQLITE_OK}
+do_test userauth01-1.21 {
+ db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
+} {alice 1 bob 0 cindy 0 david 1}
+do_test userauth01-1.22 {
+ sqlite3_user_authenticate db2 david xyzzy-david
+} {SQLITE_OK}
+do_test userauth01-1.23 {
+ db2 eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
+} {alice 1 bob 0 cindy 0 david 1}
+do_test userauth01-1.24 {
+ sqlite3_user_change db david pw-4-david 0
+} {SQLITE_OK}
+do_test userauth01-1.25 {
+ sqlite3_user_authenticate db2 david pw-4-david
+} {SQLITE_OK}
+do_test userauth01-1.26 {
+ db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
+} {alice 1 bob 0 cindy 0 david 0}
+do_test userauth01-1.27 {
+ catchsql {SELECT uname, isadmin FROM sqlite_user ORDER BY uname} db2
+} {1 {no such table: sqlite_user}}
+
+# Only an admin user can change another users login
+# credentials or admin privilege setting.
+#
+do_test userauth01-1.30 {
+ sqlite3_user_change db2 bob xyzzy-bob 1
+} {SQLITE_AUTH}
+do_test userauth01-1.31 {
+ db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
+} {alice 1 bob 0 cindy 0 david 0}
+
+# The sqlite3_user_delete() interface can be used (by an admin user only)
+# to delete a user.
+#
+do_test userauth01-1.40 {
+ sqlite3_user_delete db bob
+} {SQLITE_OK}
+do_test userauth01-1.41 {
+ db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
+} {alice 1 cindy 0 david 0}
+do_test userauth01-1.42 {
+ sqlite3_user_delete db2 cindy
+} {SQLITE_AUTH}
+do_test userauth01-1.43 {
+ sqlite3_user_delete db2 alice
+} {SQLITE_AUTH}
+do_test userauth01-1.44 {
+ db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
+} {alice 1 cindy 0 david 0}
+
+# The currently logged-in user cannot be deleted
+#
+do_test userauth01-1.50 {
+ sqlite3_user_delete db alice
+} {SQLITE_AUTH}
+do_test userauth01-1.51 {
+ db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}
+} {alice 1 cindy 0 david 0}
+
+# When ATTACH-ing new database files to a connection, each newly attached
+# database that is an authentication-required database is checked using
+# the same username and password as supplied to the main database. If that
+# check fails, then the ATTACH command fails with an SQLITE_AUTH error.
+#
+do_test userauth01-1.60 {
+ forcedelete test3.db
+ sqlite3 db3 test3.db
+ sqlite3_user_add db3 alice xyzzy-alice 1
+} {SQLITE_OK}
+do_test userauth01-1.61 {
+ db3 eval {
+ CREATE TABLE t3(a,b,c); INSERT INTO t3 VALUES(1,2,3);
+ SELECT * FROM t3;
+ }
+} {1 2 3}
+do_test userauth01-1.62 {
+ db eval {
+ ATTACH 'test3.db' AS aux;
+ SELECT * FROM t1, t3 ORDER BY x LIMIT 1;
+ DETACH aux;
+ }
+} {{} 1 2 3}
+do_test userauth01-1.63 {
+ sqlite3_user_change db alice pw-4-alice 1
+ sqlite3_user_authenticate db alice pw-4-alice
+ catchsql {
+ ATTACH 'test3.db' AS aux;
+ }
+} {1 {unable to open database: test3.db}}
+do_test userauth01-1.64 {
+ sqlite3_extended_errcode db
+} {SQLITE_AUTH}
+do_test userauth01-1.65 {
+ db eval {PRAGMA database_list}
+} {~/test3.db/}
+
+# The sqlite3_set_authorizer() callback is modified to take a 7th parameter
+# which is the username of the currently logged in user, or NULL for a
+# no-authentication-required database.
+#
+proc auth {args} {
+ lappend ::authargs $args
+ return SQLITE_OK
+}
+do_test authuser01-2.1 {
+ unset -nocomplain ::authargs
+ db auth auth
+ db eval {SELECT x FROM t1}
+ set ::authargs
+} {/SQLITE_SELECT {} {} {} {} alice/}
+
+
+finish_test
diff --git a/test/utf16align.test b/test/utf16align.test
new file mode 100644
index 0000000..ef10bc6
--- /dev/null
+++ b/test/utf16align.test
@@ -0,0 +1,96 @@
+# 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]
+ sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+ 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-into.test b/test/vacuum-into.test
new file mode 100644
index 0000000..98692a1
--- /dev/null
+++ b/test/vacuum-into.test
@@ -0,0 +1,190 @@
+# 2018-12-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 file is testing the VACUUM INTO statement.
+#
+
+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
+}
+
+forcedelete out.db
+do_execsql_test vacuum-into-100 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b) SELECT x, randomblob(600) FROM c;
+ CREATE INDEX t1b ON t1(b);
+ DELETE FROM t1 WHERE a%2;
+ SELECT count(*), sum(a), sum(length(b)) FROM t1;
+} {50 2550 30000}
+do_execsql_test vacuum-into-110 {
+ VACUUM main INTO 'out.db';
+} {}
+sqlite3 db2 out.db
+do_test vacuum-into-120 {
+ db2 eval {SELECT count(*), sum(a), sum(length(b)) FROM t1}
+} {50 2550 30000}
+do_catchsql_test vacuum-into-130 {
+ VACUUM INTO 'out.db';
+} {1 {output file already exists}}
+forcedelete out2.db
+do_catchsql_test vacuum-into-140 {
+ VACUUM INTO 'out2.db';
+} {0 {}}
+do_catchsql_test vacuum-into-150 {
+ VACUUM INTO 'out2.db';
+} {1 {output file already exists}}
+
+do_catchsql_test vacuum-into-200 {
+ VACUUM main INTO ':memory:';
+} {0 {}}
+
+# The INTO argument can be an arbitrary expression.
+#
+do_execsql_test vacuum-into-300 {
+ CREATE TABLE t2(name TEXT);
+ INSERT INTO t2 VALUES(':memory:');
+ VACUUM main INTO (SELECT name FROM t2);
+} {}
+do_catchsql_test vacuum-into-310 {
+ VACUUM INTO null;
+} {1 {non-text filename}}
+do_catchsql_test vacuum-into-320 {
+ VACUUM INTO x;
+} {1 {no such column: x}}
+do_catchsql_test vacuum-into-330 {
+ VACUUM INTO t1.nosuchcol;
+} {1 {no such column: t1.nosuchcol}}
+do_catchsql_test vacuum-into-340 {
+ VACUUM INTO main.t1.nosuchcol;
+} {1 {no such column: main.t1.nosuchcol}}
+
+forcedelete test.db2
+db func target target
+proc target {} { return "test.db2" }
+do_test vacuum-into-410 {
+ execsql { VACUUM INTO target() }
+ file exists test.db2
+} 1
+do_catchsql_test vacuum-into-420 {
+ VACUUM INTO target2()
+} {1 {no such function: target2}}
+
+# The ability to VACUUM INTO a read-only database
+db close
+sqlite3 db test.db -readonly 1
+forcedelete test.db2
+do_execsql_test vacuum-into-500 {
+ VACUUM INTO 'test.db2';
+}
+sqlite3 db2 test.db2
+do_test vacuum-into-510 {
+ db2 eval {SELECT name FROM sqlite_master ORDER BY 1}
+} {t1 t1b t2}
+db2 close
+db close
+
+# Change the page-size on a VACUUM INTO even if the original
+# database is in WAL mode.
+#
+if {[wal_is_capable]} {
+ forcedelete test.db
+ forcedelete test.db2
+ do_test vacuum-into-600 {
+ sqlite3 db test.db
+ db eval {
+ PRAGMA page_size=4096;
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(19);
+ CREATE INDEX t1a ON t1(a);
+ PRAGMA integrity_check;
+ }
+ } {wal ok}
+ do_execsql_test vacuum-into-610 {
+ PRAGMA page_size;
+ } {4096}
+ do_execsql_test vacuum-into-620 {
+ PRAGMA page_size=1024;
+ VACUUM INTO 'test.db2';
+ } {}
+ do_test vacuum-into-630 {
+ sqlite3 db test.db2
+ db eval {
+ PRAGMA page_size;
+ PRAGMA integrity_check;
+ }
+ } {1024 ok}
+}
+
+#-------------------------------------------------------------------------
+
+testvfs tvfs -default 1
+tvfs filter xSync
+tvfs script xSyncCb
+proc xSyncCb {method file fileid flags} {
+ incr ::sync($flags)
+}
+
+reset_db
+
+do_execsql_test vacuum-into-700 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+}
+
+foreach {tn pragma res} {
+ 710 {
+ PRAGMA synchronous = normal
+ } {normal 2}
+ 720 {
+ PRAGMA synchronous = full
+ } {normal 3}
+ 730 {
+ PRAGMA synchronous = off
+ } {}
+ 740 {
+ PRAGMA synchronous = extra;
+ } {normal 3}
+ 750 {
+ PRAGMA fullfsync = 1;
+ PRAGMA synchronous = full;
+ } {full|dataonly 1 full 2}
+} {
+
+ forcedelete test.db2
+ array unset ::sync
+ do_execsql_test vacuum-into-$tn.1 "
+ $pragma ;
+ VACUUM INTO 'test.db2'
+ "
+
+ do_test vacuum-into-$tn.2 {
+ array get ::sync
+ } $res
+}
+
+db close
+tvfs delete
+
+
+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..89fdb50
--- /dev/null
+++ b/test/vacuum2.test
@@ -0,0 +1,251 @@
+# 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
+set testprefix vacuum2
+
+# 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.2 {
+ 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}}}
+
+#-------------------------------------------------------------------------
+# Check that if the definition of a collation sequence is changed and
+# VACUUM run, records are store in the (new) correct order following the
+# VACUUM. Even if the modified collation is attached to a PK of a WITHOUT
+# ROWID table.
+
+proc cmp {lhs rhs} { string compare $lhs $rhs }
+db collate cmp cmp
+do_execsql_test 6.0 {
+ CREATE TABLE t6(x PRIMARY KEY COLLATE cmp, y) WITHOUT ROWID;
+ CREATE INDEX t6y ON t6(y);
+ INSERT INTO t6 VALUES('i', 'one');
+ INSERT INTO t6 VALUES('ii', 'one');
+ INSERT INTO t6 VALUES('iii', 'one');
+}
+integrity_check 6.1
+proc cmp {lhs rhs} { string compare $rhs $lhs }
+do_execsql_test 6.2 VACUUM
+integrity_check 6.3
+
+finish_test
diff --git a/test/vacuum3.test b/test/vacuum3.test
new file mode 100644
index 0000000..e6a1c2b
--- /dev/null
+++ b/test/vacuum3.test
@@ -0,0 +1,350 @@
+# 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;
+ }
+ ifcapable altertable {
+ execsql { ALTER TABLE t1 ADD COLUMN d; }
+ } else {
+ execsql {
+ DROP TABLE t1;
+ CREATE TABLE t1(a, b, c, d);
+ INSERT INTO t1 VALUES(1, 2, 3, NULL);
+ }
+ }
+ execsql {
+ 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..bbf0dd4
--- /dev/null
+++ b/test/vacuum4.test
@@ -0,0 +1,69 @@
+# 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;
+ }
+} {}
+
+finish_test
diff --git a/test/vacuum5.test b/test/vacuum5.test
new file mode 100644
index 0000000..f203fb8
--- /dev/null
+++ b/test/vacuum5.test
@@ -0,0 +1,155 @@
+# 2016-08-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 a test for VACUUM on attached databases.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vacuum5
+
+# If the VACUUM statement is disabled in the current build, skip all
+# the tests in this file.
+#
+ifcapable !vacuum {
+ finish_test
+ return
+}
+
+forcedelete test2.db test3.db
+do_execsql_test vacuum5-1.1 {
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE main.t1(a,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t1(a,b) SELECT x, randomblob(1000) FROM c;
+ CREATE TEMP TABLE ttemp(x,y);
+ INSERT INTO ttemp SELECT * FROM t1;
+ ATTACH 'test2.db' AS x2;
+ ATTACH 'test3.db' AS x3;
+ CREATE TABLE x2.t2(c,d);
+ INSERT INTO t2 SELECT * FROM t1;
+ CREATE TABLE x3.t3(e,f);
+ INSERT INTO t3 SELECT * FROM t1;
+ DELETE FROM t1 WHERE (rowid%3)!=0;
+ DELETE FROM t2 WHERE (rowid%4)!=0;
+ DELETE FROM t3 WHERE (rowid%5)!=0;
+ PRAGMA main.integrity_check;
+ PRAGMA x2.integrity_check;
+ PRAGMA x3.integrity_check;
+} {ok ok ok}
+set size1 [file size test.db]
+set size2 [file size test2.db]
+set size3 [file size test3.db]
+
+do_execsql_test vacuum5-1.2.1 {
+ VACUUM main;
+} {}
+do_test vacuum5-1.2.2 {
+ expr {[file size test.db]<$size1}
+} {1}
+do_test vacuum5-1.2.3 {
+ file size test2.db
+} $size2
+do_test vacuum5-1.2.4 {
+ file size test3.db
+} $size3
+set size1 [file size test.db]
+do_execsql_test vacuum-1.2.5 {
+ DELETE FROM t1;
+ PRAGMA main.integrity_check;
+} {ok}
+
+do_execsql_test vacuum5-1.3.1 {
+ VACUUM x2;
+} {}
+do_test vacuum5-1.3.2 {
+ file size test.db
+} $size1
+do_test vacuum5-1.3.3 {
+ expr {[file size test2.db]<$size2}
+} 1
+do_test vacuum5-1.3.4 {
+ file size test3.db
+} $size3
+set size2 [file size test2.db]
+do_execsql_test vacuum-1.3.5 {
+ DELETE FROM t2;
+ PRAGMA x2.integrity_check;
+} {ok}
+
+do_execsql_test vacuum5-1.4.1 {
+ VACUUM x3;
+} {}
+do_test vacuum5-1.3.2 {
+ file size test.db
+} $size1
+do_test vacuum5-1.3.3 {
+ file size test2.db
+} $size2
+do_test vacuum5-1.3.4 {
+ expr {[file size test3.db]<$size3}
+} 1
+
+# VACUUM is a no-op on the TEMP table
+#
+set sizeTemp [db one {PRAGMA temp.page_count}]
+do_execsql_test vacuum5-1.4.1 {
+ VACUUM temp;
+} {}
+do_execsql_test vacuum5-1.4.2 {
+ PRAGMA temp.page_count;
+} $sizeTemp
+
+do_catchsql_test vacuum5-2.0 {
+ VACUUM olaf;
+} {1 {unknown database olaf}}
+
+#-------------------------------------------------------------------------
+# Test that a temp file is opened as part of VACUUM.
+#
+if {$::TEMP_STORE<3 && [permutation]!="inmemory_journal"} {
+ db close
+ testvfs tvfs
+ tvfs filter xOpen
+ tvfs script open_cb
+ forcedelete test.db
+
+ set ::openfiles [list]
+ proc open_cb {method args} {
+ lappend ::openfiles [file tail [lindex $args 0]]
+ }
+ sqlite3 db test.db -vfs tvfs
+
+ do_execsql_test 3.0 {
+ PRAGMA temp_store = file;
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 50;
+ CREATE TABLE t1(i INTEGER PRIMARY KEY, j UNIQUE);
+ WITH s(i) AS (
+ VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000
+ )
+ INSERT INTO t1 SELECT NULL, randomblob(100) FROM s;
+ }
+
+ do_execsql_test 3.1 { VACUUM }
+
+ db close
+ tvfs delete
+ if {[atomic_batch_write test.db]==0} {
+ do_test 3.2 {
+ lrange $::openfiles 0 4
+ } {test.db test.db-journal test.db-journal {} test.db-journal}
+ }
+}
+
+
+
+finish_test
diff --git a/test/vacuum6.test b/test/vacuum6.test
new file mode 100644
index 0000000..f80ff75
--- /dev/null
+++ b/test/vacuum6.test
@@ -0,0 +1,113 @@
+# 2016-08-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 a test for VACUUM on attached databases.
+#
+# TESTRUNNER: slow
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vacuum6
+
+# If the VACUUM statement is disabled in the current build, skip all
+# the tests in this file.
+#
+ifcapable !vacuum {
+ finish_test
+ return
+}
+
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(1, 1);
+} {}
+
+do_execsql_test 1.1 {
+ VACUUM
+}
+
+reset_db
+do_execsql_test 1.2 {
+ CREATE TABLE t1(x,b);
+ CREATE INDEX x1 ON t1(x);
+ CREATE INDEX x2 ON t1(x);
+ CREATE INDEX x3 ON t1(x);
+ INSERT INTO t1 SELECT 2,'';
+ VACUUM;
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+foreach {tn sz} {1 400 2 4000 3 9999} {
+ reset_db
+ do_execsql_test 2.$tn.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
+ )
+ INSERT INTO t1 SELECT i, randomblob($sz) FROM s;
+ }
+
+ do_execsql_test 2.$tn.2 {
+ vacuum;
+ }
+
+ do_execsql_test 2.$tn.3 {
+ PRAGMA integrity_check;
+ } {ok}
+}
+
+reset_db
+do_execsql_test 3.0 {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t1 VALUES(2, randomblob(1200));
+} {}
+do_execsql_test 3.1 {
+ PRAGMA page_size = 512;
+ VACUUM;
+}
+do_execsql_test 3.2 {
+ PRAGMA integrity_check
+} {ok}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE tx(a, b);
+ CREATE INDEX i1 ON tx(b);
+ WITH s(i) AS (
+ SELECT 8000 UNION ALL SELECT i+1 FROM s WHERE i<10000
+ )
+ INSERT INTO tx SELECT i, randomblob(i) FROM s;
+
+ SELECT sum(length(b)) FROM tx;
+} {18009000}
+foreach {tn pgsz av} {
+ 1 2048 0
+ 2 1024 1
+ 3 65536 0
+ 4 8192 1
+ 5 512 0
+ 6 4096 1
+} {
+ do_execsql_test 4.1.$tn.1 "
+ PRAGMA page_size = $pgsz;
+ PRAGMA auto_vacuum = $av;
+ "
+ do_execsql_test 4.1.$tn.2 VACUUM
+ integrity_check 4.1.$tn.3
+}
+
+finish_test
diff --git a/test/vacuummem.test b/test/vacuummem.test
new file mode 100644
index 0000000..9668b0e
--- /dev/null
+++ b/test/vacuummem.test
@@ -0,0 +1,74 @@
+# 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 that the VACUUM statement correctly
+# frees any memory used for a temporary cache.
+#
+# TESTRUNNER: slow
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vacuummem
+
+if {[permutation]=="memsubsys1"} {
+ finish_test
+ return
+}
+
+# If ENABLE_MEMORY_MANAGEMENT is defined, when VACUUM is run the temp db
+# is able to borrow space from the main db (and it does, because the
+# temp db is configure with a very small cache). When the VACUUM is
+# finished and the temp db closed, all the page-cache memory currently
+# assigned to the temp db is freed. If ENABLE_MEMORY_MANAGEMENT is defined
+# this causes the total memory usage to drop much more than expected,
+# causing tests in this file to fail.
+#
+ifcapable memorymanage {
+ finish_test
+ return
+}
+
+
+proc memory_used {} {
+ set stat [sqlite3_status SQLITE_STATUS_MEMORY_USED 1]
+ lindex $stat 1
+}
+
+do_execsql_test 1.0 {
+ PRAGMA cache_size = -2000;
+ CREATE TABLE t1(a, b, c);
+
+ WITH r(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM r WHERE i<100000
+ )
+ INSERT INTO t1 SELECT randomblob(100),randomblob(100),randomblob(100) FROM r;
+
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ CREATE INDEX t1c ON t1(c);
+}
+set ans "#/[memory_used]/"
+
+do_test 1.1 { memory_used } $ans
+
+do_execsql_test 1.2 VACUUM
+
+do_test 1.3 { memory_used } $ans
+
+do_execsql_test 1.4 {
+ SELECT count(*) FROM t1 WHERE +a IS NOT NULL
+} {100000}
+
+do_test 1.5 { memory_used } $ans
+
+
+
+finish_test
diff --git a/test/varint.test b/test/varint.test
new file mode 100644
index 0000000..fd0ec0d
--- /dev/null
+++ b/test/varint.test
@@ -0,0 +1,34 @@
+# 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
+ } {}
+ }
+ }
+}
+
+finish_test
diff --git a/test/veryquick.test b/test/veryquick.test
new file mode 100644
index 0000000..c8d6ce8
--- /dev/null
+++ b/test/veryquick.test
@@ -0,0 +1,18 @@
+#
+# May you do good 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..b0b6da2
--- /dev/null
+++ b/test/view.test
@@ -0,0 +1,779 @@
+# 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.1.100 {
+ db config enable_view off
+ catchsql {
+ SELECT * FROM v1 ORDER BY a;
+ }
+} {1 {access to view "v1" prohibited}}
+do_execsql_test view-1.1.101 {
+ CREATE TEMP VIEW v1temp AS SELECT a, b FROM t1;
+ SELECT * FROM v1temp ORDER BY a;
+} {1 2 4 5 7 8}
+do_test view-1.1.110 {
+ db config enable_view on
+ catchsql {
+ SELECT * FROM v1 ORDER BY a;
+ SELECT * FROM v1temp ORDER BY a;
+ }
+} {0 {1 2 4 5 7 8 1 2 4 5 7 8}}
+ifcapable vtab {
+ do_execsql_test view-1.1.120 {
+ SELECT name, type FROM pragma_table_list('v1');
+ } {v1 view}
+}
+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_execsql_test view-1.10 {
+ CREATE TABLE t9(x INTEGER);
+ CREATE VIEW v9a AS SELECT x FROM t9;
+ CREATE VIEW v9b AS SELECT * FROM t9;
+ CREATE VIEW v9c(x) AS SELECT x FROM t9;
+ CREATE VIEW v9d(x) AS SELECT * FROM t9;
+} {}
+do_execsql_test view-1.11 {
+ PRAGMA table_info(v9a);
+} {0 x INTEGER 0 {} 0}
+do_execsql_test view-1.12 {
+ PRAGMA table_info(v9b);
+} {0 x INTEGER 0 {} 0}
+do_execsql_test view-1.13 {
+ PRAGMA table_info(v9c);
+} {0 x INTEGER 0 {} 0}
+do_execsql_test view-1.14 {
+ PRAGMA table_info(v9d);
+} {0 x INTEGER 0 {} 0}
+
+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}
+do_test view-3.3.3 {
+ execsql2 {
+ CREATE VIEW v1c(x,y,z) AS SELECT a, b+c, c-b FROM t1;
+ SELECT * FROM v1c LIMIT 1;
+ }
+} {x 2 y 7 z 1}
+do_catchsql_test view-3.3.4 {
+ CREATE VIEW v1err(x,y DESC,z) AS SELECT a, b+c, c-b FROM t1;
+} {1 {syntax error after column name "y"}}
+do_catchsql_test view-3.3.5 {
+ DROP VIEW IF EXISTS v1err;
+ CREATE VIEW v1err(x,y) AS SELECT a, b+c, c-b FROM t1;
+ SELECT * FROM v1err;
+} {1 {expected 2 columns for 'v1err' but got 3}}
+do_catchsql_test view-3.3.6 {
+ DROP VIEW IF EXISTS v1err;
+ CREATE VIEW v1err(w,x,y,z) AS SELECT a, b+c, c-b FROM t1;
+ SELECT * FROM v1err;
+} {1 {expected 4 columns for 'v1err' but got 3}}
+
+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(a) AS SELECT pqr+xyz 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}}
+do_test view-12.2 {
+ catchsql {
+ CREATE VIEW v12(x) 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}}
+do_test view-14.2 {
+ catchsql {
+ DROP VIEW IF EXISTS temp.t1;
+ CREATE TEMP VIEW t1(a,b) 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);
+ }
+} {}
+
+db close
+sqlite3 db :memory:
+do_execsql_test view-22.1 {
+ CREATE VIEW x1 AS SELECT 123 AS '', 234 AS '', 345 AS '';
+ SELECT * FROM x1;
+} {123 234 345}
+do_test view-22.2 {
+ unset -nocomplain x
+ db eval {SELECT * FROM x1} x break
+ lsort [array names x]
+} {{} * :1 :2}
+
+do_test view-25.1 {
+ db eval {
+ CREATE TABLE t25 (x);
+ INSERT INTO t25 (x) VALUES (1);
+ ANALYZE;
+ }
+ proc authLogDelete {code arg1 arg2 arg3 arg4 args} {
+ if {$code=="SQLITE_DELETE" && [string match sqlite_stat* $arg1]} {
+ # lappend ::log [list $code $arg1 $arg2 $arg3 $arg4 $args]
+ lappend ::log [list $code $arg1 $arg2 $arg3 $arg4]
+ }
+ return SQLITE_OK
+ }
+ set log ""
+ db authorizer ::authLogDelete
+ db eval {DROP VIEW x1;}
+ set log
+} {}
+
+set res [list {SQLITE_DELETE sqlite_stat1 {} main {}}]
+ifcapable stat4 { lappend res {SQLITE_DELETE sqlite_stat4 {} main {}} }
+do_test view-25.2 {
+ set log ""
+ db eval {DROP TABLE t25;}
+ set log
+} $res
+
+#-------------------------------------------------------------------------
+do_execsql_test view-26.0 {
+ CREATE TABLE t16(a, b, c UNIQUE);
+ INSERT INTO t16 VALUES(1, 1, 1);
+ INSERT INTO t16 VALUES(2, 2, 2);
+ INSERT INTO t16 VALUES(3, 3, 3);
+ CREATE VIEW v16 AS SELECT max(a) AS mx, min(b) AS mn FROM t16 GROUP BY c;
+
+ SELECT * FROM v16 AS one, v16 AS two WHERE one.mx=1;
+} {
+ 1 1 1 1
+ 1 1 2 2
+ 1 1 3 3
+}
+do_execsql_test view-26.1 {
+ WITH v17(x,y) AS (SELECT max(a), min(b) FROM t16 GROUP BY c)
+ SELECT * FROM v17 AS one, v17 AS two WHERE one.x=1;
+} {
+ 1 1 1 1
+ 1 1 2 2
+ 1 1 3 3
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test view-27.0 {
+ CREATE TABLE t0(c0 TEXT, c1);
+ INSERT INTO t0(c0, c1) VALUES (-1, 0);
+ CREATE VIEW v0(c0, c1) AS SELECT t0.c0, AVG(t0.c1) FROM t0;
+}
+
+do_execsql_test view-27.1 {
+ SELECT c0, typeof(c0), c1, typeof(c1) FROM v0;
+} {
+ -1 text
+ 0.0 real
+}
+
+do_execsql_test view-27.2 { SELECT c0<c1 FROM v0 } 1
+do_execsql_test view-27.3 { SELECT c1<c0 FROM v0 } 0
+do_execsql_test view-27.4 {
+ SELECT 1 FROM v0 WHERE c1<c0
+} {}
+do_execsql_test view-27.5 {
+ SELECT 1 FROM v0 WHERE c0<c1
+} {1}
+
+do_execsql_test view-27.6 {
+ SELECT c0<c1 FROM (SELECT t0.c0 AS c0, AVG(t0.c1) AS c1 FROM t0)
+} 1
+do_execsql_test view-27.7 {
+ SELECT c1<c0 FROM (SELECT t0.c0 AS c0, AVG(t0.c1) AS c1 FROM t0)
+} 0
+do_execsql_test view-27.8 {
+ SELECT 1 FROM (SELECT t0.c0 AS c0, AVG(t0.c1) AS c1 FROM t0) WHERE c1<c0
+} {}
+do_execsql_test view-27.9 {
+ SELECT 1 FROM (SELECT t0.c0 AS c0, AVG(t0.c1) AS c1 FROM t0) WHERE c0<c1
+} {1}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test view-28.0 {
+ CREATE TABLE t0(c0 TEXT);
+ CREATE VIEW v0(c0) AS SELECT t0.c0 FROM t0;
+ INSERT INTO t0(c0) VALUES ('0');
+}
+do_execsql_test view-28.1 {
+ SELECT 0 IN (c0) FROM t0;
+} {0}
+do_execsql_test view-28.2 {
+ SELECT 0 IN (c0) FROM (SELECT c0 FROM t0);
+} {0}
+
+#-------------------------------------------------------------------------
+# 2020-10-26. https://sqlite.org/forum/forumpost/daa2c728cc
+#
+reset_db
+do_catchsql_test view-29.0 {
+ CREATE TABLE t1(a,b,c);
+ CREATE VIEW IF NOT EXISTS IF AS SELECT null;
+} {1 {malformed database schema (IF) - near "AS": syntax error}}
+do_catchsql_test view-29.1 {
+ CREATE TABLE t2(c,d,e);
+ SELECT name FROM sqlite_schema ORDER BY name;
+} {0 {t1 t2}}
+
+
+finish_test
diff --git a/test/view2.test b/test/view2.test
new file mode 100644
index 0000000..e5df143
--- /dev/null
+++ b/test/view2.test
@@ -0,0 +1,49 @@
+# 2021 May 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 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
+}
+set testprefix view2
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ CREATE VIEW v1 AS SELECT * FROM (
+ WITH x1 AS (SELECT y, x FROM t1)
+ SELECT * FROM x1
+ );
+}
+
+do_execsql_test 1.1 {
+ SELECT * FROM v1
+} {2 1}
+
+do_execsql_test 1.2 {
+ CREATE VIEW v3 AS SELECT * FROM main.t1;
+ WITH t1(a, b) AS ( SELECT 3, 4 ) SELECT * FROM v3;
+} {1 2}
+
+breakpoint
+do_execsql_test 1.3 {
+ CREATE VIEW v2 AS SELECT * FROM t1;
+ WITH t1(a, b) AS ( SELECT 3, 4 ) SELECT * FROM v2;
+} {1 2}
+
+finish_test
diff --git a/test/view3.test b/test/view3.test
new file mode 100644
index 0000000..60dd694
--- /dev/null
+++ b/test/view3.test
@@ -0,0 +1,60 @@
+# 2022 July 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 VIEW statements.
+#
+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
+}
+set testprefix view3
+
+# Ticket [d58ccbb3f1b]: Prevent Table.nRef overflow.
+db close
+sqlite3 db :memory:
+do_test 1.1 {
+ catchsql {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(5);
+ CREATE VIEW v1 AS SELECT x*2 FROM t1;
+ CREATE VIEW v2 AS SELECT * FROM v1 UNION SELECT * FROM v1;
+ CREATE VIEW v4 AS SELECT * FROM v2 UNION SELECT * FROM v2;
+ CREATE VIEW v8 AS SELECT * FROM v4 UNION SELECT * FROM v4;
+ CREATE VIEW v16 AS SELECT * FROM v8 UNION SELECT * FROM v8;
+ CREATE VIEW v32 AS SELECT * FROM v16 UNION SELECT * FROM v16;
+ CREATE VIEW v64 AS SELECT * FROM v32 UNION SELECT * FROM v32;
+ CREATE VIEW v128 AS SELECT * FROM v64 UNION SELECT * FROM v64;
+ CREATE VIEW v256 AS SELECT * FROM v128 UNION SELECT * FROM v128;
+ CREATE VIEW v512 AS SELECT * FROM v256 UNION SELECT * FROM v256;
+ CREATE VIEW v1024 AS SELECT * FROM v512 UNION SELECT * FROM v512;
+ CREATE VIEW v2048 AS SELECT * FROM v1024 UNION SELECT * FROM v1024;
+ CREATE VIEW v4096 AS SELECT * FROM v2048 UNION SELECT * FROM v2048;
+ CREATE VIEW v8192 AS SELECT * FROM v4096 UNION SELECT * FROM v4096;
+ CREATE VIEW v16384 AS SELECT * FROM v8192 UNION SELECT * FROM v8192;
+ CREATE VIEW v32768 AS SELECT * FROM v16384 UNION SELECT * FROM v16384;
+ SELECT * FROM v32768 UNION SELECT * FROM v32768;
+ }
+} {1 {too many references to "v1": max 65535}}
+ifcapable progress {
+ do_test 1.2 {
+ db progress 1000 {expr 1}
+ catchsql {
+ SELECT * FROM v32768;
+ }
+ } {1 interrupted}
+}
+
+
+finish_test
diff --git a/test/vt02.c b/test/vt02.c
new file mode 100644
index 0000000..40bd6fc
--- /dev/null
+++ b/test/vt02.c
@@ -0,0 +1,1019 @@
+/*
+** This file implements an eponymous, read-only table-valued function
+** (a virtual table) designed to be used for testing. We are not aware
+** of any practical real-world use case for the virtual table.
+**
+** This virtual table originated in the TH3 test suite. It is still used
+** there, but has now been copied into the public SQLite source tree and
+** reused for a variety of testing purpose. The name "vt02" comes from the
+** fact that there are many different testing virtual tables in TH3, of which
+** this one is the second.
+**
+** ## SUBJECT TO CHANGE
+**
+** Because this virtual table is intended for testing, its interface is not
+** guaranteed to be stable across releases. Future releases may contain
+** changes in the vt02 design and interface.
+**
+** ## OVERVIEW
+**
+** The vt02 table-valued function has 10000 rows with 5 data columns.
+** Column X contains all integer values between 0 and 9999 inclusive.
+** Columns A, B, C, and D contain the individual base-10 digits associated
+** with each X value:
+**
+** X A B C D
+** ---- - - - -
+** 0 0 0 0 0
+** 1 0 0 0 1
+** 2 0 0 0 2
+** ...
+** 4998 4 9 9 8
+** 4999 4 9 9 9
+** 5000 5 0 0 0
+** ...
+** 9995 9 9 9 5
+** 9996 9 9 9 6
+** 9997 9 9 9 7
+**
+** The xBestIndex method recognizes a variety of equality constraints
+** and attempts to optimize its output accordingly.
+**
+** x=...
+** a=...
+** a=... AND b=...
+** a=... AND b=... AND c=...
+** a=... AND b=... AND c=... AND d=...
+**
+** Various ORDER BY constraints are also recognized and consumed. The
+** OFFSET constraint is recognized and consumed.
+**
+** ## TABLE-VALUED FUNCTION
+**
+** The vt02 virtual table is eponymous and has two hidden columns, meaning
+** that it can functions a table-valued function. The two hidden columns
+** are "flags" and "logtab", in that order. The "flags" column can be set
+** to an integer where various bits enable or disable behaviors of the
+** virtual table. The "logtab" can set to the name of an ordinary SQLite
+** table into which is written information about each call to xBestIndex.
+**
+** The bits of "flags" are as follows:
+**
+** 0x01 Ignore the aConstraint[].usable flag. This might
+** result in the xBestIndex method incorrectly using
+** unusable entries in the aConstraint[] array, which
+** should result in the SQLite core detecting and
+** reporting that the virtual table is not behaving
+** to spec.
+**
+** 0x02 Do not set the orderByConsumed flag, even if it
+** could be set.
+**
+** 0x04 Do not consume the OFFSET constraint, if there is
+** one. Instead, let the generated byte-code visit
+** and ignore the first few columns of output.
+**
+** 0x08 Use sqlite3_mprintf() to allocate an idxStr string.
+** The string is never used, but allocating it does
+** test the idxStr deallocation logic inside of the
+** SQLite core.
+**
+** 0x10 Cause the xBestIndex method to generate an idxNum
+** that xFilter does not understand, thus causing
+** the OP_VFilter opcode to raise an error.
+**
+** 0x20 Set the omit flag for all equality constraints on
+** columns X, A, B, C, and D that are used to limit
+** the search.
+**
+** 0x40 Add all constraints against X,A,B,C,D to the
+** vector of results sent to xFilter. Only the first
+** few are used, as required by idxNum.
+**
+** Because these flags take effect during xBestIndex, the RHS of the
+** flag= constraint must be accessible. In other words, the RHS of flag=
+** needs to be an integer literal, not another column of a join or a
+** bound parameter.
+**
+** ## LOGGING OUTPUT
+**
+** If the "logtab" columns is set, then each call to the xBestIndex method
+** inserts multiple rows into the table identified by "logtab". These
+** rows collectively show the content of the sqlite3_index_info object and
+** other context associated with the xBestIndex call.
+**
+** If the table named by "logtab" does not previously exist, it is created
+** automatically. The schema for the logtab table is like this:
+**
+** CREATE TEMP TABLE vt02_log(
+** bi INT, -- BestIndex call counter
+** vn TEXT, -- Variable Name
+** ix INT, -- Index or value
+** cn TEXT, -- Column Name
+** op INT, -- Opcode or "DESC" value
+** ux INT, -- "Usable" flag
+** ra BOOLEAN, -- Right-hand side Available.
+** rhs ANY, -- Right-Hand Side value
+** cs TEXT -- Collating Sequence for this constraint
+** );
+**
+** Because logging happens during xBestIindex, the RHS value of "logtab" must
+** be known to xBestIndex, which means it must be a string literal, not a
+** column in a join, or a bound parameter.
+**
+** ## VIRTUAL TABLE SCHEMA
+**
+** CREATE TABLE vt02(
+** x INT, -- integer between 0 and 9999 inclusive
+** a INT, -- The 1000s digit
+** b INT, -- The 100s digit
+** c INT, -- The 10s digit
+** d INT, -- The 1s digit
+** flags INT HIDDEN, -- Option flags
+** logtab TEXT HIDDEN, -- Name of table into which to log xBestIndex
+** );
+**
+** ## COMPILING AND RUNNING
+**
+** This file can also be compiled separately as a loadable extension
+** for SQLite (as long as the -DTH3_VERSION is not defined). To compile as a
+** loadable extension do his:
+**
+** gcc -Wall -g -shared -fPIC -I. -DSQLITE_DEBUG vt02.c -o vt02.so
+**
+** Or on Windows:
+**
+** cl vt02.c -link -dll -out:vt02.dll
+**
+** Then load into the CLI using:
+**
+** .load ./vt02 sqlite3_vt02_init
+**
+** ## IDXNUM SUMMARY
+**
+** The xBestIndex method communicates the query plan to xFilter using
+** the idxNum value, as follows:
+**
+** 0 unconstrained
+** 1 X=argv[0]
+** 2 A=argv[0]
+** 3 A=argv[0], B=argv[1]
+** 4 A=argv[0], B=argv[1], C=argv[2]
+** 5 A=argv[0], B=argv[1], C=argv[2], D=argv[3]
+** 6 A=argv[0], D IN argv[2]
+** 7 A=argv[0], B=argv[2], D IN argv[3]
+** 8 A=argv[0], B=argv[2], C=argv[3], D IN argv[4]
+** 1x increment by 10
+** 2x increment by 100
+** 3x increment by 1000
+** 1xx Use offset provided by argv[N]
+*/
+#ifndef TH3_VERSION
+ /* These bits for separate compilation as a loadable extension, only */
+ #include "sqlite3ext.h"
+ SQLITE_EXTENSION_INIT1
+ #include <stdlib.h>
+ #include <string.h>
+ #include <assert.h>
+#endif
+
+/* Forward declarations */
+typedef struct vt02_vtab vt02_vtab;
+typedef struct vt02_cur vt02_cur;
+
+/*
+** The complete virtual table
+*/
+struct vt02_vtab {
+ sqlite3_vtab parent; /* Base clase. Must be first. */
+ sqlite3 *db; /* Database connection */
+ int busy; /* Currently running xBestIndex */
+};
+
+#define VT02_IGNORE_USABLE 0x0001 /* Ignore usable flags */
+#define VT02_NO_SORT_OPT 0x0002 /* Do not do any sorting optimizations */
+#define VT02_NO_OFFSET 0x0004 /* Omit the offset optimization */
+#define VT02_ALLOC_IDXSTR 0x0008 /* Alloate an idxStr */
+#define VT02_BAD_IDXNUM 0x0010 /* Generate an invalid idxNum */
+
+/*
+** A cursor
+*/
+struct vt02_cur {
+ sqlite3_vtab_cursor parent; /* Base class. Must be first */
+ sqlite3_int64 i; /* Current entry */
+ sqlite3_int64 iEof; /* Indicate EOF when reaching this value */
+ int iIncr; /* Amount by which to increment */
+ unsigned int mD; /* Mask of allowed D-column values */
+};
+
+/* The xConnect method */
+int vt02Connect(
+ sqlite3 *db, /* The database connection */
+ void *pAux, /* Pointer to an alternative schema */
+ int argc, /* Number of arguments */
+ const char *const*argv, /* Text of the arguments */
+ sqlite3_vtab **ppVTab, /* Write the new vtab here */
+ char **pzErr /* Error message written here */
+){
+ vt02_vtab *pVtab;
+ int rc;
+ const char *zSchema = (const char*)pAux;
+ static const char zDefaultSchema[] =
+ "CREATE TABLE x(x INT, a INT, b INT, c INT, d INT,"
+ " flags INT HIDDEN, logtab TEXT HIDDEN);";
+#define VT02_COL_X 0
+#define VT02_COL_A 1
+#define VT02_COL_B 2
+#define VT02_COL_C 3
+#define VT02_COL_D 4
+#define VT02_COL_FLAGS 5
+#define VT02_COL_LOGTAB 6
+#define VT02_COL_NONE 7
+
+ pVtab = sqlite3_malloc( sizeof(*pVtab) );
+ if( pVtab==0 ){
+ *pzErr = sqlite3_mprintf("out of memory");
+ return SQLITE_NOMEM;
+ }
+ memset(pVtab, 0, sizeof(*pVtab));
+ pVtab->db = db;
+ rc = sqlite3_declare_vtab(db, zSchema ? zSchema : zDefaultSchema);
+ if( rc ){
+ sqlite3_free(pVtab);
+ }else{
+ *ppVTab = &pVtab->parent;
+ }
+ return rc;
+}
+
+/* the xDisconnect method
+*/
+int vt02Disconnect(sqlite3_vtab *pVTab){
+ sqlite3_free(pVTab);
+ return SQLITE_OK;
+}
+
+/* Put an error message into the zErrMsg string of the virtual table.
+*/
+static void vt02ErrMsg(sqlite3_vtab *pVtab, const char *zFormat, ...){
+ va_list ap;
+ sqlite3_free(pVtab->zErrMsg);
+ va_start(ap, zFormat);
+ pVtab->zErrMsg = sqlite3_vmprintf(zFormat, ap);
+ va_end(ap);
+}
+
+
+/* Open a cursor for scanning
+*/
+static int vt02Open(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
+ vt02_cur *pCur;
+ pCur = sqlite3_malloc( sizeof(*pCur) );
+ if( pCur==0 ){
+ vt02ErrMsg(pVTab, "out of memory");
+ return SQLITE_NOMEM;
+ }
+ *ppCursor = &pCur->parent;
+ pCur->i = -1;
+ return SQLITE_OK;
+}
+
+/* Close a cursor
+*/
+static int vt02Close(sqlite3_vtab_cursor *pCursor){
+ vt02_cur *pCur = (vt02_cur*)pCursor;
+ sqlite3_free(pCur);
+ return SQLITE_OK;
+}
+
+/* Return TRUE if we are at the end of the BVS and there are
+** no more entries.
+*/
+static int vt02Eof(sqlite3_vtab_cursor *pCursor){
+ vt02_cur *pCur = (vt02_cur*)pCursor;
+ return pCur->i<0 || pCur->i>=pCur->iEof;
+}
+
+/* Advance the cursor to the next row in the table
+*/
+static int vt02Next(sqlite3_vtab_cursor *pCursor){
+ vt02_cur *pCur = (vt02_cur*)pCursor;
+ do{
+ pCur->i += pCur->iIncr;
+ if( pCur->i<0 ) pCur->i = pCur->iEof;
+ }while( (pCur->mD & (1<<(pCur->i%10)))==0 && pCur->i<pCur->iEof );
+ return SQLITE_OK;
+}
+
+/* Rewind a cursor back to the beginning of its scan.
+**
+** Scanning is always increasing.
+**
+** idxNum
+** 0 unconstrained
+** 1 X=argv[0]
+** 2 A=argv[0]
+** 3 A=argv[0], B=argv[1]
+** 4 A=argv[0], B=argv[1], C=argv[2]
+** 5 A=argv[0], B=argv[1], C=argv[2], D=argv[3]
+** 6 A=argv[0], D IN argv[2]
+** 7 A=argv[0], B=argv[2], D IN argv[3]
+** 8 A=argv[0], B=argv[2], C=argv[3], D IN argv[4]
+** 1x increment by 10
+** 2x increment by 100
+** 3x increment by 1000
+** 1xx Use offset provided by argv[N]
+*/
+static int vt02Filter(
+ sqlite3_vtab_cursor *pCursor, /* The cursor to rewind */
+ int idxNum, /* Search strategy */
+ const char *idxStr, /* Not used */
+ int argc, /* Not used */
+ sqlite3_value **argv /* Not used */
+){
+ vt02_cur *pCur = (vt02_cur*)pCursor; /* The vt02 cursor */
+ int bUseOffset = 0; /* True to use OFFSET value */
+ int iArg = 0; /* argv[] values used so far */
+ int iOrigIdxNum = idxNum; /* Original value for idxNum */
+
+ pCur->iIncr = 1;
+ pCur->mD = 0x3ff;
+ if( idxNum>=100 ){
+ bUseOffset = 1;
+ idxNum -= 100;
+ }
+ if( idxNum<0 || idxNum>38 ) goto vt02_bad_idxnum;
+ while( idxNum>=10 ){
+ pCur->iIncr *= 10;
+ idxNum -= 10;
+ }
+ if( idxNum==0 ){
+ pCur->i = 0;
+ pCur->iEof = 10000;
+ }else if( idxNum==1 ){
+ pCur->i = sqlite3_value_int64(argv[0]);
+ if( pCur->i<0 ) pCur->i = -1;
+ if( pCur->i>9999 ) pCur->i = 10000;
+ pCur->iEof = pCur->i+1;
+ if( pCur->i<0 || pCur->i>9999 ) pCur->i = pCur->iEof;
+ }else if( idxNum>=2 && idxNum<=5 ){
+ int i, e, m;
+ e = idxNum - 2;
+ assert( e<=argc-1 );
+ pCur->i = 0;
+ for(m=1000, i=0; i<=e; i++, m /= 10){
+ sqlite3_int64 v = sqlite3_value_int64(argv[iArg++]);
+ if( v<0 ) v = 0;
+ if( v>9 ) v = 9;
+ pCur->i += m*v;
+ pCur->iEof = pCur->i+m;
+ }
+ }else if( idxNum>=6 && idxNum<=8 ){
+ int i, e, m, rc;
+ sqlite3_value *pIn, *pVal;
+ e = idxNum - 6;
+ assert( e<=argc-2 );
+ pCur->i = 0;
+ for(m=1000, i=0; i<=e; i++, m /= 10){
+ sqlite3_int64 v;
+ pVal = 0;
+ if( sqlite3_vtab_in_first(0, &pVal)!=SQLITE_MISUSE
+ || sqlite3_vtab_in_first(argv[iArg], &pVal)!=SQLITE_MISUSE
+ ){
+ vt02ErrMsg(pCursor->pVtab,
+ "unexpected success from sqlite3_vtab_in_first()");
+ return SQLITE_ERROR;
+ }
+ v = sqlite3_value_int64(argv[iArg++]);
+ if( v<0 ) v = 0;
+ if( v>9 ) v = 9;
+ pCur->i += m*v;
+ pCur->iEof = pCur->i+m;
+ }
+ pCur->mD = 0;
+ pIn = argv[iArg++];
+ assert( sqlite3_value_type(pIn)==SQLITE_NULL );
+ for( rc = sqlite3_vtab_in_first(pIn, &pVal);
+ rc==SQLITE_OK && pVal!=0;
+ rc = sqlite3_vtab_in_next(pIn, &pVal)
+ ){
+ int eType = sqlite3_value_numeric_type(pVal);
+ if( eType==SQLITE_FLOAT ){
+ double r = sqlite3_value_double(pVal);
+ if( r<0.0 || r>9.0 || r!=(int)r ) continue;
+ }else if( eType!=SQLITE_INTEGER ){
+ continue;
+ }
+ i = sqlite3_value_int(pVal);
+ if( i<0 || i>9 ) continue;
+ pCur->mD |= 1<<i;
+ }
+ if( rc!=SQLITE_OK && rc!=SQLITE_DONE ){
+ vt02ErrMsg(pCursor->pVtab, "Error from sqlite3_vtab_in_first/next()");
+ return rc;
+ }
+ }else{
+ goto vt02_bad_idxnum;
+ }
+ if( bUseOffset ){
+ int nSkip = sqlite3_value_int(argv[iArg]);
+ while( nSkip-- > 0 ) vt02Next(pCursor);
+ }
+ return SQLITE_OK;
+
+vt02_bad_idxnum:
+ vt02ErrMsg(pCursor->pVtab, "invalid idxNum for vt02: %d", iOrigIdxNum);
+ return SQLITE_ERROR;
+}
+
+/* Return the Nth column of the current row.
+*/
+static int vt02Column(
+ sqlite3_vtab_cursor *pCursor,
+ sqlite3_context *context,
+ int N
+){
+ vt02_cur *pCur = (vt02_cur*)pCursor;
+ int v = pCur->i;
+ if( N==VT02_COL_X ){
+ sqlite3_result_int(context, v);
+ }else if( N>=VT02_COL_A && N<=VT02_COL_D ){
+ static const int iDivisor[] = { 1, 1000, 100, 10, 1 };
+ v = (v/iDivisor[N])%10;
+ sqlite3_result_int(context, v);
+ }
+ return SQLITE_OK;
+}
+
+/* Return the rowid of the current row
+*/
+static int vt02Rowid(sqlite3_vtab_cursor *pCursor, sqlite3_int64 *pRowid){
+ vt02_cur *pCur = (vt02_cur*)pCursor;
+ *pRowid = pCur->i+1;
+ return SQLITE_OK;
+}
+
+/*************************************************************************
+** Logging Subsystem
+**
+** The sqlite3BestIndexLog() routine implements a logging system for
+** xBestIndex calls. This code is portable to any virtual table.
+**
+** sqlite3BestIndexLog() is the main routine, sqlite3RunSql() is a
+** helper routine used for running various SQL statements as part of
+** creating the log.
+**
+** These two routines should be portable to other virtual tables. Simply
+** extract this code and call sqlite3BestIndexLog() near the end of the
+** xBestIndex method in cases where logging is desired.
+*/
+/*
+** Run SQL on behalf of sqlite3BestIndexLog.
+**
+** Construct the SQL using the zFormat string and subsequent arguments.
+** Or if zFormat is NULL, take the SQL as the first argument after the
+** zFormat. In either case, the dynamically allocated SQL string is
+** freed after it has been run. If something goes wrong with the SQL,
+** then an error is left in pVTab->zErrMsg.
+*/
+static void sqlite3RunSql(
+ sqlite3 *db, /* Run the SQL on this database connection */
+ sqlite3_vtab *pVTab, /* Report errors to this virtual table */
+ const char *zFormat, /* Format string for SQL, or NULL */
+ ... /* Arguments, according to the format string */
+){
+ char *zSql;
+
+ va_list ap;
+ va_start(ap, zFormat);
+ if( zFormat==0 ){
+ zSql = va_arg(ap, char*);
+ }else{
+ zSql = sqlite3_vmprintf(zFormat, ap);
+ }
+ va_end(ap);
+ if( zSql ){
+ char *zErrMsg = 0;
+ (void)sqlite3_exec(db, zSql, 0, 0, &zErrMsg);
+ if( zErrMsg ){
+ if( pVTab->zErrMsg==0 ){
+ pVTab->zErrMsg = sqlite3_mprintf("%s in [%s]", zErrMsg, zSql);
+ }
+ sqlite3_free(zErrMsg);
+ }
+ sqlite3_free(zSql);
+ }
+}
+
+/*
+** Record information about each xBestIndex method call in a separate
+** table:
+**
+** CREATE TEMP TABLE [log-table-name] (
+** bi INT, -- BestIndex call number
+** vn TEXT, -- Variable Name
+** ix INT, -- Index or value
+** cn TEXT, -- Column Name
+** op INT, -- Opcode or argvIndex
+** ux INT, -- "usable" or "omit" flag
+** rx BOOLEAN, -- True if has a RHS value
+** rhs ANY, -- The RHS value
+** cs TEXT, -- Collating Sequence
+** inop BOOLEAN -- True if this is a batchable IN operator
+** );
+**
+** If an error occurs, leave an error message in pVTab->zErrMsg.
+*/
+static void sqlite3BestIndexLog(
+ sqlite3_index_info *pInfo, /* The sqlite3_index_info object */
+ const char *zLogTab, /* Log into this table */
+ sqlite3 *db, /* Database connection containing zLogTab */
+ const char **azColname, /* Names of columns in the virtual table */
+ sqlite3_vtab *pVTab /* Record errors into this object */
+){
+ int i, rc;
+ sqlite3_str *pStr;
+ int iBI;
+
+ if( sqlite3_table_column_metadata(db,0,zLogTab,0,0,0,0,0,0) ){
+ /* The log table does not previously exist. Create it. */
+ sqlite3RunSql(db,pVTab,
+ "CREATE TABLE IF NOT EXISTS temp.\"%w\"(\n"
+ " bi INT, -- BestIndex call number\n"
+ " vn TEXT, -- Variable Name\n"
+ " ix INT, -- Index or value\n"
+ " cn TEXT, -- Column Name\n"
+ " op INT, -- Opcode or argvIndex\n"
+ " ux INT, -- usable for omit flag\n"
+ " rx BOOLEAN, -- Right-hand side value is available\n"
+ " rhs ANY, -- RHS value\n"
+ " cs TEXT, -- Collating Sequence\n"
+ " inop BOOLEAN -- IN operator capable of batch reads\n"
+ ");", zLogTab
+ );
+ iBI = 1;
+ }else{
+ /* The log table does already exist. We assume that it has the
+ ** correct schema and proceed to find the largest prior "bi" value.
+ ** If the schema is wrong, errors might result. The code is able
+ ** to deal with this. */
+ sqlite3_stmt *pStmt;
+ char *zSql;
+ zSql = sqlite3_mprintf("SELECT max(bi) FROM temp.\"%w\"",zLogTab);
+ if( zSql==0 ){
+ sqlite3_free(pVTab->zErrMsg);
+ pVTab->zErrMsg = sqlite3_mprintf("out of memory");
+ return;
+ }
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ sqlite3_free(zSql);
+ if( rc ){
+ sqlite3_free(pVTab->zErrMsg);
+ pVTab->zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(db));
+ iBI = 0;
+ }else if( sqlite3_step(pStmt)==SQLITE_ROW ){
+ iBI = sqlite3_column_int(pStmt, 0)+1;
+ }else{
+ iBI = 1;
+ }
+ sqlite3_finalize(pStmt);
+ }
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix) VALUES(%d,'nConstraint',%d)",
+ zLogTab, iBI, pInfo->nConstraint
+ );
+ for(i=0; i<pInfo->nConstraint; i++){
+ sqlite3_value *pVal;
+ char *zSql;
+ int iCol = pInfo->aConstraint[i].iColumn;
+ int op = pInfo->aConstraint[i].op;
+ const char *zCol;
+ if( op==SQLITE_INDEX_CONSTRAINT_LIMIT
+ || op==SQLITE_INDEX_CONSTRAINT_OFFSET
+ ){
+ zCol = "";
+ }else if( iCol<0 ){
+ zCol = "rowid";
+ }else{
+ zCol = azColname[iCol];
+ }
+ pStr = sqlite3_str_new(0);
+ sqlite3_str_appendf(pStr,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix,cn,op,ux,rx,rhs,cs,inop)"
+ "VALUES(%d,'aConstraint',%d,%Q,%d,%d",
+ zLogTab, iBI,
+ i,
+ zCol,
+ op,
+ pInfo->aConstraint[i].usable);
+ pVal = 0;
+ rc = sqlite3_vtab_rhs_value(pInfo, i, &pVal);
+ assert( pVal!=0 || rc!=SQLITE_OK );
+ if( rc==SQLITE_OK ){
+ sqlite3_str_appendf(pStr,",1,?1");
+ }else{
+ sqlite3_str_appendf(pStr,",0,NULL");
+ }
+ sqlite3_str_appendf(pStr,",%Q,%d)",
+ sqlite3_vtab_collation(pInfo,i),
+ sqlite3_vtab_in(pInfo,i,-1));
+ zSql = sqlite3_str_finish(pStr);
+ if( zSql==0 ){
+ if( pVTab->zErrMsg==0 ) pVTab->zErrMsg = sqlite3_mprintf("out of memory");
+ }else{
+ sqlite3_stmt *pStmt = 0;
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+ if( rc ){
+ if( pVTab->zErrMsg==0 ){
+ pVTab->zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(db));
+ }
+ }else{
+ if( pVal ) sqlite3_bind_value(pStmt, 1, pVal);
+ sqlite3_step(pStmt);
+ rc = sqlite3_reset(pStmt);
+ if( rc && pVTab->zErrMsg==0 ){
+ pVTab->zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(db));
+ }
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_free(zSql);
+ }
+ }
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix) VALUES(%d,'nOrderBy',%d)",
+ zLogTab, iBI, pInfo->nOrderBy
+ );
+ for(i=0; i<pInfo->nOrderBy; i++){
+ int iCol = pInfo->aOrderBy[i].iColumn;
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix,cn,op)VALUES(%d,'aOrderBy',%d,%Q,%d)",
+ zLogTab, iBI,
+ i,
+ iCol>=0 ? azColname[iCol] : "rowid",
+ pInfo->aOrderBy[i].desc
+ );
+ }
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix) VALUES(%d,'sqlite3_vtab_distinct',%d)",
+ zLogTab, iBI, sqlite3_vtab_distinct(pInfo)
+ );
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix) VALUES(%d,'colUsed',%lld)",
+ zLogTab, iBI, pInfo->colUsed
+ );
+ for(i=0; i<pInfo->nConstraint; i++){
+ int iCol = pInfo->aConstraint[i].iColumn;
+ int op = pInfo->aConstraint[i].op;
+ const char *zCol;
+ if( op==SQLITE_INDEX_CONSTRAINT_LIMIT
+ || op==SQLITE_INDEX_CONSTRAINT_OFFSET
+ ){
+ zCol = "";
+ }else if( iCol<0 ){
+ zCol = "rowid";
+ }else{
+ zCol = azColname[iCol];
+ }
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix,cn,op,ux)"
+ "VALUES(%d,'aConstraintUsage',%d,%Q,%d,%d)",
+ zLogTab, iBI,
+ i,
+ zCol,
+ pInfo->aConstraintUsage[i].argvIndex,
+ pInfo->aConstraintUsage[i].omit
+ );
+ }
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix)VALUES(%d,'idxNum',%d)",
+ zLogTab, iBI, pInfo->idxNum
+ );
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix)VALUES(%d,'estimatedCost',%f)",
+ zLogTab, iBI, pInfo->estimatedCost
+ );
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix)VALUES(%d,'estimatedRows',%lld)",
+ zLogTab, iBI, pInfo->estimatedRows
+ );
+ if( pInfo->idxStr ){
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix)VALUES(%d,'idxStr',%Q)",
+ zLogTab, iBI, pInfo->idxStr
+ );
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix)VALUES(%d,'needToFreeIdxStr',%d)",
+ zLogTab, iBI, pInfo->needToFreeIdxStr
+ );
+ }
+ if( pInfo->nOrderBy ){
+ sqlite3RunSql(db,pVTab,
+ "INSERT INTO temp.\"%w\"(bi,vn,ix)VALUES(%d,'orderByConsumed',%d)",
+ zLogTab, iBI, pInfo->orderByConsumed
+ );
+ }
+}
+/*
+** End of Logging Subsystem
+*****************************************************************************/
+
+
+/* Find an estimated cost of running a query against vt02.
+*/
+static int vt02BestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
+ int i; /* Loop counter */
+ int isEq[5]; /* Equality constraints on X, A, B, C, and D */
+ int isUsed[5]; /* Other non-== cosntraints X, A, B, C, and D */
+ int argvIndex = 0; /* Next available argv[] slot */
+ int iOffset = -1; /* Constraint for OFFSET */
+ void *pX = 0; /* idxStr value */
+ int flags = 0; /* RHS value for flags= */
+ const char *zLogTab = 0; /* RHS value for logtab= */
+ int iFlagTerm = -1; /* Constraint term for flags= */
+ int iLogTerm = -1; /* Constraint term for logtab= */
+ int iIn = -1; /* Index of the IN constraint */
+ vt02_vtab *pSelf; /* This virtual table */
+
+ pSelf = (vt02_vtab*)pVTab;
+ if( pSelf->busy ){
+ vt02ErrMsg(pVTab, "recursive use of vt02 prohibited");
+ return SQLITE_CONSTRAINT;
+ }
+ pSelf->busy++;
+
+
+ /* Do an initial scan for flags=N and logtab=TAB constraints with
+ ** usable RHS values */
+ for(i=0; i<pInfo->nConstraint; i++){
+ sqlite3_value *pVal;
+ if( !pInfo->aConstraint[i].usable ) continue;
+ if( pInfo->aConstraint[i].op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
+ switch( pInfo->aConstraint[i].iColumn ){
+ case VT02_COL_FLAGS:
+ if( sqlite3_vtab_rhs_value(pInfo, i, &pVal)==SQLITE_OK
+ && sqlite3_value_type(pVal)==SQLITE_INTEGER
+ ){
+ flags = sqlite3_value_int(pVal);
+ }
+ iFlagTerm = i;
+ break;
+ case VT02_COL_LOGTAB:
+ if( sqlite3_vtab_rhs_value(pInfo, i, &pVal)==SQLITE_OK
+ && sqlite3_value_type(pVal)==SQLITE_TEXT
+ ){
+ zLogTab = (const char*)sqlite3_value_text(pVal);
+ }
+ iLogTerm = i;
+ break;
+ }
+ }
+
+ /* Do a second scan to actually analyze the index information */
+ memset(isEq, 0xff, sizeof(isEq));
+ memset(isUsed, 0xff, sizeof(isUsed));
+ for(i=0; i<pInfo->nConstraint; i++){
+ int j = pInfo->aConstraint[i].iColumn;
+ if( j>=VT02_COL_FLAGS ) continue;
+ if( pInfo->aConstraint[i].usable==0
+ && (flags & VT02_IGNORE_USABLE)==0 ) continue;
+ if( j<0 ) j = VT02_COL_X;
+ switch( pInfo->aConstraint[i].op ){
+ case SQLITE_INDEX_CONSTRAINT_FUNCTION:
+ case SQLITE_INDEX_CONSTRAINT_EQ:
+ isEq[j] = i;
+ break;
+ case SQLITE_INDEX_CONSTRAINT_LT:
+ case SQLITE_INDEX_CONSTRAINT_LE:
+ case SQLITE_INDEX_CONSTRAINT_GT:
+ case SQLITE_INDEX_CONSTRAINT_GE:
+ isUsed[j] = i;
+ break;
+ case SQLITE_INDEX_CONSTRAINT_OFFSET:
+ iOffset = i;
+ break;
+ }
+ }
+
+ /* Use the analysis to find an appropriate query plan */
+ if( isEq[0]>=0 ){
+ /* A constraint of X= takes priority */
+ pInfo->estimatedCost = 1;
+ pInfo->aConstraintUsage[isEq[0]].argvIndex = ++argvIndex;
+ if( flags & 0x20 ) pInfo->aConstraintUsage[isEq[0]].omit = 1;
+ pInfo->idxNum = 1;
+ }else if( isEq[1]<0 ){
+ /* If there is no X= nor A= then we have to do a full scan */
+ pInfo->idxNum = 0;
+ pInfo->estimatedCost = 10000;
+ }else{
+ int v = 1000;
+ pInfo->aConstraintUsage[isEq[1]].argvIndex = ++argvIndex;
+ if( flags & 0x20 ) pInfo->aConstraintUsage[isEq[1]].omit = 1;
+ for(i=2; i<=4 && isEq[i]>=0; i++){
+ if( i==4 && sqlite3_vtab_in(pInfo, isEq[4], 0) ) break;
+ pInfo->aConstraintUsage[isEq[i]].argvIndex = ++argvIndex;
+ if( flags & 0x20 ) pInfo->aConstraintUsage[isEq[i]].omit = 1;
+ v /= 10;
+ }
+ pInfo->idxNum = i;
+ if( isEq[4]>=0 && sqlite3_vtab_in(pInfo,isEq[4],1) ){
+ iIn = isEq[4];
+ pInfo->aConstraintUsage[iIn].argvIndex = ++argvIndex;
+ if( flags & 0x20 ) pInfo->aConstraintUsage[iIn].omit = 1;
+ v /= 5;
+ i++;
+ pInfo->idxNum += 4;
+ }
+ pInfo->estimatedCost = v;
+ }
+ pInfo->estimatedRows = (sqlite3_int64)pInfo->estimatedCost;
+
+ /* Attempt to consume the ORDER BY clause. Except, always leave
+ ** orderByConsumed set to 0 for vt02_no_sort_opt. In this way,
+ ** we can compare vt02 and vt02_no_sort_opt to ensure they get
+ ** the same answer.
+ */
+ if( pInfo->nOrderBy>0 && (flags & VT02_NO_SORT_OPT)==0 ){
+ if( pInfo->idxNum==1 ){
+ /* There will only be one row of output. So it is always sorted. */
+ pInfo->orderByConsumed = 1;
+ }else
+ if( pInfo->aOrderBy[0].iColumn<=0
+ && pInfo->aOrderBy[0].desc==0
+ ){
+ /* First column of order by is X ascending */
+ pInfo->orderByConsumed = 1;
+ }else
+ if( sqlite3_vtab_distinct(pInfo)>=1 ){
+ unsigned int x = 0;
+ for(i=0; i<pInfo->nOrderBy; i++){
+ int iCol = pInfo->aOrderBy[i].iColumn;
+ if( iCol<0 ) iCol = 0;
+ x |= 1<<iCol;
+ }
+ if( sqlite3_vtab_distinct(pInfo)==2 ){
+ if( x==0x02 ){
+ /* DISTINCT A */
+ pInfo->idxNum += 30;
+ pInfo->orderByConsumed = 1;
+ }else if( x==0x06 ){
+ /* DISTINCT A,B */
+ pInfo->idxNum += 20;
+ pInfo->orderByConsumed = 1;
+ }else if( x==0x0e ){
+ /* DISTINCT A,B,C */
+ pInfo->idxNum += 10;
+ pInfo->orderByConsumed = 1;
+ }else if( x & 0x01 ){
+ /* DISTINCT X */
+ pInfo->orderByConsumed = 1;
+ }else if( x==0x1e ){
+ /* DISTINCT A,B,C,D */
+ pInfo->orderByConsumed = 1;
+ }
+ }else{
+ if( x==0x02 ){
+ /* GROUP BY A */
+ pInfo->orderByConsumed = 1;
+ }else if( x==0x06 ){
+ /* GROUP BY A,B */
+ pInfo->orderByConsumed = 1;
+ }else if( x==0x0e ){
+ /* GROUP BY A,B,C */
+ pInfo->orderByConsumed = 1;
+ }else if( x & 0x01 ){
+ /* GROUP BY X */
+ pInfo->orderByConsumed = 1;
+ }else if( x==0x1e ){
+ /* GROUP BY A,B,C,D */
+ pInfo->orderByConsumed = 1;
+ }
+ }
+ }
+ }
+
+ if( flags & VT02_ALLOC_IDXSTR ){
+ pInfo->idxStr = sqlite3_mprintf("test");
+ pInfo->needToFreeIdxStr = 1;
+ }
+ if( flags & VT02_BAD_IDXNUM ){
+ pInfo->idxNum += 1000;
+ }
+
+ if( iOffset>=0 ){
+ pInfo->aConstraintUsage[iOffset].argvIndex = ++argvIndex;
+ if( (flags & VT02_NO_OFFSET)==0
+ && (pInfo->nOrderBy==0 || pInfo->orderByConsumed)
+ ){
+ pInfo->aConstraintUsage[iOffset].omit = 1;
+ pInfo->idxNum += 100;
+ }
+ }
+
+
+ /* Always omit flags= and logtab= constraints to prevent them from
+ ** interfering with the bytecode. Put them at the end of the argv[]
+ ** array to keep them out of the way.
+ */
+ if( iFlagTerm>=0 ){
+ pInfo->aConstraintUsage[iFlagTerm].omit = 1;
+ pInfo->aConstraintUsage[iFlagTerm].argvIndex = ++argvIndex;
+ }
+ if( iLogTerm>=0 ){
+ pInfo->aConstraintUsage[iLogTerm].omit = 1;
+ pInfo->aConstraintUsage[iLogTerm].argvIndex = ++argvIndex;
+ }
+
+ /* The 0x40 flag means add all usable constraints to the output set */
+ if( flags & 0x40 ){
+ for(i=0; i<pInfo->nConstraint; i++){
+ if( pInfo->aConstraint[i].usable
+ && pInfo->aConstraintUsage[i].argvIndex==0
+ ){
+ pInfo->aConstraintUsage[i].argvIndex = ++argvIndex;
+ if( flags & 0x20 ) pInfo->aConstraintUsage[i].omit = 1;
+ }
+ }
+ }
+
+
+ /* Generate the log if requested */
+ if( zLogTab ){
+ static const char *azColname[] = {
+ "x", "a", "b", "c", "d", "flags", "logtab"
+ };
+ sqlite3 *db = ((vt02_vtab*)pVTab)->db;
+ sqlite3BestIndexLog(pInfo, zLogTab, db, azColname, pVTab);
+ }
+ pSelf->busy--;
+
+ /* Try to do a memory allocation solely for the purpose of causing
+ ** an error under OOM testing loops */
+ pX = sqlite3_malloc(800);
+ if( pX==0 ) return SQLITE_NOMEM;
+ sqlite3_free(pX);
+
+ return pVTab->zErrMsg!=0 ? SQLITE_ERROR : SQLITE_OK;
+}
+
+/* This is the sqlite3_module definition for the the virtual table defined
+** by this include file.
+*/
+const sqlite3_module vt02Module = {
+ /* iVersion */ 2,
+ /* xCreate */ 0, /* This is an eponymous table */
+ /* xConnect */ vt02Connect,
+ /* xBestIndex */ vt02BestIndex,
+ /* xDisconnect */ vt02Disconnect,
+ /* xDestroy */ vt02Disconnect,
+ /* xOpen */ vt02Open,
+ /* xClose */ vt02Close,
+ /* xFilter */ vt02Filter,
+ /* xNext */ vt02Next,
+ /* xEof */ vt02Eof,
+ /* xColumn */ vt02Column,
+ /* xRowid */ vt02Rowid,
+ /* xUpdate */ 0,
+ /* xBegin */ 0,
+ /* xSync */ 0,
+ /* xCommit */ 0,
+ /* xRollback */ 0,
+ /* xFindFunction */ 0,
+ /* xRename */ 0,
+ /* xSavepoint */ 0,
+ /* xRelease */ 0,
+ /* xRollbackTo */ 0
+};
+
+static void vt02CoreInit(sqlite3 *db){
+ static const char zPkXSchema[] =
+ "CREATE TABLE x(x INT NOT NULL PRIMARY KEY, a INT, b INT, c INT, d INT,"
+ " flags INT HIDDEN, logtab TEXT HIDDEN);";
+ static const char zPkABCDSchema[] =
+ "CREATE TABLE x(x INT, a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, "
+ "d INT NOT NULL, flags INT HIDDEN, logtab TEXT HIDDEN, "
+ "PRIMARY KEY(a,b,c,d));";
+ sqlite3_create_module(db, "vt02", &vt02Module, 0);
+ sqlite3_create_module(db, "vt02pkx", &vt02Module, (void*)zPkXSchema);
+ sqlite3_create_module(db, "vt02pkabcd", &vt02Module, (void*)zPkABCDSchema);
+}
+
+#ifdef TH3_VERSION
+static void vt02_init(th3state *p, int iDb, char *zArg){
+ vt02CoreInit(th3dbPointer(p, iDb));
+}
+#else
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int sqlite3_vt02_init(
+ sqlite3 *db,
+ char **pzErrMsg,
+ const sqlite3_api_routines *pApi
+){
+ SQLITE_EXTENSION_INIT2(pApi);
+ vt02CoreInit(db);
+ return SQLITE_OK;
+}
+#endif /* TH3_VERSION */
diff --git a/test/vtab1.test b/test/vtab1.test
new file mode 100644
index 0000000..4b8fb9c
--- /dev/null
+++ b/test/vtab1.test
@@ -0,0 +1,1593 @@
+# 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
+set testprefix vtab1
+
+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(...)"
+#
+# vtab1-18.*: Check that the LIKE optimization is not applied when the lhs
+# is a virtual table column.
+#
+
+
+#----------------------------------------------------------------------
+# Test cases vtab1.1.*
+#
+
+# We cannot create a virtual table if the module has not been registered.
+#
+do_test vtab1-1.1.1 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING echo;
+ }
+} {1 {no such module: echo}}
+do_test vtab1-1.1.2 {
+ catchsql {
+ CREATE VIRTUAL TABLE IF NOT EXISTS 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.1 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING echo;
+ }
+} {1 {vtable constructor did not declare schema: t1}}
+do_test vtab1-1.3.2 {
+ catchsql {
+ CREATE VIRTUAL TABLE IF NOT EXISTS 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.1 {
+ catchsql {
+ CREATE VIRTUAL TABLE t1 USING echo(no_such_table);
+ }
+} {1 {vtable constructor failed: t1}}
+do_test vtab1-1.5.2 {
+ catchsql {
+ CREATE VIRTUAL TABLE IF NOT EXISTS 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.1 {
+ catchsql {
+ CREATE VIRTUAL TABLE sqlite_master USING echo;
+ }
+} {1 {object name reserved for internal use: sqlite_master}}
+do_test vtab1-1.7.2 {
+ catchsql {
+ CREATE VIRTUAL TABLE IF NOT EXISTS sqlite_master USING echo;
+ }
+} {1 {object name reserved for internal use: sqlite_master}}
+do_test vtab1-1.8.1 {
+ catchsql {
+ CREATE TABLE treal(a, b, c);
+ CREATE VIRTUAL TABLE treal USING echo(treal);
+ }
+} {1 {table treal already exists}}
+do_test vtab1-1.8.2 {
+ catchsql {
+ CREATE VIRTUAL TABLE IF NOT EXISTS treal USING echo(treal);
+ }
+} {0 {}}
+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.1 {
+ 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.2 {
+ set echo_module ""
+ execsql {
+ SELECT * FROM t1;
+ }
+ set echo_module
+} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal'} \
+ xFilter {SELECT rowid, a, b, c 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, a, b, c FROM 'treal' WHERE b = ?} \
+ xFilter {SELECT rowid, a, b, c 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, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\
+ xFilter {SELECT rowid, a, b, c 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, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\
+ xFilter {SELECT rowid, a, b, c 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, a, b, c FROM 'treal'} \
+ xFilter {SELECT rowid, a, b, c 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, a, b, c FROM 'treal' WHERE b LIKE (SELECT '%'||?||'%')} \
+ xFilter \
+ {SELECT rowid, a, b, c 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, NULL, b, NULL FROM 'treal' ORDER BY b ASC} \
+ xFilter {SELECT rowid, NULL, b, NULL 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, NULL, b, NULL FROM 'treal' ORDER BY b DESC} \
+ xFilter {SELECT rowid, NULL, b, NULL 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, NULL, b, NULL FROM 'treal'} \
+ xFilter {SELECT rowid, NULL, b, NULL 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, a, b, c FROM 't1'} \
+ xFilter {SELECT rowid, d, e, f FROM 't2'} \
+ xFilter {SELECT rowid, d, e, f 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, a, b, c FROM 't1'} \
+ xFilter {SELECT rowid, d, e, f FROM 't2'} \
+ xFilter {SELECT rowid, d, e, f 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, a, b, c FROM 't1'} \
+ xFilter {SELECT rowid, d, e, f FROM 't2' WHERE d = ?} \
+ xFilter {SELECT rowid, d, e, f FROM 't2' WHERE d = ?} \
+]
+
+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
+ }
+} {}
+
+# PRAGMA index_info and index_xinfo are no-ops on a virtual table
+do_test vtab1.7-14 {
+ execsql {
+ PRAGMA index_info('echo_abc');
+ PRAGMA index_xinfo('echo_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 {bad parameter or other API misuse}}
+do_test vtab1.10-3 {
+ set ::echo_module_begin_fail r
+ catchsql {
+ INSERT INTO e VALUES(1, 2, 3);
+ }
+} {1 {SQL logic error}}
+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, a, b, c FROM 'r'} \
+ xFilter {SELECT rowid, a, b, c FROM 'r'} \
+]
+proc match_func {args} {return ""}
+do_test vtab1.10-6 {
+ set echo_module ""
+ sqlite_delete_function db match
+ db function match match_func
+ execsql {
+ SELECT * FROM e WHERE match('pattern', rowid, 'pattern2');
+ }
+ set echo_module
+} [list \
+ xBestIndex {SELECT rowid, a, b, c FROM 'r'} \
+ xFilter {SELECT rowid, a, b, c 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: UNIQUE constraint failed: c.a}}
+do_test vtab1.12-2.1 {
+ sqlite3_errmsg db
+} {echo-vtab-error: UNIQUE constraint failed: c.a}
+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: UNIQUE constraint failed: c.a}}
+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-4 {
+ unset -nocomplain null
+ execsql {
+ SELECT * FROM echo_c WHERE b IS $null
+ }
+} {15 {} 16}
+do_test vtab1.13-5 {
+ execsql {
+ SELECT * FROM echo_c WHERE b IS NULL AND a = 15;
+ }
+} {15 {} 16}
+do_test vtab1.13-6 {
+ execsql {
+ SELECT * FROM echo_c WHERE NULL IS b AND a IS 15;
+ }
+} {15 {} 16}
+
+
+do_test vtab1-14.001 {
+ execsql {SELECT rowid, * FROM echo_c WHERE +rowid IN (1,2,3)}
+} {1 3 G H 2 {} 15 16 3 15 {} 16}
+do_test vtab1-14.002 {
+ execsql {SELECT rowid, * FROM echo_c WHERE rowid IN (1,2,3)}
+} {1 3 G H 2 {} 15 16 3 15 {} 16}
+do_test vtab1-14.003 {
+ execsql {SELECT rowid, * FROM echo_c WHERE +rowid IN (0,1,5,2,'a',3,NULL)}
+} {1 3 G H 2 {} 15 16 3 15 {} 16}
+do_test vtab1-14.004 {
+ execsql {SELECT rowid, * FROM echo_c WHERE rowid IN (0,1,5,'a',2,3,NULL)}
+} {1 3 G H 2 {} 15 16 3 15 {} 16}
+do_test vtab1-14.005 {
+ execsql {SELECT rowid, * FROM echo_c WHERE rowid NOT IN (0,1,5,'a',2,3)}
+} {}
+do_test vtab1-14.006 {
+ execsql {SELECT rowid, * FROM echo_c WHERE rowid NOT IN (0,5,'a',2,3)}
+} {1 3 G H}
+do_test vtab1-14.007 {
+ execsql {SELECT rowid, * FROM echo_c WHERE +rowid NOT IN (0,5,'a',2,3,NULL)}
+} {}
+do_test vtab1-14.008 {
+ execsql {SELECT rowid, * FROM echo_c WHERE rowid NOT IN (0,5,'a',2,3,NULL)}
+} {}
+do_test vtab1-14.011 {
+ execsql {SELECT * FROM echo_c WHERE +a IN (1,3,8,'x',NULL,15,24)}
+} {3 G H 15 {} 16}
+do_test vtab1-14.012 {
+ execsql {SELECT * FROM echo_c WHERE a IN (1,3,8,'x',NULL,15,24)}
+} {3 G H 15 {} 16}
+do_test vtab1-14.013 {
+ execsql {SELECT * FROM echo_c WHERE a NOT IN (1,8,'x',15,24)}
+} {3 G H}
+do_test vtab1-14.014 {
+ execsql {SELECT * FROM echo_c WHERE a NOT IN (1,8,'x',NULL,15,24)}
+} {}
+do_test vtab1-14.015 {
+ execsql {SELECT * FROM echo_c WHERE +a NOT IN (1,8,'x',NULL,15,24)}
+} {}
+
+
+
+#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
+#} {/.*xBestIndex {SELECT rowid, . FROM 'c' WHERE rowid = .} xFilter {SELECT rowid, . FROM 'c'} 1/}
+
+do_test vtab1-14.2 {
+ set echo_module ""
+ execsql { SELECT * FROM echo_c WHERE rowid = 1 }
+ set echo_module
+} [list xBestIndex {SELECT rowid, a, b, c FROM 'c' WHERE rowid = ?} \
+ xFilter {SELECT rowid, a, b, c 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, a, b, c FROM 'c' WHERE a = ?} \
+ xFilter {SELECT rowid, a, b, c 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
+#} {/xBestIndex {SELECT rowid, . FROM 'c' WHERE a = .} xFilter {SELECT rowid, . FROM 'c' WHERE a = .} 1/}
+
+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 {
+ sqlite3_db_config db DEFENSIVE 0
+ 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;
+ }
+} {}
+
+do_test vtab1-17.2 {
+ execsql { DELETE FROM sqlite_master WHERE sql LIKE 'insert%' }
+} {}
+
+#-------------------------------------------------------------------------
+# The following tests - vtab1-18.* - test that the optimization of LIKE
+# constraints in where.c plays well with virtual tables.
+#
+# 18.1.*: Case-insensitive LIKE.
+# 18.2.*: Case-sensitive LIKE.
+#
+unset -nocomplain echo_module_begin_fail
+
+do_execsql_test 18.1.0 {
+ CREATE TABLE t6(a, b TEXT);
+ CREATE INDEX i6 ON t6(b, a);
+ INSERT INTO t6 VALUES(1, 'Peter');
+ INSERT INTO t6 VALUES(2, 'Andrew');
+ INSERT INTO t6 VALUES(3, '8James');
+ INSERT INTO t6 VALUES(4, '8John');
+ INSERT INTO t6 VALUES(5, 'Phillip');
+ INSERT INTO t6 VALUES(6, 'Bartholomew');
+ CREATE VIRTUAL TABLE e6 USING echo(t6);
+}
+
+ifcapable !icu {
+ foreach {tn sql res filter} {
+ 1.1 "SELECT a FROM e6 WHERE b>'8James'" {4 2 6 1 5}
+ {xFilter {SELECT rowid, a, b FROM 't6' WHERE b > ?} 8James}
+
+ 1.2 "SELECT a FROM e6 WHERE b>='8' AND b<'9'" {3 4}
+ {xFilter {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ?} 8 9}
+
+ 1.3 "SELECT a FROM e6 WHERE b LIKE '8J%'" {3 4}
+ {xFilter {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ? AND b like ?} 8J 8k 8J%}
+
+ 1.4 "SELECT a FROM e6 WHERE b LIKE '8j%'" {3 4}
+ {xFilter {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ? AND b like ?} 8J 8k 8j%}
+
+ 1.5 "SELECT a FROM e6 WHERE b LIKE '8%'" {3 4}
+ {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} 8%}
+ } {
+ set echo_module {}
+ do_execsql_test 18.$tn.1 $sql $res
+ do_test 18.$tn.2 { lrange $::echo_module 2 end } $filter
+ }
+}
+
+do_execsql_test 18.2.0 { PRAGMA case_sensitive_like = ON }
+foreach {tn sql res filter} {
+ 2.1 "SELECT a FROM e6 WHERE b LIKE '8%'" {3 4}
+ {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} 8%}
+
+ 2.2 "SELECT a FROM e6 WHERE b LIKE '8j%'" {}
+ {xFilter {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ? AND b like ?} 8j 8k 8j%}
+
+ 2.3 "SELECT a FROM e6 WHERE b LIKE '8J%'" {3 4}
+ {xFilter {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ? AND b like ?} 8J 8K 8J%}
+} {
+ set echo_module {}
+ do_execsql_test 18.$tn.1 $sql $res
+ do_test 18.$tn.2 { lrange $::echo_module 2 end } $filter
+}
+do_execsql_test 18.2.x { PRAGMA case_sensitive_like = OFF }
+
+#-------------------------------------------------------------------------
+# Test that it is ok to override and existing module.
+#
+do_test 19.1 {
+ sqlite3 db2 test.db
+ register_echo_module [sqlite3_connection_pointer db2]
+} SQLITE_OK
+do_test 19.2 {
+ register_echo_module [sqlite3_connection_pointer db2]
+} SQLITE_OK
+do_test 19.3 {
+ db2 close
+} {}
+
+#-------------------------------------------------------------------------
+# Test that the bug fixed by [b0c1ba655d69] really is fixed.
+#
+do_execsql_test 20.1 {
+ CREATE TABLE t7 (a, b);
+ CREATE TABLE t8 (c, d);
+ CREATE INDEX i2 ON t7(a);
+ CREATE INDEX i3 ON t7(b);
+ CREATE INDEX i4 ON t8(c);
+ CREATE INDEX i5 ON t8(d);
+
+ CREATE VIRTUAL TABLE t7v USING echo(t7);
+ CREATE VIRTUAL TABLE t8v USING echo(t8);
+}
+
+do_test 20.2 {
+ for {set i 0} {$i < 1000} {incr i} {
+ db eval {INSERT INTO t7 VALUES($i, $i)}
+ db eval {INSERT INTO t8 VALUES($i, $i)}
+ }
+} {}
+
+do_execsql_test 20.3 {
+ SELECT a, b FROM (
+ SELECT a, b FROM t7 WHERE a=11 OR b=12
+ UNION ALL
+ SELECT c, d FROM t8 WHERE c=5 OR d=6
+ )
+ ORDER BY 1, 2;
+} {5 5 6 6 11 11 12 12}
+
+do_execsql_test 20.4 {
+ SELECT a, b FROM (
+ SELECT a, b FROM t7v WHERE a=11 OR b=12
+ UNION ALL
+ SELECT c, d FROM t8v WHERE c=5 OR d=6
+ )
+ ORDER BY 1, 2;
+} {5 5 6 6 11 11 12 12}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 21.1 {
+ CREATE TABLE t9(a,b,c);
+ CREATE VIRTUAL TABLE t9v USING echo(t9);
+
+ INSERT INTO t9 VALUES(1,2,3);
+ INSERT INTO t9 VALUES(3,2,1);
+ INSERT INTO t9 VALUES(2,2,2);
+}
+
+do_execsql_test 21.2 {
+ SELECT * FROM t9v WHERE a<b;
+} {1 2 3}
+
+do_execsql_test 21.3 {
+ SELECT * FROM t9v WHERE a=b;
+} {2 2 2}
+
+#-------------------------------------------------------------------------
+# At one point executing a CREATE VIRTUAL TABLE statement that specified
+# a database name but no virtual table arguments was causing an internal
+# buffer overread. Valgrind would report errors while running the following
+# tests. Specifically:
+#
+# CREATE VIRTUAL TABLE t1 USING fts4; -- Ok - no db name.
+# CREATE VIRTUAL TABLE main.t1 USING fts4(x); -- Ok - has vtab arguments.
+# CREATE VIRTUAL TABLE main.t1 USING fts4; -- Had the problem.
+#
+ifcapable fts3 {
+ forcedelete test.db2
+ set nm [string repeat abcdefghij 100]
+ do_execsql_test 22.1 {
+ ATTACH 'test.db2' AS $nm
+ }
+
+ execsql "SELECT * FROM sqlite_master"
+ do_execsql_test 22.2 "CREATE VIRTUAL TABLE ${nm}.t1 USING fts4"
+
+ do_test 22.3.1 {
+ set sql "CREATE VIRTUAL TABLE ${nm}.t2 USING fts4"
+ set stmt [sqlite3_prepare_v2 db $sql -1 dummy]
+ sqlite3_step $stmt
+ } {SQLITE_DONE}
+
+ do_test 22.3.2 {
+ sqlite3_finalize $stmt
+ } {SQLITE_OK}
+
+ do_test 22.4.1 {
+ set sql "CREATE VIRTUAL TABLE ${nm}.t3 USING fts4"
+ set n [string length $sql]
+ set stmt [sqlite3_prepare db "${sql}xyz" $n dummy]
+ sqlite3_step $stmt
+ } {SQLITE_DONE}
+
+ do_test 22.4.2 {
+ sqlite3_finalize $stmt
+ } {SQLITE_OK}
+}
+
+
+#-------------------------------------------------------------------------
+# The following tests verify that a DROP TABLE command on a virtual
+# table does not cause other operations to crash.
+#
+# 23.1: Dropping a vtab while a SELECT is running on it.
+#
+# 23.2: Dropping a vtab while a SELECT that will, but has not yet,
+# open a cursor on the vtab, is running. In this case the
+# DROP TABLE succeeds and the SELECT hits an error.
+#
+# 23.3: Dropping a vtab from within a user-defined-function callback
+# in the middle of an "INSERT INTO vtab SELECT ..." statement.
+#
+reset_db
+load_static_extension db wholenumber
+load_static_extension db eval
+register_echo_module db
+
+do_test 23.1 {
+ execsql { CREATE VIRTUAL TABLE t1 USING wholenumber }
+ set res ""
+ db eval { SELECT value FROM t1 WHERE value<10 } {
+ if {$value == 5} {
+ set res [catchsql { DROP TABLE t1 }]
+ }
+ }
+ set res
+} {1 {database table is locked}}
+
+do_test 23.2 {
+ execsql {
+ CREATE TABLE t2(value);
+ INSERT INTO t2 VALUES(1), (2), (3);
+ }
+
+ set res2 [list [catch {
+ db eval {
+ SELECT value FROM t2 UNION ALL
+ SELECT value FROM t1 WHERE value<10
+ } {
+ if {$value == 2} { set res1 [catchsql { DROP TABLE t1 }] }
+ }
+ } msg] $msg]
+ list $res1 $res2
+} {{0 {}} {1 {database table is locked}}}
+
+do_test 23.3.1 {
+ execsql { CREATE VIRTUAL TABLE t1e USING echo(t2) }
+ execsql { INSERT INTO t1e SELECT 4 }
+ catchsql { INSERT INTO t1e SELECT eval('DROP TABLE t1e') }
+} {1 {database table is locked}}
+do_execsql_test 23.3.2 { SELECT * FROM t1e } {1 2 3 4}
+
+#-------------------------------------------------------------------------
+# At one point SQL like this:
+#
+# SAVEPOINT xyz; -- Opens SQL transaction
+# INSERT INTO vtab -- Write to virtual table
+# ROLLBACK TO xyz;
+# RELEASE xyz;
+#
+# was not invoking the xRollbackTo() callback for the ROLLBACK TO
+# operation. Which meant that virtual tables like FTS3 would incorrectly
+# commit the results of the INSERT as part of the "RELEASE xyz" command.
+#
+# The following tests check that this has been fixed.
+#
+ifcapable fts3 {
+ do_execsql_test 24.0 {
+ CREATE VIRTUAL TABLE t4 USING fts3();
+ SAVEPOINT a;
+ INSERT INTO t4 VALUES('a b c');
+ ROLLBACK TO a;
+ RELEASE a;
+ SELECT * FROM t4;
+ } {}
+
+ do_execsql_test 24.1 { SELECT * FROM t4 WHERE t4 MATCH 'b' } {}
+ do_execsql_test 24.2 { INSERT INTO t4(t4) VALUES('integrity-check') } {}
+
+ do_execsql_test 24.3 {
+ SAVEPOINT a;
+ CREATE VIRTUAL TABLE t5 USING fts3();
+ SAVEPOINT b;
+ ROLLBACK TO a;
+ SAVEPOINT c;
+ RELEASE a;
+ }
+}
+
+# 2021-07-04 https://sqlite.org/forum/forumpost/16ca0e9f32
+# Yu Liang crash involving UPDATE on a virtual table with
+# a duplicate column in a vector changeset and invoking the
+# query flattener for UNION ALL.
+#
+reset_db
+register_echo_module db
+do_catchsql_test 25.0 {
+ CREATE TABLE t0(a);
+ CREATE VIRTUAL TABLE t1 USING echo(t0);
+ WITH t3(a) AS (SELECT * FROM t1 UNION ALL SELECT * FROM t1)
+ UPDATE t1 SET (a,a) = (SELECT 1, 0) FROM t3;
+} {0 {}}
+
+#--------------------------------------------------------------------------
+#
+reset_db
+load_static_extension db wholenumber
+do_execsql_test 26.1 {
+ CREATE VIRTUAL TABLE t1 USING wholenumber;
+ CREATE TABLE tx(a, b, c);
+}
+do_test 26.2 {
+ sqlite3 db2 test.db
+ db2 eval { CREATE TABLE ty(x, y) }
+ db2 close
+} {}
+do_execsql_test 26.3 {
+ SELECT value FROM t1 WHERE value<5
+} {1 2 3 4}
+
+
+finish_test
diff --git a/test/vtab2.test b/test/vtab2.test
new file mode 100644
index 0000000..7bd27a5
--- /dev/null
+++ b/test/vtab2.test
@@ -0,0 +1,163 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vtab2
+
+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 name, arrayname, value 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 name, arrayname, value 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-3.3 {
+ execsql {
+ SELECT *, b.rowid
+ FROM schema a LEFT JOIN schema b ON a.dflt_value IS b.dflt_value
+ AND a.dflt_value IS NOT NULL
+ 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}
+
+#-------------------------------------------------------------------------
+#
+ifcapable fts3 {
+ reset_db
+ do_execsql_test 5.1 {
+ PRAGMA encoding='UTF16';
+ }
+
+ do_test 5.2 {
+ sqlite3_exec_hex db { CREATE VIRTUAL TABLE %C8 USING fts3 }
+ } {0 {}}
+
+ do_test 5.3 {
+ sqlite3_exec_hex db { CREATE VIRTUAL TABLE %C9 USING s }
+ } {/1 {malformed database schema.* already exists}/}
+}
+
+
+
+finish_test
diff --git a/test/vtab3.test b/test/vtab3.test
new file mode 100644
index 0000000..e8c6982
--- /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 args} {
+ 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..d12ca33
--- /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, a, b, c FROM 'treal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, a, b, c 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, NULL, NULL, NULL FROM 'treal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, NULL, NULL, NULL 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, a, b, c FROM 'treal'} \
+ xBegin echo(sreal) \
+ xFilter {SELECT rowid, a, b, c FROM 'treal'} \
+ xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'treal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, NULL, NULL, NULL 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, a, b, c FROM 'sreal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, a, b, c FROM 'sreal'} \
+ xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \
+ xBegin echo(sreal) \
+ xFilter {SELECT rowid, NULL, NULL, NULL 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, a, b, c FROM 'sreal'} \
+ xBegin echo(treal) \
+ xFilter {SELECT rowid, a, b, c FROM 'sreal'} \
+ xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \
+ xBegin echo(sreal) \
+ xFilter {SELECT rowid, NULL, NULL, NULL 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..1c220e1
--- /dev/null
+++ b/test/vtab6.test
@@ -0,0 +1,583 @@
+# 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.4.1 {
+ execsql {
+ SELECT * FROM t1 LEFT JOIN t2 ON t1.a IS 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 {near "USING": syntax error}}
+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}}
+
+# EVIDENCE-OF: R-47973-48020 you cannot say "INNER OUTER JOIN", because
+# that would be contradictory.
+do_test vtab6-3.7 {
+ catchsql {
+ SELECT * FROM t1 INNER OUTER JOIN t2;
+ }
+} {1 {unknown join type: INNER OUTER}}
+
+do_test vtab6-3.7 {
+ catchsql {
+ SELECT * FROM t1 LEFT BOGUS JOIN t2;
+ }
+} {1 {unknown 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 {
+ sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 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 {ab.xBestIndex malfunction}}
+do_test vtab6-11.4.2 {
+ catchsql {
+ SELECT a, b, c FROM bc NATURAL JOIN ab;
+ }
+} {1 {bc.xBestIndex malfunction}}
+
+unset ::echo_module_ignore_usable
+
+finish_test
diff --git a/test/vtab7.test b/test/vtab7.test
new file mode 100644
index 0000000..8320993
--- /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 {bad parameter or other API misuse}}
+
+# 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..4c9beae
--- /dev/null
+++ b/test/vtabA.test
@@ -0,0 +1,164 @@
+# 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}}
+do_execsql_test vtabA-1.7 {
+ DELETE FROM t1e;
+ INSERT INTO t1e SELECT 'abc','def';
+} {}
+do_execsql_test vtabA-1.8 {
+ INSERT INTO t1e VALUES('ghi','jkl'),('mno','pqr'),('stu','vwx');
+} {}
+do_execsql_test vtabA-1.9 {
+ SELECT a,b,c, '|' FROM t1e ORDER BY 1;
+} {abc {} def | ghi {} jkl | mno {} pqr | stu {} vwx |}
+
+
+# Test that the expansion of a '*' expression in the result set of
+# a SELECT does not include the hidden column.
+#
+do_test vtabA-1.20 {
+ execsql {
+ INSERT INTO t1e SELECT * FROM t1e;
+ }
+} {}
+do_test vtabA-1.21 {
+ execsql {
+ SELECT * FROM t1e ORDER BY 1;
+ }
+} {abc def abc def ghi jkl ghi jkl mno pqr mno pqr stu vwx stu vwx}
+
+# Test that the declaration type of the hidden column does not include
+# the token "HIDDEN".
+#
+do_test vtabA-1.22 {
+ get_decltype t1e b
+} {VARCHAR}
+do_test vtabA-1.23 {
+ 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..589f518
--- /dev/null
+++ b/test/vtabD.test
@@ -0,0 +1,69 @@
+# 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;
+ 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;
+ 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..cbb6a1e
--- /dev/null
+++ b/test/vtabE.test
@@ -0,0 +1,52 @@
+# 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.name, t1.arrayname, t1.value,
+ t2.name, t2.arrayname, t2.value,
+ 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 {}}
+
+finish_test
diff --git a/test/vtabF.test b/test/vtabF.test
new file mode 100644
index 0000000..7b11cb8
--- /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 vtabF-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 vtabF-1.2 {
+ execsql {SELECT b FROM tv1 WHERE a IS NOT NULL}
+} {110 111 112 113}
+
+
+finish_test
diff --git a/test/vtabH.test b/test/vtabH.test
new file mode 100644
index 0000000..f1a0466
--- /dev/null
+++ b/test/vtabH.test
@@ -0,0 +1,261 @@
+# 2015 Nov 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. Specifically,
+# it tests that the GLOB, LIKE and REGEXP operators are correctly exposed
+# to virtual table implementations.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vtabH
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_echo_module db
+
+do_execsql_test 1.0 {
+ CREATE TABLE t6(a, b TEXT);
+ CREATE INDEX i6 ON t6(b, a);
+ CREATE VIRTUAL TABLE e6 USING echo(t6);
+}
+
+ifcapable !icu {
+ foreach {tn sql expect} {
+ 1 "SELECT * FROM e6 WHERE b LIKE '8abc'" {
+ xBestIndex
+ {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ? AND b like ?}
+ xFilter
+ {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ? AND b like ?}
+ 8ABC 8abd 8abc
+ }
+
+ 2 "SELECT * FROM e6 WHERE b GLOB '8abc'" {
+ xBestIndex
+ {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ? AND b glob ?}
+ xFilter
+ {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ? AND b glob ?}
+ 8abc 8abd 8abc
+ }
+ 3 "SELECT * FROM e6 WHERE b LIKE '8e/'" {
+ xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b like ?}
+ xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} 8e/
+ }
+ 4 "SELECT * FROM e6 WHERE b GLOB '8e/'" {
+ xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b glob ?}
+ xFilter {SELECT rowid, a, b FROM 't6' WHERE b glob ?} 8e/
+ }
+ } {
+ do_test 1.$tn {
+ set echo_module {}
+ execsql $sql
+ set ::echo_module
+ } [list {*}$expect]
+ }
+}
+
+
+#--------------------------------------------------------------------------
+
+register_tclvar_module db
+set ::xyz 10
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE vars USING tclvar;
+ SELECT name, arrayname, value FROM vars WHERE name = 'xyz';
+} {xyz {} 10}
+
+set x1 aback
+set x2 abaft
+set x3 abandon
+set x4 abandonint
+set x5 babble
+set x6 baboon
+set x7 backbone
+set x8 backarrow
+set x9 castle
+
+db func glob -argcount 2 gfunc
+proc gfunc {a b} {
+ incr ::gfunc
+ return 1
+}
+
+db func like -argcount 2 lfunc
+proc lfunc {a b} {
+ incr ::gfunc 100
+ return 1
+}
+
+db func regexp -argcount 2 rfunc
+proc rfunc {a b} {
+ incr ::gfunc 10000
+ return 1
+}
+
+foreach ::tclvar_set_omit {0 1} {
+ foreach {tn expr res cnt} {
+ 1 {value GLOB 'aban*'} {x3 abandon x4 abandonint} 2
+ 2 {value LIKE '%ac%'} {x1 aback x7 backbone x8 backarrow} 300
+ 3 {value REGEXP '^......$'} {x5 babble x6 baboon x9 castle} 30000
+ } {
+ db cache flush
+ set ::gfunc 0
+ if {$::tclvar_set_omit} {set cnt 0}
+
+ do_test 2.$tclvar_set_omit.$tn.1 {
+ execsql "SELECT name, value FROM vars WHERE name MATCH 'x*' AND $expr"
+ } $res
+
+ do_test 2.$tclvar_set_omit.$tn.2 {
+ set ::gfunc
+ } $cnt
+ }
+}
+
+#-------------------------------------------------------------------------
+#
+if {$tcl_platform(platform)=="windows"} {
+ set drive [string range [pwd] 0 1]
+ set ::env(fstreeDrive) $drive
+}
+if {$tcl_platform(platform)!="windows" || \
+ [regexp -nocase -- {^[A-Z]:} $drive]} {
+ reset_db
+ register_fs_module db
+ do_execsql_test 3.0 {
+ SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db';
+ SELECT name FROM fsdir WHERE dir = '.' AND name = '.'
+ } {test.db .}
+
+ proc sort_files { names {nocase false} } {
+ if {$nocase && $::tcl_platform(platform) eq "windows"} {
+ return [lsort -nocase $names]
+ } else {
+ return [lsort $names]
+ }
+ }
+
+ proc list_root_files {} {
+ if {$::tcl_platform(platform) eq "windows"} {
+ set res [list]; set dir $::env(fstreeDrive)/; set names [list]
+ eval lappend names [glob -nocomplain -directory $dir -- *]
+ foreach name $names {
+ if {[string index [file tail $name] 0] eq "."} continue
+ if {[file attributes $name -hidden]} continue
+ if {[file attributes $name -system]} continue
+ lappend res $name
+ }
+ return [sort_files $res true]
+ } else {
+ return [sort_files [string map {/ {}} [glob -nocomplain -- /*]]]
+ }
+ }
+
+ proc list_files { pattern } {
+ if {$::tcl_platform(platform) eq "windows"} {
+ set res [list]; set names [list]
+ eval lappend names [glob -nocomplain -- $pattern]
+ foreach name $names {
+ if {[string index [file tail $name] 0] eq "."} continue
+ if {[file attributes $name -hidden]} continue
+ if {[file attributes $name -system]} continue
+ lappend res $name
+ }
+ return [sort_files $res]
+ } else {
+ return [sort_files [glob -nocomplain -- $pattern]]
+ }
+ }
+
+ # Read the first 5 entries from the root directory. Except, ignore
+ # files that contain the "$" character in their names as these are
+ # special files on some Windows platforms.
+ #
+ set res [list]
+ set root_files [list_root_files]
+ foreach p $root_files {
+ if {$::tcl_platform(platform) eq "windows"} {
+ if {![regexp {\$} $p]} {lappend res $p}
+ } else {
+ lappend res "/$p"
+ }
+ }
+ set num_root_files [llength $root_files]
+ do_test 3.1 {
+ sort_files [execsql {
+ SELECT path FROM fstree WHERE path NOT GLOB '*\$*' LIMIT $num_root_files;
+ }] true
+ } [sort_files $res true]
+
+ # Read all entries in the current directory.
+ #
+ proc contents {pattern} {
+ set res [list]
+ foreach f [list_files $pattern] {
+ lappend res $f
+ if {[file isdir $f]} {
+ set res [concat $res [contents "$f/*"]]
+ }
+ }
+ set res
+ }
+ set pwd "[pwd]/*"
+ set res [contents $pwd]
+ do_execsql_test 3.2 {
+ SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1
+ } [sort_files $res]
+
+ # Add some sub-directories and files to the current directory.
+ #
+ do_test 3.3 {
+ catch { file delete -force subdir }
+ foreach {path sz} {
+ subdir/x1.txt 143
+ subdir/x2.txt 153
+ } {
+ set dir [file dirname $path]
+ catch { file mkdir $dir }
+ set fd [open $path w]
+ puts -nonewline $fd [string repeat 1 $sz]
+ close $fd
+ }
+ } {}
+
+ set pwd [pwd]
+ if {![string match {*[_%]*} $pwd]} {
+ do_execsql_test 3.5 {
+ SELECT path, size FROM fstree
+ WHERE path GLOB $pwd || '/subdir/*' ORDER BY 1
+ } [list \
+ "$pwd/subdir/x1.txt" 143 \
+ "$pwd/subdir/x2.txt" 153 \
+ ]
+ do_execsql_test 3.6 {
+ SELECT path, size FROM fstree
+ WHERE path LIKE $pwd || '/subdir/%' ORDER BY 1
+ } [list \
+ "$pwd/subdir/x1.txt" 143 \
+ "$pwd/subdir/x2.txt" 153 \
+ ]
+ do_execsql_test 3.7 {
+ SELECT sum(size) FROM fstree WHERE path LIKE $pwd || '/subdir/%'
+ } 296
+ do_execsql_test 3.8 {
+ SELECT size FROM fstree WHERE path = $pwd || '/subdir/x1.txt'
+ } 143
+ }
+
+}
+
+
+finish_test
diff --git a/test/vtabI.test b/test/vtabI.test
new file mode 100644
index 0000000..4b5a0a8
--- /dev/null
+++ b/test/vtabI.test
@@ -0,0 +1,126 @@
+# 2015 Nov 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 the sqlite3_index_info.colUsed variable is set correctly.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vtabI
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_echo_module db
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c, d, e);
+ CREATE VIRTUAL TABLE e1 USING echo(t1);
+}
+
+foreach {tn query filter} {
+ 1 {SELECT * FROM e1}
+ {SELECT rowid, a, b, c, d, e FROM 't1'}
+
+ 2 {SELECT a, b FROM e1}
+ {SELECT rowid, a, b, NULL, NULL, NULL FROM 't1'}
+
+ 3 {SELECT count(*) FROM e1 GROUP BY b}
+ {SELECT rowid, NULL, b, NULL, NULL, NULL FROM 't1'}
+
+ 4 {SELECT count(*) FROM e1 GROUP BY b HAVING a=?}
+ {SELECT rowid, a, b, NULL, NULL, NULL FROM 't1'}
+
+ 5 {SELECT a FROM e1 WHERE c=?}
+ {SELECT rowid, a, NULL, c, NULL, NULL FROM 't1'}
+
+ 6 {SELECT a FROM e1 ORDER BY e}
+ {SELECT rowid, a, NULL, NULL, NULL, e FROM 't1'}
+
+ 7 {SELECT a FROM e1 ORDER BY e, d}
+ {SELECT rowid, a, NULL, NULL, d, e FROM 't1'}
+} {
+ do_test 1.$tn {
+ set ::echo_module [list]
+ execsql $query
+ set idx [lsearch -exact $::echo_module xFilter]
+ lindex $::echo_module [expr $idx+1]
+ } $filter
+}
+
+#-------------------------------------------------------------------------
+# Tests with a table with more than 64 columns.
+#
+proc all_col_list {} {
+ set L [list]
+ for {set i 1} {$i <= 100} {incr i} { lappend L "c$i" }
+ set L
+}
+
+proc part_col_list {cols} {
+ set L [list]
+ for {set i 1} {$i <= 100} {incr i} {
+ set c "c$i"
+ if {[lsearch $cols $c]>=0} {
+ lappend L "c$i"
+ } else {
+ lappend L NULL
+ }
+ }
+ set L
+}
+proc CL {args} {
+ join [part_col_list $args] ", "
+}
+proc CLT {args} {
+ set cols $args
+ for {set i 64} {$i <= 100} {incr i} {
+ lappend cols "c$i"
+ }
+ join [part_col_list $cols] ", "
+}
+
+do_test 2.0 {
+ execsql "CREATE TABLE t2([join [all_col_list] ,])"
+ execsql "CREATE VIRTUAL TABLE e2 USING echo(t2)"
+} {}
+
+foreach {tn query filter} {
+ 1 {SELECT c1, c10, c20 FROM e2}
+ {SELECT rowid, [CL c1 c10 c20] FROM 't2'}
+
+ 2 {SELECT c40, c50, c60 FROM e2}
+ {SELECT rowid, [CL c40 c50 c60] FROM 't2'}
+
+ 3 {SELECT c7, c80, c90 FROM e2}
+ {SELECT rowid, [CLT c7] FROM 't2'}
+
+ 4 {SELECT c64 FROM e2}
+ {SELECT rowid, [CLT c64] FROM 't2'}
+
+ 5 {SELECT c63 FROM e2}
+ {SELECT rowid, [CL c63] FROM 't2'}
+
+ 6 {SELECT c22 FROM e2 ORDER BY c50, c70}
+ {SELECT rowid, [CLT c22 c50] FROM 't2'}
+
+} {
+ do_test 2.$tn {
+ set ::echo_module [list]
+ execsql $query
+ set idx [lsearch -exact $::echo_module xFilter]
+ lindex $::echo_module [expr $idx+1]
+ } [subst $filter]
+}
+
+finish_test
diff --git a/test/vtabJ.test b/test/vtabJ.test
new file mode 100644
index 0000000..123009f
--- /dev/null
+++ b/test/vtabJ.test
@@ -0,0 +1,154 @@
+# 2017-08-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 tests of writing to WITHOUT ROWID virtual tables
+# using the tclvar eponymous virtual table.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vtabJ
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+register_tclvar_module db
+
+unset -nocomplain vtabJ
+do_test 100 {
+ set vtabJ(1) this
+ set vtabJ(two) is
+ set vtabJ(3) {a test}
+ db eval {
+ SELECT fullname, value FROM tclvar WHERE name='vtabJ' ORDER BY fullname;
+ }
+} {vtabJ(1) this vtabJ(3) {a test} vtabJ(two) is}
+
+do_execsql_test 110 {
+ INSERT INTO tclvar(fullname, value)
+ VALUES('vtabJ(4)',4),('vtabJ(five)',555);
+ SELECT fullname, value FROM tclvar WHERE name='vtabJ' ORDER BY fullname;
+} {vtabJ(1) this vtabJ(3) {a test} vtabJ(4) 4 vtabJ(five) 555 vtabJ(two) is}
+do_test 111 {
+ set res {}
+ foreach vname [lsort [array names vtabJ]] {
+ lappend res vtabJ($vname) $vtabJ($vname)
+ }
+ set res
+} {vtabJ(1) this vtabJ(3) {a test} vtabJ(4) 4 vtabJ(five) 555 vtabJ(two) is}
+
+do_test 120 {
+ db eval {
+ INSERT INTO tclvar(fullname, value) VALUES('vtabJ(4)',444);
+ }
+ set vtabJ(4)
+} {444}
+
+do_test 130 {
+ db eval {
+ INSERT INTO tclvar(fullname, value) VALUES('vtabJ(4)',NULL);
+ }
+ info exists vtabJ(4)
+} {0}
+
+do_test 140 {
+ db eval {
+ UPDATE tclvar SET value=55 WHERE fullname='vtabJ(five)';
+ }
+ set vtabJ(five)
+} {55}
+
+do_test 150 {
+ db eval {
+ UPDATE tclvar SET fullname='vtabJ(5)' WHERE fullname='vtabJ(five)';
+ }
+ set vtabJ(5)
+} {55}
+do_test 151 {
+ info exists vtabJ(five)
+} {0}
+do_test 152 {
+ set res {}
+ foreach vname [lsort [array names vtabJ]] {
+ lappend res vtabJ($vname) $vtabJ($vname)
+ }
+ set res
+} {vtabJ(1) this vtabJ(3) {a test} vtabJ(5) 55 vtabJ(two) is}
+
+do_execsql_test 160 {
+ SELECT fullname FROM tclvar WHERE arrayname='two'
+} {vtabJ(two)}
+do_execsql_test 161 {
+ DELETE FROM tclvar WHERE arrayname='two';
+ SELECT fullname, value FROM tclvar WHERE name='vtabJ' ORDER BY fullname;
+} {vtabJ(1) this vtabJ(3) {a test} vtabJ(5) 55}
+do_test 162 {
+ set res {}
+ foreach vname [lsort [array names vtabJ]] {
+ lappend res vtabJ($vname) $vtabJ($vname)
+ }
+ set res
+} {vtabJ(1) this vtabJ(3) {a test} vtabJ(5) 55}
+
+# Try to trick the module into updating the same variable twice for a
+# single UPDATE statement.
+#
+do_execsql_test 171 {
+ INSERT INTO tclvar(fullname, value) VALUES('xx', 'a');
+ SELECT name, value FROM tclvar where name = 'xx';
+} {xx a}
+do_execsql_test 172 {
+ UPDATE tclvar SET value = value || 't'
+ WHERE name = 'xx' OR name = 'x'||'x';
+ SELECT name, value FROM tclvar where name = 'xx';
+} {xx at}
+do_execsql_test 173 {
+ UPDATE tclvar SET value = value || 't'
+ WHERE name = 'xx' OR name BETWEEN 'xx' AND 'xx';
+ SELECT name, value FROM tclvar where name = 'xx';
+} {xx att}
+
+do_execsql_test 181 {
+ DELETE FROM tclvar WHERE name BETWEEN 'xx' AND 'xx' OR name='xx';
+ SELECT name, value FROM tclvar where name = 'xx';
+} {}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 200 {
+ CREATE TABLE var(k TEXT, v TEXT);
+ INSERT INTO var VALUES('testvar1', 10);
+ INSERT INTO var VALUES('testvar2', 20);
+ INSERT INTO var VALUES('testvar3', 30);
+}
+
+do_test 210 {
+ foreach {testvar1 testvar2 testvar3} {1 2 3} {}
+ execsql {
+ UPDATE tclvar SET value = var.v FROM var WHERE name = var.k;
+ }
+ list $testvar1 $testvar2 $testvar3
+} {10 20 30}
+
+do_test 220 {
+ execsql {
+ CREATE TABLE nam(k TEXT, v TEXT);
+ INSERT INTO nam VALUES('testvar1', 'tv1');
+ INSERT INTO nam VALUES('testvar2', 'tv2');
+ INSERT INTO nam VALUES('testvar3', 'tv3');
+ UPDATE tclvar SET fullname = nam.v FROM nam WHERE name = nam.k;
+ }
+ list $tv1 $tv2 $tv3
+} {10 20 30}
+
+
+finish_test
diff --git a/test/vtabK.test b/test/vtabK.test
new file mode 100644
index 0000000..07fe9c1
--- /dev/null
+++ b/test/vtabK.test
@@ -0,0 +1,83 @@
+# 2020-09-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 for a strange scenario discovered by
+# dbsqlfuzz (0ad6d441f9bf3dfc32626a9900bc1700495b16f9) in which a
+# virtual table is named "sqlite_stat1".
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vtabK
+
+ifcapable !vtab||!rtree||!fts5 {
+ finish_test
+ return
+}
+
+do_execsql_test 100 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(123);
+ PRAGMA writable_schema=ON;
+ CREATE VIRTUAL TABLE sqlite_stat1 USING fts5(a);
+ PRAGMA writable_schema=OFF;
+ CREATE VIRTUAL TABLE t3 USING fts5(b);
+ INSERT INTO t3 VALUES('this is a test');
+}
+do_catchsql_test 110 {
+ CREATE VIRTUAL TABLE t2 USING rtree(id,x,y);
+} {1 {no such column: stat}}
+do_execsql_test 120 {
+ SELECT * FROM t1;
+} {123}
+do_execsql_test 130 {
+ INSERT INTO t3(b) VALUES('Four score and seven years ago');
+ SELECT * FROM t3 WHERE t3 MATCH 'this';
+} {{this is a test}}
+do_execsql_test 140 {
+ SELECT * FROM t3 WHERE t3 MATCH 'four seven';
+} {{Four score and seven years ago}}
+do_execsql_test 150 {
+ INSERT INTO sqlite_stat1(a)
+ VALUES('We hold these truths to be self-evident...');
+ SELECT * FROM sqlite_stat1;
+} {{We hold these truths to be self-evident...}}
+do_catchsql_test 160 {
+ ANALYZE;
+} {1 {database disk image is malformed}}
+do_execsql_test 170 {
+ PRAGMA integrity_check;
+} {ok}
+
+# Follow-on dbsqlfuzz bc02a0cde82dee801a8d6f653d2831680f87dca1
+reset_db
+do_execsql_test 200 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES('Ebed-malech');
+ CREATE TABLE x(a);
+ PRAGMA writable_schema=ON;
+ CREATE VIRTUAL TABLE sqlite_stat1 USING fts5(a);
+} {}
+do_catchsql_test 210 {
+ CREATE VIRTUAL TABLE t2 USING rtree(id,x,y);
+} {1 {no such column: stat}}
+do_execsql_test 220 {
+ SELECT * FROM t1;
+} {Ebed-malech}
+
+# Follow-on dbsqlfuzz a097eaad43c3c845b236126df92fb49b25449b0c
+reset_db
+do_catchsql_test 300 {
+ CREATE VIRTUAL TABLE t1 USING rtree(a,b,c);
+ CREATE TABLE t2(x);
+ ALTER TABLE t2 ADD d GENERATED ALWAYS AS (c IN (SELECT 1 FROM t1)) VIRTUAL;
+} {1 {error in table t2 after add column: subqueries prohibited in generated columns}}
+
+finish_test
diff --git a/test/vtab_alter.test b/test/vtab_alter.test
new file mode 100644
index 0000000..64053d1
--- /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}}
+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..cfc5fc3
--- /dev/null
+++ b/test/vtab_err.test
@@ -0,0 +1,87 @@
+# 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;
+}
+
+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
+
+reset_db
+register_echo_module [sqlite3_connection_pointer db]
+do_execsql_test vtab_err-3.0 {
+ CREATE TABLE r(a PRIMARY KEY, b, c);
+ CREATE VIRTUAL TABLE e USING echo(r);
+}
+faultsim_save_and_close
+
+do_faultsim_test vtab_err-3 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+ register_echo_module [sqlite3_connection_pointer db]
+} -body {
+ execsql {
+ BEGIN;
+ CREATE TABLE xyz(x);
+ SELECT a FROM e;
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/vtab_shared.test b/test/vtab_shared.test
new file mode 100644
index 0000000..a9079ea
--- /dev/null
+++ b/test/vtab_shared.test
@@ -0,0 +1,278 @@
+# 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
+set testprefix vtab_shared
+
+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 {
+ 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}
+
+ifcapable compound {
+ 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
+
+#---------------------------------------------------------------
+# Test calling sqlite3_close() with vtabs on the disconnect list.
+#
+ifcapable rtree {
+ reset_db
+ do_test 2.1.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+
+ # Create a virtual table using [db].
+ execsql {
+ CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);
+ INSERT INTO rt VALUES(1, 2 ,3);
+ SELECT * FROM rt;
+ }
+
+ # Drop the virtual table using [db2]. The sqlite3_vtab object belonging
+ # to [db] is moved to the sqlite3.pDisconnect list.
+ execsql { DROP TABLE rt } db2
+
+ # Immediately close [db]. At one point this would fail due to the
+ # unfinalized statements held by the un-xDisconnect()ed sqlite3_vtab.
+ db close
+ } {}
+ db2 close
+}
+
+ifcapable fts3 {
+ # Same test as above, except using fts3 instead of rtree.
+ reset_db
+ do_test 2.2.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ execsql {
+ CREATE VIRTUAL TABLE ft USING fts3;
+ INSERT INTO ft VALUES('hello world');
+ SELECT * FROM ft;
+ }
+ execsql { DROP TABLE ft } db2
+ db close
+ } {}
+ db2 close
+}
+
+sqlite3_enable_shared_cache 0
+finish_test
diff --git a/test/vtabdistinct.test b/test/vtabdistinct.test
new file mode 100644
index 0000000..e18e121
--- /dev/null
+++ b/test/vtabdistinct.test
@@ -0,0 +1,41 @@
+# 2022-01-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 for sqlite3_vtab_distinct() interface.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vtabdistinct
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+load_static_extension db qpvtab
+
+do_execsql_test 1.1 {
+ SELECT ix FROM qpvtab WHERE vn='sqlite3_vtab_distinct';
+} {0}
+do_execsql_test 1.2 {
+ SELECT DISTINCT ix FROM qpvtab WHERE vn='sqlite3_vtab_distinct';
+} {2}
+do_execsql_test 1.3 {
+ SELECT distinct vn, ix FROM qpvtab(3)
+ WHERE +vn IN ('sqlite3_vtab_distinct','nOrderBy');
+} {nOrderBy 2 sqlite3_vtab_distinct 2}
+do_execsql_test 1.4 {
+ SELECT vn, ix FROM qpvtab
+ GROUP BY vn
+ HAVING vn='sqlite3_vtab_distinct';
+} {sqlite3_vtab_distinct 1}
+
+finish_test
diff --git a/test/vtabdrop.test b/test/vtabdrop.test
new file mode 100644
index 0000000..1f9309e
--- /dev/null
+++ b/test/vtabdrop.test
@@ -0,0 +1,127 @@
+# 2018 December 28
+#
+# May you 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 edge cases surrounding DROP TABLE on
+# virtual tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab { finish_test ; return }
+source $testdir/fts3_common.tcl
+source $testdir/malloc_common.tcl
+
+set testprefix vtabdrop
+
+#-------------------------------------------------------------------------
+# Test that if a DROP TABLE is executed against an rtree table, but the
+# xDestroy() call fails, the rtree table is not dropped, the sqlite_master
+# table is not modified and the internal schema remains intact.
+#
+ifcapable rtree {
+ do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+
+ do_test 1.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ db eval { SELECT * FROM t1 } {
+ catchsql { DROP TABLE rt }
+ }
+ execsql COMMIT
+ } {}
+
+ do_execsql_test 1.2 {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ SELECT * FROM t1;
+ SELECT * FROM rt;
+ } {rt rt_node rt_parent rt_rowid t1 1 2 3 4}
+
+ db close
+ sqlite3 db test.db
+
+ do_execsql_test 1.3 {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ } {rt rt_node rt_parent rt_rowid t1}
+}
+
+#-------------------------------------------------------------------------
+# Same as tests 1.*, except with fts5 instead of rtree.
+#
+ifcapable fts5 {
+ reset_db
+ do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE ft USING fts5(x);
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+
+ do_test 2.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ db eval { SELECT * FROM t1 } {
+ catchsql { DROP TABLE ft }
+ }
+ execsql COMMIT
+ } {}
+
+ do_execsql_test 2.2 {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ } {ft ft_config ft_content ft_data ft_docsize ft_idx t1}
+
+ db close
+ sqlite3 db test.db
+
+ do_execsql_test 2.3 {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ } {ft ft_config ft_content ft_data ft_docsize ft_idx t1}
+}
+
+#-------------------------------------------------------------------------
+# Same as tests 1.*, except with fts3 instead of rtree.
+#
+ifcapable fts3 {
+ reset_db
+ do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE ft USING fts3(x);
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+
+ do_test 2.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ db eval { SELECT * FROM t1 } {
+ catchsql { DROP TABLE ft }
+ }
+ execsql COMMIT
+ } {}
+
+ do_execsql_test 2.2 {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ } {ft ft_content ft_segdir ft_segments sqlite_autoindex_ft_segdir_1 t1}
+
+ db close
+ sqlite3 db test.db
+
+ do_execsql_test 2.3 {
+ SELECT name FROM sqlite_master ORDER BY 1;
+ } {ft ft_content ft_segdir ft_segments sqlite_autoindex_ft_segdir_1 t1}
+}
+
+finish_test
diff --git a/test/vtabrhs1.test b/test/vtabrhs1.test
new file mode 100644
index 0000000..0476a36
--- /dev/null
+++ b/test/vtabrhs1.test
@@ -0,0 +1,76 @@
+# 2022-01-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 for sqlite3_vtab_rhs_value() interface.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix vtabrhs1
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+load_static_extension db qpvtab
+
+# EVIDENCE-OF: R-60223-49197 When the sqlite3_vtab_rhs_value(P,J,V)
+# interface is invoked from within the xBestIndex method of a virtual
+# table implementation, with P being a copy of the sqlite3_index_info
+# object pointer passed into xBestIndex and J being a 0-based index into
+# P->aConstraint[], then this routine attempts to set *V to the value
+# of the right-hand operand of that constraint if the right-hand operand
+# is known.
+#
+do_execsql_test 1.1 {
+ SELECT rhs FROM qpvtab
+ WHERE cn='a'
+ AND a=12345
+} {12345}
+do_execsql_test 1.2 {
+ SELECT rhs FROM qpvtab
+ WHERE cn='a'
+ AND a<>4.5
+} {4.5}
+do_execsql_test 1.3 {
+ SELECT rhs FROM qpvtab
+ WHERE cn='a'
+ AND 'quokka' < a
+} {'quokka'}
+do_execsql_test 1.4 {
+ SELECT rhs FROM qpvtab
+ WHERE cn='a'
+ AND a IS NULL
+} {{}}
+do_execsql_test 1.5 {
+ SELECT rhs FROM qpvtab
+ WHERE cn='a'
+ AND a GLOB x'0123'
+} {x'0123'}
+
+# EVIDENCE-OF: R-37799-62852 If the right-hand operand is not known,
+# then *V is set to a NULL pointer.
+#
+do_execsql_test 2.1 {
+ SELECT typeof(rhs) FROM qpvtab WHERE cn='a' AND a=format('abc');
+} {null}
+do_execsql_test 2.2 {
+ SELECT typeof(rhs) FROM qpvtab WHERE cn='a' AND a=?2
+} {null}
+
+# EVIDENCE-OF: R-14553-25174 When xBestIndex returns, the sqlite3_value
+# object returned by sqlite3_vtab_rhs_value() is automatically
+# deallocated.
+#
+# Where this not the case, the following "finish_test" statement would
+# report a memory leak.
+#
+finish_test
diff --git a/test/wal.test b/test/wal.test
new file mode 100644
index 0000000..2346682
--- /dev/null
+++ b/test/wal.test
@@ -0,0 +1,1550 @@
+# 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 }
+test_set_config_pagecache 0 0
+
+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
+ db timeout 1000
+}
+
+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 {UNIQUE constraint failed: t3.x}}
+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 {
+ PRAGMA cache_size=2000;
+ 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 7 7}} ;# 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 8 7}}
+
+ # 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 8 8}}
+ do_test wal-10.$tn.17 {
+ execsql { PRAGMA wal_checkpoint }
+ } {0 8 8}
+ 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 9 9}
+ 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 9 9}
+ 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 3 0}}
+ do_test wal-10.$tn.30 {
+ code3 { sqlite3_finalize $::STMT }
+ execsql { PRAGMA wal_checkpoint }
+ } {0 3 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 8 8}}
+ 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 9 9}
+}
+
+#-------------------------------------------------------------------------
+# 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 40 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 40 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
+
+# After adding the capability of WAL to overwrite prior uncommitted
+# frame in the WAL-file with revised content, the size of the WAL file
+# following cache-spill is smaller.
+#
+#set nWal 39
+#if {[permutation]!="mmap"} {set nWal 37}
+#ifcapable !mmap {set nWal 37}
+set nWal 34
+
+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 $nWal 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 $nWal 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 $nWal 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
+
+#-------------------------------------------------------------------------
+# 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 13 13} 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 main.synchronous = NORMAL;
+ PRAGMA aux.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 13 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 13 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 cache_size = -2000;
+ 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
+
+ # Since the magic number at the start of the -wal file header is
+ # 931071618 that indicates that the content should always be read as
+ # little-endian.
+ #
+ 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.
+#
+if {[permutation]!="unix-excl"} {
+ 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.
+#
+incr ::do_not_use_codec
+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}
+ }]
+}
+incr ::do_not_use_codec -1
+
+#-------------------------------------------------------------------------
+# Test that when 1 or more pages are recovered from a WAL file,
+# sqlite3_log() is invoked to report this to the user.
+#
+ifcapable curdir {
+ set walfile [file nativename [file join [get_pwd] test.db-wal]]
+} else {
+ set walfile 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}
+do_test wal-23.4 {
+ set ::log
+} [list SQLITE_NOTICE_RECOVER_WAL \
+ "recovered 2 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]
+
+ # WAL file now contains a single frame - the new root page for table t1.
+ # It would be two frames (the new root page and a padding frame) if the
+ # ZERO_DAMAGE flag were not set.
+ do_test 24.5 {
+ file size test.db-wal
+ } [wal_file_size 1 1024]
+}
+
+db close
+sqlite3_shutdown
+test_sqlite3_log
+sqlite3_initialize
+
+# Make sure PRAGMA journal_mode=WAL works with ATTACHED databases in
+# all journal modes.
+#
+foreach mode {OFF MEMORY PERSIST DELETE TRUNCATE WAL} {
+ delete_file test.db test2.db
+ sqlite3 db test.db
+ do_test wal-25.$mode {
+ db eval "PRAGMA journal_mode=$mode"
+ db eval {ATTACH 'test2.db' AS t2; PRAGMA journal_mode=WAL;}
+ } {wal}
+ db close
+}
+
+# 2021-03-10 forum post https://sqlite.org/forum/forumpost/a006d86f72
+#
+file delete test.db
+sqlite3 db test.db
+db eval {PRAGMA journal_mode=WAL}
+for {set i 0} {$i<$SQLITE_MAX_ATTACHED} {incr i} {
+ do_test wal-26.1.$i {
+ file delete attached-$i.db
+ db eval "ATTACH 'attached-$i.db' AS a$i;"
+ db eval "PRAGMA a$i.journal_mode=WAL;"
+ db eval "CREATE TABLE a$i.t$i (x);"
+ db eval "INSERT INTO t$i VALUES(zeroblob(10000));"
+ db eval "DELETE FROM t$i;"
+ db eval "INSERT INTO t$i VALUES(randomblob(10000));"
+ expr {[file size attached-$i.db-wal]>10000}
+ } {1}
+}
+for {set i [expr {$SQLITE_MAX_ATTACHED-1}]} {$i>=0} {incr i -1} {
+ do_test wal-26.2.$i {
+ db eval "PRAGMA a$i.wal_checkpoint(TRUNCATE);"
+ file size attached-$i.db-wal
+ } {0}
+ for {set j 0} {$j<$i} {incr j} {
+ do_test wal-26.2.$i.$j {
+ expr {[file size attached-$j.db-wal]>10000}
+ } {1}
+ }
+}
+db close
+
+
+test_restore_config_pagecache
+finish_test
diff --git a/test/wal2.test b/test/wal2.test
new file mode 100644
index 0000000..ae6134d
--- /dev/null
+++ b/test/wal2.test
@@ -0,0 +1,1353 @@
+# 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 {$::tcl_platform(byteOrder)=="bigEndian"} {set fmt I} {set fmt i}
+
+ 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 ${fmt}${nInt}${fmt}${nInt}a* $ia $ib $tail]
+ tvfs shm $file $blob
+ }
+
+ binary scan $blob ${fmt}${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 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 2 lock exclusive} \
+ {4 1 lock exclusive} {4 1 unlock exclusive} \
+ {5 1 lock exclusive} {5 1 unlock exclusive} \
+ {6 1 lock exclusive} {6 1 unlock exclusive} \
+ {7 1 lock exclusive} {7 1 unlock exclusive} \
+ {1 2 unlock exclusive} {0 1 unlock exclusive} \
+]
+set READ [list \
+ {4 1 lock shared} {4 1 unlock shared} \
+]
+set INITSLOT [list \
+ {4 1 lock exclusive} {4 1 unlock exclusive} \
+]
+
+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 {$INITSLOT $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;
+ }
+ # Three pages in the WAL file at this point: One copy of page 1 and two
+ # of the root page for table "data".
+} {wal 0 3 3}
+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 1 lock exclusive} ;# Lock recovery
+# lappend expected_locks {4 4 lock exclusive} ;# Lock all aReadMark[]
+lappend expected_locks {4 1 lock exclusive} ;# Lock aReadMark[1]
+lappend expected_locks {4 1 unlock exclusive} ;# Unlock aReadMark[1]
+lappend expected_locks {5 1 lock exclusive}
+lappend expected_locks {5 1 unlock exclusive}
+lappend expected_locks {6 1 lock exclusive}
+lappend expected_locks {6 1 unlock exclusive}
+lappend expected_locks {7 1 lock exclusive}
+lappend expected_locks {7 1 unlock exclusive}
+lappend expected_locks {2 1 unlock exclusive} ;# Unlock recovery
+# lappend expected_locks {4 4 unlock exclusive} ;# Unlock all 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');
+ }
+} {}
+if {[atomic_batch_write test.db]==0} {
+ do_test wal2-6.3.4.1 {
+ 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 }
+} {}
+if {[atomic_batch_write test.db]==0} {
+ do_test wal2-6.3.6.1 {
+ 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 2 lock exclusive}
+ {4 1 lock exclusive} {4 1 unlock exclusive}
+ {5 1 lock exclusive} {5 1 unlock exclusive}
+ {6 1 lock exclusive} {6 1 unlock exclusive}
+ {7 1 lock exclusive} {7 1 unlock exclusive}
+ {1 2 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 2 2 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 2 2}
+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
+ # The first 32 bytes of the WAL file contain the WAL header. Offset 48
+ # is the first byte of the checksum for the first frame in the WAL.
+ # The following three lines replaces the contents of that byte with
+ # a different value.
+ set newval FF
+ if {$newval == [hexio_read test2.db-wal 48 1]} { set newval 00 }
+ hexio_write test2.db-wal 48 $newval
+} {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
+ # Changed on 2012-02-13: umask is deliberately ignored for -wal files.
+ #set umask [exec /bin/sh -c umask]
+ set umask 0
+
+
+ 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
+ string map {o 0} [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 {
+ set x [list [file attr test.db-wal -perm] [file attr test.db-shm -perm]]
+ string map {o 0} $x
+ } [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 1 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]
+ string map {o 0} $L
+ } [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 { } {10 0 4 0 6 0}
+ 2 { PRAGMA checkpoint_fullfsync = 1 } {10 6 4 3 6 3}
+ 3 { PRAGMA checkpoint_fullfsync = 0 } {10 0 4 0 6 0}
+} {
+ ifcapable default_ckptfullfsync {
+ if {[string trim $sql]==""} continue
+ }
+ faultsim_delete_and_reopen
+
+ execsql {PRAGMA auto_vacuum = 0; PRAGMA synchronous = FULL;}
+ execsql $sql
+ do_execsql_test wal2-14.$tn.0 { PRAGMA page_size = 4096 } {}
+ 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); -- 2 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; -- 2 wal sync
+ PRAGMA wal_checkpoint; -- 1 wal sync, 1 db sync
+ } {10 0 3 3 0 1 1}
+
+ 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 restart_sync commit_sync ckpt_sync} {
+ 1 {0 0 off} {0 0} {0 0} {0 0}
+ 2 {0 0 normal} {1 0} {0 0} {2 0}
+ 3 {0 0 full} {2 0} {1 0} {2 0}
+
+ 4 {0 1 off} {0 0} {0 0} {0 0}
+ 5 {0 1 normal} {0 1} {0 0} {0 2}
+ 6 {0 1 full} {0 2} {0 1} {0 2}
+
+ 7 {1 0 off} {0 0} {0 0} {0 0}
+ 8 {1 0 normal} {0 1} {0 0} {0 2}
+ 9 {1 0 full} {1 1} {1 0} {0 2}
+
+ 10 {1 1 off} {0 0} {0 0} {0 0}
+ 11 {1 1 normal} {0 1} {0 0} {0 2}
+ 12 {1 1 full} {0 2} {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 "
+ PRAGMA page_size = 4096;
+ CREATE TABLE t1(x);
+ PRAGMA wal_autocheckpoint = OFF;
+ PRAGMA journal_mode = WAL;
+ PRAGMA checkpoint_fullfsync = [lindex $settings 0];
+ PRAGMA fullfsync = [lindex $settings 1];
+ PRAGMA synchronous = [lindex $settings 2];
+ " {0 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)
+ } $restart_sync
+
+ do_test 15.$tn.3 {
+ 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.4 {
+ 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.5 {
+ 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..cb28d0f
--- /dev/null
+++ b/test/wal3.test
@@ -0,0 +1,652 @@
+# 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.
+#
+# TESTRUNNER: slow
+
+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;
+ }
+ set x [wal_frame_count test.db-wal 1024]
+ if {[permutation]=="memsubsys1"} {
+ if {$x==4251 || $x==4290} {set x 4056}
+ }
+ set x
+} 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 checkpoint_fullfsync = 0"
+ execsql { PRAGMA journal_mode = WAL }
+ execsql { CREATE TABLE filler(a,b,c); }
+
+ 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
+}
+
+
+#-------------------------------------------------------------------------
+# 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 4 4}
+
+# 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 4 4}
+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
+
+
+#-------------------------------------------------------------------------
+# 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..50c5172
--- /dev/null
+++ b/test/wal5.test
@@ -0,0 +1,478 @@
+# 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 }
+do_not_use_codec
+
+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" }
+ }
+
+ set vals {restart full truncate}
+ if {[lsearch -exact $vals $a(-mode)]<0} { 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
+ } [expr {[nonzero_reserved_bytes]?"/# # 0/":"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
+ } [expr {[nonzero_reserved_bytes]?"/# # #/":"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
+ } [expr {[nonzero_reserved_bytes]?"/# # #/":"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 3 1 3}
+ do_test 2.1.$tn.3 { code1 { do_wal_checkpoint db } } {0 3 3}
+ do_test 2.1.$tn.4 { file_page_counts } {2 3 2 3}
+ }
+
+ 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 3 1 4}
+ 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 3 3}
+ do_test 2.2.$tn.5 { file_page_counts } {2 3 2 4}
+ }
+
+ 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 3 1 3}
+ 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 4 1 4}
+ do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 4 3}
+
+ # The checkpoint above only writes page 1 of the db file. The other
+ # page (page 2) is locked by the read-transaction opened by the
+ # [sql2] commmand above. So normally, the db is 1 page in size here.
+ # However, in mmap() mode, the db is pre-allocated to 2 pages at the
+ # start of the checkpoint, even though page 2 cannot be written.
+ set nDb 2
+ if {[permutation]!="mmap"} {set nDb 1}
+ ifcapable !mmap {set nDb 1}
+ do_test 2.3.$tn.8 { file_page_counts } [list $nDb 4 2 4]
+ }
+
+ # 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 3 3} -
+ 2 TYPO - {0 3 3} -
+
+ 3 FULL - {0 4 4} 2
+ 4 FULL 1 {1 3 3} 1
+ 5 FULL 2 {1 4 3} 2
+ 6 FULL 3 {0 4 4} 2
+
+ 7 RESTART - {0 4 4} 3
+ 8 RESTART 1 {1 3 3} 1
+ 9 RESTART 2 {1 4 3} 2
+ 10 RESTART 3 {1 4 4} 3
+
+ 11 TRUNCATE - {0 0 0} 3
+ 12 TRUNCATE 1 {1 3 3} 1
+ 13 TRUNCATE 2 {1 4 3} 2
+ 14 TRUNCATE 3 {1 4 4} 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}
+ }
+
+ # Test SQLITE_CHECKPOINT_TRUNCATE.
+ #
+ do_multiclient_test tn {
+
+ code1 $do_wal_checkpoint
+ code2 $do_wal_checkpoint
+ code3 $do_wal_checkpoint
+
+ do_test 4.$tn.1 {
+ sql1 {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ PRAGMA synchronous = normal;
+ CREATE TABLE t1(x, y);
+ CREATE INDEX i1 ON t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+ file size test.db-wal
+ } [wal_file_size 8 1024]
+
+ do_test 4.$tn.2 { do_wal_checkpoint db -mode truncate } {0 0 0}
+ do_test 4.$tn.3 { file size test.db-wal } 0
+
+ do_test 4.$tn.4 {
+ sql2 { SELECT * FROM t1 }
+ } {1 2 3 4}
+
+ do_test 4.$tn.5 {
+ sql2 { INSERT INTO t1 VALUES('a', 'b') }
+ file size test.db-wal
+ } [wal_file_size 2 1024]
+
+ }
+
+ # Test that FULL, RESTART and TRUNCATE callbacks block on other clients
+ # and truncate the wal file as required even if the entire wal file has
+ # already been checkpointed when they are invoked.
+ #
+ do_multiclient_test tn {
+
+ code1 $do_wal_checkpoint
+ code2 $do_wal_checkpoint
+ code3 $do_wal_checkpoint
+
+ do_test 5.$tn.1 {
+ sql1 {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ PRAGMA synchronous = normal;
+ CREATE TABLE t1(x, y);
+ CREATE INDEX i1 ON t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ }
+ file size test.db-wal
+ } [wal_file_size 10 1024]
+
+ do_test 5.$tn.2 {
+ sql2 { BEGIN; SELECT * FROM t1 }
+ } {1 2 3 4 5 6}
+
+ do_test 5.$tn.3 { do_wal_checkpoint db -mode passive } {0 10 10}
+
+ do_test 5.$tn.4 {
+ sql3 { BEGIN; INSERT INTO t1 VALUES(7, 8); }
+ } {}
+
+ do_test 5.$tn.5 { do_wal_checkpoint db -mode passive } {0 10 10}
+ do_test 5.$tn.6 { do_wal_checkpoint db -mode full } {1 10 10}
+
+ do_test 5.$tn.7 { sql3 { ROLLBACK } } {}
+
+ do_test 5.$tn.8 { do_wal_checkpoint db -mode full } {0 10 10}
+ do_test 5.$tn.9 { do_wal_checkpoint db -mode truncate } {1 10 10}
+
+ do_test 5.$tn.10 {
+ file size test.db-wal
+ } [wal_file_size 10 1024]
+
+ proc xBusyHandler {n} { sql2 { COMMIT } ; return 0 }
+ db busy xBusyHandler
+
+ do_test 5.$tn.11 { do_wal_checkpoint db -mode truncate } {0 0 0}
+ do_test 5.$tn.12 { file size test.db-wal } 0
+
+ do_test 5.$tn.13 {
+ sql1 {
+ INSERT INTO t1 VALUES(7, 8);
+ INSERT INTO t1 VALUES(9, 10);
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ do_test 5.$tn.14 {
+ sql2 { BEGIN; SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ proc xBusyHandler {n} { return 1 }
+ do_test 5.$tn.15 { do_wal_checkpoint db -mode truncate } {1 4 4}
+ do_test 5.$tn.16 { file size test.db-wal } [wal_file_size 4 1024]
+
+ do_test 5.$tn.17 { do_wal_checkpoint db -mode restart } {1 4 4}
+
+ proc xBusyHandler {n} { sql2 { COMMIT } ; return 0 }
+ db busy xBusyHandler
+ do_test 5.$tn.18 { do_wal_checkpoint db -mode restart } {0 4 4}
+ do_test 5.$tn.19 { file size test.db-wal } [wal_file_size 4 1024]
+
+ do_test 5.$tn.20 { do_wal_checkpoint db -mode truncate } {0 0 0}
+ do_test 5.$tn.21 { file size test.db-wal } 0
+ }
+
+}
+
+
+finish_test
diff --git a/test/wal6.test b/test/wal6.test
new file mode 100644
index 0000000..9bbc584
--- /dev/null
+++ b/test/wal6.test
@@ -0,0 +1,269 @@
+# 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]
+set testprefix wal6
+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
+
+}
+
+#-------------------------------------------------------------------------
+# Test that SQLITE_BUSY_SNAPSHOT is returned as expected.
+#
+reset_db
+sqlite3 db2 test.db
+
+do_execsql_test 2.1 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a PRIMARY KEY, b TEXT);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+ BEGIN;
+ SELECT * FROM t1;
+} {wal 1 one 2 two}
+
+do_test 2.2 {
+ execsql {
+ SELECT * FROM t1;
+ INSERT INTO t1 VALUES(3, 'three');
+ } db2
+} {1 one 2 two}
+
+do_catchsql_test 2.3 {
+ INSERT INTO t1 VALUES('x', 'x')
+} {1 {database is locked}}
+
+do_test 2.4 {
+ list [sqlite3_errcode db] [sqlite3_extended_errcode db]
+} {SQLITE_BUSY SQLITE_BUSY_SNAPSHOT}
+
+do_execsql_test 2.5 {
+ SELECT * FROM t1;
+ COMMIT;
+ INSERT INTO t1 VALUES('x', 'x')
+} {1 one 2 two}
+
+proc test3 {prefix} {
+ do_test $prefix.1 {
+ execsql { SELECT count(*) FROM t1 }
+ } {0}
+ do_test $prefix.2 {
+ execsql { INSERT INTO t1 VALUES('x', 'x') } db2
+ } {}
+ do_test $prefix.3 {
+ execsql { INSERT INTO t1 VALUES('y', 'y') }
+ } {}
+ do_test $prefix.4 {
+ execsql { SELECT count(*) FROM t1 }
+ } {2}
+}
+
+do_execsql_test 2.6.1 { DELETE FROM t1 }
+test3 2.6.2
+
+db func test3 test3
+do_execsql_test 2.6.3 { DELETE FROM t1 }
+db eval {SELECT test3('2.6.4')}
+
+do_test 2.x {
+ db2 close
+} {}
+
+#-------------------------------------------------------------------------
+# Check that if BEGIN IMMEDIATE fails, it does not leave the user with
+# an open read-transaction (unless one was already open before the BEGIN
+# IMMEDIATE). Even if there are other active VMs.
+#
+
+proc test4 {prefix} {
+ do_test $prefix.1 {
+ catchsql { BEGIN IMMEDIATE }
+ } {1 {database is locked}}
+
+ do_test $prefix.2 {
+ execsql { COMMIT } db2
+ } {}
+
+ do_test $prefix.3 {
+ execsql { BEGIN IMMEDIATE }
+ } {}
+ do_test $prefix.4 {
+ execsql { COMMIT }
+ } {}
+}
+
+reset_db
+sqlite3 db2 test.db
+do_execsql_test 3.1 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE ab(a PRIMARY KEY, b);
+} {wal}
+
+do_test 3.2.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO ab VALUES(1, 2);
+ } db2
+} {}
+test4 3.2.2
+
+db func test4 test4
+do_test 3.3.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO ab VALUES(3, 4);
+ } db2
+} {}
+
+db eval {SELECT test4('3.3.2')}
+
+do_test 3.x {
+ db2 close
+} {}
+
+#-------------------------------------------------------------------------
+# Check that if a wal file has been partially checkpointed, no frames are
+# read from the checkpointed part.
+#
+reset_db
+do_execsql_test 4.1 {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ PRAGMA wal_checkpoint = truncate;
+} {wal 0 0 0}
+
+do_test 4.2 {
+ execsql { INSERT INTO t1 VALUES(1, 2) }
+ file size test.db-wal
+} [wal_file_size 1 1024]
+
+do_test 4.3 {
+ sqlite3 db2 test.db
+ execsql {
+ BEGIN;
+ INSERT INTO t2 VALUES(3, 4);
+ }
+ execsql { PRAGMA wal_checkpoint = passive } db2
+} {0 1 1}
+
+do_test 4.3 {
+ execsql { COMMIT }
+ db2 close
+ hexio_write test.db-wal 0 [string repeat 00 2000]
+ sqlite3 db2 test.db
+} {}
+
+do_test 4.4.1 {
+ catchsql { SELECT * FROM t1 } db2
+} {0 {1 2}}
+do_test 4.4.2 {
+ catchsql { SELECT * FROM t2 } db2
+} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+# Confirm that it is possible to get an SQLITE_BUSY_SNAPSHOT error from
+# "BEGIN EXCLUSIVE" if the connection already has an open read-transaction.
+#
+db close
+db2 close
+reset_db
+sqlite3 db2 test.db
+do_execsql_test 5.1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+} {wal}
+do_test 5.2 {
+ set res [list]
+ db eval {
+ SELECT * FROM t1
+ } {
+ if {$x==1} {
+ db2 eval { INSERT INTO t1 VALUES(5, 6) }
+ }
+ if {$x==3} {
+ set res [catchsql {BEGIN EXCLUSIVE}]
+ lappend res [sqlite3_extended_errcode db]
+ }
+ }
+ set res
+} {1 {database is locked} SQLITE_BUSY_SNAPSHOT}
+
+
+
+finish_test
diff --git a/test/wal64k.test b/test/wal64k.test
new file mode 100644
index 0000000..8ff8e4b
--- /dev/null
+++ b/test/wal64k.test
@@ -0,0 +1,63 @@
+# 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
+set testprefix wal64k
+
+ifcapable !wal {finish_test ; return }
+
+if {$tcl_platform(platform) != "unix"} {
+ finish_test
+ return
+}
+
+db close
+test_syscall pagesize 65536
+sqlite3 db test.db
+
+do_execsql_test 1.0 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x);
+ CREATE INDEX i1 ON t1(x);
+} {wal}
+do_test 1.1 { file size test.db-shm } {65536}
+
+do_test 1.2 {
+ execsql BEGIN
+ while {[file size test.db-shm]==65536} {
+ execsql { INSERT INTO t1 VALUES( randstr(900,1100) ) }
+ }
+ execsql COMMIT
+ file size test.db-shm
+} {131072}
+
+integrity_check 1.3
+
+db close
+forcedelete test.db
+sqlite3 db test.db -vfs unix-excl
+do_execsql_test 2.1 {
+ PRAGMA page_size=512;
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(a,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<8200)
+ INSERT INTO t1(a,b) SELECT x, zeroblob(300) FROM c;
+ PRAGMA integrity_check;
+} {wal ok}
+
+db close
+test_syscall pagesize -1
+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/wal8.test b/test/wal8.test
new file mode 100644
index 0000000..3e5a0c2
--- /dev/null
+++ b/test/wal8.test
@@ -0,0 +1,91 @@
+# 2012 February 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 operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+# Specifically, it tests the case where a connection opens an empty
+# file. Then, another connection opens the same file and initializes
+# the connection as a WAL database. Following this, the first connection
+# executes a "PRAGMA page_size = XXX" command to set its expected page
+# size, and then queries the database.
+#
+# This is an unusual case, as normally SQLite is able to glean the page
+# size from the database file as soon as it is opened (even before the
+# first read transaction is executed), and the "PRAGMA page_size = XXX"
+# is a no-op.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix wal8
+ifcapable !wal {finish_test ; return }
+do_not_use_codec
+
+db close
+forcedelete test.db test.db-wal
+
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test 1.0 {
+ execsql {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ } db2
+} {wal}
+
+do_catchsql_test 1.1 {
+ PRAGMA page_size = 4096;
+ VACUUM;
+} {0 {}}
+
+db close
+db2 close
+forcedelete test.db test.db-wal
+
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test 2.0 {
+ execsql {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA journal_mode = wal;
+ } db2
+} {wal}
+
+do_catchsql_test 2.1 {
+ PRAGMA page_size = 4096;
+ VACUUM;
+} {0 {}}
+
+db close
+db2 close
+forcedelete test.db test.db-wal
+
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test 3.0 {
+ execsql {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ } db2
+} {wal}
+
+do_execsql_test 3.1 {
+ PRAGMA page_size = 4096;
+ SELECT name FROM sqlite_master;
+} {t1}
+
+finish_test
diff --git a/test/wal9.test b/test/wal9.test
new file mode 100644
index 0000000..ae2a52b
--- /dev/null
+++ b/test/wal9.test
@@ -0,0 +1,94 @@
+# 2012 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.
+#
+#***********************************************************************
+#
+# This test case tests that a problem causing a failing assert() has
+# been fixed. The problem occurred if a writer process with a subset
+# of the *shm file mapped rolled back a transaction begun after the
+# entire WAL file was checkpointed into the db file (i.e. a transaction
+# that would have restarted the WAL file from the beginning).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix wal9
+
+sqlite3 db2 test.db
+
+do_execsql_test 1.0 {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 0;
+ CREATE TABLE t(x);
+} {wal 0}
+
+do_test 1.1 {
+ execsql "SELECT * FROM t" db2
+} {}
+
+do_execsql_test 1.2 {
+ BEGIN;
+ INSERT INTO t VALUES(randomblob(100));
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ INSERT INTO t SELECT randomblob(100) FROM t;
+ COMMIT;
+} {}
+
+# Check file sizes are as expected. The real requirement here is that
+# the *shm file is now more than one chunk (>32KiB).
+#
+# The sizes of various files are slightly different in normal and
+# auto-vacuum mode.
+do_test 1.3 { file size test.db } {1024}
+do_test 1.4 { expr {[file size test.db-wal]>(1500*1024)} } {1}
+do_test 1.5 { expr {[file size test.db-shm]>32768} } {1}
+do_test 1.6 {
+ foreach {a b c} [db eval {PRAGMA wal_checkpoint}] break
+ list [expr {$a==0}] [expr {$b>14500}] [expr {$c>14500}] [expr {$b==$c}]
+} {1 1 1 1}
+
+# At this point connection [db2] has mapped the first 32KB of the *shm file
+# only. Because the entire WAL file has been checkpointed, it is not
+# necessary to map any more of the *-shm file to read or write the database
+# (since all data will be read directly from the db file).
+#
+# However, at one point if a transaction that had not yet written to the
+# WAL file was rolled back an assert() attempting to verify that the entire
+# *-shm file was mapped would fail. If NDEBUG was defined (and the assert()
+# disabled) this bug caused SQLite to ignore the return code of a mmap()
+# call.
+#
+do_test 1.7 {
+ execsql {
+ BEGIN;
+ INSERT INTO t VALUES('hello');
+ ROLLBACK;
+ } db2
+} {}
+db2 close
+
+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..0e0f999
--- /dev/null
+++ b/test/walbak.test
@@ -0,0 +1,359 @@
+# 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 {
+ forcedelete abc.db
+ 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);
+ }
+ }
+
+} {
+ if {$tn==4 && [sqlite3 -has-codec]} continue
+ 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..c43b7e2
--- /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 [get_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/walblock.test b/test/walblock.test
new file mode 100644
index 0000000..23167a8
--- /dev/null
+++ b/test/walblock.test
@@ -0,0 +1,114 @@
+# 2015 Mar 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/wal_common.tcl
+
+finish_test; return; # Feature currently not implemented.
+ifcapable !wal {finish_test ; return }
+if {$::tcl_platform(platform)!="unix"} { finish_test ; return }
+set testprefix walblock
+
+catch { db close }
+testvfs tvfs -fullshm 1
+foreach f [glob test.db*] { forcedelete $f }
+
+sqlite3 db test.db -vfs tvfs
+do_execsql_test 1.1.0 {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(7, 8);
+} {wal}
+
+do_test 1.1.1 {
+ lsort [glob test.db*]
+} {test.db test.db-shm test.db-wal}
+
+do_test 1.1.2 {
+ set C [launch_testfixture]
+ testfixture $C {
+ sqlite3 db test.db
+ db eval { SELECT * FROM t1 }
+ }
+} {1 2 3 4 5 6 7 8}
+
+do_test 1.1.3 {
+ set ::out [list]
+ testfixture $C {
+ db eval { SELECT * FROM t1 }
+ } [list set ::out]
+ set ::out
+} {}
+
+do_test 1.1.4 {
+ vwait ::out
+ set ::out
+} {1 2 3 4 5 6 7 8}
+
+#
+# Test that if a read client cannot read the wal-index header because a
+# write client is in the middle of updating it, the reader blocks until
+# the writer finishes.
+#
+# 1. Open a write transaction using client [db] in this process.
+#
+# 2. Attempt to commit the write transaction. Intercept the xShmBarrier()
+# call made by the writer between updating the two copies of the
+# wal-index header.
+#
+# 3. Within the xShmBarrier() callback, make an asynchronous request to
+# the other process to read from the database. It should block, as it
+# cannot get read the wal-index header.
+#
+# 4. Still in xShmBarrier(), wait for 5 seconds. Check that the other
+# process has not answered the request.
+#
+# 5: Finish committing the transaction. Then wait for 0.5 seconds more.
+# Ensure that the second process has by this stage read the database
+# and that the snapshot it read included the transaction committed in
+# step (4).
+#
+do_execsql_test 1.2.1 {
+ BEGIN;
+ INSERT INTO t1 VALUES(9, 10);
+} {}
+
+tvfs script barrier_callback
+tvfs filter xShmBarrier
+proc barrier_callback {method args} {
+ set ::out ""
+ testfixture $::C { db eval { SELECT * FROM t1 } } {set ::out}
+
+ do_test "1.2.2.(blocking 10 seconds)" {
+ set ::continue 0
+ after 10000 {set ::continue 1}
+ vwait ::continue
+ set ::out
+ } {}
+}
+
+execsql COMMIT
+
+do_test "1.2.3.(blocking 0.5 seconds)" {
+ set ::continue 0
+ after 500 {set ::continue 1}
+ vwait ::continue
+ set ::out
+} {1 2 3 4 5 6 7 8 9 10}
+
+
+finish_test
diff --git a/test/walcksum.test b/test/walcksum.test
new file mode 100644
index 0000000..f3fc427
--- /dev/null
+++ b/test/walcksum.test
@@ -0,0 +1,338 @@
+# 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 }
+
+
+finish_test
diff --git a/test/walcrash.test b/test/walcrash.test
new file mode 100644
index 0000000..b8ca7fb
--- /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 5 -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 4 -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 13 -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 14 -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(9000));
+ INSERT INTO t1 VALUES(randomblob(9000));
+ INSERT INTO t1 VALUES(randomblob(9000));
+ INSERT INTO t1 VALUES(randomblob(9000));
+ }
+ } {1 {child process exited abnormally}}
+
+ do_test walcrash-6.$i.2 {
+ sqlite3 db test.db
+ execsql { SELECT count(*) BETWEEN 34 AND 36 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..9c93bcd
--- /dev/null
+++ b/test/walcrash2.test
@@ -0,0 +1,98 @@
+# 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/walcrash3.test b/test/walcrash3.test
new file mode 100644
index 0000000..71dfb45
--- /dev/null
+++ b/test/walcrash3.test
@@ -0,0 +1,128 @@
+# 2011 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 test simulates an application crash immediately following a
+# system call to truncate a file. Specifically, the system call that
+# truncates the WAL file if "PRAGMA journal_size_limit" is configured.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !wal {finish_test ; return }
+set testprefix walcrash3
+
+db close
+testvfs tvfs
+tvfs filter {xTruncate xWrite}
+tvfs script tvfs_callback
+proc tvfs_callback {args} {}
+
+sqlite3 db test.db -vfs tvfs
+do_execsql_test 1.1 {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 128;
+ PRAGMA journal_size_limit = 16384;
+
+ CREATE TABLE t1(a BLOB, b BLOB, UNIQUE(a, b));
+ INSERT INTO t1 VALUES(randomblob(10), randomblob(1000));
+} {wal 128 16384}
+
+proc tvfs_callback {method file arglist} {
+ if {$::state==1} {
+ foreach f [glob -nocomplain xx_test.*] { forcedelete $f }
+ foreach f [glob -nocomplain test.*] { forcecopy $f "xx_$f" }
+ set ::state 2
+ }
+ if {$::state==0 && $method=="xTruncate" && [file tail $file]=="test.db-wal"} {
+ set ::state 1
+ }
+}
+
+for {set i 2} {$i<1000} {incr i} {
+
+ # If the WAL file is truncated within the following, within the following
+ # xWrite call the [tvfs_callback] makes a copy of the database and WAL
+ # files set sets $::state to 2. So that the copied files are in the same
+ # state as the real database and WAL files would be if an application crash
+ # occurred immediately following the xTruncate().
+ #
+ set ::state 0
+ do_execsql_test 1.$i.1 {
+ INSERT INTO t1 VALUES(randomblob(10), randomblob(1000));
+ }
+
+ # If a copy was made, open it and run the integrity-check.
+ #
+ if {$::state==2} {
+ sqlite3 db2 xx_test.db
+ do_test 1.$i.2 { execsql { PRAGMA integrity_check } db2 } "ok"
+ do_test 1.$i.3 { execsql { SELECT count(*) FROM t1 } db2 } [expr $i-1]
+ db2 close
+ }
+}
+catch { db close }
+tvfs delete
+
+#--------------------------------------------------------------------------
+#
+catch { db close }
+forcedelete test.db
+
+do_test 2.1 {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 512;
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint = 128;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(randomblob(25), randomblob(200));
+ }
+
+ for {set i 0} {$i < 1500} {incr i} {
+ execsql { INSERT INTO t1 VALUES(randomblob(25), randomblob(200)) }
+ }
+
+ db_save
+ db close
+} {}
+
+set nInitialErr [set_test_counter errors]
+for {set i 2} {$i<10000 && [set_test_counter errors]==$nInitialErr} {incr i} {
+
+ do_test 2.$i.1 {
+ catch { db close }
+ db_restore
+ crashsql -delay 2 -file test.db-wal -seed $i {
+ SELECT * FROM sqlite_master;
+ PRAGMA synchronous = full;
+ PRAGMA wal_checkpoint;
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(26), randomblob(200));
+ INSERT INTO t1 VALUES(randomblob(26), randomblob(200));
+ INSERT INTO t1 VALUES(randomblob(26), randomblob(200));
+ INSERT INTO t1 VALUES(randomblob(26), randomblob(200));
+ INSERT INTO t1 VALUES(randomblob(26), randomblob(200));
+ INSERT INTO t1 VALUES(randomblob(26), randomblob(200));
+ INSERT INTO t1 VALUES(randomblob(26), randomblob(200));
+ INSERT INTO t1 VALUES(randomblob(26), randomblob(200));
+ COMMIT;
+ }
+ } {1 {child process exited abnormally}}
+
+ do_test 2.$i.2 {
+ sqlite3 db test.db
+ execsql { PRAGMA integrity_check }
+ } {ok}
+}
+
+finish_test
diff --git a/test/walcrash4.test b/test/walcrash4.test
new file mode 100644
index 0000000..80839b3
--- /dev/null
+++ b/test/walcrash4.test
@@ -0,0 +1,85 @@
+# 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 }
+set testprefix walcrash4
+do_not_use_codec
+
+#-------------------------------------------------------------------------
+# At one point, if "PRAGMA synchronous=full" is set and the platform
+# does not support POWERSAFE_OVERWRITE, and the last frame written to
+# the wal file in a transaction is aligned with a sector boundary, the
+# xSync() call was omitted.
+#
+# The following test verifies that this has been fixed.
+#
+do_execsql_test 1.0 {
+ PRAGMA autovacuum = 0;
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = wal;
+ PRAGMA main.synchronous = full;
+} {wal}
+
+faultsim_save_and_close
+
+# The error message is different on unix and windows
+#
+if {$::tcl_platform(platform)=="windows"} {
+ set msg "child killed: unknown signal"
+} else {
+ set msg "child process exited abnormally"
+}
+
+for {set nExtra 0} {$nExtra < 10} {incr nExtra} {
+ for {set i 0} {$i < 10} {incr i} {
+ do_test 1.nExtra=$nExtra.i=$i.1 {
+ faultsim_restore_and_reopen
+
+ set fd [open crash.tcl w]
+ puts $fd [subst -nocommands {
+ sqlite3_crash_enable 1
+ sqlite3_test_control_pending_byte $::sqlite_pending_byte
+ sqlite3 db test.db -vfs crash
+ db eval {
+ PRAGMA main.synchronous=FULL;
+ BEGIN;
+ CREATE TABLE t1(x UNIQUE);
+ }
+ for {set e 2} {[set e] < ($nExtra+2)} {incr e} {
+ db eval "CREATE TABLE t[set e] (x)"
+ }
+ db eval {
+ INSERT INTO t1 VALUES( randomblob(170000) );
+ COMMIT;
+ }
+ sqlite3_crash_now
+ }]
+ close $fd
+
+ set r [catch { exec [info nameofexec] crash.tcl >@stdout } msg]
+ list $r $msg
+ } "1 {$msg}"
+
+ do_execsql_test 1.nExtra=$nExtra.i=$i.2 {
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+ } {1 ok}
+ }
+}
+
+
+finish_test
diff --git a/test/walfault.test b/test/walfault.test
new file mode 100644
index 0000000..6cb760b
--- /dev/null
+++ b/test/walfault.test
@@ -0,0 +1,590 @@
+# 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 {
+ # Update: The following changed from {0 {wal 0 7 7 a b}} as a result
+ # of PSOW being set by default.
+ faultsim_test_result {0 {wal 0 5 5 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 9 9}}
+ 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 switching out of exclusive-locking mode.
+#
+do_test walfault-15-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-15 -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ SELECT count(*) FROM abc;
+ PRAGMA locking_mode = exclusive;
+ BEGIN;
+ INSERT INTO abc VALUES(randomblob(1500));
+ COMMIT;
+ }
+} -body {
+ db eval {
+ PRAGMA locking_mode = normal;
+ BEGIN;
+ INSERT INTO abc VALUES(randomblob(1500));
+ COMMIT;
+ }
+} -test {
+ faultsim_integrity_check
+ set nRow [db eval {SELECT count(*) FROM abc}]
+ if {$nRow!=3 && $nRow!=4} { error "Bad db content" }
+}
+
+finish_test
diff --git a/test/walfault2.test b/test/walfault2.test
new file mode 100644
index 0000000..a4c352b
--- /dev/null
+++ b/test/walfault2.test
@@ -0,0 +1,91 @@
+# 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 }
+set testprefix walfault2
+
+#-------------------------------------------------------------------------
+# Inject faults while truncating the wal file.
+#
+do_execsql_test 1.0 {
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a, b);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 30
+ )
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
+} {wal}
+faultsim_save_and_close
+
+do_faultsim_test 1 -prep {
+ catch { db close }
+ faultsim_restore
+ sqlite3 db file:test.db?psow=0 -uri 1
+ file_control_powersafe_overwrite db 0
+ execsql {
+ PRAGMA wal_checkpoint;
+ PRAGMA journal_size_limit = 10000;
+ PRAGMA synchronous = full;
+ }
+} -body {
+ execsql { INSERT INTO t1 VALUES(1,1) }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+# Inject faults while rewriting checksums.
+#
+reset_db
+do_execsql_test 2.0 {
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a, b);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 30
+ )
+ INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
+} {wal}
+faultsim_save_and_close
+
+do_faultsim_test 2 -prep {
+ faultsim_restore_and_reopen
+ execsql {
+ PRAGMA cache_size = 2;
+ BEGIN;
+ UPDATE t1 SET a=randomblob(400);
+ UPDATE t1 SET b=randomblob(400);
+ UPDATE t1 SET a=randomblob(400);
+ UPDATE t1 SET b=randomblob(400);
+ UPDATE t1 SET a=randomblob(400);
+ UPDATE t1 SET b=randomblob(400);
+ UPDATE t1 SET a=randomblob(400);
+ UPDATE t1 SET b=randomblob(400);
+ }
+} -body {
+ execsql COMMIT
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+
+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..f760823
--- /dev/null
+++ b/test/walmode.test
@@ -0,0 +1,393 @@
+# 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}
+
+if {[atomic_batch_write test.db]==0} {
+ 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}
+if {[atomic_batch_write test.db]==0} {
+ 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}
+if {[atomic_batch_write test.db]==0} {
+ 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/waloverwrite.test b/test/waloverwrite.test
new file mode 100644
index 0000000..ff8bc5a
--- /dev/null
+++ b/test/waloverwrite.test
@@ -0,0 +1,162 @@
+# 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/wal_common.tcl
+set testprefix waloverwrite
+
+ifcapable !wal {finish_test ; return }
+
+# Simple test:
+#
+# Test cases *.1 - *.6:
+#
+# + Create a database of blobs roughly 50 pages in size.
+#
+# + Set the db cache size to something much smaller than this (5 pages)
+#
+# + Within a transaction, loop through the set of blobs 5 times. Update
+# each blob as it is visited.
+#
+# + Test that the wal file is roughly 50 pages in size - even though many
+# database pages have been written to it multiple times.
+#
+# + Take a copy of the database and wal file. Test that recovery can
+# be run on it.
+#
+# Test cases *.7 - *.9:
+#
+# + Same thing, but before committing the statement transaction open
+# a SAVEPOINT, update the blobs another 5 times, then roll it back.
+#
+# + Check that if recovery is run on the resulting wal file, the rolled
+# back changes from within the SAVEPOINT are not present in the db.
+#
+# The above is run twice - once where the wal file is empty at the start of
+# step 3 (tn==1) and once where it already contains a transaction (tn==2).
+#
+foreach {tn xtra} {
+ 1 {}
+ 2 { UPDATE t1 SET y = randomblob(799) WHERE x=4 }
+} {
+ reset_db
+ do_execsql_test 1.$tn.0 {
+ CREATE TABLE t1(x, y);
+ CREATE TABLE t2(x, y);
+ CREATE INDEX i1y ON t1(y);
+
+ WITH cnt(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<20
+ )
+ INSERT INTO t1 SELECT i, randomblob(800) FROM cnt;
+ } {}
+
+ do_test 1.$tn.1 {
+ set nPg [db one { PRAGMA page_count } ]
+ expr $nPg>40 && $nPg<50
+ } {1}
+
+ do_test 1.$tn.2 {
+ db close
+ sqlite3 db test.db
+
+ execsql {PRAGMA journal_mode = wal}
+ execsql {PRAGMA cache_size = 5}
+ execsql $xtra
+
+ db transaction {
+ for {set i 0} {$i < 5} {incr i} {
+ foreach x [db eval {SELECT x FROM t1}] {
+ execsql { UPDATE t1 SET y = randomblob(799) WHERE x=$x }
+ }
+ }
+ }
+
+ set nPg [wal_frame_count test.db-wal 1024]
+ expr $nPg>40 && $nPg<60
+ } {1}
+
+ do_execsql_test 1.$tn.3 { PRAGMA integrity_check } ok
+
+ do_test 1.$tn.4 {
+ forcedelete test.db2 test.db2-wal
+ forcecopy test.db test.db2
+ sqlite3 db2 test.db2
+ execsql { SELECT sum(length(y)) FROM t1 } db2
+ } [expr 20*800]
+
+ do_test 1.$tn.5 {
+ db2 close
+ forcecopy test.db test.db2
+ forcecopy test.db-wal test.db2-wal
+ sqlite3 db2 test.db2
+ execsql { SELECT sum(length(y)) FROM t1 } db2
+ } [expr 20*799]
+
+ do_test 1.$tn.6 {
+ execsql { PRAGMA integrity_check } db2
+ } ok
+ db2 close
+
+ do_test 1.$tn.7 {
+ execsql { PRAGMA wal_checkpoint }
+ db transaction {
+ for {set i 0} {$i < 1} {incr i} {
+ foreach x [db eval {SELECT x FROM t1}] {
+ execsql { UPDATE t1 SET y = randomblob(798) WHERE x=$x }
+ }
+ }
+
+ execsql {
+ WITH cnt(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<20)
+ INSERT INTO t2 SELECT i, randomblob(800) FROM cnt;
+ }
+
+ execsql {SAVEPOINT abc}
+ for {set i 0} {$i < 5} {incr i} {
+ foreach x [db eval {SELECT x FROM t1}] {
+ execsql { UPDATE t1 SET y = randomblob(797) WHERE x=$x }
+ }
+ }
+ execsql {ROLLBACK TO abc}
+
+ }
+
+ set nPg [wal_frame_count test.db-wal 1024]
+ expr $nPg>55 && $nPg<75
+ } {1}
+
+ do_test 1.$tn.8 {
+ forcedelete test.db2 test.db2-wal
+ forcecopy test.db test.db2
+ sqlite3 db2 test.db2
+ execsql { SELECT sum(length(y)) FROM t1 } db2
+ } [expr 20*799]
+
+ do_test 1.$tn.9 {
+ db2 close
+ forcecopy test.db-wal test.db2-wal
+ sqlite3 db2 test.db2
+ execsql { SELECT sum(length(y)) FROM t1 } db2
+ } [expr 20*798]
+
+ do_test 1.$tn.10 {
+ execsql { PRAGMA integrity_check } db2
+ } ok
+ db2 close
+}
+
+finish_test
diff --git a/test/walpersist.test b/test/walpersist.test
new file mode 100644
index 0000000..692728d
--- /dev/null
+++ b/test/walpersist.test
@@ -0,0 +1,126 @@
+# 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}
+
+# Make sure the journal_size_limit works to limit the size of the
+# persisted wal file. In persistent-wal mode, any non-negative
+# journal_size_limit causes the WAL file to be truncated to zero bytes
+# when closing.
+#
+forcedelete test.db test.db-shm test.db-wal
+do_test walpersist-2.1 {
+ sqlite3 db test.db
+ db eval {
+ PRAGMA journal_mode=WAL;
+ PRAGMA wal_autocheckpoint=OFF;
+ PRAGMA journal_size_limit=12000;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(randomblob(50000));
+ UPDATE t1 SET x=randomblob(50000);
+ }
+ expr {[file size test.db-wal]>100000}
+} {1}
+do_test walpersist-2.2 {
+ file_control_persist_wal db 1
+ db close
+ concat [file exists test.db-wal] [file size test.db-wal]
+} {1 0}
+do_test walpersist-2.3 {
+ sqlite3 db test.db
+ execsql { PRAGMA integrity_check }
+} {ok}
+
+do_test 3.1 {
+ catch {db close}
+ forcedelete test.db test.db-shm test.db-wal
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ PRAGMA wal_autocheckpoint=128;
+ PRAGMA journal_size_limit=16384;
+ CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
+ }
+} {wal 128 16384}
+do_test 3.2 {
+ for {set i 0} {$i<200} {incr i} {
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) }
+ }
+ file_control_persist_wal db 1
+ db close
+} {}
+do_test walpersist-3.3 {
+ file size test.db-wal
+} {0}
+do_test walpersist-3.4 {
+ sqlite3 db test.db
+ execsql { PRAGMA integrity_check }
+} {ok}
+
+
+finish_test
diff --git a/test/walprotocol.test b/test/walprotocol.test
new file mode 100644
index 0000000..a262cdd
--- /dev/null
+++ b/test/walprotocol.test
@@ -0,0 +1,201 @@
+# 2016 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 operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+# More specifically, it tests "locking protocol" errors - errors that
+# may be caused if one or more SQLite clients does not follow the expected
+# locking protocol when accessing a wal-mode database. These tests take
+# quite a while to run.
+#
+
+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 walprotocol
+
+#-------------------------------------------------------------------------
+# 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 1.3).
+#
+# Also test the effect of hitting an SQLITE_BUSY while attempting to obtain
+# the WRITER lock (should be the same). Test case 1.4.
+#
+do_execsql_test 1.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE x(y);
+ INSERT INTO x VALUES('z');
+} {wal}
+
+proc lock_callback {method filename handle lock} {
+ lappend ::locks $lock
+}
+do_test 1.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 11
+} [list {0 1 lock exclusive} {1 2 lock exclusive} \
+ {4 1 lock exclusive} {4 1 unlock exclusive} \
+ {5 1 lock exclusive} {5 1 unlock exclusive} \
+ {6 1 lock exclusive} {6 1 unlock exclusive} \
+ {7 1 lock exclusive} {7 1 unlock exclusive} \
+ {1 2 unlock exclusive} \
+ {0 1 unlock exclusive} \
+]
+do_test 1.2 {
+ db close
+ set ::locks [list]
+ sqlite3 db test.db -vfs T
+ execsql { SELECT * FROM x }
+ lrange $::locks 0 11
+} [list {0 1 lock exclusive} {1 2 lock exclusive} \
+ {4 1 lock exclusive} {4 1 unlock exclusive} \
+ {5 1 lock exclusive} {5 1 unlock exclusive} \
+ {6 1 lock exclusive} {6 1 unlock exclusive} \
+ {7 1 lock exclusive} {7 1 unlock exclusive} \
+ {1 2 unlock exclusive} \
+ {0 1 unlock exclusive} \
+]
+proc lock_callback {method filename handle lock} {
+ if {$lock == "1 2 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 delay of roughly 10 seconds, but if SQLite"
+puts "# is built on unix without HAVE_USLEEP defined, it may be much longer."
+do_test 1.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 1.4 {
+ db close
+ set ::locks [list]
+ sqlite3 db test.db -vfs T
+ catchsql { SELECT * FROM x }
+} {1 {locking protocol}}
+
+puts "# Warning: Third time!"
+proc lock_callback {method filename handle lock} {
+ if {$lock == "4 4 lock exclusive"} { return SQLITE_BUSY }
+ return SQLITE_OK
+}
+do_test 1.5 {
+ db close
+ set ::locks [list]
+ sqlite3 db test.db -vfs T
+ catchsql { SELECT * FROM x }
+} {0 z}
+db close
+T delete
+
+#-------------------------------------------------------------------------
+#
+do_test 2.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 5 5}
+do_test 2.2 {
+ execsql { SELECT * FROM b }
+} {Tehran Qom Markazi}
+do_test 2.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 2.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 == "1 2 unlock exclusive"} {
+ T filter {}
+ set ::r [catchsql { SELECT * FROM b } db2]
+ }
+}
+sqlite3 db test.db
+sqlite3 db2 test.db
+puts "# Warning: Another slow test!"
+do_test 2.5 {
+ execsql { SELECT * FROM b }
+} {Tehran Qom Markazi Qazvin Gilan Ardabil}
+do_test 2.6 {
+ set ::r
+} {0 {Tehran Qom Markazi Qazvin Gilan Ardabil}}
+
+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 2 unlock exclusive"} {
+ T filter {}
+ set ::r [catchsql { SELECT * FROM b } db2]
+ }
+}
+unset ::r
+puts "# Warning: Last one!"
+do_test 2.7 {
+ execsql { SELECT * FROM b }
+} {Tehran Qom Markazi Qazvin Gilan Ardabil}
+do_test 2.8 {
+ set ::r
+} {0 {Tehran Qom Markazi Qazvin Gilan Ardabil}}
+
+db close
+db2 close
+T delete
+
+finish_test
diff --git a/test/walprotocol2.test b/test/walprotocol2.test
new file mode 100644
index 0000000..0792c9a
--- /dev/null
+++ b/test/walprotocol2.test
@@ -0,0 +1,97 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+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 walprotocol2
+
+#-------------------------------------------------------------------------
+# 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 1.3).
+#
+# Also test the effect of hitting an SQLITE_BUSY while attempting to obtain
+# the WRITER lock (should be the same). Test case 1.4.
+#
+do_execsql_test 1.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE x(y);
+ INSERT INTO x VALUES('z');
+} {wal}
+
+db close
+
+proc lock_callback {method filename handle lock} {
+ # puts "$method $filename $handle $lock"
+}
+testvfs T
+T filter xShmLock
+T script lock_callback
+
+sqlite3 db test.db -vfs T
+sqlite3 db2 test.db -vfs T
+
+do_execsql_test 2.0 {
+ SELECT * FROM x;
+} {z}
+do_execsql_test -db db2 2.1 {
+ SELECT * FROM x;
+} {z}
+
+#---------------------------------------------------------------
+# Attempt a "BEGIN EXCLUSIVE" using connection handle [db]. This
+# causes SQLite to open a read transaction, then a write transaction.
+# Rig the xShmLock() callback so that just before the EXCLUSIVE lock
+# for the write transaction is taken, connection [db2] jumps in and
+# modifies the database. This causes the "BEGIN EXCLUSIVE" to throw
+# an SQLITE_BUSY_SNAPSHOT error.
+#
+proc lock_callback {method filename handle lock} {
+ if {$lock=="0 1 lock exclusive"} {
+ proc lock_callback {method filename handle lock} {}
+ db2 eval { INSERT INTO x VALUES('y') }
+ }
+}
+do_catchsql_test 2.2 {
+ BEGIN EXCLUSIVE;
+} {1 {database is locked}}
+do_test 2.3 {
+ sqlite3_extended_errcode db
+} {SQLITE_BUSY}
+
+#---------------------------------------------------------------
+# Same again, but with a busy-handler. This time, following the
+# SQLITE_BUSY_SNAPSHOT error the busy-handler is invoked and then the
+# whole thing retried from the beginning. This time it succeeds.
+#
+proc lock_callback {method filename handle lock} {
+ if {$lock=="0 1 lock exclusive"} {
+ proc lock_callback {method filename handle lock} {}
+ db2 eval { INSERT INTO x VALUES('x') }
+ }
+}
+db timeout 10
+do_catchsql_test 2.4 {
+ BEGIN EXCLUSIVE;
+} {0 {}}
+do_execsql_test 2.5 {
+ SELECT * FROM x;
+ COMMIT;
+} {z y x}
+
+finish_test
diff --git a/test/walro.test b/test/walro.test
new file mode 100644
index 0000000..cae52db
--- /dev/null
+++ b/test/walro.test
@@ -0,0 +1,300 @@
+# 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 {
+
+ # Close all connections and delete the database.
+ #
+ code1 { db close }
+ code2 { db2 close }
+ code3 { db3 close }
+ forcedelete test.db
+ forcedelete walro
+
+ # Do not run tests with the connections in the same process.
+ #
+ if {$tn==2} continue
+
+ 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 auto_vacuum = 0;
+ 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 }
+ list [catch { sql1 { SELECT * FROM t1 } } msg] $msg
+ } {0 {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 }
+ } {0 {a b c d e f g h i j}}
+ do_test 1.2.4 {
+ code1 { sqlite3_extended_errcode db }
+ } {SQLITE_OK}
+
+ 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.
+ #
+ # UPDATE: os_unix.c now opens the *-shm file in readonly mode
+ # automatically.
+ #
+ do_test 1.3.1 {
+ code1 { db close }
+ code1 { sqlite3 db test.db }
+ csql1 { SELECT * FROM t1 }
+ } {0 {a b c d e f g h i j k l}}
+
+ # 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 }
+ } {0 {a b c d e f g h i j k l}}
+ do_test 1.3.2.4 {
+ code1 { sqlite3_extended_errcode db }
+ } {SQLITE_OK}
+
+ #-----------------------------------------------------------------------
+ # Test cases 1.4.* check that checkpoints and log wraps don't prevent
+ # read-only connections from reading the database.
+ do_test 1.4.1 {
+ code1 { db close }
+ forcedelete test.db-shm
+ file exists test.db-shm
+ } {0}
+
+ # Open one read-only and one read-write connection. Write some data
+ # and then run a checkpoint using the read-write connection. Then
+ # check the read-only connection can still read.
+ do_test 1.4.2 {
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ code2 { sqlite3 db2 test.db }
+ csql2 {
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ PRAGMA wal_checkpoint;
+ }
+ } {0 {0 3 3}}
+ do_test 1.4.3 {
+ csql1 { SELECT * FROM t1 }
+ } {0 {a b c d e f g h i j k l 1 2 3 4 5 6}}
+
+ # Using the read-write connection, open a transaction and write lots
+ # of data - causing a cache spill and a log wrap. Then check that the
+ # read-only connection can still read the database.
+ do_test 1.4.4.1 {
+ csql2 {
+ PRAGMA cache_size = 10;
+ BEGIN;
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES('abc', 'xyz');
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ }
+ file size test.db-wal
+ } [expr {[nonzero_reserved_bytes]?148848:147800}]
+ do_test 1.4.4.2 {
+ csql1 { SELECT * FROM t1 }
+ } {0 {a b c d e f g h i j k l 1 2 3 4 5 6}}
+ do_test 1.4.4.3 {
+ csql2 COMMIT
+ csql1 { SELECT count(*) FROM t2 }
+ } {0 512}
+ do_test 1.4.5 {
+ code2 { db2 close }
+ code1 { db close }
+ } {}
+}
+
+forcedelete test.db
+
+#-----------------------------------------------------------------------
+# Test cases 2.* check that a read-only connection may read the
+# database file while a checkpoint operation is ongoing.
+#
+do_multiclient_test tn {
+
+ # Close all connections and delete the database.
+ #
+ code1 { db close }
+ code2 { db2 close }
+ code3 { db3 close }
+ forcedelete test.db
+ forcedelete walro
+
+ # Do not run tests with the connections in the same process.
+ #
+ if {$tn==2} continue
+
+ foreach c {code1 code2 code3} {
+ $c {
+ sqlite3_shutdown
+ sqlite3_config_uri 1
+ }
+ }
+
+ proc tv_hook {x file args} {
+ if {[file tail $file]=="test.db-wal"} {
+ do_test 2.1.2 {
+ code2 { sqlite3 db2 file:test.db?readonly_shm=1 }
+ csql2 { SELECT count(*) FROM t2 }
+ } {0 4}
+ do_test 2.1.3 {
+ code2 { db2 close }
+ } {}
+ }
+ }
+
+ do_test 2.1.1 {
+ testvfs tv -default 1 -fullshm 1
+ tv script tv_hook
+ tv filter {}
+ code1 { sqlite3 db test.db }
+ csql1 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = WAL;
+ BEGIN;
+ CREATE TABLE t2(x, y);
+ INSERT INTO t2 VALUES('abc', 'xyz');
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ INSERT INTO t2 SELECT x||y, y||x FROM t2;
+ COMMIT;
+ }
+ } {0 wal}
+
+ tv filter xSync
+ set res [csql1 { PRAGMA wal_checkpoint }]
+ do_test 2.1.4 { set res } {0 {0 2 2}}
+
+ do_test 2.1.5 {
+ code1 { db close }
+ code1 { tv delete }
+ } {}
+}
+
+finish_test
diff --git a/test/walro2.test b/test/walro2.test
new file mode 100644
index 0000000..1eb9d1c
--- /dev/null
+++ b/test/walro2.test
@@ -0,0 +1,411 @@
+# 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
+source $testdir/wal_common.tcl
+set ::testprefix walro2
+
+# And only if the build is WAL-capable.
+#
+ifcapable !wal {
+ finish_test
+ return
+}
+
+proc copy_to_test2 {bZeroShm} {
+ forcecopy test.db test.db2
+ forcecopy test.db-wal test.db2-wal
+ if {$bZeroShm} {
+ forcedelete test.db2-shm
+ set fd [open test.db2-shm w]
+ seek $fd [expr [file size test.db-shm]-1]
+ puts -nonewline $fd "\0"
+ close $fd
+ } else {
+ forcecopy test.db-shm test.db2-shm
+ }
+}
+
+# Most systems allocate the *-shm file in 32KB trunks. But on UNIX systems
+# for which the getpagesize() call returns greater than 32K, the *-shm
+# file is allocated in page-sized units (since you cannot mmap part of
+# a page). The following code sets variable $MINSHMSZ to the smallest
+# possible *-shm file (i.e. the greater of 32KB and the system page-size).
+#
+do_execsql_test 0.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x);
+} {wal}
+set MINSHMSZ [file size test.db-shm]
+set dfltpgsz [db one {PRAGMA page_size}]
+
+foreach bZeroShm {0 1} {
+ for {set pgsz 512} {$pgsz<=65536} {set pgsz [expr {$pgsz*2}]} {
+ set TN [expr $bZeroShm+1]-$pgsz
+ do_multiclient_test tn {
+
+ # Close all connections and delete the database.
+ #
+ code1 { db close }
+ code2 { db2 close }
+ code3 { db3 close }
+ forcedelete test.db
+
+ # Do not run tests with the connections in the same process.
+ #
+ if {$tn==2} continue
+
+ foreach c {code1 code2 code3} {
+ $c {
+ sqlite3_shutdown
+ sqlite3_config_uri 1
+ }
+ }
+
+ do_test $TN.1.1 {
+ code2 { sqlite3 db2 test.db }
+ sql2 "PRAGMA page_size=$::pgsz"
+ sql2 {
+ CREATE TABLE t1(x, y);
+ PRAGMA journal_mode = WAL;
+ INSERT INTO t1 VALUES('a', 'b');
+ INSERT INTO t1 VALUES('c', 'd');
+ }
+ file exists test.db-shm
+ } {1}
+
+ do_test $TN.1.2.1 {
+ copy_to_test2 $bZeroShm
+ code1 {
+ sqlite3 db file:test.db2?readonly_shm=1
+ }
+
+ sql1 { SELECT * FROM t1 }
+ } {a b c d}
+ do_test $TN.1.2.2 {
+ sql1 { SELECT * FROM t1 }
+ } {a b c d}
+
+ do_test $TN.1.3.1 {
+ code3 { sqlite3 db3 test.db2 }
+ sql3 { SELECT * FROM t1 }
+ } {a b c d}
+
+ do_test $TN.1.3.2 {
+ sql1 { SELECT * FROM t1 }
+ } {a b c d}
+
+ code1 { db close }
+ code2 { db2 close }
+ code3 { db3 close }
+
+ do_test $TN.2.1 {
+ code2 { sqlite3 db2 test.db }
+ sql2 "PRAGMA page_size=$::pgsz;"
+ sql2 {
+ INSERT INTO t1 VALUES('e', 'f');
+ INSERT INTO t1 VALUES('g', 'h');
+ }
+ file exists test.db-shm
+ } {1}
+
+ do_test $TN.2.2 {
+ copy_to_test2 $bZeroShm
+ code1 {
+ sqlite3 db file:test.db2?readonly_shm=1
+ }
+ sql1 {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {a b c d e f g h}
+
+ do_test $TN.2.3.1 {
+ code3 { sqlite3 db3 test.db2 }
+ sql3 { SELECT * FROM t1 }
+ } {a b c d e f g h}
+ do_test $TN.2.3.2 {
+ sql3 { INSERT INTO t1 VALUES('i', 'j') }
+ code3 { db3 close }
+ sql1 { COMMIT }
+ } {}
+ do_test $TN.2.3.3 {
+ sql1 { SELECT * FROM t1 }
+ } {a b c d e f g h i j}
+
+
+ #-----------------------------------------------------------------------
+ # 3.1.*: That a readonly_shm connection can read a database file if both
+ # the *-wal and *-shm files are zero bytes in size.
+ #
+ # 3.2.*: That it flushes the cache if, between transactions on a db with a
+ # zero byte *-wal file, some other connection modifies the db, then
+ # does "PRAGMA wal_checkpoint=truncate" to truncate the wal file
+ # back to zero bytes in size.
+ #
+ # 3.3.*: That, if between transactions some other process wraps the wal
+ # file, the readonly_shm client reruns recovery.
+ #
+ catch { code1 { db close } }
+ catch { code2 { db2 close } }
+ catch { code3 { db3 close } }
+ do_test $TN.3.1.0 {
+ list [file exists test.db-wal] [file exists test.db-shm]
+ } {0 0}
+ do_test $TN.3.1.1 {
+ close [open test.db-wal w]
+ close [open test.db-shm w]
+ code1 {
+ sqlite3 db file:test.db?readonly_shm=1
+ }
+ sql1 { SELECT * FROM t1 }
+ } {a b c d e f g h}
+
+ do_test $TN.3.2.0 {
+ list [file size test.db-wal] [file size test.db-shm]
+ } {0 0}
+ do_test $TN.3.2.1 {
+ code2 { sqlite3 db2 test.db }
+ sql2 { INSERT INTO t1 VALUES(1, 2) ; PRAGMA wal_checkpoint=truncate }
+ code2 { db2 close }
+ sql1 { SELECT * FROM t1 }
+ } {a b c d e f g h 1 2}
+ if {$pgsz!=$dfltpgsz} continue
+ do_test $TN.3.2.2 {
+ list [file size test.db-wal] [file size test.db-shm]
+ } [list 0 $MINSHMSZ]
+ do_test $TN.3.3.0 {
+ code2 { sqlite3 db2 test.db }
+ sql2 {
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ INSERT INTO t1 VALUES(7, 8);
+ INSERT INTO t1 VALUES(9, 10);
+ }
+ code2 { db2 close }
+ code1 { db close }
+ list [file size test.db-wal] [file size test.db-shm]
+ } [list [wal_file_size 4 1024] $MINSHMSZ]
+ do_test $TN.3.3.1 {
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ sql1 { SELECT * FROM t1 }
+ } {a b c d e f g h 1 2 3 4 5 6 7 8 9 10}
+ do_test $TN.3.3.2 {
+ code2 { sqlite3 db2 test.db }
+ sql2 {
+ PRAGMA wal_checkpoint;
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES('i', 'ii');
+ }
+ code2 { db2 close }
+ list [file size test.db-wal] [file size test.db-shm]
+ } [list [wal_file_size 4 1024] $MINSHMSZ]
+ do_test $TN.3.3.3 {
+ sql1 { SELECT * FROM t1 }
+ } {i ii}
+
+ #-----------------------------------------------------------------------
+ #
+ #
+ catch { code1 { db close } }
+ catch { code2 { db2 close } }
+ catch { code3 { db3 close } }
+
+ do_test $TN.4.0 {
+ code1 { forcedelete test.db }
+ code1 { sqlite3 db test.db }
+ sql1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t1 VALUES('world');
+ }
+
+ copy_to_test2 $bZeroShm
+
+ code1 { db close }
+ } {}
+
+ do_test $TN.4.1.1 {
+ code2 { sqlite3 db2 file:test.db2?readonly_shm=1 }
+ sql2 { SELECT * FROM t1 }
+ } {hello world}
+
+ do_test $TN.4.1.2 {
+ code3 { sqlite3 db3 test.db2 }
+ sql3 {
+ INSERT INTO t1 VALUES('!');
+ PRAGMA wal_checkpoint = truncate;
+ }
+ code3 { db3 close }
+ } {}
+ do_test $TN.4.1.3 {
+ sql2 { SELECT * FROM t1 }
+ } {hello world !}
+
+ catch { code1 { db close } }
+ catch { code2 { db2 close } }
+ catch { code3 { db3 close } }
+
+ do_test $TN.4.2.1 {
+ code1 { sqlite3 db test.db }
+ sql1 {
+ INSERT INTO t1 VALUES('!');
+ INSERT INTO t1 VALUES('!');
+
+ PRAGMA cache_size = 10;
+ CREATE TABLE t2(x);
+
+ BEGIN;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500
+ )
+ INSERT INTO t2 SELECT randomblob(500) FROM s;
+ SELECT count(*) FROM t2;
+ }
+ } {500}
+ set sz [file size test.db-wal]
+ do_test $TN.4.2.2.(sz=$sz) {
+ expr {$sz>400000}
+ } {1}
+ do_test $TN.4.2.4 {
+ file_control_persist_wal db 1; db close
+
+ copy_to_test2 $bZeroShm
+ code2 { sqlite3 db2 file:test.db2?readonly_shm=1 }
+ sql2 {
+ SELECT * FROM t1;
+ SELECT count(*) FROM t2;
+ }
+ } {hello world ! ! 0}
+
+ #-----------------------------------------------------------------------
+ #
+ #
+ catch { code1 { db close } }
+ catch { code2 { db2 close } }
+ catch { code3 { db3 close } }
+
+ do_test $TN.5.0 {
+ code1 { forcedelete test.db }
+ code1 { sqlite3 db test.db }
+ sql1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t1 VALUES('world');
+ INSERT INTO t1 VALUES('!');
+ INSERT INTO t1 VALUES('world');
+ INSERT INTO t1 VALUES('hello');
+ }
+
+ copy_to_test2 $bZeroShm
+
+ code1 { db close }
+ } {}
+
+ do_test $TN.5.1 {
+ code2 { sqlite3 db2 file:test.db2?readonly_shm=1 }
+ sql2 {
+ SELECT * FROM t1;
+ }
+ } {hello world ! world hello}
+
+ do_test $TN.5.2 {
+ code1 {
+ proc handle_read {op args} {
+ if {$op=="xRead" && [file tail [lindex $args 0]]=="test.db2-wal"} {
+ set ::res2 [sql2 { SELECT * FROM t1 }]
+ }
+ puts "$msg xRead $args"
+ return "SQLITE_OK"
+ }
+ testvfs tvfs -fullshm 1
+
+ sqlite3 db file:test.db2?vfs=tvfs
+ db eval { SELECT * FROM sqlite_master }
+
+ tvfs filter xRead
+ tvfs script handle_read
+ }
+ sql1 {
+ PRAGMA wal_checkpoint = truncate;
+ }
+ code1 { set ::res2 }
+ } {hello world ! world hello}
+
+ do_test $TN.5.3 {
+ code1 { db close }
+ code1 { tvfs delete }
+ } {}
+
+ #-----------------------------------------------------------------------
+ #
+ #
+ catch { code1 { db close } }
+ catch { code2 { db2 close } }
+ catch { code3 { db3 close } }
+
+ do_test $TN.6.1 {
+ code1 { forcedelete test.db }
+ code1 { sqlite3 db test.db }
+ sql1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t1 VALUES('world');
+ INSERT INTO t1 VALUES('!');
+ INSERT INTO t1 VALUES('world');
+ INSERT INTO t1 VALUES('hello');
+ }
+
+ copy_to_test2 $bZeroShm
+
+ code1 { db close }
+ } {}
+
+ do_test $TN.6.2 {
+ code1 {
+ set ::nRem 5
+ proc handle_read {op args} {
+ if {$op=="xRead" && [file tail [lindex $args 0]]=="test.db2-wal"} {
+ incr ::nRem -1
+ if {$::nRem==0} {
+ code2 { sqlite3 db2 test.db2 }
+ sql2 { PRAGMA wal_checkpoint = truncate }
+ }
+ }
+ return "SQLITE_OK"
+ }
+ testvfs tvfs -fullshm 1
+
+ tvfs filter xRead
+ tvfs script handle_read
+
+ sqlite3 db file:test.db2?readonly_shm=1&vfs=tvfs
+ db eval { SELECT * FROM t1 }
+ }
+ } {hello world ! world hello}
+
+ do_test $TN.6.3 {
+ code1 { db close }
+ code1 { tvfs delete }
+ } {}
+ }
+ } ;# for pgsz
+} ;# foreach bZeroShm
+
+finish_test
diff --git a/test/walrofault.test b/test/walrofault.test
new file mode 100644
index 0000000..3e66e2d
--- /dev/null
+++ b/test/walrofault.test
@@ -0,0 +1,60 @@
+# 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/malloc_common.tcl
+set ::testprefix walro2
+
+# And only if the build is WAL-capable.
+#
+ifcapable !wal {
+ finish_test
+ return
+}
+
+db close
+sqlite3_shutdown
+sqlite3_config_uri 1
+sqlite3 db test.db
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(b);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES('hello');
+ INSERT INTO t1 VALUES('world');
+ INSERT INTO t1 VALUES('!');
+ INSERT INTO t1 VALUES('world');
+ INSERT INTO t1 VALUES('hello');
+ PRAGMA cache_size = 10;
+ BEGIN;
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<30 )
+ INSERT INTO t1(b) SELECT randomblob(800) FROM s;
+} {wal}
+file_control_persist_wal db 1; db close
+faultsim_save_and_close
+
+do_faultsim_test 1 -faults oom* -prep {
+ catch { db close }
+ faultsim_restore
+ sqlite3 db file:test.db?readonly_shm=1
+} -body {
+ execsql { SELECT * FROM t1 }
+} -test {
+ faultsim_test_result {0 {hello world ! world hello}}
+}
+
+
+
+finish_test
diff --git a/test/walsetlk.test b/test/walsetlk.test
new file mode 100644
index 0000000..1e09238
--- /dev/null
+++ b/test/walsetlk.test
@@ -0,0 +1,199 @@
+# 2020 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.
+#
+#***********************************************************************
+#
+# TESTRUNNER: slow
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+set testprefix walsetlk
+
+ifcapable !wal {finish_test ; return }
+db timeout 1000
+
+#-------------------------------------------------------------------------
+# 1.*: Test that nothing goes wrong if recovery is forced while opening
+# a write transaction or performing a checkpoint with blocking locks.
+#
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ INSERT INTO t1 VALUES(7, 8);
+} {wal}
+
+sqlite3 db2 test.db
+db2 timeout 1000
+
+do_execsql_test -db db2 1.1 {
+ SELECT * FROM t1
+} {1 2 3 4 5 6 7 8}
+
+set fd [open test.db-shm r+]
+puts $fd "blahblahblahblah"
+flush $fd
+
+do_execsql_test 1.2 {
+ BEGIN;
+ INSERT INTO t1 VALUES(9, 10);
+}
+
+do_execsql_test -db db2 1.3 {
+ SELECT * FROM t1
+} {1 2 3 4 5 6 7 8}
+
+do_test 1.4 {
+ list [catch {db2 eval { BEGIN EXCLUSIVE }} msg] $msg
+} {1 {database is locked}}
+
+do_execsql_test 1.5 { COMMIT }
+do_execsql_test -db db2 1.6 {
+ SELECT * FROM t1
+} {1 2 3 4 5 6 7 8 9 10}
+
+puts $fd "blahblahblahblah"
+flush $fd
+
+do_execsql_test -db db2 1.7 {
+ PRAGMA wal_checkpoint = TRUNCATE
+} {0 0 0}
+
+do_test 1.8 {
+ file size test.db-wal
+} 0
+
+close $fd
+db close
+db2 close
+#-------------------------------------------------------------------------
+
+do_multiclient_test tn {
+ do_test 2.$tn.1 {
+ sql1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(s, v);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t1 VALUES(5, 6);
+ }
+ code1 { db timeout 1100 }
+ } {}
+
+ do_test 2.$tn.2 {
+ sql2 {
+ BEGIN;
+ INSERT INTO t1 VALUES(7, 8);
+ }
+ } {}
+
+ do_test 2.$tn.3 {
+ set us [lindex [time { catch {db eval "BEGIN EXCLUSIVE"} }] 0]
+ expr $us>1000000 && $us<4000000
+ } {1}
+
+ do_test 2.$tn.4 {
+ sql2 { COMMIT }
+ sql1 { SELECT * FROM t1 }
+ } {1 2 3 4 5 6 7 8}
+
+ do_test 2.$tn.5 {
+ sql2 {
+ BEGIN;
+ INSERT INTO t1 VALUES(9, 10);
+ }
+ } {}
+
+ do_test 2.$tn.6 {
+ set us [lindex [time { catch {db eval "PRAGMA wal_checkpoint=RESTART"} }] 0]
+ expr $us>1000000 && $us<4000000
+ } {1}
+
+ do_test 2.$tn.7 {
+ sql2 {
+ COMMIT;
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ } {1 2 3 4 5 6 7 8 9 10}
+
+ do_test 2.$tn.8 {
+ set us [lindex [time { catch {db eval "PRAGMA wal_checkpoint=RESTART"} }] 0]
+ expr $us>1000000 && $us<4000000
+ } {1}
+
+ do_test 2.$tn.9 {
+ sql3 {
+ INSERT INTO t1 VALUES(11, 12);
+ }
+ sql2 {
+ COMMIT;
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ sql3 {
+ INSERT INTO t1 VALUES(13, 14);
+ }
+ } {}
+
+ do_test 2.$tn.10 {
+ set us [lindex [time { catch {db eval "PRAGMA wal_checkpoint=RESTART"} }] 0]
+ expr $us>1000000 && $us<4000000
+ } {1}
+
+ do_test 2.$tn.11 {
+ sql3 {
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ sql1 { INSERT INTO t1 VALUES(15, 16); }
+ } {}
+
+ do_test 2.$tn.12 {
+ set us [lindex [time { catch {db eval "PRAGMA wal_checkpoint=RESTART"} }] 0]
+ expr $us>1000000 && $us<4000000
+ } {1}
+
+ do_test 2.$tn.13 {
+ sql2 {
+ COMMIT;
+ BEGIN;
+ SELECT * FROM t1;
+ }
+ sql1 { INSERT INTO t1 VALUES(17, 18); }
+ } {}
+
+ do_test 2.$tn.14 {
+ set us [lindex [time { catch {db eval "PRAGMA wal_checkpoint=RESTART"} }] 0]
+ expr $us>1000000 && $us<4000000
+ } {1}
+
+}
+
+#-------------------------------------------------------------------------
+reset_db
+sqlite3 db2 test.db
+db2 timeout 1000
+do_execsql_test 3.0 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE x1(x, y);
+ BEGIN;
+ INSERT INTO x1 VALUES(1, 2);
+} {wal}
+
+do_test 3.1 {
+ list [catch { db2 eval {BEGIN EXCLUSIVE} } msg] $msg
+} {1 {database is locked}}
+
+finish_test
diff --git a/test/walshared.test b/test/walshared.test
new file mode 100644
index 0000000..ccac948
--- /dev/null
+++ b/test/walshared.test
@@ -0,0 +1,62 @@
+# 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||!shared_cache {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..2a52a22
--- /dev/null
+++ b/test/walslow.test
@@ -0,0 +1,231 @@
+# 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
+source $testdir/wal_common.tcl
+source $testdir/lock_common.tcl
+
+ifcapable !wal {finish_test ; return }
+
+set testprefix walslow
+
+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
+ }
+}
+
+#-------------------------------------------------------------------------
+# Test case walslow-3.* tests that the checksum calculation detects single
+# byte changes to frame or frame-header data and considers the frame
+# invalid as a result.
+#
+reset_db
+do_test 3.1 {
+
+ 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 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 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}
+}
+
+
+#-------------------------------------------------------------------------
+# 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.
+#
+# 4.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.
+#
+# 4.2.*: Test that a process may create a large log file and query
+# the database (including the log file that it itself created).
+#
+# 4.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.
+#
+# 4.4.*: Same test as wal-13.3.*. Except in this case the second
+# connection is opened by an external process.
+#
+set ::blobcnt 0
+proc blob {nByte} {
+ incr ::blobcnt
+ return [string range [string repeat "${::blobcnt}x" $nByte] 1 $nByte]
+}
+
+reset_db
+do_execsql_test 4.1 {
+ PRAGMA journal_mode = wal;
+ CREATE TABLE t1(x, y);
+ INSERT INTO "t1" VALUES('A',0);
+ CREATE TABLE t2(x, y);
+ INSERT INTO "t2" VALUES('B',2);
+} {wal}
+db close
+
+do_test 4.1.1 {
+ list [file exists test.db] [file exists test.db-wal]
+} {1 0}
+do_test 4.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}
+do_test 4.1.3 {
+ db close
+ file exists test.db-wal
+} {0}
+
+do_test 4.2.1 {
+ sqlite3 db test.db
+ execsql { SELECT count(*) FROM t2 }
+} {1}
+do_test 4.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 4.2.3 {
+ expr [file size test.db-wal] > [wal_file_size 33000 1024]
+} 1
+
+do_multiclient_test tn {
+ incr tn 2
+
+ do_test 4.$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 4.$tn.$ii.a {
+ sql2 { INSERT INTO t1 SELECT randomblob(800) FROM t1 }
+ sql2 { SELECT count(*) FROM t1 }
+ } [expr (1<<$ii)]
+ do_test 4.$tn.$ii.b {
+ sql1 { SELECT count(*) FROM t1 }
+ } [expr (1<<$ii)]
+ do_test 4.$tn.$ii.c {
+ sql1 { SELECT count(*) FROM t1 }
+ } [expr (1<<$ii)]
+ do_test 4.$tn.$ii.d {
+ sql1 { PRAGMA integrity_check }
+ } {ok}
+ }
+}
+
+finish_test
diff --git a/test/walthread.test b/test/walthread.test
new file mode 100644
index 0000000..8e5df9e
--- /dev/null
+++ b/test/walthread.test
@@ -0,0 +1,529 @@
+# 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(101 + $::E(pid)));
+ INSERT INTO t1 VALUES(randomblob(101 + $::E(pid)));
+ 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".
+#
+if {[atomic_batch_write test.db]==0} {
+ 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/walvfs.test b/test/walvfs.test
new file mode 100644
index 0000000..d32cbd7
--- /dev/null
+++ b/test/walvfs.test
@@ -0,0 +1,437 @@
+# 2018 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 operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+# TESTRUNNER: slow
+
+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 walvfs
+
+ifcapable !wal {finish_test ; return }
+
+db close
+testvfs tvfs
+tvfs script xSync
+tvfs filter xSync
+set ::sync_count 0
+proc xSync {method file args} {
+ if {[file tail $file]=="test.db-wal"} {
+ incr ::sync_count
+ }
+}
+
+
+#-------------------------------------------------------------------------
+# Test that if IOCAP_SEQUENTIAL is set, the wal-header is not synced to
+# disk immediately after it is written.
+#
+sqlite3 db test.db -vfs tvfs
+do_execsql_test 1.0 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = wal;
+ PRAGMA synchronous = normal;
+ 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);
+ PRAGMA wal_checkpoint;
+} {wal 0 5 5}
+
+set ::sync_count 0
+do_test 1.1 {
+ execsql { INSERT INTO t1 VALUES(10, 11, 12) }
+ set ::sync_count
+} 1
+
+db close
+tvfs devchar sequential
+sqlite3 db test.db -vfs tvfs
+do_execsql_test 1.2 {
+ PRAGMA synchronous = normal;
+ INSERT INTO t1 VALUES(13, 14, 15);
+ INSERT INTO t1 VALUES(16, 17, 18);
+ PRAGMA wal_checkpoint;
+} {0 4 4}
+
+set ::sync_count 0
+do_test 1.3 {
+ execsql { INSERT INTO t1 VALUES(10, 11, 12) }
+ set ::sync_count
+} 0
+
+#-------------------------------------------------------------------------
+# Test that "PRAGMA journal_size_limit" works in wal mode.
+#
+reset_db
+do_execsql_test 2.0 {
+ PRAGMA journal_size_limit = 10000;
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
+ )
+ INSERT INTO t1 SELECT randomblob(750) FROM s;
+} {10000 wal}
+do_test 2.1 {
+ expr [file size test.db-wal]>12000
+} {1}
+do_test 2.2 {
+ execsql {
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES(randomblob(750));
+ }
+ file size test.db-wal
+} {10000}
+do_test 2.3 {
+ execsql {
+ PRAGMA journal_size_limit = 8000;
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES(randomblob(750));
+ }
+ file size test.db-wal
+} {8000}
+
+#-------------------------------------------------------------------------
+# Test that a checkpoint may be interrupted using sqlite3_interrupt().
+# And that the error code is SQLITE_NOMEM, not SQLITE_INTERRUPT, if
+# an OOM error occurs just before the sqlite3_interrupt() call.
+#
+reset_db
+db close
+sqlite3 db test.db -vfs tvfs
+tvfs filter {}
+
+do_execsql_test 3.0 {
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
+ )
+ INSERT INTO t1 SELECT randomblob(750) FROM s;
+} {wal}
+
+tvfs filter xWrite
+tvfs script xWrite
+set ::cnt 2
+proc xWrite {method file args} {
+ if {[file tail $file]=="test.db"} {
+ incr ::cnt -1
+ if {$::cnt==0} {
+ sqlite3_interrupt db
+ }
+ }
+ return SQLITE_OK
+}
+
+do_catchsql_test 3.1 {
+ PRAGMA wal_checkpoint
+} {1 interrupted}
+
+set ::cnt 2
+proc xWrite {method file args} {
+ if {[file tail $file]=="test.db"} {
+ incr ::cnt -1
+ if {$::cnt==0} {
+ sqlite3_memdebug_fail 1 -repeat 0
+ # For this test to pass, the following statement must call malloc() at
+ # least once. Even if the lookaside is enabled.
+ set ::xwrite_stmt_res [catchsql { SELECT hex(randomblob(4000)) }]
+ sqlite3_interrupt db
+ }
+ }
+ return SQLITE_OK
+}
+
+set ::xwrite_stmt_res ""
+do_catchsql_test 3.2 {
+ PRAGMA wal_checkpoint
+} {1 {out of memory}}
+do_test 3.2.2 {
+ set ::xwrite_stmt_res
+} {1 {out of memory}}
+unset ::xwrite_stmt_res
+
+#-------------------------------------------------------------------------
+#
+reset_db
+db close
+do_test 4.0 {
+ sqlite3 db test.db -vfs tvfs
+ execsql {
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
+ )
+ INSERT INTO t1 SELECT randomblob(750) FROM s;
+ } db
+} {wal}
+db close
+
+tvfs filter xShmMap
+tvfs script xShmMap
+proc xShmMap {method file args} {
+ return SQLITE_READONLY
+}
+sqlite3 db test.db -vfs tvfs
+do_catchsql_test 4.1 {
+ SELECT count(*) FROM t1
+} {1 {attempt to write a readonly database}}
+
+set ::cnt 5
+tvfs filter {xShmMap xShmLock}
+proc xShmMap {method file name args} {
+ switch -- $method {
+ xShmMap { return SQLITE_READONLY }
+ xShmLock {
+ if {$args == "{0 1 lock shared}"} {
+ incr ::cnt -1
+ if {$::cnt>0} { return SQLITE_BUSY }
+ }
+ }
+ }
+ return SQLITE_OK
+}
+do_catchsql_test 4.2 {
+ SELECT count(*) FROM t1
+} {1 {attempt to write a readonly database}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+db close
+sqlite3 db test.db -vfs tvfs
+tvfs filter {}
+do_execsql_test 5.0 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
+ )
+ INSERT INTO t1 SELECT randomblob(750) FROM s;
+} {wal}
+
+do_execsql_test 5.1 {
+ SELECT count(*) FROM t1
+} {20}
+
+do_test 5.2 {
+ vfs_set_readmark db main 1 100
+ vfs_set_readmark db main 2 100
+ vfs_set_readmark db main 3 100
+ vfs_set_readmark db main 4 100
+} {100}
+
+do_execsql_test 5.3 {
+ SELECT count(*) FROM t1
+} {20}
+
+do_test 5.3 {
+ list [vfs_set_readmark db main 1] \
+ [vfs_set_readmark db main 2] \
+ [vfs_set_readmark db main 3] \
+ [vfs_set_readmark db main 4]
+} {24 100 100 100}
+
+tvfs script xShmLock
+tvfs filter xShmLock
+set ::cnt 20
+proc xShmLock {args} {
+ incr ::cnt -1
+ if {$::cnt>0} { return SQLITE_BUSY }
+ return SQLITE_OK
+}
+
+do_test 5.4 {
+ vfs_set_readmark db main 1 100
+ execsql { SELECT count(*) FROM t1 }
+} {20}
+
+vfs_set_readmark db main 1 100
+vfs_set_readmark db main 2 100
+vfs_set_readmark db main 3 100
+vfs_set_readmark db main 4 100
+
+tvfs script xShmMapLock
+tvfs filter {xShmLock xShmMap}
+proc xShmMapLock {method args} {
+ if {$method=="xShmMap"} {
+ return "SQLITE_READONLY"
+ }
+ return SQLITE_BUSY
+}
+
+sqlite3 db2 test.db -vfs tvfs
+breakpoint
+do_test 5.5 {
+ list [catch { execsql { SELECT count(*) FROM t1 } db2 } msg] $msg
+} {1 {attempt to write a readonly database}}
+
+tvfs filter {}
+vfs_set_readmark db main 1 1
+
+do_test 5.6 {
+ list [catch { execsql { SELECT count(*) FROM t1 } db2 } msg] $msg
+} {0 20}
+db2 close
+db close
+
+#-------------------------------------------------------------------------
+# Cause an SQLITE_PROTOCOL while attempting to restart the wal file.
+#
+reset_db
+tvfs filter {}
+db close
+sqlite3 db test.db -vfs tvfs
+do_execsql_test 6.0 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
+ )
+ INSERT INTO t1 SELECT randomblob(750) FROM s;
+} {wal}
+
+do_test 6.1 {
+ execsql { PRAGMA wal_checkpoint }
+ set {} {}
+} {}
+
+tvfs filter xShmLock
+tvfs script xShmLock
+set ::flag 0
+proc xShmLock {method file handle spec} {
+ if {$::flag && [lrange $spec 2 end]=="lock shared"} {
+ return SQLITE_BUSY
+ }
+ if {$spec=="3 1 unlock shared"} {
+ set ::flag 1
+ }
+ return SQLITE_OK
+}
+
+puts "# WARNING: This next test takes around 12 seconds"
+do_catchsql_test 6.2 {
+ INSERT INTO t1 VALUES(1);
+} {1 {locking protocol}}
+
+#-------------------------------------------------------------------------
+# Check that a checkpoint fails if it cannot get the CHECKPOINTER lock
+#
+reset_db
+tvfs filter {}
+db close
+sqlite3 db test.db -vfs tvfs
+do_execsql_test 7.0 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
+ )
+ INSERT INTO t1 SELECT randomblob(750) FROM s;
+} {wal}
+
+tvfs script xShmLock
+tvfs filter xShmLock
+proc xShmLock {method file handle spec} {
+ if {$spec=="1 1 lock exclusive"} {
+ return SQLITE_BUSY
+ }
+ return SQLITE_OK
+}
+
+do_execsql_test 7.1 {
+ PRAGMA wal_checkpoint
+} {1 -1 -1}
+
+#-------------------------------------------------------------------------
+# Check that the page cache is correctly flushed if a checkpointer using
+# a version 2 VFS makes a checkpoint with an out-of-date cache.
+#
+reset_db
+testvfs tvfs2 -iversion 2
+db close
+sqlite3 db test.db -vfs tvfs2
+do_execsql_test 8.0 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20 )
+ INSERT INTO t1 SELECT randomblob(75) FROM s;
+} {wal}
+
+do_execsql_test 8.1 { SELECT count(*) FROM t1 } {20}
+
+do_test 8.2 {
+ sqlite3 db2 test.db -vfs tvfs2
+ execsql {
+ INSERT INTO t1 VALUES(randomblob(75));
+ } db2
+ db2 close
+} {}
+
+do_execsql_test 8.3 {
+ PRAGMA wal_checkpoint;
+ SELECT count(*) FROM t1
+} {0 5 5 21}
+db close
+tvfs2 delete
+
+#-------------------------------------------------------------------------
+reset_db
+db close
+sqlite3 db test.db -vfs tvfs
+do_execsql_test 9.0 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(x);
+ PRAGMA journal_mode = wal;
+ WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20 )
+ INSERT INTO t1 SELECT randomblob(75) FROM s;
+} {wal}
+
+sqlite3 db2 test.db -vfs tvfs
+tvfs filter {xShmMap xShmLock}
+tvfs script xShmMap
+proc xShmMap {method file handle args} {
+ switch -- $method {
+ xShmMap {
+ return "SQLITE_READONLY_CANTINIT"
+ }
+ xShmLock {
+ if {$args=="{3 1 lock shared}"} {
+ return "SQLITE_IOERR"
+ }
+ }
+ }
+}
+
+do_test 9.1 {
+ catchsql { SELECT count(*) FROM t1 } db2
+} {1 {disk I/O error}}
+
+db close
+db2 close
+tvfs delete
+finish_test
diff --git a/test/wapp.tcl b/test/wapp.tcl
new file mode 100644
index 0000000..53c21e8
--- /dev/null
+++ b/test/wapp.tcl
@@ -0,0 +1,987 @@
+# Copyright (c) 2017 D. Richard Hipp
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the Simplified BSD License (also
+# known as the "2-Clause License" or "FreeBSD License".)
+#
+# This program is distributed in the hope that it will be useful,
+# but without any warranty; without even the implied warranty of
+# merchantability or fitness for a particular purpose.
+#
+#---------------------------------------------------------------------------
+#
+# Design rules:
+#
+# (1) All identifiers in the global namespace begin with "wapp"
+#
+# (2) Indentifiers intended for internal use only begin with "wappInt"
+#
+package require Tcl 8.6
+
+# Add text to the end of the HTTP reply. No interpretation or transformation
+# of the text is performs. The argument should be enclosed within {...}
+#
+proc wapp {txt} {
+ global wapp
+ dict append wapp .reply $txt
+}
+
+# Add text to the page under construction. Do no escaping on the text.
+#
+# Though "unsafe" in general, there are uses for this kind of thing.
+# For example, if you want to return the complete, unmodified content of
+# a file:
+#
+# set fd [open content.html rb]
+# wapp-unsafe [read $fd]
+# close $fd
+#
+# You could do the same thing using ordinary "wapp" instead of "wapp-unsafe".
+# The difference is that wapp-safety-check will complain about the misuse
+# of "wapp", but it assumes that the person who write "wapp-unsafe" understands
+# the risks.
+#
+# Though occasionally necessary, the use of this interface should be minimized.
+#
+proc wapp-unsafe {txt} {
+ global wapp
+ dict append wapp .reply $txt
+}
+
+# Add text to the end of the reply under construction. The following
+# substitutions are made:
+#
+# %html(...) Escape text for inclusion in HTML
+# %url(...) Escape text for use as a URL
+# %qp(...) Escape text for use as a URI query parameter
+# %string(...) Escape text for use within a JSON string
+# %unsafe(...) No transformations of the text
+#
+# The substitutions above terminate at the first ")" character. If the
+# text of the TCL string in ... contains ")" characters itself, use instead:
+#
+# %html%(...)%
+# %url%(...)%
+# %qp%(...)%
+# %string%(...)%
+# %unsafe%(...)%
+#
+# In other words, use "%(...)%" instead of "(...)" to include the TCL string
+# to substitute.
+#
+# The %unsafe substitution should be avoided whenever possible, obviously.
+# In addition to the substitutions above, the text also does backslash
+# escapes.
+#
+# The wapp-trim proc works the same as wapp-subst except that it also removes
+# whitespace from the left margin, so that the generated HTML/CSS/Javascript
+# does not appear to be indented when delivered to the client web browser.
+#
+if {$tcl_version>=8.7} {
+ proc wapp-subst {txt} {
+ global wapp
+ regsub -all -command \
+ {%(html|url|qp|string|unsafe){1,1}?(|%)\((.+)\)\2} $txt wappInt-enc txt
+ dict append wapp .reply [subst -novariables -nocommand $txt]
+ }
+ proc wapp-trim {txt} {
+ global wapp
+ regsub -all {\n\s+} [string trim $txt] \n txt
+ regsub -all -command \
+ {%(html|url|qp|string|unsafe){1,1}?(|%)\((.+)\)\2} $txt wappInt-enc txt
+ dict append wapp .reply [subst -novariables -nocommand $txt]
+ }
+ proc wappInt-enc {all mode nu1 txt} {
+ return [uplevel 2 "wappInt-enc-$mode \"$txt\""]
+ }
+} else {
+ proc wapp-subst {txt} {
+ global wapp
+ regsub -all {%(html|url|qp|string|unsafe){1,1}?(|%)\((.+)\)\2} $txt \
+ {[wappInt-enc-\1 "\3"]} txt
+ dict append wapp .reply [uplevel 1 [list subst -novariables $txt]]
+ }
+ proc wapp-trim {txt} {
+ global wapp
+ regsub -all {\n\s+} [string trim $txt] \n txt
+ regsub -all {%(html|url|qp|string|unsafe){1,1}?(|%)\((.+)\)\2} $txt \
+ {[wappInt-enc-\1 "\3"]} txt
+ dict append wapp .reply [uplevel 1 [list subst -novariables $txt]]
+ }
+}
+
+# There must be a wappInt-enc-NAME routine for each possible substitution
+# in wapp-subst. Thus there are routines for "html", "url", "qp", and "unsafe".
+#
+# wappInt-enc-html Escape text so that it is safe to use in the
+# body of an HTML document.
+#
+# wappInt-enc-url Escape text so that it is safe to pass as an
+# argument to href= and src= attributes in HTML.
+#
+# wappInt-enc-qp Escape text so that it is safe to use as the
+# value of a query parameter in a URL or in
+# post data or in a cookie.
+#
+# wappInt-enc-string Escape ", ', \, and < for using inside of a
+# javascript string literal. The < character
+# is escaped to prevent "</script>" from causing
+# problems in embedded javascript.
+#
+# wappInt-enc-unsafe Perform no encoding at all. Unsafe.
+#
+proc wappInt-enc-html {txt} {
+ return [string map {& &amp; < &lt; > &gt; \" &quot; \\ &#92;} $txt]
+}
+proc wappInt-enc-unsafe {txt} {
+ return $txt
+}
+proc wappInt-enc-url {s} {
+ if {[regsub -all {[^-{}@~?=#_.:/a-zA-Z0-9]} $s {[wappInt-%HHchar {&}]} s]} {
+ set s [subst -novar -noback $s]
+ }
+ if {[regsub -all {[{}]} $s {[wappInt-%HHchar \\&]} s]} {
+ set s [subst -novar -noback $s]
+ }
+ return $s
+}
+proc wappInt-enc-qp {s} {
+ if {[regsub -all {[^-{}_.a-zA-Z0-9]} $s {[wappInt-%HHchar {&}]} s]} {
+ set s [subst -novar -noback $s]
+ }
+ if {[regsub -all {[{}]} $s {[wappInt-%HHchar \\&]} s]} {
+ set s [subst -novar -noback $s]
+ }
+ return $s
+}
+proc wappInt-enc-string {s} {
+ return [string map {\\ \\\\ \" \\\" ' \\' < \\u003c} $s]
+}
+
+# This is a helper routine for wappInt-enc-url and wappInt-enc-qp. It returns
+# an appropriate %HH encoding for the single character c. If c is a unicode
+# character, then this routine might return multiple bytes: %HH%HH%HH
+#
+proc wappInt-%HHchar {c} {
+ if {$c==" "} {return +}
+ return [regsub -all .. [binary encode hex [encoding convertto utf-8 $c]] {%&}]
+}
+
+
+# Undo the www-url-encoded format.
+#
+# HT: This code stolen from ncgi.tcl
+#
+proc wappInt-decode-url {str} {
+ set str [string map [list + { } "\\" "\\\\" \[ \\\[ \] \\\]] $str]
+ regsub -all -- \
+ {%([Ee][A-Fa-f0-9])%([89ABab][A-Fa-f0-9])%([89ABab][A-Fa-f0-9])} \
+ $str {[encoding convertfrom utf-8 [binary decode hex \1\2\3]]} str
+ regsub -all -- \
+ {%([CDcd][A-Fa-f0-9])%([89ABab][A-Fa-f0-9])} \
+ $str {[encoding convertfrom utf-8 [binary decode hex \1\2]]} str
+ regsub -all -- {%([0-7][A-Fa-f0-9])} $str {\\u00\1} str
+ return [subst -novar $str]
+}
+
+# Reset the document back to an empty string.
+#
+proc wapp-reset {} {
+ global wapp
+ dict set wapp .reply {}
+}
+
+# Change the mime-type of the result document.
+#
+proc wapp-mimetype {x} {
+ global wapp
+ dict set wapp .mimetype $x
+}
+
+# Change the reply code.
+#
+proc wapp-reply-code {x} {
+ global wapp
+ dict set wapp .reply-code $x
+}
+
+# Set a cookie
+#
+proc wapp-set-cookie {name value} {
+ global wapp
+ dict lappend wapp .new-cookies $name $value
+}
+
+# Unset a cookie
+#
+proc wapp-clear-cookie {name} {
+ wapp-set-cookie $name {}
+}
+
+# Add extra entries to the reply header
+#
+proc wapp-reply-extra {name value} {
+ global wapp
+ dict lappend wapp .reply-extra $name $value
+}
+
+# Specifies how the web-page under construction should be cached.
+# The argument should be one of:
+#
+# no-cache
+# max-age=N (for some integer number of seconds, N)
+# private,max-age=N
+#
+proc wapp-cache-control {x} {
+ wapp-reply-extra Cache-Control $x
+}
+
+# Redirect to a different web page
+#
+proc wapp-redirect {uri} {
+ wapp-reply-code {307 Redirect}
+ wapp-reply-extra Location $uri
+}
+
+# Return the value of a wapp parameter
+#
+proc wapp-param {name {dflt {}}} {
+ global wapp
+ if {![dict exists $wapp $name]} {return $dflt}
+ return [dict get $wapp $name]
+}
+
+# Return true if a and only if the wapp parameter $name exists
+#
+proc wapp-param-exists {name} {
+ global wapp
+ return [dict exists $wapp $name]
+}
+
+# Set the value of a wapp parameter
+#
+proc wapp-set-param {name value} {
+ global wapp
+ dict set wapp $name $value
+}
+
+# Return all parameter names that match the GLOB pattern, or all
+# names if the GLOB pattern is omitted.
+#
+proc wapp-param-list {{glob {*}}} {
+ global wapp
+ return [dict keys $wapp $glob]
+}
+
+# By default, Wapp does not decode query parameters and POST parameters
+# for cross-origin requests. This is a security restriction, designed to
+# help prevent cross-site request forgery (CSRF) attacks.
+#
+# As a consequence of this restriction, URLs for sites generated by Wapp
+# that contain query parameters will not work as URLs found in other
+# websites. You cannot create a link from a second website into a Wapp
+# website if the link contains query planner, by default.
+#
+# Of course, it is sometimes desirable to allow query parameters on external
+# links. For URLs for which this is safe, the application should invoke
+# wapp-allow-xorigin-params. This procedure tells Wapp that it is safe to
+# go ahead and decode the query parameters even for cross-site requests.
+#
+# In other words, for Wapp security is the default setting. Individual pages
+# need to actively disable the cross-site request security if those pages
+# are safe for cross-site access.
+#
+proc wapp-allow-xorigin-params {} {
+ global wapp
+ if {![dict exists $wapp .qp] && ![dict get $wapp SAME_ORIGIN]} {
+ wappInt-decode-query-params
+ }
+}
+
+# Set the content-security-policy.
+#
+# The default content-security-policy is very strict: "default-src 'self'"
+# The default policy prohibits the use of in-line javascript or CSS.
+#
+# Provide an alternative CSP as the argument. Or use "off" to disable
+# the CSP completely.
+#
+proc wapp-content-security-policy {val} {
+ global wapp
+ if {$val=="off"} {
+ dict unset wapp .csp
+ } else {
+ dict set wapp .csp $val
+ }
+}
+
+# Examine the bodys of all procedures in this program looking for
+# unsafe calls to various Wapp interfaces. Return a text string
+# containing warnings. Return an empty string if all is ok.
+#
+# This routine is advisory only. It misses some constructs that are
+# dangerous and flags others that are safe.
+#
+proc wapp-safety-check {} {
+ set res {}
+ foreach p [info procs] {
+ set ln 0
+ foreach x [split [info body $p] \n] {
+ incr ln
+ if {[regexp {^[ \t]*wapp[ \t]+([^\n]+)} $x all tail]
+ && [string index $tail 0]!="\173"
+ && [regexp {[[$]} $tail]
+ } {
+ append res "$p:$ln: unsafe \"wapp\" call: \"[string trim $x]\"\n"
+ }
+ if {[regexp {^[ \t]*wapp-(subst|trim)[ \t]+[^\173]} $x all cx]} {
+ append res "$p:$ln: unsafe \"wapp-$cx\" call: \"[string trim $x]\"\n"
+ }
+ }
+ }
+ return $res
+}
+
+# Return a string that descripts the current environment. Applications
+# might find this useful for debugging.
+#
+proc wapp-debug-env {} {
+ global wapp
+ set out {}
+ foreach var [lsort [dict keys $wapp]] {
+ if {[string index $var 0]=="."} continue
+ append out "$var = [list [dict get $wapp $var]]\n"
+ }
+ append out "\[pwd\] = [list [pwd]]\n"
+ return $out
+}
+
+# Tracing function for each HTTP request. This is overridden by wapp-start
+# if tracing is enabled.
+#
+proc wappInt-trace {} {}
+
+# Start up a listening socket. Arrange to invoke wappInt-new-connection
+# for each inbound HTTP connection.
+#
+# port Listen on this TCP port. 0 means to select a port
+# that is not currently in use
+#
+# wappmode One of "scgi", "remote-scgi", "server", or "local".
+#
+# fromip If not {}, then reject all requests from IP addresses
+# other than $fromip
+#
+proc wappInt-start-listener {port wappmode fromip} {
+ if {[string match *scgi $wappmode]} {
+ set type SCGI
+ set server [list wappInt-new-connection \
+ wappInt-scgi-readable $wappmode $fromip]
+ } else {
+ set type HTTP
+ set server [list wappInt-new-connection \
+ wappInt-http-readable $wappmode $fromip]
+ }
+ if {$wappmode=="local" || $wappmode=="scgi"} {
+ set x [socket -server $server -myaddr 127.0.0.1 $port]
+ } else {
+ set x [socket -server $server $port]
+ }
+ set coninfo [chan configure $x -sockname]
+ set port [lindex $coninfo 2]
+ if {$wappmode=="local"} {
+ wappInt-start-browser http://127.0.0.1:$port/
+ } elseif {$fromip!=""} {
+ puts "Listening for $type requests on TCP port $port from IP $fromip"
+ } else {
+ puts "Listening for $type requests on TCP port $port"
+ }
+}
+
+# Start a web-browser and point it at $URL
+#
+proc wappInt-start-browser {url} {
+ global tcl_platform
+ if {$tcl_platform(platform)=="windows"} {
+ exec cmd /c start $url &
+ } elseif {$tcl_platform(os)=="Darwin"} {
+ exec open $url &
+ } elseif {[catch {exec xdg-open $url}]} {
+ exec firefox $url &
+ }
+}
+
+# This routine is a "socket -server" callback. The $chan, $ip, and $port
+# arguments are added by the socket command.
+#
+# Arrange to invoke $callback when content is available on the new socket.
+# The $callback will process inbound HTTP or SCGI content. Reject the
+# request if $fromip is not an empty string and does not match $ip.
+#
+proc wappInt-new-connection {callback wappmode fromip chan ip port} {
+ upvar #0 wappInt-$chan W
+ if {$fromip!="" && ![string match $fromip $ip]} {
+ close $chan
+ return
+ }
+ set W [dict create REMOTE_ADDR $ip REMOTE_PORT $port WAPP_MODE $wappmode \
+ .header {}]
+ fconfigure $chan -blocking 0 -translation binary
+ fileevent $chan readable [list $callback $chan]
+}
+
+# Close an input channel
+#
+proc wappInt-close-channel {chan} {
+ if {$chan=="stdout"} {
+ # This happens after completing a CGI request
+ exit 0
+ } else {
+ unset ::wappInt-$chan
+ close $chan
+ }
+}
+
+# Process new text received on an inbound HTTP request
+#
+proc wappInt-http-readable {chan} {
+ if {[catch [list wappInt-http-readable-unsafe $chan] msg]} {
+ puts stderr "$msg\n$::errorInfo"
+ wappInt-close-channel $chan
+ }
+}
+proc wappInt-http-readable-unsafe {chan} {
+ upvar #0 wappInt-$chan W wapp wapp
+ if {![dict exists $W .toread]} {
+ # If the .toread key is not set, that means we are still reading
+ # the header
+ set line [string trimright [gets $chan]]
+ set n [string length $line]
+ if {$n>0} {
+ if {[dict get $W .header]=="" || [regexp {^\s+} $line]} {
+ dict append W .header $line
+ } else {
+ dict append W .header \n$line
+ }
+ if {[string length [dict get $W .header]]>100000} {
+ error "HTTP request header too big - possible DOS attack"
+ }
+ } elseif {$n==0} {
+ # We have reached the blank line that terminates the header.
+ global argv0
+ set a0 [file normalize $argv0]
+ dict set W SCRIPT_FILENAME $a0
+ dict set W DOCUMENT_ROOT [file dir $a0]
+ if {[wappInt-parse-header $chan]} {
+ catch {close $chan}
+ return
+ }
+ set len 0
+ if {[dict exists $W CONTENT_LENGTH]} {
+ set len [dict get $W CONTENT_LENGTH]
+ }
+ if {$len>0} {
+ # Still need to read the query content
+ dict set W .toread $len
+ } else {
+ # There is no query content, so handle the request immediately
+ set wapp $W
+ wappInt-handle-request $chan 0
+ }
+ }
+ } else {
+ # If .toread is set, that means we are reading the query content.
+ # Continue reading until .toread reaches zero.
+ set got [read $chan [dict get $W .toread]]
+ dict append W CONTENT $got
+ dict set W .toread [expr {[dict get $W .toread]-[string length $got]}]
+ if {[dict get $W .toread]<=0} {
+ # Handle the request as soon as all the query content is received
+ set wapp $W
+ wappInt-handle-request $chan 0
+ }
+ }
+}
+
+# Decode the HTTP request header.
+#
+# This routine is always running inside of a [catch], so if
+# any problems arise, simply raise an error.
+#
+proc wappInt-parse-header {chan} {
+ upvar #0 wappInt-$chan W
+ set hdr [split [dict get $W .header] \n]
+ if {$hdr==""} {return 1}
+ set req [lindex $hdr 0]
+ dict set W REQUEST_METHOD [set method [lindex $req 0]]
+ if {[lsearch {GET HEAD POST} $method]<0} {
+ error "unsupported request method: \"[dict get $W REQUEST_METHOD]\""
+ }
+ set uri [lindex $req 1]
+ set split_uri [split $uri ?]
+ set uri0 [lindex $split_uri 0]
+ if {![regexp {^/[-.a-z0-9_/]*$} $uri0]} {
+ error "invalid request uri: \"$uri0\""
+ }
+ dict set W REQUEST_URI $uri0
+ dict set W PATH_INFO $uri0
+ set uri1 [lindex $split_uri 1]
+ dict set W QUERY_STRING $uri1
+ set n [llength $hdr]
+ for {set i 1} {$i<$n} {incr i} {
+ set x [lindex $hdr $i]
+ if {![regexp {^(.+): +(.*)$} $x all name value]} {
+ error "invalid header line: \"$x\""
+ }
+ set name [string toupper $name]
+ switch -- $name {
+ REFERER {set name HTTP_REFERER}
+ USER-AGENT {set name HTTP_USER_AGENT}
+ CONTENT-LENGTH {set name CONTENT_LENGTH}
+ CONTENT-TYPE {set name CONTENT_TYPE}
+ HOST {set name HTTP_HOST}
+ COOKIE {set name HTTP_COOKIE}
+ ACCEPT-ENCODING {set name HTTP_ACCEPT_ENCODING}
+ default {set name .hdr:$name}
+ }
+ dict set W $name $value
+ }
+ return 0
+}
+
+# Decode the QUERY_STRING parameters from a GET request or the
+# application/x-www-form-urlencoded CONTENT from a POST request.
+#
+# This routine sets the ".qp" element of the ::wapp dict as a signal
+# that query parameters have already been decoded.
+#
+proc wappInt-decode-query-params {} {
+ global wapp
+ dict set wapp .qp 1
+ if {[dict exists $wapp QUERY_STRING]} {
+ foreach qterm [split [dict get $wapp QUERY_STRING] &] {
+ set qsplit [split $qterm =]
+ set nm [lindex $qsplit 0]
+ if {[regexp {^[a-z][a-z0-9]*$} $nm]} {
+ dict set wapp $nm [wappInt-decode-url [lindex $qsplit 1]]
+ }
+ }
+ }
+ if {[dict exists $wapp CONTENT_TYPE] && [dict exists $wapp CONTENT]} {
+ set ctype [dict get $wapp CONTENT_TYPE]
+ if {$ctype=="application/x-www-form-urlencoded"} {
+ foreach qterm [split [string trim [dict get $wapp CONTENT]] &] {
+ set qsplit [split $qterm =]
+ set nm [lindex $qsplit 0]
+ if {[regexp {^[a-z][-a-z0-9_]*$} $nm]} {
+ dict set wapp $nm [wappInt-decode-url [lindex $qsplit 1]]
+ }
+ }
+ } elseif {[string match multipart/form-data* $ctype]} {
+ regexp {^(.*?)\r\n(.*)$} [dict get $wapp CONTENT] all divider body
+ set ndiv [string length $divider]
+ while {[string length $body]} {
+ set idx [string first $divider $body]
+ set unit [string range $body 0 [expr {$idx-3}]]
+ set body [string range $body [expr {$idx+$ndiv+2}] end]
+ if {[regexp {^Content-Disposition: form-data; (.*?)\r\n\r\n(.*)$} \
+ $unit unit hdr content]} {
+ if {[regexp {name="(.*)"; filename="(.*)"\r\nContent-Type: (.*?)$}\
+ $hdr hr name filename mimetype]} {
+ dict set wapp $name.filename \
+ [string map [list \\\" \" \\\\ \\] $filename]
+ dict set wapp $name.mimetype $mimetype
+ dict set wapp $name.content $content
+ } elseif {[regexp {name="(.*)"} $hdr hr name]} {
+ dict set wapp $name $content
+ }
+ }
+ }
+ }
+ }
+}
+
+# Invoke application-supplied methods to generate a reply to
+# a single HTTP request.
+#
+# This routine always runs within [catch], so handle exceptions by
+# invoking [error].
+#
+proc wappInt-handle-request {chan useCgi} {
+ global wapp
+ dict set wapp .reply {}
+ dict set wapp .mimetype {text/html; charset=utf-8}
+ dict set wapp .reply-code {200 Ok}
+ dict set wapp .csp {default-src 'self'}
+
+ # Set up additional CGI environment values
+ #
+ if {![dict exists $wapp HTTP_HOST]} {
+ dict set wapp BASE_URL {}
+ } elseif {[dict exists $wapp HTTPS]} {
+ dict set wapp BASE_URL https://[dict get $wapp HTTP_HOST]
+ } else {
+ dict set wapp BASE_URL http://[dict get $wapp HTTP_HOST]
+ }
+ if {![dict exists $wapp REQUEST_URI]} {
+ dict set wapp REQUEST_URI /
+ } elseif {[regsub {\?.*} [dict get $wapp REQUEST_URI] {} newR]} {
+ # Some servers (ex: nginx) append the query parameters to REQUEST_URI.
+ # These need to be stripped off
+ dict set wapp REQUEST_URI $newR
+ }
+ if {[dict exists $wapp SCRIPT_NAME]} {
+ dict append wapp BASE_URL [dict get $wapp SCRIPT_NAME]
+ } else {
+ dict set wapp SCRIPT_NAME {}
+ }
+ if {![dict exists $wapp PATH_INFO]} {
+ # If PATH_INFO is missing (ex: nginx) then construct it
+ set URI [dict get $wapp REQUEST_URI]
+ set skip [string length [dict get $wapp SCRIPT_NAME]]
+ dict set wapp PATH_INFO [string range $URI $skip end]
+ }
+ if {[regexp {^/([^/]+)(.*)$} [dict get $wapp PATH_INFO] all head tail]} {
+ dict set wapp PATH_HEAD $head
+ dict set wapp PATH_TAIL [string trimleft $tail /]
+ } else {
+ dict set wapp PATH_INFO {}
+ dict set wapp PATH_HEAD {}
+ dict set wapp PATH_TAIL {}
+ }
+ dict set wapp SELF_URL [dict get $wapp BASE_URL]/[dict get $wapp PATH_HEAD]
+
+ # Parse query parameters from the query string, the cookies, and
+ # POST data
+ #
+ if {[dict exists $wapp HTTP_COOKIE]} {
+ foreach qterm [split [dict get $wapp HTTP_COOKIE] {;}] {
+ set qsplit [split [string trim $qterm] =]
+ set nm [lindex $qsplit 0]
+ if {[regexp {^[a-z][-a-z0-9_]*$} $nm]} {
+ dict set wapp $nm [wappInt-decode-url [lindex $qsplit 1]]
+ }
+ }
+ }
+ set same_origin 0
+ if {[dict exists $wapp HTTP_REFERER]} {
+ set referer [dict get $wapp HTTP_REFERER]
+ set base [dict get $wapp BASE_URL]
+ if {$referer==$base || [string match $base/* $referer]} {
+ set same_origin 1
+ }
+ }
+ dict set wapp SAME_ORIGIN $same_origin
+ if {$same_origin} {
+ wappInt-decode-query-params
+ }
+
+ # Invoke the application-defined handler procedure for this page
+ # request. If an error occurs while running that procedure, generate
+ # an HTTP reply that contains the error message.
+ #
+ wapp-before-dispatch-hook
+ wappInt-trace
+ set mname [dict get $wapp PATH_HEAD]
+ if {[catch {
+ if {$mname!="" && [llength [info proc wapp-page-$mname]]>0} {
+ wapp-page-$mname
+ } else {
+ wapp-default
+ }
+ } msg]} {
+ if {[wapp-param WAPP_MODE]=="local" || [wapp-param WAPP_MODE]=="server"} {
+ puts "ERROR: $::errorInfo"
+ }
+ wapp-reset
+ wapp-reply-code "500 Internal Server Error"
+ wapp-mimetype text/html
+ wapp-trim {
+ <h1>Wapp Application Error</h1>
+ <pre>%html($::errorInfo)</pre>
+ }
+ dict unset wapp .new-cookies
+ }
+
+ # Transmit the HTTP reply
+ #
+ if {$chan=="stdout"} {
+ puts $chan "Status: [dict get $wapp .reply-code]\r"
+ } else {
+ puts $chan "HTTP/1.1 [dict get $wapp .reply-code]\r"
+ puts $chan "Server: wapp\r"
+ puts $chan "Connection: close\r"
+ }
+ if {[dict exists $wapp .reply-extra]} {
+ foreach {name value} [dict get $wapp .reply-extra] {
+ puts $chan "$name: $value\r"
+ }
+ }
+ if {[dict exists $wapp .csp]} {
+ puts $chan "Content-Security-Policy: [dict get $wapp .csp]\r"
+ }
+ set mimetype [dict get $wapp .mimetype]
+ puts $chan "Content-Type: $mimetype\r"
+ if {[dict exists $wapp .new-cookies]} {
+ foreach {nm val} [dict get $wapp .new-cookies] {
+ if {[regexp {^[a-z][-a-z0-9_]*$} $nm]} {
+ if {$val==""} {
+ puts $chan "Set-Cookie: $nm=; HttpOnly; Path=/; Max-Age=1\r"
+ } else {
+ set val [wappInt-enc-url $val]
+ puts $chan "Set-Cookie: $nm=$val; HttpOnly; Path=/\r"
+ }
+ }
+ }
+ }
+ if {[string match text/* $mimetype]} {
+ set reply [encoding convertto utf-8 [dict get $wapp .reply]]
+ if {[regexp {\ygzip\y} [wapp-param HTTP_ACCEPT_ENCODING]]} {
+ catch {
+ set x [zlib gzip $reply]
+ set reply $x
+ puts $chan "Content-Encoding: gzip\r"
+ }
+ }
+ } else {
+ set reply [dict get $wapp .reply]
+ }
+ puts $chan "Content-Length: [string length $reply]\r"
+ puts $chan \r
+ puts -nonewline $chan $reply
+ flush $chan
+ wappInt-close-channel $chan
+}
+
+# This routine runs just prior to request-handler dispatch. The
+# default implementation is a no-op, but applications can override
+# to do additional transformations or checks.
+#
+proc wapp-before-dispatch-hook {} {return}
+
+# Process a single CGI request
+#
+proc wappInt-handle-cgi-request {} {
+ global wapp env
+ foreach key {
+ CONTENT_LENGTH
+ CONTENT_TYPE
+ DOCUMENT_ROOT
+ HTTP_ACCEPT_ENCODING
+ HTTP_COOKIE
+ HTTP_HOST
+ HTTP_REFERER
+ HTTP_USER_AGENT
+ HTTPS
+ PATH_INFO
+ QUERY_STRING
+ REMOTE_ADDR
+ REQUEST_METHOD
+ REQUEST_URI
+ REMOTE_USER
+ SCRIPT_FILENAME
+ SCRIPT_NAME
+ SERVER_NAME
+ SERVER_PORT
+ SERVER_PROTOCOL
+ } {
+ if {[info exists env($key)]} {
+ dict set wapp $key $env($key)
+ }
+ }
+ set len 0
+ if {[dict exists $wapp CONTENT_LENGTH]} {
+ set len [dict get $wapp CONTENT_LENGTH]
+ }
+ if {$len>0} {
+ fconfigure stdin -translation binary
+ dict set wapp CONTENT [read stdin $len]
+ }
+ dict set wapp WAPP_MODE cgi
+ fconfigure stdout -translation binary
+ wappInt-handle-request stdout 1
+}
+
+# Process new text received on an inbound SCGI request
+#
+proc wappInt-scgi-readable {chan} {
+ if {[catch [list wappInt-scgi-readable-unsafe $chan] msg]} {
+ puts stderr "$msg\n$::errorInfo"
+ wappInt-close-channel $chan
+ }
+}
+proc wappInt-scgi-readable-unsafe {chan} {
+ upvar #0 wappInt-$chan W wapp wapp
+ if {![dict exists $W .toread]} {
+ # If the .toread key is not set, that means we are still reading
+ # the header.
+ #
+ # An SGI header is short. This implementation assumes the entire
+ # header is available all at once.
+ #
+ dict set W .remove_addr [dict get $W REMOTE_ADDR]
+ set req [read $chan 15]
+ set n [string length $req]
+ scan $req %d:%s len hdr
+ incr len [string length "$len:,"]
+ append hdr [read $chan [expr {$len-15}]]
+ foreach {nm val} [split $hdr \000] {
+ if {$nm==","} break
+ dict set W $nm $val
+ }
+ set len 0
+ if {[dict exists $W CONTENT_LENGTH]} {
+ set len [dict get $W CONTENT_LENGTH]
+ }
+ if {$len>0} {
+ # Still need to read the query content
+ dict set W .toread $len
+ } else {
+ # There is no query content, so handle the request immediately
+ dict set W SERVER_ADDR [dict get $W .remove_addr]
+ set wapp $W
+ wappInt-handle-request $chan 0
+ }
+ } else {
+ # If .toread is set, that means we are reading the query content.
+ # Continue reading until .toread reaches zero.
+ set got [read $chan [dict get $W .toread]]
+ dict append W CONTENT $got
+ dict set W .toread [expr {[dict get $W .toread]-[string length $got]}]
+ if {[dict get $W .toread]<=0} {
+ # Handle the request as soon as all the query content is received
+ dict set W SERVER_ADDR [dict get $W .remove_addr]
+ set wapp $W
+ wappInt-handle-request $chan 0
+ }
+ }
+}
+
+# Start up the wapp framework. Parameters are a list passed as the
+# single argument.
+#
+# -server $PORT Listen for HTTP requests on this TCP port $PORT
+#
+# -local $PORT Listen for HTTP requests on 127.0.0.1:$PORT
+#
+# -scgi $PORT Listen for SCGI requests on 127.0.0.1:$PORT
+#
+# -remote-scgi $PORT Listen for SCGI requests on TCP port $PORT
+#
+# -cgi Handle a single CGI request
+#
+# With no arguments, the behavior is called "auto". In "auto" mode,
+# if the GATEWAY_INTERFACE environment variable indicates CGI, then run
+# as CGI. Otherwise, start an HTTP server bound to the loopback address
+# only, on an arbitrary TCP port, and automatically launch a web browser
+# on that TCP port.
+#
+# Additional options:
+#
+# -fromip GLOB Reject any incoming request where the remote
+# IP address does not match the GLOB pattern. This
+# value defaults to '127.0.0.1' for -local and -scgi.
+#
+# -nowait Do not wait in the event loop. Return immediately
+# after all event handlers are established.
+#
+# -trace "puts" each request URL as it is handled, for
+# debugging
+#
+# -lint Run wapp-safety-check on the application instead
+# of running the application itself
+#
+# -Dvar=value Set TCL global variable "var" to "value"
+#
+#
+proc wapp-start {arglist} {
+ global env
+ set mode auto
+ set port 0
+ set nowait 0
+ set fromip {}
+ set n [llength $arglist]
+ for {set i 0} {$i<$n} {incr i} {
+ set term [lindex $arglist $i]
+ if {[string match --* $term]} {set term [string range $term 1 end]}
+ switch -glob -- $term {
+ -server {
+ incr i;
+ set mode "server"
+ set port [lindex $arglist $i]
+ }
+ -local {
+ incr i;
+ set mode "local"
+ set fromip 127.0.0.1
+ set port [lindex $arglist $i]
+ }
+ -scgi {
+ incr i;
+ set mode "scgi"
+ set fromip 127.0.0.1
+ set port [lindex $arglist $i]
+ }
+ -remote-scgi {
+ incr i;
+ set mode "remote-scgi"
+ set port [lindex $arglist $i]
+ }
+ -cgi {
+ set mode "cgi"
+ }
+ -fromip {
+ incr i
+ set fromip [lindex $arglist $i]
+ }
+ -nowait {
+ set nowait 1
+ }
+ -trace {
+ proc wappInt-trace {} {
+ set q [wapp-param QUERY_STRING]
+ set uri [wapp-param BASE_URL][wapp-param PATH_INFO]
+ if {$q!=""} {append uri ?$q}
+ puts $uri
+ }
+ }
+ -lint {
+ set res [wapp-safety-check]
+ if {$res!=""} {
+ puts "Potential problems in this code:"
+ puts $res
+ exit 1
+ } else {
+ exit
+ }
+ }
+ -D*=* {
+ if {[regexp {^.D([^=]+)=(.*)$} $term all var val]} {
+ set ::$var $val
+ }
+ }
+ default {
+ error "unknown option: $term"
+ }
+ }
+ }
+ if {$mode=="auto"} {
+ if {[info exists env(GATEWAY_INTERFACE)]
+ && [string match CGI/1.* $env(GATEWAY_INTERFACE)]} {
+ set mode cgi
+ } else {
+ set mode local
+ }
+ }
+ if {$mode=="cgi"} {
+ wappInt-handle-cgi-request
+ } else {
+ wappInt-start-listener $port $mode $fromip
+ if {!$nowait} {
+ vwait ::forever
+ }
+ }
+}
+
+# Call this version 1.0
+package provide wapp 1.0
diff --git a/test/wapptest.tcl b/test/wapptest.tcl
new file mode 100755
index 0000000..d37b2e4
--- /dev/null
+++ b/test/wapptest.tcl
@@ -0,0 +1,909 @@
+#!/bin/sh
+# \
+exec wapptclsh "$0" ${1+"$@"}
+
+# package required wapp
+source [file join [file dirname [info script]] wapp.tcl]
+
+# Variables set by the "control" form:
+#
+# G(platform) - User selected platform.
+# G(cfgglob) - Glob pattern that all configurations must match
+# G(test) - Set to "Normal", "Veryquick", "Smoketest" or "Build-Only".
+# G(keep) - Boolean. True to delete no files after each test.
+# G(msvc) - Boolean. True to use MSVC as the compiler.
+# G(tcl) - Use Tcl from this directory for builds.
+# G(jobs) - How many sub-processes to run simultaneously.
+#
+set G(platform) $::tcl_platform(os)-$::tcl_platform(machine)
+set G(cfgglob) *
+set G(test) Normal
+set G(keep) 1
+set G(msvc) 0
+set G(tcl) [::tcl::pkgconfig get libdir,install]
+set G(jobs) 3
+set G(debug) 0
+
+set G(noui) 0
+set G(stdout) 0
+
+
+proc wapptest_init {} {
+ global G
+
+ set lSave [list platform test keep msvc tcl jobs debug noui stdout cfgglob]
+ foreach k $lSave { set A($k) $G($k) }
+ array unset G
+ foreach k $lSave { set G($k) $A($k) }
+
+ # The root of the SQLite source tree.
+ set G(srcdir) [file dirname [file dirname [info script]]]
+
+ set G(sqlite_version) "unknown"
+
+ # Either "config", "running" or "stopped":
+ set G(state) "config"
+
+ set G(hostname) "(unknown host)"
+ catch { set G(hostname) [exec hostname] }
+ set G(host) $G(hostname)
+ append G(host) " $::tcl_platform(os) $::tcl_platform(osVersion)"
+ append G(host) " $::tcl_platform(machine) $::tcl_platform(byteOrder)"
+}
+
+proc wapptest_run {} {
+ global G
+ set_test_array
+ set G(state) "running"
+
+ wapptest_openlog
+
+ wapptest_output "Running the following for $G(platform). $G(jobs) jobs."
+ foreach t $G(test_array) {
+ set config [dict get $t config]
+ set target [dict get $t target]
+ wapptest_output [format " %-25s%s" $config $target]
+ }
+ wapptest_output [string repeat * 70]
+}
+
+proc releasetest_data {args} {
+ global G
+ set rtd [file join $G(srcdir) test releasetest_data.tcl]
+ set fd [open "|[info nameofexecutable] $rtd $args" r+]
+ set ret [read $fd]
+ close $fd
+ return $ret
+}
+
+# Generate the text for the box at the top of the UI. The current SQLite
+# version, according to fossil, along with a warning if there are
+# uncommitted changes in the checkout.
+#
+proc generate_fossil_info {} {
+ global G
+ set pwd [pwd]
+ cd $G(srcdir)
+ set rc [catch {
+ set r1 [exec fossil info]
+ set r2 [exec fossil changes]
+ }]
+ cd $pwd
+ if {$rc} return
+
+ foreach line [split $r1 "\n"] {
+ if {[regexp {^checkout: *(.*)$} $line -> co]} {
+ wapp-trim { <br> %html($co) }
+ }
+ }
+
+ if {[string trim $r2]!=""} {
+ wapp-trim {
+ <br><span class=warning>
+ WARNING: Uncommitted changes in checkout
+ </span>
+ }
+ }
+}
+
+# If the application is in "config" state, set the contents of the
+# ::G(test_array) global to reflect the tests that will be run. If the
+# app is in some other state ("running" or "stopped"), this command
+# is a no-op.
+#
+proc set_test_array {} {
+ global G
+ if { $G(state)=="config" } {
+ set G(test_array) [list]
+ set debug "-debug"
+ if {$G(debug)==0} { set debug "-nodebug"}
+ foreach {config target} [releasetest_data tests $debug $G(platform)] {
+
+ # All configuration names must match $g(cfgglob), which defaults to *
+ #
+ if {![string match -nocase $G(cfgglob) $config]} continue
+
+ # If using MSVC, do not run sanitize or valgrind tests. Or the
+ # checksymbols test.
+ if {$G(msvc) && (
+ "Sanitize" == $config
+ || "checksymbols" in $target
+ || "valgrindtest" in $target
+ )} {
+ continue
+ }
+
+ # If the test mode is not "Normal", override the target.
+ #
+ if {$target!="checksymbols" && $G(platform)!="Failure-Detection"} {
+ switch -- $G(test) {
+ Veryquick { set target quicktest }
+ Smoketest { set target smoketest }
+ Build-Only {
+ set target testfixture
+ if {$::tcl_platform(platform)=="windows"} {
+ set target testfixture.exe
+ }
+ }
+ }
+ }
+
+ lappend G(test_array) [dict create config $config target $target]
+ }
+ }
+}
+
+proc count_tests_and_errors {name logfile} {
+ global G
+
+ set fd [open $logfile rb]
+ set seen 0
+ while {![eof $fd]} {
+ set line [gets $fd]
+ if {[regexp {(\d+) errors out of (\d+) tests} $line all nerr ntest]} {
+ incr G(test.$name.nError) $nerr
+ incr G(test.$name.nTest) $ntest
+ set seen 1
+ if {$nerr>0} {
+ set G(test.$name.errmsg) $line
+ }
+ }
+ if {[regexp {runtime error: +(.*)} $line all msg]} {
+ # skip over "value is outside range" errors
+ if {[regexp {.* is outside the range of representable} $line]} {
+ # noop
+ } else {
+ incr G(test.$name.nError)
+ if {$G(test.$name.errmsg)==""} {
+ set G(test.$name.errmsg) $msg
+ }
+ }
+ }
+ if {[regexp {fatal error +(.*)} $line all msg]} {
+ incr G(test.$name.nError)
+ if {$G(test.$name.errmsg)==""} {
+ set G(test.$name.errmsg) $msg
+ }
+ }
+ if {[regexp {ERROR SUMMARY: (\d+) errors.*} $line all cnt] && $cnt>0} {
+ incr G(test.$name.nError)
+ if {$G(test.$name.errmsg)==""} {
+ set G(test.$name.errmsg) $all
+ }
+ }
+ if {[regexp {^VERSION: 3\.\d+.\d+} $line]} {
+ set v [string range $line 9 end]
+ if {$G(sqlite_version) eq "unknown"} {
+ set G(sqlite_version) $v
+ } elseif {$G(sqlite_version) ne $v} {
+ set G(test.$name.errmsg) "version conflict: {$G(sqlite_version)} vs. {$v}"
+ }
+ }
+ }
+ close $fd
+ if {$G(test) == "Build-Only"} {
+ incr G(test.$name.nTest)
+ if {$G(test.$name.nError)>0} {
+ set errmsg "Build failed"
+ }
+ } elseif {!$seen} {
+ set G(test.$name.errmsg) "Test did not complete"
+ if {[file readable core]} {
+ append G(test.$name.errmsg) " - core file exists"
+ }
+ }
+}
+
+proc wapptest_output {str} {
+ global G
+ if {$G(stdout)} { puts $str }
+ if {[info exists G(log)]} {
+ puts $G(log) $str
+ flush $G(log)
+ }
+}
+proc wapptest_openlog {} {
+ global G
+ set G(log) [open wapptest-out.txt w+]
+}
+proc wapptest_closelog {} {
+ global G
+ close $G(log)
+ unset G(log)
+}
+
+proc format_seconds {seconds} {
+ set min [format %.2d [expr ($seconds / 60) % 60]]
+ set hr [format %.2d [expr $seconds / 3600]]
+ set sec [format %.2d [expr $seconds % 60]]
+ return "$hr:$min:$sec"
+}
+
+# This command is invoked once a slave process has finished running its
+# tests, successfully or otherwise. Parameter $name is the name of the
+# test, $rc the exit code returned by the slave process.
+#
+proc slave_test_done {name rc} {
+ global G
+ set G(test.$name.done) [clock seconds]
+ set G(test.$name.nError) 0
+ set G(test.$name.nTest) 0
+ set G(test.$name.errmsg) ""
+ if {$rc} {
+ incr G(test.$name.nError)
+ }
+ if {[file exists $G(test.$name.log)]} {
+ count_tests_and_errors $name $G(test.$name.log)
+ }
+
+ # If the "keep files" checkbox is clear, delete all files except for
+ # the executables and test logs. And any core file that is present.
+ if {$G(keep)==0} {
+ set keeplist {
+ testfixture testfixture.exe
+ sqlite3 sqlite3.exe
+ test.log test-out.txt
+ core
+ wapptest_make.sh
+ wapptest_configure.sh
+ wapptest_run.tcl
+ }
+ foreach f [glob -nocomplain [file join $G(test.$name.dir) *]] {
+ set t [file tail $f]
+ if {[lsearch $keeplist $t]<0} {
+ catch { file delete -force $f }
+ }
+ }
+ }
+
+ # Format a message regarding the success or failure of hte test.
+ set t [format_seconds [expr $G(test.$name.done) - $G(test.$name.start)]]
+ set res "OK"
+ if {$G(test.$name.nError)} { set res "FAILED" }
+ set dots [string repeat . [expr 60 - [string length $name]]]
+ set msg "$name $dots $res ($t)"
+
+ wapptest_output $msg
+ if {[info exists G(test.$name.errmsg)] && $G(test.$name.errmsg)!=""} {
+ wapptest_output " $G(test.$name.errmsg)"
+ }
+}
+
+# This is a fileevent callback invoked each time a file-descriptor that
+# connects this process to a slave process is readable.
+#
+proc slave_fileevent {name} {
+ global G
+ set fd $G(test.$name.channel)
+
+ if {[eof $fd]} {
+ fconfigure $fd -blocking 1
+ set rc [catch { close $fd }]
+ unset G(test.$name.channel)
+ slave_test_done $name $rc
+ } else {
+ set line [gets $fd]
+ if {[string trim $line] != ""} { puts "Trace : $name - \"$line\"" }
+ }
+
+ do_some_stuff
+}
+
+# Return the contents of the "slave script" - the script run by slave
+# processes to actually perform the test. All it does is execute the
+# test script already written to disk (wapptest_cmd.sh or wapptest_cmd.bat).
+#
+proc wapptest_slave_script {} {
+ global G
+ if {$G(msvc)==0} {
+ set dir [file join .. $G(srcdir)]
+ set res [subst -nocommands {
+ set rc [catch "exec sh wapptest_cmd.sh {$dir} >>& test.log" ]
+ exit [set rc]
+ }]
+ } else {
+ set dir [file nativename [file normalize $G(srcdir)]]
+ set dir [string map [list "\\" "\\\\"] $dir]
+ set res [subst -nocommands {
+ set rc [catch "exec wapptest_cmd.bat {$dir} >>& test.log" ]
+ exit [set rc]
+ }]
+ }
+
+ set res
+}
+
+
+# Launch a slave process to run a test.
+#
+proc slave_launch {name target dir} {
+ global G
+
+ catch { file mkdir $dir } msg
+ foreach f [glob -nocomplain [file join $dir *]] {
+ catch { file delete -force $f }
+ }
+ set G(test.$name.dir) $dir
+
+ # Write the test command to wapptest_cmd.sh|bat.
+ #
+ set ext sh
+ if {$G(msvc)} { set ext bat }
+ set fd1 [open [file join $dir wapptest_cmd.$ext] w]
+ if {$G(msvc)} {
+ puts $fd1 [releasetest_data script -msvc $name $target]
+ } else {
+ puts $fd1 [releasetest_data script $name $target]
+ }
+ close $fd1
+
+ # Write the wapptest_run.tcl script to the test directory. To run the
+ # commands in the other two files.
+ #
+ set fd3 [open [file join $dir wapptest_run.tcl] w]
+ puts $fd3 [wapptest_slave_script]
+ close $fd3
+
+ set pwd [pwd]
+ cd $dir
+ set fd [open "|[info nameofexecutable] wapptest_run.tcl" r+]
+ cd $pwd
+
+ set G(test.$name.channel) $fd
+ fconfigure $fd -blocking 0
+ fileevent $fd readable [list slave_fileevent $name]
+}
+
+proc do_some_stuff {} {
+ global G
+
+ # Count the number of running jobs. A running job has an entry named
+ # "channel" in its dictionary.
+ set nRunning 0
+ set bFinished 1
+ foreach j $G(test_array) {
+ set name [dict get $j config]
+ if { [info exists G(test.$name.channel)]} { incr nRunning }
+ if {![info exists G(test.$name.done)]} { set bFinished 0 }
+ }
+
+ if {$bFinished} {
+ set nError 0
+ set nTest 0
+ set nConfig 0
+ foreach j $G(test_array) {
+ set name [dict get $j config]
+ incr nError $G(test.$name.nError)
+ incr nTest $G(test.$name.nTest)
+ incr nConfig
+ }
+ set G(result) "$nError errors from $nTest tests in $nConfig configurations."
+ wapptest_output [string repeat * 70]
+ wapptest_output $G(result)
+ catch {
+ append G(result) " SQLite version $G(sqlite_version)"
+ wapptest_output " SQLite version $G(sqlite_version)"
+ }
+ set G(state) "stopped"
+ wapptest_closelog
+ if {$G(noui)} { exit 0 }
+ } else {
+ set nLaunch [expr $G(jobs) - $nRunning]
+ foreach j $G(test_array) {
+ if {$nLaunch<=0} break
+ set name [dict get $j config]
+ if { ![info exists G(test.$name.channel)]
+ && ![info exists G(test.$name.done)]
+ } {
+
+ set target [dict get $j target]
+ set dir [string tolower [string map {" " _ "-" _} $name]]
+ set G(test.$name.start) [clock seconds]
+ set G(test.$name.log) [file join $dir test.log]
+
+ slave_launch $name $target $dir
+
+ incr nLaunch -1
+ }
+ }
+ }
+}
+
+proc generate_select_widget {label id lOpt opt} {
+ wapp-trim {
+ <label> %string($label) </label>
+ <select id=%string($id) name=%string($id)>
+ }
+ foreach o $lOpt {
+ set selected ""
+ if {$o==$opt} { set selected " selected=1" }
+ wapp-subst "<option $selected>$o</option>"
+ }
+ wapp-trim { </select> }
+}
+
+proc generate_main_page {{extra {}}} {
+ global G
+ set_test_array
+
+ set hostname $G(hostname)
+ wapp-trim {
+ <html>
+ <head>
+ <title> %html($hostname): wapptest.tcl </title>
+ <link rel="stylesheet" type="text/css" href="style.css"/>
+ </head>
+ <body>
+ }
+
+ set host $G(host)
+ wapp-trim {
+ <div class="border">%string($host)
+ }
+ generate_fossil_info
+ wapp-trim {
+ </div>
+ <div class="border" id=controls>
+ <form action="control" method="post" name="control">
+ }
+
+ # Build the "platform" select widget.
+ set lOpt [releasetest_data platforms]
+ generate_select_widget Platform control_platform $lOpt $G(platform)
+
+ # Build the "test" select widget.
+ set lOpt [list Normal Veryquick Smoketest Build-Only]
+ generate_select_widget Test control_test $lOpt $G(test)
+
+ # Build the "jobs" select widget. Options are 1 to 8.
+ generate_select_widget Jobs control_jobs {1 2 3 4 5 6 7 8 12 16} $G(jobs)
+
+ switch $G(state) {
+ config {
+ set txt "Run Tests!"
+ set id control_run
+ }
+ running {
+ set txt "STOP Tests!"
+ set id control_stop
+ }
+ stopped {
+ set txt "Reset!"
+ set id control_reset
+ }
+ }
+ wapp-trim {
+ <div class=right>
+ <input id=%string($id) name=%string($id) type=submit value="%string($txt)">
+ </input>
+ </div>
+ }
+
+ wapp-trim {
+ <br><br>
+ <label> Tcl: </label>
+ <input id="control_tcl" name="control_tcl"></input>
+ <label> Keep files: </label>
+ <input id="control_keep" name="control_keep" type=checkbox value=1>
+ </input>
+ <label> Use MSVC: </label>
+ <input id="control_msvc" name="control_msvc" type=checkbox value=1>
+ <label> Debug tests: </label>
+ <input id="control_debug" name="control_debug" type=checkbox value=1>
+ </input>
+ }
+ wapp-trim {
+ </form>
+ }
+ wapp-trim {
+ </div>
+ <div id=tests>
+ }
+ wapp-page-tests
+
+ set script "script/$G(state).js"
+ wapp-trim {
+ </div>
+ <script src=%string($script)></script>
+ </body>
+ </html>
+ }
+}
+
+proc wapp-default {} {
+ generate_main_page
+}
+
+proc wapp-page-tests {} {
+ global G
+ wapp-trim { <table class="border" width=100%> }
+ foreach t $G(test_array) {
+ set config [dict get $t config]
+ set target [dict get $t target]
+
+ set class "testwait"
+ set seconds ""
+
+ if {[info exists G(test.$config.log)]} {
+ if {[info exists G(test.$config.channel)]} {
+ set class "testrunning"
+ set seconds [expr [clock seconds] - $G(test.$config.start)]
+ } elseif {[info exists G(test.$config.done)]} {
+ if {$G(test.$config.nError)>0} {
+ set class "testfail"
+ } else {
+ set class "testdone"
+ }
+ set seconds [expr $G(test.$config.done) - $G(test.$config.start)]
+ }
+ set seconds [format_seconds $seconds]
+ }
+
+ wapp-trim {
+ <tr class=%string($class)>
+ <td class="nowrap"> %html($config)
+ <td class="padleft nowrap"> %html($target)
+ <td class="padleft nowrap"> %html($seconds)
+ <td class="padleft nowrap">
+ }
+ if {[info exists G(test.$config.log)]} {
+ set log $G(test.$config.log)
+ set uri "log/$log"
+ wapp-trim {
+ <a href=%url($uri)> %html($log) </a>
+ }
+ }
+ if {[info exists G(test.$config.errmsg)] && $G(test.$config.errmsg)!=""} {
+ set errmsg $G(test.$config.errmsg)
+ wapp-trim {
+ <tr class=testfail>
+ <td> <td class="padleft" colspan=3> %html($errmsg)
+ }
+ }
+ }
+
+ wapp-trim { </table> }
+
+ if {[info exists G(result)]} {
+ set res $G(result)
+ wapp-trim {
+ <div class=border id=result> %string($res) </div>
+ }
+ }
+}
+
+# URI: /control
+#
+# Whenever the form at the top of the application page is submitted, it
+# is submitted here.
+#
+proc wapp-page-control {} {
+ global G
+ if {$::G(state)=="config"} {
+ set lControls [list platform test tcl jobs keep msvc debug]
+ set G(msvc) 0
+ set G(keep) 0
+ set G(debug) 0
+ } else {
+ set lControls [list jobs]
+ }
+ foreach v $lControls {
+ if {[wapp-param-exists control_$v]} {
+ set G($v) [wapp-param control_$v]
+ }
+ }
+
+ if {[wapp-param-exists control_run]} {
+ # This is a "run test" command.
+ wapptest_run
+ }
+
+ if {[wapp-param-exists control_stop]} {
+ # A "STOP tests" command.
+ set G(state) "stopped"
+ set G(result) "Test halted by user"
+ foreach j $G(test_array) {
+ set name [dict get $j config]
+ if { [info exists G(test.$name.channel)] } {
+ close $G(test.$name.channel)
+ unset G(test.$name.channel)
+ slave_test_done $name 1
+ }
+ }
+ wapptest_closelog
+ }
+
+ if {[wapp-param-exists control_reset]} {
+ # A "reset app" command.
+ set G(state) "config"
+ wapptest_init
+ }
+
+ if {$::G(state) == "running"} {
+ do_some_stuff
+ }
+ wapp-redirect /
+}
+
+# URI: /style.css
+#
+# Return the stylesheet for the application main page.
+#
+proc wapp-page-style.css {} {
+ wapp-subst {
+
+ /* The boxes with black borders use this class */
+ .border {
+ border: 3px groove #444444;
+ padding: 1em;
+ margin-top: 1em;
+ margin-bottom: 1em;
+ }
+
+ /* Float to the right (used for the Run/Stop/Reset button) */
+ .right { float: right; }
+
+ /* Style for the large red warning at the top of the page */
+ .warning {
+ color: red;
+ font-weight: bold;
+ }
+
+ /* Styles used by cells in the test table */
+ .padleft { padding-left: 5ex; }
+ .nowrap { white-space: nowrap; }
+
+ /* Styles for individual tests, depending on the outcome */
+ .testwait { }
+ .testrunning { color: blue }
+ .testdone { color: green }
+ .testfail { color: red }
+ }
+}
+
+# URI: /script/${state}.js
+#
+# The last part of this URI is always "config.js", "running.js" or
+# "stopped.js", depending on the state of the application. It returns
+# the javascript part of the front-end for the requested state to the
+# browser.
+#
+proc wapp-page-script {} {
+ regexp {[^/]*$} [wapp-param REQUEST_URI] script
+
+ set tcl $::G(tcl)
+ set keep $::G(keep)
+ set msvc $::G(msvc)
+ set debug $::G(debug)
+
+ wapp-subst {
+ var lElem = \["control_platform", "control_test", "control_msvc",
+ "control_jobs", "control_debug"
+ \];
+ lElem.forEach(function(e) {
+ var elem = document.getElementById(e);
+ elem.addEventListener("change", function() { control.submit() } );
+ })
+
+ elem = document.getElementById("control_tcl");
+ elem.value = "%string($tcl)"
+
+ elem = document.getElementById("control_keep");
+ elem.checked = %string($keep);
+
+ elem = document.getElementById("control_msvc");
+ elem.checked = %string($msvc);
+
+ elem = document.getElementById("control_debug");
+ elem.checked = %string($debug);
+ }
+
+ if {$script != "config.js"} {
+ wapp-subst {
+ var lElem = \["control_platform", "control_test",
+ "control_tcl", "control_keep", "control_msvc",
+ "control_debug"
+ \];
+ lElem.forEach(function(e) {
+ var elem = document.getElementById(e);
+ elem.disabled = true;
+ })
+ }
+ }
+
+ if {$script == "running.js"} {
+ wapp-subst {
+ function reload_tests() {
+ fetch('tests')
+ .then( data => data.text() )
+ .then( data => {
+ document.getElementById("tests").innerHTML = data;
+ })
+ .then( data => {
+ if( document.getElementById("result") ){
+ document.location = document.location;
+ } else {
+ setTimeout(reload_tests, 1000)
+ }
+ });
+ }
+
+ setTimeout(reload_tests, 1000)
+ }
+ }
+}
+
+# URI: /env
+#
+# This is for debugging only. Serves no other purpose.
+#
+proc wapp-page-env {} {
+ wapp-allow-xorigin-params
+ wapp-trim {
+ <h1>Wapp Environment</h1>\n<pre>
+ <pre>%html([wapp-debug-env])</pre>
+ }
+}
+
+# URI: /log/dirname/test.log
+#
+# This URI reads file "dirname/test.log" from disk, wraps it in a <pre>
+# block, and returns it to the browser. Use for viewing log files.
+#
+proc wapp-page-log {} {
+ set log [string range [wapp-param REQUEST_URI] 5 end]
+ set fd [open $log]
+ set data [read $fd]
+ close $fd
+ wapp-trim {
+ <pre>
+ %html($data)
+ </pre>
+ }
+}
+
+# Print out a usage message. Then do [exit 1].
+#
+proc wapptest_usage {} {
+ puts stderr {
+This Tcl script is used to test various configurations of SQLite. By
+default it uses "wapp" to provide an interactive interface. Supported
+command line options (all optional) are:
+
+ --platform PLATFORM (which tests to run)
+ --config GLOB (only run configurations matching GLOB)
+ --smoketest (run "make smoketest" only)
+ --veryquick (run veryquick.test only)
+ --buildonly (build executables, do not run tests)
+ --jobs N (number of concurrent jobs)
+ --tcl DIR (where to find tclConfig.sh)
+ --deletefiles (delete extra files after each test)
+ --msvc (Use MS Visual C)
+ --debug (Also run [n]debugging versions of tests)
+ --noui (do not use wapp)
+ }
+ exit 1
+}
+
+# Sort command line arguments into two groups: those that belong to wapp,
+# and those that belong to the application.
+set WAPPARG(-server) 1
+set WAPPARG(-local) 1
+set WAPPARG(-scgi) 1
+set WAPPARG(-remote-scgi) 1
+set WAPPARG(-fromip) 1
+set WAPPARG(-nowait) 0
+set WAPPARG(-cgi) 0
+set lWappArg [list]
+set lTestArg [list]
+for {set i 0} {$i < [llength $argv]} {incr i} {
+ set arg [lindex $argv $i]
+ if {[string range $arg 0 1]=="--"} {
+ set arg [string range $arg 1 end]
+ }
+ if {[info exists WAPPARG($arg)]} {
+ lappend lWappArg $arg
+ if {$WAPPARG($arg)} {
+ incr i
+ lappend lWappArg [lindex $argv $i]
+ }
+ } else {
+ lappend lTestArg $arg
+ }
+}
+
+wapptest_init
+for {set i 0} {$i < [llength $lTestArg]} {incr i} {
+ set opt [lindex $lTestArg $i]
+ if {[string range $opt 0 1]=="--"} {
+ set opt [string range $opt 1 end]
+ }
+ switch -- $opt {
+ -platform {
+ if {$i==[llength $lTestArg]-1} { wapptest_usage }
+ incr i
+ set arg [lindex $lTestArg $i]
+ set lPlatform [releasetest_data platforms]
+ if {[lsearch $lPlatform $arg]<0} {
+ puts stderr "No such platform: $arg. Platforms are: $lPlatform"
+ exit -1
+ }
+ set G(platform) $arg
+ }
+
+ -smoketest { set G(test) Smoketest }
+ -veryquick { set G(test) Veryquick }
+ -buildonly { set G(test) Build-Only }
+ -jobs {
+ if {$i==[llength $lTestArg]-1} { wapptest_usage }
+ incr i
+ set G(jobs) [lindex $lTestArg $i]
+ }
+
+ -tcl {
+ if {$i==[llength $lTestArg]-1} { wapptest_usage }
+ incr i
+ set G(tcl) [lindex $lTestArg $i]
+ }
+
+ -deletefiles {
+ set G(keep) 0
+ }
+
+ -msvc {
+ set G(msvc) 1
+ }
+
+ -debug {
+ set G(debug) 1
+ }
+
+ -noui {
+ set G(noui) 1
+ set G(stdout) 1
+ }
+
+ -config {
+ if {$i==[llength $lTestArg]-1} { wapptest_usage }
+ incr i
+ set G(cfgglob) [lindex $lTestArg $i]
+ }
+
+ -stdout {
+ set G(stdout) 1
+ }
+
+ default {
+ puts stderr "Unrecognized option: [lindex $lTestArg $i]"
+ wapptest_usage
+ }
+ }
+}
+
+if {$G(noui)==0} {
+ wapp-start $lWappArg
+} else {
+ wapptest_run
+ do_some_stuff
+ vwait forever
+}
diff --git a/test/where.test b/test/where.test
new file mode 100644
index 0000000..b559f5e
--- /dev/null
+++ b/test/where.test
@@ -0,0 +1,1637 @@
+# 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.
+#
+
+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"); -- Verify quoted identifier names
+ CREATE INDEX i1xy ON t1(`x`,'y' ASC); -- Old MySQL compatibility
+ 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.1b {
+ count {SELECT x, y, w FROM t1 WHERE w IS 10}
+} {3 121 10 3}
+do_eqp_test where-1.1.2 {
+ SELECT x, y, w FROM t1 WHERE w=10
+} {*SEARCH t1 USING INDEX i1w (w=?)*}
+do_eqp_test where-1.1.2b {
+ SELECT x, y, w FROM t1 WHERE w IS 10
+} {*SEARCH t1 USING INDEX i1w (w=?)*}
+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_eqp_test where-1.1.6 {
+ SELECT x, y, w FROM t1 WHERE +w=10
+} {*SCAN t1*}
+do_test where-1.1.7 {
+ count {SELECT x, y, w AS abc FROM t1 WHERE abc=10}
+} {3 121 10 3}
+do_eqp_test where-1.1.8 {
+ SELECT x, y, w AS abc FROM t1 WHERE abc=10
+} {*SEARCH t1 USING INDEX i1w (w=?)*}
+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.3.3 {
+ count {SELECT x, y, w AS abc FROM t1 WHERE 11 IS 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.1b {
+ count {SELECT w, x, y FROM t1 WHERE 11 IS w AND x>2}
+} {11 3 144 3}
+do_eqp_test where-1.4.2 {
+ SELECT w, x, y FROM t1 WHERE 11=w AND x>2
+} {*SEARCH t1 USING INDEX i1w (w=?)*}
+do_eqp_test where-1.4.2b {
+ SELECT w, x, y FROM t1 WHERE 11 IS w AND x>2
+} {*SEARCH t1 USING INDEX i1w (w=?)*}
+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_eqp_test where-1.4.4 {
+ SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2
+} {*SEARCH t1 USING INDEX i1w (w=?)*}
+do_test where-1.5 {
+ count {SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2}
+} {3 144 3}
+do_eqp_test where-1.5.2 {
+ SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2
+} {*SEARCH t1 USING INDEX i1w (w=?)*}
+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_eqp_test where-1.8.2 {
+ SELECT x, y FROM t1 WHERE w>10 AND y=144 AND x=3
+} {*SEARCH t1 USING INDEX i1xy (x=? AND y=?)*}
+do_eqp_test where-1.8.3 {
+ SELECT x, y FROM t1 WHERE y=144 AND x=3
+} {*SEARCH t1 USING COVERING INDEX i1xy (x=? AND y=?)*}
+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}
+do_test where-1.11b {
+ count {SELECT x, y FROM t1 WHERE x IS 3 AND y IS 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.12b {
+ count {SELECT w FROM t1 WHERE x IS 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.14b {
+ count {SELECT w FROM t1 WHERE 3 IS 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.18b {
+ count {SELECT w FROM t1 WHERE x IS 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.22b {
+ count {SELECT w FROM t1 WHERE x IS 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 3}
+do_test where-1.36 {
+ count {SELECT w FROM t1 WHERE w<=3}
+} {1 2 3 4}
+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.3a {
+ count {
+ SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1;
+ }
+ } {1 0 4 2 1 9 3 1 16 12}
+ do_test where-5.3b {
+ count {
+ SELECT * FROM t1 WHERE w IN (3,-1,1,2) order by 1;
+ }
+ } {1 0 4 2 1 9 3 1 16 12}
+ do_test where-5.3c {
+ count {
+ SELECT * FROM t1 WHERE w IN (3,2,-1,1,2) order by 1;
+ }
+ } {1 0 4 2 1 9 3 1 16 12}
+ do_test where-5.3d {
+ count {
+ SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1 DESC;
+ }
+ } {3 1 16 2 1 9 1 0 4 11}
+ 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 6}
+ 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 6}
+ 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 5}
+ 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 9}
+ do_test where-5.100 {
+ db eval {
+ SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)
+ ORDER BY x, y
+ }
+ } {2 1 9 54 5 3025 62 5 3969}
+ do_test where-5.101 {
+ db eval {
+ SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)
+ ORDER BY x DESC, y DESC
+ }
+ } {62 5 3969 54 5 3025 2 1 9}
+ do_test where-5.102 {
+ db eval {
+ SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)
+ ORDER BY x DESC, y
+ }
+ } {54 5 3025 62 5 3969 2 1 9}
+ do_test where-5.103 {
+ db eval {
+ SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)
+ ORDER BY x, y DESC
+ }
+ } {2 1 9 62 5 3969 54 5 3025}
+}
+
+# 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.1 {
+ cksort {
+ SELECT * FROM t3 WHERE b>0 ORDER BY a LIMIT 10
+ }
+} {/1 100 4 2 99 9 3 98 16 .* nosort/}
+do_test where-6.7.2 {
+ cksort {
+ SELECT * FROM t3 WHERE b>0 ORDER BY a LIMIT 1
+ }
+} {1 100 4 nosort}
+ifcapable subquery {
+ do_test where-6.8a {
+ 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 nosort}
+ do_test where-6.8b {
+ cksort {
+ SELECT * FROM t3 WHERE a IN (3,5,7,1,9,4,2) ORDER BY a DESC LIMIT 3
+ }
+ } {9 92 100 7 94 64 5 96 36 nosort}
+}
+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 nosort}
+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.
+#
+if {[permutation] != "no_optimization"} {
+do_test where-14.1 {
+ execsql {
+ CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT UNIQUE, c CHAR(100));
+ INSERT INTO t8(a,b) VALUES(1,'one');
+ INSERT INTO t8(a,b) 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 nosort}
+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 nosort}
+do_test where-14.3 {
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, x.b
+ }
+} {1/4 1/1 4/4 4/1 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/4 1/1 4/4 4/1 nosort}
+do_test where-14.5 {
+ # This test case changed from "nosort" to "sort". See ticket 2a5629202f.
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b
+ }
+} {/4/[14] 4/[14] 1/[14] 1/[14] sort/}
+do_test where-14.6 {
+ # This test case changed from "nosort" to "sort". See ticket 2a5629202f.
+ cksort {
+ SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b DESC
+ }
+} {/4/[14] 4/[14] 1/[14] 1/[14] sort/}
+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/4 4/1 1/4 1/1 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}
+} ;# {permutation != "no_optimization"}
+
+# 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}
+
+# Ticket [be84e357c035d068135f20bcfe82761bbf95006b] 2013-09-03
+# Segfault during query involving LEFT JOIN column in the ORDER BY clause.
+#
+do_execsql_test where-18.1 {
+ CREATE TABLE t181(a);
+ CREATE TABLE t182(b,c);
+ INSERT INTO t181 VALUES(1);
+ SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY c IS NULL;
+} {1}
+do_execsql_test where-18.1rj {
+ SELECT DISTINCT a FROM t182 RIGHT JOIN t181 ON a=b ORDER BY c IS NULL;
+} {1}
+do_execsql_test where-18.2 {
+ SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY +c;
+} {1}
+do_execsql_test where-18.3 {
+ SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY c;
+} {1}
+do_execsql_test where-18.3rj {
+ SELECT DISTINCT a FROM t182 RIGHT JOIN t181 ON a=b ORDER BY c;
+} {1}
+do_execsql_test where-18.4 {
+ INSERT INTO t181 VALUES(1),(1),(1),(1);
+ SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY +c;
+} {1}
+do_execsql_test where-18.4rj {
+ SELECT DISTINCT a FROM t182 RIGHT JOIN t181 ON a=b ORDER BY +c;
+} {1}
+do_execsql_test where-18.5 {
+ INSERT INTO t181 VALUES(2);
+ SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY c IS NULL, +a;
+} {1 2}
+do_execsql_test where-18.6 {
+ INSERT INTO t181 VALUES(2);
+ SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY +a, +c IS NULL;
+} {1 2}
+
+# Make sure the OR optimization works on a JOIN
+#
+do_execsql_test where-19.0 {
+ CREATE TABLE t191(a INT UNIQUE NOT NULL, b INT UNIQUE NOT NULL,c,d);
+ CREATE INDEX t191a ON t1(a);
+ CREATE INDEX t191b ON t1(b);
+ CREATE TABLE t192(x INTEGER PRIMARY KEY,y INT, z INT);
+
+ EXPLAIN QUERY PLAN
+ SELECT t191.rowid FROM t192, t191 WHERE (a=y OR b=y) AND x=?1;
+} {/.* sqlite_autoindex_t191_1 .* sqlite_autoindex_t191_2 .*/}
+
+# 2018-04-24 ticket [https://www.sqlite.org/src/info/4ba5abf65c5b0f9a]
+# Index on expressions leads to an incorrect answer for a LEFT JOIN
+#
+do_execsql_test where-20.0 {
+ CREATE TABLE t201(x);
+ CREATE TABLE t202(y, z);
+ INSERT INTO t201 VALUES('key');
+ INSERT INTO t202 VALUES('key', -1);
+ CREATE INDEX t202i ON t202(y, ifnull(z, 0));
+ SELECT count(*) FROM t201 LEFT JOIN t202 ON (x=y) WHERE ifnull(z, 0) >=0;
+} {0}
+
+do_execsql_test where-21.0 {
+ CREATE TABLE t12(a, b, c);
+ CREATE TABLE t13(x);
+ CREATE INDEX t12ab ON t12(b, a);
+ CREATE INDEX t12ac ON t12(c, a);
+
+ INSERT INTO t12 VALUES(4, 0, 1);
+ INSERT INTO t12 VALUES(4, 1, 0);
+ INSERT INTO t12 VALUES(5, 0, 1);
+ INSERT INTO t12 VALUES(5, 1, 0);
+
+ INSERT INTO t13 VALUES(1), (2), (3), (4);
+}
+do_execsql_test where-21.1 {
+ SELECT * FROM t12 WHERE
+ a = (SELECT * FROM (SELECT count(*) FROM t13 LIMIT 5) ORDER BY 1 LIMIT 10)
+ AND (b=1 OR c=1);
+} {
+ 4 1 0
+ 4 0 1
+}
+
+# 2018-11-05: ticket [https://www.sqlite.org/src/tktview/65eb38f6e46de8c75e188a]
+# Incorrect result in LEFT JOIN when STAT4 is enabled.
+#
+sqlite3 db :memory:
+do_execsql_test where-22.1 {
+ CREATE TABLE t1(a INT);
+ CREATE INDEX t1a ON t1(a);
+ INSERT INTO t1(a) VALUES(NULL),(NULL),(42),(NULL),(NULL);
+ CREATE TABLE t2(dummy INT);
+ SELECT count(*) FROM t1 LEFT JOIN t2 ON a IS NOT NULL;
+} {5}
+
+# 20190-02-22: A bug introduced by checkin
+# https://www.sqlite.org/src/info/fa792714ae62fa98.
+#
+do_execsql_test where-23.0 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY);
+ INSERT INTO t1(a) VALUES(1),(2),(3);
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y INT);
+ INSERT INTO t2(y) VALUES(2),(3);
+ SELECT * FROM t1, t2 WHERE a=y AND y=3;
+} {3 2 3}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test where-24.0 {
+ 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');
+ INSERT INTO t1 VALUES(4, 'four');
+}
+
+foreach {tn sql res} {
+ 1 "SELECT b FROM t1" {one two three four}
+ 2 "SELECT b FROM t1 WHERE a<4" {one two three}
+ 3 "SELECT b FROM t1 WHERE a>1" {two three four}
+ 4 "SELECT b FROM t1 WHERE a>1 AND a<4" {two three}
+
+ 5 "SELECT b FROM t1 WHERE a>? AND a<4" {}
+ 6 "SELECT b FROM t1 WHERE a>1 AND a<?" {}
+ 7 "SELECT b FROM t1 WHERE a>? AND a<?" {}
+
+ 7 "SELECT b FROM t1 WHERE a>=? AND a<=4" {}
+ 8 "SELECT b FROM t1 WHERE a>=1 AND a<=?" {}
+ 9 "SELECT b FROM t1 WHERE a>=? AND a<=?" {}
+} {
+ set rev [list]
+ foreach r $res { set rev [concat $r $rev] }
+
+ do_execsql_test where-24.$tn.1 "$sql" $res
+ do_execsql_test where-24.$tn.2 "$sql ORDER BY rowid" $res
+ do_execsql_test where-24.$tn.3 "$sql ORDER BY rowid DESC" $rev
+
+ do_execsql_test where-24-$tn.4 "
+ BEGIN;
+ DELETE FROM t1;
+ $sql;
+ $sql ORDER BY rowid;
+ $sql ORDER BY rowid DESC;
+ ROLLBACK;
+ "
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test where-25.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ CREATE UNIQUE INDEX i1 ON t1(c);
+ INSERT INTO t1 VALUES(1, 'one', 'i');
+ INSERT INTO t1 VALUES(2, 'two', 'ii');
+
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
+ CREATE UNIQUE INDEX i2 ON t2(c);
+ INSERT INTO t2 VALUES(1, 'one', 'i');
+ INSERT INTO t2 VALUES(2, 'two', 'ii');
+ INSERT INTO t2 VALUES(3, 'three', 'iii');
+
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_schema SET rootpage = (
+ SELECT rootpage FROM sqlite_schema WHERE name = 'i2'
+ ) WHERE name = 'i1';
+}
+db close
+sqlite3 db test.db
+do_catchsql_test where-25.1 {
+ DELETE FROM t1 WHERE c='iii'
+} {1 {database disk image is malformed}}
+do_catchsql_test where-25.2 {
+ INSERT INTO t1 VALUES(4, 'four', 'iii')
+ ON CONFLICT(c) DO UPDATE SET b=NULL
+} {1 {database disk image is malformed}}
+
+reset_db
+do_execsql_test where-25.3 {
+ CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
+ CREATE UNIQUE INDEX i1 ON t1(c);
+ INSERT INTO t1 VALUES(1, 'one', 'i');
+ INSERT INTO t1 VALUES(2, 'two', 'ii');
+
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
+ CREATE UNIQUE INDEX i2 ON t2(c);
+ INSERT INTO t2 VALUES(1, 'one', 'i');
+ INSERT INTO t2 VALUES(2, 'two', 'ii');
+ INSERT INTO t2 VALUES(3, 'three', 'iii');
+
+ PRAGMA writable_schema = 1;
+ UPDATE sqlite_schema SET rootpage = (
+ SELECT rootpage FROM sqlite_schema WHERE name = 'i2'
+ ) WHERE name = 'i1';
+}
+db close
+sqlite3 db test.db
+do_catchsql_test where-25.4 {
+ SELECT * FROM t1 WHERE c='iii'
+} {0 {}}
+do_catchsql_test where-25.5 {
+ INSERT INTO t1 VALUES(4, 'four', 'iii')
+ ON CONFLICT(c) DO UPDATE SET b=NULL
+} {1 {corrupt database}}
+
+# 2019-08-21 Ticket https://www.sqlite.org/src/info/d9f584e936c7a8d0
+#
+db close
+sqlite3 db :memory:
+do_execsql_test where-26.1 {
+ CREATE TABLE t0(c0 INTEGER PRIMARY KEY, c1 TEXT);
+ INSERT INTO t0(c0, c1) VALUES (1, 'a');
+ CREATE TABLE t1(c0 INT PRIMARY KEY, c1 TEXT);
+ INSERT INTO t1(c0, c1) VALUES (1, 'a');
+ SELECT * FROM t0 WHERE '-1' BETWEEN 0 AND t0.c0;
+} {1 a}
+do_execsql_test where-26.2 {
+ SELECT * FROM t1 WHERE '-1' BETWEEN 0 AND t1.c0;
+} {1 a}
+do_execsql_test where-26.3 {
+ SELECT * FROM t0 WHERE '-1'>=0 AND '-1'<=t0.c0;
+} {1 a}
+do_execsql_test where-26.4 {
+ SELECT * FROM t1 WHERE '-1'>=0 AND '-1'<=t1.c0;
+} {1 a}
+do_execsql_test where-26.5 {
+ SELECT '-1' BETWEEN 0 AND t0.c0 FROM t0;
+} {1}
+do_execsql_test where-26.6 {
+ SELECT '-1' BETWEEN 0 AND t1.c0 FROM t1;
+} {1}
+do_execsql_test where-26.7 {
+ SELECT '-1'>=0 AND '-1'<=t0.c0 FROM t0;
+} {1}
+do_execsql_test where-26.8 {
+ SELECT '-1'>=0 AND '-1'<=t1.c0 FROM t1;
+} {1}
+
+# 2021-07-19 https://sqlite.org/forum/forumpost/2bdb86a068
+# Lose of precision when doing comparisons between integer and
+# floating point values that are near 9223372036854775807 in the
+# OP_SeekGE opcode (and similar).
+#
+# Valgrind documentation acknowledges that under valgrind, FP calculations
+# may not be as accurate as on x86/amd64 hardware. This seems to be causing
+# these tests to fail.
+#
+# https://valgrind.org/docs/manual/manual-core.html#manual-core.limits
+#
+if {[permutation]!="valgrind"} {
+ reset_db
+ do_execsql_test where-27.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY);
+ INSERT INTO t1(a) VALUES(9223372036854775807);
+ SELECT 1 FROM t1 WHERE a>=(9223372036854775807+1);
+ } {}
+ do_execsql_test where-27.2 {
+ SELECT a>=9223372036854775807+1 FROM t1;
+ } {0}
+}
+
+# 2022-05-10 dbsqlfuzz 4c5e3e89bc251d28378be88233f531b84ec66901
+#
+reset_db
+do_execsql_test where-28.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
+ CREATE INDEX t1b ON t1(b,b,b,b,b,b,b,b,b,b,b,b,b);
+ INSERT INTO t1(a,b) VALUES(1,1),(15,2),(19,5);
+ UPDATE t1 SET b=999 WHERE a IN (SELECT 15) AND b IN (1,2);
+ SELECT * FROM t1;
+} {
+ 1 1
+ 15 999
+ 19 5
+}
+
+# 2022-12-07 Yong Heng [https://sqlite.org/forum/forumpost/dfe8084751]
+#
+ifcapable vtab {
+ do_execsql_test where-29.1 {
+ SELECT DISTINCT 'xyz' FROM pragma_cache_size
+ WHERE rowid OR abs(0)
+ ORDER BY
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1;
+ } {xyz}
+}
+
+finish_test
diff --git a/test/where2.test b/test/where2.test
new file mode 100644
index 0000000..7a7e9b9
--- /dev/null
+++ b/test/where2.test
@@ -0,0 +1,781 @@
+# 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 name of the table and index used.
+#
+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
+ set eqp [execsql "EXPLAIN QUERY PLAN $sql"]
+ # puts eqp=$eqp
+ foreach {a b c x} $eqp {
+ if {[regexp {SCAN CONSTANT} $x]} {
+ # noop
+ } elseif {[regexp {(SCAN|SEARCH) (\w+ AS )?(\w+) USING.* INDEX (\w+)\y} \
+ $x all ss as tab idx]} {
+ lappend data $tab $idx
+ } elseif {[regexp {(SCAN|SEARCH) (\w+ AS )?(\w+)\y} $x all ss as tab]} {
+ lappend data $tab *
+ }
+ }
+ return $data
+}
+
+
+# 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 *}
+
+# Ticket [65bdeb9739605cc22966f49208452996ff29a640] 2014-02-26
+# Make sure "ORDER BY random" does not gets optimized out.
+#
+do_test where2-2.4 {
+ db eval {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b DEFAULT 1);
+ WITH RECURSIVE
+ cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<50)
+ INSERT INTO x1 SELECT x, 1 FROM cnt;
+ CREATE TABLE x2(x INTEGER PRIMARY KEY);
+ INSERT INTO x2 VALUES(1);
+ }
+ set sql {SELECT * FROM x1, x2 WHERE x=1 ORDER BY random()}
+ set out1 [db eval $sql]
+ set out2 [db eval $sql]
+ set out3 [db eval $sql]
+ expr {$out1!=$out2 && $out2!=$out3}
+} {1}
+do_execsql_test where2-2.5 {
+ -- random() is not optimized out
+ EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY random();
+} {/ random/}
+do_execsql_test where2-2.5b {
+ -- random() is not optimized out
+ EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY random();
+} {/ SorterOpen /}
+do_execsql_test where2-2.6 {
+ -- other constant functions are optimized out
+ EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY abs(5);
+} {~/ abs/}
+do_execsql_test where2-2.6b {
+ -- other constant functions are optimized out
+ EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY abs(5);
+} {~/ SorterOpen /}
+
+
+
+# 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.6a {
+ 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 x
+ }
+ } {99 6 10000 10006 nosort t1 i1xy}
+ do_test where2-4.6b {
+ 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 x DESC
+ }
+ } {99 6 10000 10006 nosort t1 i1xy}
+ do_test where2-4.6c {
+ 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 x, y
+ }
+ } {99 6 10000 10006 nosort t1 i1xy}
+ do_test where2-4.6d {
+ 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 x, y DESC
+ }
+ } {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.6x {
+ 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}
+ do_test where2-4.6y {
+ queryplan {
+ SELECT * FROM t1 WHERE z IN (10207,10006,10006,10207)
+ ORDER BY w DESC
+ }
+ } {100 6 10201 10207 99 6 10000 10006 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.2a {
+ queryplan {
+ SELECT * FROM t1 WHERE w IN (99) ORDER BY w
+ }
+ } {99 6 10000 10006 nosort t1 i1w}
+ do_test where2-5.2b {
+ queryplan {
+ SELECT * FROM t1 WHERE w IN (99) ORDER BY w DESC
+ }
+ } {99 6 10000 10006 nosort 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 *}
+do_test where2-6.5 {
+ queryplan {
+ SELECT *, '|' FROM t1 WHERE w=99 OR y=10201 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]
+
+if {[permutation] != "no_optimization"} {
+
+# 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, x CHAR(100));
+ CREATE TABLE t2249b(b INTEGER);
+ INSERT INTO t2249a(a) 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 b,a FROM t2249b CROSS JOIN t2249a WHERE a=b;
+ }
+} {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
+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 b,a FROM t2249b CROSS JOIN t2249a WHERE a=+b;
+ }
+} {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
+do_test where2-6.9.2 {
+ # The same thing but with the expression flipped around.
+ queryplan {
+ SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE +b=a
+ }
+} {nosort t2249b * t2249a 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 b,a FROM t2249b CROSS JOIN t2249a WHERE +a=+b;
+ }
+} {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
+do_test where2-6.11 {
+ # This will not attempt the OR optimization because of the a=b
+ # comparison.
+ queryplan {
+ SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=b OR a='hello';
+ }
+} {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
+do_test where2-6.11.2 {
+ # Permutations of the expression terms.
+ queryplan {
+ SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE b=a OR a='hello';
+ }
+} {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
+do_test where2-6.11.3 {
+ # Permutations of the expression terms.
+ queryplan {
+ SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE 'hello'=a OR b=a;
+ }
+} {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
+do_test where2-6.11.4 {
+ # Permutations of the expression terms.
+ queryplan {
+ SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR b=a;
+ }
+} {123 0123 nosort t2249b * t2249a 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.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 b,a FROM t2249b CROSS JOIN t2249a WHERE a=+b OR a='hello';
+ }
+ } {nosort t2249b * t2249a 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 b,a FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR +b=a;
+ }
+ } {nosort t2249b * t2249a 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 b,a FROM t2249b CROSS JOIN t2249a WHERE +b=a OR a='hello';
+ }
+ } {nosort t2249b * t2249a 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 b,a FROM t2249b CROSS JOIN t2249a WHERE a=+b OR +a='hello';
+ }
+ } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
+}
+
+# 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 x.a, y.a FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a
+ }
+} {0123 0123 nosort x sqlite_autoindex_t2249a_1 y 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 x.a,y.a FROM t2249a x CROSS JOIN t2249a y
+ WHERE x.a=y.a OR y.a='hello'
+ }
+ } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}
+ do_test where2-6.22 {
+ queryplan {
+ SELECT x.a,y.a FROM t2249a x CROSS JOIN t2249a y
+ WHERE y.a=x.a OR y.a='hello'
+ }
+ } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}
+ do_test where2-6.23 {
+ queryplan {
+ SELECT x.a,y.a FROM t2249a x CROSS JOIN t2249a y
+ WHERE y.a='hello' OR x.a=y.a
+ }
+ } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y 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}
+
+} ;# if {[permutation] != "no_optimization"}
+
+# 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}
+
+# Verify that the OR clause is used in an outer loop even when
+# the OR clause scores slightly better on an inner loop.
+if {[permutation] != "no_optimization"} {
+do_execsql_test where2-12.1 {
+ CREATE TABLE t12(x INTEGER PRIMARY KEY, y INT, z CHAR(100));
+ CREATE INDEX t12y ON t12(y);
+ EXPLAIN QUERY PLAN
+ SELECT a.x, b.x
+ FROM t12 AS a JOIN t12 AS b ON a.y=b.x
+ WHERE (b.x=$abc OR b.y=$abc);
+} {/SEARCH b .*SEARCH b /}
+}
+
+# Verify that all necessary OP_OpenRead opcodes occur in the OR optimization.
+#
+do_execsql_test where2-13.1 {
+ CREATE TABLE t13(a,b);
+ CREATE INDEX t13a ON t13(a);
+ INSERT INTO t13 VALUES(4,5);
+ SELECT * FROM t13 WHERE (1=2 AND a=3) OR a=4;
+} {4 5}
+
+# https://www.sqlite.org/src/info/5e3c886796e5512e (2016-03-09)
+# Correlated subquery on the RHS of an IN operator
+#
+do_execsql_test where2-14.1 {
+ CREATE TABLE t14a(x INTEGER PRIMARY KEY);
+ INSERT INTO t14a(x) VALUES(1),(2),(3),(4);
+ CREATE TABLE t14b(y INTEGER PRIMARY KEY);
+ INSERT INTO t14b(y) VALUES(1);
+ SELECT x FROM t14a WHERE x NOT IN (SELECT x FROM t14b);
+} {}
+
+finish_test
diff --git a/test/where3.test b/test/where3.test
new file mode 100644
index 0000000..20af995
--- /dev/null
+++ b/test/where3.test
@@ -0,0 +1,496 @@
+# 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&&!cursorhints {
+ 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&&!cursorhints {
+ 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 names of the table and index used
+#
+proc queryplan {sql} {
+ set ::sqlite_sort_count 0
+ set data [execsql $sql]
+ set eqp [execsql "EXPLAIN QUERY PLAN $sql"]
+ # puts eqp=$eqp
+ foreach {a b c x} $eqp {
+ if {[regexp {SCAN CONSTANT} $x]} {
+ # noop
+ } elseif {[regexp {(SCAN|SEARCH) (\w+ AS )?(\w+) USING.* INDEX (\w+)\y} \
+ $x all ss as tab idx]} {
+ lappend data $tab $idx
+ } elseif {[regexp {(SCAN|SEARCH) (\w+ AS )?(\w+)\y} $x all ss as tab]} {
+ lappend data $tab *
+ }
+ }
+ return $data
+}
+
+
+# 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);
+ INSERT INTO t301 VALUES(2,2,3);
+ CREATE TABLE t302(x, y);
+ INSERT INTO t302 VALUES(4,5);
+ ANALYZE;
+}
+do_eqp_test where3-3.0a {
+ SELECT * FROM t302, t301 WHERE t302.x=5 AND t301.a=t302.y;
+} {
+ QUERY PLAN
+ |--SCAN t302
+ `--SEARCH t301 USING INTEGER PRIMARY KEY (rowid=?)
+}
+do_eqp_test where3-3.1 {
+ SELECT * FROM t301, t302 WHERE t302.x=5 AND t301.a=t302.y;
+} {
+ QUERY PLAN
+ |--SCAN t302
+ `--SEARCH t301 USING INTEGER PRIMARY KEY (rowid=?)
+}
+do_execsql_test where3-3.2 {
+ SELECT * FROM t301 WHERE c=3 AND a IS NULL;
+} {}
+do_execsql_test where3-3.3 {
+ SELECT * FROM t301 WHERE c=3 AND a IS NOT NULL;
+} {1 2 3 2 2 3}
+
+if 0 { # Query planner no longer does this
+# 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 t402}
+ 0 1 0 {SCAN t400}
+ 0 2 1 {SCAN t401}
+}
+do_execsql_test where3-4.1 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t400, t401, t402 WHERE t401.r GLOB 'abc*';
+} {
+ 0 0 1 {SCAN t401}
+ 0 1 0 {SCAN t400}
+ 0 2 2 {SCAN t402}
+}
+do_execsql_test where3-4.2 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t400, t401, t402 WHERE t400.c GLOB 'abc*';
+} {
+ 0 0 0 {SCAN t400}
+ 0 1 1 {SCAN t401}
+ 0 2 2 {SCAN t402}
+}
+} ;# endif
+
+# 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);
+}
+do_eqp_test where3-5.0a {
+ 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;
+} {
+ QUERY PLAN
+ |--SEARCH aaa USING INDEX aaa_333 (fk=?)
+ |--SEARCH bbb USING INTEGER PRIMARY KEY (rowid=?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_eqp_test where3-5.1 {
+ 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;
+} {
+ QUERY PLAN
+ |--SEARCH aaa USING INDEX aaa_333 (fk=?)
+ |--SEARCH bbb USING INTEGER PRIMARY KEY (rowid=?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_eqp_test where3-5.2 {
+ 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;
+} {
+ QUERY PLAN
+ |--SEARCH aaa USING INDEX aaa_333 (fk=?)
+ |--SEARCH bbb USING INTEGER PRIMARY KEY (rowid=?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_eqp_test where3-5.3 {
+ 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;
+} {
+ QUERY PLAN
+ |--SEARCH aaa USING INDEX aaa_333 (fk=?)
+ |--SEARCH bbb USING INTEGER PRIMARY KEY (rowid=?)
+ `--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}
+}
+
+do_execsql_test where3-7-setup {
+ CREATE TABLE t71(x1 INTEGER PRIMARY KEY, y1);
+ CREATE TABLE t72(x2 INTEGER PRIMARY KEY, y2);
+ CREATE TABLE t73(x3, y3);
+ CREATE TABLE t74(x4, y4);
+ INSERT INTO t71 VALUES(123,234);
+ INSERT INTO t72 VALUES(234,345);
+ INSERT INTO t73 VALUES(123,234);
+ INSERT INTO t74 VALUES(234,345);
+ INSERT INTO t74 VALUES(234,678);
+} {}
+foreach disabled_opt {none omit-noop-join all} {
+ optimization_control db all 1
+ optimization_control db $disabled_opt 0
+ do_execsql_test where3-7.$disabled_opt.1 {
+ SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1;
+ } {123}
+ do_execsql_test where3-7.$disabled_opt.2 {
+ SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1 WHERE y2 IS NULL;
+ } {}
+ do_execsql_test where3-7.$disabled_opt.3 {
+ SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1 WHERE y2 IS NOT NULL;
+ } {123}
+ do_execsql_test where3-7.$disabled_opt.4 {
+ SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1 AND y2 IS NULL;
+ } {123}
+ do_execsql_test where3-7.$disabled_opt.5 {
+ SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1 AND y2 IS NOT NULL;
+ } {123}
+ do_execsql_test where3-7.$disabled_opt.6 {
+ SELECT x3 FROM t73 LEFT JOIN t72 ON x2=y3;
+ } {123}
+ do_execsql_test where3-7.$disabled_opt.7 {
+ SELECT DISTINCT x3 FROM t73 LEFT JOIN t72 ON x2=y3;
+ } {123}
+ do_execsql_test where3-7.$disabled_opt.8 {
+ SELECT x3 FROM t73 LEFT JOIN t74 ON x4=y3;
+ } {123 123}
+ do_execsql_test where3-7.$disabled_opt.9 {
+ SELECT DISTINCT x3 FROM t73 LEFT JOIN t74 ON x4=y3;
+ } {123}
+}
+
+
+finish_test
diff --git a/test/where4.test b/test/where4.test
new file mode 100644
index 0000000..bafc84f
--- /dev/null
+++ b/test/where4.test
@@ -0,0 +1,307 @@
+# 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
+set testprefix where4
+
+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.1b {
+ unset -nocomplain null
+ 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 2}
+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}
+} {0}
+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}
+} {1}
+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' ASC)); -- Goofy syntax allowed
+ 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 {} {}}
+do_test where4-3.3 {
+ execsql {
+ SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE NULL is y;
+ }
+} {2 2 {} 3 {} {}}
+do_test where4-3.4 {
+ unset -nocomplain null
+ 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 {
+ -- Allow the 'x' syntax for backwards compatibility
+ CREATE TABLE t4(x,y,z,PRIMARY KEY('x' ASC, "y" ASC));
+ }
+ 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
+
+#-------------------------------------------------------------------------
+# Verify that "IS ?" with a NULL bound to the variable also functions
+# correctly.
+
+unset -nocomplain null
+
+do_execsql_test 8.1 {
+ CREATE TABLE u9(a UNIQUE, b);
+ INSERT INTO u9 VALUES(NULL, 1);
+ INSERT INTO u9 VALUES(NULL, 2);
+}
+do_execsql_test 8.2 { SELECT * FROM u9 WHERE a IS NULL } {{} 1 {} 2}
+do_execsql_test 8.2 { SELECT * FROM u9 WHERE a IS $null } {{} 1 {} 2}
+
+
+
+
+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..f76e8ab
--- /dev/null
+++ b/test/where7.test
@@ -0,0 +1,23388 @@
+# 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_execsql_test where7-1.1.1 {
+ CREATE TABLE t(a);
+ CREATE INDEX ta ON t(a);
+ INSERT INTO t(a) VALUES(1),(2);
+ SELECT * FROM t ORDER BY a;
+ SELECT * FROM t WHERE a<2 OR a<3 ORDER BY a;
+ PRAGMA count_changes=ON;
+ DELETE FROM t WHERE a<2 OR a<3;
+ SELECT * FROM t;
+ PRAGMA count_changes=OFF;
+ DROP TABLE t;
+} {1 2 1 2 2}
+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
+# removed.
+#
+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);
+}
+do_eqp_test where7-3.2 {
+ 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;
+} {
+ QUERY PLAN
+ |--MULTI-INDEX OR
+ | |--INDEX 1
+ | | `--SEARCH t301 USING COVERING INDEX t301_c4 (c4=?)
+ | `--INDEX 2
+ | `--SEARCH t301 USING INTEGER PRIMARY KEY (rowid=?)
+ |--SEARCH t302 USING INDEX t302_c8_c3 (c8=? AND c3>?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+
+# 2022-03-03 https://sqlite.org/forum/forumpost/36937b197273d403
+#
+# In the multi-index OR, if there is an auxiliary WHERE clause term
+# that includes a subquery and that subquery is pushed down into the
+# OR-clause subqueries, WHERE subquery might get coded as a subroutine.
+# In that case, the covering-index optimizer will attempt to change
+# table-references into index-references. But it will do so for the
+# index of the OR branch in which the subquery is coded. If the
+# subquery subroutine is called from a different OR branch, the
+# index might be different and the index-reference will no longer
+# work. tag-20220303a
+#
+reset_db
+do_execsql_test 4.1 {
+ CREATE TABLE t0(w);
+ INSERT INTO t0(w) VALUES(1);
+ CREATE TABLE t1(x INT, y INT PRIMARY KEY, z);
+ INSERT INTO t1 VALUES(0,111,222);
+ CREATE INDEX t1zxy ON t1(z,x,y);
+ SELECT y FROM t1
+ WHERE (z=222 OR y=111)
+ AND (false OR EXISTS(SELECT 1 FROM t0 WHERE t1.y));
+} {111}
+
+finish_test
diff --git a/test/where8.test b/test/where8.test
new file mode 100644
index 0000000..a8dbcfd
--- /dev/null
+++ b/test/where8.test
@@ -0,0 +1,773 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {[permutation]=="sorterref"} {
+ finish_test
+ return
+}
+
+# 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}
+
+ifcapable like_match_blobs {
+ do_test where8-1.4a {
+ execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 't*' }
+ } {IX X III II 0 0 10}
+ do_test where8-1.5a {
+ execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 'f*' }
+ } {IX X V IV 0 0 10}
+} else {
+ do_test where8-1.4b {
+ 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 7}
+
+do_test where8-1.10 {
+ execsql_status2 {
+ SELECT c FROM t1 WHERE (a >= 9 AND c != 'X') OR b <= 'eight'
+ }
+} {IX VIII 0 0 7}
+
+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')
+ ORDER BY +a, +d;
+ }
+} {2 2 2 4 3 3 3 4 0 1}
+
+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 [01]/}
+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 9 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}
+
+
+do_test where8-3.21 {
+ 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.21.1 {
+ execsql_status {
+ SELECT a, d FROM t1, ((t2)) AS t3 WHERE (a=d OR b=e) AND a<5 ORDER BY a
+ }
+} {1 1 2 2 3 3 4 2 4 4 0 0}
+if {[permutation] != "no_optimization"} {
+do_test where8-3.21.2 {
+ execsql_status {
+ SELECT a, d FROM t1, ((SELECT * FROM t2)) AS t3 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.22 {
+ 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}
+if {[permutation] != "no_optimization"} {
+do_test where8-3.23 {
+ execsql_status {
+ SELECT * FROM ((SELECT * FROM t2)) AS t3;
+ }
+} {1 {} I 2 four IV 3 {} IX 4 sixteen XVI 5 {} XXV 6 thirtysix XXXVI 7 fortynine XLIX 8 sixtyeight LXIV 9 eightyone LXXXIX 10 {} C 9 0}
+}
+
+#-----------------------------------------------------------------------
+# 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 {}}
+
+# The OR optimization and WITHOUT ROWID
+#
+do_execsql_test where8-6.1 {
+ CREATE TABLE t600(a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE INDEX t600b ON t600(b);
+ INSERT INTO t600 VALUES('state','screen'),('exact','dolphin'),('green','mercury');
+ SELECT a, b, '|' FROM t600 WHERE a=='state' OR b='mercury' ORDER BY +a;
+} {green mercury | state screen |}
+
+finish_test
diff --git a/test/where9.test b/test/where9.test
new file mode 100644
index 0000000..4757881
--- /dev/null
+++ b/test/where9.test
@@ -0,0 +1,1004 @@
+# 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||!compound {
+ 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_eqp_test where9-3.1 {
+ 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)
+ } [string map {"\n " \n} {
+ QUERY PLAN
+ |--SEARCH t1 USING INTEGER PRIMARY KEY (rowid=?)
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SEARCH t2 USING INDEX t2d (d=?)
+ `--INDEX 3
+ `--SEARCH t2 USING COVERING INDEX t2f (f=?)
+ }]
+ do_eqp_test where9-3.2 {
+ 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
+ } [string map {"\n " \n} {
+ QUERY PLAN
+ |--SEARCH t1 USING INTEGER PRIMARY KEY (rowid=?)
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SEARCH t2 USING INDEX t2d (d=?) LEFT-JOIN
+ `--INDEX 2
+ `--SEARCH t2 USING COVERING INDEX t2f (f=?) LEFT-JOIN
+ }]
+}
+
+# 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
+ }
+} {0 {92 93 97}}
+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
+ }
+} {0 {92 93 97}}
+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
+ }
+} {0 {92 93 97}}
+
+# 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_eqp_test where9-5.1 {
+ SELECT a FROM t1 WHERE b>1000 AND (c=31031 OR d IS NULL)
+} {
+ QUERY PLAN
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SEARCH t1 USING INDEX t1c (c=?)
+ `--INDEX 2
+ `--SEARCH t1 USING INDEX t1d (d=?)
+}
+
+# In contrast, b=1000 is preferred over any OR-clause.
+#
+do_eqp_test where9-5.2 {
+ SELECT a FROM t1 WHERE b=1000 AND (c=31031 OR d IS NULL)
+} {SEARCH t1 USING INDEX t1b (b=?)}
+
+# Likewise, inequalities in an AND are preferred over inequalities in
+# an OR.
+#
+do_eqp_test where9-5.3 {
+ SELECT a FROM t1 WHERE b>1000 AND (c>=31031 OR d IS NULL)
+} {SEARCH t1 USING INDEX t1b (b>?)}
+
+############################################################################
+# 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) ORDER BY rowid;
+ 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)
+ }
+} {0 {}}
+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)
+ }
+} {0 {}}
+
+set solution_possible 0
+ifcapable stat4 {
+ if {[permutation] != "no_optimization"} { set solution_possible 1 }
+}
+if $solution_possible {
+ # When STAT3 is enabled, the "b NOT NULL" terms get translated
+ # into b>NULL, which can be satified by the index t1b. It is a very
+ # expensive way to do the query, but it works, and so a solution is possible.
+ do_test where9-6.8.3-stat4 {
+ 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)
+ }
+ } {0 {}}
+ do_test where9-6.8.4-stat4 {
+ 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)
+ }
+ } {0 {}}
+} else {
+ do_test where9-6.8.3 {
+ 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)
+ }
+ } {0 {}}
+ do_test where9-6.8.4 {
+ 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)
+ }
+ } {0 {}}
+}
+############################################################################
+# 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}
+
+# Fix for ticket [b7c8682cc17f32903f03a610bd0d35ffd3c1e6e4]
+# "Incorrect result from LEFT JOIN with OR in the WHERE clause"
+#
+do_test where9-8.1 {
+ db eval {
+ CREATE TABLE t81(a INTEGER PRIMARY KEY, b, c, d);
+ CREATE TABLE t82(x INTEGER PRIMARY KEY, y);
+ CREATE TABLE t83(p INTEGER PRIMARY KEY, q);
+
+ INSERT INTO t81 VALUES(2,3,4,5);
+ INSERT INTO t81 VALUES(3,4,5,6);
+ INSERT INTO t82 VALUES(2,4);
+ INSERT INTO t83 VALUES(5,55);
+
+ SELECT *
+ FROM t81 LEFT JOIN t82 ON y=b JOIN t83
+ WHERE c==p OR d==p
+ ORDER BY +a;
+ }
+} {2 3 4 5 {} {} 5 55 3 4 5 6 2 4 5 55}
+do_test where9-8.2 {
+ db eval {
+ SELECT *
+ FROM t81 LEFT JOIN (t82) ON y=b JOIN t83
+ WHERE c==p OR d==p
+ ORDER BY +a;
+ }
+} {2 3 4 5 {} {} 5 55 3 4 5 6 2 4 5 55}
+do_test where9-8.3 {
+ db eval {
+ SELECT *
+ FROM (t81) LEFT JOIN (main.t82) ON y=b JOIN t83
+ WHERE c==p OR d==p
+ ORDER BY +a;
+ }
+} {2 3 4 5 {} {} 5 55 3 4 5 6 2 4 5 55}
+
+# Fix for ticket [f2369304e47167e3e644e2f1fe9736063391d7b7]
+# Incorrect results when OR is used in the ON clause of a LEFT JOIN
+#
+do_test where9-9.1 {
+ db eval {
+ CREATE TABLE t91(x); INSERT INTO t91 VALUES(1);
+ CREATE TABLE t92(y INTEGER PRIMARY KEY,a,b);
+ INSERT INTO t92 VALUES(1,2,3);
+ SELECT 1 FROM t91 LEFT JOIN t92 ON a=2 OR b=3;
+ SELECT 2 FROM t91 LEFT JOIN t92 ON a=2 AND b=3;
+ SELECT 3 FROM t91 LEFT JOIN t92 ON (a=2 OR b=3) AND y IS NULL;
+ SELECT 4 FROM t91 LEFT JOIN t92 ON (a=2 AND b=3) AND y IS NULL;
+ CREATE TEMP TABLE x9 AS SELECT * FROM t91 LEFT JOIN t92 ON a=2 OR b=3;
+ SELECT 5 FROM x9 WHERE y IS NULL;
+ SELECT 6 FROM t91 LEFT JOIN t92 ON a=2 OR b=3 WHERE y IS NULL;
+ SELECT 7 FROM t91 LEFT JOIN t92 ON a=2 AND b=3 WHERE y IS NULL;
+ SELECT 8 FROM t91 LEFT JOIN t92 ON a=22 OR b=33 WHERE y IS NULL;
+ SELECT 9 FROM t91 LEFT JOIN t92 ON a=22 AND b=33 WHERE y IS NULL;
+ }
+} {1 2 3 4 8 9}
+
+# Fix for ticket [bc878246eafe0f52c519e29049b2fe4a99491b27]
+# Incorrect result when OR is used in a join to the right of a LEFT JOIN
+#
+do_test where9-10.1 {
+ db eval {
+ CREATE TABLE t101 (id INTEGER PRIMARY KEY);
+ INSERT INTO t101 VALUES (1);
+ SELECT * FROM t101 AS t0
+ LEFT JOIN t101 AS t1 ON t1.id BETWEEN 10 AND 20
+ JOIN t101 AS t2 ON (t2.id = t0.id OR (t2.id<>555 AND t2.id=t1.id));
+ }
+} {1 {} 1}
+do_test where9-10.2 {
+ db eval {
+ CREATE TABLE t102 (id TEXT UNIQUE NOT NULL);
+ INSERT INTO t102 VALUES ('1');
+ SELECT * FROM t102 AS t0
+ LEFT JOIN t102 AS t1 ON t1.id GLOB 'abc%'
+ JOIN t102 AS t2 ON (t2.id = t0.id OR (t2.id<>555 AND t2.id=t1.id));
+ }
+} {1 {} 1}
+
+# dbsqlfuzz 9df1d53c24c4c96af0dae15ee764897af415ac76
+# The MULTI-INDEX OR processing evaluates the same WHERE-clause sub-expression
+# twice. But if that sub-expression contains a UNION ALL SELECT statement
+# subject to query flattening, the sub-expression might be transformed in a
+# way that it can only be code-generated once. An assert() will fail on
+# the second attempt to generate code from the same sub-expression.
+# The solution is to make a copy of sub-expressions used by MULTI-INDEX OR
+#
+reset_db
+do_execsql_test where9-11.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ CREATE TABLE t2_a(k INTEGER PRIMARY KEY, v TEXT);
+ CREATE TABLE t2_b(k INTEGER PRIMARY KEY, v TEXT);
+ CREATE VIEW t2 AS SELECT * FROM t2_a UNION ALL SELECT * FROM t2_b;
+ SELECT 1 FROM t1 JOIN t1 USING(a)
+ WHERE (a=1)
+ OR (a=2 AND (SELECT 4 FROM t2,(SELECT 5 FROM t1 ORDER BY a) WHERE a));
+} {}
+
+finish_test
diff --git a/test/whereA.test b/test/whereA.test
new file mode 100644
index 0000000..dff24d8
--- /dev/null
+++ b/test/whereA.test
@@ -0,0 +1,189 @@
+# 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_execsql_test whereA-1.8 {
+ SELECT * FROM t1 WHERE b=2 AND a IS NULL;
+} {}
+do_execsql_test whereA-1.9 {
+ SELECT * FROM t1 WHERE b=2 AND a IS NOT NULL;
+} {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}
+
+# Ticket https://sqlite.org/src/tktview/cb91bf4290c211 2017-08-01
+# Assertion fault following PRAGMA reverse_unordered_selects=ON.
+#
+do_execsql_test whereA-5.1 {
+ PRAGMA reverse_unordered_selects=on;
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ CREATE INDEX t1b ON t1(b);
+ SELECT a FROM t1 WHERE b=-99 OR b>1;
+} {1}
+
+# 2020-10-02 OSSFuzz find for an issue introduced by a check-in
+# on the previous day.
+#
+reset_db
+do_execsql_test whereA-6.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX t1aa ON t1(a,a);
+ INSERT INTO t1 VALUES(1,2);
+ ANALYZE;
+ UPDATE sqlite_stat1 SET stat='27 3 3' WHERE idx='t1aa';
+ ANALYZE sqlite_schema;
+ PRAGMA reverse_unordered_selects (1) ;
+ SELECT a FROM t1 WHERE a=1 OR a=2;
+} {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/whereC.test b/test/whereC.test
new file mode 100644
index 0000000..f172069
--- /dev/null
+++ b/test/whereC.test
@@ -0,0 +1,70 @@
+# 2011 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix whereC
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b INTEGER);
+
+ INSERT INTO t1 VALUES(1, 1, 1);
+ INSERT INTO t1 VALUES(2, 1, 1);
+ INSERT INTO t1 VALUES(3, 1, 2);
+ INSERT INTO t1 VALUES(4, 1, 2);
+ INSERT INTO t1 VALUES(5, 1, 2);
+ INSERT INTO t1 VALUES(6, 1, 3);
+ INSERT INTO t1 VALUES(7, 1, 3);
+
+ INSERT INTO t1 VALUES(8, 2, 1);
+ INSERT INTO t1 VALUES(9, 2, 1);
+ INSERT INTO t1 VALUES(10, 2, 2);
+ INSERT INTO t1 VALUES(11, 2, 2);
+ INSERT INTO t1 VALUES(12, 2, 2);
+ INSERT INTO t1 VALUES(13, 2, 3);
+ INSERT INTO t1 VALUES(14, 2, 3);
+
+ INSERT INTO t1 VALUES(15, 2, 1);
+ INSERT INTO t1 VALUES(16, 2, 1);
+ INSERT INTO t1 VALUES(17, 2, 2);
+ INSERT INTO t1 VALUES(18, 2, 2);
+ INSERT INTO t1 VALUES(19, 2, 2);
+ INSERT INTO t1 VALUES(20, 2, 3);
+ INSERT INTO t1 VALUES(21, 2, 3);
+
+ CREATE INDEX i1 ON t1(a, b);
+}
+
+foreach {tn sql res} {
+ 1 "SELECT i FROM t1 WHERE a=1 AND b=2 AND i>3" {4 5}
+ 2 "SELECT i FROM t1 WHERE rowid='12'" {12}
+ 3 "SELECT i FROM t1 WHERE a=1 AND b='2'" {3 4 5}
+ 4 "SELECT i FROM t1 WHERE a=1 AND b='2' AND i>'3'" {4 5}
+ 5 "SELECT i FROM t1 WHERE a=1 AND b='2' AND i<5" {3 4}
+ 6 "SELECT i FROM t1 WHERE a=2 AND b=2 AND i<12" {10 11}
+ 7 "SELECT i FROM t1 WHERE a IN(1, 2) AND b=2 AND i<11" {3 4 5 10}
+ 8 "SELECT i FROM t1 WHERE a=2 AND b=2 AND i BETWEEN 10 AND 12" {10 11 12}
+ 9 "SELECT i FROM t1 WHERE a=2 AND b=2 AND i BETWEEN 11 AND 12" {11 12}
+ 10 "SELECT i FROM t1 WHERE a=2 AND b=2 AND i BETWEEN 10 AND 11" {10 11}
+ 11 "SELECT i FROM t1 WHERE a=2 AND b=2 AND i BETWEEN 12 AND 10" {}
+ 12 "SELECT i FROM t1 WHERE a=2 AND b=2 AND i<NULL" {}
+ 13 "SELECT i FROM t1 WHERE a=2 AND b=2 AND i>=NULL" {}
+ 14 "SELECT i FROM t1 WHERE a=1 AND b='2' AND i<4.5" {3 4}
+ 15 "SELECT i FROM t1 WHERE rowid IS '12'" {12}
+} {
+ do_execsql_test 1.$tn.1 $sql $res
+ do_execsql_test 1.$tn.2 "$sql ORDER BY i ASC" [lsort -integer -inc $res]
+ do_execsql_test 1.$tn.3 "$sql ORDER BY i DESC" [lsort -integer -dec $res]
+}
+
+
+finish_test
diff --git a/test/whereD.test b/test/whereD.test
new file mode 100644
index 0000000..e727f47
--- /dev/null
+++ b/test/whereD.test
@@ -0,0 +1,433 @@
+# 2012 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 file is testing that an index may be used as a covering
+# index when there are OR expressions in the WHERE clause.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix whereD
+
+do_execsql_test 1.1 {
+ CREATE TABLE t(i,j,k,m,n);
+ CREATE INDEX ijk ON t(i,j,k);
+ CREATE INDEX jmn ON t(j,m,n);
+
+ INSERT INTO t VALUES(3, 3, 'three', 3, 'tres');
+ INSERT INTO t VALUES(2, 2, 'two', 2, 'dos');
+ INSERT INTO t VALUES(1, 1, 'one', 1, 'uno');
+ INSERT INTO t VALUES(4, 4, 'four', 4, 'cuatro');
+}
+
+do_execsql_test 1.2 {
+ SELECT k FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2);
+} {one two}
+do_execsql_test 1.3 {
+ SELECT k FROM t WHERE (i=1 AND j=1) OR (+i=2 AND j=2);
+} {one two}
+do_execsql_test 1.4 {
+ SELECT n FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2);
+} {uno dos}
+do_execsql_test 1.5 {
+ SELECT k, n FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2);
+} {one uno two dos}
+do_execsql_test 1.6 {
+ SELECT k FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2) OR (i=3 AND j=3);
+} {one two three}
+do_execsql_test 1.7 {
+ SELECT n FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2) OR (i=3 AND j=3);
+} {uno dos tres}
+do_execsql_test 1.8 {
+ SELECT k FROM t WHERE (i=1 AND j=1) OR (j=2 AND m=2);
+} {one two}
+do_execsql_test 1.9 {
+ SELECT k FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2) OR (j=3 AND m=3);
+} {one two three}
+do_execsql_test 1.10 {
+ SELECT n FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2) OR (j=3 AND m=3);
+} {uno dos tres}
+do_execsql_test 1.11 {
+ SELECT k FROM t WHERE (i=1 AND j=1) OR (j=2 AND m=2) OR (i=3 AND j=3);
+} {one two three}
+do_execsql_test 1.12 {
+ SELECT n FROM t WHERE (i=1 AND j=1) OR (j=2 AND m=2) OR (i=3 AND j=3);
+} {uno dos tres}
+do_execsql_test 1.13 {
+ SELECT k FROM t WHERE (j=1 AND m=1) OR (i=2 AND j=2) OR (i=3 AND j=3);
+} {one two three}
+do_execsql_test 1.14 {
+ SELECT k FROM t WHERE (i=1 AND j=1) OR (j=2 AND i=2) OR (i=3 AND j=3);
+} {one two three}
+do_execsql_test 1.15 {
+ SELECT k FROM t WHERE (i=1 AND j=2) OR (i=2 AND j=1) OR (i=3 AND j=4);
+} {}
+do_execsql_test 1.16 {
+ SELECT k FROM t WHERE (i=1 AND (j=1 or j=2)) OR (i=3 AND j=3);
+} {one three}
+
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE INDEX t1b ON t1(b);
+ CREATE INDEX t1c ON t1(c);
+ CREATE INDEX t1d ON t1(d);
+ CREATE TABLE t2(x,y);
+ CREATE INDEX t2y ON t2(y);
+
+ INSERT INTO t1 VALUES(1,2,3,4);
+ INSERT INTO t1 VALUES(5,6,7,8);
+ INSERT INTO t2 VALUES(1,2);
+ INSERT INTO t2 VALUES(2,7);
+ INSERT INTO t2 VALUES(3,4);
+} {}
+do_execsql_test 2.1 {
+ SELECT a, x FROM t1 JOIN t2 ON +y=d OR x=7 ORDER BY a, x;
+} {1 3}
+do_execsql_test 2.2 {
+ SELECT a, x FROM t1 JOIN t2 ON y=d OR x=7 ORDER BY a, x;
+} {1 3}
+
+
+# Similar to [do_execsql_test], except that two elements are appended
+# to the result - the string "search" and the number of times test variable
+# sqlite3_search_count is incremented by running the supplied SQL. e.g.
+#
+# do_searchcount_test 1.0 { SELECT * FROM t1 } {x y search 2}
+#
+proc do_searchcount_test {tn sql res} {
+ uplevel [subst -nocommands {
+ do_test $tn {
+ set ::sqlite_search_count 0
+ concat [db eval {$sql}] search [set ::sqlite_search_count]
+ } [list $res]
+ }]
+}
+
+do_execsql_test 3.0 {
+ CREATE TABLE t3(a, b, c);
+ CREATE UNIQUE INDEX i3 ON t3(a, b);
+ INSERT INTO t3 VALUES(1, 'one', 'i');
+ INSERT INTO t3 VALUES(3, 'three', 'iii');
+ INSERT INTO t3 VALUES(6, 'six', 'vi');
+ INSERT INTO t3 VALUES(2, 'two', 'ii');
+ INSERT INTO t3 VALUES(4, 'four', 'iv');
+ INSERT INTO t3 VALUES(5, 'five', 'v');
+
+ CREATE TABLE t4(x PRIMARY KEY, y);
+ INSERT INTO t4 VALUES('a', 'one');
+ INSERT INTO t4 VALUES('b', 'two');
+}
+
+do_searchcount_test 3.1 {
+ SELECT a, b FROM t3 WHERE (a=1 AND b='one') OR (a=2 AND b='two')
+} {1 one 2 two search 4}
+
+do_searchcount_test 3.2 {
+ SELECT a, c FROM t3 WHERE (a=1 AND b='one') OR (a=2 AND b='two')
+} {1 i 2 ii search 6}
+
+do_searchcount_test 3.4.1 {
+ SELECT y FROM t4 WHERE x='a'
+} {one search 2}
+do_searchcount_test 3.4.2 {
+ SELECT a, b FROM t3 WHERE
+ (a=1 AND b=(SELECT y FROM t4 WHERE x='a'))
+ OR (a=2 AND b='two')
+} {1 one 2 two search 6}
+do_searchcount_test 3.4.3 {
+ SELECT a, b FROM t3 WHERE
+ (a=2 AND b='two')
+ OR (a=1 AND b=(SELECT y FROM t4 WHERE x='a'))
+} {2 two 1 one search 6}
+do_searchcount_test 3.4.4 {
+ SELECT a, b FROM t3 WHERE
+ (a=2 AND b=(SELECT y FROM t4 WHERE x='b'))
+ OR (a=1 AND b=(SELECT y FROM t4 WHERE x='a'))
+} {2 two 1 one search 8}
+
+do_searchcount_test 3.5.1 {
+ SELECT a, b FROM t3 WHERE (a=1 AND b='one') OR rowid=4
+} {1 one 2 two search 2}
+do_searchcount_test 3.5.2 {
+ SELECT a, c FROM t3 WHERE (a=1 AND b='one') OR rowid=4
+} {1 i 2 ii search 3}
+
+# Ticket [d02e1406a58ea02d] (2012-10-04)
+# LEFT JOIN with an OR in the ON clause causes segfault
+#
+do_test 4.1 {
+ db eval {
+ CREATE TABLE t41(a,b,c);
+ INSERT INTO t41 VALUES(1,2,3), (4,5,6);
+ CREATE TABLE t42(d,e,f);
+ INSERT INTO t42 VALUES(3,6,9), (4,8,12);
+ SELECT * FROM t41 AS x LEFT JOIN t42 AS y ON (y.d=x.c) OR (y.e=x.b);
+ }
+} {1 2 3 3 6 9 4 5 6 {} {} {}}
+do_test 4.2 {
+ db eval {
+ CREATE INDEX t42d ON t42(d);
+ CREATE INDEX t42e ON t42(e);
+ SELECT * FROM t41 AS x LEFT JOIN t42 AS y ON (y.d=x.c) OR (y.e=x.b);
+ }
+} {1 2 3 3 6 9 4 5 6 {} {} {}}
+do_test 4.3 {
+ db eval {
+ SELECT * FROM t41 AS x LEFT JOIN t42 AS y ON (y.d=x.c) OR (y.d=x.b);
+ }
+} {1 2 3 3 6 9 4 5 6 {} {} {}}
+
+# Ticket [bc1aea7b725f276177]
+# Incorrect result on LEFT JOIN with OR constraints and an ORDER BY clause.
+#
+do_execsql_test 4.4 {
+ CREATE TABLE t44(a INTEGER, b INTEGER);
+ INSERT INTO t44 VALUES(1,2);
+ INSERT INTO t44 VALUES(3,4);
+ SELECT *
+ FROM t44 AS x
+ LEFT JOIN (SELECT a AS c, b AS d FROM t44) AS y ON a=c
+ WHERE d=4 OR d IS NULL;
+} {3 4 3 4}
+do_execsql_test 4.5 {
+ SELECT *
+ FROM t44 AS x
+ LEFT JOIN (SELECT a AS c, b AS d FROM t44) AS y ON a=c
+ WHERE d=4 OR d IS NULL
+ ORDER BY a;
+} {3 4 3 4}
+do_execsql_test 4.6 {
+ CREATE TABLE t46(c INTEGER, d INTEGER);
+ INSERT INTO t46 SELECT a, b FROM t44;
+ SELECT * FROM t44 LEFT JOIN t46 ON a=c
+ WHERE d=4 OR d IS NULL;
+} {3 4 3 4}
+do_execsql_test 4.7 {
+ SELECT * FROM t44 LEFT JOIN t46 ON a=c
+ WHERE d=4 OR d IS NULL
+ ORDER BY a;
+} {3 4 3 4}
+
+# Verify fix of a bug reported on the mailing list by Peter Reid
+#
+do_execsql_test 5.1 {
+ DROP TABLE IF EXISTS t;
+ CREATE TABLE t(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17);
+ CREATE INDEX tc0 ON t(c0);
+ CREATE INDEX tc1 ON t(c1);
+ CREATE INDEX tc2 ON t(c2);
+ CREATE INDEX tc3 ON t(c3);
+ CREATE INDEX tc4 ON t(c4);
+ CREATE INDEX tc5 ON t(c5);
+ CREATE INDEX tc6 ON t(c6);
+ CREATE INDEX tc7 ON t(c7);
+ CREATE INDEX tc8 ON t(c8);
+ CREATE INDEX tc9 ON t(c9);
+ CREATE INDEX tc10 ON t(c10);
+ CREATE INDEX tc11 ON t(c11);
+ CREATE INDEX tc12 ON t(c12);
+ CREATE INDEX tc13 ON t(c13);
+ CREATE INDEX tc14 ON t(c14);
+ CREATE INDEX tc15 ON t(c15);
+ CREATE INDEX tc16 ON t(c16);
+ CREATE INDEX tc17 ON t(c17);
+
+ INSERT INTO t(c0, c16) VALUES (1,1);
+
+ SELECT * FROM t WHERE
+ c0=1 or c1=1 or c2=1 or c3=1 or
+ c4=1 or c5=1 or c6=1 or c7=1 or
+ c8=1 or c9=1 or c10=1 or c11=1 or
+ c12=1 or c13=1 or c14=1 or c15=1 or
+ c16=1 or c17=1;
+} {1 {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} 1 {}}
+do_execsql_test 5.2 {
+ DELETE FROM t;
+ INSERT INTO t(c0,c17) VALUES(1,1);
+ SELECT * FROM t WHERE
+ c0=1 or c1=1 or c2=1 or c3=1 or
+ c4=1 or c5=1 or c6=1 or c7=1 or
+ c8=1 or c9=1 or c10=1 or c11=1 or
+ c12=1 or c13=1 or c14=1 or c15=1 or
+ c16=1 or c17=1;
+} {1 {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} 1}
+do_execsql_test 5.3 {
+ DELETE FROM t;
+ INSERT INTO t(c0,c15) VALUES(1,1);
+ SELECT * FROM t WHERE
+ c0=1 or c1=1 or c2=1 or c3=1 or
+ c4=1 or c5=1 or c6=1 or c7=1 or
+ c8=1 or c9=1 or c10=1 or c11=1 or
+ c12=1 or c13=1 or c14=1 or c15=1 or
+ c16=1 or c17=1;
+} {1 {} {} {} {} {} {} {} {} {} {} {} {} {} {} 1 {} {}}
+
+#-------------------------------------------------------------------------
+do_execsql_test 6.1 {
+ CREATE TABLE x1(a, b, c, d, e);
+ CREATE INDEX x1a ON x1(a);
+ CREATE INDEX x1bc ON x1(b, c);
+ CREATE INDEX x1cd ON x1(c, d);
+
+ INSERT INTO x1 VALUES(1, 2, 3, 4, 'A');
+ INSERT INTO x1 VALUES(5, 6, 7, 8, 'B');
+ INSERT INTO x1 VALUES(9, 10, 11, 12, 'C');
+ INSERT INTO x1 VALUES(13, 14, 15, 16, 'D');
+}
+
+do_searchcount_test 6.2.1 {
+ SELECT e FROM x1 WHERE b=2 OR c=7;
+} {A B search 6}
+do_searchcount_test 6.2.2 {
+ SELECT c FROM x1 WHERE b=2 OR c=7;
+} {3 7 search 4}
+
+do_searchcount_test 6.3.1 {
+ SELECT e FROM x1 WHERE a=1 OR b=10;
+} {A C search 6}
+do_searchcount_test 6.3.2 {
+ SELECT c FROM x1 WHERE a=1 OR b=10;
+} {3 11 search 5}
+do_searchcount_test 6.3.3 {
+ SELECT rowid FROM x1 WHERE a=1 OR b=10;
+} {1 3 search 4}
+
+do_searchcount_test 6.4.1 {
+ SELECT a FROM x1 WHERE b BETWEEN 1 AND 4 OR c BETWEEN 8 AND 12
+} {1 9 search 6}
+do_searchcount_test 6.4.2 {
+ SELECT b, c FROM x1 WHERE b BETWEEN 1 AND 4 OR c BETWEEN 8 AND 12
+} {2 3 10 11 search 5}
+do_searchcount_test 6.4.3 {
+ SELECT rowid, c FROM x1 WHERE b BETWEEN 1 AND 4 OR c BETWEEN 8 AND 12
+} {1 3 3 11 search 4}
+
+do_searchcount_test 6.5.1 {
+ SELECT a FROM x1 WHERE rowid = 2 OR c=11
+} {5 9 search 3}
+do_searchcount_test 6.5.2 {
+ SELECT d FROM x1 WHERE rowid = 2 OR c=11
+} {8 12 search 2}
+do_searchcount_test 6.5.3 {
+ SELECT d FROM x1 WHERE c=11 OR rowid = 2
+} {12 8 search 2}
+do_searchcount_test 6.5.4 {
+ SELECT a FROM x1 WHERE c=11 OR rowid = 2
+} {9 5 search 3}
+
+do_searchcount_test 6.6.1 {
+ SELECT rowid FROM x1 WHERE a=1 OR b=6 OR c=11
+} {1 2 3 search 6}
+do_searchcount_test 6.6.2 {
+ SELECT c FROM x1 WHERE a=1 OR b=6 OR c=11
+} {3 7 11 search 7}
+do_searchcount_test 6.6.3 {
+ SELECT c FROM x1 WHERE c=11 OR a=1 OR b=6
+} {11 3 7 search 7}
+do_searchcount_test 6.6.4 {
+ SELECT c FROM x1 WHERE b=6 OR c=11 OR a=1
+} {7 11 3 search 7}
+
+# 2020-02-22 ticket aa4378693018aa99
+# In the OP_Column opcode, if a cursor is marked with OP_NullRow
+# (because it is the right table of a LEFT JOIN that does not match)
+# then do not substitute index cursors, as the index cursors do not
+# have the VdbeCursor.nullRow flag set.
+#
+do_execsql_test 6.7 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a UNIQUE, b UNIQUE);
+ INSERT INTO t1(a,b) VALUES(null,2);
+ CREATE VIEW t2 AS SELECT * FROM t1 WHERE b<10 OR a<7 ORDER BY b;
+ SELECT t1.* FROM t1 LEFT JOIN t2 ON abs(t1.a)=abs(t2.b);
+} {{} 2}
+
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 7.0 {
+ CREATE TABLE y1(a, b);
+ CREATE TABLE y2(x, y);
+ CREATE INDEX y2xy ON y2(x, y);
+ INSERT INTO y1 VALUES(1, 1);
+ INSERT INTO y2 VALUES(3, 3);
+}
+
+do_execsql_test 7.1 {
+ SELECT * FROM y1 LEFT JOIN y2 ON ((x=1 AND y=b) OR (x=2 AND y=b))
+} {1 1 {} {}}
+
+do_execsql_test 7.3 {
+ CREATE TABLE foo (Id INTEGER PRIMARY KEY, fa INTEGER, fb INTEGER);
+ CREATE TABLE bar (Id INTEGER PRIMARY KEY, ba INTEGER, bb INTEGER);
+
+ INSERT INTO foo VALUES(1, 1, 1);
+ INSERT INTO foo VALUES(2, 1, 2);
+ INSERT INTO foo VALUES(3, 1, 3);
+ INSERT INTO foo VALUES(4, 1, 4);
+ INSERT INTO foo VALUES(5, 1, 5);
+ INSERT INTO foo VALUES(6, 1, 6);
+ INSERT INTO foo VALUES(7, 1, 7);
+ INSERT INTO foo VALUES(8, 1, 8);
+ INSERT INTO foo VALUES(9, 1, 9);
+
+ INSERT INTO bar VALUES(NULL, 1, 1);
+ INSERT INTO bar VALUES(NULL, 2, 2);
+ INSERT INTO bar VALUES(NULL, 3, 3);
+ INSERT INTO bar VALUES(NULL, 1, 4);
+ INSERT INTO bar VALUES(NULL, 2, 5);
+ INSERT INTO bar VALUES(NULL, 3, 6);
+ INSERT INTO bar VALUES(NULL, 1, 7);
+ INSERT INTO bar VALUES(NULL, 2, 8);
+ INSERT INTO bar VALUES(NULL, 3, 9);
+}
+
+do_execsql_test 7.4 {
+ SELECT
+ bar.Id, bar.ba, bar.bb, foo.fb
+ FROM foo LEFT JOIN bar
+ ON (bar.ba = 1 AND bar.bb = foo.fb)
+ OR (bar.ba = 5 AND bar.bb = foo.fb);
+} {
+ 1 1 1 1
+ {} {} {} 2
+ {} {} {} 3
+ 4 1 4 4
+ {} {} {} 5
+ {} {} {} 6
+ 7 1 7 7
+ {} {} {} 8
+ {} {} {} 9
+}
+
+do_execsql_test 7.5 {
+ CREATE INDEX idx_bar ON bar(ba, bb);
+ SELECT
+ bar.Id, bar.ba, bar.bb, foo.fb
+ FROM foo LEFT JOIN bar
+ ON (bar.ba = 1 AND bar.bb = foo.fb)
+ OR (bar.ba = 5 AND bar.bb = foo.fb);
+} {
+ 1 1 1 1
+ {} {} {} 2
+ {} {} {} 3
+ 4 1 4 4
+ {} {} {} 5
+ {} {} {} 6
+ 7 1 7 7
+ {} {} {} 8
+ {} {} {} 9
+}
+
+
+finish_test
diff --git a/test/whereE.test b/test/whereE.test
new file mode 100644
index 0000000..cd9f81d
--- /dev/null
+++ b/test/whereE.test
@@ -0,0 +1,68 @@
+# 2012 November 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 query planner to make sure it
+# is making good planning decisions.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix whereE
+
+# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
+ifcapable !altertable {
+ finish_test
+ return
+}
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,10), (2,20), (3,30), (2,22), (3, 33);
+ 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;
+ INSERT INTO t1 SELECT * FROM t1;
+ INSERT INTO t1 SELECT * FROM t1;
+ ALTER TABLE t1 ADD COLUMN c;
+ UPDATE t1 SET c=a*rowid+10000;
+ CREATE INDEX t1ab ON t1(a,b);
+
+ CREATE TABLE t2(x,y);
+ INSERT INTO t2 VALUES(4,44),(5,55),(6,66),(7,77);
+ INSERT INTO t2 SELECT x+4, (x+4)*11 FROM t2;
+ INSERT INTO t2 SELECT x+8, (x+8)*11 FROM t2;
+ INSERT INTO t2 SELECT x+16, (x+16)*11 FROM t2;
+ INSERT INTO t2 SELECT x+32, (x+32)*11 FROM t2;
+ INSERT INTO t2 SELECT x+64, (x+32)*11 FROM t2;
+ ALTER TABLE t2 ADD COLUMN z;
+ UPDATE t2 SET z=2;
+ CREATE UNIQUE INDEX t2zx ON t2(z,x);
+
+ EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x;
+} {/.*SCAN t1.*SEARCH t2.*/}
+do_execsql_test 1.2 {
+ EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x;
+} {/.*SCAN t1.*SEARCH t2.*/}
+do_execsql_test 1.3 {
+ ANALYZE;
+ EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x;
+} {/.*SCAN t1.*SEARCH t2.*/}
+do_execsql_test 1.4 {
+ EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x;
+} {/.*SCAN t1.*SEARCH t2.*/}
+
+finish_test
diff --git a/test/whereF.test b/test/whereF.test
new file mode 100644
index 0000000..ac7fd80
--- /dev/null
+++ b/test/whereF.test
@@ -0,0 +1,312 @@
+# 2012 November 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 cases for query planning decisions.
+
+
+#
+# The tests in this file demonstrate the behaviour of the query planner
+# in determining the order in which joined tables are scanned.
+#
+# Assume there are two tables being joined - t1 and t2. Each has a cost
+# if it is the outer loop, and a cost if it is the inner loop. As follows:
+#
+# t1(outer) - cost of scanning t1 as the outer loop.
+# t1(inner) - cost of scanning t1 as the inner loop.
+# t2(outer) - cost of scanning t2 as the outer loop.
+# t2(inner) - cost of scanning t2 as the inner loop.
+#
+# Depending on the order in which the planner nests the scans, the total
+# cost of the join query is one of:
+#
+# t1(outer) * t2(inner)
+# t2(outer) * t1(inner)
+#
+# The tests in this file attempt to verify that the planner nests joins in
+# the correct order when the following are true:
+#
+# + (t1(outer) * t2(inner)) > (t1(inner) * t2(outer)
+# + t1(outer) < t2(outer)
+#
+# In other words, when the best overall query plan has t2 as the outer loop,
+# but when the outer loop is considered independent of the inner, t1 is the
+# most efficient choice.
+#
+# In order to make them more predictable, automatic indexes are turned off for
+# the tests in this file.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix whereF
+
+do_execsql_test 1.0 {
+ PRAGMA automatic_index = 0;
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+ CREATE UNIQUE INDEX i1 ON t1(a);
+ CREATE UNIQUE INDEX i2 ON t2(d);
+} {}
+
+foreach {tn sql} {
+ 1 "SELECT * FROM t1, t2 WHERE t1.a=t2.e AND t2.d<t1.b AND t1.c!=10"
+ 2 "SELECT * FROM t2, t1 WHERE t1.a=t2.e AND t2.d<t1.b AND t1.c!=10"
+ 3 "SELECT * FROM t2 CROSS JOIN t1 WHERE t1.a=t2.e AND t2.d<t1.b AND t1.c!=10"
+} {
+ do_test 1.$tn {
+ db eval "EXPLAIN QUERY PLAN $sql"
+ } {/.*SCAN t2\y.*SEARCH t1\y.*/}
+}
+
+do_execsql_test 2.0 {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+
+ CREATE UNIQUE INDEX i1 ON t1(a);
+ CREATE UNIQUE INDEX i2 ON t1(b);
+ CREATE UNIQUE INDEX i3 ON t2(d);
+} {}
+
+foreach {tn sql} {
+ 1 "SELECT * FROM t1, t2 WHERE t1.a>? AND t2.d>t1.c AND t1.b=t2.e"
+ 2 "SELECT * FROM t2, t1 WHERE t1.a>? AND t2.d>t1.c AND t1.b=t2.e"
+ 3 "SELECT * FROM t2 CROSS JOIN t1 WHERE t1.a>? AND t2.d>t1.c AND t1.b=t2.e"
+} {
+ do_test 2.$tn {
+ db eval "EXPLAIN QUERY PLAN $sql"
+ } {/.*SCAN t2\y.*SEARCH t1\y.*/}
+}
+
+do_execsql_test 3.0 {
+ DROP TABLE t1;
+ DROP TABLE t2;
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(d, e, f);
+
+ CREATE UNIQUE INDEX i1 ON t1(a, b);
+ CREATE INDEX i2 ON t2(d);
+} {}
+
+foreach {tn sql} {
+ 1 {SELECT t1.a, t1.b, t2.d, t2.e FROM t1, t2
+ WHERE t2.d=t1.b AND t1.a=(t2.d+1) AND t1.b = (t2.e+1)}
+
+ 2 {SELECT t1.a, t1.b, t2.d, t2.e FROM t2, t1
+ WHERE t2.d=t1.b AND t1.a=(t2.d+1) AND t1.b = (t2.e+1)}
+
+ 3 {SELECT t1.a, t1.b, t2.d, t2.e FROM t2 CROSS JOIN t1
+ WHERE t2.d=t1.b AND t1.a=(t2.d+1) AND t1.b = (t2.e+1)}
+} {
+ do_test 3.$tn {
+ db eval "EXPLAIN QUERY PLAN $sql"
+ } {/.*SCAN t2\y.*SEARCH t1\y.*/}
+}
+
+do_execsql_test 4.0 {
+ CREATE TABLE t4(a,b,c,d,e, PRIMARY KEY(a,b,c));
+ CREATE INDEX t4adc ON t4(a,d,c);
+ CREATE UNIQUE INDEX t4aebc ON t4(a,e,b,c);
+ EXPLAIN QUERY PLAN SELECT rowid FROM t4 WHERE a=? AND b=?;
+} {/a=. AND b=./}
+
+#-------------------------------------------------------------------------
+# Test the following case:
+#
+# ... FROM t1, t2 WHERE (
+# t2.rowid = +t1.rowid OR (t2.f2 = t1.f1 AND t1.f1!=-1)
+# )
+#
+# where there is an index on t2(f2). The planner should use "t1" as the
+# outer loop. The inner loop, on "t2", is an OR optimization. One pass
+# for:
+#
+# t2.rowid = $1
+#
+# and another for:
+#
+# t2.f2=$1 AND $1!=-1
+#
+# the test is to ensure that on the second pass, the ($1!=-1) condition
+# is tested before any seek operations are performed - i.e. outside of
+# the loop through the f2=$1 range of the t2(f2) index.
+#
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(f1);
+ CREATE TABLE t2(f2);
+ CREATE INDEX t2f ON t2(f2);
+
+ INSERT INTO t1 VALUES(-1);
+ INSERT INTO t1 VALUES(-1);
+ INSERT INTO t1 VALUES(-1);
+ INSERT INTO t1 VALUES(-1);
+
+ WITH w(i) AS (
+ SELECT 1 UNION ALL SELECT i+1 FROM w WHERE i<1000
+ )
+ INSERT INTO t2 SELECT -1 FROM w;
+}
+
+do_execsql_test 5.1 {
+ SELECT count(*) FROM t1, t2 WHERE t2.rowid = +t1.rowid
+} {4}
+do_test 5.2 { expr [db status vmstep]<200 } 1
+
+do_execsql_test 5.3 {
+ SELECT count(*) FROM t1, t2 WHERE (
+ t2.rowid = +t1.rowid OR t2.f2 = t1.f1
+ )
+} {4000}
+do_test 5.4 { expr [db status vmstep]>1000 } 1
+
+do_execsql_test 5.5 {
+ SELECT count(*) FROM t1, t2 WHERE (
+ t2.rowid = +t1.rowid OR (t2.f2 = t1.f1 AND t1.f1!=-1)
+ )
+} {4}
+do_test 5.6 { expr [db status vmstep]<200 } 1
+
+# 2017-09-04 ticket b899b6042f97f52d
+# Segfault on correlated subquery...
+#
+ifcapable json1&&vtab {
+ do_execsql_test 6.1 {
+ CREATE TABLE t6(x);
+ SELECT * FROM t6 WHERE 1 IN (SELECT value FROM json_each(x));
+ } {}
+
+ do_execsql_test 6.2 {
+ DROP TABLE t6;
+ CREATE TABLE t6(a,b,c);
+ INSERT INTO t6 VALUES
+ (0,null,'{"a":0,"b":[3,4,5],"c":{"x":4.5,"y":7.8}}'),
+ (1,null,'{"a":1,"b":[3,4,5],"c":{"x":4.5,"y":7.8}}'),
+ (2,null,'{"a":9,"b":[3,4,5],"c":{"x":4.5,"y":7.8}}');
+ SELECT * FROM t6
+ WHERE (EXISTS (SELECT 1 FROM json_each(t6.c) AS x WHERE x.value=1));
+ } {1 {} {{"a":1,"b":[3,4,5],"c":{"x":4.5,"y":7.8}}}}
+
+ # Another test case derived from a posting by Wout Mertens on the
+ # sqlite-users mailing list on 2017-10-04.
+ do_execsql_test 6.3 {
+ DROP TABLE IF EXISTS t;
+ CREATE TABLE t(json JSON);
+ SELECT * FROM t
+ WHERE(EXISTS(SELECT 1 FROM json_each(t.json,"$.foo") j
+ WHERE j.value = 'meep'));
+ } {}
+ do_execsql_test 6.4 {
+ INSERT INTO t VALUES('{"xyzzy":null}');
+ INSERT INTO t VALUES('{"foo":"meep","other":12345}');
+ INSERT INTO t VALUES('{"foo":"bingo","alt":5.25}');
+ SELECT * FROM t
+ WHERE(EXISTS(SELECT 1 FROM json_each(t.json,"$.foo") j
+ WHERE j.value = 'meep'));
+ } {{{"foo":"meep","other":12345}}}
+}
+
+# 2018-01-27
+# Ticket https://sqlite.org/src/tktview/ec32177c99ccac2b180fd3ea2083
+# Incorrect result when using the new OR clause factoring optimization
+#
+# This is the original test case as reported on the sqlite-users mailing
+# list
+#
+do_execsql_test 7.1 {
+ DROP TABLE IF EXISTS cd;
+ CREATE TABLE cd ( cdid INTEGER PRIMARY KEY NOT NULL, genreid integer );
+ CREATE INDEX cd_idx_genreid ON cd (genreid);
+ INSERT INTO cd ( cdid, genreid ) VALUES
+ ( 1, 1 ),
+ ( 2, NULL ),
+ ( 3, NULL ),
+ ( 4, NULL ),
+ ( 5, NULL );
+
+ SELECT cdid
+ FROM cd me
+ WHERE 2 > (
+ SELECT COUNT( * )
+ FROM cd rownum__emulation
+ WHERE
+ (
+ me.genreid IS NOT NULL
+ AND
+ rownum__emulation.genreid IS NULL
+ )
+ OR
+ (
+ me.genreid IS NOT NULL
+ AND
+ rownum__emulation.genreid IS NOT NULL
+ AND
+ rownum__emulation.genreid < me.genreid
+ )
+ OR
+ (
+ ( me.genreid = rownum__emulation.genreid OR ( me.genreid IS NULL
+ AND rownum__emulation.genreid IS NULL ) )
+ AND
+ rownum__emulation.cdid > me.cdid
+ )
+ );
+} {4 5}
+
+# Simplified test cases from the ticket
+#
+do_execsql_test 7.2 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1(a,b) VALUES(1,1);
+ CREATE TABLE t2(aa INTEGER PRIMARY KEY, bb);
+ INSERT INTO t2(aa,bb) VALUES(1,1),(2,NULL),(3,NULL);
+ SELECT (
+ SELECT COUNT(*) FROM t2
+ WHERE ( t1.b IS NOT NULL AND t2.bb IS NULL )
+ OR ( t2.bb < t1.b )
+ OR ( t1.b IS t2.bb AND t2.aa > t1.a )
+ )
+ FROM t1;
+} {2}
+
+# The fix for ticket ec32177c99ccac2b180fd3ea2083 only makes a difference
+# in the output when there is a TERM_VNULL entry in the WhereClause array.
+# And TERM_VNULL entries are only generated when compiling with
+# SQLITE_ENABLE_STAT4. Nevertheless, it is correct that TERM_VIRTUAL terms
+# should not participate in the factoring optimization. In all cases other
+# than TERM_VNULL, participation is harmless, but it does consume a few
+# extra CPU cycles.
+#
+# The following test verifies that the TERM_VIRTUAL terms resulting from
+# a GLOB operator do not appear anywhere in the generated code. This
+# confirms that the problem is fixed, even on builds that omit STAT4.
+#
+do_execsql_test 7.3 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t1(a,b) VALUES(1,'abcxyz');
+ CREATE TABLE t2(aa INTEGER PRIMARY KEY, bb TEXT);
+ INSERT INTO t2(aa,bb) VALUES(1,'abc'),(2,'wxyz'),(3,'xyz');
+ CREATE INDEX t2bb ON t2(bb);
+ EXPLAIN SELECT (
+ SELECT COUNT(*) FROM t2
+ WHERE ( t1.b GLOB 'a*z' AND t2.bb='xyz' )
+ OR ( t2.bb = t1.b )
+ OR ( t2.aa = t1.a )
+ )
+ FROM t1;
+} {~/ (Lt|Ge) /}
+
+finish_test
diff --git a/test/whereG.test b/test/whereG.test
new file mode 100644
index 0000000..6ca363e
--- /dev/null
+++ b/test/whereG.test
@@ -0,0 +1,388 @@
+# 2013-09-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.
+#
+#***********************************************************************
+#
+# Test cases for query planning decisions and the likely(), unlikely(), and
+# likelihood() functions.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix whereG
+
+do_execsql_test whereG-1.0 {
+ CREATE TABLE composer(
+ cid INTEGER PRIMARY KEY,
+ cname TEXT
+ );
+ CREATE TABLE album(
+ aid INTEGER PRIMARY KEY,
+ aname TEXT
+ );
+ CREATE TABLE track(
+ tid INTEGER PRIMARY KEY,
+ cid INTEGER REFERENCES composer,
+ aid INTEGER REFERENCES album,
+ title TEXT
+ );
+ CREATE INDEX track_i1 ON track(cid);
+ CREATE INDEX track_i2 ON track(aid);
+ INSERT INTO composer VALUES(1, 'W. A. Mozart');
+ INSERT INTO composer VALUES(2, 'Beethoven');
+ INSERT INTO composer VALUES(3, 'Thomas Tallis');
+ INSERT INTO composer VALUES(4, 'Joseph Hayden');
+ INSERT INTO composer VALUES(5, 'Thomas Weelkes');
+ INSERT INTO composer VALUES(6, 'J. S. Bach');
+ INSERT INTO composer VALUES(7, 'Orlando Gibbons');
+ INSERT INTO composer VALUES(8, 'Josquin des Prés');
+ INSERT INTO composer VALUES(9, 'Byrd');
+ INSERT INTO composer VALUES(10, 'Francis Poulenc');
+ INSERT INTO composer VALUES(11, 'Mendelsshon');
+ INSERT INTO composer VALUES(12, 'Zoltán Kodály');
+ INSERT INTO composer VALUES(13, 'Handel');
+ INSERT INTO album VALUES(100, 'Kodály: Missa Brevis');
+ INSERT INTO album VALUES(101, 'Messiah');
+ INSERT INTO album VALUES(102, 'Missa Brevis in D-, K.65');
+ INSERT INTO album VALUES(103, 'The complete English anthems');
+ INSERT INTO album VALUES(104, 'Mass in B Minor, BWV 232');
+ INSERT INTO track VALUES(10005, 12, 100, 'Sanctus');
+ INSERT INTO track VALUES(10007, 12, 100, 'Agnus Dei');
+ INSERT INTO track VALUES(10115, 13, 101, 'Surely He Hath Borne Our Griefs');
+ INSERT INTO track VALUES(10129, 13, 101, 'Since By Man Came Death');
+ INSERT INTO track VALUES(10206, 1, 102, 'Agnus Dei');
+ INSERT INTO track VALUES(10301, 3, 103, 'If Ye Love Me');
+ INSERT INTO track VALUES(10402, 6, 104, 'Domine Deus');
+ INSERT INTO track VALUES(10403, 6, 104, 'Qui tollis');
+} {}
+do_eqp_test whereG-1.1 {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE unlikely(cname LIKE '%bach%')
+ AND composer.cid=track.cid
+ AND album.aid=track.aid;
+} {composer*track*album}
+do_execsql_test whereG-1.2 {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE unlikely(cname LIKE '%bach%')
+ AND composer.cid=track.cid
+ AND album.aid=track.aid;
+} {{Mass in B Minor, BWV 232}}
+
+do_eqp_test whereG-1.3 {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE likelihood(cname LIKE '%bach%', 0.5)
+ AND composer.cid=track.cid
+ AND album.aid=track.aid;
+} {/.*track.*composer.*album.*/}
+do_execsql_test whereG-1.4 {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE likelihood(cname LIKE '%bach%', 0.5)
+ AND composer.cid=track.cid
+ AND album.aid=track.aid;
+} {{Mass in B Minor, BWV 232}}
+
+do_eqp_test whereG-1.5 {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE cname LIKE '%bach%'
+ AND composer.cid=track.cid
+ AND album.aid=track.aid;
+} {/.*track.*(composer.*album|album.*composer).*/}
+do_execsql_test whereG-1.6 {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE cname LIKE '%bach%'
+ AND composer.cid=track.cid
+ AND album.aid=track.aid;
+} {{Mass in B Minor, BWV 232}}
+
+do_eqp_test whereG-1.7 {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE cname LIKE '%bach%'
+ AND unlikely(composer.cid=track.cid)
+ AND unlikely(album.aid=track.aid);
+} {/.*track.*(composer.*album|album.*composer).*/}
+do_execsql_test whereG-1.8 {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE cname LIKE '%bach%'
+ AND unlikely(composer.cid=track.cid)
+ AND unlikely(album.aid=track.aid);
+} {{Mass in B Minor, BWV 232}}
+
+do_test whereG-2.1 {
+ catchsql {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE likelihood(cname LIKE '%bach%', -0.01)
+ AND composer.cid=track.cid
+ AND album.aid=track.aid;
+ }
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+do_test whereG-2.2 {
+ catchsql {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE likelihood(cname LIKE '%bach%', 1.01)
+ AND composer.cid=track.cid
+ AND album.aid=track.aid;
+ }
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+do_test whereG-2.3 {
+ catchsql {
+ SELECT DISTINCT aname
+ FROM album, composer, track
+ WHERE likelihood(cname LIKE '%bach%', track.cid)
+ AND composer.cid=track.cid
+ AND album.aid=track.aid;
+ }
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+
+# Commuting a term of the WHERE clause should not change the query plan
+#
+do_execsql_test whereG-3.0 {
+ CREATE TABLE a(a1 PRIMARY KEY, a2);
+ CREATE TABLE b(b1 PRIMARY KEY, b2);
+} {}
+do_eqp_test whereG-3.1 {
+ SELECT * FROM a, b WHERE b1=a1 AND a2=5;
+} {/.*SCAN a.*SEARCH b USING INDEX .*b_1 .b1=..*/}
+do_eqp_test whereG-3.2 {
+ SELECT * FROM a, b WHERE a1=b1 AND a2=5;
+} {/.*SCAN a.*SEARCH b USING INDEX .*b_1 .b1=..*/}
+do_eqp_test whereG-3.3 {
+ SELECT * FROM a, b WHERE a2=5 AND b1=a1;
+} {/.*SCAN a.*SEARCH b USING INDEX .*b_1 .b1=..*/}
+do_eqp_test whereG-3.4 {
+ SELECT * FROM a, b WHERE a2=5 AND a1=b1;
+} {/.*SCAN a.*SEARCH b USING INDEX .*b_1 .b1=..*/}
+
+# Ticket [1e64dd782a126f48d78c43a664844a41d0e6334e]:
+# Incorrect result in a nested GROUP BY/DISTINCT due to the use of an OP_SCopy
+# where an OP_Copy was needed.
+#
+do_execsql_test whereG-4.0 {
+ CREATE TABLE t4(x);
+ INSERT INTO t4 VALUES('right'),('wrong');
+ SELECT DISTINCT x
+ FROM (SELECT x FROM t4 GROUP BY x)
+ WHERE x='right'
+ ORDER BY x;
+} {right}
+
+#-------------------------------------------------------------------------
+# Test that likelihood() specifications on indexed terms are taken into
+# account by various forms of loops.
+#
+# 5.1.*: open ended range scans
+# 5.2.*: skip-scans
+#
+reset_db
+
+do_execsql_test 5.1 {
+ CREATE TABLE t1(a, b, c);
+ CREATE INDEX i1 ON t1(a, b);
+}
+do_eqp_test 5.1.2 {
+ SELECT * FROM t1 WHERE a>?
+} {SEARCH t1 USING INDEX i1 (a>?)}
+do_eqp_test 5.1.3 {
+ SELECT * FROM t1 WHERE likelihood(a>?, 0.9)
+} {SCAN t1}
+do_eqp_test 5.1.4 {
+ SELECT * FROM t1 WHERE likely(a>?)
+} {SCAN t1}
+
+do_test 5.2 {
+ for {set i 0} {$i < 100} {incr i} {
+ execsql { INSERT INTO t1 VALUES('abc', $i, $i); }
+ }
+ execsql { INSERT INTO t1 SELECT 'def', b, c FROM t1; }
+ execsql { ANALYZE }
+} {}
+do_eqp_test 5.2.2 {
+ SELECT * FROM t1 WHERE likelihood(b>?, 0.01)
+} {SEARCH t1 USING INDEX i1 (ANY(a) AND b>?)}
+do_eqp_test 5.2.3 {
+ SELECT * FROM t1 WHERE likelihood(b>?, 0.9)
+} {SCAN t1}
+do_eqp_test 5.2.4 {
+ SELECT * FROM t1 WHERE likely(b>?)
+} {SCAN t1}
+
+ifcapable stat4 {
+ do_eqp_test 5.3.1.stat4 {
+ SELECT * FROM t1 WHERE a=?
+ } {SCAN t1}
+} else {
+ do_eqp_test 5.3.1 {
+ SELECT * FROM t1 WHERE a=?
+ } {SEARCH t1 USING INDEX i1}
+}
+do_eqp_test 5.3.2 {
+ SELECT * FROM t1 WHERE likelihood(a=?, 0.9)
+} {SCAN t1}
+do_eqp_test 5.3.3 {
+ SELECT * FROM t1 WHERE likely(a=?)
+} {SCAN t1}
+
+# 2015-06-18
+# Ticket [https://www.sqlite.org/see/tktview/472f0742a1868fb58862bc588ed70]
+#
+do_execsql_test 6.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(i int, x, y, z);
+ INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4);
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(i int, bool char);
+ INSERT INTO t2 VALUES(1,'T'), (2,'F');
+ SELECT count(*) FROM t1 LEFT JOIN t2 ON t1.i=t2.i AND bool='T';
+ SELECT count(*) FROM t1 LEFT JOIN t2 ON likely(t1.i=t2.i) AND bool='T';
+} {4 4}
+
+# 2015-06-20
+# Crash discovered by AFL
+#
+do_execsql_test 7.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b, PRIMARY KEY(a,b));
+ INSERT INTO t1 VALUES(9,1),(1,2);
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x, y, PRIMARY KEY(x,y));
+ INSERT INTO t2 VALUES(3,3),(4,4);
+ SELECT likely(a), x FROM t1, t2 ORDER BY 1, 2;
+} {1 3 1 4 9 3 9 4}
+do_execsql_test 7.1 {
+ SELECT unlikely(a), x FROM t1, t2 ORDER BY 1, 2;
+} {1 3 1 4 9 3 9 4}
+do_execsql_test 7.2 {
+ SELECT likelihood(a,0.5), x FROM t1, t2 ORDER BY 1, 2;
+} {1 3 1 4 9 3 9 4}
+do_execsql_test 7.3 {
+ SELECT coalesce(a,a), x FROM t1, t2 ORDER BY 1, 2;
+} {1 3 1 4 9 3 9 4}
+
+# 2019-08-22
+# Ticket https://www.sqlite.org/src/info/7e07a3dbf5a8cd26
+#
+do_execsql_test 8.1 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0 (c0);
+ INSERT INTO t0(c0) VALUES ('a');
+ SELECT LIKELY(t0.rowid) <= '0' FROM t0;
+} {1}
+do_execsql_test 8.2 {
+ SELECT * FROM t0 WHERE LIKELY(t0.rowid) <= '0';
+} {a}
+do_execsql_test 8.3 {
+ SELECT (t0.rowid) <= '0' FROM t0;
+} {0}
+do_execsql_test 8.4 {
+ SELECT * FROM t0 WHERE (t0.rowid) <= '0';
+} {}
+do_execsql_test 8.5 {
+ SELECT unlikely(t0.rowid) <= '0', likelihood(t0.rowid,0.5) <= '0' FROM t0;
+} {1 1}
+do_execsql_test 8.6 {
+ SELECT * FROM t0 WHERE unlikely(t0.rowid) <= '0';
+} {a}
+do_execsql_test 8.7 {
+ SELECT * FROM t0 WHERE likelihood(t0.rowid, 0.5) <= '0';
+} {a}
+do_execsql_test 8.8 {
+ SELECT unlikely(t0.rowid <= '0'),
+ likely(t0.rowid <= '0'),
+ likelihood(t0.rowid <= '0',0.5)
+ FROM t0;
+} {0 0 0}
+do_execsql_test 8.9 {
+ SELECT * FROM t0 WHERE unlikely(t0.rowid <= '0');
+} {}
+do_execsql_test 8.10 {
+ SELECT * FROM t0 WHERE likelihood(t0.rowid <= '0', 0.5);
+} {}
+
+# 2019-12-31: assertion fault discovered by Yongheng's fuzzer.
+# Harmless memIsValid() due to the code generators failure to
+# release the registers used by OP_ResultRow.
+#
+do_execsql_test 9.10 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b FLOAT);
+ INSERT INTO t1(a) VALUES(''),(NULL),('X'),(NULL);
+ SELECT coalesce(max(quote(a)),10) FROM t1 GROUP BY a;
+} {NULL '' 'X'}
+
+# 2020-06-14: assert() changed back into testcase()
+# ticket 9fb26d37cefaba40
+#
+reset_db
+do_execsql_test 10.1 {
+ CREATE TABLE a(b TEXT); INSERT INTO a VALUES(0),(4),(9);
+ CREATE TABLE c(d NUM);
+ CREATE VIEW f(g, h) AS SELECT b, 0 FROM a UNION SELECT d, d FROM c;
+ SELECT g = g FROM f GROUP BY h;
+} {1}
+
+reset_db
+do_execsql_test 11.0 {
+ CREATE TABLE t1(x PRIMARY KEY, y);
+ INSERT INTO t1 VALUES('AAA', 'BBB');
+
+ CREATE TABLE t2(z);
+ INSERT INTO t2 VALUES('t2');
+
+ CREATE TABLE t3(x PRIMARY KEY, y);
+ INSERT INTO t3 VALUES('AAA', 'AAA');
+}
+
+do_execsql_test 11.1.1 {
+ SELECT * FROM t1 JOIN t2 ON unlikely(x=y) AND y='AAA'
+}
+do_execsql_test 11.1.2 {
+ SELECT * FROM t1 JOIN t2 ON likely(x=y) AND y='AAA'
+}
+do_execsql_test 11.1.3 {
+ SELECT * FROM t1 JOIN t2 ON x=y AND y='AAA'
+}
+
+do_execsql_test 11.2.1 {
+ SELECT * FROM t3 JOIN t2 ON unlikely(x=y) AND y='AAA'
+} {AAA AAA t2}
+do_execsql_test 11.2.2 {
+ SELECT * FROM t3 JOIN t2 ON likely(x=y) AND y='AAA'
+} {AAA AAA t2}
+do_execsql_test 11.2.3 {
+ SELECT * FROM t3 JOIN t2 ON x=y AND y='AAA'
+} {AAA AAA t2}
+
+# 2021-06-14 forum https://sqlite.org/forum/forumpost/3b940c437a
+# Affinity problem when a likely() function is used as a column in
+# an index.
+#
+reset_db
+do_execsql_test 12.0 {
+ CREATE TABLE t1(a REAL);
+ INSERT INTO t1(a) VALUES(123);
+ CREATE INDEX t1x1 ON t1(likely(a));
+ SELECT typeof(likely(a)) FROM t1 NOT INDEXED;
+ SELECT typeof(likely(a)) FROM t1 INDEXED BY t1x1;
+} {real real}
+do_execsql_test 12.1 {
+ CREATE INDEX t1x2 ON t1(abs(a));
+ SELECT typeof(abs(a)) FROM t1 NOT INDEXED;
+ SELECT typeof(abs(a)) FROM t1 INDEXED BY t1x2;
+} {real real}
+
+
+finish_test
diff --git a/test/whereH.test b/test/whereH.test
new file mode 100644
index 0000000..c252fe1
--- /dev/null
+++ b/test/whereH.test
@@ -0,0 +1,139 @@
+# 2014-03-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.
+#
+#***********************************************************************
+#
+# Test cases for query planning decisions where one candidate index
+# covers a proper superset of the WHERE clause terms of another
+# candidate index.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test whereH-1.1 {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE INDEX t1abc ON t1(a,b,c);
+ CREATE INDEX t1bc ON t1(b,c);
+
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;
+} {/INDEX t1abc /}
+do_execsql_test whereH-1.2 {
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;
+} {~/TEMP B-TREE FOR ORDER BY/}
+
+do_execsql_test whereH-2.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,d);
+ CREATE INDEX t1bc ON t1(b,c);
+ CREATE INDEX t1abc ON t1(a,b,c);
+
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;
+} {/INDEX t1abc /}
+do_execsql_test whereH-2.2 {
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;
+} {~/TEMP B-TREE FOR ORDER BY/}
+
+do_execsql_test whereH-3.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,d,e);
+ CREATE INDEX t1cd ON t1(c,d);
+ CREATE INDEX t1bcd ON t1(b,c,d);
+ CREATE INDEX t1abcd ON t1(a,b,c,d);
+
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {/INDEX t1abcd /}
+do_execsql_test whereH-3.2 {
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {~/TEMP B-TREE FOR ORDER BY/}
+
+do_execsql_test whereH-4.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,d,e);
+ CREATE INDEX t1cd ON t1(c,d);
+ CREATE INDEX t1abcd ON t1(a,b,c,d);
+ CREATE INDEX t1bcd ON t1(b,c,d);
+
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {/INDEX t1abcd /}
+do_execsql_test whereH-4.2 {
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {~/TEMP B-TREE FOR ORDER BY/}
+
+do_execsql_test whereH-5.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,d,e);
+ CREATE INDEX t1bcd ON t1(b,c,d);
+ CREATE INDEX t1cd ON t1(c,d);
+ CREATE INDEX t1abcd ON t1(a,b,c,d);
+
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {/INDEX t1abcd /}
+do_execsql_test whereH-5.2 {
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {~/TEMP B-TREE FOR ORDER BY/}
+
+do_execsql_test whereH-6.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,d,e);
+ CREATE INDEX t1bcd ON t1(b,c,d);
+ CREATE INDEX t1abcd ON t1(a,b,c,d);
+ CREATE INDEX t1cd ON t1(c,d);
+
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {/INDEX t1abcd /}
+do_execsql_test whereH-6.2 {
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {~/TEMP B-TREE FOR ORDER BY/}
+
+do_execsql_test whereH-7.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,d,e);
+ CREATE INDEX t1abcd ON t1(a,b,c,d);
+ CREATE INDEX t1bcd ON t1(b,c,d);
+ CREATE INDEX t1cd ON t1(c,d);
+
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {/INDEX t1abcd /}
+do_execsql_test whereH-7.2 {
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {~/TEMP B-TREE FOR ORDER BY/}
+
+do_execsql_test whereH-8.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,d,e);
+ CREATE INDEX t1abcd ON t1(a,b,c,d);
+ CREATE INDEX t1cd ON t1(c,d);
+ CREATE INDEX t1bcd ON t1(b,c,d);
+
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {/INDEX t1abcd /}
+do_execsql_test whereH-8.2 {
+ EXPLAIN QUERY PLAN
+ SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
+} {~/TEMP B-TREE FOR ORDER BY/}
+
+
+
+finish_test
diff --git a/test/whereI.test b/test/whereI.test
new file mode 100644
index 0000000..38e0148
--- /dev/null
+++ b/test/whereI.test
@@ -0,0 +1,99 @@
+# 2014-03-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.
+#
+#***********************************************************************
+# The focus of this file is testing the OR optimization on WITHOUT ROWID
+# tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix whereI
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c, PRIMARY KEY(a)) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1, 'a', 'z');
+ INSERT INTO t1 VALUES(2, 'b', 'y');
+ INSERT INTO t1 VALUES(3, 'c', 'x');
+ INSERT INTO t1 VALUES(4, 'd', 'w');
+ CREATE INDEX i1 ON t1(b);
+ CREATE INDEX i2 ON t1(c);
+}
+
+do_eqp_test 1.1 {
+ SELECT a FROM t1 WHERE b='b' OR c='x'
+} {
+ QUERY PLAN
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SEARCH t1 USING INDEX i1 (b=?)
+ `--INDEX 2
+ `--SEARCH t1 USING INDEX i2 (c=?)
+}
+
+do_execsql_test 1.2 {
+ SELECT a FROM t1 WHERE b='b' OR c='x'
+} {2 3}
+
+do_execsql_test 1.3 {
+ SELECT a FROM t1 WHERE b='a' OR c='z'
+} {1}
+
+#----------------------------------------------------------------------
+# Try that again, this time with non integer PRIMARY KEY values.
+#
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a, b, c, PRIMARY KEY(a)) WITHOUT ROWID;
+ INSERT INTO t2 VALUES('i', 'a', 'z');
+ INSERT INTO t2 VALUES('ii', 'b', 'y');
+ INSERT INTO t2 VALUES('iii', 'c', 'x');
+ INSERT INTO t2 VALUES('iv', 'd', 'w');
+ CREATE INDEX i3 ON t2(b);
+ CREATE INDEX i4 ON t2(c);
+}
+
+do_eqp_test 2.1 {
+ SELECT a FROM t2 WHERE b='b' OR c='x'
+} {
+ QUERY PLAN
+ `--MULTI-INDEX OR
+ |--INDEX 1
+ | `--SEARCH t2 USING INDEX i3 (b=?)
+ `--INDEX 2
+ `--SEARCH t2 USING INDEX i4 (c=?)
+}
+
+do_execsql_test 2.2 {
+ SELECT a FROM t2 WHERE b='b' OR c='x'
+} {ii iii}
+
+do_execsql_test 2.3 {
+ SELECT a FROM t2 WHERE b='a' OR c='z'
+} {i}
+
+#----------------------------------------------------------------------
+# On a table with a multi-column PK.
+#
+do_execsql_test 3.0 {
+ CREATE TABLE t3(a, b, c, d, PRIMARY KEY(c, b)) WITHOUT ROWID;
+
+ INSERT INTO t3 VALUES('f', 1, 1, 'o');
+ INSERT INTO t3 VALUES('o', 2, 1, 't');
+ INSERT INTO t3 VALUES('t', 1, 2, 't');
+ INSERT INTO t3 VALUES('t', 2, 2, 'f');
+
+ CREATE INDEX t3i1 ON t3(d);
+ CREATE INDEX t3i2 ON t3(a);
+
+ SELECT c||'.'||b FROM t3 WHERE a='t' OR d='t'
+} {
+ 2.1 2.2 1.2
+}
+
+finish_test
diff --git a/test/whereJ.test b/test/whereJ.test
new file mode 100644
index 0000000..c31ab8c
--- /dev/null
+++ b/test/whereJ.test
@@ -0,0 +1,674 @@
+# 2014-06-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 a complex
+# query planning case.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix whereJ
+
+ifcapable !stat4 {
+ finish_test
+ return
+}
+
+do_execsql_test whereJ-1.0 {
+ CREATE TABLE tx1 (
+ est,
+ cid,
+ sid,
+ fid,
+ aid,
+ edate,
+ rstat,
+ ftype,
+ cx,
+ fyear,
+ fp,
+ acode,
+ a1,
+ curx,
+ tdate,
+ gstat,
+ trgtpx,
+ effdate,
+ adate,
+ ytime,
+ mstat
+ );
+ CREATE INDEX ix0 on tx1(a1,curx,aid,cid,sid,ftype,fp,fyear DESC,edate DESC,fid);
+ CREATE INDEX ix1 on tx1(a1,curx,aid,ftype,fp,fyear DESC,fid,edate DESC,cid,sid);
+ CREATE INDEX ix2 on tx1(a1,curx,cid,sid,ftype,fp,fyear DESC,edate DESC,aid,fid);
+ CREATE INDEX ix3 on tx1(a1,curx,fid,ftype,fp,fyear DESC,cid,sid,aid,edate DESC);
+ CREATE INDEX ix4 on tx1(a1,curx,ftype,cid,sid,aid,edate DESC,fid,fp,fyear DESC);
+ CREATE INDEX ix5 on tx1(a1,curx,ftype,aid,fid,cid,sid,edate DESC,fp,fyear DESC);
+ CREATE INDEX ix6 on tx1(ftype,fp,fyear DESC,cid,sid,edate DESC,a1,fid,aid,curx,est,rstat,cx,acode,tdate,gstat,trgtpx,effdate,adate,ytime,mstat);
+ CREATE INDEX ix7 on tx1(cid,a1,curx,sid,ftype,est,fid,aid,edate,rstat,cx,fyear,fp,acode,tdate,gstat,trgtpx,effdate,adate,ytime,mstat);
+ CREATE INDEX ix8 on tx1(cid,sid,edate DESC,aid,est);
+ CREATE INDEX ix9 on tx1(aid,edate DESC,a1,curx);
+} {}
+do_execsql_test whereJ-1.1 {
+ ANALYZE sqlite_master;
+ DELETE FROM sqlite_stat1;
+ DELETE FROM sqlite_stat4;
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix9','11680827 289 2 2 2');
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix8','11680827 286 250 2 2 2');
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix7','11680827 286 194 98 88 83 18 7 6 2 2 2 2 2 2 2 2 2 2 2 2 2');
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix6','11680827 5840414 5840414 5840414 240 212 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2');
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix5','11680827 5840414 2920207 1668690 114 90 8 8 2 2 2');
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix4','11680827 5840414 2920207 1668690 92 83 9 2 2 2 2');
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix3','11680827 5840414 2920207 2048 1835 1835 1835 12 11 8 2');
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix2','11680827 5840414 2920207 98 88 83 83 83 2 2 2');
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix1','11680827 5840414 2920207 117 114 114 114 90 2 2 2');
+ INSERT INTO sqlite_stat1 VALUES('tx1','ix0','11680827 5840414 2920207 117 9 9 9 9 9 2 2');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6736 21 21 21 1','29210 29404 29404 29404 29424','44 12184 13020 13079 29424',X'06030409080416C1150133512800B01FCA');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6658 24 21 21 1','452220 453273 453276 453276 453296','622 226258 235279 236774 453296',X'06030409080416F34501332ADC00AA1BD3');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','820 2 2 2 1','1297771 1297869 1297869 1297869 1297869','1964 681724 711020 715822 1297869',X'06030409080317875501332C6C55AF4D');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','26985 2216 2216 2216 1','1797607 1797782 1797782 1797782 1799997','3162 970307 1008879 1016089 1799997',X'0603040809041A08040132401A0099A334');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','10434 19 17 17 1','2118117 2120403 2120405 2120405 2120421','3815 1136110 1181459 1190207 2120421',X'0603040908041AD36901332CD000861A2F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','437 1 1 1 1','2595414 2595739 2595739 2595739 2595739','5005 1409452 1464066 1475163 2595739',X'0603040808031CE7FD01317FD46BFBCC');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','12619 38 38 38 1','2595957 2600212 2600212 2600212 2600249','5007 1410347 1464961 1476068 2600249',X'0603040808041CE87E01328F61008CE96A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','7534 23 18 18 1','3329985 3334890 3334895 3334895 3334912','6901 1834013 1902216 1917268 3334912',X'060304090804244E1901328F59008CAA39');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','5693 1 1 1 1','3891665 3893609 3893609 3893609 3893609','8357 2164400 2245393 2263185 3893609',X'0603040808043063B70132B66800A28A43');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','44405 2588 2223 1527 1','4220255 4221633 4221998 4222694 4224220','9221 2354858 2441973 2461511 4224220',X'0603040909043377630133517A00B0DE4F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6883 32 28 28 1','4423918 4429926 4429930 4429930 4429957','9690 2452276 2543443 2563995 4429957',X'06030409080434F46801328F5C008CC3DA');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6974 27 26 26 1','5048404 5051129 5051130 5051130 5051155','11703 2817010 2920184 2944013 5051155',X'0603040908043C1C5C0132DEA5009F7473');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','476 2 2 2 1','5191322 5191479 5191479 5191479 5191479','12242 2901130 3006663 3031222 5191479',X'0603040908033DC6080132DEA478849A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','627 4 4 4 1','6488823 6489349 6489349 6489349 6489349','16423 3644815 3778857 3809866 6489349',X'0603040808035AA00E0131F4AE342150');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','145 2 2 1 1','7787091 7787218 7787218 7787219 7787219','20223 4343720 4510110 4547961 7787219',X'0603040809037254890132189C703706');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','20 1 1 1 1','9085074 9085089 9085089 9085089 9085089','25315 5033102 5230788 5275692 9085089',X'06040408080300EAE6CA01326657620652');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','229621 6135 5934 5934 1','9507353 9572696 9572696 9572696 9576801','27189 5255584 5463962 5511784 9576801',X'06040408080300F2FA440132DF1A7D1A60');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6376 24 22 22 1','10381524 10382938 10382940 10382940 10382959','30519 5581705 5804515 5856651 10382959',X'06040409080400F9DBF3013305AC00A688A4');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','7761 45 9 9 1','10569039 10572476 10572512 10572512 10572520','31455 5661599 5888691 5941811 10572520',X'06040409080400FB31560132DDD800A05DF5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','8382 37 37 37 1','10866664 10867565 10867565 10867565 10867601','33475 5809193 6042611 6097741 10867601',X'06040409080400FFA4A701332A0E00A93957');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','76136 4099 3018 3018 1','11283107 11308143 11309224 11309224 11312241','37001 6022861 6264510 6322923 11312241',X'060404090804010B0A5C0133517200B0E8E0');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','23472 2188 2188 2181 1','11365285 11380281 11380281 11380288 11382468','37055 6026680 6268909 6327509 11382468',X'060404080904010B3C6701332B2E00AA4374');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','59591 4087 4073 4 1','11415316 11448759 11448773 11452842 11452845','37350 6040743 6283483 6342389 11452845',X'060404090904010BFA810133512800B010AE');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix9','43891 3029 3021 4 1','11598477 11622881 11622889 11625906 11625909','39110 6107644 6353109 6413914 11625909',X'0604040909040113B9960133512800B01235');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7340 4977 19 1 1 1','206533 206533 208739 208757 208757 208757','125 164 111403 207397 207399 208757',X'070308040407030187840132B54B0101A0D1401C0000000000004C87E5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','8877 8788 45 1 1 1','1221375 1221375 1224509 1224553 1224553 1224553','931 1117 679933 1216705 1216722 1224553',X'07030804040703018D3F0133023D010B9B67401C0000000000007A99EF');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7204 7204 39 1 1 1','1240162 1240162 1242572 1242610 1242610 1242610','942 1131 688420 1234655 1234672 1242610',X'07030804040703018D4F0132DB820105D324401C0000000000007EC569');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','9608 9608 44 1 1 1','1264939 1264939 1266529 1266572 1266572 1266572','952 1145 699518 1258423 1258440 1266572',X'07030804040704018D61013305B9010D3CEB406E8000000000000081E17A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','6636 6636 1 1 1 1','1294580 1294580 1297869 1297869 1297869 1297869','964 1159 713121 1289522 1289540 1297869',X'07030804030704018D7801328F693482A2403400000000000000A26728');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7822 6629 26 1 1 1','2375708 2375708 2381333 2381358 2381358 2381358','3423 3833 1371902 2366527 2366559 2381358',X'0703080403070301B1F501317F16403B7B403F00000000000060D67A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','1403 1303 5 1 1 1','2594767 2594767 2595737 2595739 2595739 2595739','3914 4427 1512042 2580073 2580114 2595739',X'0703080403070301B6480131CC18558082407120000000000029CC12');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7901 6067 26 1 1 1','3424107 3424107 3425939 3425964 3425964 3425964','5872 6630 2032411 3406550 3406594 3425964',X'0703080404070401C3F90132B7A100FDCC04403E00000000000000A014CE');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7483 6161 22 1 1 1','3549446 3549446 3555223 3555244 3555244 3555244','5932 6752 2099309 3535259 3535304 3555244',X'0703080403070301C4490131573F4104F8403400000000000067FD1E');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','12076 8263 37 1 1 1','3558079 3558079 3560036 3560072 3560072 3560072','5935 6758 2101989 3540078 3540123 3560072',X'0703080404070301C44E0132DD0901076DA9404200000000000076F994');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','1123 1113 1 1 1 1','3892913 3892913 3893609 3893609 3893609 3893609','6594 7611 2305483 3871711 3871770 3893609',X'0703080403070301CA280131CA1C215083401C00000000000071F6B2');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','9344 7315 41 1 1 1','4213510 4213510 4219434 4219474 4219474 4219474','7200 8390 2503024 4196141 4196204 4219474',X'0703080404070301CE8C01317DE800FE4E8B4034000000000000458317');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','8062 3291 1 1 1 1','5037060 5037060 5040350 5040350 5040350 5040350','10201 11915 3045602 5012912 5012997 5040350',X'070308040307030213B20130B83A16DF86403600000000000028F8CD');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','9125 2926 1 1 1 1','5046490 5052665 5055590 5055590 5055590 5055590','10203 11926 3055524 5028097 5028182 5055590',X'070302040307030213B5232A013107F01745AF40330000000000002B57DE');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','591 591 1 1 1 1','5190991 5190991 5191479 5191479 5191479 5191479','10649 12426 3145181 5163206 5163296 5191479',X'070308040307030244AD0131315217C1CD401C00000000000003BC32');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7381 4689 1 1 1 1','6112248 6112248 6116936 6116936 6116936 6116936','13780 16308 3748958 6083681 6083797 6116936',X'0703080403070402A9D1013108B531A21C401C0000000000000092F5C6');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7569 7381 28 1 1 1','6280084 6280084 6281842 6281869 6281869 6281869','14559 17217 3856803 6247722 6247841 6281869',X'0703080404070302C14C0132DBF101044CC7401C00000000000074FB16');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','8289 7047 28 1 1 1','6290764 6290764 6296854 6296881 6296881 6296881','14569 17229 3863206 6262658 6262777 6296881',X'0703080403070302C16401317CC348B670401C0000000000006824BB');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','2209 2209 1 1 1 1','6489075 6489075 6489349 6489349 6489349 6489349','15377 18147 3986912 6454194 6454318 6489349',X'0703080403070402EA5901332A656C6F5E401C00000000000000AE7C03');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7381 6799 1 1 1 1','7314420 7314420 7321218 7321218 7321218 7321218','18403 21722 4532963 7281695 7281847 7321218',X'07030804030703049EE501310667176DC940438000000000005ED2B5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7163 7001 31 1 1 1','7652849 7652849 7658600 7658630 7658630 7658630','19462 22956 4750159 7617449 7617608 7658630',X'070308040407030503EB01317DEF010ADD3F402800000000000061C3EF');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','1433 1433 2 1 1 1','7785842 7785842 7787219 7787219 7787219 7787219','20001 23575 4834605 7745315 7745477 7787219',X'07030804030703055010013156D81B11AC404380000000000004A313');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','2247 2247 1 1 1 1','9083272 9083272 9085089 9085089 9085089 9085089','24940 29143 5668423 9036693 9036887 9085089',X'070308040307031A620A01323EEB5CE39C406FE000000000006F8177');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix8','107 107 5 1 1 1','10382912 10382912 10382957 10382959 10382959 10382959','31251 36297 6541362 10329764 10330008 10382959',X'0704080403070400955501013350516AA9D0406060000000000000884648');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7340 4770 4527 3331 3331 970 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','206533 206533 206533 206533 206533 206596 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565','125 202 402 512 560 6209 20696 25885 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 207565',X'1703080808080704030408030808010308070808080803018784401C000000000000024FD353493F8801317E4700FFFF0F00FFFFC0F869E0000000002642C5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','8877 4669 71 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1221375 1225583 1230181 1230249 1230249 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251','931 1504 2992 3495 3751 39629 120561 147424 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1230251',X'1703090902080704030408090808010108070404040804018D3F03E8405680000000000000822B981EB823013351F00F0C4086E00000000000013351F0013351F053870D7500B22A8C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7204 4801 193 193 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1240162 1240162 1244770 1244770 1244959 1244961 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962','942 1520 3024 3531 3791 40098 122274 149540 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1244962',X'1703080908010703030408030808010308070408040803018D4F07406FE000000000000602CF16DE05013303C300FFFF0300FFFFC0F869E000000000013303C3008000004BD756');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','9608 6098 5910 5910 5910 2149 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1264939 1264939 1264939 1264939 1264939 1265217 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365','952 1536 3055 3576 3841 40616 124132 151876 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1267365',X'1703080808080704030408090808010101070404040803018D61401C0000000000000131374D1726AB0132DD780F0C0540390000000000000132DD780132DD784E2789C6190CA9');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','6636 4411 4237 4237 4237 33 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1294580 1294580 1294580 1294580 1294580 1297842 1297862 1297862 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869','964 1557 3097 3622 3888 41246 126538 154868 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1297869',X'1703080808080703030408090808010308070808080803018D7840420000000000007332F1227B5901321AF80800FFFF40260000000000006D0CEB');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7822 4817 260 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','2375708 2375708 2380265 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524','3423 5117 10120 11184 11775 86237 242937 294878 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2380524',X'170308090308070304040803080801030807040408080401B1F501831C405C40000000000077646800EAD44C0132697000FFFF0300FFFFC0F869E0000000000132696F0132696F0094935E');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','1403 1022 82 74 74 55 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','2594767 2594767 2595707 2595707 2595707 2595708 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739','3914 5817 11518 12879 13613 98100 278304 342850 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2595739',X'170308090808070303040803080801030807080808080301B648405C400000000000038EAC243F770131A6F700FFFF0E00FFFFC0F869E0000000005C8664');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7901 5298 291 55 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3424107 3424107 3429114 3429350 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404','5872 8944 17727 19769 20846 145206 401995 498360 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3429404',X'170308090201070404040803080801030807040808080401C3F9232807405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E000000000013329460083157B');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7483 5407 230 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3549446 3549446 3554623 3554845 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852','5932 9041 17921 20139 21264 149060 417718 520064 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3554852',X'170308090201070404040803080801030807040808080401C449232807405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E000000000013329460083162A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','12076 8365 7981 5546 5546 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3558079 3558079 3558079 3558079 3558079 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624','5935 9046 17930 20154 21279 149235 418443 521109 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3563624',X'170308080808070303040803080801030107040408080301C44E4074300000000000029EB13BB98E01328EFE00FFFF0E00FFFF0AC0F869E00000000001328F0001328F0071D802');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','1123 916 875 875 875 93 22 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3892913 3892913 3892913 3892913 3892913 3893531 3893602 3893602 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609','6594 10057 19942 22653 23964 165533 468498 587524 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3893609',X'170308080808070403040802080801030107040404080301CA28403F00000000000000832DC71933330132DB8800FC0F00FFFF054050C000000000000132DB870132DB8A4D5E35A2107205');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','9344 6359 6022 9 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','4213510 4213510 4213510 4219523 4219523 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531','7200 11025 21872 25036 26543 181203 517345 652858 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4219531',X'170308080308070303040803080801030807080808080301CE8C0186A0403F00000000000002C2142F19870131554100FFFF0F00FFFFC0F869E0000000000687F7');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','8062 4993 241 53 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','5037060 5037060 5041812 5042000 5042051 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052','10201 15484 30736 35196 37326 231854 654010 829510 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5042052',X'17030809020107030404080308080103080704080808030213B2245407406FE0000000000002C0AA00F6ABA101332A7E00FFFF0300FFFFC0F869E00000000001332A7E5287C0');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','9125 5761 264 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','5046490 5046490 5051987 5052246 5052246 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250','10203 15488 30744 35230 37365 232178 654964 830718 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5052250',X'17030809030807030304080308080103080708080808030213B501831F406FE00000000000029E627136F901328DD500FFFF0300FFFFC0F869E000000000290DD6');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','591 591 566 566 566 27 18 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1','5190991 5190991 5190991 5190991 5190991 5191461 5191464 5191474 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479','10649 16115 31973 36593 38793 239550 673441 853755 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5191479',X'17030808080807030404080108080101080708080808040244AD4045800000000000029E6200EAE8740132690D0A0F0C402E00000000000000941EAF');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7381 3728 83 16 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6112248 6115901 6119546 6119613 6119613 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628','13780 20707 41067 47538 50438 296473 834203 1056686 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6119628',X'170309090208070304040809080801010807040404080402A9D12328407360000000000002172300EABCFF0133517F0F0C404AA6665E02EA960133517F01335239538BC5C1008B5EC9');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7569 5785 274 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6280084 6280084 6285595 6285867 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868','14559 21811 43240 50020 53057 307264 862871 1092992 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6285868',X'170308090301070404040803080801030807040808080302C14C01832707405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E000000000013329461E5109');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','8289 5734 266 33 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6290764 6290764 6296232 6296465 6296495 6296495 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497','14569 21827 43272 50056 53096 307563 864043 1094585 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6296497',X'170308090201070404040803080801030807040808080402C164232807405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E0000000000133294600A90415');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','2209 1450 1369 1369 1369 597 13 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6489075 6489075 6489075 6489075 6489075 6489139 6489344 6489344 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349','15377 22998 45584 52641 55837 319564 895653 1134252 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6489349',X'170308080808070303040802080801030807040404080302EA59401C0000000000000D4B201AD8B30132DF0400FC0600FFFF40180000000000000132DF040132DF054EBA338714FBBA');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7381 5446 171 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','7314420 7314420 7319695 7319855 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865','18403 27319 54152 62541 66337 369851 1032180 1306261 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7319865',X'1703080902010703030408030808010308070408080804049EE503E907405C400000000000029EC32E97BE0133061F00FFFF0300FFFFC0F869E0000000000133061F00A9ECEF');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7163 4782 209 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','7652849 7652849 7657422 7657626 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630','19462 28830 57147 65962 69945 388539 1084446 1372423 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7657630',X'17030809020107040404080308080103080704080808040503EB03EA07405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E0000000000133294600831554');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','1433 582 571 571 571 15 15 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1','7785842 7786693 7786693 7786693 7786693 7787208 7787208 7787208 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219','20001 29582 58632 67649 71736 396840 1107204 1400830 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7787219',X'1703090808080703040408090808010108070404040804055010406E80000000000001C7A600FC429201332D890F0C402C00000000000001332D890133505352D7248A008775D8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','2247 682 657 657 657 117 45 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1','9083272 9084837 9084837 9084837 9084837 9085088 9085088 9085088 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089','24940 36384 72113 82665 87632 474987 1318830 1664527 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9085089',X'17030908080807030304080208080103010704040408031A620A403E00000000000001C3D332CF850132DE9D00FC0200FFFF054050E000000000000132DE9D0132DE9D4E8C092E790553');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix7','107 77 69 69 69 11 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1','10382912 10382942 10382942 10382942 10382942 10382952 10382956 10382956 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959','31251 45639 90416 102896 109225 567280 1544395 1943661 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10382959',X'170409080808070303040809080801010807040404080300955501403E000000000000029E686E250B01332D220F0C402E00000000000001332D220133504E52CFCF4F21CD7F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7337 4975 19 19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 206462 206462 210789 210789 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807','0 0 0 125 164 112407 128579 207456 209489 209490 209490 209490 209490 209490 209490 209490 209490 209490 209490 209490 209490 210807',X'170808080308040804030807080301030807080808080301878401317F26024FD3531E2DAF404200000000000000FFFF0200FFFFC0F869E0000000002642C4');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 8874 8785 45 25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1221012 1221012 1224145 1224165 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189','0 0 0 931 1117 679896 773861 1207582 1216653 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1224189',X'1708080803080409040408070809010308070404040803018D3F0133023D01940C420106B14D40420000000000000F00FFFF4070E000000000000133023D0133023D4F2053654AE525');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7200 7200 39 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1239793 1239793 1242199 1242223 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237','0 0 0 942 1131 688381 783660 1225441 1234602 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1242237',X'1708080803080409040308070809010301070404040804018D4F0132DB820113FAB92F19C5401C0000000000000F00FFFF0F403A0000000000000132DB820132DB824D542A4F009B5C72');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 9606 9606 44 25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1264560 1264560 1266149 1266168 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192','0 0 0 952 1145 699479 796008 1249062 1258369 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1266192',X'1708080803080409040308070809010101070404040803018D61013305B9017CDF4916F8B140280000000000000F0C0A403600000000000001330557013305B9507EA8DD212E79');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 6635 6635 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1294199 1294199 1297868 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869','0 0 0 964 1159 713241 812408 1280435 1289849 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1297869',X'1708080803080409030308070803010308070808080803018D78013267DC0EF747387106403F00000000000000FFFF0F00FFFFC0F869E00000000006B968');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7815 6624 26 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 2374939 2374939 2380559 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584','0 0 0 3423 3833 1371803 1539928 2350493 2366415 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2380584',X'170808080308040903030807080301030807080808080301B1F501317F160DDEA51C46AB405280000000000000FFFF0F00FFFFC0F869E0000000006ADDA9');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 3595 3459 10 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 2595336 2595336 2595734 2595737 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739','0 0 0 3918 4433 1512586 1693312 2557025 2580917 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2595739',X'170808080308040903030807080101010107040404080301B64F01332ACC029E833D19084028000000000000320F0C054074A0000000000001332A0901332ACC518A316F1F30D6');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7894 6061 26 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3422592 3422592 3424418 3424434 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443','0 0 0 5872 6630 2032185 2267240 3366727 3406294 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3424443',X'170808080308040904030807080101030807040404080401C3F90132B7A100D6FD7F6CE97F4070500000000000100F00FFFF40560000000000000132B7310132DB2D4D3F72D9009AE8EE');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7479 6158 22 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3547845 3547845 3553619 3553619 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640','0 0 0 5932 6752 2099067 2343370 3491679 3534981 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3553640',X'170808080308040804030807080301030807080808080301C4490131573F008E7AC03077E0403E00000000000000FFFF0F00FFFFC0F869E00000000065B45A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 12068 8257 37 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3556474 3556474 3558426 3558446 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462','0 0 0 5935 6758 2101744 2346448 3496404 3539797 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3558462',X'170808080308040904030807080201010107040404080301C44E0132DD09016891C11788EB404200000000000000FC0F0C0F400199999999999A0132DD090132DD094DE5DCE3763299');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 1510 1497 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3892149 3892149 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609','0 0 0 6596 7614 2306358 2572095 3823194 3873232 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3893609',X'170808080308040803030807080301030807080808080301CA2E01312E3A038EE6257265400000000000000000FFFF0600FFFFC0F869E00000000032518F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 9341 7313 41 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 4211282 4211282 4217204 4217243 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244','0 0 0 7200 8390 2502650 2792131 4139620 4195704 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4217244',X'170808080308040903030807080301030807080808080301CE8C01317DE8029E9D3B6D23403E00000000000000FFFF0F00FFFFC0F869E00000000008EF7D');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 8055 3290 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 5033936 5033936 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225','0 0 0 10201 11915 3045026 3383481 4941323 5012256 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5037225',X'17080808030804090303080708030803080708080808030213B20130B83A018A7516DF86403600000000000000FFFF00FFFFC0F869E00000000028F8CD');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 9117 2923 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 5043358 5049528 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450','0 0 0 10203 11926 3054947 3394812 4956408 5027439 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5052450',X'17080808030204080303080708030103080708080808030213B5232A013107F00217231745AF403300000000000000FFFF0200FFFFC0F869E0000000002B57DE');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 333 333 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 5191271 5191271 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479','0 0 0 10672 12452 3147059 3494842 5093162 5165710 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5191479',X'17080808030804080303080708030103080708080808030244F00131CB4201C1C917188E403F00000000000000FFFF0800FFFFC0F869E00000000001C5CB');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7374 4684 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6107894 6107894 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577','0 0 0 13780 16308 3748117 4153600 5995776 6082692 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6112577',X'170808080308040803030807080301030807080808080402A9D1013108B5029E6831A21C401C00000000000000FFFF0200FFFFC0F869E0000000000092F5C6');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7562 7376 28 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6275521 6275521 6277274 6277291 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301','0 0 0 14559 17217 3855913 4271255 6156622 6246677 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6277301',X'170808080308040904030807080201030107040404080302C14C0132DBF100832DC739FF53403F00000000000000FC0F00FFFF05402C0000000000000132DBF10132DBF34D89B7AA1114CB');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 8282 7043 28 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6286191 6286191 6292277 6292277 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304','0 0 0 14569 17229 3862314 4278722 6171137 6261611 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6292304',X'170808080308040804030807080301030807080808080302C16401317CC301B5AA4A1AB270405680000000000000FFFF0F00FFFFC0F869E00000000048FD4C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 3101 3101 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6486495 6486495 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349','0 0 0 15379 18149 3988504 4417216 6363796 6457879 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6489349',X'170808080308040803030807080301030807080808080302EA6601317F7301C3EB17C4CE401C00000000000000FFFF0F00FFFFC0F869E000000000398198');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7379 6798 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 7308682 7308682 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479','0 0 0 18403 21722 4531809 5008068 7172304 7280343 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7315479',X'1708080803080408040308070803010308070808080803049EE501310667008390D0176DC9404380000000000000FFFF0500FFFFC0F869E0000000005ED2B5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 211 211 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 7787150 7787150 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219','0 0 0 20027 23602 4837427 5341824 7634169 7750020 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7787219',X'17080808030804080303080708090103080704040808030550B30132B73501A79C17C3D840340000000000000F00FFFF40140000000000000132B6D00132B7400D1DB9');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 26 26 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 9085083 9085083 9085088 9085088 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089','0 0 0 24964 29171 5671673 6246216 8904392 9042441 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9085089',X'17080808030804080303080708030103080708080808031AA25C0131CA197A6D831B1D84401C00000000000000FFFF0F00FFFFC0F869E00000000071E307');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 1261 1261 9 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 10381872 10381872 10382956 10382956 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959','0 0 0 31297 36344 6545140 7198586 10180602 10336983 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10382959',X'17080808040804080303080708010101080708080808030095A4C401321BB603010141073C401C000000000000080F0C40308000000000007E55BE');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix6','12287 12287 12287 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','11668540 11668540 11668540 11672111 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127','1 1 1 43128 49243 7431284 8170740 11452355 11624787 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11672127',X'1701080803020408040409070803010308070408040804070267C127130133041E00AB540900E64074405C40000000000000FFFF0300FFFFC0F869E0000000000133041E0080000000A3EE16');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 24157 24157 29 29 1 1 1 1','0 0 0 1236590 1236590 1251799 1251799 1251827 1251827 1251827 1251827','0 0 0 3120 4771 71527 72755 1238782 1238782 1238782 1251827',X'0C08080803040308040808031A080400FF5594029BB30131CD372B1368');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 1209 1209 129 129 1 1 1 1','0 0 0 1296873 1296873 1297744 1297744 1297869 1297869 1297869 1297869','0 0 0 3203 4902 74577 75831 1284645 1284645 1284645 1297869',X'0C08080803030308040808041A215F04C9D901B0A30131066F0087162A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 12129 9261 428 428 1 1 1 1','0 0 0 1790076 1790076 1790076 1790076 1790503 1790503 1790503 1790503','0 0 0 4938 7561 108783 110860 1774402 1774402 1774402 1790503',X'0C08080803030308040808031CE87E029E6B018700013219C1373BA8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 273 273 5 5 1 1 1 1','0 0 0 2595625 2595625 2595738 2595738 2595739 2595739 2595739 2595739','0 0 0 7863 12132 166423 169877 2575172 2575172 2575172 2595739',X'0C08080803030308040808042F020502DA0E02C73A0133049700A711F8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 7735 7735 29 29 1 1 1 1','0 0 0 2924165 2924165 2929754 2929754 2929782 2929782 2929782 2929782','0 0 0 9123 14045 191316 195293 2907742 2907742 2907742 2929782',X'0C080808030403080408080333776300FF559475928D013329435A824F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 360 229 27 27 1 1 1 1','0 0 0 3893374 3893505 3893605 3893605 3893609 3893609 3893609 3893609','0 0 0 13912 21124 273265 278784 3866425 3866425 3866425 3893609',X'0C08080803030308040808044717710E070B01E88F0131A5B80098D0A5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 683 671 32 32 1 1 1 1','0 0 0 5191447 5191459 5191477 5191477 5191479 5191479 5191479 5191479','0 0 0 20361 30776 381171 389104 5158962 5158962 5158962 5191479',X'0C08080803030308040808037370D10F00290188450132B537354C5E');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 213354 213354 113 113 1 1 1 1','0 0 0 6102233 6102233 6155183 6155183 6155295 6155295 6155295 6155295','0 0 0 26812 39489 472780 483115 6119281 6119281 6119281 6155295',X'0C080808040403080408080300F2FA4400FF5594019B6D01324067714AE8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 3675 3675 241 241 1 1 1 1','0 0 0 6486701 6486701 6489287 6489287 6489349 6489349 6489349 6489349','0 0 0 28380 41383 502486 513750 6452691 6452691 6452691 6489349',X'0C080808040304080408080300F6ABAC6C967D009F84B60132DBDD155A2A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 24063 24063 38 38 1 1 1 1','0 0 0 7080911 7080911 7102380 7102380 7102417 7102417 7102417 7102417','0 0 0 35724 49844 582928 595393 7065320 7065320 7065320 7102417',X'0C0808080404040804080803010B0A5C00FF559400CCD3EE0133294559DDCD');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 20284 20284 38 38 1 1 1 1','0 0 0 7107237 7107237 7126606 7126606 7126643 7126643 7126643 7126643','0 0 0 35764 49885 586473 599030 7089546 7089546 7089546 7126643',X'0C0808080404040804080803010B3C6700FF55940114CE73013329432225CC');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 630326 618063 11855 11855 3 1 1 1 1 1','0 7173953 7173953 7665258 7665258 7672559 7672561 7672561 7672561 7672561 7672561','0 1 2 64320 91213 1077048 1100563 7630436 7630436 7630436 7672561',X'0C080908040403020408080400F2FA4400FF559405DD0A23280132DD75009F3468');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 630326 618063 4 4 1 1 1 1 1 1','0 7173953 7173953 7787218 7787218 7787219 7787219 7787219 7787219 7787219 7787219','0 1 2 74034 102405 1189484 1215034 7745001 7745001 7745001 7787219',X'0C0809080403040804080803010DDABE0368B700FEBFF60133068F22D1E5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 630326 12263 1433 1433 1 1 1 1 1 1','0 7173953 7792016 7797877 7797877 7799309 7799309 7799309 7799309 7799309 7799309','0 1 3 76213 104626 1201397 1227113 7757087 7757087 7757087 7799309',X'0C08090104040408040808030700F2FA4400FF559401C3969E013329461E5052');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 8657 8657 605 605 1 1 1 1','7804279 7804279 7804279 8360485 8360485 8364643 8364643 8365247 8365247 8365247 8365247','1 2 4 77865 106290 1217527 1243460 8321843 8321843 8321843 8365247',X'0C09080803030308040808031AD369021FFC0DC36E01328E2F3D9128');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 33421 33421 57 26 1 1 1 1','7804279 7804279 7804279 8873934 8873934 8891008 8891039 8891064 8891064 8891064 8891064','1 2 4 78914 107340 1231432 1257622 8846644 8846644 8846644 8891064',X'0C090808030403020408080433776300FF55940CE166232801332A1800836DFB');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 2182 2182 94 94 1 1 1 1','7804279 7804279 7804279 9083187 9083187 9085006 9085006 9085089 9085089 9085089 9085089','1 2 4 79307 107733 1237174 1263453 9040316 9040316 9040316 9085089',X'0C09080803030308040808033AC92C021FFC04AF670132B5FC38DBD0');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 6023 6023 50 50 1 1 1 1','7804279 7804279 7804279 9393480 9393480 9395815 9395815 9395864 9395864 9395864 9395864','1 2 4 79973 108402 1245294 1271679 9350536 9350536 9350536 9395864',X'0C09080803030308040808034CDD9A7E1C2301C30D0132908703CC11');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 79 79 6 6 1 1 1 1','7804279 7804279 7804279 10382946 10382946 10382956 10382956 10382959 10382959 10382959 10382959','1 2 4 82501 110947 1276304 1303221 10336296 10336296 10336296 10382959',X'0C090808040303080408080400E9A10A0CC31602A47201332C6C00ABCD60');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 8251 8251 280 280 1 1 1 1','7804279 7804279 7804279 11067468 11067468 11072690 11072690 11072969 11072969 11072969 11072969','1 2 4 85529 113989 1307763 1335183 11025935 11025935 11025935 11072969',X'0C090808040404080408080300FFA4A7008A66AD0089DBDD0132B5FF6AE2B8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 44772 44772 58 58 1 1 1 1','7804279 7804279 7804279 11268036 11268036 11269261 11269261 11269318 11269318 11269318 11269318','1 2 4 87132 115597 1321101 1348736 11222284 11222284 11222284 11269318',X'0C0908080404030804080804010B0A5C00FF5594018ACD0133294300B0E291');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 53775 53775 37 19 1 1 1 1','7804279 7804279 7804279 11330929 11330929 11355027 11355045 11355063 11355063 11355063 11355063','1 2 4 87335 115800 1327560 1355328 11308029 11308029 11308029 11355063',X'0C0908080404030204080803010BFA8100FF5594026C24232801332B2E1F8BB5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 39430 39430 39 39 1 1 1 1','7804279 7804279 7804279 11458789 11458789 11476757 11476757 11476795 11476795 11476795 11476795','1 2 4 88502 116970 1340484 1368500 11429761 11429761 11429761 11476795',X'0C09080804040308040808030113B99600FF559402F6AF01332B2E1F8A54');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 157757 157736 5317 5317 1 1 1 1 1 1','7804279 11523070 11523070 11652823 11652823 11658139 11658139 11658139 11658139 11658139 11658139','1 3 5 100045 128561 1480184 1510648 11611105 11611105 11611105 11658139',X'0C0909080404040204080803010BFA8100FF559402594CCB2328013351E85B0F5D');
+} {}
+do_execsql_test whereJ-1.3 {
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4748 4629 308 1 1 1 1 1','0 0 0 634880 634880 639119 639426 639426 639426 639426 639426','0 0 0 779 907 26900 633919 633920 633920 633920 639426',X'0C0808080308040403080803018C4A00F450A80132671F029EAC271DA5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4608 4608 246 1 1 1 1 1','0 0 0 752580 752580 755578 755823 755823 755823 755823 755823','0 0 0 936 1089 31876 749384 749385 749385 749385 755823',X'0C0808080308030403080804018D4F347FD20131547D018A7500936FE2');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4776 4776 240 1 1 1 1 1','0 0 0 762070 762070 764545 764784 764784 764784 764784 764784','0 0 0 940 1097 32187 758274 758275 758275 758275 764784',X'0C0808080308030403080804018D562E0EAB0131A68F029E9300994D36');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5910 5910 257 1 1 1 1 1','0 0 0 771353 771353 772646 772902 772902 772902 772902 772902','0 0 0 946 1103 32460 766333 766334 766334 766334 772902',X'0C0808080308030404080803018D611726F40130E13C00822B980302A0');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 1834 1834 46 1 1 1 1 1','0 0 0 1296866 1296866 1297832 1297869 1297869 1297869 1297869 1297869','0 0 0 2621 2842 56932 1287063 1287064 1287064 1287064 1297869',X'0C080808030803040308080301A6E33010BC01317F2005516E3932DB');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5007 3959 317 1 1 1 1 1','0 0 0 2152400 2152400 2153781 2154097 2154097 2154097 2154097 2154097','0 0 0 5683 6304 111431 2139450 2139457 2139457 2139457 2154097',X'0C080808030803040308080301C3F91E114001315549029F74635F36');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4768 4609 397 1 1 1 1 1','0 0 0 2200466 2200466 2200700 2201096 2201096 2201096 2201096 2201096','0 0 0 5714 6370 114266 2186220 2186227 2186227 2186227 2201096',X'0C080808030803040308080401C42217887E01312D72036D5B009AF3F8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5177 4669 264 1 1 1 1 1','0 0 0 2234078 2234078 2235865 2236128 2236128 2236128 2236128 2236128','0 0 0 5743 6422 116499 2221108 2221115 2221115 2221115 2236128',X'0C080808030803040308080401C4491EF49D013155450D4B200091BFB3');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 7981 5546 272 1 1 1 1 1','0 0 0 2239923 2239923 2242583 2242854 2242854 2242854 2242854 2242854','0 0 0 5746 6428 116800 2227775 2227782 2227782 2227782 2242854',X'0C080808030803040308080301C44E2EFF35013109E67764687E36D6');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 351 336 15 1 1 1 1 1','0 0 0 2595725 2595725 2595725 2595739 2595739 2595739 2595739 2595739','0 0 0 6747 7717 144364 2578697 2578708 2578708 2578708 2595739',X'0C080808030803040308080401CCC91782C20131CC1902D7C0008E7A4F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 6022 4942 304 1 1 1 1 1','0 0 0 2648510 2648510 2648849 2649152 2649152 2649152 2649152 2649152','0 0 0 6934 7959 149030 2631886 2631900 2631900 2631900 2649152',X'0C080808030803040308080301CE8C17887E01312D6E036D5B424939');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4752 1965 5 1 1 1 1 1','0 0 0 3161780 3161780 3163740 3163744 3163744 3163744 3163744 3163744','0 0 0 9707 11219 194477 3143873 3143896 3143896 3143896 3163744',X'0C08080803080404030808030213B20116290C01332B9D0270102494C2');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5497 1880 3 1 1 1 1 1','0 0 0 3167643 3167643 3169520 3169522 3169522 3169522 3169522 3169522','0 0 0 9709 11226 194760 3149632 3149655 3149655 3149655 3169522',X'0C08080803080404040808030213B5010B0A5C0133294500FF55941DCA72');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 2185 2126 134 1 1 1 1 1','0 0 0 3891669 3891669 3893607 3893609 3893609 3893609 3893609 3893609','0 0 0 13596 15952 257364 3869701 3869733 3869733 3869733 3893609',X'0C080808030804040308080302BD5F01010F13013350517B8BF356D913');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5511 5355 345 1 1 1 1 1','0 0 0 3931849 3931849 3931954 3932298 3932298 3932298 3932298 3932298','0 0 0 13793 16188 260160 3908172 3908206 3908206 3908206 3932298',X'0C080808030803040308080402C14C17887E01312D75036D5B009AF4B1');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5468 5115 310 1 1 1 1 1','0 0 0 3939090 3939090 3939894 3940203 3940203 3940203 3940203 3940203','0 0 0 13803 16200 260571 3916034 3916068 3916068 3916068 3940203',X'0C080808030803040308080302C164191E7F0131A4FC0606F30CE25A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5275 4792 252 1 1 1 1 1','0 0 0 4590216 4590216 4591340 4591591 4591591 4591591 4591591 4591591','0 0 0 17456 20455 315887 4563939 4563981 4563981 4563981 4591591',X'0C0808080308030403080804049EE51EB67B01317C5204C9D900AE08CD');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 339 339 20 1 1 1 1 1','0 0 0 5191257 5191257 5191475 5191479 5191479 5191479 5191479 5191479','0 0 0 20754 24230 366257 5160652 5160701 5160701 5160701 5191479',X'0C08080803080404030808030CEE9300E50D8D013242BE018A755F6BC3');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 13 13 1 1 1 1 1 1','0 0 0 6489337 6489337 6489349 6489349 6489349 6489349 6489349 6489349','0 0 0 29449 33987 481632 6453309 6453378 6453378 6453378 6489349',X'0C08080804080304030808030091B3AB600E9801323F54029F7403EF0C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 630326 618063 10 9 1 1 1 1 1 1','0 7173953 7173953 7787217 7787217 7787219 7787219 7787219 7787219 7787219 7787219','0 1 2 74978 85458 1107555 7744920 7744997 7744997 7744997 7787219',X'0C0809080408030403080804014F459B48960801332ADC01C7A600AA1BA3');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 630326 12263 17 1 1 1 1 1 1 1','0 7173953 7792016 7795570 7795586 7795586 7795586 7795586 7795586 7795586 7795586','0 1 3 78329 89057 1115864 7753287 7753364 7753364 7753364 7795586',X'0C0809010302040404080804070267C1271300E640740133041E00AB540900A3EE16');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','3876548 3718791 3718791 397 397 46 1 1 1 1 1','7804279 7804279 7804279 9084892 9084892 9085088 9085089 9085089 9085089 9085089 9085089','1 2 4 87584 99143 1159195 9040539 9040616 9040616 9040616 9085089',X'0C090808030804040308080301CBAF00E5C288013351810C390F26671E');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','3876548 3718791 3718791 141 141 20 1 1 1 1 1','7804279 7804279 7804279 10382921 10382921 10382951 10382959 10382959 10382959 10382959 10382959','1 2 4 95054 107437 1210217 10336699 10336776 10336776 10336776 10382959',X'0C09080803080304030808030DB5C14114E301332A7E018A751F17C1');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix4','3876548 157757 157736 83 16 1 1 1 1 1 1','7804279 11523070 11523070 11587733 11587800 11587815 11587815 11587815 11587815 11587815 11587815','1 3 5 112412 126326 1332792 11540704 11540781 11540781 11540781 11587815',X'0C090908030204040308080402A9D12328010B92880133517F029E9D008B5B23');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 213279 213279 213279 213279 376 212 101 1 1','0 0 12394 12394 12394 12394 18421 18421 18421 18424 18424','0 0 3 3 3 3 810 1027 1949 18324 18424',X'0C0808030808080308030403018A75018788178574013265FC611E2A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 86515 86515 86515 86515 377 377 377 1 1','0 0 271240 271240 271240 271240 274521 274521 274521 274780 274780','0 0 8 8 8 8 9766 10762 19602 273178 274780',X'0C080803080808030803040401A79C01886F174AEF0132678B00A4AEFF');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 193482 193482 193482 193482 444 444 444 1 1','0 0 542802 542802 542802 542802 575453 575453 575453 575505 575505','0 0 27 27 27 27 24310 25597 43165 571774 575505',X'0C080803080808030803040401C3EB018CCE55312F013305B700AF487C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 126108 126108 126108 126108 200 200 28 1 1','0 0 747801 747801 747801 747801 762121 762121 762293 762320 762320','0 0 33 33 33 33 30770 32410 56629 757315 762320',X'0C080803080808030803040301C7A6018A9D6AB1100131F17D04364A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 149712 149712 149712 149712 216 216 5 1 1','0 0 1107747 1107747 1107747 1107747 1147090 1147090 1147301 1147305 1147305','0 0 98 98 98 98 51603 53785 94043 1139967 1147305',X'0C080803080808030803040302172301B84D2E828501317B95651924');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 87289 87289 87289 87289 27 27 12 1 1','0 0 1257751 1257751 1257751 1257751 1297850 1297850 1297865 1297869 1297869','0 0 100 100 100 100 57625 60123 107069 1289807 1297869',X'0C0808030808080308040403021FFC02554D00E643C7013242692A9BBC');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 192597 192597 192597 192597 291 291 3 1 1','0 0 1464077 1464077 1464077 1464077 1512946 1512946 1513234 1513236 1513236','0 0 134 134 134 134 67476 70262 123260 1502886 1513236',X'0C0808030808080308040404029E6201B94000F8341701330419008B74DA');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 196917 196917 196917 196917 326 326 12 1 1','0 0 1677739 1677739 1677739 1677739 1797333 1797333 1797647 1797658 1797658','0 0 136 136 136 136 76717 80026 143308 1785522 1797658',X'0C0808030808080308040404029E6802B7DC0108ACBA0132DD7B0087795F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 140297 140297 140297 140297 206 188 90 1 1','0 0 1951850 1951850 1951850 1951850 2020506 2020524 2020622 2020711 2020711','0 0 146 146 146 146 85439 89181 160816 2006993 2020711',X'0C0808030808080302040403029E8102171603E800FA82B20132B5AD384ECD');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 132041 132041 132041 132041 173 173 20 1 1','0 0 2415706 2415706 2415706 2415706 2428962 2428962 2429115 2429134 2429134','0 0 163 163 163 163 100984 105182 186071 2412732 2429134',X'0C0808030808080308030403029EB1018BF55020D60131A3D23BB156');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 6830 6830 6830 6830 35 35 35 1 1','0 0 2595444 2595444 2595444 2595444 2595711 2595711 2595711 2595739 2595739','0 0 169 169 169 169 108584 113037 199947 2578183 2595739',X'0C0808030808080308030403029EC001878C17A7520131A43A6E513C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 101615 101615 101615 101615 244 33 33 1 1','0 0 2999185 2999185 2999185 2999185 3019255 3019466 3019466 3019498 3019498','0 0 213 213 213 213 131035 136293 237357 2999333 3019498',X'0C080803080808030203040302D7C001B93E03F041A96D013303017C72B6');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 26914 26914 26914 26914 87 87 73 1 1','0 0 3868553 3868553 3868553 3868553 3893568 3893568 3893582 3893609 3893609','0 0 387 387 387 387 172456 180121 311050 3869040 3893609',X'0C08080308080803080304040498C86B7EF347CC5A0132B678008A4646');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 97492 97492 97492 97492 410 410 44 1 1','0 0 4948831 4948831 4948831 4948831 5009456 5009456 5009822 5009865 5009865','0 0 751 751 751 751 226745 236274 399260 4980988 5009865',X'0C08080308080803080404030E565F03686C00F89CD001332A115479DC');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 1782 1782 1782 1782 52 52 52 1 1','0 0 5190938 5190938 5190938 5190938 5191434 5191434 5191434 5191479 5191479','0 0 800 800 800 800 236362 246237 414618 5161779 5191479',X'0C08080308080803080304040EBD0F0268E064A6DB013242CB00875BAF');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 4645 4645 4645 4645 17 17 17 1 1','0 0 6485214 6485214 6485214 6485214 6489339 6489339 6489339 6489349 6489349','0 0 1396 1396 1396 1396 317293 329836 538486 6453712 6489349',X'0C080804080808040803040300ABD9B000A69D33737CBB01328F6B0F6298');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 290196 290196 290196 290196 138 138 26 1 1','0 0 6734628 6734628 6734628 6734628 6744872 6744872 6744984 6745009 6745009','0 0 1641 1641 1641 1641 338986 352099 569319 6708651 6745009',X'0C080804080808030804040400FF5594018819010B3C670133294300B1674C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 630326 24310 1435 1435 1435 1 1 1 1 1','0 7173953 7763625 7786500 7786500 7786500 7787219 7787219 7787219 7787219 7787219','0 1 3518 4119 4119 4119 726018 753845 1215054 7745002 7787219',X'0C080904010808030204040400FF5594070357AB232800F2FA440133294600A90441');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 114188 114188 114188 114188 463 61 61 1 1','7804279 7804279 7809377 7809377 7809377 7809377 7864755 7865157 7865157 7865217 7865217','1 2 3751 4413 4413 4413 740133 768607 1233927 7822883 7865217',X'0C0908030808080302030403018A750213B2245416DF860131CB3A2879CC');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 86108 86108 86108 86108 605 605 605 1 1','7804279 7804279 8403815 8403815 8403815 8403815 8463845 8463845 8463845 8464449 8464449','1 2 3805 4467 4467 4467 760796 789718 1255047 8421249 8464449',X'0C0908030808080308030403021FFC0DC36E1AD36901328E2F3D9128');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 60490 60490 60490 60490 44 44 44 1 1','7804279 7804279 9062901 9062901 9062901 9062901 9085056 9085056 9085056 9085089 9085089','1 2 3845 4507 4507 4507 778931 808217 1273550 9040805 9085089',X'0C0908030808080308040403029EB101C30B00E889140132697F092505');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 57304 57304 57304 57304 2 2 2 1 1','7804279 7804279 10328144 10328144 10328144 10328144 10382958 10382958 10382958 10382959 10382959','1 2 4106 4768 4768 4768 823966 853934 1319290 10336860 10382959',X'0C09080308080804080404040E565F00CE8C3100E7F68D0133517900B0B4CE');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 174377 174377 174377 174377 81 81 66 1 1','7804279 7804279 11246252 11246252 11246252 11246252 11358749 11358749 11358764 11358829 11358829','1 2 4517 5179 5179 5179 867595 898252 1363807 11311829 11358829',X'0C090804080808030804040300FF55940E584300F2FA44013240670E2E89');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 157757 15066 15066 15066 15066 1 1 1 1 1','7804279 11523070 11657249 11657249 11657249 11657249 11672314 11672314 11672314 11672314 11672314','1 3 5503 6167 6167 6167 1025351 1059076 1524822 11625280 11672314',X'0C090904080808040203040300FF5594025D19032328337763013351F2277A3E');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4748 4629 4629 4629 4629 17 1 1 1','0 0 634880 634880 634880 634880 634880 639175 639191 639191 639191','0 0 779 907 907 907 907 415429 633684 633685 639191',X'0C0808030808080804030303018C4A013157983CE7FE05E54B6BB7FB');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4608 4608 4608 4608 4608 33 1 1 1','0 0 752580 752580 752580 752580 752580 755506 755538 755538 755538','0 0 936 1089 1089 1089 1089 491324 749126 749127 755538',X'0C0808030808080804030303018D4F0131A682512ECF029E6A70A9E9');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4776 4776 4776 4776 4776 27 1 1 1','0 0 762070 762070 762070 762070 762070 763357 763383 763383 763383','0 0 940 1097 1097 1097 1097 495628 756890 756891 763383',X'0C0808030808080804040303018D560132DB8800F3416D029EA654D9AC');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5910 5910 5910 5910 5910 37 2 2 1','0 0 771353 771353 771353 771353 771353 775562 775597 775597 775598','0 0 946 1103 1103 1103 1103 501111 769013 769014 775598',X'0C0808030808080804030303018D610131CADE4C6E2D01D5860141A9');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 1834 1834 1834 1834 1834 6 1 1 1','0 0 1296866 1296866 1296866 1296866 1296866 1297867 1297869 1297869 1297869','0 0 2621 2842 2842 2842 2842 857867 1287063 1287064 1297869',X'0C080803080808080403030301A6E30132419A1E1B7F0567EE2880C0');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5007 3959 3959 3959 3959 25 1 1 1','0 0 2152400 2152400 2152400 2152400 2152400 2155551 2155575 2155575 2155575','0 0 5683 6304 6304 6304 6304 1442790 2140930 2140937 2155575',X'0C080803080808080404030301C3F901317CC701044CC7029E6834F7E2');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4768 4609 4609 4609 4609 26 1 1 1','0 0 2200466 2200466 2200466 2200466 2200466 2204364 2204389 2204389 2204389','0 0 5714 6370 6370 6370 6370 1470393 2189496 2189503 2204389',X'0C080803080808080403030301C4220131586B3EB735018A7567CE9E');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5177 4669 4669 4669 4669 22 1 1 1','0 0 2234078 2234078 2234078 2234078 2234078 2238366 2238387 2238387 2238387','0 0 5743 6422 6422 6422 6422 1490145 2223355 2223362 2238387',X'0C080803080808080403030301C4490131573F4104F802D9CA67FD1E');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 7981 5546 5546 5546 5546 32 1 1 1','0 0 2239923 2239923 2239923 2239923 2239923 2243388 2243419 2243419 2243419','0 0 5746 6428 6428 6428 6428 1492784 2228358 2228365 2243419',X'0C080803080808080404030301C44E0131A4FE00FDCC04029E8175076B');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 351 336 336 336 336 1 1 1 1','0 0 2595725 2595725 2595725 2595725 2595725 2595739 2595739 2595739 2595739','0 0 6747 7717 7717 7717 7717 1732397 2578697 2578708 2595739',X'0C080803080808080404030301CCC901332A7700F17E5D0E5D6F523B01');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 6022 4942 4942 4942 4942 38 1 1 1','0 0 2648510 2648510 2648510 2648510 2648510 2652126 2652163 2652163 2652163','0 0 6934 7959 7959 7959 7959 1770411 2634884 2634898 2652163',X'0C080803080808080404030301CE8C01317DE800FE4E8B029E81458317');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4752 1965 1965 1965 1965 1 1 1 1','0 0 3161780 3161780 3161780 3161780 3161780 3163744 3163744 3163744 3163744','0 0 9707 11219 11219 11219 11219 2143797 3143873 3143896 3163744',X'0C08080308080808040303030213B20130BC9216F939029E815B86EE');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5497 1880 1880 1880 1880 1 1 1 1','0 0 3167643 3167643 3167643 3167643 3167643 3169522 3169522 3169522 3169522','0 0 9709 11226 11226 11226 11226 2148088 3149632 3149655 3169522',X'0C08080308080808040303030213B50130BBC616FC6501C7A62A1BB2');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 2185 2126 2126 2126 2126 4 1 1 1','0 0 3891670 3891670 3891670 3891670 3891670 3893609 3893609 3893609 3893609','0 0 13596 15952 15953 15953 15953 2677069 3869700 3869732 3893609',X'0C080803080808080403030302BD5F01317CC81782F704C9D95EFF0C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5511 5355 5355 5355 5355 21 1 1 1','0 0 3931850 3931850 3931850 3931850 3931850 3936206 3936226 3936226 3936226','0 0 13793 16188 16189 16189 16189 2705655 3912091 3912125 3936226',X'0C080803080808080403030302C14C01317C514010FA01B64235E688');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5468 5115 5115 5115 5115 27 1 1 1','0 0 3939091 3939091 3939091 3939091 3939091 3943255 3943281 3943281 3943281','0 0 13803 16200 16201 16201 16201 2709082 3919099 3919133 3943281',X'0C080803080808080403030302C16401317CC348B67001C3EB6824BB');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5275 4792 4792 4792 4792 31 1 1 1','0 0 4590217 4590217 4590217 4590217 4590217 4591639 4591669 4591669 4591669','0 0 17456 20455 20456 20456 20456 3175906 4564022 4564064 4591669',X'0C0808030808080804040403049EE50132915200FA2F9300EA0DC50554E0');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 339 339 339 339 339 2 1 1 1','0 0 5191258 5191258 5191258 5191258 5191258 5191478 5191479 5191479 5191479','0 0 20754 24230 24231 24231 24231 3601696 5160652 5160701 5191479',X'0C08080308080808040303030CEE930132671A1B8AFF01B6426386D0');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 13 13 13 13 13 1 1 1 1','0 0 6489339 6489339 6489339 6489339 6489339 6489349 6489349 6489349 6489349','0 0 29449 33987 33989 33989 33989 4540005 6453309 6453378 6489349',X'0C08080408080808040303030091B3AB01321B5A4F26F2018A750B6686');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 630326 19 19 18 18 18 1 1 1 1','0 7173953 7787203 7787203 7787203 7787203 7787203 7787219 7787219 7787219 7787219','0 1 73522 83967 91688 91688 91688 5643606 7744920 7744997 7787219',X'0C080904080808080404030300FF69210132DB2900FB0715029EB573EB9F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 3718791 4598 4512 4512 4512 4512 38 1 1 1','7804279 7804279 8237877 8237877 8237877 8237877 8237877 8238986 8239023 8239023 8239023','1 2 76726 87349 95641 95641 95641 5923145 8195880 8195957 8239023',X'0C0908030808080804040404018D3F01332A780111068001FB6F840083BEF9');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 3718791 397 397 397 397 397 2 1 1 1','7804279 7804279 9084892 9084892 9084892 9084892 9084892 9085089 9085089 9085089 9085089','1 2 79826 90851 99143 99143 99143 6505397 9040540 9040617 9085089',X'0C090803080808080403030301CBAF0133028A4E35BE715A2A49098C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 3718791 141 141 141 141 141 2 1 1 1','7804279 7804279 10382921 10382921 10382921 10382921 10382921 10382958 10382959 10382959 10382959','1 2 87296 99145 107437 107437 107437 7432077 10336699 10336776 10382959',X'0C09080308080808040403030DB5C101332BF7010E37310EB97420BFF6');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 157757 83 16 16 16 16 1 1 1 1','7804279 11523070 11587750 11587817 11587817 11587817 11587817 11587832 11587832 11587832 11587832','1 3 104655 118035 126343 126343 126343 8311754 11540721 11540798 11587832',X'0C090903020808080404030402A9D1232801332CC300EB7D35029E83008581B1');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 24157 24157 24157 24157 24157 133 1 1 1','0 0 1236590 1236590 1236590 1236590 1236590 1241150 1241282 1241282 1241282','0 0 3120 3120 3120 3120 4771 741878 1223262 1228239 1241282',X'0C08080308080804040408031A080400FF559401321BC20099C49F3BE84C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 1209 1209 1209 1209 1209 2 1 1 1','0 0 1296873 1296873 1296873 1296873 1296873 1297868 1297869 1297869 1297869','0 0 3203 3203 3203 3203 4902 763298 1279554 1284645 1297869',X'0C08080308080803040308031A215F04C9D901317D1501B0A355A290');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 12129 12129 12129 12129 9261 38 1 1 1','0 0 1790076 1790076 1790076 1790076 1790076 1791737 1791774 1791774 1791774','0 0 4938 4938 4938 4938 7561 1075153 1767990 1775629 1791774',X'0C08080308080803040408031CE87E029E6B01328F6100B473FD5BE552');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 273 273 273 273 273 1 1 1 1','0 0 2595625 2595625 2595625 2595625 2595625 2595739 2595739 2595739 2595739','0 0 7863 7863 7863 7863 12132 1580849 2562484 2575172 2595739',X'0C08080308080803040308032F020502DA0E013241A16B73DE01E021');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 7735 7735 7735 7735 7735 503 1 1 1','0 0 2924165 2924165 2924165 2924165 2924165 2931394 2931896 2931896 2931896','0 0 9123 9123 9123 9123 14045 1794002 2895440 2909856 2931896',X'0C080803080808040404080433776300FF55940133294301C56631008BCB5A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 360 360 360 360 229 1 1 1 1','0 0 3893374 3893374 3893374 3893374 3893505 3893609 3893609 3893609 3893609','0 0 13912 13912 13912 13912 21124 2420346 3846830 3866425 3893609',X'0C08080308080803040308034717710E070B01317F7102C73A396CE1');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 683 683 683 683 671 2 1 1 1','0 0 5191447 5191447 5191447 5191447 5191459 5191479 5191479 5191479 5191479','0 0 20361 20361 20361 20361 30776 3226670 5127525 5158962 5191479',X'0C08080308080803040308037370D10F00290132B59A018F7A694C9B');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 213354 213354 213354 213354 213354 5934 1 1 1','0 0 6102233 6102233 6102233 6102233 6102233 6154276 6155650 6155650 6155650','0 0 26812 26812 26812 26812 39489 3770219 6079715 6119855 6155650',X'0C080804080808040403080300F2FA4400FF55940132DF1A01C0C115D4D4');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 3675 3675 3675 3675 3675 14 1 1 1','0 0 6486701 6486701 6486701 6486701 6486701 6489347 6489349 6489349 6489349','0 0 28380 28380 28380 28380 41383 3868787 6409451 6452691 6489349',X'0C080804080808030403020300F6ABAC6C967D0132B672026C8D03E8155844');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 24063 24063 24063 24063 24063 1799 1 1 1','0 0 7080914 7080914 7080914 7080914 7080914 7103178 7104976 7104976 7104976','0 0 35724 35725 35725 35725 49845 4189282 7019641 7067879 7104976',X'0C0808040808080404040804010B0A5C00FF55940133294301D2C35700A877B5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 20284 20284 20284 20284 20284 1518 1 1 1','0 0 7107240 7107240 7107240 7107240 7107240 7124584 7126101 7126101 7126101','0 0 35764 35765 35765 35765 49886 4191089 7040717 7089004 7126101',X'0C0808040808080404040803010B3C6700FF55940133294501F0A829511573');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 630326 13288 11855 11855 11855 11855 5449 1 1 1','0 7173953 7671119 7671119 7671119 7671119 7671119 7676514 7676526 7676526 7676526','0 1 64320 65543 65543 65543 92453 4431581 7580039 7634401 7676526',X'0C080904080808040403080400F2FA4400FF5594013329430186CB00A866E4');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 630326 61 61 61 61 61 14 1 1 1','0 7173953 7787172 7787172 7787172 7787172 7787172 7787217 7787219 7787219 7787219','0 1 73272 75274 75274 75274 103642 4468650 7689369 7745002 7787219',X'0C0809040808080304030803010ABA910DD2420133068F05DE6223042F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 8657 8657 8657 8657 8657 18 1 1 1','7804279 7804279 8360485 8360485 8360485 8360485 8360485 8360977 8360994 8360994 8360994','1 2 75785 77865 77865 77865 106290 4756698 8258979 8317590 8360994',X'0C09080308080803040408031AD369021FFC0133517F01B017F259F6C3');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 33421 33421 33421 33421 33421 2221 1 1 1','7804279 7804279 8873934 8873934 8873934 8873934 8873934 8874868 8877088 8877088 8877088','1 2 76834 78914 78914 78914 107340 5041847 8770182 8832668 8877088',X'0C090803080808040404020333776300FF5594013351790241FEE4232825FB3D');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 2182 2182 2182 2182 2182 20 1 1 1','7804279 7804279 9083187 9083187 9083187 9083187 9083187 9085087 9085089 9085089 9085089','1 2 77227 79307 79307 79307 107733 5141706 8974619 9040316 9085089',X'0C09080308080803040308043AC92C021FFC0132B668018BAB00964778');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 6008 6008 6008 6008 6008 26 1 1 1','7804279 7804279 9124662 9124662 9124662 9124662 9124662 9128286 9128311 9128311 9128311','1 2 77300 79380 79380 79380 107806 5160088 9016921 9083451 9128311',X'0C09080308080804040408033C1C5C00F024880132DB2100B88E8A420C1B');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 6023 6023 6023 6023 6023 91 1 1 1','7804279 7804279 9393480 9393480 9393480 9393480 9393480 9396519 9396609 9396609 9396609','1 2 77893 79973 79973 79973 108402 5311949 9282988 9351281 9396609',X'0C09080308080803040408044CDD9A7E1C230132DE4200D105C800A087F7');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 79 79 79 79 79 1 1 1 1','7804279 7804279 10382946 10382946 10382946 10382946 10382946 10382959 10382959 10382959 10382959','1 2 80421 82501 82501 82501 110947 5821380 10258569 10336296 10382959',X'0C090804080808030403080300E9A10A0CC3160133505F0D25365733C6');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 8251 8251 8251 8251 8251 37 1 1 1','7804279 7804279 11067468 11067468 11067468 11067468 11067468 11068084 11068120 11068120 11068120','1 2 83449 85529 85529 85529 113989 6177561 10936213 11021086 11068120',X'0C090804080808040404080400FFA4A7008A66AD01332AD10170A8B10084054A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 44772 44772 44772 44772 44772 3018 1 1 1','7804279 7804279 11268036 11268036 11268036 11268036 11268036 11282829 11285846 11285846 11285846','1 2 85052 87132 87132 87132 115597 6281979 11151347 11238812 11285846',X'0C0908040808080404040804010B0A5C00FF5594013351720249087400B0523C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 53775 53775 53775 53775 53775 4069 1 1 1','7804279 7804279 11330929 11330929 11330929 11330929 11330929 11359035 11363103 11363103 11363103','1 2 85255 87335 87335 87335 115800 6292285 11227544 11316069 11363103',X'0C0908040808080404040804010BFA8100FF5594013351280252F8A000B01818');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 39430 39430 39430 39430 39430 3018 1 1 1','7804279 7804279 11458789 11458789 11458789 11458789 11458789 11468188 11471205 11471205 11471205','1 2 86422 88502 88502 88502 116970 6333877 11333316 11424171 11471205',X'0C09080408080804040408040113B99600FF559401335174024530C4008AC82C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 157757 5317 5317 5317 5317 5317 12 1 1 1','7804279 11523070 11652844 11652844 11652844 11652844 11652844 11658149 11658160 11658160 11658160','1 3 97969 100051 100051 100051 128567 6429914 11517744 11611126 11658160',X'0C0909040808080404040804010BFA8100FF559401332B2E01521E0B008447F4');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 24157 29 29 29 29 29 1 1 1','0 0 1236590 1251799 1251799 1251799 1251799 1251799 1251827 1251827 1251827','0 0 3120 62451 63798 63798 63798 63798 1238772 1238782 1251827',X'0C08080303080808080404031A0804029BB30131CD3700FF55942B1368');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 1209 129 129 129 129 129 1 1 1','0 0 1296873 1297744 1297744 1297744 1297744 1297744 1297869 1297869 1297869','0 0 3203 65280 66657 66657 66657 66657 1284635 1284645 1297869',X'0C08080303080808080403041A215F01B0A30131066F04C9D90087162A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 12129 604 604 604 604 604 1 1 1','0 0 1790076 1790076 1790076 1790076 1790076 1790076 1790679 1790679 1790679','0 0 4938 95334 97612 97612 97612 97612 1774566 1774578 1790679',X'0C08080303080808080403031CE87E01870001317C4D0CED622FE2E8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 273 5 5 5 5 5 1 1 1','0 0 2595625 2595738 2595738 2595738 2595738 2595738 2595739 2595739 2595739','0 0 7863 145612 149427 149427 149427 149427 2575145 2575172 2595739',X'0C08080303080808080403042F020502C73A0133049702DA0E00A711F8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 7735 29 29 29 29 29 1 1 1','0 0 2924165 2929754 2929754 2929754 2929754 2929754 2929782 2929782 2929782','0 0 9123 167852 172269 172269 172269 172269 2907715 2907742 2929782',X'0C080803030808080804040333776375928D0133294300FF55945A824F');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 360 6 6 6 6 6 1 1 1','0 0 3893374 3893607 3893607 3893607 3893607 3893607 3893609 3893609 3893609','0 0 13912 240908 247109 247109 247109 247109 3866384 3866425 3893609',X'0C080803030808080804030347177104AF8701317D220E070B687905');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 683 32 32 32 32 32 2 2 1','0 0 5191447 5191465 5191465 5191465 5191465 5191465 5191479 5191479 5191479','0 0 20361 336764 345696 345696 345696 345696 5158907 5158962 5191479',X'0C08080303080808080403037370D101884501328F690F002900A69C');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 213354 113 113 113 113 113 1 1 1','0 0 6102233 6155183 6155183 6155183 6155183 6155183 6155295 6155295 6155295','0 0 26812 421693 433202 433202 433202 433202 6119212 6119281 6155295',X'0C080804030808080804040300F2FA44019B6D0132406700FF5594714AE8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 3675 241 241 241 241 241 1 1 1','0 0 6486701 6489287 6489287 6489287 6489287 6489287 6489349 6489349 6489349','0 0 28380 450494 462953 462953 462953 462953 6452616 6452691 6489349',X'0C080804040808080804030300F6ABAC009F84B60132DBDD6C967D155A2A');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 24063 38 38 38 38 38 1 1 1','0 0 7080914 7102383 7102383 7102383 7102383 7102383 7102420 7102420 7102420','0 0 35724 528136 541855 541858 541858 541858 7065247 7065323 7102420',X'0C0808040408080808040403010B0A5C00CCD3EE0133294500FF559459DDCD');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 20284 38 38 38 38 38 1 1 1','0 0 7107240 7126609 7126609 7126609 7126609 7126609 7126646 7126646 7126646','0 0 35764 531673 545484 545487 545487 545487 7089473 7089549 7126646',X'0C0808040408080808040403010B3C670114CE730133294300FF55942225CC');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 630326 13288 5 1 1 1 1 1 1 1','0 7173953 7671119 7675167 7675171 7675171 7675171 7675171 7675171 7675171 7675171','0 1 64320 967583 993386 999414 999414 999414 7632969 7633046 7675171',X'0C080904030308080804040400F2FA4401D16F0183350132DEFE00FF5594009FA501');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 630326 61 1 1 1 1 1 1 1 1','0 7173953 7787172 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219','0 1 73272 1068631 1096442 1107608 1107608 1107608 7744925 7745002 7787219',X'0C0809040408080808040304010ABA9100AA4C1F013351DB0DD242008BFFEF');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 8657 605 605 605 605 605 1 1 1','7804279 7804279 8360485 8364643 8364643 8364643 8364643 8364643 8365247 8365247 8365247','1 2 75785 1096159 1124446 1135923 1135923 1135923 8321766 8321843 8365247',X'0C09080303080808080403031AD3690DC36E01328E2F021FFC3D9128');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 33421 57 26 26 26 26 1 1 1','7804279 7804279 8873934 8891008 8891039 8891039 8891039 8891039 8891064 8891064 8891064','1 2 76834 1110063 1138607 1150084 1150084 1150084 8846567 8846644 8891064',X'0C09080303020808080404043377630CE166232801332A1800FF559400836DFB');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 2182 94 94 94 94 94 1 1 1','7804279 7804279 9083187 9085006 9085006 9085006 9085006 9085006 9085089 9085089 9085089','1 2 77227 1115805 1144438 1155915 1155915 1155915 9040239 9040316 9085089',X'0C09080303080808080403033AC92C04AF670132B5FC021FFC38DBD0');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 6008 277 277 277 277 277 1 1 1','7804279 7804279 9124662 9124662 9124662 9124662 9124662 9124662 9124938 9124938 9124938','1 2 77300 1116652 1145304 1156781 1156781 1156781 9080000 9080077 9124938',X'0C09080303080808080404033C1C5C01B49901328DDA00F024883D6052');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 6023 50 50 50 50 50 1 1 1','7804279 7804279 9393480 9395815 9395815 9395815 9395815 9395815 9395864 9395864 9395864','1 2 77893 1123924 1152663 1164140 1164140 1164140 9350459 9350536 9395864',X'0C09080303080808080403034CDD9A01C30D013290877E1C2303CC11');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 79 6 6 6 6 6 1 1 1','7804279 7804279 10382946 10382956 10382956 10382956 10382956 10382956 10382959 10382959 10382959','1 2 80421 1154920 1184197 1195674 1195674 1195674 10336219 10336296 10382959',X'0C090804030808080804030400E9A10A02A47201332C6C0CC31600ABCD60');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 8251 280 280 280 280 280 1 1 1','7804279 7804279 11067468 11072690 11072690 11072690 11072690 11072690 11072969 11072969 11072969','1 2 83449 1186373 1216159 1227636 1227636 1227636 11025858 11025935 11072969',X'0C090804040808080804040300FFA4A70089DBDD0132B5FF008A66AD6AE2B8');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 44772 58 58 58 58 58 1 1 1','7804279 7804279 11268036 11269261 11269261 11269261 11269261 11269261 11269318 11269318 11269318','1 2 85052 1199706 1229712 1241189 1241189 1241189 11222207 11222284 11269318',X'0C0908040308080808040404010B0A5C018ACD0133294300FF559400B0E291');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 53775 37 19 19 19 19 1 1 1','7804279 7804279 11330929 11355027 11355045 11355045 11355045 11355045 11355063 11355063 11355063','1 2 85255 1206165 1236304 1247781 1247781 1247781 11307952 11308029 11355063',X'0C0908040302080808040403010BFA81026C24232801332B2E00FF55941F8BB5');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 39430 39 39 39 39 39 1 1 1','7804279 7804279 11458789 11476757 11476757 11476757 11476757 11476757 11476795 11476795 11476795','1 2 86422 1219089 1249476 1260953 1260953 1260953 11429684 11429761 11476795',X'0C09080403080808080404030113B99602F6AF01332B2E00FF55941F8A54');
+ INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 157757 5317 1 1 1 1 1 1 1 1','7804279 11523070 11652844 11658160 11658160 11658160 11658160 11658160 11658160 11658160 11658160','1 3 97969 1358780 1391643 1403122 1403122 1403122 11611049 11611126 11658160',X'0C0909040402080808040403010BFA8102594CCB2328013351E800FF55945B0F5D');
+ ANALYZE sqlite_master;
+} {}
+
+# Ensure that the query planner implements the GROUP BY using a separate sort
+#
+do_execsql_test whereJ-1.4 {
+ EXPLAIN QUERY PLAN
+ SELECT aid, sid, MAX(edate) edate
+ FROM tx1
+ WHERE cid = 115790
+ AND sid = 9100
+ AND edate <= 20140430 AND edate >= 20120429
+ GROUP BY aid;
+} {/B-TREE/}
+
+############################################################################
+# Ensure that the sorting cost does not swamp the loop costs and cause
+# distinctions between individual loop costs to get lost, and hence for
+# sub-optimal loops to be chosen.
+#
+do_execsql_test whereJ-2.1 {
+ CREATE TABLE tab(
+ id INTEGER PRIMARY KEY,
+ minChild INTEGER REFERENCES t1,
+ maxChild INTEGER REFERENCES t1,
+ x INTEGER
+ );
+ EXPLAIN QUERY PLAN
+ SELECT t4.x
+ FROM tab AS t0, tab AS t1, tab AS t2, tab AS t3, tab AS t4
+ WHERE t0.id=0
+ AND t1.id BETWEEN t0.minChild AND t0.maxChild
+ AND t2.id BETWEEN t1.minChild AND t1.maxChild
+ AND t3.id BETWEEN t2.minChild AND t2.maxChild
+ AND t4.id BETWEEN t3.minChild AND t3.maxChild
+ ORDER BY t4.x;
+} {~/SCAN/}
+do_execsql_test whereJ-2.2 {
+ EXPLAIN QUERY PLAN
+ SELECT t4.x
+ FROM tab AS t0a, tab AS t0b,
+ tab AS t1a, tab AS t1b,
+ tab AS t2a, tab AS t2b,
+ tab AS t3a, tab AS t3b,
+ tab AS t4
+ WHERE 1
+ AND t0a.id=1
+ AND t1a.id BETWEEN t0a.minChild AND t0a.maxChild
+ AND t2a.id BETWEEN t1a.minChild AND t1a.maxChild
+ AND t3a.id BETWEEN t2a.minChild AND t2a.maxChild
+ AND t0b.id=2
+ AND t1b.id BETWEEN t0b.minChild AND t0b.maxChild
+ AND t2b.id BETWEEN t1b.minChild AND t1b.maxChild
+ AND t3b.id BETWEEN t2b.minChild AND t2b.maxChild
+ AND t4.id BETWEEN t3a.minChild AND t3b.maxChild
+ ORDER BY t4.x;
+} {~/SCAN/}
+
+############################################################################
+
+# Create and populate table.
+do_execsql_test 3.1 { CREATE TABLE t1(a, b, c) }
+for {set i 0} {$i < 32} {incr i 2} {
+ for {set x 0} {$x < 100} {incr x} {
+ execsql { INSERT INTO t1 VALUES($i, $x, $c) }
+ incr c
+ }
+ execsql { INSERT INTO t1 VALUES($i+1, 5, $c) }
+ incr c
+}
+
+do_execsql_test 3.2 {
+ SELECT a, count(*) FROM t1 GROUP BY a HAVING a < 8;
+} {
+ 0 100 1 1 2 100 3 1 4 100 5 1 6 100 7 1
+}
+
+do_execsql_test 3.3 {
+ CREATE INDEX idx_ab ON t1(a, b);
+ CREATE INDEX idx_c ON t1(c);
+ ANALYZE;
+} {}
+
+# This one should use index "idx_c".
+do_eqp_test 3.4 {
+ SELECT * FROM t1 WHERE
+ a = 4 AND b BETWEEN 20 AND 80 -- Matches 80 rows
+ AND
+ c BETWEEN 150 AND 160 -- Matches 10 rows
+} {SEARCH t1 USING INDEX idx_c (c>? AND c<?)}
+
+# This one should use index "idx_ab".
+do_eqp_test 3.5 {
+ SELECT * FROM t1 WHERE
+ a = 5 AND b BETWEEN 20 AND 80 -- Matches 1 row
+ AND
+ c BETWEEN 150 AND 160 -- Matches 10 rows
+} {SEARCH t1 USING INDEX idx_ab (a=? AND b>? AND b<?)}
+
+###########################################################################################
+
+# Reset the database and setup for a test case derived from actual SQLite users
+#
+db close
+sqlite3 db test.db
+do_execsql_test 4.1 {
+ CREATE TABLE le(
+ le_id largeint,
+ xid char(31),
+ type smallint,
+ name char(255) DEFAULT '',
+ mtime largeint DEFAULT 0,
+ muuid int DEFAULT 0
+ );
+ CREATE TABLE cx(
+ cx_id largeint,
+ code char(31),
+ type smallint,
+ name char(31),
+ description varchar,
+ role smallint,
+ mtime largeint DEFAULT 0,
+ muuid int DEFAULT 0,
+ le_id largeint DEFAULT 0,
+ imco smallint DEFAULT 0
+ );
+ CREATE TABLE px(
+ px_id largeint,
+ cx_id largeint,
+ px_tid largeint,
+ name char(31),
+ description varchar DEFAULT '',
+ ia smallint,
+ sl smallint,
+ le_id largeint DEFAULT 0,
+ mtime largeint DEFAULT 0,
+ muuid int DEFAULT 0
+ );
+ CREATE INDEX le_id on le (le_id);
+ CREATE INDEX c_id on cx (cx_id);
+ CREATE INDEX c_leid on cx (le_id);
+ CREATE INDEX p_id on px (px_id);
+ CREATE INDEX p_cid0 on px (cx_id);
+ CREATE INDEX p_pt on px (px_tid);
+ CREATE INDEX p_leid on px (le_id);
+} {}
+do_execsql_test 4.2 {
+ ANALYZE sqlite_master;
+ INSERT INTO sqlite_stat1 VALUES('le','le_id','1979 1');
+ INSERT INTO sqlite_stat1 VALUES('cx','c_leid','852 171');
+ INSERT INTO sqlite_stat1 VALUES('cx','c_id','852 1');
+ INSERT INTO sqlite_stat1 VALUES('px','p_leid','114443 63');
+ INSERT INTO sqlite_stat1 VALUES('px','p_pt','114443 22889');
+ INSERT INTO sqlite_stat1 VALUES('px','p_cid0','114443 181');
+ INSERT INTO sqlite_stat1 VALUES('px','p_id','114443 1');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','162 162','162 162',X'030202013903fb');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','208 208','208 208',X'0302020253012d');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','219 219','219 219',X'030202025e0131');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','248 248','248 248',X'030202027b014e');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','265 265','265 265',X'030202028c015f');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','358 358','358 358',X'03020202e901bc');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','439 439','439 439',X'030202033a020d');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','657 657','657 657',X'030202041402b4');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','659 659','659 659',X'030202041602b6');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','681 681','681 681',X'030202042c02cc');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','831 831','831 831',X'03020204c20482');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','852 852','852 852',X'03020204d70497');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','870 870','870 870',X'03020204e904a9');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','879 879','879 879',X'03020204f204b2');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1099 1099','1099 1099',X'03020205ce058e');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1273 1273','1273 1273',X'030202067c05a9');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1319 1319','1319 1319',X'03020206e30730');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1330 1330','1330 1330',X'0302020700035b');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1539 1539','1539 1539',X'03020207d105d8');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1603 1603','1603 1603',X'03020208390780');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1759 1759','1759 1759',X'030202092f0618');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1843 1843','1843 1843',X'03020209880650');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1915 1915','1915 1915',X'03020209d0068b');
+ INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1927 1927','1927 1927',X'03020209dc0697');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 94','0 94',X'0308015f');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 189','0 189',X'03080200be');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 284','0 284',X'0308020120');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 379','0 379',X'030802017f');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 474','0 474',X'03080201de');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 569','0 569',X'030802023d');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 664','0 664',X'030802029f');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 759','0 759',X'03080202fe');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','3 1','846 847','1 847',X'0301024500e6');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','1 1','849 849','2 849',X'03010246027e');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','1 1','850 850','3 850',X'0301024700c9');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_leid','1 1','851 851','4 851',X'03010248027f');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','94 94','94 94',X'03020200b801a8');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','113 113','113 113',X'03020200d101ad');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','171 171','171 171',X'030201011d2a');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','177 177','177 177',X'030202012600f2');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','189 189','189 189',X'030202013501c8');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','206 206','206 206',X'030201014f2d');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','231 231','231 231',X'030202016d00fc');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','284 284','284 284',X'03020201b702d0');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','291 291','291 291',X'03020101c042');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','311 311','311 311',X'03020201d801e7');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','339 339','339 339',X'03020101f74b');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','347 347','347 347',X'03020202030118');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','379 379','379 379',X'030202022f01fa');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','393 393','393 393',X'030201023f55');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','407 407','407 407',X'03020202500201');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','413 413','413 413',X'03020102565a');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','468 468','468 468',X'030201029468');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','474 474','474 474',X'030202029a0211');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','517 517','517 517',X'03020102cc76');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','548 548','548 548',X'03020202f00223');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','569 569','569 569',X'03020203090087');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','664 664','664 664',X'03020203740163');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','759 759','759 759',X'03020203e800b3');
+ INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','803 803','803 803',X'030202041b026f');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 12715','0 12715',X'030802345b');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 25431','0 25431',X'0308026718');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 38147','0 38147',X'030803009a5c');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 50863','0 50863',X'03080300cdbe');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 63579','0 63579',X'0308030100e8');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 76295','0 76295',X'03080301351d');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 89011','0 89011',X'03080301674c');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 101727','0 101727',X'030803019b99');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','28 1','110824 110843','16 110843',X'0301037a0107f1');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','53 1','110873 110875','25 110875',X'0302020095275a');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','32 1','110927 110936','27 110936',X'030203009b009b4a');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','51 1','110980 111017','30 111017',X'03020300a4016c00');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','67 1','111047 111059','38 111059',X'03020200af2611');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','60 1','111136 111156','43 111156',X'03020300bc009aeb');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','42 1','111222 111239','59 111239',X'03020300d200b17b');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','36 1','111264 111266','60 111266',X'03020200d426d6');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','27 1','111733 111757','159 111757',X'030203014e017e1b');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','36 1','111760 111773','160 111773',X'030203014f00a2b9');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','29 1','111822 111833','167 111833',X'0302030176009c22');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','75 1','113031 113095','1190 113095',X'030203068501912c');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','132 1','113230 113263','1252 113263',X'0302030711009ee6');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','110 1','113851 113918','1572 113918',X'03020308e9011ca2');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','78 1','114212 114217','1791 114217',X'03020209e13b24');
+ INSERT INTO sqlite_stat4 VALUES('px','p_leid','112 1','114303 114351','1799 114351',X'03020309ea0128f2');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 12715','0 12715',X'030802477e');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 25431','0 25431',X'0308027c20');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 38147','0 38147',X'03080300c211');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 50863','0 50863',X'03080300fbe5');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 63579','0 63579',X'0308030140ff');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 76295','0 76295',X'03080301792d');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 89011','0 89011',X'03080301bb68');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','24217 1','89824 101727','1 101727',X'03090300da12');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','154 1','114041 114154','2 114154',X'0301030200e5e9');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','198 1','114195 114351','3 114351',X'03010303015cb1');
+ INSERT INTO sqlite_stat4 VALUES('px','p_pt','50 1','114393 114441','4 114441',X'0301030401b2ef');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','3867 1','3 3736','2 3736',X'03010337015c6a');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','4194 1','4177 8209','5 8209',X'0301033b015075');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','4335 1','8371 11129','6 11129',X'0301033d0156fc');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1740 1','12706 12715','7 12715',X'0301023e34b9');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1680 1','14446 15487','8 15487',X'0301033f011694');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','7163 1','20116 25431','32 25431',X'03020300a400ed26');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1525 1','29100 29302','42 29302',X'03020200bb00d1');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','3703 1','30655 33323','45 33323',X'03020300be013fa5');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2612 1','37767 38147','61 38147',X'03020200e32828');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1882 1','40545 41584','63 41584',X'03020300ea01a35a');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','6984 1','44110 50863','73 50863',X'0302030102017467');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1728 1','51230 51680','75 51680',X'030203010400b3e0');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2805 1','55491 57936','95 57936',X'030203014101a004');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2837 1','58934 59506','103 59506',X'030203015900a283');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','94 1','63492 63579','137 63579',X'0302030191016319');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','3573 1','63591 64497','140 64497',X'030203019c00822e');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','5037 1','70917 73033','160 73033',X'03020301c70091d9');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1940 1','75954 76295','161 76295',X'03020201c817f1');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1927 1','83926 84371','209 84371',X'03020202114295');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1522 1','86601 88117','213 88117',X'030203021b01b7b5');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','210 1','88906 89011','226 89011',X'030203022800dbbb');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','6165 1','92125 98066','258 98066',X'030203024d0189ac');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2900 1','100721 101727','293 101727',X'030203027500cf39');
+ INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1501 1','110012 110154','503 110154',X'0302020380493a');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','11129 11129','11129 11129',X'03030300d84e014d51');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','12715 12715','12715 12715',X'03030200de816f51');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','13030 13030','13030 13030',X'03030200e05b6fc4');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','25431 25431','25431 25431',X'0303030123df00efb0');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','29302 29302','29302 29302',X'030302013a2812c7');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','35463 35463','35463 35463',X'03030301666e00f866');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','38147 38147','38147 38147',X'030302017a391b74');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','38525 38525','38525 38525',X'030303017c6e00fb58');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','50863 50863','50863 50863',X'03030201b68724dd');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','58461 58461','58461 58461',X'03030201d95b2e1e');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','59506 59506','59506 59506',X'03030301dd7000a0fb');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','63468 63468','63468 63468',X'03030301ecea011405');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','63579 63579','63579 63579',X'03030201ed5932d5');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','64497 64497','64497 64497',X'03030301f0ef00a680');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','73033 73033','73033 73033',X'0303030225b90190e5');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','75650 75650','75650 75650',X'030303023a19019362');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','76295 76295','76295 76295',X'030303023e9801940c');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','79152 79152','79152 79152',X'030303024be50196b9');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','83249 83249','83249 83249',X'0303030261750123b1');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','89011 89011','89011 89011',X'030303027b3900c3af');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','98066 98066','98066 98066',X'03030302a76500ce54');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','101590 101590','101590 101590',X'03030302b63d00d3b5');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','101727 101727','101727 101727',X'03030202b6f24e9b');
+ INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','107960 107960','107960 107960',X'03030302d8ce0136ad');
+ ANALYZE sqlite_master;
+} {}
+
+# The following query should do a full table scan of cx in the outer loop.
+# It is not correct to search table px using indx p_pt in the outer loop
+# with cx in the middle loop. Test case from Bloomberg on 2014-09-05.
+#
+do_execsql_test 4.2 {
+ EXPLAIN QUERY PLAN
+ SELECT
+ px.name,
+ px.description
+ FROM
+ le,
+ cx,
+ px
+ WHERE
+ cx.code = '2990'
+ AND cx.type=2
+ AND px.cx_id = cx.cx_id
+ AND px.px_tid = 0
+ AND px.le_id = le.le_id;
+} {/.*SCAN cx.*SEARCH px.*SEARCH le.*/}
+
+
+# The following test is derived from a performance problem reported from
+# the field. Notice the multiple indexes with the same initial tables,
+# and the unusual WHERE clause terms.
+#
+do_test 5.1 {
+ set res [db eval {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b,c,d,e,f,g,h);
+ CREATE INDEX t1abc ON t1(a,b,c);
+ CREATE INDEX t1abe ON t1(a,b,e);
+ CREATE INDEX t1abf ON t1(a,b,f);
+ ANALYZE;
+ DROP TABLE IF EXISTS sqlite_stat4;
+ DROP TABLE IF EXISTS sqlite_stat3;
+ DELETE FROM sqlite_stat1;
+ INSERT INTO sqlite_stat1(tbl,idx,stat)
+ VALUES('t1','t1abc','2000000 8000 1600 800'),
+ ('t1','t1abe','2000000 8000 1600 150'),
+ ('t1','t1abf','2000000 8000 1600 150');
+ ANALYZE sqlite_master;
+
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t1
+ WHERE (a=1 OR a=2)
+ AND (b=3 OR b=4)
+ AND (d>=5 AND d<=5)
+ AND ((e>=7 AND e<=7) OR (f>=8 AND f<=8))
+ AND g>0;
+ }]
+} {~/ANY/}
+do_test 5.2 {set res} {/USING INDEX t1abe/}
+do_test 5.3 {set res} {/USING INDEX t1abf/}
+
+
+
+finish_test
diff --git a/test/whereK.test b/test/whereK.test
new file mode 100644
index 0000000..060d470
--- /dev/null
+++ b/test/whereK.test
@@ -0,0 +1,72 @@
+# 2015-03-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 OR expressions where terms can be
+# factored from either side of the OR and combined into a single new
+# AND term that is beneficial to the search. Examples:
+#
+# (x>A OR x=A) --> ... AND (x>=A)
+# (x>A OR (x=A AND y>=B) --> ... AND (x>=A)
+#
+
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix whereK
+
+do_execsql_test 1.1 {
+ CREATE TABLE t1(a,b,c);
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<99)
+ INSERT INTO t1(a,b,c) SELECT x, x/10, x%10 FROM c;
+ CREATE INDEX t1bc ON t1(b,c);
+ SELECT a FROM t1 WHERE b>9 OR b=9 ORDER BY +a;
+} {90 91 92 93 94 95 96 97 98 99}
+do_execsql_test 1.1eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE b>9 OR b=9 ORDER BY +a;
+} {/SEARCH t1 USING INDEX t1bc/}
+
+do_execsql_test 1.2 {
+ SELECT a FROM t1 WHERE b>8 OR (b=8 AND c>7) ORDER BY +a;
+} {88 89 90 91 92 93 94 95 96 97 98 99}
+do_execsql_test 1.2eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE b>8 OR (b=8 AND c>7) ORDER BY +a;
+} {/SEARCH t1 USING INDEX t1bc/}
+
+do_execsql_test 1.3 {
+ SELECT a FROM t1 WHERE (b=8 AND c>7) OR b>8 ORDER BY +a;
+} {88 89 90 91 92 93 94 95 96 97 98 99}
+do_execsql_test 1.3eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE (b=8 AND c>7) OR b>8 ORDER BY +a;
+} {/SEARCH t1 USING INDEX t1bc/}
+
+do_execsql_test 1.4 {
+ SELECT a FROM t1 WHERE (b=8 AND c>7) OR 8<b ORDER BY +a;
+} {88 89 90 91 92 93 94 95 96 97 98 99}
+do_execsql_test 1.4eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE (b=8 AND c>7) OR 8<b ORDER BY +a;
+} {/SEARCH t1 USING INDEX t1bc/}
+
+do_execsql_test 1.5 {
+ SELECT a FROM t1 WHERE (b=8 AND c>7) OR (b>8 AND c NOT IN (4,5,6))
+ ORDER BY +a;
+} {88 89 90 91 92 93 97 98 99}
+do_execsql_test 1.5eqp {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE (b=8 AND c>7) OR (b>8 AND c NOT IN (4,5,6))
+ ORDER BY +a;
+} {/SEARCH t1 USING INDEX t1bc/}
+
+finish_test
diff --git a/test/whereL.test b/test/whereL.test
new file mode 100644
index 0000000..b6f86fc
--- /dev/null
+++ b/test/whereL.test
@@ -0,0 +1,193 @@
+# 2018-07-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 WHERE-clause constant propagation
+# optimization.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix whereL
+
+do_execsql_test 100 {
+ CREATE TABLE t1(a INT PRIMARY KEY, b, c, d, e);
+ CREATE TABLE t2(a INT PRIMARY KEY, f, g, h, i);
+ CREATE TABLE t3(a INT PRIMARY KEY, j, k, l, m);
+ CREATE VIEW v4 AS SELECT * FROM t2 UNION ALL SELECT * FROM t3;
+}
+do_eqp_test 110 {
+ SELECT * FROM t1, v4 WHERE t1.a=?1 AND v4.a=t1.a;
+} {
+ QUERY PLAN
+ `--COMPOUND QUERY
+ |--LEFT-MOST SUBQUERY
+ | |--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (a=?)
+ | `--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?)
+ `--UNION ALL
+ |--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (a=?)
+ `--SEARCH t3 USING INDEX sqlite_autoindex_t3_1 (a=?)
+}
+
+# The scan of the t1 table goes first since that enables the ORDER BY
+# sort to be omitted. This would not be possible without constant
+# propagation because without it the t1 table would depend on t3.
+#
+do_eqp_test 120 {
+ SELECT * FROM t1, t2, t3
+ WHERE t1.a=t2.a AND t2.a=t3.j AND t3.j=5
+ ORDER BY t1.a;
+} {
+ QUERY PLAN
+ |--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (a=?)
+ |--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?)
+ `--SCAN t3
+}
+
+# Constant propagation in the face of collating sequences:
+#
+do_execsql_test 200 {
+ CREATE TABLE c3(x COLLATE binary, y COLLATE nocase, z COLLATE binary);
+ CREATE INDEX c3x ON c3(x);
+ INSERT INTO c3 VALUES('ABC', 'ABC', 'abc');
+ SELECT * FROM c3 WHERE x=y AND y=z AND z='abc';
+} {ABC ABC abc}
+
+# If the constants are blindly propagated, as shown in the following
+# query, the wrong answer results:
+#
+do_execsql_test 201 {
+ SELECT * FROM c3 WHERE x='abc' AND y='abc' AND z='abc';
+} {}
+
+# Constant propagation caused an incorrect answer in the following
+# query. (Reported by Bentley system on 2018-08-09.)
+#
+do_execsql_test 300 {
+ CREATE TABLE A(id INTEGER PRIMARY KEY, label TEXT);
+ CREATE TABLE B(id INTEGER PRIMARY KEY, label TEXT, Aid INTEGER);
+ CREATE TABLE C(
+ id INTEGER PRIMARY KEY,
+ xx INTEGER NOT NULL,
+ yy INTEGER,
+ zz INTEGER
+ );
+ CREATE UNIQUE INDEX x2 ON C(yy);
+ CREATE UNIQUE INDEX x4 ON C(yy, zz);
+ INSERT INTO A(id) VALUES(1);
+ INSERT INTO B(id) VALUES(2);
+ INSERT INTO C(id,xx,yy,zz) VALUES(99,50,1,2);
+ SELECT 1
+ FROM A,
+ (SELECT id,xx,yy,zz FROM C) subq,
+ B
+ WHERE A.id='1'
+ AND A.id=subq.yy
+ AND B.id=subq.zz;
+} {1}
+do_execsql_test 301 {
+ SELECT 1
+ FROM A,
+ (SELECT id,xx,yy,zz FROM C) subq,
+ B
+ WHERE A.id=1
+ AND A.id=subq.yy
+ AND B.id=subq.zz;
+} {1}
+do_execsql_test 302 {
+ SELECT 1
+ FROM A,
+ (SELECT id,yy,zz FROM C) subq,
+ B
+ WHERE A.id='1'
+ AND A.id=subq.yy
+ AND B.id=subq.zz;
+} {1}
+
+# 2018-10-25: Ticket [cf5ed20f]
+# Incorrect join result with duplicate WHERE clause constraint.
+#
+do_execsql_test 400 {
+ CREATE TABLE x(a, b, c);
+ CREATE TABLE y(a, b);
+ INSERT INTO x VALUES (1, 0, 1);
+ INSERT INTO y VALUES (1, 2);
+ SELECT x.a FROM x JOIN y ON x.c = y.a WHERE x.b = 1 AND x.b = 1;
+} {}
+
+# 2020-01-07: ticket 82ac75ba0093e5dc
+# Incorrect join result due to mishandling of affinity in constant
+# propagation.
+#
+reset_db
+do_execsql_test 500 {
+ PRAGMA automatic_index=OFF;
+ CREATE TABLE t0(c0);
+ INSERT INTO t0 VALUES('0');
+ CREATE VIEW v0(c0) AS SELECT CAST(0 AS INT) FROM t0;
+ SELECT 200, * FROM t0, v0 WHERE 0 = t0.c0 AND t0.c0 = v0.c0;
+} {}
+do_execsql_test 510 {
+ SELECT 200, * FROM t0, v0 WHERE t0.c0 = 0 AND t0.c0 = v0.c0;
+} {}
+do_execsql_test 520 {
+ SELECT 200, * FROM t0, v0 WHERE 0 = t0.c0 AND v0.c0 = t0.c0;
+} {}
+do_execsql_test 530 {
+ SELECT 200, * FROM t0, v0 WHERE t0.c0 = 0 AND v0.c0 = t0.c0;
+} {}
+
+# 2020-02-13: ticket 1dcb4d44964846ad
+# A problem introduced while making optimizations on the fixes above.
+#
+reset_db
+do_execsql_test 600 {
+ CREATE TABLE t1(x TEXT);
+ CREATE TABLE t2(y TEXT);
+ INSERT INTO t1 VALUES('good'),('bad');
+ INSERT INTO t2 VALUES('good'),('bad');
+ SELECT * FROM t1 JOIN t2 ON x=y
+ WHERE x='good' AND y='good';
+} {good good}
+
+# 2020-04-24: Another test case for the previous (1dcb4d44964846ad)
+# ticket. The test case comes from
+# https://stackoverflow.com/questions/61399253/sqlite3-different-result-in-console-compared-to-python-script/
+# Output verified against postgresql.
+#
+do_execsql_test 610 {
+ CREATE TABLE tableA(
+ ID int,
+ RunYearMonth int
+ );
+ INSERT INTO tableA VALUES(1,202003),(2,202003),(3,202003),(4,202004),
+ (5,202004),(6,202004),(7,202004),(8,202004);
+ CREATE TABLE tableB (
+ ID int,
+ RunYearMonth int
+ );
+ INSERT INTO tableB VALUES(1,202004),(2,202004),(3,202004),(4,202004),
+ (5,202004);
+ SELECT *
+ FROM (
+ SELECT *
+ FROM tableA
+ WHERE RunYearMonth = 202004
+ ) AS A
+ INNER JOIN (
+ SELECT *
+ FROM tableB
+ WHERE RunYearMonth = 202004
+ ) AS B
+ ON A.ID = B.ID
+ AND A.RunYearMonth = B.RunYearMonth;
+} {4 202004 4 202004 5 202004 5 202004}
+
+
+finish_test
diff --git a/test/whereM.test b/test/whereM.test
new file mode 100644
index 0000000..8343689
--- /dev/null
+++ b/test/whereM.test
@@ -0,0 +1,112 @@
+# 2021 May 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.
+#
+#***********************************************************************
+# Tests focused on the "constant propagation" that occurs within the
+# WHERE clause of a SELECT statemente.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix whereM
+
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b INTEGER, c TEXT, d REAL, e BLOB);
+ INSERT INTO t1 VALUES(10.0, 10.0, 10.0, 10.0, 10.0);
+ SELECT * FROM t1;
+} {
+ 10.0 10 10.0 10.0 10.0
+}
+
+do_execsql_test 1.1.1 {
+ SELECT a=10, a = '10.0', a LIKE '10.0' FROM t1;
+} {1 0 1}
+do_execsql_test 1.1.2 {
+ SELECT count(*) FROM t1 WHERE a=10 AND a = '10.0'
+} {0}
+do_execsql_test 1.1.3 {
+ SELECT count(*) FROM t1 WHERE a=10 AND a LIKE '10.0'
+} {1}
+do_execsql_test 1.1.4 {
+ SELECT count(*) FROM t1 WHERE a='10.0' AND a LIKE '10.0'
+} {0}
+
+do_execsql_test 1.2.1 {
+ SELECT b=10, b = '10.0', b LIKE '10.0', b LIKE '10' FROM t1;
+} {1 1 0 1}
+do_execsql_test 1.2.2 {
+ SELECT count(*) FROM t1 WHERE b=10 AND b = '10.0'
+} {1}
+do_execsql_test 1.2.3 {
+ SELECT count(*) FROM t1 WHERE b=10 AND b LIKE '10.0'
+} {0}
+do_execsql_test 1.2.4 {
+ SELECT count(*) FROM t1 WHERE b='10.0' AND b LIKE '10.0'
+} {0}
+do_execsql_test 1.2.3 {
+ SELECT count(*) FROM t1 WHERE b=10 AND b LIKE '10'
+} {1}
+do_execsql_test 1.2.4 {
+ SELECT count(*) FROM t1 WHERE b='10.0' AND b LIKE '10'
+} {1}
+
+do_execsql_test 1.3.1 {
+ SELECT c=10, c = 10.0, c = '10.0', c LIKE '10.0' FROM t1;
+} {0 1 1 1}
+do_execsql_test 1.3.2 {
+ SELECT count(*) FROM t1 WHERE c=10 AND c = '10.0'
+} {0}
+do_execsql_test 1.3.3 {
+ SELECT count(*) FROM t1 WHERE c=10 AND c LIKE '10.0'
+} {0}
+do_execsql_test 1.3.4 {
+ SELECT count(*) FROM t1 WHERE c='10.0' AND c LIKE '10.0'
+} {1}
+do_execsql_test 1.3.5 {
+ SELECT count(*) FROM t1 WHERE c=10.0 AND c = '10.0'
+} {1}
+do_execsql_test 1.3.6 {
+ SELECT count(*) FROM t1 WHERE c=10.0 AND c LIKE '10.0'
+} {1}
+
+do_execsql_test 1.4.1 {
+ SELECT d=10, d = 10.0, d = '10.0', d LIKE '10.0', d LIKE '10' FROM t1;
+} {1 1 1 1 0}
+do_execsql_test 1.4.2 {
+ SELECT count(*) FROM t1 WHERE d=10 AND d = '10.0'
+} {1}
+do_execsql_test 1.4.3 {
+ SELECT count(*) FROM t1 WHERE d=10 AND d LIKE '10.0'
+} {1}
+do_execsql_test 1.4.4 {
+ SELECT count(*) FROM t1 WHERE d='10.0' AND d LIKE '10.0'
+} {1}
+do_execsql_test 1.4.5 {
+ SELECT count(*) FROM t1 WHERE d='10' AND d LIKE '10.0'
+} {1}
+
+do_execsql_test 1.5.1 {
+ SELECT e=10, e = '10.0', e LIKE '10.0', e LIKE '10' FROM t1;
+} {1 0 1 0}
+do_execsql_test 1.5.2 {
+ SELECT count(*) FROM t1 WHERE e=10 AND e = '10.0'
+} {0}
+do_execsql_test 1.5.3 {
+ SELECT count(*) FROM t1 WHERE e=10 AND e LIKE '10.0'
+} {1}
+do_execsql_test 1.5.4 {
+ SELECT count(*) FROM t1 WHERE e='10.0' AND e LIKE '10.0'
+} {0}
+do_execsql_test 1.5.5 {
+ SELECT count(*) FROM t1 WHERE e=10.0 AND e LIKE '10.0'
+} {1}
+
+finish_test
diff --git a/test/wherefault.test b/test/wherefault.test
new file mode 100644
index 0000000..7f07ad5
--- /dev/null
+++ b/test/wherefault.test
@@ -0,0 +1,83 @@
+# 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 on handling OOM
+# errors within the code that optimizes WHERE clauses that feature the
+# OR operator.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+source $testdir/malloc_common.tcl
+
+set testprefix wherefault
+
+do_malloc_test 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 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;
+}
+
+reset_db
+do_execsql_test 3.0 {
+ PRAGMA writable_schema = 1;
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(
+ a INT AS (c*11),
+ b TEXT AS (substr(d,1,3)) STORED,
+ c INTEGEB PRIMARI KEY, d TEXT
+ );
+ CREATE INDEX t1a ON t1(a);
+ COMMIT;
+}
+faultsim_save_and_close
+
+do_faultsim_test 3.1 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT * FROM (SELECT a FROM t1 NATURAL JOIN t1 WHERE a IN (SELECT b FROM t1 ORDER BY b)) WHERE (SELECT a FROM t1 NATURAL JOIN (SELECT * FROM (SELECT a FROM t1 NATURAL JOIN t1 WHERE a IN (SELECT CASE b WHEN 82 THEN 207 WHEN 869 THEN 406 WHEN 85 THEN 83 WHEN 705 THEN 698 ELSE 1992229051 END%5 FROM t1 ORDER BY b)) WHERE (SELECT a FROM t1 NATURAL JOIN (SELECT b FROM t1 ORDER BY b) WHERE a IN (SELECT b FROM t1 ORDER BY b))) WHERE a );
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/wherelfault.test b/test/wherelfault.test
new file mode 100644
index 0000000..cfb8c1c
--- /dev/null
+++ b/test/wherelfault.test
@@ -0,0 +1,82 @@
+# 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 fault-injection with the
+# LIMIT ... OFFSET ... clause of UPDATE and DELETE statements.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix wherelfault
+
+ifcapable !update_delete_limit {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'f');
+ INSERT INTO t1 VALUES(2, 'e');
+ INSERT INTO t1 VALUES(3, 'd');
+ INSERT INTO t1 VALUES(4, 'c');
+ INSERT INTO t1 VALUES(5, 'b');
+ INSERT INTO t1 VALUES(6, 'a');
+
+ CREATE VIEW v1 AS SELECT a,b FROM t1;
+ CREATE TABLE log(op, a);
+
+ CREATE TRIGGER v1del INSTEAD OF DELETE ON v1 BEGIN
+ INSERT INTO log VALUES('delete', old.a);
+ END;
+
+ CREATE TRIGGER v1upd INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO log VALUES('update', old.a);
+ END;
+}
+
+faultsim_save_and_close
+do_faultsim_test 1.1 -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql { DELETE FROM v1 ORDER BY a LIMIT 3; }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 1.2 -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql { UPDATE v1 SET b = 555 ORDER BY a LIMIT 3 }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+sqlite3 db test.db
+do_execsql_test 2.1.0 {
+ CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID;
+}
+faultsim_save_and_close
+
+do_faultsim_test 2.1 -prep {
+ faultsim_restore_and_reopen
+ db eval {SELECT * FROM sqlite_master}
+} -body {
+ execsql { DELETE FROM t2 WHERE c=? ORDER BY a DESC LIMIT 10 }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+finish_test
diff --git a/test/wherelimit.test b/test/wherelimit.test
new file mode 100644
index 0000000..f6efab6
--- /dev/null
+++ b/test/wherelimit.test
@@ -0,0 +1,342 @@
+# 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} {
+
+ execsql { CREATE TABLE t1(x, y) }
+
+ # 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
+ #
+ # UPDATE: As of version 3.24, AS clauses are allowed as part of
+ # UPDATE or DELETE statements.
+ do_test wherelimit-0.4 {
+ catchsql {DELETE FROM t1 AS a WHERE a.x=1}
+ } {0 {}}
+ do_test wherelimit-0.5.1 {
+ catchsql {UPDATE t1 AS a SET y=1 WHERE x=1}
+ } {0 {}}
+ do_test wherelimit-0.5.2 {
+ catchsql {UPDATE t1 AS a SET y=1 WHERE t1.x=1}
+ } {1 {no such column: t1.x}}
+
+ # 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}}
+
+ execsql { DROP TABLE t1 }
+
+ # 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}
+ create_test_data 4
+ do_test wherelimit-1.3b {
+ # limit 5
+ execsql {DELETE FROM t1 RETURNING x, y, '|' ORDER BY x, y LIMIT 5}
+ } {1 1 | 1 2 | 1 3 | 1 4 | 2 1 |}
+ do_test wherelimit-1.3c {
+ execsql {SELECT count(*) FROM t1}
+ } {11}
+ do_test wherelimit-1.4 {
+ # limit 5, offset 2
+ execsql {DELETE FROM t1 RETURNING x, y, '|' ORDER BY x LIMIT 5 OFFSET 2}
+ } {2 4 | 3 1 | 3 2 | 3 3 | 3 4 |}
+ do_test wherelimit-1.4cnt {
+ execsql {SELECT count(*) FROM t1}
+ } {6}
+ 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}
+ } {1}
+ 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}
+ } {1}
+ 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 RETURNING x, y, '|' LIMIT 5}
+ } {1 1 | 1 1 | 1 1 | 1 1 | 1 1 |}
+ do_test wherelimit-3.2cnt {
+ 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}
+
+ # Cannot use a LIMIT for UPDATE or DELETE against a WITHOUT ROWID table
+ # or a VIEW. (We should fix this someday).
+ #
+ db close
+ sqlite3 db :memory:
+ do_execsql_test wherelimit-4.1 {
+ CREATE TABLE t1(a int);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ CREATE TABLE t2(a int);
+ INSERT INTO t2 SELECT a+100 FROM t1;
+ CREATE VIEW tv(r,a) AS
+ SELECT rowid, a FROM t2 UNION ALL SELECT rowid, a FROM t1;
+ CREATE TRIGGER tv_del INSTEAD OF DELETE ON tv
+ BEGIN
+ DELETE FROM t1 WHERE rowid=old.r;
+ DELETE FROM t2 WHERE rowid=old.r;
+ END;
+ } {}
+ do_catchsql_test wherelimit-4.2 {
+ DELETE FROM tv WHERE 1 LIMIT 2;
+ } {0 {}}
+ do_catchsql_test wherelimit-4.3 {
+ DELETE FROM tv WHERE 1 ORDER BY a LIMIT 2;
+ } {0 {}}
+ do_execsql_test wherelimit-4.10 {
+ CREATE TABLE t3(a,b,c,d TEXT, PRIMARY KEY(a,b)) WITHOUT ROWID;
+ INSERT INTO t3(a,b,c,d) VALUES(1,2,3,4),(5,6,7,8),(9,10,11,12);
+ } {}
+ do_catchsql_test wherelimit-4.11 {
+ DELETE FROM t3 WHERE a=5 LIMIT 2;
+ } {0 {}}
+ do_execsql_test wherelimit-4.12 {
+ SELECT a,b,c,d FROM t3 ORDER BY 1;
+ } {1 2 3 4 9 10 11 12}
+
+}
+
+finish_test
diff --git a/test/wherelimit2.test b/test/wherelimit2.test
new file mode 100644
index 0000000..8e39127
--- /dev/null
+++ b/test/wherelimit2.test
@@ -0,0 +1,303 @@
+# 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix wherelimit2
+
+ifcapable !update_delete_limit {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Test with views and INSTEAD OF triggers.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 'f');
+ INSERT INTO t1 VALUES(2, 'e');
+ INSERT INTO t1 VALUES(3, 'd');
+ INSERT INTO t1 VALUES(4, 'c');
+ INSERT INTO t1 VALUES(5, 'b');
+ INSERT INTO t1 VALUES(6, 'a');
+
+ CREATE VIEW v1 AS SELECT a,b FROM t1;
+ CREATE TABLE log(op, a);
+
+ CREATE TRIGGER v1del INSTEAD OF DELETE ON v1 BEGIN
+ INSERT INTO log VALUES('delete', old.a);
+ END;
+
+ CREATE TRIGGER v1upd INSTEAD OF UPDATE ON v1 BEGIN
+ INSERT INTO log VALUES('update', old.a);
+ END;
+}
+
+do_execsql_test 1.1 {
+ DELETE FROM v1 ORDER BY a LIMIT 3;
+ SELECT * FROM log; DELETE FROM log;
+} {
+ delete 1 delete 2 delete 3
+}
+do_execsql_test 1.2 {
+ DELETE FROM v1 ORDER BY b LIMIT 3;
+ SELECT * FROM log; DELETE FROM log;
+} {
+ delete 6 delete 5 delete 4
+}
+do_execsql_test 1.3 {
+ UPDATE v1 SET b = 555 ORDER BY a LIMIT 3;
+ SELECT * FROM log; DELETE FROM log;
+} {
+ update 1 update 2 update 3
+}
+do_execsql_test 1.4 {
+ UPDATE v1 SET b = 555 ORDER BY b LIMIT 3;
+ SELECT * FROM log; DELETE FROM log;
+} {
+ update 6 update 5 update 4
+}
+
+#-------------------------------------------------------------------------
+# Simple test using WITHOUT ROWID table.
+#
+do_execsql_test 2.1.0 {
+ CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID;
+ INSERT INTO t2 VALUES(1, 1, 'h');
+ INSERT INTO t2 VALUES(1, 2, 'g');
+ INSERT INTO t2 VALUES(2, 1, 'f');
+ INSERT INTO t2 VALUES(2, 2, 'e');
+ INSERT INTO t2 VALUES(3, 1, 'd');
+ INSERT INTO t2 VALUES(3, 2, 'c');
+ INSERT INTO t2 VALUES(4, 1, 'b');
+ INSERT INTO t2 VALUES(4, 2, 'a');
+}
+
+do_execsql_test 2.1.1 {
+ BEGIN;
+ DELETE FROM t2 WHERE b=1 ORDER BY c LIMIT 2;
+ SELECT c FROM t2 ORDER BY 1;
+ ROLLBACK;
+} {a c e f g h}
+
+do_execsql_test 2.1.2 {
+ BEGIN;
+ UPDATE t2 SET c=NULL ORDER BY a, b DESC LIMIT 3 OFFSET 1;
+ SELECT a, b, c FROM t2;
+ ROLLBACK;
+} {
+ 1 1 {}
+ 1 2 g
+ 2 1 {}
+ 2 2 {}
+ 3 1 d
+ 3 2 c
+ 4 1 b
+ 4 2 a
+}
+
+do_execsql_test 2.2.0 {
+ DROP TABLE t2;
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c) WITHOUT ROWID;
+ INSERT INTO t2 VALUES(1, 1, 'h');
+ INSERT INTO t2 VALUES(2, 2, 'g');
+ INSERT INTO t2 VALUES(3, 1, 'f');
+ INSERT INTO t2 VALUES(4, 2, 'e');
+ INSERT INTO t2 VALUES(5, 1, 'd');
+ INSERT INTO t2 VALUES(6, 2, 'c');
+ INSERT INTO t2 VALUES(7, 1, 'b');
+ INSERT INTO t2 VALUES(8, 2, 'a');
+}
+
+do_execsql_test 2.2.1 {
+ BEGIN;
+ DELETE FROM t2 WHERE b=1 ORDER BY c LIMIT 2;
+ SELECT c FROM t2 ORDER BY 1;
+ ROLLBACK;
+} {a c e f g h}
+
+do_execsql_test 2.2.2 {
+ BEGIN;
+ UPDATE t2 SET c=NULL ORDER BY a DESC LIMIT 3 OFFSET 1;
+ SELECT a, b, c FROM t2;
+ ROLLBACK;
+} {
+ 1 1 h
+ 2 2 g
+ 3 1 f
+ 4 2 e
+ 5 1 {}
+ 6 2 {}
+ 7 1 {}
+ 8 2 a
+}
+
+#-------------------------------------------------------------------------
+# Test using a virtual table
+#
+ifcapable fts5 {
+ do_execsql_test 3.0 {
+ CREATE VIRTUAL TABLE ft USING fts5(x);
+ INSERT INTO ft(rowid, x) VALUES(-45, 'a a');
+ INSERT INTO ft(rowid, x) VALUES(12, 'a b');
+ INSERT INTO ft(rowid, x) VALUES(444, 'a c');
+ INSERT INTO ft(rowid, x) VALUES(12300, 'a d');
+ INSERT INTO ft(rowid, x) VALUES(25400, 'a c');
+ INSERT INTO ft(rowid, x) VALUES(25401, 'a b');
+ INSERT INTO ft(rowid, x) VALUES(50000, 'a a');
+ }
+
+ do_execsql_test 3.1.1 {
+ BEGIN;
+ DELETE FROM ft ORDER BY rowid LIMIT 3;
+ SELECT x FROM ft;
+ ROLLBACK;
+ } {{a d} {a c} {a b} {a a}}
+
+ do_execsql_test 3.1.2 {
+ BEGIN;
+ DELETE FROM ft WHERE ft MATCH 'a' ORDER BY rowid LIMIT 3;
+ SELECT x FROM ft;
+ ROLLBACK;
+ } {{a d} {a c} {a b} {a a}}
+
+ do_execsql_test 3.1.3 {
+ BEGIN;
+ DELETE FROM ft WHERE ft MATCH 'b' ORDER BY rowid ASC LIMIT 1 OFFSET 1;
+ SELECT rowid FROM ft;
+ ROLLBACK;
+ } {-45 12 444 12300 25400 50000}
+
+ do_execsql_test 3.2.1 {
+ BEGIN;
+ UPDATE ft SET x='hello' ORDER BY rowid LIMIT 2 OFFSET 2;
+ SELECT x FROM ft;
+ ROLLBACK;
+ } {{a a} {a b} hello hello {a c} {a b} {a a}}
+
+ do_execsql_test 3.2.2 {
+ BEGIN;
+ UPDATE ft SET x='hello' WHERE ft MATCH 'a'
+ ORDER BY rowid DESC LIMIT 2 OFFSET 2;
+ SELECT x FROM ft;
+ ROLLBACK;
+ } {{a a} {a b} {a c} hello hello {a b} {a a}}
+} ;# fts5
+
+#-------------------------------------------------------------------------
+# Test using INDEXED BY clauses.
+#
+do_execsql_test 4.0 {
+ CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c, d);
+ CREATE INDEX x1bc ON x1(b, c);
+ INSERT INTO x1 VALUES(1,1,1,1);
+ INSERT INTO x1 VALUES(2,1,2,2);
+ INSERT INTO x1 VALUES(3,2,1,3);
+ INSERT INTO x1 VALUES(4,2,2,3);
+ INSERT INTO x1 VALUES(5,3,1,2);
+ INSERT INTO x1 VALUES(6,3,2,1);
+}
+
+do_execsql_test 4.1 {
+ BEGIN;
+ DELETE FROM x1 ORDER BY a LIMIT 2;
+ SELECT a FROM x1;
+ ROLLBACK;
+} {3 4 5 6}
+
+# 2020-06-03: Query planner improved so that a solution is possible.
+#
+#do_catchsql_test 4.2 {
+# DELETE FROM x1 INDEXED BY x1bc WHERE d=3 LIMIT 1;
+#} {1 {no query solution}}
+
+do_execsql_test 4.3 {
+ DELETE FROM x1 INDEXED BY x1bc WHERE b=3 LIMIT 1;
+ SELECT a FROM x1;
+} {1 2 3 4 6}
+
+# 2020-06-03: Query planner improved so that a solution is possible.
+#
+#do_catchsql_test 4.4 {
+# UPDATE x1 INDEXED BY x1bc SET d=5 WHERE d=3 LIMIT 1;
+#} {1 {no query solution}}
+
+do_execsql_test 4.5 {
+ UPDATE x1 INDEXED BY x1bc SET d=5 WHERE b=2 LIMIT 1;
+ SELECT a, d FROM x1;
+} {1 1 2 2 3 5 4 3 6 1}
+
+#-------------------------------------------------------------------------
+# Test using object names that require quoting.
+#
+do_execsql_test 5.0 {
+ CREATE TABLE "x y"("a b" PRIMARY KEY, "c d") WITHOUT ROWID;
+ CREATE INDEX xycd ON "x y"("c d");
+
+ INSERT INTO "x y" VALUES('a', 'a');
+ INSERT INTO "x y" VALUES('b', 'b');
+ INSERT INTO "x y" VALUES('c', 'c');
+ INSERT INTO "x y" VALUES('d', 'd');
+ INSERT INTO "x y" VALUES('e', 'a');
+ INSERT INTO "x y" VALUES('f', 'b');
+ INSERT INTO "x y" VALUES('g', 'c');
+ INSERT INTO "x y" VALUES('h', 'd');
+}
+
+do_execsql_test 5.1 {
+ BEGIN;
+ DELETE FROM "x y" WHERE "c d"!='e' ORDER BY "c d" LIMIT 2 OFFSET 2;
+ SELECT * FROM "x y" ORDER BY 1;
+ ROLLBACK;
+} {
+ a a c c d d e a g c h d
+}
+
+do_execsql_test 5.2 {
+ BEGIN;
+ UPDATE "x y" SET "c d"='e' WHERE "c d"!='e' ORDER BY "c d" LIMIT 2 OFFSET 2;
+ SELECT * FROM "x y" ORDER BY 1;
+ ROLLBACK;
+} {
+ a a b e c c d d e a f e g c h d
+}
+
+proc log {args} { lappend ::log {*}$args }
+db func log log
+do_execsql_test 5.3 {
+ CREATE VIEW "v w" AS SELECT * FROM "x y";
+ CREATE TRIGGER tr1 INSTEAD OF DELETE ON "v w" BEGIN
+ SELECT log(old."a b", old."c d");
+ END;
+ CREATE TRIGGER tr2 INSTEAD OF UPDATE ON "v w" BEGIN
+ SELECT log(new."a b", new."c d");
+ END;
+}
+
+do_test 5.4 {
+ set ::log {}
+ execsql { DELETE FROM "v w" ORDER BY "a b" LIMIT 3 }
+ set ::log
+} {a a b b c c}
+
+do_test 5.5 {
+ set ::log {}
+ execsql { UPDATE "v w" SET "a b" = "a b" || 'x' ORDER BY "a b" LIMIT 5; }
+ set ::log
+} {ax a bx b cx c dx d ex a}
+
+
+finish_test
diff --git a/test/widetab1.test b/test/widetab1.test
new file mode 100644
index 0000000..39523ce
--- /dev/null
+++ b/test/widetab1.test
@@ -0,0 +1,156 @@
+# 2022-10-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 test cases for wide table (tables with more than
+# 64 columns) and indexes that reference columns beyond the 63rd or 64th
+# column.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix widetab1
+
+
+# In order to pick the better index in the following query, SQLite needs to
+# be able to detect when an index that references later columns in a wide
+# table is a covering index.
+#
+do_execsql_test 100 {
+ CREATE TABLE a(
+ a00, a01, a02, a03, a04, a05, a06, a07, a08, a09,
+ 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,
+ pd, bn, vb, bc, cn, ie, qm);
+ CREATE INDEX a1 on a(pd, bn, vb, bc, cn); -- preferred index
+ CREATE INDEX a2 on a(pd, bc, ie, qm); -- suboptimal index
+ CREATE TABLE b(bg, bc, bn, iv, ln, mg);
+ CREATE INDEX b1 on b(bn, iv, bg);
+}
+do_eqp_test 110 {
+ SELECT dc, count(cn)
+ FROM (SELECT coalesce(b.bg, a.bc) as dc, cn
+ FROM a LEFT JOIN b
+ ON a.bn = b.bn
+ AND CASE WHEN a.vb IS NOT NULL THEN 1 ELSE 0 END = b.iv
+ WHERE pd BETWEEN 0 AND 10)
+ GROUP BY dc;
+} {
+ QUERY PLAN
+ |--SEARCH a USING COVERING INDEX a1 (pd>? AND pd<?)
+ |--SEARCH b USING COVERING INDEX b1 (bn=? AND iv=?) LEFT-JOIN
+ `--USE TEMP B-TREE FOR GROUP BY
+}
+
+reset_db
+do_execsql_test 200 {
+ CREATE TABLE t1(
+ 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,
+ 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,c66,c67,c68,c69,
+ c70,c71,c72,c73,c74,c75,c76,c77,c78,c79,
+ c80,c81,c82,c83,c84,c85,c86,c87,c88,c89,
+ c90,c91,c92,c93,c94,c95,c96,c97,c98,c99,
+ a,b,c,d,e
+ );
+ CREATE INDEX t1x1 on t1(c00,a,b,
+ 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,
+ 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,c66,c67,c68,c69,
+ c70,c71,c72,c73,c74,c75,c76,c77,c78,c79,
+ c80,c81,c82,c83,c84,c85,c86,c87,c88,c89,
+ c90,c91,c92,c93,c94,c00,c96,c97,c98,c99
+ );
+ CREATE INDEX t1cd ON t1(c,d);
+ CREATE INDEX t1x2 ON t1(c01,c02,c03,a,b);
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1000 FROM c WHERE x<9000)
+ INSERT INTO t1 SELECT
+ x+00, x+01, x+02, x+03, x+04, x+05, x+06, x+07, x+08, x+09,
+ x+10, x+11, x+12, x+13, x+14, x+15, x+16, x+17, x+18, x+19,
+ x+20, x+21, x+22, x+23, x+24, x+25, x+26, x+27, x+28, x+29,
+ x+30, x+31, x+32, x+33, x+34, x+35, x+36, x+37, x+38, x+39,
+ x+40, x+41, x+42, x+43, x+44, x+45, x+46, x+47, x+48, x+49,
+ x+50, x+51, x+52, x+53, x+54, x+55, x+56, x+57, x+58, x+59,
+ x+60, x+61, x+62, x+63, x+64, x+65, x+66, x+67, x+68, x+69,
+ x+70, x+71, x+72, x+73, x+74, x+75, x+76, x+77, x+78, x+79,
+ x+80, x+81, x+82, x+83, x+84, x+85, x+86, x+87, x+88, x+89,
+ x+90, x+91, x+92, x+93, x+94, x+95, x+96, x+97, x+98, x+99,
+ x+100, x+101, x+102, x+103, x+104 FROM c;
+}
+
+do_execsql_test 210 {SELECT sum(c62) FROM t1;} 45620
+do_execsql_test 220 {SELECT sum(c63) FROM t1;} 45630
+do_execsql_test 230 {SELECT sum(c64) FROM t1;} 45640
+do_execsql_test 240 {SELECT sum(c65) FROM t1;} 45650
+
+do_execsql_test 300 {
+ BEGIN;
+ SELECT sum(c62) FROM t1;
+ UPDATE t1 SET c62=c62+1 WHERE c00=1000;
+ SELECT sum(c62) FROM t1;
+} {45620 45621}
+do_execsql_test 310 {
+ SELECT sum(c65) FROM t1;
+ UPDATE t1 SET c65=c65+1 WHERE c00=1000;
+ SELECT sum(c65) FROM t1;
+ ROLLBACK;
+} {45650 45651}
+
+do_execsql_test 320 {
+ BEGIN;
+ SELECT count(*) FROM t1;
+ DELETE FROM t1 WHERE c=3102;
+ SELECT COUNT(*) FROM t1;
+ ROLLBACK;
+} {10 9}
+do_execsql_test 330 {
+ BEGIN;
+ SELECT count(*) FROM t1;
+ DELETE FROM t1 WHERE c=3102 AND d=3103;
+ SELECT COUNT(*) FROM t1;
+ ROLLBACK;
+} {10 9}
+do_execsql_test 340 {
+ BEGIN;
+ DELETE FROM t1 WHERE (c,d) IN (VALUES(3102,3103),(4102,4103),(5102,5103),(1,2));
+ SELECT count(*) FROM t1;
+ ROLLBACK;
+} {7}
+
+do_execsql_test 400 {
+ DROP INDEX t1cd;
+ DROP INDEX t1x1;
+ DROP INDEX t1x2;
+ CREATE INDEX t1x3 ON t1(c00,c05,c08);
+}
+do_execsql_test 410 {SELECT sum(c08) FROM t1 WHERE c00 IN (1000,5000);} 6016
+do_execsql_test 420 {SELECT sum(c63) FROM t1 WHERE c00 IN (1000,5000);} 6126
+do_execsql_test 430 {SELECT sum(c64) FROM t1 WHERE c00 IN (1000,5000);} 6128
+
+do_execsql_test 500 {
+ DROP INDEX t1x3;
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ CREATE INDEX t1x4 ON t1(c00, c62, a, b);
+ CREATE INDEX t2x4 ON t2(c01, c62, c63, b, c);
+ SELECT t1.b, t2.b FROM t1 JOIN t2 ON t2.c01=t1.c00+1 WHERE +t1.b<7000
+ ORDER BY +t1.b;
+} {101 101 1101 1101 2101 2101 3101 3101 4101 4101 5101 5101 6101 6101}
+
+finish_test
diff --git a/test/win32heap.test b/test/win32heap.test
new file mode 100644
index 0000000..82a3f6b
--- /dev/null
+++ b/test/win32heap.test
@@ -0,0 +1,73 @@
+# 2013 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. The
+# focus of this script is the Win32 heap implementation.
+#
+
+if {$tcl_platform(platform)!="windows"} return
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !win32malloc {
+ finish_test
+ return
+}
+
+set testprefix win32heap
+
+do_test 1.1 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap_size 1048576
+ sqlite3_initialize
+} {SQLITE_OK}
+
+do_test 1.2 {
+ sqlite3 db test.db
+ catchsql {
+ CREATE TABLE t1(x);
+ }
+} {0 {}}
+
+do_test 1.3 {
+ catchsql {
+ INSERT INTO t1 (x) VALUES(RANDOMBLOB(1048576));
+ }
+} {1 {out of memory}}
+
+do_test 1.4 {
+ catchsql {
+ SELECT COUNT(*) FROM t1;
+ }
+} {0 0}
+
+do_test 1.5 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap_size 0
+ sqlite3_initialize
+} {SQLITE_OK}
+
+do_test 1.6 {
+ sqlite3 db test.db
+ catchsql {
+ INSERT INTO t1 (x) VALUES(RANDOMBLOB(1048576));
+ }
+} {0 {}}
+
+do_test 1.7 {
+ catchsql {
+ SELECT COUNT(*) FROM t1;
+ }
+} {0 1}
+
+finish_test
diff --git a/test/win32lock.test b/test/win32lock.test
new file mode 100644
index 0000000..fbb2dd1
--- /dev/null
+++ b/test/win32lock.test
@@ -0,0 +1,184 @@
+# 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.
+#
+# TESTRUNNER: slow
+#
+
+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
+db eval {PRAGMA mmap_size=0}
+
+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
+ regsub { at line \d+} $x "" 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
+ regsub { at line \d+} $x "" 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
+forcedelete test.db
+
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test win32lock-3.0 {
+ db eval {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ }
+} {}
+
+do_test win32lock-3.1 {
+ db eval {
+ BEGIN EXCLUSIVE;
+ INSERT INTO t1 VALUES(4);
+ }
+} {}
+
+do_test win32lock-3.2 {
+ catchsql {
+ BEGIN EXCLUSIVE;
+ INSERT INTO t1 VALUES(5);
+ COMMIT;
+ } db2
+} {1 {database is locked}}
+
+do_test win32lock-3.3 {
+ db eval {
+ COMMIT;
+ }
+} {}
+
+do_test win32lock-3.4 {
+ set handle [lindex [file_control_win32_set_handle db 0] end]
+ list [catchsql {
+ BEGIN EXCLUSIVE;
+ INSERT INTO t1 VALUES(6);
+ COMMIT;
+ }] [file_control_win32_set_handle db $handle] [sqlite3_extended_errcode db]
+} {{1 {disk I/O error}} {0 0} SQLITE_IOERR_LOCK}
+
+db2 close
+db close
+sqlite3_shutdown
+test_sqlite3_log
+sqlite3_initialize
+finish_test
diff --git a/test/win32longpath.test b/test/win32longpath.test
new file mode 100644
index 0000000..01b4af7
--- /dev/null
+++ b/test/win32longpath.test
@@ -0,0 +1,139 @@
+# 2013 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 testing the file name handling provided
+# by the "win32-longpath" VFS.
+#
+
+if {$tcl_platform(platform)!="windows"} return
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix win32longpath
+
+do_test 1.0 {
+ file_control_vfsname db
+} win32
+
+db close
+set rawPath [get_pwd]
+set path [file nativename $rawPath]
+sqlite3 db [file join $path test.db] -vfs win32-longpath
+
+do_test 1.1 {
+ file_control_vfsname db
+} win32-longpath
+
+do_test 1.2 {
+ db eval {
+ BEGIN EXCLUSIVE;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+ SELECT x FROM t1 ORDER BY x;
+ COMMIT;
+ }
+} {1 2 3 4}
+
+set longPath(1) \\\\?\\$path\\[pid]
+set uriPath(1a) %5C%5C%3F%5C$path\\[pid]
+set uriPath(1b) %5C%5C%3F%5C$rawPath/[pid]
+
+make_win32_dir $longPath(1)
+
+set longPath(2) $longPath(1)\\[string repeat X 255]
+set uriPath(2a) $uriPath(1a)\\[string repeat X 255]
+set uriPath(2b) $uriPath(1b)/[string repeat X 255]
+
+make_win32_dir $longPath(2)
+
+set longPath(3) $longPath(2)\\[string repeat Y 255]
+set uriPath(3a) $uriPath(2a)\\[string repeat Y 255]
+set uriPath(3b) $uriPath(2b)/[string repeat Y 255]
+
+make_win32_dir $longPath(3)
+
+set fileName $longPath(3)\\test.db
+
+set uri(1a) file:$uriPath(3a)\\test.db
+set uri(1b) file:$uriPath(3b)/test.db
+set uri(1c) file:///$uriPath(3a)\\test.db
+set uri(1d) file:///$uriPath(3b)/test.db
+set uri(1e) file://localhost/$uriPath(3a)\\test.db
+set uri(1f) file://localhost/$uriPath(3b)/test.db
+
+do_test 1.3 {
+ list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg
+} {1 {unable to open database file}}
+
+sqlite3 db3 $fileName -vfs win32-longpath
+
+do_test 1.4 {
+ db3 eval {
+ BEGIN EXCLUSIVE;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(5);
+ INSERT INTO t1 VALUES(6);
+ INSERT INTO t1 VALUES(7);
+ INSERT INTO t1 VALUES(8);
+ SELECT x FROM t1 ORDER BY x;
+ COMMIT;
+ }
+} {5 6 7 8}
+
+db3 close
+# puts " Database exists \{[exists_win32_path $fileName]\}"
+
+sqlite3 db3 $fileName -vfs win32-longpath
+
+do_test 1.5 {
+ db3 eval {
+ PRAGMA journal_mode = WAL;
+ }
+} {wal}
+
+do_test 1.6 {
+ db3 eval {
+ BEGIN EXCLUSIVE;
+ INSERT INTO t1 VALUES(9);
+ INSERT INTO t1 VALUES(10);
+ INSERT INTO t1 VALUES(11);
+ INSERT INTO t1 VALUES(12);
+ SELECT x FROM t1 ORDER BY x;
+ COMMIT;
+ }
+} {5 6 7 8 9 10 11 12}
+
+db3 close
+# puts " Database exists \{[exists_win32_path $fileName]\}"
+
+foreach tn {1a 1b 1c 1d 1e 1f} {
+ sqlite3 db3 $uri($tn) -vfs win32-longpath -uri 1 -translatefilename 0
+
+ do_test 1.7.$tn {
+ db3 eval {
+ SELECT x FROM t1 ORDER BY x;
+ }
+ } {5 6 7 8 9 10 11 12}
+
+ db3 close
+}
+
+do_delete_win32_file $fileName
+# puts " Files remaining \{[find_win32_file $longPath(3)\\*]\}"
+
+do_remove_win32_dir $longPath(3)
+do_remove_win32_dir $longPath(2)
+do_remove_win32_dir $longPath(1)
+
+finish_test
diff --git a/test/win32nolock.test b/test/win32nolock.test
new file mode 100644
index 0000000..8128860
--- /dev/null
+++ b/test/win32nolock.test
@@ -0,0 +1,126 @@
+# 2016 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.
+#
+
+if {$tcl_platform(platform)!="windows"} return
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix win32nolock
+
+do_test win32nolock-1.0 {
+ sqlite3 db test.db
+ execsql {
+ CREATE TABLE t1(a, b);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ }
+} {}
+
+do_test win32nolock-1.1 {
+ execsql COMMIT
+ catchsql { SELECT * FROM t1 }
+} {0 {1 2}}
+
+db close
+
+do_test win32nolock-1.2 {
+ sqlite3 db test.db -vfs win32-none
+ sqlite3 db2 test.db -vfs win32-none
+ execsql { PRAGMA mmap_size = 0 } db2
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(3, 4);
+ }
+} {}
+
+do_test win32nolock-1.3 {
+ execsql { SELECT * FROM t1 }
+} {1 2 3 4}
+
+do_test win32nolock-1.4 {
+ execsql { SELECT * FROM t1; } db2
+} {1 2}
+
+do_test win32nolock-1.5 {
+ execsql {
+ BEGIN;
+ SELECT * FROM t1;
+ } db2
+} {1 2}
+
+do_test win32nolock-1.6 {
+ execsql COMMIT
+ execsql {SELECT * FROM t1} db2
+} {1 2}
+
+ifcapable memorymanage {
+ do_test win32nolock-1.7 {
+ sqlite3_release_memory 1000000
+ execsql {SELECT * FROM t1} db2
+ } {1 2 3 4}
+}
+
+do_test win32nolock-1.8 {
+ db close
+ db2 close
+} {}
+
+do_test win32nolock-1.9.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db
+ list [catchsql { BEGIN EXCLUSIVE; } db] \
+ [catchsql { BEGIN EXCLUSIVE; } db2]
+} {{0 {}} {1 {database is locked}}}
+
+do_test win32nolock-1.9.2 {
+ db close
+ db2 close
+} {}
+
+do_test win32nolock-1.10.1 {
+ sqlite3 db test.db -vfs win32-none
+ sqlite3 db2 test.db
+ list [catchsql { BEGIN EXCLUSIVE; } db] \
+ [catchsql { BEGIN EXCLUSIVE; } db2]
+} {{0 {}} {0 {}}}
+
+do_test win32nolock-1.10.2 {
+ db close
+ db2 close
+} {}
+
+do_test win32nolock-1.11.1 {
+ sqlite3 db test.db
+ sqlite3 db2 test.db -vfs win32-none
+ list [catchsql { BEGIN EXCLUSIVE; } db] \
+ [catchsql { BEGIN EXCLUSIVE; } db2]
+} {{0 {}} {0 {}}}
+
+do_test win32nolock-1.11.2 {
+ db close
+ db2 close
+} {}
+
+do_test win32nolock-1.12.1 {
+ sqlite3 db test.db -vfs win32-none
+ sqlite3 db2 test.db -vfs win32-none
+ list [catchsql { BEGIN EXCLUSIVE; } db] \
+ [catchsql { BEGIN EXCLUSIVE; } db2]
+} {{0 {}} {0 {}}}
+
+do_test win32nolock-1.12.2 {
+ db close
+ db2 close
+} {}
+
+finish_test
diff --git a/test/window1.test b/test/window1.test
new file mode 100644
index 0000000..0f22829
--- /dev/null
+++ b/test/window1.test
@@ -0,0 +1,2213 @@
+# 2018 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 implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window1
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c, d);
+ INSERT INTO t1 VALUES(1, 2, 3, 4);
+ INSERT INTO t1 VALUES(5, 6, 7, 8);
+ INSERT INTO t1 VALUES(9, 10, 11, 12);
+}
+
+do_execsql_test 1.1 {
+ SELECT sum(b) OVER () FROM t1
+} {18 18 18}
+
+do_execsql_test 1.2 {
+ SELECT a, sum(b) OVER () FROM t1
+} {1 18 5 18 9 18}
+
+do_execsql_test 1.3 {
+ SELECT a, 4 + sum(b) OVER () FROM t1
+} {1 22 5 22 9 22}
+
+do_execsql_test 1.4 {
+ SELECT a + 4 + sum(b) OVER () FROM t1
+} {23 27 31}
+
+do_execsql_test 1.5 {
+ SELECT a, sum(b) OVER (PARTITION BY c) FROM t1
+} {1 2 5 6 9 10}
+
+foreach {tn sql} {
+ 1 "SELECT sum(b) OVER () FROM t1"
+ 2 "SELECT sum(b) OVER (PARTITION BY c) FROM t1"
+ 3 "SELECT sum(b) OVER (ORDER BY c) FROM t1"
+ 4 "SELECT sum(b) OVER (PARTITION BY d ORDER BY c) FROM t1"
+ 5 "SELECT sum(b) FILTER (WHERE a>0) OVER (PARTITION BY d ORDER BY c) FROM t1"
+ 6 "SELECT sum(b) OVER (ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t1"
+ 7 "SELECT sum(b) OVER (ORDER BY c ROWS 45 PRECEDING) FROM t1"
+ 8 "SELECT sum(b) OVER (ORDER BY c RANGE CURRENT ROW) FROM t1"
+ 9 "SELECT sum(b) OVER (ORDER BY c RANGE BETWEEN UNBOUNDED PRECEDING
+ AND CURRENT ROW) FROM t1"
+ 10 "SELECT sum(b) OVER (ORDER BY c ROWS BETWEEN UNBOUNDED PRECEDING
+ AND UNBOUNDED FOLLOWING) FROM t1"
+} {
+ do_test 2.$tn { lindex [catchsql $sql] 0 } 0
+}
+
+foreach {tn sql} {
+ 1 "SELECT * FROM t1 WHERE sum(b) OVER ()"
+ 2 "SELECT * FROM t1 GROUP BY sum(b) OVER ()"
+ 3 "SELECT * FROM t1 GROUP BY a HAVING sum(b) OVER ()"
+} {
+ do_catchsql_test 3.$tn $sql {1 {misuse of window function sum()}}
+}
+
+do_execsql_test 4.0 {
+ CREATE TABLE t2(a, b, c);
+ INSERT INTO t2 VALUES(0, 0, 0);
+ INSERT INTO t2 VALUES(1, 1, 1);
+ INSERT INTO t2 VALUES(2, 0, 2);
+ INSERT INTO t2 VALUES(3, 1, 0);
+ INSERT INTO t2 VALUES(4, 0, 1);
+ INSERT INTO t2 VALUES(5, 1, 2);
+ INSERT INTO t2 VALUES(6, 0, 0);
+}
+
+do_execsql_test 4.1 {
+ SELECT a, sum(a) OVER (PARTITION BY b) FROM t2;
+} {
+ 0 12 2 12 4 12 6 12 1 9 3 9 5 9
+}
+
+do_execsql_test 4.2 {
+ SELECT a, sum(a) OVER (PARTITION BY b) FROM t2 ORDER BY a;
+} {
+ 0 12 1 9 2 12 3 9 4 12 5 9 6 12
+}
+
+do_execsql_test 4.3 {
+ SELECT a, sum(a) OVER () FROM t2 ORDER BY a;
+} {
+ 0 21 1 21 2 21 3 21 4 21 5 21 6 21
+}
+
+do_execsql_test 4.4 {
+ SELECT a, sum(a) OVER (ORDER BY a) FROM t2;
+} {
+ 0 0 1 1 2 3 3 6 4 10 5 15 6 21
+}
+
+do_execsql_test 4.5 {
+ SELECT a, sum(a) OVER (PARTITION BY b ORDER BY a) FROM t2 ORDER BY a
+} {
+ 0 0 1 1 2 2 3 4 4 6 5 9 6 12
+}
+
+do_execsql_test 4.6 {
+ SELECT a, sum(a) OVER (PARTITION BY c ORDER BY a) FROM t2 ORDER BY a
+} {
+ 0 0 1 1 2 2 3 3 4 5 5 7 6 9
+}
+
+do_execsql_test 4.7 {
+ SELECT a, sum(a) OVER (PARTITION BY b ORDER BY a DESC) FROM t2 ORDER BY a
+} {
+ 0 12 1 9 2 12 3 8 4 10 5 5 6 6
+}
+
+do_execsql_test 4.8 {
+ SELECT a,
+ sum(a) OVER (PARTITION BY b ORDER BY a DESC),
+ sum(a) OVER (PARTITION BY c ORDER BY a)
+ FROM t2 ORDER BY a
+} {
+ 0 12 0
+ 1 9 1
+ 2 12 2
+ 3 8 3
+ 4 10 5
+ 5 5 7
+ 6 6 9
+}
+
+do_execsql_test 4.9 {
+ SELECT a,
+ sum(a) OVER (ORDER BY a),
+ avg(a) OVER (ORDER BY a)
+ FROM t2 ORDER BY a
+} {
+ 0 0 0.0
+ 1 1 0.5
+ 2 3 1.0
+ 3 6 1.5
+ 4 10 2.0
+ 5 15 2.5
+ 6 21 3.0
+}
+
+do_execsql_test 4.10.1 {
+ SELECT a,
+ count() OVER (ORDER BY a DESC),
+ group_concat(a, '.') OVER (ORDER BY a DESC)
+ FROM t2 ORDER BY a DESC
+} {
+ 6 1 6
+ 5 2 6.5
+ 4 3 6.5.4
+ 3 4 6.5.4.3
+ 2 5 6.5.4.3.2
+ 1 6 6.5.4.3.2.1
+ 0 7 6.5.4.3.2.1.0
+}
+
+do_execsql_test 4.10.2 {
+ SELECT a,
+ count(*) OVER (ORDER BY a DESC),
+ group_concat(a, '.') OVER (ORDER BY a DESC)
+ FROM t2 ORDER BY a DESC
+} {
+ 6 1 6
+ 5 2 6.5
+ 4 3 6.5.4
+ 3 4 6.5.4.3
+ 2 5 6.5.4.3.2
+ 1 6 6.5.4.3.2.1
+ 0 7 6.5.4.3.2.1.0
+}
+
+do_catchsql_test 5.1 {
+ SELECT ntile(0) OVER (ORDER BY a) FROM t2;
+} {1 {argument of ntile must be a positive integer}}
+do_catchsql_test 5.2 {
+ SELECT ntile(-1) OVER (ORDER BY a) FROM t2;
+} {1 {argument of ntile must be a positive integer}}
+do_catchsql_test 5.3 {
+ SELECT ntile('zbc') OVER (ORDER BY a) FROM t2;
+} {1 {argument of ntile must be a positive integer}}
+do_execsql_test 5.4 {
+ CREATE TABLE t4(a, b);
+ SELECT ntile(1) OVER (ORDER BY a) FROM t4;
+} {}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 6.1 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(7), (6), (5), (4), (3), (2), (1);
+
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES('b'), ('a');
+
+ SELECT x, count(*) OVER (ORDER BY x) FROM t1;
+} {1 1 2 2 3 3 4 4 5 5 6 6 7 7}
+
+do_execsql_test 6.2 {
+ SELECT * FROM t2, (SELECT x, count(*) OVER (ORDER BY x) FROM t1)
+ ORDER BY 1, 2;
+} {
+ a 1 1 a 2 2 a 3 3 a 4 4 a 5 5 a 6 6 a 7 7
+ b 1 1 b 2 2 b 3 3 b 4 4 b 5 5 b 6 6 b 7 7
+}
+
+do_catchsql_test 6.3 {
+ SELECT x, lag(x) FILTER (WHERE (x%2)=0) OVER w FROM t1
+ WINDOW w AS (ORDER BY x)
+} {1 {FILTER clause may only be used with aggregate window functions}}
+
+#-------------------------------------------------------------------------
+# Attempt to use a window function as an aggregate. And other errors.
+#
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE t1(x, y);
+ 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);
+}
+
+do_catchsql_test 7.1.1 {
+ SELECT nth_value(x, 1) FROM t1;
+} {1 {misuse of window function nth_value()}}
+do_catchsql_test 7.1.2 {
+ SELECT * FROM t1 WHERE nth_value(x, 1) OVER (ORDER BY y);
+} {1 {misuse of window function nth_value()}}
+do_catchsql_test 7.1.3 {
+ SELECT count(*) FROM t1 GROUP BY y HAVING nth_value(x, 1) OVER (ORDER BY y);
+} {1 {misuse of window function nth_value()}}
+do_catchsql_test 7.1.4 {
+ SELECT count(*) FROM t1 GROUP BY nth_value(x, 1) OVER (ORDER BY y);
+} {1 {misuse of window function nth_value()}}
+do_catchsql_test 7.1.5 {
+ SELECT count(*) FROM t1 LIMIT nth_value(x, 1) OVER ();
+} {1 {no such column: x}}
+do_catchsql_test 7.1.6 {
+ SELECT trim(x) OVER (ORDER BY y) FROM t1;
+} {1 {trim() may not be used as a window function}}
+do_catchsql_test 7.1.7 {
+ SELECT max(x) OVER abc FROM t1 WINDOW def AS (ORDER BY y);
+} {1 {no such window: abc}}
+do_catchsql_test 7.1.8 {
+ SELECT row_number(x) OVER () FROM t1
+} {1 {wrong number of arguments to function row_number()}}
+
+do_execsql_test 7.2 {
+ SELECT
+ lead(y) OVER win,
+ lead(y, 2) OVER win,
+ lead(y, 3, 'default') OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY x)
+} {
+ 4 6 8 6 8 10 8 10 default 10 {} default {} {} default
+}
+
+do_execsql_test 7.3 {
+ SELECT row_number() OVER (ORDER BY x) FROM t1
+} {1 2 3 4 5}
+
+do_execsql_test 7.4 {
+ SELECT
+ row_number() OVER win,
+ lead(x) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY x ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {1 3 2 5 3 7 4 9 5 {}}
+
+#-------------------------------------------------------------------------
+# Attempt to use a window function in a view.
+#
+do_execsql_test 8.0 {
+ CREATE TABLE t3(a, b, c);
+
+ WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<6 )
+ INSERT INTO t3 SELECT i, i, i FROM s;
+
+ CREATE VIEW v1 AS SELECT
+ sum(b) OVER (ORDER BY c),
+ min(b) OVER (ORDER BY c),
+ max(b) OVER (ORDER BY c)
+ FROM t3;
+
+ CREATE VIEW v2 AS SELECT
+ sum(b) OVER win,
+ min(b) OVER win,
+ max(b) OVER win
+ FROM t3
+ WINDOW win AS (ORDER BY c);
+}
+
+do_execsql_test 8.1.1 {
+ SELECT * FROM v1
+} {1 1 1 3 1 2 6 1 3 10 1 4 15 1 5 21 1 6}
+do_execsql_test 8.1.2 {
+ SELECT * FROM v2
+} {1 1 1 3 1 2 6 1 3 10 1 4 15 1 5 21 1 6}
+
+db close
+sqlite3 db test.db
+do_execsql_test 8.2.1 {
+ SELECT * FROM v1
+} {1 1 1 3 1 2 6 1 3 10 1 4 15 1 5 21 1 6}
+do_execsql_test 8.2.2 {
+ SELECT * FROM v2
+} {1 1 1 3 1 2 6 1 3 10 1 4 15 1 5 21 1 6}
+
+#-------------------------------------------------------------------------
+# Attempt to use a window function in a trigger.
+#
+do_execsql_test 9.0 {
+ CREATE TABLE t4(x, y);
+ INSERT INTO t4 VALUES(1, 'g');
+ INSERT INTO t4 VALUES(2, 'i');
+ INSERT INTO t4 VALUES(3, 'l');
+ INSERT INTO t4 VALUES(4, 'g');
+ INSERT INTO t4 VALUES(5, 'a');
+
+ CREATE TABLE t5(x, y, m);
+ CREATE TRIGGER t4i AFTER INSERT ON t4 BEGIN
+ DELETE FROM t5;
+ INSERT INTO t5
+ SELECT x, y, max(y) OVER xyz FROM t4
+ WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x);
+ END;
+}
+
+do_execsql_test 9.1.1 {
+ SELECT x, y, max(y) OVER xyz FROM t4
+ WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x) ORDER BY 1
+} {1 g g 2 i i 3 l l 4 g i 5 a l}
+
+do_execsql_test 9.1.2 {
+ INSERT INTO t4 VALUES(6, 'm');
+ SELECT x, y, max(y) OVER xyz FROM t4
+ WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x) ORDER BY 1
+} {1 g g 2 i i 3 l l 4 g i 5 a l 6 m m}
+
+do_execsql_test 9.1.3 {
+ SELECT * FROM t5 ORDER BY 1
+} {1 g g 2 i i 3 l l 4 g i 5 a l 6 m m}
+
+do_execsql_test 9.2 {
+ WITH aaa(x, y, z) AS (
+ SELECT x, y, max(y) OVER xyz FROM t4
+ WINDOW xyz AS (PARTITION BY (x%2) ORDER BY x)
+ )
+ SELECT * FROM aaa ORDER BY 1;
+} {1 g g 2 i i 3 l l 4 g i 5 a l 6 m m}
+
+do_execsql_test 9.3 {
+ WITH aaa(x, y, z) AS (
+ SELECT x, y, max(y) OVER xyz FROM t4
+ WINDOW xyz AS (ORDER BY x)
+ )
+ SELECT *, min(z) OVER (ORDER BY x) FROM aaa ORDER BY 1;
+} {1 g g g 2 i i g 3 l l g 4 g l g 5 a l g 6 m m g}
+
+do_catchsql_test 9.4 {
+ -- 2021-04-17 dbsqlfuzz d9cf66100064952b66951845dfab41de1c124611
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b,c,d);
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x,y);
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2(x,y)
+ SELECT a, max(d) OVER w1 FROM t1
+ WINDOW w1 AS (PARTITION BY EXISTS(SELECT 1 FROM t1 WHERE c=?1) );
+ END;
+} {1 {trigger cannot use variables}}
+
+do_catchsql_test 9.4.2 {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t1(a,b)
+ SELECT a, max(d) OVER w1 FROM t1
+ WINDOW w1 AS (
+ ORDER BY a ROWS BETWEEN ? PRECEDING AND UNBOUNDED FOLLOWING
+ );
+ END;
+} {1 {trigger cannot use variables}}
+do_catchsql_test 9.4.3 {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO t1(a,b)
+ SELECT a, max(d) OVER w1 FROM t1
+ WINDOW w1 AS (
+ ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND ? FOLLOWING
+ );
+ END;
+} {1 {trigger cannot use variables}}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 10.0 {
+ CREATE TABLE sales(emp TEXT PRIMARY KEY, region, total);
+ INSERT INTO sales VALUES
+ ('Alice', 'North', 34),
+ ('Frank', 'South', 22),
+ ('Charles', 'North', 45),
+ ('Darrell', 'South', 8),
+ ('Grant', 'South', 23),
+ ('Brad' , 'North', 22),
+ ('Elizabeth', 'South', 99),
+ ('Horace', 'East', 1);
+}
+
+# Best two salespeople from each region
+#
+do_execsql_test 10.1 {
+ SELECT emp, region, total FROM (
+ SELECT
+ emp, region, total,
+ row_number() OVER (PARTITION BY region ORDER BY total DESC) AS rank
+ FROM sales
+ ) WHERE rank<=2 ORDER BY region, total DESC
+} {
+ Horace East 1
+ Charles North 45
+ Alice North 34
+ Elizabeth South 99
+ Grant South 23
+}
+
+do_execsql_test 10.2 {
+ SELECT emp, region, sum(total) OVER win FROM sales
+ WINDOW win AS (PARTITION BY region ORDER BY total)
+} {
+ Horace East 1
+ Brad North 22
+ Alice North 56
+ Charles North 101
+ Darrell South 8
+ Frank South 30
+ Grant South 53
+ Elizabeth South 152
+}
+
+do_execsql_test 10.3 {
+ SELECT emp, region, sum(total) OVER win FROM sales
+ WINDOW win AS (PARTITION BY region ORDER BY total)
+ LIMIT 5
+} {
+ Horace East 1
+ Brad North 22
+ Alice North 56
+ Charles North 101
+ Darrell South 8
+}
+
+do_execsql_test 10.4 {
+ SELECT emp, region, sum(total) OVER win FROM sales
+ WINDOW win AS (PARTITION BY region ORDER BY total)
+ LIMIT 5 OFFSET 2
+} {
+ Alice North 56
+ Charles North 101
+ Darrell South 8
+ Frank South 30
+ Grant South 53
+}
+
+do_execsql_test 10.5 {
+ SELECT emp, region, sum(total) OVER win FROM sales
+ WINDOW win AS (
+ PARTITION BY region ORDER BY total
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ )
+} {
+ Horace East 1
+ Brad North 101
+ Alice North 79
+ Charles North 45
+ Darrell South 152
+ Frank South 144
+ Grant South 122
+ Elizabeth South 99
+}
+
+do_execsql_test 10.6 {
+ SELECT emp, region, sum(total) OVER win FROM sales
+ WINDOW win AS (
+ PARTITION BY region ORDER BY total
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) LIMIT 5 OFFSET 2
+} {
+ Alice North 79
+ Charles North 45
+ Darrell South 152
+ Frank South 144
+ Grant South 122
+}
+
+do_execsql_test 10.7 {
+ SELECT emp, region, (
+ SELECT sum(total) OVER (
+ ORDER BY total RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) || outer.emp FROM sales
+ ) FROM sales AS outer;
+} {
+ Alice North 254Alice
+ Frank South 254Frank
+ Charles North 254Charles
+ Darrell South 254Darrell
+ Grant South 254Grant
+ Brad North 254Brad
+ Elizabeth South 254Elizabeth
+ Horace East 254Horace
+}
+
+do_execsql_test 10.8 {
+ SELECT emp, region, (
+ SELECT sum(total) FILTER (WHERE sales.emp!=outer.emp) OVER (
+ ORDER BY total RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM sales
+ ) FROM sales AS outer;
+} {
+ Alice North 220
+ Frank South 232
+ Charles North 209
+ Darrell South 246
+ Grant South 231
+ Brad North 232
+ Elizabeth South 155
+ Horace East 253
+}
+
+#-------------------------------------------------------------------------
+# Check that it is not possible to use a window function in a CREATE INDEX
+# statement.
+#
+do_execsql_test 11.0 { CREATE TABLE t6(a, b, c); }
+
+do_catchsql_test 11.1 {
+ CREATE INDEX t6i ON t6(a) WHERE sum(b) OVER ();
+} {1 {misuse of window function sum()}}
+do_catchsql_test 11.2 {
+ CREATE INDEX t6i ON t6(a) WHERE lead(b) OVER ();
+} {1 {misuse of window function lead()}}
+
+do_catchsql_test 11.3 {
+ CREATE INDEX t6i ON t6(sum(b) OVER ());
+} {1 {misuse of window function sum()}}
+do_catchsql_test 11.4 {
+ CREATE INDEX t6i ON t6(lead(b) OVER ());
+} {1 {misuse of window function lead()}}
+
+# 2018-09-17 ticket 510cde277783b5fb5de628393959849dff377eb3
+# Endless loop on a query with window functions and a limit
+#
+do_execsql_test 12.100 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(id INT, b VARCHAR, c VARCHAR);
+ INSERT INTO t1 VALUES(1, 'A', 'one');
+ INSERT INTO t1 VALUES(2, 'B', 'two');
+ INSERT INTO t1 VALUES(3, 'C', 'three');
+ INSERT INTO t1 VALUES(4, 'D', 'one');
+ INSERT INTO t1 VALUES(5, 'E', 'two');
+ SELECT id, b, lead(c,1) OVER(ORDER BY c) AS x
+ FROM t1 WHERE id>1
+ ORDER BY b LIMIT 1;
+} {2 B two}
+do_execsql_test 12.110 {
+ INSERT INTO t1 VALUES(6, 'F', 'three');
+ INSERT INTO t1 VALUES(7, 'G', 'one');
+ SELECT id, b, lead(c,1) OVER(ORDER BY c) AS x
+ FROM t1 WHERE id>1
+ ORDER BY b LIMIT 2;
+} {2 B two 3 C three}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 13.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a int, b int);
+ INSERT INTO t1 VALUES(1,11);
+ INSERT INTO t1 VALUES(2,12);
+}
+
+do_execsql_test 13.2.1 {
+ SELECT a, rank() OVER(ORDER BY b) FROM t1;
+ SELECT a, rank() OVER(ORDER BY b DESC) FROM t1;
+} {
+ 1 1 2 2 2 1 1 2
+}
+do_execsql_test 13.2.2 {
+ SELECT a, rank() OVER(ORDER BY b) FROM t1
+ UNION ALL
+ SELECT a, rank() OVER(ORDER BY b DESC) FROM t1;
+} {
+ 1 1 2 2 2 1 1 2
+}
+do_execsql_test 13.3 {
+ SELECT a, rank() OVER(ORDER BY b) FROM t1
+ UNION
+ SELECT a, rank() OVER(ORDER BY b DESC) FROM t1;
+} {
+ 1 1 1 2 2 1 2 2
+}
+
+do_execsql_test 13.4 {
+ SELECT a, rank() OVER(ORDER BY b) FROM t1
+ EXCEPT
+ SELECT a, rank() OVER(ORDER BY b DESC) FROM t1;
+} {
+ 1 1 2 2
+}
+
+do_execsql_test 13.5 {
+ SELECT a, rank() OVER(ORDER BY b) FROM t1
+ INTERSECT
+ SELECT a, rank() OVER(ORDER BY b DESC) FROM t1;
+} {}
+
+# 2018-12-06
+# https://www.sqlite.org/src/info/f09fcd17810f65f7
+# Assertion fault when window functions are used.
+#
+# Root cause is the query flattener invoking sqlite3ExprDup() on
+# expressions that contain subqueries with window functions. The
+# sqlite3ExprDup() routine is not making correctly initializing
+# Select.pWin field of the subqueries.
+#
+sqlite3 db :memory:
+do_execsql_test 14.0 {
+ SELECT * FROM(
+ SELECT * FROM (SELECT 1 AS c) WHERE c IN (
+ SELECT (row_number() OVER()) FROM (VALUES (0))
+ )
+ );
+} {1}
+do_execsql_test 14.1 {
+ CREATE TABLE t1(x); INSERT INTO t1(x) VALUES(12345);
+ CREATE TABLE t2(c); INSERT INTO t2(c) VALUES(1);
+ SELECT y, y+1, y+2 FROM (
+ SELECT c IN (
+ SELECT (row_number() OVER()) FROM t1
+ ) AS y FROM t2
+ );
+} {1 2 3}
+
+# 2018-12-31
+# https://www.sqlite.org/src/info/d0866b26f83e9c55
+# Window function in correlated subquery causes assertion fault
+#
+do_catchsql_test 15.0 {
+ WITH t(id, parent) AS (
+ SELECT CAST(1 AS INT), CAST(NULL AS INT)
+ UNION ALL
+ SELECT 2, NULL
+ UNION ALL
+ SELECT 3, 1
+ UNION ALL
+ SELECT 4, 1
+ UNION ALL
+ SELECT 5, 2
+ UNION ALL
+ SELECT 6, 2
+ ), q AS (
+ SELECT t.*, ROW_NUMBER() OVER (ORDER BY t.id) AS rn
+ FROM t
+ WHERE parent IS NULL
+ UNION ALL
+ SELECT t.*, ROW_NUMBER() OVER (ORDER BY t.id) AS rn
+ FROM q
+ JOIN t
+ ON t.parent = q.id
+ )
+ SELECT *
+ FROM q;
+} {1 {cannot use window functions in recursive queries}}
+do_execsql_test 15.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('a'), ('b'), ('c');
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES('X', 1), ('X', 2), ('Y', 2), ('Y', 3);
+ SELECT x, (
+ SELECT sum(b)
+ OVER (PARTITION BY a ROWS BETWEEN UNBOUNDED PRECEDING
+ AND UNBOUNDED FOLLOWING)
+ FROM t2 WHERE b<x
+ ) FROM t1;
+} {a 3 b 3 c 3}
+
+do_execsql_test 15.2 {
+ SELECT(
+ WITH c AS(
+ VALUES(1)
+ ) SELECT '' FROM c,c
+ ) x WHERE x+x;
+} {}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 16.0 {
+ CREATE TABLE t7(a,b);
+ INSERT INTO t7(rowid, a, b) VALUES
+ (1, 1, 3),
+ (2, 10, 4),
+ (3, 100, 2);
+}
+
+do_execsql_test 16.1 {
+ SELECT rowid, sum(a) OVER (PARTITION BY b IN (SELECT rowid FROM t7)) FROM t7;
+} {
+ 2 10
+ 1 101
+ 3 101
+}
+
+do_execsql_test 16.2 {
+ SELECT rowid, sum(a) OVER w1 FROM t7
+ WINDOW w1 AS (PARTITION BY b IN (SELECT rowid FROM t7));
+} {
+ 2 10
+ 1 101
+ 3 101
+}
+
+#-------------------------------------------------------------------------
+do_execsql_test 17.0 {
+ CREATE TABLE t8(a);
+ INSERT INTO t8 VALUES(1), (2), (3);
+}
+
+do_execsql_test 17.1 {
+ SELECT +sum(0) OVER () ORDER BY +sum(0) OVER ();
+} {0}
+
+do_execsql_test 17.2 {
+ select +sum(a) OVER () FROM t8 ORDER BY +sum(a) OVER () DESC;
+} {6 6 6}
+
+do_execsql_test 17.3 {
+ SELECT 10+sum(a) OVER (ORDER BY a)
+ FROM t8
+ ORDER BY 10+sum(a) OVER (ORDER BY a) DESC;
+} {16 13 11}
+
+
+#-------------------------------------------------------------------------
+# Test error cases from chaining window definitions.
+#
+reset_db
+do_execsql_test 18.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
+ INSERT INTO t1 VALUES(1, 'odd', 'one', 1);
+ INSERT INTO t1 VALUES(2, 'even', 'two', 2);
+ INSERT INTO t1 VALUES(3, 'odd', 'three', 3);
+ INSERT INTO t1 VALUES(4, 'even', 'four', 4);
+ INSERT INTO t1 VALUES(5, 'odd', 'five', 5);
+ INSERT INTO t1 VALUES(6, 'even', 'six', 6);
+}
+
+foreach {tn sql error} {
+ 1 {
+ SELECT c, sum(d) OVER win2 FROM t1
+ WINDOW win1 AS (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING),
+ win2 AS (win1 ORDER BY b)
+ } {cannot override frame specification of window: win1}
+
+ 2 {
+ SELECT c, sum(d) OVER win2 FROM t1
+ WINDOW win1 AS (),
+ win2 AS (win4 ORDER BY b)
+ } {no such window: win4}
+
+ 3 {
+ SELECT c, sum(d) OVER win2 FROM t1
+ WINDOW win1 AS (),
+ win2 AS (win1 PARTITION BY d)
+ } {cannot override PARTITION clause of window: win1}
+
+ 4 {
+ SELECT c, sum(d) OVER win2 FROM t1
+ WINDOW win1 AS (ORDER BY b),
+ win2 AS (win1 ORDER BY d)
+ } {cannot override ORDER BY clause of window: win1}
+} {
+ do_catchsql_test 18.1.$tn $sql [list 1 $error]
+}
+
+foreach {tn sql error} {
+ 1 {
+ SELECT c, sum(d) OVER (win1 ORDER BY b) FROM t1
+ WINDOW win1 AS (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
+ } {cannot override frame specification of window: win1}
+
+ 2 {
+ SELECT c, sum(d) OVER (win4 ORDER BY b) FROM t1
+ WINDOW win1 AS ()
+ } {no such window: win4}
+
+ 3 {
+ SELECT c, sum(d) OVER (win1 PARTITION BY d) FROM t1
+ WINDOW win1 AS ()
+ } {cannot override PARTITION clause of window: win1}
+
+ 4 {
+ SELECT c, sum(d) OVER (win1 ORDER BY d) FROM t1
+ WINDOW win1 AS (ORDER BY b)
+ } {cannot override ORDER BY clause of window: win1}
+} {
+ do_catchsql_test 18.2.$tn $sql [list 1 $error]
+}
+
+do_execsql_test 18.3.1 {
+ SELECT group_concat(c, '.') OVER (PARTITION BY b ORDER BY c)
+ FROM t1
+} {four four.six four.six.two five five.one five.one.three}
+
+do_execsql_test 18.3.2 {
+ SELECT group_concat(c, '.') OVER (win1 ORDER BY c)
+ FROM t1
+ WINDOW win1 AS (PARTITION BY b)
+} {four four.six four.six.two five five.one five.one.three}
+
+do_execsql_test 18.3.3 {
+ SELECT group_concat(c, '.') OVER win2
+ FROM t1
+ WINDOW win1 AS (PARTITION BY b),
+ win2 AS (win1 ORDER BY c)
+} {four four.six four.six.two five five.one five.one.three}
+
+do_execsql_test 18.3.4 {
+ SELECT group_concat(c, '.') OVER (win2)
+ FROM t1
+ WINDOW win1 AS (PARTITION BY b),
+ win2 AS (win1 ORDER BY c)
+} {four four.six four.six.two five five.one five.one.three}
+
+do_execsql_test 18.3.5 {
+ SELECT group_concat(c, '.') OVER win5
+ FROM t1
+ WINDOW win1 AS (PARTITION BY b),
+ win2 AS (win1),
+ win3 AS (win2),
+ win4 AS (win3),
+ win5 AS (win4 ORDER BY c)
+} {four four.six four.six.two five five.one five.one.three}
+
+#-------------------------------------------------------------------------
+# Test RANGE <expr> PRECEDING/FOLLOWING when there are string, blob
+# and NULL values in the dataset.
+#
+reset_db
+do_execsql_test 19.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES
+ (1, 1), (2, 2), (3, 3), (4, 4), (5, 5),
+ ('a', 6), ('b', 7), ('c', 8), ('d', 9), ('e', 10);
+}
+do_execsql_test 19.1 {
+ SELECT a, sum(b) OVER (ORDER BY a) FROM t1;
+} {1 1 2 3 3 6 4 10 5 15 a 21 b 28 c 36 d 45 e 55}
+
+do_execsql_test 19.2.1 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1;
+} {1 3 2 6 3 9 4 12 5 9 a 6 b 7 c 8 d 9 e 10}
+do_execsql_test 19.2.2 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY a ASC;
+} {1 3 2 6 3 9 4 12 5 9 a 6 b 7 c 8 d 9 e 10}
+
+do_execsql_test 19.3.1 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 2 PRECEDING AND 1 FOLLOWING
+ ) FROM t1;
+} {1 3 2 6 3 10 4 14 5 12 a 6 b 7 c 8 d 9 e 10}
+do_execsql_test 19.3.2 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 1 PRECEDING AND 2 FOLLOWING
+ ) FROM t1 ORDER BY a ASC;
+} {1 3 2 6 3 10 4 14 5 12 a 6 b 7 c 8 d 9 e 10}
+
+
+reset_db
+do_execsql_test 20.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES
+ (NULL, 100), (NULL, 100),
+ (1, 1), (2, 2), (3, 3), (4, 4), (5, 5),
+ ('a', 6), ('b', 7), ('c', 8), ('d', 9), ('e', 10);
+}
+do_execsql_test 20.1 {
+ SELECT a, sum(b) OVER (ORDER BY a) FROM t1;
+} {
+ {} 200 {} 200 1 201 2 203 3 206 4 210 5 215
+ a 221 b 228 c 236 d 245 e 255
+}
+
+do_execsql_test 20.2.1 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1;
+} {{} 200 {} 200 1 3 2 6 3 9 4 12 5 9 a 6 b 7 c 8 d 9 e 10}
+do_execsql_test 20.2.2 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY a ASC;
+} {{} 200 {} 200 1 3 2 6 3 9 4 12 5 9 a 6 b 7 c 8 d 9 e 10}
+
+do_execsql_test 20.3.1 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 2 PRECEDING AND 1 FOLLOWING
+ ) FROM t1;
+} {{} 200 {} 200 1 3 2 6 3 10 4 14 5 12 a 6 b 7 c 8 d 9 e 10}
+do_execsql_test 20.3.2 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 1 PRECEDING AND 2 FOLLOWING
+ ) FROM t1 ORDER BY a ASC;
+} {{} 200 {} 200 1 3 2 6 3 10 4 14 5 12 a 6 b 7 c 8 d 9 e 10}
+
+#-------------------------------------------------------------------------
+do_execsql_test 21.0 {
+ CREATE TABLE keyword_tab(
+ current, exclude, filter, following, groups, no, others, over,
+ partition, preceding, range, ties, unbounded, window
+ );
+}
+do_execsql_test 21.1 {
+ SELECT
+ current, exclude, filter, following, groups, no, others, over,
+ partition, preceding, range, ties, unbounded, window
+ FROM keyword_tab
+}
+
+#-------------------------------------------------------------------------
+foreach {tn expr err} {
+ 1 4.5 0
+ 2 NULL 1
+ 3 0.0 0
+ 4 0.1 0
+ 5 -0.1 1
+ 6 '' 1
+ 7 '2.0' 0
+ 8 '2.0x' 1
+ 9 x'1234' 1
+ 10 '1.2' 0
+} {
+ set res {0 1}
+ if {$err} {set res {1 {frame starting offset must be a non-negative number}} }
+ do_catchsql_test 22.$tn.1 "
+ WITH a(x, y) AS ( VALUES(1, 2) )
+ SELECT sum(x) OVER (
+ ORDER BY y RANGE BETWEEN $expr PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM a
+ " $res
+
+ set res {0 1}
+ if {$err} {set res {1 {frame ending offset must be a non-negative number}} }
+ do_catchsql_test 22.$tn.2 "
+ WITH a(x, y) AS ( VALUES(1, 2) )
+ SELECT sum(x) OVER (
+ ORDER BY y RANGE BETWEEN UNBOUNDED PRECEDING AND $expr FOLLOWING
+ ) FROM a
+ " $res
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 23.0 {
+ CREATE TABLE t5(a, b, c);
+ CREATE INDEX t5ab ON t5(a, b);
+}
+
+proc do_ordercount_test {tn sql nOrderBy} {
+ set plan [execsql "EXPLAIN QUERY PLAN $sql"]
+ uplevel [list do_test $tn [list regexp -all ORDER $plan] $nOrderBy]
+}
+
+do_ordercount_test 23.1 {
+ SELECT
+ sum(c) OVER (ORDER BY a, b),
+ sum(c) OVER (PARTITION BY a ORDER BY b)
+ FROM t5
+} 0
+
+do_ordercount_test 23.2 {
+ SELECT
+ sum(c) OVER (ORDER BY b, a),
+ sum(c) OVER (PARTITION BY b ORDER BY a)
+ FROM t5
+} 1
+
+do_ordercount_test 23.3 {
+ SELECT
+ sum(c) OVER (ORDER BY b, a),
+ sum(c) OVER (ORDER BY c, b)
+ FROM t5
+} 2
+
+do_ordercount_test 23.4 {
+ SELECT
+ sum(c) OVER (ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (ORDER BY b GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM t5
+} 1
+
+do_ordercount_test 23.5 {
+ SELECT
+ sum(c) OVER (ORDER BY b+1 ROWS UNBOUNDED PRECEDING),
+ sum(c) OVER (ORDER BY b+1 RANGE UNBOUNDED PRECEDING),
+ sum(c) OVER (ORDER BY b+1 GROUPS UNBOUNDED PRECEDING)
+ FROM t5
+} 1
+
+do_ordercount_test 23.6 {
+ SELECT
+ sum(c) OVER (ORDER BY b+1 ROWS UNBOUNDED PRECEDING),
+ sum(c) OVER (ORDER BY b+2 RANGE UNBOUNDED PRECEDING),
+ sum(c) OVER (ORDER BY b+3 GROUPS UNBOUNDED PRECEDING)
+ FROM t5
+} 3
+
+do_execsql_test 24.1 {
+ SELECT sum(44) OVER ()
+} {44}
+
+do_execsql_test 24.2 {
+ SELECT lead(44) OVER ()
+} {{}}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 25.0 {
+ CREATE TABLE t1 ( t1_id INTEGER PRIMARY KEY );
+ CREATE TABLE t2 ( t2_id INTEGER PRIMARY KEY );
+ CREATE TABLE t3 ( t3_id INTEGER PRIMARY KEY );
+
+ INSERT INTO t1 VALUES(1), (3), (5);
+ INSERT INTO t2 VALUES (3), (5);
+ INSERT INTO t3 VALUES(10), (11), (12);
+}
+
+do_execsql_test 25.1 {
+ SELECT t1.* FROM t1, t2 WHERE
+ t1_id=t2_id AND t1_id IN (
+ SELECT t1_id + row_number() OVER ( ORDER BY t1_id ) FROM t3
+ )
+}
+
+do_execsql_test 25.2 {
+ SELECT t1.* FROM t1, t2 WHERE
+ t1_id=t2_id AND t1_id IN (
+ SELECT row_number() OVER ( ORDER BY t1_id ) FROM t3
+ )
+} {3}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 26.0 {
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(c);
+}
+
+do_execsql_test 26.1 {
+ SELECT ( SELECT row_number() OVER () FROM ( SELECT c FROM t1 ) ) FROM t2
+} {}
+
+do_execsql_test 26.2 {
+ INSERT INTO t1 VALUES(1), (2), (3), (4);
+ INSERT INTO t2 VALUES(2), (6), (8), (4);
+ SELECT c, c IN (
+ SELECT row_number() OVER () FROM ( SELECT c FROM t1 )
+ ) FROM t2
+} {2 1 6 0 8 0 4 1}
+
+do_execsql_test 26.3 {
+ DELETE FROM t1;
+ DELETE FROM t2;
+
+ INSERT INTO t2 VALUES(1), (2), (3), (4);
+ INSERT INTO t1 VALUES(1), (1), (2), (3), (3), (3), (3), (4), (4);
+
+ SELECT c, c IN (
+ SELECT row_number() OVER () FROM ( SELECT 1 FROM t1 WHERE x=c )
+ ) FROM t2
+} {1 1 2 0 3 1 4 0}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 27.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(NULL), (1), (2), (3), (4), (5);
+}
+do_execsql_test 27.1 {
+ SELECT min(x) FROM t1;
+} {1}
+do_execsql_test 27.2 {
+ SELECT min(x) OVER win FROM t1
+ WINDOW win AS (ORDER BY rowid ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
+} {1 1 1 2 3 4}
+
+#-------------------------------------------------------------------------
+
+reset_db
+do_execsql_test 28.1.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b CHAR(1), c CHAR(2), d ANY);
+ INSERT INTO t1 VALUES (3, 'C', 'cc', 1.0);
+ INSERT INTO t1 VALUES (13,'M', 'cc', NULL);
+}
+
+do_execsql_test 28.1.2 {
+ SELECT group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS (ORDER BY a RANGE BETWEEN 3 PRECEDING AND 1 PRECEDING)
+} {
+ {} {}
+}
+
+do_execsql_test 28.2.1 {
+ CREATE TABLE t2(a TEXT, b INTEGER);
+ INSERT INTO t2 VALUES('A', NULL);
+ INSERT INTO t2 VALUES('B', NULL);
+}
+
+do_execsql_test 28.2.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b CHAR(1), c CHAR(2), d ANY);
+ INSERT INTO t1 VALUES
+ (10,'J', 'cc', NULL),
+ (11,'K', 'cc', 'xyz'),
+ (13,'M', 'cc', NULL);
+}
+
+do_execsql_test 28.2.2 {
+ SELECT a, b, c, quote(d), group_concat(b,'') OVER w1, '|' FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC RANGE BETWEEN 7.0 PRECEDING AND 2.5 PRECEDING)
+ ORDER BY c, d, a;
+} {
+ 10 J cc NULL JM |
+ 13 M cc NULL JM |
+ 11 K cc 'xyz' K |
+}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 29.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b CHAR(1), c CHAR(2), d ANY);
+ INSERT INTO t1 VALUES
+ (1, 'A', 'aa', 2.5),
+ (2, 'B', 'bb', 3.75),
+ (3, 'C', 'cc', 1.0),
+ (4, 'D', 'cc', 8.25),
+ (5, 'E', 'bb', 6.5),
+ (6, 'F', 'aa', 6.5),
+ (7, 'G', 'aa', 6.0),
+ (8, 'H', 'bb', 9.0),
+ (9, 'I', 'aa', 3.75),
+ (10,'J', 'cc', NULL),
+ (11,'K', 'cc', 'xyz'),
+ (12,'L', 'cc', 'xyZ'),
+ (13,'M', 'cc', NULL);
+}
+
+do_execsql_test 29.2 {
+ SELECT a, b, c, quote(d), group_concat(b,'') OVER w1, '|' FROM t1
+ WINDOW w1 AS
+ (PARTITION BY c ORDER BY d DESC
+ RANGE BETWEEN 7.0 PRECEDING AND 2.5 PRECEDING)
+ ORDER BY c, d, a;
+} {
+ 1 A aa 2.5 FG |
+ 9 I aa 3.75 F |
+ 7 G aa 6 {} |
+ 6 F aa 6.5 {} |
+ 2 B bb 3.75 HE |
+ 5 E bb 6.5 H |
+ 8 H bb 9 {} |
+ 10 J cc NULL JM |
+ 13 M cc NULL JM |
+ 3 C cc 1 {} |
+ 4 D cc 8.25 {} |
+ 12 L cc 'xyZ' L |
+ 11 K cc 'xyz' K |
+}
+
+# 2019-07-18
+# Check-in [7ef7b23cbb1b9ace] (which was itself a fix for ticket
+# https://www.sqlite.org/src/info/1be72aab9) introduced a new problem
+# if the LHS of a BETWEEN operator is a WINDOW function. The problem
+# was found by (the recently enhanced) dbsqlfuzz.
+#
+do_execsql_test 30.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('BB','aa',399);
+ SELECT
+ count () OVER win1 NOT BETWEEN 'a' AND 'mmm',
+ count () OVER win3
+ FROM t1
+ WINDOW win1 AS (ORDER BY a GROUPS BETWEEN 4 PRECEDING AND 1 FOLLOWING
+ EXCLUDE CURRENT ROW),
+ win2 AS (PARTITION BY b ORDER BY a),
+ win3 AS (win2 RANGE BETWEEN 5.2 PRECEDING AND true PRECEDING );
+} {1 1}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 31.1 {
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ CREATE TABLE t3(e, f);
+
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t2 VALUES(1, 1);
+ INSERT INTO t3 VALUES(1, 1);
+}
+
+do_execsql_test 31.2 {
+ SELECT d IN (SELECT sum(c) OVER (ORDER BY e+c) FROM t3) FROM (
+ SELECT * FROM t2
+ );
+} {1}
+
+do_execsql_test 31.3 {
+ SELECT d IN (SELECT sum(c) OVER (PARTITION BY d ORDER BY e+c) FROM t3) FROM (
+ SELECT * FROM t2
+ );
+} {1}
+
+do_catchsql_test 31.3 {
+ SELECT d IN (
+ SELECT sum(c) OVER ( ROWS BETWEEN d FOLLOWING AND UNBOUNDED FOLLOWING)
+ FROM t3
+ )
+ FROM (
+ SELECT * FROM t2
+ );
+} {1 {frame starting offset must be a non-negative integer}}
+
+do_catchsql_test 31.3 {
+ SELECT d IN (
+ SELECT sum(c) OVER ( ROWS BETWEEN CURRENT ROW AND c FOLLOWING)
+ FROM t3
+ )
+ FROM (
+ SELECT * FROM t2
+ );
+} {1 {frame ending offset must be a non-negative integer}}
+
+# 2019-11-16 chromium issue 1025467
+ifcapable altertable {
+ db close
+ sqlite3 db :memory:
+ do_catchsql_test 32.10 {
+ CREATE VIEW a AS SELECT NULL INTERSECT SELECT NULL ORDER BY s() OVER R;
+ CREATE TABLE a0 AS SELECT 0;
+ ALTER TABLE a0 RENAME TO S;
+ } {1 {error in view a: 1st ORDER BY term does not match any column in the result set}}
+}
+
+reset_db
+do_execsql_test 33.1 {
+ CREATE TABLE t1(aa, bb);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(5, 6);
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES(1);
+}
+do_execsql_test 33.2 {
+ SELECT (SELECT DISTINCT sum(aa) OVER() FROM t1 ORDER BY 1), x FROM t2
+ ORDER BY 1;
+} {6 1}
+
+reset_db
+do_execsql_test 34.1 {
+ CREATE TABLE t1(a,b,c);
+}
+do_execsql_test 34.2 {
+ SELECT avg(a) OVER (
+ ORDER BY (SELECT sum(b) OVER ()
+ FROM t1 ORDER BY (
+ SELECT total(d) OVER (ORDER BY c)
+ FROM (SELECT 1 AS d) ORDER BY 1
+ )
+ )
+ )
+ FROM t1;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_catchsql_test 35.0 {
+ SELECT * WINDOW f AS () ORDER BY name COLLATE nocase;
+} {1 {no tables specified}}
+
+do_catchsql_test 35.1 {
+ VALUES(1) INTERSECT SELECT * WINDOW f AS () ORDER BY x COLLATE nocase;
+} {1 {no tables specified}}
+
+do_execsql_test 35.2 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1), (2), (3);
+ VALUES(1) INTERSECT
+ SELECT sum(x) OVER f FROM t1 WINDOW f AS (ORDER BY x) ORDER BY 1;
+} {1}
+
+do_execsql_test 35.3 {
+ VALUES(8) EXCEPT
+ SELECT sum(x) OVER f FROM t1 WINDOW f AS (ORDER BY x) ORDER BY 1;
+} {8}
+
+do_execsql_test 35.4 {
+ VALUES(1) UNION
+ SELECT sum(x) OVER f FROM t1 WINDOW f AS (ORDER BY x) ORDER BY 1;
+} {1 3 6}
+
+# 2019-12-07 gramfuzz find
+#
+do_execsql_test 36.10 {
+ VALUES(count(*)OVER());
+} {1}
+do_execsql_test 36.20 {
+ VALUES(count(*)OVER()),(2);
+} {1 2}
+do_execsql_test 36.30 {
+ VALUES(2),(count(*)OVER());
+} {2 1}
+do_execsql_test 36.40 {
+ VALUES(2),(3),(count(*)OVER()),(4),(5);
+} {2 3 1 4 5}
+
+# 2019-12-17 crash test case found by Yongheng and Rui
+# See check-in 1ca0bd982ab1183b
+#
+reset_db
+do_execsql_test 37.10 {
+ CREATE TABLE t0(a UNIQUE, b PRIMARY KEY);
+ CREATE VIEW v0(c) AS SELECT max((SELECT count(a)OVER(ORDER BY 1))) FROM t0;
+ SELECT c FROM v0 WHERE c BETWEEN 10 AND 20;
+} {}
+do_execsql_test 37.20 {
+ DROP VIEW v0;
+ CREATE VIEW v0(c) AS SELECT max((SELECT count(a)OVER(ORDER BY 1234))) FROM t0;
+ SELECT c FROM v0 WHERE c BETWEEN -10 AND 20;
+} {}
+
+# 2019-12-20 mrigger reported problem with a FILTER clause on an aggregate
+# in a join.
+#
+reset_db
+do_catchsql_test 38.10 {
+ CREATE TABLE t0(c0);
+ CREATE TABLE t1(c0, c1 UNIQUE);
+ INSERT INTO t0(c0) VALUES(1);
+ INSERT INTO t1(c0,c1) VALUES(2,3);
+ SELECT COUNT(*) FROM t0, t1 WHERE (SELECT AVG(0) FILTER(WHERE t1.c1));
+} {1 {misuse of aggregate: AVG()}}
+do_execsql_test 38.20 {
+ SELECT COUNT(*), AVG(1) FILTER(WHERE t1.c1) FROM t0, t1;
+} {1 1.0}
+do_catchsql_test 38.30 {
+ SELECT COUNT(*) FROM t0, t1 WHERE (SELECT AVG(1) FILTER(WHERE t1.c1));
+} {1 {misuse of aggregate: AVG()}}
+
+reset_db
+do_execsql_test 39.1 {
+ CREATE TABLE t0(c0 UNIQUE);
+}
+do_execsql_test 39.2 {
+ SELECT FIRST_VALUE(0) OVER();
+} {0}
+do_execsql_test 39.3 {
+ SELECT * FROM t0 WHERE(c0, 0) IN(SELECT FIRST_VALUE(0) OVER(), 0);
+}
+do_execsql_test 39.4 {
+ SELECT * FROM t0 WHERE (t0.c0, 1) IN(SELECT NTILE(1) OVER(), 0 FROM t0);
+}
+
+ifcapable rtree {
+ # 2019-12-25 ticket d87336c81c7d0873
+ #
+ reset_db
+ do_catchsql_test 40.1 {
+ CREATE VIRTUAL TABLE t0 USING rtree(c0, c1, c2);
+ SELECT * FROM t0
+ WHERE ((0,0) IN (SELECT COUNT(*),LAG(5)OVER(PARTITION BY 0) FROM t0),0)<=(c1,0);
+ } {0 {}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 41.1 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(NULL,'bb',355);
+ INSERT INTO t1 VALUES('CC','aa',158);
+ INSERT INTO t1 VALUES('GG','bb',929);
+ INSERT INTO t1 VALUES('FF','Rb',574);
+}
+
+do_execsql_test 41.2 {
+ SELECT min(c) OVER (
+ ORDER BY a RANGE BETWEEN 5.2 PRECEDING AND 0.1 PRECEDING
+ ) FROM t1
+} {355 158 574 929}
+
+do_execsql_test 41.2 {
+ SELECT min(c) OVER (
+ ORDER BY a RANGE BETWEEN 5.2 PRECEDING AND 0.1 PRECEDING
+ ) << 100 FROM t1
+} {0 0 0 0}
+
+do_execsql_test 41.3 {
+ SELECT
+ min(c) OVER win3 << first_value(c) OVER win3,
+ min(c) OVER win3 << first_value(c) OVER win3
+ FROM t1
+ WINDOW win3 AS (
+ PARTITION BY 6 ORDER BY a RANGE BETWEEN 5.2 PRECEDING AND 0.1 PRECEDING
+ );
+} {0 0 0 0 0 0 0 0}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 42.1 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 1, 1);
+ INSERT INTO t1 VALUES(2, 2, 2);
+}
+do_execsql_test 42.2 {
+ SELECT * FROM t1 WHERE (0, 0) IN ( SELECT count(*), 0 FROM t1 )
+} {}
+do_execsql_test 42.3 {
+ SELECT * FROM t1 WHERE (2, 0) IN ( SELECT count(*), 0 FROM t1 )
+} {1 1 1 2 2 2}
+
+do_execsql_test 42.3 {
+ SELECT count(*), max(a) OVER () FROM t1 GROUP BY c;
+} {1 2 1 2}
+
+do_execsql_test 42.4 {
+ SELECT sum(a), max(b) OVER () FROM t1;
+} {3 1}
+
+do_execsql_test 42.5 {
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2 VALUES('a', 1);
+ INSERT INTO t2 VALUES('a', 2);
+ INSERT INTO t2 VALUES('a', 3);
+ INSERT INTO t2 VALUES('b', 4);
+ INSERT INTO t2 VALUES('b', 5);
+ INSERT INTO t2 VALUES('b', 6);
+}
+
+do_execsql_test 42.6 {
+ SELECT a, sum(b), sum( sum(b) ) OVER (ORDER BY a) FROM t2 GROUP BY a;
+} {a 6 6 b 15 21}
+
+do_execsql_test 42.7 {
+ SELECT sum(b), sum( sum(b) ) OVER (ORDER BY a) FROM t2;
+} {21 21}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 43.1.1 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES (10);
+}
+do_catchsql_test 43.1.2 {
+ SELECT count() OVER() AS m FROM t1 ORDER BY (SELECT m);
+} {1 {misuse of aliased window function m}}
+
+reset_db
+do_execsql_test 43.2.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER);
+ INSERT INTO t1(a, b) VALUES(1, 10); -- 10
+ INSERT INTO t1(a, b) VALUES(2, 15); -- 25
+ INSERT INTO t1(a, b) VALUES(3, -5); -- 20
+ INSERT INTO t1(a, b) VALUES(4, -5); -- 15
+ INSERT INTO t1(a, b) VALUES(5, 20); -- 35
+ INSERT INTO t1(a, b) VALUES(6, -11); -- 24
+}
+
+do_execsql_test 43.2.2 {
+ SELECT a, sum(b) OVER (ORDER BY a) AS abc FROM t1 ORDER BY 2
+} {
+ 1 10 4 15 3 20 6 24 2 25 5 35
+}
+
+do_execsql_test 43.2.3 {
+ SELECT a, sum(b) OVER (ORDER BY a) AS abc FROM t1 ORDER BY abc
+} {
+ 1 10 4 15 3 20 6 24 2 25 5 35
+}
+
+do_execsql_test 43.2.4 {
+ SELECT a, sum(b) OVER (ORDER BY a) AS abc FROM t1 ORDER BY abc+5
+} {
+ 1 10 4 15 3 20 6 24 2 25 5 35
+}
+
+do_catchsql_test 43.2.5 {
+ SELECT a, sum(b) OVER (ORDER BY a) AS abc FROM t1 ORDER BY (SELECT abc)
+} {1 {misuse of aliased window function abc}}
+
+do_catchsql_test 43.2.6 {
+ SELECT a, 1+sum(b) OVER (ORDER BY a) AS abc FROM t1 ORDER BY (SELECT abc)
+} {1 {misuse of aliased window function abc}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 44.1 {
+ CREATE TABLE t0(c0);
+}
+
+do_catchsql_test 44.2.1 {
+ SELECT ntile(0) OVER ();
+} {1 {argument of ntile must be a positive integer}}
+do_catchsql_test 44.2.2 {
+ SELECT (0, 0) IN(SELECT MIN(c0), NTILE(0) OVER()) FROM t0;
+} {1 {argument of ntile must be a positive integer}}
+
+do_execsql_test 44.3.1 {
+ SELECT ntile(1) OVER ();
+} {1}
+do_execsql_test 44.3.2 {
+ SELECT (0, 0) IN(SELECT MIN(c0), NTILE(1) OVER()) FROM t0;
+} {0}
+
+do_execsql_test 44.4.2 {
+ INSERT INTO t0 VALUES(2), (1), (0);
+ SELECT (0, 1) IN(SELECT MIN(c0), NTILE(1) OVER()) FROM t0;
+} {1}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 45.1 {
+ CREATE TABLE t0(x);
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1000);
+ INSERT INTO t1 VALUES(1000);
+ INSERT INTO t0 VALUES(10000);
+}
+do_execsql_test 45.2 {
+ SELECT * FROM (
+ SELECT sum (a) OVER() FROM t1 UNION ALL SELECT x FROM t0
+ );
+} {2000 2000 10000}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 46.1 {
+ CREATE TABLE t1 (a);
+ CREATE INDEX i1 ON t1(a);
+
+ INSERT INTO t1 VALUES (10);
+}
+
+do_execsql_test 46.2 {
+ SELECT (SELECT sum(a) OVER(ORDER BY a)) FROM t1
+} 10
+
+do_execsql_test 46.3 {
+ SELECT * FROM t1 WHERE (SELECT sum(a) OVER(ORDER BY a));
+} 10
+
+do_execsql_test 46.4 {
+ SELECT * FROM t1 NATURAL JOIN t1
+ WHERE a=1
+ OR ((SELECT sum(a)OVER(ORDER BY a)) AND a<=10)
+} 10
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 47.0 {
+ CREATE TABLE t1(
+ a,
+ e,
+ f,
+ g UNIQUE,
+ h UNIQUE
+ );
+}
+
+do_execsql_test 47.1 {
+ CREATE VIEW t2(k) AS
+ SELECT e FROM t1 WHERE g = 'abc' OR h BETWEEN 10 AND f;
+}
+
+do_catchsql_test 47.2 {
+ SELECT 234 FROM t2
+ WHERE k=1
+ OR (SELECT k FROM t2 WHERE (SELECT sum(a) OVER() FROM t1 GROUP BY 1));
+} {1 {misuse of window function sum()}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 48.0 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ SELECT (SELECT max(x)OVER(ORDER BY x) + min(x)OVER(ORDER BY x))
+ FROM (SELECT (SELECT sum(a) FROM t1) AS x FROM t1);
+} {12 12 12}
+
+do_execsql_test 48.1 {
+ SELECT (SELECT max(x)OVER(ORDER BY x) + min(x)OVER(ORDER BY x))
+ FROM (SELECT (SELECT sum(a) FROM t1 GROUP BY a) AS x FROM t1);
+} {2 2 2}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 49.1 {
+ CREATE TABLE t1 (a PRIMARY KEY);
+ INSERT INTO t1 VALUES(1);
+}
+
+do_execsql_test 49.2 {
+ SELECT b AS c FROM (
+ SELECT a AS b FROM (
+ SELECT a FROM t1 WHERE a=1 OR (SELECT sum(a) OVER ())
+ )
+ WHERE b=1 OR b<10
+ )
+ WHERE c=1 OR c>=10;
+} {1}
+
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 50.0 {
+ CREATE TABLE t1 (a DOUBLE PRIMARY KEY);
+ INSERT INTO t1 VALUES(10.0);
+}
+
+do_execsql_test 50.1 {
+ SELECT * FROM t1 WHERE a%1 OR (SELECT sum(a) OVER (ORDER BY a%2))
+} {10.0}
+
+do_execsql_test 50.2 {
+ SELECT * FROM (
+ SELECT * FROM t1 WHERE a%1 OR (SELECT sum(a) OVER (ORDER BY a%2))
+ )
+ WHERE a=1 OR ( (SELECT sum(a) OVER (ORDER BY a%4)) AND a<=10 )
+} {10.0}
+
+do_execsql_test 50.3 {
+ SELECT a FROM (
+ SELECT * FROM (
+ SELECT * FROM t1 WHERE a%1 OR (SELECT sum(a) OVER (ORDER BY a%2))
+ )
+ WHERE a=1 OR ( (SELECT sum(a) OVER (ORDER BY a%4)) AND a<=10 )
+ )
+ WHERE a=1 OR a=10.0
+} {10.0}
+
+do_execsql_test 50.4 {
+ SELECT a FROM (
+ SELECT * FROM (
+ SELECT * FROM t1 WHERE a%1 OR (SELECT sum(a) OVER (ORDER BY a%2))
+ )
+ WHERE a=1 OR ( (SELECT sum(a) OVER (ORDER BY a%4)) AND a<=10 )
+ )
+ WHERE a=1 OR ((SELECT sum(a) OVER(ORDER BY a%8)) AND 10<=a)
+} {10.0}
+
+do_execsql_test 50.5 {
+SELECT * FROM (SELECT * FROM t1 NATURAL JOIN t1 WHERE a%1 OR ((SELECT sum(a)OVER(ORDER BY a)) AND a<=10)) NATURAL JOIN t1 WHERE a=1 OR ((SELECT sum((SELECT * FROM (SELECT * FROM (SELECT * FROM t1 NATURAL JOIN t1 WHERE a%1 OR ((SELECT sum(a)OVER(ORDER BY a)) AND a<=10)) NATURAL JOIN t1 WHERE a=1 OR ((SELECT sum((SELECT * FROM t1 NATURAL JOIN t1 WHERE a=1 OR ((SELECT sum(a)OVER(ORDER BY a)) AND a<=10)))OVER(ORDER BY a% 1 )) AND a<=10)) NATURAL JOIN t1 WHERE a=1 OR ((SELECT sum(a)OVER(ORDER BY a)) AND 10<=a)))OVER(ORDER BY a%5)) AND a<=10);
+} {10.0}
+
+# 2020-04-03 ticket af4556bb5c285c08
+#
+reset_db
+do_catchsql_test 51.1 {
+ CREATE TABLE a(b, c);
+ SELECT c FROM a GROUP BY c
+ HAVING(SELECT(sum(b) OVER(ORDER BY b),
+ sum(b) OVER(PARTITION BY min(DISTINCT c), c ORDER BY b)));
+} {1 {row value misused}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 52.1 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES('AA','bb',356);
+ INSERT INTO t1 VALUES('CC','aa',158);
+ INSERT INTO t1 VALUES('BB','aa',399);
+ INSERT INTO t1 VALUES('FF','bb',938);
+}
+
+do_execsql_test 52.2 {
+ SELECT
+ count() OVER win1,
+ sum(c) OVER win2,
+ first_value(c) OVER win2,
+ count(a) OVER (ORDER BY b)
+ FROM t1
+ WINDOW
+ win1 AS (ORDER BY a),
+ win2 AS (PARTITION BY 6 ORDER BY a
+ RANGE BETWEEN 5 PRECEDING AND 0 PRECEDING );
+} {
+ 1 356 356 4
+ 2 399 399 2
+ 3 158 158 2
+ 4 938 938 4
+}
+
+do_execsql_test 52.3 {
+SELECT
+ count() OVER (),
+ sum(c) OVER win2,
+ first_value(c) OVER win2,
+ count(a) OVER (ORDER BY b)
+FROM t1
+WINDOW
+ win1 AS (ORDER BY a),
+ win2 AS (PARTITION BY 6 COLLATE binary ORDER BY a
+ RANGE BETWEEN 5 PRECEDING AND 0 PRECEDING );
+} {
+ 4 356 356 4
+ 4 399 399 2
+ 4 158 158 2
+ 4 938 938 4
+}
+
+do_execsql_test 52.4 {
+ SELECT
+ count() OVER win1,
+ sum(c) OVER win2,
+ first_value(c) OVER win2,
+ count(a) OVER (ORDER BY b)
+ FROM t1
+ WINDOW
+ win1 AS (ORDER BY a),
+ win2 AS (PARTITION BY 6 COLLATE binary ORDER BY a
+ RANGE BETWEEN 5 PRECEDING AND 0 PRECEDING );
+} {
+ 1 356 356 4
+ 2 399 399 2
+ 3 158 158 2
+ 4 938 938 4
+}
+
+# 2020-05-23
+# ticket 7a5279a25c57adf1
+#
+reset_db
+do_execsql_test 53.0 {
+ CREATE TABLE a(c UNIQUE);
+ INSERT INTO a VALUES(4),(0),(9),(-9);
+ SELECT a.c
+ FROM a
+ JOIN a AS b ON a.c=4
+ JOIN a AS e ON a.c=e.c
+ WHERE a.c=(SELECT (SELECT coalesce(lead(2) OVER(),0) + sum(d.c))
+ FROM a AS d
+ WHERE a.c);
+} {4 4 4 4}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 54.1 {
+ CREATE TABLE t1(a VARCHAR(20), b FLOAT);
+ INSERT INTO t1 VALUES('1',10.0);
+}
+
+do_catchsql_test 54.2 {
+ SELECT * FROM (
+ SELECT sum(b) OVER() AS c FROM t1
+ UNION
+ SELECT b AS c FROM t1
+ ) WHERE c>10;
+} {0 {}}
+
+do_execsql_test 54.3 {
+ INSERT INTO t1 VALUES('2',5.0);
+ INSERT INTO t1 VALUES('3',15.0);
+}
+
+do_catchsql_test 54.4 {
+ SELECT * FROM (
+ SELECT sum(b) OVER() AS c FROM t1
+ UNION
+ SELECT b AS c FROM t1
+ ) WHERE c>10;
+} {0 {15.0 30.0}}
+
+# 2020-06-05 ticket c8d3b9f0a750a529
+reset_db
+do_execsql_test 55.1 {
+ CREATE TABLE a(b);
+ SELECT
+ (SELECT b FROM a
+ GROUP BY b
+ HAVING (SELECT COUNT()OVER() + lead(b)OVER(ORDER BY SUM(DISTINCT b) + b))
+ )
+ FROM a
+ UNION
+ SELECT 99
+ ORDER BY 1;
+} {99}
+
+#------------------------------------------------------------------------
+reset_db
+do_execsql_test 56.1 {
+ CREATE TABLE t1(a, b INTEGER);
+ CREATE TABLE t2(c, d);
+}
+do_catchsql_test 56.2 {
+ SELECT avg(b) FROM t1
+ UNION ALL
+ SELECT min(c) OVER () FROM t2
+ ORDER BY nosuchcolumn;
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+reset_db
+do_execsql_test 57.1 {
+ CREATE TABLE t4(a, b, c, d, e);
+}
+
+do_catchsql_test 57.2 {
+ SELECT b FROM t4
+ UNION
+ SELECT a FROM t4
+ ORDER BY (
+ SELECT sum(x) OVER() FROM (
+ SELECT c AS x FROM t4
+ UNION
+ SELECT d FROM t4
+ ORDER BY (SELECT e FROM t4)
+ )
+ );
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+# 2020-06-06 various dbsqlfuzz finds and
+# ticket 0899cf62f597d7e7
+#
+reset_db
+do_execsql_test 57.1 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(NULL,NULL,NULL);
+ SELECT
+ sum(a),
+ min(b) OVER (),
+ count(c) OVER (ORDER BY b)
+ FROM t1;
+} {{} {} 0}
+do_execsql_test 57.2 {
+ CREATE TABLE v0 ( v1 INTEGER PRIMARY KEY ) ;
+ INSERT INTO v0 VALUES ( 10 ) ;
+ SELECT DISTINCT v1, lead(v1) OVER() FROM v0 GROUP BY v1 ORDER BY 2;
+} {10 {}}
+do_catchsql_test 57.3 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a);
+ INSERT INTO t1(a) VALUES(22);
+ CREATE TABLE t3(y);
+ INSERT INTO t3(y) VALUES(5),(11),(-9);
+ SELECT (
+ SELECT max(y) OVER( ORDER BY (SELECT x FROM (SELECT sum(y) AS x FROM t1)))
+ )
+ FROM t3;
+} {1 {misuse of aggregate: sum()}}
+
+# 2020-06-06 ticket 1f6f353b684fc708
+reset_db
+do_execsql_test 58.1 {
+ CREATE TABLE a(a, b, c);
+ INSERT INTO a VALUES(1, 2, 3);
+ INSERT INTO a VALUES(4, 5, 6);
+ SELECT sum(345+b) OVER (ORDER BY b),
+ sum(avg(678)) OVER (ORDER BY c) FROM a;
+} {347 678.0}
+
+# 2020-06-06 ticket e5504e987e419fb0
+do_catchsql_test 59.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES (123);
+ SELECT
+ ntile( (SELECT sum(x)) ) OVER(ORDER BY x),
+ min(x) OVER(ORDER BY x)
+ FROM t1;
+} {1 {misuse of aggregate: sum()}}
+
+# 2020-06-07 ticket f7d890858f361402
+do_execsql_test 60.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1 (x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES (99);
+ SELECT EXISTS(SELECT count(*) OVER() FROM t1 ORDER BY sum(x) OVER());
+} {1}
+
+# 2020-06-07 test case generated by dbsqlfuzz showing how an AggInfo
+# object might be referenced after the sqlite3Select() call that created
+# it returns. This proves the need to persist all AggInfo objects until
+# the Parse object is destroyed.
+#
+reset_db
+do_catchsql_test 61.1 {
+CREATE TABLE t1(a);
+INSERT INTO t1 VALUES(5),(NULL),('seventeen');
+SELECT (SELECT max(x)OVER(ORDER BY x) % min(x)OVER(ORDER BY CASE x WHEN 889 THEN x WHEN x THEN x END)) FROM (SELECT (SELECT sum(CAST(a IN(SELECT (SELECT max(x)OVER(ORDER BY CASE x WHEN 889 THEN 299 WHEN 863 THEN 863 END)) FROM (SELECT (SELECT sum(CAST((SELECT (SELECT max(x)OVER(ORDER BY x) / min(x)OVER(ORDER BY CASE x WHEN 889 THEN 299 WHEN -true THEN 863 END)) FROM (SELECT (SELECT sum(CAST(a IN(SELECT (SELECT max(x) & sum ( a )OVER(ORDER BY CASE x WHEN -8 THEN 299 WHEN 863 THEN 863 END)) FROM (SELECT (SELECT sum(CAST(a AS )) FROM t1) AS x FROM t1)) AS t1 )) FROM t1) AS x FROM t1)) AS x )) FROM t1) AS x FROM t1)) AS real)) FROM t1) AS x FROM t1);
+} {0 {{} {} {}}}
+
+foreach tn {1 2} {
+ if {$tn==2} { optimization_control db query-flattener 0 }
+ do_catchsql_test 61.2.$tn {
+ SELECT
+ (SELECT max(x)OVER(ORDER BY x) / min(x) OVER() )
+ FROM (
+ SELECT (SELECT sum(a) FROM t1 ) AS x FROM t1
+ )
+
+ } {0 {1.0 1.0 1.0}}
+}
+
+reset_db
+optimization_control db all 0
+do_execsql_test 61.3.0 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(y);
+}
+
+do_execsql_test 61.3.1 {
+ SELECT (
+ SELECT count(a) OVER ( ORDER BY (SELECT sum(y) FROM t2) )
+ + total(a) OVER()
+ )
+ FROM t1
+} {}
+do_execsql_test 61.4.2 {
+ SELECT (
+ SELECT count(a) OVER ( ORDER BY sum(a) )
+ + total(a) OVER()
+ )
+ FROM t1
+} {0.0}
+
+do_catchsql_test 61.4.3 {
+ SELECT
+ sum(a) OVER ( ORDER BY a )
+ FROM t1
+ ORDER BY (SELECT sum(a) FROM t2)
+} {1 {misuse of aggregate: sum()}}
+do_execsql_test 61.4.4 {
+ SELECT
+ sum(a) OVER ( ORDER BY a )
+ FROM t1
+ ORDER BY (SELECT sum(y) FROM t2)
+}
+
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 62.1 {
+ CREATE TABLE t1(a VARCHAR(20), b FLOAT);
+ INSERT INTO t1 VALUES('1',10.0);
+}
+
+do_execsql_test 62.2 {
+ SELECT * FROM (
+ SELECT sum(b) OVER() AS c FROM t1
+ UNION
+ SELECT b AS c FROM t1
+ ) WHERE c>10;
+}
+
+do_execsql_test 62.3 {
+ INSERT INTO t1 VALUES('2',5.0);
+ INSERT INTO t1 VALUES('3',15.0);
+}
+
+do_execsql_test 62.4 {
+ SELECT * FROM (
+ SELECT sum(b) OVER() AS c FROM t1
+ UNION
+ SELECT b AS c FROM t1
+ ) WHERE c>10;
+} {15.0 30.0}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 63.1 {
+ CREATE TABLE t1(b, x);
+ CREATE TABLE t2(c, d);
+ CREATE TABLE t3(e, f);
+}
+
+do_execsql_test 63.2 {
+ SELECT max(b) OVER(
+ ORDER BY SUM(
+ (SELECT c FROM t2 UNION SELECT x ORDER BY c)
+ )
+ ) FROM t1;
+} {{}}
+
+do_execsql_test 63.3 {
+ SELECT sum(b) over(
+ ORDER BY (
+ SELECT max(b) OVER(
+ ORDER BY sum(
+ (SELECT x AS c UNION SELECT 1234 ORDER BY c)
+ )
+ ) AS e
+ ORDER BY e
+ )
+ )
+ FROM t1;
+} {{}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 64.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 'abcd');
+ INSERT INTO t1 VALUES(2, 'BCDE');
+ INSERT INTO t1 VALUES(3, 'cdef');
+ INSERT INTO t1 VALUES(4, 'DEFG');
+}
+
+do_execsql_test 64.2 {
+ SELECT rowid, max(b COLLATE nocase)||''
+ FROM t1
+ GROUP BY rowid
+ ORDER BY max(b COLLATE nocase)||'';
+} {1 abcd 2 BCDE 3 cdef 4 DEFG}
+
+do_execsql_test 64.3 {
+ SELECT count() OVER (), rowid, max(b COLLATE nocase)||''
+ FROM t1
+ GROUP BY rowid
+ ORDER BY max(b COLLATE nocase)||'';
+} {4 1 abcd 4 2 BCDE 4 3 cdef 4 4 DEFG}
+
+do_execsql_test 64.4 {
+ SELECT count() OVER (), rowid, max(b COLLATE nocase)
+ FROM t1
+ GROUP BY rowid
+ ORDER BY max(b COLLATE nocase);
+} {4 1 abcd 4 2 BCDE 4 3 cdef 4 4 DEFG}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 65.1 {
+ CREATE TABLE t1(c1);
+ INSERT INTO t1 VALUES('abcd');
+}
+do_execsql_test 65.2 {
+ SELECT max(c1 COLLATE nocase) IN (SELECT 'aBCd') FROM t1;
+} {1}
+
+do_execsql_test 65.3 {
+ SELECT
+ count() OVER (),
+ group_concat(c1 COLLATE nocase) IN (SELECT 'aBCd') FROM t1;
+} {1 1}
+
+do_execsql_test 65.4 {
+ SELECT COUNT() OVER () LIKE lead(102030) OVER(
+ ORDER BY sum('abcdef' COLLATE nocase) IN (SELECT 54321)
+ )
+ FROM t1;
+} {{}}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 66.1 {
+ CREATE TABLE t1(a INTEGER);
+ INSERT INTO t1 VALUES(3578824042033200656);
+ INSERT INTO t1 VALUES(3029012920382354029);
+}
+
+foreach {tn spec} {
+ 1 "ORDER BY a RANGE BETWEEN 0.3 PRECEDING AND 10 FOLLOWING"
+ 2 "ORDER BY a RANGE BETWEEN 0.3 PRECEDING AND 0.1 PRECEDING"
+ 3 "ORDER BY a RANGE BETWEEN 0.3 FOLLOWING AND 10 FOLLOWING"
+ 4 "ORDER BY a DESC RANGE BETWEEN 0.3 PRECEDING AND 10 FOLLOWING"
+ 5 "ORDER BY a NULLS LAST RANGE BETWEEN 0.3 PRECEDING AND 10 FOLLOWING"
+ 6 "ORDER BY a RANGE BETWEEN 1.0 PRECEDING AND 2.0 PRECEDING"
+} {
+ do_execsql_test 66.2.$tn "
+ SELECT total(a) OVER ( $spec ) FROM t1 ORDER BY a
+ " {
+ 3.02901292038235e+18 3.5788240420332e+18
+ }
+}
+
+
+do_execsql_test 66.3 {
+ CREATE TABLE t2(a INTEGER);
+ INSERT INTO t2 VALUES(45);
+ INSERT INTO t2 VALUES(30);
+}
+
+foreach {tn spec res} {
+ 1 "ORDER BY a RANGE BETWEEN 0.3 PRECEDING AND 10 FOLLOWING" {30.0 45.0}
+ 2 "ORDER BY a RANGE BETWEEN 0.3 PRECEDING AND 0.1 PRECEDING" {0.0 0.0}
+ 3 "ORDER BY a RANGE BETWEEN 0.3 FOLLOWING AND 10 FOLLOWING" {0.0 0.0}
+ 4 "ORDER BY a DESC RANGE BETWEEN 0.3 PRECEDING AND 10 FOLLOWING" {30.0 45.0}
+ 5 "ORDER BY a NULLS LAST RANGE BETWEEN 0.3 PRECEDING AND 10 FOLLOWING" {30.0 45.0}
+ 6 "ORDER BY a RANGE BETWEEN 1.0 PRECEDING AND 2.0 PRECEDING" {0.0 0.0}
+} {
+ do_execsql_test 66.2.$tn "
+ SELECT total(a) OVER ( $spec ) FROM t2 ORDER BY a
+ " $res
+}
+
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 67.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE TABLE t2(a, b, c);
+}
+
+do_catchsql_test 67.1 {
+ SELECT a,c,b FROM t1 INTERSECT SELECT a,b,c FROM t1 ORDER BY (
+ SELECT nth_value(a,2) OVER w1
+ WINDOW w1 AS ( ORDER BY ((SELECT 1 FROM v1)) )
+ )
+} {1 {no such table: v1}}
+
+do_catchsql_test 67.2 {
+ SELECT a,c,b FROM t1 INTERSECT SELECT a,b,c FROM t1 ORDER BY (
+ SELECT nth_value(a,2) OVER w1
+ WINDOW w1 AS ( ORDER BY ((SELECT 1 FROM t2)) )
+ )
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+# 2021-05-07
+# Do not allow aggregate functions in the ORDER BY clause even if
+# there are window functions in the result set.
+# Forum: /forumpost/540fdfef77
+#
+reset_db
+do_catchsql_test 68.0 {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1(a,b) VALUES(0,0),(1,1),(2,4),(3,9),(4,99);
+ SELECT rowid, a, b, sum(a)OVER() FROM t1 ORDER BY count(b);
+} {1 {misuse of aggregate: count()}}
+
+# 2021-05-22
+# Forum https://sqlite.org/forum/forumpost/7e484e225c
+#
+reset_db
+do_catchsql_test 69.0 {
+ CREATE TABLE t1(a,b);
+ CREATE INDEX t1ba ON t1(b,a);
+ SELECT * FROM t1 WHERE b = (SELECT b FROM t1 ORDER BY lead(b) OVER () AND sum(a));
+} {1 {misuse of aggregate: sum()}}
+do_catchsql_test 69.1 {
+ SELECT * FROM t1 WHERE b >= (SELECT b FROM t1 ORDER BY lead(b) OVER () AND sum(a));
+} {1 {misuse of aggregate: sum()}}
+do_catchsql_test 69.2 {
+ SELECT * FROM t1 WHERE b <= (SELECT b FROM t1 ORDER BY lead(b) OVER () AND sum(a));
+} {1 {misuse of aggregate: sum()}}
+
+# 2021-06-23
+# Forum https://sqlite.org/forum/forumpost/31e0432608
+#
+reset_db
+do_execsql_test 70.0 {
+ CREATE TABLE t1(a);
+}
+do_execsql_test 70.1 {
+ SELECT substr(a,4,lag(a,7) OVER(PARTITION BY 'cf23' ORDER BY 2)) AS ca0 FROM t1 ORDER BY ca0;
+}
+do_execsql_test 70.2 {
+ SELECT substr(a,4,lag(a,7) OVER(PARTITION BY 'cf23' ORDER BY likely(2))) AS ca0 FROM t1 ORDER BY ca0;
+}
+
+# 2021-11-07
+# Bug report from Wang Ke
+# https://sqlite.org/forum/forumpost/9ba4f60ff8
+reset_db
+do_catchsql_test 71.0 {
+ CREATE TABLE t0(a);
+ SELECT a FROM t0, (SELECT a AS b FROM t0)
+ WHERE (a,1)=(SELECT 2,2 UNION SELECT sum(b),max(b) OVER(ORDER BY b) ORDER BY 2)
+ AND b=4
+ ORDER BY b;
+} {/1 {.*}/}
+
+do_execsql_test 72.1 {
+ CREATE TABLE dual(dummy); INSERT INTO dual VALUES('X');
+ CREATE VIEW v1(x,y) AS SELECT RANK() OVER (PARTITION BY 0), SUM(0) FROM dual;
+ SELECT * FROM v1 WHERE true;
+} {1 0}
+
+finish_test
diff --git a/test/window2.tcl b/test/window2.tcl
new file mode 100644
index 0000000..4c18b79
--- /dev/null
+++ b/test/window2.tcl
@@ -0,0 +1,494 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+source [file join [file dirname $argv0] pg_common.tcl]
+
+#=========================================================================
+
+
+start_test window2 "2018 May 19"
+
+ifcapable !windowfunc
+
+execsql_test 1.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
+ INSERT INTO t1 VALUES(1, 'odd', 'one', 1);
+ INSERT INTO t1 VALUES(2, 'even', 'two', 2);
+ INSERT INTO t1 VALUES(3, 'odd', 'three', 3);
+ INSERT INTO t1 VALUES(4, 'even', 'four', 4);
+ INSERT INTO t1 VALUES(5, 'odd', 'five', 5);
+ INSERT INTO t1 VALUES(6, 'even', 'six', 6);
+}
+
+execsql_test 1.1 {
+ SELECT c, sum(d) OVER (PARTITION BY b ORDER BY c) FROM t1;
+}
+
+execsql_test 1.2 {
+ SELECT sum(d) OVER () FROM t1;
+}
+
+execsql_test 1.3 {
+ SELECT sum(d) OVER (PARTITION BY b) FROM t1;
+}
+
+==========
+execsql_test 2.1 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1000 PRECEDING AND 1 FOLLOWING
+ ) FROM t1
+}
+execsql_test 2.2 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1000 PRECEDING AND 1000 FOLLOWING
+ ) FROM t1
+}
+execsql_test 2.3 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 1000 FOLLOWING
+ ) FROM t1
+}
+execsql_test 2.4 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1
+}
+execsql_test 2.5 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 0 FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.6 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.7 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 0 PRECEDING AND 0 FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.8 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.9 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.10 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.11 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 2 PRECEDING AND CURRENT ROW
+ ) FROM t1
+}
+
+execsql_test 2.13 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.14 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 3 PRECEDING AND 1 PRECEDING
+ ) FROM t1
+}
+
+execsql_test 2.15 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 0 PRECEDING
+ ) FROM t1
+}
+
+execsql_test 2.16 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
+ ) FROM t1
+}
+
+execsql_test 2.17 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING
+ ) FROM t1
+}
+
+execsql_test 2.18 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING
+ ) FROM t1
+}
+
+execsql_test 2.19 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 FOLLOWING AND 3 FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.20 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.21 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.22 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.23 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.24 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY a%2
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.25 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.26 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 2.27 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t1
+}
+
+execsql_test 2.28 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t1
+}
+
+execsql_test 2.29 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+execsql_test 2.30 {
+ SELECT a, sum(d) OVER (
+ ORDER BY b
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 3.1 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b ORDER BY d
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 3.2 {
+ SELECT a, sum(d) OVER (
+ ORDER BY b
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 3.3 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+}
+
+execsql_test 3.4 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d/2
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t1
+}
+
+#puts $::fd finish_test
+
+==========
+
+execsql_test 4.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
+ INSERT INTO t2(a, b) VALUES
+ (1,0), (2,74), (3,41), (4,74), (5,23), (6,99), (7,26), (8,33), (9,2),
+ (10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
+ (18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
+ (26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
+ (34,23), (35,16), (36,16), (37,93), (38,65), (39,35), (40,47), (41,7),
+ (42,86), (43,74), (44,61), (45,91), (46,85), (47,24), (48,85), (49,43),
+ (50,59), (51,12), (52,32), (53,56), (54,3), (55,91), (56,22), (57,90),
+ (58,55), (59,15), (60,28), (61,89), (62,25), (63,47), (64,1), (65,56),
+ (66,40), (67,43), (68,56), (69,16), (70,75), (71,36), (72,89), (73,98),
+ (74,76), (75,81), (76,4), (77,94), (78,42), (79,30), (80,78), (81,33),
+ (82,29), (83,53), (84,63), (85,2), (86,87), (87,37), (88,80), (89,84),
+ (90,72), (91,41), (92,9), (93,61), (94,73), (95,95), (96,65), (97,13),
+ (98,58), (99,96), (100,98), (101,1), (102,21), (103,74), (104,65), (105,35),
+ (106,5), (107,73), (108,11), (109,51), (110,87), (111,41), (112,12), (113,8),
+ (114,20), (115,31), (116,31), (117,15), (118,95), (119,22), (120,73),
+ (121,79), (122,88), (123,34), (124,8), (125,11), (126,49), (127,34),
+ (128,90), (129,59), (130,96), (131,60), (132,55), (133,75), (134,77),
+ (135,44), (136,2), (137,7), (138,85), (139,57), (140,74), (141,29), (142,70),
+ (143,59), (144,19), (145,39), (146,26), (147,26), (148,47), (149,80),
+ (150,90), (151,36), (152,58), (153,47), (154,9), (155,72), (156,72), (157,66),
+ (158,33), (159,93), (160,75), (161,64), (162,81), (163,9), (164,23), (165,37),
+ (166,13), (167,12), (168,14), (169,62), (170,91), (171,36), (172,91),
+ (173,33), (174,15), (175,34), (176,36), (177,99), (178,3), (179,95), (180,69),
+ (181,58), (182,52), (183,30), (184,50), (185,84), (186,10), (187,84),
+ (188,33), (189,21), (190,39), (191,44), (192,58), (193,30), (194,38),
+ (195,34), (196,83), (197,27), (198,82), (199,17), (200,7);
+}
+
+execsql_test 4.1 {
+ SELECT a, sum(b) OVER (
+ PARTITION BY (b%10)
+ ORDER BY b
+ ) FROM t2 ORDER BY a;
+}
+
+execsql_test 4.2 {
+ SELECT a, sum(b) OVER (
+ PARTITION BY (b%10)
+ ORDER BY b
+ RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t2 ORDER BY a;
+}
+
+execsql_test 4.3 {
+ SELECT b, sum(b) OVER (
+ ORDER BY b
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t2 ORDER BY b;
+}
+
+execsql_test 4.4 {
+ SELECT b, sum(b) OVER (
+ ORDER BY b
+ RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY b;
+}
+
+execsql_test 4.5 {
+ SELECT b, sum(b) OVER (
+ ORDER BY b
+ RANGE BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t2 ORDER BY b;
+}
+
+execsql_test 4.6.1 {
+ SELECT b, sum(b) OVER (
+ RANGE BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t2 ORDER BY b;
+}
+execsql_test 4.6.2 {
+ SELECT b, sum(b) OVER () FROM t2 ORDER BY b;
+}
+execsql_test 4.6.3 {
+ SELECT b, sum(b) OVER (
+ RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY b;
+}
+execsql_test 4.6.4 {
+ SELECT b, sum(b) OVER (
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY b;
+}
+
+execsql_test 4.7.1 {
+ SELECT b, sum(b) OVER (
+ ROWS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t2 ORDER BY 1, 2;
+}
+execsql_test 4.7.2 {
+ SELECT b, sum(b) OVER (
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t2 ORDER BY 1, 2;
+}
+execsql_test 4.7.3 {
+ SELECT b, sum(b) OVER (
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY 1, 2;
+}
+execsql_test 4.7.4 {
+ SELECT b, sum(b) OVER (
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY 1, 2;
+}
+
+execsql_test 4.8.1 {
+ SELECT b, sum(b) OVER (
+ ORDER BY a
+ ROWS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t2 ORDER BY 1, 2;
+}
+execsql_test 4.8.2 {
+ SELECT b, sum(b) OVER (
+ ORDER BY a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t2 ORDER BY 1, 2;
+}
+execsql_test 4.8.3 {
+ SELECT b, sum(b) OVER (
+ ORDER BY a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY 1, 2;
+}
+execsql_test 4.8.4 {
+ SELECT b, sum(b) OVER (
+ ORDER BY a
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY 1, 2;
+}
+
+execsql_float_test 4.9 {
+ SELECT
+ rank() OVER win AS rank,
+ cume_dist() OVER win AS cume_dist FROM t1
+ WINDOW win AS (ORDER BY 1);
+}
+
+execsql_test 4.10 {
+ SELECT count(*) OVER (ORDER BY b) FROM t1
+}
+
+execsql_test 4.11 {
+ SELECT count(distinct a) FILTER (WHERE b='odd') FROM t1
+}
+
+==========
+
+execsql_test 5.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x INTEGER, y INTEGER);
+ INSERT INTO t1 VALUES(10, 1);
+ INSERT INTO t1 VALUES(20, 2);
+ INSERT INTO t1 VALUES(3, 3);
+ INSERT INTO t1 VALUES(2, 4);
+ INSERT INTO t1 VALUES(1, 5);
+}
+
+execsql_float_test 5.1 {
+ SELECT avg(x) OVER (ORDER BY y) AS z FROM t1 ORDER BY z;
+}
+
+==========
+
+execsql_test 6.0 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 INTEGER UNIQUE);
+ INSERT INTO t0 VALUES(0);
+}
+execsql_test 6.1 {
+ SELECT DENSE_RANK() OVER(), LAG(0) OVER() FROM t0;
+}
+execsql_test 6.2 {
+ SELECT * FROM t0 WHERE
+ (0, t0.c0) IN (SELECT DENSE_RANK() OVER(), LAG(0) OVER() FROM t0);
+}
+
+==========
+
+execsql_test 7.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER);
+ INSERT INTO t1 VALUES(1, 1, 1);
+ INSERT INTO t1 VALUES(1, 2, 2);
+ INSERT INTO t1 VALUES(3, 3, 3);
+ INSERT INTO t1 VALUES(3, 4, 4);
+}
+
+execsql_test 7.1 {
+ SELECT c, sum(c) OVER win1 FROM t1
+ WINDOW win1 AS (ORDER BY b)
+}
+
+execsql_test 7.2 {
+ SELECT c, sum(c) OVER win1 FROM t1
+ WINDOW win1 AS (PARTITION BY 1 ORDER BY b)
+}
+
+execsql_test 7.3 {
+ SELECT c, sum(c) OVER win1 FROM t1
+ WINDOW win1 AS (ORDER BY 1)
+}
+
+finish_test
+
+
diff --git a/test/window2.test b/test/window2.test
new file mode 100644
index 0000000..e241d59
--- /dev/null
+++ b/test/window2.test
@@ -0,0 +1,976 @@
+# 2018 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.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window2
+
+ifcapable !windowfunc { finish_test ; return }
+do_execsql_test 1.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
+ INSERT INTO t1 VALUES(1, 'odd', 'one', 1);
+ INSERT INTO t1 VALUES(2, 'even', 'two', 2);
+ INSERT INTO t1 VALUES(3, 'odd', 'three', 3);
+ INSERT INTO t1 VALUES(4, 'even', 'four', 4);
+ INSERT INTO t1 VALUES(5, 'odd', 'five', 5);
+ INSERT INTO t1 VALUES(6, 'even', 'six', 6);
+} {}
+
+do_execsql_test 1.1 {
+ SELECT c, sum(d) OVER (PARTITION BY b ORDER BY c) FROM t1;
+} {four 4 six 10 two 12 five 5 one 6 three 9}
+
+do_execsql_test 1.2 {
+ SELECT sum(d) OVER () FROM t1;
+} {21 21 21 21 21 21}
+
+do_execsql_test 1.3 {
+ SELECT sum(d) OVER (PARTITION BY b) FROM t1;
+} {12 12 12 9 9 9}
+
+#==========================================================================
+
+do_execsql_test 2.1 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1000 PRECEDING AND 1 FOLLOWING
+ ) FROM t1
+} {1 3 2 6 3 10 4 15 5 21 6 21}
+
+do_execsql_test 2.2 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1000 PRECEDING AND 1000 FOLLOWING
+ ) FROM t1
+} {1 21 2 21 3 21 4 21 5 21 6 21}
+
+do_execsql_test 2.3 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 1000 FOLLOWING
+ ) FROM t1
+} {1 21 2 21 3 20 4 18 5 15 6 11}
+
+do_execsql_test 2.4 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1
+} {1 3 2 6 3 9 4 12 5 15 6 11}
+
+do_execsql_test 2.5 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 0 FOLLOWING
+ ) FROM t1
+} {1 1 2 3 3 5 4 7 5 9 6 11}
+
+do_execsql_test 2.6 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1
+} {2 6 4 12 6 10 1 4 3 9 5 8}
+
+do_execsql_test 2.7 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 0 PRECEDING AND 0 FOLLOWING
+ ) FROM t1
+} {2 2 4 4 6 6 1 1 3 3 5 5}
+
+do_execsql_test 2.8 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING
+ ) FROM t1
+} {1 6 2 9 3 12 4 15 5 11 6 6}
+
+do_execsql_test 2.9 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING
+ ) FROM t1
+} {1 6 2 10 3 15 4 21 5 21 6 21}
+
+do_execsql_test 2.10 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING
+ ) FROM t1
+} {1 6 2 9 3 12 4 15 5 11 6 6}
+
+do_execsql_test 2.11 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 2 PRECEDING AND CURRENT ROW
+ ) FROM t1
+} {1 1 2 3 3 6 4 9 5 12 6 15}
+
+do_execsql_test 2.13 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {1 21 2 21 3 21 4 20 5 18 6 15}
+
+do_execsql_test 2.14 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 3 PRECEDING AND 1 PRECEDING
+ ) FROM t1
+} {1 {} 2 1 3 3 4 6 5 9 6 12}
+
+do_execsql_test 2.15 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 0 PRECEDING
+ ) FROM t1
+} {2 2 4 6 6 10 1 1 3 4 5 8}
+
+do_execsql_test 2.16 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
+ ) FROM t1
+} {2 {} 4 2 6 4 1 {} 3 1 5 3}
+
+do_execsql_test 2.17 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING
+ ) FROM t1
+} {2 {} 4 {} 6 {} 1 {} 3 {} 5 {}}
+
+do_execsql_test 2.18 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING
+ ) FROM t1
+} {2 {} 4 {} 6 2 1 {} 3 {} 5 1}
+
+do_execsql_test 2.19 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 FOLLOWING AND 3 FOLLOWING
+ ) FROM t1
+} {2 10 4 6 6 {} 1 8 3 5 5 {}}
+
+do_execsql_test 2.20 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING
+ ) FROM t1
+} {1 5 2 7 3 9 4 11 5 6 6 {}}
+
+do_execsql_test 2.21 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {1 20 2 18 3 15 4 11 5 6 6 {}}
+
+do_execsql_test 2.22 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {2 10 4 6 6 {} 1 8 3 5 5 {}}
+
+do_execsql_test 2.23 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {1 21 2 20 3 18 4 15 5 11 6 6}
+
+do_execsql_test 2.24 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY a%2
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {2 12 4 10 6 6 1 9 3 8 5 5}
+
+do_execsql_test 2.25 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {1 21 2 21 3 21 4 21 5 21 6 21}
+
+do_execsql_test 2.26 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {2 12 4 12 6 12 1 9 3 9 5 9}
+
+do_execsql_test 2.27 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t1
+} {1 1 2 2 3 3 4 4 5 5 6 6}
+
+do_execsql_test 2.28 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b
+ ORDER BY d
+ ROWS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t1
+} {2 2 4 4 6 6 1 1 3 3 5 5}
+
+do_execsql_test 2.29 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {1 21 2 20 3 18 4 15 5 11 6 6}
+
+do_execsql_test 2.30 {
+ SELECT a, sum(d) OVER (
+ ORDER BY b
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {2 21 4 21 6 21 1 9 3 9 5 9}
+
+do_execsql_test 3.1 {
+ SELECT a, sum(d) OVER (
+ PARTITION BY b ORDER BY d
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {2 12 4 10 6 6 1 9 3 8 5 5}
+
+do_execsql_test 3.2 {
+ SELECT a, sum(d) OVER (
+ ORDER BY b
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {2 21 4 21 6 21 1 9 3 9 5 9}
+
+do_execsql_test 3.3 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t1
+} {1 21 2 21 3 21 4 21 5 21 6 21}
+
+do_execsql_test 3.4 {
+ SELECT a, sum(d) OVER (
+ ORDER BY d/2
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t1
+} {1 1 2 3 3 6 4 10 5 15 6 21}
+
+#==========================================================================
+
+do_execsql_test 4.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
+ INSERT INTO t2(a, b) VALUES
+ (1,0), (2,74), (3,41), (4,74), (5,23), (6,99), (7,26), (8,33), (9,2),
+ (10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
+ (18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
+ (26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
+ (34,23), (35,16), (36,16), (37,93), (38,65), (39,35), (40,47), (41,7),
+ (42,86), (43,74), (44,61), (45,91), (46,85), (47,24), (48,85), (49,43),
+ (50,59), (51,12), (52,32), (53,56), (54,3), (55,91), (56,22), (57,90),
+ (58,55), (59,15), (60,28), (61,89), (62,25), (63,47), (64,1), (65,56),
+ (66,40), (67,43), (68,56), (69,16), (70,75), (71,36), (72,89), (73,98),
+ (74,76), (75,81), (76,4), (77,94), (78,42), (79,30), (80,78), (81,33),
+ (82,29), (83,53), (84,63), (85,2), (86,87), (87,37), (88,80), (89,84),
+ (90,72), (91,41), (92,9), (93,61), (94,73), (95,95), (96,65), (97,13),
+ (98,58), (99,96), (100,98), (101,1), (102,21), (103,74), (104,65), (105,35),
+ (106,5), (107,73), (108,11), (109,51), (110,87), (111,41), (112,12), (113,8),
+ (114,20), (115,31), (116,31), (117,15), (118,95), (119,22), (120,73),
+ (121,79), (122,88), (123,34), (124,8), (125,11), (126,49), (127,34),
+ (128,90), (129,59), (130,96), (131,60), (132,55), (133,75), (134,77),
+ (135,44), (136,2), (137,7), (138,85), (139,57), (140,74), (141,29), (142,70),
+ (143,59), (144,19), (145,39), (146,26), (147,26), (148,47), (149,80),
+ (150,90), (151,36), (152,58), (153,47), (154,9), (155,72), (156,72), (157,66),
+ (158,33), (159,93), (160,75), (161,64), (162,81), (163,9), (164,23), (165,37),
+ (166,13), (167,12), (168,14), (169,62), (170,91), (171,36), (172,91),
+ (173,33), (174,15), (175,34), (176,36), (177,99), (178,3), (179,95), (180,69),
+ (181,58), (182,52), (183,30), (184,50), (185,84), (186,10), (187,84),
+ (188,33), (189,21), (190,39), (191,44), (192,58), (193,30), (194,38),
+ (195,34), (196,83), (197,27), (198,82), (199,17), (200,7);
+} {}
+
+do_execsql_test 4.1 {
+ SELECT a, sum(b) OVER (
+ PARTITION BY (b%10)
+ ORDER BY b
+ ) FROM t2 ORDER BY a;
+} {1 0 2 754 3 251 4 754 5 101 6 1247 7 132 8 266 9 6 10 950
+ 11 667 12 1052 13 535 14 128 15 428 16 250 17 336 18 1122
+ 19 368 20 6 21 1247 22 1000 23 92 24 368 25 584 26 320
+ 27 1000 28 24 29 478 30 133 31 1049 32 1090 33 632 34 101
+ 35 54 36 54 37 1049 38 450 39 145 40 354 41 21 42 764
+ 43 754 44 424 45 1122 46 930 47 42 48 930 49 352 50 535
+ 51 42 52 118 53 536 54 6 55 1122 56 86 57 770 58 255 59 50
+ 60 52 61 950 62 75 63 354 64 2 65 536 66 160 67 352 68 536
+ 69 54 70 675 71 276 72 950 73 868 74 678 75 667 76 4
+ 77 1184 78 160 79 120 80 584 81 266 82 133 83 405 84 468
+ 85 6 86 806 87 166 88 500 89 1090 90 552 91 251 92 27
+ 93 424 94 687 95 1215 96 450 97 32 98 360 99 1052 100 868
+ 101 2 102 66 103 754 104 450 105 145 106 5 107 687 108 24
+ 109 302 110 806 111 251 112 42 113 24 114 30 115 128 116 128
+ 117 50 118 1215 119 86 120 687 121 683 122 672 123 178 124 24
+ 125 24 126 299 127 178 128 770 129 535 130 1052 131 270
+ 132 255 133 675 134 632 135 266 136 6 137 21 138 930 139 411
+ 140 754 141 133 142 340 143 535 144 46 145 250 146 132
+ 147 132 148 354 149 500 150 770 151 276 152 360 153 354
+ 154 27 155 552 156 552 157 602 158 266 159 1049 160 675
+ 161 384 162 667 163 27 164 101 165 166 166 32 167 42 168 18
+ 169 336 170 1122 171 276 172 1122 173 266 174 50 175 178
+ 176 276 177 1247 178 6 179 1215 180 604 181 360 182 212
+ 183 120 184 210 185 1090 186 10 187 1090 188 266 189 66
+ 190 250 191 266 192 360 193 120 194 128 195 178 196 770
+ 197 92 198 634 199 38 200 21}
+
+do_execsql_test 4.2 {
+ SELECT a, sum(b) OVER (
+ PARTITION BY (b%10)
+ ORDER BY b
+ RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t2 ORDER BY a;
+} {1 0 2 754 3 251 4 754 5 101 6 1247 7 132 8 266 9 6 10 950
+ 11 667 12 1052 13 535 14 128 15 428 16 250 17 336 18 1122
+ 19 368 20 6 21 1247 22 1000 23 92 24 368 25 584 26 320
+ 27 1000 28 24 29 478 30 133 31 1049 32 1090 33 632 34 101
+ 35 54 36 54 37 1049 38 450 39 145 40 354 41 21 42 764
+ 43 754 44 424 45 1122 46 930 47 42 48 930 49 352 50 535
+ 51 42 52 118 53 536 54 6 55 1122 56 86 57 770 58 255 59 50
+ 60 52 61 950 62 75 63 354 64 2 65 536 66 160 67 352 68 536
+ 69 54 70 675 71 276 72 950 73 868 74 678 75 667 76 4
+ 77 1184 78 160 79 120 80 584 81 266 82 133 83 405 84 468
+ 85 6 86 806 87 166 88 500 89 1090 90 552 91 251 92 27
+ 93 424 94 687 95 1215 96 450 97 32 98 360 99 1052 100 868
+ 101 2 102 66 103 754 104 450 105 145 106 5 107 687 108 24
+ 109 302 110 806 111 251 112 42 113 24 114 30 115 128 116 128
+ 117 50 118 1215 119 86 120 687 121 683 122 672 123 178 124 24
+ 125 24 126 299 127 178 128 770 129 535 130 1052 131 270
+ 132 255 133 675 134 632 135 266 136 6 137 21 138 930 139 411
+ 140 754 141 133 142 340 143 535 144 46 145 250 146 132
+ 147 132 148 354 149 500 150 770 151 276 152 360 153 354
+ 154 27 155 552 156 552 157 602 158 266 159 1049 160 675
+ 161 384 162 667 163 27 164 101 165 166 166 32 167 42 168 18
+ 169 336 170 1122 171 276 172 1122 173 266 174 50 175 178
+ 176 276 177 1247 178 6 179 1215 180 604 181 360 182 212
+ 183 120 184 210 185 1090 186 10 187 1090 188 266 189 66
+ 190 250 191 266 192 360 193 120 194 128 195 178 196 770
+ 197 92 198 634 199 38 200 21}
+
+do_execsql_test 4.3 {
+ SELECT b, sum(b) OVER (
+ ORDER BY b
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t2 ORDER BY b;
+} {0 0 1 1 1 2 2 4 2 6 2 8 3 11 3 14 4 18 5 23 6 29 7 36
+ 7 43 7 50 8 58 8 66 8 74 9 83 9 92 9 101 10 111 11 122
+ 11 133 12 145 12 157 12 169 13 182 13 195 14 209 15 224
+ 15 239 15 254 16 270 16 286 16 302 17 319 19 338 20 358
+ 21 379 21 400 22 422 22 444 23 467 23 490 23 513 24 537
+ 25 562 26 588 26 614 26 640 27 667 27 694 28 722 29 751
+ 29 780 29 809 30 839 30 869 30 899 31 930 31 961 32 993
+ 33 1026 33 1059 33 1092 33 1125 33 1158 34 1192 34 1226
+ 34 1260 34 1294 35 1329 35 1364 36 1400 36 1436 36 1472
+ 36 1508 37 1545 37 1582 38 1620 38 1658 39 1697 39 1736
+ 39 1775 40 1815 41 1856 41 1897 41 1938 42 1980 43 2023
+ 43 2066 44 2110 44 2154 46 2200 46 2246 47 2293 47 2340
+ 47 2387 47 2434 49 2483 50 2533 51 2584 52 2636 53 2689
+ 54 2743 55 2798 55 2853 56 2909 56 2965 56 3021 57 3078
+ 58 3136 58 3194 58 3252 58 3310 59 3369 59 3428 59 3487
+ 59 3546 60 3606 61 3667 61 3728 62 3790 62 3852 63 3915
+ 64 3979 65 4044 65 4109 65 4174 66 4240 67 4307 68 4375
+ 69 4444 70 4514 72 4586 72 4658 72 4730 73 4803 73 4876
+ 73 4949 74 5023 74 5097 74 5171 74 5245 74 5319 75 5394
+ 75 5469 75 5544 76 5620 77 5697 77 5774 78 5852 78 5930
+ 79 6009 80 6089 80 6169 81 6250 81 6331 81 6412 82 6494
+ 83 6577 84 6661 84 6745 84 6829 84 6913 85 6998 85 7083
+ 85 7168 86 7254 87 7341 87 7428 88 7516 89 7605 89 7694
+ 89 7783 90 7873 90 7963 90 8053 91 8144 91 8235 91 8326
+ 91 8417 91 8508 93 8601 93 8694 93 8787 94 8881 95 8976
+ 95 9071 95 9166 96 9262 96 9358 96 9454 97 9551 97 9648
+ 98 9746 98 9844 99 9943 99 10042 99 10141}
+
+do_execsql_test 4.4 {
+ SELECT b, sum(b) OVER (
+ ORDER BY b
+ RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY b;
+} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141
+ 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141
+ 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141
+ 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141
+ 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141
+ 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141
+ 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141
+ 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141
+ 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141
+ 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141
+ 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141
+ 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141
+ 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141
+ 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141
+ 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141
+ 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141
+ 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141
+ 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141
+ 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141
+ 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141
+ 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141
+ 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141
+ 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141
+ 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141
+ 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141
+ 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141
+ 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141
+ 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141
+ 98 10141 99 10141 99 10141 99 10141}
+
+do_execsql_test 4.5 {
+ SELECT b, sum(b) OVER (
+ ORDER BY b
+ RANGE BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t2 ORDER BY b;
+} {0 0 1 2 1 2 2 6 2 6 2 6 3 6 3 6 4 4 5 5 6 6 7 21
+ 7 21 7 21 8 24 8 24 8 24 9 27 9 27 9 27 10 10 11 22
+ 11 22 12 36 12 36 12 36 13 26 13 26 14 14 15 45 15 45
+ 15 45 16 48 16 48 16 48 17 17 19 19 20 20 21 42 21 42
+ 22 44 22 44 23 69 23 69 23 69 24 24 25 25 26 78 26 78
+ 26 78 27 54 27 54 28 28 29 87 29 87 29 87 30 90 30 90
+ 30 90 31 62 31 62 32 32 33 165 33 165 33 165 33 165 33 165
+ 34 136 34 136 34 136 34 136 35 70 35 70 36 144 36 144
+ 36 144 36 144 37 74 37 74 38 76 38 76 39 117 39 117 39 117
+ 40 40 41 123 41 123 41 123 42 42 43 86 43 86 44 88 44 88
+ 46 92 46 92 47 188 47 188 47 188 47 188 49 49 50 50 51 51
+ 52 52 53 53 54 54 55 110 55 110 56 168 56 168 56 168 57 57
+ 58 232 58 232 58 232 58 232 59 236 59 236 59 236 59 236
+ 60 60 61 122 61 122 62 124 62 124 63 63 64 64 65 195 65 195
+ 65 195 66 66 67 67 68 68 69 69 70 70 72 216 72 216 72 216
+ 73 219 73 219 73 219 74 370 74 370 74 370 74 370 74 370
+ 75 225 75 225 75 225 76 76 77 154 77 154 78 156 78 156
+ 79 79 80 160 80 160 81 243 81 243 81 243 82 82 83 83 84 336
+ 84 336 84 336 84 336 85 255 85 255 85 255 86 86 87 174
+ 87 174 88 88 89 267 89 267 89 267 90 270 90 270 90 270
+ 91 455 91 455 91 455 91 455 91 455 93 279 93 279 93 279
+ 94 94 95 285 95 285 95 285 96 288 96 288 96 288 97 194
+ 97 194 98 196 98 196 99 297 99 297 99 297}
+
+do_execsql_test 4.6.1 {
+ SELECT b, sum(b) OVER (
+ RANGE BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t2 ORDER BY b;
+} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141
+ 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141
+ 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141
+ 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141
+ 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141
+ 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141
+ 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141
+ 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141
+ 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141
+ 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141
+ 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141
+ 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141
+ 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141
+ 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141
+ 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141
+ 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141
+ 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141
+ 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141
+ 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141
+ 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141
+ 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141
+ 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141
+ 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141
+ 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141
+ 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141
+ 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141
+ 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141
+ 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141
+ 98 10141 99 10141 99 10141 99 10141}
+
+do_execsql_test 4.6.2 {
+ SELECT b, sum(b) OVER () FROM t2 ORDER BY b;
+} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141
+ 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141
+ 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141
+ 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141
+ 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141
+ 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141
+ 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141
+ 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141
+ 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141
+ 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141
+ 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141
+ 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141
+ 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141
+ 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141
+ 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141
+ 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141
+ 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141
+ 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141
+ 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141
+ 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141
+ 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141
+ 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141
+ 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141
+ 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141
+ 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141
+ 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141
+ 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141
+ 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141
+ 98 10141 99 10141 99 10141 99 10141}
+
+do_execsql_test 4.6.3 {
+ SELECT b, sum(b) OVER (
+ RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY b;
+} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141
+ 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141
+ 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141
+ 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141
+ 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141
+ 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141
+ 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141
+ 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141
+ 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141
+ 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141
+ 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141
+ 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141
+ 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141
+ 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141
+ 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141
+ 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141
+ 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141
+ 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141
+ 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141
+ 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141
+ 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141
+ 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141
+ 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141
+ 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141
+ 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141
+ 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141
+ 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141
+ 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141
+ 98 10141 99 10141 99 10141 99 10141}
+
+do_execsql_test 4.6.4 {
+ SELECT b, sum(b) OVER (
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY b;
+} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141
+ 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141
+ 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141
+ 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141
+ 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141
+ 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141
+ 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141
+ 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141
+ 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141
+ 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141
+ 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141
+ 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141
+ 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141
+ 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141
+ 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141
+ 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141
+ 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141
+ 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141
+ 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141
+ 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141
+ 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141
+ 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141
+ 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141
+ 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141
+ 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141
+ 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141
+ 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141
+ 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141
+ 98 10141 99 10141 99 10141 99 10141}
+
+do_execsql_test 4.7.1 {
+ SELECT b, sum(b) OVER (
+ ROWS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t2 ORDER BY 1, 2;
+} {0 0 1 1 1 1 2 2 2 2 2 2 3 3 3 3 4 4 5 5 6 6 7 7 7 7
+ 7 7 8 8 8 8 8 8 9 9 9 9 9 9 10 10 11 11 11 11 12 12
+ 12 12 12 12 13 13 13 13 14 14 15 15 15 15 15 15 16 16
+ 16 16 16 16 17 17 19 19 20 20 21 21 21 21 22 22 22 22
+ 23 23 23 23 23 23 24 24 25 25 26 26 26 26 26 26 27 27
+ 27 27 28 28 29 29 29 29 29 29 30 30 30 30 30 30 31 31
+ 31 31 32 32 33 33 33 33 33 33 33 33 33 33 34 34 34 34
+ 34 34 34 34 35 35 35 35 36 36 36 36 36 36 36 36 37 37
+ 37 37 38 38 38 38 39 39 39 39 39 39 40 40 41 41 41 41
+ 41 41 42 42 43 43 43 43 44 44 44 44 46 46 46 46 47 47
+ 47 47 47 47 47 47 49 49 50 50 51 51 52 52 53 53 54 54
+ 55 55 55 55 56 56 56 56 56 56 57 57 58 58 58 58 58 58
+ 58 58 59 59 59 59 59 59 59 59 60 60 61 61 61 61 62 62
+ 62 62 63 63 64 64 65 65 65 65 65 65 66 66 67 67 68 68
+ 69 69 70 70 72 72 72 72 72 72 73 73 73 73 73 73 74 74
+ 74 74 74 74 74 74 74 74 75 75 75 75 75 75 76 76 77 77
+ 77 77 78 78 78 78 79 79 80 80 80 80 81 81 81 81 81 81
+ 82 82 83 83 84 84 84 84 84 84 84 84 85 85 85 85 85 85
+ 86 86 87 87 87 87 88 88 89 89 89 89 89 89 90 90 90 90
+ 90 90 91 91 91 91 91 91 91 91 91 91 93 93 93 93 93 93
+ 94 94 95 95 95 95 95 95 96 96 96 96 96 96 97 97 97 97
+ 98 98 98 98 99 99 99 99 99 99}
+
+do_execsql_test 4.7.2 {
+ SELECT b, sum(b) OVER (
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t2 ORDER BY 1, 2;
+} {0 0 1 3379 1 5443 2 372 2 4473 2 7074 3 2916 3 9096 4 4049
+ 5 5643 6 1047 7 2205 7 7081 7 10141 8 1553 8 5926 8 6422
+ 9 4883 9 7932 9 8497 10 9544 11 5727 11 6433 12 2825 12 5918
+ 12 8582 13 5190 13 8570 14 8596 15 3189 15 6023 15 8924
+ 16 1942 16 1958 16 3590 17 10134 19 7474 20 5946 21 5464
+ 21 9682 22 3029 22 6140 23 212 23 1926 23 8520 24 2626
+ 25 3331 26 337 26 7539 26 7565 27 1270 27 10035 28 3217
+ 29 1649 29 4355 29 7326 30 4215 30 9400 30 9853 31 5977
+ 31 6008 32 2857 33 370 33 4326 33 8175 33 8909 33 9661
+ 34 6414 34 6516 34 8958 34 9925 35 2151 35 5638 36 3701
+ 36 7818 36 8785 36 8994 37 4597 37 8557 38 735 38 9891 39 842
+ 39 7513 39 9721 40 3475 41 115 41 4874 41 5906 42 4185
+ 43 2754 43 3518 44 7072 44 9765 46 1041 46 1316 47 2198
+ 47 3378 47 7612 47 7923 49 6482 50 9450 51 5778 52 9370
+ 53 4408 54 1448 55 3174 55 6876 56 2913 56 3435 56 3574
+ 57 7223 58 5248 58 7876 58 9318 58 9823 59 697 59 2813
+ 59 6665 59 7455 60 6821 61 2426 61 4944 62 904 62 8658
+ 63 4471 64 8407 65 2116 65 5177 65 5603 66 8142 67 1620
+ 68 803 69 9260 70 7396 72 4833 72 8004 72 8076 73 5017
+ 73 5716 73 6213 74 74 74 189 74 2365 74 5538 74 7297 75 3665
+ 75 6951 75 8343 76 3964 77 1903 77 7028 78 1394 78 4293
+ 79 6292 80 4677 80 7692 81 542 81 4045 81 8488 82 10117
+ 83 10008 84 1826 84 4761 84 9534 84 9628 85 2602 85 2711
+ 85 7166 86 2291 87 4560 87 5865 88 6380 89 461 89 3306
+ 89 3790 90 3119 90 6606 90 7782 91 995 91 2517 91 3007
+ 91 8749 91 8876 93 1742 93 2051 93 8268 94 4143 95 5112
+ 95 6118 95 9191 96 638 96 5344 96 6761 97 1243 97 1545
+ 98 3888 98 5442 99 311 99 1146 99 9093}
+
+do_execsql_test 4.7.3 {
+ SELECT b, sum(b) OVER (
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY 1, 2;
+} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141
+ 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141
+ 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141
+ 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141
+ 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141
+ 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141
+ 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141
+ 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141
+ 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141
+ 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141
+ 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141
+ 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141
+ 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141
+ 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141
+ 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141
+ 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141
+ 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141
+ 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141
+ 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141
+ 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141
+ 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141
+ 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141
+ 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141
+ 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141
+ 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141
+ 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141
+ 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141
+ 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141
+ 98 10141 99 10141 99 10141 99 10141}
+
+do_execsql_test 4.7.4 {
+ SELECT b, sum(b) OVER (
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY 1, 2;
+} {0 10141 1 4699 1 6763 2 3069 2 5670 2 9771 3 1048 3 7228
+ 4 6096 5 4503 6 9100 7 7 7 3067 7 7943 8 3727 8 4223 8 8596
+ 9 1653 9 2218 9 5267 10 607 11 3719 11 4425 12 1571 12 4235
+ 12 7328 13 1584 13 4964 14 1559 15 1232 15 4133 15 6967
+ 16 6567 16 8199 16 8215 17 24 19 2686 20 4215 21 480 21 4698
+ 22 4023 22 7134 23 1644 23 8238 23 9952 24 7539 25 6835
+ 26 2602 26 2628 26 9830 27 133 27 8898 28 6952 29 2844
+ 29 5815 29 8521 30 318 30 771 30 5956 31 4164 31 4195 32 7316
+ 33 513 33 1265 33 1999 33 5848 33 9804 34 250 34 1217 34 3659
+ 34 3761 35 4538 35 8025 36 1183 36 1392 36 2359 36 6476
+ 37 1621 37 5581 38 288 38 9444 39 459 39 2667 39 9338 40 6706
+ 41 4276 41 5308 41 10067 42 5998 43 6666 43 7430 44 420
+ 44 3113 46 8871 46 9146 47 2265 47 2576 47 6810 47 7990
+ 49 3708 50 741 51 4414 52 823 53 5786 54 8747 55 3320 55 7022
+ 56 6623 56 6762 56 7284 57 2975 58 376 58 881 58 2323 58 4951
+ 59 2745 59 3535 59 7387 59 9503 60 3380 61 5258 61 7776
+ 62 1545 62 9299 63 5733 64 1798 65 4603 65 5029 65 8090
+ 66 2065 67 8588 68 9406 69 950 70 2815 72 2137 72 2209
+ 72 5380 73 4001 73 4498 73 5197 74 2918 74 4677 74 7850
+ 74 10026 74 10141 75 1873 75 3265 75 6551 76 6253 77 3190
+ 77 8315 78 5926 78 8825 79 3928 80 2529 80 5544 81 1734
+ 81 6177 81 9680 82 106 83 216 84 597 84 691 84 5464 84 8399
+ 85 3060 85 7515 85 7624 86 7936 87 4363 87 5668 88 3849
+ 89 6440 89 6924 89 9769 90 2449 90 3625 90 7112 91 1356
+ 91 1483 91 7225 91 7715 91 9237 93 1966 93 8183 93 8492
+ 94 6092 95 1045 95 4118 95 5124 96 3476 96 4893 96 9599
+ 97 8693 97 8995 98 4797 98 6351 99 1147 99 9094 99 9929}
+
+do_execsql_test 4.8.1 {
+ SELECT b, sum(b) OVER (
+ ORDER BY a
+ ROWS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t2 ORDER BY 1, 2;
+} {0 0 1 1 1 1 2 2 2 2 2 2 3 3 3 3 4 4 5 5 6 6 7 7 7 7
+ 7 7 8 8 8 8 8 8 9 9 9 9 9 9 10 10 11 11 11 11 12 12
+ 12 12 12 12 13 13 13 13 14 14 15 15 15 15 15 15 16 16
+ 16 16 16 16 17 17 19 19 20 20 21 21 21 21 22 22 22 22
+ 23 23 23 23 23 23 24 24 25 25 26 26 26 26 26 26 27 27
+ 27 27 28 28 29 29 29 29 29 29 30 30 30 30 30 30 31 31
+ 31 31 32 32 33 33 33 33 33 33 33 33 33 33 34 34 34 34
+ 34 34 34 34 35 35 35 35 36 36 36 36 36 36 36 36 37 37
+ 37 37 38 38 38 38 39 39 39 39 39 39 40 40 41 41 41 41
+ 41 41 42 42 43 43 43 43 44 44 44 44 46 46 46 46 47 47
+ 47 47 47 47 47 47 49 49 50 50 51 51 52 52 53 53 54 54
+ 55 55 55 55 56 56 56 56 56 56 57 57 58 58 58 58 58 58
+ 58 58 59 59 59 59 59 59 59 59 60 60 61 61 61 61 62 62
+ 62 62 63 63 64 64 65 65 65 65 65 65 66 66 67 67 68 68
+ 69 69 70 70 72 72 72 72 72 72 73 73 73 73 73 73 74 74
+ 74 74 74 74 74 74 74 74 75 75 75 75 75 75 76 76 77 77
+ 77 77 78 78 78 78 79 79 80 80 80 80 81 81 81 81 81 81
+ 82 82 83 83 84 84 84 84 84 84 84 84 85 85 85 85 85 85
+ 86 86 87 87 87 87 88 88 89 89 89 89 89 89 90 90 90 90
+ 90 90 91 91 91 91 91 91 91 91 91 91 93 93 93 93 93 93
+ 94 94 95 95 95 95 95 95 96 96 96 96 96 96 97 97 97 97
+ 98 98 98 98 99 99 99 99 99 99}
+
+do_execsql_test 4.8.2 {
+ SELECT b, sum(b) OVER (
+ ORDER BY a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ ) FROM t2 ORDER BY 1, 2;
+} {0 0 1 3379 1 5443 2 372 2 4473 2 7074 3 2916 3 9096 4 4049
+ 5 5643 6 1047 7 2205 7 7081 7 10141 8 1553 8 5926 8 6422
+ 9 4883 9 7932 9 8497 10 9544 11 5727 11 6433 12 2825 12 5918
+ 12 8582 13 5190 13 8570 14 8596 15 3189 15 6023 15 8924
+ 16 1942 16 1958 16 3590 17 10134 19 7474 20 5946 21 5464
+ 21 9682 22 3029 22 6140 23 212 23 1926 23 8520 24 2626
+ 25 3331 26 337 26 7539 26 7565 27 1270 27 10035 28 3217
+ 29 1649 29 4355 29 7326 30 4215 30 9400 30 9853 31 5977
+ 31 6008 32 2857 33 370 33 4326 33 8175 33 8909 33 9661
+ 34 6414 34 6516 34 8958 34 9925 35 2151 35 5638 36 3701
+ 36 7818 36 8785 36 8994 37 4597 37 8557 38 735 38 9891 39 842
+ 39 7513 39 9721 40 3475 41 115 41 4874 41 5906 42 4185
+ 43 2754 43 3518 44 7072 44 9765 46 1041 46 1316 47 2198
+ 47 3378 47 7612 47 7923 49 6482 50 9450 51 5778 52 9370
+ 53 4408 54 1448 55 3174 55 6876 56 2913 56 3435 56 3574
+ 57 7223 58 5248 58 7876 58 9318 58 9823 59 697 59 2813
+ 59 6665 59 7455 60 6821 61 2426 61 4944 62 904 62 8658
+ 63 4471 64 8407 65 2116 65 5177 65 5603 66 8142 67 1620
+ 68 803 69 9260 70 7396 72 4833 72 8004 72 8076 73 5017
+ 73 5716 73 6213 74 74 74 189 74 2365 74 5538 74 7297 75 3665
+ 75 6951 75 8343 76 3964 77 1903 77 7028 78 1394 78 4293
+ 79 6292 80 4677 80 7692 81 542 81 4045 81 8488 82 10117
+ 83 10008 84 1826 84 4761 84 9534 84 9628 85 2602 85 2711
+ 85 7166 86 2291 87 4560 87 5865 88 6380 89 461 89 3306
+ 89 3790 90 3119 90 6606 90 7782 91 995 91 2517 91 3007
+ 91 8749 91 8876 93 1742 93 2051 93 8268 94 4143 95 5112
+ 95 6118 95 9191 96 638 96 5344 96 6761 97 1243 97 1545
+ 98 3888 98 5442 99 311 99 1146 99 9093}
+
+do_execsql_test 4.8.3 {
+ SELECT b, sum(b) OVER (
+ ORDER BY a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY 1, 2;
+} {0 10141 1 10141 1 10141 2 10141 2 10141 2 10141 3 10141
+ 3 10141 4 10141 5 10141 6 10141 7 10141 7 10141 7 10141
+ 8 10141 8 10141 8 10141 9 10141 9 10141 9 10141 10 10141
+ 11 10141 11 10141 12 10141 12 10141 12 10141 13 10141 13 10141
+ 14 10141 15 10141 15 10141 15 10141 16 10141 16 10141 16 10141
+ 17 10141 19 10141 20 10141 21 10141 21 10141 22 10141 22 10141
+ 23 10141 23 10141 23 10141 24 10141 25 10141 26 10141 26 10141
+ 26 10141 27 10141 27 10141 28 10141 29 10141 29 10141 29 10141
+ 30 10141 30 10141 30 10141 31 10141 31 10141 32 10141 33 10141
+ 33 10141 33 10141 33 10141 33 10141 34 10141 34 10141 34 10141
+ 34 10141 35 10141 35 10141 36 10141 36 10141 36 10141 36 10141
+ 37 10141 37 10141 38 10141 38 10141 39 10141 39 10141 39 10141
+ 40 10141 41 10141 41 10141 41 10141 42 10141 43 10141 43 10141
+ 44 10141 44 10141 46 10141 46 10141 47 10141 47 10141 47 10141
+ 47 10141 49 10141 50 10141 51 10141 52 10141 53 10141 54 10141
+ 55 10141 55 10141 56 10141 56 10141 56 10141 57 10141 58 10141
+ 58 10141 58 10141 58 10141 59 10141 59 10141 59 10141 59 10141
+ 60 10141 61 10141 61 10141 62 10141 62 10141 63 10141 64 10141
+ 65 10141 65 10141 65 10141 66 10141 67 10141 68 10141 69 10141
+ 70 10141 72 10141 72 10141 72 10141 73 10141 73 10141 73 10141
+ 74 10141 74 10141 74 10141 74 10141 74 10141 75 10141 75 10141
+ 75 10141 76 10141 77 10141 77 10141 78 10141 78 10141 79 10141
+ 80 10141 80 10141 81 10141 81 10141 81 10141 82 10141 83 10141
+ 84 10141 84 10141 84 10141 84 10141 85 10141 85 10141 85 10141
+ 86 10141 87 10141 87 10141 88 10141 89 10141 89 10141 89 10141
+ 90 10141 90 10141 90 10141 91 10141 91 10141 91 10141 91 10141
+ 91 10141 93 10141 93 10141 93 10141 94 10141 95 10141 95 10141
+ 95 10141 96 10141 96 10141 96 10141 97 10141 97 10141 98 10141
+ 98 10141 99 10141 99 10141 99 10141}
+
+do_execsql_test 4.8.4 {
+ SELECT b, sum(b) OVER (
+ ORDER BY a
+ ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t2 ORDER BY 1, 2;
+} {0 10141 1 4699 1 6763 2 3069 2 5670 2 9771 3 1048 3 7228
+ 4 6096 5 4503 6 9100 7 7 7 3067 7 7943 8 3727 8 4223 8 8596
+ 9 1653 9 2218 9 5267 10 607 11 3719 11 4425 12 1571 12 4235
+ 12 7328 13 1584 13 4964 14 1559 15 1232 15 4133 15 6967
+ 16 6567 16 8199 16 8215 17 24 19 2686 20 4215 21 480 21 4698
+ 22 4023 22 7134 23 1644 23 8238 23 9952 24 7539 25 6835
+ 26 2602 26 2628 26 9830 27 133 27 8898 28 6952 29 2844
+ 29 5815 29 8521 30 318 30 771 30 5956 31 4164 31 4195 32 7316
+ 33 513 33 1265 33 1999 33 5848 33 9804 34 250 34 1217 34 3659
+ 34 3761 35 4538 35 8025 36 1183 36 1392 36 2359 36 6476
+ 37 1621 37 5581 38 288 38 9444 39 459 39 2667 39 9338 40 6706
+ 41 4276 41 5308 41 10067 42 5998 43 6666 43 7430 44 420
+ 44 3113 46 8871 46 9146 47 2265 47 2576 47 6810 47 7990
+ 49 3708 50 741 51 4414 52 823 53 5786 54 8747 55 3320 55 7022
+ 56 6623 56 6762 56 7284 57 2975 58 376 58 881 58 2323 58 4951
+ 59 2745 59 3535 59 7387 59 9503 60 3380 61 5258 61 7776
+ 62 1545 62 9299 63 5733 64 1798 65 4603 65 5029 65 8090
+ 66 2065 67 8588 68 9406 69 950 70 2815 72 2137 72 2209
+ 72 5380 73 4001 73 4498 73 5197 74 2918 74 4677 74 7850
+ 74 10026 74 10141 75 1873 75 3265 75 6551 76 6253 77 3190
+ 77 8315 78 5926 78 8825 79 3928 80 2529 80 5544 81 1734
+ 81 6177 81 9680 82 106 83 216 84 597 84 691 84 5464 84 8399
+ 85 3060 85 7515 85 7624 86 7936 87 4363 87 5668 88 3849
+ 89 6440 89 6924 89 9769 90 2449 90 3625 90 7112 91 1356
+ 91 1483 91 7225 91 7715 91 9237 93 1966 93 8183 93 8492
+ 94 6092 95 1045 95 4118 95 5124 96 3476 96 4893 96 9599
+ 97 8693 97 8995 98 4797 98 6351 99 1147 99 9094 99 9929}
+
+
+do_test 4.9 {
+ set myres {}
+ foreach r [db eval {SELECT
+ rank() OVER win AS rank,
+ cume_dist() OVER win AS cume_dist FROM t1
+ WINDOW win AS (ORDER BY 1);}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 4.10 {
+ SELECT count(*) OVER (ORDER BY b) FROM t1
+} {3 3 3 6 6 6}
+
+do_execsql_test 4.11 {
+ SELECT count(distinct a) FILTER (WHERE b='odd') FROM t1
+} {3}
+
+#==========================================================================
+
+do_execsql_test 5.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x INTEGER, y INTEGER);
+ INSERT INTO t1 VALUES(10, 1);
+ INSERT INTO t1 VALUES(20, 2);
+ INSERT INTO t1 VALUES(3, 3);
+ INSERT INTO t1 VALUES(2, 4);
+ INSERT INTO t1 VALUES(1, 5);
+} {}
+
+
+do_test 5.1 {
+ set myres {}
+ foreach r [db eval {SELECT avg(x) OVER (ORDER BY y) AS z FROM t1 ORDER BY z;}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {7.2000 8.7500 10.0000 11.0000 15.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+#==========================================================================
+
+do_execsql_test 6.0 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 INTEGER UNIQUE);
+ INSERT INTO t0 VALUES(0);
+} {}
+
+do_execsql_test 6.1 {
+ SELECT DENSE_RANK() OVER(), LAG(0) OVER() FROM t0;
+} {1 {}}
+
+do_execsql_test 6.2 {
+ SELECT * FROM t0 WHERE
+ (0, t0.c0) IN (SELECT DENSE_RANK() OVER(), LAG(0) OVER() FROM t0);
+} {}
+
+#==========================================================================
+
+do_execsql_test 7.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER);
+ INSERT INTO t1 VALUES(1, 1, 1);
+ INSERT INTO t1 VALUES(1, 2, 2);
+ INSERT INTO t1 VALUES(3, 3, 3);
+ INSERT INTO t1 VALUES(3, 4, 4);
+} {}
+
+do_execsql_test 7.1 {
+ SELECT c, sum(c) OVER win1 FROM t1
+ WINDOW win1 AS (ORDER BY b)
+} {1 1 2 3 3 6 4 10}
+
+do_execsql_test 7.2 {
+ SELECT c, sum(c) OVER win1 FROM t1
+ WINDOW win1 AS (PARTITION BY 1 ORDER BY b)
+} {1 1 2 3 3 6 4 10}
+
+do_execsql_test 7.3 {
+ SELECT c, sum(c) OVER win1 FROM t1
+ WINDOW win1 AS (ORDER BY 1)
+} {1 10 2 10 3 10 4 10}
+
+finish_test
diff --git a/test/window3.tcl b/test/window3.tcl
new file mode 100644
index 0000000..f2c596c
--- /dev/null
+++ b/test/window3.tcl
@@ -0,0 +1,363 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+source [file join [file dirname $argv0] pg_common.tcl]
+
+#=========================================================================
+
+start_test window3 "2018 May 31"
+ifcapable !windowfunc
+
+execsql_test 1.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
+ INSERT INTO t2(a, b) VALUES
+ (10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
+ (18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
+ (26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
+ (34,23), (35,16), (36,16), (37,93), (38,65), (39,35), (40,47), (41,7),
+ (42,86), (43,74), (44,61), (45,91), (46,85), (47,24), (48,85), (49,43),
+ (50,59), (51,12), (52,32), (53,56), (54,3), (55,91), (56,22), (57,90),
+ (58,55), (59,15), (60,28), (61,89), (62,25), (63,47), (64,1), (65,56),
+ (66,40), (67,43), (68,56), (69,16), (70,75), (71,36), (72,89), (73,98),
+ (74,76), (75,81), (76,4), (77,94), (78,42), (79,30), (80,78), (81,33),
+ (82,29), (83,53), (84,63), (85,2), (86,87), (87,37), (88,80), (89,84),
+ (90,72), (91,41), (92,9), (93,61), (94,73), (95,95), (96,65), (97,13),
+ (98,58), (99,96), (100,98), (101,1), (102,21), (103,74), (104,65), (105,35),
+ (106,5), (107,73), (108,11), (109,51), (110,87), (111,41), (112,12), (113,8),
+ (114,20), (115,31), (116,31), (117,15), (118,95), (119,22), (120,73),
+ (121,79), (122,88), (123,34), (124,8), (125,11), (126,49), (127,34),
+ (128,90), (129,59), (130,96), (131,60), (132,55), (133,75), (134,77),
+ (135,44), (136,2), (137,7), (138,85), (139,57), (140,74), (141,29), (142,70),
+ (143,59), (144,19), (145,39), (146,26), (147,26), (148,47), (149,80),
+ (150,90), (151,36), (152,58), (153,47), (154,9), (155,72), (156,72), (157,66),
+ (158,33), (159,93), (160,75), (161,64), (162,81), (163,9), (164,23), (165,37),
+ (166,13), (167,12), (168,14), (169,62), (170,91), (171,36), (172,91),
+ (173,33), (174,15), (175,34), (176,36), (177,99), (178,3), (179,95), (180,69),
+ (181,58), (182,52), (183,30), (184,50), (185,84), (186,10), (187,84),
+ (188,33), (189,21), (190,39), (191,44), (192,58), (193,30), (194,38),
+ (195,34), (196,83), (197,27), (198,82), (199,17), (200,7);
+}
+
+execsql_test 1.1 {
+ SELECT max(b) OVER (
+ ORDER BY a
+ ) FROM t2
+}
+
+foreach {tn window} {
+ 1 "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW"
+ 2 "RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
+ 3 "RANGE BETWEEN CURRENT ROW AND CURRENT ROW"
+ 4 "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING"
+ 5 "ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING"
+ 6 "ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING"
+ 7 "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW"
+ 8 "ROWS BETWEEN 4 PRECEDING AND CURRENT ROW"
+ 9 "ROWS BETWEEN CURRENT ROW AND CURRENT ROW"
+ 10 "ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING"
+ 11 "ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING"
+ 12 "ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING"
+ 13 "ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING"
+ 14 "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
+ 15 "ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING"
+ 16 "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING"
+ 17 "ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING"
+
+ 18 "ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW"
+ 19 "ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES"
+ 20 "ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP"
+
+} {
+ execsql_test 1.$tn.2.1 "SELECT max(b) OVER ( ORDER BY a $window ) FROM t2"
+ execsql_test 1.$tn.2.2 "SELECT min(b) OVER ( ORDER BY a $window ) FROM t2"
+
+ execsql_test 1.$tn.3.1 "
+ SELECT row_number() OVER ( ORDER BY a $window ) FROM t2
+ "
+ execsql_test 1.$tn.3.2 "
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
+ "
+ execsql_test 1.$tn.3.3 "
+ SELECT row_number() OVER ( $window ) FROM t2
+ "
+
+ execsql_test 1.$tn.4.1 "
+ SELECT dense_rank() OVER ( ORDER BY a $window ) FROM t2
+ "
+ execsql_test 1.$tn.4.2 "
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
+ "
+ execsql_test 1.$tn.4.3 "
+ SELECT dense_rank() OVER ( ORDER BY b $window ) FROM t2
+ "
+ execsql_test 1.$tn.4.4 "
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
+ "
+ execsql_test 1.$tn.4.5 "
+ SELECT dense_rank() OVER ( ORDER BY b%10 $window ) FROM t2
+ "
+ execsql_test 1.$tn.4.6 "
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
+ "
+
+ execsql_test 1.$tn.5.1 "
+ SELECT rank() OVER ( ORDER BY a $window ) FROM t2
+ "
+ execsql_test 1.$tn.5.2 "
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
+ "
+ execsql_test 1.$tn.5.3 "
+ SELECT rank() OVER ( ORDER BY b $window ) FROM t2
+ "
+ execsql_test 1.$tn.5.4 "
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
+ "
+ execsql_test 1.$tn.5.5 "
+ SELECT rank() OVER ( ORDER BY b%10 $window ) FROM t2
+ "
+ execsql_test 1.$tn.5.6 "
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
+ "
+
+ execsql_test 1.$tn.6.1 "
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window )
+ FROM t2
+ "
+
+ execsql_float_test 1.$tn.7.1 "
+ SELECT percent_rank() OVER ( ORDER BY a $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.7.2 "
+ SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.7.3 "
+ SELECT percent_rank() OVER ( ORDER BY b $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.7.4 "
+ SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.7.5 "
+ SELECT percent_rank() OVER ( ORDER BY b%10 $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.7.6 "
+ SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 $window) FROM t2
+ "
+
+ execsql_float_test 1.$tn.8.1 "
+ SELECT cume_dist() OVER ( ORDER BY a $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.2 "
+ SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.3 "
+ SELECT cume_dist() OVER ( ORDER BY b $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.4 "
+ SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.5 "
+ SELECT cume_dist() OVER ( ORDER BY b%10 $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.6 "
+ SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
+ "
+
+ execsql_float_test 1.$tn.8.1 "
+ SELECT ntile(100) OVER ( ORDER BY a $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.2 "
+ SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.3 "
+ SELECT ntile(102) OVER ( ORDER BY b,a $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.4 "
+ SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.5 "
+ SELECT ntile(104) OVER ( ORDER BY b%10,a $window ) FROM t2
+ "
+ execsql_float_test 1.$tn.8.6 "
+ SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
+ "
+ execsql_float_test 1.$tn.8.7 "
+ SELECT ntile(105) OVER ( $window ) FROM t2
+ "
+
+ execsql_test 1.$tn.9.1 "
+ SELECT last_value(a+b) OVER ( ORDER BY a $window ) FROM t2
+ "
+ execsql_test 1.$tn.9.2 "
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
+ "
+ execsql_test 1.$tn.9.3 "
+ SELECT last_value(a+b) OVER ( ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.9.4 "
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.9.5 "
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.9.6 "
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
+ "
+
+ execsql_test 1.$tn.10.1 "
+ SELECT nth_value(b,b+1) OVER (ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.10.2 "
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.10.3 "
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.10.4 "
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.10.5 "
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.10.6 "
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
+ "
+
+ execsql_test 1.$tn.11.1 "
+ SELECT first_value(b) OVER (ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.11.2 "
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.11.3 "
+ SELECT first_value(b) OVER ( ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.11.4 "
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.11.5 "
+ SELECT first_value(b) OVER ( ORDER BY b%10,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.11.6 "
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
+ "
+
+ execsql_test 1.$tn.12.1 "
+ SELECT lead(b,b) OVER (ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.12.2 "
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.12.3 "
+ SELECT lead(b,b) OVER ( ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.12.4 "
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.12.5 "
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.12.6 "
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
+ "
+
+ execsql_test 1.$tn.13.1 "
+ SELECT lag(b,b) OVER (ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.13.2 "
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.13.3 "
+ SELECT lag(b,b) OVER ( ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.13.4 "
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.13.5 "
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.13.6 "
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
+ "
+
+ execsql_test 1.$tn.14.1 "
+ SELECT string_agg(CAST(b AS TEXT), '.') OVER (ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.14.2 "
+ SELECT string_agg(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a $window) FROM t2
+ "
+ execsql_test 1.$tn.14.3 "
+ SELECT string_agg(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.14.4 "
+ SELECT string_agg(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.14.5 "
+ SELECT string_agg(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a $window ) FROM t2
+ "
+ execsql_test 1.$tn.14.6 "
+ SELECT string_agg(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
+ "
+
+ execsql_test 1.$tn.14.7 "
+ SELECT string_agg(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 $window)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+ "
+
+ execsql_test 1.$tn.14.8 "
+ SELECT string_agg(CAST(b AS TEXT), '.') OVER (win1 $window)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+ "
+
+ execsql_test 1.$tn.14.9 "
+ SELECT string_agg(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 $window)
+ ORDER BY 1
+ "
+
+ execsql_test 1.$tn.15.1 "
+ SELECT count(*) OVER win, string_agg(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a $window)
+ "
+
+ execsql_test 1.$tn.15.2 "
+ SELECT count(*) OVER win, string_agg(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a $window)
+ "
+
+ execsql_test 1.$tn.15.3 "
+ SELECT count(*) OVER win, string_agg(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a $window)
+ "
+
+ execsql_test 1.$tn.15.4 "
+ SELECT count(*) OVER win, string_agg(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a $window)
+ "
+
+}
+
+finish_test
+
diff --git a/test/window3.test b/test/window3.test
new file mode 100644
index 0000000..4f759ab
--- /dev/null
+++ b/test/window3.test
@@ -0,0 +1,40613 @@
+# 2018 May 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.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window3
+
+ifcapable !windowfunc { finish_test ; return }
+do_execsql_test 1.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
+ INSERT INTO t2(a, b) VALUES
+ (10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
+ (18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
+ (26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
+ (34,23), (35,16), (36,16), (37,93), (38,65), (39,35), (40,47), (41,7),
+ (42,86), (43,74), (44,61), (45,91), (46,85), (47,24), (48,85), (49,43),
+ (50,59), (51,12), (52,32), (53,56), (54,3), (55,91), (56,22), (57,90),
+ (58,55), (59,15), (60,28), (61,89), (62,25), (63,47), (64,1), (65,56),
+ (66,40), (67,43), (68,56), (69,16), (70,75), (71,36), (72,89), (73,98),
+ (74,76), (75,81), (76,4), (77,94), (78,42), (79,30), (80,78), (81,33),
+ (82,29), (83,53), (84,63), (85,2), (86,87), (87,37), (88,80), (89,84),
+ (90,72), (91,41), (92,9), (93,61), (94,73), (95,95), (96,65), (97,13),
+ (98,58), (99,96), (100,98), (101,1), (102,21), (103,74), (104,65), (105,35),
+ (106,5), (107,73), (108,11), (109,51), (110,87), (111,41), (112,12), (113,8),
+ (114,20), (115,31), (116,31), (117,15), (118,95), (119,22), (120,73),
+ (121,79), (122,88), (123,34), (124,8), (125,11), (126,49), (127,34),
+ (128,90), (129,59), (130,96), (131,60), (132,55), (133,75), (134,77),
+ (135,44), (136,2), (137,7), (138,85), (139,57), (140,74), (141,29), (142,70),
+ (143,59), (144,19), (145,39), (146,26), (147,26), (148,47), (149,80),
+ (150,90), (151,36), (152,58), (153,47), (154,9), (155,72), (156,72), (157,66),
+ (158,33), (159,93), (160,75), (161,64), (162,81), (163,9), (164,23), (165,37),
+ (166,13), (167,12), (168,14), (169,62), (170,91), (171,36), (172,91),
+ (173,33), (174,15), (175,34), (176,36), (177,99), (178,3), (179,95), (180,69),
+ (181,58), (182,52), (183,30), (184,50), (185,84), (186,10), (187,84),
+ (188,33), (189,21), (190,39), (191,44), (192,58), (193,30), (194,38),
+ (195,34), (196,83), (197,27), (198,82), (199,17), (200,7);
+} {}
+
+do_execsql_test 1.1 {
+ SELECT max(b) OVER (
+ ORDER BY a
+ ) FROM t2
+} {89 89 96 96 96 96 96 96 96 96 96 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99}
+
+do_execsql_test 1.1.2.1 {
+ SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {89 89 96 96 96 96 96 96 96 96 96 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99}
+
+do_execsql_test 1.1.2.2 {
+ SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {89 81 81 59 38 38 38 38 38 38 6 6 6 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 6 6 6 6 6 3 3 3 3 3 3 3 3 3 3 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1}
+
+do_execsql_test 1.1.3.1 {
+ SELECT row_number() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.1.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.1.3.3 {
+ SELECT row_number() OVER ( RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.1.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.1.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.1.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.1.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.1.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.1.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.1.5.1 {
+ SELECT rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.1.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.1.5.3 {
+ SELECT rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.1.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.1.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.1.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.1.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.1.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.1.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.1.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {99 92 108 72 52 83 55 79 109 65 26 120 119 50
+ 70 103 80 124 36 96 59 124 116 110 57 51 52 130
+ 103 74 87 48 128 117 105 136 131 71 133 92 109 63
+ 84 109 57 146 78 147 113 74 88 150 87 110 65 121
+ 106 110 124 85 145 107 161 171 150 156 80 171 120
+ 109 158 114 111 136 147 87 173 124 168 173 162 132
+ 101 154 167 190 161 110 156 195 198 102 123 177 169
+ 140 111 180 119 160 197 152 124 121 134 146 147 132
+ 213 141 193 200 210 157 132 136 175 161 218 188 226
+ 191 187 208 211 179 138 144 223 196 214 170 212 202
+ 163 184 172 173 195 229 240 187 210 200 163 227 228
+ 223 191 252 235 225 243 172 187 202 179 179 182 231
+ 261 207 263 206 189 209 212 276 181 274 249 239 234
+ 213 234 269 196 271 221 210 229 235 250 223 232 229
+ 279 224 280 216 207}
+
+do_execsql_test 1.1.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.1.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {65 102 87 138 57 181 80 111 26 48 144 207 36 121
+ 132 101 163 172 196 119 136 63 124 179 110 179 182
+ 74 132 189 51 52 85 216 163 134 123 210 78 141 57
+ 187 71 87 172 173 50 224 88 59 111 170 109 213
+ 223 146 147 84 114 191 206 221 157 161 209 229 74
+ 140 107 187 207 212 124 202 52 232 55 184 229 106
+ 132 152 120 92 110 179 235 65 70 87 110 195 200
+ 175 234 160 234 136 80 113 187 109 121 124 196 156
+ 210 239 250 72 109 188 202 191 105 154 79 231 147
+ 225 103 161 169 223 96 83 249 212 162 227 228 167
+ 180 193 117 177 214 145 208 235 150 110 211 103 158
+ 200 168 229 92 156 243 280 279 116 173 269 271 131
+ 133 223 128 173 197 210 99 150 161 147 218 240 109
+ 136 146 261 263 124 130 252 171 190 213 274 108 195
+ 226 119 124 171 198 120 276}
+
+do_execsql_test 1.1.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {196 134 109 213 223 106 234 191 212 168 229 147 218
+ 240 65 102 119 136 123 210 146 147 132 152 160 105
+ 154 92 156 243 109 136 146 261 263 87 138 63 124
+ 179 78 141 84 120 234 79 231 162 227 228 280 57
+ 181 110 179 57 187 114 191 206 221 92 110 136 147
+ 167 180 193 279 124 130 252 80 182 71 157 161 209
+ 229 179 235 80 225 117 177 214 116 173 269 271 171
+ 111 74 132 189 87 74 140 113 187 103 161 169 145
+ 208 235 131 133 223 190 213 274 26 51 52 85 172
+ 173 107 187 207 212 65 70 109 121 124 223 150 128
+ 108 195 226 48 144 207 216 50 224 124 202 87 110
+ 195 200 196 96 110 211 173 197 119 124 36 121 132
+ 88 52 232 156 210 239 250 83 103 158 210 171 198
+ 101 163 172 163 59 111 170 55 184 229 175 72 109
+ 188 202 249 200 99 150 161 120 276}
+
+do_execsql_test 1.1.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.1.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.1.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 39 {} {} {} {}
+ {} {} {} 91 {} {} {} {} {} 77 54 54 {} {} {}
+ {} 62 {} {} {} {} {} 23 {} {} {} 97 86 {} 59
+ {} 84 {} {} 78 65 {} 16 90 81 {} 59 56 40 54
+ {} 85 {} {} {} {} 38 {} 32 47 {} 74 35 47 98
+ 96 {} 24 {} {} 29 12 46 36 53 {} 81 27 56 {}
+ {} 81 93 63 81 91 68 53 99 89 13 12 97 91 29
+ 7 7 78 35 84 53 84 58 61 91 99 15 61 98 16 5
+ 75 56 2 37 3 96 62 95 43 63 35 78 16 67 43 16
+ 16 90 72 98 85 56 90 46 29 29 4 74 74 2 76 41
+ 46 77 24 27 97 46 89 1 85 1 74 78 61 85 51 59
+ 35 30 56 25 47 28 73 6 73 74 93 43 3 56 47 85
+ 61 61 93 9 97 62}
+
+do_execsql_test 1.1.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 91 {} 11 {} {} {} {}
+ 11 {} {} {} {} {} {} {} {} {} 32 {} {} {} 32
+ {} {} 12 {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} {} {} {} {} {} {} 33 {} 43 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 15 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 47 {} {} {} {} {} {} {} {} {} 98 {} 98
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} 9 9 {} {} {}}
+
+do_execsql_test 1.1.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} 1 2 2 2 2 3 3 4 5 5 5 6 6 6 7 7 7 7
+ 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9 11 11 12
+ 12 12 12 12 12 13 13 14 14 15 15 15 15 15 15
+ 16 16 16 16 16 16 17 17 17 17 19 19 19 19 20
+ 20 21 21 21 21 21 21 22 22 22 22 22 23 23 23
+ 24 25 25 26 26 27 27 27 27 27 27 29 29 29 30
+ 30 30 31 31 31 31 31 32 33 33 33 33 33 33 33
+ 33 33 33 33 34 34 34 34 34 34 34 35 35 36 36
+ 36 37 37 37 37 37 37 38 38 38 38 38 38 39 39
+ 39 39 39 40 41 41 41 41 41 42 43 43 43 43 43
+ 44 44 44 44 46 46 46 47 47 47 47 47 47 47 47
+ 47 47 47 49 49 49 50 51 51 51 52 52 52 53 53
+ 54 54 55 55}
+
+do_execsql_test 1.1.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.1.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 40 {} {} {} 40 41 50 {} {} {} {}
+ 50 {} {} {} 41 {} 10 91 61 {} 30 {} 10 61 30
+ {} {} 10 {} {} {} {} 1 {} 22 80 22 91 93 {}
+ {} 30 {} {} 91 {} 1 30 91 80 91 {} 43 {} 74
+ 21 20 {} {} 74 21 21 2 74 33 81 21 64 64 2 21
+ 93 62 14 14 3 91 11 24 55 93 93 62 90 91 55 3
+ 24 14 24 91 55 15 72 60 72 61 61 34 43 43 43
+ 61 12 4 15 15 51 51 12 23 12 12 25 41 25 13
+ 94 12 70 12 84 32 84 94 70 33 12 12 32 41 91
+ 70 22 33 84 80 31 75 84 53 75 80 84 80 53 53
+ 53 22 44 63 42 95 31 63 44 44 31 90 74 52 63
+ 31 63 1 42 90 90 95 3 42}
+
+do_execsql_test 1.1.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.1.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.1.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 81
+ 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81
+ 81 81 81 81 81 62 62 62 62 62 62 62 62 62 62
+ 62 62 62 62 62 62 93 93 93 93 93 93 93 93 93
+ 93 93 93 93 93 93 93 93 93 93 93 93 54 54 54
+ 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
+ 54 65 65 65 65 65 65 65 65 65 65 65 65 65 65
+ 65 65 65 65 65 65 65 96 96 96 96 96 96 96 96
+ 96 96 96 96 96 96 96 96 96 96 96 96 96 97 97
+ 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97
+ 97 97 97 38 38 38 38 38 38 38 38 38 38 38 38
+ 38 38 38 38 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.1.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1}
+
+do_execsql_test 1.1.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
+ 9 9 9 9}
+
+do_execsql_test 1.1.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90}
+
+do_execsql_test 1.1.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.1.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.1.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.1.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.1.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.1.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.1.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.1.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.1.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.1.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.1.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.1.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.1.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.1.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {89 89.81 89.81.96 89.81.96.59 89.81.96.59.38 89.81.96.59.38.68
+ 89.81.96.59.38.68.39 89.81.96.59.38.68.39.62 89.81.96.59.38.68.39.62.91
+ 89.81.96.59.38.68.39.62.91.46 89.81.96.59.38.68.39.62.91.46.6
+ 89.81.96.59.38.68.39.62.91.46.6.99 89.81.96.59.38.68.39.62.91.46.6.99.97
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7}
+
+do_execsql_test 1.1.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {90 90.40 90.40.30 90.40.30.80 90.40.30.80.20 90.40.30.80.20.90
+ 90.40.30.80.20.90.60 90.40.30.80.20.90.60.70 90.40.30.80.20.90.60.70.80
+ 90.40.30.80.20.90.60.70.80.90 90.40.30.80.20.90.60.70.80.90.30
+ 90.40.30.80.20.90.60.70.80.90.30.50
+ 90.40.30.80.20.90.60.70.80.90.30.50.10
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30 81 81.91 81.91.61
+ 81.91.61.91 81.91.61.91.91 81.91.61.91.91.1 81.91.61.91.91.1.81
+ 81.91.61.91.91.1.81.41 81.91.61.91.91.1.81.41.61
+ 81.91.61.91.91.1.81.41.61.1 81.91.61.91.91.1.81.41.61.1.21
+ 81.91.61.91.91.1.81.41.61.1.21.11 81.91.61.91.91.1.81.41.61.1.21.11.51
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21 62 62.12
+ 62.12.32 62.12.32.22 62.12.32.22.42 62.12.32.22.42.2
+ 62.12.32.22.42.2.72 62.12.32.22.42.2.72.12 62.12.32.22.42.2.72.12.22
+ 62.12.32.22.42.2.72.12.22.2 62.12.32.22.42.2.72.12.22.2.72
+ 62.12.32.22.42.2.72.12.22.2.72.72 62.12.32.22.42.2.72.12.22.2.72.72.12
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82 93 93.23 93.23.93
+ 93.23.93.43 93.23.93.43.3 93.23.93.43.3.43 93.23.93.43.3.43.33
+ 93.23.93.43.3.43.33.53 93.23.93.43.3.43.33.53.63
+ 93.23.93.43.3.43.33.53.63.73 93.23.93.43.3.43.33.53.63.73.13
+ 93.23.93.43.3.43.33.53.63.73.13.73 93.23.93.43.3.43.33.53.63.73.13.73.73
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83 54 54.84
+ 54.84.74 54.84.74.24 54.84.74.24.4 54.84.74.24.4.94
+ 54.84.74.24.4.94.84 54.84.74.24.4.94.84.74 54.84.74.24.4.94.84.74.34
+ 54.84.74.24.4.94.84.74.34.34 54.84.74.24.4.94.84.74.34.34.44
+ 54.84.74.24.4.94.84.74.34.34.44.74 54.84.74.24.4.94.84.74.34.34.44.74.64
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34 65 65.35
+ 65.35.85 65.35.85.85 65.35.85.85.55 65.35.85.85.55.15
+ 65.35.85.85.55.15.25 65.35.85.85.55.15.25.75 65.35.85.85.55.15.25.75.95
+ 65.35.85.85.55.15.25.75.95.65 65.35.85.85.55.15.25.75.95.65.65
+ 65.35.85.85.55.15.25.75.95.65.65.35 65.35.85.85.55.15.25.75.95.65.65.35.5
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95 96 96.46
+ 96.46.6 96.46.6.46 96.46.6.46.16 96.46.6.46.16.16
+ 96.46.6.46.16.16.86 96.46.6.46.16.16.86.56 96.46.6.46.16.16.86.56.56
+ 96.46.6.46.16.16.86.56.56.56 96.46.6.46.16.16.86.56.56.56.16
+ 96.46.6.46.16.16.86.56.56.56.16.36 96.46.6.46.16.16.86.56.56.56.16.36.76
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36 97 97.27
+ 97.27.97 97.27.97.67 97.27.97.67.77 97.27.97.67.77.47
+ 97.27.97.67.77.47.7 97.27.97.67.77.47.7.47 97.27.97.67.77.47.7.47.87
+ 97.27.97.67.77.47.7.47.87.37 97.27.97.67.77.47.7.47.87.37.87
+ 97.27.97.67.77.47.7.47.87.37.87.77 97.27.97.67.77.47.7.47.87.37.87.77.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7 38 38.68
+ 38.68.78 38.68.78.8 38.68.78.8.28 38.68.78.8.28.98
+ 38.68.78.8.28.98.78 38.68.78.8.28.98.78.58 38.68.78.8.28.98.78.58.98
+ 38.68.78.8.28.98.78.58.98.8 38.68.78.8.28.98.78.58.98.8.88
+ 38.68.78.8.28.98.78.58.98.8.88.8 38.68.78.8.28.98.78.58.98.8.88.8.58
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38 89 89.59 89.59.39
+ 89.59.39.99 89.59.39.99.29 89.59.39.99.29.59 89.59.39.99.29.59.89
+ 89.59.39.99.29.59.89.89 89.59.39.99.29.59.89.89.29
+ 89.59.39.99.29.59.89.89.29.9 89.59.39.99.29.59.89.89.29.9.79
+ 89.59.39.99.29.59.89.89.29.9.79.49 89.59.39.99.29.59.89.89.29.9.79.49.59
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.1.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1.1 1.1.2 1.1.2.2 1.1.2.2.3 1.1.2.2.3.3 1.1.2.2.3.3.4
+ 1.1.2.2.3.3.4.5 1.1.2.2.3.3.4.5.6 1.1.2.2.3.3.4.5.6.7
+ 1.1.2.2.3.3.4.5.6.7.7 1.1.2.2.3.3.4.5.6.7.7.7 1.1.2.2.3.3.4.5.6.7.7.7.8
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99}
+
+do_execsql_test 1.1.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {10 10.20 10.20.30 10.20.30.30 10.20.30.30.30 10.20.30.30.30.40
+ 10.20.30.30.30.40.50 10.20.30.30.30.40.50.60 10.20.30.30.30.40.50.60.70
+ 10.20.30.30.30.40.50.60.70.80 10.20.30.30.30.40.50.60.70.80.80
+ 10.20.30.30.30.40.50.60.70.80.80.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90 1 1.1 1.1.11 1.1.11.11
+ 1.1.11.11.21 1.1.11.11.21.21 1.1.11.11.21.21.31 1.1.11.11.21.21.31.31
+ 1.1.11.11.21.21.31.31.41 1.1.11.11.21.21.31.31.41.41
+ 1.1.11.11.21.21.31.31.41.41.51 1.1.11.11.21.21.31.31.41.41.51.61
+ 1.1.11.11.21.21.31.31.41.41.51.61.61
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91 2 2.2
+ 2.2.12 2.2.12.12 2.2.12.12.12 2.2.12.12.12.22 2.2.12.12.12.22.22
+ 2.2.12.12.12.22.22.32 2.2.12.12.12.22.22.32.42
+ 2.2.12.12.12.22.22.32.42.52 2.2.12.12.12.22.22.32.42.52.62
+ 2.2.12.12.12.22.22.32.42.52.62.62 2.2.12.12.12.22.22.32.42.52.62.62.72
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82 3 3.3 3.3.13
+ 3.3.13.13 3.3.13.13.23 3.3.13.13.23.23 3.3.13.13.23.23.33
+ 3.3.13.13.23.23.33.33 3.3.13.13.23.23.33.33.33
+ 3.3.13.13.23.23.33.33.33.33 3.3.13.13.23.23.33.33.33.33.43
+ 3.3.13.13.23.23.33.33.33.33.43.43 3.3.13.13.23.23.33.33.33.33.43.43.53
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93 4 4.14
+ 4.14.24 4.14.24.34 4.14.24.34.34 4.14.24.34.34.34
+ 4.14.24.34.34.34.34 4.14.24.34.34.34.34.44 4.14.24.34.34.34.34.44.44
+ 4.14.24.34.34.34.34.44.44.54 4.14.24.34.34.34.34.44.44.54.64
+ 4.14.24.34.34.34.34.44.44.54.64.74 4.14.24.34.34.34.34.44.44.54.64.74.74
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94 5 5.15
+ 5.15.15 5.15.15.15 5.15.15.15.25 5.15.15.15.25.35
+ 5.15.15.15.25.35.35 5.15.15.15.25.35.35.55 5.15.15.15.25.35.35.55.55
+ 5.15.15.15.25.35.35.55.55.65 5.15.15.15.25.35.35.55.55.65.65
+ 5.15.15.15.25.35.35.55.55.65.65.65 5.15.15.15.25.35.35.55.55.65.65.65.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95 6 6.16
+ 6.16.16 6.16.16.16 6.16.16.16.26 6.16.16.16.26.26
+ 6.16.16.16.26.26.36 6.16.16.16.26.26.36.36 6.16.16.16.26.26.36.36.36
+ 6.16.16.16.26.26.36.36.36.36 6.16.16.16.26.26.36.36.36.36.46
+ 6.16.16.16.26.26.36.36.36.36.46.46 6.16.16.16.26.26.36.36.36.36.46.46.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96 7 7.7
+ 7.7.7 7.7.7.17 7.7.7.17.27 7.7.7.17.27.27 7.7.7.17.27.27.37
+ 7.7.7.17.27.27.37.37 7.7.7.17.27.27.37.37.47 7.7.7.17.27.27.37.37.47.47
+ 7.7.7.17.27.27.37.37.47.47.47 7.7.7.17.27.27.37.37.47.47.47.47
+ 7.7.7.17.27.27.37.37.47.47.47.47.57
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97 8 8.8 8.8.8
+ 8.8.8.28 8.8.8.28.38 8.8.8.28.38.38 8.8.8.28.38.38.58
+ 8.8.8.28.38.38.58.58 8.8.8.28.38.38.58.58.58 8.8.8.28.38.38.58.58.58.58
+ 8.8.8.28.38.38.58.58.58.58.68 8.8.8.28.38.38.58.58.58.58.68.78
+ 8.8.8.28.38.38.58.58.58.58.68.78.78
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98 9 9.9 9.9.9 9.9.9.19
+ 9.9.9.19.29 9.9.9.19.29.29 9.9.9.19.29.29.29 9.9.9.19.29.29.29.39
+ 9.9.9.19.29.29.29.39.39 9.9.9.19.29.29.29.39.39.39
+ 9.9.9.19.29.29.29.39.39.39.49 9.9.9.19.29.29.29.39.39.39.49.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99}
+
+do_execsql_test 1.1.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {90 90.40 90.40.30 90.40.30.80 90.40.30.80.20 90.40.30.80.20.90
+ 90.40.30.80.20.90.60 90.40.30.80.20.90.60.70 90.40.30.80.20.90.60.70.80
+ 90.40.30.80.20.90.60.70.80.90 90.40.30.80.20.90.60.70.80.90.30
+ 90.40.30.80.20.90.60.70.80.90.30.50
+ 90.40.30.80.20.90.60.70.80.90.30.50.10
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.1.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.1.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.1.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.1.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.1.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {1 89 2 89 3 89.96 4 89.96 5 89.96.38 6 89.96.38 7 89.96.38.39
+ 8 89.96.38.39 9 89.96.38.39.91 10 89.96.38.39.91 11 89.96.38.39.91.6
+ 12 89.96.38.39.91.6 13 89.96.38.39.91.6.97 14 89.96.38.39.91.6.97
+ 15 89.96.38.39.91.6.97.46 16 89.96.38.39.91.6.97.46
+ 17 89.96.38.39.91.6.97.46.54 18 89.96.38.39.91.6.97.46.54
+ 19 89.96.38.39.91.6.97.46.54.8 20 89.96.38.39.91.6.97.46.54.8
+ 21 89.96.38.39.91.6.97.46.54.8.29 22 89.96.38.39.91.6.97.46.54.8.29
+ 23 89.96.38.39.91.6.97.46.54.8.29.84 24 89.96.38.39.91.6.97.46.54.8.29.84
+ 25 89.96.38.39.91.6.97.46.54.8.29.84.23
+ 26 89.96.38.39.91.6.97.46.54.8.29.84.23
+ 27 89.96.38.39.91.6.97.46.54.8.29.84.23.16
+ 28 89.96.38.39.91.6.97.46.54.8.29.84.23.16
+ 29 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65
+ 30 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65
+ 31 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47
+ 32 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47
+ 33 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86
+ 34 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86
+ 35 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61
+ 36 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61
+ 37 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85
+ 38 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85
+ 39 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85
+ 40 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85
+ 41 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59
+ 42 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59
+ 43 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32
+ 44 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32
+ 45 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3
+ 46 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3
+ 47 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22
+ 48 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22
+ 49 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55
+ 50 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55
+ 51 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28
+ 52 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28
+ 53 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25
+ 54 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25
+ 55 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1
+ 56 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1
+ 57 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40
+ 58 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40
+ 59 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56
+ 60 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56
+ 61 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75
+ 62 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75
+ 63 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89
+ 64 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89
+ 65 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76
+ 66 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76
+ 67 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4
+ 68 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4
+ 69 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42
+ 70 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42
+ 71 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78
+ 72 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78
+ 73 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29
+ 74 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29
+ 75 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63
+ 76 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63
+ 77 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87
+ 78 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87
+ 79 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80
+ 80 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80
+ 81 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72
+ 82 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72
+ 83 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9
+ 84 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9
+ 85 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73
+ 86 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73
+ 87 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65
+ 88 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65
+ 89 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58
+ 90 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58
+ 91 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98
+ 92 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98
+ 93 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21
+ 94 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21
+ 95 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65
+ 96 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65
+ 97 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5
+ 98 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5
+ 99 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11
+ 100 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11
+ 101 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87
+ 102 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87
+ 103 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12
+ 104 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12
+ 105 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20
+ 106 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20
+ 107 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31
+ 108 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31
+ 109 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95
+ 110 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95
+ 111 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73
+ 112 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73
+ 113 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88
+ 114 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88
+ 115 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8
+ 116 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8
+ 117 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49
+ 118 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49
+ 119 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90
+ 120 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90
+ 121 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96
+ 122 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96
+ 123 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55
+ 124 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55
+ 125 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77
+ 126 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77
+ 127 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2
+ 128 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2
+ 129 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85
+ 130 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85
+ 131 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74
+ 132 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74
+ 133 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70
+ 134 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70
+ 135 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19
+ 136 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19
+ 137 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26
+ 138 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26
+ 139 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47
+ 140 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47
+ 141 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90
+ 142 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90
+ 143 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58
+ 144 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58
+ 145 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9
+ 146 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9
+ 147 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72
+ 148 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72
+ 149 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33
+ 150 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33
+ 151 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75
+ 152 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75
+ 153 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81
+ 154 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81
+ 155 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23
+ 156 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23
+ 157 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13
+ 158 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13
+ 159 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14
+ 160 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14
+ 161 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91
+ 162 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91
+ 163 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91
+ 164 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91
+ 165 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15
+ 166 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15
+ 167 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36
+ 168 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36
+ 169 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3
+ 170 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3
+ 171 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69
+ 172 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69
+ 173 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52
+ 174 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52
+ 175 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50
+ 176 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50
+ 177 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10
+ 178 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10
+ 179 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33
+ 180 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33
+ 181 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39
+ 182 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39
+ 183 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58
+ 184 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58
+ 185 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38
+ 186 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38
+ 187 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83
+ 188 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83
+ 189 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82
+ 190 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7}
+
+do_execsql_test 1.1.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {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 {}
+ 101 {} 102 {} 103 {} 104 {} 105 {} 106 {} 107 {} 108 {}
+ 109 {} 110 {} 111 {} 112 {} 113 {} 114 {} 115 {} 116 {}
+ 117 {} 118 {} 119 {} 120 {} 121 {} 122 {} 123 {} 124 {}
+ 125 {} 126 {} 127 {} 128 {} 129 {} 130 {} 131 {} 132 {}
+ 133 {} 134 {} 135 {} 136 {} 137 {} 138 {} 139 {} 140 {}
+ 141 {} 142 {} 143 {} 144 {} 145 {} 146 {} 147 {} 148 {}
+ 149 {} 150 {} 151 {} 152 {} 153 {} 154 {} 155 {} 156 {}
+ 157 {} 158 {} 159 {} 160 {} 161 {} 162 {} 163 {} 164 {}
+ 165 {} 166 {} 167 {} 168 {} 169 {} 170 {} 171 {} 172 {}
+ 173 {} 174 {} 175 {} 176 {} 177 {} 178 {} 179 {} 180 {}
+ 181 {} 182 {} 183 {} 184 {} 185 {} 186 {} 187 {} 188 {}
+ 189 {} 190 {} 191 {}}
+
+do_execsql_test 1.1.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {}
+ 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {}
+ 20 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {}}
+
+do_execsql_test 1.1.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {1 89 2 89.6 3 89.6.29 4 89.6.29.47 5 89.6.29.47.59
+ 6 89.6.29.47.59.28 7 89.6.29.47.59.28.75 8 89.6.29.47.59.28.75.78
+ 9 89.6.29.47.59.28.75.78.72 10 89.6.29.47.59.28.75.78.72.98
+ 11 89.6.29.47.59.28.75.78.72.98.87 12 89.6.29.47.59.28.75.78.72.98.87.73
+ 13 89.6.29.47.59.28.75.78.72.98.87.73.96
+ 14 89.6.29.47.59.28.75.78.72.98.87.73.96.74
+ 15 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90
+ 16 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75
+ 17 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91
+ 18 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69
+ 19 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 1 96 2 96.97
+ 3 96.97.84 4 96.97.84.86 5 96.97.84.86.32 6 96.97.84.86.32.25
+ 7 96.97.84.86.32.25.89 8 96.97.84.86.32.25.89.29
+ 9 96.97.84.86.32.25.89.29.9 10 96.97.84.86.32.25.89.29.9.21
+ 11 96.97.84.86.32.25.89.29.9.21.12 12 96.97.84.86.32.25.89.29.9.21.12.88
+ 13 96.97.84.86.32.25.89.29.9.21.12.88.55
+ 14 96.97.84.86.32.25.89.29.9.21.12.88.55.70
+ 15 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58
+ 16 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81
+ 17 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91
+ 18 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 1 38 2 38.46
+ 3 38.46.23 4 38.46.23.61 5 38.46.23.61.3 6 38.46.23.61.3.1
+ 7 38.46.23.61.3.1.76 8 38.46.23.61.3.1.76.63 9 38.46.23.61.3.1.76.63.73
+ 10 38.46.23.61.3.1.76.63.73.65 11 38.46.23.61.3.1.76.63.73.65.20
+ 12 38.46.23.61.3.1.76.63.73.65.20.8
+ 13 38.46.23.61.3.1.76.63.73.65.20.8.77
+ 14 38.46.23.61.3.1.76.63.73.65.20.8.77.19
+ 15 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9
+ 16 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23
+ 17 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15
+ 18 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 1 39 2 39.54
+ 3 39.54.16 4 39.54.16.85 5 39.54.16.85.22 6 39.54.16.85.22.40
+ 7 39.54.16.85.22.40.4 8 39.54.16.85.22.40.4.87
+ 9 39.54.16.85.22.40.4.87.65 10 39.54.16.85.22.40.4.87.65.5
+ 11 39.54.16.85.22.40.4.87.65.5.31 12 39.54.16.85.22.40.4.87.65.5.31.49
+ 13 39.54.16.85.22.40.4.87.65.5.31.49.2
+ 14 39.54.16.85.22.40.4.87.65.5.31.49.2.26
+ 15 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72
+ 16 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13
+ 17 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36
+ 18 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 1 91 2 91.8
+ 3 91.8.65 4 91.8.65.85 5 91.8.65.85.55 6 91.8.65.85.55.56
+ 7 91.8.65.85.55.56.42 8 91.8.65.85.55.56.42.80
+ 9 91.8.65.85.55.56.42.80.58 10 91.8.65.85.55.56.42.80.58.11
+ 11 91.8.65.85.55.56.42.80.58.11.95 12 91.8.65.85.55.56.42.80.58.11.95.90
+ 13 91.8.65.85.55.56.42.80.58.11.95.90.85
+ 14 91.8.65.85.55.56.42.80.58.11.95.90.85.47
+ 15 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33
+ 16 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14
+ 17 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3
+ 18 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {}}
+
+do_execsql_test 1.2.2.1 {
+ SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99}
+
+do_execsql_test 1.2.2.2 {
+ SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1}
+
+do_execsql_test 1.2.3.1 {
+ SELECT row_number() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.2.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.2.3.3 {
+ SELECT row_number() OVER ( RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.2.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.2.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.2.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.2.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.2.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.2.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.2.5.1 {
+ SELECT rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.2.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.2.5.3 {
+ SELECT rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.2.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.2.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.2.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.2.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.2.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.2.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.2.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207}
+
+do_execsql_test 1.2.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {223 223 223 223 223 223 223 223 223 223 223 223 223
+ 223 210 210 210 210 210 210 210 210 210 210 210 210
+ 210 210 210 210 210 210 210 210 210 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 279
+ 279 279 279 279 279 279 279 279 279 279 279 279 279
+ 279 279 279 279 279 279 279 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 212 212 212 212 212
+ 212 212 212 212 212 212 212 212 212 212 212 212 212
+ 212 212 212 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 232 232 232
+ 232 232 232 232 232 232 232 232 232 232 232 232 232
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.2.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.2.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {240 240 240 240 240 240 240 240 240 240 240 240 240
+ 240 263 263 263 263 263 263 263 263 263 263 263 263
+ 263 263 263 263 263 263 263 263 263 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 252
+ 252 252 252 252 252 252 252 252 252 252 252 252 252
+ 252 252 252 252 252 252 252 171 171 171 171 171 171
+ 171 171 171 171 171 171 171 171 171 171 171 171 171
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 226 226 226 226 226
+ 226 226 226 226 226 226 226 226 226 226 226 226 226
+ 226 226 226 124 124 124 124 124 124 124 124 124 124
+ 124 124 124 124 124 124 124 124 124 124 198 198 198
+ 198 198 198 198 198 198 198 198 198 198 198 198 198
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.2.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.2.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.2.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 41 5 16 85 42 43 89 1 22 39 51 73 93 22 80
+ 1 73 91 94 35 74 73 37 77 54 54 74 81 91 90
+ 62 65 63 36 1 95 23 95 56 16 97 86 40 59 1 84
+ 98 56 78 65 96 16 90 81 40 59 56 40 54 2 85
+ 96 11 87 41 38 65 32 47 80 74 35 47 98 96 13
+ 24 72 73 29 12 46 36 53 35 81 27 56 5 11 81
+ 93 63 81 91 68 53 99 89 13 12 97 91 29 7 7 78
+ 35 84 53 84 58 61 91 99 15 61 98 16 5 75 56 2
+ 37 3 96 62 95 43 63 35 78 16 67 43 16 16 90
+ 72 98 85 56 90 46 29 29 4 74 74 2 76 41 46 77
+ 24 27 97 46 89 1 85 1 74 78 61 85 51 59 35 30
+ 56 25 47 28 73 6 73 74 93 43 3 56 47 85 61 61
+ 93 9 97 62}
+
+do_execsql_test 1.2.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 91 {} 11 {} {} {} {}
+ 11 {} {} {} {} {} 12 {} {} {} 32 {} 12 {} 32
+ {} {} 12 {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} 33 {} {} {} {} {} 33 {} 43 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} 34 {} {} {} {}
+ {} {} {} {} {} {} 55 {} {} {} {} {} {} 15 55
+ {} {} {} {} {} 55 {} {} {} 86 {} 26 26 {} {}
+ {} {} 26 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 47 {} {} {} {} {} 47 {} {} {} {}
+ {} 27 47 {} {} {} 98 {} {} {} {} {} 98 {} 98
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} 99 {} 9 9 {} {} {}}
+
+do_execsql_test 1.2.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 2 2 3 3 4 5 5 5 6 6 6 7 7 7 7
+ 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9 11 11 12
+ 12 12 12 12 12 13 13 14 14 15 15 15 15 15 15
+ 16 16 16 16 16 16 17 17 17 17 19 19 19 19 20
+ 20 21 21 21 21 21 21 22 22 22 22 22 23 23 23
+ 24 25 25 26 26 27 27 27 27 27 27 29 29 29 30
+ 30 30 31 31 31 31 31 32 33 33 33 33 33 33 33
+ 33 33 33 33 34 34 34 34 34 34 34 35 35 36 36
+ 36 37 37 37 37 37 37 38 38 38 38 38 38 39 39
+ 39 39 39 40 41 41 41 41 41 42 43 43 43 43 43
+ 44 44 44 44 46 46 46 47 47 47 47 47 47 47 47
+ 47 47 47 49 49 49 50 51 51 51 52 52 52 53 53
+ 54 54 55 55}
+
+do_execsql_test 1.2.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1 1
+ 61 61 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 12 12 72 72 72 {} {} {} {} {} {}
+ {} {} {} {} {} 13 13 63 63 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} 34 84 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 35 85 85 85 {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 36 76 76 76 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 37 37 37
+ 87 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} 58 58 58 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 39 39 39 89 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.2.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 2 11 34 81 34 73 33 34 34 11 82 30 11 34
+ 65 13 65 65 40 34 72 13 40 41 50 93 72 81 81
+ 50 34 65 65 41 73 10 91 61 12 30 54 10 61 30
+ 54 54 10 73 23 44 85 1 85 22 80 22 91 93 73
+ 84 30 84 84 91 85 1 30 91 80 91 74 43 64 74
+ 21 20 85 64 74 21 21 2 74 33 81 21 64 64 2 21
+ 93 62 14 14 3 91 11 24 55 93 93 62 90 91 55 3
+ 24 14 24 91 55 15 72 60 72 61 61 34 43 43 43
+ 61 12 4 15 15 51 51 12 23 12 12 25 41 25 13
+ 94 12 70 12 84 32 84 94 70 33 12 12 32 41 91
+ 70 22 33 84 80 31 75 84 53 75 80 84 80 53 53
+ 53 22 44 63 42 95 31 63 44 44 31 90 74 52 63
+ 31 63 1 42 90 90 95 3 42}
+
+do_execsql_test 1.2.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.2.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.2.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 81
+ 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81
+ 81 81 81 81 81 62 62 62 62 62 62 62 62 62 62
+ 62 62 62 62 62 62 93 93 93 93 93 93 93 93 93
+ 93 93 93 93 93 93 93 93 93 93 93 93 54 54 54
+ 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
+ 54 65 65 65 65 65 65 65 65 65 65 65 65 65 65
+ 65 65 65 65 65 65 65 96 96 96 96 96 96 96 96
+ 96 96 96 96 96 96 96 96 96 96 96 96 96 97 97
+ 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97
+ 97 97 97 38 38 38 38 38 38 38 38 38 38 38 38
+ 38 38 38 38 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.2.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1}
+
+do_execsql_test 1.2.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
+ 9 9 9 9}
+
+do_execsql_test 1.2.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90}
+
+do_execsql_test 1.2.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.2.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.2.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.2.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.2.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.2.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.2.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.2.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.2.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.2.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.2.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.2.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.2.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.2.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7}
+
+do_execsql_test 1.2.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.2.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99}
+
+do_execsql_test 1.2.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99}
+
+do_execsql_test 1.2.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.2.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.2.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.2.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.2.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.2.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+} {191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7}
+
+do_execsql_test 1.2.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+} {191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}}
+
+do_execsql_test 1.2.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+} {20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {}
+ 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {}
+ 20 {} 20 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {}}
+
+do_execsql_test 1.2.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+} {20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}}
+
+do_execsql_test 1.3.2.1 {
+ SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.3.2.2 {
+ SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.3.3.1 {
+ SELECT row_number() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.3.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.3.3.3 {
+ SELECT row_number() OVER ( RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.3.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.3.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.3.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.3.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.3.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.3.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.3.5.1 {
+ SELECT rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.3.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.3.5.3 {
+ SELECT rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.3.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.3.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.3.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.3.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.3.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.3.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.3.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {99 92 108 72 52 83 55 79 109 65 26 120 119 50
+ 70 103 80 124 36 96 59 124 116 110 57 51 52 130
+ 103 74 87 48 128 117 105 136 131 71 133 92 109 63
+ 84 109 57 146 78 147 113 74 88 150 87 110 65 121
+ 106 110 124 85 145 107 161 171 150 156 80 171 120
+ 109 158 114 111 136 147 87 173 124 168 173 162 132
+ 101 154 167 190 161 110 156 195 198 102 123 177 169
+ 140 111 180 119 160 197 152 124 121 134 146 147 132
+ 213 141 193 200 210 157 132 136 175 161 218 188 226
+ 191 187 208 211 179 138 144 223 196 214 170 212 202
+ 163 184 172 173 195 229 240 187 210 200 163 227 228
+ 223 191 252 235 225 243 172 187 202 179 179 182 231
+ 261 207 263 206 189 209 212 276 181 274 249 239 234
+ 213 234 269 196 271 221 210 229 235 250 223 232 229
+ 279 224 280 216 207}
+
+do_execsql_test 1.3.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.3.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {65 102 87 138 57 181 80 111 26 48 144 207 36 121
+ 132 101 163 172 196 119 136 63 124 179 110 179 182
+ 74 132 189 51 52 85 216 163 134 123 210 78 141 57
+ 187 71 87 172 173 50 224 88 59 111 170 109 213
+ 223 146 147 84 114 191 206 221 157 161 209 229 74
+ 140 107 187 207 212 124 202 52 232 55 184 229 106
+ 132 152 120 92 110 179 235 65 70 87 110 195 200
+ 175 234 160 234 136 80 113 187 109 121 124 196 156
+ 210 239 250 72 109 188 202 191 105 154 79 231 147
+ 225 103 161 169 223 96 83 249 212 162 227 228 167
+ 180 193 117 177 214 145 208 235 150 110 211 103 158
+ 200 168 229 92 156 243 280 279 116 173 269 271 131
+ 133 223 128 173 197 210 99 150 161 147 218 240 109
+ 136 146 261 263 124 130 252 171 190 213 274 108 195
+ 226 119 124 171 198 120 276}
+
+do_execsql_test 1.3.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {196 134 109 213 223 106 234 191 212 168 229 147 218
+ 240 65 102 119 136 123 210 146 147 132 152 160 105
+ 154 92 156 243 109 136 146 261 263 87 138 63 124
+ 179 78 141 84 120 234 79 231 162 227 228 280 57
+ 181 110 179 57 187 114 191 206 221 92 110 136 147
+ 167 180 193 279 124 130 252 80 182 71 157 161 209
+ 229 179 235 80 225 117 177 214 116 173 269 271 171
+ 111 74 132 189 87 74 140 113 187 103 161 169 145
+ 208 235 131 133 223 190 213 274 26 51 52 85 172
+ 173 107 187 207 212 65 70 109 121 124 223 150 128
+ 108 195 226 48 144 207 216 50 224 124 202 87 110
+ 195 200 196 96 110 211 173 197 119 124 36 121 132
+ 88 52 232 156 210 239 250 83 103 158 210 171 198
+ 101 163 172 163 59 111 170 55 184 229 175 72 109
+ 188 202 249 200 99 150 161 120 276}
+
+do_execsql_test 1.3.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.3.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.3.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.3.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.3.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 19 20 21 21 22 22 23 23 24 25 26 26 27 27 28
+ 29 29 29 30 30 30 31 31 32 33 33 33 33 34 34
+ 34 34 35 35 36 36 36 36 37 37 38 38 39 39 39
+ 40 41 41 42 43 43 44 44 46 46 47 47 47 47 49
+ 50 51 52 53 54 55 55 56 56 56 57 58 58 58 58
+ 59 59 59 59 60 61 61 62 62 63 64 65 65 65 66
+ 67 68 69 70 72 72 72 73 73 73 74 74 74 75 75
+ 75 76 77 77 78 78 79 80 80 81 81 81 82 83 84
+ 84 84 84 85 85 85 86 87 87 88 89 89 89 90 90
+ 90 91 91 91 91 91 93 93 93 94 95 95 95 96 96
+ 96 97 97 98 98 99 99}
+
+do_execsql_test 1.3.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {10 20 30 30 30 40 50 60 70 80 80 90 90 90 1 1
+ 11 11 21 21 31 31 41 41 51 61 61 81 81 81 91
+ 91 91 91 91 2 2 12 12 12 22 22 32 42 52 62 62
+ 72 72 72 82 3 3 13 13 23 23 33 33 33 33 43 43
+ 53 63 73 73 73 83 93 93 93 4 14 24 34 34 34
+ 34 44 44 54 64 74 74 74 84 84 84 84 94 5 15
+ 15 15 25 35 35 55 55 65 65 65 75 75 75 85 85
+ 85 95 95 95 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 86 96 96 96 7 7 7 17 27 27
+ 37 37 47 47 47 47 57 67 77 77 87 87 97 97 8 8
+ 8 28 38 38 58 58 58 58 68 78 78 88 98 98 9 9
+ 9 19 29 29 29 39 39 39 49 59 59 59 59 69 79
+ 89 89 89 99 99}
+
+do_execsql_test 1.3.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.3.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.3.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.3.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.3.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.3.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.3.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.3.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.3.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.3.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.3.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 19 20 21 21 22 22 23 23 24 25 26 26 27 27 28
+ 29 29 29 30 30 30 31 31 32 33 33 33 33 34 34
+ 34 34 35 35 36 36 36 36 37 37 38 38 39 39 39
+ 40 41 41 42 43 43 44 44 46 46 47 47 47 47 49
+ 50 51 52 53 54 55 55 56 56 56 57 58 58 58 58
+ 59 59 59 59 60 61 61 62 62 63 64 65 65 65 66
+ 67 68 69 70 72 72 72 73 73 73 74 74 74 75 75
+ 75 76 77 77 78 78 79 80 80 81 81 81 82 83 84
+ 84 84 84 85 85 85 86 87 87 88 89 89 89 90 90
+ 90 91 91 91 91 91 93 93 93 94 95 95 95 96 96
+ 96 97 97 98 98 99 99}
+
+do_execsql_test 1.3.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {10 20 30 30 30 40 50 60 70 80 80 90 90 90 1 1
+ 11 11 21 21 31 31 41 41 51 61 61 81 81 81 91
+ 91 91 91 91 2 2 12 12 12 22 22 32 42 52 62 62
+ 72 72 72 82 3 3 13 13 23 23 33 33 33 33 43 43
+ 53 63 73 73 73 83 93 93 93 4 14 24 34 34 34
+ 34 44 44 54 64 74 74 74 84 84 84 84 94 5 15
+ 15 15 25 35 35 55 55 65 65 65 75 75 75 85 85
+ 85 95 95 95 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 86 96 96 96 7 7 7 17 27 27
+ 37 37 47 47 47 47 57 67 77 77 87 87 97 97 8 8
+ 8 28 38 38 58 58 58 58 68 78 78 88 98 98 9 9
+ 9 19 29 29 29 39 39 39 49 59 59 59 59 69 79
+ 89 89 89 99 99}
+
+do_execsql_test 1.3.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.3.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.3.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.3.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.3.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.3.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+} {1 89 1 {} 1 96 1 {} 1 38 1 {} 1 39 1 {} 1 91 1 {} 1 6
+ 1 {} 1 97 1 {} 1 46 1 {} 1 54 1 {} 1 8 1 {} 1 29 1 {}
+ 1 84 1 {} 1 23 1 {} 1 16 1 {} 1 65 1 {} 1 47 1 {} 1 86
+ 1 {} 1 61 1 {} 1 85 1 {} 1 85 1 {} 1 59 1 {} 1 32 1 {}
+ 1 3 1 {} 1 22 1 {} 1 55 1 {} 1 28 1 {} 1 25 1 {} 1 1
+ 1 {} 1 40 1 {} 1 56 1 {} 1 75 1 {} 1 89 1 {} 1 76 1 {}
+ 1 4 1 {} 1 42 1 {} 1 78 1 {} 1 29 1 {} 1 63 1 {} 1 87
+ 1 {} 1 80 1 {} 1 72 1 {} 1 9 1 {} 1 73 1 {} 1 65 1 {}
+ 1 58 1 {} 1 98 1 {} 1 21 1 {} 1 65 1 {} 1 5 1 {} 1 11
+ 1 {} 1 87 1 {} 1 12 1 {} 1 20 1 {} 1 31 1 {} 1 95 1 {}
+ 1 73 1 {} 1 88 1 {} 1 8 1 {} 1 49 1 {} 1 90 1 {} 1 96
+ 1 {} 1 55 1 {} 1 77 1 {} 1 2 1 {} 1 85 1 {} 1 74 1 {}
+ 1 70 1 {} 1 19 1 {} 1 26 1 {} 1 47 1 {} 1 90 1 {} 1 58
+ 1 {} 1 9 1 {} 1 72 1 {} 1 33 1 {} 1 75 1 {} 1 81 1 {}
+ 1 23 1 {} 1 13 1 {} 1 14 1 {} 1 91 1 {} 1 91 1 {} 1 15
+ 1 {} 1 36 1 {} 1 3 1 {} 1 69 1 {} 1 52 1 {} 1 50 1 {}
+ 1 10 1 {} 1 33 1 {} 1 39 1 {} 1 58 1 {} 1 38 1 {} 1 83
+ 1 {} 1 82 1 {} 1 7}
+
+do_execsql_test 1.3.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+} {1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {}}
+
+do_execsql_test 1.3.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+} {1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {}}
+
+do_execsql_test 1.3.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+} {1 89 1 6 1 29 1 47 1 59 1 28 1 75 1 78 1 72 1 98 1 87
+ 1 73 1 96 1 74 1 90 1 75 1 91 1 69 1 39 1 7 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 96 1 97 1 84 1 86 1 32
+ 1 25 1 89 1 29 1 9 1 21 1 12 1 88 1 55 1 70 1 58 1 81
+ 1 91 1 52 1 58 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 38 1 46 1 23 1 61 1 3 1 1 1 76 1 63 1 73 1 65 1 20
+ 1 8 1 77 1 19 1 9 1 23 1 15 1 50 1 38 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 39 1 54 1 16 1 85 1 22 1 40
+ 1 4 1 87 1 65 1 5 1 31 1 49 1 2 1 26 1 72 1 13 1 36
+ 1 10 1 83 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 91
+ 1 8 1 65 1 85 1 55 1 56 1 42 1 80 1 58 1 11 1 95 1 90
+ 1 85 1 47 1 33 1 14 1 3 1 33 1 82 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {}}
+
+do_execsql_test 1.4.2.1 {
+ SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 95 95 84 84 84 84 84 84 84 84 83 83
+ 83 83 83 83 83 83 83 82 82 17 7}
+
+do_execsql_test 1.4.2.2 {
+ SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 7}
+
+do_execsql_test 1.4.3.1 {
+ SELECT row_number() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.4.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.4.3.3 {
+ SELECT row_number() OVER ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.4.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.4.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.4.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.4.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.4.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.4.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.4.5.1 {
+ SELECT rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.4.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.4.5.3 {
+ SELECT rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.4.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.4.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.4.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.4.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.4.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.4.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.4.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207}
+
+do_execsql_test 1.4.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {223 223 223 223 223 223 223 223 223 223 223 223 223
+ 223 210 210 210 210 210 210 210 210 210 210 210 210
+ 210 210 210 210 210 210 210 210 210 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 279
+ 279 279 279 279 279 279 279 279 279 279 279 279 279
+ 279 279 279 279 279 279 279 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 212 212 212 212 212
+ 212 212 212 212 212 212 212 212 212 212 212 212 212
+ 212 212 212 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 232 232 232
+ 232 232 232 232 232 232 232 232 232 232 232 232 232
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.4.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.4.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {240 240 240 240 240 240 240 240 240 240 240 240 240
+ 240 263 263 263 263 263 263 263 263 263 263 263 263
+ 263 263 263 263 263 263 263 263 263 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 252
+ 252 252 252 252 252 252 252 252 252 252 252 252 252
+ 252 252 252 252 252 252 252 171 171 171 171 171 171
+ 171 171 171 171 171 171 171 171 171 171 171 171 171
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 226 226 226 226 226
+ 226 226 226 226 226 226 226 226 226 226 226 226 226
+ 226 226 226 124 124 124 124 124 124 124 124 124 124
+ 124 124 124 124 124 124 124 124 124 124 198 198 198
+ 198 198 198 198 198 198 198 198 198 198 198 198 198
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.4.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.4.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.4.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.4.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.4.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.4.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 19 20 21 21 22 22 23 23 24 25 26 26 27 27 28
+ 29 29 29 30 30 30 31 31 32 33 33 33 33 34 34
+ 34 34 35 35 36 36 36 36 37 37 38 38 39 39 39
+ 40 41 41 42 43 43 44 44 46 46 47 47 47 47 49
+ 50 51 52 53 54 55 55 56 56 56 57 58 58 58 58
+ 59 59 59 59 60 61 61 62 62 63 64 65 65 65 66
+ 67 68 69 70 72 72 72 73 73 73 74 74 74 75 75
+ 75 76 77 77 78 78 79 80 80 81 81 81 82 83 84
+ 84 84 84 85 85 85 86 87 87 88 89 89 89 90 90
+ 90 91 91 91 91 91 93 93 93 94 95 95 95 96 96
+ 96 97 97 98 98 99 99}
+
+do_execsql_test 1.4.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {10 20 30 30 30 40 50 60 70 80 80 90 90 90 1 1
+ 11 11 21 21 31 31 41 41 51 61 61 81 81 81 91
+ 91 91 91 91 2 2 12 12 12 22 22 32 42 52 62 62
+ 72 72 72 82 3 3 13 13 23 23 33 33 33 33 43 43
+ 53 63 73 73 73 83 93 93 93 4 14 24 34 34 34
+ 34 44 44 54 64 74 74 74 84 84 84 84 94 5 15
+ 15 15 25 35 35 55 55 65 65 65 75 75 75 85 85
+ 85 95 95 95 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 86 96 96 96 7 7 7 17 27 27
+ 37 37 47 47 47 47 57 67 77 77 87 87 97 97 8 8
+ 8 28 38 38 58 58 58 58 68 78 78 88 98 98 9 9
+ 9 19 29 29 29 39 39 39 49 59 59 59 59 69 79
+ 89 89 89 99 99}
+
+do_execsql_test 1.4.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.4.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.4.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.4.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.4.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.4.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.4.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.4.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.4.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.21.39.44.58.30.38.34.83.27.82.17.7 21.39.44.58.30.38.34.83.27.82.17.7
+ 39.44.58.30.38.34.83.27.82.17.7 44.58.30.38.34.83.27.82.17.7
+ 58.30.38.34.83.27.82.17.7 30.38.34.83.27.82.17.7 38.34.83.27.82.17.7
+ 34.83.27.82.17.7 83.27.82.17.7 27.82.17.7 82.17.7 17.7 7}
+
+do_execsql_test 1.4.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 40.30.80.20.90.60.70.80.90.30.50.10.30
+ 30.80.20.90.60.70.80.90.30.50.10.30 80.20.90.60.70.80.90.30.50.10.30
+ 20.90.60.70.80.90.30.50.10.30 90.60.70.80.90.30.50.10.30
+ 60.70.80.90.30.50.10.30 70.80.90.30.50.10.30 80.90.30.50.10.30
+ 90.30.50.10.30 30.50.10.30 50.10.30 10.30 30
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.1.21.11.51.41.31.31.11.81.91.91.21 1.21.11.51.41.31.31.11.81.91.91.21
+ 21.11.51.41.31.31.11.81.91.91.21 11.51.41.31.31.11.81.91.91.21
+ 51.41.31.31.11.81.91.91.21 41.31.31.11.81.91.91.21 31.31.11.81.91.91.21
+ 31.11.81.91.91.21 11.81.91.91.21 81.91.91.21 91.91.21 91.21 21
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 22.42.2.72.12.22.2.72.72.12.62.52.82 42.2.72.12.22.2.72.72.12.62.52.82
+ 2.72.12.22.2.72.72.12.62.52.82 72.12.22.2.72.72.12.62.52.82
+ 12.22.2.72.72.12.62.52.82 22.2.72.72.12.62.52.82 2.72.72.12.62.52.82
+ 72.72.12.62.52.82 72.12.62.52.82 12.62.52.82 62.52.82 52.82 82
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 63.73.13.73.73.33.93.23.13.33.3.33.83 73.13.73.73.33.93.23.13.33.3.33.83
+ 13.73.73.33.93.23.13.33.3.33.83 73.73.33.93.23.13.33.3.33.83
+ 73.33.93.23.13.33.3.33.83 33.93.23.13.33.3.33.83 93.23.13.33.3.33.83
+ 23.13.33.3.33.83 13.33.3.33.83 33.3.33.83 3.33.83 33.83 83
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.34.34.44.74.64.14.34.84.84.44.34 34.34.44.74.64.14.34.84.84.44.34
+ 34.44.74.64.14.34.84.84.44.34 44.74.64.14.34.84.84.44.34
+ 74.64.14.34.84.84.44.34 64.14.34.84.84.44.34 14.34.84.84.44.34
+ 34.84.84.44.34 84.84.44.34 84.44.34 44.34 34
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 95.65.65.35.5.15.95.55.75.85.75.15.95 65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.5.15.95.55.75.85.75.15.95 35.5.15.95.55.75.85.75.15.95
+ 5.15.95.55.75.85.75.15.95 15.95.55.75.85.75.15.95 95.55.75.85.75.15.95
+ 55.75.85.75.15.95 75.85.75.15.95 85.75.15.95 75.15.95 15.95 95
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.16.36.76.96.96.26.26.36.66.36.36 16.36.76.96.96.26.26.36.66.36.36
+ 36.76.96.96.26.26.36.66.36.36 76.96.96.26.26.36.66.36.36
+ 96.96.26.26.36.66.36.36 96.26.26.36.66.36.36 26.26.36.66.36.36
+ 26.36.66.36.36 36.66.36.36 66.36.36 36.36 36
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.87.37.87.77.7.57.47.47.37.27.17.7 87.37.87.77.7.57.47.47.37.27.17.7
+ 37.87.77.7.57.47.47.37.27.17.7 87.77.7.57.47.47.37.27.17.7
+ 77.7.57.47.47.37.27.17.7 7.57.47.47.37.27.17.7 57.47.47.37.27.17.7
+ 47.47.37.27.17.7 47.37.27.17.7 37.27.17.7 27.17.7 17.7 7
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 8.28.98.78.58.98.8.88.8.58.58.58.38 28.98.78.58.98.8.88.8.58.58.58.38
+ 98.78.58.98.8.88.8.58.58.58.38 78.58.98.8.88.8.58.58.58.38
+ 58.98.8.88.8.58.58.58.38 98.8.88.8.58.58.58.38 8.88.8.58.58.58.38
+ 88.8.58.58.58.38 8.58.58.58.38 58.58.58.38 58.58.38 58.38 38
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39 9.99.69.39 99.69.39 69.39 39}
+
+do_execsql_test 1.4.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 94.95.95.95.96.96.96.97.97.98.98.99.99
+ 95.95.95.96.96.96.97.97.98.98.99.99 95.95.96.96.96.97.97.98.98.99.99
+ 95.96.96.96.97.97.98.98.99.99 96.96.96.97.97.98.98.99.99
+ 96.96.97.97.98.98.99.99 96.97.97.98.98.99.99 97.97.98.98.99.99
+ 97.98.98.99.99 98.98.99.99 98.99.99 99.99 99}
+
+do_execsql_test 1.4.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 20.30.30.30.40.50.60.70.80.80.90.90.90
+ 30.30.30.40.50.60.70.80.80.90.90.90 30.30.40.50.60.70.80.80.90.90.90
+ 30.40.50.60.70.80.80.90.90.90 40.50.60.70.80.80.90.90.90
+ 50.60.70.80.80.90.90.90 60.70.80.80.90.90.90 70.80.80.90.90.90
+ 80.80.90.90.90 80.90.90.90 90.90.90 90.90 90
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.51.61.61.81.81.81.91.91.91.91.91 51.61.61.81.81.81.91.91.91.91.91
+ 61.61.81.81.81.91.91.91.91.91 61.81.81.81.91.91.91.91.91
+ 81.81.81.91.91.91.91.91 81.81.91.91.91.91.91 81.91.91.91.91.91
+ 91.91.91.91.91 91.91.91.91 91.91.91 91.91 91
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.22.22.32.42.52.62.62.72.72.72.82 22.22.32.42.52.62.62.72.72.72.82
+ 22.32.42.52.62.62.72.72.72.82 32.42.52.62.62.72.72.72.82
+ 42.52.62.62.72.72.72.82 52.62.62.72.72.72.82 62.62.72.72.72.82
+ 62.72.72.72.82 72.72.72.82 72.72.82 72.82 82
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.43.43.53.63.73.73.73.83.93.93.93 43.43.53.63.73.73.73.83.93.93.93
+ 43.53.63.73.73.73.83.93.93.93 53.63.73.73.73.83.93.93.93
+ 63.73.73.73.83.93.93.93 73.73.73.83.93.93.93 73.73.83.93.93.93
+ 73.83.93.93.93 83.93.93.93 93.93.93 93.93 93
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.44.44.54.64.74.74.74.84.84.84.84.94
+ 44.44.54.64.74.74.74.84.84.84.84.94 44.54.64.74.74.74.84.84.84.84.94
+ 54.64.74.74.74.84.84.84.84.94 64.74.74.74.84.84.84.84.94
+ 74.74.74.84.84.84.84.94 74.74.84.84.84.84.94 74.84.84.84.84.94
+ 84.84.84.84.94 84.84.84.94 84.84.94 84.94 94
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.65.65.65.75.75.75.85.85.85.95.95.95
+ 65.65.65.75.75.75.85.85.85.95.95.95 65.65.75.75.75.85.85.85.95.95.95
+ 65.75.75.75.85.85.85.95.95.95 75.75.75.85.85.85.95.95.95
+ 75.75.85.85.85.95.95.95 75.85.85.85.95.95.95 85.85.85.95.95.95
+ 85.85.95.95.95 85.95.95.95 95.95.95 95.95 95
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.46.46.56.56.56.66.76.86.96.96.96 46.46.56.56.56.66.76.86.96.96.96
+ 46.56.56.56.66.76.86.96.96.96 56.56.56.66.76.86.96.96.96
+ 56.56.66.76.86.96.96.96 56.66.76.86.96.96.96 66.76.86.96.96.96
+ 76.86.96.96.96 86.96.96.96 96.96.96 96.96 96
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.47.47.47.47.57.67.77.77.87.87.97.97
+ 47.47.47.47.57.67.77.77.87.87.97.97 47.47.47.57.67.77.77.87.87.97.97
+ 47.47.57.67.77.77.87.87.97.97 47.57.67.77.77.87.87.97.97
+ 57.67.77.77.87.87.97.97 67.77.77.87.87.97.97 77.77.87.87.97.97
+ 77.87.87.97.97 87.87.97.97 87.97.97 97.97 97
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 28.38.38.58.58.58.58.68.78.78.88.98.98
+ 38.38.58.58.58.58.68.78.78.88.98.98 38.58.58.58.58.68.78.78.88.98.98
+ 58.58.58.58.68.78.78.88.98.98 58.58.58.68.78.78.88.98.98
+ 58.58.68.78.78.88.98.98 58.68.78.78.88.98.98 68.78.78.88.98.98
+ 78.78.88.98.98 78.88.98.98 88.98.98 98.98 98
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.49.59.59.59.59.69.79.89.89.89.99.99
+ 49.59.59.59.59.69.79.89.89.89.99.99 59.59.59.59.69.79.89.89.89.99.99
+ 59.59.59.69.79.89.89.89.99.99 59.59.69.79.89.89.89.99.99
+ 59.69.79.89.89.89.99.99 69.79.89.89.89.99.99 79.89.89.89.99.99
+ 89.89.89.99.99 89.89.99.99 89.99.99 99.99 99}
+
+do_execsql_test 1.4.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39 9.99.69.39 99.69.39 69.39 39}
+
+do_execsql_test 1.4.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.4.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.4.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.4.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.4.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+} {191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 189 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 188 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 187 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 186 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 185 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 184 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 183 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 182 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 181 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 180 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 179 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 178 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 177 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 176 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 175 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 174 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 173 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 172 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 171 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 170 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 169 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 168 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 167 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 166 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 165 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 164 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 163 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 162 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 161 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 160 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 159 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 158 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 157 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 156 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 155 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 154 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 153 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 152 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 151 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 150 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 149 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 148 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 147 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 146 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 145 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 144 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 143 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 142 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 141 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 140 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 139 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 138 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 137 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 136 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 135 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 134 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 133 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 132 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 131 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 130 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 129 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 128 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 127 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 126 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 125 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 124 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 123 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 122 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 121 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 120 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 119 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 118 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 117 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 116 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 115 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 114 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 113 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 112 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 111 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 110 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 109 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 108 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 107 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 106 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 105 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 104 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 103 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 102 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 101 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 100 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 99 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 98 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 97 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 96 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 95 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 94 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 93 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 92 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 91 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 90 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 89 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 88 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 87 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 86 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 85 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 84 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 83 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 82 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 81 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 80 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 79 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 78 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 77 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 76 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 75 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 74 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 73 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 72 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 71 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 70 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 69 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 68 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 67 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 66 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 65 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 64 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 63 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 62 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 61 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 60 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 59 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 58 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 57 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 56 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 55 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 54 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 53 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 52 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 51 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 50 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 49 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 48 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 47 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 46 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 45 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 44 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 43 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 42 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 41 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 40 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 39 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 38 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 37 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 36 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 35 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 34 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 33 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 32 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 31 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 30 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 29 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 28 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 27 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 26 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 25 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 24 3.69.52.50.10.33.39.58.38.83.82.7 23 3.69.52.50.10.33.39.58.38.83.82.7
+ 22 69.52.50.10.33.39.58.38.83.82.7 21 69.52.50.10.33.39.58.38.83.82.7
+ 20 52.50.10.33.39.58.38.83.82.7 19 52.50.10.33.39.58.38.83.82.7
+ 18 50.10.33.39.58.38.83.82.7 17 50.10.33.39.58.38.83.82.7
+ 16 10.33.39.58.38.83.82.7 15 10.33.39.58.38.83.82.7
+ 14 33.39.58.38.83.82.7 13 33.39.58.38.83.82.7 12 39.58.38.83.82.7
+ 11 39.58.38.83.82.7 10 58.38.83.82.7 9 58.38.83.82.7 8 38.83.82.7
+ 7 38.83.82.7 6 83.82.7 5 83.82.7 4 82.7 3 82.7 2 7 1 7}
+
+do_execsql_test 1.4.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+} {191 {} 190 {} 189 {} 188 {} 187 {} 186 {} 185 {} 184 {}
+ 183 {} 182 {} 181 {} 180 {} 179 {} 178 {} 177 {} 176 {}
+ 175 {} 174 {} 173 {} 172 {} 171 {} 170 {} 169 {} 168 {}
+ 167 {} 166 {} 165 {} 164 {} 163 {} 162 {} 161 {} 160 {}
+ 159 {} 158 {} 157 {} 156 {} 155 {} 154 {} 153 {} 152 {}
+ 151 {} 150 {} 149 {} 148 {} 147 {} 146 {} 145 {} 144 {}
+ 143 {} 142 {} 141 {} 140 {} 139 {} 138 {} 137 {} 136 {}
+ 135 {} 134 {} 133 {} 132 {} 131 {} 130 {} 129 {} 128 {}
+ 127 {} 126 {} 125 {} 124 {} 123 {} 122 {} 121 {} 120 {}
+ 119 {} 118 {} 117 {} 116 {} 115 {} 114 {} 113 {} 112 {}
+ 111 {} 110 {} 109 {} 108 {} 107 {} 106 {} 105 {} 104 {}
+ 103 {} 102 {} 101 {} 100 {} 99 {} 98 {} 97 {} 96 {} 95 {}
+ 94 {} 93 {} 92 {} 91 {} 90 {} 89 {} 88 {} 87 {} 86 {}
+ 85 {} 84 {} 83 {} 82 {} 81 {} 80 {} 79 {} 78 {} 77 {}
+ 76 {} 75 {} 74 {} 73 {} 72 {} 71 {} 70 {} 69 {} 68 {}
+ 67 {} 66 {} 65 {} 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_execsql_test 1.4.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+} {20 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {}}
+
+do_execsql_test 1.4.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+} {20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 18 29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 17 47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 16 59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 15 28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 14 75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 13 78.72.98.87.73.96.74.90.75.91.69.39.7
+ 12 72.98.87.73.96.74.90.75.91.69.39.7 11 98.87.73.96.74.90.75.91.69.39.7
+ 10 87.73.96.74.90.75.91.69.39.7 9 73.96.74.90.75.91.69.39.7
+ 8 96.74.90.75.91.69.39.7 7 74.90.75.91.69.39.7 6 90.75.91.69.39.7
+ 5 75.91.69.39.7 4 91.69.39.7 3 69.39.7 2 39.7 1 7 19 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 17 84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 16 86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 15 32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 14 25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 13 89.29.9.21.12.88.55.70.58.81.91.52.58
+ 12 29.9.21.12.88.55.70.58.81.91.52.58 11 9.21.12.88.55.70.58.81.91.52.58
+ 10 21.12.88.55.70.58.81.91.52.58 9 12.88.55.70.58.81.91.52.58
+ 8 88.55.70.58.81.91.52.58 7 55.70.58.81.91.52.58 6 70.58.81.91.52.58
+ 5 58.81.91.52.58 4 81.91.52.58 3 91.52.58 2 52.58 1 58 19 {}
+ 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {}
+ 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 17 23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 16 61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 15 3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 14 1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 13 76.63.73.65.20.8.77.19.9.23.15.50.38
+ 12 63.73.65.20.8.77.19.9.23.15.50.38 11 73.65.20.8.77.19.9.23.15.50.38
+ 10 65.20.8.77.19.9.23.15.50.38 9 20.8.77.19.9.23.15.50.38
+ 8 8.77.19.9.23.15.50.38 7 77.19.9.23.15.50.38 6 19.9.23.15.50.38
+ 5 9.23.15.50.38 4 23.15.50.38 3 15.50.38 2 50.38 1 38 19 {}
+ 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {}
+ 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 17 16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 16 85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 15 22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 14 40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 13 4.87.65.5.31.49.2.26.72.13.36.10.83
+ 12 87.65.5.31.49.2.26.72.13.36.10.83 11 65.5.31.49.2.26.72.13.36.10.83
+ 10 5.31.49.2.26.72.13.36.10.83 9 31.49.2.26.72.13.36.10.83
+ 8 49.2.26.72.13.36.10.83 7 2.26.72.13.36.10.83 6 26.72.13.36.10.83
+ 5 72.13.36.10.83 4 13.36.10.83 3 36.10.83 2 10.83 1 83 19 {}
+ 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {}
+ 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 17 65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 16 85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 15 55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 14 56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 13 42.80.58.11.95.90.85.47.33.14.3.33.82
+ 12 80.58.11.95.90.85.47.33.14.3.33.82 11 58.11.95.90.85.47.33.14.3.33.82
+ 10 11.95.90.85.47.33.14.3.33.82 9 95.90.85.47.33.14.3.33.82
+ 8 90.85.47.33.14.3.33.82 7 85.47.33.14.3.33.82 6 47.33.14.3.33.82
+ 5 33.14.3.33.82 4 14.3.33.82 3 3.33.82 2 33.82 1 82 19 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}}
+
+do_execsql_test 1.5.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 89 89 96 96 96 96 96 96 96 96 96
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99}
+
+do_execsql_test 1.5.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 89 81 81 59 38 38 38 38 38 38 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 3 3 3 3 3 3
+ 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1}
+
+do_execsql_test 1.5.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.5.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.5.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.5.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.5.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.5.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.5.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.5.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.5.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.5.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.5.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.5.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.5.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.5.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.5.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.5.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.5.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.5.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.5.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 99 92 108 72 52 83 55 79 109 65 26
+ 120 119 50 70 103 80 124 36 96 59 124 116 110 57
+ 51 52 130 103 74 87 48 128 117 105 136 131 71 133
+ 92 109 63 84 109 57 146 78 147 113 74 88 150 87
+ 110 65 121 106 110 124 85 145 107 161 171 150 156
+ 80 171 120 109 158 114 111 136 147 87 173 124 168
+ 173 162 132 101 154 167 190 161 110 156 195 198 102
+ 123 177 169 140 111 180 119 160 197 152 124 121 134
+ 146 147 132 213 141 193 200 210 157 132 136 175 161
+ 218 188 226 191 187 208 211 179 138 144 223 196 214
+ 170 212 202 163 184 172 173 195 229 240 187 210 200
+ 163 227 228 223 191 252 235 225 243 172 187 202 179
+ 179 182 231 261 207 263 206 189 209 212 276 181 274
+ 249 239 234 213 234 269 196 271 221 210 229 235 250
+ 223 232 229 279}
+
+do_execsql_test 1.5.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 147 106 109 168 134 218 191 212 229
+ 240 {} {} {} {} 92 109 105 136 146 65 156 132 154
+ 102 123 119 160 152 146 147 136 {} {} {} {} 79 63
+ 84 78 120 87 162 124 141 138 227 228 {} {} {} {}
+ 124 57 130 92 57 110 114 136 147 167 110 180 193
+ 191 252 187 179 {} {} {} {} 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 {} {} {} {}
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 {} {} {} {} 108 65 26 70 51 52
+ 128 109 121 124 85 107 150 195 226 172 173 {} {}
+ {} {} 119 50 124 96 110 87 48 110 173 124 197 211
+ 144 196 195 200 {} {} {} {} 52 83 103 36 88 171
+ 158 156 198 121 210 132 {} {} {} {} 99 72 55 120
+ 59 109 150 161 111 101 200 175 188 170 202 163 184
+ 163}
+
+do_execsql_test 1.5.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 65 102 87 138 57 181 80 111 26 48
+ 144 207 36 121 132 101 163 172 196 119 136 63 124
+ 179 110 179 182 74 132 189 51 52 85 216 163 134
+ 123 210 78 141 57 187 71 87 172 173 50 224 88 59
+ 111 170 109 213 223 146 147 84 114 191 206 221 157
+ 161 209 229 74 140 107 187 207 212 124 202 52 232
+ 55 184 229 106 132 152 120 92 110 179 235 65 70
+ 87 110 195 200 175 234 160 234 136 80 113 187 109
+ 121 124 196 156 210 239 250 72 109 188 202 191 105
+ 154 79 231 147 225 103 161 169 223 96 83 249 212
+ 162 227 228 167 180 193 117 177 214 145 208 235 150
+ 110 211 103 158 200 168 229 92 156 243 280 279 116
+ 173 269 271 131 133 223 128 173 197 210 99 150 161
+ 147 218 240 109 136 146 261 263 124 130 252 171 190
+ 213 274 108 195 226 119 124}
+
+do_execsql_test 1.5.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 196 134 109 213 223 106 234 191 212
+ 168 {} {} {} {} 65 102 119 136 123 210 146 147
+ 132 152 160 105 154 92 156 243 109 {} {} {} {} 87
+ 138 63 124 179 78 141 84 120 234 79 231 {} {} {}
+ {} 57 181 110 179 57 187 114 191 206 221 92 110
+ 136 147 167 180 193 {} {} {} {} 80 182 71 157 161
+ 209 229 179 235 80 225 117 177 214 116 {} {} {}
+ {} 111 74 132 189 87 74 140 113 187 103 161 169
+ 145 208 235 131 133 {} {} {} {} 26 51 52 85 172
+ 173 107 187 207 212 65 70 109 121 124 223 150 {}
+ {} {} {} 48 144 207 216 50 224 124 202 87 110 195
+ 200 196 96 110 211 {} {} {} {} 36 121 132 88 52
+ 232 156 210 239 250 83 103 {} {} {} {} 101 163
+ 172 163 59 111 170 55 184 229 175 72 109 188 202
+ 249 200 99}
+
+do_execsql_test 1.5.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 147 106 109 168 134 218 191 212 229
+ 240 213 234 196 223 92 109 105 136 146 65 156 132
+ 154 102 123 119 160 152 146 147 136 243 261 263 210
+ 79 63 84 78 120 87 162 124 141 138 227 228 179
+ 231 234 280 124 57 130 92 57 110 114 136 147 167
+ 110 180 193 191 252 187 179 206 181 221 279 80 116
+ 117 71 80 171 173 177 157 161 179 214 225 182 209
+ 269 271 235 229 103 74 131 133 113 74 87 145 190
+ 161 169 140 111 132 213 187 208 223 235 189 274 108
+ 65 26 70 51 52 128 109 121 124 85 107 150 195 226
+ 172 173 187 223 207 212 119 50 124 96 110 87 48
+ 110 173 124 197 211 144 196 195 200 202 224 216 207
+ 52 83 103 36 88 171 158 156 198 121 210 132 210
+ 239 250 232 99 72 55 120 59 109 150 161 111 101
+ 200 175 188 170 202 163 184 163}
+
+do_execsql_test 1.5.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 39 {} {} {} {}
+ {} {} {} 91 {} {} {} {} {} {} 54 54 {} {} {}
+ {} 62 {} {} {} {} {} 23 {} {} {} 97 86 {} 59
+ {} 84 {} {} 78 65 {} 16 90 81 {} 59 56 {} 54
+ {} 85 {} {} {} {} 38 {} 32 47 {} 74 35 47 98
+ 96 {} 24 {} {} 29 12 46 36 53 {} 81 27 56 {}
+ {} 81 93 63 81 91 68 53 99 89 13 12 97 91 29
+ 7 7 78 35 84 53 84 58 61 91 99 15 61 98 16 5
+ 75 56 2 37 3 96 62 95 43 63 35 78 16 67 43 16
+ 16 90 72 98 85 56 90 46 29 29 4 74 74 2 76 41
+ 46 77 24 27 97 46 89 1 85 1 74 78 61 85 51 59
+ 35 30 56 25 47 28 73 6 73 74 93 43 3 56 47 85
+ 61 61 93 9 97 62}
+
+do_execsql_test 1.5.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 91 {} {} {} 91 {} {} {} {} {} {}
+ 11 {} {} {} {} {} {} {} {} {} {} {} {} {} 32
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 43 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 15 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} {} 47 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 9 9 {} {} {}}
+
+do_execsql_test 1.5.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} 5 6 6 6 7
+ 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9 11
+ 11 12 12 12 12 12 12 13 13 14 14 15 15 15 15
+ 15 15 16 16 16 16 16 16 17 17 17 17 19 19 19
+ 19 20 20 21 21 21 21 21 21 22 22 22 22 22 23
+ 23 23 24 25 25 26 26 27 27 27 27 27 27 29 29
+ 29 30 30 30 31 31 31 31 31 32 33 33 33 33 33
+ 33 33 33 33 33 33 34 34 34 34 34 34 34 35 35
+ 36 36 36 37 37 37 37 37 37 38 38 38 38 38 38
+ 39 39 39 39 39 40 41 41 41 41 41 42 43 43 43
+ 43 43 44 44 44 44 46 46 46 47 47 47 47 47 47
+ 47 47 47 47 47 49 49 49 50 51 51 51 52 52 52
+ 53 53 54 54 55 55}
+
+do_execsql_test 1.5.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 40 {} {} {} 40 {} 50 {} {} {} {}
+ 50 {} {} {} 41 {} 10 91 61 {} 30 {} 10 61 30
+ {} {} 10 {} {} {} {} 1 {} 22 80 22 91 93 {}
+ {} 30 {} {} 91 {} 1 30 91 80 91 {} 43 {} {}
+ 21 20 {} {} 74 21 21 2 74 33 81 21 {} 64 2 21
+ 93 62 14 14 3 91 11 24 55 93 93 62 90 91 55 3
+ 24 14 24 91 55 15 72 60 72 61 61 34 43 43 43
+ 61 12 4 15 15 51 51 12 23 12 12 25 41 25 13
+ 94 12 70 12 84 32 84 94 70 33 12 12 32 41 91
+ 70 22 33 84 80 31 75 84 53 75 80 84 80 53 53
+ 53 22 44 63 42 95 31 63 44 44 31 90 74 52 63
+ 31 63 1 42 90 90 95 3 42}
+
+do_execsql_test 1.5.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.5.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} 90 90 90 90 90 90 90 90 90 90 {}
+ {} {} {} 81 81 81 81 81 81 81 81 81 81 81 81
+ 81 81 81 81 81 {} {} {} {} 62 62 62 62 62 62
+ 62 62 62 62 62 62 {} {} {} {} 93 93 93 93 93
+ 93 93 93 93 93 93 93 93 93 93 93 93 {} {} {}
+ {} 54 54 54 54 54 54 54 54 54 54 54 54 54 54
+ 54 {} {} {} {} 65 65 65 65 65 65 65 65 65 65
+ 65 65 65 65 65 65 65 {} {} {} {} 96 96 96 96
+ 96 96 96 96 96 96 96 96 96 96 96 96 96 {} {}
+ {} {} 97 97 97 97 97 97 97 97 97 97 97 97 97
+ 97 97 97 {} {} {} {} 38 38 38 38 38 38 38 38
+ 38 38 38 38 {} {} {} {} 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.5.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1}
+
+do_execsql_test 1.5.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 10 10 10 10 10 10 10 10 10 10 {}
+ {} {} {} 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 {} {} {} {} 2 2 2 2 2 2 2 2 2 2 2 2
+ {} {} {} {} 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 3 {} {} {} {} 4 4 4 4 4 4 4 4 4 4 4
+ 4 4 4 4 {} {} {} {} 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 {} {} {} {} 6 6 6 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 {} {} {} {} 7 7 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 {} {} {} {} 8 8
+ 8 8 8 8 8 8 8 8 8 8 {} {} {} {} 9 9 9 9
+ 9 9 9 9 9 9 9 9 9 9 9 9 9 9}
+
+do_execsql_test 1.5.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90}
+
+do_execsql_test 1.5.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.5.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.5.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.5.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.5.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.5.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} 89 89.81 89.81.96 89.81.96.59 89.81.96.59.38
+ 89.81.96.59.38.68 89.81.96.59.38.68.39 89.81.96.59.38.68.39.62
+ 89.81.96.59.38.68.39.62.91 89.81.96.59.38.68.39.62.91.46
+ 89.81.96.59.38.68.39.62.91.46.6 89.81.96.59.38.68.39.62.91.46.6.99
+ 89.81.96.59.38.68.39.62.91.46.6.99.97
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83}
+
+do_execsql_test 1.5.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} 90 90.40 90.40.30 90.40.30.80 90.40.30.80.20
+ 90.40.30.80.20.90 90.40.30.80.20.90.60 90.40.30.80.20.90.60.70
+ 90.40.30.80.20.90.60.70.80 90.40.30.80.20.90.60.70.80.90 {} {} {}
+ {} 81 81.91 81.91.61 81.91.61.91 81.91.61.91.91
+ 81.91.61.91.91.1 81.91.61.91.91.1.81 81.91.61.91.91.1.81.41
+ 81.91.61.91.91.1.81.41.61 81.91.61.91.91.1.81.41.61.1
+ 81.91.61.91.91.1.81.41.61.1.21 81.91.61.91.91.1.81.41.61.1.21.11
+ 81.91.61.91.91.1.81.41.61.1.21.11.51
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11 {} {} {} {} 62
+ 62.12 62.12.32 62.12.32.22 62.12.32.22.42 62.12.32.22.42.2
+ 62.12.32.22.42.2.72 62.12.32.22.42.2.72.12 62.12.32.22.42.2.72.12.22
+ 62.12.32.22.42.2.72.12.22.2 62.12.32.22.42.2.72.12.22.2.72
+ 62.12.32.22.42.2.72.12.22.2.72.72 {} {} {} {} 93 93.23
+ 93.23.93 93.23.93.43 93.23.93.43.3 93.23.93.43.3.43
+ 93.23.93.43.3.43.33 93.23.93.43.3.43.33.53 93.23.93.43.3.43.33.53.63
+ 93.23.93.43.3.43.33.53.63.73 93.23.93.43.3.43.33.53.63.73.13
+ 93.23.93.43.3.43.33.53.63.73.13.73 93.23.93.43.3.43.33.53.63.73.13.73.73
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13 {} {} {} {} 54
+ 54.84 54.84.74 54.84.74.24 54.84.74.24.4 54.84.74.24.4.94
+ 54.84.74.24.4.94.84 54.84.74.24.4.94.84.74 54.84.74.24.4.94.84.74.34
+ 54.84.74.24.4.94.84.74.34.34 54.84.74.24.4.94.84.74.34.34.44
+ 54.84.74.24.4.94.84.74.34.34.44.74 54.84.74.24.4.94.84.74.34.34.44.74.64
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34 {} {} {} {} 65
+ 65.35 65.35.85 65.35.85.85 65.35.85.85.55 65.35.85.85.55.15
+ 65.35.85.85.55.15.25 65.35.85.85.55.15.25.75 65.35.85.85.55.15.25.75.95
+ 65.35.85.85.55.15.25.75.95.65 65.35.85.85.55.15.25.75.95.65.65
+ 65.35.85.85.55.15.25.75.95.65.65.35 65.35.85.85.55.15.25.75.95.65.65.35.5
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75 {} {} {} {} 96
+ 96.46 96.46.6 96.46.6.46 96.46.6.46.16 96.46.6.46.16.16
+ 96.46.6.46.16.16.86 96.46.6.46.16.16.86.56 96.46.6.46.16.16.86.56.56
+ 96.46.6.46.16.16.86.56.56.56 96.46.6.46.16.16.86.56.56.56.16
+ 96.46.6.46.16.16.86.56.56.56.16.36 96.46.6.46.16.16.86.56.56.56.16.36.76
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26 {} {} {} {} 97
+ 97.27 97.27.97 97.27.97.67 97.27.97.67.77 97.27.97.67.77.47
+ 97.27.97.67.77.47.7 97.27.97.67.77.47.7.47 97.27.97.67.77.47.7.47.87
+ 97.27.97.67.77.47.7.47.87.37 97.27.97.67.77.47.7.47.87.37.87
+ 97.27.97.67.77.47.7.47.87.37.87.77 97.27.97.67.77.47.7.47.87.37.87.77.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47 {} {} {} {} 38
+ 38.68 38.68.78 38.68.78.8 38.68.78.8.28 38.68.78.8.28.98
+ 38.68.78.8.28.98.78 38.68.78.8.28.98.78.58 38.68.78.8.28.98.78.58.98
+ 38.68.78.8.28.98.78.58.98.8 38.68.78.8.28.98.78.58.98.8.88
+ 38.68.78.8.28.98.78.58.98.8.88.8 {} {} {} {} 89 89.59
+ 89.59.39 89.59.39.99 89.59.39.99.29 89.59.39.99.29.59
+ 89.59.39.99.29.59.89 89.59.39.99.29.59.89.89 89.59.39.99.29.59.89.89.29
+ 89.59.39.99.29.59.89.89.29.9 89.59.39.99.29.59.89.89.29.9.79
+ 89.59.39.99.29.59.89.89.29.9.79.49 89.59.39.99.29.59.89.89.29.9.79.49.59
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9}
+
+do_execsql_test 1.5.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 1 1.1 1.1.2 1.1.2.2 1.1.2.2.3 1.1.2.2.3.3
+ 1.1.2.2.3.3.4 1.1.2.2.3.3.4.5 1.1.2.2.3.3.4.5.6 1.1.2.2.3.3.4.5.6.7
+ 1.1.2.2.3.3.4.5.6.7.7 1.1.2.2.3.3.4.5.6.7.7.7 1.1.2.2.3.3.4.5.6.7.7.7.8
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97}
+
+do_execsql_test 1.5.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 10 10.20 10.20.30 10.20.30.30 10.20.30.30.30
+ 10.20.30.30.30.40 10.20.30.30.30.40.50 10.20.30.30.30.40.50.60
+ 10.20.30.30.30.40.50.60.70 10.20.30.30.30.40.50.60.70.80 {} {} {}
+ {} 1 1.1 1.1.11 1.1.11.11 1.1.11.11.21 1.1.11.11.21.21
+ 1.1.11.11.21.21.31 1.1.11.11.21.21.31.31 1.1.11.11.21.21.31.31.41
+ 1.1.11.11.21.21.31.31.41.41 1.1.11.11.21.21.31.31.41.41.51
+ 1.1.11.11.21.21.31.31.41.41.51.61 1.1.11.11.21.21.31.31.41.41.51.61.61
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91 {} {} {} {} 2
+ 2.2 2.2.12 2.2.12.12 2.2.12.12.12 2.2.12.12.12.22
+ 2.2.12.12.12.22.22 2.2.12.12.12.22.22.32 2.2.12.12.12.22.22.32.42
+ 2.2.12.12.12.22.22.32.42.52 2.2.12.12.12.22.22.32.42.52.62
+ 2.2.12.12.12.22.22.32.42.52.62.62 {} {} {} {} 3 3.3 3.3.13
+ 3.3.13.13 3.3.13.13.23 3.3.13.13.23.23 3.3.13.13.23.23.33
+ 3.3.13.13.23.23.33.33 3.3.13.13.23.23.33.33.33
+ 3.3.13.13.23.23.33.33.33.33 3.3.13.13.23.23.33.33.33.33.43
+ 3.3.13.13.23.23.33.33.33.33.43.43 3.3.13.13.23.23.33.33.33.33.43.43.53
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73 {} {} {} {} 4
+ 4.14 4.14.24 4.14.24.34 4.14.24.34.34 4.14.24.34.34.34
+ 4.14.24.34.34.34.34 4.14.24.34.34.34.34.44 4.14.24.34.34.34.34.44.44
+ 4.14.24.34.34.34.34.44.44.54 4.14.24.34.34.34.34.44.44.54.64
+ 4.14.24.34.34.34.34.44.44.54.64.74 4.14.24.34.34.34.34.44.44.54.64.74.74
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84 {} {} {} {} 5 5.15
+ 5.15.15 5.15.15.15 5.15.15.15.25 5.15.15.15.25.35
+ 5.15.15.15.25.35.35 5.15.15.15.25.35.35.55 5.15.15.15.25.35.35.55.55
+ 5.15.15.15.25.35.35.55.55.65 5.15.15.15.25.35.35.55.55.65.65
+ 5.15.15.15.25.35.35.55.55.65.65.65 5.15.15.15.25.35.35.55.55.65.65.65.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85 {} {} {} {} 6
+ 6.16 6.16.16 6.16.16.16 6.16.16.16.26 6.16.16.16.26.26
+ 6.16.16.16.26.26.36 6.16.16.16.26.26.36.36 6.16.16.16.26.26.36.36.36
+ 6.16.16.16.26.26.36.36.36.36 6.16.16.16.26.26.36.36.36.36.46
+ 6.16.16.16.26.26.36.36.36.36.46.46 6.16.16.16.26.26.36.36.36.36.46.46.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76 {} {} {} {} 7
+ 7.7 7.7.7 7.7.7.17 7.7.7.17.27 7.7.7.17.27.27 7.7.7.17.27.27.37
+ 7.7.7.17.27.27.37.37 7.7.7.17.27.27.37.37.47 7.7.7.17.27.27.37.37.47.47
+ 7.7.7.17.27.27.37.37.47.47.47 7.7.7.17.27.27.37.37.47.47.47.47
+ 7.7.7.17.27.27.37.37.47.47.47.47.57
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77 {} {} {} {} 8 8.8
+ 8.8.8 8.8.8.28 8.8.8.28.38 8.8.8.28.38.38 8.8.8.28.38.38.58
+ 8.8.8.28.38.38.58.58 8.8.8.28.38.38.58.58.58 8.8.8.28.38.38.58.58.58.58
+ 8.8.8.28.38.38.58.58.58.58.68 8.8.8.28.38.38.58.58.58.58.68.78 {} {}
+ {} {} 9 9.9 9.9.9 9.9.9.19 9.9.9.19.29 9.9.9.19.29.29
+ 9.9.9.19.29.29.29 9.9.9.19.29.29.29.39 9.9.9.19.29.29.29.39.39
+ 9.9.9.19.29.29.29.39.39.39 9.9.9.19.29.29.29.39.39.39.49
+ 9.9.9.19.29.29.29.39.39.39.49.59 9.9.9.19.29.29.29.39.39.39.49.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89}
+
+do_execsql_test 1.5.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
+} {{} {} {} {} 90 90.40 90.40.30 90.40.30.80 90.40.30.80.20
+ 90.40.30.80.20.90 90.40.30.80.20.90.60 90.40.30.80.20.90.60.70
+ 90.40.30.80.20.90.60.70.80 90.40.30.80.20.90.60.70.80.90
+ 90.40.30.80.20.90.60.70.80.90.30 90.40.30.80.20.90.60.70.80.90.30.50
+ 90.40.30.80.20.90.60.70.80.90.30.50.10
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9}
+
+do_execsql_test 1.5.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.5.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING)
+} {0 {} 0 {} 0 {} 0 {} 1 89 2 89 3 89.96 4 89.96 5 89.96.38
+ 6 89.96.38 7 89.96.38.39 8 89.96.38.39 9 89.96.38.39.91
+ 10 89.96.38.39.91 11 89.96.38.39.91.6 12 89.96.38.39.91.6
+ 13 89.96.38.39.91.6.97 14 89.96.38.39.91.6.97 15 89.96.38.39.91.6.97.46
+ 16 89.96.38.39.91.6.97.46 17 89.96.38.39.91.6.97.46.54
+ 18 89.96.38.39.91.6.97.46.54 19 89.96.38.39.91.6.97.46.54.8
+ 20 89.96.38.39.91.6.97.46.54.8 21 89.96.38.39.91.6.97.46.54.8.29
+ 22 89.96.38.39.91.6.97.46.54.8.29 23 89.96.38.39.91.6.97.46.54.8.29.84
+ 24 89.96.38.39.91.6.97.46.54.8.29.84
+ 25 89.96.38.39.91.6.97.46.54.8.29.84.23
+ 26 89.96.38.39.91.6.97.46.54.8.29.84.23
+ 27 89.96.38.39.91.6.97.46.54.8.29.84.23.16
+ 28 89.96.38.39.91.6.97.46.54.8.29.84.23.16
+ 29 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65
+ 30 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65
+ 31 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47
+ 32 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47
+ 33 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86
+ 34 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86
+ 35 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61
+ 36 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61
+ 37 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85
+ 38 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85
+ 39 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85
+ 40 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85
+ 41 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59
+ 42 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59
+ 43 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32
+ 44 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32
+ 45 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3
+ 46 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3
+ 47 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22
+ 48 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22
+ 49 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55
+ 50 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55
+ 51 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28
+ 52 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28
+ 53 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25
+ 54 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25
+ 55 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1
+ 56 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1
+ 57 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40
+ 58 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40
+ 59 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56
+ 60 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56
+ 61 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75
+ 62 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75
+ 63 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89
+ 64 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89
+ 65 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76
+ 66 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76
+ 67 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4
+ 68 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4
+ 69 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42
+ 70 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42
+ 71 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78
+ 72 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78
+ 73 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29
+ 74 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29
+ 75 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63
+ 76 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63
+ 77 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87
+ 78 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87
+ 79 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80
+ 80 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80
+ 81 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72
+ 82 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72
+ 83 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9
+ 84 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9
+ 85 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73
+ 86 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73
+ 87 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65
+ 88 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65
+ 89 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58
+ 90 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58
+ 91 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98
+ 92 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98
+ 93 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21
+ 94 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21
+ 95 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65
+ 96 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65
+ 97 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5
+ 98 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5
+ 99 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11
+ 100 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11
+ 101 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87
+ 102 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87
+ 103 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12
+ 104 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12
+ 105 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20
+ 106 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20
+ 107 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31
+ 108 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31
+ 109 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95
+ 110 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95
+ 111 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73
+ 112 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73
+ 113 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88
+ 114 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88
+ 115 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8
+ 116 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8
+ 117 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49
+ 118 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49
+ 119 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90
+ 120 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90
+ 121 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96
+ 122 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96
+ 123 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55
+ 124 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55
+ 125 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77
+ 126 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77
+ 127 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2
+ 128 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2
+ 129 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85
+ 130 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85
+ 131 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74
+ 132 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74
+ 133 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70
+ 134 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70
+ 135 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19
+ 136 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19
+ 137 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26
+ 138 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26
+ 139 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47
+ 140 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47
+ 141 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90
+ 142 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90
+ 143 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58
+ 144 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58
+ 145 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9
+ 146 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9
+ 147 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72
+ 148 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72
+ 149 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33
+ 150 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33
+ 151 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75
+ 152 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75
+ 153 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81
+ 154 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81
+ 155 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23
+ 156 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23
+ 157 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13
+ 158 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13
+ 159 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14
+ 160 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14
+ 161 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91
+ 162 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91
+ 163 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91
+ 164 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91
+ 165 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15
+ 166 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15
+ 167 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36
+ 168 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36
+ 169 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3
+ 170 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3
+ 171 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69
+ 172 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69
+ 173 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52
+ 174 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52
+ 175 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50
+ 176 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50
+ 177 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10
+ 178 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10
+ 179 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33
+ 180 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33
+ 181 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39
+ 182 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39
+ 183 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58
+ 184 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58
+ 185 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38
+ 186 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38
+ 187 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83}
+
+do_execsql_test 1.5.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING)
+} {0 {} 0 {} 0 {} 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 {} 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 {} 101 {} 102 {} 103 {} 104 {} 105 {} 106 {}
+ 107 {} 108 {} 109 {} 110 {} 111 {} 112 {} 113 {} 114 {}
+ 115 {} 116 {} 117 {} 118 {} 119 {} 120 {} 121 {} 122 {}
+ 123 {} 124 {} 125 {} 126 {} 127 {} 128 {} 129 {} 130 {}
+ 131 {} 132 {} 133 {} 134 {} 135 {} 136 {} 137 {} 138 {}
+ 139 {} 140 {} 141 {} 142 {} 143 {} 144 {} 145 {} 146 {}
+ 147 {} 148 {} 149 {} 150 {} 151 {} 152 {} 153 {} 154 {}
+ 155 {} 156 {} 157 {} 158 {} 159 {} 160 {} 161 {} 162 {}
+ 163 {} 164 {} 165 {} 166 {} 167 {} 168 {} 169 {} 170 {}
+ 171 {} 172 {} 173 {} 174 {} 175 {} 176 {} 177 {} 178 {}
+ 179 {} 180 {} 181 {} 182 {} 183 {} 184 {} 185 {} 186 {}
+ 187 {}}
+
+do_execsql_test 1.5.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING)
+} {0 {} 0 {} 0 {} 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {}
+ 8 {} 9 {} 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 0 {}
+ 0 {} 0 {} 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {}
+ 9 {} 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 0 {} 0 {} 0 {}
+ 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {}
+ 11 {} 12 {} 13 {} 14 {} 15 {} 0 {} 0 {} 0 {} 0 {} 1 {}
+ 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {}
+ 12 {} 13 {} 14 {} 15 {} 0 {} 0 {} 0 {} 0 {} 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 0 {} 0 {} 0 {} 0 {} 1 {} 2 {} 3 {}
+ 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 0 {} 0 {} 0 {} 0 {} 1 {} 2 {} 3 {} 4 {}
+ 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {} 14 {}
+ 15 {} 0 {} 0 {} 0 {} 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {}
+ 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 0 {}
+ 0 {} 0 {} 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {}
+ 9 {} 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 0 {} 0 {} 0 {}
+ 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {}
+ 11 {} 12 {} 13 {} 14 {} 15 {}}
+
+do_execsql_test 1.5.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING)
+} {0 {} 0 {} 0 {} 0 {} 1 89 2 89.6 3 89.6.29 4 89.6.29.47
+ 5 89.6.29.47.59 6 89.6.29.47.59.28 7 89.6.29.47.59.28.75
+ 8 89.6.29.47.59.28.75.78 9 89.6.29.47.59.28.75.78.72
+ 10 89.6.29.47.59.28.75.78.72.98 11 89.6.29.47.59.28.75.78.72.98.87
+ 12 89.6.29.47.59.28.75.78.72.98.87.73
+ 13 89.6.29.47.59.28.75.78.72.98.87.73.96
+ 14 89.6.29.47.59.28.75.78.72.98.87.73.96.74
+ 15 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90
+ 16 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75 0 {} 0 {} 0 {}
+ 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {}
+ 11 {} 12 {} 13 {} 14 {} 15 {} 0 {} 0 {} 0 {} 0 {} 1 96
+ 2 96.97 3 96.97.84 4 96.97.84.86 5 96.97.84.86.32
+ 6 96.97.84.86.32.25 7 96.97.84.86.32.25.89 8 96.97.84.86.32.25.89.29
+ 9 96.97.84.86.32.25.89.29.9 10 96.97.84.86.32.25.89.29.9.21
+ 11 96.97.84.86.32.25.89.29.9.21.12 12 96.97.84.86.32.25.89.29.9.21.12.88
+ 13 96.97.84.86.32.25.89.29.9.21.12.88.55
+ 14 96.97.84.86.32.25.89.29.9.21.12.88.55.70
+ 15 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58 0 {} 0 {} 0 {} 0 {}
+ 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {}
+ 11 {} 12 {} 13 {} 14 {} 15 {} 0 {} 0 {} 0 {} 0 {} 1 38
+ 2 38.46 3 38.46.23 4 38.46.23.61 5 38.46.23.61.3 6 38.46.23.61.3.1
+ 7 38.46.23.61.3.1.76 8 38.46.23.61.3.1.76.63 9 38.46.23.61.3.1.76.63.73
+ 10 38.46.23.61.3.1.76.63.73.65 11 38.46.23.61.3.1.76.63.73.65.20
+ 12 38.46.23.61.3.1.76.63.73.65.20.8
+ 13 38.46.23.61.3.1.76.63.73.65.20.8.77
+ 14 38.46.23.61.3.1.76.63.73.65.20.8.77.19
+ 15 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9 0 {} 0 {} 0 {} 0 {}
+ 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {}
+ 11 {} 12 {} 13 {} 14 {} 15 {} 0 {} 0 {} 0 {} 0 {} 1 39
+ 2 39.54 3 39.54.16 4 39.54.16.85 5 39.54.16.85.22
+ 6 39.54.16.85.22.40 7 39.54.16.85.22.40.4 8 39.54.16.85.22.40.4.87
+ 9 39.54.16.85.22.40.4.87.65 10 39.54.16.85.22.40.4.87.65.5
+ 11 39.54.16.85.22.40.4.87.65.5.31 12 39.54.16.85.22.40.4.87.65.5.31.49
+ 13 39.54.16.85.22.40.4.87.65.5.31.49.2
+ 14 39.54.16.85.22.40.4.87.65.5.31.49.2.26
+ 15 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72 0 {} 0 {} 0 {} 0 {}
+ 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {}
+ 11 {} 12 {} 13 {} 14 {} 15 {} 0 {} 0 {} 0 {} 0 {} 1 91
+ 2 91.8 3 91.8.65 4 91.8.65.85 5 91.8.65.85.55 6 91.8.65.85.55.56
+ 7 91.8.65.85.55.56.42 8 91.8.65.85.55.56.42.80
+ 9 91.8.65.85.55.56.42.80.58 10 91.8.65.85.55.56.42.80.58.11
+ 11 91.8.65.85.55.56.42.80.58.11.95 12 91.8.65.85.55.56.42.80.58.11.95.90
+ 13 91.8.65.85.55.56.42.80.58.11.95.90.85
+ 14 91.8.65.85.55.56.42.80.58.11.95.90.85.47
+ 15 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33 0 {} 0 {} 0 {} 0 {}
+ 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {}
+ 11 {} 12 {} 13 {} 14 {} 15 {}}
+
+do_execsql_test 1.6.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 89 89 96 96 96 68 68 68 91 91 91 99 99
+ 99 97 78 78 97 97 97 67 93 93 93 84 77 23 93
+ 93 93 65 47 86 86 86 91 91 91 85 85 85 59 59
+ 56 56 91 91 91 90 90 55 89 89 89 47 56 56 56
+ 56 56 75 75 89 98 98 98 81 94 94 94 78 78 78
+ 53 63 63 87 87 87 84 84 84 72 61 73 95 95 95
+ 65 96 98 98 98 74 74 74 65 73 73 73 87 87 87
+ 41 20 31 31 31 95 95 95 79 88 88 88 34 49 49
+ 90 90 96 96 96 75 77 77 77 44 85 85 85 74 74
+ 70 70 59 39 39 47 80 90 90 90 58 58 72 72 72
+ 72 93 93 93 81 81 81 37 37 37 14 62 91 91 91
+ 91 91 34 36 99 99 99 95 95 69 58 52 84 84 84
+ 84 84 39 44 58 58 58 38 83 83 83}
+
+do_execsql_test 1.6.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 89 81 81 59 38 38 38 39 39 46 6 6 6 27
+ 27 27 46 54 8 8 8 29 29 77 23 16 16 16 16 35
+ 35 7 7 7 61 61 61 24 24 24 43 12 12 12 3 3
+ 3 22 22 15 15 15 25 25 1 1 1 40 40 16 16 16
+ 36 36 76 76 4 4 4 30 30 30 29 29 29 2 2 2
+ 37 37 72 41 9 9 9 61 65 13 13 13 58 1 1 1
+ 21 35 5 5 5 11 11 41 12 8 8 8 20 15 15 15
+ 22 22 73 34 8 8 8 11 34 34 59 59 55 55 55 44
+ 2 2 2 7 57 29 29 29 19 19 19 26 26 26 47 36
+ 36 36 9 9 9 66 33 33 33 64 64 9 9 9 13 12
+ 12 12 14 36 36 33 15 15 15 34 3 3 3 58 52 30
+ 30 30 10 10 10 21 21 21 39 30 30 30 34 27 27}
+
+do_execsql_test 1.6.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.6.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.6.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.6.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.6.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.6.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.6.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.6.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.6.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.6.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.6.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.6.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.6.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.6.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.6.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.6.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.6.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.6.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.6.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 99 92 108 72 52 83 55 79 109 65 26 120
+ 119 50 70 103 80 124 36 96 59 124 116 110 57 51
+ 52 130 103 74 87 48 128 117 105 136 131 71 133 92
+ 109 63 84 109 57 146 78 147 113 74 88 150 87 110
+ 65 121 106 110 124 85 145 107 161 171 150 156 80
+ 171 120 109 158 114 111 136 147 87 173 124 168 173
+ 162 132 101 154 167 190 161 110 156 195 198 102 123
+ 177 169 140 111 180 119 160 197 152 124 121 134 146
+ 147 132 213 141 193 200 210 157 132 136 175 161 218
+ 188 226 191 187 208 211 179 138 144 223 196 214 170
+ 212 202 163 184 172 173 195 229 240 187 210 200 163
+ 227 228 223 191 252 235 225 243 172 187 202 179 179
+ 182 231 261 207 263 206 189 209 212 276 181 274 249
+ 239 234 213 234 269 196 271 221 210 229 235 250 223
+ 232 229 279 224 280}
+
+do_execsql_test 1.6.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 147 106 109 168 134 218 191 212 229 240 213
+ 234 {} {} 92 109 105 136 146 65 156 132 154 102
+ 123 119 160 152 146 147 136 243 261 {} {} 79 63
+ 84 78 120 87 162 124 141 138 227 228 179 231 {}
+ {} 124 57 130 92 57 110 114 136 147 167 110 180
+ 193 191 252 187 179 206 181 {} {} 80 116 117 71
+ 80 171 173 177 157 161 179 214 225 182 209 269 271
+ {} {} 103 74 131 133 113 74 87 145 190 161 169
+ 140 111 132 213 187 208 223 235 {} {} 108 65 26
+ 70 51 52 128 109 121 124 85 107 150 195 226 172
+ 173 187 223 {} {} 119 50 124 96 110 87 48 110 173
+ 124 197 211 144 196 195 200 202 224 {} {} 52 83
+ 103 36 88 171 158 156 198 121 210 132 210 239 {}
+ {} 99 72 55 120 59 109 150 161 111 101 200 175
+ 188 170 202 163 184 163 172 276}
+
+do_execsql_test 1.6.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 65 102 87 138 57 181 80 111 26 48 144 207
+ 36 121 132 101 163 172 196 119 136 63 124 179 110
+ 179 182 74 132 189 51 52 85 216 163 134 123 210
+ 78 141 57 187 71 87 172 173 50 224 88 59 111 170
+ 109 213 223 146 147 84 114 191 206 221 157 161 209
+ 229 74 140 107 187 207 212 124 202 52 232 55 184
+ 229 106 132 152 120 92 110 179 235 65 70 87 110
+ 195 200 175 234 160 234 136 80 113 187 109 121 124
+ 196 156 210 239 250 72 109 188 202 191 105 154 79
+ 231 147 225 103 161 169 223 96 83 249 212 162 227
+ 228 167 180 193 117 177 214 145 208 235 150 110 211
+ 103 158 200 168 229 92 156 243 280 279 116 173 269
+ 271 131 133 223 128 173 197 210 99 150 161 147 218
+ 240 109 136 146 261 263 124 130 252 171 190 213 274
+ 108 195 226 119 124 171 198}
+
+do_execsql_test 1.6.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 196 134 109 213 223 106 234 191 212 168 229
+ 147 {} {} 65 102 119 136 123 210 146 147 132 152
+ 160 105 154 92 156 243 109 136 146 {} {} 87 138
+ 63 124 179 78 141 84 120 234 79 231 162 227 {} {}
+ 57 181 110 179 57 187 114 191 206 221 92 110 136
+ 147 167 180 193 279 124 {} {} 80 182 71 157 161
+ 209 229 179 235 80 225 117 177 214 116 173 269 {}
+ {} 111 74 132 189 87 74 140 113 187 103 161 169
+ 145 208 235 131 133 223 190 {} {} 26 51 52 85 172
+ 173 107 187 207 212 65 70 109 121 124 223 150 128
+ 108 {} {} 48 144 207 216 50 224 124 202 87 110
+ 195 200 196 96 110 211 173 197 {} {} 36 121 132
+ 88 52 232 156 210 239 250 83 103 158 210 {} {}
+ 101 163 172 163 59 111 170 55 184 229 175 72 109
+ 188 202 249 200 99 150 161}
+
+do_execsql_test 1.6.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 147 106 109 168 134 218 191 212 229 240 213
+ 234 196 223 92 109 105 136 146 65 156 132 154 102
+ 123 119 160 152 146 147 136 243 261 263 210 79 63
+ 84 78 120 87 162 124 141 138 227 228 179 231 234
+ 280 124 57 130 92 57 110 114 136 147 167 110 180
+ 193 191 252 187 179 206 181 221 279 80 116 117 71
+ 80 171 173 177 157 161 179 214 225 182 209 269 271
+ 235 229 103 74 131 133 113 74 87 145 190 161 169
+ 140 111 132 213 187 208 223 235 189 274 108 65 26
+ 70 51 52 128 109 121 124 85 107 150 195 226 172
+ 173 187 223 207 212 119 50 124 96 110 87 48 110
+ 173 124 197 211 144 196 195 200 202 224 216 207 52
+ 83 103 36 88 171 158 156 198 121 210 132 210 239
+ 250 232 99 72 55 120 59 109 150 161 111 101 200
+ 175 188 170 202 163 184 163 172 276}
+
+do_execsql_test 1.6.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 89 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 53 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 58 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 77 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} 89 89 89 81 96 59 38 68 39 62 91 46 6
+ 99 97 27 46 78 54 97 8 67 29 93 84 77 23 16
+ 16 93 65 35 47 7 86 74 61 91 85 24 85 43 59
+ 12 32 56 3 91 22 90 55 15 28 89 25 47 1 56 40
+ 43 56 16 75 36 89 98 76 81 4 94 42 30 78 33
+ 29 53 63 2 87 37 80 84 72 41 9 61 73 95 65 13
+ 58 96 98 1 21 74 65 35 5 73 11 51 87 41 12 8
+ 20 31 31 15 95 22 73 79 88 34 8 11 49 34 90
+ 59 96 60 55 75 77 44 2 7 85 57 74 29 70 59 19
+ 39 26 26 47 80 90 36 58 47 9 72 72 66 33 93
+ 75 64 81 9 23 37 13 12 14 62 91 36 91 33 15
+ 34 36 99 3 95 69 58 52 30 50 84 10 84 33 21
+ 39 44 58 30 38 34 83}
+
+do_execsql_test 1.6.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} 90 90 90 40 30 80 20 90 60 70 80 90 {}
+ {} 81 81 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 {} {} 62 62 62 12 32 22 42 2 72
+ 12 22 2 72 72 {} {} 93 93 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 {} {} 54 54 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 {}
+ {} 65 65 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 {} {} 96 96 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 {} {} 97 97 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 {}
+ {} 38 38 38 68 78 8 28 98 78 58 98 8 88 8 {}
+ {} 89 89 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.6.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 1 1 1 1 2 2 3 3 4 5 6 7 7 7 8 8 8
+ 9 9 9 10 11 11 12 12 12 13 13 14 15 15 15 16
+ 16 16 17 19 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 30 30 30 31 31 32 33 33 33
+ 33 34 34 34 34 35 35 36 36 36 36 37 37 38 38
+ 39 39 39 40 41 41 42 43 43 44 44 46 46 47 47
+ 47 47 49 50 51 52 53 54 55 55 56 56 56 57 58
+ 58 58 58 59 59 59 59 60 61 61 62 62 63 64 65
+ 65 65 66 67 68 69 70 72 72 72 73 73 73 74 74
+ 74 75 75 75 76 77 77 78 78 79 80 80 81 81 81
+ 82 83 84 84 84 84 85 85 85 86 87 87 88 89 89
+ 89 90 90 90 91 91 91 91 91 93 93 93 94 95 95
+ 95 96 96 96 97 97}
+
+do_execsql_test 1.6.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 10 10 10 20 30 30 30 40 50 60 70 80 {}
+ {} 1 1 1 1 11 11 21 21 31 31 41 41 51 61 61
+ 81 81 81 91 {} {} 2 2 2 2 12 12 12 22 22 32
+ 42 52 62 62 {} {} 3 3 3 3 13 13 23 23 33 33
+ 33 33 43 43 53 63 73 73 73 {} {} 4 4 4 14 24
+ 34 34 34 34 44 44 54 64 74 74 74 84 {} {} 5 5
+ 5 15 15 15 25 35 35 55 55 65 65 65 75 75 75
+ 85 85 {} {} 6 6 6 16 16 16 26 26 36 36 36 36
+ 46 46 56 56 56 66 76 {} {} 7 7 7 7 7 17 27
+ 27 37 37 47 47 47 47 57 67 77 77 {} {} 8 8 8
+ 8 8 28 38 38 58 58 58 58 68 78 {} {} 9 9 9
+ 9 9 19 29 29 29 39 39 39 49 59 59 59 59 69 79
+ 89}
+
+do_execsql_test 1.6.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 90 90 90 40 30 80 20 90 60 70 80 90 30
+ 50 10 30 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 81 91 91 21 62 12 32 22 42 2 72
+ 12 22 2 72 72 12 62 52 82 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 33 3 33 83 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 84
+ 84 44 34 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 85 75 15 95 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 36 66 36 36 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 37
+ 27 17 7 38 68 78 8 28 98 78 58 98 8 88 8 58
+ 58 58 38 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.6.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.6.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.6.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.6.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.6.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.6.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} 89 89.81 89.81.96 81.96.59 96.59.38 59.38.68 38.68.39
+ 68.39.62 39.62.91 62.91.46 91.46.6 46.6.99 6.99.97 99.97.27
+ 97.27.46 27.46.78 46.78.54 78.54.97 54.97.8 97.8.67 8.67.29
+ 67.29.93 29.93.84 93.84.77 84.77.23 77.23.16 23.16.16 16.16.93
+ 16.93.65 93.65.35 65.35.47 35.47.7 47.7.86 7.86.74 86.74.61
+ 74.61.91 61.91.85 91.85.24 85.24.85 24.85.43 85.43.59 43.59.12
+ 59.12.32 12.32.56 32.56.3 56.3.91 3.91.22 91.22.90 22.90.55
+ 90.55.15 55.15.28 15.28.89 28.89.25 89.25.47 25.47.1 47.1.56
+ 1.56.40 56.40.43 40.43.56 43.56.16 56.16.75 16.75.36 75.36.89
+ 36.89.98 89.98.76 98.76.81 76.81.4 81.4.94 4.94.42 94.42.30
+ 42.30.78 30.78.33 78.33.29 33.29.53 29.53.63 53.63.2 63.2.87
+ 2.87.37 87.37.80 37.80.84 80.84.72 84.72.41 72.41.9 41.9.61
+ 9.61.73 61.73.95 73.95.65 95.65.13 65.13.58 13.58.96 58.96.98
+ 96.98.1 98.1.21 1.21.74 21.74.65 74.65.35 65.35.5 35.5.73
+ 5.73.11 73.11.51 11.51.87 51.87.41 87.41.12 41.12.8 12.8.20
+ 8.20.31 20.31.31 31.31.15 31.15.95 15.95.22 95.22.73 22.73.79
+ 73.79.88 79.88.34 88.34.8 34.8.11 8.11.49 11.49.34 49.34.90
+ 34.90.59 90.59.96 59.96.60 96.60.55 60.55.75 55.75.77 75.77.44
+ 77.44.2 44.2.7 2.7.85 7.85.57 85.57.74 57.74.29 74.29.70
+ 29.70.59 70.59.19 59.19.39 19.39.26 39.26.26 26.26.47 26.47.80
+ 47.80.90 80.90.36 90.36.58 36.58.47 58.47.9 47.9.72 9.72.72
+ 72.72.66 72.66.33 66.33.93 33.93.75 93.75.64 75.64.81 64.81.9
+ 81.9.23 9.23.37 23.37.13 37.13.12 13.12.14 12.14.62 14.62.91
+ 62.91.36 91.36.91 36.91.33 91.33.15 33.15.34 15.34.36 34.36.99
+ 36.99.3 99.3.95 3.95.69 95.69.58 69.58.52 58.52.30 52.30.50
+ 30.50.84 50.84.10 84.10.84 10.84.33 84.33.21 33.21.39 21.39.44
+ 39.44.58 44.58.30 58.30.38 30.38.34 38.34.83 34.83.27 83.27.82}
+
+do_execsql_test 1.6.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} 90 90.40 90.40.30 40.30.80 30.80.20 80.20.90 20.90.60
+ 90.60.70 60.70.80 70.80.90 80.90.30 90.30.50 {} {} 81 81.91
+ 81.91.61 91.61.91 61.91.91 91.91.1 91.1.81 1.81.41 81.41.61
+ 41.61.1 61.1.21 1.21.11 21.11.51 11.51.41 51.41.31 41.31.31
+ 31.31.11 31.11.81 11.81.91 {} {} 62 62.12 62.12.32 12.32.22
+ 32.22.42 22.42.2 42.2.72 2.72.12 72.12.22 12.22.2 22.2.72
+ 2.72.72 72.72.12 72.12.62 {} {} 93 93.23 93.23.93 23.93.43
+ 93.43.3 43.3.43 3.43.33 43.33.53 33.53.63 53.63.73 63.73.13
+ 73.13.73 13.73.73 73.73.33 73.33.93 33.93.23 93.23.13 23.13.33
+ 13.33.3 {} {} 54 54.84 54.84.74 84.74.24 74.24.4 24.4.94
+ 4.94.84 94.84.74 84.74.34 74.34.34 34.34.44 34.44.74 44.74.64
+ 74.64.14 64.14.34 14.34.84 34.84.84 {} {} 65 65.35 65.35.85
+ 35.85.85 85.85.55 85.55.15 55.15.25 15.25.75 25.75.95 75.95.65
+ 95.65.65 65.65.35 65.35.5 35.5.15 5.15.95 15.95.55 95.55.75
+ 55.75.85 75.85.75 {} {} 96 96.46 96.46.6 46.6.46 6.46.16
+ 46.16.16 16.16.86 16.86.56 86.56.56 56.56.56 56.56.16 56.16.36
+ 16.36.76 36.76.96 76.96.96 96.96.26 96.26.26 26.26.36 26.36.66
+ {} {} 97 97.27 97.27.97 27.97.67 97.67.77 67.77.47 77.47.7
+ 47.7.47 7.47.87 47.87.37 87.37.87 37.87.77 87.77.7 77.7.57
+ 7.57.47 57.47.47 47.47.37 47.37.27 {} {} 38 38.68 38.68.78
+ 68.78.8 78.8.28 8.28.98 28.98.78 98.78.58 78.58.98 58.98.8
+ 98.8.88 8.88.8 88.8.58 8.58.58 {} {} 89 89.59 89.59.39
+ 59.39.99 39.99.29 99.29.59 29.59.89 59.89.89 89.89.29 89.29.9
+ 29.9.79 9.79.49 79.49.59 49.59.29 59.29.59 29.59.19 59.19.39
+ 19.39.9 39.9.9 9.9.99}
+
+do_execsql_test 1.6.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 1 1.1 1.1.2 1.2.2 2.2.3 2.3.3 3.3.4 3.4.5 4.5.6
+ 5.6.7 6.7.7 7.7.7 7.7.8 7.8.8 8.8.8 8.8.9 8.9.9 9.9.9
+ 9.9.10 9.10.11 10.11.11 11.11.12 11.12.12 12.12.12 12.12.13
+ 12.13.13 13.13.14 13.14.15 14.15.15 15.15.15 15.15.16 15.16.16
+ 16.16.16 16.16.17 16.17.19 17.19.20 19.20.21 20.21.21 21.21.22
+ 21.22.22 22.22.23 22.23.23 23.23.24 23.24.25 24.25.26 25.26.26
+ 26.26.27 26.27.27 27.27.28 27.28.29 28.29.29 29.29.29 29.29.30
+ 29.30.30 30.30.30 30.30.31 30.31.31 31.31.32 31.32.33 32.33.33
+ 33.33.33 33.33.33 33.33.34 33.34.34 34.34.34 34.34.34 34.34.35
+ 34.35.35 35.35.36 35.36.36 36.36.36 36.36.36 36.36.37 36.37.37
+ 37.37.38 37.38.38 38.38.39 38.39.39 39.39.39 39.39.40 39.40.41
+ 40.41.41 41.41.42 41.42.43 42.43.43 43.43.44 43.44.44 44.44.46
+ 44.46.46 46.46.47 46.47.47 47.47.47 47.47.47 47.47.49 47.49.50
+ 49.50.51 50.51.52 51.52.53 52.53.54 53.54.55 54.55.55 55.55.56
+ 55.56.56 56.56.56 56.56.57 56.57.58 57.58.58 58.58.58 58.58.58
+ 58.58.59 58.59.59 59.59.59 59.59.59 59.59.60 59.60.61 60.61.61
+ 61.61.62 61.62.62 62.62.63 62.63.64 63.64.65 64.65.65 65.65.65
+ 65.65.66 65.66.67 66.67.68 67.68.69 68.69.70 69.70.72 70.72.72
+ 72.72.72 72.72.73 72.73.73 73.73.73 73.73.74 73.74.74 74.74.74
+ 74.74.75 74.75.75 75.75.75 75.75.76 75.76.77 76.77.77 77.77.78
+ 77.78.78 78.78.79 78.79.80 79.80.80 80.80.81 80.81.81 81.81.81
+ 81.81.82 81.82.83 82.83.84 83.84.84 84.84.84 84.84.84 84.84.85
+ 84.85.85 85.85.85 85.85.86 85.86.87 86.87.87 87.87.88 87.88.89
+ 88.89.89 89.89.89 89.89.90 89.90.90 90.90.90 90.90.91 90.91.91
+ 91.91.91 91.91.91 91.91.91 91.91.93 91.93.93 93.93.93 93.93.94
+ 93.94.95 94.95.95 95.95.95 95.95.96 95.96.96 96.96.96 96.96.97
+ 96.97.97 97.97.98 97.98.98}
+
+do_execsql_test 1.6.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 10 10.20 10.20.30 20.30.30 30.30.30 30.30.40 30.40.50
+ 40.50.60 50.60.70 60.70.80 70.80.80 80.80.90 {} {} 1 1.1
+ 1.1.11 1.11.11 11.11.21 11.21.21 21.21.31 21.31.31 31.31.41
+ 31.41.41 41.41.51 41.51.61 51.61.61 61.61.81 61.81.81 81.81.81
+ 81.81.91 81.91.91 91.91.91 {} {} 2 2.2 2.2.12 2.12.12
+ 12.12.12 12.12.22 12.22.22 22.22.32 22.32.42 32.42.52 42.52.62
+ 52.62.62 62.62.72 62.72.72 {} {} 3 3.3 3.3.13 3.13.13
+ 13.13.23 13.23.23 23.23.33 23.33.33 33.33.33 33.33.33 33.33.43
+ 33.43.43 43.43.53 43.53.63 53.63.73 63.73.73 73.73.73 73.73.83
+ 73.83.93 {} {} 4 4.14 4.14.24 14.24.34 24.34.34 34.34.34
+ 34.34.34 34.34.44 34.44.44 44.44.54 44.54.64 54.64.74 64.74.74
+ 74.74.74 74.74.84 74.84.84 84.84.84 {} {} 5 5.15 5.15.15
+ 15.15.15 15.15.25 15.25.35 25.35.35 35.35.55 35.55.55 55.55.65
+ 55.65.65 65.65.65 65.65.75 65.75.75 75.75.75 75.75.85 75.85.85
+ 85.85.85 85.85.95 {} {} 6 6.16 6.16.16 16.16.16 16.16.26
+ 16.26.26 26.26.36 26.36.36 36.36.36 36.36.36 36.36.46 36.46.46
+ 46.46.56 46.56.56 56.56.56 56.56.66 56.66.76 66.76.86 76.86.96
+ {} {} 7 7.7 7.7.7 7.7.17 7.17.27 17.27.27 27.27.37
+ 27.37.37 37.37.47 37.47.47 47.47.47 47.47.47 47.47.57 47.57.67
+ 57.67.77 67.77.77 77.77.87 77.87.87 {} {} 8 8.8 8.8.8
+ 8.8.28 8.28.38 28.38.38 38.38.58 38.58.58 58.58.58 58.58.58
+ 58.58.68 58.68.78 68.78.78 78.78.88 {} {} 9 9.9 9.9.9
+ 9.9.19 9.19.29 19.29.29 29.29.29 29.29.39 29.39.39 39.39.39
+ 39.39.49 39.49.59 49.59.59 59.59.59 59.59.59 59.59.69 59.69.79
+ 69.79.89 79.89.89 89.89.89}
+
+do_execsql_test 1.6.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING ) FROM t2
+} {{} {} 90 90.40 90.40.30 40.30.80 30.80.20 80.20.90 20.90.60
+ 90.60.70 60.70.80 70.80.90 80.90.30 90.30.50 30.50.10 50.10.30
+ 10.30.81 30.81.91 81.91.61 91.61.91 61.91.91 91.91.1 91.1.81
+ 1.81.41 81.41.61 41.61.1 61.1.21 1.21.11 21.11.51 11.51.41
+ 51.41.31 41.31.31 31.31.11 31.11.81 11.81.91 81.91.91 91.91.21
+ 91.21.62 21.62.12 62.12.32 12.32.22 32.22.42 22.42.2 42.2.72
+ 2.72.12 72.12.22 12.22.2 22.2.72 2.72.72 72.72.12 72.12.62
+ 12.62.52 62.52.82 52.82.93 82.93.23 93.23.93 23.93.43 93.43.3
+ 43.3.43 3.43.33 43.33.53 33.53.63 53.63.73 63.73.13 73.13.73
+ 13.73.73 73.73.33 73.33.93 33.93.23 93.23.13 23.13.33 13.33.3
+ 33.3.33 3.33.83 33.83.54 83.54.84 54.84.74 84.74.24 74.24.4
+ 24.4.94 4.94.84 94.84.74 84.74.34 74.34.34 34.34.44 34.44.74
+ 44.74.64 74.64.14 64.14.34 14.34.84 34.84.84 84.84.44 84.44.34
+ 44.34.65 34.65.35 65.35.85 35.85.85 85.85.55 85.55.15 55.15.25
+ 15.25.75 25.75.95 75.95.65 95.65.65 65.65.35 65.35.5 35.5.15
+ 5.15.95 15.95.55 95.55.75 55.75.85 75.85.75 85.75.15 75.15.95
+ 15.95.96 95.96.46 96.46.6 46.6.46 6.46.16 46.16.16 16.16.86
+ 16.86.56 86.56.56 56.56.56 56.56.16 56.16.36 16.36.76 36.76.96
+ 76.96.96 96.96.26 96.26.26 26.26.36 26.36.66 36.66.36 66.36.36
+ 36.36.97 36.97.27 97.27.97 27.97.67 97.67.77 67.77.47 77.47.7
+ 47.7.47 7.47.87 47.87.37 87.37.87 37.87.77 87.77.7 77.7.57
+ 7.57.47 57.47.47 47.47.37 47.37.27 37.27.17 27.17.7 17.7.38
+ 7.38.68 38.68.78 68.78.8 78.8.28 8.28.98 28.98.78 98.78.58
+ 78.58.98 58.98.8 98.8.88 8.88.8 88.8.58 8.58.58 58.58.58
+ 58.58.38 58.38.89 38.89.59 89.59.39 59.39.99 39.99.29 99.29.59
+ 29.59.89 59.89.89 89.89.29 89.29.9 29.9.79 9.79.49 79.49.59
+ 49.59.29 59.29.59 29.59.19 59.19.39 19.39.9 39.9.9 9.9.99}
+
+do_execsql_test 1.6.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.6.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING)
+} {0 {} 0 {} 1 89 2 89 3 89.96 3 96 3 96.38 3 38 3 38.39
+ 3 39 3 39.91 3 91 3 91.6 3 6 3 6.97 3 97 3 97.46 3 46
+ 3 46.54 3 54 3 54.8 3 8 3 8.29 3 29 3 29.84 3 84 3 84.23
+ 3 23 3 23.16 3 16 3 16.65 3 65 3 65.47 3 47 3 47.86 3 86
+ 3 86.61 3 61 3 61.85 3 85 3 85.85 3 85 3 85.59 3 59 3 59.32
+ 3 32 3 32.3 3 3 3 3.22 3 22 3 22.55 3 55 3 55.28 3 28
+ 3 28.25 3 25 3 25.1 3 1 3 1.40 3 40 3 40.56 3 56 3 56.75
+ 3 75 3 75.89 3 89 3 89.76 3 76 3 76.4 3 4 3 4.42 3 42
+ 3 42.78 3 78 3 78.29 3 29 3 29.63 3 63 3 63.87 3 87 3 87.80
+ 3 80 3 80.72 3 72 3 72.9 3 9 3 9.73 3 73 3 73.65 3 65
+ 3 65.58 3 58 3 58.98 3 98 3 98.21 3 21 3 21.65 3 65 3 65.5
+ 3 5 3 5.11 3 11 3 11.87 3 87 3 87.12 3 12 3 12.20 3 20
+ 3 20.31 3 31 3 31.95 3 95 3 95.73 3 73 3 73.88 3 88 3 88.8
+ 3 8 3 8.49 3 49 3 49.90 3 90 3 90.96 3 96 3 96.55 3 55
+ 3 55.77 3 77 3 77.2 3 2 3 2.85 3 85 3 85.74 3 74 3 74.70
+ 3 70 3 70.19 3 19 3 19.26 3 26 3 26.47 3 47 3 47.90 3 90
+ 3 90.58 3 58 3 58.9 3 9 3 9.72 3 72 3 72.33 3 33 3 33.75
+ 3 75 3 75.81 3 81 3 81.23 3 23 3 23.13 3 13 3 13.14 3 14
+ 3 14.91 3 91 3 91.91 3 91 3 91.15 3 15 3 15.36 3 36 3 36.3
+ 3 3 3 3.69 3 69 3 69.52 3 52 3 52.50 3 50 3 50.10 3 10
+ 3 10.33 3 33 3 33.39 3 39 3 39.58 3 58 3 58.38 3 38 3 38.83
+ 3 83 3 83.82}
+
+do_execsql_test 1.6.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING)
+} {0 {} 0 {} 1 {} 2 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {}}
+
+do_execsql_test 1.6.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING)
+} {0 {} 0 {} 1 {} 2 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 0 {} 0 {}
+ 1 {} 2 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 0 {} 0 {} 1 {} 2 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 0 {} 0 {} 1 {} 2 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 0 {} 0 {} 1 {} 2 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 0 {} 0 {} 1 {}
+ 2 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 0 {} 0 {} 1 {} 2 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 0 {} 0 {} 1 {} 2 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 0 {}
+ 0 {} 1 {} 2 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 0 {} 0 {} 1 {} 2 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {}}
+
+do_execsql_test 1.6.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING)
+} {0 {} 0 {} 1 89 2 89.6 3 89.6.29 3 6.29.47 3 29.47.59
+ 3 47.59.28 3 59.28.75 3 28.75.78 3 75.78.72 3 78.72.98 3 72.98.87
+ 3 98.87.73 3 87.73.96 3 73.96.74 3 96.74.90 3 74.90.75 3 90.75.91
+ 3 75.91.69 0 {} 0 {} 1 {} 2 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 0 {}
+ 0 {} 1 96 2 96.97 3 96.97.84 3 97.84.86 3 84.86.32 3 86.32.25
+ 3 32.25.89 3 25.89.29 3 89.29.9 3 29.9.21 3 9.21.12 3 21.12.88
+ 3 12.88.55 3 88.55.70 3 55.70.58 3 70.58.81 3 58.81.91 0 {}
+ 0 {} 1 {} 2 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 0 {} 0 {} 1 38
+ 2 38.46 3 38.46.23 3 46.23.61 3 23.61.3 3 61.3.1 3 3.1.76
+ 3 1.76.63 3 76.63.73 3 63.73.65 3 73.65.20 3 65.20.8 3 20.8.77
+ 3 8.77.19 3 77.19.9 3 19.9.23 3 9.23.15 0 {} 0 {} 1 {} 2 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 0 {} 0 {} 1 39 2 39.54 3 39.54.16
+ 3 54.16.85 3 16.85.22 3 85.22.40 3 22.40.4 3 40.4.87 3 4.87.65
+ 3 87.65.5 3 65.5.31 3 5.31.49 3 31.49.2 3 49.2.26 3 2.26.72
+ 3 26.72.13 3 72.13.36 0 {} 0 {} 1 {} 2 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 0 {} 0 {} 1 91 2 91.8 3 91.8.65 3 8.65.85 3 65.85.55
+ 3 85.55.56 3 55.56.42 3 56.42.80 3 42.80.58 3 80.58.11 3 58.11.95
+ 3 11.95.90 3 95.90.85 3 90.85.47 3 85.47.33 3 47.33.14 3 33.14.3
+ 0 {} 0 {} 1 {} 2 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}}
+
+do_execsql_test 1.7.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {89 89 96 96 96 96 96 96 96 96 96 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99}
+
+do_execsql_test 1.7.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {89 81 81 59 38 38 38 38 38 38 6 6 6 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 6 6 6 6 6 3 3 3 3 3 3 3 3 3 3 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1}
+
+do_execsql_test 1.7.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.7.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.7.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.7.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.7.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.7.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.7.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.7.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.7.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.7.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.7.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.7.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.7.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.7.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.7.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.7.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.7.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.7.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.7.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {99 92 108 72 52 83 55 79 109 65 26 120 119 50
+ 70 103 80 124 36 96 59 124 116 110 57 51 52 130
+ 103 74 87 48 128 117 105 136 131 71 133 92 109 63
+ 84 109 57 146 78 147 113 74 88 150 87 110 65 121
+ 106 110 124 85 145 107 161 171 150 156 80 171 120
+ 109 158 114 111 136 147 87 173 124 168 173 162 132
+ 101 154 167 190 161 110 156 195 198 102 123 177 169
+ 140 111 180 119 160 197 152 124 121 134 146 147 132
+ 213 141 193 200 210 157 132 136 175 161 218 188 226
+ 191 187 208 211 179 138 144 223 196 214 170 212 202
+ 163 184 172 173 195 229 240 187 210 200 163 227 228
+ 223 191 252 235 225 243 172 187 202 179 179 182 231
+ 261 207 263 206 189 209 212 276 181 274 249 239 234
+ 213 234 269 196 271 221 210 229 235 250 223 232 229
+ 279 224 280 216 207}
+
+do_execsql_test 1.7.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.7.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {65 102 87 138 57 181 80 111 26 48 144 207 36 121
+ 132 101 163 172 196 119 136 63 124 179 110 179 182
+ 74 132 189 51 52 85 216 163 134 123 210 78 141 57
+ 187 71 87 172 173 50 224 88 59 111 170 109 213
+ 223 146 147 84 114 191 206 221 157 161 209 229 74
+ 140 107 187 207 212 124 202 52 232 55 184 229 106
+ 132 152 120 92 110 179 235 65 70 87 110 195 200
+ 175 234 160 234 136 80 113 187 109 121 124 196 156
+ 210 239 250 72 109 188 202 191 105 154 79 231 147
+ 225 103 161 169 223 96 83 249 212 162 227 228 167
+ 180 193 117 177 214 145 208 235 150 110 211 103 158
+ 200 168 229 92 156 243 280 279 116 173 269 271 131
+ 133 223 128 173 197 210 99 150 161 147 218 240 109
+ 136 146 261 263 124 130 252 171 190 213 274 108 195
+ 226 119 124 171 198 120 276}
+
+do_execsql_test 1.7.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {196 134 109 213 223 106 234 191 212 168 229 147 218
+ 240 65 102 119 136 123 210 146 147 132 152 160 105
+ 154 92 156 243 109 136 146 261 263 87 138 63 124
+ 179 78 141 84 120 234 79 231 162 227 228 280 57
+ 181 110 179 57 187 114 191 206 221 92 110 136 147
+ 167 180 193 279 124 130 252 80 182 71 157 161 209
+ 229 179 235 80 225 117 177 214 116 173 269 271 171
+ 111 74 132 189 87 74 140 113 187 103 161 169 145
+ 208 235 131 133 223 190 213 274 26 51 52 85 172
+ 173 107 187 207 212 65 70 109 121 124 223 150 128
+ 108 195 226 48 144 207 216 50 224 124 202 87 110
+ 195 200 196 96 110 211 173 197 119 124 36 121 132
+ 88 52 232 156 210 239 250 83 103 158 210 171 198
+ 101 163 172 163 59 111 170 55 184 229 175 72 109
+ 188 202 249 200 99 150 161 120 276}
+
+do_execsql_test 1.7.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.7.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.7.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 39 {} {} {} {}
+ {} {} {} 91 {} {} {} {} {} 77 54 54 {} {} {}
+ {} 62 {} {} {} {} {} 23 {} {} {} 97 86 {} 59
+ {} 84 {} {} 78 65 {} 16 90 81 {} 59 56 40 54
+ {} 85 {} {} {} {} 38 {} 32 47 {} 74 35 47 98
+ 96 {} 24 {} {} 29 12 46 36 53 {} 81 27 56 {}
+ {} 81 93 63 81 91 68 53 99 89 13 12 97 91 29
+ 7 7 78 35 84 53 84 58 61 91 99 15 61 98 16 5
+ 75 56 2 37 3 96 62 95 43 63 35 78 16 67 43 16
+ 16 90 72 98 85 56 90 46 29 29 4 74 74 2 76 41
+ 46 77 24 27 97 46 89 1 85 1 74 78 61 85 51 59
+ 35 30 56 25 47 28 73 6 73 74 93 43 3 56 47 85
+ 61 61 93 9 97 62}
+
+do_execsql_test 1.7.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 91 {} 11 {} {} {} {}
+ 11 {} {} {} {} {} {} {} {} {} 32 {} {} {} 32
+ {} {} 12 {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} {} {} {} {} {} {} 33 {} 43 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 15 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 47 {} {} {} {} {} {} {} {} {} 98 {} 98
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} 9 9 {} {} {}}
+
+do_execsql_test 1.7.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} 1 2 2 2 2 3 3 4 5 5 5 6 6 6 7 7 7 7
+ 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9 11 11 12
+ 12 12 12 12 12 13 13 14 14 15 15 15 15 15 15
+ 16 16 16 16 16 16 17 17 17 17 19 19 19 19 20
+ 20 21 21 21 21 21 21 22 22 22 22 22 23 23 23
+ 24 25 25 26 26 27 27 27 27 27 27 29 29 29 30
+ 30 30 31 31 31 31 31 32 33 33 33 33 33 33 33
+ 33 33 33 33 34 34 34 34 34 34 34 35 35 36 36
+ 36 37 37 37 37 37 37 38 38 38 38 38 38 39 39
+ 39 39 39 40 41 41 41 41 41 42 43 43 43 43 43
+ 44 44 44 44 46 46 46 47 47 47 47 47 47 47 47
+ 47 47 47 49 49 49 50 51 51 51 52 52 52 53 53
+ 54 54 55 55}
+
+do_execsql_test 1.7.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.7.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 40 {} {} {} 40 41 50 {} {} {} {}
+ 50 {} {} {} 41 {} 10 91 61 {} 30 {} 10 61 30
+ {} {} 10 {} {} {} {} 1 {} 22 80 22 91 93 {}
+ {} 30 {} {} 91 {} 1 30 91 80 91 {} 43 {} 74
+ 21 20 {} {} 74 21 21 2 74 33 81 21 64 64 2 21
+ 93 62 14 14 3 91 11 24 55 93 93 62 90 91 55 3
+ 24 14 24 91 55 15 72 60 72 61 61 34 43 43 43
+ 61 12 4 15 15 51 51 12 23 12 12 25 41 25 13
+ 94 12 70 12 84 32 84 94 70 33 12 12 32 41 91
+ 70 22 33 84 80 31 75 84 53 75 80 84 80 53 53
+ 53 22 44 63 42 95 31 63 44 44 31 90 74 52 63
+ 31 63 1 42 90 90 95 3 42}
+
+do_execsql_test 1.7.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.7.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.7.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 81
+ 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81
+ 81 81 81 81 81 62 62 62 62 62 62 62 62 62 62
+ 62 62 62 62 62 62 93 93 93 93 93 93 93 93 93
+ 93 93 93 93 93 93 93 93 93 93 93 93 54 54 54
+ 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
+ 54 65 65 65 65 65 65 65 65 65 65 65 65 65 65
+ 65 65 65 65 65 65 65 96 96 96 96 96 96 96 96
+ 96 96 96 96 96 96 96 96 96 96 96 96 96 97 97
+ 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97
+ 97 97 97 38 38 38 38 38 38 38 38 38 38 38 38
+ 38 38 38 38 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.7.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1}
+
+do_execsql_test 1.7.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
+ 9 9 9 9}
+
+do_execsql_test 1.7.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90}
+
+do_execsql_test 1.7.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.7.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.7.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.7.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.7.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.7.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.7.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.7.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.7.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.7.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.7.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.7.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.7.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.7.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {89 89.81 89.81.96 89.81.96.59 89.81.96.59.38 89.81.96.59.38.68
+ 89.81.96.59.38.68.39 89.81.96.59.38.68.39.62 89.81.96.59.38.68.39.62.91
+ 89.81.96.59.38.68.39.62.91.46 89.81.96.59.38.68.39.62.91.46.6
+ 89.81.96.59.38.68.39.62.91.46.6.99 89.81.96.59.38.68.39.62.91.46.6.99.97
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7}
+
+do_execsql_test 1.7.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {90 90.40 90.40.30 90.40.30.80 90.40.30.80.20 90.40.30.80.20.90
+ 90.40.30.80.20.90.60 90.40.30.80.20.90.60.70 90.40.30.80.20.90.60.70.80
+ 90.40.30.80.20.90.60.70.80.90 90.40.30.80.20.90.60.70.80.90.30
+ 90.40.30.80.20.90.60.70.80.90.30.50
+ 90.40.30.80.20.90.60.70.80.90.30.50.10
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30 81 81.91 81.91.61
+ 81.91.61.91 81.91.61.91.91 81.91.61.91.91.1 81.91.61.91.91.1.81
+ 81.91.61.91.91.1.81.41 81.91.61.91.91.1.81.41.61
+ 81.91.61.91.91.1.81.41.61.1 81.91.61.91.91.1.81.41.61.1.21
+ 81.91.61.91.91.1.81.41.61.1.21.11 81.91.61.91.91.1.81.41.61.1.21.11.51
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21 62 62.12
+ 62.12.32 62.12.32.22 62.12.32.22.42 62.12.32.22.42.2
+ 62.12.32.22.42.2.72 62.12.32.22.42.2.72.12 62.12.32.22.42.2.72.12.22
+ 62.12.32.22.42.2.72.12.22.2 62.12.32.22.42.2.72.12.22.2.72
+ 62.12.32.22.42.2.72.12.22.2.72.72 62.12.32.22.42.2.72.12.22.2.72.72.12
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82 93 93.23 93.23.93
+ 93.23.93.43 93.23.93.43.3 93.23.93.43.3.43 93.23.93.43.3.43.33
+ 93.23.93.43.3.43.33.53 93.23.93.43.3.43.33.53.63
+ 93.23.93.43.3.43.33.53.63.73 93.23.93.43.3.43.33.53.63.73.13
+ 93.23.93.43.3.43.33.53.63.73.13.73 93.23.93.43.3.43.33.53.63.73.13.73.73
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83 54 54.84
+ 54.84.74 54.84.74.24 54.84.74.24.4 54.84.74.24.4.94
+ 54.84.74.24.4.94.84 54.84.74.24.4.94.84.74 54.84.74.24.4.94.84.74.34
+ 54.84.74.24.4.94.84.74.34.34 54.84.74.24.4.94.84.74.34.34.44
+ 54.84.74.24.4.94.84.74.34.34.44.74 54.84.74.24.4.94.84.74.34.34.44.74.64
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34 65 65.35
+ 65.35.85 65.35.85.85 65.35.85.85.55 65.35.85.85.55.15
+ 65.35.85.85.55.15.25 65.35.85.85.55.15.25.75 65.35.85.85.55.15.25.75.95
+ 65.35.85.85.55.15.25.75.95.65 65.35.85.85.55.15.25.75.95.65.65
+ 65.35.85.85.55.15.25.75.95.65.65.35 65.35.85.85.55.15.25.75.95.65.65.35.5
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95 96 96.46
+ 96.46.6 96.46.6.46 96.46.6.46.16 96.46.6.46.16.16
+ 96.46.6.46.16.16.86 96.46.6.46.16.16.86.56 96.46.6.46.16.16.86.56.56
+ 96.46.6.46.16.16.86.56.56.56 96.46.6.46.16.16.86.56.56.56.16
+ 96.46.6.46.16.16.86.56.56.56.16.36 96.46.6.46.16.16.86.56.56.56.16.36.76
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36 97 97.27
+ 97.27.97 97.27.97.67 97.27.97.67.77 97.27.97.67.77.47
+ 97.27.97.67.77.47.7 97.27.97.67.77.47.7.47 97.27.97.67.77.47.7.47.87
+ 97.27.97.67.77.47.7.47.87.37 97.27.97.67.77.47.7.47.87.37.87
+ 97.27.97.67.77.47.7.47.87.37.87.77 97.27.97.67.77.47.7.47.87.37.87.77.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7 38 38.68
+ 38.68.78 38.68.78.8 38.68.78.8.28 38.68.78.8.28.98
+ 38.68.78.8.28.98.78 38.68.78.8.28.98.78.58 38.68.78.8.28.98.78.58.98
+ 38.68.78.8.28.98.78.58.98.8 38.68.78.8.28.98.78.58.98.8.88
+ 38.68.78.8.28.98.78.58.98.8.88.8 38.68.78.8.28.98.78.58.98.8.88.8.58
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38 89 89.59 89.59.39
+ 89.59.39.99 89.59.39.99.29 89.59.39.99.29.59 89.59.39.99.29.59.89
+ 89.59.39.99.29.59.89.89 89.59.39.99.29.59.89.89.29
+ 89.59.39.99.29.59.89.89.29.9 89.59.39.99.29.59.89.89.29.9.79
+ 89.59.39.99.29.59.89.89.29.9.79.49 89.59.39.99.29.59.89.89.29.9.79.49.59
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.7.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1.1 1.1.2 1.1.2.2 1.1.2.2.3 1.1.2.2.3.3 1.1.2.2.3.3.4
+ 1.1.2.2.3.3.4.5 1.1.2.2.3.3.4.5.6 1.1.2.2.3.3.4.5.6.7
+ 1.1.2.2.3.3.4.5.6.7.7 1.1.2.2.3.3.4.5.6.7.7.7 1.1.2.2.3.3.4.5.6.7.7.7.8
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99}
+
+do_execsql_test 1.7.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {10 10.20 10.20.30 10.20.30.30 10.20.30.30.30 10.20.30.30.30.40
+ 10.20.30.30.30.40.50 10.20.30.30.30.40.50.60 10.20.30.30.30.40.50.60.70
+ 10.20.30.30.30.40.50.60.70.80 10.20.30.30.30.40.50.60.70.80.80
+ 10.20.30.30.30.40.50.60.70.80.80.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90 1 1.1 1.1.11 1.1.11.11
+ 1.1.11.11.21 1.1.11.11.21.21 1.1.11.11.21.21.31 1.1.11.11.21.21.31.31
+ 1.1.11.11.21.21.31.31.41 1.1.11.11.21.21.31.31.41.41
+ 1.1.11.11.21.21.31.31.41.41.51 1.1.11.11.21.21.31.31.41.41.51.61
+ 1.1.11.11.21.21.31.31.41.41.51.61.61
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91 2 2.2
+ 2.2.12 2.2.12.12 2.2.12.12.12 2.2.12.12.12.22 2.2.12.12.12.22.22
+ 2.2.12.12.12.22.22.32 2.2.12.12.12.22.22.32.42
+ 2.2.12.12.12.22.22.32.42.52 2.2.12.12.12.22.22.32.42.52.62
+ 2.2.12.12.12.22.22.32.42.52.62.62 2.2.12.12.12.22.22.32.42.52.62.62.72
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82 3 3.3 3.3.13
+ 3.3.13.13 3.3.13.13.23 3.3.13.13.23.23 3.3.13.13.23.23.33
+ 3.3.13.13.23.23.33.33 3.3.13.13.23.23.33.33.33
+ 3.3.13.13.23.23.33.33.33.33 3.3.13.13.23.23.33.33.33.33.43
+ 3.3.13.13.23.23.33.33.33.33.43.43 3.3.13.13.23.23.33.33.33.33.43.43.53
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93 4 4.14
+ 4.14.24 4.14.24.34 4.14.24.34.34 4.14.24.34.34.34
+ 4.14.24.34.34.34.34 4.14.24.34.34.34.34.44 4.14.24.34.34.34.34.44.44
+ 4.14.24.34.34.34.34.44.44.54 4.14.24.34.34.34.34.44.44.54.64
+ 4.14.24.34.34.34.34.44.44.54.64.74 4.14.24.34.34.34.34.44.44.54.64.74.74
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94 5 5.15
+ 5.15.15 5.15.15.15 5.15.15.15.25 5.15.15.15.25.35
+ 5.15.15.15.25.35.35 5.15.15.15.25.35.35.55 5.15.15.15.25.35.35.55.55
+ 5.15.15.15.25.35.35.55.55.65 5.15.15.15.25.35.35.55.55.65.65
+ 5.15.15.15.25.35.35.55.55.65.65.65 5.15.15.15.25.35.35.55.55.65.65.65.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95 6 6.16
+ 6.16.16 6.16.16.16 6.16.16.16.26 6.16.16.16.26.26
+ 6.16.16.16.26.26.36 6.16.16.16.26.26.36.36 6.16.16.16.26.26.36.36.36
+ 6.16.16.16.26.26.36.36.36.36 6.16.16.16.26.26.36.36.36.36.46
+ 6.16.16.16.26.26.36.36.36.36.46.46 6.16.16.16.26.26.36.36.36.36.46.46.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96 7 7.7
+ 7.7.7 7.7.7.17 7.7.7.17.27 7.7.7.17.27.27 7.7.7.17.27.27.37
+ 7.7.7.17.27.27.37.37 7.7.7.17.27.27.37.37.47 7.7.7.17.27.27.37.37.47.47
+ 7.7.7.17.27.27.37.37.47.47.47 7.7.7.17.27.27.37.37.47.47.47.47
+ 7.7.7.17.27.27.37.37.47.47.47.47.57
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97 8 8.8 8.8.8
+ 8.8.8.28 8.8.8.28.38 8.8.8.28.38.38 8.8.8.28.38.38.58
+ 8.8.8.28.38.38.58.58 8.8.8.28.38.38.58.58.58 8.8.8.28.38.38.58.58.58.58
+ 8.8.8.28.38.38.58.58.58.58.68 8.8.8.28.38.38.58.58.58.58.68.78
+ 8.8.8.28.38.38.58.58.58.58.68.78.78
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98 9 9.9 9.9.9 9.9.9.19
+ 9.9.9.19.29 9.9.9.19.29.29 9.9.9.19.29.29.29 9.9.9.19.29.29.29.39
+ 9.9.9.19.29.29.29.39.39 9.9.9.19.29.29.29.39.39.39
+ 9.9.9.19.29.29.29.39.39.39.49 9.9.9.19.29.29.29.39.39.39.49.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99}
+
+do_execsql_test 1.7.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
+} {90 90.40 90.40.30 90.40.30.80 90.40.30.80.20 90.40.30.80.20.90
+ 90.40.30.80.20.90.60 90.40.30.80.20.90.60.70 90.40.30.80.20.90.60.70.80
+ 90.40.30.80.20.90.60.70.80.90 90.40.30.80.20.90.60.70.80.90.30
+ 90.40.30.80.20.90.60.70.80.90.30.50
+ 90.40.30.80.20.90.60.70.80.90.30.50.10
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.7.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.7.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.7.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.7.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.7.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {1 89 2 89 3 89.96 4 89.96 5 89.96.38 6 89.96.38 7 89.96.38.39
+ 8 89.96.38.39 9 89.96.38.39.91 10 89.96.38.39.91 11 89.96.38.39.91.6
+ 12 89.96.38.39.91.6 13 89.96.38.39.91.6.97 14 89.96.38.39.91.6.97
+ 15 89.96.38.39.91.6.97.46 16 89.96.38.39.91.6.97.46
+ 17 89.96.38.39.91.6.97.46.54 18 89.96.38.39.91.6.97.46.54
+ 19 89.96.38.39.91.6.97.46.54.8 20 89.96.38.39.91.6.97.46.54.8
+ 21 89.96.38.39.91.6.97.46.54.8.29 22 89.96.38.39.91.6.97.46.54.8.29
+ 23 89.96.38.39.91.6.97.46.54.8.29.84 24 89.96.38.39.91.6.97.46.54.8.29.84
+ 25 89.96.38.39.91.6.97.46.54.8.29.84.23
+ 26 89.96.38.39.91.6.97.46.54.8.29.84.23
+ 27 89.96.38.39.91.6.97.46.54.8.29.84.23.16
+ 28 89.96.38.39.91.6.97.46.54.8.29.84.23.16
+ 29 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65
+ 30 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65
+ 31 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47
+ 32 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47
+ 33 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86
+ 34 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86
+ 35 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61
+ 36 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61
+ 37 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85
+ 38 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85
+ 39 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85
+ 40 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85
+ 41 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59
+ 42 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59
+ 43 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32
+ 44 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32
+ 45 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3
+ 46 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3
+ 47 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22
+ 48 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22
+ 49 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55
+ 50 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55
+ 51 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28
+ 52 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28
+ 53 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25
+ 54 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25
+ 55 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1
+ 56 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1
+ 57 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40
+ 58 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40
+ 59 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56
+ 60 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56
+ 61 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75
+ 62 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75
+ 63 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89
+ 64 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89
+ 65 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76
+ 66 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76
+ 67 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4
+ 68 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4
+ 69 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42
+ 70 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42
+ 71 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78
+ 72 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78
+ 73 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29
+ 74 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29
+ 75 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63
+ 76 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63
+ 77 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87
+ 78 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87
+ 79 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80
+ 80 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80
+ 81 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72
+ 82 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72
+ 83 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9
+ 84 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9
+ 85 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73
+ 86 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73
+ 87 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65
+ 88 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65
+ 89 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58
+ 90 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58
+ 91 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98
+ 92 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98
+ 93 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21
+ 94 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21
+ 95 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65
+ 96 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65
+ 97 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5
+ 98 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5
+ 99 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11
+ 100 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11
+ 101 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87
+ 102 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87
+ 103 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12
+ 104 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12
+ 105 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20
+ 106 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20
+ 107 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31
+ 108 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31
+ 109 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95
+ 110 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95
+ 111 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73
+ 112 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73
+ 113 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88
+ 114 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88
+ 115 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8
+ 116 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8
+ 117 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49
+ 118 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49
+ 119 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90
+ 120 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90
+ 121 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96
+ 122 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96
+ 123 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55
+ 124 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55
+ 125 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77
+ 126 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77
+ 127 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2
+ 128 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2
+ 129 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85
+ 130 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85
+ 131 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74
+ 132 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74
+ 133 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70
+ 134 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70
+ 135 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19
+ 136 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19
+ 137 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26
+ 138 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26
+ 139 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47
+ 140 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47
+ 141 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90
+ 142 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90
+ 143 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58
+ 144 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58
+ 145 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9
+ 146 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9
+ 147 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72
+ 148 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72
+ 149 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33
+ 150 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33
+ 151 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75
+ 152 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75
+ 153 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81
+ 154 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81
+ 155 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23
+ 156 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23
+ 157 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13
+ 158 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13
+ 159 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14
+ 160 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14
+ 161 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91
+ 162 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91
+ 163 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91
+ 164 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91
+ 165 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15
+ 166 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15
+ 167 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36
+ 168 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36
+ 169 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3
+ 170 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3
+ 171 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69
+ 172 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69
+ 173 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52
+ 174 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52
+ 175 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50
+ 176 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50
+ 177 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10
+ 178 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10
+ 179 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33
+ 180 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33
+ 181 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39
+ 182 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39
+ 183 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58
+ 184 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58
+ 185 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38
+ 186 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38
+ 187 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83
+ 188 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83
+ 189 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82
+ 190 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7}
+
+do_execsql_test 1.7.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {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 {}
+ 101 {} 102 {} 103 {} 104 {} 105 {} 106 {} 107 {} 108 {}
+ 109 {} 110 {} 111 {} 112 {} 113 {} 114 {} 115 {} 116 {}
+ 117 {} 118 {} 119 {} 120 {} 121 {} 122 {} 123 {} 124 {}
+ 125 {} 126 {} 127 {} 128 {} 129 {} 130 {} 131 {} 132 {}
+ 133 {} 134 {} 135 {} 136 {} 137 {} 138 {} 139 {} 140 {}
+ 141 {} 142 {} 143 {} 144 {} 145 {} 146 {} 147 {} 148 {}
+ 149 {} 150 {} 151 {} 152 {} 153 {} 154 {} 155 {} 156 {}
+ 157 {} 158 {} 159 {} 160 {} 161 {} 162 {} 163 {} 164 {}
+ 165 {} 166 {} 167 {} 168 {} 169 {} 170 {} 171 {} 172 {}
+ 173 {} 174 {} 175 {} 176 {} 177 {} 178 {} 179 {} 180 {}
+ 181 {} 182 {} 183 {} 184 {} 185 {} 186 {} 187 {} 188 {}
+ 189 {} 190 {} 191 {}}
+
+do_execsql_test 1.7.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {}
+ 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {}
+ 20 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {}
+ 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {} 17 {} 18 {}
+ 19 {}}
+
+do_execsql_test 1.7.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {1 89 2 89.6 3 89.6.29 4 89.6.29.47 5 89.6.29.47.59
+ 6 89.6.29.47.59.28 7 89.6.29.47.59.28.75 8 89.6.29.47.59.28.75.78
+ 9 89.6.29.47.59.28.75.78.72 10 89.6.29.47.59.28.75.78.72.98
+ 11 89.6.29.47.59.28.75.78.72.98.87 12 89.6.29.47.59.28.75.78.72.98.87.73
+ 13 89.6.29.47.59.28.75.78.72.98.87.73.96
+ 14 89.6.29.47.59.28.75.78.72.98.87.73.96.74
+ 15 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90
+ 16 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75
+ 17 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91
+ 18 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69
+ 19 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 1 96 2 96.97
+ 3 96.97.84 4 96.97.84.86 5 96.97.84.86.32 6 96.97.84.86.32.25
+ 7 96.97.84.86.32.25.89 8 96.97.84.86.32.25.89.29
+ 9 96.97.84.86.32.25.89.29.9 10 96.97.84.86.32.25.89.29.9.21
+ 11 96.97.84.86.32.25.89.29.9.21.12 12 96.97.84.86.32.25.89.29.9.21.12.88
+ 13 96.97.84.86.32.25.89.29.9.21.12.88.55
+ 14 96.97.84.86.32.25.89.29.9.21.12.88.55.70
+ 15 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58
+ 16 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81
+ 17 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91
+ 18 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 1 38 2 38.46
+ 3 38.46.23 4 38.46.23.61 5 38.46.23.61.3 6 38.46.23.61.3.1
+ 7 38.46.23.61.3.1.76 8 38.46.23.61.3.1.76.63 9 38.46.23.61.3.1.76.63.73
+ 10 38.46.23.61.3.1.76.63.73.65 11 38.46.23.61.3.1.76.63.73.65.20
+ 12 38.46.23.61.3.1.76.63.73.65.20.8
+ 13 38.46.23.61.3.1.76.63.73.65.20.8.77
+ 14 38.46.23.61.3.1.76.63.73.65.20.8.77.19
+ 15 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9
+ 16 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23
+ 17 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15
+ 18 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 1 39 2 39.54
+ 3 39.54.16 4 39.54.16.85 5 39.54.16.85.22 6 39.54.16.85.22.40
+ 7 39.54.16.85.22.40.4 8 39.54.16.85.22.40.4.87
+ 9 39.54.16.85.22.40.4.87.65 10 39.54.16.85.22.40.4.87.65.5
+ 11 39.54.16.85.22.40.4.87.65.5.31 12 39.54.16.85.22.40.4.87.65.5.31.49
+ 13 39.54.16.85.22.40.4.87.65.5.31.49.2
+ 14 39.54.16.85.22.40.4.87.65.5.31.49.2.26
+ 15 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72
+ 16 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13
+ 17 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36
+ 18 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 1 91 2 91.8
+ 3 91.8.65 4 91.8.65.85 5 91.8.65.85.55 6 91.8.65.85.55.56
+ 7 91.8.65.85.55.56.42 8 91.8.65.85.55.56.42.80
+ 9 91.8.65.85.55.56.42.80.58 10 91.8.65.85.55.56.42.80.58.11
+ 11 91.8.65.85.55.56.42.80.58.11.95 12 91.8.65.85.55.56.42.80.58.11.95.90
+ 13 91.8.65.85.55.56.42.80.58.11.95.90.85
+ 14 91.8.65.85.55.56.42.80.58.11.95.90.85.47
+ 15 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33
+ 16 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14
+ 17 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3
+ 18 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82 1 {} 2 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {}
+ 13 {} 14 {} 15 {} 16 {} 17 {} 18 {} 19 {}}
+
+do_execsql_test 1.8.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {89 89 96 96 96 96 96 68 91 91 91 99 99 99 99
+ 99 97 97 97 97 97 97 93 93 93 93 84 93 93 93
+ 93 93 86 86 86 91 91 91 91 91 85 85 85 59 59
+ 91 91 91 91 91 90 90 89 89 89 89 56 56 56 56
+ 75 75 89 98 98 98 98 98 94 94 94 94 78 78 78
+ 63 87 87 87 87 87 84 84 84 73 95 95 95 95 96
+ 98 98 98 98 98 74 74 74 73 73 87 87 87 87 87
+ 41 31 31 95 95 95 95 95 88 88 88 88 49 90 90
+ 96 96 96 96 96 77 77 77 85 85 85 85 85 74 74
+ 70 70 59 47 80 90 90 90 90 90 72 72 72 72 93
+ 93 93 93 93 81 81 81 37 37 62 91 91 91 91 91
+ 91 91 99 99 99 99 99 95 95 69 84 84 84 84 84
+ 84 84 58 58 58 58 83 83 83 83 83}
+
+do_execsql_test 1.8.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {89 81 81 59 38 38 38 38 38 39 6 6 6 6 6 27
+ 27 27 8 8 8 8 8 29 23 16 16 16 16 16 16 7 7
+ 7 7 7 61 24 24 24 24 12 12 12 3 3 3 3 3 15
+ 15 15 15 15 1 1 1 1 1 16 16 16 16 16 36 36
+ 4 4 4 4 4 30 29 29 29 2 2 2 2 2 37 37 9 9
+ 9 9 9 13 13 13 13 1 1 1 1 1 5 5 5 5 5 11
+ 11 8 8 8 8 8 15 15 15 15 22 22 8 8 8 8 8
+ 11 34 34 55 55 55 44 2 2 2 2 2 7 29 29 19
+ 19 19 19 19 26 26 26 36 36 9 9 9 9 9 33 33
+ 33 33 9 9 9 9 9 12 12 12 12 14 33 15 15 15
+ 15 3 3 3 3 3 30 30 30 10 10 10 10 10 21 21
+ 21 30 30 30 27 27 17 7}
+
+do_execsql_test 1.8.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.8.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.8.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.8.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.8.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.8.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.8.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.8.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.8.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.8.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.8.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.8.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.8.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.8.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.8.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.8.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.8.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.8.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.8.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {99 92 108 72 52 83 55 79 109 65 26 120 119 50
+ 70 103 80 124 36 96 59 124 116 110 57 51 52 130
+ 103 74 87 48 128 117 105 136 131 71 133 92 109 63
+ 84 109 57 146 78 147 113 74 88 150 87 110 65 121
+ 106 110 124 85 145 107 161 171 150 156 80 171 120
+ 109 158 114 111 136 147 87 173 124 168 173 162 132
+ 101 154 167 190 161 110 156 195 198 102 123 177 169
+ 140 111 180 119 160 197 152 124 121 134 146 147 132
+ 213 141 193 200 210 157 132 136 175 161 218 188 226
+ 191 187 208 211 179 138 144 223 196 214 170 212 202
+ 163 184 172 173 195 229 240 187 210 200 163 227 228
+ 223 191 252 235 225 243 172 187 202 179 179 182 231
+ 261 207 263 206 189 209 212 276 181 274 249 239 234
+ 213 234 269 196 271 221 210 229 235 250 223 232 229
+ 279 224 280 216 207}
+
+do_execsql_test 1.8.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.8.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {65 102 87 138 57 181 80 111 26 48 144 207 36 121
+ 132 101 163 172 196 119 136 63 124 179 110 179 182
+ 74 132 189 51 52 85 216 163 134 123 210 78 141 57
+ 187 71 87 172 173 50 224 88 59 111 170 109 213
+ 223 146 147 84 114 191 206 221 157 161 209 229 74
+ 140 107 187 207 212 124 202 52 232 55 184 229 106
+ 132 152 120 92 110 179 235 65 70 87 110 195 200
+ 175 234 160 234 136 80 113 187 109 121 124 196 156
+ 210 239 250 72 109 188 202 191 105 154 79 231 147
+ 225 103 161 169 223 96 83 249 212 162 227 228 167
+ 180 193 117 177 214 145 208 235 150 110 211 103 158
+ 200 168 229 92 156 243 280 279 116 173 269 271 131
+ 133 223 128 173 197 210 99 150 161 147 218 240 109
+ 136 146 261 263 124 130 252 171 190 213 274 108 195
+ 226 119 124 171 198 120 276}
+
+do_execsql_test 1.8.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {196 134 109 213 223 106 234 191 212 168 229 147 218
+ 240 65 102 119 136 123 210 146 147 132 152 160 105
+ 154 92 156 243 109 136 146 261 263 87 138 63 124
+ 179 78 141 84 120 234 79 231 162 227 228 280 57
+ 181 110 179 57 187 114 191 206 221 92 110 136 147
+ 167 180 193 279 124 130 252 80 182 71 157 161 209
+ 229 179 235 80 225 117 177 214 116 173 269 271 171
+ 111 74 132 189 87 74 140 113 187 103 161 169 145
+ 208 235 131 133 223 190 213 274 26 51 52 85 172
+ 173 107 187 207 212 65 70 109 121 124 223 150 128
+ 108 195 226 48 144 207 216 50 224 124 202 87 110
+ 195 200 196 96 110 211 173 197 119 124 36 121 132
+ 88 52 232 156 210 239 250 83 103 158 210 171 198
+ 101 163 172 163 59 111 170 55 184 229 175 72 109
+ 188 202 249 200 99 150 161 120 276}
+
+do_execsql_test 1.8.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.8.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.8.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} 56
+ {} {} {} {} {} {} {} {} {} 89 {} {} {} {} {}
+ {} {} {} {} {} {} 4 {} {} {} {} {} {} {} {}
+ 53 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 58 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 77 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 99 {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} {} {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 33 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {{} 1 2 2 2 3 4 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} {} {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 33 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {89 89 89 89 89 81 96 59 38 68 39 62 91 46 6
+ 99 97 27 46 78 54 97 8 67 29 93 84 77 23 16
+ 16 93 65 35 47 7 86 74 61 91 85 24 85 43 59
+ 12 32 56 3 91 22 90 55 15 28 89 25 47 1 56 40
+ 43 56 16 75 36 89 98 76 81 4 94 42 30 78 33
+ 29 53 63 2 87 37 80 84 72 41 9 61 73 95 65 13
+ 58 96 98 1 21 74 65 35 5 73 11 51 87 41 12 8
+ 20 31 31 15 95 22 73 79 88 34 8 11 49 34 90
+ 59 96 60 55 75 77 44 2 7 85 57 74 29 70 59 19
+ 39 26 26 47 80 90 36 58 47 9 72 72 66 33 93
+ 75 64 81 9 23 37 13 12 14 62 91 36 91 33 15
+ 34 36 99 3 95 69 58 52 30 50 84 10 84 33 21
+ 39 44 58 30 38 34 83}
+
+do_execsql_test 1.8.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {90 90 90 90 90 40 30 80 20 90 60 70 80 90 81
+ 81 81 81 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 62 62 62 62 62 12 32 22 42 2 72
+ 12 22 2 72 72 93 93 93 93 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 54 54 54 54 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 65
+ 65 65 65 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 96 96 96 96 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 97 97 97 97 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 38
+ 38 38 38 38 68 78 8 28 98 78 58 98 8 88 8 89
+ 89 89 89 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.8.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 2 2 3 3 4 5 6 7 7 7 8 8 8
+ 9 9 9 10 11 11 12 12 12 13 13 14 15 15 15 16
+ 16 16 17 19 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 30 30 30 31 31 32 33 33 33
+ 33 34 34 34 34 35 35 36 36 36 36 37 37 38 38
+ 39 39 39 40 41 41 42 43 43 44 44 46 46 47 47
+ 47 47 49 50 51 52 53 54 55 55 56 56 56 57 58
+ 58 58 58 59 59 59 59 60 61 61 62 62 63 64 65
+ 65 65 66 67 68 69 70 72 72 72 73 73 73 74 74
+ 74 75 75 75 76 77 77 78 78 79 80 80 81 81 81
+ 82 83 84 84 84 84 85 85 85 86 87 87 88 89 89
+ 89 90 90 90 91 91 91 91 91 93 93 93 94 95 95
+ 95 96 96 96 97 97}
+
+do_execsql_test 1.8.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {10 10 10 10 10 20 30 30 30 40 50 60 70 80 1 1
+ 1 1 1 1 11 11 21 21 31 31 41 41 51 61 61 81
+ 81 81 91 2 2 2 2 2 2 12 12 12 22 22 32 42
+ 52 62 62 3 3 3 3 3 3 13 13 23 23 33 33 33
+ 33 43 43 53 63 73 73 73 4 4 4 4 4 14 24 34
+ 34 34 34 44 44 54 64 74 74 74 84 5 5 5 5 5
+ 15 15 15 25 35 35 55 55 65 65 65 75 75 75 85
+ 85 6 6 6 6 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 7 7 7 7 7 7 7 17 27 27 37
+ 37 47 47 47 47 57 67 77 77 8 8 8 8 8 8 8 28
+ 38 38 58 58 58 58 68 78 9 9 9 9 9 9 9 19 29
+ 29 29 39 39 39 49 59 59 59 59 69 79 89}
+
+do_execsql_test 1.8.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {90 90 90 90 90 40 30 80 20 90 60 70 80 90 30
+ 50 10 30 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 81 91 91 21 62 12 32 22 42 2 72
+ 12 22 2 72 72 12 62 52 82 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 33 3 33 83 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 84
+ 84 44 34 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 85 75 15 95 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 36 66 36 36 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 37
+ 27 17 7 38 68 78 8 28 98 78 58 98 8 88 8 58
+ 58 58 38 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.8.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.8.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.8.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.8.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.8.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.8.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.8.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.8.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {89 89.81 89.81.96 89.81.96.59 89.81.96.59.38 81.96.59.38.68
+ 96.59.38.68.39 59.38.68.39.62 38.68.39.62.91 68.39.62.91.46
+ 39.62.91.46.6 62.91.46.6.99 91.46.6.99.97 46.6.99.97.27
+ 6.99.97.27.46 99.97.27.46.78 97.27.46.78.54 27.46.78.54.97
+ 46.78.54.97.8 78.54.97.8.67 54.97.8.67.29 97.8.67.29.93
+ 8.67.29.93.84 67.29.93.84.77 29.93.84.77.23 93.84.77.23.16
+ 84.77.23.16.16 77.23.16.16.93 23.16.16.93.65 16.16.93.65.35
+ 16.93.65.35.47 93.65.35.47.7 65.35.47.7.86 35.47.7.86.74
+ 47.7.86.74.61 7.86.74.61.91 86.74.61.91.85 74.61.91.85.24
+ 61.91.85.24.85 91.85.24.85.43 85.24.85.43.59 24.85.43.59.12
+ 85.43.59.12.32 43.59.12.32.56 59.12.32.56.3 12.32.56.3.91
+ 32.56.3.91.22 56.3.91.22.90 3.91.22.90.55 91.22.90.55.15
+ 22.90.55.15.28 90.55.15.28.89 55.15.28.89.25 15.28.89.25.47
+ 28.89.25.47.1 89.25.47.1.56 25.47.1.56.40 47.1.56.40.43
+ 1.56.40.43.56 56.40.43.56.16 40.43.56.16.75 43.56.16.75.36
+ 56.16.75.36.89 16.75.36.89.98 75.36.89.98.76 36.89.98.76.81
+ 89.98.76.81.4 98.76.81.4.94 76.81.4.94.42 81.4.94.42.30
+ 4.94.42.30.78 94.42.30.78.33 42.30.78.33.29 30.78.33.29.53
+ 78.33.29.53.63 33.29.53.63.2 29.53.63.2.87 53.63.2.87.37
+ 63.2.87.37.80 2.87.37.80.84 87.37.80.84.72 37.80.84.72.41
+ 80.84.72.41.9 84.72.41.9.61 72.41.9.61.73 41.9.61.73.95
+ 9.61.73.95.65 61.73.95.65.13 73.95.65.13.58 95.65.13.58.96
+ 65.13.58.96.98 13.58.96.98.1 58.96.98.1.21 96.98.1.21.74
+ 98.1.21.74.65 1.21.74.65.35 21.74.65.35.5 74.65.35.5.73
+ 65.35.5.73.11 35.5.73.11.51 5.73.11.51.87 73.11.51.87.41
+ 11.51.87.41.12 51.87.41.12.8 87.41.12.8.20 41.12.8.20.31
+ 12.8.20.31.31 8.20.31.31.15 20.31.31.15.95 31.31.15.95.22
+ 31.15.95.22.73 15.95.22.73.79 95.22.73.79.88 22.73.79.88.34
+ 73.79.88.34.8 79.88.34.8.11 88.34.8.11.49 34.8.11.49.34
+ 8.11.49.34.90 11.49.34.90.59 49.34.90.59.96 34.90.59.96.60
+ 90.59.96.60.55 59.96.60.55.75 96.60.55.75.77 60.55.75.77.44
+ 55.75.77.44.2 75.77.44.2.7 77.44.2.7.85 44.2.7.85.57 2.7.85.57.74
+ 7.85.57.74.29 85.57.74.29.70 57.74.29.70.59 74.29.70.59.19
+ 29.70.59.19.39 70.59.19.39.26 59.19.39.26.26 19.39.26.26.47
+ 39.26.26.47.80 26.26.47.80.90 26.47.80.90.36 47.80.90.36.58
+ 80.90.36.58.47 90.36.58.47.9 36.58.47.9.72 58.47.9.72.72
+ 47.9.72.72.66 9.72.72.66.33 72.72.66.33.93 72.66.33.93.75
+ 66.33.93.75.64 33.93.75.64.81 93.75.64.81.9 75.64.81.9.23
+ 64.81.9.23.37 81.9.23.37.13 9.23.37.13.12 23.37.13.12.14
+ 37.13.12.14.62 13.12.14.62.91 12.14.62.91.36 14.62.91.36.91
+ 62.91.36.91.33 91.36.91.33.15 36.91.33.15.34 91.33.15.34.36
+ 33.15.34.36.99 15.34.36.99.3 34.36.99.3.95 36.99.3.95.69
+ 99.3.95.69.58 3.95.69.58.52 95.69.58.52.30 69.58.52.30.50
+ 58.52.30.50.84 52.30.50.84.10 30.50.84.10.84 50.84.10.84.33
+ 84.10.84.33.21 10.84.33.21.39 84.33.21.39.44 33.21.39.44.58
+ 21.39.44.58.30 39.44.58.30.38 44.58.30.38.34 58.30.38.34.83
+ 30.38.34.83.27 38.34.83.27.82 34.83.27.82.17 83.27.82.17.7}
+
+do_execsql_test 1.8.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {90 90.40 90.40.30 90.40.30.80 90.40.30.80.20 40.30.80.20.90
+ 30.80.20.90.60 80.20.90.60.70 20.90.60.70.80 90.60.70.80.90
+ 60.70.80.90.30 70.80.90.30.50 80.90.30.50.10 90.30.50.10.30 81
+ 81.91 81.91.61 81.91.61.91 81.91.61.91.91 91.61.91.91.1
+ 61.91.91.1.81 91.91.1.81.41 91.1.81.41.61 1.81.41.61.1
+ 81.41.61.1.21 41.61.1.21.11 61.1.21.11.51 1.21.11.51.41
+ 21.11.51.41.31 11.51.41.31.31 51.41.31.31.11 41.31.31.11.81
+ 31.31.11.81.91 31.11.81.91.91 11.81.91.91.21 62 62.12 62.12.32
+ 62.12.32.22 62.12.32.22.42 12.32.22.42.2 32.22.42.2.72
+ 22.42.2.72.12 42.2.72.12.22 2.72.12.22.2 72.12.22.2.72
+ 12.22.2.72.72 22.2.72.72.12 2.72.72.12.62 72.72.12.62.52
+ 72.12.62.52.82 93 93.23 93.23.93 93.23.93.43 93.23.93.43.3
+ 23.93.43.3.43 93.43.3.43.33 43.3.43.33.53 3.43.33.53.63
+ 43.33.53.63.73 33.53.63.73.13 53.63.73.13.73 63.73.13.73.73
+ 73.13.73.73.33 13.73.73.33.93 73.73.33.93.23 73.33.93.23.13
+ 33.93.23.13.33 93.23.13.33.3 23.13.33.3.33 13.33.3.33.83 54 54.84
+ 54.84.74 54.84.74.24 54.84.74.24.4 84.74.24.4.94 74.24.4.94.84
+ 24.4.94.84.74 4.94.84.74.34 94.84.74.34.34 84.74.34.34.44
+ 74.34.34.44.74 34.34.44.74.64 34.44.74.64.14 44.74.64.14.34
+ 74.64.14.34.84 64.14.34.84.84 14.34.84.84.44 34.84.84.44.34 65
+ 65.35 65.35.85 65.35.85.85 65.35.85.85.55 35.85.85.55.15
+ 85.85.55.15.25 85.55.15.25.75 55.15.25.75.95 15.25.75.95.65
+ 25.75.95.65.65 75.95.65.65.35 95.65.65.35.5 65.65.35.5.15
+ 65.35.5.15.95 35.5.15.95.55 5.15.95.55.75 15.95.55.75.85
+ 95.55.75.85.75 55.75.85.75.15 75.85.75.15.95 96 96.46 96.46.6
+ 96.46.6.46 96.46.6.46.16 46.6.46.16.16 6.46.16.16.86 46.16.16.86.56
+ 16.16.86.56.56 16.86.56.56.56 86.56.56.56.16 56.56.56.16.36
+ 56.56.16.36.76 56.16.36.76.96 16.36.76.96.96 36.76.96.96.26
+ 76.96.96.26.26 96.96.26.26.36 96.26.26.36.66 26.26.36.66.36
+ 26.36.66.36.36 97 97.27 97.27.97 97.27.97.67 97.27.97.67.77
+ 27.97.67.77.47 97.67.77.47.7 67.77.47.7.47 77.47.7.47.87
+ 47.7.47.87.37 7.47.87.37.87 47.87.37.87.77 87.37.87.77.7
+ 37.87.77.7.57 87.77.7.57.47 77.7.57.47.47 7.57.47.47.37
+ 57.47.47.37.27 47.47.37.27.17 47.37.27.17.7 38 38.68 38.68.78
+ 38.68.78.8 38.68.78.8.28 68.78.8.28.98 78.8.28.98.78 8.28.98.78.58
+ 28.98.78.58.98 98.78.58.98.8 78.58.98.8.88 58.98.8.88.8
+ 98.8.88.8.58 8.88.8.58.58 88.8.58.58.58 8.58.58.58.38 89 89.59
+ 89.59.39 89.59.39.99 89.59.39.99.29 59.39.99.29.59 39.99.29.59.89
+ 99.29.59.89.89 29.59.89.89.29 59.89.89.29.9 89.89.29.9.79
+ 89.29.9.79.49 29.9.79.49.59 9.79.49.59.29 79.49.59.29.59
+ 49.59.29.59.19 59.29.59.19.39 29.59.19.39.9 59.19.39.9.9
+ 19.39.9.9.99 39.9.9.99.69 9.9.99.69.39}
+
+do_execsql_test 1.8.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {1 1.1 1.1.2 1.1.2.2 1.1.2.2.3 1.2.2.3.3 2.2.3.3.4 2.3.3.4.5
+ 3.3.4.5.6 3.4.5.6.7 4.5.6.7.7 5.6.7.7.7 6.7.7.7.8 7.7.7.8.8
+ 7.7.8.8.8 7.8.8.8.9 8.8.8.9.9 8.8.9.9.9 8.9.9.9.10 9.9.9.10.11
+ 9.9.10.11.11 9.10.11.11.12 10.11.11.12.12 11.11.12.12.12
+ 11.12.12.12.13 12.12.12.13.13 12.12.13.13.14 12.13.13.14.15
+ 13.13.14.15.15 13.14.15.15.15 14.15.15.15.16 15.15.15.16.16
+ 15.15.16.16.16 15.16.16.16.17 16.16.16.17.19 16.16.17.19.20
+ 16.17.19.20.21 17.19.20.21.21 19.20.21.21.22 20.21.21.22.22
+ 21.21.22.22.23 21.22.22.23.23 22.22.23.23.24 22.23.23.24.25
+ 23.23.24.25.26 23.24.25.26.26 24.25.26.26.27 25.26.26.27.27
+ 26.26.27.27.28 26.27.27.28.29 27.27.28.29.29 27.28.29.29.29
+ 28.29.29.29.30 29.29.29.30.30 29.29.30.30.30 29.30.30.30.31
+ 30.30.30.31.31 30.30.31.31.32 30.31.31.32.33 31.31.32.33.33
+ 31.32.33.33.33 32.33.33.33.33 33.33.33.33.34 33.33.33.34.34
+ 33.33.34.34.34 33.34.34.34.34 34.34.34.34.35 34.34.34.35.35
+ 34.34.35.35.36 34.35.35.36.36 35.35.36.36.36 35.36.36.36.36
+ 36.36.36.36.37 36.36.36.37.37 36.36.37.37.38 36.37.37.38.38
+ 37.37.38.38.39 37.38.38.39.39 38.38.39.39.39 38.39.39.39.40
+ 39.39.39.40.41 39.39.40.41.41 39.40.41.41.42 40.41.41.42.43
+ 41.41.42.43.43 41.42.43.43.44 42.43.43.44.44 43.43.44.44.46
+ 43.44.44.46.46 44.44.46.46.47 44.46.46.47.47 46.46.47.47.47
+ 46.47.47.47.47 47.47.47.47.49 47.47.47.49.50 47.47.49.50.51
+ 47.49.50.51.52 49.50.51.52.53 50.51.52.53.54 51.52.53.54.55
+ 52.53.54.55.55 53.54.55.55.56 54.55.55.56.56 55.55.56.56.56
+ 55.56.56.56.57 56.56.56.57.58 56.56.57.58.58 56.57.58.58.58
+ 57.58.58.58.58 58.58.58.58.59 58.58.58.59.59 58.58.59.59.59
+ 58.59.59.59.59 59.59.59.59.60 59.59.59.60.61 59.59.60.61.61
+ 59.60.61.61.62 60.61.61.62.62 61.61.62.62.63 61.62.62.63.64
+ 62.62.63.64.65 62.63.64.65.65 63.64.65.65.65 64.65.65.65.66
+ 65.65.65.66.67 65.65.66.67.68 65.66.67.68.69 66.67.68.69.70
+ 67.68.69.70.72 68.69.70.72.72 69.70.72.72.72 70.72.72.72.73
+ 72.72.72.73.73 72.72.73.73.73 72.73.73.73.74 73.73.73.74.74
+ 73.73.74.74.74 73.74.74.74.75 74.74.74.75.75 74.74.75.75.75
+ 74.75.75.75.76 75.75.75.76.77 75.75.76.77.77 75.76.77.77.78
+ 76.77.77.78.78 77.77.78.78.79 77.78.78.79.80 78.78.79.80.80
+ 78.79.80.80.81 79.80.80.81.81 80.80.81.81.81 80.81.81.81.82
+ 81.81.81.82.83 81.81.82.83.84 81.82.83.84.84 82.83.84.84.84
+ 83.84.84.84.84 84.84.84.84.85 84.84.84.85.85 84.84.85.85.85
+ 84.85.85.85.86 85.85.85.86.87 85.85.86.87.87 85.86.87.87.88
+ 86.87.87.88.89 87.87.88.89.89 87.88.89.89.89 88.89.89.89.90
+ 89.89.89.90.90 89.89.90.90.90 89.90.90.90.91 90.90.90.91.91
+ 90.90.91.91.91 90.91.91.91.91 91.91.91.91.91 91.91.91.91.93
+ 91.91.91.93.93 91.91.93.93.93 91.93.93.93.94 93.93.93.94.95
+ 93.93.94.95.95 93.94.95.95.95 94.95.95.95.96 95.95.95.96.96
+ 95.95.96.96.96 95.96.96.96.97 96.96.96.97.97 96.96.97.97.98
+ 96.97.97.98.98 97.97.98.98.99 97.98.98.99.99}
+
+do_execsql_test 1.8.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {10 10.20 10.20.30 10.20.30.30 10.20.30.30.30 20.30.30.30.40
+ 30.30.30.40.50 30.30.40.50.60 30.40.50.60.70 40.50.60.70.80
+ 50.60.70.80.80 60.70.80.80.90 70.80.80.90.90 80.80.90.90.90 1 1.1
+ 1.1.11 1.1.11.11 1.1.11.11.21 1.11.11.21.21 11.11.21.21.31
+ 11.21.21.31.31 21.21.31.31.41 21.31.31.41.41 31.31.41.41.51
+ 31.41.41.51.61 41.41.51.61.61 41.51.61.61.81 51.61.61.81.81
+ 61.61.81.81.81 61.81.81.81.91 81.81.81.91.91 81.81.91.91.91
+ 81.91.91.91.91 91.91.91.91.91 2 2.2 2.2.12 2.2.12.12
+ 2.2.12.12.12 2.12.12.12.22 12.12.12.22.22 12.12.22.22.32
+ 12.22.22.32.42 22.22.32.42.52 22.32.42.52.62 32.42.52.62.62
+ 42.52.62.62.72 52.62.62.72.72 62.62.72.72.72 62.72.72.72.82 3 3.3
+ 3.3.13 3.3.13.13 3.3.13.13.23 3.13.13.23.23 13.13.23.23.33
+ 13.23.23.33.33 23.23.33.33.33 23.33.33.33.33 33.33.33.33.43
+ 33.33.33.43.43 33.33.43.43.53 33.43.43.53.63 43.43.53.63.73
+ 43.53.63.73.73 53.63.73.73.73 63.73.73.73.83 73.73.73.83.93
+ 73.73.83.93.93 73.83.93.93.93 4 4.14 4.14.24 4.14.24.34
+ 4.14.24.34.34 14.24.34.34.34 24.34.34.34.34 34.34.34.34.44
+ 34.34.34.44.44 34.34.44.44.54 34.44.44.54.64 44.44.54.64.74
+ 44.54.64.74.74 54.64.74.74.74 64.74.74.74.84 74.74.74.84.84
+ 74.74.84.84.84 74.84.84.84.84 84.84.84.84.94 5 5.15 5.15.15
+ 5.15.15.15 5.15.15.15.25 15.15.15.25.35 15.15.25.35.35
+ 15.25.35.35.55 25.35.35.55.55 35.35.55.55.65 35.55.55.65.65
+ 55.55.65.65.65 55.65.65.65.75 65.65.65.75.75 65.65.75.75.75
+ 65.75.75.75.85 75.75.75.85.85 75.75.85.85.85 75.85.85.85.95
+ 85.85.85.95.95 85.85.95.95.95 6 6.16 6.16.16 6.16.16.16
+ 6.16.16.16.26 16.16.16.26.26 16.16.26.26.36 16.26.26.36.36
+ 26.26.36.36.36 26.36.36.36.36 36.36.36.36.46 36.36.36.46.46
+ 36.36.46.46.56 36.46.46.56.56 46.46.56.56.56 46.56.56.56.66
+ 56.56.56.66.76 56.56.66.76.86 56.66.76.86.96 66.76.86.96.96
+ 76.86.96.96.96 7 7.7 7.7.7 7.7.7.17 7.7.7.17.27 7.7.17.27.27
+ 7.17.27.27.37 17.27.27.37.37 27.27.37.37.47 27.37.37.47.47
+ 37.37.47.47.47 37.47.47.47.47 47.47.47.47.57 47.47.47.57.67
+ 47.47.57.67.77 47.57.67.77.77 57.67.77.77.87 67.77.77.87.87
+ 77.77.87.87.97 77.87.87.97.97 8 8.8 8.8.8 8.8.8.28 8.8.8.28.38
+ 8.8.28.38.38 8.28.38.38.58 28.38.38.58.58 38.38.58.58.58
+ 38.58.58.58.58 58.58.58.58.68 58.58.58.68.78 58.58.68.78.78
+ 58.68.78.78.88 68.78.78.88.98 78.78.88.98.98 9 9.9 9.9.9
+ 9.9.9.19 9.9.9.19.29 9.9.19.29.29 9.19.29.29.29 19.29.29.29.39
+ 29.29.29.39.39 29.29.39.39.39 29.39.39.39.49 39.39.39.49.59
+ 39.39.49.59.59 39.49.59.59.59 49.59.59.59.59 59.59.59.59.69
+ 59.59.59.69.79 59.59.69.79.89 59.69.79.89.89 69.79.89.89.89
+ 79.89.89.89.99 89.89.89.99.99}
+
+do_execsql_test 1.8.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) FROM t2
+} {90 90.40 90.40.30 90.40.30.80 90.40.30.80.20 40.30.80.20.90
+ 30.80.20.90.60 80.20.90.60.70 20.90.60.70.80 90.60.70.80.90
+ 60.70.80.90.30 70.80.90.30.50 80.90.30.50.10 90.30.50.10.30
+ 30.50.10.30.81 50.10.30.81.91 10.30.81.91.61 30.81.91.61.91
+ 81.91.61.91.91 91.61.91.91.1 61.91.91.1.81 91.91.1.81.41
+ 91.1.81.41.61 1.81.41.61.1 81.41.61.1.21 41.61.1.21.11
+ 61.1.21.11.51 1.21.11.51.41 21.11.51.41.31 11.51.41.31.31
+ 51.41.31.31.11 41.31.31.11.81 31.31.11.81.91 31.11.81.91.91
+ 11.81.91.91.21 81.91.91.21.62 91.91.21.62.12 91.21.62.12.32
+ 21.62.12.32.22 62.12.32.22.42 12.32.22.42.2 32.22.42.2.72
+ 22.42.2.72.12 42.2.72.12.22 2.72.12.22.2 72.12.22.2.72
+ 12.22.2.72.72 22.2.72.72.12 2.72.72.12.62 72.72.12.62.52
+ 72.12.62.52.82 12.62.52.82.93 62.52.82.93.23 52.82.93.23.93
+ 82.93.23.93.43 93.23.93.43.3 23.93.43.3.43 93.43.3.43.33
+ 43.3.43.33.53 3.43.33.53.63 43.33.53.63.73 33.53.63.73.13
+ 53.63.73.13.73 63.73.13.73.73 73.13.73.73.33 13.73.73.33.93
+ 73.73.33.93.23 73.33.93.23.13 33.93.23.13.33 93.23.13.33.3
+ 23.13.33.3.33 13.33.3.33.83 33.3.33.83.54 3.33.83.54.84
+ 33.83.54.84.74 83.54.84.74.24 54.84.74.24.4 84.74.24.4.94
+ 74.24.4.94.84 24.4.94.84.74 4.94.84.74.34 94.84.74.34.34
+ 84.74.34.34.44 74.34.34.44.74 34.34.44.74.64 34.44.74.64.14
+ 44.74.64.14.34 74.64.14.34.84 64.14.34.84.84 14.34.84.84.44
+ 34.84.84.44.34 84.84.44.34.65 84.44.34.65.35 44.34.65.35.85
+ 34.65.35.85.85 65.35.85.85.55 35.85.85.55.15 85.85.55.15.25
+ 85.55.15.25.75 55.15.25.75.95 15.25.75.95.65 25.75.95.65.65
+ 75.95.65.65.35 95.65.65.35.5 65.65.35.5.15 65.35.5.15.95
+ 35.5.15.95.55 5.15.95.55.75 15.95.55.75.85 95.55.75.85.75
+ 55.75.85.75.15 75.85.75.15.95 85.75.15.95.96 75.15.95.96.46
+ 15.95.96.46.6 95.96.46.6.46 96.46.6.46.16 46.6.46.16.16
+ 6.46.16.16.86 46.16.16.86.56 16.16.86.56.56 16.86.56.56.56
+ 86.56.56.56.16 56.56.56.16.36 56.56.16.36.76 56.16.36.76.96
+ 16.36.76.96.96 36.76.96.96.26 76.96.96.26.26 96.96.26.26.36
+ 96.26.26.36.66 26.26.36.66.36 26.36.66.36.36 36.66.36.36.97
+ 66.36.36.97.27 36.36.97.27.97 36.97.27.97.67 97.27.97.67.77
+ 27.97.67.77.47 97.67.77.47.7 67.77.47.7.47 77.47.7.47.87
+ 47.7.47.87.37 7.47.87.37.87 47.87.37.87.77 87.37.87.77.7
+ 37.87.77.7.57 87.77.7.57.47 77.7.57.47.47 7.57.47.47.37
+ 57.47.47.37.27 47.47.37.27.17 47.37.27.17.7 37.27.17.7.38
+ 27.17.7.38.68 17.7.38.68.78 7.38.68.78.8 38.68.78.8.28
+ 68.78.8.28.98 78.8.28.98.78 8.28.98.78.58 28.98.78.58.98
+ 98.78.58.98.8 78.58.98.8.88 58.98.8.88.8 98.8.88.8.58 8.88.8.58.58
+ 88.8.58.58.58 8.58.58.58.38 58.58.58.38.89 58.58.38.89.59
+ 58.38.89.59.39 38.89.59.39.99 89.59.39.99.29 59.39.99.29.59
+ 39.99.29.59.89 99.29.59.89.89 29.59.89.89.29 59.89.89.29.9
+ 89.89.29.9.79 89.29.9.79.49 29.9.79.49.59 9.79.49.59.29
+ 79.49.59.29.59 49.59.29.59.19 59.29.59.19.39 29.59.19.39.9
+ 59.19.39.9.9 19.39.9.9.99 39.9.9.99.69 9.9.99.69.39}
+
+do_execsql_test 1.8.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.8.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.8.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.8.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.8.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW)
+} {1 89 2 89 3 89.96 4 89.96 5 89.96.38 5 96.38 5 96.38.39
+ 5 38.39 5 38.39.91 5 39.91 5 39.91.6 5 91.6 5 91.6.97 5 6.97
+ 5 6.97.46 5 97.46 5 97.46.54 5 46.54 5 46.54.8 5 54.8 5 54.8.29
+ 5 8.29 5 8.29.84 5 29.84 5 29.84.23 5 84.23 5 84.23.16 5 23.16
+ 5 23.16.65 5 16.65 5 16.65.47 5 65.47 5 65.47.86 5 47.86
+ 5 47.86.61 5 86.61 5 86.61.85 5 61.85 5 61.85.85 5 85.85
+ 5 85.85.59 5 85.59 5 85.59.32 5 59.32 5 59.32.3 5 32.3
+ 5 32.3.22 5 3.22 5 3.22.55 5 22.55 5 22.55.28 5 55.28
+ 5 55.28.25 5 28.25 5 28.25.1 5 25.1 5 25.1.40 5 1.40 5 1.40.56
+ 5 40.56 5 40.56.75 5 56.75 5 56.75.89 5 75.89 5 75.89.76
+ 5 89.76 5 89.76.4 5 76.4 5 76.4.42 5 4.42 5 4.42.78 5 42.78
+ 5 42.78.29 5 78.29 5 78.29.63 5 29.63 5 29.63.87 5 63.87
+ 5 63.87.80 5 87.80 5 87.80.72 5 80.72 5 80.72.9 5 72.9
+ 5 72.9.73 5 9.73 5 9.73.65 5 73.65 5 73.65.58 5 65.58
+ 5 65.58.98 5 58.98 5 58.98.21 5 98.21 5 98.21.65 5 21.65
+ 5 21.65.5 5 65.5 5 65.5.11 5 5.11 5 5.11.87 5 11.87 5 11.87.12
+ 5 87.12 5 87.12.20 5 12.20 5 12.20.31 5 20.31 5 20.31.95
+ 5 31.95 5 31.95.73 5 95.73 5 95.73.88 5 73.88 5 73.88.8 5 88.8
+ 5 88.8.49 5 8.49 5 8.49.90 5 49.90 5 49.90.96 5 90.96
+ 5 90.96.55 5 96.55 5 96.55.77 5 55.77 5 55.77.2 5 77.2
+ 5 77.2.85 5 2.85 5 2.85.74 5 85.74 5 85.74.70 5 74.70
+ 5 74.70.19 5 70.19 5 70.19.26 5 19.26 5 19.26.47 5 26.47
+ 5 26.47.90 5 47.90 5 47.90.58 5 90.58 5 90.58.9 5 58.9
+ 5 58.9.72 5 9.72 5 9.72.33 5 72.33 5 72.33.75 5 33.75
+ 5 33.75.81 5 75.81 5 75.81.23 5 81.23 5 81.23.13 5 23.13
+ 5 23.13.14 5 13.14 5 13.14.91 5 14.91 5 14.91.91 5 91.91
+ 5 91.91.15 5 91.15 5 91.15.36 5 15.36 5 15.36.3 5 36.3
+ 5 36.3.69 5 3.69 5 3.69.52 5 69.52 5 69.52.50 5 52.50
+ 5 52.50.10 5 50.10 5 50.10.33 5 10.33 5 10.33.39 5 33.39
+ 5 33.39.58 5 39.58 5 39.58.38 5 58.38 5 58.38.83 5 38.83
+ 5 38.83.82 5 83.82 5 83.82.7}
+
+do_execsql_test 1.8.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW)
+} {1 {} 2 {} 3 {} 4 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {}}
+
+do_execsql_test 1.8.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW)
+} {1 {} 2 {} 3 {} 4 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 1 {} 2 {}
+ 3 {} 4 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 1 {} 2 {} 3 {} 4 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 1 {} 2 {} 3 {} 4 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 1 {} 2 {} 3 {} 4 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 1 {} 2 {} 3 {}
+ 4 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 1 {} 2 {} 3 {} 4 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 1 {} 2 {} 3 {} 4 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 1 {}
+ 2 {} 3 {} 4 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 1 {} 2 {} 3 {} 4 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {}}
+
+do_execsql_test 1.8.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND CURRENT ROW)
+} {1 89 2 89.6 3 89.6.29 4 89.6.29.47 5 89.6.29.47.59
+ 5 6.29.47.59.28 5 29.47.59.28.75 5 47.59.28.75.78 5 59.28.75.78.72
+ 5 28.75.78.72.98 5 75.78.72.98.87 5 78.72.98.87.73 5 72.98.87.73.96
+ 5 98.87.73.96.74 5 87.73.96.74.90 5 73.96.74.90.75 5 96.74.90.75.91
+ 5 74.90.75.91.69 5 90.75.91.69.39 5 75.91.69.39.7 1 {} 2 {} 3 {}
+ 4 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 1 96 2 96.97 3 96.97.84
+ 4 96.97.84.86 5 96.97.84.86.32 5 97.84.86.32.25 5 84.86.32.25.89
+ 5 86.32.25.89.29 5 32.25.89.29.9 5 25.89.29.9.21 5 89.29.9.21.12
+ 5 29.9.21.12.88 5 9.21.12.88.55 5 21.12.88.55.70 5 12.88.55.70.58
+ 5 88.55.70.58.81 5 55.70.58.81.91 5 70.58.81.91.52 5 58.81.91.52.58
+ 1 {} 2 {} 3 {} 4 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 1 38 2 38.46
+ 3 38.46.23 4 38.46.23.61 5 38.46.23.61.3 5 46.23.61.3.1
+ 5 23.61.3.1.76 5 61.3.1.76.63 5 3.1.76.63.73 5 1.76.63.73.65
+ 5 76.63.73.65.20 5 63.73.65.20.8 5 73.65.20.8.77 5 65.20.8.77.19
+ 5 20.8.77.19.9 5 8.77.19.9.23 5 77.19.9.23.15 5 19.9.23.15.50
+ 5 9.23.15.50.38 1 {} 2 {} 3 {} 4 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 1 39 2 39.54 3 39.54.16 4 39.54.16.85 5 39.54.16.85.22
+ 5 54.16.85.22.40 5 16.85.22.40.4 5 85.22.40.4.87 5 22.40.4.87.65
+ 5 40.4.87.65.5 5 4.87.65.5.31 5 87.65.5.31.49 5 65.5.31.49.2
+ 5 5.31.49.2.26 5 31.49.2.26.72 5 49.2.26.72.13 5 2.26.72.13.36
+ 5 26.72.13.36.10 5 72.13.36.10.83 1 {} 2 {} 3 {} 4 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 1 91 2 91.8 3 91.8.65 4 91.8.65.85
+ 5 91.8.65.85.55 5 8.65.85.55.56 5 65.85.55.56.42 5 85.55.56.42.80
+ 5 55.56.42.80.58 5 56.42.80.58.11 5 42.80.58.11.95 5 80.58.11.95.90
+ 5 58.11.95.90.85 5 11.95.90.85.47 5 95.90.85.47.33 5 90.85.47.33.14
+ 5 85.47.33.14.3 5 47.33.14.3.33 5 33.14.3.33.82 1 {} 2 {} 3 {}
+ 4 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {}}
+
+do_execsql_test 1.9.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.9.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.9.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.9.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.9.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.9.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.9.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.9.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.9.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.9.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.9.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.9.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.9.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.9.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.9.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.9.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.9.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.9.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.9.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.9.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.9.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {99 92 108 72 52 83 55 79 109 65 26 120 119 50
+ 70 103 80 124 36 96 59 124 116 110 57 51 52 130
+ 103 74 87 48 128 117 105 136 131 71 133 92 109 63
+ 84 109 57 146 78 147 113 74 88 150 87 110 65 121
+ 106 110 124 85 145 107 161 171 150 156 80 171 120
+ 109 158 114 111 136 147 87 173 124 168 173 162 132
+ 101 154 167 190 161 110 156 195 198 102 123 177 169
+ 140 111 180 119 160 197 152 124 121 134 146 147 132
+ 213 141 193 200 210 157 132 136 175 161 218 188 226
+ 191 187 208 211 179 138 144 223 196 214 170 212 202
+ 163 184 172 173 195 229 240 187 210 200 163 227 228
+ 223 191 252 235 225 243 172 187 202 179 179 182 231
+ 261 207 263 206 189 209 212 276 181 274 249 239 234
+ 213 234 269 196 271 221 210 229 235 250 223 232 229
+ 279 224 280 216 207}
+
+do_execsql_test 1.9.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.9.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {65 102 87 138 57 181 80 111 26 48 144 207 36 121
+ 132 101 163 172 196 119 136 63 124 179 110 179 182
+ 74 132 189 51 52 85 216 163 134 123 210 78 141 57
+ 187 71 87 172 173 50 224 88 59 111 170 109 213
+ 223 146 147 84 114 191 206 221 157 161 209 229 74
+ 140 107 187 207 212 124 202 52 232 55 184 229 106
+ 132 152 120 92 110 179 235 65 70 87 110 195 200
+ 175 234 160 234 136 80 113 187 109 121 124 196 156
+ 210 239 250 72 109 188 202 191 105 154 79 231 147
+ 225 103 161 169 223 96 83 249 212 162 227 228 167
+ 180 193 117 177 214 145 208 235 150 110 211 103 158
+ 200 168 229 92 156 243 280 279 116 173 269 271 131
+ 133 223 128 173 197 210 99 150 161 147 218 240 109
+ 136 146 261 263 124 130 252 171 190 213 274 108 195
+ 226 119 124 171 198 120 276}
+
+do_execsql_test 1.9.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {196 134 109 213 223 106 234 191 212 168 229 147 218
+ 240 65 102 119 136 123 210 146 147 132 152 160 105
+ 154 92 156 243 109 136 146 261 263 87 138 63 124
+ 179 78 141 84 120 234 79 231 162 227 228 280 57
+ 181 110 179 57 187 114 191 206 221 92 110 136 147
+ 167 180 193 279 124 130 252 80 182 71 157 161 209
+ 229 179 235 80 225 117 177 214 116 173 269 271 171
+ 111 74 132 189 87 74 140 113 187 103 161 169 145
+ 208 235 131 133 223 190 213 274 26 51 52 85 172
+ 173 107 187 207 212 65 70 109 121 124 223 150 128
+ 108 195 226 48 144 207 216 50 224 124 202 87 110
+ 195 200 196 96 110 211 173 197 119 124 36 121 132
+ 88 52 232 156 210 239 250 83 103 158 210 171 198
+ 101 163 172 163 59 111 170 55 184 229 175 72 109
+ 188 202 249 200 99 150 161 120 276}
+
+do_execsql_test 1.9.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {147 106 109 168 134 218 191 212 229 240 213 234 196
+ 223 92 109 105 136 146 65 156 132 154 102 123 119
+ 160 152 146 147 136 243 261 263 210 79 63 84 78
+ 120 87 162 124 141 138 227 228 179 231 234 280 124
+ 57 130 92 57 110 114 136 147 167 110 180 193 191
+ 252 187 179 206 181 221 279 80 116 117 71 80 171
+ 173 177 157 161 179 214 225 182 209 269 271 235 229
+ 103 74 131 133 113 74 87 145 190 161 169 140 111
+ 132 213 187 208 223 235 189 274 108 65 26 70 51
+ 52 128 109 121 124 85 107 150 195 226 172 173 187
+ 223 207 212 119 50 124 96 110 87 48 110 173 124
+ 197 211 144 196 195 200 202 224 216 207 52 83 103
+ 36 88 171 158 156 198 121 210 132 210 239 250 232
+ 99 72 55 120 59 109 150 161 111 101 200 175 188
+ 170 202 163 184 163 172 276 249 229}
+
+do_execsql_test 1.9.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.9.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.9.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.9.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 19 20 21 21 22 22 23 23 24 25 26 26 27 27 28
+ 29 29 29 30 30 30 31 31 32 33 33 33 33 34 34
+ 34 34 35 35 36 36 36 36 37 37 38 38 39 39 39
+ 40 41 41 42 43 43 44 44 46 46 47 47 47 47 49
+ 50 51 52 53 54 55 55 56 56 56 57 58 58 58 58
+ 59 59 59 59 60 61 61 62 62 63 64 65 65 65 66
+ 67 68 69 70 72 72 72 73 73 73 74 74 74 75 75
+ 75 76 77 77 78 78 79 80 80 81 81 81 82 83 84
+ 84 84 84 85 85 85 86 87 87 88 89 89 89 90 90
+ 90 91 91 91 91 91 93 93 93 94 95 95 95 96 96
+ 96 97 97 98 98 99 99}
+
+do_execsql_test 1.9.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {10 20 30 30 30 40 50 60 70 80 80 90 90 90 1 1
+ 11 11 21 21 31 31 41 41 51 61 61 81 81 81 91
+ 91 91 91 91 2 2 12 12 12 22 22 32 42 52 62 62
+ 72 72 72 82 3 3 13 13 23 23 33 33 33 33 43 43
+ 53 63 73 73 73 83 93 93 93 4 14 24 34 34 34
+ 34 44 44 54 64 74 74 74 84 84 84 84 94 5 15
+ 15 15 25 35 35 55 55 65 65 65 75 75 75 85 85
+ 85 95 95 95 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 86 96 96 96 7 7 7 17 27 27
+ 37 37 47 47 47 47 57 67 77 77 87 87 97 97 8 8
+ 8 28 38 38 58 58 58 58 68 78 78 88 98 98 9 9
+ 9 19 29 29 29 39 39 39 49 59 59 59 59 69 79
+ 89 89 89 99 99}
+
+do_execsql_test 1.9.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.9.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.9.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.9.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.9.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.9.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.9.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.9.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.9.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.9.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.9.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 19 20 21 21 22 22 23 23 24 25 26 26 27 27 28
+ 29 29 29 30 30 30 31 31 32 33 33 33 33 34 34
+ 34 34 35 35 36 36 36 36 37 37 38 38 39 39 39
+ 40 41 41 42 43 43 44 44 46 46 47 47 47 47 49
+ 50 51 52 53 54 55 55 56 56 56 57 58 58 58 58
+ 59 59 59 59 60 61 61 62 62 63 64 65 65 65 66
+ 67 68 69 70 72 72 72 73 73 73 74 74 74 75 75
+ 75 76 77 77 78 78 79 80 80 81 81 81 82 83 84
+ 84 84 84 85 85 85 86 87 87 88 89 89 89 90 90
+ 90 91 91 91 91 91 93 93 93 94 95 95 95 96 96
+ 96 97 97 98 98 99 99}
+
+do_execsql_test 1.9.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {10 20 30 30 30 40 50 60 70 80 80 90 90 90 1 1
+ 11 11 21 21 31 31 41 41 51 61 61 81 81 81 91
+ 91 91 91 91 2 2 12 12 12 22 22 32 42 52 62 62
+ 72 72 72 82 3 3 13 13 23 23 33 33 33 33 43 43
+ 53 63 73 73 73 83 93 93 93 4 14 24 34 34 34
+ 34 44 44 54 64 74 74 74 84 84 84 84 94 5 15
+ 15 15 25 35 35 55 55 65 65 65 75 75 75 85 85
+ 85 95 95 95 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 86 96 96 96 7 7 7 17 27 27
+ 37 37 47 47 47 47 57 67 77 77 87 87 97 97 8 8
+ 8 28 38 38 58 58 58 58 68 78 78 88 98 98 9 9
+ 9 19 29 29 29 39 39 39 49 59 59 59 59 69 79
+ 89 89 89 99 99}
+
+do_execsql_test 1.9.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND CURRENT ROW ) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.9.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.9.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.9.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.9.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN CURRENT ROW AND CURRENT ROW)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.9.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW)
+} {1 89 1 {} 1 96 1 {} 1 38 1 {} 1 39 1 {} 1 91 1 {} 1 6
+ 1 {} 1 97 1 {} 1 46 1 {} 1 54 1 {} 1 8 1 {} 1 29 1 {}
+ 1 84 1 {} 1 23 1 {} 1 16 1 {} 1 65 1 {} 1 47 1 {} 1 86
+ 1 {} 1 61 1 {} 1 85 1 {} 1 85 1 {} 1 59 1 {} 1 32 1 {}
+ 1 3 1 {} 1 22 1 {} 1 55 1 {} 1 28 1 {} 1 25 1 {} 1 1
+ 1 {} 1 40 1 {} 1 56 1 {} 1 75 1 {} 1 89 1 {} 1 76 1 {}
+ 1 4 1 {} 1 42 1 {} 1 78 1 {} 1 29 1 {} 1 63 1 {} 1 87
+ 1 {} 1 80 1 {} 1 72 1 {} 1 9 1 {} 1 73 1 {} 1 65 1 {}
+ 1 58 1 {} 1 98 1 {} 1 21 1 {} 1 65 1 {} 1 5 1 {} 1 11
+ 1 {} 1 87 1 {} 1 12 1 {} 1 20 1 {} 1 31 1 {} 1 95 1 {}
+ 1 73 1 {} 1 88 1 {} 1 8 1 {} 1 49 1 {} 1 90 1 {} 1 96
+ 1 {} 1 55 1 {} 1 77 1 {} 1 2 1 {} 1 85 1 {} 1 74 1 {}
+ 1 70 1 {} 1 19 1 {} 1 26 1 {} 1 47 1 {} 1 90 1 {} 1 58
+ 1 {} 1 9 1 {} 1 72 1 {} 1 33 1 {} 1 75 1 {} 1 81 1 {}
+ 1 23 1 {} 1 13 1 {} 1 14 1 {} 1 91 1 {} 1 91 1 {} 1 15
+ 1 {} 1 36 1 {} 1 3 1 {} 1 69 1 {} 1 52 1 {} 1 50 1 {}
+ 1 10 1 {} 1 33 1 {} 1 39 1 {} 1 58 1 {} 1 38 1 {} 1 83
+ 1 {} 1 82 1 {} 1 7}
+
+do_execsql_test 1.9.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW)
+} {1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {}}
+
+do_execsql_test 1.9.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW)
+} {1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {}}
+
+do_execsql_test 1.9.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN CURRENT ROW AND CURRENT ROW)
+} {1 89 1 6 1 29 1 47 1 59 1 28 1 75 1 78 1 72 1 98 1 87
+ 1 73 1 96 1 74 1 90 1 75 1 91 1 69 1 39 1 7 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 96 1 97 1 84 1 86 1 32
+ 1 25 1 89 1 29 1 9 1 21 1 12 1 88 1 55 1 70 1 58 1 81
+ 1 91 1 52 1 58 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 38 1 46 1 23 1 61 1 3 1 1 1 76 1 63 1 73 1 65 1 20
+ 1 8 1 77 1 19 1 9 1 23 1 15 1 50 1 38 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 39 1 54 1 16 1 85 1 22 1 40
+ 1 4 1 87 1 65 1 5 1 31 1 49 1 2 1 26 1 72 1 13 1 36
+ 1 10 1 83 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 91
+ 1 8 1 65 1 85 1 55 1 56 1 42 1 80 1 58 1 11 1 95 1 90
+ 1 85 1 47 1 33 1 14 1 3 1 33 1 82 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {} 1 {}
+ 1 {} 1 {} 1 {} 1 {}}
+
+do_execsql_test 1.10.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {96 96 96 96 96 96 96 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99}
+
+do_execsql_test 1.10.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {38 38 38 38 38 38 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1}
+
+do_execsql_test 1.10.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.10.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.10.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.10.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.10.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.10.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.10.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.10.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.10.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.10.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.10.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.10.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.10.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.10.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.10.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.10.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.10.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.10.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.10.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {52 83 55 79 109 65 26 120 119 50 70 103 80 124
+ 36 96 59 124 116 110 57 51 52 130 103 74 87 48
+ 128 117 105 136 131 71 133 92 109 63 84 109 57
+ 146 78 147 113 74 88 150 87 110 65 121 106 110
+ 124 85 145 107 161 171 150 156 80 171 120 109 158
+ 114 111 136 147 87 173 124 168 173 162 132 101 154
+ 167 190 161 110 156 195 198 102 123 177 169 140 111
+ 180 119 160 197 152 124 121 134 146 147 132 213 141
+ 193 200 210 157 132 136 175 161 218 188 226 191 187
+ 208 211 179 138 144 223 196 214 170 212 202 163 184
+ 172 173 195 229 240 187 210 200 163 227 228 223 191
+ 252 235 225 243 172 187 202 179 179 182 231 261 207
+ 263 206 189 209 212 276 181 274 249 239 234 213 234
+ 269 196 271 221 210 229 235 250 223 232 229 279 224
+ 280 216 207 207 207 207 207}
+
+do_execsql_test 1.10.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {134 218 191 212 229 240 213 234 196 223 223 223 223
+ 223 146 65 156 132 154 102 123 119 160 152 146 147
+ 136 243 261 263 210 210 210 210 210 120 87 162 124
+ 141 138 227 228 179 231 234 280 280 280 280 280 57
+ 110 114 136 147 167 110 180 193 191 252 187 179 206
+ 181 221 279 279 279 279 279 80 171 173 177 157 161
+ 179 214 225 182 209 269 271 235 229 229 229 229 229
+ 113 74 87 145 190 161 169 140 111 132 213 187 208
+ 223 235 189 274 274 274 274 274 51 52 128 109 121
+ 124 85 107 150 195 226 172 173 187 223 207 212 212
+ 212 212 212 110 87 48 110 173 124 197 211 144 196
+ 195 200 202 224 216 207 207 207 207 207 88 171 158
+ 156 198 121 210 132 210 239 250 232 232 232 232 232
+ 59 109 150 161 111 101 200 175 188 170 202 163 184
+ 163 172 276 249 229 229 229 229 229}
+
+do_execsql_test 1.10.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {57 181 80 111 26 48 144 207 36 121 132 101 163
+ 172 196 119 136 63 124 179 110 179 182 74 132 189
+ 51 52 85 216 163 134 123 210 78 141 57 187 71 87
+ 172 173 50 224 88 59 111 170 109 213 223 146 147
+ 84 114 191 206 221 157 161 209 229 74 140 107 187
+ 207 212 124 202 52 232 55 184 229 106 132 152 120
+ 92 110 179 235 65 70 87 110 195 200 175 234 160
+ 234 136 80 113 187 109 121 124 196 156 210 239 250
+ 72 109 188 202 191 105 154 79 231 147 225 103 161
+ 169 223 96 83 249 212 162 227 228 167 180 193 117
+ 177 214 145 208 235 150 110 211 103 158 200 168 229
+ 92 156 243 280 279 116 173 269 271 131 133 223 128
+ 173 197 210 99 150 161 147 218 240 109 136 146 261
+ 263 124 130 252 171 190 213 274 108 195 226 119 124
+ 171 198 120 276 276 276 276 276}
+
+do_execsql_test 1.10.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {223 106 234 191 212 168 229 147 218 240 240 240 240
+ 240 123 210 146 147 132 152 160 105 154 92 156 243
+ 109 136 146 261 263 263 263 263 263 179 78 141 84
+ 120 234 79 231 162 227 228 280 280 280 280 280 57
+ 187 114 191 206 221 92 110 136 147 167 180 193 279
+ 124 130 252 252 252 252 252 161 209 229 179 235 80
+ 225 117 177 214 116 173 269 271 171 171 171 171 171
+ 87 74 140 113 187 103 161 169 145 208 235 131 133
+ 223 190 213 274 274 274 274 274 172 173 107 187 207
+ 212 65 70 109 121 124 223 150 128 108 195 226 226
+ 226 226 226 50 224 124 202 87 110 195 200 196 96
+ 110 211 173 197 119 124 124 124 124 124 52 232 156
+ 210 239 250 83 103 158 210 171 198 198 198 198 198
+ 59 111 170 55 184 229 175 72 109 188 202 249 200
+ 99 150 161 120 276 276 276 276 276}
+
+do_execsql_test 1.10.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {134 218 191 212 229 240 213 234 196 223 92 109 105
+ 136 146 65 156 132 154 102 123 119 160 152 146 147
+ 136 243 261 263 210 79 63 84 78 120 87 162 124
+ 141 138 227 228 179 231 234 280 124 57 130 92 57
+ 110 114 136 147 167 110 180 193 191 252 187 179 206
+ 181 221 279 80 116 117 71 80 171 173 177 157 161
+ 179 214 225 182 209 269 271 235 229 103 74 131 133
+ 113 74 87 145 190 161 169 140 111 132 213 187 208
+ 223 235 189 274 108 65 26 70 51 52 128 109 121
+ 124 85 107 150 195 226 172 173 187 223 207 212 119
+ 50 124 96 110 87 48 110 173 124 197 211 144 196
+ 195 200 202 224 216 207 52 83 103 36 88 171 158
+ 156 198 121 210 132 210 239 250 232 99 72 55 120
+ 59 109 150 161 111 101 200 175 188 170 202 163 184
+ 163 172 276 249 229 229 229 229 229}
+
+do_execsql_test 1.10.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.10.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 39 {} {} {} {}
+ {} {} {} 91 {} {} {} {} {} 77 54 54 {} {} {}
+ {} 62 {} {} {} {} {} 23 {} 56 {} 97 86 {} 59
+ {} 84 {} {} 78 65 {} 16 90 81 40 59 56 40 54
+ {} 85 {} {} {} {} 38 {} 32 47 {} 74 35 47 98
+ 96 {} 24 72 {} 29 12 46 36 53 {} 81 27 56 {}
+ {} 81 93 63 81 91 68 53 99 89 13 12 97 91 29
+ 7 7 78 35 84 53 84 58 61 91 99 15 61 98 16 5
+ 75 56 2 37 3 96 62 95 43 63 35 78 16 67 43 16
+ 16 90 72 98 85 56 90 46 29 29 4 74 74 2 76 41
+ 46 77 24 27 97 46 89 1 85 1 74 78 61 85 51 59
+ 35 30 56 25 47 28 73 6 73 74 93 43 3 56 47 85
+ 61 61 93 9 97 62}
+
+do_execsql_test 1.10.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 91 {} 11 {} {} {} {}
+ 11 {} {} {} {} {} {} {} {} {} 32 {} {} {} 32
+ {} {} 12 {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} 33 {} {} {} {} {} 33 {} 43 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} 34 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 15 55
+ {} {} {} {} {} 55 {} {} {} 86 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 47 {} {} {} {} {} 47 {} {} {} {}
+ {} 27 47 {} {} {} {} {} {} {} {} {} 98 {} 98
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} 99 {} 9 9 {} {} {}}
+
+do_execsql_test 1.10.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 1 2 2 2 2 3 3 4 5 5 5 6 6 6 7 7 7 7
+ 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9 11 11 12
+ 12 12 12 12 12 13 13 14 14 15 15 15 15 15 15
+ 16 16 16 16 16 16 17 17 17 17 19 19 19 19 20
+ 20 21 21 21 21 21 21 22 22 22 22 22 23 23 23
+ 24 25 25 26 26 27 27 27 27 27 27 29 29 29 30
+ 30 30 31 31 31 31 31 32 33 33 33 33 33 33 33
+ 33 33 33 33 34 34 34 34 34 34 34 35 35 36 36
+ 36 37 37 37 37 37 37 38 38 38 38 38 38 39 39
+ 39 39 39 40 41 41 41 41 41 42 43 43 43 43 43
+ 44 44 44 44 46 46 46 47 47 47 47 47 47 47 47
+ 47 47 47 49 49 49 50 51 51 51 52 52 52 53 53
+ 54 54 55 55}
+
+do_execsql_test 1.10.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} 1 1
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 12 12 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 13 13 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} 34 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.10.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 40 {} {} {} 40 41 50 {} {} 81 81
+ 50 {} {} {} 41 {} 10 91 61 12 30 {} 10 61 30
+ {} {} 10 {} 23 {} {} 1 {} 22 80 22 91 93 73
+ {} 30 {} {} 91 {} 1 30 91 80 91 {} 43 {} 74
+ 21 20 {} {} 74 21 21 2 74 33 81 21 64 64 2 21
+ 93 62 14 14 3 91 11 24 55 93 93 62 90 91 55 3
+ 24 14 24 91 55 15 72 60 72 61 61 34 43 43 43
+ 61 12 4 15 15 51 51 12 23 12 12 25 41 25 13
+ 94 12 70 12 84 32 84 94 70 33 12 12 32 41 91
+ 70 22 33 84 80 31 75 84 53 75 80 84 80 53 53
+ 53 22 44 63 42 95 31 63 44 44 31 90 74 52 63
+ 31 63 1 42 90 90 95 3 42}
+
+do_execsql_test 1.10.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.10.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.10.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 81
+ 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81
+ 81 81 81 81 81 62 62 62 62 62 62 62 62 62 62
+ 62 62 62 62 62 62 93 93 93 93 93 93 93 93 93
+ 93 93 93 93 93 93 93 93 93 93 93 93 54 54 54
+ 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
+ 54 65 65 65 65 65 65 65 65 65 65 65 65 65 65
+ 65 65 65 65 65 65 65 96 96 96 96 96 96 96 96
+ 96 96 96 96 96 96 96 96 96 96 96 96 96 97 97
+ 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97
+ 97 97 97 38 38 38 38 38 38 38 38 38 38 38 38
+ 38 38 38 38 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.10.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1}
+
+do_execsql_test 1.10.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
+ 9 9 9 9}
+
+do_execsql_test 1.10.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90}
+
+do_execsql_test 1.10.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.10.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.10.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.10.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.10.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.10.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.10.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.10.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.10.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.10.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.10.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.10.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.10.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.10.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {89.81.96.59.38 89.81.96.59.38.68 89.81.96.59.38.68.39
+ 89.81.96.59.38.68.39.62 89.81.96.59.38.68.39.62.91
+ 89.81.96.59.38.68.39.62.91.46 89.81.96.59.38.68.39.62.91.46.6
+ 89.81.96.59.38.68.39.62.91.46.6.99 89.81.96.59.38.68.39.62.91.46.6.99.97
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7}
+
+do_execsql_test 1.10.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {90.40.30.80.20 90.40.30.80.20.90 90.40.30.80.20.90.60
+ 90.40.30.80.20.90.60.70 90.40.30.80.20.90.60.70.80
+ 90.40.30.80.20.90.60.70.80.90 90.40.30.80.20.90.60.70.80.90.30
+ 90.40.30.80.20.90.60.70.80.90.30.50
+ 90.40.30.80.20.90.60.70.80.90.30.50.10
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30 81.91.61.91.91
+ 81.91.61.91.91.1 81.91.61.91.91.1.81 81.91.61.91.91.1.81.41
+ 81.91.61.91.91.1.81.41.61 81.91.61.91.91.1.81.41.61.1
+ 81.91.61.91.91.1.81.41.61.1.21 81.91.61.91.91.1.81.41.61.1.21.11
+ 81.91.61.91.91.1.81.41.61.1.21.11.51
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 62.12.32.22.42 62.12.32.22.42.2 62.12.32.22.42.2.72
+ 62.12.32.22.42.2.72.12 62.12.32.22.42.2.72.12.22
+ 62.12.32.22.42.2.72.12.22.2 62.12.32.22.42.2.72.12.22.2.72
+ 62.12.32.22.42.2.72.12.22.2.72.72 62.12.32.22.42.2.72.12.22.2.72.72.12
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82 93.23.93.43.3
+ 93.23.93.43.3.43 93.23.93.43.3.43.33 93.23.93.43.3.43.33.53
+ 93.23.93.43.3.43.33.53.63 93.23.93.43.3.43.33.53.63.73
+ 93.23.93.43.3.43.33.53.63.73.13 93.23.93.43.3.43.33.53.63.73.13.73
+ 93.23.93.43.3.43.33.53.63.73.13.73.73
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 54.84.74.24.4 54.84.74.24.4.94 54.84.74.24.4.94.84
+ 54.84.74.24.4.94.84.74 54.84.74.24.4.94.84.74.34
+ 54.84.74.24.4.94.84.74.34.34 54.84.74.24.4.94.84.74.34.34.44
+ 54.84.74.24.4.94.84.74.34.34.44.74 54.84.74.24.4.94.84.74.34.34.44.74.64
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34 65.35.85.85.55
+ 65.35.85.85.55.15 65.35.85.85.55.15.25 65.35.85.85.55.15.25.75
+ 65.35.85.85.55.15.25.75.95 65.35.85.85.55.15.25.75.95.65
+ 65.35.85.85.55.15.25.75.95.65.65 65.35.85.85.55.15.25.75.95.65.65.35
+ 65.35.85.85.55.15.25.75.95.65.65.35.5
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 96.46.6.46.16 96.46.6.46.16.16 96.46.6.46.16.16.86
+ 96.46.6.46.16.16.86.56 96.46.6.46.16.16.86.56.56
+ 96.46.6.46.16.16.86.56.56.56 96.46.6.46.16.16.86.56.56.56.16
+ 96.46.6.46.16.16.86.56.56.56.16.36 96.46.6.46.16.16.86.56.56.56.16.36.76
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 97.27.97.67.77 97.27.97.67.77.47 97.27.97.67.77.47.7
+ 97.27.97.67.77.47.7.47 97.27.97.67.77.47.7.47.87
+ 97.27.97.67.77.47.7.47.87.37 97.27.97.67.77.47.7.47.87.37.87
+ 97.27.97.67.77.47.7.47.87.37.87.77 97.27.97.67.77.47.7.47.87.37.87.77.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7 38.68.78.8.28
+ 38.68.78.8.28.98 38.68.78.8.28.98.78 38.68.78.8.28.98.78.58
+ 38.68.78.8.28.98.78.58.98 38.68.78.8.28.98.78.58.98.8
+ 38.68.78.8.28.98.78.58.98.8.88 38.68.78.8.28.98.78.58.98.8.88.8
+ 38.68.78.8.28.98.78.58.98.8.88.8.58
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38 89.59.39.99.29
+ 89.59.39.99.29.59 89.59.39.99.29.59.89 89.59.39.99.29.59.89.89
+ 89.59.39.99.29.59.89.89.29 89.59.39.99.29.59.89.89.29.9
+ 89.59.39.99.29.59.89.89.29.9.79 89.59.39.99.29.59.89.89.29.9.79.49
+ 89.59.39.99.29.59.89.89.29.9.79.49.59
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.10.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {1.1.2.2.3 1.1.2.2.3.3 1.1.2.2.3.3.4 1.1.2.2.3.3.4.5
+ 1.1.2.2.3.3.4.5.6 1.1.2.2.3.3.4.5.6.7 1.1.2.2.3.3.4.5.6.7.7
+ 1.1.2.2.3.3.4.5.6.7.7.7 1.1.2.2.3.3.4.5.6.7.7.7.8
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99}
+
+do_execsql_test 1.10.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {10.20.30.30.30 10.20.30.30.30.40 10.20.30.30.30.40.50
+ 10.20.30.30.30.40.50.60 10.20.30.30.30.40.50.60.70
+ 10.20.30.30.30.40.50.60.70.80 10.20.30.30.30.40.50.60.70.80.80
+ 10.20.30.30.30.40.50.60.70.80.80.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90 1.1.11.11.21 1.1.11.11.21.21
+ 1.1.11.11.21.21.31 1.1.11.11.21.21.31.31 1.1.11.11.21.21.31.31.41
+ 1.1.11.11.21.21.31.31.41.41 1.1.11.11.21.21.31.31.41.41.51
+ 1.1.11.11.21.21.31.31.41.41.51.61 1.1.11.11.21.21.31.31.41.41.51.61.61
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91 2.2.12.12.12
+ 2.2.12.12.12.22 2.2.12.12.12.22.22 2.2.12.12.12.22.22.32
+ 2.2.12.12.12.22.22.32.42 2.2.12.12.12.22.22.32.42.52
+ 2.2.12.12.12.22.22.32.42.52.62 2.2.12.12.12.22.22.32.42.52.62.62
+ 2.2.12.12.12.22.22.32.42.52.62.62.72
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82 3.3.13.13.23
+ 3.3.13.13.23.23 3.3.13.13.23.23.33 3.3.13.13.23.23.33.33
+ 3.3.13.13.23.23.33.33.33 3.3.13.13.23.23.33.33.33.33
+ 3.3.13.13.23.23.33.33.33.33.43 3.3.13.13.23.23.33.33.33.33.43.43
+ 3.3.13.13.23.23.33.33.33.33.43.43.53
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 4.14.24.34.34 4.14.24.34.34.34 4.14.24.34.34.34.34
+ 4.14.24.34.34.34.34.44 4.14.24.34.34.34.34.44.44
+ 4.14.24.34.34.34.34.44.44.54 4.14.24.34.34.34.34.44.44.54.64
+ 4.14.24.34.34.34.34.44.44.54.64.74 4.14.24.34.34.34.34.44.44.54.64.74.74
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94 5.15.15.15.25
+ 5.15.15.15.25.35 5.15.15.15.25.35.35 5.15.15.15.25.35.35.55
+ 5.15.15.15.25.35.35.55.55 5.15.15.15.25.35.35.55.55.65
+ 5.15.15.15.25.35.35.55.55.65.65 5.15.15.15.25.35.35.55.55.65.65.65
+ 5.15.15.15.25.35.35.55.55.65.65.65.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 6.16.16.16.26 6.16.16.16.26.26 6.16.16.16.26.26.36
+ 6.16.16.16.26.26.36.36 6.16.16.16.26.26.36.36.36
+ 6.16.16.16.26.26.36.36.36.36 6.16.16.16.26.26.36.36.36.36.46
+ 6.16.16.16.26.26.36.36.36.36.46.46 6.16.16.16.26.26.36.36.36.36.46.46.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96 7.7.7.17.27
+ 7.7.7.17.27.27 7.7.7.17.27.27.37 7.7.7.17.27.27.37.37
+ 7.7.7.17.27.27.37.37.47 7.7.7.17.27.27.37.37.47.47
+ 7.7.7.17.27.27.37.37.47.47.47 7.7.7.17.27.27.37.37.47.47.47.47
+ 7.7.7.17.27.27.37.37.47.47.47.47.57
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97 8.8.8.28.38
+ 8.8.8.28.38.38 8.8.8.28.38.38.58 8.8.8.28.38.38.58.58
+ 8.8.8.28.38.38.58.58.58 8.8.8.28.38.38.58.58.58.58
+ 8.8.8.28.38.38.58.58.58.58.68 8.8.8.28.38.38.58.58.58.58.68.78
+ 8.8.8.28.38.38.58.58.58.58.68.78.78
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98 9.9.9.19.29 9.9.9.19.29.29
+ 9.9.9.19.29.29.29 9.9.9.19.29.29.29.39 9.9.9.19.29.29.29.39.39
+ 9.9.9.19.29.29.29.39.39.39 9.9.9.19.29.29.29.39.39.39.49
+ 9.9.9.19.29.29.29.39.39.39.49.59 9.9.9.19.29.29.29.39.39.39.49.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99}
+
+do_execsql_test 1.10.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
+} {90.40.30.80.20 90.40.30.80.20.90 90.40.30.80.20.90.60
+ 90.40.30.80.20.90.60.70 90.40.30.80.20.90.60.70.80
+ 90.40.30.80.20.90.60.70.80.90 90.40.30.80.20.90.60.70.80.90.30
+ 90.40.30.80.20.90.60.70.80.90.30.50
+ 90.40.30.80.20.90.60.70.80.90.30.50.10
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.10.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.10.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.10.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.10.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.10.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING)
+} {5 89.96.38 6 89.96.38 7 89.96.38.39 8 89.96.38.39 9 89.96.38.39.91
+ 10 89.96.38.39.91 11 89.96.38.39.91.6 12 89.96.38.39.91.6
+ 13 89.96.38.39.91.6.97 14 89.96.38.39.91.6.97 15 89.96.38.39.91.6.97.46
+ 16 89.96.38.39.91.6.97.46 17 89.96.38.39.91.6.97.46.54
+ 18 89.96.38.39.91.6.97.46.54 19 89.96.38.39.91.6.97.46.54.8
+ 20 89.96.38.39.91.6.97.46.54.8 21 89.96.38.39.91.6.97.46.54.8.29
+ 22 89.96.38.39.91.6.97.46.54.8.29 23 89.96.38.39.91.6.97.46.54.8.29.84
+ 24 89.96.38.39.91.6.97.46.54.8.29.84
+ 25 89.96.38.39.91.6.97.46.54.8.29.84.23
+ 26 89.96.38.39.91.6.97.46.54.8.29.84.23
+ 27 89.96.38.39.91.6.97.46.54.8.29.84.23.16
+ 28 89.96.38.39.91.6.97.46.54.8.29.84.23.16
+ 29 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65
+ 30 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65
+ 31 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47
+ 32 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47
+ 33 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86
+ 34 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86
+ 35 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61
+ 36 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61
+ 37 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85
+ 38 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85
+ 39 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85
+ 40 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85
+ 41 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59
+ 42 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59
+ 43 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32
+ 44 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32
+ 45 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3
+ 46 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3
+ 47 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22
+ 48 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22
+ 49 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55
+ 50 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55
+ 51 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28
+ 52 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28
+ 53 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25
+ 54 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25
+ 55 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1
+ 56 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1
+ 57 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40
+ 58 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40
+ 59 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56
+ 60 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56
+ 61 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75
+ 62 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75
+ 63 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89
+ 64 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89
+ 65 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76
+ 66 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76
+ 67 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4
+ 68 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4
+ 69 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42
+ 70 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42
+ 71 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78
+ 72 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78
+ 73 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29
+ 74 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29
+ 75 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63
+ 76 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63
+ 77 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87
+ 78 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87
+ 79 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80
+ 80 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80
+ 81 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72
+ 82 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72
+ 83 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9
+ 84 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9
+ 85 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73
+ 86 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73
+ 87 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65
+ 88 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65
+ 89 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58
+ 90 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58
+ 91 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98
+ 92 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98
+ 93 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21
+ 94 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21
+ 95 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65
+ 96 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65
+ 97 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5
+ 98 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5
+ 99 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11
+ 100 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11
+ 101 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87
+ 102 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87
+ 103 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12
+ 104 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12
+ 105 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20
+ 106 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20
+ 107 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31
+ 108 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31
+ 109 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95
+ 110 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95
+ 111 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73
+ 112 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73
+ 113 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88
+ 114 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88
+ 115 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8
+ 116 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8
+ 117 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49
+ 118 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49
+ 119 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90
+ 120 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90
+ 121 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96
+ 122 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96
+ 123 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55
+ 124 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55
+ 125 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77
+ 126 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77
+ 127 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2
+ 128 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2
+ 129 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85
+ 130 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85
+ 131 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74
+ 132 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74
+ 133 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70
+ 134 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70
+ 135 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19
+ 136 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19
+ 137 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26
+ 138 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26
+ 139 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47
+ 140 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47
+ 141 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90
+ 142 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90
+ 143 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58
+ 144 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58
+ 145 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9
+ 146 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9
+ 147 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72
+ 148 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72
+ 149 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33
+ 150 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33
+ 151 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75
+ 152 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75
+ 153 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81
+ 154 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81
+ 155 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23
+ 156 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23
+ 157 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13
+ 158 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13
+ 159 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14
+ 160 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14
+ 161 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91
+ 162 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91
+ 163 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91
+ 164 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91
+ 165 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15
+ 166 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15
+ 167 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36
+ 168 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36
+ 169 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3
+ 170 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3
+ 171 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69
+ 172 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69
+ 173 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52
+ 174 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52
+ 175 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50
+ 176 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50
+ 177 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10
+ 178 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10
+ 179 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33
+ 180 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33
+ 181 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39
+ 182 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39
+ 183 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58
+ 184 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58
+ 185 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38
+ 186 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38
+ 187 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83
+ 188 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83
+ 189 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82
+ 190 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7}
+
+do_execsql_test 1.10.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING)
+} {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 {} 101 {} 102 {} 103 {} 104 {}
+ 105 {} 106 {} 107 {} 108 {} 109 {} 110 {} 111 {} 112 {}
+ 113 {} 114 {} 115 {} 116 {} 117 {} 118 {} 119 {} 120 {}
+ 121 {} 122 {} 123 {} 124 {} 125 {} 126 {} 127 {} 128 {}
+ 129 {} 130 {} 131 {} 132 {} 133 {} 134 {} 135 {} 136 {}
+ 137 {} 138 {} 139 {} 140 {} 141 {} 142 {} 143 {} 144 {}
+ 145 {} 146 {} 147 {} 148 {} 149 {} 150 {} 151 {} 152 {}
+ 153 {} 154 {} 155 {} 156 {} 157 {} 158 {} 159 {} 160 {}
+ 161 {} 162 {} 163 {} 164 {} 165 {} 166 {} 167 {} 168 {}
+ 169 {} 170 {} 171 {} 172 {} 173 {} 174 {} 175 {} 176 {}
+ 177 {} 178 {} 179 {} 180 {} 181 {} 182 {} 183 {} 184 {}
+ 185 {} 186 {} 187 {} 188 {} 189 {} 190 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {}}
+
+do_execsql_test 1.10.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING)
+} {5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {} 14 {}
+ 15 {} 16 {} 17 {} 18 {} 19 {} 20 {} 20 {} 20 {} 20 {}
+ 20 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 5 {} 6 {} 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {}
+ 14 {} 15 {} 16 {} 17 {} 18 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {}}
+
+do_execsql_test 1.10.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING)
+} {5 89.6.29.47.59 6 89.6.29.47.59.28 7 89.6.29.47.59.28.75
+ 8 89.6.29.47.59.28.75.78 9 89.6.29.47.59.28.75.78.72
+ 10 89.6.29.47.59.28.75.78.72.98 11 89.6.29.47.59.28.75.78.72.98.87
+ 12 89.6.29.47.59.28.75.78.72.98.87.73
+ 13 89.6.29.47.59.28.75.78.72.98.87.73.96
+ 14 89.6.29.47.59.28.75.78.72.98.87.73.96.74
+ 15 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90
+ 16 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75
+ 17 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91
+ 18 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69
+ 19 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7 5 {} 6 {}
+ 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {}
+ 17 {} 18 {} 19 {} 19 {} 19 {} 19 {} 19 {} 5 96.97.84.86.32
+ 6 96.97.84.86.32.25 7 96.97.84.86.32.25.89 8 96.97.84.86.32.25.89.29
+ 9 96.97.84.86.32.25.89.29.9 10 96.97.84.86.32.25.89.29.9.21
+ 11 96.97.84.86.32.25.89.29.9.21.12 12 96.97.84.86.32.25.89.29.9.21.12.88
+ 13 96.97.84.86.32.25.89.29.9.21.12.88.55
+ 14 96.97.84.86.32.25.89.29.9.21.12.88.55.70
+ 15 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58
+ 16 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81
+ 17 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91
+ 18 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58 5 {} 6 {}
+ 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {}
+ 17 {} 18 {} 19 {} 19 {} 19 {} 19 {} 19 {} 5 38.46.23.61.3
+ 6 38.46.23.61.3.1 7 38.46.23.61.3.1.76 8 38.46.23.61.3.1.76.63
+ 9 38.46.23.61.3.1.76.63.73 10 38.46.23.61.3.1.76.63.73.65
+ 11 38.46.23.61.3.1.76.63.73.65.20 12 38.46.23.61.3.1.76.63.73.65.20.8
+ 13 38.46.23.61.3.1.76.63.73.65.20.8.77
+ 14 38.46.23.61.3.1.76.63.73.65.20.8.77.19
+ 15 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9
+ 16 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23
+ 17 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15
+ 18 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38 5 {} 6 {}
+ 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {}
+ 17 {} 18 {} 19 {} 19 {} 19 {} 19 {} 19 {} 5 39.54.16.85.22
+ 6 39.54.16.85.22.40 7 39.54.16.85.22.40.4 8 39.54.16.85.22.40.4.87
+ 9 39.54.16.85.22.40.4.87.65 10 39.54.16.85.22.40.4.87.65.5
+ 11 39.54.16.85.22.40.4.87.65.5.31 12 39.54.16.85.22.40.4.87.65.5.31.49
+ 13 39.54.16.85.22.40.4.87.65.5.31.49.2
+ 14 39.54.16.85.22.40.4.87.65.5.31.49.2.26
+ 15 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72
+ 16 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13
+ 17 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36
+ 18 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83 5 {} 6 {}
+ 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {}
+ 17 {} 18 {} 19 {} 19 {} 19 {} 19 {} 19 {} 5 91.8.65.85.55
+ 6 91.8.65.85.55.56 7 91.8.65.85.55.56.42 8 91.8.65.85.55.56.42.80
+ 9 91.8.65.85.55.56.42.80.58 10 91.8.65.85.55.56.42.80.58.11
+ 11 91.8.65.85.55.56.42.80.58.11.95 12 91.8.65.85.55.56.42.80.58.11.95.90
+ 13 91.8.65.85.55.56.42.80.58.11.95.90.85
+ 14 91.8.65.85.55.56.42.80.58.11.95.90.85.47
+ 15 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33
+ 16 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14
+ 17 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3
+ 18 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82 5 {} 6 {}
+ 7 {} 8 {} 9 {} 10 {} 11 {} 12 {} 13 {} 14 {} 15 {} 16 {}
+ 17 {} 18 {} 19 {} 19 {} 19 {} 19 {} 19 {}}
+
+do_execsql_test 1.11.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {96 96 96 96 96 96 96 91 91 99 99 99 99 99 99
+ 99 97 97 97 97 97 97 93 93 93 93 93 93 93 93
+ 93 93 86 91 91 91 91 91 91 91 85 85 85 91 91
+ 91 91 91 91 91 90 90 89 89 89 89 56 56 75 75
+ 89 98 98 98 98 98 98 98 94 94 94 94 78 78 87
+ 87 87 87 87 87 87 84 84 95 95 95 95 96 98 98
+ 98 98 98 98 98 74 74 74 87 87 87 87 87 87 87
+ 41 95 95 95 95 95 95 95 88 88 88 90 90 96 96
+ 96 96 96 96 96 77 85 85 85 85 85 85 85 74 74
+ 70 70 80 90 90 90 90 90 90 90 72 72 93 93 93
+ 93 93 93 93 81 81 81 62 91 91 91 91 91 91 91
+ 99 99 99 99 99 99 99 95 95 84 84 84 84 84 84
+ 84 84 58 58 83 83 83 83 83 83 83}
+
+do_execsql_test 1.11.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {81 59 38 38 38 38 38 38 6 6 6 6 6 6 6 27 8
+ 8 8 8 8 8 8 16 16 16 16 16 16 7 7 7 7 7 7
+ 7 24 24 24 12 12 12 3 3 3 3 3 3 3 15 15 15
+ 1 1 1 1 1 1 1 16 16 16 16 16 4 4 4 4 4 4
+ 4 29 29 2 2 2 2 2 2 2 9 9 9 9 9 9 9 13
+ 13 1 1 1 1 1 1 1 5 5 5 5 5 8 8 8 8 8 8
+ 8 15 15 15 15 8 8 8 8 8 8 8 11 34 34 55 44
+ 2 2 2 2 2 2 2 7 19 19 19 19 19 19 19 26 26
+ 26 9 9 9 9 9 9 9 33 33 9 9 9 9 9 9 9 12
+ 12 12 12 14 15 15 15 3 3 3 3 3 3 3 30 10 10
+ 10 10 10 10 10 21 21 21 30 27 27 17 7 7 7}
+
+do_execsql_test 1.11.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.11.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.11.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.11.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.11.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.11.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.11.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.11.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.11.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.11.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.11.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.11.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.11.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.11.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.11.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.11.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.11.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.11.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.11.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {108 72 52 83 55 79 109 65 26 120 119 50 70 103
+ 80 124 36 96 59 124 116 110 57 51 52 130 103 74
+ 87 48 128 117 105 136 131 71 133 92 109 63 84 109
+ 57 146 78 147 113 74 88 150 87 110 65 121 106 110
+ 124 85 145 107 161 171 150 156 80 171 120 109 158
+ 114 111 136 147 87 173 124 168 173 162 132 101 154
+ 167 190 161 110 156 195 198 102 123 177 169 140 111
+ 180 119 160 197 152 124 121 134 146 147 132 213 141
+ 193 200 210 157 132 136 175 161 218 188 226 191 187
+ 208 211 179 138 144 223 196 214 170 212 202 163 184
+ 172 173 195 229 240 187 210 200 163 227 228 223 191
+ 252 235 225 243 172 187 202 179 179 182 231 261 207
+ 263 206 189 209 212 276 181 274 249 239 234 213 234
+ 269 196 271 221 210 229 235 250 223 232 229 279 224
+ 280 216 207 207 207}
+
+do_execsql_test 1.11.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {109 168 134 218 191 212 229 240 213 234 196 223 223
+ 223 105 136 146 65 156 132 154 102 123 119 160 152
+ 146 147 136 243 261 263 210 210 210 84 78 120 87
+ 162 124 141 138 227 228 179 231 234 280 280 280 130
+ 92 57 110 114 136 147 167 110 180 193 191 252 187
+ 179 206 181 221 279 279 279 117 71 80 171 173 177
+ 157 161 179 214 225 182 209 269 271 235 229 229 229
+ 131 133 113 74 87 145 190 161 169 140 111 132 213
+ 187 208 223 235 189 274 274 274 26 70 51 52 128
+ 109 121 124 85 107 150 195 226 172 173 187 223 207
+ 212 212 212 124 96 110 87 48 110 173 124 197 211
+ 144 196 195 200 202 224 216 207 207 207 103 36 88
+ 171 158 156 198 121 210 132 210 239 250 232 232 232
+ 55 120 59 109 150 161 111 101 200 175 188 170 202
+ 163 184 163 172 276 249 229 229 229}
+
+do_execsql_test 1.11.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {87 138 57 181 80 111 26 48 144 207 36 121 132 101
+ 163 172 196 119 136 63 124 179 110 179 182 74 132
+ 189 51 52 85 216 163 134 123 210 78 141 57 187 71
+ 87 172 173 50 224 88 59 111 170 109 213 223 146
+ 147 84 114 191 206 221 157 161 209 229 74 140 107
+ 187 207 212 124 202 52 232 55 184 229 106 132 152
+ 120 92 110 179 235 65 70 87 110 195 200 175 234
+ 160 234 136 80 113 187 109 121 124 196 156 210 239
+ 250 72 109 188 202 191 105 154 79 231 147 225 103
+ 161 169 223 96 83 249 212 162 227 228 167 180 193
+ 117 177 214 145 208 235 150 110 211 103 158 200 168
+ 229 92 156 243 280 279 116 173 269 271 131 133 223
+ 128 173 197 210 99 150 161 147 218 240 109 136 146
+ 261 263 124 130 252 171 190 213 274 108 195 226 119
+ 124 171 198 120 276 276 276}
+
+do_execsql_test 1.11.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {109 213 223 106 234 191 212 168 229 147 218 240 240
+ 240 119 136 123 210 146 147 132 152 160 105 154 92
+ 156 243 109 136 146 261 263 263 263 63 124 179 78
+ 141 84 120 234 79 231 162 227 228 280 280 280 110
+ 179 57 187 114 191 206 221 92 110 136 147 167 180
+ 193 279 124 130 252 252 252 71 157 161 209 229 179
+ 235 80 225 117 177 214 116 173 269 271 171 171 171
+ 132 189 87 74 140 113 187 103 161 169 145 208 235
+ 131 133 223 190 213 274 274 274 52 85 172 173 107
+ 187 207 212 65 70 109 121 124 223 150 128 108 195
+ 226 226 226 207 216 50 224 124 202 87 110 195 200
+ 196 96 110 211 173 197 119 124 124 124 132 88 52
+ 232 156 210 239 250 83 103 158 210 171 198 198 198
+ 172 163 59 111 170 55 184 229 175 72 109 188 202
+ 249 200 99 150 161 120 276 276 276}
+
+do_execsql_test 1.11.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {109 168 134 218 191 212 229 240 213 234 196 223 92
+ 109 105 136 146 65 156 132 154 102 123 119 160 152
+ 146 147 136 243 261 263 210 79 63 84 78 120 87
+ 162 124 141 138 227 228 179 231 234 280 124 57 130
+ 92 57 110 114 136 147 167 110 180 193 191 252 187
+ 179 206 181 221 279 80 116 117 71 80 171 173 177
+ 157 161 179 214 225 182 209 269 271 235 229 103 74
+ 131 133 113 74 87 145 190 161 169 140 111 132 213
+ 187 208 223 235 189 274 108 65 26 70 51 52 128
+ 109 121 124 85 107 150 195 226 172 173 187 223 207
+ 212 119 50 124 96 110 87 48 110 173 124 197 211
+ 144 196 195 200 202 224 216 207 52 83 103 36 88
+ 171 158 156 198 121 210 132 210 239 250 232 99 72
+ 55 120 59 109 150 161 111 101 200 175 188 170 202
+ 163 184 163 172 276 249 229 229 229}
+
+do_execsql_test 1.11.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.11.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 97 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} 56
+ {} {} {} {} {} {} {} {} {} 89 {} {} {} {} {}
+ {} {} {} {} {} {} 4 {} {} {} {} {} {} {} {}
+ 53 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 58 {} {} {} {} 73 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 77 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 99 {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} {} {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 33 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 15 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 1 2 2 2 3 4 6 7 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} 1 1
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 12 12 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} {} {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 33 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 15 {}
+ {} {} {} {} {} {} {} {} {} 16 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {89 89 89 89 89 81 96 59 38 68 39 62 91 46 6
+ 99 97 27 46 78 54 97 8 67 29 93 84 77 23 16
+ 16 93 65 35 47 7 86 74 61 91 85 24 85 43 59
+ 12 32 56 3 91 22 90 55 15 28 89 25 47 1 56 40
+ 43 56 16 75 36 89 98 76 81 4 94 42 30 78 33
+ 29 53 63 2 87 37 80 84 72 41 9 61 73 95 65 13
+ 58 96 98 1 21 74 65 35 5 73 11 51 87 41 12 8
+ 20 31 31 15 95 22 73 79 88 34 8 11 49 34 90
+ 59 96 60 55 75 77 44 2 7 85 57 74 29 70 59 19
+ 39 26 26 47 80 90 36 58 47 9 72 72 66 33 93
+ 75 64 81 9 23 37 13 12 14 62 91 36 91 33 15
+ 34 36 99 3 95 69 58 52 30 50 84 10 84 33 21
+ 39 44 58 30 38 34 83}
+
+do_execsql_test 1.11.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {90 90 90 90 90 40 30 80 20 90 60 70 80 90 81
+ 81 81 81 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 62 62 62 62 62 12 32 22 42 2 72
+ 12 22 2 72 72 93 93 93 93 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 54 54 54 54 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 65
+ 65 65 65 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 96 96 96 96 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 97 97 97 97 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 38
+ 38 38 38 38 68 78 8 28 98 78 58 98 8 88 8 89
+ 89 89 89 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.11.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 2 2 3 3 4 5 6 7 7 7 8 8 8
+ 9 9 9 10 11 11 12 12 12 13 13 14 15 15 15 16
+ 16 16 17 19 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 30 30 30 31 31 32 33 33 33
+ 33 34 34 34 34 35 35 36 36 36 36 37 37 38 38
+ 39 39 39 40 41 41 42 43 43 44 44 46 46 47 47
+ 47 47 49 50 51 52 53 54 55 55 56 56 56 57 58
+ 58 58 58 59 59 59 59 60 61 61 62 62 63 64 65
+ 65 65 66 67 68 69 70 72 72 72 73 73 73 74 74
+ 74 75 75 75 76 77 77 78 78 79 80 80 81 81 81
+ 82 83 84 84 84 84 85 85 85 86 87 87 88 89 89
+ 89 90 90 90 91 91 91 91 91 93 93 93 94 95 95
+ 95 96 96 96 97 97}
+
+do_execsql_test 1.11.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {10 10 10 10 10 20 30 30 30 40 50 60 70 80 1 1
+ 1 1 1 1 11 11 21 21 31 31 41 41 51 61 61 81
+ 81 81 91 2 2 2 2 2 2 12 12 12 22 22 32 42
+ 52 62 62 3 3 3 3 3 3 13 13 23 23 33 33 33
+ 33 43 43 53 63 73 73 73 4 4 4 4 4 14 24 34
+ 34 34 34 44 44 54 64 74 74 74 84 5 5 5 5 5
+ 15 15 15 25 35 35 55 55 65 65 65 75 75 75 85
+ 85 6 6 6 6 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 7 7 7 7 7 7 7 17 27 27 37
+ 37 47 47 47 47 57 67 77 77 8 8 8 8 8 8 8 28
+ 38 38 58 58 58 58 68 78 9 9 9 9 9 9 9 19 29
+ 29 29 39 39 39 49 59 59 59 59 69 79 89}
+
+do_execsql_test 1.11.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {90 90 90 90 90 40 30 80 20 90 60 70 80 90 30
+ 50 10 30 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 81 91 91 21 62 12 32 22 42 2 72
+ 12 22 2 72 72 12 62 52 82 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 33 3 33 83 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 84
+ 84 44 34 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 85 75 15 95 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 36 66 36 36 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 37
+ 27 17 7 38 68 78 8 28 98 78 58 98 8 88 8 58
+ 58 58 38 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.11.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.11.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.11.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.11.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.11.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.11.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.11.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.11.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {89.81.96 89.81.96.59 89.81.96.59.38 89.81.96.59.38.68
+ 89.81.96.59.38.68.39 81.96.59.38.68.39.62 96.59.38.68.39.62.91
+ 59.38.68.39.62.91.46 38.68.39.62.91.46.6 68.39.62.91.46.6.99
+ 39.62.91.46.6.99.97 62.91.46.6.99.97.27 91.46.6.99.97.27.46
+ 46.6.99.97.27.46.78 6.99.97.27.46.78.54 99.97.27.46.78.54.97
+ 97.27.46.78.54.97.8 27.46.78.54.97.8.67 46.78.54.97.8.67.29
+ 78.54.97.8.67.29.93 54.97.8.67.29.93.84 97.8.67.29.93.84.77
+ 8.67.29.93.84.77.23 67.29.93.84.77.23.16 29.93.84.77.23.16.16
+ 93.84.77.23.16.16.93 84.77.23.16.16.93.65 77.23.16.16.93.65.35
+ 23.16.16.93.65.35.47 16.16.93.65.35.47.7 16.93.65.35.47.7.86
+ 93.65.35.47.7.86.74 65.35.47.7.86.74.61 35.47.7.86.74.61.91
+ 47.7.86.74.61.91.85 7.86.74.61.91.85.24 86.74.61.91.85.24.85
+ 74.61.91.85.24.85.43 61.91.85.24.85.43.59 91.85.24.85.43.59.12
+ 85.24.85.43.59.12.32 24.85.43.59.12.32.56 85.43.59.12.32.56.3
+ 43.59.12.32.56.3.91 59.12.32.56.3.91.22 12.32.56.3.91.22.90
+ 32.56.3.91.22.90.55 56.3.91.22.90.55.15 3.91.22.90.55.15.28
+ 91.22.90.55.15.28.89 22.90.55.15.28.89.25 90.55.15.28.89.25.47
+ 55.15.28.89.25.47.1 15.28.89.25.47.1.56 28.89.25.47.1.56.40
+ 89.25.47.1.56.40.43 25.47.1.56.40.43.56 47.1.56.40.43.56.16
+ 1.56.40.43.56.16.75 56.40.43.56.16.75.36 40.43.56.16.75.36.89
+ 43.56.16.75.36.89.98 56.16.75.36.89.98.76 16.75.36.89.98.76.81
+ 75.36.89.98.76.81.4 36.89.98.76.81.4.94 89.98.76.81.4.94.42
+ 98.76.81.4.94.42.30 76.81.4.94.42.30.78 81.4.94.42.30.78.33
+ 4.94.42.30.78.33.29 94.42.30.78.33.29.53 42.30.78.33.29.53.63
+ 30.78.33.29.53.63.2 78.33.29.53.63.2.87 33.29.53.63.2.87.37
+ 29.53.63.2.87.37.80 53.63.2.87.37.80.84 63.2.87.37.80.84.72
+ 2.87.37.80.84.72.41 87.37.80.84.72.41.9 37.80.84.72.41.9.61
+ 80.84.72.41.9.61.73 84.72.41.9.61.73.95 72.41.9.61.73.95.65
+ 41.9.61.73.95.65.13 9.61.73.95.65.13.58 61.73.95.65.13.58.96
+ 73.95.65.13.58.96.98 95.65.13.58.96.98.1 65.13.58.96.98.1.21
+ 13.58.96.98.1.21.74 58.96.98.1.21.74.65 96.98.1.21.74.65.35
+ 98.1.21.74.65.35.5 1.21.74.65.35.5.73 21.74.65.35.5.73.11
+ 74.65.35.5.73.11.51 65.35.5.73.11.51.87 35.5.73.11.51.87.41
+ 5.73.11.51.87.41.12 73.11.51.87.41.12.8 11.51.87.41.12.8.20
+ 51.87.41.12.8.20.31 87.41.12.8.20.31.31 41.12.8.20.31.31.15
+ 12.8.20.31.31.15.95 8.20.31.31.15.95.22 20.31.31.15.95.22.73
+ 31.31.15.95.22.73.79 31.15.95.22.73.79.88 15.95.22.73.79.88.34
+ 95.22.73.79.88.34.8 22.73.79.88.34.8.11 73.79.88.34.8.11.49
+ 79.88.34.8.11.49.34 88.34.8.11.49.34.90 34.8.11.49.34.90.59
+ 8.11.49.34.90.59.96 11.49.34.90.59.96.60 49.34.90.59.96.60.55
+ 34.90.59.96.60.55.75 90.59.96.60.55.75.77 59.96.60.55.75.77.44
+ 96.60.55.75.77.44.2 60.55.75.77.44.2.7 55.75.77.44.2.7.85
+ 75.77.44.2.7.85.57 77.44.2.7.85.57.74 44.2.7.85.57.74.29
+ 2.7.85.57.74.29.70 7.85.57.74.29.70.59 85.57.74.29.70.59.19
+ 57.74.29.70.59.19.39 74.29.70.59.19.39.26 29.70.59.19.39.26.26
+ 70.59.19.39.26.26.47 59.19.39.26.26.47.80 19.39.26.26.47.80.90
+ 39.26.26.47.80.90.36 26.26.47.80.90.36.58 26.47.80.90.36.58.47
+ 47.80.90.36.58.47.9 80.90.36.58.47.9.72 90.36.58.47.9.72.72
+ 36.58.47.9.72.72.66 58.47.9.72.72.66.33 47.9.72.72.66.33.93
+ 9.72.72.66.33.93.75 72.72.66.33.93.75.64 72.66.33.93.75.64.81
+ 66.33.93.75.64.81.9 33.93.75.64.81.9.23 93.75.64.81.9.23.37
+ 75.64.81.9.23.37.13 64.81.9.23.37.13.12 81.9.23.37.13.12.14
+ 9.23.37.13.12.14.62 23.37.13.12.14.62.91 37.13.12.14.62.91.36
+ 13.12.14.62.91.36.91 12.14.62.91.36.91.33 14.62.91.36.91.33.15
+ 62.91.36.91.33.15.34 91.36.91.33.15.34.36 36.91.33.15.34.36.99
+ 91.33.15.34.36.99.3 33.15.34.36.99.3.95 15.34.36.99.3.95.69
+ 34.36.99.3.95.69.58 36.99.3.95.69.58.52 99.3.95.69.58.52.30
+ 3.95.69.58.52.30.50 95.69.58.52.30.50.84 69.58.52.30.50.84.10
+ 58.52.30.50.84.10.84 52.30.50.84.10.84.33 30.50.84.10.84.33.21
+ 50.84.10.84.33.21.39 84.10.84.33.21.39.44 10.84.33.21.39.44.58
+ 84.33.21.39.44.58.30 33.21.39.44.58.30.38 21.39.44.58.30.38.34
+ 39.44.58.30.38.34.83 44.58.30.38.34.83.27 58.30.38.34.83.27.82
+ 30.38.34.83.27.82.17 38.34.83.27.82.17.7 34.83.27.82.17.7
+ 83.27.82.17.7}
+
+do_execsql_test 1.11.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {90.40.30 90.40.30.80 90.40.30.80.20 90.40.30.80.20.90
+ 90.40.30.80.20.90.60 40.30.80.20.90.60.70 30.80.20.90.60.70.80
+ 80.20.90.60.70.80.90 20.90.60.70.80.90.30 90.60.70.80.90.30.50
+ 60.70.80.90.30.50.10 70.80.90.30.50.10.30 80.90.30.50.10.30
+ 90.30.50.10.30 81.91.61 81.91.61.91 81.91.61.91.91 81.91.61.91.91.1
+ 81.91.61.91.91.1.81 91.61.91.91.1.81.41 61.91.91.1.81.41.61
+ 91.91.1.81.41.61.1 91.1.81.41.61.1.21 1.81.41.61.1.21.11
+ 81.41.61.1.21.11.51 41.61.1.21.11.51.41 61.1.21.11.51.41.31
+ 1.21.11.51.41.31.31 21.11.51.41.31.31.11 11.51.41.31.31.11.81
+ 51.41.31.31.11.81.91 41.31.31.11.81.91.91 31.31.11.81.91.91.21
+ 31.11.81.91.91.21 11.81.91.91.21 62.12.32 62.12.32.22
+ 62.12.32.22.42 62.12.32.22.42.2 62.12.32.22.42.2.72
+ 12.32.22.42.2.72.12 32.22.42.2.72.12.22 22.42.2.72.12.22.2
+ 42.2.72.12.22.2.72 2.72.12.22.2.72.72 72.12.22.2.72.72.12
+ 12.22.2.72.72.12.62 22.2.72.72.12.62.52 2.72.72.12.62.52.82
+ 72.72.12.62.52.82 72.12.62.52.82 93.23.93 93.23.93.43 93.23.93.43.3
+ 93.23.93.43.3.43 93.23.93.43.3.43.33 23.93.43.3.43.33.53
+ 93.43.3.43.33.53.63 43.3.43.33.53.63.73 3.43.33.53.63.73.13
+ 43.33.53.63.73.13.73 33.53.63.73.13.73.73 53.63.73.13.73.73.33
+ 63.73.13.73.73.33.93 73.13.73.73.33.93.23 13.73.73.33.93.23.13
+ 73.73.33.93.23.13.33 73.33.93.23.13.33.3 33.93.23.13.33.3.33
+ 93.23.13.33.3.33.83 23.13.33.3.33.83 13.33.3.33.83 54.84.74
+ 54.84.74.24 54.84.74.24.4 54.84.74.24.4.94 54.84.74.24.4.94.84
+ 84.74.24.4.94.84.74 74.24.4.94.84.74.34 24.4.94.84.74.34.34
+ 4.94.84.74.34.34.44 94.84.74.34.34.44.74 84.74.34.34.44.74.64
+ 74.34.34.44.74.64.14 34.34.44.74.64.14.34 34.44.74.64.14.34.84
+ 44.74.64.14.34.84.84 74.64.14.34.84.84.44 64.14.34.84.84.44.34
+ 14.34.84.84.44.34 34.84.84.44.34 65.35.85 65.35.85.85
+ 65.35.85.85.55 65.35.85.85.55.15 65.35.85.85.55.15.25
+ 35.85.85.55.15.25.75 85.85.55.15.25.75.95 85.55.15.25.75.95.65
+ 55.15.25.75.95.65.65 15.25.75.95.65.65.35 25.75.95.65.65.35.5
+ 75.95.65.65.35.5.15 95.65.65.35.5.15.95 65.65.35.5.15.95.55
+ 65.35.5.15.95.55.75 35.5.15.95.55.75.85 5.15.95.55.75.85.75
+ 15.95.55.75.85.75.15 95.55.75.85.75.15.95 55.75.85.75.15.95
+ 75.85.75.15.95 96.46.6 96.46.6.46 96.46.6.46.16 96.46.6.46.16.16
+ 96.46.6.46.16.16.86 46.6.46.16.16.86.56 6.46.16.16.86.56.56
+ 46.16.16.86.56.56.56 16.16.86.56.56.56.16 16.86.56.56.56.16.36
+ 86.56.56.56.16.36.76 56.56.56.16.36.76.96 56.56.16.36.76.96.96
+ 56.16.36.76.96.96.26 16.36.76.96.96.26.26 36.76.96.96.26.26.36
+ 76.96.96.26.26.36.66 96.96.26.26.36.66.36 96.26.26.36.66.36.36
+ 26.26.36.66.36.36 26.36.66.36.36 97.27.97 97.27.97.67
+ 97.27.97.67.77 97.27.97.67.77.47 97.27.97.67.77.47.7
+ 27.97.67.77.47.7.47 97.67.77.47.7.47.87 67.77.47.7.47.87.37
+ 77.47.7.47.87.37.87 47.7.47.87.37.87.77 7.47.87.37.87.77.7
+ 47.87.37.87.77.7.57 87.37.87.77.7.57.47 37.87.77.7.57.47.47
+ 87.77.7.57.47.47.37 77.7.57.47.47.37.27 7.57.47.47.37.27.17
+ 57.47.47.37.27.17.7 47.47.37.27.17.7 47.37.27.17.7 38.68.78
+ 38.68.78.8 38.68.78.8.28 38.68.78.8.28.98 38.68.78.8.28.98.78
+ 68.78.8.28.98.78.58 78.8.28.98.78.58.98 8.28.98.78.58.98.8
+ 28.98.78.58.98.8.88 98.78.58.98.8.88.8 78.58.98.8.88.8.58
+ 58.98.8.88.8.58.58 98.8.88.8.58.58.58 8.88.8.58.58.58.38
+ 88.8.58.58.58.38 8.58.58.58.38 89.59.39 89.59.39.99 89.59.39.99.29
+ 89.59.39.99.29.59 89.59.39.99.29.59.89 59.39.99.29.59.89.89
+ 39.99.29.59.89.89.29 99.29.59.89.89.29.9 29.59.89.89.29.9.79
+ 59.89.89.29.9.79.49 89.89.29.9.79.49.59 89.29.9.79.49.59.29
+ 29.9.79.49.59.29.59 9.79.49.59.29.59.19 79.49.59.29.59.19.39
+ 49.59.29.59.19.39.9 59.29.59.19.39.9.9 29.59.19.39.9.9.99
+ 59.19.39.9.9.99.69 19.39.9.9.99.69.39 39.9.9.99.69.39 9.9.99.69.39}
+
+do_execsql_test 1.11.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {1.1.2 1.1.2.2 1.1.2.2.3 1.1.2.2.3.3 1.1.2.2.3.3.4 1.2.2.3.3.4.5
+ 2.2.3.3.4.5.6 2.3.3.4.5.6.7 3.3.4.5.6.7.7 3.4.5.6.7.7.7
+ 4.5.6.7.7.7.8 5.6.7.7.7.8.8 6.7.7.7.8.8.8 7.7.7.8.8.8.9
+ 7.7.8.8.8.9.9 7.8.8.8.9.9.9 8.8.8.9.9.9.10 8.8.9.9.9.10.11
+ 8.9.9.9.10.11.11 9.9.9.10.11.11.12 9.9.10.11.11.12.12
+ 9.10.11.11.12.12.12 10.11.11.12.12.12.13 11.11.12.12.12.13.13
+ 11.12.12.12.13.13.14 12.12.12.13.13.14.15 12.12.13.13.14.15.15
+ 12.13.13.14.15.15.15 13.13.14.15.15.15.16 13.14.15.15.15.16.16
+ 14.15.15.15.16.16.16 15.15.15.16.16.16.17 15.15.16.16.16.17.19
+ 15.16.16.16.17.19.20 16.16.16.17.19.20.21 16.16.17.19.20.21.21
+ 16.17.19.20.21.21.22 17.19.20.21.21.22.22 19.20.21.21.22.22.23
+ 20.21.21.22.22.23.23 21.21.22.22.23.23.24 21.22.22.23.23.24.25
+ 22.22.23.23.24.25.26 22.23.23.24.25.26.26 23.23.24.25.26.26.27
+ 23.24.25.26.26.27.27 24.25.26.26.27.27.28 25.26.26.27.27.28.29
+ 26.26.27.27.28.29.29 26.27.27.28.29.29.29 27.27.28.29.29.29.30
+ 27.28.29.29.29.30.30 28.29.29.29.30.30.30 29.29.29.30.30.30.31
+ 29.29.30.30.30.31.31 29.30.30.30.31.31.32 30.30.30.31.31.32.33
+ 30.30.31.31.32.33.33 30.31.31.32.33.33.33 31.31.32.33.33.33.33
+ 31.32.33.33.33.33.34 32.33.33.33.33.34.34 33.33.33.33.34.34.34
+ 33.33.33.34.34.34.34 33.33.34.34.34.34.35 33.34.34.34.34.35.35
+ 34.34.34.34.35.35.36 34.34.34.35.35.36.36 34.34.35.35.36.36.36
+ 34.35.35.36.36.36.36 35.35.36.36.36.36.37 35.36.36.36.36.37.37
+ 36.36.36.36.37.37.38 36.36.36.37.37.38.38 36.36.37.37.38.38.39
+ 36.37.37.38.38.39.39 37.37.38.38.39.39.39 37.38.38.39.39.39.40
+ 38.38.39.39.39.40.41 38.39.39.39.40.41.41 39.39.39.40.41.41.42
+ 39.39.40.41.41.42.43 39.40.41.41.42.43.43 40.41.41.42.43.43.44
+ 41.41.42.43.43.44.44 41.42.43.43.44.44.46 42.43.43.44.44.46.46
+ 43.43.44.44.46.46.47 43.44.44.46.46.47.47 44.44.46.46.47.47.47
+ 44.46.46.47.47.47.47 46.46.47.47.47.47.49 46.47.47.47.47.49.50
+ 47.47.47.47.49.50.51 47.47.47.49.50.51.52 47.47.49.50.51.52.53
+ 47.49.50.51.52.53.54 49.50.51.52.53.54.55 50.51.52.53.54.55.55
+ 51.52.53.54.55.55.56 52.53.54.55.55.56.56 53.54.55.55.56.56.56
+ 54.55.55.56.56.56.57 55.55.56.56.56.57.58 55.56.56.56.57.58.58
+ 56.56.56.57.58.58.58 56.56.57.58.58.58.58 56.57.58.58.58.58.59
+ 57.58.58.58.58.59.59 58.58.58.58.59.59.59 58.58.58.59.59.59.59
+ 58.58.59.59.59.59.60 58.59.59.59.59.60.61 59.59.59.59.60.61.61
+ 59.59.59.60.61.61.62 59.59.60.61.61.62.62 59.60.61.61.62.62.63
+ 60.61.61.62.62.63.64 61.61.62.62.63.64.65 61.62.62.63.64.65.65
+ 62.62.63.64.65.65.65 62.63.64.65.65.65.66 63.64.65.65.65.66.67
+ 64.65.65.65.66.67.68 65.65.65.66.67.68.69 65.65.66.67.68.69.70
+ 65.66.67.68.69.70.72 66.67.68.69.70.72.72 67.68.69.70.72.72.72
+ 68.69.70.72.72.72.73 69.70.72.72.72.73.73 70.72.72.72.73.73.73
+ 72.72.72.73.73.73.74 72.72.73.73.73.74.74 72.73.73.73.74.74.74
+ 73.73.73.74.74.74.75 73.73.74.74.74.75.75 73.74.74.74.75.75.75
+ 74.74.74.75.75.75.76 74.74.75.75.75.76.77 74.75.75.75.76.77.77
+ 75.75.75.76.77.77.78 75.75.76.77.77.78.78 75.76.77.77.78.78.79
+ 76.77.77.78.78.79.80 77.77.78.78.79.80.80 77.78.78.79.80.80.81
+ 78.78.79.80.80.81.81 78.79.80.80.81.81.81 79.80.80.81.81.81.82
+ 80.80.81.81.81.82.83 80.81.81.81.82.83.84 81.81.81.82.83.84.84
+ 81.81.82.83.84.84.84 81.82.83.84.84.84.84 82.83.84.84.84.84.85
+ 83.84.84.84.84.85.85 84.84.84.84.85.85.85 84.84.84.85.85.85.86
+ 84.84.85.85.85.86.87 84.85.85.85.86.87.87 85.85.85.86.87.87.88
+ 85.85.86.87.87.88.89 85.86.87.87.88.89.89 86.87.87.88.89.89.89
+ 87.87.88.89.89.89.90 87.88.89.89.89.90.90 88.89.89.89.90.90.90
+ 89.89.89.90.90.90.91 89.89.90.90.90.91.91 89.90.90.90.91.91.91
+ 90.90.90.91.91.91.91 90.90.91.91.91.91.91 90.91.91.91.91.91.93
+ 91.91.91.91.91.93.93 91.91.91.91.93.93.93 91.91.91.93.93.93.94
+ 91.91.93.93.93.94.95 91.93.93.93.94.95.95 93.93.93.94.95.95.95
+ 93.93.94.95.95.95.96 93.94.95.95.95.96.96 94.95.95.95.96.96.96
+ 95.95.95.96.96.96.97 95.95.96.96.96.97.97 95.96.96.96.97.97.98
+ 96.96.96.97.97.98.98 96.96.97.97.98.98.99 96.97.97.98.98.99.99
+ 97.97.98.98.99.99 97.98.98.99.99}
+
+do_execsql_test 1.11.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {10.20.30 10.20.30.30 10.20.30.30.30 10.20.30.30.30.40
+ 10.20.30.30.30.40.50 20.30.30.30.40.50.60 30.30.30.40.50.60.70
+ 30.30.40.50.60.70.80 30.40.50.60.70.80.80 40.50.60.70.80.80.90
+ 50.60.70.80.80.90.90 60.70.80.80.90.90.90 70.80.80.90.90.90
+ 80.80.90.90.90 1.1.11 1.1.11.11 1.1.11.11.21 1.1.11.11.21.21
+ 1.1.11.11.21.21.31 1.11.11.21.21.31.31 11.11.21.21.31.31.41
+ 11.21.21.31.31.41.41 21.21.31.31.41.41.51 21.31.31.41.41.51.61
+ 31.31.41.41.51.61.61 31.41.41.51.61.61.81 41.41.51.61.61.81.81
+ 41.51.61.61.81.81.81 51.61.61.81.81.81.91 61.61.81.81.81.91.91
+ 61.81.81.81.91.91.91 81.81.81.91.91.91.91 81.81.91.91.91.91.91
+ 81.91.91.91.91.91 91.91.91.91.91 2.2.12 2.2.12.12 2.2.12.12.12
+ 2.2.12.12.12.22 2.2.12.12.12.22.22 2.12.12.12.22.22.32
+ 12.12.12.22.22.32.42 12.12.22.22.32.42.52 12.22.22.32.42.52.62
+ 22.22.32.42.52.62.62 22.32.42.52.62.62.72 32.42.52.62.62.72.72
+ 42.52.62.62.72.72.72 52.62.62.72.72.72.82 62.62.72.72.72.82
+ 62.72.72.72.82 3.3.13 3.3.13.13 3.3.13.13.23 3.3.13.13.23.23
+ 3.3.13.13.23.23.33 3.13.13.23.23.33.33 13.13.23.23.33.33.33
+ 13.23.23.33.33.33.33 23.23.33.33.33.33.43 23.33.33.33.33.43.43
+ 33.33.33.33.43.43.53 33.33.33.43.43.53.63 33.33.43.43.53.63.73
+ 33.43.43.53.63.73.73 43.43.53.63.73.73.73 43.53.63.73.73.73.83
+ 53.63.73.73.73.83.93 63.73.73.73.83.93.93 73.73.73.83.93.93.93
+ 73.73.83.93.93.93 73.83.93.93.93 4.14.24 4.14.24.34 4.14.24.34.34
+ 4.14.24.34.34.34 4.14.24.34.34.34.34 14.24.34.34.34.34.44
+ 24.34.34.34.34.44.44 34.34.34.34.44.44.54 34.34.34.44.44.54.64
+ 34.34.44.44.54.64.74 34.44.44.54.64.74.74 44.44.54.64.74.74.74
+ 44.54.64.74.74.74.84 54.64.74.74.74.84.84 64.74.74.74.84.84.84
+ 74.74.74.84.84.84.84 74.74.84.84.84.84.94 74.84.84.84.84.94
+ 84.84.84.84.94 5.15.15 5.15.15.15 5.15.15.15.25 5.15.15.15.25.35
+ 5.15.15.15.25.35.35 15.15.15.25.35.35.55 15.15.25.35.35.55.55
+ 15.25.35.35.55.55.65 25.35.35.55.55.65.65 35.35.55.55.65.65.65
+ 35.55.55.65.65.65.75 55.55.65.65.65.75.75 55.65.65.65.75.75.75
+ 65.65.65.75.75.75.85 65.65.75.75.75.85.85 65.75.75.75.85.85.85
+ 75.75.75.85.85.85.95 75.75.85.85.85.95.95 75.85.85.85.95.95.95
+ 85.85.85.95.95.95 85.85.95.95.95 6.16.16 6.16.16.16 6.16.16.16.26
+ 6.16.16.16.26.26 6.16.16.16.26.26.36 16.16.16.26.26.36.36
+ 16.16.26.26.36.36.36 16.26.26.36.36.36.36 26.26.36.36.36.36.46
+ 26.36.36.36.36.46.46 36.36.36.36.46.46.56 36.36.36.46.46.56.56
+ 36.36.46.46.56.56.56 36.46.46.56.56.56.66 46.46.56.56.56.66.76
+ 46.56.56.56.66.76.86 56.56.56.66.76.86.96 56.56.66.76.86.96.96
+ 56.66.76.86.96.96.96 66.76.86.96.96.96 76.86.96.96.96 7.7.7
+ 7.7.7.17 7.7.7.17.27 7.7.7.17.27.27 7.7.7.17.27.27.37
+ 7.7.17.27.27.37.37 7.17.27.27.37.37.47 17.27.27.37.37.47.47
+ 27.27.37.37.47.47.47 27.37.37.47.47.47.47 37.37.47.47.47.47.57
+ 37.47.47.47.47.57.67 47.47.47.47.57.67.77 47.47.47.57.67.77.77
+ 47.47.57.67.77.77.87 47.57.67.77.77.87.87 57.67.77.77.87.87.97
+ 67.77.77.87.87.97.97 77.77.87.87.97.97 77.87.87.97.97 8.8.8
+ 8.8.8.28 8.8.8.28.38 8.8.8.28.38.38 8.8.8.28.38.38.58
+ 8.8.28.38.38.58.58 8.28.38.38.58.58.58 28.38.38.58.58.58.58
+ 38.38.58.58.58.58.68 38.58.58.58.58.68.78 58.58.58.58.68.78.78
+ 58.58.58.68.78.78.88 58.58.68.78.78.88.98 58.68.78.78.88.98.98
+ 68.78.78.88.98.98 78.78.88.98.98 9.9.9 9.9.9.19 9.9.9.19.29
+ 9.9.9.19.29.29 9.9.9.19.29.29.29 9.9.19.29.29.29.39
+ 9.19.29.29.29.39.39 19.29.29.29.39.39.39 29.29.29.39.39.39.49
+ 29.29.39.39.39.49.59 29.39.39.39.49.59.59 39.39.39.49.59.59.59
+ 39.39.49.59.59.59.59 39.49.59.59.59.59.69 49.59.59.59.59.69.79
+ 59.59.59.59.69.79.89 59.59.59.69.79.89.89 59.59.69.79.89.89.89
+ 59.69.79.89.89.89.99 69.79.89.89.89.99.99 79.89.89.89.99.99
+ 89.89.89.99.99}
+
+do_execsql_test 1.11.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING ) FROM t2
+} {90.40.30 90.40.30.80 90.40.30.80.20 90.40.30.80.20.90
+ 90.40.30.80.20.90.60 40.30.80.20.90.60.70 30.80.20.90.60.70.80
+ 80.20.90.60.70.80.90 20.90.60.70.80.90.30 90.60.70.80.90.30.50
+ 60.70.80.90.30.50.10 70.80.90.30.50.10.30 80.90.30.50.10.30.81
+ 90.30.50.10.30.81.91 30.50.10.30.81.91.61 50.10.30.81.91.61.91
+ 10.30.81.91.61.91.91 30.81.91.61.91.91.1 81.91.61.91.91.1.81
+ 91.61.91.91.1.81.41 61.91.91.1.81.41.61 91.91.1.81.41.61.1
+ 91.1.81.41.61.1.21 1.81.41.61.1.21.11 81.41.61.1.21.11.51
+ 41.61.1.21.11.51.41 61.1.21.11.51.41.31 1.21.11.51.41.31.31
+ 21.11.51.41.31.31.11 11.51.41.31.31.11.81 51.41.31.31.11.81.91
+ 41.31.31.11.81.91.91 31.31.11.81.91.91.21 31.11.81.91.91.21.62
+ 11.81.91.91.21.62.12 81.91.91.21.62.12.32 91.91.21.62.12.32.22
+ 91.21.62.12.32.22.42 21.62.12.32.22.42.2 62.12.32.22.42.2.72
+ 12.32.22.42.2.72.12 32.22.42.2.72.12.22 22.42.2.72.12.22.2
+ 42.2.72.12.22.2.72 2.72.12.22.2.72.72 72.12.22.2.72.72.12
+ 12.22.2.72.72.12.62 22.2.72.72.12.62.52 2.72.72.12.62.52.82
+ 72.72.12.62.52.82.93 72.12.62.52.82.93.23 12.62.52.82.93.23.93
+ 62.52.82.93.23.93.43 52.82.93.23.93.43.3 82.93.23.93.43.3.43
+ 93.23.93.43.3.43.33 23.93.43.3.43.33.53 93.43.3.43.33.53.63
+ 43.3.43.33.53.63.73 3.43.33.53.63.73.13 43.33.53.63.73.13.73
+ 33.53.63.73.13.73.73 53.63.73.13.73.73.33 63.73.13.73.73.33.93
+ 73.13.73.73.33.93.23 13.73.73.33.93.23.13 73.73.33.93.23.13.33
+ 73.33.93.23.13.33.3 33.93.23.13.33.3.33 93.23.13.33.3.33.83
+ 23.13.33.3.33.83.54 13.33.3.33.83.54.84 33.3.33.83.54.84.74
+ 3.33.83.54.84.74.24 33.83.54.84.74.24.4 83.54.84.74.24.4.94
+ 54.84.74.24.4.94.84 84.74.24.4.94.84.74 74.24.4.94.84.74.34
+ 24.4.94.84.74.34.34 4.94.84.74.34.34.44 94.84.74.34.34.44.74
+ 84.74.34.34.44.74.64 74.34.34.44.74.64.14 34.34.44.74.64.14.34
+ 34.44.74.64.14.34.84 44.74.64.14.34.84.84 74.64.14.34.84.84.44
+ 64.14.34.84.84.44.34 14.34.84.84.44.34.65 34.84.84.44.34.65.35
+ 84.84.44.34.65.35.85 84.44.34.65.35.85.85 44.34.65.35.85.85.55
+ 34.65.35.85.85.55.15 65.35.85.85.55.15.25 35.85.85.55.15.25.75
+ 85.85.55.15.25.75.95 85.55.15.25.75.95.65 55.15.25.75.95.65.65
+ 15.25.75.95.65.65.35 25.75.95.65.65.35.5 75.95.65.65.35.5.15
+ 95.65.65.35.5.15.95 65.65.35.5.15.95.55 65.35.5.15.95.55.75
+ 35.5.15.95.55.75.85 5.15.95.55.75.85.75 15.95.55.75.85.75.15
+ 95.55.75.85.75.15.95 55.75.85.75.15.95.96 75.85.75.15.95.96.46
+ 85.75.15.95.96.46.6 75.15.95.96.46.6.46 15.95.96.46.6.46.16
+ 95.96.46.6.46.16.16 96.46.6.46.16.16.86 46.6.46.16.16.86.56
+ 6.46.16.16.86.56.56 46.16.16.86.56.56.56 16.16.86.56.56.56.16
+ 16.86.56.56.56.16.36 86.56.56.56.16.36.76 56.56.56.16.36.76.96
+ 56.56.16.36.76.96.96 56.16.36.76.96.96.26 16.36.76.96.96.26.26
+ 36.76.96.96.26.26.36 76.96.96.26.26.36.66 96.96.26.26.36.66.36
+ 96.26.26.36.66.36.36 26.26.36.66.36.36.97 26.36.66.36.36.97.27
+ 36.66.36.36.97.27.97 66.36.36.97.27.97.67 36.36.97.27.97.67.77
+ 36.97.27.97.67.77.47 97.27.97.67.77.47.7 27.97.67.77.47.7.47
+ 97.67.77.47.7.47.87 67.77.47.7.47.87.37 77.47.7.47.87.37.87
+ 47.7.47.87.37.87.77 7.47.87.37.87.77.7 47.87.37.87.77.7.57
+ 87.37.87.77.7.57.47 37.87.77.7.57.47.47 87.77.7.57.47.47.37
+ 77.7.57.47.47.37.27 7.57.47.47.37.27.17 57.47.47.37.27.17.7
+ 47.47.37.27.17.7.38 47.37.27.17.7.38.68 37.27.17.7.38.68.78
+ 27.17.7.38.68.78.8 17.7.38.68.78.8.28 7.38.68.78.8.28.98
+ 38.68.78.8.28.98.78 68.78.8.28.98.78.58 78.8.28.98.78.58.98
+ 8.28.98.78.58.98.8 28.98.78.58.98.8.88 98.78.58.98.8.88.8
+ 78.58.98.8.88.8.58 58.98.8.88.8.58.58 98.8.88.8.58.58.58
+ 8.88.8.58.58.58.38 88.8.58.58.58.38.89 8.58.58.58.38.89.59
+ 58.58.58.38.89.59.39 58.58.38.89.59.39.99 58.38.89.59.39.99.29
+ 38.89.59.39.99.29.59 89.59.39.99.29.59.89 59.39.99.29.59.89.89
+ 39.99.29.59.89.89.29 99.29.59.89.89.29.9 29.59.89.89.29.9.79
+ 59.89.89.29.9.79.49 89.89.29.9.79.49.59 89.29.9.79.49.59.29
+ 29.9.79.49.59.29.59 9.79.49.59.29.59.19 79.49.59.29.59.19.39
+ 49.59.29.59.19.39.9 59.29.59.19.39.9.9 29.59.19.39.9.9.99
+ 59.19.39.9.9.99.69 19.39.9.9.99.69.39 39.9.9.99.69.39 9.9.99.69.39}
+
+do_execsql_test 1.11.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.11.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.11.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.11.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.11.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING)
+} {3 89.96 4 89.96 5 89.96.38 6 89.96.38 7 89.96.38.39 7 96.38.39
+ 7 96.38.39.91 7 38.39.91 7 38.39.91.6 7 39.91.6 7 39.91.6.97
+ 7 91.6.97 7 91.6.97.46 7 6.97.46 7 6.97.46.54 7 97.46.54
+ 7 97.46.54.8 7 46.54.8 7 46.54.8.29 7 54.8.29 7 54.8.29.84
+ 7 8.29.84 7 8.29.84.23 7 29.84.23 7 29.84.23.16 7 84.23.16
+ 7 84.23.16.65 7 23.16.65 7 23.16.65.47 7 16.65.47 7 16.65.47.86
+ 7 65.47.86 7 65.47.86.61 7 47.86.61 7 47.86.61.85 7 86.61.85
+ 7 86.61.85.85 7 61.85.85 7 61.85.85.59 7 85.85.59 7 85.85.59.32
+ 7 85.59.32 7 85.59.32.3 7 59.32.3 7 59.32.3.22 7 32.3.22
+ 7 32.3.22.55 7 3.22.55 7 3.22.55.28 7 22.55.28 7 22.55.28.25
+ 7 55.28.25 7 55.28.25.1 7 28.25.1 7 28.25.1.40 7 25.1.40
+ 7 25.1.40.56 7 1.40.56 7 1.40.56.75 7 40.56.75 7 40.56.75.89
+ 7 56.75.89 7 56.75.89.76 7 75.89.76 7 75.89.76.4 7 89.76.4
+ 7 89.76.4.42 7 76.4.42 7 76.4.42.78 7 4.42.78 7 4.42.78.29
+ 7 42.78.29 7 42.78.29.63 7 78.29.63 7 78.29.63.87 7 29.63.87
+ 7 29.63.87.80 7 63.87.80 7 63.87.80.72 7 87.80.72 7 87.80.72.9
+ 7 80.72.9 7 80.72.9.73 7 72.9.73 7 72.9.73.65 7 9.73.65
+ 7 9.73.65.58 7 73.65.58 7 73.65.58.98 7 65.58.98 7 65.58.98.21
+ 7 58.98.21 7 58.98.21.65 7 98.21.65 7 98.21.65.5 7 21.65.5
+ 7 21.65.5.11 7 65.5.11 7 65.5.11.87 7 5.11.87 7 5.11.87.12
+ 7 11.87.12 7 11.87.12.20 7 87.12.20 7 87.12.20.31 7 12.20.31
+ 7 12.20.31.95 7 20.31.95 7 20.31.95.73 7 31.95.73 7 31.95.73.88
+ 7 95.73.88 7 95.73.88.8 7 73.88.8 7 73.88.8.49 7 88.8.49
+ 7 88.8.49.90 7 8.49.90 7 8.49.90.96 7 49.90.96 7 49.90.96.55
+ 7 90.96.55 7 90.96.55.77 7 96.55.77 7 96.55.77.2 7 55.77.2
+ 7 55.77.2.85 7 77.2.85 7 77.2.85.74 7 2.85.74 7 2.85.74.70
+ 7 85.74.70 7 85.74.70.19 7 74.70.19 7 74.70.19.26 7 70.19.26
+ 7 70.19.26.47 7 19.26.47 7 19.26.47.90 7 26.47.90 7 26.47.90.58
+ 7 47.90.58 7 47.90.58.9 7 90.58.9 7 90.58.9.72 7 58.9.72
+ 7 58.9.72.33 7 9.72.33 7 9.72.33.75 7 72.33.75 7 72.33.75.81
+ 7 33.75.81 7 33.75.81.23 7 75.81.23 7 75.81.23.13 7 81.23.13
+ 7 81.23.13.14 7 23.13.14 7 23.13.14.91 7 13.14.91 7 13.14.91.91
+ 7 14.91.91 7 14.91.91.15 7 91.91.15 7 91.91.15.36 7 91.15.36
+ 7 91.15.36.3 7 15.36.3 7 15.36.3.69 7 36.3.69 7 36.3.69.52
+ 7 3.69.52 7 3.69.52.50 7 69.52.50 7 69.52.50.10 7 52.50.10
+ 7 52.50.10.33 7 50.10.33 7 50.10.33.39 7 10.33.39 7 10.33.39.58
+ 7 33.39.58 7 33.39.58.38 7 39.58.38 7 39.58.38.83 7 58.38.83
+ 7 58.38.83.82 7 38.83.82 7 38.83.82.7 6 83.82.7 5 83.82.7}
+
+do_execsql_test 1.11.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING)
+} {3 {} 4 {} 5 {} 6 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 6 {} 5 {}}
+
+do_execsql_test 1.11.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING)
+} {3 {} 4 {} 5 {} 6 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 6 {} 5 {} 3 {} 4 {}
+ 5 {} 6 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 6 {} 5 {} 3 {} 4 {} 5 {} 6 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 6 {} 5 {} 3 {} 4 {} 5 {} 6 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 6 {} 5 {}
+ 3 {} 4 {} 5 {} 6 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 6 {} 5 {} 3 {} 4 {} 5 {}
+ 6 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 6 {} 5 {} 3 {} 4 {} 5 {} 6 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 6 {} 5 {} 3 {} 4 {} 5 {} 6 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 6 {} 5 {} 3 {}
+ 4 {} 5 {} 6 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 6 {} 5 {} 3 {} 4 {} 5 {} 6 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 6 {} 5 {}}
+
+do_execsql_test 1.11.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND 2 FOLLOWING)
+} {3 89.6.29 4 89.6.29.47 5 89.6.29.47.59 6 89.6.29.47.59.28
+ 7 89.6.29.47.59.28.75 7 6.29.47.59.28.75.78 7 29.47.59.28.75.78.72
+ 7 47.59.28.75.78.72.98 7 59.28.75.78.72.98.87 7 28.75.78.72.98.87.73
+ 7 75.78.72.98.87.73.96 7 78.72.98.87.73.96.74 7 72.98.87.73.96.74.90
+ 7 98.87.73.96.74.90.75 7 87.73.96.74.90.75.91 7 73.96.74.90.75.91.69
+ 7 96.74.90.75.91.69.39 7 74.90.75.91.69.39.7 6 90.75.91.69.39.7
+ 5 75.91.69.39.7 3 {} 4 {} 5 {} 6 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 6 {} 5 {}
+ 3 96.97.84 4 96.97.84.86 5 96.97.84.86.32 6 96.97.84.86.32.25
+ 7 96.97.84.86.32.25.89 7 97.84.86.32.25.89.29 7 84.86.32.25.89.29.9
+ 7 86.32.25.89.29.9.21 7 32.25.89.29.9.21.12 7 25.89.29.9.21.12.88
+ 7 89.29.9.21.12.88.55 7 29.9.21.12.88.55.70 7 9.21.12.88.55.70.58
+ 7 21.12.88.55.70.58.81 7 12.88.55.70.58.81.91 7 88.55.70.58.81.91.52
+ 7 55.70.58.81.91.52.58 6 70.58.81.91.52.58 5 58.81.91.52.58 3 {}
+ 4 {} 5 {} 6 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 6 {} 5 {} 3 38.46.23 4 38.46.23.61
+ 5 38.46.23.61.3 6 38.46.23.61.3.1 7 38.46.23.61.3.1.76
+ 7 46.23.61.3.1.76.63 7 23.61.3.1.76.63.73 7 61.3.1.76.63.73.65
+ 7 3.1.76.63.73.65.20 7 1.76.63.73.65.20.8 7 76.63.73.65.20.8.77
+ 7 63.73.65.20.8.77.19 7 73.65.20.8.77.19.9 7 65.20.8.77.19.9.23
+ 7 20.8.77.19.9.23.15 7 8.77.19.9.23.15.50 7 77.19.9.23.15.50.38
+ 6 19.9.23.15.50.38 5 9.23.15.50.38 3 {} 4 {} 5 {} 6 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 6 {} 5 {} 3 39.54.16 4 39.54.16.85 5 39.54.16.85.22
+ 6 39.54.16.85.22.40 7 39.54.16.85.22.40.4 7 54.16.85.22.40.4.87
+ 7 16.85.22.40.4.87.65 7 85.22.40.4.87.65.5 7 22.40.4.87.65.5.31
+ 7 40.4.87.65.5.31.49 7 4.87.65.5.31.49.2 7 87.65.5.31.49.2.26
+ 7 65.5.31.49.2.26.72 7 5.31.49.2.26.72.13 7 31.49.2.26.72.13.36
+ 7 49.2.26.72.13.36.10 7 2.26.72.13.36.10.83 6 26.72.13.36.10.83
+ 5 72.13.36.10.83 3 {} 4 {} 5 {} 6 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 6 {} 5 {}
+ 3 91.8.65 4 91.8.65.85 5 91.8.65.85.55 6 91.8.65.85.55.56
+ 7 91.8.65.85.55.56.42 7 8.65.85.55.56.42.80 7 65.85.55.56.42.80.58
+ 7 85.55.56.42.80.58.11 7 55.56.42.80.58.11.95 7 56.42.80.58.11.95.90
+ 7 42.80.58.11.95.90.85 7 80.58.11.95.90.85.47 7 58.11.95.90.85.47.33
+ 7 11.95.90.85.47.33.14 7 95.90.85.47.33.14.3 7 90.85.47.33.14.3.33
+ 7 85.47.33.14.3.33.82 6 47.33.14.3.33.82 5 33.14.3.33.82 3 {} 4 {}
+ 5 {} 6 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {} 7 {}
+ 7 {} 7 {} 7 {} 7 {} 6 {} 5 {}}
+
+do_execsql_test 1.12.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {96 96 96 68 91 91 91 99 99 99 99 99 97 97 97
+ 97 97 97 93 93 93 93 84 93 93 93 93 93 86 86
+ 86 91 91 91 91 91 85 85 85 59 59 91 91 91 91
+ 91 90 90 89 89 89 89 56 56 56 56 75 75 89 98
+ 98 98 98 98 94 94 94 94 78 78 78 63 87 87 87
+ 87 87 84 84 84 73 95 95 95 95 96 98 98 98 98
+ 98 74 74 74 73 73 87 87 87 87 87 41 31 31 95
+ 95 95 95 95 88 88 88 88 49 90 90 96 96 96 96
+ 96 77 77 77 85 85 85 85 85 74 74 70 70 59 47
+ 80 90 90 90 90 90 72 72 72 72 93 93 93 93 93
+ 81 81 81 37 37 62 91 91 91 91 91 91 91 99 99
+ 99 99 99 95 95 69 84 84 84 84 84 84 84 58 58
+ 58 58 83 83 83 83 83 82 82 17 7}
+
+do_execsql_test 1.12.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {38 38 38 38 38 39 6 6 6 6 6 27 27 27 8 8 8
+ 8 8 29 23 16 16 16 16 16 16 7 7 7 7 7 61 24
+ 24 24 24 12 12 12 3 3 3 3 3 15 15 15 15 15
+ 1 1 1 1 1 16 16 16 16 16 36 36 4 4 4 4 4
+ 30 29 29 29 2 2 2 2 2 37 37 9 9 9 9 9 13
+ 13 13 13 1 1 1 1 1 5 5 5 5 5 11 11 8 8 8
+ 8 8 15 15 15 15 22 22 8 8 8 8 8 11 34 34 55
+ 55 55 44 2 2 2 2 2 7 29 29 19 19 19 19 19
+ 26 26 26 36 36 9 9 9 9 9 33 33 33 33 9 9 9
+ 9 9 12 12 12 12 14 33 15 15 15 15 3 3 3 3 3
+ 30 30 30 10 10 10 10 10 21 21 21 30 30 30 27
+ 27 17 7 7 7 7 7}
+
+do_execsql_test 1.12.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.12.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.12.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.12.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.12.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.12.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.12.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.12.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.12.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.12.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.12.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.12.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.12.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.12.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.12.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.12.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.12.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.12.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.12.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {52 83 55 79 109 65 26 120 119 50 70 103 80 124
+ 36 96 59 124 116 110 57 51 52 130 103 74 87 48
+ 128 117 105 136 131 71 133 92 109 63 84 109 57
+ 146 78 147 113 74 88 150 87 110 65 121 106 110
+ 124 85 145 107 161 171 150 156 80 171 120 109 158
+ 114 111 136 147 87 173 124 168 173 162 132 101 154
+ 167 190 161 110 156 195 198 102 123 177 169 140 111
+ 180 119 160 197 152 124 121 134 146 147 132 213 141
+ 193 200 210 157 132 136 175 161 218 188 226 191 187
+ 208 211 179 138 144 223 196 214 170 212 202 163 184
+ 172 173 195 229 240 187 210 200 163 227 228 223 191
+ 252 235 225 243 172 187 202 179 179 182 231 261 207
+ 263 206 189 209 212 276 181 274 249 239 234 213 234
+ 269 196 271 221 210 229 235 250 223 232 229 279 224
+ 280 216 207 207 207 207 207}
+
+do_execsql_test 1.12.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {134 218 191 212 229 240 213 234 196 223 223 223 223
+ 223 146 65 156 132 154 102 123 119 160 152 146 147
+ 136 243 261 263 210 210 210 210 210 120 87 162 124
+ 141 138 227 228 179 231 234 280 280 280 280 280 57
+ 110 114 136 147 167 110 180 193 191 252 187 179 206
+ 181 221 279 279 279 279 279 80 171 173 177 157 161
+ 179 214 225 182 209 269 271 235 229 229 229 229 229
+ 113 74 87 145 190 161 169 140 111 132 213 187 208
+ 223 235 189 274 274 274 274 274 51 52 128 109 121
+ 124 85 107 150 195 226 172 173 187 223 207 212 212
+ 212 212 212 110 87 48 110 173 124 197 211 144 196
+ 195 200 202 224 216 207 207 207 207 207 88 171 158
+ 156 198 121 210 132 210 239 250 232 232 232 232 232
+ 59 109 150 161 111 101 200 175 188 170 202 163 184
+ 163 172 276 249 229 229 229 229 229}
+
+do_execsql_test 1.12.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {57 181 80 111 26 48 144 207 36 121 132 101 163
+ 172 196 119 136 63 124 179 110 179 182 74 132 189
+ 51 52 85 216 163 134 123 210 78 141 57 187 71 87
+ 172 173 50 224 88 59 111 170 109 213 223 146 147
+ 84 114 191 206 221 157 161 209 229 74 140 107 187
+ 207 212 124 202 52 232 55 184 229 106 132 152 120
+ 92 110 179 235 65 70 87 110 195 200 175 234 160
+ 234 136 80 113 187 109 121 124 196 156 210 239 250
+ 72 109 188 202 191 105 154 79 231 147 225 103 161
+ 169 223 96 83 249 212 162 227 228 167 180 193 117
+ 177 214 145 208 235 150 110 211 103 158 200 168 229
+ 92 156 243 280 279 116 173 269 271 131 133 223 128
+ 173 197 210 99 150 161 147 218 240 109 136 146 261
+ 263 124 130 252 171 190 213 274 108 195 226 119 124
+ 171 198 120 276 276 276 276 276}
+
+do_execsql_test 1.12.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {223 106 234 191 212 168 229 147 218 240 240 240 240
+ 240 123 210 146 147 132 152 160 105 154 92 156 243
+ 109 136 146 261 263 263 263 263 263 179 78 141 84
+ 120 234 79 231 162 227 228 280 280 280 280 280 57
+ 187 114 191 206 221 92 110 136 147 167 180 193 279
+ 124 130 252 252 252 252 252 161 209 229 179 235 80
+ 225 117 177 214 116 173 269 271 171 171 171 171 171
+ 87 74 140 113 187 103 161 169 145 208 235 131 133
+ 223 190 213 274 274 274 274 274 172 173 107 187 207
+ 212 65 70 109 121 124 223 150 128 108 195 226 226
+ 226 226 226 50 224 124 202 87 110 195 200 196 96
+ 110 211 173 197 119 124 124 124 124 124 52 232 156
+ 210 239 250 83 103 158 210 171 198 198 198 198 198
+ 59 111 170 55 184 229 175 72 109 188 202 249 200
+ 99 150 161 120 276 276 276 276 276}
+
+do_execsql_test 1.12.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {134 218 191 212 229 240 213 234 196 223 92 109 105
+ 136 146 65 156 132 154 102 123 119 160 152 146 147
+ 136 243 261 263 210 79 63 84 78 120 87 162 124
+ 141 138 227 228 179 231 234 280 124 57 130 92 57
+ 110 114 136 147 167 110 180 193 191 252 187 179 206
+ 181 221 279 80 116 117 71 80 171 173 177 157 161
+ 179 214 225 182 209 269 271 235 229 103 74 131 133
+ 113 74 87 145 190 161 169 140 111 132 213 187 208
+ 223 235 189 274 108 65 26 70 51 52 128 109 121
+ 124 85 107 150 195 226 172 173 187 223 207 212 119
+ 50 124 96 110 87 48 110 173 124 197 211 144 196
+ 195 200 202 224 216 207 52 83 103 36 88 171 158
+ 156 198 121 210 132 210 239 250 232 99 72 55 120
+ 59 109 150 161 111 101 200 175 188 170 202 163 184
+ 163 172 276 249 229 229 229 229 229}
+
+do_execsql_test 1.12.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.12.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} 90
+ {} {} {} {} {} {} {} {} {} 56 {} {} {} {} {}
+ {} {} {} {} {} {} 78 {} {} {} {} {} {} {} {}
+ 37 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 21 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 85 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 54 {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.12.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.12.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 19 20 21 21 22 22 23 23 24 25 26 26 27 27 28
+ 29 29 29 30 30 30 31 31 32 33 33 33 33 34 34
+ 34 34 35 35 36 36 36 36 37 37 38 38 39 39 39
+ 40 41 41 42 43 43 44 44 46 46 47 47 47 47 49
+ 50 51 52 53 54 55 55 56 56 56 57 58 58 58 58
+ 59 59 59 59 60 61 61 62 62 63 64 65 65 65 66
+ 67 68 69 70 72 72 72 73 73 73 74 74 74 75 75
+ 75 76 77 77 78 78 79 80 80 81 81 81 82 83 84
+ 84 84 84 85 85 85 86 87 87 88 89 89 89 90 90
+ 90 91 91 91 91 91 93 93 93 94 95 95 95 96 96
+ 96 97 97 98 98 99 99}
+
+do_execsql_test 1.12.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {10 20 30 30 30 40 50 60 70 80 80 90 90 90 1 1
+ 11 11 21 21 31 31 41 41 51 61 61 81 81 81 91
+ 91 91 91 91 2 2 12 12 12 22 22 32 42 52 62 62
+ 72 72 72 82 3 3 13 13 23 23 33 33 33 33 43 43
+ 53 63 73 73 73 83 93 93 93 4 14 24 34 34 34
+ 34 44 44 54 64 74 74 74 84 84 84 84 94 5 15
+ 15 15 25 35 35 55 55 65 65 65 75 75 75 85 85
+ 85 95 95 95 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 86 96 96 96 7 7 7 17 27 27
+ 37 37 47 47 47 47 57 67 77 77 87 87 97 97 8 8
+ 8 28 38 38 58 58 58 58 68 78 78 88 98 98 9 9
+ 9 19 29 29 29 39 39 39 49 59 59 59 59 69 79
+ 89 89 89 99 99}
+
+do_execsql_test 1.12.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.12.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.12.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.12.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.12.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.12.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.12.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.12.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.12.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {89.81.96.59.38 81.96.59.38.68 96.59.38.68.39 59.38.68.39.62
+ 38.68.39.62.91 68.39.62.91.46 39.62.91.46.6 62.91.46.6.99
+ 91.46.6.99.97 46.6.99.97.27 6.99.97.27.46 99.97.27.46.78
+ 97.27.46.78.54 27.46.78.54.97 46.78.54.97.8 78.54.97.8.67
+ 54.97.8.67.29 97.8.67.29.93 8.67.29.93.84 67.29.93.84.77
+ 29.93.84.77.23 93.84.77.23.16 84.77.23.16.16 77.23.16.16.93
+ 23.16.16.93.65 16.16.93.65.35 16.93.65.35.47 93.65.35.47.7
+ 65.35.47.7.86 35.47.7.86.74 47.7.86.74.61 7.86.74.61.91
+ 86.74.61.91.85 74.61.91.85.24 61.91.85.24.85 91.85.24.85.43
+ 85.24.85.43.59 24.85.43.59.12 85.43.59.12.32 43.59.12.32.56
+ 59.12.32.56.3 12.32.56.3.91 32.56.3.91.22 56.3.91.22.90
+ 3.91.22.90.55 91.22.90.55.15 22.90.55.15.28 90.55.15.28.89
+ 55.15.28.89.25 15.28.89.25.47 28.89.25.47.1 89.25.47.1.56
+ 25.47.1.56.40 47.1.56.40.43 1.56.40.43.56 56.40.43.56.16
+ 40.43.56.16.75 43.56.16.75.36 56.16.75.36.89 16.75.36.89.98
+ 75.36.89.98.76 36.89.98.76.81 89.98.76.81.4 98.76.81.4.94
+ 76.81.4.94.42 81.4.94.42.30 4.94.42.30.78 94.42.30.78.33
+ 42.30.78.33.29 30.78.33.29.53 78.33.29.53.63 33.29.53.63.2
+ 29.53.63.2.87 53.63.2.87.37 63.2.87.37.80 2.87.37.80.84
+ 87.37.80.84.72 37.80.84.72.41 80.84.72.41.9 84.72.41.9.61
+ 72.41.9.61.73 41.9.61.73.95 9.61.73.95.65 61.73.95.65.13
+ 73.95.65.13.58 95.65.13.58.96 65.13.58.96.98 13.58.96.98.1
+ 58.96.98.1.21 96.98.1.21.74 98.1.21.74.65 1.21.74.65.35
+ 21.74.65.35.5 74.65.35.5.73 65.35.5.73.11 35.5.73.11.51
+ 5.73.11.51.87 73.11.51.87.41 11.51.87.41.12 51.87.41.12.8
+ 87.41.12.8.20 41.12.8.20.31 12.8.20.31.31 8.20.31.31.15
+ 20.31.31.15.95 31.31.15.95.22 31.15.95.22.73 15.95.22.73.79
+ 95.22.73.79.88 22.73.79.88.34 73.79.88.34.8 79.88.34.8.11
+ 88.34.8.11.49 34.8.11.49.34 8.11.49.34.90 11.49.34.90.59
+ 49.34.90.59.96 34.90.59.96.60 90.59.96.60.55 59.96.60.55.75
+ 96.60.55.75.77 60.55.75.77.44 55.75.77.44.2 75.77.44.2.7
+ 77.44.2.7.85 44.2.7.85.57 2.7.85.57.74 7.85.57.74.29 85.57.74.29.70
+ 57.74.29.70.59 74.29.70.59.19 29.70.59.19.39 70.59.19.39.26
+ 59.19.39.26.26 19.39.26.26.47 39.26.26.47.80 26.26.47.80.90
+ 26.47.80.90.36 47.80.90.36.58 80.90.36.58.47 90.36.58.47.9
+ 36.58.47.9.72 58.47.9.72.72 47.9.72.72.66 9.72.72.66.33
+ 72.72.66.33.93 72.66.33.93.75 66.33.93.75.64 33.93.75.64.81
+ 93.75.64.81.9 75.64.81.9.23 64.81.9.23.37 81.9.23.37.13
+ 9.23.37.13.12 23.37.13.12.14 37.13.12.14.62 13.12.14.62.91
+ 12.14.62.91.36 14.62.91.36.91 62.91.36.91.33 91.36.91.33.15
+ 36.91.33.15.34 91.33.15.34.36 33.15.34.36.99 15.34.36.99.3
+ 34.36.99.3.95 36.99.3.95.69 99.3.95.69.58 3.95.69.58.52
+ 95.69.58.52.30 69.58.52.30.50 58.52.30.50.84 52.30.50.84.10
+ 30.50.84.10.84 50.84.10.84.33 84.10.84.33.21 10.84.33.21.39
+ 84.33.21.39.44 33.21.39.44.58 21.39.44.58.30 39.44.58.30.38
+ 44.58.30.38.34 58.30.38.34.83 30.38.34.83.27 38.34.83.27.82
+ 34.83.27.82.17 83.27.82.17.7 27.82.17.7 82.17.7 17.7 7}
+
+do_execsql_test 1.12.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {90.40.30.80.20 40.30.80.20.90 30.80.20.90.60 80.20.90.60.70
+ 20.90.60.70.80 90.60.70.80.90 60.70.80.90.30 70.80.90.30.50
+ 80.90.30.50.10 90.30.50.10.30 30.50.10.30 50.10.30 10.30 30
+ 81.91.61.91.91 91.61.91.91.1 61.91.91.1.81 91.91.1.81.41
+ 91.1.81.41.61 1.81.41.61.1 81.41.61.1.21 41.61.1.21.11
+ 61.1.21.11.51 1.21.11.51.41 21.11.51.41.31 11.51.41.31.31
+ 51.41.31.31.11 41.31.31.11.81 31.31.11.81.91 31.11.81.91.91
+ 11.81.91.91.21 81.91.91.21 91.91.21 91.21 21 62.12.32.22.42
+ 12.32.22.42.2 32.22.42.2.72 22.42.2.72.12 42.2.72.12.22
+ 2.72.12.22.2 72.12.22.2.72 12.22.2.72.72 22.2.72.72.12
+ 2.72.72.12.62 72.72.12.62.52 72.12.62.52.82 12.62.52.82 62.52.82
+ 52.82 82 93.23.93.43.3 23.93.43.3.43 93.43.3.43.33 43.3.43.33.53
+ 3.43.33.53.63 43.33.53.63.73 33.53.63.73.13 53.63.73.13.73
+ 63.73.13.73.73 73.13.73.73.33 13.73.73.33.93 73.73.33.93.23
+ 73.33.93.23.13 33.93.23.13.33 93.23.13.33.3 23.13.33.3.33
+ 13.33.3.33.83 33.3.33.83 3.33.83 33.83 83 54.84.74.24.4
+ 84.74.24.4.94 74.24.4.94.84 24.4.94.84.74 4.94.84.74.34
+ 94.84.74.34.34 84.74.34.34.44 74.34.34.44.74 34.34.44.74.64
+ 34.44.74.64.14 44.74.64.14.34 74.64.14.34.84 64.14.34.84.84
+ 14.34.84.84.44 34.84.84.44.34 84.84.44.34 84.44.34 44.34 34
+ 65.35.85.85.55 35.85.85.55.15 85.85.55.15.25 85.55.15.25.75
+ 55.15.25.75.95 15.25.75.95.65 25.75.95.65.65 75.95.65.65.35
+ 95.65.65.35.5 65.65.35.5.15 65.35.5.15.95 35.5.15.95.55
+ 5.15.95.55.75 15.95.55.75.85 95.55.75.85.75 55.75.85.75.15
+ 75.85.75.15.95 85.75.15.95 75.15.95 15.95 95 96.46.6.46.16
+ 46.6.46.16.16 6.46.16.16.86 46.16.16.86.56 16.16.86.56.56
+ 16.86.56.56.56 86.56.56.56.16 56.56.56.16.36 56.56.16.36.76
+ 56.16.36.76.96 16.36.76.96.96 36.76.96.96.26 76.96.96.26.26
+ 96.96.26.26.36 96.26.26.36.66 26.26.36.66.36 26.36.66.36.36
+ 36.66.36.36 66.36.36 36.36 36 97.27.97.67.77 27.97.67.77.47
+ 97.67.77.47.7 67.77.47.7.47 77.47.7.47.87 47.7.47.87.37
+ 7.47.87.37.87 47.87.37.87.77 87.37.87.77.7 37.87.77.7.57
+ 87.77.7.57.47 77.7.57.47.47 7.57.47.47.37 57.47.47.37.27
+ 47.47.37.27.17 47.37.27.17.7 37.27.17.7 27.17.7 17.7 7
+ 38.68.78.8.28 68.78.8.28.98 78.8.28.98.78 8.28.98.78.58
+ 28.98.78.58.98 98.78.58.98.8 78.58.98.8.88 58.98.8.88.8
+ 98.8.88.8.58 8.88.8.58.58 88.8.58.58.58 8.58.58.58.38 58.58.58.38
+ 58.58.38 58.38 38 89.59.39.99.29 59.39.99.29.59 39.99.29.59.89
+ 99.29.59.89.89 29.59.89.89.29 59.89.89.29.9 89.89.29.9.79
+ 89.29.9.79.49 29.9.79.49.59 9.79.49.59.29 79.49.59.29.59
+ 49.59.29.59.19 59.29.59.19.39 29.59.19.39.9 59.19.39.9.9
+ 19.39.9.9.99 39.9.9.99.69 9.9.99.69.39 9.99.69.39 99.69.39 69.39
+ 39}
+
+do_execsql_test 1.12.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {1.1.2.2.3 1.2.2.3.3 2.2.3.3.4 2.3.3.4.5 3.3.4.5.6 3.4.5.6.7
+ 4.5.6.7.7 5.6.7.7.7 6.7.7.7.8 7.7.7.8.8 7.7.8.8.8 7.8.8.8.9
+ 8.8.8.9.9 8.8.9.9.9 8.9.9.9.10 9.9.9.10.11 9.9.10.11.11
+ 9.10.11.11.12 10.11.11.12.12 11.11.12.12.12 11.12.12.12.13
+ 12.12.12.13.13 12.12.13.13.14 12.13.13.14.15 13.13.14.15.15
+ 13.14.15.15.15 14.15.15.15.16 15.15.15.16.16 15.15.16.16.16
+ 15.16.16.16.17 16.16.16.17.19 16.16.17.19.20 16.17.19.20.21
+ 17.19.20.21.21 19.20.21.21.22 20.21.21.22.22 21.21.22.22.23
+ 21.22.22.23.23 22.22.23.23.24 22.23.23.24.25 23.23.24.25.26
+ 23.24.25.26.26 24.25.26.26.27 25.26.26.27.27 26.26.27.27.28
+ 26.27.27.28.29 27.27.28.29.29 27.28.29.29.29 28.29.29.29.30
+ 29.29.29.30.30 29.29.30.30.30 29.30.30.30.31 30.30.30.31.31
+ 30.30.31.31.32 30.31.31.32.33 31.31.32.33.33 31.32.33.33.33
+ 32.33.33.33.33 33.33.33.33.34 33.33.33.34.34 33.33.34.34.34
+ 33.34.34.34.34 34.34.34.34.35 34.34.34.35.35 34.34.35.35.36
+ 34.35.35.36.36 35.35.36.36.36 35.36.36.36.36 36.36.36.36.37
+ 36.36.36.37.37 36.36.37.37.38 36.37.37.38.38 37.37.38.38.39
+ 37.38.38.39.39 38.38.39.39.39 38.39.39.39.40 39.39.39.40.41
+ 39.39.40.41.41 39.40.41.41.42 40.41.41.42.43 41.41.42.43.43
+ 41.42.43.43.44 42.43.43.44.44 43.43.44.44.46 43.44.44.46.46
+ 44.44.46.46.47 44.46.46.47.47 46.46.47.47.47 46.47.47.47.47
+ 47.47.47.47.49 47.47.47.49.50 47.47.49.50.51 47.49.50.51.52
+ 49.50.51.52.53 50.51.52.53.54 51.52.53.54.55 52.53.54.55.55
+ 53.54.55.55.56 54.55.55.56.56 55.55.56.56.56 55.56.56.56.57
+ 56.56.56.57.58 56.56.57.58.58 56.57.58.58.58 57.58.58.58.58
+ 58.58.58.58.59 58.58.58.59.59 58.58.59.59.59 58.59.59.59.59
+ 59.59.59.59.60 59.59.59.60.61 59.59.60.61.61 59.60.61.61.62
+ 60.61.61.62.62 61.61.62.62.63 61.62.62.63.64 62.62.63.64.65
+ 62.63.64.65.65 63.64.65.65.65 64.65.65.65.66 65.65.65.66.67
+ 65.65.66.67.68 65.66.67.68.69 66.67.68.69.70 67.68.69.70.72
+ 68.69.70.72.72 69.70.72.72.72 70.72.72.72.73 72.72.72.73.73
+ 72.72.73.73.73 72.73.73.73.74 73.73.73.74.74 73.73.74.74.74
+ 73.74.74.74.75 74.74.74.75.75 74.74.75.75.75 74.75.75.75.76
+ 75.75.75.76.77 75.75.76.77.77 75.76.77.77.78 76.77.77.78.78
+ 77.77.78.78.79 77.78.78.79.80 78.78.79.80.80 78.79.80.80.81
+ 79.80.80.81.81 80.80.81.81.81 80.81.81.81.82 81.81.81.82.83
+ 81.81.82.83.84 81.82.83.84.84 82.83.84.84.84 83.84.84.84.84
+ 84.84.84.84.85 84.84.84.85.85 84.84.85.85.85 84.85.85.85.86
+ 85.85.85.86.87 85.85.86.87.87 85.86.87.87.88 86.87.87.88.89
+ 87.87.88.89.89 87.88.89.89.89 88.89.89.89.90 89.89.89.90.90
+ 89.89.90.90.90 89.90.90.90.91 90.90.90.91.91 90.90.91.91.91
+ 90.91.91.91.91 91.91.91.91.91 91.91.91.91.93 91.91.91.93.93
+ 91.91.93.93.93 91.93.93.93.94 93.93.93.94.95 93.93.94.95.95
+ 93.94.95.95.95 94.95.95.95.96 95.95.95.96.96 95.95.96.96.96
+ 95.96.96.96.97 96.96.96.97.97 96.96.97.97.98 96.97.97.98.98
+ 97.97.98.98.99 97.98.98.99.99 98.98.99.99 98.99.99 99.99 99}
+
+do_execsql_test 1.12.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {10.20.30.30.30 20.30.30.30.40 30.30.30.40.50 30.30.40.50.60
+ 30.40.50.60.70 40.50.60.70.80 50.60.70.80.80 60.70.80.80.90
+ 70.80.80.90.90 80.80.90.90.90 80.90.90.90 90.90.90 90.90 90
+ 1.1.11.11.21 1.11.11.21.21 11.11.21.21.31 11.21.21.31.31
+ 21.21.31.31.41 21.31.31.41.41 31.31.41.41.51 31.41.41.51.61
+ 41.41.51.61.61 41.51.61.61.81 51.61.61.81.81 61.61.81.81.81
+ 61.81.81.81.91 81.81.81.91.91 81.81.91.91.91 81.91.91.91.91
+ 91.91.91.91.91 91.91.91.91 91.91.91 91.91 91 2.2.12.12.12
+ 2.12.12.12.22 12.12.12.22.22 12.12.22.22.32 12.22.22.32.42
+ 22.22.32.42.52 22.32.42.52.62 32.42.52.62.62 42.52.62.62.72
+ 52.62.62.72.72 62.62.72.72.72 62.72.72.72.82 72.72.72.82 72.72.82
+ 72.82 82 3.3.13.13.23 3.13.13.23.23 13.13.23.23.33 13.23.23.33.33
+ 23.23.33.33.33 23.33.33.33.33 33.33.33.33.43 33.33.33.43.43
+ 33.33.43.43.53 33.43.43.53.63 43.43.53.63.73 43.53.63.73.73
+ 53.63.73.73.73 63.73.73.73.83 73.73.73.83.93 73.73.83.93.93
+ 73.83.93.93.93 83.93.93.93 93.93.93 93.93 93 4.14.24.34.34
+ 14.24.34.34.34 24.34.34.34.34 34.34.34.34.44 34.34.34.44.44
+ 34.34.44.44.54 34.44.44.54.64 44.44.54.64.74 44.54.64.74.74
+ 54.64.74.74.74 64.74.74.74.84 74.74.74.84.84 74.74.84.84.84
+ 74.84.84.84.84 84.84.84.84.94 84.84.84.94 84.84.94 84.94 94
+ 5.15.15.15.25 15.15.15.25.35 15.15.25.35.35 15.25.35.35.55
+ 25.35.35.55.55 35.35.55.55.65 35.55.55.65.65 55.55.65.65.65
+ 55.65.65.65.75 65.65.65.75.75 65.65.75.75.75 65.75.75.75.85
+ 75.75.75.85.85 75.75.85.85.85 75.85.85.85.95 85.85.85.95.95
+ 85.85.95.95.95 85.95.95.95 95.95.95 95.95 95 6.16.16.16.26
+ 16.16.16.26.26 16.16.26.26.36 16.26.26.36.36 26.26.36.36.36
+ 26.36.36.36.36 36.36.36.36.46 36.36.36.46.46 36.36.46.46.56
+ 36.46.46.56.56 46.46.56.56.56 46.56.56.56.66 56.56.56.66.76
+ 56.56.66.76.86 56.66.76.86.96 66.76.86.96.96 76.86.96.96.96
+ 86.96.96.96 96.96.96 96.96 96 7.7.7.17.27 7.7.17.27.27
+ 7.17.27.27.37 17.27.27.37.37 27.27.37.37.47 27.37.37.47.47
+ 37.37.47.47.47 37.47.47.47.47 47.47.47.47.57 47.47.47.57.67
+ 47.47.57.67.77 47.57.67.77.77 57.67.77.77.87 67.77.77.87.87
+ 77.77.87.87.97 77.87.87.97.97 87.87.97.97 87.97.97 97.97 97
+ 8.8.8.28.38 8.8.28.38.38 8.28.38.38.58 28.38.38.58.58
+ 38.38.58.58.58 38.58.58.58.58 58.58.58.58.68 58.58.58.68.78
+ 58.58.68.78.78 58.68.78.78.88 68.78.78.88.98 78.78.88.98.98
+ 78.88.98.98 88.98.98 98.98 98 9.9.9.19.29 9.9.19.29.29
+ 9.19.29.29.29 19.29.29.29.39 29.29.29.39.39 29.29.39.39.39
+ 29.39.39.39.49 39.39.39.49.59 39.39.49.59.59 39.49.59.59.59
+ 49.59.59.59.59 59.59.59.59.69 59.59.59.69.79 59.59.69.79.89
+ 59.69.79.89.89 69.79.89.89.89 79.89.89.89.99 89.89.89.99.99
+ 89.89.99.99 89.99.99 99.99 99}
+
+do_execsql_test 1.12.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING ) FROM t2
+} {90.40.30.80.20 40.30.80.20.90 30.80.20.90.60 80.20.90.60.70
+ 20.90.60.70.80 90.60.70.80.90 60.70.80.90.30 70.80.90.30.50
+ 80.90.30.50.10 90.30.50.10.30 30.50.10.30.81 50.10.30.81.91
+ 10.30.81.91.61 30.81.91.61.91 81.91.61.91.91 91.61.91.91.1
+ 61.91.91.1.81 91.91.1.81.41 91.1.81.41.61 1.81.41.61.1
+ 81.41.61.1.21 41.61.1.21.11 61.1.21.11.51 1.21.11.51.41
+ 21.11.51.41.31 11.51.41.31.31 51.41.31.31.11 41.31.31.11.81
+ 31.31.11.81.91 31.11.81.91.91 11.81.91.91.21 81.91.91.21.62
+ 91.91.21.62.12 91.21.62.12.32 21.62.12.32.22 62.12.32.22.42
+ 12.32.22.42.2 32.22.42.2.72 22.42.2.72.12 42.2.72.12.22
+ 2.72.12.22.2 72.12.22.2.72 12.22.2.72.72 22.2.72.72.12
+ 2.72.72.12.62 72.72.12.62.52 72.12.62.52.82 12.62.52.82.93
+ 62.52.82.93.23 52.82.93.23.93 82.93.23.93.43 93.23.93.43.3
+ 23.93.43.3.43 93.43.3.43.33 43.3.43.33.53 3.43.33.53.63
+ 43.33.53.63.73 33.53.63.73.13 53.63.73.13.73 63.73.13.73.73
+ 73.13.73.73.33 13.73.73.33.93 73.73.33.93.23 73.33.93.23.13
+ 33.93.23.13.33 93.23.13.33.3 23.13.33.3.33 13.33.3.33.83
+ 33.3.33.83.54 3.33.83.54.84 33.83.54.84.74 83.54.84.74.24
+ 54.84.74.24.4 84.74.24.4.94 74.24.4.94.84 24.4.94.84.74
+ 4.94.84.74.34 94.84.74.34.34 84.74.34.34.44 74.34.34.44.74
+ 34.34.44.74.64 34.44.74.64.14 44.74.64.14.34 74.64.14.34.84
+ 64.14.34.84.84 14.34.84.84.44 34.84.84.44.34 84.84.44.34.65
+ 84.44.34.65.35 44.34.65.35.85 34.65.35.85.85 65.35.85.85.55
+ 35.85.85.55.15 85.85.55.15.25 85.55.15.25.75 55.15.25.75.95
+ 15.25.75.95.65 25.75.95.65.65 75.95.65.65.35 95.65.65.35.5
+ 65.65.35.5.15 65.35.5.15.95 35.5.15.95.55 5.15.95.55.75
+ 15.95.55.75.85 95.55.75.85.75 55.75.85.75.15 75.85.75.15.95
+ 85.75.15.95.96 75.15.95.96.46 15.95.96.46.6 95.96.46.6.46
+ 96.46.6.46.16 46.6.46.16.16 6.46.16.16.86 46.16.16.86.56
+ 16.16.86.56.56 16.86.56.56.56 86.56.56.56.16 56.56.56.16.36
+ 56.56.16.36.76 56.16.36.76.96 16.36.76.96.96 36.76.96.96.26
+ 76.96.96.26.26 96.96.26.26.36 96.26.26.36.66 26.26.36.66.36
+ 26.36.66.36.36 36.66.36.36.97 66.36.36.97.27 36.36.97.27.97
+ 36.97.27.97.67 97.27.97.67.77 27.97.67.77.47 97.67.77.47.7
+ 67.77.47.7.47 77.47.7.47.87 47.7.47.87.37 7.47.87.37.87
+ 47.87.37.87.77 87.37.87.77.7 37.87.77.7.57 87.77.7.57.47
+ 77.7.57.47.47 7.57.47.47.37 57.47.47.37.27 47.47.37.27.17
+ 47.37.27.17.7 37.27.17.7.38 27.17.7.38.68 17.7.38.68.78
+ 7.38.68.78.8 38.68.78.8.28 68.78.8.28.98 78.8.28.98.78
+ 8.28.98.78.58 28.98.78.58.98 98.78.58.98.8 78.58.98.8.88
+ 58.98.8.88.8 98.8.88.8.58 8.88.8.58.58 88.8.58.58.58 8.58.58.58.38
+ 58.58.58.38.89 58.58.38.89.59 58.38.89.59.39 38.89.59.39.99
+ 89.59.39.99.29 59.39.99.29.59 39.99.29.59.89 99.29.59.89.89
+ 29.59.89.89.29 59.89.89.29.9 89.89.29.9.79 89.29.9.79.49
+ 29.9.79.49.59 9.79.49.59.29 79.49.59.29.59 49.59.29.59.19
+ 59.29.59.19.39 29.59.19.39.9 59.19.39.9.9 19.39.9.9.99 39.9.9.99.69
+ 9.9.99.69.39 9.99.69.39 99.69.39 69.39 39}
+
+do_execsql_test 1.12.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.12.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.12.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.12.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.12.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING)
+} {5 89.96.38 5 96.38 5 96.38.39 5 38.39 5 38.39.91 5 39.91
+ 5 39.91.6 5 91.6 5 91.6.97 5 6.97 5 6.97.46 5 97.46 5 97.46.54
+ 5 46.54 5 46.54.8 5 54.8 5 54.8.29 5 8.29 5 8.29.84 5 29.84
+ 5 29.84.23 5 84.23 5 84.23.16 5 23.16 5 23.16.65 5 16.65
+ 5 16.65.47 5 65.47 5 65.47.86 5 47.86 5 47.86.61 5 86.61
+ 5 86.61.85 5 61.85 5 61.85.85 5 85.85 5 85.85.59 5 85.59
+ 5 85.59.32 5 59.32 5 59.32.3 5 32.3 5 32.3.22 5 3.22 5 3.22.55
+ 5 22.55 5 22.55.28 5 55.28 5 55.28.25 5 28.25 5 28.25.1 5 25.1
+ 5 25.1.40 5 1.40 5 1.40.56 5 40.56 5 40.56.75 5 56.75
+ 5 56.75.89 5 75.89 5 75.89.76 5 89.76 5 89.76.4 5 76.4
+ 5 76.4.42 5 4.42 5 4.42.78 5 42.78 5 42.78.29 5 78.29
+ 5 78.29.63 5 29.63 5 29.63.87 5 63.87 5 63.87.80 5 87.80
+ 5 87.80.72 5 80.72 5 80.72.9 5 72.9 5 72.9.73 5 9.73 5 9.73.65
+ 5 73.65 5 73.65.58 5 65.58 5 65.58.98 5 58.98 5 58.98.21
+ 5 98.21 5 98.21.65 5 21.65 5 21.65.5 5 65.5 5 65.5.11 5 5.11
+ 5 5.11.87 5 11.87 5 11.87.12 5 87.12 5 87.12.20 5 12.20
+ 5 12.20.31 5 20.31 5 20.31.95 5 31.95 5 31.95.73 5 95.73
+ 5 95.73.88 5 73.88 5 73.88.8 5 88.8 5 88.8.49 5 8.49 5 8.49.90
+ 5 49.90 5 49.90.96 5 90.96 5 90.96.55 5 96.55 5 96.55.77
+ 5 55.77 5 55.77.2 5 77.2 5 77.2.85 5 2.85 5 2.85.74 5 85.74
+ 5 85.74.70 5 74.70 5 74.70.19 5 70.19 5 70.19.26 5 19.26
+ 5 19.26.47 5 26.47 5 26.47.90 5 47.90 5 47.90.58 5 90.58
+ 5 90.58.9 5 58.9 5 58.9.72 5 9.72 5 9.72.33 5 72.33 5 72.33.75
+ 5 33.75 5 33.75.81 5 75.81 5 75.81.23 5 81.23 5 81.23.13
+ 5 23.13 5 23.13.14 5 13.14 5 13.14.91 5 14.91 5 14.91.91
+ 5 91.91 5 91.91.15 5 91.15 5 91.15.36 5 15.36 5 15.36.3 5 36.3
+ 5 36.3.69 5 3.69 5 3.69.52 5 69.52 5 69.52.50 5 52.50
+ 5 52.50.10 5 50.10 5 50.10.33 5 10.33 5 10.33.39 5 33.39
+ 5 33.39.58 5 39.58 5 39.58.38 5 58.38 5 58.38.83 5 38.83
+ 5 38.83.82 5 83.82 5 83.82.7 4 82.7 3 82.7 2 7 1 7}
+
+do_execsql_test 1.12.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING)
+} {5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 4 {} 3 {} 2 {} 1 {}}
+
+do_execsql_test 1.12.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING)
+} {5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 4 {} 3 {} 2 {} 1 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 4 {} 3 {} 2 {} 1 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 4 {}
+ 3 {} 2 {} 1 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 4 {} 3 {} 2 {} 1 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 4 {} 3 {} 2 {} 1 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 4 {} 3 {}
+ 2 {} 1 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 4 {} 3 {} 2 {} 1 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 4 {} 3 {} 2 {} 1 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 4 {} 3 {} 2 {} 1 {}}
+
+do_execsql_test 1.12.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN CURRENT ROW AND 4 FOLLOWING)
+} {5 89.6.29.47.59 5 6.29.47.59.28 5 29.47.59.28.75 5 47.59.28.75.78
+ 5 59.28.75.78.72 5 28.75.78.72.98 5 75.78.72.98.87 5 78.72.98.87.73
+ 5 72.98.87.73.96 5 98.87.73.96.74 5 87.73.96.74.90 5 73.96.74.90.75
+ 5 96.74.90.75.91 5 74.90.75.91.69 5 90.75.91.69.39 5 75.91.69.39.7
+ 4 91.69.39.7 3 69.39.7 2 39.7 1 7 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 4 {}
+ 3 {} 2 {} 1 {} 5 96.97.84.86.32 5 97.84.86.32.25 5 84.86.32.25.89
+ 5 86.32.25.89.29 5 32.25.89.29.9 5 25.89.29.9.21 5 89.29.9.21.12
+ 5 29.9.21.12.88 5 9.21.12.88.55 5 21.12.88.55.70 5 12.88.55.70.58
+ 5 88.55.70.58.81 5 55.70.58.81.91 5 70.58.81.91.52 5 58.81.91.52.58
+ 4 81.91.52.58 3 91.52.58 2 52.58 1 58 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 4 {} 3 {} 2 {} 1 {} 5 38.46.23.61.3 5 46.23.61.3.1
+ 5 23.61.3.1.76 5 61.3.1.76.63 5 3.1.76.63.73 5 1.76.63.73.65
+ 5 76.63.73.65.20 5 63.73.65.20.8 5 73.65.20.8.77 5 65.20.8.77.19
+ 5 20.8.77.19.9 5 8.77.19.9.23 5 77.19.9.23.15 5 19.9.23.15.50
+ 5 9.23.15.50.38 4 23.15.50.38 3 15.50.38 2 50.38 1 38 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 4 {} 3 {} 2 {} 1 {} 5 39.54.16.85.22
+ 5 54.16.85.22.40 5 16.85.22.40.4 5 85.22.40.4.87 5 22.40.4.87.65
+ 5 40.4.87.65.5 5 4.87.65.5.31 5 87.65.5.31.49 5 65.5.31.49.2
+ 5 5.31.49.2.26 5 31.49.2.26.72 5 49.2.26.72.13 5 2.26.72.13.36
+ 5 26.72.13.36.10 5 72.13.36.10.83 4 13.36.10.83 3 36.10.83 2 10.83
+ 1 83 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 5 91.8.65.85.55 5 8.65.85.55.56 5 65.85.55.56.42 5 85.55.56.42.80
+ 5 55.56.42.80.58 5 56.42.80.58.11 5 42.80.58.11.95 5 80.58.11.95.90
+ 5 58.11.95.90.85 5 11.95.90.85.47 5 95.90.85.47.33 5 90.85.47.33.14
+ 5 85.47.33.14.3 5 47.33.14.3.33 5 33.14.3.33.82 4 14.3.33.82
+ 3 3.33.82 2 33.82 1 82 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {}
+ 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {}}
+
+do_execsql_test 1.13.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {96 68 68 68 91 91 91 99 99 99 97 78 78 97 97
+ 97 67 93 93 93 84 77 23 93 93 93 65 47 86 86
+ 86 91 91 91 85 85 85 59 59 56 56 91 91 91 90
+ 90 55 89 89 89 47 56 56 56 56 56 75 75 89 98
+ 98 98 81 94 94 94 78 78 78 53 63 63 87 87 87
+ 84 84 84 72 61 73 95 95 95 65 96 98 98 98 74
+ 74 74 65 73 73 73 87 87 87 41 20 31 31 31 95
+ 95 95 79 88 88 88 34 49 49 90 90 96 96 96 75
+ 77 77 77 44 85 85 85 74 74 70 70 59 39 39 47
+ 80 90 90 90 58 58 72 72 72 72 93 93 93 81 81
+ 81 37 37 37 14 62 91 91 91 91 91 34 36 99 99
+ 99 95 95 69 58 52 84 84 84 84 84 39 44 58 58
+ 58 38 83 83 83 82 82 17 7 {} {}}
+
+do_execsql_test 1.13.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {38 38 38 39 39 46 6 6 6 27 27 27 46 54 8 8
+ 8 29 29 77 23 16 16 16 16 35 35 7 7 7 61 61
+ 61 24 24 24 43 12 12 12 3 3 3 22 22 15 15 15
+ 25 25 1 1 1 40 40 16 16 16 36 36 76 76 4 4
+ 4 30 30 30 29 29 29 2 2 2 37 37 72 41 9 9 9
+ 61 65 13 13 13 58 1 1 1 21 35 5 5 5 11 11
+ 41 12 8 8 8 20 15 15 15 22 22 73 34 8 8 8
+ 11 34 34 59 59 55 55 55 44 2 2 2 7 57 29 29
+ 29 19 19 19 26 26 26 47 36 36 36 9 9 9 66 33
+ 33 33 64 64 9 9 9 13 12 12 12 14 36 36 33 15
+ 15 15 34 3 3 3 58 52 30 30 30 10 10 10 21 21
+ 21 39 30 30 30 34 27 27 17 7 7 7 {} {}}
+
+do_execsql_test 1.13.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.13.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.13.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.13.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.13.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.13.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.13.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.13.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.13.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.13.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.13.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.13.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.13.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.13.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.13.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.13.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.13.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.13.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.13.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {52 83 55 79 109 65 26 120 119 50 70 103 80 124
+ 36 96 59 124 116 110 57 51 52 130 103 74 87 48
+ 128 117 105 136 131 71 133 92 109 63 84 109 57
+ 146 78 147 113 74 88 150 87 110 65 121 106 110
+ 124 85 145 107 161 171 150 156 80 171 120 109 158
+ 114 111 136 147 87 173 124 168 173 162 132 101 154
+ 167 190 161 110 156 195 198 102 123 177 169 140 111
+ 180 119 160 197 152 124 121 134 146 147 132 213 141
+ 193 200 210 157 132 136 175 161 218 188 226 191 187
+ 208 211 179 138 144 223 196 214 170 212 202 163 184
+ 172 173 195 229 240 187 210 200 163 227 228 223 191
+ 252 235 225 243 172 187 202 179 179 182 231 261 207
+ 263 206 189 209 212 276 181 274 249 239 234 213 234
+ 269 196 271 221 210 229 235 250 223 232 229 279 224
+ 280 216 207 207 207 {} {}}
+
+do_execsql_test 1.13.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {134 218 191 212 229 240 213 234 196 223 223 223 {}
+ {} 146 65 156 132 154 102 123 119 160 152 146 147
+ 136 243 261 263 210 210 210 {} {} 120 87 162 124
+ 141 138 227 228 179 231 234 280 280 280 {} {} 57
+ 110 114 136 147 167 110 180 193 191 252 187 179 206
+ 181 221 279 279 279 {} {} 80 171 173 177 157 161
+ 179 214 225 182 209 269 271 235 229 229 229 {} {}
+ 113 74 87 145 190 161 169 140 111 132 213 187 208
+ 223 235 189 274 274 274 {} {} 51 52 128 109 121
+ 124 85 107 150 195 226 172 173 187 223 207 212 212
+ 212 {} {} 110 87 48 110 173 124 197 211 144 196
+ 195 200 202 224 216 207 207 207 {} {} 88 171 158
+ 156 198 121 210 132 210 239 250 232 232 232 {} {}
+ 59 109 150 161 111 101 200 175 188 170 202 163 184
+ 163 172 276 249 229 229 229 {} {}}
+
+do_execsql_test 1.13.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {57 181 80 111 26 48 144 207 36 121 132 101 163
+ 172 196 119 136 63 124 179 110 179 182 74 132 189
+ 51 52 85 216 163 134 123 210 78 141 57 187 71 87
+ 172 173 50 224 88 59 111 170 109 213 223 146 147
+ 84 114 191 206 221 157 161 209 229 74 140 107 187
+ 207 212 124 202 52 232 55 184 229 106 132 152 120
+ 92 110 179 235 65 70 87 110 195 200 175 234 160
+ 234 136 80 113 187 109 121 124 196 156 210 239 250
+ 72 109 188 202 191 105 154 79 231 147 225 103 161
+ 169 223 96 83 249 212 162 227 228 167 180 193 117
+ 177 214 145 208 235 150 110 211 103 158 200 168 229
+ 92 156 243 280 279 116 173 269 271 131 133 223 128
+ 173 197 210 99 150 161 147 218 240 109 136 146 261
+ 263 124 130 252 171 190 213 274 108 195 226 119 124
+ 171 198 120 276 276 276 {} {}}
+
+do_execsql_test 1.13.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {223 106 234 191 212 168 229 147 218 240 240 240 {}
+ {} 123 210 146 147 132 152 160 105 154 92 156 243
+ 109 136 146 261 263 263 263 {} {} 179 78 141 84
+ 120 234 79 231 162 227 228 280 280 280 {} {} 57
+ 187 114 191 206 221 92 110 136 147 167 180 193 279
+ 124 130 252 252 252 {} {} 161 209 229 179 235 80
+ 225 117 177 214 116 173 269 271 171 171 171 {} {}
+ 87 74 140 113 187 103 161 169 145 208 235 131 133
+ 223 190 213 274 274 274 {} {} 172 173 107 187 207
+ 212 65 70 109 121 124 223 150 128 108 195 226 226
+ 226 {} {} 50 224 124 202 87 110 195 200 196 96
+ 110 211 173 197 119 124 124 124 {} {} 52 232 156
+ 210 239 250 83 103 158 210 171 198 198 198 {} {}
+ 59 111 170 55 184 229 175 72 109 188 202 249 200
+ 99 150 161 120 276 276 276 {} {}}
+
+do_execsql_test 1.13.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {134 218 191 212 229 240 213 234 196 223 92 109 105
+ 136 146 65 156 132 154 102 123 119 160 152 146 147
+ 136 243 261 263 210 79 63 84 78 120 87 162 124
+ 141 138 227 228 179 231 234 280 124 57 130 92 57
+ 110 114 136 147 167 110 180 193 191 252 187 179 206
+ 181 221 279 80 116 117 71 80 171 173 177 157 161
+ 179 214 225 182 209 269 271 235 229 103 74 131 133
+ 113 74 87 145 190 161 169 140 111 132 213 187 208
+ 223 235 189 274 108 65 26 70 51 52 128 109 121
+ 124 85 107 150 195 226 172 173 187 223 207 212 119
+ 50 124 96 110 87 48 110 173 124 197 211 144 196
+ 195 200 202 224 216 207 52 83 103 36 88 171 158
+ 156 198 121 210 132 210 239 250 232 99 72 55 120
+ 59 109 150 161 111 101 200 175 188 170 202 163 184
+ 163 172 276 249 229 229 229 {} {}}
+
+do_execsql_test 1.13.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 43 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 84 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 65 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 74 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 51 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 2 {} {} {} 62
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {2 3 4 5 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} 11
+ 21 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 22 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 51 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 2 {} {} {} 62
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {96 59 38 68 39 62 91 46 6 99 97 27 46 78 54
+ 97 8 67 29 93 84 77 23 16 16 93 65 35 47 7 86
+ 74 61 91 85 24 85 43 59 12 32 56 3 91 22 90
+ 55 15 28 89 25 47 1 56 40 43 56 16 75 36 89
+ 98 76 81 4 94 42 30 78 33 29 53 63 2 87 37 80
+ 84 72 41 9 61 73 95 65 13 58 96 98 1 21 74 65
+ 35 5 73 11 51 87 41 12 8 20 31 31 15 95 22 73
+ 79 88 34 8 11 49 34 90 59 96 60 55 75 77 44 2
+ 7 85 57 74 29 70 59 19 39 26 26 47 80 90 36
+ 58 47 9 72 72 66 33 93 75 64 81 9 23 37 13 12
+ 14 62 91 36 91 33 15 34 36 99 3 95 69 58 52
+ 30 50 84 10 84 33 21 39 44 58 30 38 34 83 27
+ 82 17 7 {} {}}
+
+do_execsql_test 1.13.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {30 80 20 90 60 70 80 90 30 50 10 30 {} {} 61
+ 91 91 1 81 41 61 1 21 11 51 41 31 31 11 81 91
+ 91 21 {} {} 32 22 42 2 72 12 22 2 72 72 12 62
+ 52 82 {} {} 93 43 3 43 33 53 63 73 13 73 73
+ 33 93 23 13 33 3 33 83 {} {} 74 24 4 94 84 74
+ 34 34 44 74 64 14 34 84 84 44 34 {} {} 85 85
+ 55 15 25 75 95 65 65 35 5 15 95 55 75 85 75
+ 15 95 {} {} 6 46 16 16 86 56 56 56 16 36 76
+ 96 96 26 26 36 66 36 36 {} {} 97 67 77 47 7
+ 47 87 37 87 77 7 57 47 47 37 27 17 7 {} {} 78
+ 8 28 98 78 58 98 8 88 8 58 58 58 38 {} {} 39
+ 99 29 59 89 89 29 9 79 49 59 29 59 19 39 9 9
+ 99 69 39 {} {}}
+
+do_execsql_test 1.13.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10 11
+ 11 12 12 12 13 13 14 15 15 15 16 16 16 17 19
+ 20 21 21 22 22 23 23 24 25 26 26 27 27 28 29
+ 29 29 30 30 30 31 31 32 33 33 33 33 34 34 34
+ 34 35 35 36 36 36 36 37 37 38 38 39 39 39 40
+ 41 41 42 43 43 44 44 46 46 47 47 47 47 49 50
+ 51 52 53 54 55 55 56 56 56 57 58 58 58 58 59
+ 59 59 59 60 61 61 62 62 63 64 65 65 65 66 67
+ 68 69 70 72 72 72 73 73 73 74 74 74 75 75 75
+ 76 77 77 78 78 79 80 80 81 81 81 82 83 84 84
+ 84 84 85 85 85 86 87 87 88 89 89 89 90 90 90
+ 91 91 91 91 91 93 93 93 94 95 95 95 96 96 96
+ 97 97 98 98 99 99 {} {}}
+
+do_execsql_test 1.13.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {30 30 30 40 50 60 70 80 80 90 90 90 {} {} 11
+ 11 21 21 31 31 41 41 51 61 61 81 81 81 91 91
+ 91 91 91 {} {} 12 12 12 22 22 32 42 52 62 62
+ 72 72 72 82 {} {} 13 13 23 23 33 33 33 33 43
+ 43 53 63 73 73 73 83 93 93 93 {} {} 24 34 34
+ 34 34 44 44 54 64 74 74 74 84 84 84 84 94 {}
+ {} 15 15 25 35 35 55 55 65 65 65 75 75 75 85
+ 85 85 95 95 95 {} {} 16 16 26 26 36 36 36 36
+ 46 46 56 56 56 66 76 86 96 96 96 {} {} 7 17
+ 27 27 37 37 47 47 47 47 57 67 77 77 87 87 97
+ 97 {} {} 8 28 38 38 58 58 58 58 68 78 78 88
+ 98 98 {} {} 9 19 29 29 29 39 39 39 49 59 59
+ 59 59 69 79 89 89 89 99 99 {} {}}
+
+do_execsql_test 1.13.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {30 80 20 90 60 70 80 90 30 50 10 30 81 91 61
+ 91 91 1 81 41 61 1 21 11 51 41 31 31 11 81 91
+ 91 21 62 12 32 22 42 2 72 12 22 2 72 72 12 62
+ 52 82 93 23 93 43 3 43 33 53 63 73 13 73 73
+ 33 93 23 13 33 3 33 83 54 84 74 24 4 94 84 74
+ 34 34 44 74 64 14 34 84 84 44 34 65 35 85 85
+ 55 15 25 75 95 65 65 35 5 15 95 55 75 85 75
+ 15 95 96 46 6 46 16 16 86 56 56 56 16 36 76
+ 96 96 26 26 36 66 36 36 97 27 97 67 77 47 7
+ 47 87 37 87 77 7 57 47 47 37 27 17 7 38 68 78
+ 8 28 98 78 58 98 8 88 8 58 58 58 38 89 59 39
+ 99 29 59 89 89 29 9 79 49 59 29 59 19 39 9 9
+ 99 69 39 {} {}}
+
+do_execsql_test 1.13.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.13.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.13.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.13.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.13.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.13.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {96.59.38 59.38.68 38.68.39 68.39.62 39.62.91 62.91.46 91.46.6
+ 46.6.99 6.99.97 99.97.27 97.27.46 27.46.78 46.78.54 78.54.97
+ 54.97.8 97.8.67 8.67.29 67.29.93 29.93.84 93.84.77 84.77.23
+ 77.23.16 23.16.16 16.16.93 16.93.65 93.65.35 65.35.47 35.47.7
+ 47.7.86 7.86.74 86.74.61 74.61.91 61.91.85 91.85.24 85.24.85
+ 24.85.43 85.43.59 43.59.12 59.12.32 12.32.56 32.56.3 56.3.91
+ 3.91.22 91.22.90 22.90.55 90.55.15 55.15.28 15.28.89 28.89.25
+ 89.25.47 25.47.1 47.1.56 1.56.40 56.40.43 40.43.56 43.56.16
+ 56.16.75 16.75.36 75.36.89 36.89.98 89.98.76 98.76.81 76.81.4
+ 81.4.94 4.94.42 94.42.30 42.30.78 30.78.33 78.33.29 33.29.53
+ 29.53.63 53.63.2 63.2.87 2.87.37 87.37.80 37.80.84 80.84.72
+ 84.72.41 72.41.9 41.9.61 9.61.73 61.73.95 73.95.65 95.65.13
+ 65.13.58 13.58.96 58.96.98 96.98.1 98.1.21 1.21.74 21.74.65
+ 74.65.35 65.35.5 35.5.73 5.73.11 73.11.51 11.51.87 51.87.41
+ 87.41.12 41.12.8 12.8.20 8.20.31 20.31.31 31.31.15 31.15.95
+ 15.95.22 95.22.73 22.73.79 73.79.88 79.88.34 88.34.8 34.8.11
+ 8.11.49 11.49.34 49.34.90 34.90.59 90.59.96 59.96.60 96.60.55
+ 60.55.75 55.75.77 75.77.44 77.44.2 44.2.7 2.7.85 7.85.57
+ 85.57.74 57.74.29 74.29.70 29.70.59 70.59.19 59.19.39 19.39.26
+ 39.26.26 26.26.47 26.47.80 47.80.90 80.90.36 90.36.58 36.58.47
+ 58.47.9 47.9.72 9.72.72 72.72.66 72.66.33 66.33.93 33.93.75
+ 93.75.64 75.64.81 64.81.9 81.9.23 9.23.37 23.37.13 37.13.12
+ 13.12.14 12.14.62 14.62.91 62.91.36 91.36.91 36.91.33 91.33.15
+ 33.15.34 15.34.36 34.36.99 36.99.3 99.3.95 3.95.69 95.69.58
+ 69.58.52 58.52.30 52.30.50 30.50.84 50.84.10 84.10.84 10.84.33
+ 84.33.21 33.21.39 21.39.44 39.44.58 44.58.30 58.30.38 30.38.34
+ 38.34.83 34.83.27 83.27.82 27.82.17 82.17.7 17.7 7 {} {}}
+
+do_execsql_test 1.13.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {30.80.20 80.20.90 20.90.60 90.60.70 60.70.80 70.80.90 80.90.30
+ 90.30.50 30.50.10 50.10.30 10.30 30 {} {} 61.91.91 91.91.1
+ 91.1.81 1.81.41 81.41.61 41.61.1 61.1.21 1.21.11 21.11.51
+ 11.51.41 51.41.31 41.31.31 31.31.11 31.11.81 11.81.91 81.91.91
+ 91.91.21 91.21 21 {} {} 32.22.42 22.42.2 42.2.72 2.72.12
+ 72.12.22 12.22.2 22.2.72 2.72.72 72.72.12 72.12.62 12.62.52
+ 62.52.82 52.82 82 {} {} 93.43.3 43.3.43 3.43.33 43.33.53
+ 33.53.63 53.63.73 63.73.13 73.13.73 13.73.73 73.73.33 73.33.93
+ 33.93.23 93.23.13 23.13.33 13.33.3 33.3.33 3.33.83 33.83 83
+ {} {} 74.24.4 24.4.94 4.94.84 94.84.74 84.74.34 74.34.34
+ 34.34.44 34.44.74 44.74.64 74.64.14 64.14.34 14.34.84 34.84.84
+ 84.84.44 84.44.34 44.34 34 {} {} 85.85.55 85.55.15 55.15.25
+ 15.25.75 25.75.95 75.95.65 95.65.65 65.65.35 65.35.5 35.5.15
+ 5.15.95 15.95.55 95.55.75 55.75.85 75.85.75 85.75.15 75.15.95
+ 15.95 95 {} {} 6.46.16 46.16.16 16.16.86 16.86.56 86.56.56
+ 56.56.56 56.56.16 56.16.36 16.36.76 36.76.96 76.96.96 96.96.26
+ 96.26.26 26.26.36 26.36.66 36.66.36 66.36.36 36.36 36 {} {}
+ 97.67.77 67.77.47 77.47.7 47.7.47 7.47.87 47.87.37 87.37.87
+ 37.87.77 87.77.7 77.7.57 7.57.47 57.47.47 47.47.37 47.37.27
+ 37.27.17 27.17.7 17.7 7 {} {} 78.8.28 8.28.98 28.98.78
+ 98.78.58 78.58.98 58.98.8 98.8.88 8.88.8 88.8.58 8.58.58
+ 58.58.58 58.58.38 58.38 38 {} {} 39.99.29 99.29.59 29.59.89
+ 59.89.89 89.89.29 89.29.9 29.9.79 9.79.49 79.49.59 49.59.29
+ 59.29.59 29.59.19 59.19.39 19.39.9 39.9.9 9.9.99 9.99.69
+ 99.69.39 69.39 39 {} {}}
+
+do_execsql_test 1.13.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {2.2.3 2.3.3 3.3.4 3.4.5 4.5.6 5.6.7 6.7.7 7.7.7 7.7.8
+ 7.8.8 8.8.8 8.8.9 8.9.9 9.9.9 9.9.10 9.10.11 10.11.11
+ 11.11.12 11.12.12 12.12.12 12.12.13 12.13.13 13.13.14 13.14.15
+ 14.15.15 15.15.15 15.15.16 15.16.16 16.16.16 16.16.17 16.17.19
+ 17.19.20 19.20.21 20.21.21 21.21.22 21.22.22 22.22.23 22.23.23
+ 23.23.24 23.24.25 24.25.26 25.26.26 26.26.27 26.27.27 27.27.28
+ 27.28.29 28.29.29 29.29.29 29.29.30 29.30.30 30.30.30 30.30.31
+ 30.31.31 31.31.32 31.32.33 32.33.33 33.33.33 33.33.33 33.33.34
+ 33.34.34 34.34.34 34.34.34 34.34.35 34.35.35 35.35.36 35.36.36
+ 36.36.36 36.36.36 36.36.37 36.37.37 37.37.38 37.38.38 38.38.39
+ 38.39.39 39.39.39 39.39.40 39.40.41 40.41.41 41.41.42 41.42.43
+ 42.43.43 43.43.44 43.44.44 44.44.46 44.46.46 46.46.47 46.47.47
+ 47.47.47 47.47.47 47.47.49 47.49.50 49.50.51 50.51.52 51.52.53
+ 52.53.54 53.54.55 54.55.55 55.55.56 55.56.56 56.56.56 56.56.57
+ 56.57.58 57.58.58 58.58.58 58.58.58 58.58.59 58.59.59 59.59.59
+ 59.59.59 59.59.60 59.60.61 60.61.61 61.61.62 61.62.62 62.62.63
+ 62.63.64 63.64.65 64.65.65 65.65.65 65.65.66 65.66.67 66.67.68
+ 67.68.69 68.69.70 69.70.72 70.72.72 72.72.72 72.72.73 72.73.73
+ 73.73.73 73.73.74 73.74.74 74.74.74 74.74.75 74.75.75 75.75.75
+ 75.75.76 75.76.77 76.77.77 77.77.78 77.78.78 78.78.79 78.79.80
+ 79.80.80 80.80.81 80.81.81 81.81.81 81.81.82 81.82.83 82.83.84
+ 83.84.84 84.84.84 84.84.84 84.84.85 84.85.85 85.85.85 85.85.86
+ 85.86.87 86.87.87 87.87.88 87.88.89 88.89.89 89.89.89 89.89.90
+ 89.90.90 90.90.90 90.90.91 90.91.91 91.91.91 91.91.91 91.91.91
+ 91.91.93 91.93.93 93.93.93 93.93.94 93.94.95 94.95.95 95.95.95
+ 95.95.96 95.96.96 96.96.96 96.96.97 96.97.97 97.97.98 97.98.98
+ 98.98.99 98.99.99 99.99 99 {} {}}
+
+do_execsql_test 1.13.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {30.30.30 30.30.40 30.40.50 40.50.60 50.60.70 60.70.80 70.80.80
+ 80.80.90 80.90.90 90.90.90 90.90 90 {} {} 11.11.21 11.21.21
+ 21.21.31 21.31.31 31.31.41 31.41.41 41.41.51 41.51.61 51.61.61
+ 61.61.81 61.81.81 81.81.81 81.81.91 81.91.91 91.91.91 91.91.91
+ 91.91.91 91.91 91 {} {} 12.12.12 12.12.22 12.22.22 22.22.32
+ 22.32.42 32.42.52 42.52.62 52.62.62 62.62.72 62.72.72 72.72.72
+ 72.72.82 72.82 82 {} {} 13.13.23 13.23.23 23.23.33 23.33.33
+ 33.33.33 33.33.33 33.33.43 33.43.43 43.43.53 43.53.63 53.63.73
+ 63.73.73 73.73.73 73.73.83 73.83.93 83.93.93 93.93.93 93.93
+ 93 {} {} 24.34.34 34.34.34 34.34.34 34.34.44 34.44.44
+ 44.44.54 44.54.64 54.64.74 64.74.74 74.74.74 74.74.84 74.84.84
+ 84.84.84 84.84.84 84.84.94 84.94 94 {} {} 15.15.25 15.25.35
+ 25.35.35 35.35.55 35.55.55 55.55.65 55.65.65 65.65.65 65.65.75
+ 65.75.75 75.75.75 75.75.85 75.85.85 85.85.85 85.85.95 85.95.95
+ 95.95.95 95.95 95 {} {} 16.16.26 16.26.26 26.26.36 26.36.36
+ 36.36.36 36.36.36 36.36.46 36.46.46 46.46.56 46.56.56 56.56.56
+ 56.56.66 56.66.76 66.76.86 76.86.96 86.96.96 96.96.96 96.96
+ 96 {} {} 7.17.27 17.27.27 27.27.37 27.37.37 37.37.47
+ 37.47.47 47.47.47 47.47.47 47.47.57 47.57.67 57.67.77 67.77.77
+ 77.77.87 77.87.87 87.87.97 87.97.97 97.97 97 {} {} 8.28.38
+ 28.38.38 38.38.58 38.58.58 58.58.58 58.58.58 58.58.68 58.68.78
+ 68.78.78 78.78.88 78.88.98 88.98.98 98.98 98 {} {} 9.19.29
+ 19.29.29 29.29.29 29.29.39 29.39.39 39.39.39 39.39.49 39.49.59
+ 49.59.59 59.59.59 59.59.59 59.59.69 59.69.79 69.79.89 79.89.89
+ 89.89.89 89.89.99 89.99.99 99.99 99 {} {}}
+
+do_execsql_test 1.13.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING ) FROM t2
+} {30.80.20 80.20.90 20.90.60 90.60.70 60.70.80 70.80.90 80.90.30
+ 90.30.50 30.50.10 50.10.30 10.30.81 30.81.91 81.91.61 91.61.91
+ 61.91.91 91.91.1 91.1.81 1.81.41 81.41.61 41.61.1 61.1.21
+ 1.21.11 21.11.51 11.51.41 51.41.31 41.31.31 31.31.11 31.11.81
+ 11.81.91 81.91.91 91.91.21 91.21.62 21.62.12 62.12.32 12.32.22
+ 32.22.42 22.42.2 42.2.72 2.72.12 72.12.22 12.22.2 22.2.72
+ 2.72.72 72.72.12 72.12.62 12.62.52 62.52.82 52.82.93 82.93.23
+ 93.23.93 23.93.43 93.43.3 43.3.43 3.43.33 43.33.53 33.53.63
+ 53.63.73 63.73.13 73.13.73 13.73.73 73.73.33 73.33.93 33.93.23
+ 93.23.13 23.13.33 13.33.3 33.3.33 3.33.83 33.83.54 83.54.84
+ 54.84.74 84.74.24 74.24.4 24.4.94 4.94.84 94.84.74 84.74.34
+ 74.34.34 34.34.44 34.44.74 44.74.64 74.64.14 64.14.34 14.34.84
+ 34.84.84 84.84.44 84.44.34 44.34.65 34.65.35 65.35.85 35.85.85
+ 85.85.55 85.55.15 55.15.25 15.25.75 25.75.95 75.95.65 95.65.65
+ 65.65.35 65.35.5 35.5.15 5.15.95 15.95.55 95.55.75 55.75.85
+ 75.85.75 85.75.15 75.15.95 15.95.96 95.96.46 96.46.6 46.6.46
+ 6.46.16 46.16.16 16.16.86 16.86.56 86.56.56 56.56.56 56.56.16
+ 56.16.36 16.36.76 36.76.96 76.96.96 96.96.26 96.26.26 26.26.36
+ 26.36.66 36.66.36 66.36.36 36.36.97 36.97.27 97.27.97 27.97.67
+ 97.67.77 67.77.47 77.47.7 47.7.47 7.47.87 47.87.37 87.37.87
+ 37.87.77 87.77.7 77.7.57 7.57.47 57.47.47 47.47.37 47.37.27
+ 37.27.17 27.17.7 17.7.38 7.38.68 38.68.78 68.78.8 78.8.28
+ 8.28.98 28.98.78 98.78.58 78.58.98 58.98.8 98.8.88 8.88.8
+ 88.8.58 8.58.58 58.58.58 58.58.38 58.38.89 38.89.59 89.59.39
+ 59.39.99 39.99.29 99.29.59 29.59.89 59.89.89 89.89.29 89.29.9
+ 29.9.79 9.79.49 79.49.59 49.59.29 59.29.59 29.59.19 59.19.39
+ 19.39.9 39.9.9 9.9.99 9.99.69 99.69.39 69.39 39 {} {}}
+
+do_execsql_test 1.13.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.13.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING)
+} {3 96.38 3 38 3 38.39 3 39 3 39.91 3 91 3 91.6 3 6 3 6.97
+ 3 97 3 97.46 3 46 3 46.54 3 54 3 54.8 3 8 3 8.29 3 29
+ 3 29.84 3 84 3 84.23 3 23 3 23.16 3 16 3 16.65 3 65 3 65.47
+ 3 47 3 47.86 3 86 3 86.61 3 61 3 61.85 3 85 3 85.85 3 85
+ 3 85.59 3 59 3 59.32 3 32 3 32.3 3 3 3 3.22 3 22 3 22.55
+ 3 55 3 55.28 3 28 3 28.25 3 25 3 25.1 3 1 3 1.40 3 40
+ 3 40.56 3 56 3 56.75 3 75 3 75.89 3 89 3 89.76 3 76 3 76.4
+ 3 4 3 4.42 3 42 3 42.78 3 78 3 78.29 3 29 3 29.63 3 63
+ 3 63.87 3 87 3 87.80 3 80 3 80.72 3 72 3 72.9 3 9 3 9.73
+ 3 73 3 73.65 3 65 3 65.58 3 58 3 58.98 3 98 3 98.21 3 21
+ 3 21.65 3 65 3 65.5 3 5 3 5.11 3 11 3 11.87 3 87 3 87.12
+ 3 12 3 12.20 3 20 3 20.31 3 31 3 31.95 3 95 3 95.73 3 73
+ 3 73.88 3 88 3 88.8 3 8 3 8.49 3 49 3 49.90 3 90 3 90.96
+ 3 96 3 96.55 3 55 3 55.77 3 77 3 77.2 3 2 3 2.85 3 85
+ 3 85.74 3 74 3 74.70 3 70 3 70.19 3 19 3 19.26 3 26 3 26.47
+ 3 47 3 47.90 3 90 3 90.58 3 58 3 58.9 3 9 3 9.72 3 72
+ 3 72.33 3 33 3 33.75 3 75 3 75.81 3 81 3 81.23 3 23 3 23.13
+ 3 13 3 13.14 3 14 3 14.91 3 91 3 91.91 3 91 3 91.15 3 15
+ 3 15.36 3 36 3 36.3 3 3 3 3.69 3 69 3 69.52 3 52 3 52.50
+ 3 50 3 50.10 3 10 3 10.33 3 33 3 33.39 3 39 3 39.58 3 58
+ 3 58.38 3 38 3 38.83 3 83 3 83.82 3 82 3 82.7 2 7 1 7
+ 0 {} 0 {}}
+
+do_execsql_test 1.13.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING)
+} {3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 2 {} 1 {} 0 {} 0 {}}
+
+do_execsql_test 1.13.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING)
+} {3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 2 {} 1 {} 0 {} 0 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 2 {} 1 {} 0 {} 0 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 2 {}
+ 1 {} 0 {} 0 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 2 {} 1 {} 0 {} 0 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 2 {} 1 {} 0 {} 0 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 2 {} 1 {} 0 {} 0 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 2 {} 1 {}
+ 0 {} 0 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 2 {} 1 {} 0 {} 0 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 2 {} 1 {} 0 {} 0 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 2 {} 1 {} 0 {} 0 {}}
+
+do_execsql_test 1.13.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 4 FOLLOWING)
+} {3 29.47.59 3 47.59.28 3 59.28.75 3 28.75.78 3 75.78.72 3 78.72.98
+ 3 72.98.87 3 98.87.73 3 87.73.96 3 73.96.74 3 96.74.90 3 74.90.75
+ 3 90.75.91 3 75.91.69 3 91.69.39 3 69.39.7 2 39.7 1 7 0 {}
+ 0 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 2 {} 1 {} 0 {} 0 {} 3 84.86.32
+ 3 86.32.25 3 32.25.89 3 25.89.29 3 89.29.9 3 29.9.21 3 9.21.12
+ 3 21.12.88 3 12.88.55 3 88.55.70 3 55.70.58 3 70.58.81 3 58.81.91
+ 3 81.91.52 3 91.52.58 2 52.58 1 58 0 {} 0 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 2 {} 1 {} 0 {} 0 {} 3 23.61.3 3 61.3.1 3 3.1.76
+ 3 1.76.63 3 76.63.73 3 63.73.65 3 73.65.20 3 65.20.8 3 20.8.77
+ 3 8.77.19 3 77.19.9 3 19.9.23 3 9.23.15 3 23.15.50 3 15.50.38
+ 2 50.38 1 38 0 {} 0 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 2 {} 1 {}
+ 0 {} 0 {} 3 16.85.22 3 85.22.40 3 22.40.4 3 40.4.87 3 4.87.65
+ 3 87.65.5 3 65.5.31 3 5.31.49 3 31.49.2 3 49.2.26 3 2.26.72
+ 3 26.72.13 3 72.13.36 3 13.36.10 3 36.10.83 2 10.83 1 83 0 {}
+ 0 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 2 {} 1 {} 0 {} 0 {} 3 65.85.55
+ 3 85.55.56 3 55.56.42 3 56.42.80 3 42.80.58 3 80.58.11 3 58.11.95
+ 3 11.95.90 3 95.90.85 3 90.85.47 3 85.47.33 3 47.33.14 3 33.14.3
+ 3 14.3.33 3 3.33.82 2 33.82 1 82 0 {} 0 {} 3 {} 3 {} 3 {}
+ 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {} 3 {}
+ 3 {} 2 {} 1 {} 0 {} 0 {}}
+
+do_execsql_test 1.14.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99}
+
+do_execsql_test 1.14.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1}
+
+do_execsql_test 1.14.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.14.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.14.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.14.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.14.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.14.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.14.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.14.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.14.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.14.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.14.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.14.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.14.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.14.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.14.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.14.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.14.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.14.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.14.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207}
+
+do_execsql_test 1.14.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {223 223 223 223 223 223 223 223 223 223 223 223 223
+ 223 210 210 210 210 210 210 210 210 210 210 210 210
+ 210 210 210 210 210 210 210 210 210 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 279
+ 279 279 279 279 279 279 279 279 279 279 279 279 279
+ 279 279 279 279 279 279 279 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 212 212 212 212 212
+ 212 212 212 212 212 212 212 212 212 212 212 212 212
+ 212 212 212 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 232 232 232
+ 232 232 232 232 232 232 232 232 232 232 232 232 232
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.14.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.14.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {240 240 240 240 240 240 240 240 240 240 240 240 240
+ 240 263 263 263 263 263 263 263 263 263 263 263 263
+ 263 263 263 263 263 263 263 263 263 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 252
+ 252 252 252 252 252 252 252 252 252 252 252 252 252
+ 252 252 252 252 252 252 252 171 171 171 171 171 171
+ 171 171 171 171 171 171 171 171 171 171 171 171 171
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 226 226 226 226 226
+ 226 226 226 226 226 226 226 226 226 226 226 226 226
+ 226 226 226 124 124 124 124 124 124 124 124 124 124
+ 124 124 124 124 124 124 124 124 124 124 198 198 198
+ 198 198 198 198 198 198 198 198 198 198 198 198 198
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.14.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.14.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.14.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 41 5 16 85 42 43 89 1 22 39 51 73 93 22 80
+ 1 73 91 94 35 74 73 37 77 54 54 74 81 91 90
+ 62 65 63 36 1 95 23 95 56 16 97 86 40 59 1 84
+ 98 56 78 65 96 16 90 81 40 59 56 40 54 2 85
+ 96 11 87 41 38 65 32 47 80 74 35 47 98 96 13
+ 24 72 73 29 12 46 36 53 35 81 27 56 5 11 81
+ 93 63 81 91 68 53 99 89 13 12 97 91 29 7 7 78
+ 35 84 53 84 58 61 91 99 15 61 98 16 5 75 56 2
+ 37 3 96 62 95 43 63 35 78 16 67 43 16 16 90
+ 72 98 85 56 90 46 29 29 4 74 74 2 76 41 46 77
+ 24 27 97 46 89 1 85 1 74 78 61 85 51 59 35 30
+ 56 25 47 28 73 6 73 74 93 43 3 56 47 85 61 61
+ 93 9 97 62}
+
+do_execsql_test 1.14.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 91 {} 11 {} {} {} {}
+ 11 {} {} {} {} {} 12 {} {} {} 32 {} 12 {} 32
+ {} {} 12 {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} 33 {} {} {} {} {} 33 {} 43 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} 34 {} {} {} {}
+ {} {} {} {} {} {} 55 {} {} {} {} {} {} 15 55
+ {} {} {} {} {} 55 {} {} {} 86 {} 26 26 {} {}
+ {} {} 26 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 47 {} {} {} {} {} 47 {} {} {} {}
+ {} 27 47 {} {} {} 98 {} {} {} {} {} 98 {} 98
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} 99 {} 9 9 {} {} {}}
+
+do_execsql_test 1.14.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 2 2 3 3 4 5 5 5 6 6 6 7 7 7 7
+ 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9 11 11 12
+ 12 12 12 12 12 13 13 14 14 15 15 15 15 15 15
+ 16 16 16 16 16 16 17 17 17 17 19 19 19 19 20
+ 20 21 21 21 21 21 21 22 22 22 22 22 23 23 23
+ 24 25 25 26 26 27 27 27 27 27 27 29 29 29 30
+ 30 30 31 31 31 31 31 32 33 33 33 33 33 33 33
+ 33 33 33 33 34 34 34 34 34 34 34 35 35 36 36
+ 36 37 37 37 37 37 37 38 38 38 38 38 38 39 39
+ 39 39 39 40 41 41 41 41 41 42 43 43 43 43 43
+ 44 44 44 44 46 46 46 47 47 47 47 47 47 47 47
+ 47 47 47 49 49 49 50 51 51 51 52 52 52 53 53
+ 54 54 55 55}
+
+do_execsql_test 1.14.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1 1
+ 61 61 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 12 12 72 72 72 {} {} {} {} {} {}
+ {} {} {} {} {} 13 13 63 63 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} 34 84 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 35 85 85 85 {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 36 76 76 76 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 37 37 37
+ 87 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} 58 58 58 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 39 39 39 89 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.14.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 2 11 34 81 34 73 33 34 34 11 82 30 11 34
+ 65 13 65 65 40 34 72 13 40 41 50 93 72 81 81
+ 50 34 65 65 41 73 10 91 61 12 30 54 10 61 30
+ 54 54 10 73 23 44 85 1 85 22 80 22 91 93 73
+ 84 30 84 84 91 85 1 30 91 80 91 74 43 64 74
+ 21 20 85 64 74 21 21 2 74 33 81 21 64 64 2 21
+ 93 62 14 14 3 91 11 24 55 93 93 62 90 91 55 3
+ 24 14 24 91 55 15 72 60 72 61 61 34 43 43 43
+ 61 12 4 15 15 51 51 12 23 12 12 25 41 25 13
+ 94 12 70 12 84 32 84 94 70 33 12 12 32 41 91
+ 70 22 33 84 80 31 75 84 53 75 80 84 80 53 53
+ 53 22 44 63 42 95 31 63 44 44 31 90 74 52 63
+ 31 63 1 42 90 90 95 3 42}
+
+do_execsql_test 1.14.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.14.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.14.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 81
+ 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81
+ 81 81 81 81 81 62 62 62 62 62 62 62 62 62 62
+ 62 62 62 62 62 62 93 93 93 93 93 93 93 93 93
+ 93 93 93 93 93 93 93 93 93 93 93 93 54 54 54
+ 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
+ 54 65 65 65 65 65 65 65 65 65 65 65 65 65 65
+ 65 65 65 65 65 65 65 96 96 96 96 96 96 96 96
+ 96 96 96 96 96 96 96 96 96 96 96 96 96 97 97
+ 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97
+ 97 97 97 38 38 38 38 38 38 38 38 38 38 38 38
+ 38 38 38 38 89 89 89 89 89 89 89 89 89 89 89
+ 89 89 89 89 89 89 89 89 89 89 89}
+
+do_execsql_test 1.14.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1}
+
+do_execsql_test 1.14.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
+ 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
+ 9 9 9 9}
+
+do_execsql_test 1.14.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
+ 90 90 90 90 90 90 90 90 90 90 90}
+
+do_execsql_test 1.14.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.14.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.14.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.14.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.14.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.14.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.14.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.14.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.14.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.14.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.14.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.14.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.14.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.14.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7}
+
+do_execsql_test 1.14.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.14.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99}
+
+do_execsql_test 1.14.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99}
+
+do_execsql_test 1.14.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39}
+
+do_execsql_test 1.14.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.14.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.14.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.14.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.14.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+} {191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7}
+
+do_execsql_test 1.14.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+} {191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}
+ 191 {} 191 {} 191 {} 191 {} 191 {} 191 {} 191 {}}
+
+do_execsql_test 1.14.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+} {20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {}
+ 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {} 20 {}
+ 20 {} 20 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {}}
+
+do_execsql_test 1.14.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+} {20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}
+ 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {} 19 {}}
+
+do_execsql_test 1.15.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 95 95 84 84 84 84 84 84
+ 84 84 83 83 83 83 83 83 83 83 83}
+
+do_execsql_test 1.15.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 7}
+
+do_execsql_test 1.15.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.15.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.15.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.15.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.15.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.15.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.15.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.15.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.15.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.15.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.15.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.15.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.15.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.15.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.15.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.15.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.15.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.15.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.15.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207}
+
+do_execsql_test 1.15.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {223 223 223 223 223 223 223 223 223 223 223 223 223
+ 223 210 210 210 210 210 210 210 210 210 210 210 210
+ 210 210 210 210 210 210 210 210 210 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 279
+ 279 279 279 279 279 279 279 279 279 279 279 279 279
+ 279 279 279 279 279 279 279 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 212 212 212 212 212
+ 212 212 212 212 212 212 212 212 212 212 212 212 212
+ 212 212 212 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 232 232 232
+ 232 232 232 232 232 232 232 232 232 232 232 232 232
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.15.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.15.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {240 240 240 240 240 240 240 240 240 240 240 240 240
+ 240 263 263 263 263 263 263 263 263 263 263 263 263
+ 263 263 263 263 263 263 263 263 263 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 252
+ 252 252 252 252 252 252 252 252 252 252 252 252 252
+ 252 252 252 252 252 252 252 171 171 171 171 171 171
+ 171 171 171 171 171 171 171 171 171 171 171 171 171
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 226 226 226 226 226
+ 226 226 226 226 226 226 226 226 226 226 226 226 226
+ 226 226 226 124 124 124 124 124 124 124 124 124 124
+ 124 124 124 124 124 124 124 124 124 124 198 198 198
+ 198 198 198 198 198 198 198 198 198 198 198 198 198
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.15.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.15.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.15.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 41 5 16 85 30 12 81 35 89 97 31 31 85 40
+ 96 4 73 84 9 91 73 12 5 56 24 85 49 96 75 53
+ 61 8 8 1 55 34 43 59 80 35 15 78 35 56 70 76
+ 59 51 75 63 26 53 5 89 15 21 5 73 33 29 74 66
+ 12 26 58 4 12 31 35 9 87 73 55 59 53 62 73 23
+ 62 33 90 13 90 9 10 66 5 58 44 38 58 22 33 37
+ 2 73 36 31 72 30 47 73 15 96 70 59 90 {} 7 21
+ 83 {} 47 90 55 36 66 {} 50 {} 84 30 {} {} 34
+ 77 74 {} 58 {} 13 {} 82 93 69 14 62 44 {} {}
+ 30 {} 83 93 {} {} {} 84 {} {} {} {} 14 30 82
+ 34 34 3 {} {} {} {} {} 84 {} {} {} 99 {} {}
+ {} {} {} {} {} 58 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {}}
+
+do_execsql_test 1.15.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} 91 {} {} {} {}
+ {} {} {} {} {} {} 12 {} {} {} 22 {} 82 {} 12
+ {} {} {} {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} 33 {} {} {} {} {} {} {} 33 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 75 {} {} {} {} {} {} 15 {}
+ {} {} {} {} {} {} {} {} {} 86 {} 26 36 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 37 {} {} {} {} {} 47 {} {} {} {}
+ {} {} {} {} {} {} 98 {} {} {} {} {} 58 {} 38
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 59 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 2 3 4 6 7 8 8 8 9 9 10 11 12 12
+ 13 14 15 15 16 16 17 19 21 22 22 23 24 25 26
+ 27 29 29 30 30 31 32 33 33 34 34 35 35 36 36
+ 37 38 38 39 39 40 41 42 43 44 46 46 47 47 47
+ 49 50 51 53 54 55 56 56 56 58 58 58 59 59 59
+ 60 61 62 63 65 65 66 68 69 72 72 73 73 74 74
+ 75 76 77 78 80 81 81 82 84 84 84 85 85 86 87
+ 87 89 89 89 90 90 91 91 91 93 93 95 95 96 96
+ 97 98 99 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1 1
+ 61 61 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 12 12 72 72 72 {} {} {} {} {} {}
+ {} {} {} {} {} 13 13 63 63 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} 34 84 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 35 85 85 85 {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 36 76 76 76 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 37 37 37
+ 87 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} 58 58 58 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 39 39 39 89 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 2 11 34 81 65 73 84 64 55 12 33 91 42 65
+ 35 84 15 95 61 25 53 74 81 72 91 84 33 3 43
+ 32 85 56 56 93 85 2 93 43 94 22 75 82 13 12
+ 46 6 3 55 25 26 47 83 37 85 43 55 34 75 86 36
+ 33 36 36 85 68 14 4 25 33 95 27 16 38 77 55 4
+ 58 98 37 15 95 16 38 77 55 16 58 38 36 56 7
+ 36 59 89 57 75 86 89 39 98 8 97 15 46 {} 28 9
+ 69 49 56 {} {} 78 16 28 26 36 {} 39 99 29 27
+ 78 {} {} {} 37 27 98 {} 88 8 {} 28 {} {} {}
+ 59 37 59 {} 89 {} {} 47 {} 39 {} 29 29 8 78 9
+ {} {} 58 59 {} {} {} {} 58 {} 38 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 59 {} {} {} {} {}
+ {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {89 89 89 89 89 81 96 59 38 68 39 62 91 46 6
+ 99 97 27 46 78 54 97 8 67 29 93 84 77 23 16
+ 16 93 65 35 47 7 86 74 61 91 85 24 85 43 59
+ 12 32 56 3 91 22 90 55 15 28 89 25 47 1 56 40
+ 43 56 16 75 36 89 98 76 81 4 94 42 30 78 33
+ 29 53 63 2 87 37 80 84 72 41 9 61 73 95 65 13
+ 58 96 98 1 21 74 65 35 5 73 11 51 87 41 12 8
+ 20 31 31 15 95 22 73 79 88 34 8 11 49 34 90
+ 59 96 60 55 75 77 44 2 7 85 57 74 29 70 59 19
+ 39 26 26 47 80 90 36 58 47 9 72 72 66 33 93
+ 75 64 81 9 23 37 13 12 14 62 91 36 91 33 15
+ 34 36 99 3 95 69 58 52 30 50 84 10 84 33 21
+ 39 44 58 30 38 34 83}
+
+do_execsql_test 1.15.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {90 90 90 90 90 40 30 80 20 90 60 70 80 90 81
+ 81 81 81 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 62 62 62 62 62 12 32 22 42 2 72
+ 12 22 2 72 72 93 93 93 93 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 54 54 54 54 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 65
+ 65 65 65 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 96 96 96 96 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 97 97 97 97 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 38
+ 38 38 38 38 68 78 8 28 98 78 58 98 8 88 8 89
+ 89 89 89 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.15.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 2 2 3 3 4 5 6 7 7 7 8 8 8
+ 9 9 9 10 11 11 12 12 12 13 13 14 15 15 15 16
+ 16 16 17 19 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 30 30 30 31 31 32 33 33 33
+ 33 34 34 34 34 35 35 36 36 36 36 37 37 38 38
+ 39 39 39 40 41 41 42 43 43 44 44 46 46 47 47
+ 47 47 49 50 51 52 53 54 55 55 56 56 56 57 58
+ 58 58 58 59 59 59 59 60 61 61 62 62 63 64 65
+ 65 65 66 67 68 69 70 72 72 72 73 73 73 74 74
+ 74 75 75 75 76 77 77 78 78 79 80 80 81 81 81
+ 82 83 84 84 84 84 85 85 85 86 87 87 88 89 89
+ 89 90 90 90 91 91 91 91 91 93 93 93 94 95 95
+ 95 96 96 96 97 97}
+
+do_execsql_test 1.15.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {10 10 10 10 10 20 30 30 30 40 50 60 70 80 1 1
+ 1 1 1 1 11 11 21 21 31 31 41 41 51 61 61 81
+ 81 81 91 2 2 2 2 2 2 12 12 12 22 22 32 42
+ 52 62 62 3 3 3 3 3 3 13 13 23 23 33 33 33
+ 33 43 43 53 63 73 73 73 4 4 4 4 4 14 24 34
+ 34 34 34 44 44 54 64 74 74 74 84 5 5 5 5 5
+ 15 15 15 25 35 35 55 55 65 65 65 75 75 75 85
+ 85 6 6 6 6 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 7 7 7 7 7 7 7 17 27 27 37
+ 37 47 47 47 47 57 67 77 77 8 8 8 8 8 8 8 28
+ 38 38 58 58 58 58 68 78 9 9 9 9 9 9 9 19 29
+ 29 29 39 39 39 49 59 59 59 59 69 79 89}
+
+do_execsql_test 1.15.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {90 90 90 90 90 40 30 80 20 90 60 70 80 90 30
+ 50 10 30 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 81 91 91 21 62 12 32 22 42 2 72
+ 12 22 2 72 72 12 62 52 82 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 33 3 33 83 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 84
+ 84 44 34 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 85 75 15 95 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 36 66 36 36 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 37
+ 27 17 7 38 68 78 8 28 98 78 58 98 8 88 8 58
+ 58 58 38 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.15.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.15.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.15.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.15.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.15.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.15.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.15.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.15.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.21.39.44.58.30.38.34.83.27.82.17.7 21.39.44.58.30.38.34.83.27.82.17.7
+ 39.44.58.30.38.34.83.27.82.17.7 44.58.30.38.34.83.27.82.17.7
+ 58.30.38.34.83.27.82.17.7 30.38.34.83.27.82.17.7 38.34.83.27.82.17.7
+ 34.83.27.82.17.7 83.27.82.17.7}
+
+do_execsql_test 1.15.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 40.30.80.20.90.60.70.80.90.30.50.10.30
+ 30.80.20.90.60.70.80.90.30.50.10.30 80.20.90.60.70.80.90.30.50.10.30
+ 20.90.60.70.80.90.30.50.10.30 90.60.70.80.90.30.50.10.30
+ 60.70.80.90.30.50.10.30 70.80.90.30.50.10.30 80.90.30.50.10.30
+ 90.30.50.10.30
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.1.21.11.51.41.31.31.11.81.91.91.21 1.21.11.51.41.31.31.11.81.91.91.21
+ 21.11.51.41.31.31.11.81.91.91.21 11.51.41.31.31.11.81.91.91.21
+ 51.41.31.31.11.81.91.91.21 41.31.31.11.81.91.91.21 31.31.11.81.91.91.21
+ 31.11.81.91.91.21 11.81.91.91.21
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 22.42.2.72.12.22.2.72.72.12.62.52.82 42.2.72.12.22.2.72.72.12.62.52.82
+ 2.72.12.22.2.72.72.12.62.52.82 72.12.22.2.72.72.12.62.52.82
+ 12.22.2.72.72.12.62.52.82 22.2.72.72.12.62.52.82 2.72.72.12.62.52.82
+ 72.72.12.62.52.82 72.12.62.52.82
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 63.73.13.73.73.33.93.23.13.33.3.33.83 73.13.73.73.33.93.23.13.33.3.33.83
+ 13.73.73.33.93.23.13.33.3.33.83 73.73.33.93.23.13.33.3.33.83
+ 73.33.93.23.13.33.3.33.83 33.93.23.13.33.3.33.83 93.23.13.33.3.33.83
+ 23.13.33.3.33.83 13.33.3.33.83
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.34.34.44.74.64.14.34.84.84.44.34 34.34.44.74.64.14.34.84.84.44.34
+ 34.44.74.64.14.34.84.84.44.34 44.74.64.14.34.84.84.44.34
+ 74.64.14.34.84.84.44.34 64.14.34.84.84.44.34 14.34.84.84.44.34
+ 34.84.84.44.34
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 95.65.65.35.5.15.95.55.75.85.75.15.95 65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.5.15.95.55.75.85.75.15.95 35.5.15.95.55.75.85.75.15.95
+ 5.15.95.55.75.85.75.15.95 15.95.55.75.85.75.15.95 95.55.75.85.75.15.95
+ 55.75.85.75.15.95 75.85.75.15.95
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.16.36.76.96.96.26.26.36.66.36.36 16.36.76.96.96.26.26.36.66.36.36
+ 36.76.96.96.26.26.36.66.36.36 76.96.96.26.26.36.66.36.36
+ 96.96.26.26.36.66.36.36 96.26.26.36.66.36.36 26.26.36.66.36.36
+ 26.36.66.36.36 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.87.37.87.77.7.57.47.47.37.27.17.7 87.37.87.77.7.57.47.47.37.27.17.7
+ 37.87.77.7.57.47.47.37.27.17.7 87.77.7.57.47.47.37.27.17.7
+ 77.7.57.47.47.37.27.17.7 7.57.47.47.37.27.17.7 57.47.47.37.27.17.7
+ 47.47.37.27.17.7 47.37.27.17.7
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 8.28.98.78.58.98.8.88.8.58.58.58.38 28.98.78.58.98.8.88.8.58.58.58.38
+ 98.78.58.98.8.88.8.58.58.58.38 78.58.98.8.88.8.58.58.58.38
+ 58.98.8.88.8.58.58.58.38 98.8.88.8.58.58.58.38 8.88.8.58.58.58.38
+ 88.8.58.58.58.38 8.58.58.58.38
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39}
+
+do_execsql_test 1.15.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 94.95.95.95.96.96.96.97.97.98.98.99.99
+ 95.95.95.96.96.96.97.97.98.98.99.99 95.95.96.96.96.97.97.98.98.99.99
+ 95.96.96.96.97.97.98.98.99.99 96.96.96.97.97.98.98.99.99
+ 96.96.97.97.98.98.99.99 96.97.97.98.98.99.99 97.97.98.98.99.99
+ 97.98.98.99.99}
+
+do_execsql_test 1.15.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 20.30.30.30.40.50.60.70.80.80.90.90.90
+ 30.30.30.40.50.60.70.80.80.90.90.90 30.30.40.50.60.70.80.80.90.90.90
+ 30.40.50.60.70.80.80.90.90.90 40.50.60.70.80.80.90.90.90
+ 50.60.70.80.80.90.90.90 60.70.80.80.90.90.90 70.80.80.90.90.90
+ 80.80.90.90.90
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.51.61.61.81.81.81.91.91.91.91.91 51.61.61.81.81.81.91.91.91.91.91
+ 61.61.81.81.81.91.91.91.91.91 61.81.81.81.91.91.91.91.91
+ 81.81.81.91.91.91.91.91 81.81.91.91.91.91.91 81.91.91.91.91.91
+ 91.91.91.91.91 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.22.22.32.42.52.62.62.72.72.72.82 22.22.32.42.52.62.62.72.72.72.82
+ 22.32.42.52.62.62.72.72.72.82 32.42.52.62.62.72.72.72.82
+ 42.52.62.62.72.72.72.82 52.62.62.72.72.72.82 62.62.72.72.72.82
+ 62.72.72.72.82
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.43.43.53.63.73.73.73.83.93.93.93 43.43.53.63.73.73.73.83.93.93.93
+ 43.53.63.73.73.73.83.93.93.93 53.63.73.73.73.83.93.93.93
+ 63.73.73.73.83.93.93.93 73.73.73.83.93.93.93 73.73.83.93.93.93
+ 73.83.93.93.93 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.44.44.54.64.74.74.74.84.84.84.84.94
+ 44.44.54.64.74.74.74.84.84.84.84.94 44.54.64.74.74.74.84.84.84.84.94
+ 54.64.74.74.74.84.84.84.84.94 64.74.74.74.84.84.84.84.94
+ 74.74.74.84.84.84.84.94 74.74.84.84.84.84.94 74.84.84.84.84.94
+ 84.84.84.84.94
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.65.65.65.75.75.75.85.85.85.95.95.95
+ 65.65.65.75.75.75.85.85.85.95.95.95 65.65.75.75.75.85.85.85.95.95.95
+ 65.75.75.75.85.85.85.95.95.95 75.75.75.85.85.85.95.95.95
+ 75.75.85.85.85.95.95.95 75.85.85.85.95.95.95 85.85.85.95.95.95
+ 85.85.95.95.95
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.46.46.56.56.56.66.76.86.96.96.96 46.46.56.56.56.66.76.86.96.96.96
+ 46.56.56.56.66.76.86.96.96.96 56.56.56.66.76.86.96.96.96
+ 56.56.66.76.86.96.96.96 56.66.76.86.96.96.96 66.76.86.96.96.96
+ 76.86.96.96.96 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.47.47.47.47.57.67.77.77.87.87.97.97
+ 47.47.47.47.57.67.77.77.87.87.97.97 47.47.47.57.67.77.77.87.87.97.97
+ 47.47.57.67.77.77.87.87.97.97 47.57.67.77.77.87.87.97.97
+ 57.67.77.77.87.87.97.97 67.77.77.87.87.97.97 77.77.87.87.97.97
+ 77.87.87.97.97 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 28.38.38.58.58.58.58.68.78.78.88.98.98
+ 38.38.58.58.58.58.68.78.78.88.98.98 38.58.58.58.58.68.78.78.88.98.98
+ 58.58.58.58.68.78.78.88.98.98 58.58.58.68.78.78.88.98.98
+ 58.58.68.78.78.88.98.98 58.68.78.78.88.98.98 68.78.78.88.98.98
+ 78.78.88.98.98
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.49.59.59.59.59.69.79.89.89.89.99.99
+ 49.59.59.59.59.69.79.89.89.89.99.99 59.59.59.59.69.79.89.89.89.99.99
+ 59.59.59.69.79.89.89.89.99.99 59.59.69.79.89.89.89.99.99
+ 59.69.79.89.89.89.99.99 69.79.89.89.89.99.99 79.89.89.89.99.99
+ 89.89.89.99.99}
+
+do_execsql_test 1.15.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39}
+
+do_execsql_test 1.15.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.15.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.15.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.15.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.15.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING)
+} {191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 189 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 188 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 187 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 186 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 185 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 184 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 183 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 182 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 181 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 180 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 179 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 178 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 177 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 176 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 175 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 174 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 173 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 172 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 171 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 170 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 169 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 168 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 167 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 166 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 165 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 164 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 163 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 162 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 161 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 160 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 159 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 158 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 157 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 156 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 155 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 154 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 153 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 152 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 151 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 150 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 149 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 148 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 147 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 146 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 145 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 144 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 143 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 142 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 141 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 140 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 139 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 138 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 137 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 136 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 135 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 134 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 133 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 132 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 131 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 130 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 129 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 128 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 127 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 126 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 125 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 124 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 123 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 122 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 121 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 120 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 119 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 118 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 117 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 116 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 115 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 114 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 113 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 112 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 111 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 110 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 109 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 108 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 107 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 106 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 105 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 104 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 103 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 102 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 101 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 100 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 99 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 98 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 97 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 96 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 95 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 94 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 93 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 92 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 91 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 90 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 89 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 88 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 87 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 86 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 85 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 84 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 83 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 82 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 81 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 80 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 79 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 78 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 77 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 76 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 75 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 74 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 73 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 72 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 71 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 70 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 69 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 68 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 67 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 66 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 65 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 64 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 63 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 62 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 61 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 60 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 59 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 58 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 57 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 56 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 55 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 54 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 53 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 52 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 51 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 50 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 49 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 48 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 47 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 46 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 45 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 44 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 43 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 42 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 41 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 40 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 39 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 38 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 37 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 36 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 35 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 34 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 33 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 32 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 31 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 30 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 29 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 28 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 27 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 26 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 25 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 24 3.69.52.50.10.33.39.58.38.83.82.7 23 3.69.52.50.10.33.39.58.38.83.82.7
+ 22 69.52.50.10.33.39.58.38.83.82.7 21 69.52.50.10.33.39.58.38.83.82.7
+ 20 52.50.10.33.39.58.38.83.82.7 19 52.50.10.33.39.58.38.83.82.7
+ 18 50.10.33.39.58.38.83.82.7 17 50.10.33.39.58.38.83.82.7
+ 16 10.33.39.58.38.83.82.7 15 10.33.39.58.38.83.82.7
+ 14 33.39.58.38.83.82.7 13 33.39.58.38.83.82.7 12 39.58.38.83.82.7
+ 11 39.58.38.83.82.7 10 58.38.83.82.7 9 58.38.83.82.7 8 38.83.82.7
+ 7 38.83.82.7 6 83.82.7 5 83.82.7}
+
+do_execsql_test 1.15.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING)
+} {191 {} 191 {} 191 {} 191 {} 191 {} 190 {} 189 {} 188 {}
+ 187 {} 186 {} 185 {} 184 {} 183 {} 182 {} 181 {} 180 {}
+ 179 {} 178 {} 177 {} 176 {} 175 {} 174 {} 173 {} 172 {}
+ 171 {} 170 {} 169 {} 168 {} 167 {} 166 {} 165 {} 164 {}
+ 163 {} 162 {} 161 {} 160 {} 159 {} 158 {} 157 {} 156 {}
+ 155 {} 154 {} 153 {} 152 {} 151 {} 150 {} 149 {} 148 {}
+ 147 {} 146 {} 145 {} 144 {} 143 {} 142 {} 141 {} 140 {}
+ 139 {} 138 {} 137 {} 136 {} 135 {} 134 {} 133 {} 132 {}
+ 131 {} 130 {} 129 {} 128 {} 127 {} 126 {} 125 {} 124 {}
+ 123 {} 122 {} 121 {} 120 {} 119 {} 118 {} 117 {} 116 {}
+ 115 {} 114 {} 113 {} 112 {} 111 {} 110 {} 109 {} 108 {}
+ 107 {} 106 {} 105 {} 104 {} 103 {} 102 {} 101 {} 100 {}
+ 99 {} 98 {} 97 {} 96 {} 95 {} 94 {} 93 {} 92 {} 91 {}
+ 90 {} 89 {} 88 {} 87 {} 86 {} 85 {} 84 {} 83 {} 82 {}
+ 81 {} 80 {} 79 {} 78 {} 77 {} 76 {} 75 {} 74 {} 73 {}
+ 72 {} 71 {} 70 {} 69 {} 68 {} 67 {} 66 {} 65 {} 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 {}}
+
+do_execsql_test 1.15.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING)
+} {20 {} 20 {} 20 {} 20 {} 20 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {}}
+
+do_execsql_test 1.15.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING)
+} {20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 18 29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 17 47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 16 59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 15 28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 14 75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 13 78.72.98.87.73.96.74.90.75.91.69.39.7
+ 12 72.98.87.73.96.74.90.75.91.69.39.7 11 98.87.73.96.74.90.75.91.69.39.7
+ 10 87.73.96.74.90.75.91.69.39.7 9 73.96.74.90.75.91.69.39.7
+ 8 96.74.90.75.91.69.39.7 7 74.90.75.91.69.39.7 6 90.75.91.69.39.7
+ 5 75.91.69.39.7 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 17 84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 16 86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 15 32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 14 25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 13 89.29.9.21.12.88.55.70.58.81.91.52.58
+ 12 29.9.21.12.88.55.70.58.81.91.52.58 11 9.21.12.88.55.70.58.81.91.52.58
+ 10 21.12.88.55.70.58.81.91.52.58 9 12.88.55.70.58.81.91.52.58
+ 8 88.55.70.58.81.91.52.58 7 55.70.58.81.91.52.58 6 70.58.81.91.52.58
+ 5 58.81.91.52.58 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 17 23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 16 61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 15 3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 14 1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 13 76.63.73.65.20.8.77.19.9.23.15.50.38
+ 12 63.73.65.20.8.77.19.9.23.15.50.38 11 73.65.20.8.77.19.9.23.15.50.38
+ 10 65.20.8.77.19.9.23.15.50.38 9 20.8.77.19.9.23.15.50.38
+ 8 8.77.19.9.23.15.50.38 7 77.19.9.23.15.50.38 6 19.9.23.15.50.38
+ 5 9.23.15.50.38 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 17 16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 16 85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 15 22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 14 40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 13 4.87.65.5.31.49.2.26.72.13.36.10.83
+ 12 87.65.5.31.49.2.26.72.13.36.10.83 11 65.5.31.49.2.26.72.13.36.10.83
+ 10 5.31.49.2.26.72.13.36.10.83 9 31.49.2.26.72.13.36.10.83
+ 8 49.2.26.72.13.36.10.83 7 2.26.72.13.36.10.83 6 26.72.13.36.10.83
+ 5 72.13.36.10.83 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 17 65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 16 85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 15 55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 14 56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 13 42.80.58.11.95.90.85.47.33.14.3.33.82
+ 12 80.58.11.95.90.85.47.33.14.3.33.82 11 58.11.95.90.85.47.33.14.3.33.82
+ 10 11.95.90.85.47.33.14.3.33.82 9 95.90.85.47.33.14.3.33.82
+ 8 90.85.47.33.14.3.33.82 7 85.47.33.14.3.33.82 6 47.33.14.3.33.82
+ 5 33.14.3.33.82 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {}}
+
+do_execsql_test 1.16.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 95 95 84 84 84 84 84 84 84 84 83 83
+ 83 83 83 83 83 83 83 82 82 17 7}
+
+do_execsql_test 1.16.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 7}
+
+do_execsql_test 1.16.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.16.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.16.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.16.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.16.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.16.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.16.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.16.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.16.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.16.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.16.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.16.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.16.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.16.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.16.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.16.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.16.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.16.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.16.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207}
+
+do_execsql_test 1.16.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {223 223 223 223 223 223 223 223 223 223 223 223 223
+ 223 210 210 210 210 210 210 210 210 210 210 210 210
+ 210 210 210 210 210 210 210 210 210 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 279
+ 279 279 279 279 279 279 279 279 279 279 279 279 279
+ 279 279 279 279 279 279 279 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 212 212 212 212 212
+ 212 212 212 212 212 212 212 212 212 212 212 212 212
+ 212 212 212 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 232 232 232
+ 232 232 232 232 232 232 232 232 232 232 232 232 232
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.16.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.16.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {240 240 240 240 240 240 240 240 240 240 240 240 240
+ 240 263 263 263 263 263 263 263 263 263 263 263 263
+ 263 263 263 263 263 263 263 263 263 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 252
+ 252 252 252 252 252 252 252 252 252 252 252 252 252
+ 252 252 252 252 252 252 252 171 171 171 171 171 171
+ 171 171 171 171 171 171 171 171 171 171 171 171 171
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 226 226 226 226 226
+ 226 226 226 226 226 226 226 226 226 226 226 226 226
+ 226 226 226 124 124 124 124 124 124 124 124 124 124
+ 124 124 124 124 124 124 124 124 124 124 198 198 198
+ 198 198 198 198 198 198 198 198 198 198 198 198 198
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.16.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.16.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.16.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.16.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {89 81 96 59 38 68 39 62 91 46 6 99 97 27 46
+ 78 54 97 8 67 29 93 84 77 23 16 16 93 65 35
+ 47 7 86 74 61 91 85 24 85 43 59 12 32 56 3 91
+ 22 90 55 15 28 89 25 47 1 56 40 43 56 16 75
+ 36 89 98 76 81 4 94 42 30 78 33 29 53 63 2 87
+ 37 80 84 72 41 9 61 73 95 65 13 58 96 98 1 21
+ 74 65 35 5 73 11 51 87 41 12 8 20 31 31 15 95
+ 22 73 79 88 34 8 11 49 34 90 59 96 60 55 75
+ 77 44 2 7 85 57 74 29 70 59 19 39 26 26 47 80
+ 90 36 58 47 9 72 72 66 33 93 75 64 81 9 23 37
+ 13 12 14 62 91 36 91 33 15 34 36 99 3 95 69
+ 58 52 30 50 84 10 84 33 21 39 44 58 30 38 34
+ 83 27 82 17 7}
+
+do_execsql_test 1.16.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.16.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 19 20 21 21 22 22 23 23 24 25 26 26 27 27 28
+ 29 29 29 30 30 30 31 31 32 33 33 33 33 34 34
+ 34 34 35 35 36 36 36 36 37 37 38 38 39 39 39
+ 40 41 41 42 43 43 44 44 46 46 47 47 47 47 49
+ 50 51 52 53 54 55 55 56 56 56 57 58 58 58 58
+ 59 59 59 59 60 61 61 62 62 63 64 65 65 65 66
+ 67 68 69 70 72 72 72 73 73 73 74 74 74 75 75
+ 75 76 77 77 78 78 79 80 80 81 81 81 82 83 84
+ 84 84 84 85 85 85 86 87 87 88 89 89 89 90 90
+ 90 91 91 91 91 91 93 93 93 94 95 95 95 96 96
+ 96 97 97 98 98 99 99}
+
+do_execsql_test 1.16.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {10 20 30 30 30 40 50 60 70 80 80 90 90 90 1 1
+ 11 11 21 21 31 31 41 41 51 61 61 81 81 81 91
+ 91 91 91 91 2 2 12 12 12 22 22 32 42 52 62 62
+ 72 72 72 82 3 3 13 13 23 23 33 33 33 33 43 43
+ 53 63 73 73 73 83 93 93 93 4 14 24 34 34 34
+ 34 44 44 54 64 74 74 74 84 84 84 84 94 5 15
+ 15 15 25 35 35 55 55 65 65 65 75 75 75 85 85
+ 85 95 95 95 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 86 96 96 96 7 7 7 17 27 27
+ 37 37 47 47 47 47 57 67 77 77 87 87 97 97 8 8
+ 8 28 38 38 58 58 58 58 68 78 78 88 98 98 9 9
+ 9 19 29 29 29 39 39 39 49 59 59 59 59 69 79
+ 89 89 89 99 99}
+
+do_execsql_test 1.16.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {90 40 30 80 20 90 60 70 80 90 30 50 10 30 81
+ 91 61 91 91 1 81 41 61 1 21 11 51 41 31 31 11
+ 81 91 91 21 62 12 32 22 42 2 72 12 22 2 72 72
+ 12 62 52 82 93 23 93 43 3 43 33 53 63 73 13
+ 73 73 33 93 23 13 33 3 33 83 54 84 74 24 4 94
+ 84 74 34 34 44 74 64 14 34 84 84 44 34 65 35
+ 85 85 55 15 25 75 95 65 65 35 5 15 95 55 75
+ 85 75 15 95 96 46 6 46 16 16 86 56 56 56 16
+ 36 76 96 96 26 26 36 66 36 36 97 27 97 67 77
+ 47 7 47 87 37 87 77 7 57 47 47 37 27 17 7 38
+ 68 78 8 28 98 78 58 98 8 88 8 58 58 58 38 89
+ 59 39 99 29 59 89 89 29 9 79 49 59 29 59 19
+ 39 9 9 99 69 39}
+
+do_execsql_test 1.16.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.16.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.16.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.16.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.16.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.16.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.16.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.16.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.21.39.44.58.30.38.34.83.27.82.17.7 21.39.44.58.30.38.34.83.27.82.17.7
+ 39.44.58.30.38.34.83.27.82.17.7 44.58.30.38.34.83.27.82.17.7
+ 58.30.38.34.83.27.82.17.7 30.38.34.83.27.82.17.7 38.34.83.27.82.17.7
+ 34.83.27.82.17.7 83.27.82.17.7 27.82.17.7 82.17.7 17.7 7}
+
+do_execsql_test 1.16.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 40.30.80.20.90.60.70.80.90.30.50.10.30
+ 30.80.20.90.60.70.80.90.30.50.10.30 80.20.90.60.70.80.90.30.50.10.30
+ 20.90.60.70.80.90.30.50.10.30 90.60.70.80.90.30.50.10.30
+ 60.70.80.90.30.50.10.30 70.80.90.30.50.10.30 80.90.30.50.10.30
+ 90.30.50.10.30 30.50.10.30 50.10.30 10.30 30
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.1.21.11.51.41.31.31.11.81.91.91.21 1.21.11.51.41.31.31.11.81.91.91.21
+ 21.11.51.41.31.31.11.81.91.91.21 11.51.41.31.31.11.81.91.91.21
+ 51.41.31.31.11.81.91.91.21 41.31.31.11.81.91.91.21 31.31.11.81.91.91.21
+ 31.11.81.91.91.21 11.81.91.91.21 81.91.91.21 91.91.21 91.21 21
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 22.42.2.72.12.22.2.72.72.12.62.52.82 42.2.72.12.22.2.72.72.12.62.52.82
+ 2.72.12.22.2.72.72.12.62.52.82 72.12.22.2.72.72.12.62.52.82
+ 12.22.2.72.72.12.62.52.82 22.2.72.72.12.62.52.82 2.72.72.12.62.52.82
+ 72.72.12.62.52.82 72.12.62.52.82 12.62.52.82 62.52.82 52.82 82
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 63.73.13.73.73.33.93.23.13.33.3.33.83 73.13.73.73.33.93.23.13.33.3.33.83
+ 13.73.73.33.93.23.13.33.3.33.83 73.73.33.93.23.13.33.3.33.83
+ 73.33.93.23.13.33.3.33.83 33.93.23.13.33.3.33.83 93.23.13.33.3.33.83
+ 23.13.33.3.33.83 13.33.3.33.83 33.3.33.83 3.33.83 33.83 83
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.34.34.44.74.64.14.34.84.84.44.34 34.34.44.74.64.14.34.84.84.44.34
+ 34.44.74.64.14.34.84.84.44.34 44.74.64.14.34.84.84.44.34
+ 74.64.14.34.84.84.44.34 64.14.34.84.84.44.34 14.34.84.84.44.34
+ 34.84.84.44.34 84.84.44.34 84.44.34 44.34 34
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 95.65.65.35.5.15.95.55.75.85.75.15.95 65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.5.15.95.55.75.85.75.15.95 35.5.15.95.55.75.85.75.15.95
+ 5.15.95.55.75.85.75.15.95 15.95.55.75.85.75.15.95 95.55.75.85.75.15.95
+ 55.75.85.75.15.95 75.85.75.15.95 85.75.15.95 75.15.95 15.95 95
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.16.36.76.96.96.26.26.36.66.36.36 16.36.76.96.96.26.26.36.66.36.36
+ 36.76.96.96.26.26.36.66.36.36 76.96.96.26.26.36.66.36.36
+ 96.96.26.26.36.66.36.36 96.26.26.36.66.36.36 26.26.36.66.36.36
+ 26.36.66.36.36 36.66.36.36 66.36.36 36.36 36
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.87.37.87.77.7.57.47.47.37.27.17.7 87.37.87.77.7.57.47.47.37.27.17.7
+ 37.87.77.7.57.47.47.37.27.17.7 87.77.7.57.47.47.37.27.17.7
+ 77.7.57.47.47.37.27.17.7 7.57.47.47.37.27.17.7 57.47.47.37.27.17.7
+ 47.47.37.27.17.7 47.37.27.17.7 37.27.17.7 27.17.7 17.7 7
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 8.28.98.78.58.98.8.88.8.58.58.58.38 28.98.78.58.98.8.88.8.58.58.58.38
+ 98.78.58.98.8.88.8.58.58.58.38 78.58.98.8.88.8.58.58.58.38
+ 58.98.8.88.8.58.58.58.38 98.8.88.8.58.58.58.38 8.88.8.58.58.58.38
+ 88.8.58.58.58.38 8.58.58.58.38 58.58.58.38 58.58.38 58.38 38
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39 9.99.69.39 99.69.39 69.39 39}
+
+do_execsql_test 1.16.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 94.95.95.95.96.96.96.97.97.98.98.99.99
+ 95.95.95.96.96.96.97.97.98.98.99.99 95.95.96.96.96.97.97.98.98.99.99
+ 95.96.96.96.97.97.98.98.99.99 96.96.96.97.97.98.98.99.99
+ 96.96.97.97.98.98.99.99 96.97.97.98.98.99.99 97.97.98.98.99.99
+ 97.98.98.99.99 98.98.99.99 98.99.99 99.99 99}
+
+do_execsql_test 1.16.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 20.30.30.30.40.50.60.70.80.80.90.90.90
+ 30.30.30.40.50.60.70.80.80.90.90.90 30.30.40.50.60.70.80.80.90.90.90
+ 30.40.50.60.70.80.80.90.90.90 40.50.60.70.80.80.90.90.90
+ 50.60.70.80.80.90.90.90 60.70.80.80.90.90.90 70.80.80.90.90.90
+ 80.80.90.90.90 80.90.90.90 90.90.90 90.90 90
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.51.61.61.81.81.81.91.91.91.91.91 51.61.61.81.81.81.91.91.91.91.91
+ 61.61.81.81.81.91.91.91.91.91 61.81.81.81.91.91.91.91.91
+ 81.81.81.91.91.91.91.91 81.81.91.91.91.91.91 81.91.91.91.91.91
+ 91.91.91.91.91 91.91.91.91 91.91.91 91.91 91
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.22.22.32.42.52.62.62.72.72.72.82 22.22.32.42.52.62.62.72.72.72.82
+ 22.32.42.52.62.62.72.72.72.82 32.42.52.62.62.72.72.72.82
+ 42.52.62.62.72.72.72.82 52.62.62.72.72.72.82 62.62.72.72.72.82
+ 62.72.72.72.82 72.72.72.82 72.72.82 72.82 82
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.43.43.53.63.73.73.73.83.93.93.93 43.43.53.63.73.73.73.83.93.93.93
+ 43.53.63.73.73.73.83.93.93.93 53.63.73.73.73.83.93.93.93
+ 63.73.73.73.83.93.93.93 73.73.73.83.93.93.93 73.73.83.93.93.93
+ 73.83.93.93.93 83.93.93.93 93.93.93 93.93 93
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.44.44.54.64.74.74.74.84.84.84.84.94
+ 44.44.54.64.74.74.74.84.84.84.84.94 44.54.64.74.74.74.84.84.84.84.94
+ 54.64.74.74.74.84.84.84.84.94 64.74.74.74.84.84.84.84.94
+ 74.74.74.84.84.84.84.94 74.74.84.84.84.84.94 74.84.84.84.84.94
+ 84.84.84.84.94 84.84.84.94 84.84.94 84.94 94
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.65.65.65.75.75.75.85.85.85.95.95.95
+ 65.65.65.75.75.75.85.85.85.95.95.95 65.65.75.75.75.85.85.85.95.95.95
+ 65.75.75.75.85.85.85.95.95.95 75.75.75.85.85.85.95.95.95
+ 75.75.85.85.85.95.95.95 75.85.85.85.95.95.95 85.85.85.95.95.95
+ 85.85.95.95.95 85.95.95.95 95.95.95 95.95 95
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.46.46.56.56.56.66.76.86.96.96.96 46.46.56.56.56.66.76.86.96.96.96
+ 46.56.56.56.66.76.86.96.96.96 56.56.56.66.76.86.96.96.96
+ 56.56.66.76.86.96.96.96 56.66.76.86.96.96.96 66.76.86.96.96.96
+ 76.86.96.96.96 86.96.96.96 96.96.96 96.96 96
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.47.47.47.47.57.67.77.77.87.87.97.97
+ 47.47.47.47.57.67.77.77.87.87.97.97 47.47.47.57.67.77.77.87.87.97.97
+ 47.47.57.67.77.77.87.87.97.97 47.57.67.77.77.87.87.97.97
+ 57.67.77.77.87.87.97.97 67.77.77.87.87.97.97 77.77.87.87.97.97
+ 77.87.87.97.97 87.87.97.97 87.97.97 97.97 97
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 28.38.38.58.58.58.58.68.78.78.88.98.98
+ 38.38.58.58.58.58.68.78.78.88.98.98 38.58.58.58.58.68.78.78.88.98.98
+ 58.58.58.58.68.78.78.88.98.98 58.58.58.68.78.78.88.98.98
+ 58.58.68.78.78.88.98.98 58.68.78.78.88.98.98 68.78.78.88.98.98
+ 78.78.88.98.98 78.88.98.98 88.98.98 98.98 98
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.49.59.59.59.59.69.79.89.89.89.99.99
+ 49.59.59.59.59.69.79.89.89.89.99.99 59.59.59.59.69.79.89.89.89.99.99
+ 59.59.59.69.79.89.89.89.99.99 59.59.69.79.89.89.89.99.99
+ 59.69.79.89.89.89.99.99 69.79.89.89.89.99.99 79.89.89.89.99.99
+ 89.89.89.99.99 89.89.99.99 89.99.99 99.99 99}
+
+do_execsql_test 1.16.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39 9.99.69.39 99.69.39 69.39 39}
+
+do_execsql_test 1.16.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.16.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.16.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.16.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.16.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+} {191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 189 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 188 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 187 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 186 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 185 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 184 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 183 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 182 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 181 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 180 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 179 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 178 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 177 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 176 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 175 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 174 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 173 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 172 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 171 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 170 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 169 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 168 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 167 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 166 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 165 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 164 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 163 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 162 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 161 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 160 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 159 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 158 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 157 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 156 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 155 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 154 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 153 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 152 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 151 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 150 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 149 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 148 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 147 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 146 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 145 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 144 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 143 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 142 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 141 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 140 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 139 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 138 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 137 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 136 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 135 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 134 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 133 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 132 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 131 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 130 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 129 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 128 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 127 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 126 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 125 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 124 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 123 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 122 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 121 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 120 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 119 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 118 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 117 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 116 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 115 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 114 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 113 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 112 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 111 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 110 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 109 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 108 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 107 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 106 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 105 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 104 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 103 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 102 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 101 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 100 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 99 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 98 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 97 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 96 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 95 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 94 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 93 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 92 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 91 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 90 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 89 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 88 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 87 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 86 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 85 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 84 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 83 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 82 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 81 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 80 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 79 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 78 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 77 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 76 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 75 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 74 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 73 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 72 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 71 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 70 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 69 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 68 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 67 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 66 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 65 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 64 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 63 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 62 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 61 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 60 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 59 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 58 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 57 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 56 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 55 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 54 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 53 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 52 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 51 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 50 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 49 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 48 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 47 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 46 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 45 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 44 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 43 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 42 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 41 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 40 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 39 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 38 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 37 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 36 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 35 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 34 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 33 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 32 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 31 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 30 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 29 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 28 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 27 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 26 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 25 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 24 3.69.52.50.10.33.39.58.38.83.82.7 23 3.69.52.50.10.33.39.58.38.83.82.7
+ 22 69.52.50.10.33.39.58.38.83.82.7 21 69.52.50.10.33.39.58.38.83.82.7
+ 20 52.50.10.33.39.58.38.83.82.7 19 52.50.10.33.39.58.38.83.82.7
+ 18 50.10.33.39.58.38.83.82.7 17 50.10.33.39.58.38.83.82.7
+ 16 10.33.39.58.38.83.82.7 15 10.33.39.58.38.83.82.7
+ 14 33.39.58.38.83.82.7 13 33.39.58.38.83.82.7 12 39.58.38.83.82.7
+ 11 39.58.38.83.82.7 10 58.38.83.82.7 9 58.38.83.82.7 8 38.83.82.7
+ 7 38.83.82.7 6 83.82.7 5 83.82.7 4 82.7 3 82.7 2 7 1 7}
+
+do_execsql_test 1.16.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+} {191 {} 190 {} 189 {} 188 {} 187 {} 186 {} 185 {} 184 {}
+ 183 {} 182 {} 181 {} 180 {} 179 {} 178 {} 177 {} 176 {}
+ 175 {} 174 {} 173 {} 172 {} 171 {} 170 {} 169 {} 168 {}
+ 167 {} 166 {} 165 {} 164 {} 163 {} 162 {} 161 {} 160 {}
+ 159 {} 158 {} 157 {} 156 {} 155 {} 154 {} 153 {} 152 {}
+ 151 {} 150 {} 149 {} 148 {} 147 {} 146 {} 145 {} 144 {}
+ 143 {} 142 {} 141 {} 140 {} 139 {} 138 {} 137 {} 136 {}
+ 135 {} 134 {} 133 {} 132 {} 131 {} 130 {} 129 {} 128 {}
+ 127 {} 126 {} 125 {} 124 {} 123 {} 122 {} 121 {} 120 {}
+ 119 {} 118 {} 117 {} 116 {} 115 {} 114 {} 113 {} 112 {}
+ 111 {} 110 {} 109 {} 108 {} 107 {} 106 {} 105 {} 104 {}
+ 103 {} 102 {} 101 {} 100 {} 99 {} 98 {} 97 {} 96 {} 95 {}
+ 94 {} 93 {} 92 {} 91 {} 90 {} 89 {} 88 {} 87 {} 86 {}
+ 85 {} 84 {} 83 {} 82 {} 81 {} 80 {} 79 {} 78 {} 77 {}
+ 76 {} 75 {} 74 {} 73 {} 72 {} 71 {} 70 {} 69 {} 68 {}
+ 67 {} 66 {} 65 {} 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_execsql_test 1.16.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+} {20 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 19 {} 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {}}
+
+do_execsql_test 1.16.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+} {20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 18 29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 17 47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 16 59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 15 28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 14 75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 13 78.72.98.87.73.96.74.90.75.91.69.39.7
+ 12 72.98.87.73.96.74.90.75.91.69.39.7 11 98.87.73.96.74.90.75.91.69.39.7
+ 10 87.73.96.74.90.75.91.69.39.7 9 73.96.74.90.75.91.69.39.7
+ 8 96.74.90.75.91.69.39.7 7 74.90.75.91.69.39.7 6 90.75.91.69.39.7
+ 5 75.91.69.39.7 4 91.69.39.7 3 69.39.7 2 39.7 1 7 19 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 17 84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 16 86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 15 32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 14 25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 13 89.29.9.21.12.88.55.70.58.81.91.52.58
+ 12 29.9.21.12.88.55.70.58.81.91.52.58 11 9.21.12.88.55.70.58.81.91.52.58
+ 10 21.12.88.55.70.58.81.91.52.58 9 12.88.55.70.58.81.91.52.58
+ 8 88.55.70.58.81.91.52.58 7 55.70.58.81.91.52.58 6 70.58.81.91.52.58
+ 5 58.81.91.52.58 4 81.91.52.58 3 91.52.58 2 52.58 1 58 19 {}
+ 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {}
+ 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 17 23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 16 61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 15 3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 14 1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 13 76.63.73.65.20.8.77.19.9.23.15.50.38
+ 12 63.73.65.20.8.77.19.9.23.15.50.38 11 73.65.20.8.77.19.9.23.15.50.38
+ 10 65.20.8.77.19.9.23.15.50.38 9 20.8.77.19.9.23.15.50.38
+ 8 8.77.19.9.23.15.50.38 7 77.19.9.23.15.50.38 6 19.9.23.15.50.38
+ 5 9.23.15.50.38 4 23.15.50.38 3 15.50.38 2 50.38 1 38 19 {}
+ 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {}
+ 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 17 16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 16 85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 15 22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 14 40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 13 4.87.65.5.31.49.2.26.72.13.36.10.83
+ 12 87.65.5.31.49.2.26.72.13.36.10.83 11 65.5.31.49.2.26.72.13.36.10.83
+ 10 5.31.49.2.26.72.13.36.10.83 9 31.49.2.26.72.13.36.10.83
+ 8 49.2.26.72.13.36.10.83 7 2.26.72.13.36.10.83 6 26.72.13.36.10.83
+ 5 72.13.36.10.83 4 13.36.10.83 3 36.10.83 2 10.83 1 83 19 {}
+ 18 {} 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {}
+ 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 17 65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 16 85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 15 55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 14 56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 13 42.80.58.11.95.90.85.47.33.14.3.33.82
+ 12 80.58.11.95.90.85.47.33.14.3.33.82 11 58.11.95.90.85.47.33.14.3.33.82
+ 10 11.95.90.85.47.33.14.3.33.82 9 95.90.85.47.33.14.3.33.82
+ 8 90.85.47.33.14.3.33.82 7 85.47.33.14.3.33.82 6 47.33.14.3.33.82
+ 5 33.14.3.33.82 4 14.3.33.82 3 3.33.82 2 33.82 1 82 19 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {}}
+
+do_execsql_test 1.17.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 95
+ 95 84 84 84 84 84 84 84 84 83 83 83 83 83 83
+ 83 83 83 82 82 17 7 {} {} {} {}}
+
+do_execsql_test 1.17.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 7 7 7 7 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 {} {}
+ {} {}}
+
+do_execsql_test 1.17.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.17.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.17.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.17.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.17.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.17.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.17.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.17.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.17.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.17.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.17.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.17.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.17.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.17.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.17.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.17.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.17.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.17.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.17.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 {} {} {} {}}
+
+do_execsql_test 1.17.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {223 223 223 223 223 223 223 223 223 223 {} {} {}
+ {} 210 210 210 210 210 210 210 210 210 210 210 210
+ 210 210 210 210 210 {} {} {} {} 280 280 280 280
+ 280 280 280 280 280 280 280 280 {} {} {} {} 279
+ 279 279 279 279 279 279 279 279 279 279 279 279 279
+ 279 279 279 {} {} {} {} 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 {} {} {} {}
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 {} {} {} {} 212 212 212 212 212
+ 212 212 212 212 212 212 212 212 212 212 212 212 {}
+ {} {} {} 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 {} {} {} {} 232 232 232
+ 232 232 232 232 232 232 232 232 232 {} {} {} {}
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 {} {} {} {}}
+
+do_execsql_test 1.17.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 {} {} {} {}}
+
+do_execsql_test 1.17.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {240 240 240 240 240 240 240 240 240 240 {} {} {}
+ {} 263 263 263 263 263 263 263 263 263 263 263 263
+ 263 263 263 263 263 {} {} {} {} 280 280 280 280
+ 280 280 280 280 280 280 280 280 {} {} {} {} 252
+ 252 252 252 252 252 252 252 252 252 252 252 252 252
+ 252 252 252 {} {} {} {} 171 171 171 171 171 171
+ 171 171 171 171 171 171 171 171 171 {} {} {} {}
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 {} {} {} {} 226 226 226 226 226
+ 226 226 226 226 226 226 226 226 226 226 226 226 {}
+ {} {} {} 124 124 124 124 124 124 124 124 124 124
+ 124 124 124 124 124 124 {} {} {} {} 198 198 198
+ 198 198 198 198 198 198 198 198 198 {} {} {} {}
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 {} {} {} {}}
+
+do_execsql_test 1.17.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 {} {} {} {}}
+
+do_execsql_test 1.17.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {74 65 12 4 22 37 15 53 8 16 29 8 34 3 76 73
+ 63 90 47 98 47 90 73 20 89 91 22 77 73 42 41
+ 32 55 79 51 74 44 81 7 65 8 43 80 8 89 90 29
+ 36 15 42 9 9 41 20 16 11 87 20 90 84 80 41 37
+ 34 9 75 63 34 8 8 81 95 31 74 36 41 99 90 91
+ 99 13 2 35 33 36 38 37 20 75 17 {} 5 34 58 33
+ 19 31 50 34 23 {} 72 90 11 85 90 36 2 {} 39
+ 27 {} {} 64 2 74 95 37 {} 58 {} 34 44 {} {}
+ 30 70 47 {} 7 {} 15 {} {} 12 33 36 99 17 {}
+ {} 44 {} {} 12 {} {} {} 34 {} {} {} {} 36 44
+ {} 30 30 10 {} {} {} {} {} 30 {} {} {} 84 {}
+ {} {} {} {} {} {} 7 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {}}
+
+do_execsql_test 1.17.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 21 {} {} {} 31 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 72 {} {} {} 82
+ {} {} {} {} {} {} {} {} {} {} 73 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 64 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 76 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 27 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 38 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {3 4 6 7 7 8 8 9 10 11 12 12 13 13 14 15 15
+ 16 16 19 20 21 22 22 23 24 26 27 27 28 29 29
+ 30 30 32 33 33 34 34 34 35 36 36 37 38 38 39
+ 39 41 42 43 43 44 46 46 47 47 49 51 52 53 54
+ 55 56 56 56 58 58 58 59 59 59 60 61 62 62 64
+ 65 65 66 68 69 72 72 73 73 74 75 75 76 77 77
+ 78 80 81 81 83 84 84 85 85 87 87 88 89 90 90
+ 90 91 91 91 91 93 93 95 95 96 96 97 98 99 99
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} 21
+ 31 91 91 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 22 32 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 33 33 93 93 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 44 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 65 95 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 46 {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 47 57
+ 67 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 78 88 98 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 59 59 69 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {85 72 12 84 31 95 33 34 35 5 2 93 51 12 95 15
+ 34 96 46 21 95 23 84 31 52 2 34 54 73 33 72
+ 16 26 26 63 65 23 84 33 14 72 16 53 3 82 56
+ 16 73 6 95 67 47 74 27 65 73 5 85 46 96 77 84
+ 7 47 65 8 85 64 95 4 75 98 66 98 7 5 64 89
+ 58 28 86 56 66 98 7 5 76 89 89 77 26 58 36 29
+ 59 68 46 96 29 {} 89 59 87 96 36 {} 58 9 {}
+ 99 36 {} {} 88 76 58 67 77 {} 79 49 59 37 88
+ {} {} {} 28 98 89 {} 39 99 {} 58 {} {} {} 69
+ 27 {} {} 59 {} {} 8 {} {} {} 39 59 99 88 {}
+ {} {} 38 69 {} {} {} {} 59 {} 89 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {38 68 39 62 91 46 6 99 97 27 46 78 54 97 8 67
+ 29 93 84 77 23 16 16 93 65 35 47 7 86 74 61
+ 91 85 24 85 43 59 12 32 56 3 91 22 90 55 15
+ 28 89 25 47 1 56 40 43 56 16 75 36 89 98 76
+ 81 4 94 42 30 78 33 29 53 63 2 87 37 80 84 72
+ 41 9 61 73 95 65 13 58 96 98 1 21 74 65 35 5
+ 73 11 51 87 41 12 8 20 31 31 15 95 22 73 79
+ 88 34 8 11 49 34 90 59 96 60 55 75 77 44 2 7
+ 85 57 74 29 70 59 19 39 26 26 47 80 90 36 58
+ 47 9 72 72 66 33 93 75 64 81 9 23 37 13 12 14
+ 62 91 36 91 33 15 34 36 99 3 95 69 58 52 30
+ 50 84 10 84 33 21 39 44 58 30 38 34 83 27 82
+ 17 7 {} {} {} {}}
+
+do_execsql_test 1.17.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {20 90 60 70 80 90 30 50 10 30 {} {} {} {} 91
+ 1 81 41 61 1 21 11 51 41 31 31 11 81 91 91 21
+ {} {} {} {} 42 2 72 12 22 2 72 72 12 62 52 82
+ {} {} {} {} 3 43 33 53 63 73 13 73 73 33 93
+ 23 13 33 3 33 83 {} {} {} {} 4 94 84 74 34 34
+ 44 74 64 14 34 84 84 44 34 {} {} {} {} 55 15
+ 25 75 95 65 65 35 5 15 95 55 75 85 75 15 95
+ {} {} {} {} 16 16 86 56 56 56 16 36 76 96 96
+ 26 26 36 66 36 36 {} {} {} {} 77 47 7 47 87
+ 37 87 77 7 57 47 47 37 27 17 7 {} {} {} {} 28
+ 98 78 58 98 8 88 8 58 58 58 38 {} {} {} {} 29
+ 59 89 89 29 9 79 49 59 29 59 19 39 9 9 99 69
+ 39 {} {} {} {}}
+
+do_execsql_test 1.17.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {3 3 4 5 6 7 7 7 8 8 8 9 9 9 10 11 11 12
+ 12 12 13 13 14 15 15 15 16 16 16 17 19 20 21
+ 21 22 22 23 23 24 25 26 26 27 27 28 29 29 29
+ 30 30 30 31 31 32 33 33 33 33 34 34 34 34 35
+ 35 36 36 36 36 37 37 38 38 39 39 39 40 41 41
+ 42 43 43 44 44 46 46 47 47 47 47 49 50 51 52
+ 53 54 55 55 56 56 56 57 58 58 58 58 59 59 59
+ 59 60 61 61 62 62 63 64 65 65 65 66 67 68 69
+ 70 72 72 72 73 73 73 74 74 74 75 75 75 76 77
+ 77 78 78 79 80 80 81 81 81 82 83 84 84 84 84
+ 85 85 85 86 87 87 88 89 89 89 90 90 90 91 91
+ 91 91 91 93 93 93 94 95 95 95 96 96 96 97 97
+ 98 98 99 99 {} {} {} {}}
+
+do_execsql_test 1.17.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {30 40 50 60 70 80 80 90 90 90 {} {} {} {} 21
+ 21 31 31 41 41 51 61 61 81 81 81 91 91 91 91
+ 91 {} {} {} {} 12 22 22 32 42 52 62 62 72 72
+ 72 82 {} {} {} {} 23 23 33 33 33 33 43 43 53
+ 63 73 73 73 83 93 93 93 {} {} {} {} 34 34 34
+ 44 44 54 64 74 74 74 84 84 84 84 94 {} {} {}
+ {} 25 35 35 55 55 65 65 65 75 75 75 85 85 85
+ 95 95 95 {} {} {} {} 26 26 36 36 36 36 46 46
+ 56 56 56 66 76 86 96 96 96 {} {} {} {} 27 27
+ 37 37 47 47 47 47 57 67 77 77 87 87 97 97 {}
+ {} {} {} 38 38 58 58 58 58 68 78 78 88 98 98
+ {} {} {} {} 29 29 29 39 39 39 49 59 59 59 59
+ 69 79 89 89 89 99 99 {} {} {} {}}
+
+do_execsql_test 1.17.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {20 90 60 70 80 90 30 50 10 30 81 91 61 91 91
+ 1 81 41 61 1 21 11 51 41 31 31 11 81 91 91 21
+ 62 12 32 22 42 2 72 12 22 2 72 72 12 62 52 82
+ 93 23 93 43 3 43 33 53 63 73 13 73 73 33 93
+ 23 13 33 3 33 83 54 84 74 24 4 94 84 74 34 34
+ 44 74 64 14 34 84 84 44 34 65 35 85 85 55 15
+ 25 75 95 65 65 35 5 15 95 55 75 85 75 15 95
+ 96 46 6 46 16 16 86 56 56 56 16 36 76 96 96
+ 26 26 36 66 36 36 97 27 97 67 77 47 7 47 87
+ 37 87 77 7 57 47 47 37 27 17 7 38 68 78 8 28
+ 98 78 58 98 8 88 8 58 58 58 38 89 59 39 99 29
+ 59 89 89 29 9 79 49 59 29 59 19 39 9 9 99 69
+ 39 {} {} {} {}}
+
+do_execsql_test 1.17.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.17.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.17.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.17.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.17.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.17.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.21.39.44.58.30.38.34.83.27.82.17.7 21.39.44.58.30.38.34.83.27.82.17.7
+ 39.44.58.30.38.34.83.27.82.17.7 44.58.30.38.34.83.27.82.17.7
+ 58.30.38.34.83.27.82.17.7 30.38.34.83.27.82.17.7 38.34.83.27.82.17.7
+ 34.83.27.82.17.7 83.27.82.17.7 27.82.17.7 82.17.7 17.7 7 {}
+ {} {} {}}
+
+do_execsql_test 1.17.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {20.90.60.70.80.90.30.50.10.30 90.60.70.80.90.30.50.10.30
+ 60.70.80.90.30.50.10.30 70.80.90.30.50.10.30 80.90.30.50.10.30
+ 90.30.50.10.30 30.50.10.30 50.10.30 10.30 30 {} {} {} {}
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.1.21.11.51.41.31.31.11.81.91.91.21 1.21.11.51.41.31.31.11.81.91.91.21
+ 21.11.51.41.31.31.11.81.91.91.21 11.51.41.31.31.11.81.91.91.21
+ 51.41.31.31.11.81.91.91.21 41.31.31.11.81.91.91.21 31.31.11.81.91.91.21
+ 31.11.81.91.91.21 11.81.91.91.21 81.91.91.21 91.91.21 91.21 21
+ {} {} {} {} 42.2.72.12.22.2.72.72.12.62.52.82
+ 2.72.12.22.2.72.72.12.62.52.82 72.12.22.2.72.72.12.62.52.82
+ 12.22.2.72.72.12.62.52.82 22.2.72.72.12.62.52.82 2.72.72.12.62.52.82
+ 72.72.12.62.52.82 72.12.62.52.82 12.62.52.82 62.52.82 52.82 82
+ {} {} {} {} 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 63.73.13.73.73.33.93.23.13.33.3.33.83 73.13.73.73.33.93.23.13.33.3.33.83
+ 13.73.73.33.93.23.13.33.3.33.83 73.73.33.93.23.13.33.3.33.83
+ 73.33.93.23.13.33.3.33.83 33.93.23.13.33.3.33.83 93.23.13.33.3.33.83
+ 23.13.33.3.33.83 13.33.3.33.83 33.3.33.83 3.33.83 33.83 83 {}
+ {} {} {} 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.34.34.44.74.64.14.34.84.84.44.34 34.34.44.74.64.14.34.84.84.44.34
+ 34.44.74.64.14.34.84.84.44.34 44.74.64.14.34.84.84.44.34
+ 74.64.14.34.84.84.44.34 64.14.34.84.84.44.34 14.34.84.84.44.34
+ 34.84.84.44.34 84.84.44.34 84.44.34 44.34 34 {} {} {} {}
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 95.65.65.35.5.15.95.55.75.85.75.15.95 65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.5.15.95.55.75.85.75.15.95 35.5.15.95.55.75.85.75.15.95
+ 5.15.95.55.75.85.75.15.95 15.95.55.75.85.75.15.95 95.55.75.85.75.15.95
+ 55.75.85.75.15.95 75.85.75.15.95 85.75.15.95 75.15.95 15.95 95
+ {} {} {} {} 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.16.36.76.96.96.26.26.36.66.36.36 16.36.76.96.96.26.26.36.66.36.36
+ 36.76.96.96.26.26.36.66.36.36 76.96.96.26.26.36.66.36.36
+ 96.96.26.26.36.66.36.36 96.26.26.36.66.36.36 26.26.36.66.36.36
+ 26.36.66.36.36 36.66.36.36 66.36.36 36.36 36 {} {} {} {}
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.87.37.87.77.7.57.47.47.37.27.17.7 87.37.87.77.7.57.47.47.37.27.17.7
+ 37.87.77.7.57.47.47.37.27.17.7 87.77.7.57.47.47.37.27.17.7
+ 77.7.57.47.47.37.27.17.7 7.57.47.47.37.27.17.7 57.47.47.37.27.17.7
+ 47.47.37.27.17.7 47.37.27.17.7 37.27.17.7 27.17.7 17.7 7 {}
+ {} {} {} 28.98.78.58.98.8.88.8.58.58.58.38
+ 98.78.58.98.8.88.8.58.58.58.38 78.58.98.8.88.8.58.58.58.38
+ 58.98.8.88.8.58.58.58.38 98.8.88.8.58.58.58.38 8.88.8.58.58.58.38
+ 88.8.58.58.58.38 8.58.58.58.38 58.58.58.38 58.58.38 58.38 38 {}
+ {} {} {} 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39 9.99.69.39 99.69.39 69.39 39 {}
+ {} {} {}}
+
+do_execsql_test 1.17.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 94.95.95.95.96.96.96.97.97.98.98.99.99
+ 95.95.95.96.96.96.97.97.98.98.99.99 95.95.96.96.96.97.97.98.98.99.99
+ 95.96.96.96.97.97.98.98.99.99 96.96.96.97.97.98.98.99.99
+ 96.96.97.97.98.98.99.99 96.97.97.98.98.99.99 97.97.98.98.99.99
+ 97.98.98.99.99 98.98.99.99 98.99.99 99.99 99 {} {} {} {}}
+
+do_execsql_test 1.17.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {30.40.50.60.70.80.80.90.90.90 40.50.60.70.80.80.90.90.90
+ 50.60.70.80.80.90.90.90 60.70.80.80.90.90.90 70.80.80.90.90.90
+ 80.80.90.90.90 80.90.90.90 90.90.90 90.90 90 {} {} {} {}
+ 21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.51.61.61.81.81.81.91.91.91.91.91 51.61.61.81.81.81.91.91.91.91.91
+ 61.61.81.81.81.91.91.91.91.91 61.81.81.81.91.91.91.91.91
+ 81.81.81.91.91.91.91.91 81.81.91.91.91.91.91 81.91.91.91.91.91
+ 91.91.91.91.91 91.91.91.91 91.91.91 91.91 91 {} {} {} {}
+ 12.22.22.32.42.52.62.62.72.72.72.82 22.22.32.42.52.62.62.72.72.72.82
+ 22.32.42.52.62.62.72.72.72.82 32.42.52.62.62.72.72.72.82
+ 42.52.62.62.72.72.72.82 52.62.62.72.72.72.82 62.62.72.72.72.82
+ 62.72.72.72.82 72.72.72.82 72.72.82 72.82 82 {} {} {} {}
+ 23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.43.43.53.63.73.73.73.83.93.93.93 43.43.53.63.73.73.73.83.93.93.93
+ 43.53.63.73.73.73.83.93.93.93 53.63.73.73.73.83.93.93.93
+ 63.73.73.73.83.93.93.93 73.73.73.83.93.93.93 73.73.83.93.93.93
+ 73.83.93.93.93 83.93.93.93 93.93.93 93.93 93 {} {} {} {}
+ 34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.44.44.54.64.74.74.74.84.84.84.84.94
+ 44.44.54.64.74.74.74.84.84.84.84.94 44.54.64.74.74.74.84.84.84.84.94
+ 54.64.74.74.74.84.84.84.84.94 64.74.74.74.84.84.84.84.94
+ 74.74.74.84.84.84.84.94 74.74.84.84.84.84.94 74.84.84.84.84.94
+ 84.84.84.84.94 84.84.84.94 84.84.94 84.94 94 {} {} {} {}
+ 25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.65.65.65.75.75.75.85.85.85.95.95.95
+ 65.65.65.75.75.75.85.85.85.95.95.95 65.65.75.75.75.85.85.85.95.95.95
+ 65.75.75.75.85.85.85.95.95.95 75.75.75.85.85.85.95.95.95
+ 75.75.85.85.85.95.95.95 75.85.85.85.95.95.95 85.85.85.95.95.95
+ 85.85.95.95.95 85.95.95.95 95.95.95 95.95 95 {} {} {} {}
+ 26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.46.46.56.56.56.66.76.86.96.96.96 46.46.56.56.56.66.76.86.96.96.96
+ 46.56.56.56.66.76.86.96.96.96 56.56.56.66.76.86.96.96.96
+ 56.56.66.76.86.96.96.96 56.66.76.86.96.96.96 66.76.86.96.96.96
+ 76.86.96.96.96 86.96.96.96 96.96.96 96.96 96 {} {} {} {}
+ 27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.47.47.47.47.57.67.77.77.87.87.97.97
+ 47.47.47.47.57.67.77.77.87.87.97.97 47.47.47.57.67.77.77.87.87.97.97
+ 47.47.57.67.77.77.87.87.97.97 47.57.67.77.77.87.87.97.97
+ 57.67.77.77.87.87.97.97 67.77.77.87.87.97.97 77.77.87.87.97.97
+ 77.87.87.97.97 87.87.97.97 87.97.97 97.97 97 {} {} {} {}
+ 38.38.58.58.58.58.68.78.78.88.98.98 38.58.58.58.58.68.78.78.88.98.98
+ 58.58.58.58.68.78.78.88.98.98 58.58.58.68.78.78.88.98.98
+ 58.58.68.78.78.88.98.98 58.68.78.78.88.98.98 68.78.78.88.98.98
+ 78.78.88.98.98 78.88.98.98 88.98.98 98.98 98 {} {} {} {}
+ 29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.49.59.59.59.59.69.79.89.89.89.99.99
+ 49.59.59.59.59.69.79.89.89.89.99.99 59.59.59.59.69.79.89.89.89.99.99
+ 59.59.59.69.79.89.89.89.99.99 59.59.69.79.89.89.89.99.99
+ 59.69.79.89.89.89.99.99 69.79.89.89.89.99.99 79.89.89.89.99.99
+ 89.89.89.99.99 89.89.99.99 89.99.99 99.99 99 {} {} {} {}}
+
+do_execsql_test 1.17.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t2
+} {20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39 9.99.69.39 99.69.39 69.39 39 {}
+ {} {} {}}
+
+do_execsql_test 1.17.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.17.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING)
+} {187 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 186 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 185 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 184 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 183 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 182 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 181 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 180 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 179 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 178 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 177 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 176 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 175 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 174 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 173 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 172 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 171 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 170 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 169 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 168 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 167 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 166 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 165 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 164 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 163 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 162 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 161 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 160 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 159 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 158 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 157 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 156 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 155 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 154 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 153 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 152 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 151 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 150 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 149 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 148 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 147 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 146 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 145 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 144 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 143 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 142 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 141 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 140 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 139 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 138 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 137 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 136 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 135 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 134 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 133 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 132 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 131 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 130 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 129 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 128 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 127 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 126 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 125 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 124 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 123 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 122 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 121 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 120 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 119 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 118 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 117 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 116 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 115 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 114 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 113 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 112 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 111 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 110 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 109 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 108 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 107 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 106 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 105 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 104 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 103 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 102 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 101 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 100 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 99 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 98 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 97 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 96 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 95 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 94 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 93 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 92 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 91 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 90 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 89 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 88 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 87 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 86 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 85 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 84 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 83 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 82 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 81 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 80 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 79 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 78 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 77 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 76 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 75 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 74 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 73 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 72 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 71 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 70 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 69 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 68 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 67 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 66 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 65 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 64 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 63 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 62 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 61 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 60 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 59 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 58 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 57 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 56 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 55 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 54 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 53 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 52 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 51 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 50 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 49 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 48 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 47 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 46 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 45 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 44 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 43 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 42 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 41 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 40 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 39 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 38 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 37 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 36 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 35 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 34 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 33 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 32 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 31 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 30 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 29 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 28 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 27 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 26 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 25 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 24 3.69.52.50.10.33.39.58.38.83.82.7 23 3.69.52.50.10.33.39.58.38.83.82.7
+ 22 69.52.50.10.33.39.58.38.83.82.7 21 69.52.50.10.33.39.58.38.83.82.7
+ 20 52.50.10.33.39.58.38.83.82.7 19 52.50.10.33.39.58.38.83.82.7
+ 18 50.10.33.39.58.38.83.82.7 17 50.10.33.39.58.38.83.82.7
+ 16 10.33.39.58.38.83.82.7 15 10.33.39.58.38.83.82.7
+ 14 33.39.58.38.83.82.7 13 33.39.58.38.83.82.7 12 39.58.38.83.82.7
+ 11 39.58.38.83.82.7 10 58.38.83.82.7 9 58.38.83.82.7 8 38.83.82.7
+ 7 38.83.82.7 6 83.82.7 5 83.82.7 4 82.7 3 82.7 2 7 1 7 0 {}
+ 0 {} 0 {} 0 {}}
+
+do_execsql_test 1.17.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING)
+} {187 {} 186 {} 185 {} 184 {} 183 {} 182 {} 181 {} 180 {}
+ 179 {} 178 {} 177 {} 176 {} 175 {} 174 {} 173 {} 172 {}
+ 171 {} 170 {} 169 {} 168 {} 167 {} 166 {} 165 {} 164 {}
+ 163 {} 162 {} 161 {} 160 {} 159 {} 158 {} 157 {} 156 {}
+ 155 {} 154 {} 153 {} 152 {} 151 {} 150 {} 149 {} 148 {}
+ 147 {} 146 {} 145 {} 144 {} 143 {} 142 {} 141 {} 140 {}
+ 139 {} 138 {} 137 {} 136 {} 135 {} 134 {} 133 {} 132 {}
+ 131 {} 130 {} 129 {} 128 {} 127 {} 126 {} 125 {} 124 {}
+ 123 {} 122 {} 121 {} 120 {} 119 {} 118 {} 117 {} 116 {}
+ 115 {} 114 {} 113 {} 112 {} 111 {} 110 {} 109 {} 108 {}
+ 107 {} 106 {} 105 {} 104 {} 103 {} 102 {} 101 {} 100 {}
+ 99 {} 98 {} 97 {} 96 {} 95 {} 94 {} 93 {} 92 {} 91 {}
+ 90 {} 89 {} 88 {} 87 {} 86 {} 85 {} 84 {} 83 {} 82 {}
+ 81 {} 80 {} 79 {} 78 {} 77 {} 76 {} 75 {} 74 {} 73 {}
+ 72 {} 71 {} 70 {} 69 {} 68 {} 67 {} 66 {} 65 {} 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 {} 0 {} 0 {}
+ 0 {} 0 {}}
+
+do_execsql_test 1.17.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING)
+} {16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {} 0 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {} 0 {} 15 {} 14 {}
+ 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {}
+ 3 {} 2 {} 1 {} 0 {} 0 {} 0 {} 0 {} 15 {} 14 {} 13 {}
+ 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {}
+ 2 {} 1 {} 0 {} 0 {} 0 {} 0 {} 15 {} 14 {} 13 {} 12 {}
+ 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {}
+ 1 {} 0 {} 0 {} 0 {} 0 {} 15 {} 14 {} 13 {} 12 {} 11 {}
+ 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {} 0 {}
+ 0 {} 0 {} 0 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {}
+ 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {}
+ 0 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {} 0 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {} 0 {} 15 {} 14 {}
+ 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {} 4 {}
+ 3 {} 2 {} 1 {} 0 {} 0 {} 0 {} 0 {}}
+
+do_execsql_test 1.17.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 FOLLOWING AND UNBOUNDED FOLLOWING)
+} {16 59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 15 28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 14 75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 13 78.72.98.87.73.96.74.90.75.91.69.39.7
+ 12 72.98.87.73.96.74.90.75.91.69.39.7 11 98.87.73.96.74.90.75.91.69.39.7
+ 10 87.73.96.74.90.75.91.69.39.7 9 73.96.74.90.75.91.69.39.7
+ 8 96.74.90.75.91.69.39.7 7 74.90.75.91.69.39.7 6 90.75.91.69.39.7
+ 5 75.91.69.39.7 4 91.69.39.7 3 69.39.7 2 39.7 1 7 0 {} 0 {}
+ 0 {} 0 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {} 0 {}
+ 15 32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 14 25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 13 89.29.9.21.12.88.55.70.58.81.91.52.58
+ 12 29.9.21.12.88.55.70.58.81.91.52.58 11 9.21.12.88.55.70.58.81.91.52.58
+ 10 21.12.88.55.70.58.81.91.52.58 9 12.88.55.70.58.81.91.52.58
+ 8 88.55.70.58.81.91.52.58 7 55.70.58.81.91.52.58 6 70.58.81.91.52.58
+ 5 58.81.91.52.58 4 81.91.52.58 3 91.52.58 2 52.58 1 58 0 {}
+ 0 {} 0 {} 0 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {}
+ 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {}
+ 0 {} 15 3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 14 1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 13 76.63.73.65.20.8.77.19.9.23.15.50.38
+ 12 63.73.65.20.8.77.19.9.23.15.50.38 11 73.65.20.8.77.19.9.23.15.50.38
+ 10 65.20.8.77.19.9.23.15.50.38 9 20.8.77.19.9.23.15.50.38
+ 8 8.77.19.9.23.15.50.38 7 77.19.9.23.15.50.38 6 19.9.23.15.50.38
+ 5 9.23.15.50.38 4 23.15.50.38 3 15.50.38 2 50.38 1 38 0 {} 0 {}
+ 0 {} 0 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {} 0 {}
+ 15 22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 14 40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 13 4.87.65.5.31.49.2.26.72.13.36.10.83
+ 12 87.65.5.31.49.2.26.72.13.36.10.83 11 65.5.31.49.2.26.72.13.36.10.83
+ 10 5.31.49.2.26.72.13.36.10.83 9 31.49.2.26.72.13.36.10.83
+ 8 49.2.26.72.13.36.10.83 7 2.26.72.13.36.10.83 6 26.72.13.36.10.83
+ 5 72.13.36.10.83 4 13.36.10.83 3 36.10.83 2 10.83 1 83 0 {}
+ 0 {} 0 {} 0 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {}
+ 8 {} 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {}
+ 0 {} 15 55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 14 56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 13 42.80.58.11.95.90.85.47.33.14.3.33.82
+ 12 80.58.11.95.90.85.47.33.14.3.33.82 11 58.11.95.90.85.47.33.14.3.33.82
+ 10 11.95.90.85.47.33.14.3.33.82 9 95.90.85.47.33.14.3.33.82
+ 8 90.85.47.33.14.3.33.82 7 85.47.33.14.3.33.82 6 47.33.14.3.33.82
+ 5 33.14.3.33.82 4 14.3.33.82 3 3.33.82 2 33.82 1 82 0 {} 0 {}
+ 0 {} 0 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {} 3 {} 2 {} 1 {} 0 {} 0 {} 0 {} 0 {}}
+
+do_execsql_test 1.18.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 95 99 99 99 99 95 95 84 84 84 84 84 84
+ 84 84 83 83 83 83 82 83 83 83 83}
+
+do_execsql_test 1.18.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1
+ 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 7 3 3
+ 3 3 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 17}
+
+do_execsql_test 1.18.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.18.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.18.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.18.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.18.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.18.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.18.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.18.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.18.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.18.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.18.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.18.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.18.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.18.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.18.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.18.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.18.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.18.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.18.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 216}
+
+do_execsql_test 1.18.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {223 223 223 223 223 223 223 223 223 223 223 223 223
+ 196 210 210 210 210 210 210 210 210 210 210 210 210
+ 210 210 210 210 210 210 210 210 263 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 234 279
+ 279 279 279 279 279 279 279 279 279 279 279 279 279
+ 279 279 279 279 279 279 221 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 235
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 189 212 212 212 212 212
+ 212 212 212 212 212 212 212 212 212 212 212 212 212
+ 212 212 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 216 232 232 232
+ 232 232 232 232 232 232 232 232 232 232 232 232 250
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 249}
+
+do_execsql_test 1.18.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 120}
+
+do_execsql_test 1.18.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {240 240 240 240 240 240 240 240 240 240 240 240 240
+ 218 263 263 263 263 263 263 263 263 263 263 263 263
+ 263 263 263 263 263 263 263 263 261 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 228 252
+ 252 252 252 252 252 252 252 252 252 252 252 252 252
+ 252 252 252 252 252 252 130 171 171 171 171 171 171
+ 171 171 171 171 171 171 171 171 171 171 171 171 271
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 213 226 226 226 226 226
+ 226 226 226 226 226 226 226 226 226 226 226 226 226
+ 226 226 195 124 124 124 124 124 124 124 124 124 124
+ 124 124 124 124 124 124 124 124 124 119 198 198 198
+ 198 198 198 198 198 198 198 198 198 198 198 198 171
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 120}
+
+do_execsql_test 1.18.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 249}
+
+do_execsql_test 1.18.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {98 9 73 75 43 78 32 4 5 25 27 15 31 24 43 98
+ 94 79 77 61 22 79 8 73 3 85 43 34 98 36 63 91
+ 11 20 21 75 90 56 96 84 5 28 33 5 56 59 81 19
+ 87 36 2 26 63 73 89 95 74 73 79 29 70 65 33
+ 14 26 47 94 14 15 5 72 41 11 75 19 53 91 79
+ 37 91 93 59 58 36 23 84 33 73 47 58 34 58 73
+ 15 13 7 11 99 31 66 38 80 79 95 60 59 19 59
+ {} 85 39 27 {} 9 59 75 91 33 {} 84 {} 33 50
+ {} {} 36 77 29 {} 30 {} 12 {} 17 75 58 62 91
+ 58 {} {} 50 {} 27 75 {} {} {} 33 {} {} {} {}
+ 62 50 17 36 36 95 {} {} {} {} {} 10 {} {} {}
+ 99 {} {} {} {} {} {} {} 30 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} 91 {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 22 {} {} {} 12
+ {} {} {} {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} 83 {} {} {} {} {} {} {} 33 {} {} {} {} {}
+ {} 94 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 85 {} {} {} {} {} {} 95 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 66 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 87 {} {} {} {} {} 37 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} 58 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 19 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {2 2 2 2 2 3 5 7 7 8 8 9 9 10 11 12 12 12
+ 13 15 15 16 16 16 19 20 21 22 23 23 25 26 26
+ 27 29 30 30 31 32 33 33 33 34 34 35 36 36 36
+ 37 38 39 39 40 41 41 43 43 44 46 47 47 47 49
+ 50 51 52 54 55 56 56 56 57 58 58 59 59 59 60
+ 61 62 63 64 65 66 67 69 70 72 73 73 74 74 74
+ 75 77 78 79 80 81 82 83 84 84 84 85 86 87 87
+ 88 89 89 90 90 91 91 91 93 93 94 95 96 96 96
+ 97 98 99 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {90 {} {} {} {} {} {} {} {} {} {} {} {} {} 11
+ 11 61 61 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 72 72 {} {} {} {} {}
+ {} {} {} {} {} {} 23 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 85 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 86 86 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 47 47
+ 47 97 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 58 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 49 49 49 99 {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {65 72 81 34 41 35 73 74 14 15 32 53 1 2 35 5
+ 74 95 55 61 75 63 34 81 12 91 74 93 43 33 22
+ 75 56 56 23 85 72 23 33 84 22 15 93 73 12 6
+ 46 43 75 75 36 87 54 87 85 43 15 84 85 56 66
+ 83 36 97 85 78 34 94 75 33 65 17 36 68 7 15
+ 94 38 78 27 95 96 36 68 7 15 16 38 89 66 56
+ 38 76 89 89 47 85 56 59 {} 8 88 27 95 16 {}
+ 98 79 39 59 16 {} {} 8 16 98 36 66 {} 99 29
+ 59 97 8 {} {} {} 27 17 8 {} 8 58 {} 98 {} {}
+ {} 29 87 19 {} 89 {} {} 37 {} {} {} 59 59 58
+ 8 99 {} {} 98 29 {} {} {} {} 58 {} 89 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} 19 {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {81 89 89 89 89 81 96 59 38 68 39 62 91 46 6
+ 99 97 27 46 78 54 97 8 67 29 93 84 77 23 16
+ 16 93 65 35 47 7 86 74 61 91 85 24 85 43 59
+ 12 32 56 3 91 22 90 55 15 28 89 25 47 1 56 40
+ 43 56 16 75 36 89 98 76 81 4 94 42 30 78 33
+ 29 53 63 2 87 37 80 84 72 41 9 61 73 95 65 13
+ 58 96 98 1 21 74 65 35 5 73 11 51 87 41 12 8
+ 20 31 31 15 95 22 73 79 88 34 8 11 49 34 90
+ 59 96 60 55 75 77 44 2 7 85 57 74 29 70 59 19
+ 39 26 26 47 80 90 36 58 47 9 72 72 66 33 93
+ 75 64 81 9 23 37 13 12 14 62 91 36 91 33 15
+ 34 36 99 3 95 69 58 52 30 50 84 10 84 33 21
+ 39 44 58 30 38 34 83}
+
+do_execsql_test 1.18.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {40 90 90 90 90 40 30 80 20 90 60 70 80 90 91
+ 81 81 81 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 12 62 62 62 62 12 32 22 42 2 72
+ 12 22 2 72 72 23 93 93 93 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 84 54 54 54 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 35
+ 65 65 65 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 46 96 96 96 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 27 97 97 97 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 68
+ 38 38 38 38 68 78 8 28 98 78 58 98 8 88 8 59
+ 89 89 89 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.18.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 1 1 1 1 1 2 2 3 3 4 5 6 7 7 7 8 8 8
+ 9 9 9 10 11 11 12 12 12 13 13 14 15 15 15 16
+ 16 16 17 19 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 30 30 30 31 31 32 33 33 33
+ 33 34 34 34 34 35 35 36 36 36 36 37 37 38 38
+ 39 39 39 40 41 41 42 43 43 44 44 46 46 47 47
+ 47 47 49 50 51 52 53 54 55 55 56 56 56 57 58
+ 58 58 58 59 59 59 59 60 61 61 62 62 63 64 65
+ 65 65 66 67 68 69 70 72 72 72 73 73 73 74 74
+ 74 75 75 75 76 77 77 78 78 79 80 80 81 81 81
+ 82 83 84 84 84 84 85 85 85 86 87 87 88 89 89
+ 89 90 90 90 91 91 91 91 91 93 93 93 94 95 95
+ 95 96 96 96 97 97}
+
+do_execsql_test 1.18.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {20 10 10 10 10 20 30 30 30 40 50 60 70 80 1 1
+ 1 1 1 1 11 11 21 21 31 31 41 41 51 61 61 81
+ 81 81 91 2 2 2 2 2 2 12 12 12 22 22 32 42
+ 52 62 62 3 3 3 3 3 3 13 13 23 23 33 33 33
+ 33 43 43 53 63 73 73 73 14 4 4 4 4 14 24 34
+ 34 34 34 44 44 54 64 74 74 74 84 15 5 5 5 5
+ 15 15 15 25 35 35 55 55 65 65 65 75 75 75 85
+ 85 16 6 6 6 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 7 7 7 7 7 7 7 17 27 27 37
+ 37 47 47 47 47 57 67 77 77 8 8 8 8 8 8 8 28
+ 38 38 58 58 58 58 68 78 9 9 9 9 9 9 9 19 29
+ 29 29 39 39 39 49 59 59 59 59 69 79 89}
+
+do_execsql_test 1.18.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {40 90 90 90 90 40 30 80 20 90 60 70 80 90 30
+ 50 10 30 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 81 91 91 21 62 12 32 22 42 2 72
+ 12 22 2 72 72 12 62 52 82 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 33 3 33 83 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 84
+ 84 44 34 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 85 75 15 95 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 36 66 36 36 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 37
+ 27 17 7 38 68 78 8 28 98 78 58 98 8 88 8 58
+ 58 58 38 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.18.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.18.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.18.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.18.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.18.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.18.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.96.59.38.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.59.38.68.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.38.68.39.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 38.68.39.62.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 68.39.62.91.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.62.91.46.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.46.6.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.46.6.99.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.6.99.97.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 6.99.97.27.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.97.27.46.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.27.46.78.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 27.46.78.54.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.78.54.97.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.54.97.8.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 54.97.8.67.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.8.67.29.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.67.29.93.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 67.29.93.84.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.93.84.77.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.84.77.23.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.77.23.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.23.16.16.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.16.16.93.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.16.93.65.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.93.65.35.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.65.35.47.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.47.7.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.47.7.86.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.7.86.74.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.86.74.61.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 86.74.61.91.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.61.91.85.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.91.85.24.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.85.24.85.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.24.85.43.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 24.85.43.59.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.43.59.12.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.59.12.32.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.12.32.56.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.32.56.3.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 32.56.3.91.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.3.91.22.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.91.22.90.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.22.90.55.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.90.55.15.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.55.15.28.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.15.28.89.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.28.89.25.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 28.89.25.47.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.25.47.1.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 25.47.1.56.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.1.56.40.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.56.40.43.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.40.43.56.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 40.43.56.16.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.56.16.75.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.16.75.36.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.75.36.89.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.36.89.98.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.89.98.76.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.98.76.81.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.76.81.4.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 76.81.4.94.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.4.94.42.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 4.94.42.30.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 94.42.30.78.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 42.30.78.33.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.78.33.29.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.33.29.53.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.29.53.63.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.53.63.2.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 53.63.2.87.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 63.2.87.37.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.87.37.80.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.37.80.84.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.80.84.72.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.84.72.41.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.72.41.9.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.41.9.61.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.9.61.73.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.61.73.95.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.73.95.65.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.95.65.13.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.65.13.58.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.13.58.96.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.58.96.98.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.96.98.1.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.98.1.21.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.1.21.74.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.21.74.65.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 21.74.65.35.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.65.35.5.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.5.73.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.5.73.11.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 5.73.11.51.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.11.51.87.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.51.87.41.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 51.87.41.12.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.41.12.8.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.12.8.20.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.8.20.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.20.31.31.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 20.31.31.15.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.31.15.95.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.15.95.22.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.95.22.73.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.22.73.79.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.73.79.88.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.79.88.34.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 79.88.34.8.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 88.34.8.11.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.8.11.49.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.11.49.34.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.49.34.90.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 49.34.90.59.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.90.59.96.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.59.96.60.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.96.60.55.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.60.55.75.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 60.55.75.77.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.75.77.44.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.77.44.2.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.44.2.7.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 44.2.7.85.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.7.85.57.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.85.57.74.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.57.74.29.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 57.74.29.70.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.29.70.59.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.70.59.19.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 70.59.19.39.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.19.39.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 19.39.26.26.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.26.26.47.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.26.47.80.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.47.80.90.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.80.90.36.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.90.36.58.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.36.58.47.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.58.47.9.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.47.9.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.9.72.72.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.72.72.66.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.72.66.33.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.66.33.93.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 66.33.93.75.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.93.75.64.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.75.64.81.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.64.81.9.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 64.81.9.23.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.9.23.37.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.23.37.13.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.37.13.12.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.13.12.14.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.12.14.62.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.14.62.91.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 14.62.91.36.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.36.91.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.36.91.33.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.91.33.15.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.33.15.34.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.15.34.36.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.34.36.99.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.36.99.3.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.99.3.95.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.3.95.69.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.95.69.58.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.69.58.52.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 69.58.52.30.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.52.30.50.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 52.30.50.84.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.50.84.10.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 50.84.10.84.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.10.84.33.39.44.58.30.38.34.83.27.82.17.7
+ 10.84.33.21.44.58.30.38.34.83.27.82.17.7
+ 84.33.21.39.58.30.38.34.83.27.82.17.7 33.21.39.44.30.38.34.83.27.82.17.7
+ 21.39.44.58.38.34.83.27.82.17.7 39.44.58.30.34.83.27.82.17.7
+ 44.58.30.38.83.27.82.17.7 58.30.38.34.27.82.17.7 30.38.34.83.82.17.7
+ 38.34.83.27.17.7 34.83.27.82.7 83.27.82.17}
+
+do_execsql_test 1.18.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.90.60.70.80.90.30.50.10.30
+ 40.30.80.20.60.70.80.90.30.50.10.30 30.80.20.90.70.80.90.30.50.10.30
+ 80.20.90.60.80.90.30.50.10.30 20.90.60.70.90.30.50.10.30
+ 90.60.70.80.30.50.10.30 60.70.80.90.50.10.30 70.80.90.30.10.30
+ 80.90.30.50.30 90.30.50.10
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.61.91.91.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.91.91.1.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.91.1.81.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.1.81.41.1.21.11.51.41.31.31.11.81.91.91.21
+ 1.81.41.61.21.11.51.41.31.31.11.81.91.91.21
+ 81.41.61.1.11.51.41.31.31.11.81.91.91.21
+ 41.61.1.21.51.41.31.31.11.81.91.91.21 61.1.21.11.41.31.31.11.81.91.91.21
+ 1.21.11.51.31.31.11.81.91.91.21 21.11.51.41.31.11.81.91.91.21
+ 11.51.41.31.11.81.91.91.21 51.41.31.31.81.91.91.21 41.31.31.11.91.91.21
+ 31.31.11.81.91.21 31.11.81.91.21 11.81.91.91
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.2.72.12.22.2.72.72.12.62.52.82
+ 12.32.22.42.72.12.22.2.72.72.12.62.52.82
+ 32.22.42.2.12.22.2.72.72.12.62.52.82 22.42.2.72.22.2.72.72.12.62.52.82
+ 42.2.72.12.2.72.72.12.62.52.82 2.72.12.22.72.72.12.62.52.82
+ 72.12.22.2.72.12.62.52.82 12.22.2.72.12.62.52.82 22.2.72.72.62.52.82
+ 2.72.72.12.52.82 72.72.12.62.82 72.12.62.52
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 23.93.43.3.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.43.3.43.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.3.43.33.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 3.43.33.53.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.33.53.63.13.73.73.33.93.23.13.33.3.33.83
+ 33.53.63.73.73.73.33.93.23.13.33.3.33.83
+ 53.63.73.13.73.33.93.23.13.33.3.33.83 63.73.13.73.33.93.23.13.33.3.33.83
+ 73.13.73.73.93.23.13.33.3.33.83 13.73.73.33.23.13.33.3.33.83
+ 73.73.33.93.13.33.3.33.83 73.33.93.23.33.3.33.83 33.93.23.13.3.33.83
+ 93.23.13.33.33.83 23.13.33.3.83 13.33.3.33
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.24.4.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.24.4.94.74.34.34.44.74.64.14.34.84.84.44.34
+ 24.4.94.84.34.34.44.74.64.14.34.84.84.44.34
+ 4.94.84.74.34.44.74.64.14.34.84.84.44.34
+ 94.84.74.34.44.74.64.14.34.84.84.44.34
+ 84.74.34.34.74.64.14.34.84.84.44.34 74.34.34.44.64.14.34.84.84.44.34
+ 34.34.44.74.14.34.84.84.44.34 34.44.74.64.34.84.84.44.34
+ 44.74.64.14.84.84.44.34 74.64.14.34.84.44.34 64.14.34.84.44.34
+ 14.34.84.84.34 34.84.84.44
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 35.85.85.55.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.85.55.15.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.55.15.25.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 55.15.25.75.65.65.35.5.15.95.55.75.85.75.15.95
+ 15.25.75.95.65.35.5.15.95.55.75.85.75.15.95
+ 25.75.95.65.35.5.15.95.55.75.85.75.15.95
+ 75.95.65.65.5.15.95.55.75.85.75.15.95 95.65.65.35.15.95.55.75.85.75.15.95
+ 65.65.35.5.95.55.75.85.75.15.95 65.35.5.15.55.75.85.75.15.95
+ 35.5.15.95.75.85.75.15.95 5.15.95.55.85.75.15.95 15.95.55.75.75.15.95
+ 95.55.75.85.15.95 55.75.85.75.95 75.85.75.15
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.6.46.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 6.46.16.16.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.16.16.86.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.16.86.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.86.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 86.56.56.56.36.76.96.96.26.26.36.66.36.36
+ 56.56.56.16.76.96.96.26.26.36.66.36.36
+ 56.56.16.36.96.96.26.26.36.66.36.36 56.16.36.76.96.26.26.36.66.36.36
+ 16.36.76.96.26.26.36.66.36.36 36.76.96.96.26.36.66.36.36
+ 76.96.96.26.36.66.36.36 96.96.26.26.66.36.36 96.26.26.36.36.36
+ 26.26.36.66.36 26.36.66.36
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 27.97.67.77.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.67.77.47.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 67.77.47.7.87.37.87.77.7.57.47.47.37.27.17.7
+ 77.47.7.47.37.87.77.7.57.47.47.37.27.17.7
+ 47.7.47.87.87.77.7.57.47.47.37.27.17.7
+ 7.47.87.37.77.7.57.47.47.37.27.17.7 47.87.37.87.7.57.47.47.37.27.17.7
+ 87.37.87.77.57.47.47.37.27.17.7 37.87.77.7.47.47.37.27.17.7
+ 87.77.7.57.47.37.27.17.7 77.7.57.47.37.27.17.7 7.57.47.47.27.17.7
+ 57.47.47.37.17.7 47.47.37.27.7 47.37.27.17
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.98.78.58.98.8.88.8.58.58.58.38
+ 68.78.8.28.78.58.98.8.88.8.58.58.58.38
+ 78.8.28.98.58.98.8.88.8.58.58.58.38 8.28.98.78.98.8.88.8.58.58.58.38
+ 28.98.78.58.8.88.8.58.58.58.38 98.78.58.98.88.8.58.58.58.38
+ 78.58.98.8.8.58.58.58.38 58.98.8.88.58.58.58.38 98.8.88.8.58.58.38
+ 8.88.8.58.58.38 88.8.58.58.38 8.58.58.58
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.29.59.19.39.9.9.99.69.39 9.79.49.59.59.19.39.9.9.99.69.39
+ 79.49.59.29.19.39.9.9.99.69.39 49.59.29.59.39.9.9.99.69.39
+ 59.29.59.19.9.9.99.69.39 29.59.19.39.9.99.69.39 59.19.39.9.99.69.39
+ 19.39.9.9.69.39 39.9.9.99.39 9.9.99.69}
+
+do_execsql_test 1.18.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.2.2.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.2.3.3.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.3.3.4.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.3.4.5.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.4.5.6.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 4.5.6.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 5.6.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 6.7.7.7.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.7.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.8.8.8.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.8.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.9.9.9.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.9.10.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.10.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.10.11.11.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 10.11.11.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.11.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.12.12.12.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.12.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.13.13.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.13.13.14.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.13.14.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.14.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 14.15.15.15.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.15.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.16.16.16.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.16.17.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.17.19.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.17.19.20.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 17.19.20.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 19.20.21.21.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 20.21.21.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.21.22.22.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.22.22.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.22.23.23.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.23.23.24.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.23.24.25.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.24.25.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 24.25.26.26.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 25.26.26.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.26.27.27.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.27.27.28.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.27.28.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.28.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 28.29.29.29.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.29.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.30.30.30.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.30.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.31.31.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.31.31.32.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.31.32.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.32.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 32.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.33.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.34.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.35.35.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.35.35.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.35.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.36.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.37.37.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.37.37.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.37.38.38.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.38.38.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.38.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.39.39.39.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.39.40.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.40.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.40.41.41.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 40.41.41.42.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.41.42.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.42.43.43.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 42.43.43.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.43.44.44.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.44.44.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.44.46.46.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.46.46.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.46.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.47.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.49.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.49.50.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.49.50.51.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 49.50.51.52.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 50.51.52.53.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 51.52.53.54.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 52.53.54.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 53.54.55.55.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 54.55.55.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.55.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.56.56.56.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.56.57.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.57.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.57.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 57.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.58.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.59.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.60.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.60.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.60.61.61.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 60.61.61.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.61.62.62.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.62.62.63.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.62.63.64.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.63.64.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 63.64.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 64.65.65.65.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.65.66.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.66.67.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.66.67.68.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 66.67.68.69.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 67.68.69.70.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 68.69.70.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 69.70.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 70.72.72.72.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.72.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.73.73.73.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.73.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.74.74.74.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.74.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.75.75.75.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.75.76.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.76.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.76.77.77.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 76.77.77.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.77.78.78.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.78.78.79.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.78.79.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.79.80.80.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 79.80.80.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.80.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.81.81.81.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.81.82.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.82.83.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.82.83.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 82.83.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 83.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.84.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.85.85.85.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.85.86.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.86.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.86.87.87.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 86.87.87.88.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.87.88.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.88.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 88.89.89.89.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.89.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.90.90.90.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.90.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.93.93.93.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.93.94.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.94.95.95.96.96.96.97.97.98.98.99.99
+ 93.94.95.95.96.96.96.97.97.98.98.99.99
+ 94.95.95.95.96.96.97.97.98.98.99.99 95.95.95.96.96.97.97.98.98.99.99
+ 95.95.96.96.97.97.98.98.99.99 95.96.96.96.97.98.98.99.99
+ 96.96.96.97.98.98.99.99 96.96.97.97.98.99.99 96.97.97.98.99.99
+ 97.97.98.98.99 97.98.98.99}
+
+do_execsql_test 1.18.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.40.50.60.70.80.80.90.90.90
+ 20.30.30.30.50.60.70.80.80.90.90.90 30.30.30.40.60.70.80.80.90.90.90
+ 30.30.40.50.70.80.80.90.90.90 30.40.50.60.80.80.90.90.90
+ 40.50.60.70.80.90.90.90 50.60.70.80.90.90.90 60.70.80.80.90.90
+ 70.80.80.90.90 80.80.90.90
+ 1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.11.11.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.11.21.21.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.21.21.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.21.31.31.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.31.31.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.31.41.41.61.61.81.81.81.91.91.91.91.91
+ 31.41.41.51.61.81.81.81.91.91.91.91.91
+ 41.41.51.61.81.81.81.91.91.91.91.91 41.51.61.61.81.81.91.91.91.91.91
+ 51.61.61.81.81.91.91.91.91.91 61.61.81.81.91.91.91.91.91
+ 61.81.81.81.91.91.91.91 81.81.81.91.91.91.91 81.81.91.91.91.91
+ 81.91.91.91.91 91.91.91.91 2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.12.12.12.22.32.42.52.62.62.72.72.72.82
+ 12.12.12.22.32.42.52.62.62.72.72.72.82
+ 12.12.22.22.42.52.62.62.72.72.72.82 12.22.22.32.52.62.62.72.72.72.82
+ 22.22.32.42.62.62.72.72.72.82 22.32.42.52.62.72.72.72.82
+ 32.42.52.62.72.72.72.82 42.52.62.62.72.72.82 52.62.62.72.72.82
+ 62.62.72.72.82 62.72.72.72
+ 3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.13.13.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.13.23.23.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.23.23.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.23.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.33.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.43.53.63.73.73.73.83.93.93.93
+ 33.33.43.43.63.73.73.73.83.93.93.93 33.43.43.53.73.73.73.83.93.93.93
+ 43.43.53.63.73.73.83.93.93.93 43.53.63.73.73.83.93.93.93
+ 53.63.73.73.83.93.93.93 63.73.73.73.93.93.93 73.73.73.83.93.93
+ 73.73.83.93.93 73.83.93.93
+ 14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 14.24.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 24.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.34.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.44.44.64.74.74.74.84.84.84.84.94
+ 34.44.44.54.74.74.74.84.84.84.84.94 44.44.54.64.74.74.84.84.84.84.94
+ 44.54.64.74.74.84.84.84.84.94 54.64.74.74.84.84.84.84.94
+ 64.74.74.74.84.84.84.94 74.74.74.84.84.84.94 74.74.84.84.84.94
+ 74.84.84.84.94 84.84.84.84
+ 15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.15.25.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.25.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.25.35.35.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 25.35.35.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.35.55.55.65.65.75.75.75.85.85.85.95.95.95
+ 35.55.55.65.65.75.75.75.85.85.85.95.95.95
+ 55.55.65.65.75.75.75.85.85.85.95.95.95
+ 55.65.65.65.75.75.85.85.85.95.95.95 65.65.65.75.75.85.85.85.95.95.95
+ 65.65.75.75.85.85.85.95.95.95 65.75.75.75.85.85.95.95.95
+ 75.75.75.85.85.95.95.95 75.75.85.85.95.95.95 75.85.85.85.95.95
+ 85.85.85.95.95 85.85.95.95
+ 16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.16.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.26.26.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.26.26.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.26.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.36.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.46.56.56.56.66.76.86.96.96.96
+ 36.36.46.46.56.56.66.76.86.96.96.96 36.46.46.56.56.66.76.86.96.96.96
+ 46.46.56.56.66.76.86.96.96.96 46.56.56.56.76.86.96.96.96
+ 56.56.56.66.86.96.96.96 56.56.66.76.96.96.96 56.66.76.86.96.96
+ 66.76.86.96.96 76.86.96.96
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.17.27.27.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 17.27.27.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.27.37.37.47.47.47.57.67.77.77.87.87.97.97
+ 27.37.37.47.47.47.57.67.77.77.87.87.97.97
+ 37.37.47.47.47.57.67.77.77.87.87.97.97
+ 37.47.47.47.57.67.77.77.87.87.97.97 47.47.47.47.67.77.77.87.87.97.97
+ 47.47.47.57.77.77.87.87.97.97 47.47.57.67.77.87.87.97.97
+ 47.57.67.77.87.87.97.97 57.67.77.77.87.97.97 67.77.77.87.97.97
+ 77.77.87.87.97 77.87.87.97 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.58.58.58.58.68.78.78.88.98.98
+ 8.28.38.38.58.58.58.68.78.78.88.98.98 28.38.38.58.58.58.68.78.78.88.98.98
+ 38.38.58.58.58.68.78.78.88.98.98 38.58.58.58.68.78.78.88.98.98
+ 58.58.58.58.78.78.88.98.98 58.58.58.68.78.88.98.98 58.58.68.78.88.98.98
+ 58.68.78.78.98.98 68.78.78.88.98 78.78.88.98
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.19.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 19.29.29.29.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.29.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.39.39.39.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.39.49.59.59.59.69.79.89.89.89.99.99
+ 39.39.49.59.59.59.69.79.89.89.89.99.99
+ 39.49.59.59.59.69.79.89.89.89.99.99 49.59.59.59.69.79.89.89.89.99.99
+ 59.59.59.59.79.89.89.89.99.99 59.59.59.69.89.89.89.99.99
+ 59.59.69.79.89.89.99.99 59.69.79.89.89.99.99 69.79.89.89.99.99
+ 79.89.89.89.99 89.89.89.99}
+
+do_execsql_test 1.18.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW ) FROM t2
+} {40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 40.30.80.20.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.80.20.90.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.20.90.60.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 20.90.60.70.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.60.70.80.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 60.70.80.90.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 70.80.90.30.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.90.30.50.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.30.50.10.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.50.10.30.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 50.10.30.81.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 10.30.81.91.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.81.91.61.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.61.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.61.91.91.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.91.91.1.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.1.81.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.1.81.41.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.81.41.61.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.41.61.1.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.61.1.21.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.1.21.11.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.21.11.51.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.11.51.41.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.51.41.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 51.41.31.31.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.31.31.11.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.31.11.81.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.11.81.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.81.91.91.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.91.21.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.21.62.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.21.62.12.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.62.12.32.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.12.32.22.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.32.22.42.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 32.22.42.2.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.42.2.72.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 42.2.72.12.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.12.22.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.22.2.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.22.2.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.2.72.72.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.72.12.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.72.12.62.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.62.52.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.62.52.82.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.52.82.93.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 52.82.93.23.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 82.93.23.93.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.93.43.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.93.43.3.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.43.3.43.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.3.43.33.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.43.33.53.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.33.53.63.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.53.63.73.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 53.63.73.13.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 63.73.13.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.13.73.73.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.73.73.33.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.73.33.93.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.33.93.23.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.93.23.13.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.13.33.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.13.33.3.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.33.3.33.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.3.33.83.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.33.83.54.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.83.54.84.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 83.54.84.74.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 54.84.74.24.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.24.4.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.24.4.94.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 24.4.94.84.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 4.94.84.74.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 94.84.74.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.34.34.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.34.34.44.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.34.44.74.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.44.74.64.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.74.64.14.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.64.14.34.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 64.14.34.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 14.34.84.84.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.84.84.44.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.84.44.34.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.44.34.65.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.34.65.35.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.65.35.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.85.85.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.85.85.55.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.85.55.15.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.55.15.25.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.15.25.75.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.25.75.95.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 25.75.95.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.95.65.65.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.65.65.35.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.65.35.5.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.5.15.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.5.15.95.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 5.15.95.55.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.55.75.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.55.75.85.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.75.85.75.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.85.75.15.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.75.15.95.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.15.95.96.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.96.46.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.96.46.6.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.46.6.46.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.6.46.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 6.46.16.16.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.16.16.86.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.16.86.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.86.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 86.56.56.56.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.56.16.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.16.36.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.16.36.76.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.36.76.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.76.96.96.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 76.96.96.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.96.26.26.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.26.26.36.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.26.36.66.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.36.66.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.66.36.36.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 66.36.36.97.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.36.97.27.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.97.27.97.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.27.97.67.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.97.67.77.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.67.77.47.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 67.77.47.7.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.47.7.47.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.7.47.87.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.47.87.37.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.87.37.87.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.37.87.77.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.87.77.7.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.77.7.57.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.7.57.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.57.47.47.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 57.47.47.37.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.47.37.27.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.37.27.17.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.27.17.7.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.17.7.38.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 17.7.38.68.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.38.68.78.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.68.78.8.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 68.78.8.28.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.8.28.98.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.28.98.78.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 28.98.78.58.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.78.58.98.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.58.98.8.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.98.8.88.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.8.88.8.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.88.8.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 88.8.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.58.58.58.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.58.38.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.38.89.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.38.89.59.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.89.59.39.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.29.59.19.39.9.9.99.69.39 9.79.49.59.59.19.39.9.9.99.69.39
+ 79.49.59.29.19.39.9.9.99.69.39 49.59.29.59.39.9.9.99.69.39
+ 59.29.59.19.9.9.99.69.39 29.59.19.39.9.99.69.39 59.19.39.9.99.69.39
+ 19.39.9.9.69.39 39.9.9.99.39 9.9.99.69}
+
+do_execsql_test 1.18.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.18.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW)
+} {190 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 89.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 89.96.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 189 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 188 96.38.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 187 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 186 38.39.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 185 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 184 39.91.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 183 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 182 91.6.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 181 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 180 6.97.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 179 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 178 97.46.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 177 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 176 46.54.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 175 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 174 54.8.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 173 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 172 8.29.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 171 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 170 29.84.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 169 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 168 84.23.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 167 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 166 23.16.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 165 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 164 16.65.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 163 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 162 65.47.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 161 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 160 47.86.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 159 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 158 86.61.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 157 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 156 61.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 155 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 154 85.85.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 153 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 152 85.59.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 151 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 150 59.32.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 149 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 148 32.3.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 147 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 146 3.22.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 145 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 144 22.55.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 143 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 142 55.28.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 141 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 140 28.25.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 139 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 138 25.1.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 137 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 136 1.40.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 135 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 134 40.56.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 133 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 132 56.75.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 131 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 130 75.89.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 129 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 128 89.76.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 127 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 126 76.4.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 125 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 124 4.42.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 123 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 122 42.78.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 121 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 120 78.29.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 119 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 118 29.63.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 117 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 116 63.87.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 115 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 114 87.80.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 113 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 112 80.72.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 111 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 110 72.9.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 109 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 108 9.73.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 107 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 106 73.65.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 105 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 104 65.58.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 103 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 102 58.98.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 101 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 100 98.21.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 99 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 98 21.65.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 97 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 96 65.5.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 95 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 94 5.11.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 93 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 92 11.87.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 91 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 90 87.12.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 89 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 88 12.20.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 87 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 86 20.31.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 85 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 84 31.95.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 83 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 82 95.73.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 81 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 80 73.88.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 79 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 78 88.8.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 77 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 76 8.49.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 75 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 74 49.90.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 73 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 72 90.96.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 71 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 70 96.55.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 69 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 68 55.77.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 67 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 66 77.2.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 65 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 64 2.85.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 63 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 62 85.74.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 61 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 60 74.70.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 59 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 58 70.19.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 57 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 56 19.26.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 55 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 54 26.47.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 53 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 52 47.90.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 51 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 50 90.58.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 49 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 48 58.9.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 47 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 46 9.72.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 45 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 44 72.33.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 43 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 42 33.75.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 41 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 40 75.81.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 39 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 38 81.23.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 37 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 36 23.13.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 35 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 34 13.14.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 33 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 32 14.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 31 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 30 91.91.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 29 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 28 91.15.3.69.52.50.10.33.39.58.38.83.82.7
+ 27 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 26 15.36.69.52.50.10.33.39.58.38.83.82.7
+ 25 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 24 36.3.52.50.10.33.39.58.38.83.82.7 23 3.69.52.50.10.33.39.58.38.83.82.7
+ 22 3.69.50.10.33.39.58.38.83.82.7 21 69.52.50.10.33.39.58.38.83.82.7
+ 20 69.52.10.33.39.58.38.83.82.7 19 52.50.10.33.39.58.38.83.82.7
+ 18 52.50.33.39.58.38.83.82.7 17 50.10.33.39.58.38.83.82.7
+ 16 50.10.39.58.38.83.82.7 15 10.33.39.58.38.83.82.7
+ 14 10.33.58.38.83.82.7 13 33.39.58.38.83.82.7 12 33.39.38.83.82.7
+ 11 39.58.38.83.82.7 10 39.58.83.82.7 9 58.38.83.82.7 8 58.38.82.7
+ 7 38.83.82.7 6 38.83.7 5 83.82.7 4 83.82}
+
+do_execsql_test 1.18.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW)
+} {190 {} 190 {} 190 {} 190 {} 190 {} 189 {} 188 {} 187 {}
+ 186 {} 185 {} 184 {} 183 {} 182 {} 181 {} 180 {} 179 {}
+ 178 {} 177 {} 176 {} 175 {} 174 {} 173 {} 172 {} 171 {}
+ 170 {} 169 {} 168 {} 167 {} 166 {} 165 {} 164 {} 163 {}
+ 162 {} 161 {} 160 {} 159 {} 158 {} 157 {} 156 {} 155 {}
+ 154 {} 153 {} 152 {} 151 {} 150 {} 149 {} 148 {} 147 {}
+ 146 {} 145 {} 144 {} 143 {} 142 {} 141 {} 140 {} 139 {}
+ 138 {} 137 {} 136 {} 135 {} 134 {} 133 {} 132 {} 131 {}
+ 130 {} 129 {} 128 {} 127 {} 126 {} 125 {} 124 {} 123 {}
+ 122 {} 121 {} 120 {} 119 {} 118 {} 117 {} 116 {} 115 {}
+ 114 {} 113 {} 112 {} 111 {} 110 {} 109 {} 108 {} 107 {}
+ 106 {} 105 {} 104 {} 103 {} 102 {} 101 {} 100 {} 99 {}
+ 98 {} 97 {} 96 {} 95 {} 94 {} 93 {} 92 {} 91 {} 90 {}
+ 89 {} 88 {} 87 {} 86 {} 85 {} 84 {} 83 {} 82 {} 81 {}
+ 80 {} 79 {} 78 {} 77 {} 76 {} 75 {} 74 {} 73 {} 72 {}
+ 71 {} 70 {} 69 {} 68 {} 67 {} 66 {} 65 {} 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 {}}
+
+do_execsql_test 1.18.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW)
+} {19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {}}
+
+do_execsql_test 1.18.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW)
+} {19 6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 89.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 89.6.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 89.6.29.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 89.6.29.47.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 18 6.29.47.59.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 17 29.47.59.28.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 16 47.59.28.75.72.98.87.73.96.74.90.75.91.69.39.7
+ 15 59.28.75.78.98.87.73.96.74.90.75.91.69.39.7
+ 14 28.75.78.72.87.73.96.74.90.75.91.69.39.7
+ 13 75.78.72.98.73.96.74.90.75.91.69.39.7
+ 12 78.72.98.87.96.74.90.75.91.69.39.7 11 72.98.87.73.74.90.75.91.69.39.7
+ 10 98.87.73.96.90.75.91.69.39.7 9 87.73.96.74.75.91.69.39.7
+ 8 73.96.74.90.91.69.39.7 7 96.74.90.75.69.39.7 6 74.90.75.91.39.7
+ 5 90.75.91.69.7 4 75.91.69.39 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}
+ 18 97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 96.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 96.97.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 96.97.84.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 96.97.84.86.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 17 97.84.86.32.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 16 84.86.32.25.29.9.21.12.88.55.70.58.81.91.52.58
+ 15 86.32.25.89.9.21.12.88.55.70.58.81.91.52.58
+ 14 32.25.89.29.21.12.88.55.70.58.81.91.52.58
+ 13 25.89.29.9.12.88.55.70.58.81.91.52.58
+ 12 89.29.9.21.88.55.70.58.81.91.52.58 11 29.9.21.12.55.70.58.81.91.52.58
+ 10 9.21.12.88.70.58.81.91.52.58 9 21.12.88.55.58.81.91.52.58
+ 8 12.88.55.70.81.91.52.58 7 88.55.70.58.91.52.58 6 55.70.58.81.52.58
+ 5 70.58.81.91.58 4 58.81.91.52 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}
+ 18 46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 38.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 38.46.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 38.46.23.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 38.46.23.61.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 17 46.23.61.3.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 16 23.61.3.1.63.73.65.20.8.77.19.9.23.15.50.38
+ 15 61.3.1.76.73.65.20.8.77.19.9.23.15.50.38
+ 14 3.1.76.63.65.20.8.77.19.9.23.15.50.38
+ 13 1.76.63.73.20.8.77.19.9.23.15.50.38
+ 12 76.63.73.65.8.77.19.9.23.15.50.38 11 63.73.65.20.77.19.9.23.15.50.38
+ 10 73.65.20.8.19.9.23.15.50.38 9 65.20.8.77.9.23.15.50.38
+ 8 20.8.77.19.23.15.50.38 7 8.77.19.9.15.50.38 6 77.19.9.23.50.38
+ 5 19.9.23.15.38 4 9.23.15.50 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}
+ 18 54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 39.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 39.54.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 39.54.16.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 39.54.16.85.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 17 54.16.85.22.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 16 16.85.22.40.87.65.5.31.49.2.26.72.13.36.10.83
+ 15 85.22.40.4.65.5.31.49.2.26.72.13.36.10.83
+ 14 22.40.4.87.5.31.49.2.26.72.13.36.10.83
+ 13 40.4.87.65.31.49.2.26.72.13.36.10.83
+ 12 4.87.65.5.49.2.26.72.13.36.10.83 11 87.65.5.31.2.26.72.13.36.10.83
+ 10 65.5.31.49.26.72.13.36.10.83 9 5.31.49.2.72.13.36.10.83
+ 8 31.49.2.26.13.36.10.83 7 49.2.26.72.36.10.83 6 2.26.72.13.10.83
+ 5 26.72.13.36.83 4 72.13.36.10 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}
+ 18 8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 91.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 91.8.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 91.8.65.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 91.8.65.85.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 17 8.65.85.55.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 16 65.85.55.56.80.58.11.95.90.85.47.33.14.3.33.82
+ 15 85.55.56.42.58.11.95.90.85.47.33.14.3.33.82
+ 14 55.56.42.80.11.95.90.85.47.33.14.3.33.82
+ 13 56.42.80.58.95.90.85.47.33.14.3.33.82
+ 12 42.80.58.11.90.85.47.33.14.3.33.82 11 80.58.11.95.85.47.33.14.3.33.82
+ 10 58.11.95.90.47.33.14.3.33.82 9 11.95.90.85.33.14.3.33.82
+ 8 95.90.85.47.14.3.33.82 7 90.85.47.33.3.33.82 6 85.47.33.14.33.82
+ 5 47.33.14.3.82 4 33.14.3.33 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}}
+
+do_execsql_test 1.19.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 95 95 84 84 84 84 84 84
+ 84 84 83 83 83 83 83 83 83 83 83}
+
+do_execsql_test 1.19.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 7}
+
+do_execsql_test 1.19.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.19.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.19.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.19.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.19.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.19.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.19.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.19.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.19.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.19.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.19.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.19.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.19.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.19.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.19.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.19.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.19.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.19.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.19.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207}
+
+do_execsql_test 1.19.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {223 223 223 223 223 223 223 223 223 223 223 223 223
+ 223 210 210 210 210 210 210 210 210 210 210 210 210
+ 210 210 210 210 210 210 210 210 210 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 279
+ 279 279 279 279 279 279 279 279 279 279 279 279 279
+ 279 279 279 279 279 279 279 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 212 212 212 212 212
+ 212 212 212 212 212 212 212 212 212 212 212 212 212
+ 212 212 212 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 232 232 232
+ 232 232 232 232 232 232 232 232 232 232 232 232 232
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.19.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.19.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {240 240 240 240 240 240 240 240 240 240 240 240 240
+ 240 263 263 263 263 263 263 263 263 263 263 263 263
+ 263 263 263 263 263 263 263 263 263 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 280 252
+ 252 252 252 252 252 252 252 252 252 252 252 252 252
+ 252 252 252 252 252 252 252 171 171 171 171 171 171
+ 171 171 171 171 171 171 171 171 171 171 171 171 171
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 274 226 226 226 226 226
+ 226 226 226 226 226 226 226 226 226 226 226 226 226
+ 226 226 226 124 124 124 124 124 124 124 124 124 124
+ 124 124 124 124 124 124 124 124 124 124 198 198 198
+ 198 198 198 198 198 198 198 198 198 198 198 198 198
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276}
+
+do_execsql_test 1.19.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229}
+
+do_execsql_test 1.19.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {108 52 83 79 65 26 70 103 80 36 116 51 52 128
+ 117 71 63 84 109 78 147 88 121 106 124 85 107 171
+ 150 80 171 120 109 158 87 168 173 162 156 195 198
+ 177 124 121 134 141 210 157 132 161 218 226 191 179
+ 138 214 212 172 173 229 240 187 210 227 228 223 225
+ 179 182 231 207 209 212 239 234 213 234 269 196 271
+ 235 250 223 232 229 280 99 92 72 55 109 120 119
+ 50 124 96 59 124 110 57 130 103 74 87 48 105 136
+ 131 133 92 109 57 146 113 74 150 87 110 65 110
+ 145 161 156 114 111 136 147 173 124 132 101 154 167
+ 190 161 110 102 123 169 140 111 180 119 160 197 152
+ 146 147 132 213 193 200 136 175 188 187 208 211 144
+ 223 196 170 202 163 184 195 200 163 191 252 235 243
+ 172 187 202 179 261 263 206 189 276 181 274 249 221
+ 210 229 279 224 216 207}
+
+do_execsql_test 1.19.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {96 41 5 16 85 30 12 81 35 89 97 31 31 85 40
+ 96 4 73 84 9 91 73 12 5 56 24 85 49 96 75 53
+ 61 8 8 1 55 34 43 59 80 35 15 78 35 56 70 76
+ 59 51 75 63 26 53 5 89 15 21 5 73 33 29 74 66
+ 12 26 58 4 12 31 35 9 87 73 55 59 53 62 73 23
+ 62 33 90 13 90 9 10 66 5 58 44 38 58 22 33 37
+ 2 73 36 31 72 30 47 73 15 96 70 59 90 {} 7 21
+ 83 {} 47 90 55 36 66 {} 50 {} 84 30 {} {} 34
+ 77 74 {} 58 {} 13 {} 82 93 69 14 62 44 {} {}
+ 30 {} 83 93 {} {} {} 84 {} {} {} {} 14 30 82
+ 34 34 3 {} {} {} {} {} 84 {} {} {} 99 {} {}
+ {} {} {} {} {} 58 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {}}
+
+do_execsql_test 1.19.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} 91 {} {} {} {}
+ {} {} {} {} {} {} 12 {} {} {} 22 {} 82 {} 12
+ {} {} {} {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} 33 {} {} {} {} {} {} {} 33 {} {} {} {} {}
+ {} 4 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 75 {} {} {} {} {} {} 15 {}
+ {} {} {} {} {} {} {} {} {} 86 {} 26 36 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 37 {} {} {} {} {} 47 {} {} {} {}
+ {} {} {} {} {} {} 98 {} {} {} {} {} 58 {} 38
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 59 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 1 2 2 2 3 4 6 7 8 8 8 9 9 10 11 12 12
+ 13 14 15 15 16 16 17 19 21 22 22 23 24 25 26
+ 27 29 29 30 30 31 32 33 33 34 34 35 35 36 36
+ 37 38 38 39 39 40 41 42 43 44 46 46 47 47 47
+ 49 50 51 53 54 55 56 56 56 58 58 58 59 59 59
+ 60 61 62 63 65 65 66 68 69 72 72 73 73 74 74
+ 75 76 77 78 80 81 81 82 84 84 84 85 85 86 87
+ 87 89 89 89 90 90 91 91 91 93 93 95 95 96 96
+ 97 98 99 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1 1
+ 61 61 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 12 12 72 72 72 {} {} {} {} {} {}
+ {} {} {} {} {} 13 13 63 63 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} 34 84 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 35 85 85 85 {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 36 76 76 76 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 37 37 37
+ 87 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} 58 58 58 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 39 39 39 89 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {34 2 11 34 81 65 73 84 64 55 12 33 91 42 65
+ 35 84 15 95 61 25 53 74 81 72 91 84 33 3 43
+ 32 85 56 56 93 85 2 93 43 94 22 75 82 13 12
+ 46 6 3 55 25 26 47 83 37 85 43 55 34 75 86 36
+ 33 36 36 85 68 14 4 25 33 95 27 16 38 77 55 4
+ 58 98 37 15 95 16 38 77 55 16 58 38 36 56 7
+ 36 59 89 57 75 86 89 39 98 8 97 15 46 {} 28 9
+ 69 49 56 {} {} 78 16 28 26 36 {} 39 99 29 27
+ 78 {} {} {} 37 27 98 {} 88 8 {} 28 {} {} {}
+ 59 37 59 {} 89 {} {} 47 {} 39 {} 29 29 8 78 9
+ {} {} 58 59 {} {} {} {} 58 {} 38 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} 59 {} {} {} {} {}
+ {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {89 89 89 89 89 81 96 59 38 68 39 62 91 46 6
+ 99 97 27 46 78 54 97 8 67 29 93 84 77 23 16
+ 16 93 65 35 47 7 86 74 61 91 85 24 85 43 59
+ 12 32 56 3 91 22 90 55 15 28 89 25 47 1 56 40
+ 43 56 16 75 36 89 98 76 81 4 94 42 30 78 33
+ 29 53 63 2 87 37 80 84 72 41 9 61 73 95 65 13
+ 58 96 98 1 21 74 65 35 5 73 11 51 87 41 12 8
+ 20 31 31 15 95 22 73 79 88 34 8 11 49 34 90
+ 59 96 60 55 75 77 44 2 7 85 57 74 29 70 59 19
+ 39 26 26 47 80 90 36 58 47 9 72 72 66 33 93
+ 75 64 81 9 23 37 13 12 14 62 91 36 91 33 15
+ 34 36 99 3 95 69 58 52 30 50 84 10 84 33 21
+ 39 44 58 30 38 34 83}
+
+do_execsql_test 1.19.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {90 90 90 90 90 40 30 80 20 90 60 70 80 90 81
+ 81 81 81 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 62 62 62 62 62 12 32 22 42 2 72
+ 12 22 2 72 72 93 93 93 93 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 54 54 54 54 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 65
+ 65 65 65 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 96 96 96 96 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 97 97 97 97 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 38
+ 38 38 38 38 68 78 8 28 98 78 58 98 8 88 8 89
+ 89 89 89 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.19.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 1 1 1 1 1 2 2 3 3 4 5 6 7 7 7 8 8 8
+ 9 9 9 10 11 11 12 12 12 13 13 14 15 15 15 16
+ 16 16 17 19 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 30 30 30 31 31 32 33 33 33
+ 33 34 34 34 34 35 35 36 36 36 36 37 37 38 38
+ 39 39 39 40 41 41 42 43 43 44 44 46 46 47 47
+ 47 47 49 50 51 52 53 54 55 55 56 56 56 57 58
+ 58 58 58 59 59 59 59 60 61 61 62 62 63 64 65
+ 65 65 66 67 68 69 70 72 72 72 73 73 73 74 74
+ 74 75 75 75 76 77 77 78 78 79 80 80 81 81 81
+ 82 83 84 84 84 84 85 85 85 86 87 87 88 89 89
+ 89 90 90 90 91 91 91 91 91 93 93 93 94 95 95
+ 95 96 96 96 97 97}
+
+do_execsql_test 1.19.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {10 10 10 10 10 20 30 30 30 40 50 60 70 80 1 1
+ 1 1 1 1 11 11 21 21 31 31 41 41 51 61 61 81
+ 81 81 91 2 2 2 2 2 2 12 12 12 22 22 32 42
+ 52 62 62 3 3 3 3 3 3 13 13 23 23 33 33 33
+ 33 43 43 53 63 73 73 73 4 4 4 4 4 14 24 34
+ 34 34 34 44 44 54 64 74 74 74 84 5 5 5 5 5
+ 15 15 15 25 35 35 55 55 65 65 65 75 75 75 85
+ 85 6 6 6 6 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 7 7 7 7 7 7 7 17 27 27 37
+ 37 47 47 47 47 57 67 77 77 8 8 8 8 8 8 8 28
+ 38 38 58 58 58 58 68 78 9 9 9 9 9 9 9 19 29
+ 29 29 39 39 39 49 59 59 59 59 69 79 89}
+
+do_execsql_test 1.19.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {90 90 90 90 90 40 30 80 20 90 60 70 80 90 30
+ 50 10 30 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 81 91 91 21 62 12 32 22 42 2 72
+ 12 22 2 72 72 12 62 52 82 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 33 3 33 83 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 84
+ 84 44 34 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 85 75 15 95 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 36 66 36 36 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 37
+ 27 17 7 38 68 78 8 28 98 78 58 98 8 88 8 58
+ 58 58 38 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.19.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.19.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.19.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.19.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.19.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.19.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.19.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.19.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.21.39.44.58.30.38.34.83.27.82.17.7 21.39.44.58.30.38.34.83.27.82.17.7
+ 39.44.58.30.38.34.83.27.82.17.7 44.58.30.38.34.83.27.82.17.7
+ 58.30.38.34.83.27.82.17.7 30.38.34.83.27.82.17.7 38.34.83.27.82.17.7
+ 34.83.27.82.17.7 83.27.82.17.7}
+
+do_execsql_test 1.19.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30
+ 40.30.80.20.90.60.70.80.90.30.50.10.30
+ 30.80.20.90.60.70.80.90.30.50.10.30 80.20.90.60.70.80.90.30.50.10.30
+ 20.90.60.70.80.90.30.50.10.30 90.60.70.80.90.30.50.10.30
+ 60.70.80.90.30.50.10.30 70.80.90.30.50.10.30 80.90.30.50.10.30
+ 90.30.50.10.30
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.1.21.11.51.41.31.31.11.81.91.91.21 1.21.11.51.41.31.31.11.81.91.91.21
+ 21.11.51.41.31.31.11.81.91.91.21 11.51.41.31.31.11.81.91.91.21
+ 51.41.31.31.11.81.91.91.21 41.31.31.11.81.91.91.21 31.31.11.81.91.91.21
+ 31.11.81.91.91.21 11.81.91.91.21
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 22.42.2.72.12.22.2.72.72.12.62.52.82 42.2.72.12.22.2.72.72.12.62.52.82
+ 2.72.12.22.2.72.72.12.62.52.82 72.12.22.2.72.72.12.62.52.82
+ 12.22.2.72.72.12.62.52.82 22.2.72.72.12.62.52.82 2.72.72.12.62.52.82
+ 72.72.12.62.52.82 72.12.62.52.82
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 63.73.13.73.73.33.93.23.13.33.3.33.83 73.13.73.73.33.93.23.13.33.3.33.83
+ 13.73.73.33.93.23.13.33.3.33.83 73.73.33.93.23.13.33.3.33.83
+ 73.33.93.23.13.33.3.33.83 33.93.23.13.33.3.33.83 93.23.13.33.3.33.83
+ 23.13.33.3.33.83 13.33.3.33.83
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.34.34.44.74.64.14.34.84.84.44.34 34.34.44.74.64.14.34.84.84.44.34
+ 34.44.74.64.14.34.84.84.44.34 44.74.64.14.34.84.84.44.34
+ 74.64.14.34.84.84.44.34 64.14.34.84.84.44.34 14.34.84.84.44.34
+ 34.84.84.44.34
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 95.65.65.35.5.15.95.55.75.85.75.15.95 65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.5.15.95.55.75.85.75.15.95 35.5.15.95.55.75.85.75.15.95
+ 5.15.95.55.75.85.75.15.95 15.95.55.75.85.75.15.95 95.55.75.85.75.15.95
+ 55.75.85.75.15.95 75.85.75.15.95
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.56.16.36.76.96.96.26.26.36.66.36.36
+ 56.16.36.76.96.96.26.26.36.66.36.36 16.36.76.96.96.26.26.36.66.36.36
+ 36.76.96.96.26.26.36.66.36.36 76.96.96.26.26.36.66.36.36
+ 96.96.26.26.36.66.36.36 96.26.26.36.66.36.36 26.26.36.66.36.36
+ 26.36.66.36.36 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 47.87.37.87.77.7.57.47.47.37.27.17.7 87.37.87.77.7.57.47.47.37.27.17.7
+ 37.87.77.7.57.47.47.37.27.17.7 87.77.7.57.47.47.37.27.17.7
+ 77.7.57.47.47.37.27.17.7 7.57.47.47.37.27.17.7 57.47.47.37.27.17.7
+ 47.47.37.27.17.7 47.37.27.17.7
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 8.28.98.78.58.98.8.88.8.58.58.58.38 28.98.78.58.98.8.88.8.58.58.58.38
+ 98.78.58.98.8.88.8.58.58.58.38 78.58.98.8.88.8.58.58.58.38
+ 58.98.8.88.8.58.58.58.38 98.8.88.8.58.58.58.38 8.88.8.58.58.58.38
+ 88.8.58.58.58.38 8.58.58.58.38
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39}
+
+do_execsql_test 1.19.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 94.95.95.95.96.96.96.97.97.98.98.99.99
+ 95.95.95.96.96.96.97.97.98.98.99.99 95.95.96.96.96.97.97.98.98.99.99
+ 95.96.96.96.97.97.98.98.99.99 96.96.96.97.97.98.98.99.99
+ 96.96.97.97.98.98.99.99 96.97.97.98.98.99.99 97.97.98.98.99.99
+ 97.98.98.99.99}
+
+do_execsql_test 1.19.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.30.40.50.60.70.80.80.90.90.90
+ 20.30.30.30.40.50.60.70.80.80.90.90.90
+ 30.30.30.40.50.60.70.80.80.90.90.90 30.30.40.50.60.70.80.80.90.90.90
+ 30.40.50.60.70.80.80.90.90.90 40.50.60.70.80.80.90.90.90
+ 50.60.70.80.80.90.90.90 60.70.80.80.90.90.90 70.80.80.90.90.90
+ 80.80.90.90.90
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.41.51.61.61.81.81.81.91.91.91.91.91
+ 41.51.61.61.81.81.81.91.91.91.91.91 51.61.61.81.81.81.91.91.91.91.91
+ 61.61.81.81.81.91.91.91.91.91 61.81.81.81.91.91.91.91.91
+ 81.81.81.91.91.91.91.91 81.81.91.91.91.91.91 81.91.91.91.91.91
+ 91.91.91.91.91 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.12.22.22.32.42.52.62.62.72.72.72.82
+ 12.22.22.32.42.52.62.62.72.72.72.82 22.22.32.42.52.62.62.72.72.72.82
+ 22.32.42.52.62.62.72.72.72.82 32.42.52.62.62.72.72.72.82
+ 42.52.62.62.72.72.72.82 52.62.62.72.72.72.82 62.62.72.72.72.82
+ 62.72.72.72.82
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.43.43.53.63.73.73.73.83.93.93.93 43.43.53.63.73.73.73.83.93.93.93
+ 43.53.63.73.73.73.83.93.93.93 53.63.73.73.73.83.93.93.93
+ 63.73.73.73.83.93.93.93 73.73.73.83.93.93.93 73.73.83.93.93.93
+ 73.83.93.93.93 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.44.44.54.64.74.74.74.84.84.84.84.94
+ 44.44.54.64.74.74.74.84.84.84.84.94 44.54.64.74.74.74.84.84.84.84.94
+ 54.64.74.74.74.84.84.84.84.94 64.74.74.74.84.84.84.84.94
+ 74.74.74.84.84.84.84.94 74.74.84.84.84.84.94 74.84.84.84.84.94
+ 84.84.84.84.94
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 55.65.65.65.75.75.75.85.85.85.95.95.95
+ 65.65.65.75.75.75.85.85.85.95.95.95 65.65.75.75.75.85.85.85.95.95.95
+ 65.75.75.75.85.85.85.95.95.95 75.75.75.85.85.85.95.95.95
+ 75.75.85.85.85.95.95.95 75.85.85.85.95.95.95 85.85.85.95.95.95
+ 85.85.95.95.95
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.46.46.56.56.56.66.76.86.96.96.96 46.46.56.56.56.66.76.86.96.96.96
+ 46.56.56.56.66.76.86.96.96.96 56.56.56.66.76.86.96.96.96
+ 56.56.66.76.86.96.96.96 56.66.76.86.96.96.96 66.76.86.96.96.96
+ 76.86.96.96.96 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 37.47.47.47.47.57.67.77.77.87.87.97.97
+ 47.47.47.47.57.67.77.77.87.87.97.97 47.47.47.57.67.77.77.87.87.97.97
+ 47.47.57.67.77.77.87.87.97.97 47.57.67.77.77.87.87.97.97
+ 57.67.77.77.87.87.97.97 67.77.77.87.87.97.97 77.77.87.87.97.97
+ 77.87.87.97.97 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 28.38.38.58.58.58.58.68.78.78.88.98.98
+ 38.38.58.58.58.58.68.78.78.88.98.98 38.58.58.58.58.68.78.78.88.98.98
+ 58.58.58.58.68.78.78.88.98.98 58.58.58.68.78.78.88.98.98
+ 58.58.68.78.78.88.98.98 58.68.78.78.88.98.98 68.78.78.88.98.98
+ 78.78.88.98.98
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 39.49.59.59.59.59.69.79.89.89.89.99.99
+ 49.59.59.59.59.69.79.89.89.89.99.99 59.59.59.59.69.79.89.89.89.99.99
+ 59.59.59.69.79.89.89.89.99.99 59.59.69.79.89.89.89.99.99
+ 59.69.79.89.89.89.99.99 69.79.89.89.89.99.99 79.89.89.89.99.99
+ 89.89.89.99.99}
+
+do_execsql_test 1.19.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES ) FROM t2
+} {90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 9.79.49.59.29.59.19.39.9.9.99.69.39 79.49.59.29.59.19.39.9.9.99.69.39
+ 49.59.29.59.19.39.9.9.99.69.39 59.29.59.19.39.9.9.99.69.39
+ 29.59.19.39.9.9.99.69.39 59.19.39.9.9.99.69.39 19.39.9.9.99.69.39
+ 39.9.9.99.69.39 9.9.99.69.39}
+
+do_execsql_test 1.19.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM t2
+} {96 38 68 62 46 6 46 78 54 8 84 16 16 86 74 24
+ 12 32 56 22 90 28 56 40 56 16 36 98 76 4 94
+ 42 30 78 2 80 84 72 58 96 98 74 12 8 20 22 88
+ 34 8 34 90 96 60 44 2 74 70 26 26 80 90 36 58
+ 72 72 66 64 12 14 62 36 34 36 58 52 30 50 84
+ 10 84 44 58 30 38 34 82 89 81 59 39 91 99 97
+ 27 97 67 29 93 77 23 93 65 35 47 7 61 91 85
+ 85 43 59 3 91 55 15 89 25 47 1 43 75 89 81 33
+ 29 53 63 87 37 41 9 61 73 95 65 13 1 21 65 35
+ 5 73 11 51 87 41 31 31 15 95 73 79 11 49 59
+ 55 75 77 7 85 57 29 59 19 39 47 47 9 33 93 75
+ 81 9 23 37 13 91 91 33 15 99 3 95 69 33 21 39
+ 83 27 17 7}
+
+do_execsql_test 1.19.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.19.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.19.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES)
+ ORDER BY 1
+} {1 1 10 11 11 12 12 12 13 13 14 15 15 15 16 16
+ 16 17 19 2 2 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 3 3 30 30 30 31 31 32 33 33
+ 33 33 34 34 34 34 35 35 36 36 36 36 37 37 38
+ 38 39 39 39 4 40 41 41 42 43 43 44 44 46 46
+ 47 47 47 47 49 5 50 51 52 53 54 55 55 56 56
+ 56 57 58 58 58 58 59 59 59 59 6 60 61 61 62
+ 62 63 64 65 65 65 66 67 68 69 7 7 7 70 72 72
+ 72 73 73 73 74 74 74 75 75 75 76 77 77 78 78
+ 79 8 8 8 80 80 81 81 81 82 83 84 84 84 84 85
+ 85 85 86 87 87 88 89 89 89 9 9 9 90 90 90 91
+ 91 91 91 91 93 93 93 94 95 95 95 96 96 96 97
+ 97 98 98 99 99}
+
+do_execsql_test 1.19.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES)
+} {191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 191 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 189 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 188 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 187 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 186 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 185 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 184 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 183 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 182 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 181 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 180 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 179 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 178 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 177 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 176 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 175 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 174 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 173 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 172 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 171 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 170 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 169 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 168 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 167 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 166 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 165 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 164 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 163 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 162 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 161 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 160 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 159 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 158 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 157 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 156 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 155 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 154 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 153 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 152 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 151 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 150 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 149 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 148 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 147 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 146 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 145 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 144 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 143 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 142 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 141 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 140 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 139 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 138 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 137 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 136 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 135 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 134 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 133 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 132 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 131 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 130 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 129 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 128 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 127 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 126 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 125 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 124 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 123 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 122 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 121 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 120 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 119 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 118 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 117 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 116 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 115 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 114 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 113 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 112 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 111 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 110 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 109 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 108 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 107 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 106 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 105 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 104 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 103 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 102 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 101 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 100 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 99 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 98 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 97 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 96 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 95 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 94 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 93 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 92 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 91 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 90 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 89 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 88 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 87 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 86 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 85 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 84 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 83 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 82 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 81 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 80 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 79 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 78 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 77 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 76 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 75 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 74 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 73 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 72 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 71 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 70 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 69 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 68 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 67 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 66 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 65 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 64 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 63 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 62 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 61 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 60 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 59 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 58 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 57 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 56 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 55 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 54 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 53 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 52 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 51 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 50 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 49 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 48 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 47 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 46 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 45 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 44 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 43 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 42 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 41 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 40 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 39 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 38 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 37 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 36 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 35 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 34 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 33 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 32 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 31 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 30 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 29 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 28 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 27 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 26 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 25 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 24 3.69.52.50.10.33.39.58.38.83.82.7 23 3.69.52.50.10.33.39.58.38.83.82.7
+ 22 69.52.50.10.33.39.58.38.83.82.7 21 69.52.50.10.33.39.58.38.83.82.7
+ 20 52.50.10.33.39.58.38.83.82.7 19 52.50.10.33.39.58.38.83.82.7
+ 18 50.10.33.39.58.38.83.82.7 17 50.10.33.39.58.38.83.82.7
+ 16 10.33.39.58.38.83.82.7 15 10.33.39.58.38.83.82.7
+ 14 33.39.58.38.83.82.7 13 33.39.58.38.83.82.7 12 39.58.38.83.82.7
+ 11 39.58.38.83.82.7 10 58.38.83.82.7 9 58.38.83.82.7 8 38.83.82.7
+ 7 38.83.82.7 6 83.82.7 5 83.82.7}
+
+do_execsql_test 1.19.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES)
+} {191 {} 191 {} 191 {} 191 {} 191 {} 190 {} 189 {} 188 {}
+ 187 {} 186 {} 185 {} 184 {} 183 {} 182 {} 181 {} 180 {}
+ 179 {} 178 {} 177 {} 176 {} 175 {} 174 {} 173 {} 172 {}
+ 171 {} 170 {} 169 {} 168 {} 167 {} 166 {} 165 {} 164 {}
+ 163 {} 162 {} 161 {} 160 {} 159 {} 158 {} 157 {} 156 {}
+ 155 {} 154 {} 153 {} 152 {} 151 {} 150 {} 149 {} 148 {}
+ 147 {} 146 {} 145 {} 144 {} 143 {} 142 {} 141 {} 140 {}
+ 139 {} 138 {} 137 {} 136 {} 135 {} 134 {} 133 {} 132 {}
+ 131 {} 130 {} 129 {} 128 {} 127 {} 126 {} 125 {} 124 {}
+ 123 {} 122 {} 121 {} 120 {} 119 {} 118 {} 117 {} 116 {}
+ 115 {} 114 {} 113 {} 112 {} 111 {} 110 {} 109 {} 108 {}
+ 107 {} 106 {} 105 {} 104 {} 103 {} 102 {} 101 {} 100 {}
+ 99 {} 98 {} 97 {} 96 {} 95 {} 94 {} 93 {} 92 {} 91 {}
+ 90 {} 89 {} 88 {} 87 {} 86 {} 85 {} 84 {} 83 {} 82 {}
+ 81 {} 80 {} 79 {} 78 {} 77 {} 76 {} 75 {} 74 {} 73 {}
+ 72 {} 71 {} 70 {} 69 {} 68 {} 67 {} 66 {} 65 {} 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 {}}
+
+do_execsql_test 1.19.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES)
+} {20 {} 20 {} 20 {} 20 {} 20 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {} 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {}
+ 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {}
+ 5 {}}
+
+do_execsql_test 1.19.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES)
+} {20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 20 89.6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 18 29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 17 47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 16 59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 15 28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 14 75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 13 78.72.98.87.73.96.74.90.75.91.69.39.7
+ 12 72.98.87.73.96.74.90.75.91.69.39.7 11 98.87.73.96.74.90.75.91.69.39.7
+ 10 87.73.96.74.90.75.91.69.39.7 9 73.96.74.90.75.91.69.39.7
+ 8 96.74.90.75.91.69.39.7 7 74.90.75.91.69.39.7 6 90.75.91.69.39.7
+ 5 75.91.69.39.7 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 19 96.97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 17 84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 16 86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 15 32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 14 25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 13 89.29.9.21.12.88.55.70.58.81.91.52.58
+ 12 29.9.21.12.88.55.70.58.81.91.52.58 11 9.21.12.88.55.70.58.81.91.52.58
+ 10 21.12.88.55.70.58.81.91.52.58 9 12.88.55.70.58.81.91.52.58
+ 8 88.55.70.58.81.91.52.58 7 55.70.58.81.91.52.58 6 70.58.81.91.52.58
+ 5 58.81.91.52.58 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 19 38.46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 17 23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 16 61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 15 3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 14 1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 13 76.63.73.65.20.8.77.19.9.23.15.50.38
+ 12 63.73.65.20.8.77.19.9.23.15.50.38 11 73.65.20.8.77.19.9.23.15.50.38
+ 10 65.20.8.77.19.9.23.15.50.38 9 20.8.77.19.9.23.15.50.38
+ 8 8.77.19.9.23.15.50.38 7 77.19.9.23.15.50.38 6 19.9.23.15.50.38
+ 5 9.23.15.50.38 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 19 39.54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 17 16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 16 85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 15 22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 14 40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 13 4.87.65.5.31.49.2.26.72.13.36.10.83
+ 12 87.65.5.31.49.2.26.72.13.36.10.83 11 65.5.31.49.2.26.72.13.36.10.83
+ 10 5.31.49.2.26.72.13.36.10.83 9 31.49.2.26.72.13.36.10.83
+ 8 49.2.26.72.13.36.10.83 7 2.26.72.13.36.10.83 6 26.72.13.36.10.83
+ 5 72.13.36.10.83 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {} 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 19 91.8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 17 65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 16 85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 15 55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 14 56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 13 42.80.58.11.95.90.85.47.33.14.3.33.82
+ 12 80.58.11.95.90.85.47.33.14.3.33.82 11 58.11.95.90.85.47.33.14.3.33.82
+ 10 11.95.90.85.47.33.14.3.33.82 9 95.90.85.47.33.14.3.33.82
+ 8 90.85.47.33.14.3.33.82 7 85.47.33.14.3.33.82 6 47.33.14.3.33.82
+ 5 33.14.3.33.82 19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {}
+ 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {}
+ 6 {} 5 {}}
+
+do_execsql_test 1.20.2.1 {
+ SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99
+ 99 99 95 99 99 99 99 95 95 84 84 84 84 84 84
+ 84 84 83 83 83 83 82 83 83 83 83}
+
+do_execsql_test 1.20.2.2 {
+ SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1
+ 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 7 3 3
+ 3 3 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 17}
+
+do_execsql_test 1.20.3.1 {
+ SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.20.3.2 {
+ SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.20.3.3 {
+ SELECT row_number() OVER ( ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.20.4.1 {
+ SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.20.4.2 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.20.4.3 {
+ SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 1 2 2 3 3 4 5 6 7 7 7 8 8 8 9 9 9 10
+ 11 11 12 12 12 13 13 14 15 15 15 16 16 16 17
+ 18 19 20 20 21 21 22 22 23 24 25 25 26 26 27
+ 28 28 28 29 29 29 30 30 31 32 32 32 32 33 33
+ 33 33 34 34 35 35 35 35 36 36 37 37 38 38 38
+ 39 40 40 41 42 42 43 43 44 44 45 45 45 45 46
+ 47 48 49 50 51 52 52 53 53 53 54 55 55 55 55
+ 56 56 56 56 57 58 58 59 59 60 61 62 62 62 63
+ 64 65 66 67 68 68 68 69 69 69 70 70 70 71 71
+ 71 72 73 73 74 74 75 76 76 77 77 77 78 79 80
+ 80 80 80 81 81 81 82 83 83 84 85 85 85 86 86
+ 86 87 87 87 87 87 88 88 88 89 90 90 90 91 91
+ 91 92 92 93 93 94 94}
+
+do_execsql_test 1.20.4.4 {
+ SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 2 3 3 3 4 5 6 7 8 8 9 9 9 1 1 2 2 3
+ 3 4 4 5 5 6 7 7 8 8 8 9 9 9 9 9 1 1 2
+ 2 2 3 3 4 5 6 7 7 8 8 8 9 1 1 2 2 3 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 10 10 10 1 2 3
+ 4 4 4 4 5 5 6 7 8 8 8 9 9 9 9 10 1 2 2
+ 2 3 4 4 5 5 6 6 6 7 7 7 8 8 8 9 9 9 1
+ 2 2 2 3 3 4 4 4 4 5 5 6 6 6 7 8 9 10 10
+ 10 1 1 1 2 3 3 4 4 5 5 5 5 6 7 8 8 9 9
+ 10 10 1 1 1 2 3 3 4 4 4 4 5 6 6 7 8 8 1
+ 1 1 2 3 3 3 4 4 4 5 6 6 6 6 7 8 9 9 9
+ 10 10}
+
+do_execsql_test 1.20.4.5 {
+ SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6
+ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7
+ 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10
+ 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+ 10 10 10 10 10}
+
+do_execsql_test 1.20.4.6 {
+ SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
+ 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
+ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4
+ 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5}
+
+do_execsql_test 1.20.5.1 {
+ SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {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 101 102 103 104 105 106
+ 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132
+ 133 134 135 136 137 138 139 140 141 142 143 144 145
+ 146 147 148 149 150 151 152 153 154 155 156 157 158
+ 159 160 161 162 163 164 165 166 167 168 169 170 171
+ 172 173 174 175 176 177 178 179 180 181 182 183 184
+ 185 186 187 188 189 190 191}
+
+do_execsql_test 1.20.5.2 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4
+ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 1 2 3 4 5 6 7 8 9 10 11 12 13
+ 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11
+ 12 13 14 15 16 17 18 19 20 21 1 2 3 4 5 6 7
+ 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 2
+ 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ 18 19 20 21 22}
+
+do_execsql_test 1.20.5.3 {
+ SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 1 3 3 5 5 7 8 9 10 10 10 13 13 13 16 16
+ 16 19 20 20 22 22 22 25 25 27 28 28 28 31 31
+ 31 34 35 36 37 37 39 39 41 41 43 44 45 45 47
+ 47 49 50 50 50 53 53 53 56 56 58 59 59 59 59
+ 63 63 63 63 67 67 69 69 69 69 73 73 75 75 77
+ 77 77 80 81 81 83 84 84 86 86 88 88 90 90 90
+ 90 94 95 96 97 98 99 100 100 102 102 102 105 106
+ 106 106 106 110 110 110 110 114 115 115 117 117 119
+ 120 121 121 121 124 125 126 127 128 129 129 129 132
+ 132 132 135 135 135 138 138 138 141 142 142 144 144
+ 146 147 147 149 149 149 152 153 154 154 154 154 158
+ 158 158 161 162 162 164 165 165 165 168 168 168 171
+ 171 171 171 171 176 176 176 179 180 180 180 183 183
+ 183 186 186 188 188 190 190}
+
+do_execsql_test 1.20.5.4 {
+ SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 2 3 3 3 6 7 8 9 10 10 12 12 12 1 1 3 3
+ 5 5 7 7 9 9 11 12 12 14 14 14 17 17 17 17
+ 17 1 1 3 3 3 6 6 8 9 10 11 11 13 13 13 16
+ 1 1 3 3 5 5 7 7 7 7 11 11 13 14 15 15 15
+ 18 19 19 19 1 2 3 4 4 4 4 8 8 10 11 12 12
+ 12 15 15 15 15 19 1 2 2 2 5 6 6 8 8 10 10
+ 10 13 13 13 16 16 16 19 19 19 1 2 2 2 5 5 7
+ 7 7 7 11 11 13 13 13 16 17 18 19 19 19 1 1
+ 1 4 5 5 7 7 9 9 9 9 13 14 15 15 17 17 19
+ 19 1 1 1 4 5 5 7 7 7 7 11 12 12 14 15 15
+ 1 1 1 4 5 5 5 8 8 8 11 12 12 12 12 16 17
+ 18 18 18 21 21}
+
+do_execsql_test 1.20.5.5 {
+ SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
+ 15 15 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 52 52 52 52 52 52 52 52 52 52 52 52
+ 52 52 52 52 52 52 52 52 52 73 73 73 73 73 73
+ 73 73 73 73 73 73 73 73 73 73 73 73 73 92 92
+ 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92
+ 92 92 92 92 113 113 113 113 113 113 113 113 113
+ 113 113 113 113 113 113 113 113 113 113 113 113 134
+ 134 134 134 134 134 134 134 134 134 134 134 134 134
+ 134 134 134 134 134 134 154 154 154 154 154 154 154
+ 154 154 154 154 154 154 154 154 154 170 170 170 170
+ 170 170 170 170 170 170 170 170 170 170 170 170 170
+ 170 170 170 170 170}
+
+do_execsql_test 1.20.5.6 {
+ SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 15 15 15
+ 15 15 15 15 15 15 15 15 15 15 15 15 31 31 31
+ 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
+ 31 50 50 50 50 50 50 50 50 50 50 50 50 50 50
+ 50 50 50 50 50 50 50 71 71 71 71 71 71 71 71
+ 71 71 71 71 71 71 71 71 1 1 1 1 1 1 1 1 1
+ 1 1 1 1 1 1 1 1 1 1 1 1 22 22 22 22 22 22
+ 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
+ 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
+ 43 43 43 43 43 43 64 64 64 64 64 64 64 64 64
+ 64 64 64 64 64 64 64 64 64 64 64 84 84 84 84
+ 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
+ 84 84 84}
+
+do_execsql_test 1.20.6.1 {
+ SELECT
+ row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ),
+ rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ),
+ dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ FROM t2
+} {1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1
+ 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 15 2 16 15 2 17 15 2
+ 18 15 2 19 15 2 20 15 2 21 15 2 22 15 2 23 15 2 24 15 2
+ 25 15 2 26 15 2 27 15 2 28 15 2 29 15 2 30 15 2 31 31 3
+ 32 31 3 33 31 3 34 31 3 35 31 3 36 31 3 37 31 3 38 31 3
+ 39 31 3 40 31 3 41 31 3 42 31 3 43 31 3 44 31 3 45 31 3
+ 46 31 3 47 31 3 48 31 3 49 31 3 50 50 4 51 50 4 52 50 4
+ 53 50 4 54 50 4 55 50 4 56 50 4 57 50 4 58 50 4 59 50 4
+ 60 50 4 61 50 4 62 50 4 63 50 4 64 50 4 65 50 4 66 50 4
+ 67 50 4 68 50 4 69 50 4 70 50 4 71 71 5 72 71 5 73 71 5
+ 74 71 5 75 71 5 76 71 5 77 71 5 78 71 5 79 71 5 80 71 5
+ 81 71 5 82 71 5 83 71 5 84 71 5 85 71 5 86 71 5 1 1 1 2 1 1
+ 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1
+ 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1
+ 20 1 1 21 1 1 22 22 2 23 22 2 24 22 2 25 22 2 26 22 2 27 22 2
+ 28 22 2 29 22 2 30 22 2 31 22 2 32 22 2 33 22 2 34 22 2
+ 35 22 2 36 22 2 37 22 2 38 22 2 39 22 2 40 22 2 41 22 2
+ 42 22 2 43 43 3 44 43 3 45 43 3 46 43 3 47 43 3 48 43 3
+ 49 43 3 50 43 3 51 43 3 52 43 3 53 43 3 54 43 3 55 43 3
+ 56 43 3 57 43 3 58 43 3 59 43 3 60 43 3 61 43 3 62 43 3
+ 63 43 3 64 64 4 65 64 4 66 64 4 67 64 4 68 64 4 69 64 4
+ 70 64 4 71 64 4 72 64 4 73 64 4 74 64 4 75 64 4 76 64 4
+ 77 64 4 78 64 4 79 64 4 80 64 4 81 64 4 82 64 4 83 64 4
+ 84 84 5 85 84 5 86 84 5 87 84 5 88 84 5 89 84 5 90 84 5
+ 91 84 5 92 84 5 93 84 5 94 84 5 95 84 5 96 84 5 97 84 5
+ 98 84 5 99 84 5 100 84 5 101 84 5 102 84 5 103 84 5 104 84 5
+ 105 84 5}
+
+
+do_test 1.20.7.1 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0053 0.0105 0.0158 0.0211 0.0263 0.0316 0.0368 0.0421 0.0474 0.0526 0.0579 0.0632 0.0684 0.0737 0.0789 0.0842 0.0895 0.0947 0.1000 0.1053 0.1105 0.1158 0.1211 0.1263 0.1316 0.1368 0.1421 0.1474 0.1526 0.1579 0.1632 0.1684 0.1737 0.1789 0.1842 0.1895 0.1947 0.2000 0.2053 0.2105 0.2158 0.2211 0.2263 0.2316 0.2368 0.2421 0.2474 0.2526 0.2579 0.2632 0.2684 0.2737 0.2789 0.2842 0.2895 0.2947 0.3000 0.3053 0.3105 0.3158 0.3211 0.3263 0.3316 0.3368 0.3421 0.3474 0.3526 0.3579 0.3632 0.3684 0.3737 0.3789 0.3842 0.3895 0.3947 0.4000 0.4053 0.4105 0.4158 0.4211 0.4263 0.4316 0.4368 0.4421 0.4474 0.4526 0.4579 0.4632 0.4684 0.4737 0.4789 0.4842 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5263 0.5316 0.5368 0.5421 0.5474 0.5526 0.5579 0.5632 0.5684 0.5737 0.5789 0.5842 0.5895 0.5947 0.6000 0.6053 0.6105 0.6158 0.6211 0.6263 0.6316 0.6368 0.6421 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6789 0.6842 0.6895 0.6947 0.7000 0.7053 0.7105 0.7158 0.7211 0.7263 0.7316 0.7368 0.7421 0.7474 0.7526 0.7579 0.7632 0.7684 0.7737 0.7789 0.7842 0.7895 0.7947 0.8000 0.8053 0.8105 0.8158 0.8211 0.8263 0.8316 0.8368 0.8421 0.8474 0.8526 0.8579 0.8632 0.8684 0.8737 0.8789 0.8842 0.8895 0.8947 0.9000 0.9053 0.9105 0.9158 0.9211 0.9263 0.9316 0.9368 0.9421 0.9474 0.9526 0.9579 0.9632 0.9684 0.9737 0.9789 0.9842 0.9895 0.9947 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.7.2 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.2308 0.3077 0.3846 0.4615 0.5385 0.6154 0.6923 0.7692 0.8462 0.9231 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0556 0.1111 0.1667 0.2222 0.2778 0.3333 0.3889 0.4444 0.5000 0.5556 0.6111 0.6667 0.7222 0.7778 0.8333 0.8889 0.9444 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0000 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1.0000 0.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.7.3 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0105 0.0105 0.0211 0.0211 0.0316 0.0368 0.0421 0.0474 0.0474 0.0474 0.0632 0.0632 0.0632 0.0789 0.0789 0.0789 0.0947 0.1000 0.1000 0.1105 0.1105 0.1105 0.1263 0.1263 0.1368 0.1421 0.1421 0.1421 0.1579 0.1579 0.1579 0.1737 0.1789 0.1842 0.1895 0.1895 0.2000 0.2000 0.2105 0.2105 0.2211 0.2263 0.2316 0.2316 0.2421 0.2421 0.2526 0.2579 0.2579 0.2579 0.2737 0.2737 0.2737 0.2895 0.2895 0.3000 0.3053 0.3053 0.3053 0.3053 0.3263 0.3263 0.3263 0.3263 0.3474 0.3474 0.3579 0.3579 0.3579 0.3579 0.3789 0.3789 0.3895 0.3895 0.4000 0.4000 0.4000 0.4158 0.4211 0.4211 0.4316 0.4368 0.4368 0.4474 0.4474 0.4579 0.4579 0.4684 0.4684 0.4684 0.4684 0.4895 0.4947 0.5000 0.5053 0.5105 0.5158 0.5211 0.5211 0.5316 0.5316 0.5316 0.5474 0.5526 0.5526 0.5526 0.5526 0.5737 0.5737 0.5737 0.5737 0.5947 0.6000 0.6000 0.6105 0.6105 0.6211 0.6263 0.6316 0.6316 0.6316 0.6474 0.6526 0.6579 0.6632 0.6684 0.6737 0.6737 0.6737 0.6895 0.6895 0.6895 0.7053 0.7053 0.7053 0.7211 0.7211 0.7211 0.7368 0.7421 0.7421 0.7526 0.7526 0.7632 0.7684 0.7684 0.7789 0.7789 0.7789 0.7947 0.8000 0.8053 0.8053 0.8053 0.8053 0.8263 0.8263 0.8263 0.8421 0.8474 0.8474 0.8579 0.8632 0.8632 0.8632 0.8789 0.8789 0.8789 0.8947 0.8947 0.8947 0.8947 0.8947 0.9211 0.9211 0.9211 0.9368 0.9421 0.9421 0.9421 0.9579 0.9579 0.9579 0.9737 0.9737 0.9842 0.9842 0.9947 0.9947}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.7.4 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0769 0.1538 0.1538 0.1538 0.3846 0.4615 0.5385 0.6154 0.6923 0.6923 0.8462 0.8462 0.8462 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.4000 0.4000 0.5000 0.5500 0.5500 0.6500 0.6500 0.6500 0.8000 0.8000 0.8000 0.8000 0.8000 0.0000 0.0000 0.1333 0.1333 0.1333 0.3333 0.3333 0.4667 0.5333 0.6000 0.6667 0.6667 0.8000 0.8000 0.8000 1.0000 0.0000 0.0000 0.1000 0.1000 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6500 0.7000 0.7000 0.7000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0556 0.1111 0.1667 0.1667 0.1667 0.1667 0.3889 0.3889 0.5000 0.5556 0.6111 0.6111 0.6111 0.7778 0.7778 0.7778 0.7778 1.0000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2500 0.2500 0.3500 0.3500 0.4500 0.4500 0.4500 0.6000 0.6000 0.6000 0.7500 0.7500 0.7500 0.9000 0.9000 0.9000 0.0000 0.0500 0.0500 0.0500 0.2000 0.2000 0.3000 0.3000 0.3000 0.3000 0.5000 0.5000 0.6000 0.6000 0.6000 0.7500 0.8000 0.8500 0.9000 0.9000 0.9000 0.0000 0.0000 0.0000 0.1579 0.2105 0.2105 0.3158 0.3158 0.4211 0.4211 0.4211 0.4211 0.6316 0.6842 0.7368 0.7368 0.8421 0.8421 0.9474 0.9474 0.0000 0.0000 0.0000 0.2000 0.2667 0.2667 0.4000 0.4000 0.4000 0.4000 0.6667 0.7333 0.7333 0.8667 0.9333 0.9333 0.0000 0.0000 0.0000 0.1429 0.1905 0.1905 0.1905 0.3333 0.3333 0.3333 0.4762 0.5238 0.5238 0.5238 0.5238 0.7143 0.7619 0.8095 0.8095 0.8095 0.9524 0.9524}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.7.5 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.0737 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.1842 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.2684 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.3789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.4789 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.5895 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.7000 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8053 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895 0.8895}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.7.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER (PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.1647 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.3529 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.5765 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.8235 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.2019 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.4038 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.6058 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981 0.7981}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0052 0.0105 0.0157 0.0209 0.0262 0.0314 0.0366 0.0419 0.0471 0.0524 0.0576 0.0628 0.0681 0.0733 0.0785 0.0838 0.0890 0.0942 0.0995 0.1047 0.1099 0.1152 0.1204 0.1257 0.1309 0.1361 0.1414 0.1466 0.1518 0.1571 0.1623 0.1675 0.1728 0.1780 0.1832 0.1885 0.1937 0.1990 0.2042 0.2094 0.2147 0.2199 0.2251 0.2304 0.2356 0.2408 0.2461 0.2513 0.2565 0.2618 0.2670 0.2723 0.2775 0.2827 0.2880 0.2932 0.2984 0.3037 0.3089 0.3141 0.3194 0.3246 0.3298 0.3351 0.3403 0.3455 0.3508 0.3560 0.3613 0.3665 0.3717 0.3770 0.3822 0.3874 0.3927 0.3979 0.4031 0.4084 0.4136 0.4188 0.4241 0.4293 0.4346 0.4398 0.4450 0.4503 0.4555 0.4607 0.4660 0.4712 0.4764 0.4817 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5236 0.5288 0.5340 0.5393 0.5445 0.5497 0.5550 0.5602 0.5654 0.5707 0.5759 0.5812 0.5864 0.5916 0.5969 0.6021 0.6073 0.6126 0.6178 0.6230 0.6283 0.6335 0.6387 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6754 0.6806 0.6859 0.6911 0.6963 0.7016 0.7068 0.7120 0.7173 0.7225 0.7277 0.7330 0.7382 0.7435 0.7487 0.7539 0.7592 0.7644 0.7696 0.7749 0.7801 0.7853 0.7906 0.7958 0.8010 0.8063 0.8115 0.8168 0.8220 0.8272 0.8325 0.8377 0.8429 0.8482 0.8534 0.8586 0.8639 0.8691 0.8743 0.8796 0.8848 0.8901 0.8953 0.9005 0.9058 0.9110 0.9162 0.9215 0.9267 0.9319 0.9372 0.9424 0.9476 0.9529 0.9581 0.9634 0.9686 0.9738 0.9791 0.9843 0.9895 0.9948 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.2143 0.2857 0.3571 0.4286 0.5000 0.5714 0.6429 0.7143 0.7857 0.8571 0.9286 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0476 0.0952 0.1429 0.1905 0.2381 0.2857 0.3333 0.3810 0.4286 0.4762 0.5238 0.5714 0.6190 0.6667 0.7143 0.7619 0.8095 0.8571 0.9048 0.9524 1.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 0.0625 0.1250 0.1875 0.2500 0.3125 0.3750 0.4375 0.5000 0.5625 0.6250 0.6875 0.7500 0.8125 0.8750 0.9375 1.0000 0.0455 0.0909 0.1364 0.1818 0.2273 0.2727 0.3182 0.3636 0.4091 0.4545 0.5000 0.5455 0.5909 0.6364 0.6818 0.7273 0.7727 0.8182 0.8636 0.9091 0.9545 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0105 0.0105 0.0209 0.0209 0.0314 0.0314 0.0366 0.0419 0.0471 0.0628 0.0628 0.0628 0.0785 0.0785 0.0785 0.0942 0.0942 0.0942 0.0995 0.1099 0.1099 0.1257 0.1257 0.1257 0.1361 0.1361 0.1414 0.1571 0.1571 0.1571 0.1728 0.1728 0.1728 0.1780 0.1832 0.1885 0.1990 0.1990 0.2094 0.2094 0.2199 0.2199 0.2251 0.2304 0.2408 0.2408 0.2513 0.2513 0.2565 0.2723 0.2723 0.2723 0.2880 0.2880 0.2880 0.2984 0.2984 0.3037 0.3246 0.3246 0.3246 0.3246 0.3455 0.3455 0.3455 0.3455 0.3560 0.3560 0.3770 0.3770 0.3770 0.3770 0.3874 0.3874 0.3979 0.3979 0.4136 0.4136 0.4136 0.4188 0.4293 0.4293 0.4346 0.4450 0.4450 0.4555 0.4555 0.4660 0.4660 0.4869 0.4869 0.4869 0.4869 0.4921 0.4974 0.5026 0.5079 0.5131 0.5183 0.5288 0.5288 0.5445 0.5445 0.5445 0.5497 0.5707 0.5707 0.5707 0.5707 0.5916 0.5916 0.5916 0.5916 0.5969 0.6073 0.6073 0.6178 0.6178 0.6230 0.6283 0.6440 0.6440 0.6440 0.6492 0.6545 0.6597 0.6649 0.6702 0.6859 0.6859 0.6859 0.7016 0.7016 0.7016 0.7173 0.7173 0.7173 0.7330 0.7330 0.7330 0.7382 0.7487 0.7487 0.7592 0.7592 0.7644 0.7749 0.7749 0.7906 0.7906 0.7906 0.7958 0.8010 0.8220 0.8220 0.8220 0.8220 0.8377 0.8377 0.8377 0.8429 0.8534 0.8534 0.8586 0.8743 0.8743 0.8743 0.8901 0.8901 0.8901 0.9162 0.9162 0.9162 0.9162 0.9162 0.9319 0.9319 0.9319 0.9372 0.9529 0.9529 0.9529 0.9686 0.9686 0.9686 0.9791 0.9791 0.9895 0.9895 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0714 0.1429 0.3571 0.3571 0.3571 0.4286 0.5000 0.5714 0.6429 0.7857 0.7857 1.0000 1.0000 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.3810 0.3810 0.4762 0.4762 0.5238 0.6190 0.6190 0.7619 0.7619 0.7619 1.0000 1.0000 1.0000 1.0000 1.0000 0.1250 0.1250 0.3125 0.3125 0.3125 0.4375 0.4375 0.5000 0.5625 0.6250 0.7500 0.7500 0.9375 0.9375 0.9375 1.0000 0.0952 0.0952 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.6190 0.6667 0.8095 0.8095 0.8095 0.8571 1.0000 1.0000 1.0000 0.0526 0.1053 0.1579 0.3684 0.3684 0.3684 0.3684 0.4737 0.4737 0.5263 0.5789 0.7368 0.7368 0.7368 0.9474 0.9474 0.9474 0.9474 1.0000 0.0476 0.1905 0.1905 0.1905 0.2381 0.3333 0.3333 0.4286 0.4286 0.5714 0.5714 0.5714 0.7143 0.7143 0.7143 0.8571 0.8571 0.8571 1.0000 1.0000 1.0000 0.0476 0.1905 0.1905 0.1905 0.2857 0.2857 0.4762 0.4762 0.4762 0.4762 0.5714 0.5714 0.7143 0.7143 0.7143 0.7619 0.8095 0.8571 1.0000 1.0000 1.0000 0.1500 0.1500 0.1500 0.2000 0.3000 0.3000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6500 0.7000 0.8000 0.8000 0.9000 0.9000 1.0000 1.0000 0.1875 0.1875 0.1875 0.2500 0.3750 0.3750 0.6250 0.6250 0.6250 0.6250 0.6875 0.8125 0.8125 0.8750 1.0000 1.0000 0.1364 0.1364 0.1364 0.1818 0.3182 0.3182 0.3182 0.4545 0.4545 0.4545 0.5000 0.6818 0.6818 0.6818 0.6818 0.7273 0.7727 0.9091 0.9091 0.9091 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.0733 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.1832 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.2670 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.3770 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.4764 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.5864 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.6963 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8010 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 0.8848 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.1628 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.3488 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.5698 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 0.8140 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.2000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.4000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.6000 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 0.7905 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.1 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 90.0000 91.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.2 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.3 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 88.0000 89.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.4 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.5 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.6 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 1.20.8.7 {
+ set myres {}
+ foreach r [db eval {SELECT ntile(105) OVER ( ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 4.0000 4.0000 5.0000 5.0000 6.0000 6.0000 7.0000 7.0000 8.0000 8.0000 9.0000 9.0000 10.0000 10.0000 11.0000 11.0000 12.0000 12.0000 13.0000 13.0000 14.0000 14.0000 15.0000 15.0000 16.0000 16.0000 17.0000 17.0000 18.0000 18.0000 19.0000 19.0000 20.0000 20.0000 21.0000 21.0000 22.0000 22.0000 23.0000 23.0000 24.0000 24.0000 25.0000 25.0000 26.0000 26.0000 27.0000 27.0000 28.0000 28.0000 29.0000 29.0000 30.0000 30.0000 31.0000 31.0000 32.0000 32.0000 33.0000 33.0000 34.0000 34.0000 35.0000 35.0000 36.0000 36.0000 37.0000 37.0000 38.0000 38.0000 39.0000 39.0000 40.0000 40.0000 41.0000 41.0000 42.0000 42.0000 43.0000 43.0000 44.0000 44.0000 45.0000 45.0000 46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 49.0000 49.0000 50.0000 50.0000 51.0000 51.0000 52.0000 52.0000 53.0000 53.0000 54.0000 54.0000 55.0000 55.0000 56.0000 56.0000 57.0000 57.0000 58.0000 58.0000 59.0000 59.0000 60.0000 60.0000 61.0000 61.0000 62.0000 62.0000 63.0000 63.0000 64.0000 64.0000 65.0000 65.0000 66.0000 66.0000 67.0000 67.0000 68.0000 68.0000 69.0000 69.0000 70.0000 70.0000 71.0000 71.0000 72.0000 72.0000 73.0000 73.0000 74.0000 74.0000 75.0000 75.0000 76.0000 76.0000 77.0000 77.0000 78.0000 78.0000 79.0000 79.0000 80.0000 80.0000 81.0000 81.0000 82.0000 82.0000 83.0000 83.0000 84.0000 84.0000 85.0000 85.0000 86.0000 86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000 93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000 100.0000 101.0000 102.0000 103.0000 104.0000 105.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 1.20.9.1 {
+ SELECT last_value(a+b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 216}
+
+do_execsql_test 1.20.9.2 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {223 223 223 223 223 223 223 223 223 223 223 223 223
+ 196 210 210 210 210 210 210 210 210 210 210 210 210
+ 210 210 210 210 210 210 210 210 263 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 234 279
+ 279 279 279 279 279 279 279 279 279 279 279 279 279
+ 279 279 279 279 279 279 221 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 235
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 189 212 212 212 212 212
+ 212 212 212 212 212 212 212 212 212 212 212 212 212
+ 212 212 207 207 207 207 207 207 207 207 207 207 207
+ 207 207 207 207 207 207 207 207 207 216 232 232 232
+ 232 232 232 232 232 232 232 232 232 232 232 232 250
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 249}
+
+do_execsql_test 1.20.9.3 {
+ SELECT last_value(a+b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 120}
+
+do_execsql_test 1.20.9.4 {
+ SELECT last_value(a+b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {240 240 240 240 240 240 240 240 240 240 240 240 240
+ 218 263 263 263 263 263 263 263 263 263 263 263 263
+ 263 263 263 263 263 263 263 263 261 280 280 280 280
+ 280 280 280 280 280 280 280 280 280 280 280 228 252
+ 252 252 252 252 252 252 252 252 252 252 252 252 252
+ 252 252 252 252 252 252 130 171 171 171 171 171 171
+ 171 171 171 171 171 171 171 171 171 171 171 171 271
+ 274 274 274 274 274 274 274 274 274 274 274 274 274
+ 274 274 274 274 274 274 274 213 226 226 226 226 226
+ 226 226 226 226 226 226 226 226 226 226 226 226 226
+ 226 226 195 124 124 124 124 124 124 124 124 124 124
+ 124 124 124 124 124 124 124 124 124 119 198 198 198
+ 198 198 198 198 198 198 198 198 198 198 198 198 171
+ 276 276 276 276 276 276 276 276 276 276 276 276 276
+ 276 276 276 276 276 276 276 276 120}
+
+do_execsql_test 1.20.9.5 {
+ SELECT last_value(a+b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 229 229 229 229 229
+ 229 229 229 229 229 229 229 229 249}
+
+do_execsql_test 1.20.9.6 {
+ SELECT last_value(a+b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.10.1 {
+ SELECT nth_value(b,b+1) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {98 9 73 75 43 78 32 4 5 25 27 15 31 24 43 98
+ 94 79 77 61 22 79 8 73 3 85 43 34 98 36 63 91
+ 11 20 21 75 90 56 96 84 5 28 33 5 56 59 81 19
+ 87 36 2 26 63 73 89 95 74 73 79 29 70 65 33
+ 14 26 47 94 14 15 5 72 41 11 75 19 53 91 79
+ 37 91 93 59 58 36 23 84 33 73 47 58 34 58 73
+ 15 13 7 11 99 31 66 38 80 79 95 60 59 19 59
+ {} 85 39 27 {} 9 59 75 91 33 {} 84 {} 33 50
+ {} {} 36 77 29 {} 30 {} 12 {} 17 75 58 62 91
+ 58 {} {} 50 {} 27 75 {} {} {} 33 {} {} {} {}
+ 62 50 17 36 36 95 {} {} {} {} {} 10 {} {} {}
+ 99 {} {} {} {} {} {} {} 30 {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.10.2 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 61 {} {} {} 81 {} 91 {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 22 {} {} {} 12
+ {} {} {} {} {} {} {} {} {} {} 43 {} {} {} {}
+ {} 83 {} {} {} {} {} {} {} 33 {} {} {} {} {}
+ {} 94 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 85 {} {} {} {} {} {} 95 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 66 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 87 {} {} {} {} {} 37 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} 58 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 19 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.10.3 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {2 2 2 2 2 3 5 7 7 8 8 9 9 10 11 12 12 12
+ 13 15 15 16 16 16 19 20 21 22 23 23 25 26 26
+ 27 29 30 30 31 32 33 33 33 34 34 35 36 36 36
+ 37 38 39 39 40 41 41 43 43 44 46 47 47 47 49
+ 50 51 52 54 55 56 56 56 57 58 58 59 59 59 60
+ 61 62 63 64 65 66 67 69 70 72 73 73 74 74 74
+ 75 77 78 79 80 81 82 83 84 84 84 85 86 87 87
+ 88 89 89 90 90 91 91 91 93 93 94 95 96 96 96
+ 97 98 99 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.10.4 {
+ SELECT nth_value(b,b+1) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {90 {} {} {} {} {} {} {} {} {} {} {} {} {} 11
+ 11 61 61 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 72 72 {} {} {} {} {}
+ {} {} {} {} {} {} 23 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 85 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 86 86 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 47 47
+ 47 97 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 58 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 49 49 49 99 {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.10.5 {
+ SELECT nth_value(b,b+1) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {65 72 81 34 41 35 73 74 14 15 32 53 1 2 35 5
+ 74 95 55 61 75 63 34 81 12 91 74 93 43 33 22
+ 75 56 56 23 85 72 23 33 84 22 15 93 73 12 6
+ 46 43 75 75 36 87 54 87 85 43 15 84 85 56 66
+ 83 36 97 85 78 34 94 75 33 65 17 36 68 7 15
+ 94 38 78 27 95 96 36 68 7 15 16 38 89 66 56
+ 38 76 89 89 47 85 56 59 {} 8 88 27 95 16 {}
+ 98 79 39 59 16 {} {} 8 16 98 36 66 {} 99 29
+ 59 97 8 {} {} {} 27 17 8 {} 8 58 {} 98 {} {}
+ {} 29 87 19 {} 89 {} {} 37 {} {} {} 59 59 58
+ 8 99 {} {} 98 29 {} {} {} {} 58 {} 89 {} {}
+ {} {} {} {} {} {} {} {} {} {} {} 19 {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.10.6 {
+ SELECT nth_value(b,b+1) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.11.1 {
+ SELECT first_value(b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {81 89 89 89 89 81 96 59 38 68 39 62 91 46 6
+ 99 97 27 46 78 54 97 8 67 29 93 84 77 23 16
+ 16 93 65 35 47 7 86 74 61 91 85 24 85 43 59
+ 12 32 56 3 91 22 90 55 15 28 89 25 47 1 56 40
+ 43 56 16 75 36 89 98 76 81 4 94 42 30 78 33
+ 29 53 63 2 87 37 80 84 72 41 9 61 73 95 65 13
+ 58 96 98 1 21 74 65 35 5 73 11 51 87 41 12 8
+ 20 31 31 15 95 22 73 79 88 34 8 11 49 34 90
+ 59 96 60 55 75 77 44 2 7 85 57 74 29 70 59 19
+ 39 26 26 47 80 90 36 58 47 9 72 72 66 33 93
+ 75 64 81 9 23 37 13 12 14 62 91 36 91 33 15
+ 34 36 99 3 95 69 58 52 30 50 84 10 84 33 21
+ 39 44 58 30 38 34 83}
+
+do_execsql_test 1.20.11.2 {
+ SELECT first_value(b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {40 90 90 90 90 40 30 80 20 90 60 70 80 90 91
+ 81 81 81 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 12 62 62 62 62 12 32 22 42 2 72
+ 12 22 2 72 72 23 93 93 93 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 84 54 54 54 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 35
+ 65 65 65 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 46 96 96 96 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 27 97 97 97 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 68
+ 38 38 38 38 68 78 8 28 98 78 58 98 8 88 8 59
+ 89 89 89 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.20.11.3 {
+ SELECT first_value(b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 1 1 1 1 1 2 2 3 3 4 5 6 7 7 7 8 8 8
+ 9 9 9 10 11 11 12 12 12 13 13 14 15 15 15 16
+ 16 16 17 19 20 21 21 22 22 23 23 24 25 26 26
+ 27 27 28 29 29 29 30 30 30 31 31 32 33 33 33
+ 33 34 34 34 34 35 35 36 36 36 36 37 37 38 38
+ 39 39 39 40 41 41 42 43 43 44 44 46 46 47 47
+ 47 47 49 50 51 52 53 54 55 55 56 56 56 57 58
+ 58 58 58 59 59 59 59 60 61 61 62 62 63 64 65
+ 65 65 66 67 68 69 70 72 72 72 73 73 73 74 74
+ 74 75 75 75 76 77 77 78 78 79 80 80 81 81 81
+ 82 83 84 84 84 84 85 85 85 86 87 87 88 89 89
+ 89 90 90 90 91 91 91 91 91 93 93 93 94 95 95
+ 95 96 96 96 97 97}
+
+do_execsql_test 1.20.11.4 {
+ SELECT first_value(b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {20 10 10 10 10 20 30 30 30 40 50 60 70 80 1 1
+ 1 1 1 1 11 11 21 21 31 31 41 41 51 61 61 81
+ 81 81 91 2 2 2 2 2 2 12 12 12 22 22 32 42
+ 52 62 62 3 3 3 3 3 3 13 13 23 23 33 33 33
+ 33 43 43 53 63 73 73 73 14 4 4 4 4 14 24 34
+ 34 34 34 44 44 54 64 74 74 74 84 15 5 5 5 5
+ 15 15 15 25 35 35 55 55 65 65 65 75 75 75 85
+ 85 16 6 6 6 6 16 16 16 26 26 36 36 36 36 46
+ 46 56 56 56 66 76 7 7 7 7 7 7 7 17 27 27 37
+ 37 47 47 47 47 57 67 77 77 8 8 8 8 8 8 8 28
+ 38 38 58 58 58 58 68 78 9 9 9 9 9 9 9 19 29
+ 29 29 39 39 39 49 59 59 59 59 69 79 89}
+
+do_execsql_test 1.20.11.5 {
+ SELECT first_value(b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {40 90 90 90 90 40 30 80 20 90 60 70 80 90 30
+ 50 10 30 81 91 61 91 91 1 81 41 61 1 21 11 51
+ 41 31 31 11 81 91 91 21 62 12 32 22 42 2 72
+ 12 22 2 72 72 12 62 52 82 93 23 93 43 3 43 33
+ 53 63 73 13 73 73 33 93 23 13 33 3 33 83 54
+ 84 74 24 4 94 84 74 34 34 44 74 64 14 34 84
+ 84 44 34 65 35 85 85 55 15 25 75 95 65 65 35
+ 5 15 95 55 75 85 75 15 95 96 46 6 46 16 16 86
+ 56 56 56 16 36 76 96 96 26 26 36 66 36 36 97
+ 27 97 67 77 47 7 47 87 37 87 77 7 57 47 47 37
+ 27 17 7 38 68 78 8 28 98 78 58 98 8 88 8 58
+ 58 58 38 89 59 39 99 29 59 89 89 29 9 79 49
+ 59 29 59 19 39 9}
+
+do_execsql_test 1.20.11.6 {
+ SELECT first_value(b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.12.1 {
+ SELECT lead(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {96 9 11 89 32 53 91 30 51 56 54 73 22 59 75
+ 74 78 8 16 65 15 8 31 87 90 12 32 96 74 76 37
+ 85 90 15 35 2 60 36 75 9 51 47 63 51 90 26 42
+ 26 8 76 80 90 37 87 56 79 5 87 8 2 39 73 64
+ 36 90 72 78 36 73 51 33 20 41 2 26 37 33 8 14
+ 33 81 55 1 9 12 39 64 87 72 34 82 21 34 99 62
+ 74 41 69 22 75 27 58 8 79 77 26 26 55 {} 29
+ 30 7 {} 66 55 2 34 64 {} 33 {} 44 84 {} {} 95
+ 85 19 {} 83 {} 91 {} {} 9 50 91 33 34 {} {}
+ 84 {} 7 9 {} {} {} 44 {} {} {} {} 91 84 {} 95
+ 95 52 {} {} {} {} {} 21 {} {} {} 58 {} {} {}
+ {} {} {} {} 83 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {}}
+
+do_execsql_test 1.20.12.2 {
+ SELECT lead(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 81 {} {} {} 21 {} {} {} {} {} {}
+ {} {} {} {} {} {} 62 {} {} {} 12 {} {} {} 72
+ {} {} {} {} {} {} {} {} {} {} 53 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 34 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} 95 {} {} {} {} {} {} 85 {}
+ {} {} {} {} {} {} {} {} {} 56 {} 36 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 57 {} {} {} {} {} 7 {} {} {} {}
+ {} {} {} {} {} {} 8 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 9 {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.12.3 {
+ SELECT lead(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1 2 3 3 5 6 7 8 8 9 9 10 11 12 12 13 13
+ 14 15 16 16 17 19 20 21 22 23 24 25 26 27 27
+ 28 29 30 31 32 33 33 33 34 34 35 36 36 36 37
+ 38 39 39 40 41 42 43 43 44 46 47 47 47 49 50
+ 52 53 54 55 56 56 57 58 58 58 59 59 59 60 61
+ 62 62 64 65 65 67 69 70 72 72 73 74 74 75 75
+ 75 77 78 80 81 81 83 84 84 85 85 85 87 88 89
+ 89 89 90 90 91 91 91 93 93 94 95 95 96 97 97
+ 98 99 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.12.4 {
+ SELECT lead(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {80 {} {} {} {} {} {} {} {} {} {} {} {} {} 1
+ 11 81 81 {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} 12 12 72 82 {} {} {} {} {} {}
+ {} {} {} {} {} {} 13 23 73 73 {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 34 84 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} 35 85 85 95 {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} 36 86 96 96 {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 37 47
+ 47 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} 58 58 68 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} 39 49 59 {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.12.5 {
+ SELECT lead(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {34 72 91 74 21 55 23 94 84 95 2 13 61 22 55
+ 55 94 85 75 81 65 73 74 21 72 12 94 33 63 73
+ 72 96 36 76 3 25 62 3 73 34 12 46 43 93 72 16
+ 86 63 15 65 36 77 24 57 25 53 95 34 95 16 97
+ 74 97 67 25 98 44 34 65 54 5 68 96 28 47 95
+ 34 39 8 38 6 46 96 28 47 95 56 39 99 97 76 8
+ 26 9 79 27 95 16 29 {} 58 58 77 85 56 {} 98
+ 29 {} 19 96 {} {} 78 56 98 36 97 {} 89 89 29
+ 47 78 {} {} {} 38 68 58 {} 58 38 {} 98 {} {}
+ {} 39 57 9 {} 79 {} {} 7 {} {} {} 9 29 38 78
+ {} {} {} 8 39 {} {} {} {} 59 {} 99 {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 9 {} {} {} {}
+ {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.12.6 {
+ SELECT lead(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.13.1 {
+ SELECT lag(b,b) OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} 38 {} {} {} {}
+ {} {} {} 6 {} {} {} {} {} 81 46 6 {} {} {} {}
+ 23 {} {} {} {} {} 27 {} {} {} 35 6 {} 12 {}
+ 23 {} {} 61 84 {} 93 39 47 {} 54 46 96 56 {}
+ 16 {} {} {} {} 89 {} 16 43 {} 85 56 29 99 53
+ {} 59 {} {} 91 59 53 84 99 {} 93 63 47 {} {}
+ 98 33 67 35 75 1 23 13 55 27 75 98 35 73 63 2
+ 21 27 13 24 86 23 84 31 20 94 61 65 75 23 36
+ 94 55 90 41 77 96 56 29 40 12 89 63 11 5 73
+ 79 1 16 28 31 73 5 39 53 63 41 11 40 2 13 33
+ 9 29 90 47 72 9 73 30 44 33 74 93 29 74 42 34
+ 63 41 34 96 47 77 1 36 74 72 14 36 26 77 9 72
+ 64 8 91 31 52 30}
+
+do_execsql_test 1.20.13.2 {
+ SELECT lag(b,b) OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 {} 81 {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} 22 {} {} {} 12
+ {} {} 62 {} {} {} {} {} {} {} 23 {} {} {} {}
+ {} {} {} {} {} {} {} 43 {} 23 {} {} {} {} {}
+ {} 54 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} 75 {}
+ {} {} {} {} {} 55 {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} 47 {} {} {} {}
+ {} 27 7 {} {} {} {} {} {} {} {} {} 68 {} 8 {}
+ {} {} {} {} {} {} {} {} {} {} {} {} 89 {} {}
+ {} {} {} {} {} 29 9 {} {} {}}
+
+do_execsql_test 1.20.13.3 {
+ SELECT lag(b,b) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {{} 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 5 6 6
+ 6 7 7 7 7 7 8 8 8 8 8 8 9 9 9 9 9 9 9
+ 9 9 9 10 10 10 10 11 11 11 11 11 12 12 12 12
+ 13 13 13 13 13 14 15 15 15 15 16 16 16 16 16
+ 17 19 20 20 21 21 21 21 22 22 22 22 23 23 23
+ 23 23 24 23 24 24 25 26 26 26 26 26 26 26 26
+ 26 26 26 27 27 27 27 28 29 29 29 29 30 30 30
+ 30 30 30 31 31 31 31 31 32 32 32 32 32 32 31
+ 32 33 33 33 33 33 33 34 34 34 34 34 34 34 34
+ 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37
+ 38 38 38 38 38 38 39 39 39 39 40 40 41 41 42
+ 43 42 43 43 43 43 44 44 44 46 46 46 47 47 47
+ 47 47}
+
+do_execsql_test 1.20.13.4 {
+ SELECT lag(b,b) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ 1 {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.13.5 {
+ SELECT lag(b,b) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} 30 {} {}
+ {} {} {} {} 91 {} {} {} 61 80 81 {} {} {} {}
+ 1 {} {} {} 30 {} 21 90 61 {} 22 {} 11 41 12
+ {} {} 62 {} {} {} {} 31 {} 50 23 30 21 90 {}
+ {} 62 {} {} 81 {} 22 43 62 23 32 {} 91 {} 90
+ 93 54 {} {} 90 72 12 22 90 81 83 23 80 20 72
+ 43 51 33 80 90 2 34 54 1 20 62 12 13 75 44 30
+ 93 91 1 21 55 61 61 13 85 3 65 65 91 73 33 93
+ 55 84 62 31 11 65 35 85 33 55 15 12 75 22 3
+ 73 65 36 85 43 95 43 13 47 44 65 65 96 36 27
+ 7 46 34 94 47 36 73 34 35 73 68 24 8 75 85 75
+ 66 34 95 36 84 77 46 34 84 47 89 65 36 16 38
+ 76 58 57 29 9 44 56 17}
+
+do_execsql_test 1.20.13.6 {
+ SELECT lag(b,b) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.14.1 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {81.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.96.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.59.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.38.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.81.96.59.68.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.96.59.38.39.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.59.38.68.62.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.38.68.39.91.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 38.68.39.62.46.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 68.39.62.91.6.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.62.91.46.99.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.46.6.97.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.46.6.99.27.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.6.99.97.46.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 6.99.97.27.78.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.97.27.46.54.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.27.46.78.97.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 27.46.78.54.8.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 46.78.54.97.67.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.54.97.8.29.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 54.97.8.67.93.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 97.8.67.29.84.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.67.29.93.77.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 67.29.93.84.23.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.93.84.77.16.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.84.77.23.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.77.23.16.93.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.23.16.16.65.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.16.16.93.35.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.16.93.65.47.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.93.65.35.7.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.65.35.47.86.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.47.7.74.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.47.7.86.61.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.7.86.74.91.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.86.74.61.85.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 86.74.61.91.24.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.61.91.85.85.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.91.85.24.43.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.85.24.85.59.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.24.85.43.12.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 24.85.43.59.32.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.43.59.12.56.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.59.12.32.3.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.12.32.56.91.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.32.56.3.22.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 32.56.3.91.90.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.3.91.22.55.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.91.22.90.15.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.22.90.55.28.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.90.55.15.89.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.55.15.28.25.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.15.28.89.47.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.28.89.25.1.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 28.89.25.47.56.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.25.47.1.40.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 25.47.1.56.43.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.1.56.40.56.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.56.40.43.16.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.40.43.56.75.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 40.43.56.16.36.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 43.56.16.75.89.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 56.16.75.36.98.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 16.75.36.89.76.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.36.89.98.81.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.89.98.76.4.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 89.98.76.81.94.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.76.81.4.42.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 76.81.4.94.30.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.4.94.42.78.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 4.94.42.30.33.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 94.42.30.78.29.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 42.30.78.33.53.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.78.33.29.63.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 78.33.29.53.2.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.29.53.63.87.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.53.63.2.37.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 53.63.2.87.80.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 63.2.87.37.84.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.87.37.80.72.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.37.80.84.41.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.80.84.72.9.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.84.72.41.61.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.72.41.9.73.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.41.9.61.95.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.9.61.73.65.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.61.73.95.13.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 61.73.95.65.58.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.95.65.13.96.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.65.13.58.98.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.13.58.96.1.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.58.96.98.21.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.96.98.1.74.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.98.1.21.65.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 98.1.21.74.35.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 1.21.74.65.5.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 21.74.65.35.73.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.65.35.5.11.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 65.35.5.73.51.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 35.5.73.11.87.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 5.73.11.51.41.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.11.51.87.12.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.51.87.41.8.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 51.87.41.12.20.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 87.41.12.8.31.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 41.12.8.20.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.8.20.31.15.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.20.31.31.95.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 20.31.31.15.22.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.31.15.95.73.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 31.15.95.22.79.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.95.22.73.88.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.22.73.79.34.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 22.73.79.88.8.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 73.79.88.34.11.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 79.88.34.8.49.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 88.34.8.11.34.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.8.11.49.90.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 8.11.49.34.59.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 11.49.34.90.96.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 49.34.90.59.60.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.90.59.96.55.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.59.96.60.75.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.96.60.55.77.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 96.60.55.75.44.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 60.55.75.77.2.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 55.75.77.44.7.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.77.44.2.85.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 77.44.2.7.57.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 44.2.7.85.74.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 2.7.85.57.29.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 7.85.57.74.70.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 85.57.74.29.59.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 57.74.29.70.19.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 74.29.70.59.39.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 29.70.59.19.26.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 70.59.19.39.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 59.19.39.26.47.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 19.39.26.26.80.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 39.26.26.47.90.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.26.47.80.36.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 26.47.80.90.58.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.80.90.36.47.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 80.90.36.58.9.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 90.36.58.47.72.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.58.47.9.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.47.9.72.66.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 47.9.72.72.33.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.72.72.66.93.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.72.66.33.75.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 72.66.33.93.64.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 66.33.93.75.81.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.93.75.64.9.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 93.75.64.81.23.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 75.64.81.9.37.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 64.81.9.23.13.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 81.9.23.37.12.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 9.23.37.13.14.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 23.37.13.12.62.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 37.13.12.14.91.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 13.12.14.62.36.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 12.14.62.91.91.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 14.62.91.36.33.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 62.91.36.91.15.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.36.91.33.34.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.91.33.15.36.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 91.33.15.34.99.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 33.15.34.36.3.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 15.34.36.99.95.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 34.36.99.3.69.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 36.99.3.95.58.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 99.3.95.69.52.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 3.95.69.58.30.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 95.69.58.52.50.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 69.58.52.30.84.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 58.52.30.50.10.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 52.30.50.84.84.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 30.50.84.10.33.21.39.44.58.30.38.34.83.27.82.17.7
+ 50.84.10.84.21.39.44.58.30.38.34.83.27.82.17.7
+ 84.10.84.33.39.44.58.30.38.34.83.27.82.17.7
+ 10.84.33.21.44.58.30.38.34.83.27.82.17.7
+ 84.33.21.39.58.30.38.34.83.27.82.17.7 33.21.39.44.30.38.34.83.27.82.17.7
+ 21.39.44.58.38.34.83.27.82.17.7 39.44.58.30.34.83.27.82.17.7
+ 44.58.30.38.83.27.82.17.7 58.30.38.34.27.82.17.7 30.38.34.83.82.17.7
+ 38.34.83.27.17.7 34.83.27.82.7 83.27.82.17}
+
+do_execsql_test 1.20.14.2 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {40.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.30.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.80.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.20.90.60.70.80.90.30.50.10.30
+ 90.40.30.80.90.60.70.80.90.30.50.10.30
+ 40.30.80.20.60.70.80.90.30.50.10.30 30.80.20.90.70.80.90.30.50.10.30
+ 80.20.90.60.80.90.30.50.10.30 20.90.60.70.90.30.50.10.30
+ 90.60.70.80.30.50.10.30 60.70.80.90.50.10.30 70.80.90.30.10.30
+ 80.90.30.50.30 90.30.50.10
+ 91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 81.91.61.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.61.91.91.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 61.91.91.1.41.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.91.1.81.61.1.21.11.51.41.31.31.11.81.91.91.21
+ 91.1.81.41.1.21.11.51.41.31.31.11.81.91.91.21
+ 1.81.41.61.21.11.51.41.31.31.11.81.91.91.21
+ 81.41.61.1.11.51.41.31.31.11.81.91.91.21
+ 41.61.1.21.51.41.31.31.11.81.91.91.21 61.1.21.11.41.31.31.11.81.91.91.21
+ 1.21.11.51.31.31.11.81.91.91.21 21.11.51.41.31.11.81.91.91.21
+ 11.51.41.31.11.81.91.91.21 51.41.31.31.81.91.91.21 41.31.31.11.91.91.21
+ 31.31.11.81.91.21 31.11.81.91.21 11.81.91.91
+ 12.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.32.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.22.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.42.2.72.12.22.2.72.72.12.62.52.82
+ 62.12.32.22.2.72.12.22.2.72.72.12.62.52.82
+ 12.32.22.42.72.12.22.2.72.72.12.62.52.82
+ 32.22.42.2.12.22.2.72.72.12.62.52.82 22.42.2.72.22.2.72.72.12.62.52.82
+ 42.2.72.12.2.72.72.12.62.52.82 2.72.12.22.72.72.12.62.52.82
+ 72.12.22.2.72.12.62.52.82 12.22.2.72.12.62.52.82 22.2.72.72.62.52.82
+ 2.72.72.12.52.82 72.72.12.62.82 72.12.62.52
+ 23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.23.93.43.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 23.93.43.3.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 93.43.3.43.53.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.3.43.33.63.73.13.73.73.33.93.23.13.33.3.33.83
+ 3.43.33.53.73.13.73.73.33.93.23.13.33.3.33.83
+ 43.33.53.63.13.73.73.33.93.23.13.33.3.33.83
+ 33.53.63.73.73.73.33.93.23.13.33.3.33.83
+ 53.63.73.13.73.33.93.23.13.33.3.33.83 63.73.13.73.33.93.23.13.33.3.33.83
+ 73.13.73.73.93.23.13.33.3.33.83 13.73.73.33.23.13.33.3.33.83
+ 73.73.33.93.13.33.3.33.83 73.33.93.23.33.3.33.83 33.93.23.13.3.33.83
+ 93.23.13.33.33.83 23.13.33.3.83 13.33.3.33
+ 84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 54.84.74.24.94.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 84.74.24.4.84.74.34.34.44.74.64.14.34.84.84.44.34
+ 74.24.4.94.74.34.34.44.74.64.14.34.84.84.44.34
+ 24.4.94.84.34.34.44.74.64.14.34.84.84.44.34
+ 4.94.84.74.34.44.74.64.14.34.84.84.44.34
+ 94.84.74.34.44.74.64.14.34.84.84.44.34
+ 84.74.34.34.74.64.14.34.84.84.44.34 74.34.34.44.64.14.34.84.84.44.34
+ 34.34.44.74.14.34.84.84.44.34 34.44.74.64.34.84.84.44.34
+ 44.74.64.14.84.84.44.34 74.64.14.34.84.44.34 64.14.34.84.44.34
+ 14.34.84.84.34 34.84.84.44
+ 35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 65.35.85.85.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 35.85.85.55.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.85.55.15.75.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 85.55.15.25.95.65.65.35.5.15.95.55.75.85.75.15.95
+ 55.15.25.75.65.65.35.5.15.95.55.75.85.75.15.95
+ 15.25.75.95.65.35.5.15.95.55.75.85.75.15.95
+ 25.75.95.65.35.5.15.95.55.75.85.75.15.95
+ 75.95.65.65.5.15.95.55.75.85.75.15.95 95.65.65.35.15.95.55.75.85.75.15.95
+ 65.65.35.5.95.55.75.85.75.15.95 65.35.5.15.55.75.85.75.15.95
+ 35.5.15.95.75.85.75.15.95 5.15.95.55.85.75.15.95 15.95.55.75.75.15.95
+ 95.55.75.85.15.95 55.75.85.75.95 75.85.75.15
+ 46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 96.46.6.46.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.6.46.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 6.46.16.16.56.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 46.16.16.86.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.16.86.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 16.86.56.56.16.36.76.96.96.26.26.36.66.36.36
+ 86.56.56.56.36.76.96.96.26.26.36.66.36.36
+ 56.56.56.16.76.96.96.26.26.36.66.36.36
+ 56.56.16.36.96.96.26.26.36.66.36.36 56.16.36.76.96.26.26.36.66.36.36
+ 16.36.76.96.26.26.36.66.36.36 36.76.96.96.26.36.66.36.36
+ 76.96.96.26.36.66.36.36 96.96.26.26.66.36.36 96.26.26.36.36.36
+ 26.26.36.66.36 26.36.66.36
+ 27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.27.97.67.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 27.97.67.77.7.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 97.67.77.47.47.87.37.87.77.7.57.47.47.37.27.17.7
+ 67.77.47.7.87.37.87.77.7.57.47.47.37.27.17.7
+ 77.47.7.47.37.87.77.7.57.47.47.37.27.17.7
+ 47.7.47.87.87.77.7.57.47.47.37.27.17.7
+ 7.47.87.37.77.7.57.47.47.37.27.17.7 47.87.37.87.7.57.47.47.37.27.17.7
+ 87.37.87.77.57.47.47.37.27.17.7 37.87.77.7.47.47.37.27.17.7
+ 87.77.7.57.47.37.27.17.7 77.7.57.47.37.27.17.7 7.57.47.47.27.17.7
+ 57.47.47.37.17.7 47.47.37.27.7 47.37.27.17
+ 68.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.78.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.8.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.28.98.78.58.98.8.88.8.58.58.58.38
+ 38.68.78.8.98.78.58.98.8.88.8.58.58.58.38
+ 68.78.8.28.78.58.98.8.88.8.58.58.58.38
+ 78.8.28.98.58.98.8.88.8.58.58.58.38 8.28.98.78.98.8.88.8.58.58.58.38
+ 28.98.78.58.8.88.8.58.58.58.38 98.78.58.98.88.8.58.58.58.38
+ 78.58.98.8.8.58.58.58.38 58.98.8.88.58.58.58.38 98.8.88.8.58.58.38
+ 8.88.8.58.58.38 88.8.58.58.38 8.58.58.58
+ 59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.29.59.19.39.9.9.99.69.39 9.79.49.59.59.19.39.9.9.99.69.39
+ 79.49.59.29.19.39.9.9.99.69.39 49.59.29.59.39.9.9.99.69.39
+ 59.29.59.19.9.9.99.69.39 29.59.19.39.9.99.69.39 59.19.39.9.99.69.39
+ 19.39.9.9.69.39 39.9.9.99.39 9.9.99.69}
+
+do_execsql_test 1.20.14.3 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.2.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.3.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.1.2.2.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 1.2.2.3.4.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.2.3.3.5.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 2.3.3.4.6.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.3.4.5.7.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 3.4.5.6.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 4.5.6.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 5.6.7.7.8.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 6.7.7.7.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.7.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.7.8.8.9.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 7.8.8.8.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.8.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.8.9.9.10.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 8.9.9.9.11.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.9.10.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.9.10.11.12.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 9.10.11.11.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 10.11.11.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.11.12.12.13.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 11.12.12.12.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.12.13.14.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.12.13.13.15.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 12.13.13.14.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.13.14.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 13.14.15.15.16.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 14.15.15.15.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.15.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.15.16.16.17.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 15.16.16.16.19.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.16.17.20.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.16.17.19.21.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 16.17.19.20.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 17.19.20.21.22.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 19.20.21.21.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 20.21.21.22.23.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.21.22.22.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 21.22.22.23.24.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.22.23.23.25.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 22.23.23.24.26.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.23.24.25.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 23.24.25.26.27.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 24.25.26.26.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 25.26.26.27.28.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.26.27.27.29.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 26.27.27.28.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.27.28.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 27.28.29.29.30.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 28.29.29.29.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.29.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.29.30.30.31.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 29.30.30.30.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.30.31.32.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.30.31.31.33.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 30.31.31.32.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.31.32.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 31.32.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 32.33.33.33.34.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.33.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.33.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.33.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 33.34.34.34.35.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.34.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.34.35.36.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.34.35.35.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 34.35.35.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.35.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 35.36.36.36.37.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.36.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.36.37.38.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.36.37.37.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 36.37.37.38.39.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.37.38.38.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 37.38.38.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.38.39.39.40.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 38.39.39.39.41.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.39.40.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.39.40.41.42.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 39.40.41.41.43.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 40.41.41.42.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.41.42.43.44.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 41.42.43.43.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 42.43.43.44.46.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.43.44.44.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 43.44.44.46.47.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.44.46.46.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 44.46.46.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.46.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 46.47.47.47.49.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.47.50.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.47.49.51.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.47.49.50.52.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 47.49.50.51.53.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 49.50.51.52.54.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 50.51.52.53.55.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 51.52.53.54.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 52.53.54.55.56.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 53.54.55.55.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 54.55.55.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.55.56.56.57.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 55.56.56.56.58.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.56.57.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.56.57.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 56.57.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 57.58.58.58.59.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.58.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.58.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.58.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 58.59.59.59.60.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.59.61.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.59.60.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.59.60.61.62.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 59.60.61.61.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 60.61.61.62.63.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.61.62.62.64.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 61.62.62.63.65.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.62.63.64.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 62.63.64.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 63.64.65.65.66.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 64.65.65.65.67.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.65.66.68.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.65.66.67.69.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 65.66.67.68.70.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 66.67.68.69.72.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 67.68.69.70.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 68.69.70.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 69.70.72.72.73.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 70.72.72.72.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.72.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.72.73.73.74.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 72.73.73.73.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.73.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.73.74.74.75.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 73.74.74.74.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.74.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.74.75.75.76.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 74.75.75.75.77.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.75.76.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.75.76.77.78.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 75.76.77.77.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 76.77.77.78.79.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.77.78.78.80.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 77.78.78.79.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.78.79.80.81.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 78.79.80.80.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 79.80.80.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.80.81.81.82.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 80.81.81.81.83.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.81.82.84.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.81.82.83.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 81.82.83.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 82.83.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 83.84.84.84.85.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.84.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.84.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.84.85.85.86.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 84.85.85.85.87.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.85.86.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.85.86.87.88.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 85.86.87.87.89.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 86.87.87.88.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.87.88.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 87.88.89.89.90.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 88.89.89.89.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.89.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.89.90.90.91.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 89.90.90.90.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.90.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.90.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 90.91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.93.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.91.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.91.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.91.93.93.94.95.95.95.96.96.96.97.97.98.98.99.99
+ 91.93.93.93.95.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.93.94.95.95.96.96.96.97.97.98.98.99.99
+ 93.93.94.95.95.96.96.96.97.97.98.98.99.99
+ 93.94.95.95.96.96.96.97.97.98.98.99.99
+ 94.95.95.95.96.96.97.97.98.98.99.99 95.95.95.96.96.97.97.98.98.99.99
+ 95.95.96.96.97.97.98.98.99.99 95.96.96.96.97.98.98.99.99
+ 96.96.96.97.98.98.99.99 96.96.97.97.98.99.99 96.97.97.98.99.99
+ 97.97.98.98.99 97.98.98.99}
+
+do_execsql_test 1.20.14.4 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {20.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.30.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.40.50.60.70.80.80.90.90.90
+ 10.20.30.30.40.50.60.70.80.80.90.90.90
+ 20.30.30.30.50.60.70.80.80.90.90.90 30.30.30.40.60.70.80.80.90.90.90
+ 30.30.40.50.70.80.80.90.90.90 30.40.50.60.80.80.90.90.90
+ 40.50.60.70.80.90.90.90 50.60.70.80.90.90.90 60.70.80.80.90.90
+ 70.80.80.90.90 80.80.90.90
+ 1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.11.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.21.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.1.11.11.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 1.11.11.21.31.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.11.21.21.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 11.21.21.31.41.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.21.31.31.41.51.61.61.81.81.81.91.91.91.91.91
+ 21.31.31.41.51.61.61.81.81.81.91.91.91.91.91
+ 31.31.41.41.61.61.81.81.81.91.91.91.91.91
+ 31.41.41.51.61.81.81.81.91.91.91.91.91
+ 41.41.51.61.81.81.81.91.91.91.91.91 41.51.61.61.81.81.91.91.91.91.91
+ 51.61.61.81.81.91.91.91.91.91 61.61.81.81.91.91.91.91.91
+ 61.81.81.81.91.91.91.91 81.81.81.91.91.91.91 81.81.91.91.91.91
+ 81.91.91.91.91 91.91.91.91 2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.12.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.2.12.12.22.22.32.42.52.62.62.72.72.72.82
+ 2.12.12.12.22.32.42.52.62.62.72.72.72.82
+ 12.12.12.22.32.42.52.62.62.72.72.72.82
+ 12.12.22.22.42.52.62.62.72.72.72.82 12.22.22.32.52.62.62.72.72.72.82
+ 22.22.32.42.62.62.72.72.72.82 22.32.42.52.62.72.72.72.82
+ 32.42.52.62.72.72.72.82 42.52.62.62.72.72.82 52.62.62.72.72.82
+ 62.62.72.72.82 62.72.72.72
+ 3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.13.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.23.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.3.13.13.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 3.13.13.23.33.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.13.23.23.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 13.23.23.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.23.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 23.33.33.33.43.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.33.43.53.63.73.73.73.83.93.93.93
+ 33.33.33.43.53.63.73.73.73.83.93.93.93
+ 33.33.43.43.63.73.73.73.83.93.93.93 33.43.43.53.73.73.73.83.93.93.93
+ 43.43.53.63.73.73.83.93.93.93 43.53.63.73.73.83.93.93.93
+ 53.63.73.73.83.93.93.93 63.73.73.73.93.93.93 73.73.73.83.93.93
+ 73.73.83.93.93 73.83.93.93
+ 14.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.24.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.34.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 4.14.24.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 14.24.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 24.34.34.34.44.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.34.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.34.44.54.64.74.74.74.84.84.84.84.94
+ 34.34.44.44.64.74.74.74.84.84.84.84.94
+ 34.44.44.54.74.74.74.84.84.84.84.94 44.44.54.64.74.74.84.84.84.84.94
+ 44.54.64.74.74.84.84.84.84.94 54.64.74.74.84.84.84.84.94
+ 64.74.74.74.84.84.84.94 74.74.74.84.84.84.94 74.74.84.84.84.94
+ 74.84.84.84.94 84.84.84.84
+ 15.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.25.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 5.15.15.15.35.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.15.25.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.15.25.35.55.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 15.25.35.35.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 25.35.35.55.65.65.65.75.75.75.85.85.85.95.95.95
+ 35.35.55.55.65.65.75.75.75.85.85.85.95.95.95
+ 35.55.55.65.65.75.75.75.85.85.85.95.95.95
+ 55.55.65.65.75.75.75.85.85.85.95.95.95
+ 55.65.65.65.75.75.85.85.85.95.95.95 65.65.65.75.75.85.85.85.95.95.95
+ 65.65.75.75.85.85.85.95.95.95 65.75.75.75.85.85.95.95.95
+ 75.75.75.85.85.95.95.95 75.75.85.85.95.95.95 75.85.85.85.95.95
+ 85.85.85.95.95 85.85.95.95
+ 16.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.26.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 6.16.16.16.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.16.26.36.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.16.26.26.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 16.26.26.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.26.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 26.36.36.36.46.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.36.46.56.56.56.66.76.86.96.96.96
+ 36.36.36.46.56.56.56.66.76.86.96.96.96
+ 36.36.46.46.56.56.66.76.86.96.96.96 36.46.46.56.56.66.76.86.96.96.96
+ 46.46.56.56.66.76.86.96.96.96 46.56.56.56.76.86.96.96.96
+ 56.56.56.66.86.96.96.96 56.56.66.76.96.96.96 56.66.76.86.96.96
+ 66.76.86.96.96 76.86.96.96
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.27.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.7.17.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.7.17.27.37.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 7.17.27.27.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 17.27.27.37.47.47.47.47.57.67.77.77.87.87.97.97
+ 27.27.37.37.47.47.47.57.67.77.77.87.87.97.97
+ 27.37.37.47.47.47.57.67.77.77.87.87.97.97
+ 37.37.47.47.47.57.67.77.77.87.87.97.97
+ 37.47.47.47.57.67.77.77.87.87.97.97 47.47.47.47.67.77.77.87.87.97.97
+ 47.47.47.57.77.77.87.87.97.97 47.47.57.67.77.87.87.97.97
+ 47.57.67.77.87.87.97.97 57.67.77.77.87.97.97 67.77.77.87.97.97
+ 77.77.87.87.97 77.87.87.97 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.38.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.8.28.38.58.58.58.58.68.78.78.88.98.98
+ 8.8.28.38.58.58.58.58.68.78.78.88.98.98
+ 8.28.38.38.58.58.58.68.78.78.88.98.98 28.38.38.58.58.58.68.78.78.88.98.98
+ 38.38.58.58.58.68.78.78.88.98.98 38.58.58.58.68.78.78.88.98.98
+ 58.58.58.58.78.78.88.98.98 58.58.58.68.78.88.98.98 58.58.68.78.88.98.98
+ 58.68.78.78.98.98 68.78.78.88.98 78.78.88.98
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.29.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.9.19.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.9.19.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 9.19.29.29.39.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 19.29.29.29.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.29.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.29.39.39.49.59.59.59.59.69.79.89.89.89.99.99
+ 29.39.39.39.59.59.59.59.69.79.89.89.89.99.99
+ 39.39.39.49.59.59.59.69.79.89.89.89.99.99
+ 39.39.49.59.59.59.69.79.89.89.89.99.99
+ 39.49.59.59.59.69.79.89.89.89.99.99 49.59.59.59.69.79.89.89.89.99.99
+ 59.59.59.59.79.89.89.89.99.99 59.59.59.69.89.89.89.99.99
+ 59.59.69.79.89.89.99.99 59.69.79.89.89.99.99 69.79.89.89.99.99
+ 79.89.89.89.99 89.89.89.99}
+
+do_execsql_test 1.20.14.5 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP ) FROM t2
+} {40.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.30.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.80.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.20.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.40.30.80.90.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 40.30.80.20.60.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.80.20.90.70.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.20.90.60.80.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 20.90.60.70.90.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.60.70.80.30.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 60.70.80.90.50.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 70.80.90.30.10.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 80.90.30.50.30.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 90.30.50.10.81.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.50.10.30.91.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 50.10.30.81.61.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 10.30.81.91.91.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 30.81.91.61.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.61.91.1.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.61.91.91.81.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.91.91.1.41.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.1.81.61.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.1.81.41.1.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.81.41.61.21.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.41.61.1.11.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.61.1.21.51.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 61.1.21.11.41.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 1.21.11.51.31.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.11.51.41.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.51.41.31.11.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 51.41.31.31.81.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 41.31.31.11.91.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.31.11.81.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 31.11.81.91.21.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 11.81.91.91.62.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 81.91.91.21.12.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.91.21.62.32.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 91.21.62.12.22.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 21.62.12.32.42.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.12.32.22.2.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.32.22.42.72.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 32.22.42.2.12.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.42.2.72.22.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 42.2.72.12.2.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.12.22.72.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.22.2.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.22.2.72.12.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 22.2.72.72.62.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 2.72.72.12.52.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.72.12.62.82.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 72.12.62.52.93.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 12.62.52.82.23.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 62.52.82.93.93.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 52.82.93.23.43.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 82.93.23.93.3.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.93.43.43.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.93.43.3.33.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.43.3.43.53.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.3.43.33.63.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.43.33.53.73.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 43.33.53.63.13.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.53.63.73.73.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 53.63.73.13.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 63.73.13.73.33.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.13.73.73.93.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.73.73.33.23.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.73.33.93.13.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 73.33.93.23.33.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.93.23.13.3.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 93.23.13.33.33.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 23.13.33.3.83.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 13.33.3.33.54.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.3.33.83.84.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 3.33.83.54.74.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 33.83.54.84.24.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 83.54.84.74.4.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 54.84.74.24.94.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.24.4.84.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.24.4.94.74.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 24.4.94.84.34.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 4.94.84.74.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 94.84.74.34.44.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.74.34.34.74.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.34.34.44.64.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.34.44.74.14.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.44.74.64.34.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.74.64.14.84.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 74.64.14.34.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 64.14.34.84.44.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 14.34.84.84.34.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.84.84.44.65.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.84.44.34.35.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 84.44.34.65.85.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 44.34.65.35.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 34.65.35.85.55.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.85.85.15.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.85.85.55.25.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.85.55.15.75.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.55.15.25.95.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.15.25.75.65.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.25.75.95.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 25.75.95.65.35.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.95.65.65.5.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.65.65.35.15.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.65.35.5.95.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 65.35.5.15.55.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 35.5.15.95.75.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 5.15.95.55.85.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.55.75.75.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.55.75.85.15.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 55.75.85.75.95.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.85.75.15.96.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 85.75.15.95.46.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 75.15.95.96.6.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 15.95.96.46.46.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 95.96.46.6.16.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.46.6.46.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.6.46.16.86.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 6.46.16.16.56.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 46.16.16.86.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.16.86.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.86.56.56.16.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 86.56.56.56.36.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.56.16.76.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.56.16.36.96.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 56.16.36.76.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 16.36.76.96.26.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.76.96.96.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 76.96.96.26.36.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.96.26.26.66.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 96.26.26.36.36.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.26.36.66.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 26.36.66.36.97.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.66.36.36.27.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 66.36.36.97.97.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.36.97.27.67.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 36.97.27.97.77.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.27.97.67.47.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.97.67.77.7.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 97.67.77.47.47.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 67.77.47.7.87.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.47.7.47.37.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.7.47.87.87.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.47.87.37.77.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.87.37.87.7.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.37.87.77.57.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.87.77.7.47.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 87.77.7.57.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 77.7.57.47.37.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.57.47.47.27.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 57.47.47.37.17.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.47.37.27.7.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 47.37.27.17.38.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 37.27.17.7.68.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 27.17.7.38.78.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 17.7.38.68.8.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 7.38.68.78.28.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.68.78.8.98.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 68.78.8.28.78.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.8.28.98.58.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.28.98.78.98.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 28.98.78.58.8.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.78.58.98.88.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 78.58.98.8.8.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.98.8.88.58.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 98.8.88.8.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.88.8.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 88.8.58.58.38.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 8.58.58.58.89.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.58.38.59.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.58.38.89.39.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 58.38.89.59.99.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 38.89.59.39.29.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.59.39.99.59.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.39.99.29.89.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 39.99.29.59.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 99.29.59.89.29.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 29.59.89.89.9.79.49.59.29.59.19.39.9.9.99.69.39
+ 59.89.89.29.79.49.59.29.59.19.39.9.9.99.69.39
+ 89.89.29.9.49.59.29.59.19.39.9.9.99.69.39
+ 89.29.9.79.59.29.59.19.39.9.9.99.69.39
+ 29.9.79.49.29.59.19.39.9.9.99.69.39 9.79.49.59.59.19.39.9.9.99.69.39
+ 79.49.59.29.19.39.9.9.99.69.39 49.59.29.59.39.9.9.99.69.39
+ 59.29.59.19.9.9.99.69.39 29.59.19.39.9.99.69.39 59.19.39.9.99.69.39
+ 19.39.9.9.69.39 39.9.9.99.39 9.9.99.69}
+
+do_execsql_test 1.20.14.6 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM t2
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.14.7 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.14.8 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER (win1 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP)
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.14.9 {
+ SELECT group_concat(CAST(b AS TEXT), '.') OVER win2
+ FROM t2
+ WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
+ win2 AS (win1 ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP)
+ ORDER BY 1
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+ {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 1.20.15.1 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP)
+} {190 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 89.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 89.96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 190 89.96.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 189 96.38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 188 96.38.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 187 38.39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 186 38.39.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 185 39.91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 184 39.91.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 183 91.6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 182 91.6.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 181 6.97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 180 6.97.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 179 97.46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 178 97.46.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 177 46.54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 176 46.54.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 175 54.8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 174 54.8.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 173 8.29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 172 8.29.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 171 29.84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 170 29.84.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 169 84.23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 168 84.23.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 167 23.16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 166 23.16.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 165 16.65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 164 16.65.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 163 65.47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 162 65.47.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 161 47.86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 160 47.86.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 159 86.61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 158 86.61.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 157 61.85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 156 61.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 155 85.85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 154 85.85.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 153 85.59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 152 85.59.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 151 59.32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 150 59.32.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 149 32.3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 148 32.3.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 147 3.22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 146 3.22.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 145 22.55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 144 22.55.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 143 55.28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 142 55.28.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 141 28.25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 140 28.25.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 139 25.1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 138 25.1.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 137 1.40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 136 1.40.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 135 40.56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 134 40.56.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 133 56.75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 132 56.75.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 131 75.89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 130 75.89.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 129 89.76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 128 89.76.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 127 76.4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 126 76.4.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 125 4.42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 124 4.42.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 123 42.78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 122 42.78.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 121 78.29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 120 78.29.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 119 29.63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 118 29.63.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 117 63.87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 116 63.87.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 115 87.80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 114 87.80.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 113 80.72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 112 80.72.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 111 72.9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 110 72.9.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 109 9.73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 108 9.73.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 107 73.65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 106 73.65.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 105 65.58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 104 65.58.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 103 58.98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 102 58.98.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 101 98.21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 100 98.21.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 99 21.65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 98 21.65.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 97 65.5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 96 65.5.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 95 5.11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 94 5.11.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 93 11.87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 92 11.87.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 91 87.12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 90 87.12.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 89 12.20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 88 12.20.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 87 20.31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 86 20.31.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 85 31.95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 84 31.95.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 83 95.73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 82 95.73.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 81 73.88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 80 73.88.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 79 88.8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 78 88.8.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 77 8.49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 76 8.49.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 75 49.90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 74 49.90.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 73 90.96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 72 90.96.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 71 96.55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 70 96.55.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 69 55.77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 68 55.77.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 67 77.2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 66 77.2.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 65 2.85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 64 2.85.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 63 85.74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 62 85.74.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 61 74.70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 60 74.70.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 59 70.19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 58 70.19.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 57 19.26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 56 19.26.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 55 26.47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 54 26.47.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 53 47.90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 52 47.90.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 51 90.58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 50 90.58.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 49 58.9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 48 58.9.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 47 9.72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 46 9.72.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 45 72.33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 44 72.33.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 43 33.75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 42 33.75.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 41 75.81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 40 75.81.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 39 81.23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 38 81.23.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 37 23.13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 36 23.13.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 35 13.14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 34 13.14.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 33 14.91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 32 14.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 31 91.91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 30 91.91.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 29 91.15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 28 91.15.3.69.52.50.10.33.39.58.38.83.82.7
+ 27 15.36.3.69.52.50.10.33.39.58.38.83.82.7
+ 26 15.36.69.52.50.10.33.39.58.38.83.82.7
+ 25 36.3.69.52.50.10.33.39.58.38.83.82.7
+ 24 36.3.52.50.10.33.39.58.38.83.82.7 23 3.69.52.50.10.33.39.58.38.83.82.7
+ 22 3.69.50.10.33.39.58.38.83.82.7 21 69.52.50.10.33.39.58.38.83.82.7
+ 20 69.52.10.33.39.58.38.83.82.7 19 52.50.10.33.39.58.38.83.82.7
+ 18 52.50.33.39.58.38.83.82.7 17 50.10.33.39.58.38.83.82.7
+ 16 50.10.39.58.38.83.82.7 15 10.33.39.58.38.83.82.7
+ 14 10.33.58.38.83.82.7 13 33.39.58.38.83.82.7 12 33.39.38.83.82.7
+ 11 39.58.38.83.82.7 10 39.58.83.82.7 9 58.38.83.82.7 8 58.38.82.7
+ 7 38.83.82.7 6 38.83.7 5 83.82.7 4 83.82}
+
+do_execsql_test 1.20.15.2 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 0=1) OVER win FROM t2
+ WINDOW win AS (ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP)
+} {190 {} 190 {} 190 {} 190 {} 190 {} 189 {} 188 {} 187 {}
+ 186 {} 185 {} 184 {} 183 {} 182 {} 181 {} 180 {} 179 {}
+ 178 {} 177 {} 176 {} 175 {} 174 {} 173 {} 172 {} 171 {}
+ 170 {} 169 {} 168 {} 167 {} 166 {} 165 {} 164 {} 163 {}
+ 162 {} 161 {} 160 {} 159 {} 158 {} 157 {} 156 {} 155 {}
+ 154 {} 153 {} 152 {} 151 {} 150 {} 149 {} 148 {} 147 {}
+ 146 {} 145 {} 144 {} 143 {} 142 {} 141 {} 140 {} 139 {}
+ 138 {} 137 {} 136 {} 135 {} 134 {} 133 {} 132 {} 131 {}
+ 130 {} 129 {} 128 {} 127 {} 126 {} 125 {} 124 {} 123 {}
+ 122 {} 121 {} 120 {} 119 {} 118 {} 117 {} 116 {} 115 {}
+ 114 {} 113 {} 112 {} 111 {} 110 {} 109 {} 108 {} 107 {}
+ 106 {} 105 {} 104 {} 103 {} 102 {} 101 {} 100 {} 99 {}
+ 98 {} 97 {} 96 {} 95 {} 94 {} 93 {} 92 {} 91 {} 90 {}
+ 89 {} 88 {} 87 {} 86 {} 85 {} 84 {} 83 {} 82 {} 81 {}
+ 80 {} 79 {} 78 {} 77 {} 76 {} 75 {} 74 {} 73 {} 72 {}
+ 71 {} 70 {} 69 {} 68 {} 67 {} 66 {} 65 {} 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 {}}
+
+do_execsql_test 1.20.15.3 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE 1=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP)
+} {19 {} 19 {} 19 {} 19 {} 19 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {} 18 {} 18 {} 18 {} 18 {} 18 {} 17 {} 16 {} 15 {}
+ 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {} 7 {} 6 {} 5 {}
+ 4 {}}
+
+do_execsql_test 1.20.15.4 {
+ SELECT count(*) OVER win, group_concat(CAST(b AS TEXT), '.')
+ FILTER (WHERE a%2=0) OVER win FROM t2
+ WINDOW win AS (PARTITION BY (a%10) ORDER BY a ROWS BETWEEN 4 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP)
+} {19 6.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 89.29.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 89.6.47.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 89.6.29.59.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 19 89.6.29.47.28.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 18 6.29.47.59.75.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 17 29.47.59.28.78.72.98.87.73.96.74.90.75.91.69.39.7
+ 16 47.59.28.75.72.98.87.73.96.74.90.75.91.69.39.7
+ 15 59.28.75.78.98.87.73.96.74.90.75.91.69.39.7
+ 14 28.75.78.72.87.73.96.74.90.75.91.69.39.7
+ 13 75.78.72.98.73.96.74.90.75.91.69.39.7
+ 12 78.72.98.87.96.74.90.75.91.69.39.7 11 72.98.87.73.74.90.75.91.69.39.7
+ 10 98.87.73.96.90.75.91.69.39.7 9 87.73.96.74.75.91.69.39.7
+ 8 73.96.74.90.91.69.39.7 7 96.74.90.75.69.39.7 6 74.90.75.91.39.7
+ 5 90.75.91.69.7 4 75.91.69.39 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}
+ 18 97.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 96.84.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 96.97.86.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 96.97.84.32.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 18 96.97.84.86.25.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 17 97.84.86.32.89.29.9.21.12.88.55.70.58.81.91.52.58
+ 16 84.86.32.25.29.9.21.12.88.55.70.58.81.91.52.58
+ 15 86.32.25.89.9.21.12.88.55.70.58.81.91.52.58
+ 14 32.25.89.29.21.12.88.55.70.58.81.91.52.58
+ 13 25.89.29.9.12.88.55.70.58.81.91.52.58
+ 12 89.29.9.21.88.55.70.58.81.91.52.58 11 29.9.21.12.55.70.58.81.91.52.58
+ 10 9.21.12.88.70.58.81.91.52.58 9 21.12.88.55.58.81.91.52.58
+ 8 12.88.55.70.81.91.52.58 7 88.55.70.58.91.52.58 6 55.70.58.81.52.58
+ 5 70.58.81.91.58 4 58.81.91.52 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}
+ 18 46.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 38.23.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 38.46.61.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 38.46.23.3.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 18 38.46.23.61.1.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 17 46.23.61.3.76.63.73.65.20.8.77.19.9.23.15.50.38
+ 16 23.61.3.1.63.73.65.20.8.77.19.9.23.15.50.38
+ 15 61.3.1.76.73.65.20.8.77.19.9.23.15.50.38
+ 14 3.1.76.63.65.20.8.77.19.9.23.15.50.38
+ 13 1.76.63.73.20.8.77.19.9.23.15.50.38
+ 12 76.63.73.65.8.77.19.9.23.15.50.38 11 63.73.65.20.77.19.9.23.15.50.38
+ 10 73.65.20.8.19.9.23.15.50.38 9 65.20.8.77.9.23.15.50.38
+ 8 20.8.77.19.23.15.50.38 7 8.77.19.9.15.50.38 6 77.19.9.23.50.38
+ 5 19.9.23.15.38 4 9.23.15.50 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}
+ 18 54.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 39.16.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 39.54.85.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 39.54.16.22.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 18 39.54.16.85.40.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 17 54.16.85.22.4.87.65.5.31.49.2.26.72.13.36.10.83
+ 16 16.85.22.40.87.65.5.31.49.2.26.72.13.36.10.83
+ 15 85.22.40.4.65.5.31.49.2.26.72.13.36.10.83
+ 14 22.40.4.87.5.31.49.2.26.72.13.36.10.83
+ 13 40.4.87.65.31.49.2.26.72.13.36.10.83
+ 12 4.87.65.5.49.2.26.72.13.36.10.83 11 87.65.5.31.2.26.72.13.36.10.83
+ 10 65.5.31.49.26.72.13.36.10.83 9 5.31.49.2.72.13.36.10.83
+ 8 31.49.2.26.13.36.10.83 7 49.2.26.72.36.10.83 6 2.26.72.13.10.83
+ 5 26.72.13.36.83 4 72.13.36.10 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}
+ 18 8.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 91.65.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 91.8.85.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 91.8.65.55.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 18 91.8.65.85.56.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 17 8.65.85.55.42.80.58.11.95.90.85.47.33.14.3.33.82
+ 16 65.85.55.56.80.58.11.95.90.85.47.33.14.3.33.82
+ 15 85.55.56.42.58.11.95.90.85.47.33.14.3.33.82
+ 14 55.56.42.80.11.95.90.85.47.33.14.3.33.82
+ 13 56.42.80.58.95.90.85.47.33.14.3.33.82
+ 12 42.80.58.11.90.85.47.33.14.3.33.82 11 80.58.11.95.85.47.33.14.3.33.82
+ 10 58.11.95.90.47.33.14.3.33.82 9 11.95.90.85.33.14.3.33.82
+ 8 95.90.85.47.14.3.33.82 7 90.85.47.33.3.33.82 6 85.47.33.14.33.82
+ 5 47.33.14.3.82 4 33.14.3.33 18 {} 18 {} 18 {} 18 {} 18 {}
+ 17 {} 16 {} 15 {} 14 {} 13 {} 12 {} 11 {} 10 {} 9 {} 8 {}
+ 7 {} 6 {} 5 {} 4 {}}
+
+finish_test
diff --git a/test/window4.tcl b/test/window4.tcl
new file mode 100644
index 0000000..0b91d76
--- /dev/null
+++ b/test/window4.tcl
@@ -0,0 +1,424 @@
+## 2018 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.
+#
+#***********************************************************************
+#
+
+source [file join [file dirname $argv0] pg_common.tcl]
+
+#=========================================================================
+
+start_test window4 "2018 June 04"
+ifcapable !windowfunc
+
+execsql_test 1.0 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a TEXT PRIMARY KEY);
+ INSERT INTO t3 VALUES('a'), ('b'), ('c'), ('d'), ('e');
+ INSERT INTO t3 VALUES('f'), ('g'), ('h'), ('i'), ('j');
+}
+
+for {set i 1} {$i < 20} {incr i} {
+ execsql_test 1.$i "SELECT a, ntile($i) OVER (ORDER BY a) FROM t3"
+}
+
+execsql_test 2.0 {
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(a INTEGER PRIMARY KEY, b TEXT, c INTEGER);
+ INSERT INTO t4 VALUES(1, 'A', 9);
+ INSERT INTO t4 VALUES(2, 'B', 3);
+ INSERT INTO t4 VALUES(3, 'C', 2);
+ INSERT INTO t4 VALUES(4, 'D', 10);
+ INSERT INTO t4 VALUES(5, 'E', 5);
+ INSERT INTO t4 VALUES(6, 'F', 1);
+ INSERT INTO t4 VALUES(7, 'G', 1);
+ INSERT INTO t4 VALUES(8, 'H', 2);
+ INSERT INTO t4 VALUES(9, 'I', 10);
+ INSERT INTO t4 VALUES(10, 'J', 4);
+}
+
+execsql_test 2.1 {
+ SELECT a, nth_value(b, c) OVER (ORDER BY a) FROM t4
+}
+
+execsql_test 2.2.1 {
+ SELECT a, lead(b) OVER (ORDER BY a) FROM t4
+}
+execsql_test 2.2.2 {
+ SELECT a, lead(b, 2) OVER (ORDER BY a) FROM t4
+}
+execsql_test 2.2.3 {
+ SELECT a, lead(b, 3, 'abc') OVER (ORDER BY a) FROM t4
+}
+
+execsql_test 2.3.1 {
+ SELECT a, lag(b) OVER (ORDER BY a) FROM t4
+}
+execsql_test 2.3.2 {
+ SELECT a, lag(b, 2) OVER (ORDER BY a) FROM t4
+}
+execsql_test 2.3.3 {
+ SELECT a, lag(b, 3, 'abc') OVER (ORDER BY a) FROM t4
+}
+
+execsql_test 2.4.1 {
+ SELECT string_agg(b, '.') OVER (
+ ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t4
+}
+
+execsql_test 3.0 {
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
+ INSERT INTO t5 VALUES(1, 'A', 'one', 5);
+ INSERT INTO t5 VALUES(2, 'B', 'two', 4);
+ INSERT INTO t5 VALUES(3, 'A', 'three', 3);
+ INSERT INTO t5 VALUES(4, 'B', 'four', 2);
+ INSERT INTO t5 VALUES(5, 'A', 'five', 1);
+}
+
+execsql_test 3.1 {
+ SELECT a, nth_value(c, d) OVER (ORDER BY b) FROM t5
+}
+
+execsql_test 3.2 {
+ SELECT a, nth_value(c, d) OVER (PARTITION BY b ORDER BY a) FROM t5
+}
+
+execsql_test 3.3 {
+ SELECT a, count(*) OVER abc, count(*) OVER def FROM t5
+ WINDOW abc AS (ORDER BY a),
+ def AS (ORDER BY a DESC)
+ ORDER BY a;
+}
+
+execsql_test 3.4 {
+ SELECT a, max(a) FILTER (WHERE (a%2)=0) OVER w FROM t5
+ WINDOW w AS (ORDER BY a)
+}
+
+execsql_test 3.5.1 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING)
+ FROM t5
+}
+execsql_test 3.5.2 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM t5
+}
+execsql_test 3.5.3 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 PRECEDING AND 0 PRECEDING)
+ FROM t5
+}
+
+execsql_test 3.6.1 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 1 FOLLOWING)
+ FROM t5
+}
+execsql_test 3.6.2 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)
+ FROM t5
+}
+execsql_test 3.6.3 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 FOLLOWING AND 0 FOLLOWING)
+ FROM t5
+}
+
+==========
+
+execsql_test 4.0 {
+ DROP TABLE IF EXISTS ttt;
+ CREATE TABLE ttt(a INTEGER PRIMARY KEY, b INTEGER, c INTEGER);
+ INSERT INTO ttt VALUES(1, 1, 1);
+ INSERT INTO ttt VALUES(2, 2, 2);
+ INSERT INTO ttt VALUES(3, 3, 3);
+
+ INSERT INTO ttt VALUES(4, 1, 2);
+ INSERT INTO ttt VALUES(5, 2, 3);
+ INSERT INTO ttt VALUES(6, 3, 4);
+
+ INSERT INTO ttt VALUES(7, 1, 3);
+ INSERT INTO ttt VALUES(8, 2, 4);
+ INSERT INTO ttt VALUES(9, 3, 5);
+}
+
+execsql_test 4.1 {
+ SELECT max(c), max(b) OVER (ORDER BY b) FROM ttt GROUP BY b;
+}
+
+execsql_test 4.2 {
+ SELECT max(b) OVER (ORDER BY max(c)) FROM ttt GROUP BY b;
+}
+
+execsql_test 4.3 {
+ SELECT abs(max(b) OVER (ORDER BY b)) FROM ttt GROUP BY b;
+}
+
+execsql_test 4.4 {
+ SELECT sum(b) OVER (
+ ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM ttt;
+}
+
+set lPart [list "PARTITION BY b" "PARTITION BY b, a" "" "PARTITION BY a"]
+set lOrder [list "ORDER BY a" "ORDER BY a DESC" "" "ORDER BY b, a"]
+set lRange {
+ "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW"
+ "RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
+ "RANGE BETWEEN CURRENT ROW AND CURRENT ROW"
+ "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING"
+}
+
+set lRows {
+ "ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING"
+ "ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING"
+ "ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING"
+ "ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING"
+ "ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING"
+}
+
+set tn 1
+set SQL {
+ SELECT max(c) OVER ($p1 $o1 $r1),
+ min(c) OVER ($p2 $o2 $r2)
+ FROM ttt ORDER BY a
+}
+set SQL2 {
+ SELECT sum(c) OVER ($p1 $o1 $r1),
+ sum(c) OVER ($p2 $o2 $r2)
+ FROM ttt ORDER BY a
+}
+
+set o1 [lindex $lOrder 0]
+set o2 [lindex $lOrder 0]
+set r1 [lindex $lRange 0]
+set r2 [lindex $lRange 0]
+foreach p1 $lPart { foreach p2 $lPart {
+ execsql_test 4.5.$tn.1 [subst $SQL]
+ execsql_test 4.5.$tn.2 [subst $SQL2]
+ incr tn
+}}
+
+set o1 [lindex $lOrder 0]
+set o2 [lindex $lOrder 0]
+set p1 [lindex $lPart 0]
+set p2 [lindex $lPart 0]
+foreach r1 $lRange { foreach r2 $lRange {
+ execsql_test 4.5.$tn.1 [subst $SQL]
+ execsql_test 4.5.$tn.2 [subst $SQL2]
+ incr tn
+}}
+foreach r1 $lRows { foreach r2 $lRows {
+ execsql_test 4.5.$tn.1 [subst $SQL]
+ execsql_test 4.5.$tn.2 [subst $SQL2]
+ incr tn
+}}
+
+set r1 [lindex $lRange 0]
+set r2 [lindex $lRange 0]
+set p1 [lindex $lPart 0]
+set p2 [lindex $lPart 0]
+foreach o1 $lOrder { foreach o2 $lOrder {
+ execsql_test 4.5.$tn.1 [subst $SQL]
+ execsql_test 4.5.$tn.2 [subst $SQL2]
+ incr tn
+}}
+
+==========
+
+execsql_test 7.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x INTEGER, y INTEGER);
+ 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);
+}
+
+execsql_test 7.1 {
+ SELECT lead(y) OVER win FROM t1
+ WINDOW win AS (ORDER BY x)
+}
+
+execsql_test 7.2 {
+ SELECT lead(y, 2) OVER win FROM t1
+ WINDOW win AS (ORDER BY x)
+}
+
+execsql_test 7.3 {
+ SELECT lead(y, 3, -1) OVER win FROM t1
+ WINDOW win AS (ORDER BY x)
+}
+
+execsql_test 7.4 {
+ SELECT
+ lead(y) OVER win, lead(y) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY x)
+}
+
+execsql_test 7.5 {
+ SELECT
+ lead(y) OVER win,
+ lead(y, 2) OVER win,
+ lead(y, 3, -1) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY x)
+}
+
+==========
+
+execsql_test 8.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER, d INTEGER);
+ INSERT INTO t1 VALUES(1, 2, 3, 4);
+ INSERT INTO t1 VALUES(5, 6, 7, 8);
+ INSERT INTO t1 VALUES(9, 10, 11, 12);
+}
+
+execsql_test 8.1 {
+ SELECT row_number() OVER win,
+ nth_value(d,2) OVER win,
+ lead(d) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY a)
+}
+
+execsql_test 8.2 {
+ SELECT row_number() OVER win,
+ rank() OVER win,
+ dense_rank() OVER win,
+ ntile(2) OVER win,
+ first_value(d) OVER win,
+ last_value(d) OVER win,
+ nth_value(d,2) OVER win,
+ lead(d) OVER win,
+ lag(d) OVER win,
+ max(d) OVER win,
+ min(d) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY a)
+}
+
+==========
+
+execsql_test 9.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x INTEGER);
+ INSERT INTO t2 VALUES(1), (1), (1), (4), (4), (6), (7);
+}
+
+execsql_test 9.1 {
+ SELECT rank() OVER () FROM t2
+}
+execsql_test 9.2 {
+ SELECT dense_rank() OVER (PARTITION BY x) FROM t2
+}
+execsql_float_test 9.3 {
+ SELECT x, percent_rank() OVER (PARTITION BY x ORDER BY x) FROM t2
+}
+
+execsql_test 9.4 {
+ SELECT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
+}
+
+execsql_test 9.5 {
+ SELECT DISTINCT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
+}
+
+execsql_float_test 9.6 {
+ SELECT percent_rank() OVER () FROM t1
+}
+
+execsql_float_test 9.7 {
+ SELECT cume_dist() OVER () FROM t1
+}
+
+execsql_test 10.0 {
+ DROP TABLE IF EXISTS t7;
+ CREATE TABLE t7(id INTEGER PRIMARY KEY, a INTEGER, b INTEGER);
+ INSERT INTO t7(id, a, b) VALUES
+ (1, 1, 2), (2, 1, NULL), (3, 1, 4),
+ (4, 3, NULL), (5, 3, 8), (6, 3, 1);
+}
+execsql_test 10.1 {
+ SELECT id, min(b) OVER (PARTITION BY a ORDER BY id) FROM t7;
+}
+
+execsql_test 10.2 {
+ SELECT id, lead(b, -1) OVER (PARTITION BY a ORDER BY id) FROM t7;
+}
+execsql_test 10.3 {
+ SELECT id, lag(b, -1) OVER (PARTITION BY a ORDER BY id) FROM t7;
+}
+
+execsql_test 11.0 {
+ DROP VIEW IF EXISTS v8;
+ DROP TABLE IF EXISTS t8;
+ CREATE TABLE t8(t INT, total INT);
+ INSERT INTO t8 VALUES(0,2);
+ INSERT INTO t8 VALUES(5,1);
+ INSERT INTO t8 VALUES(10,1);
+}
+
+execsql_test 11.1 {
+ SELECT NTILE(256) OVER (ORDER BY total) - 1 AS nt FROM t8;
+}
+
+execsql_test 11.2 {
+ CREATE VIEW v8 AS SELECT NTILE(256) OVER (ORDER BY total) - 1 AS nt FROM t8;
+}
+
+execsql_test 11.3 {
+ SELECT * FROM v8;
+}
+
+execsql_test 11.4 {
+ SELECT * FROM (
+ SELECT NTILE(256) OVER (ORDER BY total) - 1 AS nt FROM t8
+ ) sub;
+}
+
+execsql_test 11.5 {
+ SELECT sum( min(t) ) OVER () FROM t8 GROUP BY total;
+}
+execsql_test 11.5 {
+ SELECT sum( max(t) ) OVER () FROM t8 GROUP BY total;
+}
+
+execsql_test 11.7 {
+ SELECT sum( min(t) ) OVER () FROM t8;
+}
+execsql_test 11.8 {
+ SELECT sum( max(t) ) OVER () FROM t8;
+}
+
+execsql_test 12.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER);
+ INSERT INTO t2 VALUES(1), (2), (3);
+}
+
+execsql_test 12.1 {
+ SELECT (SELECT min(a) OVER ()) FROM t2
+}
+
+execsql_float_test 12.2 {
+ SELECT (SELECT avg(a)) FROM t2 ORDER BY 1
+}
+
+execsql_float_test 12.3 {
+ SELECT
+ (SELECT avg(a) UNION SELECT min(a) OVER ())
+ FROM t2 GROUP BY a
+ ORDER BY 1
+}
+
+finish_test
+
diff --git a/test/window4.test b/test/window4.test
new file mode 100644
index 0000000..4194f75
--- /dev/null
+++ b/test/window4.test
@@ -0,0 +1,1390 @@
+# 2018 June 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.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window4
+
+ifcapable !windowfunc { finish_test ; return }
+do_execsql_test 1.0 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a TEXT PRIMARY KEY);
+ INSERT INTO t3 VALUES('a'), ('b'), ('c'), ('d'), ('e');
+ INSERT INTO t3 VALUES('f'), ('g'), ('h'), ('i'), ('j');
+} {}
+
+do_execsql_test 1.1 {
+ SELECT a, ntile(1) OVER (ORDER BY a) FROM t3
+} {a 1 b 1 c 1 d 1 e 1 f 1 g 1 h 1 i 1 j 1}
+
+do_execsql_test 1.2 {
+ SELECT a, ntile(2) OVER (ORDER BY a) FROM t3
+} {a 1 b 1 c 1 d 1 e 1 f 2 g 2 h 2 i 2 j 2}
+
+do_execsql_test 1.3 {
+ SELECT a, ntile(3) OVER (ORDER BY a) FROM t3
+} {a 1 b 1 c 1 d 1 e 2 f 2 g 2 h 3 i 3 j 3}
+
+do_execsql_test 1.4 {
+ SELECT a, ntile(4) OVER (ORDER BY a) FROM t3
+} {a 1 b 1 c 1 d 2 e 2 f 2 g 3 h 3 i 4 j 4}
+
+do_execsql_test 1.5 {
+ SELECT a, ntile(5) OVER (ORDER BY a) FROM t3
+} {a 1 b 1 c 2 d 2 e 3 f 3 g 4 h 4 i 5 j 5}
+
+do_execsql_test 1.6 {
+ SELECT a, ntile(6) OVER (ORDER BY a) FROM t3
+} {a 1 b 1 c 2 d 2 e 3 f 3 g 4 h 4 i 5 j 6}
+
+do_execsql_test 1.7 {
+ SELECT a, ntile(7) OVER (ORDER BY a) FROM t3
+} {a 1 b 1 c 2 d 2 e 3 f 3 g 4 h 5 i 6 j 7}
+
+do_execsql_test 1.8 {
+ SELECT a, ntile(8) OVER (ORDER BY a) FROM t3
+} {a 1 b 1 c 2 d 2 e 3 f 4 g 5 h 6 i 7 j 8}
+
+do_execsql_test 1.9 {
+ SELECT a, ntile(9) OVER (ORDER BY a) FROM t3
+} {a 1 b 1 c 2 d 3 e 4 f 5 g 6 h 7 i 8 j 9}
+
+do_execsql_test 1.10 {
+ SELECT a, ntile(10) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 1.11 {
+ SELECT a, ntile(11) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 1.12 {
+ SELECT a, ntile(12) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 1.13 {
+ SELECT a, ntile(13) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 1.14 {
+ SELECT a, ntile(14) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 1.15 {
+ SELECT a, ntile(15) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 1.16 {
+ SELECT a, ntile(16) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 1.17 {
+ SELECT a, ntile(17) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 1.18 {
+ SELECT a, ntile(18) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 1.19 {
+ SELECT a, ntile(19) OVER (ORDER BY a) FROM t3
+} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
+
+do_execsql_test 2.0 {
+ DROP TABLE IF EXISTS t4;
+ CREATE TABLE t4(a INTEGER PRIMARY KEY, b TEXT, c INTEGER);
+ INSERT INTO t4 VALUES(1, 'A', 9);
+ INSERT INTO t4 VALUES(2, 'B', 3);
+ INSERT INTO t4 VALUES(3, 'C', 2);
+ INSERT INTO t4 VALUES(4, 'D', 10);
+ INSERT INTO t4 VALUES(5, 'E', 5);
+ INSERT INTO t4 VALUES(6, 'F', 1);
+ INSERT INTO t4 VALUES(7, 'G', 1);
+ INSERT INTO t4 VALUES(8, 'H', 2);
+ INSERT INTO t4 VALUES(9, 'I', 10);
+ INSERT INTO t4 VALUES(10, 'J', 4);
+} {}
+
+do_execsql_test 2.1 {
+ SELECT a, nth_value(b, c) OVER (ORDER BY a) FROM t4
+} {1 {} 2 {} 3 B 4 {} 5 E 6 A 7 A 8 B 9 {} 10 D}
+
+do_execsql_test 2.2.1 {
+ SELECT a, lead(b) OVER (ORDER BY a) FROM t4
+} {1 B 2 C 3 D 4 E 5 F 6 G 7 H 8 I 9 J 10 {}}
+
+do_execsql_test 2.2.2 {
+ SELECT a, lead(b, 2) OVER (ORDER BY a) FROM t4
+} {1 C 2 D 3 E 4 F 5 G 6 H 7 I 8 J 9 {} 10 {}}
+
+do_execsql_test 2.2.3 {
+ SELECT a, lead(b, 3, 'abc') OVER (ORDER BY a) FROM t4
+} {1 D 2 E 3 F 4 G 5 H 6 I 7 J 8 abc 9 abc 10 abc}
+
+do_execsql_test 2.3.1 {
+ SELECT a, lag(b) OVER (ORDER BY a) FROM t4
+} {1 {} 2 A 3 B 4 C 5 D 6 E 7 F 8 G 9 H 10 I}
+
+do_execsql_test 2.3.2 {
+ SELECT a, lag(b, 2) OVER (ORDER BY a) FROM t4
+} {1 {} 2 {} 3 A 4 B 5 C 6 D 7 E 8 F 9 G 10 H}
+
+do_execsql_test 2.3.3 {
+ SELECT a, lag(b, 3, 'abc') OVER (ORDER BY a) FROM t4
+} {1 abc 2 abc 3 abc 4 A 5 B 6 C 7 D 8 E 9 F 10 G}
+
+do_execsql_test 2.4.1 {
+ SELECT group_concat(b, '.') OVER (
+ ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM t4
+} {A.B.C.D.E.F.G.H.I.J B.C.D.E.F.G.H.I.J C.D.E.F.G.H.I.J D.E.F.G.H.I.J
+ E.F.G.H.I.J F.G.H.I.J G.H.I.J H.I.J I.J J}
+
+do_execsql_test 3.0 {
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
+ INSERT INTO t5 VALUES(1, 'A', 'one', 5);
+ INSERT INTO t5 VALUES(2, 'B', 'two', 4);
+ INSERT INTO t5 VALUES(3, 'A', 'three', 3);
+ INSERT INTO t5 VALUES(4, 'B', 'four', 2);
+ INSERT INTO t5 VALUES(5, 'A', 'five', 1);
+} {}
+
+do_execsql_test 3.1 {
+ SELECT a, nth_value(c, d) OVER (ORDER BY b) FROM t5
+} {1 {} 3 five 5 one 2 two 4 three}
+
+do_execsql_test 3.2 {
+ SELECT a, nth_value(c, d) OVER (PARTITION BY b ORDER BY a) FROM t5
+} {1 {} 3 {} 5 one 2 {} 4 four}
+
+do_execsql_test 3.3 {
+ SELECT a, count(*) OVER abc, count(*) OVER def FROM t5
+ WINDOW abc AS (ORDER BY a),
+ def AS (ORDER BY a DESC)
+ ORDER BY a;
+} {1 1 5 2 2 4 3 3 3 4 4 2 5 5 1}
+
+do_execsql_test 3.4 {
+ SELECT a, max(a) FILTER (WHERE (a%2)=0) OVER w FROM t5
+ WINDOW w AS (ORDER BY a)
+} {1 {} 2 2 3 2 4 4 5 4}
+
+do_execsql_test 3.5.1 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING)
+ FROM t5
+} {1 {} 2 {} 3 {} 4 {} 5 {}}
+
+do_execsql_test 3.5.2 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM t5
+} {1 {} 2 one 3 two 4 three 5 four}
+
+do_execsql_test 3.5.3 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 PRECEDING AND 0 PRECEDING)
+ FROM t5
+} {1 one 2 two 3 three 4 four 5 five}
+
+do_execsql_test 3.6.1 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 1 FOLLOWING)
+ FROM t5
+} {1 {} 2 {} 3 {} 4 {} 5 {}}
+
+do_execsql_test 3.6.2 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)
+ FROM t5
+} {1 two 2 three 3 four 4 five 5 {}}
+
+do_execsql_test 3.6.3 {
+ SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 FOLLOWING AND 0 FOLLOWING)
+ FROM t5
+} {1 one 2 two 3 three 4 four 5 five}
+
+#==========================================================================
+
+do_execsql_test 4.0 {
+ DROP TABLE IF EXISTS ttt;
+ CREATE TABLE ttt(a INTEGER PRIMARY KEY, b INTEGER, c INTEGER);
+ INSERT INTO ttt VALUES(1, 1, 1);
+ INSERT INTO ttt VALUES(2, 2, 2);
+ INSERT INTO ttt VALUES(3, 3, 3);
+
+ INSERT INTO ttt VALUES(4, 1, 2);
+ INSERT INTO ttt VALUES(5, 2, 3);
+ INSERT INTO ttt VALUES(6, 3, 4);
+
+ INSERT INTO ttt VALUES(7, 1, 3);
+ INSERT INTO ttt VALUES(8, 2, 4);
+ INSERT INTO ttt VALUES(9, 3, 5);
+} {}
+
+do_execsql_test 4.1 {
+ SELECT max(c), max(b) OVER (ORDER BY b) FROM ttt GROUP BY b;
+} {3 1 4 2 5 3}
+
+do_execsql_test 4.2 {
+ SELECT max(b) OVER (ORDER BY max(c)) FROM ttt GROUP BY b;
+} {1 2 3}
+
+do_execsql_test 4.3 {
+ SELECT abs(max(b) OVER (ORDER BY b)) FROM ttt GROUP BY b;
+} {1 2 3}
+
+do_execsql_test 4.4 {
+ SELECT sum(b) OVER (
+ ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ ) FROM ttt;
+} {18 17 15 12 11 9 6 5 3}
+
+do_execsql_test 4.5.1.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.1.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
+
+do_execsql_test 4.5.2.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.2.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 2 5 3 7 4 6 3 9 4 12 5}
+
+do_execsql_test 4.5.3.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 1 3 1 2 1 3 1 4 1 3 1 4 1 5 1}
+
+do_execsql_test 4.5.3.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 3 3 6 3 8 5 11 7 15 6 18 9 22 12 27}
+
+do_execsql_test 4.5.4.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.4.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 2 5 3 7 4 6 3 9 4 12 5}
+
+do_execsql_test 4.5.5.1 {
+ SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.5.2 {
+ SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 3 3 5 4 7 3 6 4 9 5 12}
+
+do_execsql_test 4.5.6.1 {
+ SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.6.2 {
+ SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.7.1 {
+ SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 1 3 1 2 1 3 1 4 1 3 1 4 1 5 1}
+
+do_execsql_test 4.5.7.2 {
+ SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 3 3 6 2 8 3 11 4 15 3 18 4 22 5 27}
+
+do_execsql_test 4.5.8.1 {
+ SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.8.2 {
+ SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.9.1 {
+ SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 1 3 2 4 3 4 1 4 2 5 3}
+
+do_execsql_test 4.5.9.2 {
+ SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 3 2 6 3 8 3 11 5 15 7 18 6 22 9 27 12}
+
+do_execsql_test 4.5.10.1 {
+ SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 2 3 3 4 4 4 3 4 4 5 5}
+
+do_execsql_test 4.5.10.2 {
+ SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 3 2 6 3 8 2 11 3 15 4 18 3 22 4 27 5}
+
+do_execsql_test 4.5.11.1 {
+ SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 1 3 1 3 1 3 1 4 1 4 1 4 1 5 1}
+
+do_execsql_test 4.5.11.2 {
+ SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 3 3 6 6 8 8 11 11 15 15 18 18 22 22 27 27}
+
+do_execsql_test 4.5.12.1 {
+ SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 2 3 3 4 4 4 3 4 4 5 5}
+
+do_execsql_test 4.5.12.2 {
+ SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 3 2 6 3 8 2 11 3 15 4 18 3 22 4 27 5}
+
+do_execsql_test 4.5.13.1 {
+ SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.13.2 {
+ SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 3 3 5 4 7 3 6 4 9 5 12}
+
+do_execsql_test 4.5.14.1 {
+ SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.14.2 {
+ SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.15.1 {
+ SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 1 3 1 2 1 3 1 4 1 3 1 4 1 5 1}
+
+do_execsql_test 4.5.15.2 {
+ SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 3 3 6 2 8 3 11 4 15 3 18 4 22 5 27}
+
+do_execsql_test 4.5.16.1 {
+ SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.16.2 {
+ SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.17.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.17.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
+
+do_execsql_test 4.5.18.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.18.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {1 6 2 9 3 12 3 6 5 9 7 12 6 6 9 9 12 12}
+
+do_execsql_test 4.5.19.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.19.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 2 5 3 7 4 6 3 9 4 12 5}
+
+do_execsql_test 4.5.20.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.20.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {1 6 2 9 3 12 3 5 5 7 7 9 6 3 9 4 12 5}
+
+do_execsql_test 4.5.21.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.21.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 1 9 2 12 3 6 3 9 5 12 7 6 6 9 9 12 12}
+
+do_execsql_test 4.5.22.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.22.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {6 6 9 9 12 12 6 6 9 9 12 12 6 6 9 9 12 12}
+
+do_execsql_test 4.5.23.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.23.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 1 9 2 12 3 6 2 9 3 12 4 6 3 9 4 12 5}
+
+do_execsql_test 4.5.24.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.24.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {6 6 9 9 12 12 6 5 9 7 12 9 6 3 9 4 12 5}
+
+do_execsql_test 4.5.25.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.25.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 3 3 5 4 7 3 6 4 9 5 12}
+
+do_execsql_test 4.5.26.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.26.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {1 6 2 9 3 12 2 6 3 9 4 12 3 6 4 9 5 12}
+
+do_execsql_test 4.5.27.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.27.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.28.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.28.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {1 6 2 9 3 12 2 5 3 7 4 9 3 3 4 4 5 5}
+
+do_execsql_test 4.5.29.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.29.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 1 9 2 12 3 5 3 7 5 9 7 3 6 4 9 5 12}
+
+do_execsql_test 4.5.30.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.30.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {6 6 9 9 12 12 5 6 7 9 9 12 3 6 4 9 5 12}
+
+do_execsql_test 4.5.31.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.31.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 1 9 2 12 3 5 2 7 3 9 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.32.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.32.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ FROM ttt ORDER BY a
+} {6 6 9 9 12 12 5 5 7 7 9 9 3 3 4 4 5 5}
+
+do_execsql_test 4.5.33.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {2 1 3 2 4 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.33.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 3 5 5 7 7 6 6 9 9 12 12 6 6 9 9 12 12}
+
+do_execsql_test 4.5.34.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {2 1 3 2 4 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.34.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 6 5 9 7 12 6 6 9 9 12 12 6 6 9 9 12 12}
+
+do_execsql_test 4.5.35.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {2 {} 3 {} 4 {} 3 1 4 2 5 3 3 2 4 3 5 4}
+
+do_execsql_test 4.5.35.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {3 {} 5 {} 7 {} 6 1 9 2 12 3 6 2 9 3 12 4}
+
+do_execsql_test 4.5.36.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {2 {} 3 {} 4 {} 3 {} 4 {} 5 {} 3 {} 4 {} 5 {}}
+
+do_execsql_test 4.5.36.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {3 {} 5 {} 7 {} 6 {} 9 {} 12 {} 6 {} 9 {} 12 {}}
+
+do_execsql_test 4.5.37.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {2 2 3 3 4 4 3 3 4 4 5 5 3 {} 4 {} 5 {}}
+
+do_execsql_test 4.5.37.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 5 5 7 7 9 6 3 9 4 12 5 6 {} 9 {} 12 {}}
+
+do_execsql_test 4.5.38.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.38.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {6 3 9 5 12 7 6 6 9 9 12 12 6 6 9 9 12 12}
+
+do_execsql_test 4.5.39.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.39.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {6 6 9 9 12 12 6 6 9 9 12 12 6 6 9 9 12 12}
+
+do_execsql_test 4.5.40.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {3 {} 4 {} 5 {} 3 1 4 2 5 3 3 2 4 3 5 4}
+
+do_execsql_test 4.5.40.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {6 {} 9 {} 12 {} 6 1 9 2 12 3 6 2 9 3 12 4}
+
+do_execsql_test 4.5.41.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {3 {} 4 {} 5 {} 3 {} 4 {} 5 {} 3 {} 4 {} 5 {}}
+
+do_execsql_test 4.5.41.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {6 {} 9 {} 12 {} 6 {} 9 {} 12 {} 6 {} 9 {} 12 {}}
+
+do_execsql_test 4.5.42.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 2 4 3 5 4 3 3 4 4 5 5 3 {} 4 {} 5 {}}
+
+do_execsql_test 4.5.42.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {6 5 9 7 12 9 6 3 9 4 12 5 6 {} 9 {} 12 {}}
+
+do_execsql_test 4.5.43.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 1 {} 2 {} 3 1 1 2 2 3 3 2 1 3 2 4 3}
+
+do_execsql_test 4.5.43.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 3 {} 5 {} 7 1 6 2 9 3 12 2 6 3 9 4 12}
+
+do_execsql_test 4.5.44.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 1 {} 2 {} 3 1 1 2 2 3 3 2 1 3 2 4 3}
+
+do_execsql_test 4.5.44.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 6 {} 9 {} 12 1 6 2 9 3 12 2 6 3 9 4 12}
+
+do_execsql_test 4.5.45.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {{} {} {} {} {} {} 1 1 2 2 3 3 2 2 3 3 4 4}
+
+do_execsql_test 4.5.45.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {{} {} {} {} {} {} 1 1 2 2 3 3 2 2 3 3 4 4}
+
+do_execsql_test 4.5.46.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {{} {} {} {} {} {} 1 {} 2 {} 3 {} 2 {} 3 {} 4 {}}
+
+do_execsql_test 4.5.46.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {{} {} {} {} {} {} 1 {} 2 {} 3 {} 2 {} 3 {} 4 {}}
+
+do_execsql_test 4.5.47.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 2 {} 3 {} 4 1 3 2 4 3 5 2 {} 3 {} 4 {}}
+
+do_execsql_test 4.5.47.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 5 {} 7 {} 9 1 3 2 4 3 5 2 {} 3 {} 4 {}}
+
+do_execsql_test 4.5.48.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 1 {} 2 {} 3 {} 1 {} 2 {} 3 {} 1 {} 2 {} 3}
+
+do_execsql_test 4.5.48.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 3 {} 5 {} 7 {} 6 {} 9 {} 12 {} 6 {} 9 {} 12}
+
+do_execsql_test 4.5.49.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 1 {} 2 {} 3 {} 1 {} 2 {} 3 {} 1 {} 2 {} 3}
+
+do_execsql_test 4.5.49.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 6 {} 9 {} 12 {} 6 {} 9 {} 12 {} 6 {} 9 {} 12}
+
+do_execsql_test 4.5.50.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {{} {} {} {} {} {} {} 1 {} 2 {} 3 {} 2 {} 3 {} 4}
+
+do_execsql_test 4.5.50.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {{} {} {} {} {} {} {} 1 {} 2 {} 3 {} 2 {} 3 {} 4}
+
+do_execsql_test 4.5.51.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 4.5.51.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}}
+
+do_execsql_test 4.5.52.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 2 {} 3 {} 4 {} 3 {} 4 {} 5 {} {} {} {} {} {}}
+
+do_execsql_test 4.5.52.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {{} 5 {} 7 {} 9 {} 3 {} 4 {} 5 {} {} {} {} {} {}}
+
+do_execsql_test 4.5.53.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 {} 1 {} 2 {} 3}
+
+do_execsql_test 4.5.53.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
+ FROM ttt ORDER BY a
+} {5 3 7 5 9 7 3 6 4 9 5 12 {} 6 {} 9 {} 12}
+
+do_execsql_test 4.5.54.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 {} 1 {} 2 {} 3}
+
+do_execsql_test 4.5.54.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
+ FROM ttt ORDER BY a
+} {5 6 7 9 9 12 3 6 4 9 5 12 {} 6 {} 9 {} 12}
+
+do_execsql_test 4.5.55.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {3 {} 4 {} 5 {} 3 1 4 2 5 3 {} 2 {} 3 {} 4}
+
+do_execsql_test 4.5.55.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {5 {} 7 {} 9 {} 3 1 4 2 5 3 {} 2 {} 3 {} 4}
+
+do_execsql_test 4.5.56.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {3 {} 4 {} 5 {} 3 {} 4 {} 5 {} {} {} {} {} {} {}}
+
+do_execsql_test 4.5.56.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
+ FROM ttt ORDER BY a
+} {5 {} 7 {} 9 {} 3 {} 4 {} 5 {} {} {} {} {} {} {}}
+
+do_execsql_test 4.5.57.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {3 2 4 3 5 4 3 3 4 4 5 5 {} {} {} {} {} {}}
+
+do_execsql_test 4.5.57.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
+ sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
+ FROM ttt ORDER BY a
+} {5 5 7 7 9 9 3 3 4 4 5 5 {} {} {} {} {} {}}
+
+do_execsql_test 4.5.58.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.58.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
+
+do_execsql_test 4.5.59.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.59.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 6 2 9 3 12 3 5 5 7 7 9 6 3 9 4 12 5}
+
+do_execsql_test 4.5.60.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.60.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 6 2 9 3 12 3 6 5 9 7 12 6 6 9 9 12 12}
+
+do_execsql_test 4.5.61.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.61.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
+
+do_execsql_test 4.5.62.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.62.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 1 9 2 12 3 5 3 7 5 9 7 3 6 4 9 5 12}
+
+do_execsql_test 4.5.63.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.63.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 6 9 9 12 12 5 5 7 7 9 9 3 3 4 4 5 5}
+
+do_execsql_test 4.5.64.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.64.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 6 9 9 12 12 5 6 7 9 9 12 3 6 4 9 5 12}
+
+do_execsql_test 4.5.65.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.65.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 1 9 2 12 3 5 3 7 5 9 7 3 6 4 9 5 12}
+
+do_execsql_test 4.5.66.1 {
+ SELECT max(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.66.2 {
+ SELECT sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 1 9 2 12 3 6 3 9 5 12 7 6 6 9 9 12 12}
+
+do_execsql_test 4.5.67.1 {
+ SELECT max(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.67.2 {
+ SELECT sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 6 9 9 12 12 6 5 9 7 12 9 6 3 9 4 12 5}
+
+do_execsql_test 4.5.68.1 {
+ SELECT max(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.68.2 {
+ SELECT sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 6 9 9 12 12 6 6 9 9 12 12 6 6 9 9 12 12}
+
+do_execsql_test 4.5.69.1 {
+ SELECT max(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.69.2 {
+ SELECT sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {6 1 9 2 12 3 6 3 9 5 12 7 6 6 9 9 12 12}
+
+do_execsql_test 4.5.70.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.70.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
+
+do_execsql_test 4.5.71.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
+
+do_execsql_test 4.5.71.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 6 2 9 3 12 3 5 5 7 7 9 6 3 9 4 12 5}
+
+do_execsql_test 4.5.72.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.72.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 6 2 9 3 12 3 6 5 9 7 12 6 6 9 9 12 12}
+
+do_execsql_test 4.5.73.1 {
+ SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
+
+do_execsql_test 4.5.73.2 {
+ SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
+ sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ FROM ttt ORDER BY a
+} {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
+
+#==========================================================================
+
+do_execsql_test 7.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x INTEGER, y INTEGER);
+ 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);
+} {}
+
+do_execsql_test 7.1 {
+ SELECT lead(y) OVER win FROM t1
+ WINDOW win AS (ORDER BY x)
+} {4 6 8 10 {}}
+
+do_execsql_test 7.2 {
+ SELECT lead(y, 2) OVER win FROM t1
+ WINDOW win AS (ORDER BY x)
+} {6 8 10 {} {}}
+
+do_execsql_test 7.3 {
+ SELECT lead(y, 3, -1) OVER win FROM t1
+ WINDOW win AS (ORDER BY x)
+} {8 10 -1 -1 -1}
+
+do_execsql_test 7.4 {
+ SELECT
+ lead(y) OVER win, lead(y) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY x)
+} {4 4 6 6 8 8 10 10 {} {}}
+
+do_execsql_test 7.5 {
+ SELECT
+ lead(y) OVER win,
+ lead(y, 2) OVER win,
+ lead(y, 3, -1) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY x)
+} {4 6 8 6 8 10 8 10 -1 10 {} -1 {} {} -1}
+
+#==========================================================================
+
+do_execsql_test 8.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER, d INTEGER);
+ INSERT INTO t1 VALUES(1, 2, 3, 4);
+ INSERT INTO t1 VALUES(5, 6, 7, 8);
+ INSERT INTO t1 VALUES(9, 10, 11, 12);
+} {}
+
+do_execsql_test 8.1 {
+ SELECT row_number() OVER win,
+ nth_value(d,2) OVER win,
+ lead(d) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY a)
+} {1 {} 8 2 8 12 3 8 {}}
+
+do_execsql_test 8.2 {
+ SELECT row_number() OVER win,
+ rank() OVER win,
+ dense_rank() OVER win,
+ ntile(2) OVER win,
+ first_value(d) OVER win,
+ last_value(d) OVER win,
+ nth_value(d,2) OVER win,
+ lead(d) OVER win,
+ lag(d) OVER win,
+ max(d) OVER win,
+ min(d) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY a)
+} {1 1 1 1 4 4 {} 8 {} 4 4 2 2 2 1 4 8 8 12 4 8 4 3 3 3 2 4 12 8 {} 8 12 4}
+
+#==========================================================================
+
+do_execsql_test 9.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(x INTEGER);
+ INSERT INTO t2 VALUES(1), (1), (1), (4), (4), (6), (7);
+} {}
+
+do_execsql_test 9.1 {
+ SELECT rank() OVER () FROM t2
+} {1 1 1 1 1 1 1}
+
+do_execsql_test 9.2 {
+ SELECT dense_rank() OVER (PARTITION BY x) FROM t2
+} {1 1 1 1 1 1 1}
+
+
+do_test 9.3 {
+ set myres {}
+ foreach r [db eval {SELECT x, percent_rank() OVER (PARTITION BY x ORDER BY x) FROM t2}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 0.0000 1.0000 0.0000 1.0000 0.0000 4.0000 0.0000 4.0000 0.0000 6.0000 0.0000 7.0000 0.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 9.4 {
+ SELECT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
+} {1 1 1 1 1 1 4 4 4 4 6 6 7 7}
+
+do_execsql_test 9.5 {
+ SELECT DISTINCT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
+} {1 1 4 4 6 6 7 7}
+
+
+do_test 9.6 {
+ set myres {}
+ foreach r [db eval {SELECT percent_rank() OVER () FROM t1}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {0.0000 0.0000 0.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 9.7 {
+ set myres {}
+ foreach r [db eval {SELECT cume_dist() OVER () FROM t1}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 1.0000 1.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+do_execsql_test 10.0 {
+ DROP TABLE IF EXISTS t7;
+ CREATE TABLE t7(id INTEGER PRIMARY KEY, a INTEGER, b INTEGER);
+ INSERT INTO t7(id, a, b) VALUES
+ (1, 1, 2), (2, 1, NULL), (3, 1, 4),
+ (4, 3, NULL), (5, 3, 8), (6, 3, 1);
+} {}
+
+do_execsql_test 10.1 {
+ SELECT id, min(b) OVER (PARTITION BY a ORDER BY id) FROM t7;
+} {1 2 2 2 3 2 4 {} 5 8 6 1}
+
+do_execsql_test 10.2 {
+ SELECT id, lead(b, -1) OVER (PARTITION BY a ORDER BY id) FROM t7;
+} {1 {} 2 2 3 {} 4 {} 5 {} 6 8}
+
+do_execsql_test 10.3 {
+ SELECT id, lag(b, -1) OVER (PARTITION BY a ORDER BY id) FROM t7;
+} {1 {} 2 4 3 {} 4 8 5 1 6 {}}
+
+do_execsql_test 11.0 {
+ DROP VIEW IF EXISTS v8;
+ DROP TABLE IF EXISTS t8;
+ CREATE TABLE t8(t INT, total INT);
+ INSERT INTO t8 VALUES(0,2);
+ INSERT INTO t8 VALUES(5,1);
+ INSERT INTO t8 VALUES(10,1);
+} {}
+
+do_execsql_test 11.1 {
+ SELECT NTILE(256) OVER (ORDER BY total) - 1 AS nt FROM t8;
+} {0 1 2}
+
+do_execsql_test 11.2 {
+ CREATE VIEW v8 AS SELECT NTILE(256) OVER (ORDER BY total) - 1 AS nt FROM t8;
+} {}
+
+do_execsql_test 11.3 {
+ SELECT * FROM v8;
+} {0 1 2}
+
+do_execsql_test 11.4 {
+ SELECT * FROM (
+ SELECT NTILE(256) OVER (ORDER BY total) - 1 AS nt FROM t8
+ ) sub;
+} {0 1 2}
+
+do_execsql_test 11.5 {
+ SELECT sum( min(t) ) OVER () FROM t8 GROUP BY total;
+} {5 5}
+
+do_execsql_test 11.5 {
+ SELECT sum( max(t) ) OVER () FROM t8 GROUP BY total;
+} {10 10}
+
+do_execsql_test 11.7 {
+ SELECT sum( min(t) ) OVER () FROM t8;
+} {0}
+
+do_execsql_test 11.8 {
+ SELECT sum( max(t) ) OVER () FROM t8;
+} {10}
+
+do_execsql_test 12.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER);
+ INSERT INTO t2 VALUES(1), (2), (3);
+} {}
+
+do_execsql_test 12.1 {
+ SELECT (SELECT min(a) OVER ()) FROM t2
+} {1 2 3}
+
+
+do_test 12.2 {
+ set myres {}
+ foreach r [db eval {SELECT (SELECT avg(a)) FROM t2 ORDER BY 1}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {2.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+
+do_test 12.3 {
+ set myres {}
+ foreach r [db eval {SELECT
+ (SELECT avg(a) UNION SELECT min(a) OVER ())
+ FROM t2 GROUP BY a
+ ORDER BY 1}] {
+ lappend myres [format %.4f [set r]]
+ }
+ set res2 {1.0000 2.0000 3.0000}
+ set i 0
+ foreach r [set myres] r2 [set res2] {
+ if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
+ error "list element [set i] does not match: got=[set r] expected=[set r2]"
+ }
+ incr i
+ }
+ set {} {}
+} {}
+
+finish_test
diff --git a/test/window5.test b/test/window5.test
new file mode 100644
index 0000000..890d670
--- /dev/null
+++ b/test/window5.test
@@ -0,0 +1,96 @@
+# 2018 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 implements regression tests for SQLite library. Specifically,
+# it tests the sqlite3_create_window_function() API.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window5
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+proc m_step {ctx val} {
+ lappend ctx $val
+ return $ctx
+}
+proc m_value {ctx} {
+ set lSort [lsort $ctx]
+
+ set nVal [llength $lSort]
+ set n [expr $nVal/2]
+
+ if {($nVal % 2)==0 && $nVal>0} {
+ set a [lindex $lSort $n]
+ set b [lindex $lSort $n-1]
+ if {($a+$b) % 2} {
+ set ret [expr ($a+$b)/2.0]
+ } else {
+ set ret [expr ($a+$b)/2]
+ }
+ } else {
+ set ret [lindex $lSort $n]
+ }
+ return $ret
+}
+proc m_inverse {ctx val} {
+ set ctx [lrange $ctx 1 end]
+ return $ctx
+}
+proc w_value {ctx} {
+ lsort $ctx
+}
+
+sqlite3_create_window_function db median m_step m_value m_value m_inverse
+sqlite3_create_window_function db win m_step w_value w_value m_inverse
+
+do_test 0.0 {
+ test_create_window_function_misuse db
+} {}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(4, 'a');
+ INSERT INTO t1 VALUES(6, 'b');
+ INSERT INTO t1 VALUES(1, 'c');
+ INSERT INTO t1 VALUES(5, 'd');
+ INSERT INTO t1 VALUES(2, 'e');
+ INSERT INTO t1 VALUES(3, 'f');
+}
+
+do_execsql_test 1.1 {
+ SELECT win(a) OVER (ORDER BY b), median(a) OVER (ORDER BY b) FROM t1;
+} {4 4 {4 6} 5 {1 4 6} 4 {1 4 5 6} 4.5 {1 2 4 5 6} 4 {1 2 3 4 5 6} 3.5}
+
+test_create_sumint db
+do_execsql_test 2.0 {
+ SELECT sumint(a) OVER (ORDER BY rowid) FROM t1 ORDER BY rowid;
+} {4 10 11 16 18 21}
+
+do_execsql_test 2.1 {
+ SELECT sumint(a) OVER (ORDER BY rowid ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1 ORDER BY rowid;
+} {10 11 12 8 10 5}
+
+test_override_sum db
+do_catchsql_test 3.0 {
+ SELECT sum(a) OVER
+ (ORDER BY b ROWS BETWEEN 1 PRECEDING AND CURRENT ROW)
+ FROM t1;
+} {1 {sum() may not be used as a window function}}
+do_execsql_test 3.1 {
+ SELECT sum(a) FROM t1;
+} {21}
+
+
+finish_test
diff --git a/test/window6.test b/test/window6.test
new file mode 100644
index 0000000..b5e6772
--- /dev/null
+++ b/test/window6.test
@@ -0,0 +1,371 @@
+# 2018 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 implements regression tests for SQLite library. Specifically,
+# it tests the sqlite3_create_window_function() API.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window6
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+set setup {
+ CREATE TABLE %t1(%x, %y %typename);
+ INSERT INTO %t1 VALUES(1, 'a');
+ INSERT INTO %t1 VALUES(2, 'b');
+ INSERT INTO %t1 VALUES(3, 'c');
+ INSERT INTO %t1 VALUES(4, 'd');
+ INSERT INTO %t1 VALUES(5, 'e');
+}
+
+foreach {tn vars} {
+ 1 {}
+ 2 { set A(%t1) over }
+ 3 { set A(%x) over }
+ 4 {
+ set A(%alias) over
+ set A(%x) following
+ set A(%y) over
+ }
+ 5 {
+ set A(%t1) over
+ set A(%x) following
+ set A(%y) preceding
+ set A(%w) current
+ set A(%alias) filter
+ set A(%typename) window
+ }
+
+ 6 {
+ set A(%x) window
+ }
+} {
+ set A(%t1) t1
+ set A(%x) x
+ set A(%y) y
+ set A(%w) w
+ set A(%alias) alias
+ set A(%typename) integer
+ eval $vars
+
+ set MAP [array get A]
+ set setup_sql [string map $MAP $setup]
+ reset_db
+ execsql $setup_sql
+
+ do_execsql_test 1.$tn.1 [string map $MAP {
+ SELECT group_concat(%x, '.') OVER (ORDER BY %y) FROM %t1
+ }] {1 1.2 1.2.3 1.2.3.4 1.2.3.4.5}
+
+ do_execsql_test 1.$tn.2 [string map $MAP {
+ SELECT sum(%x) OVER %w FROM %t1 WINDOW %w AS (ORDER BY %y)
+ }] {1 3 6 10 15}
+
+ do_execsql_test 1.$tn.3 [string map $MAP {
+ SELECT sum(%alias.%x) OVER %w FROM %t1 %alias WINDOW %w AS (ORDER BY %y)
+ }] {1 3 6 10 15}
+
+ do_execsql_test 1.$tn.4 [string map $MAP {
+ SELECT sum(%x) %alias FROM %t1
+ }] {15}
+}
+
+
+proc winproc {args} { return "window: $args" }
+db func window winproc
+do_execsql_test 2.0 {
+ SELECT window('hello world');
+} {{window: {hello world}}}
+
+proc wincmp {a b} { string compare $b $a }
+db collate window wincmp
+do_execsql_test 3.0 {
+ CREATE TABLE window(x COLLATE window);
+ INSERT INTO window VALUES('bob'), ('alice'), ('cate');
+ SELECT * FROM window ORDER BY x COLLATE window;
+} {cate bob alice}
+do_execsql_test 3.1 {
+ DROP TABLE window;
+ CREATE TABLE x1(x);
+ INSERT INTO x1 VALUES('bob'), ('alice'), ('cate');
+ CREATE INDEX window ON x1(x COLLATE window);
+ SELECT * FROM x1 ORDER BY x COLLATE window;
+} {cate bob alice}
+
+
+do_execsql_test 4.0 { CREATE TABLE t4(x, y); }
+
+# do_execsql_test 4.1 { PRAGMA parser_trace = 1 }
+do_execsql_test 4.1 {
+ SELECT * FROM t4 window, t4;
+}
+
+#-------------------------------------------------------------------------
+reset_db
+
+do_execsql_test 5.0 {
+ CREATE TABLE over(x, over);
+ CREATE TABLE window(x, window);
+ INSERT INTO over VALUES(1, 2), (3, 4), (5, 6);
+ INSERT INTO window VALUES(1, 2), (3, 4), (5, 6);
+ SELECT sum(x) over FROM over
+} {9}
+
+do_execsql_test 5.1 {
+ SELECT sum(x) over over FROM over WINDOW over AS ()
+} {9 9 9}
+
+do_execsql_test 5.2 {
+ SELECT sum(over) over over over FROM over over WINDOW over AS (ORDER BY over)
+} {2 6 12}
+
+do_execsql_test 5.3 {
+ SELECT sum(over) over over over FROM over over WINDOW over AS (ORDER BY over);
+} {2 6 12}
+
+do_execsql_test 5.4 {
+ SELECT sum(window) OVER window window FROM window window window window AS (ORDER BY window);
+} {2 6 12}
+
+do_execsql_test 5.5 {
+ SELECT count(*) OVER win FROM over
+ WINDOW win AS (ORDER BY x ROWS BETWEEN +2 FOLLOWING AND +3 FOLLOWING)
+} {1 0 0}
+
+#-------------------------------------------------------------------------
+#
+
+ifcapable !icu {
+ sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
+ do_execsql_test 6.0 {
+ SELECT LIKE('!', '', '!') x WHERE x;
+ } {}
+ do_execsql_test 6.1 {
+ SELECT LIKE("!","","!")""WHeRE"";
+ } {}
+ do_catchsql_test 6.2 {
+ SELECT LIKE("!","","!")""window"";
+ } {1 {near "window": syntax error}}
+}
+
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE t1(x TEXT);
+ CREATE INDEX i1 ON t1(x COLLATE nocase);
+ INSERT INTO t1 VALUES('');
+}
+
+ifcapable !icu {
+ do_execsql_test 7.1 {
+ SELECT count(*) FROM t1 WHERE x LIKE '!' ESCAPE '!';
+ } {0}
+}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 8.0 {
+ CREATE TABLE IF NOT EXISTS "sample" (
+ "id" INTEGER NOT NULL PRIMARY KEY,
+ "counter" INTEGER NOT NULL,
+ "value" REAL NOT NULL
+ );
+
+ INSERT INTO "sample" (counter, value)
+ VALUES (1, 10.), (1, 20.), (2, 1.), (2, 3.), (3, 100.);
+}
+
+do_execsql_test 8.1 {
+ SELECT "counter", "value", RANK() OVER w AS "rank"
+ FROM "sample"
+ WINDOW w AS (PARTITION BY "counter" ORDER BY "value" DESC)
+ ORDER BY "counter", RANK() OVER w
+} {
+ 1 20.0 1 1 10.0 2 2 3.0 1 2 1.0 2 3 100.0 1
+}
+
+do_execsql_test 8.2 {
+ SELECT "counter", "value", SUM("value") OVER
+ (ORDER BY "id" ROWS 2 PRECEDING)
+ FROM "sample"
+ ORDER BY "id"
+} {
+ 1 10.0 10.0 1 20.0 30.0 2 1.0 31.0 2 3.0 24.0 3 100.0 104.0
+}
+
+do_execsql_test 8.3 {
+ SELECT SUM("value") OVER
+ (ORDER BY "id" ROWS BETWEEN 2 PRECEDING AND CURRENT ROW)
+ FROM "sample"
+ ORDER BY "id"
+} {
+ 10.0 30.0 31.0 24.0 104.0
+}
+
+do_execsql_test 9.0 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ SELECT x, group_concat(x) OVER (ORDER BY x ROWS 2 PRECEDING)
+ FROM c;
+} {
+ 1 1 2 1,2 3 1,2,3 4 2,3,4 5 3,4,5
+}
+#do_catchsql_test 9.1 {
+# WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+# SELECT x, group_concat(x) OVER (ORDER BY x RANGE 2 PRECEDING)
+# FROM c;
+#} {1 {RANGE must use only UNBOUNDED or CURRENT ROW}}
+#
+#do_catchsql_test 9.2 {
+# WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+# SELECT x, group_concat(x) OVER (ORDER BY x RANGE BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING)
+# FROM c;
+#} {1 {RANGE must use only UNBOUNDED or CURRENT ROW}}
+
+do_catchsql_test 9.3 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ SELECT count(DISTINCT x) OVER (ORDER BY x) FROM c;
+} {1 {DISTINCT is not supported for window functions}}
+
+do_catchsql_test 9.4 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ SELECT count() OVER (ORDER BY x RANGE UNBOUNDED FOLLOWING) FROM c;
+} {1 {near "FOLLOWING": syntax error}}
+
+do_catchsql_test 9.5 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ SELECT count() OVER (ORDER BY x RANGE BETWEEN UNBOUNDED FOLLOWING AND UNBOUNDED FOLLOWING) FROM c;
+} {1 {near "FOLLOWING": syntax error}}
+
+do_catchsql_test 9.6 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ SELECT count() OVER (ORDER BY x RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED PRECEDING) FROM c;
+} {1 {near "PRECEDING": syntax error}}
+
+foreach {tn frame} {
+ 1 "BETWEEN CURRENT ROW AND 4 PRECEDING"
+ 2 "4 FOLLOWING"
+ 3 "BETWEEN 4 FOLLOWING AND CURRENT ROW"
+ 4 "BETWEEN 4 FOLLOWING AND 2 PRECEDING"
+} {
+ do_catchsql_test 9.7.$tn "
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ SELECT count() OVER (
+ ORDER BY x ROWS $frame
+ ) FROM c;
+ " {1 {unsupported frame specification}}
+}
+
+do_catchsql_test 9.8.1 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ SELECT count() OVER (
+ ORDER BY x ROWS BETWEEN a PRECEDING AND 2 FOLLOWING
+ ) FROM c;
+} {1 {frame starting offset must be a non-negative integer}}
+do_catchsql_test 9.8.2 {
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
+ SELECT count() OVER (
+ ORDER BY x ROWS BETWEEN 2 PRECEDING AND a FOLLOWING
+ ) FROM c;
+} {1 {frame ending offset must be a non-negative integer}}
+
+do_execsql_test 10.0 {
+ WITH t1(a,b) AS (VALUES(1,2))
+ SELECT count() FILTER (where b<>5) OVER w1
+ FROM t1
+ WINDOW w1 AS (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING);
+} {1}
+
+foreach {tn stmt} {
+ 1 "SELECT nth_value(b, 0) OVER (ORDER BY a) FROM t1"
+ 2 "SELECT nth_value(b, -1) OVER (ORDER BY a) FROM t1"
+ 3 "SELECT nth_value(b, '4ab') OVER (ORDER BY a) FROM t1"
+ 4 "SELECT nth_value(b, NULL) OVER (ORDER BY a) FROM t1"
+ 5 "SELECT nth_value(b, 8.5) OVER (ORDER BY a) FROM t1"
+} {
+ do_catchsql_test 10.1.$tn "
+ WITH t1(a,b) AS ( VALUES(1, 2), (2, 3), (3, 4) )
+ $stmt
+ " {1 {second argument to nth_value must be a positive integer}}
+}
+
+foreach {tn stmt res} {
+ 1 "SELECT nth_value(b, 1) OVER (ORDER BY a) FROM t1" {2 2 2}
+ 2 "SELECT nth_value(b, 2) OVER (ORDER BY a) FROM t1" {{} 3 3}
+ 3 "SELECT nth_value(b, '2') OVER (ORDER BY a) FROM t1" {{} 3 3}
+ 4 "SELECT nth_value(b, 2.0) OVER (ORDER BY a) FROM t1" {{} 3 3}
+ 5 "SELECT nth_value(b, '2.0') OVER (ORDER BY a) FROM t1" {{} 3 3}
+ 6 "SELECT nth_value(b, 10000000) OVER (ORDER BY a) FROM t1" {{} {} {}}
+} {
+ do_execsql_test 10.2.$tn "
+ WITH t1(a,b) AS ( VALUES(1, 2), (2, 3), (3, 4) )
+ $stmt
+ " $res
+}
+
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 11.0 {
+ CREATE TABLE t1(a INT);
+ INSERT INTO t1 VALUES(10),(15),(20),(20),(25),(30),(30),(50);
+ CREATE TABLE t3(x INT, y VARCHAR);
+ INSERT INTO t3(x,y) VALUES(10,'ten'),('15','fifteen'),(30,'thirty');
+}
+
+do_execsql_test 11.1 {
+ SELECT a, (SELECT y FROM t3 WHERE x=a) FROM t1 ORDER BY a;
+} {
+ 10 ten 15 fifteen 20 {} 20 {} 25 {} 30 thirty 30 thirty 50 {}
+}
+
+do_execsql_test 11.2 {
+ SELECT a, (SELECT y FROM t3 WHERE x=a), sum(a) OVER (ORDER BY a)
+ FROM t1 ORDER BY a;
+} {
+ 10 ten 10 15 fifteen 25 20 {} 65 20 {} 65
+ 25 {} 90 30 thirty 150 30 thirty 150 50 {} 200
+}
+
+do_execsql_test 11.3.1 {
+ SELECT a, sum(a) OVER win FROM t1
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+} {
+ 10 10 15 25 20 45 20 65 25 90 30 120 30 150 50 200
+}
+do_execsql_test 11.3.2 {
+ SELECT a, sum(a) OVER win FROM t1
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 0 FOLLOWING)
+} {
+ 10 10 15 25 20 45 20 65 25 90 30 120 30 150 50 200
+}
+do_execsql_test 11.3.3 {
+ SELECT a, sum(a) OVER win FROM t1
+ WINDOW win AS (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING)
+} {
+ 10 10 15 25 20 45 20 65 25 90 30 120 30 150 50 200
+}
+
+do_execsql_test 11.4.1 {
+ SELECT y, group_concat(y, '.') OVER win FROM t3
+ WINDOW win AS (
+ ORDER BY y RANGE BETWEEN UNBOUNDED PRECEDING AND 10 PRECEDING
+ );
+} {
+ fifteen fifteen
+ ten fifteen.ten
+ thirty fifteen.ten.thirty
+}
+
+finish_test
diff --git a/test/window7.tcl b/test/window7.tcl
new file mode 100644
index 0000000..56fc60d
--- /dev/null
+++ b/test/window7.tcl
@@ -0,0 +1,91 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+source [file join [file dirname $argv0] pg_common.tcl]
+
+#=========================================================================
+
+start_test window7 "2019 March 01"
+ifcapable !windowfunc
+
+execsql_test 1.0 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a INTEGER, b INTEGER);
+ INSERT INTO t3 VALUES
+ (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8),
+ (9, 9), (0, 10), (1, 11), (2, 12), (3, 13), (4, 14), (5, 15), (6, 16),
+ (7, 17), (8, 18), (9, 19), (0, 20), (1, 21), (2, 22), (3, 23), (4, 24),
+ (5, 25), (6, 26), (7, 27), (8, 28), (9, 29), (0, 30), (1, 31), (2, 32),
+ (3, 33), (4, 34), (5, 35), (6, 36), (7, 37), (8, 38), (9, 39), (0, 40),
+ (1, 41), (2, 42), (3, 43), (4, 44), (5, 45), (6, 46), (7, 47), (8, 48),
+ (9, 49), (0, 50), (1, 51), (2, 52), (3, 53), (4, 54), (5, 55), (6, 56),
+ (7, 57), (8, 58), (9, 59), (0, 60), (1, 61), (2, 62), (3, 63), (4, 64),
+ (5, 65), (6, 66), (7, 67), (8, 68), (9, 69), (0, 70), (1, 71), (2, 72),
+ (3, 73), (4, 74), (5, 75), (6, 76), (7, 77), (8, 78), (9, 79), (0, 80),
+ (1, 81), (2, 82), (3, 83), (4, 84), (5, 85), (6, 86), (7, 87), (8, 88),
+ (9, 89), (0, 90), (1, 91), (2, 92), (3, 93), (4, 94), (5, 95), (6, 96),
+ (7, 97), (8, 98), (9, 99), (0, 100);
+}
+
+execsql_test 1.1 {
+ SELECT a, sum(b) FROM t3 GROUP BY a ORDER BY 1;
+}
+
+execsql_test 1.2 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a GROUPS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t3 ORDER BY 1;
+}
+
+execsql_test 1.3 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a GROUPS BETWEEN 0 PRECEDING AND 0 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+}
+
+execsql_test 1.4 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a GROUPS BETWEEN 2 PRECEDING AND 2 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+}
+
+execsql_test 1.5 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+}
+
+execsql_test 1.6 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+}
+
+execsql_test 1.7 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 2 PRECEDING AND 1 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+}
+
+execsql_test 1.8.1 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 0 PRECEDING AND 1 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+}
+execsql_test 1.8.2 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 0 PRECEDING AND 1 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+}
+
+finish_test
+
diff --git a/test/window7.test b/test/window7.test
new file mode 100644
index 0000000..441e2b1
--- /dev/null
+++ b/test/window7.test
@@ -0,0 +1,186 @@
+# 2019 March 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 file implements regression tests for SQLite library.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window7
+
+ifcapable !windowfunc { finish_test ; return }
+do_execsql_test 1.0 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a INTEGER, b INTEGER);
+ INSERT INTO t3 VALUES
+ (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8),
+ (9, 9), (0, 10), (1, 11), (2, 12), (3, 13), (4, 14), (5, 15), (6, 16),
+ (7, 17), (8, 18), (9, 19), (0, 20), (1, 21), (2, 22), (3, 23), (4, 24),
+ (5, 25), (6, 26), (7, 27), (8, 28), (9, 29), (0, 30), (1, 31), (2, 32),
+ (3, 33), (4, 34), (5, 35), (6, 36), (7, 37), (8, 38), (9, 39), (0, 40),
+ (1, 41), (2, 42), (3, 43), (4, 44), (5, 45), (6, 46), (7, 47), (8, 48),
+ (9, 49), (0, 50), (1, 51), (2, 52), (3, 53), (4, 54), (5, 55), (6, 56),
+ (7, 57), (8, 58), (9, 59), (0, 60), (1, 61), (2, 62), (3, 63), (4, 64),
+ (5, 65), (6, 66), (7, 67), (8, 68), (9, 69), (0, 70), (1, 71), (2, 72),
+ (3, 73), (4, 74), (5, 75), (6, 76), (7, 77), (8, 78), (9, 79), (0, 80),
+ (1, 81), (2, 82), (3, 83), (4, 84), (5, 85), (6, 86), (7, 87), (8, 88),
+ (9, 89), (0, 90), (1, 91), (2, 92), (3, 93), (4, 94), (5, 95), (6, 96),
+ (7, 97), (8, 98), (9, 99), (0, 100);
+} {}
+
+do_execsql_test 1.1 {
+ SELECT a, sum(b) FROM t3 GROUP BY a ORDER BY 1;
+} {0 550 1 460 2 470 3 480 4 490 5 500 6 510 7 520 8 530
+ 9 540}
+
+do_execsql_test 1.2 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a GROUPS BETWEEN CURRENT ROW AND CURRENT ROW
+ ) FROM t3 ORDER BY 1;
+} {0 550 0 550 0 550 0 550 0 550 0 550 0 550 0 550 0 550
+ 0 550 1 460 1 460 1 460 1 460 1 460 1 460 1 460 1 460
+ 1 460 1 460 2 470 2 470 2 470 2 470 2 470 2 470 2 470
+ 2 470 2 470 2 470 3 480 3 480 3 480 3 480 3 480 3 480
+ 3 480 3 480 3 480 3 480 4 490 4 490 4 490 4 490 4 490
+ 4 490 4 490 4 490 4 490 4 490 5 500 5 500 5 500 5 500
+ 5 500 5 500 5 500 5 500 5 500 5 500 6 510 6 510 6 510
+ 6 510 6 510 6 510 6 510 6 510 6 510 6 510 7 520 7 520
+ 7 520 7 520 7 520 7 520 7 520 7 520 7 520 7 520 8 530
+ 8 530 8 530 8 530 8 530 8 530 8 530 8 530 8 530 8 530
+ 9 540 9 540 9 540 9 540 9 540 9 540 9 540 9 540 9 540
+ 9 540}
+
+do_execsql_test 1.3 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a GROUPS BETWEEN 0 PRECEDING AND 0 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+} {0 550 0 550 0 550 0 550 0 550 0 550 0 550 0 550 0 550
+ 0 550 1 460 1 460 1 460 1 460 1 460 1 460 1 460 1 460
+ 1 460 1 460 2 470 2 470 2 470 2 470 2 470 2 470 2 470
+ 2 470 2 470 2 470 3 480 3 480 3 480 3 480 3 480 3 480
+ 3 480 3 480 3 480 3 480 4 490 4 490 4 490 4 490 4 490
+ 4 490 4 490 4 490 4 490 4 490 5 500 5 500 5 500 5 500
+ 5 500 5 500 5 500 5 500 5 500 5 500 6 510 6 510 6 510
+ 6 510 6 510 6 510 6 510 6 510 6 510 6 510 7 520 7 520
+ 7 520 7 520 7 520 7 520 7 520 7 520 7 520 7 520 8 530
+ 8 530 8 530 8 530 8 530 8 530 8 530 8 530 8 530 8 530
+ 9 540 9 540 9 540 9 540 9 540 9 540 9 540 9 540 9 540
+ 9 540}
+
+do_execsql_test 1.4 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a GROUPS BETWEEN 2 PRECEDING AND 2 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+} {0 1480 0 1480 0 1480 0 1480 0 1480 0 1480 0 1480 0 1480
+ 0 1480 0 1480 1 1960 1 1960 1 1960 1 1960 1 1960 1 1960
+ 1 1960 1 1960 1 1960 1 1960 2 2450 2 2450 2 2450 2 2450
+ 2 2450 2 2450 2 2450 2 2450 2 2450 2 2450 3 2400 3 2400
+ 3 2400 3 2400 3 2400 3 2400 3 2400 3 2400 3 2400 3 2400
+ 4 2450 4 2450 4 2450 4 2450 4 2450 4 2450 4 2450 4 2450
+ 4 2450 4 2450 5 2500 5 2500 5 2500 5 2500 5 2500 5 2500
+ 5 2500 5 2500 5 2500 5 2500 6 2550 6 2550 6 2550 6 2550
+ 6 2550 6 2550 6 2550 6 2550 6 2550 6 2550 7 2600 7 2600
+ 7 2600 7 2600 7 2600 7 2600 7 2600 7 2600 7 2600 7 2600
+ 8 2100 8 2100 8 2100 8 2100 8 2100 8 2100 8 2100 8 2100
+ 8 2100 8 2100 9 1590 9 1590 9 1590 9 1590 9 1590 9 1590
+ 9 1590 9 1590 9 1590 9 1590}
+
+do_execsql_test 1.5 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+} {0 550 0 550 0 550 0 550 0 550 0 550 0 550 0 550 0 550
+ 0 550 1 460 1 460 1 460 1 460 1 460 1 460 1 460 1 460
+ 1 460 1 460 2 470 2 470 2 470 2 470 2 470 2 470 2 470
+ 2 470 2 470 2 470 3 480 3 480 3 480 3 480 3 480 3 480
+ 3 480 3 480 3 480 3 480 4 490 4 490 4 490 4 490 4 490
+ 4 490 4 490 4 490 4 490 4 490 5 500 5 500 5 500 5 500
+ 5 500 5 500 5 500 5 500 5 500 5 500 6 510 6 510 6 510
+ 6 510 6 510 6 510 6 510 6 510 6 510 6 510 7 520 7 520
+ 7 520 7 520 7 520 7 520 7 520 7 520 7 520 7 520 8 530
+ 8 530 8 530 8 530 8 530 8 530 8 530 8 530 8 530 8 530
+ 9 540 9 540 9 540 9 540 9 540 9 540 9 540 9 540 9 540
+ 9 540}
+
+do_execsql_test 1.6 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+} {0 1480 0 1480 0 1480 0 1480 0 1480 0 1480 0 1480 0 1480
+ 0 1480 0 1480 1 1960 1 1960 1 1960 1 1960 1 1960 1 1960
+ 1 1960 1 1960 1 1960 1 1960 2 2450 2 2450 2 2450 2 2450
+ 2 2450 2 2450 2 2450 2 2450 2 2450 2 2450 3 2400 3 2400
+ 3 2400 3 2400 3 2400 3 2400 3 2400 3 2400 3 2400 3 2400
+ 4 2450 4 2450 4 2450 4 2450 4 2450 4 2450 4 2450 4 2450
+ 4 2450 4 2450 5 2500 5 2500 5 2500 5 2500 5 2500 5 2500
+ 5 2500 5 2500 5 2500 5 2500 6 2550 6 2550 6 2550 6 2550
+ 6 2550 6 2550 6 2550 6 2550 6 2550 6 2550 7 2600 7 2600
+ 7 2600 7 2600 7 2600 7 2600 7 2600 7 2600 7 2600 7 2600
+ 8 2100 8 2100 8 2100 8 2100 8 2100 8 2100 8 2100 8 2100
+ 8 2100 8 2100 9 1590 9 1590 9 1590 9 1590 9 1590 9 1590
+ 9 1590 9 1590 9 1590 9 1590}
+
+do_execsql_test 1.7 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 2 PRECEDING AND 1 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+} {0 1010 0 1010 0 1010 0 1010 0 1010 0 1010 0 1010 0 1010
+ 0 1010 0 1010 1 1480 1 1480 1 1480 1 1480 1 1480 1 1480
+ 1 1480 1 1480 1 1480 1 1480 2 1960 2 1960 2 1960 2 1960
+ 2 1960 2 1960 2 1960 2 1960 2 1960 2 1960 3 1900 3 1900
+ 3 1900 3 1900 3 1900 3 1900 3 1900 3 1900 3 1900 3 1900
+ 4 1940 4 1940 4 1940 4 1940 4 1940 4 1940 4 1940 4 1940
+ 4 1940 4 1940 5 1980 5 1980 5 1980 5 1980 5 1980 5 1980
+ 5 1980 5 1980 5 1980 5 1980 6 2020 6 2020 6 2020 6 2020
+ 6 2020 6 2020 6 2020 6 2020 6 2020 6 2020 7 2060 7 2060
+ 7 2060 7 2060 7 2060 7 2060 7 2060 7 2060 7 2060 7 2060
+ 8 2100 8 2100 8 2100 8 2100 8 2100 8 2100 8 2100 8 2100
+ 8 2100 8 2100 9 1590 9 1590 9 1590 9 1590 9 1590 9 1590
+ 9 1590 9 1590 9 1590 9 1590}
+
+do_execsql_test 1.8.1 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 0 PRECEDING AND 1 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+} {0 1010 0 1010 0 1010 0 1010 0 1010 0 1010 0 1010 0 1010
+ 0 1010 0 1010 1 930 1 930 1 930 1 930 1 930 1 930 1 930
+ 1 930 1 930 1 930 2 950 2 950 2 950 2 950 2 950 2 950
+ 2 950 2 950 2 950 2 950 3 970 3 970 3 970 3 970 3 970
+ 3 970 3 970 3 970 3 970 3 970 4 990 4 990 4 990 4 990
+ 4 990 4 990 4 990 4 990 4 990 4 990 5 1010 5 1010 5 1010
+ 5 1010 5 1010 5 1010 5 1010 5 1010 5 1010 5 1010 6 1030
+ 6 1030 6 1030 6 1030 6 1030 6 1030 6 1030 6 1030 6 1030
+ 6 1030 7 1050 7 1050 7 1050 7 1050 7 1050 7 1050 7 1050
+ 7 1050 7 1050 7 1050 8 1070 8 1070 8 1070 8 1070 8 1070
+ 8 1070 8 1070 8 1070 8 1070 8 1070 9 540 9 540 9 540 9 540
+ 9 540 9 540 9 540 9 540 9 540 9 540}
+
+do_execsql_test 1.8.2 {
+ SELECT a, sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 0 PRECEDING AND 1 FOLLOWING
+ ) FROM t3 ORDER BY 1;
+} {0 550 0 550 0 550 0 550 0 550 0 550 0 550 0 550 0 550
+ 0 550 1 1010 1 1010 1 1010 1 1010 1 1010 1 1010 1 1010
+ 1 1010 1 1010 1 1010 2 930 2 930 2 930 2 930 2 930 2 930
+ 2 930 2 930 2 930 2 930 3 950 3 950 3 950 3 950 3 950
+ 3 950 3 950 3 950 3 950 3 950 4 970 4 970 4 970 4 970
+ 4 970 4 970 4 970 4 970 4 970 4 970 5 990 5 990 5 990
+ 5 990 5 990 5 990 5 990 5 990 5 990 5 990 6 1010 6 1010
+ 6 1010 6 1010 6 1010 6 1010 6 1010 6 1010 6 1010 6 1010
+ 7 1030 7 1030 7 1030 7 1030 7 1030 7 1030 7 1030 7 1030
+ 7 1030 7 1030 8 1050 8 1050 8 1050 8 1050 8 1050 8 1050
+ 8 1050 8 1050 8 1050 8 1050 9 1070 9 1070 9 1070 9 1070
+ 9 1070 9 1070 9 1070 9 1070 9 1070 9 1070}
+
+finish_test
diff --git a/test/window8.tcl b/test/window8.tcl
new file mode 100644
index 0000000..69ad0ad
--- /dev/null
+++ b/test/window8.tcl
@@ -0,0 +1,495 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+source [file join [file dirname $argv0] pg_common.tcl]
+
+#=========================================================================
+
+start_test window8 "2019 March 01"
+ifcapable !windowfunc
+
+execsql_test 1.0 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a TEXT, b TEXT, c INTEGER);
+ INSERT INTO t3 VALUES
+ ('HH', 'bb', 355), ('CC', 'aa', 158), ('BB', 'aa', 399),
+ ('FF', 'bb', 938), ('HH', 'aa', 480), ('FF', 'bb', 870),
+ ('JJ', 'aa', 768), ('JJ', 'aa', 899), ('GG', 'bb', 929),
+ ('II', 'bb', 421), ('GG', 'bb', 844), ('FF', 'bb', 574),
+ ('CC', 'bb', 822), ('GG', 'bb', 938), ('BB', 'aa', 660),
+ ('HH', 'aa', 979), ('BB', 'bb', 792), ('DD', 'aa', 845),
+ ('JJ', 'bb', 354), ('FF', 'bb', 295), ('JJ', 'aa', 234),
+ ('BB', 'bb', 840), ('AA', 'aa', 934), ('EE', 'aa', 113),
+ ('AA', 'bb', 309), ('BB', 'aa', 412), ('AA', 'aa', 911),
+ ('AA', 'bb', 572), ('II', 'aa', 398), ('II', 'bb', 250),
+ ('II', 'aa', 652), ('BB', 'bb', 633), ('AA', 'aa', 239),
+ ('FF', 'aa', 670), ('BB', 'bb', 705), ('HH', 'bb', 963),
+ ('CC', 'bb', 346), ('II', 'bb', 671), ('BB', 'aa', 247),
+ ('AA', 'aa', 223), ('GG', 'aa', 480), ('HH', 'aa', 790),
+ ('FF', 'aa', 208), ('BB', 'bb', 711), ('EE', 'aa', 777),
+ ('DD', 'bb', 716), ('CC', 'aa', 759), ('CC', 'aa', 430),
+ ('CC', 'aa', 607), ('DD', 'bb', 794), ('GG', 'aa', 148),
+ ('GG', 'aa', 634), ('JJ', 'bb', 257), ('DD', 'bb', 959),
+ ('FF', 'bb', 726), ('BB', 'aa', 762), ('JJ', 'bb', 336),
+ ('GG', 'aa', 335), ('HH', 'bb', 330), ('GG', 'bb', 160),
+ ('JJ', 'bb', 839), ('FF', 'aa', 618), ('BB', 'aa', 393),
+ ('EE', 'bb', 629), ('FF', 'aa', 667), ('AA', 'bb', 870),
+ ('FF', 'bb', 102), ('JJ', 'aa', 113), ('DD', 'aa', 224),
+ ('AA', 'bb', 627), ('HH', 'bb', 730), ('II', 'bb', 443),
+ ('HH', 'bb', 133), ('EE', 'bb', 252), ('II', 'bb', 805),
+ ('BB', 'bb', 786), ('EE', 'bb', 768), ('HH', 'bb', 683),
+ ('DD', 'bb', 238), ('DD', 'aa', 256);
+}
+
+foreach {tn frame} {
+ 1 { GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING }
+ 2 { GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW }
+ 3 { GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING }
+ 4 { GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING }
+ 5 { GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING }
+ 6 { GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING }
+ 7 { GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING }
+ 8 { GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING }
+ 9 { GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW }
+ 10 { GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING }
+ 11 { GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING }
+ 12 { GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING }
+ 13 { GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING }
+ 14 { GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING }
+ 15 { GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING }
+ 16 { GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING }
+ 17 { GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING }
+ 18 { GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING }
+ 19 { GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING }
+
+} {
+ execsql_test 1.$tn.1 "
+ SELECT a, b, sum(c) OVER (ORDER BY a $frame) FROM t3 ORDER BY 1, 2, 3;
+ "
+ execsql_test 1.$tn.2 "
+ SELECT a, b, sum(c) OVER (ORDER BY a,b $frame) FROM t3 ORDER BY 1, 2, 3;
+ "
+ execsql_test 1.$tn.3 "
+ SELECT a, b, rank() OVER (ORDER BY a $frame) FROM t3 ORDER BY 1, 2, 3;
+ "
+ execsql_test 1.$tn.4 "
+ SELECT a, b, max(c) OVER (ORDER BY a,b $frame) FROM t3 ORDER BY 1, 2, 3;
+ "
+ execsql_test 1.$tn.5 "
+ SELECT a, b, min(c) OVER (ORDER BY a,b $frame) FROM t3 ORDER BY 1, 2, 3;
+ "
+
+ set f2 "$frame EXCLUDE CURRENT ROW"
+
+ execsql_test 1.$tn.6 "
+ SELECT a, b, sum(c) OVER (ORDER BY a $f2) FROM t3 ORDER BY 1, 2, 3;
+ "
+ execsql_test 1.$tn.7 "
+ SELECT a, b, sum(c) OVER (ORDER BY a,b $f2) FROM t3 ORDER BY 1, 2, 3;
+ "
+
+ execsql_test 1.$tn.8 "
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a $f2),
+ sum(c) OVER (ORDER BY a $frame),
+ sum(c) OVER (ORDER BY a,b $f2),
+ sum(c) OVER (ORDER BY a,b $frame)
+ FROM t3 ORDER BY 1, 2, 3;
+ "
+}
+
+
+foreach {tn ex} {
+ 1 { EXCLUDE NO OTHERS }
+ 2 { EXCLUDE CURRENT ROW }
+ 3 { EXCLUDE GROUP }
+ 4 { EXCLUDE TIES }
+} {
+ execsql_test 2.$tn.1 "
+ SELECT row_number() OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING $ex
+ )
+ "
+
+ execsql_test 2.$tn.2 "
+ SELECT nth_value(c, 14) OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING $ex
+ )
+ "
+
+ execsql_test 2.$tn.3 "
+ SELECT min(c) OVER win, max(c) OVER win, sum(c) OVER win FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW $ex
+ ) ORDER BY a, b, c;
+ "
+}
+
+==========
+
+execsql_test 3.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a REAL, b INTEGER);
+ INSERT INTO t1 VALUES
+ (5, 10), (10, 20), (13, 26), (13, 26),
+ (15, 30), (20, 40), (22,80), (30, 90);
+}
+
+foreach {tn frame} {
+ 1 { ORDER BY a RANGE BETWEEN 5 PRECEDING AND 5 FOLLOWING }
+ 2 { ORDER BY a RANGE BETWEEN 10 PRECEDING AND 5 PRECEDING }
+ 3 { ORDER BY a RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING }
+ 4 { ORDER BY a DESC RANGE BETWEEN 5 PRECEDING AND 5 FOLLOWING }
+ 5 { ORDER BY a DESC RANGE BETWEEN 10 PRECEDING AND 5 PRECEDING }
+ 6 { ORDER BY a DESC RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING }
+
+ 7 { ORDER BY a RANGE BETWEEN 5.1 PRECEDING AND 5.3 FOLLOWING }
+ 8 { ORDER BY a RANGE BETWEEN 10.2 PRECEDING AND 5.4 PRECEDING }
+ 9 { ORDER BY a RANGE BETWEEN 2.6 FOLLOWING AND 3.5 FOLLOWING }
+ 10 { ORDER BY a DESC RANGE BETWEEN 5.7 PRECEDING AND 5.8 FOLLOWING }
+ 11 { ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND 5.9 PRECEDING }
+ 12 { ORDER BY a DESC RANGE BETWEEN 2.1 FOLLOWING AND UNBOUNDED FOLLOWING }
+ 13 { ORDER BY a RANGE 5.1 PRECEDING }
+} {
+ execsql_test 3.$tn "
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ($frame)
+ "
+}
+
+==========
+
+execsql_test 4.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER);
+ INSERT INTO t1 VALUES
+ (NULL, 1), (NULL, 2), (NULL, 3), (10, 4), (10, 5);
+}
+
+execsql_test 4.1.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 5 PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1;
+}
+execsql_test 4.1.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 5 PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1;
+}
+
+execsql_test 4.2.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+}
+execsql_test 4.2.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+}
+
+execsql_test 4.2.3 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+}
+execsql_test 4.2.4 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+}
+
+execsql_test 4.3.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+}
+execsql_test 4.3.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a NULLS LAST RANGE BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+}
+
+execsql_test 4.4.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a NULLS FIRST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+}
+execsql_test 4.4.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a NULLS LAST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+}
+
+execsql_test 4.4.3 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC NULLS LAST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+}
+execsql_test 4.4.4 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC NULLS LAST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+}
+
+execsql_test 4.5.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a ASC NULLS LAST RANGE BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+}
+execsql_test 4.5.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC NULLS FIRST RANGE
+ BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+}
+
+==========
+
+execsql_test 5.0 {
+ INSERT INTO t3 VALUES
+ (NULL, 'bb', 355), (NULL, 'cc', 158), (NULL, 'aa', 399),
+ ('JJ', NULL, 839), ('FF', NULL, 618), ('BB', NULL, 393),
+ (NULL, 'bb', 629), (NULL, NULL, 667), (NULL, NULL, 870);
+}
+
+foreach {tn ex} {
+ 1 { EXCLUDE NO OTHERS }
+ 2 { EXCLUDE CURRENT ROW }
+ 3 { EXCLUDE GROUP }
+ 4 { EXCLUDE TIES }
+} {
+ foreach {tn2 frame} {
+ 1 { RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING }
+ 2 { ORDER BY a NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING }
+ 3 { PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING }
+ 4 { ORDER BY a NULLS FIRST GROUPS 6 PRECEDING }
+ 5 { ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING }
+ 6 { ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING }
+ 7 { ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING }
+
+ 8 { RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING }
+ 9 { ORDER BY a NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING }
+ 10 { PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING }
+ 11 { ORDER BY a NULLS LAST GROUPS 6 PRECEDING }
+ 12 { ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING }
+ 13 { ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING }
+ 14 { ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING }
+ } {
+ execsql_test 5.$tn.$tn2.1 "
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( $frame $ex )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+ "
+
+ execsql_test 5.$tn.$tn2.2 "
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( $frame $ex )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+ "
+ }
+}
+
+==========
+
+execsql_test 6.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a TEXT, b INTEGER);
+ INSERT INTO t2 VALUES('A', NULL);
+ INSERT INTO t2 VALUES('B', NULL);
+ INSERT INTO t2 VALUES('C', 1);
+}
+
+execsql_test 6.1 {
+ SELECT string_agg(a, '.') OVER (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 7 PRECEDING AND 2 PRECEDING
+ )
+ FROM t2
+}
+
+execsql_test 6.2 {
+ SELECT string_agg(a, '.') OVER (
+ ORDER BY b DESC NULLS LAST RANGE BETWEEN 7 PRECEDING AND 2 PRECEDING
+ )
+ FROM t2
+}
+
+==========
+
+execsql_test 7.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER, b INTEGER);
+
+ INSERT INTO t2 VALUES(1, 65);
+ INSERT INTO t2 VALUES(2, NULL);
+ INSERT INTO t2 VALUES(3, NULL);
+ INSERT INTO t2 VALUES(4, NULL);
+ INSERT INTO t2 VALUES(5, 66);
+ INSERT INTO t2 VALUES(6, 67);
+}
+
+foreach {tn f ex} {
+ 1 sum ""
+ 2 min ""
+ 3 sum "EXCLUDE CURRENT ROW"
+ 4 max "EXCLUDE CURRENT ROW"
+} {
+execsql_test 7.$tn.1 "
+ SELECT $f (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 6 FOLLOWING AND UNBOUNDED FOLLOWING
+ );
+"
+execsql_test 7.$tn.2 "
+ SELECT $f (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+"
+execsql_test 7.$tn.3 "
+ SELECT $f (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+"
+execsql_test 7.$tn.4 "
+ SELECT $f (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+"
+execsql_test 7.$tn.5 "
+ SELECT $f (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+"
+
+execsql_test 7.$tn.6 "
+ SELECT $f (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1000 PRECEDING AND 2 PRECEDING
+ );
+"
+execsql_test 7.$tn.7 "
+ SELECT $f (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+"
+execsql_test 7.$tn.8 "
+ SELECT $f (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1000 PRECEDING AND 2000 PRECEDING
+ );
+"
+execsql_test 7.$tn.9 "
+ SELECT $f (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+"
+}
+
+==========
+
+execsql_test 8.0 {
+ DROP TABLE IF EXISTS tx;
+ CREATE TABLE tx(a INTEGER PRIMARY KEY);
+ INSERT INTO tx VALUES(1), (2), (3), (4), (5), (6);
+
+ DROP TABLE IF EXISTS map;
+ CREATE TABLE map(v INTEGER PRIMARY KEY, t TEXT);
+ INSERT INTO map VALUES
+ (1, 'odd'), (2, 'even'), (3, 'odd'),
+ (4, 'even'), (5, 'odd'), (6, 'even');
+}
+
+execsql_test 8.1 {
+ SELECT sum(a) OVER (
+ PARTITION BY (
+ SELECT t FROM map WHERE v=a
+ ) ORDER BY a
+ ) FROM tx;
+}
+
+execsql_test 8.2 {
+ SELECT sum(a) OVER win FROM tx
+ WINDOW win AS (
+ PARTITION BY (
+ SELECT t FROM map WHERE v=a
+ ) ORDER BY a
+ );
+}
+
+execsql_test 8.3 {
+ WITH map2 AS (
+ SELECT * FROM map
+ )
+ SELECT sum(a) OVER (
+ PARTITION BY (
+ SELECT t FROM map2 WHERE v=a
+ ) ORDER BY a
+ ) FROM tx;
+}
+
+execsql_test 8.4 {
+ WITH map2 AS (
+ SELECT * FROM map
+ )
+ SELECT sum(a) OVER win FROM tx
+ WINDOW win AS (
+ PARTITION BY (
+ SELECT t FROM map2 WHERE v=a
+ ) ORDER BY a
+ );
+}
+
+==========
+
+execsql_test 9.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER);
+ CREATE TABLE t2(y INTEGER);
+}
+
+execsql_test 9.2 {
+ SELECT (
+ SELECT max(a) OVER ( ORDER BY (SELECT sum(a) FROM t1) )
+ + min(a) OVER()
+ )
+ FROM t1
+}
+
+
+finish_test
+
+
diff --git a/test/window8.test b/test/window8.test
new file mode 100644
index 0000000..0c5d39b
--- /dev/null
+++ b/test/window8.test
@@ -0,0 +1,6543 @@
+# 2019 March 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 file implements regression tests for SQLite library.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window8
+
+ifcapable !windowfunc { finish_test ; return }
+do_execsql_test 1.0 {
+ DROP TABLE IF EXISTS t3;
+ CREATE TABLE t3(a TEXT, b TEXT, c INTEGER);
+ INSERT INTO t3 VALUES
+ ('HH', 'bb', 355), ('CC', 'aa', 158), ('BB', 'aa', 399),
+ ('FF', 'bb', 938), ('HH', 'aa', 480), ('FF', 'bb', 870),
+ ('JJ', 'aa', 768), ('JJ', 'aa', 899), ('GG', 'bb', 929),
+ ('II', 'bb', 421), ('GG', 'bb', 844), ('FF', 'bb', 574),
+ ('CC', 'bb', 822), ('GG', 'bb', 938), ('BB', 'aa', 660),
+ ('HH', 'aa', 979), ('BB', 'bb', 792), ('DD', 'aa', 845),
+ ('JJ', 'bb', 354), ('FF', 'bb', 295), ('JJ', 'aa', 234),
+ ('BB', 'bb', 840), ('AA', 'aa', 934), ('EE', 'aa', 113),
+ ('AA', 'bb', 309), ('BB', 'aa', 412), ('AA', 'aa', 911),
+ ('AA', 'bb', 572), ('II', 'aa', 398), ('II', 'bb', 250),
+ ('II', 'aa', 652), ('BB', 'bb', 633), ('AA', 'aa', 239),
+ ('FF', 'aa', 670), ('BB', 'bb', 705), ('HH', 'bb', 963),
+ ('CC', 'bb', 346), ('II', 'bb', 671), ('BB', 'aa', 247),
+ ('AA', 'aa', 223), ('GG', 'aa', 480), ('HH', 'aa', 790),
+ ('FF', 'aa', 208), ('BB', 'bb', 711), ('EE', 'aa', 777),
+ ('DD', 'bb', 716), ('CC', 'aa', 759), ('CC', 'aa', 430),
+ ('CC', 'aa', 607), ('DD', 'bb', 794), ('GG', 'aa', 148),
+ ('GG', 'aa', 634), ('JJ', 'bb', 257), ('DD', 'bb', 959),
+ ('FF', 'bb', 726), ('BB', 'aa', 762), ('JJ', 'bb', 336),
+ ('GG', 'aa', 335), ('HH', 'bb', 330), ('GG', 'bb', 160),
+ ('JJ', 'bb', 839), ('FF', 'aa', 618), ('BB', 'aa', 393),
+ ('EE', 'bb', 629), ('FF', 'aa', 667), ('AA', 'bb', 870),
+ ('FF', 'bb', 102), ('JJ', 'aa', 113), ('DD', 'aa', 224),
+ ('AA', 'bb', 627), ('HH', 'bb', 730), ('II', 'bb', 443),
+ ('HH', 'bb', 133), ('EE', 'bb', 252), ('II', 'bb', 805),
+ ('BB', 'bb', 786), ('EE', 'bb', 768), ('HH', 'bb', 683),
+ ('DD', 'bb', 238), ('DD', 'aa', 256);
+} {}
+
+do_execsql_test 1.1.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685
+ BB bb 4685 CC aa 12025 CC aa 12025 CC aa 12025 CC aa 12025
+ CC bb 12025 CC bb 12025 DD aa 15147 DD aa 15147 DD aa 15147
+ DD bb 15147 DD bb 15147 DD bb 15147 DD bb 15147 EE aa 19179
+ EE aa 19179 EE bb 19179 EE bb 19179 EE bb 19179 FF aa 21718
+ FF aa 21718 FF aa 21718 FF aa 21718 FF bb 21718 FF bb 21718
+ FF bb 21718 FF bb 21718 FF bb 21718 FF bb 21718 GG aa 27386
+ GG aa 27386 GG aa 27386 GG aa 27386 GG bb 27386 GG bb 27386
+ GG bb 27386 GG bb 27386 HH aa 31854 HH aa 31854 HH aa 31854
+ HH bb 31854 HH bb 31854 HH bb 31854 HH bb 31854 HH bb 31854
+ HH bb 31854 II aa 37297 II aa 37297 II bb 37297 II bb 37297
+ II bb 37297 II bb 37297 II bb 37297 JJ aa 40937 JJ aa 40937
+ JJ aa 40937 JJ aa 40937 JJ bb 40937 JJ bb 40937 JJ bb 40937
+ JJ bb 40937}
+
+do_execsql_test 1.1.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 2307 AA bb 2307
+ AA bb 2307 AA bb 2307 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB aa 4685 BB bb 7558 BB bb 7558 BB bb 7558 BB bb 7558
+ BB bb 7558 BB bb 7558 CC aa 12025 CC aa 12025 CC aa 12025
+ CC aa 12025 CC bb 13979 CC bb 13979 DD aa 15147 DD aa 15147
+ DD aa 15147 DD bb 16472 DD bb 16472 DD bb 16472 DD bb 16472
+ EE aa 19179 EE aa 19179 EE bb 20069 EE bb 20069 EE bb 20069
+ FF aa 21718 FF aa 21718 FF aa 21718 FF aa 21718 FF bb 23881
+ FF bb 23881 FF bb 23881 FF bb 23881 FF bb 23881 FF bb 23881
+ GG aa 27386 GG aa 27386 GG aa 27386 GG aa 27386 GG bb 28983
+ GG bb 28983 GG bb 28983 GG bb 28983 HH aa 31854 HH aa 31854
+ HH aa 31854 HH bb 34103 HH bb 34103 HH bb 34103 HH bb 34103
+ HH bb 34103 HH bb 34103 II aa 37297 II aa 37297 II bb 38347
+ II bb 38347 II bb 38347 II bb 38347 II bb 38347 JJ aa 40937
+ JJ aa 40937 JJ aa 40937 JJ aa 40937 JJ bb 42951 JJ bb 42951
+ JJ bb 42951 JJ bb 42951}
+
+do_execsql_test 1.1.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.1.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 934 AA bb 934
+ AA bb 934 AA bb 934 BB aa 934 BB aa 934 BB aa 934 BB aa 934
+ BB aa 934 BB aa 934 BB bb 934 BB bb 934 BB bb 934 BB bb 934
+ BB bb 934 BB bb 934 CC aa 934 CC aa 934 CC aa 934 CC aa 934
+ CC bb 934 CC bb 934 DD aa 934 DD aa 934 DD aa 934 DD bb 934
+ DD bb 934 DD bb 934 DD bb 934 EE aa 959 EE aa 959 EE bb 959
+ EE bb 959 EE bb 959 FF aa 959 FF aa 959 FF aa 959 FF aa 959
+ FF bb 959 FF bb 959 FF bb 959 FF bb 959 FF bb 959 FF bb 959
+ GG aa 959 GG aa 959 GG aa 959 GG aa 959 GG bb 959 GG bb 959
+ GG bb 959 GG bb 959 HH aa 959 HH aa 959 HH aa 959 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 979 II bb 979 II bb 979 II bb 979 II bb 979
+ JJ aa 979 JJ aa 979 JJ aa 979 JJ aa 979 JJ bb 979 JJ bb 979
+ JJ bb 979 JJ bb 979}
+
+do_execsql_test 1.1.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 223 AA bb 223
+ AA bb 223 AA bb 223 BB aa 223 BB aa 223 BB aa 223 BB aa 223
+ BB aa 223 BB aa 223 BB bb 223 BB bb 223 BB bb 223 BB bb 223
+ BB bb 223 BB bb 223 CC aa 223 CC aa 223 CC aa 223 CC aa 223
+ CC bb 158 CC bb 158 DD aa 158 DD aa 158 DD aa 158 DD bb 158
+ DD bb 158 DD bb 158 DD bb 158 EE aa 158 EE aa 158 EE bb 113
+ EE bb 113 EE bb 113 FF aa 113 FF aa 113 FF aa 113 FF aa 113
+ FF bb 113 FF bb 113 FF bb 113 FF bb 113 FF bb 113 FF bb 113
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 102 HH aa 102 HH aa 102 HH bb 102
+ HH bb 102 HH bb 102 HH bb 102 HH bb 102 HH bb 102 II aa 102
+ II aa 102 II bb 102 II bb 102 II bb 102 II bb 102 II bb 102
+ JJ aa 102 JJ aa 102 JJ aa 102 JJ aa 102 JJ bb 102 JJ bb 102
+ JJ bb 102 JJ bb 102}
+
+do_execsql_test 1.1.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685
+ BB bb 4685 CC aa 12025 CC aa 12025 CC aa 12025 CC aa 12025
+ CC bb 12025 CC bb 12025 DD aa 15147 DD aa 15147 DD aa 15147
+ DD bb 15147 DD bb 15147 DD bb 15147 DD bb 15147 EE aa 19179
+ EE aa 19179 EE bb 19179 EE bb 19179 EE bb 19179 FF aa 21718
+ FF aa 21718 FF aa 21718 FF aa 21718 FF bb 21718 FF bb 21718
+ FF bb 21718 FF bb 21718 FF bb 21718 FF bb 21718 GG aa 27386
+ GG aa 27386 GG aa 27386 GG aa 27386 GG bb 27386 GG bb 27386
+ GG bb 27386 GG bb 27386 HH aa 31854 HH aa 31854 HH aa 31854
+ HH bb 31854 HH bb 31854 HH bb 31854 HH bb 31854 HH bb 31854
+ HH bb 31854 II aa 37297 II aa 37297 II bb 37297 II bb 37297
+ II bb 37297 II bb 37297 II bb 37297 JJ aa 40937 JJ aa 40937
+ JJ aa 40937 JJ aa 40937 JJ bb 40937 JJ bb 40937 JJ bb 40937
+ JJ bb 40937}
+
+do_execsql_test 1.1.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 2307 AA bb 2307
+ AA bb 2307 AA bb 2307 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB aa 4685 BB bb 7558 BB bb 7558 BB bb 7558 BB bb 7558
+ BB bb 7558 BB bb 7558 CC aa 12025 CC aa 12025 CC aa 12025
+ CC aa 12025 CC bb 13979 CC bb 13979 DD aa 15147 DD aa 15147
+ DD aa 15147 DD bb 16472 DD bb 16472 DD bb 16472 DD bb 16472
+ EE aa 19179 EE aa 19179 EE bb 20069 EE bb 20069 EE bb 20069
+ FF aa 21718 FF aa 21718 FF aa 21718 FF aa 21718 FF bb 23881
+ FF bb 23881 FF bb 23881 FF bb 23881 FF bb 23881 FF bb 23881
+ GG aa 27386 GG aa 27386 GG aa 27386 GG aa 27386 GG bb 28983
+ GG bb 28983 GG bb 28983 GG bb 28983 HH aa 31854 HH aa 31854
+ HH aa 31854 HH bb 34103 HH bb 34103 HH bb 34103 HH bb 34103
+ HH bb 34103 HH bb 34103 II aa 37297 II aa 37297 II bb 38347
+ II bb 38347 II bb 38347 II bb 38347 II bb 38347 JJ aa 40937
+ JJ aa 40937 JJ aa 40937 JJ aa 40937 JJ bb 42951 JJ bb 42951
+ JJ bb 42951 JJ bb 42951}
+
+do_execsql_test 1.1.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} {} {} {} AA aa {} {} {} {} AA aa {} {} {} {}
+ AA aa {} {} {} {} AA bb {} {} 2307 2307 AA bb {} {} 2307 2307
+ AA bb {} {} 2307 2307 AA bb {} {} 2307 2307 BB aa 4685 4685 4685 4685
+ BB aa 4685 4685 4685 4685 BB aa 4685 4685 4685 4685
+ BB aa 4685 4685 4685 4685 BB aa 4685 4685 4685 4685
+ BB aa 4685 4685 4685 4685 BB bb 4685 4685 7558 7558
+ BB bb 4685 4685 7558 7558 BB bb 4685 4685 7558 7558
+ BB bb 4685 4685 7558 7558 BB bb 4685 4685 7558 7558
+ BB bb 4685 4685 7558 7558 CC aa 12025 12025 12025 12025
+ CC aa 12025 12025 12025 12025 CC aa 12025 12025 12025 12025
+ CC aa 12025 12025 12025 12025 CC bb 12025 12025 13979 13979
+ CC bb 12025 12025 13979 13979 DD aa 15147 15147 15147 15147
+ DD aa 15147 15147 15147 15147 DD aa 15147 15147 15147 15147
+ DD bb 15147 15147 16472 16472 DD bb 15147 15147 16472 16472
+ DD bb 15147 15147 16472 16472 DD bb 15147 15147 16472 16472
+ EE aa 19179 19179 19179 19179 EE aa 19179 19179 19179 19179
+ EE bb 19179 19179 20069 20069 EE bb 19179 19179 20069 20069
+ EE bb 19179 19179 20069 20069 FF aa 21718 21718 21718 21718
+ FF aa 21718 21718 21718 21718 FF aa 21718 21718 21718 21718
+ FF aa 21718 21718 21718 21718 FF bb 21718 21718 23881 23881
+ FF bb 21718 21718 23881 23881 FF bb 21718 21718 23881 23881
+ FF bb 21718 21718 23881 23881 FF bb 21718 21718 23881 23881
+ FF bb 21718 21718 23881 23881 GG aa 27386 27386 27386 27386
+ GG aa 27386 27386 27386 27386 GG aa 27386 27386 27386 27386
+ GG aa 27386 27386 27386 27386 GG bb 27386 27386 28983 28983
+ GG bb 27386 27386 28983 28983 GG bb 27386 27386 28983 28983
+ GG bb 27386 27386 28983 28983 HH aa 31854 31854 31854 31854
+ HH aa 31854 31854 31854 31854 HH aa 31854 31854 31854 31854
+ HH bb 31854 31854 34103 34103 HH bb 31854 31854 34103 34103
+ HH bb 31854 31854 34103 34103 HH bb 31854 31854 34103 34103
+ HH bb 31854 31854 34103 34103 HH bb 31854 31854 34103 34103
+ II aa 37297 37297 37297 37297 II aa 37297 37297 37297 37297
+ II bb 37297 37297 38347 38347 II bb 37297 37297 38347 38347
+ II bb 37297 37297 38347 38347 II bb 37297 37297 38347 38347
+ II bb 37297 37297 38347 38347 JJ aa 40937 40937 40937 40937
+ JJ aa 40937 40937 40937 40937 JJ aa 40937 40937 40937 40937
+ JJ aa 40937 40937 40937 40937 JJ bb 40937 40937 42951 42951
+ JJ bb 40937 40937 42951 42951 JJ bb 40937 40937 42951 42951
+ JJ bb 40937 40937 42951 42951}
+
+do_execsql_test 1.2.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 4685 AA aa 4685 AA aa 4685 AA aa 4685 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 12025 BB aa 12025 BB aa 12025
+ BB aa 12025 BB aa 12025 BB aa 12025 BB bb 12025 BB bb 12025
+ BB bb 12025 BB bb 12025 BB bb 12025 BB bb 12025 CC aa 15147
+ CC aa 15147 CC aa 15147 CC aa 15147 CC bb 15147 CC bb 15147
+ DD aa 19179 DD aa 19179 DD aa 19179 DD bb 19179 DD bb 19179
+ DD bb 19179 DD bb 19179 EE aa 21718 EE aa 21718 EE bb 21718
+ EE bb 21718 EE bb 21718 FF aa 27386 FF aa 27386 FF aa 27386
+ FF aa 27386 FF bb 27386 FF bb 27386 FF bb 27386 FF bb 27386
+ FF bb 27386 FF bb 27386 GG aa 31854 GG aa 31854 GG aa 31854
+ GG aa 31854 GG bb 31854 GG bb 31854 GG bb 31854 GG bb 31854
+ HH aa 37297 HH aa 37297 HH aa 37297 HH bb 37297 HH bb 37297
+ HH bb 37297 HH bb 37297 HH bb 37297 HH bb 37297 II aa 40937
+ II aa 40937 II bb 40937 II bb 40937 II bb 40937 II bb 40937
+ II bb 40937 JJ aa 44737 JJ aa 44737 JJ aa 44737 JJ aa 44737
+ JJ bb 44737 JJ bb 44737 JJ bb 44737 JJ bb 44737}
+
+do_execsql_test 1.2.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 2307 AA aa 2307 AA aa 2307 AA aa 2307 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 7558 BB aa 7558 BB aa 7558 BB aa 7558
+ BB aa 7558 BB aa 7558 BB bb 12025 BB bb 12025 BB bb 12025
+ BB bb 12025 BB bb 12025 BB bb 12025 CC aa 13979 CC aa 13979
+ CC aa 13979 CC aa 13979 CC bb 15147 CC bb 15147 DD aa 16472
+ DD aa 16472 DD aa 16472 DD bb 19179 DD bb 19179 DD bb 19179
+ DD bb 19179 EE aa 20069 EE aa 20069 EE bb 21718 EE bb 21718
+ EE bb 21718 FF aa 23881 FF aa 23881 FF aa 23881 FF aa 23881
+ FF bb 27386 FF bb 27386 FF bb 27386 FF bb 27386 FF bb 27386
+ FF bb 27386 GG aa 28983 GG aa 28983 GG aa 28983 GG aa 28983
+ GG bb 31854 GG bb 31854 GG bb 31854 GG bb 31854 HH aa 34103
+ HH aa 34103 HH aa 34103 HH bb 37297 HH bb 37297 HH bb 37297
+ HH bb 37297 HH bb 37297 HH bb 37297 II aa 38347 II aa 38347
+ II bb 40937 II bb 40937 II bb 40937 II bb 40937 II bb 40937
+ JJ aa 42951 JJ aa 42951 JJ aa 42951 JJ aa 42951 JJ bb 44737
+ JJ bb 44737 JJ bb 44737 JJ bb 44737}
+
+do_execsql_test 1.2.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.2.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 934 AA aa 934 AA aa 934 AA aa 934 AA bb 934 AA bb 934
+ AA bb 934 AA bb 934 BB aa 934 BB aa 934 BB aa 934 BB aa 934
+ BB aa 934 BB aa 934 BB bb 934 BB bb 934 BB bb 934 BB bb 934
+ BB bb 934 BB bb 934 CC aa 934 CC aa 934 CC aa 934 CC aa 934
+ CC bb 934 CC bb 934 DD aa 934 DD aa 934 DD aa 934 DD bb 959
+ DD bb 959 DD bb 959 DD bb 959 EE aa 959 EE aa 959 EE bb 959
+ EE bb 959 EE bb 959 FF aa 959 FF aa 959 FF aa 959 FF aa 959
+ FF bb 959 FF bb 959 FF bb 959 FF bb 959 FF bb 959 FF bb 959
+ GG aa 959 GG aa 959 GG aa 959 GG aa 959 GG bb 959 GG bb 959
+ GG bb 959 GG bb 959 HH aa 979 HH aa 979 HH aa 979 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 979 II bb 979 II bb 979 II bb 979 II bb 979
+ JJ aa 979 JJ aa 979 JJ aa 979 JJ aa 979 JJ bb 979 JJ bb 979
+ JJ bb 979 JJ bb 979}
+
+do_execsql_test 1.2.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 223 AA aa 223 AA aa 223 AA aa 223 AA bb 223 AA bb 223
+ AA bb 223 AA bb 223 BB aa 223 BB aa 223 BB aa 223 BB aa 223
+ BB aa 223 BB aa 223 BB bb 223 BB bb 223 BB bb 223 BB bb 223
+ BB bb 223 BB bb 223 CC aa 158 CC aa 158 CC aa 158 CC aa 158
+ CC bb 158 CC bb 158 DD aa 158 DD aa 158 DD aa 158 DD bb 158
+ DD bb 158 DD bb 158 DD bb 158 EE aa 113 EE aa 113 EE bb 113
+ EE bb 113 EE bb 113 FF aa 113 FF aa 113 FF aa 113 FF aa 113
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 102 HH aa 102 HH aa 102 HH bb 102
+ HH bb 102 HH bb 102 HH bb 102 HH bb 102 HH bb 102 II aa 102
+ II aa 102 II bb 102 II bb 102 II bb 102 II bb 102 II bb 102
+ JJ aa 102 JJ aa 102 JJ aa 102 JJ aa 102 JJ bb 102 JJ bb 102
+ JJ bb 102 JJ bb 102}
+
+do_execsql_test 1.2.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 AA aa 3774 AA aa 4446 AA aa 4462 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 11263 BB aa 11365 BB aa 11613
+ BB aa 11626 BB aa 11632 BB aa 11778 BB bb 11185 BB bb 11233
+ BB bb 11239 BB bb 11314 BB bb 11320 BB bb 11392 CC aa 14388
+ CC aa 14540 CC aa 14717 CC aa 14989 CC bb 14325 CC bb 14801
+ DD aa 18334 DD aa 18923 DD aa 18955 DD bb 18220 DD bb 18385
+ DD bb 18463 DD bb 18941 EE aa 20941 EE aa 21605 EE bb 20950
+ EE bb 21089 EE bb 21466 FF aa 26716 FF aa 26719 FF aa 26768
+ FF aa 27178 FF bb 26448 FF bb 26516 FF bb 26660 FF bb 26812
+ FF bb 27091 FF bb 27284 GG aa 31220 GG aa 31374 GG aa 31519
+ GG aa 31706 GG bb 30916 GG bb 30925 GG bb 31010 GG bb 31694
+ HH aa 36318 HH aa 36507 HH aa 36817 HH bb 36334 HH bb 36567
+ HH bb 36614 HH bb 36942 HH bb 36967 HH bb 37164 II aa 40285
+ II aa 40539 II bb 40132 II bb 40266 II bb 40494 II bb 40516
+ II bb 40687 JJ aa 43838 JJ aa 43969 JJ aa 44503 JJ aa 44624
+ JJ bb 43898 JJ bb 44383 JJ bb 44401 JJ bb 44480}
+
+do_execsql_test 1.2.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1373 AA aa 1396 AA aa 2068 AA aa 2084 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 6796 BB aa 6898 BB aa 7146 BB aa 7159
+ BB aa 7165 BB aa 7311 BB bb 11185 BB bb 11233 BB bb 11239
+ BB bb 11314 BB bb 11320 BB bb 11392 CC aa 13220 CC aa 13372
+ CC aa 13549 CC aa 13821 CC bb 14325 CC bb 14801 DD aa 15627
+ DD aa 16216 DD aa 16248 DD bb 18220 DD bb 18385 DD bb 18463
+ DD bb 18941 EE aa 19292 EE aa 19956 EE bb 20950 EE bb 21089
+ EE bb 21466 FF aa 23211 FF aa 23214 FF aa 23263 FF aa 23673
+ FF bb 26448 FF bb 26516 FF bb 26660 FF bb 26812 FF bb 27091
+ FF bb 27284 GG aa 28349 GG aa 28503 GG aa 28648 GG aa 28835
+ GG bb 30916 GG bb 30925 GG bb 31010 GG bb 31694 HH aa 33124
+ HH aa 33313 HH aa 33623 HH bb 36334 HH bb 36567 HH bb 36614
+ HH bb 36942 HH bb 36967 HH bb 37164 II aa 37695 II aa 37949
+ II bb 40132 II bb 40266 II bb 40494 II bb 40516 II bb 40687
+ JJ aa 42052 JJ aa 42183 JJ aa 42717 JJ aa 42838 JJ bb 43898
+ JJ bb 44383 JJ bb 44401 JJ bb 44480}
+
+do_execsql_test 1.2.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 4685 1373 2307 AA aa 3774 4685 1396 2307
+ AA aa 4446 4685 2068 2307 AA aa 4462 4685 2084 2307
+ AA bb 3815 4685 3815 4685 AA bb 4058 4685 4058 4685
+ AA bb 4113 4685 4113 4685 AA bb 4376 4685 4376 4685
+ BB aa 11263 12025 6796 7558 BB aa 11365 12025 6898 7558
+ BB aa 11613 12025 7146 7558 BB aa 11626 12025 7159 7558
+ BB aa 11632 12025 7165 7558 BB aa 11778 12025 7311 7558
+ BB bb 11185 12025 11185 12025 BB bb 11233 12025 11233 12025
+ BB bb 11239 12025 11239 12025 BB bb 11314 12025 11314 12025
+ BB bb 11320 12025 11320 12025 BB bb 11392 12025 11392 12025
+ CC aa 14388 15147 13220 13979 CC aa 14540 15147 13372 13979
+ CC aa 14717 15147 13549 13979 CC aa 14989 15147 13821 13979
+ CC bb 14325 15147 14325 15147 CC bb 14801 15147 14801 15147
+ DD aa 18334 19179 15627 16472 DD aa 18923 19179 16216 16472
+ DD aa 18955 19179 16248 16472 DD bb 18220 19179 18220 19179
+ DD bb 18385 19179 18385 19179 DD bb 18463 19179 18463 19179
+ DD bb 18941 19179 18941 19179 EE aa 20941 21718 19292 20069
+ EE aa 21605 21718 19956 20069 EE bb 20950 21718 20950 21718
+ EE bb 21089 21718 21089 21718 EE bb 21466 21718 21466 21718
+ FF aa 26716 27386 23211 23881 FF aa 26719 27386 23214 23881
+ FF aa 26768 27386 23263 23881 FF aa 27178 27386 23673 23881
+ FF bb 26448 27386 26448 27386 FF bb 26516 27386 26516 27386
+ FF bb 26660 27386 26660 27386 FF bb 26812 27386 26812 27386
+ FF bb 27091 27386 27091 27386 FF bb 27284 27386 27284 27386
+ GG aa 31220 31854 28349 28983 GG aa 31374 31854 28503 28983
+ GG aa 31519 31854 28648 28983 GG aa 31706 31854 28835 28983
+ GG bb 30916 31854 30916 31854 GG bb 30925 31854 30925 31854
+ GG bb 31010 31854 31010 31854 GG bb 31694 31854 31694 31854
+ HH aa 36318 37297 33124 34103 HH aa 36507 37297 33313 34103
+ HH aa 36817 37297 33623 34103 HH bb 36334 37297 36334 37297
+ HH bb 36567 37297 36567 37297 HH bb 36614 37297 36614 37297
+ HH bb 36942 37297 36942 37297 HH bb 36967 37297 36967 37297
+ HH bb 37164 37297 37164 37297 II aa 40285 40937 37695 38347
+ II aa 40539 40937 37949 38347 II bb 40132 40937 40132 40937
+ II bb 40266 40937 40266 40937 II bb 40494 40937 40494 40937
+ II bb 40516 40937 40516 40937 II bb 40687 40937 40687 40937
+ JJ aa 43838 44737 42052 42951 JJ aa 43969 44737 42183 42951
+ JJ aa 44503 44737 42717 42951 JJ aa 44624 44737 42838 42951
+ JJ bb 43898 44737 43898 44737 JJ bb 44383 44737 44383 44737
+ JJ bb 44401 44737 44401 44737 JJ bb 44480 44737 44480 44737}
+
+do_execsql_test 1.3.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 12025 AA aa 12025 AA aa 12025 AA aa 12025 AA bb 12025
+ AA bb 12025 AA bb 12025 AA bb 12025 BB aa 15147 BB aa 15147
+ BB aa 15147 BB aa 15147 BB aa 15147 BB aa 15147 BB bb 15147
+ BB bb 15147 BB bb 15147 BB bb 15147 BB bb 15147 BB bb 15147
+ CC aa 19179 CC aa 19179 CC aa 19179 CC aa 19179 CC bb 19179
+ CC bb 19179 DD aa 21718 DD aa 21718 DD aa 21718 DD bb 21718
+ DD bb 21718 DD bb 21718 DD bb 21718 EE aa 27386 EE aa 27386
+ EE bb 27386 EE bb 27386 EE bb 27386 FF aa 31854 FF aa 31854
+ FF aa 31854 FF aa 31854 FF bb 31854 FF bb 31854 FF bb 31854
+ FF bb 31854 FF bb 31854 FF bb 31854 GG aa 37297 GG aa 37297
+ GG aa 37297 GG aa 37297 GG bb 37297 GG bb 37297 GG bb 37297
+ GG bb 37297 HH aa 40937 HH aa 40937 HH aa 40937 HH bb 40937
+ HH bb 40937 HH bb 40937 HH bb 40937 HH bb 40937 HH bb 40937
+ II aa 44737 II aa 44737 II bb 44737 II bb 44737 II bb 44737
+ II bb 44737 II bb 44737 JJ aa 44737 JJ aa 44737 JJ aa 44737
+ JJ aa 44737 JJ bb 44737 JJ bb 44737 JJ bb 44737 JJ bb 44737}
+
+do_execsql_test 1.3.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 4685 AA aa 4685 AA aa 4685 AA aa 4685 AA bb 7558 AA bb 7558
+ AA bb 7558 AA bb 7558 BB aa 12025 BB aa 12025 BB aa 12025
+ BB aa 12025 BB aa 12025 BB aa 12025 BB bb 13979 BB bb 13979
+ BB bb 13979 BB bb 13979 BB bb 13979 BB bb 13979 CC aa 15147
+ CC aa 15147 CC aa 15147 CC aa 15147 CC bb 16472 CC bb 16472
+ DD aa 19179 DD aa 19179 DD aa 19179 DD bb 20069 DD bb 20069
+ DD bb 20069 DD bb 20069 EE aa 21718 EE aa 21718 EE bb 23881
+ EE bb 23881 EE bb 23881 FF aa 27386 FF aa 27386 FF aa 27386
+ FF aa 27386 FF bb 28983 FF bb 28983 FF bb 28983 FF bb 28983
+ FF bb 28983 FF bb 28983 GG aa 31854 GG aa 31854 GG aa 31854
+ GG aa 31854 GG bb 34103 GG bb 34103 GG bb 34103 GG bb 34103
+ HH aa 37297 HH aa 37297 HH aa 37297 HH bb 38347 HH bb 38347
+ HH bb 38347 HH bb 38347 HH bb 38347 HH bb 38347 II aa 40937
+ II aa 40937 II bb 42951 II bb 42951 II bb 42951 II bb 42951
+ II bb 42951 JJ aa 44737 JJ aa 44737 JJ aa 44737 JJ aa 44737
+ JJ bb 44737 JJ bb 44737 JJ bb 44737 JJ bb 44737}
+
+do_execsql_test 1.3.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.3.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 934 AA aa 934 AA aa 934 AA aa 934 AA bb 934 AA bb 934
+ AA bb 934 AA bb 934 BB aa 934 BB aa 934 BB aa 934 BB aa 934
+ BB aa 934 BB aa 934 BB bb 934 BB bb 934 BB bb 934 BB bb 934
+ BB bb 934 BB bb 934 CC aa 934 CC aa 934 CC aa 934 CC aa 934
+ CC bb 934 CC bb 934 DD aa 959 DD aa 959 DD aa 959 DD bb 959
+ DD bb 959 DD bb 959 DD bb 959 EE aa 959 EE aa 959 EE bb 959
+ EE bb 959 EE bb 959 FF aa 959 FF aa 959 FF aa 959 FF aa 959
+ FF bb 959 FF bb 959 FF bb 959 FF bb 959 FF bb 959 FF bb 959
+ GG aa 959 GG aa 959 GG aa 959 GG aa 959 GG bb 979 GG bb 979
+ GG bb 979 GG bb 979 HH aa 979 HH aa 979 HH aa 979 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 979 II bb 979 II bb 979 II bb 979 II bb 979
+ JJ aa 979 JJ aa 979 JJ aa 979 JJ aa 979 JJ bb 979 JJ bb 979
+ JJ bb 979 JJ bb 979}
+
+do_execsql_test 1.3.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 223 AA aa 223 AA aa 223 AA aa 223 AA bb 223 AA bb 223
+ AA bb 223 AA bb 223 BB aa 223 BB aa 223 BB aa 223 BB aa 223
+ BB aa 223 BB aa 223 BB bb 158 BB bb 158 BB bb 158 BB bb 158
+ BB bb 158 BB bb 158 CC aa 158 CC aa 158 CC aa 158 CC aa 158
+ CC bb 158 CC bb 158 DD aa 158 DD aa 158 DD aa 158 DD bb 113
+ DD bb 113 DD bb 113 DD bb 113 EE aa 113 EE aa 113 EE bb 113
+ EE bb 113 EE bb 113 FF aa 102 FF aa 102 FF aa 102 FF aa 102
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 102 HH aa 102 HH aa 102 HH bb 102
+ HH bb 102 HH bb 102 HH bb 102 HH bb 102 HH bb 102 II aa 102
+ II aa 102 II bb 102 II bb 102 II bb 102 II bb 102 II bb 102
+ JJ aa 102 JJ aa 102 JJ aa 102 JJ aa 102 JJ bb 102 JJ bb 102
+ JJ bb 102 JJ bb 102}
+
+do_execsql_test 1.3.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 11091 AA aa 11114 AA aa 11786 AA aa 11802 AA bb 11155
+ AA bb 11398 AA bb 11453 AA bb 11716 BB aa 14385 BB aa 14487
+ BB aa 14735 BB aa 14748 BB aa 14754 BB aa 14900 BB bb 14307
+ BB bb 14355 BB bb 14361 BB bb 14436 BB bb 14442 BB bb 14514
+ CC aa 18420 CC aa 18572 CC aa 18749 CC aa 19021 CC bb 18357
+ CC bb 18833 DD aa 20873 DD aa 21462 DD aa 21494 DD bb 20759
+ DD bb 20924 DD bb 21002 DD bb 21480 EE aa 26609 EE aa 27273
+ EE bb 26618 EE bb 26757 EE bb 27134 FF aa 31184 FF aa 31187
+ FF aa 31236 FF aa 31646 FF bb 30916 FF bb 30984 FF bb 31128
+ FF bb 31280 FF bb 31559 FF bb 31752 GG aa 36663 GG aa 36817
+ GG aa 36962 GG aa 37149 GG bb 36359 GG bb 36368 GG bb 36453
+ GG bb 37137 HH aa 39958 HH aa 40147 HH aa 40457 HH bb 39974
+ HH bb 40207 HH bb 40254 HH bb 40582 HH bb 40607 HH bb 40804
+ II aa 44085 II aa 44339 II bb 43932 II bb 44066 II bb 44294
+ II bb 44316 II bb 44487 JJ aa 43838 JJ aa 43969 JJ aa 44503
+ JJ aa 44624 JJ bb 43898 JJ bb 44383 JJ bb 44401 JJ bb 44480}
+
+do_execsql_test 1.3.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 AA aa 3774 AA aa 4446 AA aa 4462 AA bb 6688 AA bb 6931
+ AA bb 6986 AA bb 7249 BB aa 11263 BB aa 11365 BB aa 11613
+ BB aa 11626 BB aa 11632 BB aa 11778 BB bb 13139 BB bb 13187
+ BB bb 13193 BB bb 13268 BB bb 13274 BB bb 13346 CC aa 14388
+ CC aa 14540 CC aa 14717 CC aa 14989 CC bb 15650 CC bb 16126
+ DD aa 18334 DD aa 18923 DD aa 18955 DD bb 19110 DD bb 19275
+ DD bb 19353 DD bb 19831 EE aa 20941 EE aa 21605 EE bb 23113
+ EE bb 23252 EE bb 23629 FF aa 26716 FF aa 26719 FF aa 26768
+ FF aa 27178 FF bb 28045 FF bb 28113 FF bb 28257 FF bb 28409
+ FF bb 28688 FF bb 28881 GG aa 31220 GG aa 31374 GG aa 31519
+ GG aa 31706 GG bb 33165 GG bb 33174 GG bb 33259 GG bb 33943
+ HH aa 36318 HH aa 36507 HH aa 36817 HH bb 37384 HH bb 37617
+ HH bb 37664 HH bb 37992 HH bb 38017 HH bb 38214 II aa 40285
+ II aa 40539 II bb 42146 II bb 42280 II bb 42508 II bb 42530
+ II bb 42701 JJ aa 43838 JJ aa 43969 JJ aa 44503 JJ aa 44624
+ JJ bb 43898 JJ bb 44383 JJ bb 44401 JJ bb 44480}
+
+do_execsql_test 1.3.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 11091 12025 3751 4685 AA aa 11114 12025 3774 4685
+ AA aa 11786 12025 4446 4685 AA aa 11802 12025 4462 4685
+ AA bb 11155 12025 6688 7558 AA bb 11398 12025 6931 7558
+ AA bb 11453 12025 6986 7558 AA bb 11716 12025 7249 7558
+ BB aa 14385 15147 11263 12025 BB aa 14487 15147 11365 12025
+ BB aa 14735 15147 11613 12025 BB aa 14748 15147 11626 12025
+ BB aa 14754 15147 11632 12025 BB aa 14900 15147 11778 12025
+ BB bb 14307 15147 13139 13979 BB bb 14355 15147 13187 13979
+ BB bb 14361 15147 13193 13979 BB bb 14436 15147 13268 13979
+ BB bb 14442 15147 13274 13979 BB bb 14514 15147 13346 13979
+ CC aa 18420 19179 14388 15147 CC aa 18572 19179 14540 15147
+ CC aa 18749 19179 14717 15147 CC aa 19021 19179 14989 15147
+ CC bb 18357 19179 15650 16472 CC bb 18833 19179 16126 16472
+ DD aa 20873 21718 18334 19179 DD aa 21462 21718 18923 19179
+ DD aa 21494 21718 18955 19179 DD bb 20759 21718 19110 20069
+ DD bb 20924 21718 19275 20069 DD bb 21002 21718 19353 20069
+ DD bb 21480 21718 19831 20069 EE aa 26609 27386 20941 21718
+ EE aa 27273 27386 21605 21718 EE bb 26618 27386 23113 23881
+ EE bb 26757 27386 23252 23881 EE bb 27134 27386 23629 23881
+ FF aa 31184 31854 26716 27386 FF aa 31187 31854 26719 27386
+ FF aa 31236 31854 26768 27386 FF aa 31646 31854 27178 27386
+ FF bb 30916 31854 28045 28983 FF bb 30984 31854 28113 28983
+ FF bb 31128 31854 28257 28983 FF bb 31280 31854 28409 28983
+ FF bb 31559 31854 28688 28983 FF bb 31752 31854 28881 28983
+ GG aa 36663 37297 31220 31854 GG aa 36817 37297 31374 31854
+ GG aa 36962 37297 31519 31854 GG aa 37149 37297 31706 31854
+ GG bb 36359 37297 33165 34103 GG bb 36368 37297 33174 34103
+ GG bb 36453 37297 33259 34103 GG bb 37137 37297 33943 34103
+ HH aa 39958 40937 36318 37297 HH aa 40147 40937 36507 37297
+ HH aa 40457 40937 36817 37297 HH bb 39974 40937 37384 38347
+ HH bb 40207 40937 37617 38347 HH bb 40254 40937 37664 38347
+ HH bb 40582 40937 37992 38347 HH bb 40607 40937 38017 38347
+ HH bb 40804 40937 38214 38347 II aa 44085 44737 40285 40937
+ II aa 44339 44737 40539 40937 II bb 43932 44737 42146 42951
+ II bb 44066 44737 42280 42951 II bb 44294 44737 42508 42951
+ II bb 44316 44737 42530 42951 II bb 44487 44737 42701 42951
+ JJ aa 43838 44737 43838 44737 JJ aa 43969 44737 43969 44737
+ JJ aa 44503 44737 44503 44737 JJ aa 44624 44737 44624 44737
+ JJ bb 43898 44737 43898 44737 JJ bb 44383 44737 44383 44737
+ JJ bb 44401 44737 44401 44737 JJ bb 44480 44737 44480 44737}
+
+do_execsql_test 1.4.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 44737 AA aa 44737 AA aa 44737 AA aa 44737 AA bb 44737
+ AA bb 44737 AA bb 44737 AA bb 44737 BB aa 44737 BB aa 44737
+ BB aa 44737 BB aa 44737 BB aa 44737 BB aa 44737 BB bb 44737
+ BB bb 44737 BB bb 44737 BB bb 44737 BB bb 44737 BB bb 44737
+ CC aa 44737 CC aa 44737 CC aa 44737 CC aa 44737 CC bb 44737
+ CC bb 44737 DD aa 44737 DD aa 44737 DD aa 44737 DD bb 44737
+ DD bb 44737 DD bb 44737 DD bb 44737 EE aa 44737 EE aa 44737
+ EE bb 44737 EE bb 44737 EE bb 44737 FF aa 44737 FF aa 44737
+ FF aa 44737 FF aa 44737 FF bb 44737 FF bb 44737 FF bb 44737
+ FF bb 44737 FF bb 44737 FF bb 44737 GG aa 44737 GG aa 44737
+ GG aa 44737 GG aa 44737 GG bb 44737 GG bb 44737 GG bb 44737
+ GG bb 44737 HH aa 44737 HH aa 44737 HH aa 44737 HH bb 44737
+ HH bb 44737 HH bb 44737 HH bb 44737 HH bb 44737 HH bb 44737
+ II aa 44737 II aa 44737 II bb 44737 II bb 44737 II bb 44737
+ II bb 44737 II bb 44737 JJ aa 44737 JJ aa 44737 JJ aa 44737
+ JJ aa 44737 JJ bb 44737 JJ bb 44737 JJ bb 44737 JJ bb 44737}
+
+do_execsql_test 1.4.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 44737 AA aa 44737 AA aa 44737 AA aa 44737 AA bb 44737
+ AA bb 44737 AA bb 44737 AA bb 44737 BB aa 44737 BB aa 44737
+ BB aa 44737 BB aa 44737 BB aa 44737 BB aa 44737 BB bb 44737
+ BB bb 44737 BB bb 44737 BB bb 44737 BB bb 44737 BB bb 44737
+ CC aa 44737 CC aa 44737 CC aa 44737 CC aa 44737 CC bb 44737
+ CC bb 44737 DD aa 44737 DD aa 44737 DD aa 44737 DD bb 44737
+ DD bb 44737 DD bb 44737 DD bb 44737 EE aa 44737 EE aa 44737
+ EE bb 44737 EE bb 44737 EE bb 44737 FF aa 44737 FF aa 44737
+ FF aa 44737 FF aa 44737 FF bb 44737 FF bb 44737 FF bb 44737
+ FF bb 44737 FF bb 44737 FF bb 44737 GG aa 44737 GG aa 44737
+ GG aa 44737 GG aa 44737 GG bb 44737 GG bb 44737 GG bb 44737
+ GG bb 44737 HH aa 44737 HH aa 44737 HH aa 44737 HH bb 44737
+ HH bb 44737 HH bb 44737 HH bb 44737 HH bb 44737 HH bb 44737
+ II aa 44737 II aa 44737 II bb 44737 II bb 44737 II bb 44737
+ II bb 44737 II bb 44737 JJ aa 44737 JJ aa 44737 JJ aa 44737
+ JJ aa 44737 JJ bb 44737 JJ bb 44737 JJ bb 44737 JJ bb 44737}
+
+do_execsql_test 1.4.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.4.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 979 AA aa 979 AA aa 979 AA aa 979 AA bb 979 AA bb 979
+ AA bb 979 AA bb 979 BB aa 979 BB aa 979 BB aa 979 BB aa 979
+ BB aa 979 BB aa 979 BB bb 979 BB bb 979 BB bb 979 BB bb 979
+ BB bb 979 BB bb 979 CC aa 979 CC aa 979 CC aa 979 CC aa 979
+ CC bb 979 CC bb 979 DD aa 979 DD aa 979 DD aa 979 DD bb 979
+ DD bb 979 DD bb 979 DD bb 979 EE aa 979 EE aa 979 EE bb 979
+ EE bb 979 EE bb 979 FF aa 979 FF aa 979 FF aa 979 FF aa 979
+ FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979
+ GG aa 979 GG aa 979 GG aa 979 GG aa 979 GG bb 979 GG bb 979
+ GG bb 979 GG bb 979 HH aa 979 HH aa 979 HH aa 979 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 979 II bb 979 II bb 979 II bb 979 II bb 979
+ JJ aa 979 JJ aa 979 JJ aa 979 JJ aa 979 JJ bb 979 JJ bb 979
+ JJ bb 979 JJ bb 979}
+
+do_execsql_test 1.4.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 102 AA aa 102 AA aa 102 AA aa 102 AA bb 102 AA bb 102
+ AA bb 102 AA bb 102 BB aa 102 BB aa 102 BB aa 102 BB aa 102
+ BB aa 102 BB aa 102 BB bb 102 BB bb 102 BB bb 102 BB bb 102
+ BB bb 102 BB bb 102 CC aa 102 CC aa 102 CC aa 102 CC aa 102
+ CC bb 102 CC bb 102 DD aa 102 DD aa 102 DD aa 102 DD bb 102
+ DD bb 102 DD bb 102 DD bb 102 EE aa 102 EE aa 102 EE bb 102
+ EE bb 102 EE bb 102 FF aa 102 FF aa 102 FF aa 102 FF aa 102
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 102 HH aa 102 HH aa 102 HH bb 102
+ HH bb 102 HH bb 102 HH bb 102 HH bb 102 HH bb 102 II aa 102
+ II aa 102 II bb 102 II bb 102 II bb 102 II bb 102 II bb 102
+ JJ aa 102 JJ aa 102 JJ aa 102 JJ aa 102 JJ bb 102 JJ bb 102
+ JJ bb 102 JJ bb 102}
+
+do_execsql_test 1.4.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 AA aa 43826 AA aa 44498 AA aa 44514 AA bb 43867
+ AA bb 44110 AA bb 44165 AA bb 44428 BB aa 43975 BB aa 44077
+ BB aa 44325 BB aa 44338 BB aa 44344 BB aa 44490 BB bb 43897
+ BB bb 43945 BB bb 43951 BB bb 44026 BB bb 44032 BB bb 44104
+ CC aa 43978 CC aa 44130 CC aa 44307 CC aa 44579 CC bb 43915
+ CC bb 44391 DD aa 43892 DD aa 44481 DD aa 44513 DD bb 43778
+ DD bb 43943 DD bb 44021 DD bb 44499 EE aa 43960 EE aa 44624
+ EE bb 43969 EE bb 44108 EE bb 44485 FF aa 44067 FF aa 44070
+ FF aa 44119 FF aa 44529 FF bb 43799 FF bb 43867 FF bb 44011
+ FF bb 44163 FF bb 44442 FF bb 44635 GG aa 44103 GG aa 44257
+ GG aa 44402 GG aa 44589 GG bb 43799 GG bb 43808 GG bb 43893
+ GG bb 44577 HH aa 43758 HH aa 43947 HH aa 44257 HH bb 43774
+ HH bb 44007 HH bb 44054 HH bb 44382 HH bb 44407 HH bb 44604
+ II aa 44085 II aa 44339 II bb 43932 II bb 44066 II bb 44294
+ II bb 44316 II bb 44487 JJ aa 43838 JJ aa 43969 JJ aa 44503
+ JJ aa 44624 JJ bb 43898 JJ bb 44383 JJ bb 44401 JJ bb 44480}
+
+do_execsql_test 1.4.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 AA aa 43826 AA aa 44498 AA aa 44514 AA bb 43867
+ AA bb 44110 AA bb 44165 AA bb 44428 BB aa 43975 BB aa 44077
+ BB aa 44325 BB aa 44338 BB aa 44344 BB aa 44490 BB bb 43897
+ BB bb 43945 BB bb 43951 BB bb 44026 BB bb 44032 BB bb 44104
+ CC aa 43978 CC aa 44130 CC aa 44307 CC aa 44579 CC bb 43915
+ CC bb 44391 DD aa 43892 DD aa 44481 DD aa 44513 DD bb 43778
+ DD bb 43943 DD bb 44021 DD bb 44499 EE aa 43960 EE aa 44624
+ EE bb 43969 EE bb 44108 EE bb 44485 FF aa 44067 FF aa 44070
+ FF aa 44119 FF aa 44529 FF bb 43799 FF bb 43867 FF bb 44011
+ FF bb 44163 FF bb 44442 FF bb 44635 GG aa 44103 GG aa 44257
+ GG aa 44402 GG aa 44589 GG bb 43799 GG bb 43808 GG bb 43893
+ GG bb 44577 HH aa 43758 HH aa 43947 HH aa 44257 HH bb 43774
+ HH bb 44007 HH bb 44054 HH bb 44382 HH bb 44407 HH bb 44604
+ II aa 44085 II aa 44339 II bb 43932 II bb 44066 II bb 44294
+ II bb 44316 II bb 44487 JJ aa 43838 JJ aa 43969 JJ aa 44503
+ JJ aa 44624 JJ bb 43898 JJ bb 44383 JJ bb 44401 JJ bb 44480}
+
+do_execsql_test 1.4.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 44737 43803 44737 AA aa 43826 44737 43826 44737
+ AA aa 44498 44737 44498 44737 AA aa 44514 44737 44514 44737
+ AA bb 43867 44737 43867 44737 AA bb 44110 44737 44110 44737
+ AA bb 44165 44737 44165 44737 AA bb 44428 44737 44428 44737
+ BB aa 43975 44737 43975 44737 BB aa 44077 44737 44077 44737
+ BB aa 44325 44737 44325 44737 BB aa 44338 44737 44338 44737
+ BB aa 44344 44737 44344 44737 BB aa 44490 44737 44490 44737
+ BB bb 43897 44737 43897 44737 BB bb 43945 44737 43945 44737
+ BB bb 43951 44737 43951 44737 BB bb 44026 44737 44026 44737
+ BB bb 44032 44737 44032 44737 BB bb 44104 44737 44104 44737
+ CC aa 43978 44737 43978 44737 CC aa 44130 44737 44130 44737
+ CC aa 44307 44737 44307 44737 CC aa 44579 44737 44579 44737
+ CC bb 43915 44737 43915 44737 CC bb 44391 44737 44391 44737
+ DD aa 43892 44737 43892 44737 DD aa 44481 44737 44481 44737
+ DD aa 44513 44737 44513 44737 DD bb 43778 44737 43778 44737
+ DD bb 43943 44737 43943 44737 DD bb 44021 44737 44021 44737
+ DD bb 44499 44737 44499 44737 EE aa 43960 44737 43960 44737
+ EE aa 44624 44737 44624 44737 EE bb 43969 44737 43969 44737
+ EE bb 44108 44737 44108 44737 EE bb 44485 44737 44485 44737
+ FF aa 44067 44737 44067 44737 FF aa 44070 44737 44070 44737
+ FF aa 44119 44737 44119 44737 FF aa 44529 44737 44529 44737
+ FF bb 43799 44737 43799 44737 FF bb 43867 44737 43867 44737
+ FF bb 44011 44737 44011 44737 FF bb 44163 44737 44163 44737
+ FF bb 44442 44737 44442 44737 FF bb 44635 44737 44635 44737
+ GG aa 44103 44737 44103 44737 GG aa 44257 44737 44257 44737
+ GG aa 44402 44737 44402 44737 GG aa 44589 44737 44589 44737
+ GG bb 43799 44737 43799 44737 GG bb 43808 44737 43808 44737
+ GG bb 43893 44737 43893 44737 GG bb 44577 44737 44577 44737
+ HH aa 43758 44737 43758 44737 HH aa 43947 44737 43947 44737
+ HH aa 44257 44737 44257 44737 HH bb 43774 44737 43774 44737
+ HH bb 44007 44737 44007 44737 HH bb 44054 44737 44054 44737
+ HH bb 44382 44737 44382 44737 HH bb 44407 44737 44407 44737
+ HH bb 44604 44737 44604 44737 II aa 44085 44737 44085 44737
+ II aa 44339 44737 44339 44737 II bb 43932 44737 43932 44737
+ II bb 44066 44737 44066 44737 II bb 44294 44737 44294 44737
+ II bb 44316 44737 44316 44737 II bb 44487 44737 44487 44737
+ JJ aa 43838 44737 43838 44737 JJ aa 43969 44737 43969 44737
+ JJ aa 44503 44737 44503 44737 JJ aa 44624 44737 44624 44737
+ JJ bb 43898 44737 43898 44737 JJ bb 44383 44737 44383 44737
+ JJ bb 44401 44737 44401 44737 JJ bb 44480 44737 44480 44737}
+
+do_execsql_test 1.5.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.5.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.5.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.5.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.5.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.5.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.5.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.5.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} {} {} {} AA aa {} {} {} {} AA aa {} {} {} {}
+ AA aa {} {} {} {} AA bb {} {} {} {} AA bb {} {} {} {}
+ AA bb {} {} {} {} AA bb {} {} {} {} BB aa {} {} {} {}
+ BB aa {} {} {} {} BB aa {} {} {} {} BB aa {} {} {} {}
+ BB aa {} {} {} {} BB aa {} {} {} {} BB bb {} {} {} {}
+ BB bb {} {} {} {} BB bb {} {} {} {} BB bb {} {} {} {}
+ BB bb {} {} {} {} BB bb {} {} {} {} CC aa {} {} {} {}
+ CC aa {} {} {} {} CC aa {} {} {} {} CC aa {} {} {} {}
+ CC bb {} {} {} {} CC bb {} {} {} {} DD aa {} {} {} {}
+ DD aa {} {} {} {} DD aa {} {} {} {} DD bb {} {} {} {}
+ DD bb {} {} {} {} DD bb {} {} {} {} DD bb {} {} {} {}
+ EE aa {} {} {} {} EE aa {} {} {} {} EE bb {} {} {} {}
+ EE bb {} {} {} {} EE bb {} {} {} {} FF aa {} {} {} {}
+ FF aa {} {} {} {} FF aa {} {} {} {} FF aa {} {} {} {}
+ FF bb {} {} {} {} FF bb {} {} {} {} FF bb {} {} {} {}
+ FF bb {} {} {} {} FF bb {} {} {} {} FF bb {} {} {} {}
+ GG aa {} {} {} {} GG aa {} {} {} {} GG aa {} {} {} {}
+ GG aa {} {} {} {} GG bb {} {} {} {} GG bb {} {} {} {}
+ GG bb {} {} {} {} GG bb {} {} {} {} HH aa {} {} {} {}
+ HH aa {} {} {} {} HH aa {} {} {} {} HH bb {} {} {} {}
+ HH bb {} {} {} {} HH bb {} {} {} {} HH bb {} {} {} {}
+ HH bb {} {} {} {} HH bb {} {} {} {} II aa {} {} {} {}
+ II aa {} {} {} {} II bb {} {} {} {} II bb {} {} {} {}
+ II bb {} {} {} {} II bb {} {} {} {} II bb {} {} {} {}
+ JJ aa {} {} {} {} JJ aa {} {} {} {} JJ aa {} {} {} {}
+ JJ aa {} {} {} {} JJ bb {} {} {} {} JJ bb {} {} {} {}
+ JJ bb {} {} {} {} JJ bb {} {} {} {}}
+
+do_execsql_test 1.6.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685
+ BB bb 4685 CC aa 12025 CC aa 12025 CC aa 12025 CC aa 12025
+ CC bb 12025 CC bb 12025 DD aa 10462 DD aa 10462 DD aa 10462
+ DD bb 10462 DD bb 10462 DD bb 10462 DD bb 10462 EE aa 7154
+ EE aa 7154 EE bb 7154 EE bb 7154 EE bb 7154 FF aa 6571 FF aa 6571
+ FF aa 6571 FF aa 6571 FF bb 6571 FF bb 6571 FF bb 6571 FF bb 6571
+ FF bb 6571 FF bb 6571 GG aa 8207 GG aa 8207 GG aa 8207 GG aa 8207
+ GG bb 8207 GG bb 8207 GG bb 8207 GG bb 8207 HH aa 10136
+ HH aa 10136 HH aa 10136 HH bb 10136 HH bb 10136 HH bb 10136
+ HH bb 10136 HH bb 10136 HH bb 10136 II aa 9911 II aa 9911
+ II bb 9911 II bb 9911 II bb 9911 II bb 9911 II bb 9911 JJ aa 9083
+ JJ aa 9083 JJ aa 9083 JJ aa 9083 JJ bb 9083 JJ bb 9083 JJ bb 9083
+ JJ bb 9083}
+
+do_execsql_test 1.6.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 2307 AA bb 2307
+ AA bb 2307 AA bb 2307 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB aa 4685 BB bb 5251 BB bb 5251 BB bb 5251 BB bb 5251
+ BB bb 5251 BB bb 5251 CC aa 7340 CC aa 7340 CC aa 7340 CC aa 7340
+ CC bb 6421 CC bb 6421 DD aa 3122 DD aa 3122 DD aa 3122 DD bb 2493
+ DD bb 2493 DD bb 2493 DD bb 2493 EE aa 4032 EE aa 4032 EE bb 3597
+ EE bb 3597 EE bb 3597 FF aa 2539 FF aa 2539 FF aa 2539 FF aa 2539
+ FF bb 3812 FF bb 3812 FF bb 3812 FF bb 3812 FF bb 3812 FF bb 3812
+ GG aa 5668 GG aa 5668 GG aa 5668 GG aa 5668 GG bb 5102 GG bb 5102
+ GG bb 5102 GG bb 5102 HH aa 4468 HH aa 4468 HH aa 4468 HH bb 5120
+ HH bb 5120 HH bb 5120 HH bb 5120 HH bb 5120 HH bb 5120 II aa 5443
+ II aa 5443 II bb 4244 II bb 4244 II bb 4244 II bb 4244 II bb 4244
+ JJ aa 3640 JJ aa 3640 JJ aa 3640 JJ aa 3640 JJ bb 4604 JJ bb 4604
+ JJ bb 4604 JJ bb 4604}
+
+do_execsql_test 1.6.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.6.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 934 AA bb 934
+ AA bb 934 AA bb 934 BB aa 934 BB aa 934 BB aa 934 BB aa 934
+ BB aa 934 BB aa 934 BB bb 870 BB bb 870 BB bb 870 BB bb 870
+ BB bb 870 BB bb 870 CC aa 840 CC aa 840 CC aa 840 CC aa 840
+ CC bb 840 CC bb 840 DD aa 822 DD aa 822 DD aa 822 DD bb 845
+ DD bb 845 DD bb 845 DD bb 845 EE aa 959 EE aa 959 EE bb 959
+ EE bb 959 EE bb 959 FF aa 777 FF aa 777 FF aa 777 FF aa 777
+ FF bb 768 FF bb 768 FF bb 768 FF bb 768 FF bb 768 FF bb 768
+ GG aa 938 GG aa 938 GG aa 938 GG aa 938 GG bb 938 GG bb 938
+ GG bb 938 GG bb 938 HH aa 938 HH aa 938 HH aa 938 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 963 II bb 963 II bb 963 II bb 963 II bb 963
+ JJ aa 805 JJ aa 805 JJ aa 805 JJ aa 805 JJ bb 899 JJ bb 899
+ JJ bb 899 JJ bb 899}
+
+do_execsql_test 1.6.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 223 AA bb 223
+ AA bb 223 AA bb 223 BB aa 223 BB aa 223 BB aa 223 BB aa 223
+ BB aa 223 BB aa 223 BB bb 247 BB bb 247 BB bb 247 BB bb 247
+ BB bb 247 BB bb 247 CC aa 247 CC aa 247 CC aa 247 CC aa 247
+ CC bb 158 CC bb 158 DD aa 158 DD aa 158 DD aa 158 DD bb 224
+ DD bb 224 DD bb 224 DD bb 224 EE aa 224 EE aa 224 EE bb 113
+ EE bb 113 EE bb 113 FF aa 113 FF aa 113 FF aa 113 FF aa 113
+ FF bb 208 FF bb 208 FF bb 208 FF bb 208 FF bb 208 FF bb 208
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 148 HH aa 148 HH aa 148 HH bb 160
+ HH bb 160 HH bb 160 HH bb 160 HH bb 160 HH bb 160 II aa 133
+ II aa 133 II bb 133 II bb 133 II bb 133 II bb 133 II bb 133
+ JJ aa 250 JJ aa 250 JJ aa 250 JJ aa 250 JJ bb 113 JJ bb 113
+ JJ bb 113 JJ bb 113}
+
+do_execsql_test 1.6.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685
+ BB bb 4685 CC aa 12025 CC aa 12025 CC aa 12025 CC aa 12025
+ CC bb 12025 CC bb 12025 DD aa 10462 DD aa 10462 DD aa 10462
+ DD bb 10462 DD bb 10462 DD bb 10462 DD bb 10462 EE aa 7154
+ EE aa 7154 EE bb 7154 EE bb 7154 EE bb 7154 FF aa 6571 FF aa 6571
+ FF aa 6571 FF aa 6571 FF bb 6571 FF bb 6571 FF bb 6571 FF bb 6571
+ FF bb 6571 FF bb 6571 GG aa 8207 GG aa 8207 GG aa 8207 GG aa 8207
+ GG bb 8207 GG bb 8207 GG bb 8207 GG bb 8207 HH aa 10136
+ HH aa 10136 HH aa 10136 HH bb 10136 HH bb 10136 HH bb 10136
+ HH bb 10136 HH bb 10136 HH bb 10136 II aa 9911 II aa 9911
+ II bb 9911 II bb 9911 II bb 9911 II bb 9911 II bb 9911 JJ aa 9083
+ JJ aa 9083 JJ aa 9083 JJ aa 9083 JJ bb 9083 JJ bb 9083 JJ bb 9083
+ JJ bb 9083}
+
+do_execsql_test 1.6.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 2307 AA bb 2307
+ AA bb 2307 AA bb 2307 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB aa 4685 BB bb 5251 BB bb 5251 BB bb 5251 BB bb 5251
+ BB bb 5251 BB bb 5251 CC aa 7340 CC aa 7340 CC aa 7340 CC aa 7340
+ CC bb 6421 CC bb 6421 DD aa 3122 DD aa 3122 DD aa 3122 DD bb 2493
+ DD bb 2493 DD bb 2493 DD bb 2493 EE aa 4032 EE aa 4032 EE bb 3597
+ EE bb 3597 EE bb 3597 FF aa 2539 FF aa 2539 FF aa 2539 FF aa 2539
+ FF bb 3812 FF bb 3812 FF bb 3812 FF bb 3812 FF bb 3812 FF bb 3812
+ GG aa 5668 GG aa 5668 GG aa 5668 GG aa 5668 GG bb 5102 GG bb 5102
+ GG bb 5102 GG bb 5102 HH aa 4468 HH aa 4468 HH aa 4468 HH bb 5120
+ HH bb 5120 HH bb 5120 HH bb 5120 HH bb 5120 HH bb 5120 II aa 5443
+ II aa 5443 II bb 4244 II bb 4244 II bb 4244 II bb 4244 II bb 4244
+ JJ aa 3640 JJ aa 3640 JJ aa 3640 JJ aa 3640 JJ bb 4604 JJ bb 4604
+ JJ bb 4604 JJ bb 4604}
+
+do_execsql_test 1.6.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND 1 PRECEDING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} {} {} {} AA aa {} {} {} {} AA aa {} {} {} {}
+ AA aa {} {} {} {} AA bb {} {} 2307 2307 AA bb {} {} 2307 2307
+ AA bb {} {} 2307 2307 AA bb {} {} 2307 2307 BB aa 4685 4685 4685 4685
+ BB aa 4685 4685 4685 4685 BB aa 4685 4685 4685 4685
+ BB aa 4685 4685 4685 4685 BB aa 4685 4685 4685 4685
+ BB aa 4685 4685 4685 4685 BB bb 4685 4685 5251 5251
+ BB bb 4685 4685 5251 5251 BB bb 4685 4685 5251 5251
+ BB bb 4685 4685 5251 5251 BB bb 4685 4685 5251 5251
+ BB bb 4685 4685 5251 5251 CC aa 12025 12025 7340 7340
+ CC aa 12025 12025 7340 7340 CC aa 12025 12025 7340 7340
+ CC aa 12025 12025 7340 7340 CC bb 12025 12025 6421 6421
+ CC bb 12025 12025 6421 6421 DD aa 10462 10462 3122 3122
+ DD aa 10462 10462 3122 3122 DD aa 10462 10462 3122 3122
+ DD bb 10462 10462 2493 2493 DD bb 10462 10462 2493 2493
+ DD bb 10462 10462 2493 2493 DD bb 10462 10462 2493 2493
+ EE aa 7154 7154 4032 4032 EE aa 7154 7154 4032 4032
+ EE bb 7154 7154 3597 3597 EE bb 7154 7154 3597 3597
+ EE bb 7154 7154 3597 3597 FF aa 6571 6571 2539 2539
+ FF aa 6571 6571 2539 2539 FF aa 6571 6571 2539 2539
+ FF aa 6571 6571 2539 2539 FF bb 6571 6571 3812 3812
+ FF bb 6571 6571 3812 3812 FF bb 6571 6571 3812 3812
+ FF bb 6571 6571 3812 3812 FF bb 6571 6571 3812 3812
+ FF bb 6571 6571 3812 3812 GG aa 8207 8207 5668 5668
+ GG aa 8207 8207 5668 5668 GG aa 8207 8207 5668 5668
+ GG aa 8207 8207 5668 5668 GG bb 8207 8207 5102 5102
+ GG bb 8207 8207 5102 5102 GG bb 8207 8207 5102 5102
+ GG bb 8207 8207 5102 5102 HH aa 10136 10136 4468 4468
+ HH aa 10136 10136 4468 4468 HH aa 10136 10136 4468 4468
+ HH bb 10136 10136 5120 5120 HH bb 10136 10136 5120 5120
+ HH bb 10136 10136 5120 5120 HH bb 10136 10136 5120 5120
+ HH bb 10136 10136 5120 5120 HH bb 10136 10136 5120 5120
+ II aa 9911 9911 5443 5443 II aa 9911 9911 5443 5443
+ II bb 9911 9911 4244 4244 II bb 9911 9911 4244 4244
+ II bb 9911 9911 4244 4244 II bb 9911 9911 4244 4244
+ II bb 9911 9911 4244 4244 JJ aa 9083 9083 3640 3640
+ JJ aa 9083 9083 3640 3640 JJ aa 9083 9083 3640 3640
+ JJ aa 9083 9083 3640 3640 JJ bb 9083 9083 4604 4604
+ JJ bb 9083 9083 4604 4604 JJ bb 9083 9083 4604 4604
+ JJ bb 9083 9083 4604 4604}
+
+do_execsql_test 1.7.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685
+ BB bb 4685 CC aa 12025 CC aa 12025 CC aa 12025 CC aa 12025
+ CC bb 12025 CC bb 12025 DD aa 15147 DD aa 15147 DD aa 15147
+ DD bb 15147 DD bb 15147 DD bb 15147 DD bb 15147 EE aa 14494
+ EE aa 14494 EE bb 14494 EE bb 14494 EE bb 14494 FF aa 9693
+ FF aa 9693 FF aa 9693 FF aa 9693 FF bb 9693 FF bb 9693 FF bb 9693
+ FF bb 9693 FF bb 9693 FF bb 9693 GG aa 12239 GG aa 12239
+ GG aa 12239 GG aa 12239 GG bb 12239 GG bb 12239 GG bb 12239
+ GG bb 12239 HH aa 12675 HH aa 12675 HH aa 12675 HH bb 12675
+ HH bb 12675 HH bb 12675 HH bb 12675 HH bb 12675 HH bb 12675
+ II aa 15579 II aa 15579 II bb 15579 II bb 15579 II bb 15579
+ II bb 15579 II bb 15579 JJ aa 13551 JJ aa 13551 JJ aa 13551
+ JJ aa 13551 JJ bb 13551 JJ bb 13551 JJ bb 13551 JJ bb 13551}
+
+do_execsql_test 1.7.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 2307 AA bb 2307
+ AA bb 2307 AA bb 2307 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB aa 4685 BB bb 7558 BB bb 7558 BB bb 7558 BB bb 7558
+ BB bb 7558 BB bb 7558 CC aa 9718 CC aa 9718 CC aa 9718 CC aa 9718
+ CC bb 9294 CC bb 9294 DD aa 7589 DD aa 7589 DD aa 7589 DD bb 4447
+ DD bb 4447 DD bb 4447 DD bb 4447 EE aa 5200 EE aa 5200 EE bb 4922
+ EE bb 4922 EE bb 4922 FF aa 5246 FF aa 5246 FF aa 5246 FF aa 5246
+ FF bb 4702 FF bb 4702 FF bb 4702 FF bb 4702 FF bb 4702 FF bb 4702
+ GG aa 7317 GG aa 7317 GG aa 7317 GG aa 7317 GG bb 7265 GG bb 7265
+ GG bb 7265 GG bb 7265 HH aa 7973 HH aa 7973 HH aa 7973 HH bb 6717
+ HH bb 6717 HH bb 6717 HH bb 6717 HH bb 6717 HH bb 6717 II aa 8314
+ II aa 8314 II bb 6493 II bb 6493 II bb 6493 II bb 6493 II bb 6493
+ JJ aa 6834 JJ aa 6834 JJ aa 6834 JJ aa 6834 JJ bb 5654 JJ bb 5654
+ JJ bb 5654 JJ bb 5654}
+
+do_execsql_test 1.7.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.7.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 934 AA bb 934
+ AA bb 934 AA bb 934 BB aa 934 BB aa 934 BB aa 934 BB aa 934
+ BB aa 934 BB aa 934 BB bb 934 BB bb 934 BB bb 934 BB bb 934
+ BB bb 934 BB bb 934 CC aa 870 CC aa 870 CC aa 870 CC aa 870
+ CC bb 840 CC bb 840 DD aa 840 DD aa 840 DD aa 840 DD bb 845
+ DD bb 845 DD bb 845 DD bb 845 EE aa 959 EE aa 959 EE bb 959
+ EE bb 959 EE bb 959 FF aa 959 FF aa 959 FF aa 959 FF aa 959
+ FF bb 777 FF bb 777 FF bb 777 FF bb 777 FF bb 777 FF bb 777
+ GG aa 938 GG aa 938 GG aa 938 GG aa 938 GG bb 938 GG bb 938
+ GG bb 938 GG bb 938 HH aa 938 HH aa 938 HH aa 938 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 979 II bb 979 II bb 979 II bb 979 II bb 979
+ JJ aa 963 JJ aa 963 JJ aa 963 JJ aa 963 JJ bb 899 JJ bb 899
+ JJ bb 899 JJ bb 899}
+
+do_execsql_test 1.7.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 223 AA bb 223
+ AA bb 223 AA bb 223 BB aa 223 BB aa 223 BB aa 223 BB aa 223
+ BB aa 223 BB aa 223 BB bb 223 BB bb 223 BB bb 223 BB bb 223
+ BB bb 223 BB bb 223 CC aa 247 CC aa 247 CC aa 247 CC aa 247
+ CC bb 158 CC bb 158 DD aa 158 DD aa 158 DD aa 158 DD bb 158
+ DD bb 158 DD bb 158 DD bb 158 EE aa 224 EE aa 224 EE bb 113
+ EE bb 113 EE bb 113 FF aa 113 FF aa 113 FF aa 113 FF aa 113
+ FF bb 113 FF bb 113 FF bb 113 FF bb 113 FF bb 113 FF bb 113
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 102 HH aa 102 HH aa 102 HH bb 148
+ HH bb 148 HH bb 148 HH bb 148 HH bb 148 HH bb 148 II aa 133
+ II aa 133 II bb 133 II bb 133 II bb 133 II bb 133 II bb 133
+ JJ aa 133 JJ aa 133 JJ aa 133 JJ aa 133 JJ bb 113 JJ bb 113
+ JJ bb 113 JJ bb 113}
+
+do_execsql_test 1.7.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685 BB bb 4685
+ BB bb 4685 CC aa 12025 CC aa 12025 CC aa 12025 CC aa 12025
+ CC bb 12025 CC bb 12025 DD aa 15147 DD aa 15147 DD aa 15147
+ DD bb 15147 DD bb 15147 DD bb 15147 DD bb 15147 EE aa 14494
+ EE aa 14494 EE bb 14494 EE bb 14494 EE bb 14494 FF aa 9693
+ FF aa 9693 FF aa 9693 FF aa 9693 FF bb 9693 FF bb 9693 FF bb 9693
+ FF bb 9693 FF bb 9693 FF bb 9693 GG aa 12239 GG aa 12239
+ GG aa 12239 GG aa 12239 GG bb 12239 GG bb 12239 GG bb 12239
+ GG bb 12239 HH aa 12675 HH aa 12675 HH aa 12675 HH bb 12675
+ HH bb 12675 HH bb 12675 HH bb 12675 HH bb 12675 HH bb 12675
+ II aa 15579 II aa 15579 II bb 15579 II bb 15579 II bb 15579
+ II bb 15579 II bb 15579 JJ aa 13551 JJ aa 13551 JJ aa 13551
+ JJ aa 13551 JJ bb 13551 JJ bb 13551 JJ bb 13551 JJ bb 13551}
+
+do_execsql_test 1.7.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb 2307 AA bb 2307
+ AA bb 2307 AA bb 2307 BB aa 4685 BB aa 4685 BB aa 4685 BB aa 4685
+ BB aa 4685 BB aa 4685 BB bb 7558 BB bb 7558 BB bb 7558 BB bb 7558
+ BB bb 7558 BB bb 7558 CC aa 9718 CC aa 9718 CC aa 9718 CC aa 9718
+ CC bb 9294 CC bb 9294 DD aa 7589 DD aa 7589 DD aa 7589 DD bb 4447
+ DD bb 4447 DD bb 4447 DD bb 4447 EE aa 5200 EE aa 5200 EE bb 4922
+ EE bb 4922 EE bb 4922 FF aa 5246 FF aa 5246 FF aa 5246 FF aa 5246
+ FF bb 4702 FF bb 4702 FF bb 4702 FF bb 4702 FF bb 4702 FF bb 4702
+ GG aa 7317 GG aa 7317 GG aa 7317 GG aa 7317 GG bb 7265 GG bb 7265
+ GG bb 7265 GG bb 7265 HH aa 7973 HH aa 7973 HH aa 7973 HH bb 6717
+ HH bb 6717 HH bb 6717 HH bb 6717 HH bb 6717 HH bb 6717 II aa 8314
+ II aa 8314 II bb 6493 II bb 6493 II bb 6493 II bb 6493 II bb 6493
+ JJ aa 6834 JJ aa 6834 JJ aa 6834 JJ aa 6834 JJ bb 5654 JJ bb 5654
+ JJ bb 5654 JJ bb 5654}
+
+do_execsql_test 1.7.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 1 PRECEDING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} {} {} {} AA aa {} {} {} {} AA aa {} {} {} {}
+ AA aa {} {} {} {} AA bb {} {} 2307 2307 AA bb {} {} 2307 2307
+ AA bb {} {} 2307 2307 AA bb {} {} 2307 2307 BB aa 4685 4685 4685 4685
+ BB aa 4685 4685 4685 4685 BB aa 4685 4685 4685 4685
+ BB aa 4685 4685 4685 4685 BB aa 4685 4685 4685 4685
+ BB aa 4685 4685 4685 4685 BB bb 4685 4685 7558 7558
+ BB bb 4685 4685 7558 7558 BB bb 4685 4685 7558 7558
+ BB bb 4685 4685 7558 7558 BB bb 4685 4685 7558 7558
+ BB bb 4685 4685 7558 7558 CC aa 12025 12025 9718 9718
+ CC aa 12025 12025 9718 9718 CC aa 12025 12025 9718 9718
+ CC aa 12025 12025 9718 9718 CC bb 12025 12025 9294 9294
+ CC bb 12025 12025 9294 9294 DD aa 15147 15147 7589 7589
+ DD aa 15147 15147 7589 7589 DD aa 15147 15147 7589 7589
+ DD bb 15147 15147 4447 4447 DD bb 15147 15147 4447 4447
+ DD bb 15147 15147 4447 4447 DD bb 15147 15147 4447 4447
+ EE aa 14494 14494 5200 5200 EE aa 14494 14494 5200 5200
+ EE bb 14494 14494 4922 4922 EE bb 14494 14494 4922 4922
+ EE bb 14494 14494 4922 4922 FF aa 9693 9693 5246 5246
+ FF aa 9693 9693 5246 5246 FF aa 9693 9693 5246 5246
+ FF aa 9693 9693 5246 5246 FF bb 9693 9693 4702 4702
+ FF bb 9693 9693 4702 4702 FF bb 9693 9693 4702 4702
+ FF bb 9693 9693 4702 4702 FF bb 9693 9693 4702 4702
+ FF bb 9693 9693 4702 4702 GG aa 12239 12239 7317 7317
+ GG aa 12239 12239 7317 7317 GG aa 12239 12239 7317 7317
+ GG aa 12239 12239 7317 7317 GG bb 12239 12239 7265 7265
+ GG bb 12239 12239 7265 7265 GG bb 12239 12239 7265 7265
+ GG bb 12239 12239 7265 7265 HH aa 12675 12675 7973 7973
+ HH aa 12675 12675 7973 7973 HH aa 12675 12675 7973 7973
+ HH bb 12675 12675 6717 6717 HH bb 12675 12675 6717 6717
+ HH bb 12675 12675 6717 6717 HH bb 12675 12675 6717 6717
+ HH bb 12675 12675 6717 6717 HH bb 12675 12675 6717 6717
+ II aa 15579 15579 8314 8314 II aa 15579 15579 8314 8314
+ II bb 15579 15579 6493 6493 II bb 15579 15579 6493 6493
+ II bb 15579 15579 6493 6493 II bb 15579 15579 6493 6493
+ II bb 15579 15579 6493 6493 JJ aa 13551 13551 6834 6834
+ JJ aa 13551 13551 6834 6834 JJ aa 13551 13551 6834 6834
+ JJ aa 13551 13551 6834 6834 JJ bb 13551 13551 5654 5654
+ JJ bb 13551 13551 5654 5654 JJ bb 13551 13551 5654 5654
+ JJ bb 13551 13551 5654 5654}
+
+do_execsql_test 1.8.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 4685 AA aa 4685 AA aa 4685 AA aa 4685 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 12025 BB aa 12025 BB aa 12025
+ BB aa 12025 BB aa 12025 BB aa 12025 BB bb 12025 BB bb 12025
+ BB bb 12025 BB bb 12025 BB bb 12025 BB bb 12025 CC aa 15147
+ CC aa 15147 CC aa 15147 CC aa 15147 CC bb 15147 CC bb 15147
+ DD aa 19179 DD aa 19179 DD aa 19179 DD bb 19179 DD bb 19179
+ DD bb 19179 DD bb 19179 EE aa 17033 EE aa 17033 EE bb 17033
+ EE bb 17033 EE bb 17033 FF aa 15361 FF aa 15361 FF aa 15361
+ FF aa 15361 FF bb 15361 FF bb 15361 FF bb 15361 FF bb 15361
+ FF bb 15361 FF bb 15361 GG aa 16707 GG aa 16707 GG aa 16707
+ GG aa 16707 GG bb 16707 GG bb 16707 GG bb 16707 GG bb 16707
+ HH aa 18118 HH aa 18118 HH aa 18118 HH bb 18118 HH bb 18118
+ HH bb 18118 HH bb 18118 HH bb 18118 HH bb 18118 II aa 19219
+ II aa 19219 II bb 19219 II bb 19219 II bb 19219 II bb 19219
+ II bb 19219 JJ aa 17351 JJ aa 17351 JJ aa 17351 JJ aa 17351
+ JJ bb 17351 JJ bb 17351 JJ bb 17351 JJ bb 17351}
+
+do_execsql_test 1.8.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 2307 AA aa 2307 AA aa 2307 AA aa 2307 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 7558 BB aa 7558 BB aa 7558 BB aa 7558
+ BB aa 7558 BB aa 7558 BB bb 12025 BB bb 12025 BB bb 12025
+ BB bb 12025 BB bb 12025 BB bb 12025 CC aa 11672 CC aa 11672
+ CC aa 11672 CC aa 11672 CC bb 10462 CC bb 10462 DD aa 8914
+ DD aa 8914 DD aa 8914 DD bb 7154 DD bb 7154 DD bb 7154 DD bb 7154
+ EE aa 6090 EE aa 6090 EE bb 6571 EE bb 6571 EE bb 6571 FF aa 7409
+ FF aa 7409 FF aa 7409 FF aa 7409 FF bb 8207 FF bb 8207 FF bb 8207
+ FF bb 8207 FF bb 8207 FF bb 8207 GG aa 8914 GG aa 8914 GG aa 8914
+ GG aa 8914 GG bb 10136 GG bb 10136 GG bb 10136 GG bb 10136
+ HH aa 10222 HH aa 10222 HH aa 10222 HH bb 9911 HH bb 9911
+ HH bb 9911 HH bb 9911 HH bb 9911 HH bb 9911 II aa 9364 II aa 9364
+ II bb 9083 II bb 9083 II bb 9083 II bb 9083 II bb 9083 JJ aa 8848
+ JJ aa 8848 JJ aa 8848 JJ aa 8848 JJ bb 7440 JJ bb 7440 JJ bb 7440
+ JJ bb 7440}
+
+do_execsql_test 1.8.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.8.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 934 AA aa 934 AA aa 934 AA aa 934 AA bb 934 AA bb 934
+ AA bb 934 AA bb 934 BB aa 934 BB aa 934 BB aa 934 BB aa 934
+ BB aa 934 BB aa 934 BB bb 934 BB bb 934 BB bb 934 BB bb 934
+ BB bb 934 BB bb 934 CC aa 870 CC aa 870 CC aa 870 CC aa 870
+ CC bb 840 CC bb 840 DD aa 845 DD aa 845 DD aa 845 DD bb 959
+ DD bb 959 DD bb 959 DD bb 959 EE aa 959 EE aa 959 EE bb 959
+ EE bb 959 EE bb 959 FF aa 959 FF aa 959 FF aa 959 FF aa 959
+ FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938
+ GG aa 938 GG aa 938 GG aa 938 GG aa 938 GG bb 938 GG bb 938
+ GG bb 938 GG bb 938 HH aa 979 HH aa 979 HH aa 979 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 979 II bb 979 II bb 979 II bb 979 II bb 979
+ JJ aa 963 JJ aa 963 JJ aa 963 JJ aa 963 JJ bb 899 JJ bb 899
+ JJ bb 899 JJ bb 899}
+
+do_execsql_test 1.8.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 223 AA aa 223 AA aa 223 AA aa 223 AA bb 223 AA bb 223
+ AA bb 223 AA bb 223 BB aa 223 BB aa 223 BB aa 223 BB aa 223
+ BB aa 223 BB aa 223 BB bb 223 BB bb 223 BB bb 223 BB bb 223
+ BB bb 223 BB bb 223 CC aa 158 CC aa 158 CC aa 158 CC aa 158
+ CC bb 158 CC bb 158 DD aa 158 DD aa 158 DD aa 158 DD bb 158
+ DD bb 158 DD bb 158 DD bb 158 EE aa 113 EE aa 113 EE bb 113
+ EE bb 113 EE bb 113 FF aa 113 FF aa 113 FF aa 113 FF aa 113
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 102 HH aa 102 HH aa 102 HH bb 133
+ HH bb 133 HH bb 133 HH bb 133 HH bb 133 HH bb 133 II aa 133
+ II aa 133 II bb 133 II bb 133 II bb 133 II bb 133 II bb 133
+ JJ aa 113 JJ aa 113 JJ aa 113 JJ aa 113 JJ bb 113 JJ bb 113
+ JJ bb 113 JJ bb 113}
+
+do_execsql_test 1.8.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 AA aa 3774 AA aa 4446 AA aa 4462 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 11263 BB aa 11365 BB aa 11613
+ BB aa 11626 BB aa 11632 BB aa 11778 BB bb 11185 BB bb 11233
+ BB bb 11239 BB bb 11314 BB bb 11320 BB bb 11392 CC aa 14388
+ CC aa 14540 CC aa 14717 CC aa 14989 CC bb 14325 CC bb 14801
+ DD aa 18334 DD aa 18923 DD aa 18955 DD bb 18220 DD bb 18385
+ DD bb 18463 DD bb 18941 EE aa 16256 EE aa 16920 EE bb 16265
+ EE bb 16404 EE bb 16781 FF aa 14691 FF aa 14694 FF aa 14743
+ FF aa 15153 FF bb 14423 FF bb 14491 FF bb 14635 FF bb 14787
+ FF bb 15066 FF bb 15259 GG aa 16073 GG aa 16227 GG aa 16372
+ GG aa 16559 GG bb 15769 GG bb 15778 GG bb 15863 GG bb 16547
+ HH aa 17139 HH aa 17328 HH aa 17638 HH bb 17155 HH bb 17388
+ HH bb 17435 HH bb 17763 HH bb 17788 HH bb 17985 II aa 18567
+ II aa 18821 II bb 18414 II bb 18548 II bb 18776 II bb 18798
+ II bb 18969 JJ aa 16452 JJ aa 16583 JJ aa 17117 JJ aa 17238
+ JJ bb 16512 JJ bb 16997 JJ bb 17015 JJ bb 17094}
+
+do_execsql_test 1.8.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1373 AA aa 1396 AA aa 2068 AA aa 2084 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 6796 BB aa 6898 BB aa 7146 BB aa 7159
+ BB aa 7165 BB aa 7311 BB bb 11185 BB bb 11233 BB bb 11239
+ BB bb 11314 BB bb 11320 BB bb 11392 CC aa 10913 CC aa 11065
+ CC aa 11242 CC aa 11514 CC bb 9640 CC bb 10116 DD aa 8069
+ DD aa 8658 DD aa 8690 DD bb 6195 DD bb 6360 DD bb 6438 DD bb 6916
+ EE aa 5313 EE aa 5977 EE bb 5803 EE bb 5942 EE bb 6319 FF aa 6739
+ FF aa 6742 FF aa 6791 FF aa 7201 FF bb 7269 FF bb 7337 FF bb 7481
+ FF bb 7633 FF bb 7912 FF bb 8105 GG aa 8280 GG aa 8434 GG aa 8579
+ GG aa 8766 GG bb 9198 GG bb 9207 GG bb 9292 GG bb 9976 HH aa 9243
+ HH aa 9432 HH aa 9742 HH bb 8948 HH bb 9181 HH bb 9228 HH bb 9556
+ HH bb 9581 HH bb 9778 II aa 8712 II aa 8966 II bb 8278 II bb 8412
+ II bb 8640 II bb 8662 II bb 8833 JJ aa 7949 JJ aa 8080 JJ aa 8614
+ JJ aa 8735 JJ bb 6601 JJ bb 7086 JJ bb 7104 JJ bb 7183}
+
+do_execsql_test 1.8.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 PRECEDING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 4685 1373 2307 AA aa 3774 4685 1396 2307
+ AA aa 4446 4685 2068 2307 AA aa 4462 4685 2084 2307
+ AA bb 3815 4685 3815 4685 AA bb 4058 4685 4058 4685
+ AA bb 4113 4685 4113 4685 AA bb 4376 4685 4376 4685
+ BB aa 11263 12025 6796 7558 BB aa 11365 12025 6898 7558
+ BB aa 11613 12025 7146 7558 BB aa 11626 12025 7159 7558
+ BB aa 11632 12025 7165 7558 BB aa 11778 12025 7311 7558
+ BB bb 11185 12025 11185 12025 BB bb 11233 12025 11233 12025
+ BB bb 11239 12025 11239 12025 BB bb 11314 12025 11314 12025
+ BB bb 11320 12025 11320 12025 BB bb 11392 12025 11392 12025
+ CC aa 14388 15147 10913 11672 CC aa 14540 15147 11065 11672
+ CC aa 14717 15147 11242 11672 CC aa 14989 15147 11514 11672
+ CC bb 14325 15147 9640 10462 CC bb 14801 15147 10116 10462
+ DD aa 18334 19179 8069 8914 DD aa 18923 19179 8658 8914
+ DD aa 18955 19179 8690 8914 DD bb 18220 19179 6195 7154
+ DD bb 18385 19179 6360 7154 DD bb 18463 19179 6438 7154
+ DD bb 18941 19179 6916 7154 EE aa 16256 17033 5313 6090
+ EE aa 16920 17033 5977 6090 EE bb 16265 17033 5803 6571
+ EE bb 16404 17033 5942 6571 EE bb 16781 17033 6319 6571
+ FF aa 14691 15361 6739 7409 FF aa 14694 15361 6742 7409
+ FF aa 14743 15361 6791 7409 FF aa 15153 15361 7201 7409
+ FF bb 14423 15361 7269 8207 FF bb 14491 15361 7337 8207
+ FF bb 14635 15361 7481 8207 FF bb 14787 15361 7633 8207
+ FF bb 15066 15361 7912 8207 FF bb 15259 15361 8105 8207
+ GG aa 16073 16707 8280 8914 GG aa 16227 16707 8434 8914
+ GG aa 16372 16707 8579 8914 GG aa 16559 16707 8766 8914
+ GG bb 15769 16707 9198 10136 GG bb 15778 16707 9207 10136
+ GG bb 15863 16707 9292 10136 GG bb 16547 16707 9976 10136
+ HH aa 17139 18118 9243 10222 HH aa 17328 18118 9432 10222
+ HH aa 17638 18118 9742 10222 HH bb 17155 18118 8948 9911
+ HH bb 17388 18118 9181 9911 HH bb 17435 18118 9228 9911
+ HH bb 17763 18118 9556 9911 HH bb 17788 18118 9581 9911
+ HH bb 17985 18118 9778 9911 II aa 18567 19219 8712 9364
+ II aa 18821 19219 8966 9364 II bb 18414 19219 8278 9083
+ II bb 18548 19219 8412 9083 II bb 18776 19219 8640 9083
+ II bb 18798 19219 8662 9083 II bb 18969 19219 8833 9083
+ JJ aa 16452 17351 7949 8848 JJ aa 16583 17351 8080 8848
+ JJ aa 17117 17351 8614 8848 JJ aa 17238 17351 8735 8848
+ JJ bb 16512 17351 6601 7440 JJ bb 16997 17351 7086 7440
+ JJ bb 17015 17351 7104 7440 JJ bb 17094 17351 7183 7440}
+
+do_execsql_test 1.9.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 4685 AA aa 4685 AA aa 4685 AA aa 4685 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 12025 BB aa 12025 BB aa 12025
+ BB aa 12025 BB aa 12025 BB aa 12025 BB bb 12025 BB bb 12025
+ BB bb 12025 BB bb 12025 BB bb 12025 BB bb 12025 CC aa 15147
+ CC aa 15147 CC aa 15147 CC aa 15147 CC bb 15147 CC bb 15147
+ DD aa 14494 DD aa 14494 DD aa 14494 DD bb 14494 DD bb 14494
+ DD bb 14494 DD bb 14494 EE aa 9693 EE aa 9693 EE bb 9693
+ EE bb 9693 EE bb 9693 FF aa 12239 FF aa 12239 FF aa 12239
+ FF aa 12239 FF bb 12239 FF bb 12239 FF bb 12239 FF bb 12239
+ FF bb 12239 FF bb 12239 GG aa 12675 GG aa 12675 GG aa 12675
+ GG aa 12675 GG bb 12675 GG bb 12675 GG bb 12675 GG bb 12675
+ HH aa 15579 HH aa 15579 HH aa 15579 HH bb 15579 HH bb 15579
+ HH bb 15579 HH bb 15579 HH bb 15579 HH bb 15579 II aa 13551
+ II aa 13551 II bb 13551 II bb 13551 II bb 13551 II bb 13551
+ II bb 13551 JJ aa 12883 JJ aa 12883 JJ aa 12883 JJ aa 12883
+ JJ bb 12883 JJ bb 12883 JJ bb 12883 JJ bb 12883}
+
+do_execsql_test 1.9.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 2307 AA aa 2307 AA aa 2307 AA aa 2307 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 7558 BB aa 7558 BB aa 7558 BB aa 7558
+ BB aa 7558 BB aa 7558 BB bb 9718 BB bb 9718 BB bb 9718 BB bb 9718
+ BB bb 9718 BB bb 9718 CC aa 9294 CC aa 9294 CC aa 9294 CC aa 9294
+ CC bb 7589 CC bb 7589 DD aa 4447 DD aa 4447 DD aa 4447 DD bb 5200
+ DD bb 5200 DD bb 5200 DD bb 5200 EE aa 4922 EE aa 4922 EE bb 5246
+ EE bb 5246 EE bb 5246 FF aa 4702 FF aa 4702 FF aa 4702 FF aa 4702
+ FF bb 7317 FF bb 7317 FF bb 7317 FF bb 7317 FF bb 7317 FF bb 7317
+ GG aa 7265 GG aa 7265 GG aa 7265 GG aa 7265 GG bb 7973 GG bb 7973
+ GG bb 7973 GG bb 7973 HH aa 6717 HH aa 6717 HH aa 6717 HH bb 8314
+ HH bb 8314 HH bb 8314 HH bb 8314 HH bb 8314 HH bb 8314 II aa 6493
+ II aa 6493 II bb 6834 II bb 6834 II bb 6834 II bb 6834 II bb 6834
+ JJ aa 5654 JJ aa 5654 JJ aa 5654 JJ aa 5654 JJ bb 6390 JJ bb 6390
+ JJ bb 6390 JJ bb 6390}
+
+do_execsql_test 1.9.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.9.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 934 AA aa 934 AA aa 934 AA aa 934 AA bb 934 AA bb 934
+ AA bb 934 AA bb 934 BB aa 934 BB aa 934 BB aa 934 BB aa 934
+ BB aa 934 BB aa 934 BB bb 870 BB bb 870 BB bb 870 BB bb 870
+ BB bb 870 BB bb 870 CC aa 840 CC aa 840 CC aa 840 CC aa 840
+ CC bb 840 CC bb 840 DD aa 845 DD aa 845 DD aa 845 DD bb 959
+ DD bb 959 DD bb 959 DD bb 959 EE aa 959 EE aa 959 EE bb 959
+ EE bb 959 EE bb 959 FF aa 777 FF aa 777 FF aa 777 FF aa 777
+ FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938
+ GG aa 938 GG aa 938 GG aa 938 GG aa 938 GG bb 938 GG bb 938
+ GG bb 938 GG bb 938 HH aa 979 HH aa 979 HH aa 979 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 963 II bb 963 II bb 963 II bb 963 II bb 963
+ JJ aa 899 JJ aa 899 JJ aa 899 JJ aa 899 JJ bb 899 JJ bb 899
+ JJ bb 899 JJ bb 899}
+
+do_execsql_test 1.9.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 223 AA aa 223 AA aa 223 AA aa 223 AA bb 223 AA bb 223
+ AA bb 223 AA bb 223 BB aa 223 BB aa 223 BB aa 223 BB aa 223
+ BB aa 223 BB aa 223 BB bb 247 BB bb 247 BB bb 247 BB bb 247
+ BB bb 247 BB bb 247 CC aa 158 CC aa 158 CC aa 158 CC aa 158
+ CC bb 158 CC bb 158 DD aa 158 DD aa 158 DD aa 158 DD bb 224
+ DD bb 224 DD bb 224 DD bb 224 EE aa 113 EE aa 113 EE bb 113
+ EE bb 113 EE bb 113 FF aa 113 FF aa 113 FF aa 113 FF aa 113
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 148 HH aa 148 HH aa 148 HH bb 133
+ HH bb 133 HH bb 133 HH bb 133 HH bb 133 HH bb 133 II aa 133
+ II aa 133 II bb 133 II bb 133 II bb 133 II bb 133 II bb 133
+ JJ aa 113 JJ aa 113 JJ aa 113 JJ aa 113 JJ bb 113 JJ bb 113
+ JJ bb 113 JJ bb 113}
+
+do_execsql_test 1.9.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 AA aa 3774 AA aa 4446 AA aa 4462 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 11263 BB aa 11365 BB aa 11613
+ BB aa 11626 BB aa 11632 BB aa 11778 BB bb 11185 BB bb 11233
+ BB bb 11239 BB bb 11314 BB bb 11320 BB bb 11392 CC aa 14388
+ CC aa 14540 CC aa 14717 CC aa 14989 CC bb 14325 CC bb 14801
+ DD aa 13649 DD aa 14238 DD aa 14270 DD bb 13535 DD bb 13700
+ DD bb 13778 DD bb 14256 EE aa 8916 EE aa 9580 EE bb 8925
+ EE bb 9064 EE bb 9441 FF aa 11569 FF aa 11572 FF aa 11621
+ FF aa 12031 FF bb 11301 FF bb 11369 FF bb 11513 FF bb 11665
+ FF bb 11944 FF bb 12137 GG aa 12041 GG aa 12195 GG aa 12340
+ GG aa 12527 GG bb 11737 GG bb 11746 GG bb 11831 GG bb 12515
+ HH aa 14600 HH aa 14789 HH aa 15099 HH bb 14616 HH bb 14849
+ HH bb 14896 HH bb 15224 HH bb 15249 HH bb 15446 II aa 12899
+ II aa 13153 II bb 12746 II bb 12880 II bb 13108 II bb 13130
+ II bb 13301 JJ aa 11984 JJ aa 12115 JJ aa 12649 JJ aa 12770
+ JJ bb 12044 JJ bb 12529 JJ bb 12547 JJ bb 12626}
+
+do_execsql_test 1.9.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1373 AA aa 1396 AA aa 2068 AA aa 2084 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 6796 BB aa 6898 BB aa 7146 BB aa 7159
+ BB aa 7165 BB aa 7311 BB bb 8878 BB bb 8926 BB bb 8932 BB bb 9007
+ BB bb 9013 BB bb 9085 CC aa 8535 CC aa 8687 CC aa 8864 CC aa 9136
+ CC bb 6767 CC bb 7243 DD aa 3602 DD aa 4191 DD aa 4223 DD bb 4241
+ DD bb 4406 DD bb 4484 DD bb 4962 EE aa 4145 EE aa 4809 EE bb 4478
+ EE bb 4617 EE bb 4994 FF aa 4032 FF aa 4035 FF aa 4084 FF aa 4494
+ FF bb 6379 FF bb 6447 FF bb 6591 FF bb 6743 FF bb 7022 FF bb 7215
+ GG aa 6631 GG aa 6785 GG aa 6930 GG aa 7117 GG bb 7035 GG bb 7044
+ GG bb 7129 GG bb 7813 HH aa 5738 HH aa 5927 HH aa 6237 HH bb 7351
+ HH bb 7584 HH bb 7631 HH bb 7959 HH bb 7984 HH bb 8181 II aa 5841
+ II aa 6095 II bb 6029 II bb 6163 II bb 6391 II bb 6413 II bb 6584
+ JJ aa 4755 JJ aa 4886 JJ aa 5420 JJ aa 5541 JJ bb 5551 JJ bb 6036
+ JJ bb 6054 JJ bb 6133}
+
+do_execsql_test 1.9.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 4685 1373 2307 AA aa 3774 4685 1396 2307
+ AA aa 4446 4685 2068 2307 AA aa 4462 4685 2084 2307
+ AA bb 3815 4685 3815 4685 AA bb 4058 4685 4058 4685
+ AA bb 4113 4685 4113 4685 AA bb 4376 4685 4376 4685
+ BB aa 11263 12025 6796 7558 BB aa 11365 12025 6898 7558
+ BB aa 11613 12025 7146 7558 BB aa 11626 12025 7159 7558
+ BB aa 11632 12025 7165 7558 BB aa 11778 12025 7311 7558
+ BB bb 11185 12025 8878 9718 BB bb 11233 12025 8926 9718
+ BB bb 11239 12025 8932 9718 BB bb 11314 12025 9007 9718
+ BB bb 11320 12025 9013 9718 BB bb 11392 12025 9085 9718
+ CC aa 14388 15147 8535 9294 CC aa 14540 15147 8687 9294
+ CC aa 14717 15147 8864 9294 CC aa 14989 15147 9136 9294
+ CC bb 14325 15147 6767 7589 CC bb 14801 15147 7243 7589
+ DD aa 13649 14494 3602 4447 DD aa 14238 14494 4191 4447
+ DD aa 14270 14494 4223 4447 DD bb 13535 14494 4241 5200
+ DD bb 13700 14494 4406 5200 DD bb 13778 14494 4484 5200
+ DD bb 14256 14494 4962 5200 EE aa 8916 9693 4145 4922
+ EE aa 9580 9693 4809 4922 EE bb 8925 9693 4478 5246
+ EE bb 9064 9693 4617 5246 EE bb 9441 9693 4994 5246
+ FF aa 11569 12239 4032 4702 FF aa 11572 12239 4035 4702
+ FF aa 11621 12239 4084 4702 FF aa 12031 12239 4494 4702
+ FF bb 11301 12239 6379 7317 FF bb 11369 12239 6447 7317
+ FF bb 11513 12239 6591 7317 FF bb 11665 12239 6743 7317
+ FF bb 11944 12239 7022 7317 FF bb 12137 12239 7215 7317
+ GG aa 12041 12675 6631 7265 GG aa 12195 12675 6785 7265
+ GG aa 12340 12675 6930 7265 GG aa 12527 12675 7117 7265
+ GG bb 11737 12675 7035 7973 GG bb 11746 12675 7044 7973
+ GG bb 11831 12675 7129 7973 GG bb 12515 12675 7813 7973
+ HH aa 14600 15579 5738 6717 HH aa 14789 15579 5927 6717
+ HH aa 15099 15579 6237 6717 HH bb 14616 15579 7351 8314
+ HH bb 14849 15579 7584 8314 HH bb 14896 15579 7631 8314
+ HH bb 15224 15579 7959 8314 HH bb 15249 15579 7984 8314
+ HH bb 15446 15579 8181 8314 II aa 12899 13551 5841 6493
+ II aa 13153 13551 6095 6493 II bb 12746 13551 6029 6834
+ II bb 12880 13551 6163 6834 II bb 13108 13551 6391 6834
+ II bb 13130 13551 6413 6834 II bb 13301 13551 6584 6834
+ JJ aa 11984 12883 4755 5654 JJ aa 12115 12883 4886 5654
+ JJ aa 12649 12883 5420 5654 JJ aa 12770 12883 5541 5654
+ JJ bb 12044 12883 5551 6390 JJ bb 12529 12883 6036 6390
+ JJ bb 12547 12883 6054 6390 JJ bb 12626 12883 6133 6390}
+
+do_execsql_test 1.10.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 4685 AA aa 4685 AA aa 4685 AA aa 4685 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 12025 BB aa 12025 BB aa 12025
+ BB aa 12025 BB aa 12025 BB aa 12025 BB bb 12025 BB bb 12025
+ BB bb 12025 BB bb 12025 BB bb 12025 BB bb 12025 CC aa 15147
+ CC aa 15147 CC aa 15147 CC aa 15147 CC bb 15147 CC bb 15147
+ DD aa 19179 DD aa 19179 DD aa 19179 DD bb 19179 DD bb 19179
+ DD bb 19179 DD bb 19179 EE aa 17033 EE aa 17033 EE bb 17033
+ EE bb 17033 EE bb 17033 FF aa 15361 FF aa 15361 FF aa 15361
+ FF aa 15361 FF bb 15361 FF bb 15361 FF bb 15361 FF bb 15361
+ FF bb 15361 FF bb 15361 GG aa 16707 GG aa 16707 GG aa 16707
+ GG aa 16707 GG bb 16707 GG bb 16707 GG bb 16707 GG bb 16707
+ HH aa 18118 HH aa 18118 HH aa 18118 HH bb 18118 HH bb 18118
+ HH bb 18118 HH bb 18118 HH bb 18118 HH bb 18118 II aa 19219
+ II aa 19219 II bb 19219 II bb 19219 II bb 19219 II bb 19219
+ II bb 19219 JJ aa 17351 JJ aa 17351 JJ aa 17351 JJ aa 17351
+ JJ bb 17351 JJ bb 17351 JJ bb 17351 JJ bb 17351}
+
+do_execsql_test 1.10.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 2307 AA aa 2307 AA aa 2307 AA aa 2307 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 7558 BB aa 7558 BB aa 7558 BB aa 7558
+ BB aa 7558 BB aa 7558 BB bb 12025 BB bb 12025 BB bb 12025
+ BB bb 12025 BB bb 12025 BB bb 12025 CC aa 11672 CC aa 11672
+ CC aa 11672 CC aa 11672 CC bb 10462 CC bb 10462 DD aa 8914
+ DD aa 8914 DD aa 8914 DD bb 7154 DD bb 7154 DD bb 7154 DD bb 7154
+ EE aa 6090 EE aa 6090 EE bb 6571 EE bb 6571 EE bb 6571 FF aa 7409
+ FF aa 7409 FF aa 7409 FF aa 7409 FF bb 8207 FF bb 8207 FF bb 8207
+ FF bb 8207 FF bb 8207 FF bb 8207 GG aa 8914 GG aa 8914 GG aa 8914
+ GG aa 8914 GG bb 10136 GG bb 10136 GG bb 10136 GG bb 10136
+ HH aa 10222 HH aa 10222 HH aa 10222 HH bb 9911 HH bb 9911
+ HH bb 9911 HH bb 9911 HH bb 9911 HH bb 9911 II aa 9364 II aa 9364
+ II bb 9083 II bb 9083 II bb 9083 II bb 9083 II bb 9083 JJ aa 8848
+ JJ aa 8848 JJ aa 8848 JJ aa 8848 JJ bb 7440 JJ bb 7440 JJ bb 7440
+ JJ bb 7440}
+
+do_execsql_test 1.10.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.10.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 934 AA aa 934 AA aa 934 AA aa 934 AA bb 934 AA bb 934
+ AA bb 934 AA bb 934 BB aa 934 BB aa 934 BB aa 934 BB aa 934
+ BB aa 934 BB aa 934 BB bb 934 BB bb 934 BB bb 934 BB bb 934
+ BB bb 934 BB bb 934 CC aa 870 CC aa 870 CC aa 870 CC aa 870
+ CC bb 840 CC bb 840 DD aa 845 DD aa 845 DD aa 845 DD bb 959
+ DD bb 959 DD bb 959 DD bb 959 EE aa 959 EE aa 959 EE bb 959
+ EE bb 959 EE bb 959 FF aa 959 FF aa 959 FF aa 959 FF aa 959
+ FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938
+ GG aa 938 GG aa 938 GG aa 938 GG aa 938 GG bb 938 GG bb 938
+ GG bb 938 GG bb 938 HH aa 979 HH aa 979 HH aa 979 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 979 II bb 979 II bb 979 II bb 979 II bb 979
+ JJ aa 963 JJ aa 963 JJ aa 963 JJ aa 963 JJ bb 899 JJ bb 899
+ JJ bb 899 JJ bb 899}
+
+do_execsql_test 1.10.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 223 AA aa 223 AA aa 223 AA aa 223 AA bb 223 AA bb 223
+ AA bb 223 AA bb 223 BB aa 223 BB aa 223 BB aa 223 BB aa 223
+ BB aa 223 BB aa 223 BB bb 223 BB bb 223 BB bb 223 BB bb 223
+ BB bb 223 BB bb 223 CC aa 158 CC aa 158 CC aa 158 CC aa 158
+ CC bb 158 CC bb 158 DD aa 158 DD aa 158 DD aa 158 DD bb 158
+ DD bb 158 DD bb 158 DD bb 158 EE aa 113 EE aa 113 EE bb 113
+ EE bb 113 EE bb 113 FF aa 113 FF aa 113 FF aa 113 FF aa 113
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 102 HH aa 102 HH aa 102 HH bb 133
+ HH bb 133 HH bb 133 HH bb 133 HH bb 133 HH bb 133 II aa 133
+ II aa 133 II bb 133 II bb 133 II bb 133 II bb 133 II bb 133
+ JJ aa 113 JJ aa 113 JJ aa 113 JJ aa 113 JJ bb 113 JJ bb 113
+ JJ bb 113 JJ bb 113}
+
+do_execsql_test 1.10.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 AA aa 3774 AA aa 4446 AA aa 4462 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 11263 BB aa 11365 BB aa 11613
+ BB aa 11626 BB aa 11632 BB aa 11778 BB bb 11185 BB bb 11233
+ BB bb 11239 BB bb 11314 BB bb 11320 BB bb 11392 CC aa 14388
+ CC aa 14540 CC aa 14717 CC aa 14989 CC bb 14325 CC bb 14801
+ DD aa 18334 DD aa 18923 DD aa 18955 DD bb 18220 DD bb 18385
+ DD bb 18463 DD bb 18941 EE aa 16256 EE aa 16920 EE bb 16265
+ EE bb 16404 EE bb 16781 FF aa 14691 FF aa 14694 FF aa 14743
+ FF aa 15153 FF bb 14423 FF bb 14491 FF bb 14635 FF bb 14787
+ FF bb 15066 FF bb 15259 GG aa 16073 GG aa 16227 GG aa 16372
+ GG aa 16559 GG bb 15769 GG bb 15778 GG bb 15863 GG bb 16547
+ HH aa 17139 HH aa 17328 HH aa 17638 HH bb 17155 HH bb 17388
+ HH bb 17435 HH bb 17763 HH bb 17788 HH bb 17985 II aa 18567
+ II aa 18821 II bb 18414 II bb 18548 II bb 18776 II bb 18798
+ II bb 18969 JJ aa 16452 JJ aa 16583 JJ aa 17117 JJ aa 17238
+ JJ bb 16512 JJ bb 16997 JJ bb 17015 JJ bb 17094}
+
+do_execsql_test 1.10.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1373 AA aa 1396 AA aa 2068 AA aa 2084 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 6796 BB aa 6898 BB aa 7146 BB aa 7159
+ BB aa 7165 BB aa 7311 BB bb 11185 BB bb 11233 BB bb 11239
+ BB bb 11314 BB bb 11320 BB bb 11392 CC aa 10913 CC aa 11065
+ CC aa 11242 CC aa 11514 CC bb 9640 CC bb 10116 DD aa 8069
+ DD aa 8658 DD aa 8690 DD bb 6195 DD bb 6360 DD bb 6438 DD bb 6916
+ EE aa 5313 EE aa 5977 EE bb 5803 EE bb 5942 EE bb 6319 FF aa 6739
+ FF aa 6742 FF aa 6791 FF aa 7201 FF bb 7269 FF bb 7337 FF bb 7481
+ FF bb 7633 FF bb 7912 FF bb 8105 GG aa 8280 GG aa 8434 GG aa 8579
+ GG aa 8766 GG bb 9198 GG bb 9207 GG bb 9292 GG bb 9976 HH aa 9243
+ HH aa 9432 HH aa 9742 HH bb 8948 HH bb 9181 HH bb 9228 HH bb 9556
+ HH bb 9581 HH bb 9778 II aa 8712 II aa 8966 II bb 8278 II bb 8412
+ II bb 8640 II bb 8662 II bb 8833 JJ aa 7949 JJ aa 8080 JJ aa 8614
+ JJ aa 8735 JJ bb 6601 JJ bb 7086 JJ bb 7104 JJ bb 7183}
+
+do_execsql_test 1.10.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 3 PRECEDING AND 0 FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 4685 1373 2307 AA aa 3774 4685 1396 2307
+ AA aa 4446 4685 2068 2307 AA aa 4462 4685 2084 2307
+ AA bb 3815 4685 3815 4685 AA bb 4058 4685 4058 4685
+ AA bb 4113 4685 4113 4685 AA bb 4376 4685 4376 4685
+ BB aa 11263 12025 6796 7558 BB aa 11365 12025 6898 7558
+ BB aa 11613 12025 7146 7558 BB aa 11626 12025 7159 7558
+ BB aa 11632 12025 7165 7558 BB aa 11778 12025 7311 7558
+ BB bb 11185 12025 11185 12025 BB bb 11233 12025 11233 12025
+ BB bb 11239 12025 11239 12025 BB bb 11314 12025 11314 12025
+ BB bb 11320 12025 11320 12025 BB bb 11392 12025 11392 12025
+ CC aa 14388 15147 10913 11672 CC aa 14540 15147 11065 11672
+ CC aa 14717 15147 11242 11672 CC aa 14989 15147 11514 11672
+ CC bb 14325 15147 9640 10462 CC bb 14801 15147 10116 10462
+ DD aa 18334 19179 8069 8914 DD aa 18923 19179 8658 8914
+ DD aa 18955 19179 8690 8914 DD bb 18220 19179 6195 7154
+ DD bb 18385 19179 6360 7154 DD bb 18463 19179 6438 7154
+ DD bb 18941 19179 6916 7154 EE aa 16256 17033 5313 6090
+ EE aa 16920 17033 5977 6090 EE bb 16265 17033 5803 6571
+ EE bb 16404 17033 5942 6571 EE bb 16781 17033 6319 6571
+ FF aa 14691 15361 6739 7409 FF aa 14694 15361 6742 7409
+ FF aa 14743 15361 6791 7409 FF aa 15153 15361 7201 7409
+ FF bb 14423 15361 7269 8207 FF bb 14491 15361 7337 8207
+ FF bb 14635 15361 7481 8207 FF bb 14787 15361 7633 8207
+ FF bb 15066 15361 7912 8207 FF bb 15259 15361 8105 8207
+ GG aa 16073 16707 8280 8914 GG aa 16227 16707 8434 8914
+ GG aa 16372 16707 8579 8914 GG aa 16559 16707 8766 8914
+ GG bb 15769 16707 9198 10136 GG bb 15778 16707 9207 10136
+ GG bb 15863 16707 9292 10136 GG bb 16547 16707 9976 10136
+ HH aa 17139 18118 9243 10222 HH aa 17328 18118 9432 10222
+ HH aa 17638 18118 9742 10222 HH bb 17155 18118 8948 9911
+ HH bb 17388 18118 9181 9911 HH bb 17435 18118 9228 9911
+ HH bb 17763 18118 9556 9911 HH bb 17788 18118 9581 9911
+ HH bb 17985 18118 9778 9911 II aa 18567 19219 8712 9364
+ II aa 18821 19219 8966 9364 II bb 18414 19219 8278 9083
+ II bb 18548 19219 8412 9083 II bb 18776 19219 8640 9083
+ II bb 18798 19219 8662 9083 II bb 18969 19219 8833 9083
+ JJ aa 16452 17351 7949 8848 JJ aa 16583 17351 8080 8848
+ JJ aa 17117 17351 8614 8848 JJ aa 17238 17351 8735 8848
+ JJ bb 16512 17351 6601 7440 JJ bb 16997 17351 7086 7440
+ JJ bb 17015 17351 7104 7440 JJ bb 17094 17351 7183 7440}
+
+do_execsql_test 1.11.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 44737 AA aa 44737 AA aa 44737 AA aa 44737 AA bb 44737
+ AA bb 44737 AA bb 44737 AA bb 44737 BB aa 44737 BB aa 44737
+ BB aa 44737 BB aa 44737 BB aa 44737 BB aa 44737 BB bb 44737
+ BB bb 44737 BB bb 44737 BB bb 44737 BB bb 44737 BB bb 44737
+ CC aa 44737 CC aa 44737 CC aa 44737 CC aa 44737 CC bb 44737
+ CC bb 44737 DD aa 40052 DD aa 40052 DD aa 40052 DD bb 40052
+ DD bb 40052 DD bb 40052 DD bb 40052 EE aa 32712 EE aa 32712
+ EE bb 32712 EE bb 32712 EE bb 32712 FF aa 29590 FF aa 29590
+ FF aa 29590 FF aa 29590 FF bb 29590 FF bb 29590 FF bb 29590
+ FF bb 29590 FF bb 29590 FF bb 29590 GG aa 25558 GG aa 25558
+ GG aa 25558 GG aa 25558 GG bb 25558 GG bb 25558 GG bb 25558
+ GG bb 25558 HH aa 23019 HH aa 23019 HH aa 23019 HH bb 23019
+ HH bb 23019 HH bb 23019 HH bb 23019 HH bb 23019 HH bb 23019
+ II aa 17351 II aa 17351 II bb 17351 II bb 17351 II bb 17351
+ II bb 17351 II bb 17351 JJ aa 12883 JJ aa 12883 JJ aa 12883
+ JJ aa 12883 JJ bb 12883 JJ bb 12883 JJ bb 12883 JJ bb 12883}
+
+do_execsql_test 1.11.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 44737 AA aa 44737 AA aa 44737 AA aa 44737 AA bb 44737
+ AA bb 44737 AA bb 44737 AA bb 44737 BB aa 44737 BB aa 44737
+ BB aa 44737 BB aa 44737 BB aa 44737 BB aa 44737 BB bb 42430
+ BB bb 42430 BB bb 42430 BB bb 42430 BB bb 42430 BB bb 42430
+ CC aa 40052 CC aa 40052 CC aa 40052 CC aa 40052 CC bb 37179
+ CC bb 37179 DD aa 32712 DD aa 32712 DD aa 32712 DD bb 30758
+ DD bb 30758 DD bb 30758 DD bb 30758 EE aa 29590 EE aa 29590
+ EE bb 28265 EE bb 28265 EE bb 28265 FF aa 25558 FF aa 25558
+ FF aa 25558 FF aa 25558 FF bb 24668 FF bb 24668 FF bb 24668
+ FF bb 24668 FF bb 24668 FF bb 24668 GG aa 23019 GG aa 23019
+ GG aa 23019 GG aa 23019 GG bb 20856 GG bb 20856 GG bb 20856
+ GG bb 20856 HH aa 17351 HH aa 17351 HH aa 17351 HH bb 15754
+ HH bb 15754 HH bb 15754 HH bb 15754 HH bb 15754 HH bb 15754
+ II aa 12883 II aa 12883 II bb 10634 II bb 10634 II bb 10634
+ II bb 10634 II bb 10634 JJ aa 7440 JJ aa 7440 JJ aa 7440
+ JJ aa 7440 JJ bb 6390 JJ bb 6390 JJ bb 6390 JJ bb 6390}
+
+do_execsql_test 1.11.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.11.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 979 AA aa 979 AA aa 979 AA aa 979 AA bb 979 AA bb 979
+ AA bb 979 AA bb 979 BB aa 979 BB aa 979 BB aa 979 BB aa 979
+ BB aa 979 BB aa 979 BB bb 979 BB bb 979 BB bb 979 BB bb 979
+ BB bb 979 BB bb 979 CC aa 979 CC aa 979 CC aa 979 CC aa 979
+ CC bb 979 CC bb 979 DD aa 979 DD aa 979 DD aa 979 DD bb 979
+ DD bb 979 DD bb 979 DD bb 979 EE aa 979 EE aa 979 EE bb 979
+ EE bb 979 EE bb 979 FF aa 979 FF aa 979 FF aa 979 FF aa 979
+ FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979
+ GG aa 979 GG aa 979 GG aa 979 GG aa 979 GG bb 979 GG bb 979
+ GG bb 979 GG bb 979 HH aa 979 HH aa 979 HH aa 979 HH bb 979
+ HH bb 979 HH bb 979 HH bb 979 HH bb 979 HH bb 979 II aa 979
+ II aa 979 II bb 963 II bb 963 II bb 963 II bb 963 II bb 963
+ JJ aa 899 JJ aa 899 JJ aa 899 JJ aa 899 JJ bb 899 JJ bb 899
+ JJ bb 899 JJ bb 899}
+
+do_execsql_test 1.11.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 102 AA aa 102 AA aa 102 AA aa 102 AA bb 102 AA bb 102
+ AA bb 102 AA bb 102 BB aa 102 BB aa 102 BB aa 102 BB aa 102
+ BB aa 102 BB aa 102 BB bb 102 BB bb 102 BB bb 102 BB bb 102
+ BB bb 102 BB bb 102 CC aa 102 CC aa 102 CC aa 102 CC aa 102
+ CC bb 102 CC bb 102 DD aa 102 DD aa 102 DD aa 102 DD bb 102
+ DD bb 102 DD bb 102 DD bb 102 EE aa 102 EE aa 102 EE bb 102
+ EE bb 102 EE bb 102 FF aa 102 FF aa 102 FF aa 102 FF aa 102
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 102 GG aa 102 GG aa 102 GG aa 102 GG bb 102 GG bb 102
+ GG bb 102 GG bb 102 HH aa 113 HH aa 113 HH aa 113 HH bb 113
+ HH bb 113 HH bb 113 HH bb 113 HH bb 113 HH bb 113 II aa 113
+ II aa 113 II bb 113 II bb 113 II bb 113 II bb 113 II bb 113
+ JJ aa 113 JJ aa 113 JJ aa 113 JJ aa 113 JJ bb 113 JJ bb 113
+ JJ bb 113 JJ bb 113}
+
+do_execsql_test 1.11.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 AA aa 43826 AA aa 44498 AA aa 44514 AA bb 43867
+ AA bb 44110 AA bb 44165 AA bb 44428 BB aa 43975 BB aa 44077
+ BB aa 44325 BB aa 44338 BB aa 44344 BB aa 44490 BB bb 43897
+ BB bb 43945 BB bb 43951 BB bb 44026 BB bb 44032 BB bb 44104
+ CC aa 43978 CC aa 44130 CC aa 44307 CC aa 44579 CC bb 43915
+ CC bb 44391 DD aa 39207 DD aa 39796 DD aa 39828 DD bb 39093
+ DD bb 39258 DD bb 39336 DD bb 39814 EE aa 31935 EE aa 32599
+ EE bb 31944 EE bb 32083 EE bb 32460 FF aa 28920 FF aa 28923
+ FF aa 28972 FF aa 29382 FF bb 28652 FF bb 28720 FF bb 28864
+ FF bb 29016 FF bb 29295 FF bb 29488 GG aa 24924 GG aa 25078
+ GG aa 25223 GG aa 25410 GG bb 24620 GG bb 24629 GG bb 24714
+ GG bb 25398 HH aa 22040 HH aa 22229 HH aa 22539 HH bb 22056
+ HH bb 22289 HH bb 22336 HH bb 22664 HH bb 22689 HH bb 22886
+ II aa 16699 II aa 16953 II bb 16546 II bb 16680 II bb 16908
+ II bb 16930 II bb 17101 JJ aa 11984 JJ aa 12115 JJ aa 12649
+ JJ aa 12770 JJ bb 12044 JJ bb 12529 JJ bb 12547 JJ bb 12626}
+
+do_execsql_test 1.11.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 AA aa 43826 AA aa 44498 AA aa 44514 AA bb 43867
+ AA bb 44110 AA bb 44165 AA bb 44428 BB aa 43975 BB aa 44077
+ BB aa 44325 BB aa 44338 BB aa 44344 BB aa 44490 BB bb 41590
+ BB bb 41638 BB bb 41644 BB bb 41719 BB bb 41725 BB bb 41797
+ CC aa 39293 CC aa 39445 CC aa 39622 CC aa 39894 CC bb 36357
+ CC bb 36833 DD aa 31867 DD aa 32456 DD aa 32488 DD bb 29799
+ DD bb 29964 DD bb 30042 DD bb 30520 EE aa 28813 EE aa 29477
+ EE bb 27497 EE bb 27636 EE bb 28013 FF aa 24888 FF aa 24891
+ FF aa 24940 FF aa 25350 FF bb 23730 FF bb 23798 FF bb 23942
+ FF bb 24094 FF bb 24373 FF bb 24566 GG aa 22385 GG aa 22539
+ GG aa 22684 GG aa 22871 GG bb 19918 GG bb 19927 GG bb 20012
+ GG bb 20696 HH aa 16372 HH aa 16561 HH aa 16871 HH bb 14791
+ HH bb 15024 HH bb 15071 HH bb 15399 HH bb 15424 HH bb 15621
+ II aa 12231 II aa 12485 II bb 9829 II bb 9963 II bb 10191
+ II bb 10213 II bb 10384 JJ aa 6541 JJ aa 6672 JJ aa 7206
+ JJ aa 7327 JJ bb 5551 JJ bb 6036 JJ bb 6054 JJ bb 6133}
+
+do_execsql_test 1.11.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 2 PRECEDING AND UNBOUNDED FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 44737 43803 44737 AA aa 43826 44737 43826 44737
+ AA aa 44498 44737 44498 44737 AA aa 44514 44737 44514 44737
+ AA bb 43867 44737 43867 44737 AA bb 44110 44737 44110 44737
+ AA bb 44165 44737 44165 44737 AA bb 44428 44737 44428 44737
+ BB aa 43975 44737 43975 44737 BB aa 44077 44737 44077 44737
+ BB aa 44325 44737 44325 44737 BB aa 44338 44737 44338 44737
+ BB aa 44344 44737 44344 44737 BB aa 44490 44737 44490 44737
+ BB bb 43897 44737 41590 42430 BB bb 43945 44737 41638 42430
+ BB bb 43951 44737 41644 42430 BB bb 44026 44737 41719 42430
+ BB bb 44032 44737 41725 42430 BB bb 44104 44737 41797 42430
+ CC aa 43978 44737 39293 40052 CC aa 44130 44737 39445 40052
+ CC aa 44307 44737 39622 40052 CC aa 44579 44737 39894 40052
+ CC bb 43915 44737 36357 37179 CC bb 44391 44737 36833 37179
+ DD aa 39207 40052 31867 32712 DD aa 39796 40052 32456 32712
+ DD aa 39828 40052 32488 32712 DD bb 39093 40052 29799 30758
+ DD bb 39258 40052 29964 30758 DD bb 39336 40052 30042 30758
+ DD bb 39814 40052 30520 30758 EE aa 31935 32712 28813 29590
+ EE aa 32599 32712 29477 29590 EE bb 31944 32712 27497 28265
+ EE bb 32083 32712 27636 28265 EE bb 32460 32712 28013 28265
+ FF aa 28920 29590 24888 25558 FF aa 28923 29590 24891 25558
+ FF aa 28972 29590 24940 25558 FF aa 29382 29590 25350 25558
+ FF bb 28652 29590 23730 24668 FF bb 28720 29590 23798 24668
+ FF bb 28864 29590 23942 24668 FF bb 29016 29590 24094 24668
+ FF bb 29295 29590 24373 24668 FF bb 29488 29590 24566 24668
+ GG aa 24924 25558 22385 23019 GG aa 25078 25558 22539 23019
+ GG aa 25223 25558 22684 23019 GG aa 25410 25558 22871 23019
+ GG bb 24620 25558 19918 20856 GG bb 24629 25558 19927 20856
+ GG bb 24714 25558 20012 20856 GG bb 25398 25558 20696 20856
+ HH aa 22040 23019 16372 17351 HH aa 22229 23019 16561 17351
+ HH aa 22539 23019 16871 17351 HH bb 22056 23019 14791 15754
+ HH bb 22289 23019 15024 15754 HH bb 22336 23019 15071 15754
+ HH bb 22664 23019 15399 15754 HH bb 22689 23019 15424 15754
+ HH bb 22886 23019 15621 15754 II aa 16699 17351 12231 12883
+ II aa 16953 17351 12485 12883 II bb 16546 17351 9829 10634
+ II bb 16680 17351 9963 10634 II bb 16908 17351 10191 10634
+ II bb 16930 17351 10213 10634 II bb 17101 17351 10384 10634
+ JJ aa 11984 12883 6541 7440 JJ aa 12115 12883 6672 7440
+ JJ aa 12649 12883 7206 7440 JJ aa 12770 12883 7327 7440
+ JJ bb 12044 12883 5551 6390 JJ bb 12529 12883 6036 6390
+ JJ bb 12547 12883 6054 6390 JJ bb 12626 12883 6133 6390}
+
+do_execsql_test 1.12.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 4685 AA aa 4685 AA aa 4685 AA aa 4685 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 7340 BB aa 7340 BB aa 7340 BB aa 7340
+ BB aa 7340 BB aa 7340 BB bb 7340 BB bb 7340 BB bb 7340 BB bb 7340
+ BB bb 7340 BB bb 7340 CC aa 3122 CC aa 3122 CC aa 3122 CC aa 3122
+ CC bb 3122 CC bb 3122 DD aa 4032 DD aa 4032 DD aa 4032 DD bb 4032
+ DD bb 4032 DD bb 4032 DD bb 4032 EE aa 2539 EE aa 2539 EE bb 2539
+ EE bb 2539 EE bb 2539 FF aa 5668 FF aa 5668 FF aa 5668 FF aa 5668
+ FF bb 5668 FF bb 5668 FF bb 5668 FF bb 5668 FF bb 5668 FF bb 5668
+ GG aa 4468 GG aa 4468 GG aa 4468 GG aa 4468 GG bb 4468 GG bb 4468
+ GG bb 4468 GG bb 4468 HH aa 5443 HH aa 5443 HH aa 5443 HH bb 5443
+ HH bb 5443 HH bb 5443 HH bb 5443 HH bb 5443 HH bb 5443 II aa 3640
+ II aa 3640 II bb 3640 II bb 3640 II bb 3640 II bb 3640 II bb 3640
+ JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ bb 3800 JJ bb 3800
+ JJ bb 3800 JJ bb 3800}
+
+do_execsql_test 1.12.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 2307 AA aa 2307 AA aa 2307 AA aa 2307 AA bb 2378 AA bb 2378
+ AA bb 2378 AA bb 2378 BB aa 2873 BB aa 2873 BB aa 2873 BB aa 2873
+ BB aa 2873 BB aa 2873 BB bb 4467 BB bb 4467 BB bb 4467 BB bb 4467
+ BB bb 4467 BB bb 4467 CC aa 1954 CC aa 1954 CC aa 1954 CC aa 1954
+ CC bb 1168 CC bb 1168 DD aa 1325 DD aa 1325 DD aa 1325 DD bb 2707
+ DD bb 2707 DD bb 2707 DD bb 2707 EE aa 890 EE aa 890 EE bb 1649
+ EE bb 1649 EE bb 1649 FF aa 2163 FF aa 2163 FF aa 2163 FF aa 2163
+ FF bb 3505 FF bb 3505 FF bb 3505 FF bb 3505 FF bb 3505 FF bb 3505
+ GG aa 1597 GG aa 1597 GG aa 1597 GG aa 1597 GG bb 2871 GG bb 2871
+ GG bb 2871 GG bb 2871 HH aa 2249 HH aa 2249 HH aa 2249 HH bb 3194
+ HH bb 3194 HH bb 3194 HH bb 3194 HH bb 3194 HH bb 3194 II aa 1050
+ II aa 1050 II bb 2590 II bb 2590 II bb 2590 II bb 2590 II bb 2590
+ JJ aa 2014 JJ aa 2014 JJ aa 2014 JJ aa 2014 JJ bb 1786 JJ bb 1786
+ JJ bb 1786 JJ bb 1786}
+
+do_execsql_test 1.12.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.12.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 934 AA aa 934 AA aa 934 AA aa 934 AA bb 870 AA bb 870
+ AA bb 870 AA bb 870 BB aa 762 BB aa 762 BB aa 762 BB aa 762
+ BB aa 762 BB aa 762 BB bb 840 BB bb 840 BB bb 840 BB bb 840
+ BB bb 840 BB bb 840 CC aa 759 CC aa 759 CC aa 759 CC aa 759
+ CC bb 822 CC bb 822 DD aa 845 DD aa 845 DD aa 845 DD bb 959
+ DD bb 959 DD bb 959 DD bb 959 EE aa 777 EE aa 777 EE bb 768
+ EE bb 768 EE bb 768 FF aa 670 FF aa 670 FF aa 670 FF aa 670
+ FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938
+ GG aa 634 GG aa 634 GG aa 634 GG aa 634 GG bb 938 GG bb 938
+ GG bb 938 GG bb 938 HH aa 979 HH aa 979 HH aa 979 HH bb 963
+ HH bb 963 HH bb 963 HH bb 963 HH bb 963 HH bb 963 II aa 652
+ II aa 652 II bb 805 II bb 805 II bb 805 II bb 805 II bb 805
+ JJ aa 899 JJ aa 899 JJ aa 899 JJ aa 899 JJ bb 839 JJ bb 839
+ JJ bb 839 JJ bb 839}
+
+do_execsql_test 1.12.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 223 AA aa 223 AA aa 223 AA aa 223 AA bb 309 AA bb 309
+ AA bb 309 AA bb 309 BB aa 247 BB aa 247 BB aa 247 BB aa 247
+ BB aa 247 BB aa 247 BB bb 633 BB bb 633 BB bb 633 BB bb 633
+ BB bb 633 BB bb 633 CC aa 158 CC aa 158 CC aa 158 CC aa 158
+ CC bb 346 CC bb 346 DD aa 224 DD aa 224 DD aa 224 DD bb 238
+ DD bb 238 DD bb 238 DD bb 238 EE aa 113 EE aa 113 EE bb 252
+ EE bb 252 EE bb 252 FF aa 208 FF aa 208 FF aa 208 FF aa 208
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 148 GG aa 148 GG aa 148 GG aa 148 GG bb 160 GG bb 160
+ GG bb 160 GG bb 160 HH aa 480 HH aa 480 HH aa 480 HH bb 133
+ HH bb 133 HH bb 133 HH bb 133 HH bb 133 HH bb 133 II aa 398
+ II aa 398 II bb 250 II bb 250 II bb 250 II bb 250 II bb 250
+ JJ aa 113 JJ aa 113 JJ aa 113 JJ aa 113 JJ bb 257 JJ bb 257
+ JJ bb 257 JJ bb 257}
+
+do_execsql_test 1.12.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 AA aa 3774 AA aa 4446 AA aa 4462 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 6578 BB aa 6680 BB aa 6928 BB aa 6941
+ BB aa 6947 BB aa 7093 BB bb 6500 BB bb 6548 BB bb 6554 BB bb 6629
+ BB bb 6635 BB bb 6707 CC aa 2363 CC aa 2515 CC aa 2692 CC aa 2964
+ CC bb 2300 CC bb 2776 DD aa 3187 DD aa 3776 DD aa 3808 DD bb 3073
+ DD bb 3238 DD bb 3316 DD bb 3794 EE aa 1762 EE aa 2426 EE bb 1771
+ EE bb 1910 EE bb 2287 FF aa 4998 FF aa 5001 FF aa 5050 FF aa 5460
+ FF bb 4730 FF bb 4798 FF bb 4942 FF bb 5094 FF bb 5373 FF bb 5566
+ GG aa 3834 GG aa 3988 GG aa 4133 GG aa 4320 GG bb 3530 GG bb 3539
+ GG bb 3624 GG bb 4308 HH aa 4464 HH aa 4653 HH aa 4963 HH bb 4480
+ HH bb 4713 HH bb 4760 HH bb 5088 HH bb 5113 HH bb 5310 II aa 2988
+ II aa 3242 II bb 2835 II bb 2969 II bb 3197 II bb 3219 II bb 3390
+ JJ aa 2901 JJ aa 3032 JJ aa 3566 JJ aa 3687 JJ bb 2961 JJ bb 3446
+ JJ bb 3464 JJ bb 3543}
+
+do_execsql_test 1.12.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1373 AA aa 1396 AA aa 2068 AA aa 2084 AA bb 1508 AA bb 1751
+ AA bb 1806 AA bb 2069 BB aa 2111 BB aa 2213 BB aa 2461 BB aa 2474
+ BB aa 2480 BB aa 2626 BB bb 3627 BB bb 3675 BB bb 3681 BB bb 3756
+ BB bb 3762 BB bb 3834 CC aa 1195 CC aa 1347 CC aa 1524 CC aa 1796
+ CC bb 346 CC bb 822 DD aa 480 DD aa 1069 DD aa 1101 DD bb 1748
+ DD bb 1913 DD bb 1991 DD bb 2469 EE aa 113 EE aa 777 EE bb 881
+ EE bb 1020 EE bb 1397 FF aa 1493 FF aa 1496 FF aa 1545 FF aa 1955
+ FF bb 2567 FF bb 2635 FF bb 2779 FF bb 2931 FF bb 3210 FF bb 3403
+ GG aa 963 GG aa 1117 GG aa 1262 GG aa 1449 GG bb 1933 GG bb 1942
+ GG bb 2027 GG bb 2711 HH aa 1270 HH aa 1459 HH aa 1769 HH bb 2231
+ HH bb 2464 HH bb 2511 HH bb 2839 HH bb 2864 HH bb 3061 II aa 398
+ II aa 652 II bb 1785 II bb 1919 II bb 2147 II bb 2169 II bb 2340
+ JJ aa 1115 JJ aa 1246 JJ aa 1780 JJ aa 1901 JJ bb 947 JJ bb 1432
+ JJ bb 1450 JJ bb 1529}
+
+do_execsql_test 1.12.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 0 FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 4685 1373 2307 AA aa 3774 4685 1396 2307
+ AA aa 4446 4685 2068 2307 AA aa 4462 4685 2084 2307
+ AA bb 3815 4685 1508 2378 AA bb 4058 4685 1751 2378
+ AA bb 4113 4685 1806 2378 AA bb 4376 4685 2069 2378
+ BB aa 6578 7340 2111 2873 BB aa 6680 7340 2213 2873
+ BB aa 6928 7340 2461 2873 BB aa 6941 7340 2474 2873
+ BB aa 6947 7340 2480 2873 BB aa 7093 7340 2626 2873
+ BB bb 6500 7340 3627 4467 BB bb 6548 7340 3675 4467
+ BB bb 6554 7340 3681 4467 BB bb 6629 7340 3756 4467
+ BB bb 6635 7340 3762 4467 BB bb 6707 7340 3834 4467
+ CC aa 2363 3122 1195 1954 CC aa 2515 3122 1347 1954
+ CC aa 2692 3122 1524 1954 CC aa 2964 3122 1796 1954
+ CC bb 2300 3122 346 1168 CC bb 2776 3122 822 1168
+ DD aa 3187 4032 480 1325 DD aa 3776 4032 1069 1325
+ DD aa 3808 4032 1101 1325 DD bb 3073 4032 1748 2707
+ DD bb 3238 4032 1913 2707 DD bb 3316 4032 1991 2707
+ DD bb 3794 4032 2469 2707 EE aa 1762 2539 113 890
+ EE aa 2426 2539 777 890 EE bb 1771 2539 881 1649
+ EE bb 1910 2539 1020 1649 EE bb 2287 2539 1397 1649
+ FF aa 4998 5668 1493 2163 FF aa 5001 5668 1496 2163
+ FF aa 5050 5668 1545 2163 FF aa 5460 5668 1955 2163
+ FF bb 4730 5668 2567 3505 FF bb 4798 5668 2635 3505
+ FF bb 4942 5668 2779 3505 FF bb 5094 5668 2931 3505
+ FF bb 5373 5668 3210 3505 FF bb 5566 5668 3403 3505
+ GG aa 3834 4468 963 1597 GG aa 3988 4468 1117 1597
+ GG aa 4133 4468 1262 1597 GG aa 4320 4468 1449 1597
+ GG bb 3530 4468 1933 2871 GG bb 3539 4468 1942 2871
+ GG bb 3624 4468 2027 2871 GG bb 4308 4468 2711 2871
+ HH aa 4464 5443 1270 2249 HH aa 4653 5443 1459 2249
+ HH aa 4963 5443 1769 2249 HH bb 4480 5443 2231 3194
+ HH bb 4713 5443 2464 3194 HH bb 4760 5443 2511 3194
+ HH bb 5088 5443 2839 3194 HH bb 5113 5443 2864 3194
+ HH bb 5310 5443 3061 3194 II aa 2988 3640 398 1050
+ II aa 3242 3640 652 1050 II bb 2835 3640 1785 2590
+ II bb 2969 3640 1919 2590 II bb 3197 3640 2147 2590
+ II bb 3219 3640 2169 2590 II bb 3390 3640 2340 2590
+ JJ aa 2901 3800 1115 2014 JJ aa 3032 3800 1246 2014
+ JJ aa 3566 3800 1780 2014 JJ aa 3687 3800 1901 2014
+ JJ bb 2961 3800 947 1786 JJ bb 3446 3800 1432 1786
+ JJ bb 3464 3800 1450 1786 JJ bb 3543 3800 1529 1786}
+
+do_execsql_test 1.13.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 12025 AA aa 12025 AA aa 12025 AA aa 12025 AA bb 12025
+ AA bb 12025 AA bb 12025 AA bb 12025 BB aa 10462 BB aa 10462
+ BB aa 10462 BB aa 10462 BB aa 10462 BB aa 10462 BB bb 10462
+ BB bb 10462 BB bb 10462 BB bb 10462 BB bb 10462 BB bb 10462
+ CC aa 7154 CC aa 7154 CC aa 7154 CC aa 7154 CC bb 7154 CC bb 7154
+ DD aa 6571 DD aa 6571 DD aa 6571 DD bb 6571 DD bb 6571 DD bb 6571
+ DD bb 6571 EE aa 8207 EE aa 8207 EE bb 8207 EE bb 8207 EE bb 8207
+ FF aa 10136 FF aa 10136 FF aa 10136 FF aa 10136 FF bb 10136
+ FF bb 10136 FF bb 10136 FF bb 10136 FF bb 10136 FF bb 10136
+ GG aa 9911 GG aa 9911 GG aa 9911 GG aa 9911 GG bb 9911 GG bb 9911
+ GG bb 9911 GG bb 9911 HH aa 9083 HH aa 9083 HH aa 9083 HH bb 9083
+ HH bb 9083 HH bb 9083 HH bb 9083 HH bb 9083 HH bb 9083 II aa 7440
+ II aa 7440 II bb 7440 II bb 7440 II bb 7440 II bb 7440 II bb 7440
+ JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ bb 3800 JJ bb 3800
+ JJ bb 3800 JJ bb 3800}
+
+do_execsql_test 1.13.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 4685 AA aa 4685 AA aa 4685 AA aa 4685 AA bb 5251 AA bb 5251
+ AA bb 5251 AA bb 5251 BB aa 7340 BB aa 7340 BB aa 7340 BB aa 7340
+ BB aa 7340 BB aa 7340 BB bb 6421 BB bb 6421 BB bb 6421 BB bb 6421
+ BB bb 6421 BB bb 6421 CC aa 3122 CC aa 3122 CC aa 3122 CC aa 3122
+ CC bb 2493 CC bb 2493 DD aa 4032 DD aa 4032 DD aa 4032 DD bb 3597
+ DD bb 3597 DD bb 3597 DD bb 3597 EE aa 2539 EE aa 2539 EE bb 3812
+ EE bb 3812 EE bb 3812 FF aa 5668 FF aa 5668 FF aa 5668 FF aa 5668
+ FF bb 5102 FF bb 5102 FF bb 5102 FF bb 5102 FF bb 5102 FF bb 5102
+ GG aa 4468 GG aa 4468 GG aa 4468 GG aa 4468 GG bb 5120 GG bb 5120
+ GG bb 5120 GG bb 5120 HH aa 5443 HH aa 5443 HH aa 5443 HH bb 4244
+ HH bb 4244 HH bb 4244 HH bb 4244 HH bb 4244 HH bb 4244 II aa 3640
+ II aa 3640 II bb 4604 II bb 4604 II bb 4604 II bb 4604 II bb 4604
+ JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ bb 1786 JJ bb 1786
+ JJ bb 1786 JJ bb 1786}
+
+do_execsql_test 1.13.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.13.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 934 AA aa 934 AA aa 934 AA aa 934 AA bb 870 AA bb 870
+ AA bb 870 AA bb 870 BB aa 840 BB aa 840 BB aa 840 BB aa 840
+ BB aa 840 BB aa 840 BB bb 840 BB bb 840 BB bb 840 BB bb 840
+ BB bb 840 BB bb 840 CC aa 822 CC aa 822 CC aa 822 CC aa 822
+ CC bb 845 CC bb 845 DD aa 959 DD aa 959 DD aa 959 DD bb 959
+ DD bb 959 DD bb 959 DD bb 959 EE aa 777 EE aa 777 EE bb 768
+ EE bb 768 EE bb 768 FF aa 938 FF aa 938 FF aa 938 FF aa 938
+ FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938
+ GG aa 938 GG aa 938 GG aa 938 GG aa 938 GG bb 979 GG bb 979
+ GG bb 979 GG bb 979 HH aa 979 HH aa 979 HH aa 979 HH bb 963
+ HH bb 963 HH bb 963 HH bb 963 HH bb 963 HH bb 963 II aa 805
+ II aa 805 II bb 899 II bb 899 II bb 899 II bb 899 II bb 899
+ JJ aa 899 JJ aa 899 JJ aa 899 JJ aa 899 JJ bb 839 JJ bb 839
+ JJ bb 839 JJ bb 839}
+
+do_execsql_test 1.13.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 223 AA aa 223 AA aa 223 AA aa 223 AA bb 247 AA bb 247
+ AA bb 247 AA bb 247 BB aa 247 BB aa 247 BB aa 247 BB aa 247
+ BB aa 247 BB aa 247 BB bb 158 BB bb 158 BB bb 158 BB bb 158
+ BB bb 158 BB bb 158 CC aa 158 CC aa 158 CC aa 158 CC aa 158
+ CC bb 224 CC bb 224 DD aa 224 DD aa 224 DD aa 224 DD bb 113
+ DD bb 113 DD bb 113 DD bb 113 EE aa 113 EE aa 113 EE bb 208
+ EE bb 208 EE bb 208 FF aa 102 FF aa 102 FF aa 102 FF aa 102
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 148 GG aa 148 GG aa 148 GG aa 148 GG bb 160 GG bb 160
+ GG bb 160 GG bb 160 HH aa 133 HH aa 133 HH aa 133 HH bb 133
+ HH bb 133 HH bb 133 HH bb 133 HH bb 133 HH bb 133 II aa 250
+ II aa 250 II bb 113 II bb 113 II bb 113 II bb 113 II bb 113
+ JJ aa 113 JJ aa 113 JJ aa 113 JJ aa 113 JJ bb 257 JJ bb 257
+ JJ bb 257 JJ bb 257}
+
+do_execsql_test 1.13.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 11091 AA aa 11114 AA aa 11786 AA aa 11802 AA bb 11155
+ AA bb 11398 AA bb 11453 AA bb 11716 BB aa 9700 BB aa 9802
+ BB aa 10050 BB aa 10063 BB aa 10069 BB aa 10215 BB bb 9622
+ BB bb 9670 BB bb 9676 BB bb 9751 BB bb 9757 BB bb 9829 CC aa 6395
+ CC aa 6547 CC aa 6724 CC aa 6996 CC bb 6332 CC bb 6808 DD aa 5726
+ DD aa 6315 DD aa 6347 DD bb 5612 DD bb 5777 DD bb 5855 DD bb 6333
+ EE aa 7430 EE aa 8094 EE bb 7439 EE bb 7578 EE bb 7955 FF aa 9466
+ FF aa 9469 FF aa 9518 FF aa 9928 FF bb 9198 FF bb 9266 FF bb 9410
+ FF bb 9562 FF bb 9841 FF bb 10034 GG aa 9277 GG aa 9431
+ GG aa 9576 GG aa 9763 GG bb 8973 GG bb 8982 GG bb 9067 GG bb 9751
+ HH aa 8104 HH aa 8293 HH aa 8603 HH bb 8120 HH bb 8353 HH bb 8400
+ HH bb 8728 HH bb 8753 HH bb 8950 II aa 6788 II aa 7042 II bb 6635
+ II bb 6769 II bb 6997 II bb 7019 II bb 7190 JJ aa 2901 JJ aa 3032
+ JJ aa 3566 JJ aa 3687 JJ bb 2961 JJ bb 3446 JJ bb 3464 JJ bb 3543}
+
+do_execsql_test 1.13.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 AA aa 3774 AA aa 4446 AA aa 4462 AA bb 4381 AA bb 4624
+ AA bb 4679 AA bb 4942 BB aa 6578 BB aa 6680 BB aa 6928 BB aa 6941
+ BB aa 6947 BB aa 7093 BB bb 5581 BB bb 5629 BB bb 5635 BB bb 5710
+ BB bb 5716 BB bb 5788 CC aa 2363 CC aa 2515 CC aa 2692 CC aa 2964
+ CC bb 1671 CC bb 2147 DD aa 3187 DD aa 3776 DD aa 3808 DD bb 2638
+ DD bb 2803 DD bb 2881 DD bb 3359 EE aa 1762 EE aa 2426 EE bb 3044
+ EE bb 3183 EE bb 3560 FF aa 4998 FF aa 5001 FF aa 5050 FF aa 5460
+ FF bb 4164 FF bb 4232 FF bb 4376 FF bb 4528 FF bb 4807 FF bb 5000
+ GG aa 3834 GG aa 3988 GG aa 4133 GG aa 4320 GG bb 4182 GG bb 4191
+ GG bb 4276 GG bb 4960 HH aa 4464 HH aa 4653 HH aa 4963 HH bb 3281
+ HH bb 3514 HH bb 3561 HH bb 3889 HH bb 3914 HH bb 4111 II aa 2988
+ II aa 3242 II bb 3799 II bb 3933 II bb 4161 II bb 4183 II bb 4354
+ JJ aa 2901 JJ aa 3032 JJ aa 3566 JJ aa 3687 JJ bb 947 JJ bb 1432
+ JJ bb 1450 JJ bb 1529}
+
+do_execsql_test 1.13.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 11091 12025 3751 4685 AA aa 11114 12025 3774 4685
+ AA aa 11786 12025 4446 4685 AA aa 11802 12025 4462 4685
+ AA bb 11155 12025 4381 5251 AA bb 11398 12025 4624 5251
+ AA bb 11453 12025 4679 5251 AA bb 11716 12025 4942 5251
+ BB aa 9700 10462 6578 7340 BB aa 9802 10462 6680 7340
+ BB aa 10050 10462 6928 7340 BB aa 10063 10462 6941 7340
+ BB aa 10069 10462 6947 7340 BB aa 10215 10462 7093 7340
+ BB bb 9622 10462 5581 6421 BB bb 9670 10462 5629 6421
+ BB bb 9676 10462 5635 6421 BB bb 9751 10462 5710 6421
+ BB bb 9757 10462 5716 6421 BB bb 9829 10462 5788 6421
+ CC aa 6395 7154 2363 3122 CC aa 6547 7154 2515 3122
+ CC aa 6724 7154 2692 3122 CC aa 6996 7154 2964 3122
+ CC bb 6332 7154 1671 2493 CC bb 6808 7154 2147 2493
+ DD aa 5726 6571 3187 4032 DD aa 6315 6571 3776 4032
+ DD aa 6347 6571 3808 4032 DD bb 5612 6571 2638 3597
+ DD bb 5777 6571 2803 3597 DD bb 5855 6571 2881 3597
+ DD bb 6333 6571 3359 3597 EE aa 7430 8207 1762 2539
+ EE aa 8094 8207 2426 2539 EE bb 7439 8207 3044 3812
+ EE bb 7578 8207 3183 3812 EE bb 7955 8207 3560 3812
+ FF aa 9466 10136 4998 5668 FF aa 9469 10136 5001 5668
+ FF aa 9518 10136 5050 5668 FF aa 9928 10136 5460 5668
+ FF bb 9198 10136 4164 5102 FF bb 9266 10136 4232 5102
+ FF bb 9410 10136 4376 5102 FF bb 9562 10136 4528 5102
+ FF bb 9841 10136 4807 5102 FF bb 10034 10136 5000 5102
+ GG aa 9277 9911 3834 4468 GG aa 9431 9911 3988 4468
+ GG aa 9576 9911 4133 4468 GG aa 9763 9911 4320 4468
+ GG bb 8973 9911 4182 5120 GG bb 8982 9911 4191 5120
+ GG bb 9067 9911 4276 5120 GG bb 9751 9911 4960 5120
+ HH aa 8104 9083 4464 5443 HH aa 8293 9083 4653 5443
+ HH aa 8603 9083 4963 5443 HH bb 8120 9083 3281 4244
+ HH bb 8353 9083 3514 4244 HH bb 8400 9083 3561 4244
+ HH bb 8728 9083 3889 4244 HH bb 8753 9083 3914 4244
+ HH bb 8950 9083 4111 4244 II aa 6788 7440 2988 3640
+ II aa 7042 7440 3242 3640 II bb 6635 7440 3799 4604
+ II bb 6769 7440 3933 4604 II bb 6997 7440 4161 4604
+ II bb 7019 7440 4183 4604 II bb 7190 7440 4354 4604
+ JJ aa 2901 3800 2901 3800 JJ aa 3032 3800 3032 3800
+ JJ aa 3566 3800 3566 3800 JJ aa 3687 3800 3687 3800
+ JJ bb 2961 3800 947 1786 JJ bb 3446 3800 1432 1786
+ JJ bb 3464 3800 1450 1786 JJ bb 3543 3800 1529 1786}
+
+do_execsql_test 1.14.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 44737 AA aa 44737 AA aa 44737 AA aa 44737 AA bb 44737
+ AA bb 44737 AA bb 44737 AA bb 44737 BB aa 40052 BB aa 40052
+ BB aa 40052 BB aa 40052 BB aa 40052 BB aa 40052 BB bb 40052
+ BB bb 40052 BB bb 40052 BB bb 40052 BB bb 40052 BB bb 40052
+ CC aa 32712 CC aa 32712 CC aa 32712 CC aa 32712 CC bb 32712
+ CC bb 32712 DD aa 29590 DD aa 29590 DD aa 29590 DD bb 29590
+ DD bb 29590 DD bb 29590 DD bb 29590 EE aa 25558 EE aa 25558
+ EE bb 25558 EE bb 25558 EE bb 25558 FF aa 23019 FF aa 23019
+ FF aa 23019 FF aa 23019 FF bb 23019 FF bb 23019 FF bb 23019
+ FF bb 23019 FF bb 23019 FF bb 23019 GG aa 17351 GG aa 17351
+ GG aa 17351 GG aa 17351 GG bb 17351 GG bb 17351 GG bb 17351
+ GG bb 17351 HH aa 12883 HH aa 12883 HH aa 12883 HH bb 12883
+ HH bb 12883 HH bb 12883 HH bb 12883 HH bb 12883 HH bb 12883
+ II aa 7440 II aa 7440 II bb 7440 II bb 7440 II bb 7440 II bb 7440
+ II bb 7440 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ bb 3800
+ JJ bb 3800 JJ bb 3800 JJ bb 3800}
+
+do_execsql_test 1.14.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 44737 AA aa 44737 AA aa 44737 AA aa 44737 AA bb 42430
+ AA bb 42430 AA bb 42430 AA bb 42430 BB aa 40052 BB aa 40052
+ BB aa 40052 BB aa 40052 BB aa 40052 BB aa 40052 BB bb 37179
+ BB bb 37179 BB bb 37179 BB bb 37179 BB bb 37179 BB bb 37179
+ CC aa 32712 CC aa 32712 CC aa 32712 CC aa 32712 CC bb 30758
+ CC bb 30758 DD aa 29590 DD aa 29590 DD aa 29590 DD bb 28265
+ DD bb 28265 DD bb 28265 DD bb 28265 EE aa 25558 EE aa 25558
+ EE bb 24668 EE bb 24668 EE bb 24668 FF aa 23019 FF aa 23019
+ FF aa 23019 FF aa 23019 FF bb 20856 FF bb 20856 FF bb 20856
+ FF bb 20856 FF bb 20856 FF bb 20856 GG aa 17351 GG aa 17351
+ GG aa 17351 GG aa 17351 GG bb 15754 GG bb 15754 GG bb 15754
+ GG bb 15754 HH aa 12883 HH aa 12883 HH aa 12883 HH bb 10634
+ HH bb 10634 HH bb 10634 HH bb 10634 HH bb 10634 HH bb 10634
+ II aa 7440 II aa 7440 II bb 6390 II bb 6390 II bb 6390 II bb 6390
+ II bb 6390 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ bb 1786
+ JJ bb 1786 JJ bb 1786 JJ bb 1786}
+
+do_execsql_test 1.14.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.14.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 979 AA aa 979 AA aa 979 AA aa 979 AA bb 979 AA bb 979
+ AA bb 979 AA bb 979 BB aa 979 BB aa 979 BB aa 979 BB aa 979
+ BB aa 979 BB aa 979 BB bb 979 BB bb 979 BB bb 979 BB bb 979
+ BB bb 979 BB bb 979 CC aa 979 CC aa 979 CC aa 979 CC aa 979
+ CC bb 979 CC bb 979 DD aa 979 DD aa 979 DD aa 979 DD bb 979
+ DD bb 979 DD bb 979 DD bb 979 EE aa 979 EE aa 979 EE bb 979
+ EE bb 979 EE bb 979 FF aa 979 FF aa 979 FF aa 979 FF aa 979
+ FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979
+ GG aa 979 GG aa 979 GG aa 979 GG aa 979 GG bb 979 GG bb 979
+ GG bb 979 GG bb 979 HH aa 979 HH aa 979 HH aa 979 HH bb 963
+ HH bb 963 HH bb 963 HH bb 963 HH bb 963 HH bb 963 II aa 899
+ II aa 899 II bb 899 II bb 899 II bb 899 II bb 899 II bb 899
+ JJ aa 899 JJ aa 899 JJ aa 899 JJ aa 899 JJ bb 839 JJ bb 839
+ JJ bb 839 JJ bb 839}
+
+do_execsql_test 1.14.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 102 AA aa 102 AA aa 102 AA aa 102 AA bb 102 AA bb 102
+ AA bb 102 AA bb 102 BB aa 102 BB aa 102 BB aa 102 BB aa 102
+ BB aa 102 BB aa 102 BB bb 102 BB bb 102 BB bb 102 BB bb 102
+ BB bb 102 BB bb 102 CC aa 102 CC aa 102 CC aa 102 CC aa 102
+ CC bb 102 CC bb 102 DD aa 102 DD aa 102 DD aa 102 DD bb 102
+ DD bb 102 DD bb 102 DD bb 102 EE aa 102 EE aa 102 EE bb 102
+ EE bb 102 EE bb 102 FF aa 102 FF aa 102 FF aa 102 FF aa 102
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 113 GG aa 113 GG aa 113 GG aa 113 GG bb 113 GG bb 113
+ GG bb 113 GG bb 113 HH aa 113 HH aa 113 HH aa 113 HH bb 113
+ HH bb 113 HH bb 113 HH bb 113 HH bb 113 HH bb 113 II aa 113
+ II aa 113 II bb 113 II bb 113 II bb 113 II bb 113 II bb 113
+ JJ aa 113 JJ aa 113 JJ aa 113 JJ aa 113 JJ bb 257 JJ bb 257
+ JJ bb 257 JJ bb 257}
+
+do_execsql_test 1.14.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 AA aa 43826 AA aa 44498 AA aa 44514 AA bb 43867
+ AA bb 44110 AA bb 44165 AA bb 44428 BB aa 39290 BB aa 39392
+ BB aa 39640 BB aa 39653 BB aa 39659 BB aa 39805 BB bb 39212
+ BB bb 39260 BB bb 39266 BB bb 39341 BB bb 39347 BB bb 39419
+ CC aa 31953 CC aa 32105 CC aa 32282 CC aa 32554 CC bb 31890
+ CC bb 32366 DD aa 28745 DD aa 29334 DD aa 29366 DD bb 28631
+ DD bb 28796 DD bb 28874 DD bb 29352 EE aa 24781 EE aa 25445
+ EE bb 24790 EE bb 24929 EE bb 25306 FF aa 22349 FF aa 22352
+ FF aa 22401 FF aa 22811 FF bb 22081 FF bb 22149 FF bb 22293
+ FF bb 22445 FF bb 22724 FF bb 22917 GG aa 16717 GG aa 16871
+ GG aa 17016 GG aa 17203 GG bb 16413 GG bb 16422 GG bb 16507
+ GG bb 17191 HH aa 11904 HH aa 12093 HH aa 12403 HH bb 11920
+ HH bb 12153 HH bb 12200 HH bb 12528 HH bb 12553 HH bb 12750
+ II aa 6788 II aa 7042 II bb 6635 II bb 6769 II bb 6997 II bb 7019
+ II bb 7190 JJ aa 2901 JJ aa 3032 JJ aa 3566 JJ aa 3687 JJ bb 2961
+ JJ bb 3446 JJ bb 3464 JJ bb 3543}
+
+do_execsql_test 1.14.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 AA aa 43826 AA aa 44498 AA aa 44514 AA bb 41560
+ AA bb 41803 AA bb 41858 AA bb 42121 BB aa 39290 BB aa 39392
+ BB aa 39640 BB aa 39653 BB aa 39659 BB aa 39805 BB bb 36339
+ BB bb 36387 BB bb 36393 BB bb 36468 BB bb 36474 BB bb 36546
+ CC aa 31953 CC aa 32105 CC aa 32282 CC aa 32554 CC bb 29936
+ CC bb 30412 DD aa 28745 DD aa 29334 DD aa 29366 DD bb 27306
+ DD bb 27471 DD bb 27549 DD bb 28027 EE aa 24781 EE aa 25445
+ EE bb 23900 EE bb 24039 EE bb 24416 FF aa 22349 FF aa 22352
+ FF aa 22401 FF aa 22811 FF bb 19918 FF bb 19986 FF bb 20130
+ FF bb 20282 FF bb 20561 FF bb 20754 GG aa 16717 GG aa 16871
+ GG aa 17016 GG aa 17203 GG bb 14816 GG bb 14825 GG bb 14910
+ GG bb 15594 HH aa 11904 HH aa 12093 HH aa 12403 HH bb 9671
+ HH bb 9904 HH bb 9951 HH bb 10279 HH bb 10304 HH bb 10501
+ II aa 6788 II aa 7042 II bb 5585 II bb 5719 II bb 5947 II bb 5969
+ II bb 6140 JJ aa 2901 JJ aa 3032 JJ aa 3566 JJ aa 3687 JJ bb 947
+ JJ bb 1432 JJ bb 1450 JJ bb 1529}
+
+do_execsql_test 1.14.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 44737 43803 44737 AA aa 43826 44737 43826 44737
+ AA aa 44498 44737 44498 44737 AA aa 44514 44737 44514 44737
+ AA bb 43867 44737 41560 42430 AA bb 44110 44737 41803 42430
+ AA bb 44165 44737 41858 42430 AA bb 44428 44737 42121 42430
+ BB aa 39290 40052 39290 40052 BB aa 39392 40052 39392 40052
+ BB aa 39640 40052 39640 40052 BB aa 39653 40052 39653 40052
+ BB aa 39659 40052 39659 40052 BB aa 39805 40052 39805 40052
+ BB bb 39212 40052 36339 37179 BB bb 39260 40052 36387 37179
+ BB bb 39266 40052 36393 37179 BB bb 39341 40052 36468 37179
+ BB bb 39347 40052 36474 37179 BB bb 39419 40052 36546 37179
+ CC aa 31953 32712 31953 32712 CC aa 32105 32712 32105 32712
+ CC aa 32282 32712 32282 32712 CC aa 32554 32712 32554 32712
+ CC bb 31890 32712 29936 30758 CC bb 32366 32712 30412 30758
+ DD aa 28745 29590 28745 29590 DD aa 29334 29590 29334 29590
+ DD aa 29366 29590 29366 29590 DD bb 28631 29590 27306 28265
+ DD bb 28796 29590 27471 28265 DD bb 28874 29590 27549 28265
+ DD bb 29352 29590 28027 28265 EE aa 24781 25558 24781 25558
+ EE aa 25445 25558 25445 25558 EE bb 24790 25558 23900 24668
+ EE bb 24929 25558 24039 24668 EE bb 25306 25558 24416 24668
+ FF aa 22349 23019 22349 23019 FF aa 22352 23019 22352 23019
+ FF aa 22401 23019 22401 23019 FF aa 22811 23019 22811 23019
+ FF bb 22081 23019 19918 20856 FF bb 22149 23019 19986 20856
+ FF bb 22293 23019 20130 20856 FF bb 22445 23019 20282 20856
+ FF bb 22724 23019 20561 20856 FF bb 22917 23019 20754 20856
+ GG aa 16717 17351 16717 17351 GG aa 16871 17351 16871 17351
+ GG aa 17016 17351 17016 17351 GG aa 17203 17351 17203 17351
+ GG bb 16413 17351 14816 15754 GG bb 16422 17351 14825 15754
+ GG bb 16507 17351 14910 15754 GG bb 17191 17351 15594 15754
+ HH aa 11904 12883 11904 12883 HH aa 12093 12883 12093 12883
+ HH aa 12403 12883 12403 12883 HH bb 11920 12883 9671 10634
+ HH bb 12153 12883 9904 10634 HH bb 12200 12883 9951 10634
+ HH bb 12528 12883 10279 10634 HH bb 12553 12883 10304 10634
+ HH bb 12750 12883 10501 10634 II aa 6788 7440 6788 7440
+ II aa 7042 7440 7042 7440 II bb 6635 7440 5585 6390
+ II bb 6769 7440 5719 6390 II bb 6997 7440 5947 6390
+ II bb 7019 7440 5969 6390 II bb 7190 7440 6140 6390
+ JJ aa 2901 3800 2901 3800 JJ aa 3032 3800 3032 3800
+ JJ aa 3566 3800 3566 3800 JJ aa 3687 3800 3687 3800
+ JJ bb 2961 3800 947 1786 JJ bb 3446 3800 1432 1786
+ JJ bb 3464 3800 1450 1786 JJ bb 3543 3800 1529 1786}
+
+do_execsql_test 1.15.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 44737 AA aa 44737 AA aa 44737 AA aa 44737 AA bb 44737
+ AA bb 44737 AA bb 44737 AA bb 44737 BB aa 40052 BB aa 40052
+ BB aa 40052 BB aa 40052 BB aa 40052 BB aa 40052 BB bb 40052
+ BB bb 40052 BB bb 40052 BB bb 40052 BB bb 40052 BB bb 40052
+ CC aa 32712 CC aa 32712 CC aa 32712 CC aa 32712 CC bb 32712
+ CC bb 32712 DD aa 29590 DD aa 29590 DD aa 29590 DD bb 29590
+ DD bb 29590 DD bb 29590 DD bb 29590 EE aa 25558 EE aa 25558
+ EE bb 25558 EE bb 25558 EE bb 25558 FF aa 23019 FF aa 23019
+ FF aa 23019 FF aa 23019 FF bb 23019 FF bb 23019 FF bb 23019
+ FF bb 23019 FF bb 23019 FF bb 23019 GG aa 17351 GG aa 17351
+ GG aa 17351 GG aa 17351 GG bb 17351 GG bb 17351 GG bb 17351
+ GG bb 17351 HH aa 12883 HH aa 12883 HH aa 12883 HH bb 12883
+ HH bb 12883 HH bb 12883 HH bb 12883 HH bb 12883 HH bb 12883
+ II aa 7440 II aa 7440 II bb 7440 II bb 7440 II bb 7440 II bb 7440
+ II bb 7440 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ bb 3800
+ JJ bb 3800 JJ bb 3800 JJ bb 3800}
+
+do_execsql_test 1.15.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 44737 AA aa 44737 AA aa 44737 AA aa 44737 AA bb 42430
+ AA bb 42430 AA bb 42430 AA bb 42430 BB aa 40052 BB aa 40052
+ BB aa 40052 BB aa 40052 BB aa 40052 BB aa 40052 BB bb 37179
+ BB bb 37179 BB bb 37179 BB bb 37179 BB bb 37179 BB bb 37179
+ CC aa 32712 CC aa 32712 CC aa 32712 CC aa 32712 CC bb 30758
+ CC bb 30758 DD aa 29590 DD aa 29590 DD aa 29590 DD bb 28265
+ DD bb 28265 DD bb 28265 DD bb 28265 EE aa 25558 EE aa 25558
+ EE bb 24668 EE bb 24668 EE bb 24668 FF aa 23019 FF aa 23019
+ FF aa 23019 FF aa 23019 FF bb 20856 FF bb 20856 FF bb 20856
+ FF bb 20856 FF bb 20856 FF bb 20856 GG aa 17351 GG aa 17351
+ GG aa 17351 GG aa 17351 GG bb 15754 GG bb 15754 GG bb 15754
+ GG bb 15754 HH aa 12883 HH aa 12883 HH aa 12883 HH bb 10634
+ HH bb 10634 HH bb 10634 HH bb 10634 HH bb 10634 HH bb 10634
+ II aa 7440 II aa 7440 II bb 6390 II bb 6390 II bb 6390 II bb 6390
+ II bb 6390 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ bb 1786
+ JJ bb 1786 JJ bb 1786 JJ bb 1786}
+
+do_execsql_test 1.15.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.15.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 979 AA aa 979 AA aa 979 AA aa 979 AA bb 979 AA bb 979
+ AA bb 979 AA bb 979 BB aa 979 BB aa 979 BB aa 979 BB aa 979
+ BB aa 979 BB aa 979 BB bb 979 BB bb 979 BB bb 979 BB bb 979
+ BB bb 979 BB bb 979 CC aa 979 CC aa 979 CC aa 979 CC aa 979
+ CC bb 979 CC bb 979 DD aa 979 DD aa 979 DD aa 979 DD bb 979
+ DD bb 979 DD bb 979 DD bb 979 EE aa 979 EE aa 979 EE bb 979
+ EE bb 979 EE bb 979 FF aa 979 FF aa 979 FF aa 979 FF aa 979
+ FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979
+ GG aa 979 GG aa 979 GG aa 979 GG aa 979 GG bb 979 GG bb 979
+ GG bb 979 GG bb 979 HH aa 979 HH aa 979 HH aa 979 HH bb 963
+ HH bb 963 HH bb 963 HH bb 963 HH bb 963 HH bb 963 II aa 899
+ II aa 899 II bb 899 II bb 899 II bb 899 II bb 899 II bb 899
+ JJ aa 899 JJ aa 899 JJ aa 899 JJ aa 899 JJ bb 839 JJ bb 839
+ JJ bb 839 JJ bb 839}
+
+do_execsql_test 1.15.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 102 AA aa 102 AA aa 102 AA aa 102 AA bb 102 AA bb 102
+ AA bb 102 AA bb 102 BB aa 102 BB aa 102 BB aa 102 BB aa 102
+ BB aa 102 BB aa 102 BB bb 102 BB bb 102 BB bb 102 BB bb 102
+ BB bb 102 BB bb 102 CC aa 102 CC aa 102 CC aa 102 CC aa 102
+ CC bb 102 CC bb 102 DD aa 102 DD aa 102 DD aa 102 DD bb 102
+ DD bb 102 DD bb 102 DD bb 102 EE aa 102 EE aa 102 EE bb 102
+ EE bb 102 EE bb 102 FF aa 102 FF aa 102 FF aa 102 FF aa 102
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 113 GG aa 113 GG aa 113 GG aa 113 GG bb 113 GG bb 113
+ GG bb 113 GG bb 113 HH aa 113 HH aa 113 HH aa 113 HH bb 113
+ HH bb 113 HH bb 113 HH bb 113 HH bb 113 HH bb 113 II aa 113
+ II aa 113 II bb 113 II bb 113 II bb 113 II bb 113 II bb 113
+ JJ aa 113 JJ aa 113 JJ aa 113 JJ aa 113 JJ bb 257 JJ bb 257
+ JJ bb 257 JJ bb 257}
+
+do_execsql_test 1.15.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 AA aa 43826 AA aa 44498 AA aa 44514 AA bb 43867
+ AA bb 44110 AA bb 44165 AA bb 44428 BB aa 39290 BB aa 39392
+ BB aa 39640 BB aa 39653 BB aa 39659 BB aa 39805 BB bb 39212
+ BB bb 39260 BB bb 39266 BB bb 39341 BB bb 39347 BB bb 39419
+ CC aa 31953 CC aa 32105 CC aa 32282 CC aa 32554 CC bb 31890
+ CC bb 32366 DD aa 28745 DD aa 29334 DD aa 29366 DD bb 28631
+ DD bb 28796 DD bb 28874 DD bb 29352 EE aa 24781 EE aa 25445
+ EE bb 24790 EE bb 24929 EE bb 25306 FF aa 22349 FF aa 22352
+ FF aa 22401 FF aa 22811 FF bb 22081 FF bb 22149 FF bb 22293
+ FF bb 22445 FF bb 22724 FF bb 22917 GG aa 16717 GG aa 16871
+ GG aa 17016 GG aa 17203 GG bb 16413 GG bb 16422 GG bb 16507
+ GG bb 17191 HH aa 11904 HH aa 12093 HH aa 12403 HH bb 11920
+ HH bb 12153 HH bb 12200 HH bb 12528 HH bb 12553 HH bb 12750
+ II aa 6788 II aa 7042 II bb 6635 II bb 6769 II bb 6997 II bb 7019
+ II bb 7190 JJ aa 2901 JJ aa 3032 JJ aa 3566 JJ aa 3687 JJ bb 2961
+ JJ bb 3446 JJ bb 3464 JJ bb 3543}
+
+do_execsql_test 1.15.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 AA aa 43826 AA aa 44498 AA aa 44514 AA bb 41560
+ AA bb 41803 AA bb 41858 AA bb 42121 BB aa 39290 BB aa 39392
+ BB aa 39640 BB aa 39653 BB aa 39659 BB aa 39805 BB bb 36339
+ BB bb 36387 BB bb 36393 BB bb 36468 BB bb 36474 BB bb 36546
+ CC aa 31953 CC aa 32105 CC aa 32282 CC aa 32554 CC bb 29936
+ CC bb 30412 DD aa 28745 DD aa 29334 DD aa 29366 DD bb 27306
+ DD bb 27471 DD bb 27549 DD bb 28027 EE aa 24781 EE aa 25445
+ EE bb 23900 EE bb 24039 EE bb 24416 FF aa 22349 FF aa 22352
+ FF aa 22401 FF aa 22811 FF bb 19918 FF bb 19986 FF bb 20130
+ FF bb 20282 FF bb 20561 FF bb 20754 GG aa 16717 GG aa 16871
+ GG aa 17016 GG aa 17203 GG bb 14816 GG bb 14825 GG bb 14910
+ GG bb 15594 HH aa 11904 HH aa 12093 HH aa 12403 HH bb 9671
+ HH bb 9904 HH bb 9951 HH bb 10279 HH bb 10304 HH bb 10501
+ II aa 6788 II aa 7042 II bb 5585 II bb 5719 II bb 5947 II bb 5969
+ II bb 6140 JJ aa 2901 JJ aa 3032 JJ aa 3566 JJ aa 3687 JJ bb 947
+ JJ bb 1432 JJ bb 1450 JJ bb 1529}
+
+do_execsql_test 1.15.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 43803 44737 43803 44737 AA aa 43826 44737 43826 44737
+ AA aa 44498 44737 44498 44737 AA aa 44514 44737 44514 44737
+ AA bb 43867 44737 41560 42430 AA bb 44110 44737 41803 42430
+ AA bb 44165 44737 41858 42430 AA bb 44428 44737 42121 42430
+ BB aa 39290 40052 39290 40052 BB aa 39392 40052 39392 40052
+ BB aa 39640 40052 39640 40052 BB aa 39653 40052 39653 40052
+ BB aa 39659 40052 39659 40052 BB aa 39805 40052 39805 40052
+ BB bb 39212 40052 36339 37179 BB bb 39260 40052 36387 37179
+ BB bb 39266 40052 36393 37179 BB bb 39341 40052 36468 37179
+ BB bb 39347 40052 36474 37179 BB bb 39419 40052 36546 37179
+ CC aa 31953 32712 31953 32712 CC aa 32105 32712 32105 32712
+ CC aa 32282 32712 32282 32712 CC aa 32554 32712 32554 32712
+ CC bb 31890 32712 29936 30758 CC bb 32366 32712 30412 30758
+ DD aa 28745 29590 28745 29590 DD aa 29334 29590 29334 29590
+ DD aa 29366 29590 29366 29590 DD bb 28631 29590 27306 28265
+ DD bb 28796 29590 27471 28265 DD bb 28874 29590 27549 28265
+ DD bb 29352 29590 28027 28265 EE aa 24781 25558 24781 25558
+ EE aa 25445 25558 25445 25558 EE bb 24790 25558 23900 24668
+ EE bb 24929 25558 24039 24668 EE bb 25306 25558 24416 24668
+ FF aa 22349 23019 22349 23019 FF aa 22352 23019 22352 23019
+ FF aa 22401 23019 22401 23019 FF aa 22811 23019 22811 23019
+ FF bb 22081 23019 19918 20856 FF bb 22149 23019 19986 20856
+ FF bb 22293 23019 20130 20856 FF bb 22445 23019 20282 20856
+ FF bb 22724 23019 20561 20856 FF bb 22917 23019 20754 20856
+ GG aa 16717 17351 16717 17351 GG aa 16871 17351 16871 17351
+ GG aa 17016 17351 17016 17351 GG aa 17203 17351 17203 17351
+ GG bb 16413 17351 14816 15754 GG bb 16422 17351 14825 15754
+ GG bb 16507 17351 14910 15754 GG bb 17191 17351 15594 15754
+ HH aa 11904 12883 11904 12883 HH aa 12093 12883 12093 12883
+ HH aa 12403 12883 12403 12883 HH bb 11920 12883 9671 10634
+ HH bb 12153 12883 9904 10634 HH bb 12200 12883 9951 10634
+ HH bb 12528 12883 10279 10634 HH bb 12553 12883 10304 10634
+ HH bb 12750 12883 10501 10634 II aa 6788 7440 6788 7440
+ II aa 7042 7440 7042 7440 II bb 6635 7440 5585 6390
+ II bb 6769 7440 5719 6390 II bb 6997 7440 5947 6390
+ II bb 7019 7440 5969 6390 II bb 7190 7440 6140 6390
+ JJ aa 2901 3800 2901 3800 JJ aa 3032 3800 3032 3800
+ JJ aa 3566 3800 3566 3800 JJ aa 3687 3800 3687 3800
+ JJ bb 2961 3800 947 1786 JJ bb 3446 3800 1432 1786
+ JJ bb 3464 3800 1450 1786 JJ bb 3543 3800 1529 1786}
+
+do_execsql_test 1.16.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 4685 AA aa 4685 AA aa 4685 AA aa 4685 AA bb 4685 AA bb 4685
+ AA bb 4685 AA bb 4685 BB aa 7340 BB aa 7340 BB aa 7340 BB aa 7340
+ BB aa 7340 BB aa 7340 BB bb 7340 BB bb 7340 BB bb 7340 BB bb 7340
+ BB bb 7340 BB bb 7340 CC aa 3122 CC aa 3122 CC aa 3122 CC aa 3122
+ CC bb 3122 CC bb 3122 DD aa 4032 DD aa 4032 DD aa 4032 DD bb 4032
+ DD bb 4032 DD bb 4032 DD bb 4032 EE aa 2539 EE aa 2539 EE bb 2539
+ EE bb 2539 EE bb 2539 FF aa 5668 FF aa 5668 FF aa 5668 FF aa 5668
+ FF bb 5668 FF bb 5668 FF bb 5668 FF bb 5668 FF bb 5668 FF bb 5668
+ GG aa 4468 GG aa 4468 GG aa 4468 GG aa 4468 GG bb 4468 GG bb 4468
+ GG bb 4468 GG bb 4468 HH aa 5443 HH aa 5443 HH aa 5443 HH bb 5443
+ HH bb 5443 HH bb 5443 HH bb 5443 HH bb 5443 HH bb 5443 II aa 3640
+ II aa 3640 II bb 3640 II bb 3640 II bb 3640 II bb 3640 II bb 3640
+ JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ aa 3800 JJ bb 3800 JJ bb 3800
+ JJ bb 3800 JJ bb 3800}
+
+do_execsql_test 1.16.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 2307 AA aa 2307 AA aa 2307 AA aa 2307 AA bb 2378 AA bb 2378
+ AA bb 2378 AA bb 2378 BB aa 2873 BB aa 2873 BB aa 2873 BB aa 2873
+ BB aa 2873 BB aa 2873 BB bb 4467 BB bb 4467 BB bb 4467 BB bb 4467
+ BB bb 4467 BB bb 4467 CC aa 1954 CC aa 1954 CC aa 1954 CC aa 1954
+ CC bb 1168 CC bb 1168 DD aa 1325 DD aa 1325 DD aa 1325 DD bb 2707
+ DD bb 2707 DD bb 2707 DD bb 2707 EE aa 890 EE aa 890 EE bb 1649
+ EE bb 1649 EE bb 1649 FF aa 2163 FF aa 2163 FF aa 2163 FF aa 2163
+ FF bb 3505 FF bb 3505 FF bb 3505 FF bb 3505 FF bb 3505 FF bb 3505
+ GG aa 1597 GG aa 1597 GG aa 1597 GG aa 1597 GG bb 2871 GG bb 2871
+ GG bb 2871 GG bb 2871 HH aa 2249 HH aa 2249 HH aa 2249 HH bb 3194
+ HH bb 3194 HH bb 3194 HH bb 3194 HH bb 3194 HH bb 3194 II aa 1050
+ II aa 1050 II bb 2590 II bb 2590 II bb 2590 II bb 2590 II bb 2590
+ JJ aa 2014 JJ aa 2014 JJ aa 2014 JJ aa 2014 JJ bb 1786 JJ bb 1786
+ JJ bb 1786 JJ bb 1786}
+
+do_execsql_test 1.16.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.16.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 934 AA aa 934 AA aa 934 AA aa 934 AA bb 870 AA bb 870
+ AA bb 870 AA bb 870 BB aa 762 BB aa 762 BB aa 762 BB aa 762
+ BB aa 762 BB aa 762 BB bb 840 BB bb 840 BB bb 840 BB bb 840
+ BB bb 840 BB bb 840 CC aa 759 CC aa 759 CC aa 759 CC aa 759
+ CC bb 822 CC bb 822 DD aa 845 DD aa 845 DD aa 845 DD bb 959
+ DD bb 959 DD bb 959 DD bb 959 EE aa 777 EE aa 777 EE bb 768
+ EE bb 768 EE bb 768 FF aa 670 FF aa 670 FF aa 670 FF aa 670
+ FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938 FF bb 938
+ GG aa 634 GG aa 634 GG aa 634 GG aa 634 GG bb 938 GG bb 938
+ GG bb 938 GG bb 938 HH aa 979 HH aa 979 HH aa 979 HH bb 963
+ HH bb 963 HH bb 963 HH bb 963 HH bb 963 HH bb 963 II aa 652
+ II aa 652 II bb 805 II bb 805 II bb 805 II bb 805 II bb 805
+ JJ aa 899 JJ aa 899 JJ aa 899 JJ aa 899 JJ bb 839 JJ bb 839
+ JJ bb 839 JJ bb 839}
+
+do_execsql_test 1.16.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 223 AA aa 223 AA aa 223 AA aa 223 AA bb 309 AA bb 309
+ AA bb 309 AA bb 309 BB aa 247 BB aa 247 BB aa 247 BB aa 247
+ BB aa 247 BB aa 247 BB bb 633 BB bb 633 BB bb 633 BB bb 633
+ BB bb 633 BB bb 633 CC aa 158 CC aa 158 CC aa 158 CC aa 158
+ CC bb 346 CC bb 346 DD aa 224 DD aa 224 DD aa 224 DD bb 238
+ DD bb 238 DD bb 238 DD bb 238 EE aa 113 EE aa 113 EE bb 252
+ EE bb 252 EE bb 252 FF aa 208 FF aa 208 FF aa 208 FF aa 208
+ FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102 FF bb 102
+ GG aa 148 GG aa 148 GG aa 148 GG aa 148 GG bb 160 GG bb 160
+ GG bb 160 GG bb 160 HH aa 480 HH aa 480 HH aa 480 HH bb 133
+ HH bb 133 HH bb 133 HH bb 133 HH bb 133 HH bb 133 II aa 398
+ II aa 398 II bb 250 II bb 250 II bb 250 II bb 250 II bb 250
+ JJ aa 113 JJ aa 113 JJ aa 113 JJ aa 113 JJ bb 257 JJ bb 257
+ JJ bb 257 JJ bb 257}
+
+do_execsql_test 1.16.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 AA aa 3774 AA aa 4446 AA aa 4462 AA bb 3815 AA bb 4058
+ AA bb 4113 AA bb 4376 BB aa 6578 BB aa 6680 BB aa 6928 BB aa 6941
+ BB aa 6947 BB aa 7093 BB bb 6500 BB bb 6548 BB bb 6554 BB bb 6629
+ BB bb 6635 BB bb 6707 CC aa 2363 CC aa 2515 CC aa 2692 CC aa 2964
+ CC bb 2300 CC bb 2776 DD aa 3187 DD aa 3776 DD aa 3808 DD bb 3073
+ DD bb 3238 DD bb 3316 DD bb 3794 EE aa 1762 EE aa 2426 EE bb 1771
+ EE bb 1910 EE bb 2287 FF aa 4998 FF aa 5001 FF aa 5050 FF aa 5460
+ FF bb 4730 FF bb 4798 FF bb 4942 FF bb 5094 FF bb 5373 FF bb 5566
+ GG aa 3834 GG aa 3988 GG aa 4133 GG aa 4320 GG bb 3530 GG bb 3539
+ GG bb 3624 GG bb 4308 HH aa 4464 HH aa 4653 HH aa 4963 HH bb 4480
+ HH bb 4713 HH bb 4760 HH bb 5088 HH bb 5113 HH bb 5310 II aa 2988
+ II aa 3242 II bb 2835 II bb 2969 II bb 3197 II bb 3219 II bb 3390
+ JJ aa 2901 JJ aa 3032 JJ aa 3566 JJ aa 3687 JJ bb 2961 JJ bb 3446
+ JJ bb 3464 JJ bb 3543}
+
+do_execsql_test 1.16.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1373 AA aa 1396 AA aa 2068 AA aa 2084 AA bb 1508 AA bb 1751
+ AA bb 1806 AA bb 2069 BB aa 2111 BB aa 2213 BB aa 2461 BB aa 2474
+ BB aa 2480 BB aa 2626 BB bb 3627 BB bb 3675 BB bb 3681 BB bb 3756
+ BB bb 3762 BB bb 3834 CC aa 1195 CC aa 1347 CC aa 1524 CC aa 1796
+ CC bb 346 CC bb 822 DD aa 480 DD aa 1069 DD aa 1101 DD bb 1748
+ DD bb 1913 DD bb 1991 DD bb 2469 EE aa 113 EE aa 777 EE bb 881
+ EE bb 1020 EE bb 1397 FF aa 1493 FF aa 1496 FF aa 1545 FF aa 1955
+ FF bb 2567 FF bb 2635 FF bb 2779 FF bb 2931 FF bb 3210 FF bb 3403
+ GG aa 963 GG aa 1117 GG aa 1262 GG aa 1449 GG bb 1933 GG bb 1942
+ GG bb 2027 GG bb 2711 HH aa 1270 HH aa 1459 HH aa 1769 HH bb 2231
+ HH bb 2464 HH bb 2511 HH bb 2839 HH bb 2864 HH bb 3061 II aa 398
+ II aa 652 II bb 1785 II bb 1919 II bb 2147 II bb 2169 II bb 2340
+ JJ aa 1115 JJ aa 1246 JJ aa 1780 JJ aa 1901 JJ bb 947 JJ bb 1432
+ JJ bb 1450 JJ bb 1529}
+
+do_execsql_test 1.16.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 0 FOLLOWING AND 0 FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 3751 4685 1373 2307 AA aa 3774 4685 1396 2307
+ AA aa 4446 4685 2068 2307 AA aa 4462 4685 2084 2307
+ AA bb 3815 4685 1508 2378 AA bb 4058 4685 1751 2378
+ AA bb 4113 4685 1806 2378 AA bb 4376 4685 2069 2378
+ BB aa 6578 7340 2111 2873 BB aa 6680 7340 2213 2873
+ BB aa 6928 7340 2461 2873 BB aa 6941 7340 2474 2873
+ BB aa 6947 7340 2480 2873 BB aa 7093 7340 2626 2873
+ BB bb 6500 7340 3627 4467 BB bb 6548 7340 3675 4467
+ BB bb 6554 7340 3681 4467 BB bb 6629 7340 3756 4467
+ BB bb 6635 7340 3762 4467 BB bb 6707 7340 3834 4467
+ CC aa 2363 3122 1195 1954 CC aa 2515 3122 1347 1954
+ CC aa 2692 3122 1524 1954 CC aa 2964 3122 1796 1954
+ CC bb 2300 3122 346 1168 CC bb 2776 3122 822 1168
+ DD aa 3187 4032 480 1325 DD aa 3776 4032 1069 1325
+ DD aa 3808 4032 1101 1325 DD bb 3073 4032 1748 2707
+ DD bb 3238 4032 1913 2707 DD bb 3316 4032 1991 2707
+ DD bb 3794 4032 2469 2707 EE aa 1762 2539 113 890
+ EE aa 2426 2539 777 890 EE bb 1771 2539 881 1649
+ EE bb 1910 2539 1020 1649 EE bb 2287 2539 1397 1649
+ FF aa 4998 5668 1493 2163 FF aa 5001 5668 1496 2163
+ FF aa 5050 5668 1545 2163 FF aa 5460 5668 1955 2163
+ FF bb 4730 5668 2567 3505 FF bb 4798 5668 2635 3505
+ FF bb 4942 5668 2779 3505 FF bb 5094 5668 2931 3505
+ FF bb 5373 5668 3210 3505 FF bb 5566 5668 3403 3505
+ GG aa 3834 4468 963 1597 GG aa 3988 4468 1117 1597
+ GG aa 4133 4468 1262 1597 GG aa 4320 4468 1449 1597
+ GG bb 3530 4468 1933 2871 GG bb 3539 4468 1942 2871
+ GG bb 3624 4468 2027 2871 GG bb 4308 4468 2711 2871
+ HH aa 4464 5443 1270 2249 HH aa 4653 5443 1459 2249
+ HH aa 4963 5443 1769 2249 HH bb 4480 5443 2231 3194
+ HH bb 4713 5443 2464 3194 HH bb 4760 5443 2511 3194
+ HH bb 5088 5443 2839 3194 HH bb 5113 5443 2864 3194
+ HH bb 5310 5443 3061 3194 II aa 2988 3640 398 1050
+ II aa 3242 3640 652 1050 II bb 2835 3640 1785 2590
+ II bb 2969 3640 1919 2590 II bb 3197 3640 2147 2590
+ II bb 3219 3640 2169 2590 II bb 3390 3640 2340 2590
+ JJ aa 2901 3800 1115 2014 JJ aa 3032 3800 1246 2014
+ JJ aa 3566 3800 1780 2014 JJ aa 3687 3800 1901 2014
+ JJ bb 2961 3800 947 1786 JJ bb 3446 3800 1432 1786
+ JJ bb 3464 3800 1450 1786 JJ bb 3543 3800 1529 1786}
+
+do_execsql_test 1.17.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.17.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.17.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.17.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.17.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.17.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.17.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} AA aa {} AA aa {} AA aa {} AA bb {} AA bb {} AA bb {}
+ AA bb {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {} BB aa {}
+ BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} BB bb {} CC aa {}
+ CC aa {} CC aa {} CC aa {} CC bb {} CC bb {} DD aa {} DD aa {}
+ DD aa {} DD bb {} DD bb {} DD bb {} DD bb {} EE aa {} EE aa {}
+ EE bb {} EE bb {} EE bb {} FF aa {} FF aa {} FF aa {} FF aa {}
+ FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} FF bb {} GG aa {}
+ GG aa {} GG aa {} GG aa {} GG bb {} GG bb {} GG bb {} GG bb {}
+ HH aa {} HH aa {} HH aa {} HH bb {} HH bb {} HH bb {} HH bb {}
+ HH bb {} HH bb {} II aa {} II aa {} II bb {} II bb {} II bb {}
+ II bb {} II bb {} JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {}
+ JJ bb {} JJ bb {} JJ bb {}}
+
+do_execsql_test 1.17.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 0 FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa {} {} {} {} AA aa {} {} {} {} AA aa {} {} {} {}
+ AA aa {} {} {} {} AA bb {} {} {} {} AA bb {} {} {} {}
+ AA bb {} {} {} {} AA bb {} {} {} {} BB aa {} {} {} {}
+ BB aa {} {} {} {} BB aa {} {} {} {} BB aa {} {} {} {}
+ BB aa {} {} {} {} BB aa {} {} {} {} BB bb {} {} {} {}
+ BB bb {} {} {} {} BB bb {} {} {} {} BB bb {} {} {} {}
+ BB bb {} {} {} {} BB bb {} {} {} {} CC aa {} {} {} {}
+ CC aa {} {} {} {} CC aa {} {} {} {} CC aa {} {} {} {}
+ CC bb {} {} {} {} CC bb {} {} {} {} DD aa {} {} {} {}
+ DD aa {} {} {} {} DD aa {} {} {} {} DD bb {} {} {} {}
+ DD bb {} {} {} {} DD bb {} {} {} {} DD bb {} {} {} {}
+ EE aa {} {} {} {} EE aa {} {} {} {} EE bb {} {} {} {}
+ EE bb {} {} {} {} EE bb {} {} {} {} FF aa {} {} {} {}
+ FF aa {} {} {} {} FF aa {} {} {} {} FF aa {} {} {} {}
+ FF bb {} {} {} {} FF bb {} {} {} {} FF bb {} {} {} {}
+ FF bb {} {} {} {} FF bb {} {} {} {} FF bb {} {} {} {}
+ GG aa {} {} {} {} GG aa {} {} {} {} GG aa {} {} {} {}
+ GG aa {} {} {} {} GG bb {} {} {} {} GG bb {} {} {} {}
+ GG bb {} {} {} {} GG bb {} {} {} {} HH aa {} {} {} {}
+ HH aa {} {} {} {} HH aa {} {} {} {} HH bb {} {} {} {}
+ HH bb {} {} {} {} HH bb {} {} {} {} HH bb {} {} {} {}
+ HH bb {} {} {} {} HH bb {} {} {} {} II aa {} {} {} {}
+ II aa {} {} {} {} II bb {} {} {} {} II bb {} {} {} {}
+ II bb {} {} {} {} II bb {} {} {} {} II bb {} {} {} {}
+ JJ aa {} {} {} {} JJ aa {} {} {} {} JJ aa {} {} {} {}
+ JJ aa {} {} {} {} JJ bb {} {} {} {} JJ bb {} {} {} {}
+ JJ bb {} {} {} {} JJ bb {} {} {} {}}
+
+do_execsql_test 1.18.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 22701 AA aa 22701 AA aa 22701 AA aa 22701 AA bb 22701
+ AA bb 22701 AA bb 22701 AA bb 22701 BB aa 19829 BB aa 19829
+ BB aa 19829 BB aa 19829 BB aa 19829 BB aa 19829 BB bb 19829
+ BB bb 19829 BB bb 19829 BB bb 19829 BB bb 19829 BB bb 19829
+ CC aa 22150 CC aa 22150 CC aa 22150 CC aa 22150 CC bb 22150
+ CC bb 22150 DD aa 21758 DD aa 21758 DD aa 21758 DD bb 21758
+ DD bb 21758 DD bb 21758 DD bb 21758 EE aa 23019 EE aa 23019
+ EE bb 23019 EE bb 23019 EE bb 23019 FF aa 17351 FF aa 17351
+ FF aa 17351 FF aa 17351 FF bb 17351 FF bb 17351 FF bb 17351
+ FF bb 17351 FF bb 17351 FF bb 17351 GG aa 12883 GG aa 12883
+ GG aa 12883 GG aa 12883 GG bb 12883 GG bb 12883 GG bb 12883
+ GG bb 12883 HH aa 7440 HH aa 7440 HH aa 7440 HH bb 7440
+ HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 II aa 3800
+ II aa 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800
+ JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {} JJ bb {} JJ bb {}
+ JJ bb {}}
+
+do_execsql_test 1.18.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 12840 AA aa 12840 AA aa 12840 AA aa 12840 AA bb 11787
+ AA bb 11787 AA bb 11787 AA bb 11787 BB aa 11621 BB aa 11621
+ BB aa 11621 BB aa 11621 BB aa 11621 BB aa 11621 BB bb 8044
+ BB bb 8044 BB bb 8044 BB bb 8044 BB bb 8044 BB bb 8044 CC aa 7739
+ CC aa 7739 CC aa 7739 CC aa 7739 CC bb 8734 CC bb 8734
+ DD aa 10914 DD aa 10914 DD aa 10914 DD bb 9804 DD bb 9804
+ DD bb 9804 DD bb 9804 EE aa 11785 EE aa 11785 EE bb 12385
+ EE bb 12385 EE bb 12385 FF aa 13416 FF aa 13416 FF aa 13416
+ FF aa 13416 FF bb 10961 FF bb 10961 FF bb 10961 FF bb 10961
+ FF bb 10961 FF bb 10961 GG aa 11954 GG aa 11954 GG aa 11954
+ GG aa 11954 GG bb 11097 GG bb 11097 GG bb 11097 GG bb 11097
+ HH aa 10634 HH aa 10634 HH aa 10634 HH bb 7440 HH bb 7440
+ HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 II aa 6390 II aa 6390
+ II bb 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800 JJ aa 1786
+ JJ aa 1786 JJ aa 1786 JJ aa 1786 JJ bb {} JJ bb {} JJ bb {}
+ JJ bb {}}
+
+do_execsql_test 1.18.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.18.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 870 AA aa 870 AA aa 870 AA aa 870 AA bb 845 AA bb 845
+ AA bb 845 AA bb 845 BB aa 959 BB aa 959 BB aa 959 BB aa 959
+ BB aa 959 BB aa 959 BB bb 959 BB bb 959 BB bb 959 BB bb 959
+ BB bb 959 BB bb 959 CC aa 959 CC aa 959 CC aa 959 CC aa 959
+ CC bb 959 CC bb 959 DD aa 959 DD aa 959 DD aa 959 DD bb 938
+ DD bb 938 DD bb 938 DD bb 938 EE aa 938 EE aa 938 EE bb 979
+ EE bb 979 EE bb 979 FF aa 979 FF aa 979 FF aa 979 FF aa 979
+ FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979
+ GG aa 979 GG aa 979 GG aa 979 GG aa 979 GG bb 979 GG bb 979
+ GG bb 979 GG bb 979 HH aa 963 HH aa 963 HH aa 963 HH bb 899
+ HH bb 899 HH bb 899 HH bb 899 HH bb 899 HH bb 899 II aa 899
+ II aa 899 II bb 899 II bb 899 II bb 899 II bb 899 II bb 899
+ JJ aa 839 JJ aa 839 JJ aa 839 JJ aa 839 JJ bb {} JJ bb {}
+ JJ bb {} JJ bb {}}
+
+do_execsql_test 1.18.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 158 AA aa 158 AA aa 158 AA aa 158 AA bb 158 AA bb 158
+ AA bb 158 AA bb 158 BB aa 158 BB aa 158 BB aa 158 BB aa 158
+ BB aa 158 BB aa 158 BB bb 113 BB bb 113 BB bb 113 BB bb 113
+ BB bb 113 BB bb 113 CC aa 113 CC aa 113 CC aa 113 CC aa 113
+ CC bb 113 CC bb 113 DD aa 102 DD aa 102 DD aa 102 DD bb 102
+ DD bb 102 DD bb 102 DD bb 102 EE aa 102 EE aa 102 EE bb 102
+ EE bb 102 EE bb 102 FF aa 102 FF aa 102 FF aa 102 FF aa 102
+ FF bb 133 FF bb 133 FF bb 133 FF bb 133 FF bb 133 FF bb 133
+ GG aa 133 GG aa 133 GG aa 133 GG aa 133 GG bb 113 GG bb 113
+ GG bb 113 GG bb 113 HH aa 113 HH aa 113 HH aa 113 HH bb 113
+ HH bb 113 HH bb 113 HH bb 113 HH bb 113 HH bb 113 II aa 113
+ II aa 113 II bb 113 II bb 113 II bb 113 II bb 113 II bb 113
+ JJ aa 257 JJ aa 257 JJ aa 257 JJ aa 257 JJ bb {} JJ bb {}
+ JJ bb {} JJ bb {}}
+
+do_execsql_test 1.18.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 22701 AA aa 22701 AA aa 22701 AA aa 22701 AA bb 22701
+ AA bb 22701 AA bb 22701 AA bb 22701 BB aa 19829 BB aa 19829
+ BB aa 19829 BB aa 19829 BB aa 19829 BB aa 19829 BB bb 19829
+ BB bb 19829 BB bb 19829 BB bb 19829 BB bb 19829 BB bb 19829
+ CC aa 22150 CC aa 22150 CC aa 22150 CC aa 22150 CC bb 22150
+ CC bb 22150 DD aa 21758 DD aa 21758 DD aa 21758 DD bb 21758
+ DD bb 21758 DD bb 21758 DD bb 21758 EE aa 23019 EE aa 23019
+ EE bb 23019 EE bb 23019 EE bb 23019 FF aa 17351 FF aa 17351
+ FF aa 17351 FF aa 17351 FF bb 17351 FF bb 17351 FF bb 17351
+ FF bb 17351 FF bb 17351 FF bb 17351 GG aa 12883 GG aa 12883
+ GG aa 12883 GG aa 12883 GG bb 12883 GG bb 12883 GG bb 12883
+ GG bb 12883 HH aa 7440 HH aa 7440 HH aa 7440 HH bb 7440
+ HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 II aa 3800
+ II aa 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800
+ JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {} JJ bb {} JJ bb {}
+ JJ bb {}}
+
+do_execsql_test 1.18.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 12840 AA aa 12840 AA aa 12840 AA aa 12840 AA bb 11787
+ AA bb 11787 AA bb 11787 AA bb 11787 BB aa 11621 BB aa 11621
+ BB aa 11621 BB aa 11621 BB aa 11621 BB aa 11621 BB bb 8044
+ BB bb 8044 BB bb 8044 BB bb 8044 BB bb 8044 BB bb 8044 CC aa 7739
+ CC aa 7739 CC aa 7739 CC aa 7739 CC bb 8734 CC bb 8734
+ DD aa 10914 DD aa 10914 DD aa 10914 DD bb 9804 DD bb 9804
+ DD bb 9804 DD bb 9804 EE aa 11785 EE aa 11785 EE bb 12385
+ EE bb 12385 EE bb 12385 FF aa 13416 FF aa 13416 FF aa 13416
+ FF aa 13416 FF bb 10961 FF bb 10961 FF bb 10961 FF bb 10961
+ FF bb 10961 FF bb 10961 GG aa 11954 GG aa 11954 GG aa 11954
+ GG aa 11954 GG bb 11097 GG bb 11097 GG bb 11097 GG bb 11097
+ HH aa 10634 HH aa 10634 HH aa 10634 HH bb 7440 HH bb 7440
+ HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 II aa 6390 II aa 6390
+ II bb 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800 JJ aa 1786
+ JJ aa 1786 JJ aa 1786 JJ aa 1786 JJ bb {} JJ bb {} JJ bb {}
+ JJ bb {}}
+
+do_execsql_test 1.18.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND 5 FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 22701 22701 12840 12840 AA aa 22701 22701 12840 12840
+ AA aa 22701 22701 12840 12840 AA aa 22701 22701 12840 12840
+ AA bb 22701 22701 11787 11787 AA bb 22701 22701 11787 11787
+ AA bb 22701 22701 11787 11787 AA bb 22701 22701 11787 11787
+ BB aa 19829 19829 11621 11621 BB aa 19829 19829 11621 11621
+ BB aa 19829 19829 11621 11621 BB aa 19829 19829 11621 11621
+ BB aa 19829 19829 11621 11621 BB aa 19829 19829 11621 11621
+ BB bb 19829 19829 8044 8044 BB bb 19829 19829 8044 8044
+ BB bb 19829 19829 8044 8044 BB bb 19829 19829 8044 8044
+ BB bb 19829 19829 8044 8044 BB bb 19829 19829 8044 8044
+ CC aa 22150 22150 7739 7739 CC aa 22150 22150 7739 7739
+ CC aa 22150 22150 7739 7739 CC aa 22150 22150 7739 7739
+ CC bb 22150 22150 8734 8734 CC bb 22150 22150 8734 8734
+ DD aa 21758 21758 10914 10914 DD aa 21758 21758 10914 10914
+ DD aa 21758 21758 10914 10914 DD bb 21758 21758 9804 9804
+ DD bb 21758 21758 9804 9804 DD bb 21758 21758 9804 9804
+ DD bb 21758 21758 9804 9804 EE aa 23019 23019 11785 11785
+ EE aa 23019 23019 11785 11785 EE bb 23019 23019 12385 12385
+ EE bb 23019 23019 12385 12385 EE bb 23019 23019 12385 12385
+ FF aa 17351 17351 13416 13416 FF aa 17351 17351 13416 13416
+ FF aa 17351 17351 13416 13416 FF aa 17351 17351 13416 13416
+ FF bb 17351 17351 10961 10961 FF bb 17351 17351 10961 10961
+ FF bb 17351 17351 10961 10961 FF bb 17351 17351 10961 10961
+ FF bb 17351 17351 10961 10961 FF bb 17351 17351 10961 10961
+ GG aa 12883 12883 11954 11954 GG aa 12883 12883 11954 11954
+ GG aa 12883 12883 11954 11954 GG aa 12883 12883 11954 11954
+ GG bb 12883 12883 11097 11097 GG bb 12883 12883 11097 11097
+ GG bb 12883 12883 11097 11097 GG bb 12883 12883 11097 11097
+ HH aa 7440 7440 10634 10634 HH aa 7440 7440 10634 10634
+ HH aa 7440 7440 10634 10634 HH bb 7440 7440 7440 7440
+ HH bb 7440 7440 7440 7440 HH bb 7440 7440 7440 7440
+ HH bb 7440 7440 7440 7440 HH bb 7440 7440 7440 7440
+ HH bb 7440 7440 7440 7440 II aa 3800 3800 6390 6390
+ II aa 3800 3800 6390 6390 II bb 3800 3800 3800 3800
+ II bb 3800 3800 3800 3800 II bb 3800 3800 3800 3800
+ II bb 3800 3800 3800 3800 II bb 3800 3800 3800 3800
+ JJ aa {} {} 1786 1786 JJ aa {} {} 1786 1786 JJ aa {} {} 1786 1786
+ JJ aa {} {} 1786 1786 JJ bb {} {} {} {} JJ bb {} {} {} {}
+ JJ bb {} {} {} {} JJ bb {} {} {} {}}
+
+do_execsql_test 1.19.1 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 40052 AA aa 40052 AA aa 40052 AA aa 40052 AA bb 40052
+ AA bb 40052 AA bb 40052 AA bb 40052 BB aa 32712 BB aa 32712
+ BB aa 32712 BB aa 32712 BB aa 32712 BB aa 32712 BB bb 32712
+ BB bb 32712 BB bb 32712 BB bb 32712 BB bb 32712 BB bb 32712
+ CC aa 29590 CC aa 29590 CC aa 29590 CC aa 29590 CC bb 29590
+ CC bb 29590 DD aa 25558 DD aa 25558 DD aa 25558 DD bb 25558
+ DD bb 25558 DD bb 25558 DD bb 25558 EE aa 23019 EE aa 23019
+ EE bb 23019 EE bb 23019 EE bb 23019 FF aa 17351 FF aa 17351
+ FF aa 17351 FF aa 17351 FF bb 17351 FF bb 17351 FF bb 17351
+ FF bb 17351 FF bb 17351 FF bb 17351 GG aa 12883 GG aa 12883
+ GG aa 12883 GG aa 12883 GG bb 12883 GG bb 12883 GG bb 12883
+ GG bb 12883 HH aa 7440 HH aa 7440 HH aa 7440 HH bb 7440
+ HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 II aa 3800
+ II aa 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800
+ JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {} JJ bb {} JJ bb {}
+ JJ bb {}}
+
+do_execsql_test 1.19.2 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 42430 AA aa 42430 AA aa 42430 AA aa 42430 AA bb 40052
+ AA bb 40052 AA bb 40052 AA bb 40052 BB aa 37179 BB aa 37179
+ BB aa 37179 BB aa 37179 BB aa 37179 BB aa 37179 BB bb 32712
+ BB bb 32712 BB bb 32712 BB bb 32712 BB bb 32712 BB bb 32712
+ CC aa 30758 CC aa 30758 CC aa 30758 CC aa 30758 CC bb 29590
+ CC bb 29590 DD aa 28265 DD aa 28265 DD aa 28265 DD bb 25558
+ DD bb 25558 DD bb 25558 DD bb 25558 EE aa 24668 EE aa 24668
+ EE bb 23019 EE bb 23019 EE bb 23019 FF aa 20856 FF aa 20856
+ FF aa 20856 FF aa 20856 FF bb 17351 FF bb 17351 FF bb 17351
+ FF bb 17351 FF bb 17351 FF bb 17351 GG aa 15754 GG aa 15754
+ GG aa 15754 GG aa 15754 GG bb 12883 GG bb 12883 GG bb 12883
+ GG bb 12883 HH aa 10634 HH aa 10634 HH aa 10634 HH bb 7440
+ HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 II aa 6390
+ II aa 6390 II bb 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800
+ JJ aa 1786 JJ aa 1786 JJ aa 1786 JJ aa 1786 JJ bb {} JJ bb {}
+ JJ bb {} JJ bb {}}
+
+do_execsql_test 1.19.3 {
+ SELECT a, b, rank() OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 1 AA aa 1 AA aa 1 AA aa 1 AA bb 1 AA bb 1 AA bb 1
+ AA bb 1 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9 BB aa 9
+ BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 BB bb 9 CC aa 21
+ CC aa 21 CC aa 21 CC aa 21 CC bb 21 CC bb 21 DD aa 27 DD aa 27
+ DD aa 27 DD bb 27 DD bb 27 DD bb 27 DD bb 27 EE aa 34 EE aa 34
+ EE bb 34 EE bb 34 EE bb 34 FF aa 39 FF aa 39 FF aa 39 FF aa 39
+ FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 FF bb 39 GG aa 49
+ GG aa 49 GG aa 49 GG aa 49 GG bb 49 GG bb 49 GG bb 49 GG bb 49
+ HH aa 57 HH aa 57 HH aa 57 HH bb 57 HH bb 57 HH bb 57 HH bb 57
+ HH bb 57 HH bb 57 II aa 66 II aa 66 II bb 66 II bb 66 II bb 66
+ II bb 66 II bb 66 JJ aa 73 JJ aa 73 JJ aa 73 JJ aa 73 JJ bb 73
+ JJ bb 73 JJ bb 73 JJ bb 73}
+
+do_execsql_test 1.19.4 {
+ SELECT a, b, max(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 979 AA aa 979 AA aa 979 AA aa 979 AA bb 979 AA bb 979
+ AA bb 979 AA bb 979 BB aa 979 BB aa 979 BB aa 979 BB aa 979
+ BB aa 979 BB aa 979 BB bb 979 BB bb 979 BB bb 979 BB bb 979
+ BB bb 979 BB bb 979 CC aa 979 CC aa 979 CC aa 979 CC aa 979
+ CC bb 979 CC bb 979 DD aa 979 DD aa 979 DD aa 979 DD bb 979
+ DD bb 979 DD bb 979 DD bb 979 EE aa 979 EE aa 979 EE bb 979
+ EE bb 979 EE bb 979 FF aa 979 FF aa 979 FF aa 979 FF aa 979
+ FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979 FF bb 979
+ GG aa 979 GG aa 979 GG aa 979 GG aa 979 GG bb 979 GG bb 979
+ GG bb 979 GG bb 979 HH aa 963 HH aa 963 HH aa 963 HH bb 899
+ HH bb 899 HH bb 899 HH bb 899 HH bb 899 HH bb 899 II aa 899
+ II aa 899 II bb 899 II bb 899 II bb 899 II bb 899 II bb 899
+ JJ aa 839 JJ aa 839 JJ aa 839 JJ aa 839 JJ bb {} JJ bb {}
+ JJ bb {} JJ bb {}}
+
+do_execsql_test 1.19.5 {
+ SELECT a, b, min(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 102 AA aa 102 AA aa 102 AA aa 102 AA bb 102 AA bb 102
+ AA bb 102 AA bb 102 BB aa 102 BB aa 102 BB aa 102 BB aa 102
+ BB aa 102 BB aa 102 BB bb 102 BB bb 102 BB bb 102 BB bb 102
+ BB bb 102 BB bb 102 CC aa 102 CC aa 102 CC aa 102 CC aa 102
+ CC bb 102 CC bb 102 DD aa 102 DD aa 102 DD aa 102 DD bb 102
+ DD bb 102 DD bb 102 DD bb 102 EE aa 102 EE aa 102 EE bb 102
+ EE bb 102 EE bb 102 FF aa 102 FF aa 102 FF aa 102 FF aa 102
+ FF bb 113 FF bb 113 FF bb 113 FF bb 113 FF bb 113 FF bb 113
+ GG aa 113 GG aa 113 GG aa 113 GG aa 113 GG bb 113 GG bb 113
+ GG bb 113 GG bb 113 HH aa 113 HH aa 113 HH aa 113 HH bb 113
+ HH bb 113 HH bb 113 HH bb 113 HH bb 113 HH bb 113 II aa 113
+ II aa 113 II bb 113 II bb 113 II bb 113 II bb 113 II bb 113
+ JJ aa 257 JJ aa 257 JJ aa 257 JJ aa 257 JJ bb {} JJ bb {}
+ JJ bb {} JJ bb {}}
+
+do_execsql_test 1.19.6 {
+ SELECT a, b, sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 40052 AA aa 40052 AA aa 40052 AA aa 40052 AA bb 40052
+ AA bb 40052 AA bb 40052 AA bb 40052 BB aa 32712 BB aa 32712
+ BB aa 32712 BB aa 32712 BB aa 32712 BB aa 32712 BB bb 32712
+ BB bb 32712 BB bb 32712 BB bb 32712 BB bb 32712 BB bb 32712
+ CC aa 29590 CC aa 29590 CC aa 29590 CC aa 29590 CC bb 29590
+ CC bb 29590 DD aa 25558 DD aa 25558 DD aa 25558 DD bb 25558
+ DD bb 25558 DD bb 25558 DD bb 25558 EE aa 23019 EE aa 23019
+ EE bb 23019 EE bb 23019 EE bb 23019 FF aa 17351 FF aa 17351
+ FF aa 17351 FF aa 17351 FF bb 17351 FF bb 17351 FF bb 17351
+ FF bb 17351 FF bb 17351 FF bb 17351 GG aa 12883 GG aa 12883
+ GG aa 12883 GG aa 12883 GG bb 12883 GG bb 12883 GG bb 12883
+ GG bb 12883 HH aa 7440 HH aa 7440 HH aa 7440 HH bb 7440
+ HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 II aa 3800
+ II aa 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800
+ JJ aa {} JJ aa {} JJ aa {} JJ aa {} JJ bb {} JJ bb {} JJ bb {}
+ JJ bb {}}
+
+do_execsql_test 1.19.7 {
+ SELECT a, b, sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 42430 AA aa 42430 AA aa 42430 AA aa 42430 AA bb 40052
+ AA bb 40052 AA bb 40052 AA bb 40052 BB aa 37179 BB aa 37179
+ BB aa 37179 BB aa 37179 BB aa 37179 BB aa 37179 BB bb 32712
+ BB bb 32712 BB bb 32712 BB bb 32712 BB bb 32712 BB bb 32712
+ CC aa 30758 CC aa 30758 CC aa 30758 CC aa 30758 CC bb 29590
+ CC bb 29590 DD aa 28265 DD aa 28265 DD aa 28265 DD bb 25558
+ DD bb 25558 DD bb 25558 DD bb 25558 EE aa 24668 EE aa 24668
+ EE bb 23019 EE bb 23019 EE bb 23019 FF aa 20856 FF aa 20856
+ FF aa 20856 FF aa 20856 FF bb 17351 FF bb 17351 FF bb 17351
+ FF bb 17351 FF bb 17351 FF bb 17351 GG aa 15754 GG aa 15754
+ GG aa 15754 GG aa 15754 GG bb 12883 GG bb 12883 GG bb 12883
+ GG bb 12883 HH aa 10634 HH aa 10634 HH aa 10634 HH bb 7440
+ HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 HH bb 7440 II aa 6390
+ II aa 6390 II bb 3800 II bb 3800 II bb 3800 II bb 3800 II bb 3800
+ JJ aa 1786 JJ aa 1786 JJ aa 1786 JJ aa 1786 JJ bb {} JJ bb {}
+ JJ bb {} JJ bb {}}
+
+do_execsql_test 1.19.8 {
+ SELECT a, b,
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING ),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW),
+ sum(c) OVER (ORDER BY a,b GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING )
+ FROM t3 ORDER BY 1, 2, 3;
+} {AA aa 40052 40052 42430 42430 AA aa 40052 40052 42430 42430
+ AA aa 40052 40052 42430 42430 AA aa 40052 40052 42430 42430
+ AA bb 40052 40052 40052 40052 AA bb 40052 40052 40052 40052
+ AA bb 40052 40052 40052 40052 AA bb 40052 40052 40052 40052
+ BB aa 32712 32712 37179 37179 BB aa 32712 32712 37179 37179
+ BB aa 32712 32712 37179 37179 BB aa 32712 32712 37179 37179
+ BB aa 32712 32712 37179 37179 BB aa 32712 32712 37179 37179
+ BB bb 32712 32712 32712 32712 BB bb 32712 32712 32712 32712
+ BB bb 32712 32712 32712 32712 BB bb 32712 32712 32712 32712
+ BB bb 32712 32712 32712 32712 BB bb 32712 32712 32712 32712
+ CC aa 29590 29590 30758 30758 CC aa 29590 29590 30758 30758
+ CC aa 29590 29590 30758 30758 CC aa 29590 29590 30758 30758
+ CC bb 29590 29590 29590 29590 CC bb 29590 29590 29590 29590
+ DD aa 25558 25558 28265 28265 DD aa 25558 25558 28265 28265
+ DD aa 25558 25558 28265 28265 DD bb 25558 25558 25558 25558
+ DD bb 25558 25558 25558 25558 DD bb 25558 25558 25558 25558
+ DD bb 25558 25558 25558 25558 EE aa 23019 23019 24668 24668
+ EE aa 23019 23019 24668 24668 EE bb 23019 23019 23019 23019
+ EE bb 23019 23019 23019 23019 EE bb 23019 23019 23019 23019
+ FF aa 17351 17351 20856 20856 FF aa 17351 17351 20856 20856
+ FF aa 17351 17351 20856 20856 FF aa 17351 17351 20856 20856
+ FF bb 17351 17351 17351 17351 FF bb 17351 17351 17351 17351
+ FF bb 17351 17351 17351 17351 FF bb 17351 17351 17351 17351
+ FF bb 17351 17351 17351 17351 FF bb 17351 17351 17351 17351
+ GG aa 12883 12883 15754 15754 GG aa 12883 12883 15754 15754
+ GG aa 12883 12883 15754 15754 GG aa 12883 12883 15754 15754
+ GG bb 12883 12883 12883 12883 GG bb 12883 12883 12883 12883
+ GG bb 12883 12883 12883 12883 GG bb 12883 12883 12883 12883
+ HH aa 7440 7440 10634 10634 HH aa 7440 7440 10634 10634
+ HH aa 7440 7440 10634 10634 HH bb 7440 7440 7440 7440
+ HH bb 7440 7440 7440 7440 HH bb 7440 7440 7440 7440
+ HH bb 7440 7440 7440 7440 HH bb 7440 7440 7440 7440
+ HH bb 7440 7440 7440 7440 II aa 3800 3800 6390 6390
+ II aa 3800 3800 6390 6390 II bb 3800 3800 3800 3800
+ II bb 3800 3800 3800 3800 II bb 3800 3800 3800 3800
+ II bb 3800 3800 3800 3800 II bb 3800 3800 3800 3800
+ JJ aa {} {} 1786 1786 JJ aa {} {} 1786 1786 JJ aa {} {} 1786 1786
+ JJ aa {} {} 1786 1786 JJ bb {} {} {} {} JJ bb {} {} {} {}
+ JJ bb {} {} {} {} JJ bb {} {} {} {}}
+
+do_execsql_test 2.1.1 {
+ SELECT row_number() OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS
+ )
+} {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}
+
+do_execsql_test 2.1.2 {
+ SELECT nth_value(c, 14) OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS
+ )
+} {247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247}
+
+do_execsql_test 2.1.3 {
+ SELECT min(c) OVER win, max(c) OVER win, sum(c) OVER win FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE NO OTHERS
+ ) ORDER BY a, b, c;
+} {102 223 1358 102 239 2293 102 911 38097 102 934 39960 102 309 4159
+ 102 572 10643 102 627 13069 102 870 35417 102 247 2540 102 393 6608
+ 102 399 7405 102 412 7817 102 660 16277 102 762 24077 102 633 14331
+ 102 705 19673 102 711 20384 102 786 27176 102 792 28758
+ 102 840 32858 102 158 767 102 430 8668 102 607 11824 102 759 23315
+ 102 346 5506 102 822 31179 102 224 1582 102 256 3298 102 845 34547
+ 102 238 2054 102 716 21100 102 794 29552 102 959 42795 102 113 215
+ 102 777 26390 102 252 3042 102 629 13698 102 768 25613 102 208 1135
+ 102 618 12442 102 667 16944 102 670 17614 102 102 102 102 295 3850
+ 102 574 11217 102 726 21826 102 870 36287 102 938 40898 102 148 609
+ 102 335 4824 102 480 9591 102 634 14965 102 160 927 102 844 33702
+ 102 929 39026 102 938 41836 102 480 10071 102 790 27966
+ 102 979 44737 102 133 461 102 330 4489 102 355 6215 102 683 18968
+ 102 730 22556 102 963 43758 102 398 7006 102 652 15617 102 250 2790
+ 102 421 8238 102 443 9111 102 671 18285 102 805 30357 102 113 328
+ 102 234 1816 102 768 24845 102 899 37186 102 257 3555 102 336 5160
+ 102 354 5860 102 839 32018}
+
+do_execsql_test 2.2.1 {
+ SELECT row_number() OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW
+ )
+} {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}
+
+do_execsql_test 2.2.2 {
+ SELECT nth_value(c, 14) OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW
+ )
+} {250 250 250 250 250 250 250 250 250 250 250 250 250
+ 250 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247}
+
+do_execsql_test 2.2.3 {
+ SELECT min(c) OVER win, max(c) OVER win, sum(c) OVER win FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW
+ ) ORDER BY a, b, c;
+} {102 208 1135 102 238 2054 102 899 37186 102 929 39026 102 295 3850
+ 102 480 10071 102 618 12442 102 845 34547 102 239 2293 102 355 6215
+ 102 398 7006 102 399 7405 102 652 15617 102 759 23315 102 629 13698
+ 102 683 18968 102 705 19673 102 777 26390 102 790 27966
+ 102 839 32018 102 148 609 102 421 8238 102 574 11217 102 730 22556
+ 102 336 5160 102 805 30357 102 223 1358 102 252 3042 102 844 33702
+ 102 234 1816 102 711 20384 102 792 28758 102 938 41836 102 102 102
+ 102 768 25613 102 250 2790 102 627 13069 102 768 24845 102 160 927
+ 102 607 11824 102 660 16277 102 667 16944 {} {} {} 102 257 3555
+ 102 572 10643 102 716 21100 102 870 35417 102 934 39960 102 133 461
+ 102 330 4489 102 443 9111 102 633 14331 102 158 767 102 840 32858
+ 102 911 38097 102 938 40898 102 480 9591 102 786 27176
+ 102 963 43758 102 113 328 102 309 4159 102 354 5860 102 671 18285
+ 102 726 21826 102 959 42795 102 393 6608 102 634 14965 102 247 2540
+ 102 412 7817 102 430 8668 102 670 17614 102 794 29552 102 113 215
+ 102 224 1582 102 762 24077 102 870 36287 102 256 3298 102 335 4824
+ 102 346 5506 102 822 31179}
+
+do_execsql_test 2.3.1 {
+ SELECT row_number() OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP
+ )
+} {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}
+
+do_execsql_test 2.3.2 {
+ SELECT nth_value(c, 14) OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP
+ )
+} {250 250 250 250 250 250 250 250 250 250 250 250 250
+ 250 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247}
+
+do_execsql_test 2.3.3 {
+ SELECT min(c) OVER win, max(c) OVER win, sum(c) OVER win FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE GROUP
+ ) ORDER BY a, b, c;
+} {102 208 1135 102 238 2054 102 899 37186 102 929 39026 102 295 3850
+ 102 480 10071 102 618 12442 102 845 34547 102 239 2293 102 355 6215
+ 102 398 7006 102 399 7405 102 652 15617 102 759 23315 102 629 13698
+ 102 683 18968 102 705 19673 102 777 26390 102 790 27966
+ 102 839 32018 102 148 609 102 421 8238 102 574 11217 102 730 22556
+ 102 336 5160 102 805 30357 102 223 1358 102 252 3042 102 844 33702
+ 102 234 1816 102 711 20384 102 792 28758 102 938 41836 102 102 102
+ 102 768 25613 102 250 2790 102 627 13069 102 768 24845 102 160 927
+ 102 607 11824 102 660 16277 102 667 16944 {} {} {} 102 257 3555
+ 102 572 10643 102 716 21100 102 870 35417 102 934 39960 102 133 461
+ 102 330 4489 102 443 9111 102 633 14331 102 158 767 102 840 32858
+ 102 911 38097 102 938 40898 102 480 9591 102 786 27176
+ 102 963 43758 102 113 328 102 309 4159 102 354 5860 102 671 18285
+ 102 726 21826 102 959 42795 102 393 6608 102 634 14965 102 247 2540
+ 102 412 7817 102 430 8668 102 670 17614 102 794 29552 102 113 215
+ 102 224 1582 102 762 24077 102 870 36287 102 256 3298 102 335 4824
+ 102 346 5506 102 822 31179}
+
+do_execsql_test 2.4.1 {
+ SELECT row_number() OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES
+ )
+} {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}
+
+do_execsql_test 2.4.2 {
+ SELECT nth_value(c, 14) OVER win
+ FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES
+ )
+} {247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247 247 247 247 247 247 247 247 247 247 247 247
+ 247 247}
+
+do_execsql_test 2.4.3 {
+ SELECT min(c) OVER win, max(c) OVER win, sum(c) OVER win FROM t3
+ WINDOW win AS (
+ ORDER BY c, b, a
+ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES
+ ) ORDER BY a, b, c;
+} {102 223 1358 102 239 2293 102 911 38097 102 934 39960 102 309 4159
+ 102 572 10643 102 627 13069 102 870 35417 102 247 2540 102 393 6608
+ 102 399 7405 102 412 7817 102 660 16277 102 762 24077 102 633 14331
+ 102 705 19673 102 711 20384 102 786 27176 102 792 28758
+ 102 840 32858 102 158 767 102 430 8668 102 607 11824 102 759 23315
+ 102 346 5506 102 822 31179 102 224 1582 102 256 3298 102 845 34547
+ 102 238 2054 102 716 21100 102 794 29552 102 959 42795 102 113 215
+ 102 777 26390 102 252 3042 102 629 13698 102 768 25613 102 208 1135
+ 102 618 12442 102 667 16944 102 670 17614 102 102 102 102 295 3850
+ 102 574 11217 102 726 21826 102 870 36287 102 938 40898 102 148 609
+ 102 335 4824 102 480 9591 102 634 14965 102 160 927 102 844 33702
+ 102 929 39026 102 938 41836 102 480 10071 102 790 27966
+ 102 979 44737 102 133 461 102 330 4489 102 355 6215 102 683 18968
+ 102 730 22556 102 963 43758 102 398 7006 102 652 15617 102 250 2790
+ 102 421 8238 102 443 9111 102 671 18285 102 805 30357 102 113 328
+ 102 234 1816 102 768 24845 102 899 37186 102 257 3555 102 336 5160
+ 102 354 5860 102 839 32018}
+
+#==========================================================================
+
+do_execsql_test 3.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a REAL, b INTEGER);
+ INSERT INTO t1 VALUES
+ (5, 10), (10, 20), (13, 26), (13, 26),
+ (15, 30), (20, 40), (22,80), (30, 90);
+} {}
+
+do_execsql_test 3.1 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 5 PRECEDING AND 5 FOLLOWING )
+} {5 30 10 112 13 102 13 102 15 142 20 150 22 120 30 90}
+
+do_execsql_test 3.2 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 10 PRECEDING AND 5 PRECEDING )
+} {5 {} 10 10 13 10 13 10 15 30 20 102 22 82 30 120}
+
+do_execsql_test 3.3 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING )
+} {5 {} 10 52 13 30 13 30 15 {} 20 80 22 {} 30 {}}
+
+do_execsql_test 3.4 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 5 PRECEDING AND 5 FOLLOWING )
+} {30 90 22 120 20 150 15 142 13 102 13 102 10 112 5 30}
+
+do_execsql_test 3.5 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 10 PRECEDING AND 5 PRECEDING )
+} {30 {} 22 90 20 90 15 120 13 120 13 120 10 70 5 102}
+
+do_execsql_test 3.6 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING )
+} {30 {} 22 40 20 {} 15 52 13 20 13 20 10 {} 5 {}}
+
+do_execsql_test 3.7 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 5.1 PRECEDING AND 5.3 FOLLOWING )
+} {5 30 10 112 13 102 13 102 15 142 20 150 22 120 30 90}
+
+do_execsql_test 3.8 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 10.2 PRECEDING AND 5.4 PRECEDING )
+} {5 {} 10 {} 13 10 13 10 15 10 20 72 22 82 30 120}
+
+do_execsql_test 3.9 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 2.6 FOLLOWING AND 3.5 FOLLOWING )
+} {5 {} 10 52 13 {} 13 {} 15 {} 20 {} 22 {} 30 {}}
+
+do_execsql_test 3.10 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 5.7 PRECEDING AND 5.8 FOLLOWING )
+} {30 90 22 120 20 150 15 142 13 102 13 102 10 112 5 30}
+
+do_execsql_test 3.11 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND 5.9 PRECEDING )
+} {30 {} 22 90 20 90 15 170 13 210 13 210 10 210 5 292}
+
+do_execsql_test 3.12 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 2.1 FOLLOWING AND UNBOUNDED FOLLOWING )
+} {30 232 22 112 20 112 15 30 13 30 13 30 10 10 5 {}}
+
+do_execsql_test 3.13 {
+ SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE 5.1 PRECEDING )
+} {5 10 10 30 13 72 13 72 15 102 20 70 22 120 30 90}
+
+#==========================================================================
+
+do_execsql_test 4.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER);
+ INSERT INTO t1 VALUES
+ (NULL, 1), (NULL, 2), (NULL, 3), (10, 4), (10, 5);
+} {}
+
+do_execsql_test 4.1.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 5 PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1;
+} {6 6 6 9 9}
+
+do_execsql_test 4.1.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 5 PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1;
+} {6 6 6 9 9}
+
+do_execsql_test 4.2.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+} {{} {} 6 6 6}
+
+do_execsql_test 4.2.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+} {6 6 6 {} {}}
+
+do_execsql_test 4.2.3 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+} {{} {} 6 6 6}
+
+do_execsql_test 4.2.4 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+} {6 6 6 {} {}}
+
+do_execsql_test 4.3.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+} {6 6 6 15 15}
+
+do_execsql_test 4.3.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a NULLS LAST RANGE BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+} {9 9 15 15 15}
+
+do_execsql_test 4.4.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a NULLS FIRST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+} {3 6 9 9 12}
+
+do_execsql_test 4.4.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a NULLS LAST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+} {5 6 8 9 10}
+
+do_execsql_test 4.4.3 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC NULLS LAST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS FIRST;
+} {5 6 8 9 10}
+
+do_execsql_test 4.4.4 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC NULLS LAST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+} {5 6 8 9 10}
+
+do_execsql_test 4.5.1 {
+ SELECT sum(b) OVER (
+ ORDER BY a ASC NULLS LAST RANGE BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+} {9 9 15 15 15}
+
+do_execsql_test 4.5.2 {
+ SELECT sum(b) OVER (
+ ORDER BY a DESC NULLS FIRST RANGE
+ BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
+ ) FROM t1 ORDER BY 1 NULLS LAST;
+} {6 6 6 15 15}
+
+#==========================================================================
+
+do_execsql_test 5.0 {
+ INSERT INTO t3 VALUES
+ (NULL, 'bb', 355), (NULL, 'cc', 158), (NULL, 'aa', 399),
+ ('JJ', NULL, 839), ('FF', NULL, 618), ('BB', NULL, 393),
+ (NULL, 'bb', 629), (NULL, NULL, 667), (NULL, NULL, 870);
+} {}
+
+do_execsql_test 5.1.1.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83}
+
+do_execsql_test 5.1.1.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1}
+
+do_execsql_test 5.1.2.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {899 113 9 899 113 9 899 113 9 899 113 9 899 113 9 899 113 9
+ 899 113 9 899 113 9 899 113 9 899 113 16 899 113 16 899 113 16
+ 899 113 16 899 113 16 899 113 16 899 113 16 979 102 44 979 102 44
+ 979 102 44 979 102 44 979 102 44 979 102 44 979 102 44 979 102 44
+ 979 102 44 979 102 44 979 102 44 979 102 49 979 102 49 979 102 49
+ 979 102 49 979 102 49 979 102 56 979 102 56 979 102 56 979 102 56
+ 979 102 56 979 102 56 979 102 56 979 102 62 979 102 62 979 102 62
+ 979 102 62 979 102 62 979 102 62 979 102 75 979 102 75 979 102 75
+ 979 102 75 979 102 75 979 102 75 979 102 75 979 102 75 979 102 75
+ 979 102 75 979 102 75 979 102 75 979 102 75 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 113 25 979 113 25 979 113 25 979 113 25 979 113 25 979 113 25
+ 979 113 25 979 113 25 979 113 25 979 113 33 979 113 33 979 113 33
+ 979 113 33 979 113 33 979 113 33 979 113 33 979 113 33}
+
+do_execsql_test 5.1.2.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {2947 81 11 2947 81 11 2947 81 11 2947 81 11 2947 81 11 2947 81 11
+ 2947 81 11 2947 81 11 2947 81 11 5287 74 10 5287 74 10 5287 74 10
+ 5287 74 10 5287 74 10 5287 74 10 5287 74 10 8400 65 9 8400 65 9
+ 8400 65 9 8400 65 9 8400 65 9 8400 65 9 8400 65 9 8400 65 9
+ 8400 65 9 9664 57 8 9664 57 8 9664 57 8 9664 57 8 9664 57 8
+ 9664 57 8 9664 57 8 9664 57 8 10626 46 7 10626 46 7 10626 46 7
+ 10626 46 7 10626 46 7 10626 46 7 10626 46 7 10626 46 7 10626 46 7
+ 10626 46 7 10626 46 7 12145 41 6 12145 41 6 12145 41 6 12145 41 6
+ 12145 41 6 13949 34 5 13949 34 5 13949 34 5 13949 34 5 13949 34 5
+ 13949 34 5 13949 34 5 15315 28 4 15315 28 4 15315 28 4 15315 28 4
+ 15315 28 4 15315 28 4 18796 15 3 18796 15 3 18796 15 3 18796 15 3
+ 18796 15 3 18796 15 3 18796 15 3 18796 15 3 18796 15 3 18796 15 3
+ 18796 15 3 18796 15 3 18796 15 3 21105 7 2 21105 7 2 21105 7 2
+ 21105 7 2 21105 7 2 21105 7 2 21105 7 2 21105 7 2 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1}
+
+do_execsql_test 5.1.3.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {777 113 5 777 113 5 777 113 5 777 113 5 777 113 5 805 250 7
+ 805 250 7 805 250 7 805 250 7 805 250 7 805 250 7 805 250 7
+ 822 158 6 822 158 6 822 158 6 822 158 6 822 158 6 822 158 6
+ 840 247 13 840 247 13 840 247 13 840 247 13 840 247 13 840 247 13
+ 840 247 13 840 247 13 840 247 13 840 247 13 840 247 13 840 247 13
+ 840 247 13 870 158 0 870 158 0 870 158 0 870 158 0 870 158 0
+ 870 158 0 899 113 9 899 113 9 899 113 9 899 113 9 899 113 9
+ 899 113 9 899 113 9 899 113 9 899 113 9 934 223 8 934 223 8
+ 934 223 8 934 223 8 934 223 8 934 223 8 934 223 8 934 223 8
+ 938 102 11 938 102 11 938 102 11 938 102 11 938 102 11 938 102 11
+ 938 102 11 938 102 11 938 102 11 938 102 11 938 102 11 938 148 8
+ 938 148 8 938 148 8 938 148 8 938 148 8 938 148 8 938 148 8
+ 938 148 8 959 224 7 959 224 7 959 224 7 959 224 7 959 224 7
+ 959 224 7 959 224 7 979 133 9 979 133 9 979 133 9 979 133 9
+ 979 133 9 979 133 9 979 133 9 979 133 9 979 133 9}
+
+do_execsql_test 5.1.3.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {962 1 1 962 1 1 962 1 1 962 1 1 962 1 1 962 1 1 962 1 1
+ 962 1 1 962 1 1 962 1 1 962 1 1 1264 1 1 1264 1 1 1264 1 1
+ 1264 1 1 1264 1 1 1264 1 1 1264 1 1 1264 1 1 1366 1 1 1366 1 1
+ 1366 1 1 1366 1 1 1366 1 1 1366 1 1 1519 1 1 1519 1 1 1519 1 1
+ 1519 1 1 1519 1 1 1804 1 1 1804 1 1 1804 1 1 1804 1 1 1804 1 1
+ 1804 1 1 1804 1 1 2050 1 1 2050 1 1 2050 1 1 2050 1 1 2050 1 1
+ 2050 1 1 2309 1 1 2309 1 1 2309 1 1 2309 1 1 2309 1 1 2309 1 1
+ 2309 1 1 2309 1 1 2340 1 1 2340 1 1 2340 1 1 2340 1 1 2340 1 1
+ 2340 1 1 2340 1 1 2947 1 1 2947 1 1 2947 1 1 2947 1 1 2947 1 1
+ 2947 1 1 2947 1 1 2947 1 1 2947 1 1 3113 1 1 3113 1 1 3113 1 1
+ 3113 1 1 3113 1 1 3113 1 1 3113 1 1 3113 1 1 3113 1 1 3481 1 1
+ 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1
+ 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1}
+
+do_execsql_test 5.1.4.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST GROUPS 6 PRECEDING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {870 158 0 870 158 0 870 158 0 870 158 0 870 158 0 870 158 0
+ 934 158 8 934 158 8 934 158 8 934 158 8 934 158 8 934 158 8
+ 934 158 8 934 158 8 934 158 21 934 158 21 934 158 21 934 158 21
+ 934 158 21 934 158 21 934 158 21 934 158 21 934 158 21 934 158 21
+ 934 158 21 934 158 21 934 158 21 934 158 27 934 158 27 934 158 27
+ 934 158 27 934 158 27 934 158 27 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 102 58 959 102 58 959 102 58 959 102 58
+ 959 102 58 959 102 58 959 102 58 959 102 58 959 113 39 959 113 39
+ 959 113 39 959 113 39 959 113 39 959 158 34 959 158 34 959 158 34
+ 959 158 34 959 158 34 959 158 34 959 158 34 979 102 53 979 102 53
+ 979 102 53 979 102 53 979 102 53 979 102 53 979 102 53 979 102 56
+ 979 102 56 979 102 56 979 102 56 979 102 56 979 102 56 979 102 56
+ 979 102 56 979 102 56 979 102 59 979 102 59 979 102 59 979 102 59
+ 979 102 59 979 102 59 979 102 59 979 102 59 979 102 59}
+
+do_execsql_test 5.1.4.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST GROUPS 6 PRECEDING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {2050 1 1 2050 1 1 2050 1 1 2050 1 1 2050 1 1 2050 1 1 4359 7 2
+ 4359 7 2 4359 7 2 4359 7 2 4359 7 2 4359 7 2 4359 7 2 4359 7 2
+ 7840 15 3 7840 15 3 7840 15 3 7840 15 3 7840 15 3 7840 15 3
+ 7840 15 3 7840 15 3 7840 15 3 7840 15 3 7840 15 3 7840 15 3
+ 7840 15 3 9206 28 4 9206 28 4 9206 28 4 9206 28 4 9206 28 4
+ 9206 28 4 11010 34 5 11010 34 5 11010 34 5 11010 34 5 11010 34 5
+ 11010 34 5 11010 34 5 12368 74 10 12368 74 10 12368 74 10
+ 12368 74 10 12368 74 10 12368 74 10 12368 74 10 12529 41 6
+ 12529 41 6 12529 41 6 12529 41 6 12529 41 6 12705 57 8 12705 57 8
+ 12705 57 8 12705 57 8 12705 57 8 12705 57 8 12705 57 8 12705 57 8
+ 13491 46 7 13491 46 7 13491 46 7 13491 46 7 13491 46 7 13491 46 7
+ 13491 46 7 13491 46 7 13491 46 7 13491 46 7 13491 46 7 13509 65 9
+ 13509 65 9 13509 65 9 13509 65 9 13509 65 9 13509 65 9 13509 65 9
+ 13509 65 9 13509 65 9 13949 81 11 13949 81 11 13949 81 11
+ 13949 81 11 13949 81 11 13949 81 11 13949 81 11 13949 81 11
+ 13949 81 11}
+
+do_execsql_test 5.1.5.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 2 113 113 2 133 133 1 148 148 1 160 158 2
+ 160 158 2 160 158 2 208 208 1 224 223 2 224 223 2 239 234 3
+ 239 234 3 239 234 3 252 247 3 257 247 5 257 247 5 257 250 4
+ 257 252 3 295 295 1 309 309 1 336 330 3 336 330 3 336 330 3
+ 346 346 1 355 354 2 355 354 2 355 354 2 399 393 4 399 393 4
+ 399 393 4 399 393 4 399 393 4 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 2 480 480 2 574 572 2 574 572 2 607 607 1
+ 618 618 2 618 618 2 634 627 4 634 627 4 634 627 4 634 627 4
+ 634 629 3 652 652 1 667 660 2 671 667 3 671 667 3 671 667 3
+ 671 667 3 683 683 1 711 705 2 716 705 3 716 711 2 730 726 2
+ 730 726 2 762 759 2 768 759 4 768 762 3 768 762 3 777 777 1
+ 792 786 3 794 786 4 794 786 4 794 790 3 805 805 1 822 822 1
+ 845 839 5 845 839 5 845 839 5 845 839 5 845 839 5 870 870 2
+ 870 870 2 870 870 2 899 899 1 911 911 1 934 929 2 938 929 4
+ 938 934 3 938 934 3 963 959 2 963 959 2 979 979 1}
+
+do_execsql_test 5.1.5.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 25 23 {} 34 29
+ {} 36 31 {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 43 37 {} 43 37
+ {} 50 42 {} 60 51 {} 61 52 {} 64 55 {} 64 55 {} 67 57 {} 68 58
+ {} 69 59 {} 70 60 {} 72 62 {} 78 67 {} 78 67 {} 78 67 {} 85 72
+ {} 85 72 133 4 3 223 10 8 223 11 9 226 2 2 226 2 2 239 12 10
+ 239 13 11 239 14 12 247 15 13 257 18 16 257 19 17 295 20 18
+ 309 21 19 335 22 20 335 23 21 335 24 22 421 35 30 443 37 32
+ 504 16 14 504 17 15 607 42 36 683 56 47 710 26 24 710 27 25
+ 710 27 25 711 59 50 759 62 53 759 63 54 777 66 56 805 71 61
+ 899 81 68 911 82 69 929 83 70 929 84 71 979 89 75 1334 51 43
+ 1416 57 48 1416 58 49 1584 29 26 1584 29 26 1584 31 27 1584 32 28
+ 1584 32 28 1891 49 41 1922 87 73 1922 88 74 2005 52 44 2005 52 44
+ 2005 54 45 2005 55 46 2518 45 38 2518 46 39 2518 46 39 2518 48 40
+ 2523 73 63 2523 73 63 2523 75 64 2523 76 65 2523 77 66}
+
+do_execsql_test 5.1.6.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 2 113 113 2 133 133 1 148 148 1 158 158 1
+ 158 158 1 160 160 1 208 208 1 223 223 1 224 224 1 234 234 1
+ 238 238 1 239 239 1 247 247 1 250 250 1 252 252 1 256 256 1
+ 257 257 1 295 295 1 309 309 1 330 330 1 335 335 1 336 336 1
+ 346 346 1 354 354 1 355 355 1 355 355 1 393 393 2 393 393 2
+ 398 398 1 399 399 1 399 399 1 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 2 480 480 2 572 572 1 574 574 1 607 607 1
+ 618 618 2 618 618 2 627 627 1 629 629 1 629 629 1 633 633 1
+ 634 634 1 652 652 1 660 660 1 667 667 1 667 667 1 670 670 1
+ 671 671 1 683 683 1 705 705 1 711 711 1 716 716 1 726 726 1
+ 730 730 1 759 759 1 762 762 1 768 768 2 768 768 2 777 777 1
+ 786 786 1 790 790 1 792 792 1 794 794 1 805 805 1 822 822 1
+ 839 839 2 839 839 2 840 840 1 844 844 1 845 845 1 870 870 2
+ 870 870 2 870 870 2 899 899 1 911 911 1 929 929 1 934 934 1
+ 938 938 2 938 938 2 959 959 1 963 963 1 979 979 1}
+
+do_execsql_test 5.1.6.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 11 9 {} 12 10
+ {} 13 11 {} 16 14 {} 17 15 {} 18 16 {} 22 20 {} 24 22 {} 25 23
+ {} 26 24 {} 31 27 {} 34 29 {} 36 31 {} 38 33 {} 38 33 {} 40 34
+ {} 41 35 {} 43 37 {} 43 37 {} 49 41 {} 50 42 {} 51 43 {} 54 45
+ {} 59 50 {} 60 51 {} 61 52 {} 63 54 {} 64 55 {} 64 55 {} 67 57
+ {} 68 58 {} 69 59 {} 70 60 {} 72 62 {} 75 64 {} 76 65 {} 78 67
+ {} 78 67 {} 78 67 {} 84 71 {} 85 72 {} 85 72 133 4 3 223 10 8
+ 226 2 2 226 2 2 239 14 12 247 15 13 257 19 17 295 20 18
+ 309 21 19 335 23 21 421 35 30 443 37 32 607 42 36 627 45 38
+ 633 48 40 671 55 46 683 56 47 705 57 48 710 27 25 710 27 25
+ 711 58 49 759 62 53 777 66 56 786 29 26 786 29 26 798 32 28
+ 798 32 28 805 71 61 845 77 66 899 81 68 911 82 69 929 83 70
+ 959 87 73 963 88 74 979 89 75 1258 46 39 1258 46 39 1334 52 44
+ 1334 52 44 1678 73 63 1678 73 63}
+
+do_execsql_test 5.1.7.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 113 81 979 113 82 979 133 80 979 148 79 979 158 77
+ 979 158 78 979 160 77 979 208 76 979 223 75 979 224 74 979 234 73
+ 979 238 72 979 239 71 979 247 70 979 250 69 979 252 68 979 256 67
+ 979 257 66 979 295 65 979 309 64 979 330 63 979 335 62 979 336 61
+ 979 346 60 979 354 59 979 355 58 979 355 58 979 393 56 979 393 57
+ 979 398 55 979 399 54 979 399 54 979 412 53 979 421 52 979 430 51
+ 979 443 50 979 480 48 979 480 49 979 572 47 979 574 46 979 607 45
+ 979 618 43 979 618 44 979 627 42 979 629 41 979 629 41 979 633 40
+ 979 634 39 979 652 38 979 660 37 979 667 36 979 667 36 979 670 35
+ 979 671 34 979 683 33 979 705 32 979 711 31 979 716 30 979 726 29
+ 979 730 28 979 759 27 979 762 26 979 768 24 979 768 25 979 777 23
+ 979 786 22 979 790 21 979 792 20 979 794 19 979 805 18 979 822 17
+ 979 839 15 979 839 16 979 840 14 979 844 13 979 845 12 979 870 10
+ 979 870 11 979 870 11 979 899 9 979 911 8 979 929 7}
+
+do_execsql_test 5.1.7.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {3830 89 89 4741 88 88 5640 84 84 5640 85 85 5640 86 86 5640 87 87
+ 6485 81 81 6485 82 82 6485 83 83 7324 80 80 8163 78 78 8163 79 79
+ 8968 73 73 8968 74 74 8968 75 75 8968 76 76 8968 77 77 9745 69 69
+ 9745 70 70 9745 71 71 9745 72 72 10504 65 65 10504 66 66
+ 10504 67 67 10504 68 68 11215 64 64 11920 63 63 12603 62 62
+ 13274 60 60 13274 61 61 13941 59 59 14608 55 55 14608 56 56
+ 14608 57 57 14608 58 58 15241 54 54 15870 53 53 16499 52 52
+ 17126 49 49 17126 50 50 17126 51 51 17733 44 44 17733 45 45
+ 17733 46 46 17733 47 47 17733 48 48 18176 42 42 18176 43 43
+ 18597 40 40 18597 41 41 18996 39 39 19395 37 37 19395 38 38
+ 19788 36 36 20181 35 35 20536 34 34 20891 30 30 20891 31 31
+ 20891 32 32 20891 33 33 21226 28 28 21226 29 29 21535 27 27
+ 21830 26 26 22087 22 22 22087 23 23 22087 24 24 22087 25 25
+ 22334 21 21 22573 17 17 22573 18 18 22573 19 19 22573 20 20
+ 22796 11 11 22796 12 12 22796 13 13 22796 14 14 22796 15 15
+ 22796 16 16 22929 10 10 23042 9 9 23155 1 1 23155 2 2 23155 3 3
+ 23155 4 4 23155 5 5 23155 6 6 23155 7 7 23155 8 8}
+
+do_execsql_test 5.1.8.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83}
+
+do_execsql_test 5.1.8.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1}
+
+do_execsql_test 5.1.9.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {870 158 0 870 158 0 870 158 0 870 158 0 870 158 0 870 158 0
+ 899 113 9 899 113 9 899 113 9 899 113 9 899 113 9 899 113 9
+ 899 113 9 899 113 9 899 113 9 899 113 16 899 113 16 899 113 16
+ 899 113 16 899 113 16 899 113 16 899 113 16 979 102 44 979 102 44
+ 979 102 44 979 102 44 979 102 44 979 102 44 979 102 44 979 102 44
+ 979 102 44 979 102 44 979 102 44 979 102 49 979 102 49 979 102 49
+ 979 102 49 979 102 49 979 102 56 979 102 56 979 102 56 979 102 56
+ 979 102 56 979 102 56 979 102 56 979 102 62 979 102 62 979 102 62
+ 979 102 62 979 102 62 979 102 62 979 102 75 979 102 75 979 102 75
+ 979 102 75 979 102 75 979 102 75 979 102 75 979 102 75 979 102 75
+ 979 102 75 979 102 75 979 102 75 979 102 75 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 113 25 979 113 25 979 113 25 979 113 25 979 113 25 979 113 25
+ 979 113 25 979 113 25 979 113 25 979 113 33 979 113 33 979 113 33
+ 979 113 33 979 113 33 979 113 33 979 113 33 979 113 33}
+
+do_execsql_test 5.1.9.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {2050 84 11 2050 84 11 2050 84 11 2050 84 11 2050 84 11 2050 84 11
+ 4997 75 10 4997 75 10 4997 75 10 4997 75 10 4997 75 10 4997 75 10
+ 4997 75 10 4997 75 10 4997 75 10 7337 68 9 7337 68 9 7337 68 9
+ 7337 68 9 7337 68 9 7337 68 9 7337 68 9 10450 59 8 10450 59 8
+ 10450 59 8 10450 59 8 10450 59 8 10450 59 8 10450 59 8 10450 59 8
+ 10450 59 8 11714 51 7 11714 51 7 11714 51 7 11714 51 7 11714 51 7
+ 11714 51 7 11714 51 7 11714 51 7 12676 40 6 12676 40 6 12676 40 6
+ 12676 40 6 12676 40 6 12676 40 6 12676 40 6 12676 40 6 12676 40 6
+ 12676 40 6 12676 40 6 14195 35 5 14195 35 5 14195 35 5 14195 35 5
+ 14195 35 5 15999 28 4 15999 28 4 15999 28 4 15999 28 4 15999 28 4
+ 15999 28 4 15999 28 4 17365 22 3 17365 22 3 17365 22 3 17365 22 3
+ 17365 22 3 17365 22 3 20846 9 2 20846 9 2 20846 9 2 20846 9 2
+ 20846 9 2 20846 9 2 20846 9 2 20846 9 2 20846 9 2 20846 9 2
+ 20846 9 2 20846 9 2 20846 9 2 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1}
+
+do_execsql_test 5.1.10.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {777 113 5 777 113 5 777 113 5 777 113 5 777 113 5 805 250 7
+ 805 250 7 805 250 7 805 250 7 805 250 7 805 250 7 805 250 7
+ 822 158 6 822 158 6 822 158 6 822 158 6 822 158 6 822 158 6
+ 840 247 13 840 247 13 840 247 13 840 247 13 840 247 13 840 247 13
+ 840 247 13 840 247 13 840 247 13 840 247 13 840 247 13 840 247 13
+ 840 247 13 870 158 0 870 158 0 870 158 0 870 158 0 870 158 0
+ 870 158 0 899 113 9 899 113 9 899 113 9 899 113 9 899 113 9
+ 899 113 9 899 113 9 899 113 9 899 113 9 934 223 8 934 223 8
+ 934 223 8 934 223 8 934 223 8 934 223 8 934 223 8 934 223 8
+ 938 102 11 938 102 11 938 102 11 938 102 11 938 102 11 938 102 11
+ 938 102 11 938 102 11 938 102 11 938 102 11 938 102 11 938 148 8
+ 938 148 8 938 148 8 938 148 8 938 148 8 938 148 8 938 148 8
+ 938 148 8 959 224 7 959 224 7 959 224 7 959 224 7 959 224 7
+ 959 224 7 959 224 7 979 133 9 979 133 9 979 133 9 979 133 9
+ 979 133 9 979 133 9 979 133 9 979 133 9 979 133 9}
+
+do_execsql_test 5.1.10.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {962 1 1 962 1 1 962 1 1 962 1 1 962 1 1 962 1 1 962 1 1
+ 962 1 1 962 1 1 962 1 1 962 1 1 1264 1 1 1264 1 1 1264 1 1
+ 1264 1 1 1264 1 1 1264 1 1 1264 1 1 1264 1 1 1366 1 1 1366 1 1
+ 1366 1 1 1366 1 1 1366 1 1 1366 1 1 1519 1 1 1519 1 1 1519 1 1
+ 1519 1 1 1519 1 1 1804 1 1 1804 1 1 1804 1 1 1804 1 1 1804 1 1
+ 1804 1 1 1804 1 1 2050 1 1 2050 1 1 2050 1 1 2050 1 1 2050 1 1
+ 2050 1 1 2309 1 1 2309 1 1 2309 1 1 2309 1 1 2309 1 1 2309 1 1
+ 2309 1 1 2309 1 1 2340 1 1 2340 1 1 2340 1 1 2340 1 1 2340 1 1
+ 2340 1 1 2340 1 1 2947 1 1 2947 1 1 2947 1 1 2947 1 1 2947 1 1
+ 2947 1 1 2947 1 1 2947 1 1 2947 1 1 3113 1 1 3113 1 1 3113 1 1
+ 3113 1 1 3113 1 1 3113 1 1 3113 1 1 3113 1 1 3113 1 1 3481 1 1
+ 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1
+ 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1}
+
+do_execsql_test 5.1.11.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST GROUPS 6 PRECEDING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {934 158 27 934 158 27 934 158 27 934 158 27 934 158 27 934 158 27
+ 934 223 8 934 223 8 934 223 8 934 223 8 934 223 8 934 223 8
+ 934 223 8 934 223 8 934 223 21 934 223 21 934 223 21 934 223 21
+ 934 223 21 934 223 21 934 223 21 934 223 21 934 223 21 934 223 21
+ 934 223 21 934 223 21 934 223 21 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 102 58 959 102 58 959 102 58 959 102 58
+ 959 102 58 959 102 58 959 102 58 959 102 58 959 113 39 959 113 39
+ 959 113 39 959 113 39 959 113 39 959 158 34 959 158 34 959 158 34
+ 959 158 34 959 158 34 959 158 34 959 158 34 979 102 49 979 102 49
+ 979 102 49 979 102 49 979 102 49 979 102 49 979 102 53 979 102 53
+ 979 102 53 979 102 53 979 102 53 979 102 53 979 102 53 979 102 56
+ 979 102 56 979 102 56 979 102 56 979 102 56 979 102 56 979 102 56
+ 979 102 56 979 102 56 979 102 59 979 102 59 979 102 59 979 102 59
+ 979 102 59 979 102 59 979 102 59 979 102 59 979 102 59}
+
+do_execsql_test 5.1.11.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST GROUPS 6 PRECEDING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {2309 1 1 2309 1 1 2309 1 1 2309 1 1 2309 1 1 2309 1 1 2309 1 1
+ 2309 1 1 5790 9 2 5790 9 2 5790 9 2 5790 9 2 5790 9 2 5790 9 2
+ 5790 9 2 5790 9 2 5790 9 2 5790 9 2 5790 9 2 5790 9 2 5790 9 2
+ 7156 22 3 7156 22 3 7156 22 3 7156 22 3 7156 22 3 7156 22 3
+ 8960 28 4 8960 28 4 8960 28 4 8960 28 4 8960 28 4 8960 28 4
+ 8960 28 4 10479 35 5 10479 35 5 10479 35 5 10479 35 5 10479 35 5
+ 11441 40 6 11441 40 6 11441 40 6 11441 40 6 11441 40 6 11441 40 6
+ 11441 40 6 11441 40 6 11441 40 6 11441 40 6 11441 40 6 12368 68 9
+ 12368 68 9 12368 68 9 12368 68 9 12368 68 9 12368 68 9 12368 68 9
+ 12705 51 7 12705 51 7 12705 51 7 12705 51 7 12705 51 7 12705 51 7
+ 12705 51 7 12705 51 7 13509 59 8 13509 59 8 13509 59 8 13509 59 8
+ 13509 59 8 13509 59 8 13509 59 8 13509 59 8 13509 59 8
+ 13949 75 10 13949 75 10 13949 75 10 13949 75 10 13949 75 10
+ 13949 75 10 13949 75 10 13949 75 10 13949 75 10 14195 84 11
+ 14195 84 11 14195 84 11 14195 84 11 14195 84 11 14195 84 11}
+
+do_execsql_test 5.1.12.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 2 113 113 2 133 133 1 148 148 1 160 158 2
+ 160 158 2 160 158 2 208 208 1 224 223 2 224 223 2 239 234 3
+ 239 234 3 239 234 3 252 247 3 257 247 5 257 247 5 257 250 4
+ 257 252 3 295 295 1 309 309 1 336 330 3 336 330 3 336 330 3
+ 346 346 1 355 354 2 355 354 2 355 354 2 399 393 4 399 393 4
+ 399 393 4 399 393 4 399 393 4 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 2 480 480 2 574 572 2 574 572 2 607 607 1
+ 618 618 2 618 618 2 634 627 4 634 627 4 634 627 4 634 627 4
+ 634 629 3 652 652 1 667 660 2 671 667 3 671 667 3 671 667 3
+ 671 667 3 683 683 1 711 705 2 716 705 3 716 711 2 730 726 2
+ 730 726 2 762 759 2 768 759 4 768 762 3 768 762 3 777 777 1
+ 792 786 3 794 786 4 794 786 4 794 790 3 805 805 1 822 822 1
+ 845 839 5 845 839 5 845 839 5 845 839 5 845 839 5 870 870 2
+ 870 870 2 870 870 2 899 899 1 911 911 1 934 929 2 938 929 4
+ 938 934 3 938 934 3 963 959 2 963 959 2 979 979 1}
+
+do_execsql_test 5.1.12.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 25 23 {} 34 29
+ {} 36 31 {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 43 37 {} 43 37
+ {} 50 42 {} 60 51 {} 61 52 {} 64 55 {} 64 55 {} 67 57 {} 68 58
+ {} 69 59 {} 70 60 {} 72 62 {} 78 67 {} 78 67 {} 78 67 {} 85 72
+ {} 85 72 133 4 3 223 10 8 223 11 9 226 2 2 226 2 2 239 12 10
+ 239 13 11 239 14 12 247 15 13 257 18 16 257 19 17 295 20 18
+ 309 21 19 335 22 20 335 23 21 335 24 22 421 35 30 443 37 32
+ 504 16 14 504 17 15 607 42 36 683 56 47 710 26 24 710 27 25
+ 710 27 25 711 59 50 759 62 53 759 63 54 777 66 56 805 71 61
+ 899 81 68 911 82 69 929 83 70 929 84 71 979 89 75 1334 51 43
+ 1416 57 48 1416 58 49 1584 29 26 1584 29 26 1584 31 27 1584 32 28
+ 1584 32 28 1891 49 41 1922 87 73 1922 88 74 2005 52 44 2005 52 44
+ 2005 54 45 2005 55 46 2518 45 38 2518 46 39 2518 46 39 2518 48 40
+ 2523 73 63 2523 73 63 2523 75 64 2523 76 65 2523 77 66}
+
+do_execsql_test 5.1.13.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 2 113 113 2 133 133 1 148 148 1 158 158 1
+ 158 158 1 160 160 1 208 208 1 223 223 1 224 224 1 234 234 1
+ 238 238 1 239 239 1 247 247 1 250 250 1 252 252 1 256 256 1
+ 257 257 1 295 295 1 309 309 1 330 330 1 335 335 1 336 336 1
+ 346 346 1 354 354 1 355 355 1 355 355 1 393 393 2 393 393 2
+ 398 398 1 399 399 1 399 399 1 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 2 480 480 2 572 572 1 574 574 1 607 607 1
+ 618 618 2 618 618 2 627 627 1 629 629 1 629 629 1 633 633 1
+ 634 634 1 652 652 1 660 660 1 667 667 1 667 667 1 670 670 1
+ 671 671 1 683 683 1 705 705 1 711 711 1 716 716 1 726 726 1
+ 730 730 1 759 759 1 762 762 1 768 768 2 768 768 2 777 777 1
+ 786 786 1 790 790 1 792 792 1 794 794 1 805 805 1 822 822 1
+ 839 839 2 839 839 2 840 840 1 844 844 1 845 845 1 870 870 2
+ 870 870 2 870 870 2 899 899 1 911 911 1 929 929 1 934 934 1
+ 938 938 2 938 938 2 959 959 1 963 963 1 979 979 1}
+
+do_execsql_test 5.1.13.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 11 9 {} 12 10
+ {} 13 11 {} 16 14 {} 17 15 {} 18 16 {} 22 20 {} 24 22 {} 25 23
+ {} 26 24 {} 31 27 {} 34 29 {} 36 31 {} 38 33 {} 38 33 {} 40 34
+ {} 41 35 {} 43 37 {} 43 37 {} 49 41 {} 50 42 {} 51 43 {} 54 45
+ {} 59 50 {} 60 51 {} 61 52 {} 63 54 {} 64 55 {} 64 55 {} 67 57
+ {} 68 58 {} 69 59 {} 70 60 {} 72 62 {} 75 64 {} 76 65 {} 78 67
+ {} 78 67 {} 78 67 {} 84 71 {} 85 72 {} 85 72 133 4 3 223 10 8
+ 226 2 2 226 2 2 239 14 12 247 15 13 257 19 17 295 20 18
+ 309 21 19 335 23 21 421 35 30 443 37 32 607 42 36 627 45 38
+ 633 48 40 671 55 46 683 56 47 705 57 48 710 27 25 710 27 25
+ 711 58 49 759 62 53 777 66 56 786 29 26 786 29 26 798 32 28
+ 798 32 28 805 71 61 845 77 66 899 81 68 911 82 69 929 83 70
+ 959 87 73 963 88 74 979 89 75 1258 46 39 1258 46 39 1334 52 44
+ 1334 52 44 1678 73 63 1678 73 63}
+
+do_execsql_test 5.1.14.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 113 81 979 113 82 979 133 80 979 148 79 979 158 77
+ 979 158 78 979 160 77 979 208 76 979 223 75 979 224 74 979 234 73
+ 979 238 72 979 239 71 979 247 70 979 250 69 979 252 68 979 256 67
+ 979 257 66 979 295 65 979 309 64 979 330 63 979 335 62 979 336 61
+ 979 346 60 979 354 59 979 355 57 979 355 58 979 393 56 979 393 57
+ 979 398 55 979 399 53 979 399 54 979 412 53 979 421 52 979 430 51
+ 979 443 50 979 480 48 979 480 49 979 572 47 979 574 46 979 607 45
+ 979 618 43 979 618 44 979 627 42 979 629 40 979 629 41 979 633 40
+ 979 634 39 979 652 38 979 660 37 979 667 35 979 667 36 979 670 35
+ 979 671 34 979 683 33 979 705 32 979 711 31 979 716 30 979 726 29
+ 979 730 28 979 759 27 979 762 26 979 768 24 979 768 25 979 777 23
+ 979 786 22 979 790 21 979 792 20 979 794 19 979 805 18 979 822 17
+ 979 839 15 979 839 16 979 840 14 979 844 13 979 845 12 979 870 9
+ 979 870 10 979 870 11 979 899 9 979 911 8 979 929 7}
+
+do_execsql_test 5.1.14.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {3830 89 89 4741 88 88 5640 84 84 5640 85 85 5640 86 86 5640 87 87
+ 6485 81 81 6485 82 82 6485 83 83 7324 80 80 8163 78 78 8163 79 79
+ 8968 73 73 8968 74 74 8968 75 75 8968 76 76 8968 77 77 9745 69 69
+ 9745 70 70 9745 71 71 9745 72 72 10504 65 65 10504 66 66
+ 10504 67 67 10504 68 68 11215 64 64 11920 63 63 12603 62 62
+ 13274 60 60 13274 61 61 13941 59 59 14608 55 55 14608 56 56
+ 14608 57 57 14608 58 58 15241 54 54 15870 53 53 16499 52 52
+ 17126 49 49 17126 50 50 17126 51 51 17733 44 44 17733 45 45
+ 17733 46 46 17733 47 47 17733 48 48 18176 42 42 18176 43 43
+ 18597 40 40 18597 41 41 18996 39 39 19395 37 37 19395 38 38
+ 19788 36 36 20181 35 35 20536 34 34 20891 30 30 20891 31 31
+ 20891 32 32 20891 33 33 21226 28 28 21226 29 29 21535 27 27
+ 21830 26 26 22087 22 22 22087 23 23 22087 24 24 22087 25 25
+ 22334 21 21 22573 17 17 22573 18 18 22573 19 19 22573 20 20
+ 22796 11 11 22796 12 12 22796 13 13 22796 14 14 22796 15 15
+ 22796 16 16 22929 10 10 23042 9 9 23155 1 1 23155 2 2 23155 3 3
+ 23155 4 4 23155 5 5 23155 6 6 23155 7 7 23155 8 8}
+
+do_execsql_test 5.2.1.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {963 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 113 82}
+
+do_execsql_test 5.2.1.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {22176 1 1 22192 1 1 22196 1 1 22226 1 1 22244 1 1 22256 1 1
+ 22310 1 1 22316 1 1 22316 1 1 22350 1 1 22378 1 1 22396 1 1
+ 22444 1 1 22450 1 1 22472 1 1 22484 1 1 22488 1 1 22488 1 1
+ 22522 1 1 22526 1 1 22526 1 1 22528 1 1 22548 1 1 22712 1 1
+ 22734 1 1 22756 1 1 22756 1 1 22762 1 1 22762 1 1 22800 1 1
+ 22800 1 1 22820 1 1 22846 1 1 22860 1 1 22898 1 1 22908 1 1
+ 22916 1 1 22932 1 1 23022 1 1 23042 1 1 23042 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1}
+
+do_execsql_test 5.2.2.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {839 113 8 899 113 8 899 113 8 899 113 8 899 113 8 899 113 8
+ 899 113 8 899 113 8 899 113 15 899 113 15 899 113 15 899 113 15
+ 899 113 15 899 113 15 899 113 15 899 234 8 963 113 24 979 102 43
+ 979 102 43 979 102 43 979 102 43 979 102 43 979 102 43 979 102 43
+ 979 102 43 979 102 43 979 102 43 979 102 48 979 102 48 979 102 48
+ 979 102 48 979 102 48 979 102 55 979 102 55 979 102 55 979 102 55
+ 979 102 55 979 102 55 979 102 55 979 102 61 979 102 61 979 102 61
+ 979 102 61 979 102 61 979 102 61 979 102 74 979 102 74 979 102 74
+ 979 102 74 979 102 74 979 102 74 979 102 74 979 102 74 979 102 74
+ 979 102 74 979 102 74 979 102 74 979 102 74 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 113 24 979 113 24 979 113 24 979 113 24 979 113 24 979 113 24
+ 979 113 24 979 113 24 979 113 32 979 113 32 979 113 32 979 113 32
+ 979 113 32 979 113 32 979 113 32 979 113 32 979 113 43}
+
+do_execsql_test 5.2.2.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {2048 81 11 2108 81 11 2108 81 11 2690 81 11 2834 81 11 2947 81 11
+ 2947 81 11 2947 81 11 2947 81 11 4482 74 10 4616 74 10 4844 74 10
+ 4866 74 10 5287 74 10 5287 74 10 5287 74 10 7421 65 9 7437 65 9
+ 7717 65 9 8045 65 9 8267 65 9 8400 65 9 8400 65 9 8400 65 9
+ 8400 65 9 8735 57 8 9329 57 8 9664 57 8 9664 57 8 9664 57 8
+ 9664 57 8 9664 57 8 9664 57 8 9959 46 7 10331 46 7 10626 46 7
+ 10626 46 7 10626 46 7 10626 46 7 10626 46 7 10626 46 7 10626 46 7
+ 10626 46 7 10626 46 7 11368 41 6 11516 41 6 12032 41 6 12145 41 6
+ 12145 41 6 12990 34 5 13104 34 5 13949 34 5 13949 34 5 13949 34 5
+ 13949 34 5 13949 34 5 14556 28 4 14708 28 4 15315 28 4 15315 28 4
+ 15315 28 4 15315 28 4 18085 15 3 18091 15 3 18163 15 3 18397 15 3
+ 18403 15 3 18403 15 3 18549 15 3 18796 15 3 18796 15 3 18796 15 3
+ 18796 15 3 18796 15 3 18796 15 3 20194 7 2 20478 7 2 20796 7 2
+ 20866 7 2 20882 7 2 21105 7 2 21105 7 2 21105 7 2 22488 1 1
+ 22526 1 1 22756 1 1 22800 1 1 23155 1 1 23155 1 1}
+
+do_execsql_test 5.2.3.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {667 158 0 671 250 6 759 158 5 768 113 4 777 113 4 777 113 4
+ 777 113 4 777 252 4 792 247 12 805 250 6 805 250 6 805 250 6
+ 805 250 6 805 250 6 805 398 6 822 158 5 822 158 5 822 158 5
+ 822 158 5 822 346 5 839 113 8 840 247 12 840 247 12 840 247 12
+ 840 247 12 840 247 12 840 247 12 840 247 12 840 247 12 840 247 12
+ 840 247 12 840 247 12 840 393 12 845 224 6 870 102 10 870 158 0
+ 870 158 0 870 158 0 870 158 0 870 355 0 899 113 8 899 113 8
+ 899 113 8 899 113 8 899 113 8 899 113 8 899 113 8 899 234 8
+ 911 223 7 929 148 7 934 223 7 934 223 7 934 223 7 934 223 7
+ 934 223 7 934 223 7 934 239 7 938 102 10 938 102 10 938 102 10
+ 938 102 10 938 102 10 938 102 10 938 102 10 938 102 10 938 102 10
+ 938 148 7 938 148 7 938 148 7 938 148 7 938 148 7 938 148 7
+ 938 160 7 938 208 10 959 224 6 959 224 6 959 224 6 959 224 6
+ 959 224 6 959 238 6 963 133 8 979 133 8 979 133 8 979 133 8
+ 979 133 8 979 133 8 979 133 8 979 133 8 979 330 8}
+
+do_execsql_test 5.2.3.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {295 1 1 335 1 1 607 1 1 667 1 1 742 1 1 759 1 1 845 1 1
+ 890 1 1 929 1 1 959 1 1 962 1 1 962 1 1 962 1 1 962 1 1
+ 962 1 1 962 1 1 962 1 1 962 1 1 962 1 1 1264 1 1 1264 1 1
+ 1264 1 1 1264 1 1 1264 1 1 1264 1 1 1366 1 1 1366 1 1 1366 1 1
+ 1366 1 1 1383 1 1 1398 1 1 1406 1 1 1421 1 1 1519 1 1 1519 1 1
+ 1535 1 1 1651 1 1 1669 1 1 1682 1 1 1695 1 1 1804 1 1 1804 1 1
+ 1804 1 1 1804 1 1 1804 1 1 1897 1 1 1919 1 1 2000 1 1 2048 1 1
+ 2050 1 1 2050 1 1 2070 1 1 2086 1 1 2108 1 1 2108 1 1 2134 1 1
+ 2150 1 1 2309 1 1 2309 1 1 2309 1 1 2340 1 1 2340 1 1 2340 1 1
+ 2430 1 1 2690 1 1 2758 1 1 2770 1 1 2776 1 1 2834 1 1 2848 1 1
+ 2947 1 1 2947 1 1 2947 1 1 2947 1 1 2980 1 1 3082 1 1 3088 1 1
+ 3088 1 1 3113 1 1 3113 1 1 3113 1 1 3113 1 1 3234 1 1 3481 1 1
+ 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1}
+
+do_execsql_test 5.2.4.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST GROUPS 6 PRECEDING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {667 158 0 870 158 0 870 158 0 870 158 0 870 158 0 870 355 0
+ 911 158 7 934 158 7 934 158 7 934 158 7 934 158 7 934 158 7
+ 934 158 7 934 158 7 934 158 20 934 158 20 934 158 20 934 158 20
+ 934 158 20 934 158 20 934 158 20 934 158 20 934 158 20 934 158 20
+ 934 158 20 934 158 20 934 158 20 934 158 26 934 158 26 934 158 26
+ 934 158 26 934 158 26 934 158 26 934 158 33 959 102 49 959 102 49
+ 959 102 49 959 102 49 959 102 49 959 102 49 959 102 49 959 102 49
+ 959 102 49 959 102 49 959 102 57 959 102 57 959 102 57 959 102 57
+ 959 102 57 959 102 57 959 102 57 959 102 57 959 113 38 959 113 38
+ 959 113 38 959 113 38 959 113 49 959 158 33 959 158 33 959 158 33
+ 959 158 33 959 158 33 959 158 33 959 158 38 963 102 58 979 102 52
+ 979 102 52 979 102 52 979 102 52 979 102 52 979 102 52 979 102 52
+ 979 102 55 979 102 55 979 102 55 979 102 55 979 102 55 979 102 55
+ 979 102 55 979 102 55 979 102 55 979 102 58 979 102 58 979 102 58
+ 979 102 58 979 102 58 979 102 58 979 102 58 979 102 58}
+
+do_execsql_test 5.2.4.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST GROUPS 6 PRECEDING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {1383 1 1 1421 1 1 1651 1 1 1695 1 1 2050 1 1 2050 1 1 3448 7 2
+ 3732 7 2 4050 7 2 4120 7 2 4136 7 2 4359 7 2 4359 7 2 4359 7 2
+ 7129 15 3 7135 15 3 7207 15 3 7441 15 3 7447 15 3 7447 15 3
+ 7593 15 3 7840 15 3 7840 15 3 7840 15 3 7840 15 3 7840 15 3
+ 7840 15 3 8447 28 4 8599 28 4 9206 28 4 9206 28 4 9206 28 4
+ 9206 28 4 10051 34 5 10165 34 5 11010 34 5 11010 34 5 11010 34 5
+ 11010 34 5 11010 34 5 11563 74 10 11697 74 10 11752 41 6
+ 11776 57 8 11900 41 6 11925 74 10 11947 74 10 12368 74 10
+ 12368 74 10 12368 74 10 12370 57 8 12416 41 6 12529 41 6
+ 12529 41 6 12530 65 9 12546 65 9 12705 57 8 12705 57 8 12705 57 8
+ 12705 57 8 12705 57 8 12705 57 8 12824 46 7 12826 65 9
+ 13050 81 11 13110 81 11 13110 81 11 13154 65 9 13196 46 7
+ 13376 65 9 13491 46 7 13491 46 7 13491 46 7 13491 46 7 13491 46 7
+ 13491 46 7 13491 46 7 13491 46 7 13491 46 7 13509 65 9 13509 65 9
+ 13509 65 9 13509 65 9 13692 81 11 13836 81 11 13949 81 11
+ 13949 81 11 13949 81 11 13949 81 11}
+
+do_execsql_test 5.2.5.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 113 113 1
+ 113 113 1 158 158 1 160 158 1 160 158 2 223 223 1 224 224 1
+ 238 234 2 239 234 2 239 238 2 252 250 2 256 252 2 257 247 4
+ 257 247 4 257 250 3 335 330 2 336 330 2 336 335 2 355 354 1
+ 355 354 2 355 355 1 399 393 3 399 393 3 399 393 3 399 393 3
+ 399 393 4 480 480 1 480 480 1 572 572 1 574 574 1 618 618 1
+ 618 618 1 633 629 2 634 627 3 634 627 3 634 627 4 634 629 3
+ 667 667 1 670 667 2 671 667 2 671 667 2 671 667 3 711 711 1
+ 711 711 1 716 705 2 726 726 1 730 730 1 762 762 1 768 759 3
+ 768 762 2 768 762 2 792 790 2 792 790 2 794 786 3 794 786 3
+ 844 839 4 845 839 4 845 839 4 845 839 4 845 839 4 870 870 1
+ 870 870 1 870 870 2 934 934 1 938 929 3 938 934 2 938 934 2
+ 959 959 1 963 963 1}
+
+do_execsql_test 5.2.5.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 4 3 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 10 8
+ {} 14 12 {} 15 13 {} 19 17 {} 20 18 {} 21 19 {} 23 21 {} 25 23
+ {} 34 29 {} 35 30 {} 36 31 {} 37 32 {} 38 33 {} 38 33 {} 40 34
+ {} 41 35 {} 42 36 {} 43 37 {} 43 37 {} 50 42 {} 56 47 {} 60 51
+ {} 61 52 {} 62 53 {} 64 55 {} 64 55 {} 66 56 {} 67 57 {} 68 58
+ {} 69 59 {} 70 60 {} 71 61 {} 72 62 {} 78 67 {} 78 67 {} 78 67
+ {} 81 68 {} 82 69 {} 83 70 {} 85 72 {} 85 72 {} 89 75 113 2 2
+ 113 2 2 223 11 9 239 12 10 239 13 11 257 18 16 335 22 20
+ 335 24 22 355 27 25 355 27 25 504 16 14 504 17 15 705 58 49
+ 710 26 24 711 57 48 711 59 50 759 63 54 929 84 71 959 88 74
+ 963 87 73 1185 32 28 1185 32 28 1191 29 26 1191 29 26 1334 51 43
+ 1334 55 46 1338 52 44 1338 52 44 1584 31 27 1678 77 66 1684 73 63
+ 1684 73 63 1885 48 40 1889 46 39 1889 46 39 1891 45 38 1891 49 41
+ 2005 54 45 2523 75 64 2523 76 65}
+
+do_execsql_test 5.2.6.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 113 113 1
+ 113 113 1 158 158 0 158 158 1 355 355 0 355 355 1 393 393 1
+ 393 393 1 399 399 0 399 399 1 480 480 1 480 480 1 618 618 1
+ 618 618 1 629 629 0 629 629 1 667 667 0 667 667 1 768 768 1
+ 768 768 1 839 839 1 839 839 1 870 870 1 870 870 1 870 870 2
+ 938 938 1 938 938 1}
+
+do_execsql_test 5.2.6.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 4 3 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 10 8
+ {} 11 9 {} 12 10 {} 13 11 {} 14 12 {} 15 13 {} 16 14 {} 17 15
+ {} 18 16 {} 19 17 {} 20 18 {} 21 19 {} 22 20 {} 23 21 {} 24 22
+ {} 25 23 {} 26 24 {} 31 27 {} 34 29 {} 35 30 {} 36 31 {} 37 32
+ {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 42 36 {} 43 37 {} 43 37
+ {} 45 38 {} 48 40 {} 49 41 {} 50 42 {} 51 43 {} 54 45 {} 55 46
+ {} 56 47 {} 57 48 {} 58 49 {} 59 50 {} 60 51 {} 61 52 {} 62 53
+ {} 63 54 {} 64 55 {} 64 55 {} 66 56 {} 67 57 {} 68 58 {} 69 59
+ {} 70 60 {} 71 61 {} 72 62 {} 75 64 {} 76 65 {} 77 66 {} 78 67
+ {} 78 67 {} 78 67 {} 81 68 {} 82 69 {} 83 70 {} 84 71 {} 85 72
+ {} 85 72 {} 87 73 {} 88 74 {} 89 75 113 2 2 113 2 2 355 27 25
+ 355 27 25 393 29 26 393 29 26 399 32 28 399 32 28 629 46 39
+ 629 46 39 667 52 44 667 52 44 839 73 63 839 73 63}
+
+do_execsql_test 5.2.7.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {963 929 6 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 83 979 113 80 979 113 81 979 113 82 979 133 79 979 148 78
+ 979 158 76 979 158 77 979 160 76 979 208 75 979 223 74 979 224 73
+ 979 234 72 979 238 71 979 239 70 979 247 69 979 250 68 979 252 67
+ 979 256 66 979 257 65 979 295 64 979 309 64 979 330 62 979 335 61
+ 979 336 60 979 346 59 979 354 59 979 355 57 979 355 57 979 393 55
+ 979 393 56 979 398 54 979 399 53 979 399 53 979 412 52 979 421 51
+ 979 430 50 979 443 49 979 480 47 979 480 48 979 572 47 979 574 45
+ 979 607 44 979 618 42 979 618 43 979 627 41 979 629 40 979 629 41
+ 979 633 39 979 634 38 979 652 37 979 660 36 979 667 35 979 667 35
+ 979 670 34 979 671 33 979 683 32 979 705 31 979 711 30 979 716 29
+ 979 726 28 979 730 27 979 759 26 979 762 25 979 768 23 979 768 24
+ 979 777 22 979 786 21 979 790 20 979 792 19 979 794 18 979 805 17
+ 979 822 17 979 839 14 979 839 15 979 840 13 979 844 12 979 845 11
+ 979 870 9 979 870 10 979 870 10 979 899 8 979 911 7}
+
+do_execsql_test 5.2.7.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {2851 89 89 3778 88 88 4681 87 87 5556 83 83 5574 82 82 5586 81 81
+ 5640 84 84 5640 85 85 5640 86 86 7324 80 80 8123 77 77 8129 73 73
+ 8129 74 74 8163 78 78 8163 79 79 8940 71 71 8968 75 75 8968 76 76
+ 9727 66 66 9745 69 69 9745 70 70 9745 72 72 10504 65 65
+ 10504 67 67 10504 68 68 11215 64 64 11844 62 62 11920 63 63
+ 13274 60 60 13274 61 61 13897 58 58 13903 57 57 13925 56 56
+ 13937 55 55 13941 59 59 15203 53 53 15241 54 54 15832 52 52
+ 17100 48 48 17104 46 46 17104 47 47 17106 45 45 17126 49 49
+ 17126 50 50 17126 51 51 17569 42 42 17733 44 44 18176 43 43
+ 18597 40 40 18597 41 41 18952 37 37 18996 39 39 19395 38 38
+ 19760 35 35 19788 36 36 20492 32 32 20492 33 33 20498 30 30
+ 20536 34 34 20833 29 29 20871 28 28 20891 31 31 21180 27 27
+ 21752 23 23 21830 26 26 22025 21 21 22087 22 22 22087 24 24
+ 22087 25 25 22278 20 20 22316 19 19 22549 15 15 22557 14 14
+ 22573 17 17 22573 18 18 22706 10 10 22796 11 11 22796 12 12
+ 22796 13 13 22796 16 16 23022 4 4 23042 2 2 23042 3 3 23042 9 9
+ 23155 1 1 23155 5 5 23155 6 6 23155 7 7 23155 8 8}
+
+do_execsql_test 5.2.8.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {963 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 113 82}
+
+do_execsql_test 5.2.8.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {22176 1 1 22192 1 1 22196 1 1 22226 1 1 22244 1 1 22256 1 1
+ 22310 1 1 22316 1 1 22316 1 1 22350 1 1 22378 1 1 22396 1 1
+ 22444 1 1 22450 1 1 22472 1 1 22484 1 1 22488 1 1 22488 1 1
+ 22522 1 1 22526 1 1 22526 1 1 22528 1 1 22548 1 1 22712 1 1
+ 22734 1 1 22756 1 1 22756 1 1 22762 1 1 22762 1 1 22800 1 1
+ 22800 1 1 22820 1 1 22846 1 1 22860 1 1 22898 1 1 22908 1 1
+ 22916 1 1 22932 1 1 23022 1 1 23042 1 1 23042 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1
+ 23155 1 1 23155 1 1 23155 1 1 23155 1 1 23155 1 1}
+
+do_execsql_test 5.2.9.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {667 158 0 870 113 8 870 158 0 870 158 0 870 158 0 870 158 0
+ 870 355 0 899 113 8 899 113 8 899 113 8 899 113 8 899 113 8
+ 899 113 8 899 113 8 899 113 15 899 113 15 899 113 15 899 113 15
+ 899 113 15 899 113 15 899 113 15 899 158 8 963 113 24 979 102 43
+ 979 102 43 979 102 43 979 102 43 979 102 43 979 102 43 979 102 43
+ 979 102 43 979 102 43 979 102 43 979 102 48 979 102 48 979 102 48
+ 979 102 48 979 102 48 979 102 55 979 102 55 979 102 55 979 102 55
+ 979 102 55 979 102 55 979 102 55 979 102 61 979 102 61 979 102 61
+ 979 102 61 979 102 61 979 102 61 979 102 74 979 102 74 979 102 74
+ 979 102 74 979 102 74 979 102 74 979 102 74 979 102 74 979 102 74
+ 979 102 74 979 102 74 979 102 74 979 102 74 979 102 82 979 102 82
+ 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 113 24 979 113 24 979 113 24 979 113 24 979 113 24 979 113 24
+ 979 113 24 979 113 24 979 113 32 979 113 32 979 113 32 979 113 32
+ 979 113 32 979 113 32 979 113 32 979 113 32 979 113 43}
+
+do_execsql_test 5.2.9.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {1383 84 11 1421 84 11 1651 84 11 1695 84 11 2050 84 11 2050 84 11
+ 4098 75 10 4158 75 10 4158 75 10 4740 75 10 4884 75 10 4997 75 10
+ 4997 75 10 4997 75 10 4997 75 10 6532 68 9 6666 68 9 6894 68 9
+ 6916 68 9 7337 68 9 7337 68 9 7337 68 9 9471 59 8 9487 59 8
+ 9767 59 8 10095 59 8 10317 59 8 10450 59 8 10450 59 8 10450 59 8
+ 10450 59 8 10785 51 7 11379 51 7 11714 51 7 11714 51 7 11714 51 7
+ 11714 51 7 11714 51 7 11714 51 7 12009 40 6 12381 40 6 12676 40 6
+ 12676 40 6 12676 40 6 12676 40 6 12676 40 6 12676 40 6 12676 40 6
+ 12676 40 6 12676 40 6 13418 35 5 13566 35 5 14082 35 5 14195 35 5
+ 14195 35 5 15040 28 4 15154 28 4 15999 28 4 15999 28 4 15999 28 4
+ 15999 28 4 15999 28 4 16606 22 3 16758 22 3 17365 22 3 17365 22 3
+ 17365 22 3 17365 22 3 20135 9 2 20141 9 2 20213 9 2 20447 9 2
+ 20453 9 2 20453 9 2 20599 9 2 20846 9 2 20846 9 2 20846 9 2
+ 20846 9 2 20846 9 2 20846 9 2 22244 1 1 22528 1 1 22846 1 1
+ 22916 1 1 22932 1 1 23155 1 1 23155 1 1 23155 1 1}
+
+do_execsql_test 5.2.10.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {667 158 0 671 250 6 759 158 5 768 113 4 777 113 4 777 113 4
+ 777 113 4 777 252 4 792 247 12 805 250 6 805 250 6 805 250 6
+ 805 250 6 805 250 6 805 398 6 822 158 5 822 158 5 822 158 5
+ 822 158 5 822 346 5 839 113 8 840 247 12 840 247 12 840 247 12
+ 840 247 12 840 247 12 840 247 12 840 247 12 840 247 12 840 247 12
+ 840 247 12 840 247 12 840 393 12 845 224 6 870 102 10 870 158 0
+ 870 158 0 870 158 0 870 158 0 870 355 0 899 113 8 899 113 8
+ 899 113 8 899 113 8 899 113 8 899 113 8 899 113 8 899 234 8
+ 911 223 7 929 148 7 934 223 7 934 223 7 934 223 7 934 223 7
+ 934 223 7 934 223 7 934 239 7 938 102 10 938 102 10 938 102 10
+ 938 102 10 938 102 10 938 102 10 938 102 10 938 102 10 938 102 10
+ 938 148 7 938 148 7 938 148 7 938 148 7 938 148 7 938 148 7
+ 938 160 7 938 208 10 959 224 6 959 224 6 959 224 6 959 224 6
+ 959 224 6 959 238 6 963 133 8 979 133 8 979 133 8 979 133 8
+ 979 133 8 979 133 8 979 133 8 979 133 8 979 330 8}
+
+do_execsql_test 5.2.10.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {295 1 1 335 1 1 607 1 1 667 1 1 742 1 1 759 1 1 845 1 1
+ 890 1 1 929 1 1 959 1 1 962 1 1 962 1 1 962 1 1 962 1 1
+ 962 1 1 962 1 1 962 1 1 962 1 1 962 1 1 1264 1 1 1264 1 1
+ 1264 1 1 1264 1 1 1264 1 1 1264 1 1 1366 1 1 1366 1 1 1366 1 1
+ 1366 1 1 1383 1 1 1398 1 1 1406 1 1 1421 1 1 1519 1 1 1519 1 1
+ 1535 1 1 1651 1 1 1669 1 1 1682 1 1 1695 1 1 1804 1 1 1804 1 1
+ 1804 1 1 1804 1 1 1804 1 1 1897 1 1 1919 1 1 2000 1 1 2048 1 1
+ 2050 1 1 2050 1 1 2070 1 1 2086 1 1 2108 1 1 2108 1 1 2134 1 1
+ 2150 1 1 2309 1 1 2309 1 1 2309 1 1 2340 1 1 2340 1 1 2340 1 1
+ 2430 1 1 2690 1 1 2758 1 1 2770 1 1 2776 1 1 2834 1 1 2848 1 1
+ 2947 1 1 2947 1 1 2947 1 1 2947 1 1 2980 1 1 3082 1 1 3088 1 1
+ 3088 1 1 3113 1 1 3113 1 1 3113 1 1 3113 1 1 3234 1 1 3481 1 1
+ 3481 1 1 3481 1 1 3481 1 1 3481 1 1 3481 1 1}
+
+do_execsql_test 5.2.11.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST GROUPS 6 PRECEDING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {911 223 7 934 158 26 934 158 26 934 158 26 934 158 26 934 158 26
+ 934 158 33 934 223 7 934 223 7 934 223 7 934 223 7 934 223 7
+ 934 223 7 934 223 20 934 223 20 934 223 20 934 223 20 934 223 20
+ 934 223 20 934 223 20 934 223 20 934 223 20 934 223 20 934 223 20
+ 934 223 20 934 223 20 934 223 26 934 239 7 959 102 49 959 102 49
+ 959 102 49 959 102 49 959 102 49 959 102 49 959 102 49 959 102 49
+ 959 102 49 959 102 49 959 102 57 959 102 57 959 102 57 959 102 57
+ 959 102 57 959 102 57 959 102 57 959 102 57 959 113 38 959 113 38
+ 959 113 38 959 113 38 959 113 49 959 158 33 959 158 33 959 158 33
+ 959 158 33 959 158 33 959 158 33 959 158 38 963 102 58 979 102 49
+ 979 102 49 979 102 49 979 102 49 979 102 49 979 102 49 979 102 52
+ 979 102 52 979 102 52 979 102 52 979 102 52 979 102 52 979 102 52
+ 979 102 55 979 102 55 979 102 55 979 102 55 979 102 55 979 102 55
+ 979 102 55 979 102 55 979 102 55 979 102 58 979 102 58 979 102 58
+ 979 102 58 979 102 58 979 102 58 979 102 58 979 102 58}
+
+do_execsql_test 5.2.11.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST GROUPS 6 PRECEDING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {1398 1 1 1682 1 1 2000 1 1 2070 1 1 2086 1 1 2309 1 1 2309 1 1
+ 2309 1 1 5079 9 2 5085 9 2 5157 9 2 5391 9 2 5397 9 2 5397 9 2
+ 5543 9 2 5790 9 2 5790 9 2 5790 9 2 5790 9 2 5790 9 2 5790 9 2
+ 6397 22 3 6549 22 3 7156 22 3 7156 22 3 7156 22 3 7156 22 3
+ 8001 28 4 8115 28 4 8960 28 4 8960 28 4 8960 28 4 8960 28 4
+ 8960 28 4 9702 35 5 9850 35 5 10366 35 5 10479 35 5 10479 35 5
+ 10774 40 6 11146 40 6 11441 40 6 11441 40 6 11441 40 6 11441 40 6
+ 11441 40 6 11441 40 6 11441 40 6 11441 40 6 11441 40 6 11563 68 9
+ 11697 68 9 11776 51 7 11925 68 9 11947 68 9 12368 68 9 12368 68 9
+ 12368 68 9 12370 51 7 12530 59 8 12546 59 8 12705 51 7 12705 51 7
+ 12705 51 7 12705 51 7 12705 51 7 12705 51 7 12826 59 8
+ 13050 75 10 13110 75 10 13110 75 10 13154 59 8 13376 59 8
+ 13509 59 8 13509 59 8 13509 59 8 13509 59 8 13528 84 11
+ 13566 84 11 13692 75 10 13796 84 11 13836 75 10 13840 84 11
+ 13949 75 10 13949 75 10 13949 75 10 13949 75 10 14195 84 11
+ 14195 84 11}
+
+do_execsql_test 5.2.12.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 113 113 1
+ 113 113 1 158 158 1 160 158 1 160 158 2 223 223 1 224 224 1
+ 238 234 2 239 234 2 239 238 2 252 250 2 256 252 2 257 247 4
+ 257 247 4 257 250 3 335 330 2 336 330 2 336 335 2 355 354 1
+ 355 354 2 355 355 1 399 393 3 399 393 3 399 393 3 399 393 3
+ 399 393 4 480 480 1 480 480 1 572 572 1 574 574 1 618 618 1
+ 618 618 1 633 629 2 634 627 3 634 627 3 634 627 4 634 629 3
+ 667 667 1 670 667 2 671 667 2 671 667 2 671 667 3 711 711 1
+ 711 711 1 716 705 2 726 726 1 730 730 1 762 762 1 768 759 3
+ 768 762 2 768 762 2 792 790 2 792 790 2 794 786 3 794 786 3
+ 844 839 4 845 839 4 845 839 4 845 839 4 845 839 4 870 870 1
+ 870 870 1 870 870 2 934 934 1 938 929 3 938 934 2 938 934 2
+ 959 959 1 963 963 1}
+
+do_execsql_test 5.2.12.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 4 3 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 10 8
+ {} 14 12 {} 15 13 {} 19 17 {} 20 18 {} 21 19 {} 23 21 {} 25 23
+ {} 34 29 {} 35 30 {} 36 31 {} 37 32 {} 38 33 {} 38 33 {} 40 34
+ {} 41 35 {} 42 36 {} 43 37 {} 43 37 {} 50 42 {} 56 47 {} 60 51
+ {} 61 52 {} 62 53 {} 64 55 {} 64 55 {} 66 56 {} 67 57 {} 68 58
+ {} 69 59 {} 70 60 {} 71 61 {} 72 62 {} 78 67 {} 78 67 {} 78 67
+ {} 81 68 {} 82 69 {} 83 70 {} 85 72 {} 85 72 {} 89 75 113 2 2
+ 113 2 2 223 11 9 239 12 10 239 13 11 257 18 16 335 22 20
+ 335 24 22 355 27 25 355 27 25 504 16 14 504 17 15 705 58 49
+ 710 26 24 711 57 48 711 59 50 759 63 54 929 84 71 959 88 74
+ 963 87 73 1185 32 28 1185 32 28 1191 29 26 1191 29 26 1334 51 43
+ 1334 55 46 1338 52 44 1338 52 44 1584 31 27 1678 77 66 1684 73 63
+ 1684 73 63 1885 48 40 1889 46 39 1889 46 39 1891 45 38 1891 49 41
+ 2005 54 45 2523 75 64 2523 76 65}
+
+do_execsql_test 5.2.13.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 113 113 1
+ 113 113 1 158 158 0 158 158 1 355 355 0 355 355 1 393 393 1
+ 393 393 1 399 399 0 399 399 1 480 480 1 480 480 1 618 618 1
+ 618 618 1 629 629 0 629 629 1 667 667 0 667 667 1 768 768 1
+ 768 768 1 839 839 1 839 839 1 870 870 1 870 870 1 870 870 2
+ 938 938 1 938 938 1}
+
+do_execsql_test 5.2.13.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 4 3 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 10 8
+ {} 11 9 {} 12 10 {} 13 11 {} 14 12 {} 15 13 {} 16 14 {} 17 15
+ {} 18 16 {} 19 17 {} 20 18 {} 21 19 {} 22 20 {} 23 21 {} 24 22
+ {} 25 23 {} 26 24 {} 31 27 {} 34 29 {} 35 30 {} 36 31 {} 37 32
+ {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 42 36 {} 43 37 {} 43 37
+ {} 45 38 {} 48 40 {} 49 41 {} 50 42 {} 51 43 {} 54 45 {} 55 46
+ {} 56 47 {} 57 48 {} 58 49 {} 59 50 {} 60 51 {} 61 52 {} 62 53
+ {} 63 54 {} 64 55 {} 64 55 {} 66 56 {} 67 57 {} 68 58 {} 69 59
+ {} 70 60 {} 71 61 {} 72 62 {} 75 64 {} 76 65 {} 77 66 {} 78 67
+ {} 78 67 {} 78 67 {} 81 68 {} 82 69 {} 83 70 {} 84 71 {} 85 72
+ {} 85 72 {} 87 73 {} 88 74 {} 89 75 113 2 2 113 2 2 355 27 25
+ 355 27 25 393 29 26 393 29 26 399 32 28 399 32 28 629 46 39
+ 629 46 39 667 52 44 667 52 44 839 73 63 839 73 63}
+
+do_execsql_test 5.2.14.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {963 929 6 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 83 979 113 80 979 113 81 979 113 82 979 133 79 979 148 78
+ 979 158 76 979 158 77 979 160 76 979 208 75 979 223 74 979 224 73
+ 979 234 72 979 238 71 979 239 70 979 247 69 979 250 68 979 252 67
+ 979 256 66 979 257 65 979 295 64 979 309 63 979 330 63 979 335 61
+ 979 336 60 979 346 59 979 354 58 979 355 56 979 355 58 979 393 55
+ 979 393 56 979 398 54 979 399 52 979 399 53 979 412 52 979 421 51
+ 979 430 50 979 443 49 979 480 47 979 480 48 979 572 46 979 574 46
+ 979 607 44 979 618 42 979 618 43 979 627 41 979 629 40 979 629 40
+ 979 633 39 979 634 38 979 652 37 979 660 36 979 667 34 979 667 35
+ 979 670 34 979 671 33 979 683 32 979 705 31 979 711 30 979 716 29
+ 979 726 28 979 730 27 979 759 26 979 762 25 979 768 23 979 768 24
+ 979 777 22 979 786 21 979 790 20 979 792 19 979 794 18 979 805 17
+ 979 822 16 979 839 15 979 839 15 979 840 13 979 844 12 979 845 11
+ 979 870 8 979 870 9 979 870 10 979 899 8 979 911 7}
+
+do_execsql_test 5.2.14.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {2851 89 89 3778 88 88 4681 87 87 5556 83 83 5574 82 82 5586 81 81
+ 5640 84 84 5640 85 85 5640 86 86 7324 80 80 8123 77 77 8129 73 73
+ 8129 74 74 8163 78 78 8163 79 79 8940 71 71 8968 75 75 8968 76 76
+ 9727 66 66 9745 69 69 9745 70 70 9745 72 72 10504 65 65
+ 10504 67 67 10504 68 68 11215 64 64 11844 62 62 11920 63 63
+ 13274 60 60 13274 61 61 13897 58 58 13903 57 57 13925 56 56
+ 13937 55 55 13941 59 59 15203 53 53 15241 54 54 15832 52 52
+ 17100 48 48 17104 46 46 17104 47 47 17106 45 45 17126 49 49
+ 17126 50 50 17126 51 51 17569 42 42 17733 44 44 18176 43 43
+ 18597 40 40 18597 41 41 18952 37 37 18996 39 39 19395 38 38
+ 19760 35 35 19788 36 36 20492 32 32 20492 33 33 20498 30 30
+ 20536 34 34 20833 29 29 20871 28 28 20891 31 31 21180 27 27
+ 21752 23 23 21830 26 26 22025 21 21 22087 22 22 22087 24 24
+ 22087 25 25 22278 20 20 22316 19 19 22549 15 15 22557 14 14
+ 22573 17 17 22573 18 18 22706 10 10 22796 11 11 22796 12 12
+ 22796 13 13 22796 16 16 23022 4 4 23042 2 2 23042 3 3 23042 9 9
+ 23155 1 1 23155 5 5 23155 6 6 23155 7 7 23155 8 8}
+
+do_execsql_test 5.3.1.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0}
+
+do_execsql_test 5.3.1.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1}
+
+do_execsql_test 5.3.2.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 899 113 9 899 113 9 899 113 9 899 113 9
+ 899 113 9 899 113 9 899 113 9 899 113 16 899 113 16 899 113 16
+ 899 113 16 899 113 16 899 113 16 899 113 16 899 113 16 899 113 16
+ 979 102 44 979 102 44 979 102 44 979 102 44 979 102 44 979 102 49
+ 979 102 49 979 102 49 979 102 49 979 102 49 979 102 49 979 102 49
+ 979 102 56 979 102 56 979 102 56 979 102 56 979 102 56 979 102 56
+ 979 102 62 979 102 62 979 102 62 979 102 62 979 102 62 979 102 62
+ 979 102 62 979 102 62 979 102 62 979 102 62 979 102 62 979 102 62
+ 979 102 62 979 102 75 979 102 75 979 102 75 979 102 75 979 102 75
+ 979 102 75 979 102 75 979 102 75 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 113 25 979 113 25 979 113 25
+ 979 113 25 979 113 25 979 113 25 979 113 25 979 113 25 979 113 33
+ 979 113 33 979 113 33 979 113 33 979 113 33 979 113 33 979 113 33
+ 979 113 33 979 113 33 979 113 33 979 113 33}
+
+do_execsql_test 5.3.2.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 81 11 {} 81 11 {} 81 11 {} 81 11 {} 81 11 {} 81 11 {} 81 11
+ {} 81 11 {} 81 11 2947 74 10 2947 74 10 2947 74 10 2947 74 10
+ 2947 74 10 2947 74 10 2947 74 10 5287 65 9 5287 65 9 5287 65 9
+ 5287 65 9 5287 65 9 5287 65 9 5287 65 9 5287 65 9 5287 65 9
+ 8400 57 8 8400 57 8 8400 57 8 8400 57 8 8400 57 8 8400 57 8
+ 8400 57 8 8400 57 8 9664 46 7 9664 46 7 9664 46 7 9664 46 7
+ 9664 46 7 9664 46 7 9664 46 7 9664 46 7 9664 46 7 9664 46 7
+ 9664 46 7 10626 41 6 10626 41 6 10626 41 6 10626 41 6 10626 41 6
+ 12145 34 5 12145 34 5 12145 34 5 12145 34 5 12145 34 5 12145 34 5
+ 12145 34 5 13949 28 4 13949 28 4 13949 28 4 13949 28 4 13949 28 4
+ 13949 28 4 15315 15 3 15315 15 3 15315 15 3 15315 15 3 15315 15 3
+ 15315 15 3 15315 15 3 15315 15 3 15315 15 3 15315 15 3 15315 15 3
+ 15315 15 3 15315 15 3 18796 7 2 18796 7 2 18796 7 2 18796 7 2
+ 18796 7 2 18796 7 2 18796 7 2 18796 7 2 21105 1 1 21105 1 1
+ 21105 1 1 21105 1 1 21105 1 1 21105 1 1}
+
+do_execsql_test 5.3.3.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0}
+
+do_execsql_test 5.3.3.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1}
+
+do_execsql_test 5.3.4.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST GROUPS 6 PRECEDING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 870 158 0
+ 870 158 0 870 158 0 870 158 0 870 158 0 870 158 0 870 158 0
+ 870 158 0 934 158 8 934 158 8 934 158 8 934 158 8 934 158 8
+ 934 158 8 934 158 8 934 158 8 934 158 8 934 158 8 934 158 8
+ 934 158 8 934 158 8 934 158 21 934 158 21 934 158 21 934 158 21
+ 934 158 21 934 158 21 934 158 27 934 158 27 934 158 27 934 158 27
+ 934 158 27 934 158 27 934 158 27 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 113 39 959 113 39 959 113 39 959 113 39
+ 959 113 39 959 113 39 959 113 39 959 113 39 959 113 39 959 113 39
+ 959 113 39 959 158 34 959 158 34 959 158 34 959 158 34 959 158 34
+ 979 102 46 979 102 46 979 102 46 979 102 46 979 102 46 979 102 46
+ 979 102 46 979 102 47 979 102 47 979 102 47 979 102 47 979 102 47
+ 979 102 47 979 102 47 979 102 47 979 102 47}
+
+do_execsql_test 5.3.4.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST GROUPS 6 PRECEDING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 2050 7 2 2050 7 2
+ 2050 7 2 2050 7 2 2050 7 2 2050 7 2 2050 7 2 2050 7 2 4359 15 3
+ 4359 15 3 4359 15 3 4359 15 3 4359 15 3 4359 15 3 4359 15 3
+ 4359 15 3 4359 15 3 4359 15 3 4359 15 3 4359 15 3 4359 15 3
+ 7840 28 4 7840 28 4 7840 28 4 7840 28 4 7840 28 4 7840 28 4
+ 9206 34 5 9206 34 5 9206 34 5 9206 34 5 9206 34 5 9206 34 5
+ 9206 34 5 10028 74 10 10028 74 10 10028 74 10 10028 74 10
+ 10028 74 10 10028 74 10 10028 74 10 10396 65 9 10396 65 9
+ 10396 65 9 10396 65 9 10396 65 9 10396 65 9 10396 65 9 10396 65 9
+ 10396 65 9 11002 81 11 11002 81 11 11002 81 11 11002 81 11
+ 11002 81 11 11002 81 11 11002 81 11 11002 81 11 11002 81 11
+ 11010 41 6 11010 41 6 11010 41 6 11010 41 6 11010 41 6 11441 57 8
+ 11441 57 8 11441 57 8 11441 57 8 11441 57 8 11441 57 8 11441 57 8
+ 11441 57 8 12529 46 7 12529 46 7 12529 46 7 12529 46 7 12529 46 7
+ 12529 46 7 12529 46 7 12529 46 7 12529 46 7 12529 46 7 12529 46 7}
+
+do_execsql_test 5.3.5.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 158 158 1 160 160 1 160 160 1 223 223 1 224 224 1
+ 238 234 2 239 234 2 239 238 2 252 250 2 256 252 2 257 247 4
+ 257 247 4 257 250 3 335 330 2 336 330 2 336 335 2 354 354 1
+ 354 354 1 355 355 1 398 393 3 398 393 3 399 393 3 399 398 2
+ 399 398 2 572 572 1 574 574 1 633 629 2 634 627 3 634 627 3
+ 634 627 3 634 629 3 667 667 1 670 667 2 671 667 2 671 670 2
+ 671 670 2 711 711 1 711 711 1 716 705 2 726 726 1 730 730 1
+ 762 762 1 762 762 1 762 762 1 768 759 3 792 790 2 792 790 2
+ 794 786 3 794 786 3 844 839 4 845 839 4 845 839 4 845 840 3
+ 845 840 3 934 934 1 934 934 1 934 934 1 938 929 3 959 959 1
+ 963 963 1}
+
+do_execsql_test 5.3.5.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 2 2 {} 2 2 {} 4 3 {} 5 4 {} 6 5 {} 6 5 {} 8 6
+ {} 9 7 {} 10 8 {} 14 12 {} 15 13 {} 19 17 {} 20 18 {} 21 19
+ {} 23 21 {} 25 23 {} 27 25 {} 27 25 {} 34 29 {} 35 30 {} 36 31
+ {} 37 32 {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 42 36 {} 43 37
+ {} 43 37 {} 50 42 {} 56 47 {} 60 51 {} 61 52 {} 62 53 {} 64 55
+ {} 64 55 {} 66 56 {} 67 57 {} 68 58 {} 69 59 {} 70 60 {} 71 61
+ {} 72 62 {} 78 67 {} 78 67 {} 78 67 {} 81 68 {} 82 69 {} 83 70
+ {} 85 72 {} 85 72 {} 89 75 223 11 9 239 12 10 239 13 11
+ 257 18 16 335 22 20 335 24 22 504 16 14 504 17 15 671 52 44
+ 671 52 44 705 58 49 710 26 24 711 57 48 711 59 50 759 63 54
+ 786 32 28 786 32 28 798 29 26 798 29 26 845 73 63 845 73 63
+ 929 84 71 959 88 74 963 87 73 1260 46 39 1260 46 39 1334 51 43
+ 1334 55 46 1584 31 27 1678 77 66 1885 48 40 1891 45 38 1891 49 41
+ 2005 54 45 2523 75 64 2523 76 65}
+
+do_execsql_test 5.3.6.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0}
+
+do_execsql_test 5.3.6.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 2 2 {} 2 2 {} 4 3 {} 5 4 {} 6 5 {} 6 5 {} 8 6
+ {} 9 7 {} 10 8 {} 11 9 {} 12 10 {} 13 11 {} 14 12 {} 15 13
+ {} 16 14 {} 17 15 {} 18 16 {} 19 17 {} 20 18 {} 21 19 {} 22 20
+ {} 23 21 {} 24 22 {} 25 23 {} 26 24 {} 27 25 {} 27 25 {} 29 26
+ {} 29 26 {} 31 27 {} 32 28 {} 32 28 {} 34 29 {} 35 30 {} 36 31
+ {} 37 32 {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 42 36 {} 43 37
+ {} 43 37 {} 45 38 {} 46 39 {} 46 39 {} 48 40 {} 49 41 {} 50 42
+ {} 51 43 {} 52 44 {} 52 44 {} 54 45 {} 55 46 {} 56 47 {} 57 48
+ {} 58 49 {} 59 50 {} 60 51 {} 61 52 {} 62 53 {} 63 54 {} 64 55
+ {} 64 55 {} 66 56 {} 67 57 {} 68 58 {} 69 59 {} 70 60 {} 71 61
+ {} 72 62 {} 73 63 {} 73 63 {} 75 64 {} 76 65 {} 77 66 {} 78 67
+ {} 78 67 {} 78 67 {} 81 68 {} 82 69 {} 83 70 {} 84 71 {} 85 72
+ {} 85 72 {} 87 73 {} 88 74 {} 89 75}
+
+do_execsql_test 5.3.7.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {963 929 6 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 83 979 113 80 979 113 81 979 113 82 979 133 79 979 148 78
+ 979 158 76 979 158 77 979 160 76 979 208 75 979 223 74 979 224 73
+ 979 234 72 979 238 71 979 239 70 979 247 69 979 250 68 979 252 67
+ 979 256 66 979 257 65 979 295 64 979 309 64 979 330 62 979 335 61
+ 979 336 60 979 346 59 979 354 59 979 355 57 979 355 57 979 393 55
+ 979 393 56 979 398 54 979 399 53 979 399 53 979 412 52 979 421 51
+ 979 430 50 979 443 49 979 480 47 979 480 48 979 572 47 979 574 45
+ 979 607 44 979 618 42 979 618 43 979 627 41 979 629 40 979 629 41
+ 979 633 39 979 634 38 979 652 37 979 660 36 979 667 35 979 667 35
+ 979 670 34 979 671 33 979 683 32 979 705 31 979 711 30 979 716 29
+ 979 726 28 979 730 27 979 759 26 979 762 25 979 768 23 979 768 24
+ 979 777 22 979 786 21 979 790 20 979 792 19 979 794 18 979 805 17
+ 979 822 17 979 839 14 979 839 15 979 840 13 979 844 12 979 845 11
+ 979 870 9 979 870 10 979 870 10 979 899 8 979 911 7}
+
+do_execsql_test 5.3.7.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {2851 89 89 3778 88 88 4681 87 87 5556 83 83 5574 82 82 5586 81 81
+ 5640 84 84 5640 85 85 5640 86 86 7324 80 80 8123 77 77 8129 73 73
+ 8129 74 74 8163 78 78 8163 79 79 8940 71 71 8968 75 75 8968 76 76
+ 9727 66 66 9745 69 69 9745 70 70 9745 72 72 10504 65 65
+ 10504 67 67 10504 68 68 11215 64 64 11844 62 62 11920 63 63
+ 13274 60 60 13274 61 61 13897 58 58 13903 57 57 13925 56 56
+ 13937 55 55 13941 59 59 15203 53 53 15241 54 54 15832 52 52
+ 17100 48 48 17104 46 46 17104 47 47 17106 45 45 17126 49 49
+ 17126 50 50 17126 51 51 17569 42 42 17733 44 44 18176 43 43
+ 18597 40 40 18597 41 41 18952 37 37 18996 39 39 19395 38 38
+ 19760 35 35 19788 36 36 20492 32 32 20492 33 33 20498 30 30
+ 20536 34 34 20833 29 29 20871 28 28 20891 31 31 21180 27 27
+ 21752 23 23 21830 26 26 22025 21 21 22087 22 22 22087 24 24
+ 22087 25 25 22278 20 20 22316 19 19 22549 15 15 22557 14 14
+ 22573 17 17 22573 18 18 22706 10 10 22796 11 11 22796 12 12
+ 22796 13 13 22796 16 16 23022 4 4 23042 2 2 23042 3 3 23042 9 9
+ 23155 1 1 23155 5 5 23155 6 6 23155 7 7 23155 8 8}
+
+do_execsql_test 5.3.8.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0}
+
+do_execsql_test 5.3.8.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1}
+
+do_execsql_test 5.3.9.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 870 158 0
+ 870 158 0 870 158 0 870 158 0 870 158 0 870 158 0 870 158 0
+ 870 158 0 870 158 0 899 113 9 899 113 9 899 113 9 899 113 9
+ 899 113 9 899 113 9 899 113 9 899 113 16 899 113 16 899 113 16
+ 899 113 16 899 113 16 899 113 16 899 113 16 899 113 16 899 113 16
+ 979 102 44 979 102 44 979 102 44 979 102 44 979 102 44 979 102 49
+ 979 102 49 979 102 49 979 102 49 979 102 49 979 102 49 979 102 49
+ 979 102 56 979 102 56 979 102 56 979 102 56 979 102 56 979 102 56
+ 979 102 62 979 102 62 979 102 62 979 102 62 979 102 62 979 102 62
+ 979 102 62 979 102 62 979 102 62 979 102 62 979 102 62 979 102 62
+ 979 102 62 979 102 75 979 102 75 979 102 75 979 102 75 979 102 75
+ 979 102 75 979 102 75 979 102 75 979 113 25 979 113 25 979 113 25
+ 979 113 25 979 113 25 979 113 25 979 113 25 979 113 25 979 113 33
+ 979 113 33 979 113 33 979 113 33 979 113 33 979 113 33 979 113 33
+ 979 113 33 979 113 33 979 113 33 979 113 33}
+
+do_execsql_test 5.3.9.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 84 11 {} 84 11 {} 84 11 {} 84 11 {} 84 11 {} 84 11
+ 2050 75 10 2050 75 10 2050 75 10 2050 75 10 2050 75 10 2050 75 10
+ 2050 75 10 2050 75 10 2050 75 10 4997 68 9 4997 68 9 4997 68 9
+ 4997 68 9 4997 68 9 4997 68 9 4997 68 9 7337 59 8 7337 59 8
+ 7337 59 8 7337 59 8 7337 59 8 7337 59 8 7337 59 8 7337 59 8
+ 7337 59 8 10450 51 7 10450 51 7 10450 51 7 10450 51 7 10450 51 7
+ 10450 51 7 10450 51 7 10450 51 7 11714 40 6 11714 40 6 11714 40 6
+ 11714 40 6 11714 40 6 11714 40 6 11714 40 6 11714 40 6 11714 40 6
+ 11714 40 6 11714 40 6 12676 35 5 12676 35 5 12676 35 5 12676 35 5
+ 12676 35 5 14195 28 4 14195 28 4 14195 28 4 14195 28 4 14195 28 4
+ 14195 28 4 14195 28 4 15999 22 3 15999 22 3 15999 22 3 15999 22 3
+ 15999 22 3 15999 22 3 17365 9 2 17365 9 2 17365 9 2 17365 9 2
+ 17365 9 2 17365 9 2 17365 9 2 17365 9 2 17365 9 2 17365 9 2
+ 17365 9 2 17365 9 2 17365 9 2 20846 1 1 20846 1 1 20846 1 1
+ 20846 1 1 20846 1 1 20846 1 1 20846 1 1 20846 1 1}
+
+do_execsql_test 5.3.10.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0}
+
+do_execsql_test 5.3.10.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1}
+
+do_execsql_test 5.3.11.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST GROUPS 6 PRECEDING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 934 158 27 934 158 27 934 158 27 934 158 27 934 158 27
+ 934 158 27 934 158 27 934 223 8 934 223 8 934 223 8 934 223 8
+ 934 223 8 934 223 8 934 223 8 934 223 8 934 223 8 934 223 8
+ 934 223 8 934 223 8 934 223 8 934 223 21 934 223 21 934 223 21
+ 934 223 21 934 223 21 934 223 21 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50 959 102 50
+ 959 102 50 959 102 50 959 113 39 959 113 39 959 113 39 959 113 39
+ 959 113 39 959 113 39 959 113 39 959 113 39 959 113 39 959 113 39
+ 959 113 39 959 158 34 959 158 34 959 158 34 959 158 34 959 158 34
+ 979 102 46 979 102 46 979 102 46 979 102 46 979 102 46 979 102 46
+ 979 102 46 979 102 47 979 102 47 979 102 47 979 102 47 979 102 47
+ 979 102 47 979 102 47 979 102 47 979 102 47 979 102 49 979 102 49
+ 979 102 49 979 102 49 979 102 49 979 102 49}
+
+do_execsql_test 5.3.11.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST GROUPS 6 PRECEDING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ 2309 9 2 2309 9 2 2309 9 2 2309 9 2 2309 9 2 2309 9 2 2309 9 2
+ 2309 9 2 2309 9 2 2309 9 2 2309 9 2 2309 9 2 2309 9 2 5790 22 3
+ 5790 22 3 5790 22 3 5790 22 3 5790 22 3 5790 22 3 7156 28 4
+ 7156 28 4 7156 28 4 7156 28 4 7156 28 4 7156 28 4 7156 28 4
+ 8960 35 5 8960 35 5 8960 35 5 8960 35 5 8960 35 5 10028 68 9
+ 10028 68 9 10028 68 9 10028 68 9 10028 68 9 10028 68 9 10028 68 9
+ 10396 59 8 10396 59 8 10396 59 8 10396 59 8 10396 59 8 10396 59 8
+ 10396 59 8 10396 59 8 10396 59 8 10479 40 6 10479 40 6 10479 40 6
+ 10479 40 6 10479 40 6 10479 40 6 10479 40 6 10479 40 6 10479 40 6
+ 10479 40 6 10479 40 6 11002 75 10 11002 75 10 11002 75 10
+ 11002 75 10 11002 75 10 11002 75 10 11002 75 10 11002 75 10
+ 11002 75 10 11441 51 7 11441 51 7 11441 51 7 11441 51 7
+ 11441 51 7 11441 51 7 11441 51 7 11441 51 7 12145 84 11
+ 12145 84 11 12145 84 11 12145 84 11 12145 84 11 12145 84 11}
+
+do_execsql_test 5.3.12.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 158 158 1 160 160 1 160 160 1 223 223 1 224 224 1
+ 238 234 2 239 234 2 239 238 2 252 250 2 256 252 2 257 247 4
+ 257 247 4 257 250 3 335 330 2 336 330 2 336 335 2 354 354 1
+ 354 354 1 355 355 1 398 393 3 398 393 3 399 393 3 399 398 2
+ 399 398 2 572 572 1 574 574 1 633 629 2 634 627 3 634 627 3
+ 634 627 3 634 629 3 667 667 1 670 667 2 671 667 2 671 670 2
+ 671 670 2 711 711 1 711 711 1 716 705 2 726 726 1 730 730 1
+ 762 762 1 762 762 1 762 762 1 768 759 3 792 790 2 792 790 2
+ 794 786 3 794 786 3 844 839 4 845 839 4 845 839 4 845 840 3
+ 845 840 3 934 934 1 934 934 1 934 934 1 938 929 3 959 959 1
+ 963 963 1}
+
+do_execsql_test 5.3.12.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 2 2 {} 2 2 {} 4 3 {} 5 4 {} 6 5 {} 6 5 {} 8 6
+ {} 9 7 {} 10 8 {} 14 12 {} 15 13 {} 19 17 {} 20 18 {} 21 19
+ {} 23 21 {} 25 23 {} 27 25 {} 27 25 {} 34 29 {} 35 30 {} 36 31
+ {} 37 32 {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 42 36 {} 43 37
+ {} 43 37 {} 50 42 {} 56 47 {} 60 51 {} 61 52 {} 62 53 {} 64 55
+ {} 64 55 {} 66 56 {} 67 57 {} 68 58 {} 69 59 {} 70 60 {} 71 61
+ {} 72 62 {} 78 67 {} 78 67 {} 78 67 {} 81 68 {} 82 69 {} 83 70
+ {} 85 72 {} 85 72 {} 89 75 223 11 9 239 12 10 239 13 11
+ 257 18 16 335 22 20 335 24 22 504 16 14 504 17 15 671 52 44
+ 671 52 44 705 58 49 710 26 24 711 57 48 711 59 50 759 63 54
+ 786 32 28 786 32 28 798 29 26 798 29 26 845 73 63 845 73 63
+ 929 84 71 959 88 74 963 87 73 1260 46 39 1260 46 39 1334 51 43
+ 1334 55 46 1584 31 27 1678 77 66 1885 48 40 1891 45 38 1891 49 41
+ 2005 54 45 2523 75 64 2523 76 65}
+
+do_execsql_test 5.3.13.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0
+ {} {} 0 {} {} 0 {} {} 0 {} {} 0 {} {} 0}
+
+do_execsql_test 5.3.13.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 2 2 {} 2 2 {} 4 3 {} 5 4 {} 6 5 {} 6 5 {} 8 6
+ {} 9 7 {} 10 8 {} 11 9 {} 12 10 {} 13 11 {} 14 12 {} 15 13
+ {} 16 14 {} 17 15 {} 18 16 {} 19 17 {} 20 18 {} 21 19 {} 22 20
+ {} 23 21 {} 24 22 {} 25 23 {} 26 24 {} 27 25 {} 27 25 {} 29 26
+ {} 29 26 {} 31 27 {} 32 28 {} 32 28 {} 34 29 {} 35 30 {} 36 31
+ {} 37 32 {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 42 36 {} 43 37
+ {} 43 37 {} 45 38 {} 46 39 {} 46 39 {} 48 40 {} 49 41 {} 50 42
+ {} 51 43 {} 52 44 {} 52 44 {} 54 45 {} 55 46 {} 56 47 {} 57 48
+ {} 58 49 {} 59 50 {} 60 51 {} 61 52 {} 62 53 {} 63 54 {} 64 55
+ {} 64 55 {} 66 56 {} 67 57 {} 68 58 {} 69 59 {} 70 60 {} 71 61
+ {} 72 62 {} 73 63 {} 73 63 {} 75 64 {} 76 65 {} 77 66 {} 78 67
+ {} 78 67 {} 78 67 {} 81 68 {} 82 69 {} 83 70 {} 84 71 {} 85 72
+ {} 85 72 {} 87 73 {} 88 74 {} 89 75}
+
+do_execsql_test 5.3.14.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {963 929 6 979 102 82 979 102 82 979 102 82 979 102 82 979 102 82
+ 979 102 83 979 113 80 979 113 81 979 113 82 979 133 79 979 148 78
+ 979 158 76 979 158 77 979 160 76 979 208 75 979 223 74 979 224 73
+ 979 234 72 979 238 71 979 239 70 979 247 69 979 250 68 979 252 67
+ 979 256 66 979 257 65 979 295 64 979 309 63 979 330 63 979 335 61
+ 979 336 60 979 346 59 979 354 58 979 355 56 979 355 58 979 393 55
+ 979 393 56 979 398 54 979 399 52 979 399 53 979 412 52 979 421 51
+ 979 430 50 979 443 49 979 480 47 979 480 48 979 572 46 979 574 46
+ 979 607 44 979 618 42 979 618 43 979 627 41 979 629 40 979 629 40
+ 979 633 39 979 634 38 979 652 37 979 660 36 979 667 34 979 667 35
+ 979 670 34 979 671 33 979 683 32 979 705 31 979 711 30 979 716 29
+ 979 726 28 979 730 27 979 759 26 979 762 25 979 768 23 979 768 24
+ 979 777 22 979 786 21 979 790 20 979 792 19 979 794 18 979 805 17
+ 979 822 16 979 839 15 979 839 15 979 840 13 979 844 12 979 845 11
+ 979 870 8 979 870 9 979 870 10 979 899 8 979 911 7}
+
+do_execsql_test 5.3.14.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {2851 89 89 3778 88 88 4681 87 87 5556 83 83 5574 82 82 5586 81 81
+ 5640 84 84 5640 85 85 5640 86 86 7324 80 80 8123 77 77 8129 73 73
+ 8129 74 74 8163 78 78 8163 79 79 8940 71 71 8968 75 75 8968 76 76
+ 9727 66 66 9745 69 69 9745 70 70 9745 72 72 10504 65 65
+ 10504 67 67 10504 68 68 11215 64 64 11844 62 62 11920 63 63
+ 13274 60 60 13274 61 61 13897 58 58 13903 57 57 13925 56 56
+ 13937 55 55 13941 59 59 15203 53 53 15241 54 54 15832 52 52
+ 17100 48 48 17104 46 46 17104 47 47 17106 45 45 17126 49 49
+ 17126 50 50 17126 51 51 17569 42 42 17733 44 44 18176 43 43
+ 18597 40 40 18597 41 41 18952 37 37 18996 39 39 19395 38 38
+ 19760 35 35 19788 36 36 20492 32 32 20492 33 33 20498 30 30
+ 20536 34 34 20833 29 29 20871 28 28 20891 31 31 21180 27 27
+ 21752 23 23 21830 26 26 22025 21 21 22087 22 22 22087 24 24
+ 22087 25 25 22278 20 20 22316 19 19 22549 15 15 22557 14 14
+ 22573 17 17 22573 18 18 22706 10 10 22796 11 11 22796 12 12
+ 22796 13 13 22796 16 16 23022 4 4 23042 2 2 23042 3 3 23042 9 9
+ 23155 1 1 23155 5 5 23155 6 6 23155 7 7 23155 8 8}
+
+do_execsql_test 5.4.1.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 1 113 113 1 133 133 1 148 148 1 158 158 0
+ 158 158 1 160 160 1 208 208 1 223 223 1 224 224 1 234 234 1
+ 238 238 1 239 239 1 247 247 1 250 250 1 252 252 1 256 256 1
+ 257 257 1 295 295 1 309 309 1 330 330 1 335 335 1 336 336 1
+ 346 346 1 354 354 1 355 355 0 355 355 1 393 393 1 393 393 1
+ 398 398 1 399 399 0 399 399 1 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 1 480 480 1 572 572 1 574 574 1 607 607 1
+ 618 618 1 618 618 1 627 627 1 629 629 0 629 629 1 633 633 1
+ 634 634 1 652 652 1 660 660 1 667 667 0 667 667 1 670 670 1
+ 671 671 1 683 683 1 705 705 1 711 711 1 716 716 1 726 726 1
+ 730 730 1 759 759 1 762 762 1 768 768 1 768 768 1 777 777 1
+ 786 786 1 790 790 1 792 792 1 794 794 1 805 805 1 822 822 1
+ 839 839 1 839 839 1 840 840 1 844 844 1 845 845 1 870 870 0
+ 870 870 1 870 870 1 899 899 1 911 911 1 929 929 1 934 934 1
+ 938 938 1 938 938 1 959 959 1 963 963 1 979 979 1}
+
+do_execsql_test 5.4.1.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ 113 1 1 113 1 1 133 1 1 223 1 1 239 1 1 247 1 1 257 1 1
+ 295 1 1 309 1 1 335 1 1 355 1 1 355 1 1 393 1 1 393 1 1
+ 399 1 1 399 1 1 421 1 1 443 1 1 607 1 1 627 1 1 629 1 1
+ 629 1 1 633 1 1 667 1 1 667 1 1 671 1 1 683 1 1 705 1 1
+ 711 1 1 759 1 1 777 1 1 805 1 1 839 1 1 839 1 1 845 1 1
+ 899 1 1 911 1 1 929 1 1 959 1 1 963 1 1 979 1 1}
+
+do_execsql_test 5.4.2.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {113 113 1 234 234 1 257 257 1 336 336 1 354 354 1 768 768 1
+ 839 839 1 839 839 1 899 113 10 899 113 10 899 113 10 899 113 10
+ 899 113 10 899 113 10 899 113 10 899 113 17 899 113 17 899 113 17
+ 899 113 17 899 113 17 899 113 17 899 113 17 899 899 1 963 113 17
+ 979 102 34 979 102 45 979 102 45 979 102 45 979 102 45 979 102 45
+ 979 102 50 979 102 50 979 102 50 979 102 50 979 102 50 979 102 50
+ 979 102 50 979 102 57 979 102 57 979 102 57 979 102 57 979 102 57
+ 979 102 57 979 102 63 979 102 63 979 102 63 979 102 63 979 102 63
+ 979 102 63 979 102 63 979 102 63 979 102 63 979 102 63 979 102 63
+ 979 102 63 979 102 63 979 102 76 979 102 76 979 102 76 979 102 76
+ 979 102 76 979 102 76 979 102 76 979 102 76 979 102 83 979 102 83
+ 979 102 83 979 102 83 979 102 83 979 102 83 979 113 17 979 113 26
+ 979 113 26 979 113 26 979 113 26 979 113 26 979 113 26 979 113 26
+ 979 113 26 979 113 34 979 113 34 979 113 34 979 113 34 979 113 34
+ 979 113 34 979 113 34 979 113 34 979 113 34 979 113 34}
+
+do_execsql_test 5.4.2.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 81 11 {} 81 11 {} 81 11 {} 81 11 113 81 11 257 81 11
+ 839 81 11 839 81 11 899 81 11 2947 74 10 2947 74 10 2947 74 10
+ 3368 74 10 3390 74 10 3618 74 10 3752 74 10 5287 65 9 5287 65 9
+ 5287 65 9 5287 65 9 5420 65 9 5642 65 9 5970 65 9 6250 65 9
+ 6266 65 9 8400 57 8 8400 57 8 8400 57 8 8400 57 8 8400 57 8
+ 8400 57 8 8735 57 8 9329 57 8 9664 46 7 9664 46 7 9664 46 7
+ 9664 46 7 9664 46 7 9664 46 7 9664 46 7 9664 46 7 9664 46 7
+ 9959 46 7 10331 46 7 10626 41 6 10626 41 6 10739 41 6 11255 41 6
+ 11403 41 6 12145 34 5 12145 34 5 12145 34 5 12145 34 5 12145 34 5
+ 12990 34 5 13104 34 5 13949 28 4 13949 28 4 13949 28 4 13949 28 4
+ 14556 28 4 14708 28 4 15315 15 3 15315 15 3 15315 15 3 15315 15 3
+ 15315 15 3 15315 15 3 15562 15 3 15708 15 3 15708 15 3 15714 15 3
+ 15948 15 3 16020 15 3 16026 15 3 18796 7 2 18796 7 2 18796 7 2
+ 19019 7 2 19035 7 2 19105 7 2 19423 7 2 19707 7 2 21105 1 1
+ 21105 1 1 21460 1 1 21504 1 1 21734 1 1 21772 1 1}
+
+do_execsql_test 5.4.3.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 1 113 113 1 133 133 1 148 148 1 158 158 0
+ 158 158 1 160 160 1 208 208 1 223 223 1 224 224 1 234 234 1
+ 238 238 1 239 239 1 247 247 1 250 250 1 252 252 1 256 256 1
+ 257 257 1 295 295 1 309 309 1 330 330 1 335 335 1 336 336 1
+ 346 346 1 354 354 1 355 355 0 355 355 1 393 393 1 393 393 1
+ 398 398 1 399 399 0 399 399 1 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 1 480 480 1 572 572 1 574 574 1 607 607 1
+ 618 618 1 618 618 1 627 627 1 629 629 0 629 629 1 633 633 1
+ 634 634 1 652 652 1 660 660 1 667 667 0 667 667 1 670 670 1
+ 671 671 1 683 683 1 705 705 1 711 711 1 716 716 1 726 726 1
+ 730 730 1 759 759 1 762 762 1 768 768 1 768 768 1 777 777 1
+ 786 786 1 790 790 1 792 792 1 794 794 1 805 805 1 822 822 1
+ 839 839 1 839 839 1 840 840 1 844 844 1 845 845 1 870 870 0
+ 870 870 1 870 870 1 899 899 1 911 911 1 929 929 1 934 934 1
+ 938 938 1 938 938 1 959 959 1 963 963 1 979 979 1}
+
+do_execsql_test 5.4.3.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ 113 1 1 113 1 1 133 1 1 223 1 1 239 1 1 247 1 1 257 1 1
+ 295 1 1 309 1 1 335 1 1 355 1 1 355 1 1 393 1 1 393 1 1
+ 399 1 1 399 1 1 421 1 1 443 1 1 607 1 1 627 1 1 629 1 1
+ 629 1 1 633 1 1 667 1 1 667 1 1 671 1 1 683 1 1 705 1 1
+ 711 1 1 759 1 1 777 1 1 805 1 1 839 1 1 839 1 1 845 1 1
+ 899 1 1 911 1 1 929 1 1 959 1 1 963 1 1 979 1 1}
+
+do_execsql_test 5.4.4.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST GROUPS 6 PRECEDING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {158 158 0 355 355 0 399 399 0 629 629 0 667 667 0 870 158 1
+ 870 158 1 870 158 1 870 158 1 870 158 1 870 158 1 870 870 0
+ 911 158 1 934 158 1 934 158 9 934 158 9 934 158 9 934 158 9
+ 934 158 9 934 158 9 934 158 9 934 158 9 934 158 9 934 158 9
+ 934 158 9 934 158 9 934 158 9 934 158 22 934 158 22 934 158 22
+ 934 158 22 934 158 22 934 158 22 934 158 28 934 158 28 934 158 28
+ 934 158 28 934 158 28 934 158 28 959 102 40 959 102 51 959 102 51
+ 959 102 51 959 102 51 959 102 51 959 102 51 959 102 51 959 102 51
+ 959 102 51 959 102 51 959 102 51 959 102 51 959 102 51 959 102 51
+ 959 102 51 959 113 35 959 113 40 959 113 40 959 113 40 959 113 40
+ 959 113 40 959 113 40 959 113 40 959 113 40 959 113 40 959 113 40
+ 959 158 28 959 158 35 959 158 35 959 158 35 959 158 35 963 102 51
+ 979 102 47 979 102 47 979 102 47 979 102 47 979 102 47 979 102 47
+ 979 102 47 979 102 48 979 102 48 979 102 48 979 102 48 979 102 48
+ 979 102 48 979 102 48 979 102 48 979 102 48 979 102 51}
+
+do_execsql_test 5.4.4.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS FIRST GROUPS 6 PRECEDING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 355 1 1 399 1 1 629 1 1 667 1 1 2050 7 2
+ 2050 7 2 2050 7 2 2273 7 2 2289 7 2 2359 7 2 2677 7 2 2961 7 2
+ 4359 15 3 4359 15 3 4359 15 3 4359 15 3 4359 15 3 4359 15 3
+ 4606 15 3 4752 15 3 4752 15 3 4758 15 3 4992 15 3 5064 15 3
+ 5070 15 3 7840 28 4 7840 28 4 7840 28 4 7840 28 4 8447 28 4
+ 8599 28 4 9206 34 5 9206 34 5 9206 34 5 9206 34 5 9206 34 5
+ 10028 74 10 10028 74 10 10028 74 10 10051 34 5 10165 34 5
+ 10396 65 9 10396 65 9 10396 65 9 10396 65 9 10449 74 10
+ 10471 74 10 10529 65 9 10699 74 10 10751 65 9 10833 74 10
+ 11002 81 11 11002 81 11 11002 81 11 11002 81 11 11010 41 6
+ 11010 41 6 11079 65 9 11115 81 11 11123 41 6 11259 81 11
+ 11359 65 9 11375 65 9 11441 57 8 11441 57 8 11441 57 8 11441 57 8
+ 11441 57 8 11441 57 8 11639 41 6 11776 57 8 11787 41 6
+ 11841 81 11 11841 81 11 11901 81 11 12370 57 8 12529 46 7
+ 12529 46 7 12529 46 7 12529 46 7 12529 46 7 12529 46 7 12529 46 7
+ 12529 46 7 12529 46 7 12824 46 7 13196 46 7}
+
+do_execsql_test 5.4.5.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 1 113 113 1 133 133 1 148 148 1 160 158 1
+ 160 158 2 160 158 2 208 208 1 224 223 2 224 223 2 239 234 3
+ 239 234 3 239 234 3 252 247 3 257 247 5 257 247 5 257 250 4
+ 257 252 3 295 295 1 309 309 1 336 330 3 336 330 3 336 330 3
+ 346 346 1 355 354 1 355 354 2 355 354 2 399 393 3 399 393 3
+ 399 393 3 399 393 4 399 393 4 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 1 480 480 1 574 572 2 574 572 2 607 607 1
+ 618 618 1 618 618 1 634 627 3 634 627 4 634 627 4 634 627 4
+ 634 629 3 652 652 1 667 660 2 671 667 2 671 667 3 671 667 3
+ 671 667 3 683 683 1 711 705 2 716 705 3 716 711 2 730 726 2
+ 730 726 2 762 759 2 768 759 4 768 762 2 768 762 2 777 777 1
+ 792 786 3 794 786 4 794 786 4 794 790 3 805 805 1 822 822 1
+ 845 839 4 845 839 4 845 839 5 845 839 5 845 839 5 870 870 0
+ 870 870 1 870 870 1 899 899 1 911 911 1 934 929 2 938 929 4
+ 938 934 2 938 934 2 963 959 2 963 959 2 979 979 1}
+
+do_execsql_test 5.4.5.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 25 23 {} 34 29
+ {} 36 31 {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 43 37 {} 43 37
+ {} 50 42 {} 60 51 {} 61 52 {} 64 55 {} 64 55 {} 67 57 {} 68 58
+ {} 69 59 {} 70 60 {} 72 62 {} 78 67 {} 78 67 {} 78 67 {} 85 72
+ {} 85 72 113 2 2 113 2 2 133 4 3 223 10 8 223 11 9 239 12 10
+ 239 13 11 239 14 12 247 15 13 257 18 16 257 19 17 295 20 18
+ 309 21 19 335 22 20 335 23 21 335 24 22 355 27 25 355 27 25
+ 421 35 30 443 37 32 504 16 14 504 17 15 607 42 36 683 56 47
+ 710 26 24 711 59 50 759 62 53 759 63 54 777 66 56 805 71 61
+ 899 81 68 911 82 69 929 83 70 929 84 71 979 89 75 1185 32 28
+ 1185 32 28 1191 29 26 1191 29 26 1334 51 43 1338 52 44 1338 52 44
+ 1416 57 48 1416 58 49 1584 31 27 1684 73 63 1684 73 63 1889 46 39
+ 1889 46 39 1891 49 41 1922 87 73 1922 88 74 2005 54 45 2005 55 46
+ 2518 45 38 2518 48 40 2523 75 64 2523 76 65 2523 77 66}
+
+do_execsql_test 5.4.6.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 1 113 113 1 133 133 1 148 148 1 158 158 0
+ 158 158 1 160 160 1 208 208 1 223 223 1 224 224 1 234 234 1
+ 238 238 1 239 239 1 247 247 1 250 250 1 252 252 1 256 256 1
+ 257 257 1 295 295 1 309 309 1 330 330 1 335 335 1 336 336 1
+ 346 346 1 354 354 1 355 355 0 355 355 1 393 393 1 393 393 1
+ 398 398 1 399 399 0 399 399 1 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 1 480 480 1 572 572 1 574 574 1 607 607 1
+ 618 618 1 618 618 1 627 627 1 629 629 0 629 629 1 633 633 1
+ 634 634 1 652 652 1 660 660 1 667 667 0 667 667 1 670 670 1
+ 671 671 1 683 683 1 705 705 1 711 711 1 716 716 1 726 726 1
+ 730 730 1 759 759 1 762 762 1 768 768 1 768 768 1 777 777 1
+ 786 786 1 790 790 1 792 792 1 794 794 1 805 805 1 822 822 1
+ 839 839 1 839 839 1 840 840 1 844 844 1 845 845 1 870 870 0
+ 870 870 1 870 870 1 899 899 1 911 911 1 929 929 1 934 934 1
+ 938 938 1 938 938 1 959 959 1 963 963 1 979 979 1}
+
+do_execsql_test 5.4.6.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 11 9 {} 12 10
+ {} 13 11 {} 16 14 {} 17 15 {} 18 16 {} 22 20 {} 24 22 {} 25 23
+ {} 26 24 {} 31 27 {} 34 29 {} 36 31 {} 38 33 {} 38 33 {} 40 34
+ {} 41 35 {} 43 37 {} 43 37 {} 49 41 {} 50 42 {} 51 43 {} 54 45
+ {} 59 50 {} 60 51 {} 61 52 {} 63 54 {} 64 55 {} 64 55 {} 67 57
+ {} 68 58 {} 69 59 {} 70 60 {} 72 62 {} 75 64 {} 76 65 {} 78 67
+ {} 78 67 {} 78 67 {} 84 71 {} 85 72 {} 85 72 113 2 2 113 2 2
+ 133 4 3 223 10 8 239 14 12 247 15 13 257 19 17 295 20 18
+ 309 21 19 335 23 21 355 27 25 355 27 25 393 29 26 393 29 26
+ 399 32 28 399 32 28 421 35 30 443 37 32 607 42 36 627 45 38
+ 629 46 39 629 46 39 633 48 40 667 52 44 667 52 44 671 55 46
+ 683 56 47 705 57 48 711 58 49 759 62 53 777 66 56 805 71 61
+ 839 73 63 839 73 63 845 77 66 899 81 68 911 82 69 929 83 70
+ 959 87 73 963 88 74 979 89 75}
+
+do_execsql_test 5.4.7.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 113 81 979 113 82 979 133 80 979 148 79 979 158 77
+ 979 158 78 979 160 77 979 208 76 979 223 75 979 224 74 979 234 73
+ 979 238 72 979 239 71 979 247 70 979 250 69 979 252 68 979 256 67
+ 979 257 66 979 295 65 979 309 64 979 330 63 979 335 62 979 336 61
+ 979 346 60 979 354 59 979 355 58 979 355 58 979 393 56 979 393 57
+ 979 398 55 979 399 54 979 399 54 979 412 53 979 421 52 979 430 51
+ 979 443 50 979 480 48 979 480 49 979 572 47 979 574 46 979 607 45
+ 979 618 43 979 618 44 979 627 42 979 629 41 979 629 41 979 633 40
+ 979 634 39 979 652 38 979 660 37 979 667 36 979 667 36 979 670 35
+ 979 671 34 979 683 33 979 705 32 979 711 31 979 716 30 979 726 29
+ 979 730 28 979 759 27 979 762 26 979 768 24 979 768 25 979 777 23
+ 979 786 22 979 790 21 979 792 20 979 794 19 979 805 18 979 822 17
+ 979 839 15 979 839 16 979 840 14 979 844 13 979 845 12 979 870 10
+ 979 870 11 979 870 11 979 899 9 979 911 8 979 929 7}
+
+do_execsql_test 5.4.7.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {3830 89 89 4741 88 88 5640 84 84 5640 85 85 5640 86 86 5640 87 87
+ 6485 81 81 6485 82 82 6485 83 83 7324 80 80 8163 78 78 8163 79 79
+ 8968 73 73 8968 74 74 8968 75 75 8968 76 76 8968 77 77 9745 69 69
+ 9745 70 70 9745 71 71 9745 72 72 10504 65 65 10504 66 66
+ 10504 67 67 10504 68 68 11215 64 64 11920 63 63 12603 62 62
+ 13274 60 60 13274 61 61 13941 59 59 14608 55 55 14608 56 56
+ 14608 57 57 14608 58 58 15241 54 54 15870 53 53 16499 52 52
+ 17126 49 49 17126 50 50 17126 51 51 17733 44 44 17733 45 45
+ 17733 46 46 17733 47 47 17733 48 48 18176 42 42 18176 43 43
+ 18597 40 40 18597 41 41 18996 39 39 19395 37 37 19395 38 38
+ 19788 36 36 20181 35 35 20536 34 34 20891 30 30 20891 31 31
+ 20891 32 32 20891 33 33 21226 28 28 21226 29 29 21535 27 27
+ 21830 26 26 22087 22 22 22087 23 23 22087 24 24 22087 25 25
+ 22334 21 21 22573 17 17 22573 18 18 22573 19 19 22573 20 20
+ 22796 11 11 22796 12 12 22796 13 13 22796 14 14 22796 15 15
+ 22796 16 16 22929 10 10 23042 9 9 23155 1 1 23155 2 2 23155 3 3
+ 23155 4 4 23155 5 5 23155 6 6 23155 7 7 23155 8 8}
+
+do_execsql_test 5.4.8.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 1 113 113 1 133 133 1 148 148 1 158 158 0
+ 158 158 1 160 160 1 208 208 1 223 223 1 224 224 1 234 234 1
+ 238 238 1 239 239 1 247 247 1 250 250 1 252 252 1 256 256 1
+ 257 257 1 295 295 1 309 309 1 330 330 1 335 335 1 336 336 1
+ 346 346 1 354 354 1 355 355 0 355 355 1 393 393 1 393 393 1
+ 398 398 1 399 399 0 399 399 1 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 1 480 480 1 572 572 1 574 574 1 607 607 1
+ 618 618 1 618 618 1 627 627 1 629 629 0 629 629 1 633 633 1
+ 634 634 1 652 652 1 660 660 1 667 667 0 667 667 1 670 670 1
+ 671 671 1 683 683 1 705 705 1 711 711 1 716 716 1 726 726 1
+ 730 730 1 759 759 1 762 762 1 768 768 1 768 768 1 777 777 1
+ 786 786 1 790 790 1 792 792 1 794 794 1 805 805 1 822 822 1
+ 839 839 1 839 839 1 840 840 1 844 844 1 845 845 1 870 870 0
+ 870 870 1 870 870 1 899 899 1 911 911 1 929 929 1 934 934 1
+ 938 938 1 938 938 1 959 959 1 963 963 1 979 979 1}
+
+do_execsql_test 5.4.8.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ 113 1 1 113 1 1 133 1 1 223 1 1 239 1 1 247 1 1 257 1 1
+ 295 1 1 309 1 1 335 1 1 355 1 1 355 1 1 393 1 1 393 1 1
+ 399 1 1 399 1 1 421 1 1 443 1 1 607 1 1 627 1 1 629 1 1
+ 629 1 1 633 1 1 667 1 1 667 1 1 671 1 1 683 1 1 705 1 1
+ 711 1 1 759 1 1 777 1 1 805 1 1 839 1 1 839 1 1 845 1 1
+ 899 1 1 911 1 1 929 1 1 959 1 1 963 1 1 979 1 1}
+
+do_execsql_test 5.4.9.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {158 158 0 355 355 0 399 399 0 629 629 0 667 667 0 870 113 1
+ 870 158 1 870 158 1 870 158 1 870 158 1 870 158 1 870 158 1
+ 870 158 1 870 870 0 899 113 10 899 113 10 899 113 10 899 113 10
+ 899 113 10 899 113 10 899 113 10 899 113 17 899 113 17 899 113 17
+ 899 113 17 899 113 17 899 113 17 899 113 17 899 158 1 963 113 17
+ 979 102 34 979 102 45 979 102 45 979 102 45 979 102 45 979 102 45
+ 979 102 50 979 102 50 979 102 50 979 102 50 979 102 50 979 102 50
+ 979 102 50 979 102 57 979 102 57 979 102 57 979 102 57 979 102 57
+ 979 102 57 979 102 63 979 102 63 979 102 63 979 102 63 979 102 63
+ 979 102 63 979 102 63 979 102 63 979 102 63 979 102 63 979 102 63
+ 979 102 63 979 102 63 979 102 76 979 102 76 979 102 76 979 102 76
+ 979 102 76 979 102 76 979 102 76 979 102 76 979 113 17 979 113 26
+ 979 113 26 979 113 26 979 113 26 979 113 26 979 113 26 979 113 26
+ 979 113 26 979 113 34 979 113 34 979 113 34 979 113 34 979 113 34
+ 979 113 34 979 113 34 979 113 34 979 113 34 979 113 34}
+
+do_execsql_test 5.4.9.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 84 11 {} 84 11 355 84 11 399 84 11 629 84 11 667 84 11
+ 2050 75 10 2050 75 10 2050 75 10 2050 75 10 2163 75 10 2307 75 10
+ 2889 75 10 2889 75 10 2949 75 10 4997 68 9 4997 68 9 4997 68 9
+ 5418 68 9 5440 68 9 5668 68 9 5802 68 9 7337 59 8 7337 59 8
+ 7337 59 8 7337 59 8 7470 59 8 7692 59 8 8020 59 8 8300 59 8
+ 8316 59 8 10450 51 7 10450 51 7 10450 51 7 10450 51 7 10450 51 7
+ 10450 51 7 10785 51 7 11379 51 7 11714 40 6 11714 40 6 11714 40 6
+ 11714 40 6 11714 40 6 11714 40 6 11714 40 6 11714 40 6 11714 40 6
+ 12009 40 6 12381 40 6 12676 35 5 12676 35 5 12789 35 5 13305 35 5
+ 13453 35 5 14195 28 4 14195 28 4 14195 28 4 14195 28 4 14195 28 4
+ 15040 28 4 15154 28 4 15999 22 3 15999 22 3 15999 22 3 15999 22 3
+ 16606 22 3 16758 22 3 17365 9 2 17365 9 2 17365 9 2 17365 9 2
+ 17365 9 2 17365 9 2 17612 9 2 17758 9 2 17758 9 2 17764 9 2
+ 17998 9 2 18070 9 2 18076 9 2 20846 1 1 20846 1 1 20846 1 1
+ 21069 1 1 21085 1 1 21155 1 1 21473 1 1 21757 1 1}
+
+do_execsql_test 5.4.10.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 1 113 113 1 133 133 1 148 148 1 158 158 0
+ 158 158 1 160 160 1 208 208 1 223 223 1 224 224 1 234 234 1
+ 238 238 1 239 239 1 247 247 1 250 250 1 252 252 1 256 256 1
+ 257 257 1 295 295 1 309 309 1 330 330 1 335 335 1 336 336 1
+ 346 346 1 354 354 1 355 355 0 355 355 1 393 393 1 393 393 1
+ 398 398 1 399 399 0 399 399 1 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 1 480 480 1 572 572 1 574 574 1 607 607 1
+ 618 618 1 618 618 1 627 627 1 629 629 0 629 629 1 633 633 1
+ 634 634 1 652 652 1 660 660 1 667 667 0 667 667 1 670 670 1
+ 671 671 1 683 683 1 705 705 1 711 711 1 716 716 1 726 726 1
+ 730 730 1 759 759 1 762 762 1 768 768 1 768 768 1 777 777 1
+ 786 786 1 790 790 1 792 792 1 794 794 1 805 805 1 822 822 1
+ 839 839 1 839 839 1 840 840 1 844 844 1 845 845 1 870 870 0
+ 870 870 1 870 870 1 899 899 1 911 911 1 929 929 1 934 934 1
+ 938 938 1 938 938 1 959 959 1 963 963 1 979 979 1}
+
+do_execsql_test 5.4.10.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( PARTITION BY coalesce(a, '')
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1 {} 1 1
+ 113 1 1 113 1 1 133 1 1 223 1 1 239 1 1 247 1 1 257 1 1
+ 295 1 1 309 1 1 335 1 1 355 1 1 355 1 1 393 1 1 393 1 1
+ 399 1 1 399 1 1 421 1 1 443 1 1 607 1 1 627 1 1 629 1 1
+ 629 1 1 633 1 1 667 1 1 667 1 1 671 1 1 683 1 1 705 1 1
+ 711 1 1 759 1 1 777 1 1 805 1 1 839 1 1 839 1 1 845 1 1
+ 899 1 1 911 1 1 929 1 1 959 1 1 963 1 1 979 1 1}
+
+do_execsql_test 5.4.11.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST GROUPS 6 PRECEDING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {223 223 1 239 239 1 309 309 1 572 572 1 627 627 1 870 870 1
+ 911 911 1 934 158 22 934 158 28 934 158 28 934 158 28 934 158 28
+ 934 158 28 934 158 28 934 223 9 934 223 9 934 223 9 934 223 9
+ 934 223 9 934 223 9 934 223 9 934 223 9 934 223 9 934 223 9
+ 934 223 9 934 223 9 934 223 9 934 223 22 934 223 22 934 223 22
+ 934 223 22 934 223 22 934 934 1 959 102 40 959 102 51 959 102 51
+ 959 102 51 959 102 51 959 102 51 959 102 51 959 102 51 959 102 51
+ 959 102 51 959 102 51 959 102 51 959 102 51 959 102 51 959 102 51
+ 959 102 51 959 113 35 959 113 40 959 113 40 959 113 40 959 113 40
+ 959 113 40 959 113 40 959 113 40 959 113 40 959 113 40 959 113 40
+ 959 158 28 959 158 35 959 158 35 959 158 35 959 158 35 963 102 51
+ 979 102 47 979 102 47 979 102 47 979 102 47 979 102 47 979 102 47
+ 979 102 47 979 102 48 979 102 48 979 102 48 979 102 48 979 102 48
+ 979 102 48 979 102 48 979 102 48 979 102 48 979 102 49 979 102 49
+ 979 102 49 979 102 49 979 102 49 979 102 49 979 102 51}
+
+do_execsql_test 5.4.11.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY a NULLS LAST GROUPS 6 PRECEDING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 1 1 {} 1 1 223 1 1 239 1 1 309 1 1 627 1 1 911 1 1
+ 2309 9 2 2309 9 2 2309 9 2 2309 9 2 2309 9 2 2309 9 2 2556 9 2
+ 2702 9 2 2702 9 2 2708 9 2 2942 9 2 3014 9 2 3020 9 2 5790 22 3
+ 5790 22 3 5790 22 3 5790 22 3 6397 22 3 6549 22 3 7156 28 4
+ 7156 28 4 7156 28 4 7156 28 4 7156 28 4 8001 28 4 8115 28 4
+ 8960 35 5 8960 35 5 9073 35 5 9589 35 5 9737 35 5 10028 68 9
+ 10028 68 9 10028 68 9 10396 59 8 10396 59 8 10396 59 8 10396 59 8
+ 10449 68 9 10471 68 9 10479 40 6 10479 40 6 10479 40 6 10479 40 6
+ 10479 40 6 10479 40 6 10479 40 6 10479 40 6 10479 40 6 10529 59 8
+ 10699 68 9 10751 59 8 10774 40 6 10833 68 9 11002 75 10
+ 11002 75 10 11002 75 10 11002 75 10 11079 59 8 11115 75 10
+ 11146 40 6 11259 75 10 11359 59 8 11375 59 8 11441 51 7
+ 11441 51 7 11441 51 7 11441 51 7 11441 51 7 11441 51 7 11776 51 7
+ 11841 75 10 11841 75 10 11901 75 10 12145 84 11 12145 84 11
+ 12370 51 7 12500 84 11 12544 84 11 12774 84 11 12812 84 11}
+
+do_execsql_test 5.4.12.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 1 113 113 1 133 133 1 148 148 1 160 158 1
+ 160 158 2 160 158 2 208 208 1 224 223 2 224 223 2 239 234 3
+ 239 234 3 239 234 3 252 247 3 257 247 5 257 247 5 257 250 4
+ 257 252 3 295 295 1 309 309 1 336 330 3 336 330 3 336 330 3
+ 346 346 1 355 354 1 355 354 2 355 354 2 399 393 3 399 393 3
+ 399 393 3 399 393 4 399 393 4 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 1 480 480 1 574 572 2 574 572 2 607 607 1
+ 618 618 1 618 618 1 634 627 3 634 627 4 634 627 4 634 627 4
+ 634 629 3 652 652 1 667 660 2 671 667 2 671 667 3 671 667 3
+ 671 667 3 683 683 1 711 705 2 716 705 3 716 711 2 730 726 2
+ 730 726 2 762 759 2 768 759 4 768 762 2 768 762 2 777 777 1
+ 792 786 3 794 786 4 794 786 4 794 790 3 805 805 1 822 822 1
+ 845 839 4 845 839 4 845 839 5 845 839 5 845 839 5 870 870 0
+ 870 870 1 870 870 1 899 899 1 911 911 1 934 929 2 938 929 4
+ 938 934 2 938 934 2 963 959 2 963 959 2 979 979 1}
+
+do_execsql_test 5.4.12.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 25 23 {} 34 29
+ {} 36 31 {} 38 33 {} 38 33 {} 40 34 {} 41 35 {} 43 37 {} 43 37
+ {} 50 42 {} 60 51 {} 61 52 {} 64 55 {} 64 55 {} 67 57 {} 68 58
+ {} 69 59 {} 70 60 {} 72 62 {} 78 67 {} 78 67 {} 78 67 {} 85 72
+ {} 85 72 113 2 2 113 2 2 133 4 3 223 10 8 223 11 9 239 12 10
+ 239 13 11 239 14 12 247 15 13 257 18 16 257 19 17 295 20 18
+ 309 21 19 335 22 20 335 23 21 335 24 22 355 27 25 355 27 25
+ 421 35 30 443 37 32 504 16 14 504 17 15 607 42 36 683 56 47
+ 710 26 24 711 59 50 759 62 53 759 63 54 777 66 56 805 71 61
+ 899 81 68 911 82 69 929 83 70 929 84 71 979 89 75 1185 32 28
+ 1185 32 28 1191 29 26 1191 29 26 1334 51 43 1338 52 44 1338 52 44
+ 1416 57 48 1416 58 49 1584 31 27 1684 73 63 1684 73 63 1889 46 39
+ 1889 46 39 1891 49 41 1922 87 73 1922 88 74 2005 54 45 2005 55 46
+ 2518 45 38 2518 48 40 2523 75 64 2523 76 65 2523 77 66}
+
+do_execsql_test 5.4.13.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {102 102 1 113 113 1 113 113 1 133 133 1 148 148 1 158 158 0
+ 158 158 1 160 160 1 208 208 1 223 223 1 224 224 1 234 234 1
+ 238 238 1 239 239 1 247 247 1 250 250 1 252 252 1 256 256 1
+ 257 257 1 295 295 1 309 309 1 330 330 1 335 335 1 336 336 1
+ 346 346 1 354 354 1 355 355 0 355 355 1 393 393 1 393 393 1
+ 398 398 1 399 399 0 399 399 1 412 412 1 421 421 1 430 430 1
+ 443 443 1 480 480 1 480 480 1 572 572 1 574 574 1 607 607 1
+ 618 618 1 618 618 1 627 627 1 629 629 0 629 629 1 633 633 1
+ 634 634 1 652 652 1 660 660 1 667 667 0 667 667 1 670 670 1
+ 671 671 1 683 683 1 705 705 1 711 711 1 716 716 1 726 726 1
+ 730 730 1 759 759 1 762 762 1 768 768 1 768 768 1 777 777 1
+ 786 786 1 790 790 1 792 792 1 794 794 1 805 805 1 822 822 1
+ 839 839 1 839 839 1 840 840 1 844 844 1 845 845 1 870 870 0
+ 870 870 1 870 870 1 899 899 1 911 911 1 929 929 1 934 934 1
+ 938 938 1 938 938 1 959 959 1 963 963 1 979 979 1}
+
+do_execsql_test 5.4.13.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {{} 1 1 {} 5 4 {} 6 5 {} 6 5 {} 8 6 {} 9 7 {} 11 9 {} 12 10
+ {} 13 11 {} 16 14 {} 17 15 {} 18 16 {} 22 20 {} 24 22 {} 25 23
+ {} 26 24 {} 31 27 {} 34 29 {} 36 31 {} 38 33 {} 38 33 {} 40 34
+ {} 41 35 {} 43 37 {} 43 37 {} 49 41 {} 50 42 {} 51 43 {} 54 45
+ {} 59 50 {} 60 51 {} 61 52 {} 63 54 {} 64 55 {} 64 55 {} 67 57
+ {} 68 58 {} 69 59 {} 70 60 {} 72 62 {} 75 64 {} 76 65 {} 78 67
+ {} 78 67 {} 78 67 {} 84 71 {} 85 72 {} 85 72 113 2 2 113 2 2
+ 133 4 3 223 10 8 239 14 12 247 15 13 257 19 17 295 20 18
+ 309 21 19 335 23 21 355 27 25 355 27 25 393 29 26 393 29 26
+ 399 32 28 399 32 28 421 35 30 443 37 32 607 42 36 627 45 38
+ 629 46 39 629 46 39 633 48 40 667 52 44 667 52 44 671 55 46
+ 683 56 47 705 57 48 711 58 49 759 62 53 777 66 56 805 71 61
+ 839 73 63 839 73 63 845 77 66 899 81 68 911 82 69 929 83 70
+ 959 87 73 963 88 74 979 89 75}
+
+do_execsql_test 5.4.14.1 {
+ SELECT max(c) OVER win,
+ min(c) OVER win,
+ count(a) OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {979 102 83 979 102 83 979 102 83 979 102 83 979 102 83 979 102 83
+ 979 102 83 979 113 81 979 113 82 979 133 80 979 148 79 979 158 77
+ 979 158 78 979 160 77 979 208 76 979 223 75 979 224 74 979 234 73
+ 979 238 72 979 239 71 979 247 70 979 250 69 979 252 68 979 256 67
+ 979 257 66 979 295 65 979 309 64 979 330 63 979 335 62 979 336 61
+ 979 346 60 979 354 59 979 355 57 979 355 58 979 393 56 979 393 57
+ 979 398 55 979 399 53 979 399 54 979 412 53 979 421 52 979 430 51
+ 979 443 50 979 480 48 979 480 49 979 572 47 979 574 46 979 607 45
+ 979 618 43 979 618 44 979 627 42 979 629 40 979 629 41 979 633 40
+ 979 634 39 979 652 38 979 660 37 979 667 35 979 667 36 979 670 35
+ 979 671 34 979 683 33 979 705 32 979 711 31 979 716 30 979 726 29
+ 979 730 28 979 759 27 979 762 26 979 768 24 979 768 25 979 777 23
+ 979 786 22 979 790 21 979 792 20 979 794 19 979 805 18 979 822 17
+ 979 839 15 979 839 16 979 840 14 979 844 13 979 845 12 979 870 9
+ 979 870 10 979 870 11 979 899 9 979 911 8 979 929 7}
+
+do_execsql_test 5.4.14.2 {
+ SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t3
+ WINDOW win AS ( ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
+ ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES )
+ ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
+} {3830 89 89 4741 88 88 5640 84 84 5640 85 85 5640 86 86 5640 87 87
+ 6485 81 81 6485 82 82 6485 83 83 7324 80 80 8163 78 78 8163 79 79
+ 8968 73 73 8968 74 74 8968 75 75 8968 76 76 8968 77 77 9745 69 69
+ 9745 70 70 9745 71 71 9745 72 72 10504 65 65 10504 66 66
+ 10504 67 67 10504 68 68 11215 64 64 11920 63 63 12603 62 62
+ 13274 60 60 13274 61 61 13941 59 59 14608 55 55 14608 56 56
+ 14608 57 57 14608 58 58 15241 54 54 15870 53 53 16499 52 52
+ 17126 49 49 17126 50 50 17126 51 51 17733 44 44 17733 45 45
+ 17733 46 46 17733 47 47 17733 48 48 18176 42 42 18176 43 43
+ 18597 40 40 18597 41 41 18996 39 39 19395 37 37 19395 38 38
+ 19788 36 36 20181 35 35 20536 34 34 20891 30 30 20891 31 31
+ 20891 32 32 20891 33 33 21226 28 28 21226 29 29 21535 27 27
+ 21830 26 26 22087 22 22 22087 23 23 22087 24 24 22087 25 25
+ 22334 21 21 22573 17 17 22573 18 18 22573 19 19 22573 20 20
+ 22796 11 11 22796 12 12 22796 13 13 22796 14 14 22796 15 15
+ 22796 16 16 22929 10 10 23042 9 9 23155 1 1 23155 2 2 23155 3 3
+ 23155 4 4 23155 5 5 23155 6 6 23155 7 7 23155 8 8}
+
+#==========================================================================
+
+do_execsql_test 6.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a TEXT, b INTEGER);
+ INSERT INTO t2 VALUES('A', NULL);
+ INSERT INTO t2 VALUES('B', NULL);
+ INSERT INTO t2 VALUES('C', 1);
+} {}
+
+do_execsql_test 6.1 {
+ SELECT group_concat(a, '.') OVER (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 7 PRECEDING AND 2 PRECEDING
+ )
+ FROM t2
+} {A.B A.B {}}
+
+do_execsql_test 6.2 {
+ SELECT group_concat(a, '.') OVER (
+ ORDER BY b DESC NULLS LAST RANGE BETWEEN 7 PRECEDING AND 2 PRECEDING
+ )
+ FROM t2
+} {{} A.B A.B}
+
+#==========================================================================
+
+do_execsql_test 7.0 {
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t2(a INTEGER, b INTEGER);
+
+ INSERT INTO t2 VALUES(1, 65);
+ INSERT INTO t2 VALUES(2, NULL);
+ INSERT INTO t2 VALUES(3, NULL);
+ INSERT INTO t2 VALUES(4, NULL);
+ INSERT INTO t2 VALUES(5, 66);
+ INSERT INTO t2 VALUES(6, 67);
+} {}
+
+do_execsql_test 7.1.1 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 6 FOLLOWING AND UNBOUNDED FOLLOWING
+ );
+} {9 9 9 9 9 9}
+
+do_execsql_test 7.1.2 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+} {{} {} {} 9 9 9}
+
+do_execsql_test 7.1.3 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+} {{} {} {} 9 9 9}
+
+do_execsql_test 7.1.4 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+} {9 9 9 {} {} {}}
+
+do_execsql_test 7.1.5 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+} {9 9 9 {} {} {}}
+
+do_execsql_test 7.1.6 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1000 PRECEDING AND 2 PRECEDING
+ );
+} {{} {} 1 9 9 9}
+
+do_execsql_test 7.1.7 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+} {{} {} {} 9 9 9}
+
+do_execsql_test 7.1.8 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1000 PRECEDING AND 2000 PRECEDING
+ );
+} {9 9 9 {} {} {}}
+
+do_execsql_test 7.1.9 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+} {9 9 9 {} {} {}}
+
+do_execsql_test 7.2.1 {
+ SELECT min (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 6 FOLLOWING AND UNBOUNDED FOLLOWING
+ );
+} {2 2 2 2 2 2}
+
+do_execsql_test 7.2.2 {
+ SELECT min (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+} {{} {} {} 2 2 2}
+
+do_execsql_test 7.2.3 {
+ SELECT min (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+} {{} {} {} 2 2 2}
+
+do_execsql_test 7.2.4 {
+ SELECT min (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+} {2 2 2 {} {} {}}
+
+do_execsql_test 7.2.5 {
+ SELECT min (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+} {2 2 2 {} {} {}}
+
+do_execsql_test 7.2.6 {
+ SELECT min (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1000 PRECEDING AND 2 PRECEDING
+ );
+} {{} {} 1 2 2 2}
+
+do_execsql_test 7.2.7 {
+ SELECT min (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+} {{} {} {} 2 2 2}
+
+do_execsql_test 7.2.8 {
+ SELECT min (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1000 PRECEDING AND 2000 PRECEDING
+ );
+} {2 2 2 {} {} {}}
+
+do_execsql_test 7.2.9 {
+ SELECT min (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+} {2 2 2 {} {} {}}
+
+do_execsql_test 7.3.1 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 6 FOLLOWING AND UNBOUNDED FOLLOWING
+ );
+} {9 9 9 9 9 9}
+
+do_execsql_test 7.3.2 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+} {{} {} {} 9 9 9}
+
+do_execsql_test 7.3.3 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+} {{} {} {} 9 9 9}
+
+do_execsql_test 7.3.4 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+} {9 9 9 {} {} {}}
+
+do_execsql_test 7.3.5 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+} {9 9 9 {} {} {}}
+
+do_execsql_test 7.3.6 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1000 PRECEDING AND 2 PRECEDING
+ );
+} {{} {} 1 9 9 9}
+
+do_execsql_test 7.3.7 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+} {{} {} {} 9 9 9}
+
+do_execsql_test 7.3.8 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1000 PRECEDING AND 2000 PRECEDING
+ );
+} {9 9 9 {} {} {}}
+
+do_execsql_test 7.3.9 {
+ SELECT sum (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+} {9 9 9 {} {} {}}
+
+do_execsql_test 7.4.1 {
+ SELECT max (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 6 FOLLOWING AND UNBOUNDED FOLLOWING
+ );
+} {4 4 4 4 4 4}
+
+do_execsql_test 7.4.2 {
+ SELECT max (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+} {{} {} {} 4 4 4}
+
+do_execsql_test 7.4.3 {
+ SELECT max (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+} {{} {} {} 4 4 4}
+
+do_execsql_test 7.4.4 {
+ SELECT max (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ );
+} {4 4 4 {} {} {}}
+
+do_execsql_test 7.4.5 {
+ SELECT max (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
+ );
+} {4 4 4 {} {} {}}
+
+do_execsql_test 7.4.6 {
+ SELECT max (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 1000 PRECEDING AND 2 PRECEDING
+ );
+} {{} {} 1 4 4 4}
+
+do_execsql_test 7.4.7 {
+ SELECT max (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS LAST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+} {{} {} {} 4 4 4}
+
+do_execsql_test 7.4.8 {
+ SELECT max (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 1000 PRECEDING AND 2000 PRECEDING
+ );
+} {4 4 4 {} {} {}}
+
+do_execsql_test 7.4.9 {
+ SELECT max (a) OVER win FROM t2
+ WINDOW win AS (
+ ORDER BY b NULLS FIRST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
+ );
+} {4 4 4 {} {} {}}
+
+#==========================================================================
+
+do_execsql_test 8.0 {
+ DROP TABLE IF EXISTS tx;
+ CREATE TABLE tx(a INTEGER PRIMARY KEY);
+ INSERT INTO tx VALUES(1), (2), (3), (4), (5), (6);
+
+ DROP TABLE IF EXISTS map;
+ CREATE TABLE map(v INTEGER PRIMARY KEY, t TEXT);
+ INSERT INTO map VALUES
+ (1, 'odd'), (2, 'even'), (3, 'odd'),
+ (4, 'even'), (5, 'odd'), (6, 'even');
+} {}
+
+do_execsql_test 8.1 {
+ SELECT sum(a) OVER (
+ PARTITION BY (
+ SELECT t FROM map WHERE v=a
+ ) ORDER BY a
+ ) FROM tx;
+} {2 6 12 1 4 9}
+
+do_execsql_test 8.2 {
+ SELECT sum(a) OVER win FROM tx
+ WINDOW win AS (
+ PARTITION BY (
+ SELECT t FROM map WHERE v=a
+ ) ORDER BY a
+ );
+} {2 6 12 1 4 9}
+
+do_execsql_test 8.3 {
+ WITH map2 AS (
+ SELECT * FROM map
+ )
+ SELECT sum(a) OVER (
+ PARTITION BY (
+ SELECT t FROM map2 WHERE v=a
+ ) ORDER BY a
+ ) FROM tx;
+} {2 6 12 1 4 9}
+
+do_execsql_test 8.4 {
+ WITH map2 AS (
+ SELECT * FROM map
+ )
+ SELECT sum(a) OVER win FROM tx
+ WINDOW win AS (
+ PARTITION BY (
+ SELECT t FROM map2 WHERE v=a
+ ) ORDER BY a
+ );
+} {2 6 12 1 4 9}
+
+#==========================================================================
+
+do_execsql_test 9.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a INTEGER);
+ CREATE TABLE t2(y INTEGER);
+} {}
+
+do_execsql_test 9.2 {
+ SELECT (
+ SELECT max(a) OVER ( ORDER BY (SELECT sum(a) FROM t1) )
+ + min(a) OVER()
+ )
+ FROM t1
+} {}
+
+finish_test
diff --git a/test/window9.test b/test/window9.test
new file mode 100644
index 0000000..4b8e4fa
--- /dev/null
+++ b/test/window9.test
@@ -0,0 +1,285 @@
+# 2019 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix window9
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE fruits(
+ name TEXT COLLATE NOCASE,
+ color TEXT COLLATE NOCASE
+ );
+}
+
+do_execsql_test 1.1 {
+ INSERT INTO fruits (name, color) VALUES ('apple', 'RED');
+ INSERT INTO fruits (name, color) VALUES ('APPLE', 'yellow');
+ INSERT INTO fruits (name, color) VALUES ('pear', 'YELLOW');
+ INSERT INTO fruits (name, color) VALUES ('PEAR', 'green');
+}
+
+do_execsql_test 1.2 {
+ SELECT name, color, dense_rank() OVER (ORDER BY name) FROM fruits;
+} {
+ apple RED 1
+ APPLE yellow 1
+ pear YELLOW 2
+ PEAR green 2
+}
+
+do_execsql_test 1.3 {
+ SELECT name, color,
+ dense_rank() OVER (PARTITION BY name ORDER BY color)
+ FROM fruits;
+} {
+ apple RED 1
+ APPLE yellow 2
+ PEAR green 1
+ pear YELLOW 2
+}
+
+do_execsql_test 1.4 {
+ SELECT name, color,
+ dense_rank() OVER (ORDER BY name),
+ dense_rank() OVER (PARTITION BY name ORDER BY color)
+ FROM fruits;
+} {
+ apple RED 1 1
+ APPLE yellow 1 2
+ PEAR green 2 1
+ pear YELLOW 2 2
+}
+
+do_execsql_test 1.5 {
+ SELECT name, color,
+ dense_rank() OVER (ORDER BY name),
+ dense_rank() OVER (PARTITION BY name ORDER BY color)
+ FROM fruits ORDER BY color;
+} {
+ PEAR green 2 1
+ apple RED 1 1
+ APPLE yellow 1 2
+ pear YELLOW 2 2
+}
+
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a BLOB, b INTEGER, c COLLATE nocase);
+ INSERT INTO t1 VALUES(1, 2, 'abc');
+ INSERT INTO t1 VALUES(3, 4, 'ABC');
+}
+
+do_execsql_test 2.1.1 {
+ SELECT c=='Abc' FROM t1
+} {1 1}
+do_execsql_test 2.1.2 {
+ SELECT c=='Abc', rank() OVER (ORDER BY b) FROM t1
+} {1 1 1 2}
+
+do_execsql_test 2.2.1 {
+ SELECT b=='2' FROM t1
+} {1 0}
+do_execsql_test 2.2.2 {
+ SELECT b=='2', rank() OVER (ORDER BY a) FROM t1
+} {1 1 0 2}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(a);
+ CREATE TABLE t2(a,b,c);
+}
+
+do_execsql_test 3.1 {
+ SELECT EXISTS(SELECT 1 FROM t1 ORDER BY sum(a) OVER ()) FROM t1;
+}
+
+do_execsql_test 3.2 {
+ SELECT sum(a) OVER () FROM t2
+ ORDER BY EXISTS(SELECT 1 FROM t2 ORDER BY sum(a) OVER ());
+}
+
+do_catchsql_test 3.3 {
+ SELECT a, sum(a) OVER (ORDER BY a DESC) FROM t2
+ ORDER BY EXISTS(
+ SELECT 1 FROM t2 ORDER BY sum(a) OVER (ORDER BY a)
+ ) OVER (ORDER BY a);
+} {1 {near "OVER": syntax error}}
+
+do_catchsql_test 3.4 {
+ SELECT y, y+1, y+2 FROM (
+ SELECT c IN (
+ SELECT min(a) OVER (),
+ (abs(row_number() OVER())+22)/19,
+ max(a) OVER () FROM t1
+ ) AS y FROM t2
+ );
+} {1 {sub-select returns 3 columns - expected 1}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1(a, b TEXT);
+ INSERT INTO t1 VALUES('A', 1), ('A', 2), ('2', 1), ('2', 2);
+}
+
+do_execsql_test 4.1.1 {
+ SELECT b, b=count(*), '1,2' FROM t1 GROUP BY b;
+} {1 0 1,2 2 1 1,2}
+do_execsql_test 4.1.2 {
+ SELECT b, b=count(*), group_concat(b) OVER () FROM t1 GROUP BY b;
+} {1 0 1,2 2 1 1,2}
+
+#--------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a, b, c, d, e);
+ CREATE INDEX i1 ON t1(a, b, c, d, e);
+}
+
+foreach {tn sql} {
+ 1 {
+ SELECT
+ sum(e) OVER (),
+ sum(e) OVER (ORDER BY a),
+ sum(e) OVER (PARTITION BY a ORDER BY b),
+ sum(e) OVER (PARTITION BY a, b ORDER BY c),
+ sum(e) OVER (PARTITION BY a, b, c ORDER BY d)
+ FROM t1;
+ }
+ 2 {
+ SELECT sum(e) OVER (PARTITION BY a ORDER BY b) FROM t1 ORDER BY a;
+ }
+} {
+ do_test 5.1.$tn {
+ execsql "EXPLAIN QUERY PLAN $sql"
+ } {~/ORDER/}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 6.0 {
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES (0);
+}
+
+do_execsql_test 6.1 {
+ SELECT * FROM t0 WHERE
+ EXISTS (
+ SELECT MIN(c0) OVER (), CUME_DIST() OVER () FROM t0
+ ) >=1 AND
+ EXISTS (
+ SELECT MIN(c0) OVER (), CUME_DIST() OVER () FROM t0
+ ) <=1;
+} {0}
+
+do_execsql_test 6.2 {
+ SELECT * FROM t0 WHERE EXISTS (
+ SELECT MIN(c0) OVER (), CUME_DIST() OVER () FROM t0
+ )
+ BETWEEN 1 AND 1;
+} {0}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 7.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES(10, 1);
+ INSERT INTO t1 VALUES(20, 2);
+ INSERT INTO t1 VALUES(3, 3);
+ INSERT INTO t1 VALUES(2, 4);
+ INSERT INTO t1 VALUES(1, 5);
+} {}
+
+
+do_execsql_test 7.1 {
+ SELECT avg(x) OVER (ORDER BY y) AS z FROM t1 ORDER BY z
+} {
+ 7.2 8.75 10.0 11.0 15.0
+}
+
+do_execsql_test 7.2 {
+ SELECT avg(x) OVER (ORDER BY y) z FROM t1 ORDER BY (z IS y);
+} {
+ 10.0 15.0 11.0 8.75 7.2
+}
+
+do_execsql_test 7.3 {
+ SELECT avg(x) OVER (ORDER BY y) z FROM t1 ORDER BY (y IS z);
+} {
+ 10.0 15.0 11.0 8.75 7.2
+}
+
+do_execsql_test 7.4 {
+ SELECT avg(x) OVER (ORDER BY y) z FROM t1 ORDER BY z + 0.0;
+} {
+ 7.2 8.75 10.0 11.0 15.0
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 8.1.1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2), (3, 4);
+ SELECT min( sum(a) ) OVER () FROM t1;
+} {4}
+
+do_execsql_test 8.1.2 {
+ SELECT min( sum(a) ) OVER () FROM t1 GROUP BY a;
+} {1 1}
+
+do_execsql_test 8.2 {
+ CREATE VIEW v1 AS
+ SELECT 0 AS x
+ UNION
+ SELECT count() OVER() FROM (SELECT 0)
+ ORDER BY 1
+ ;
+}
+
+do_catchsql_test 8.3 {
+ SELECT min( max((SELECT x FROM v1)) ) OVER()
+} {0 0}
+
+do_execsql_test 8.4 {
+ SELECT(
+ SELECT x UNION
+ SELECT sum( avg((SELECT x FROM v1)) ) OVER()
+ )
+ FROM v1;
+} {0.0 0.0}
+
+#--------------------------------------------------------------------------
+reset_db
+do_execsql_test 9.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(NULL,'bb',356);
+ INSERT INTO t1 VALUES('CB','aa',158);
+ INSERT INTO t1 VALUES('BB','aa',399);
+ INSERT INTO t1 VALUES('FF','bb',938);
+}
+
+do_catchsql_test 9.1 {
+ SELECT sum(c) OVER (
+ ORDER BY c RANGE BETWEEN 0 PRECEDING AND '-700' PRECEDING
+ )
+ FROM t1
+} {1 {frame ending offset must be a non-negative number}}
+
+finish_test
diff --git a/test/windowA.test b/test/windowA.test
new file mode 100644
index 0000000..e94ae57
--- /dev/null
+++ b/test/windowA.test
@@ -0,0 +1,309 @@
+# 2019-08-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.
+#
+#***********************************************************************
+# Test cases for RANGE BETWEEN and especially with NULLS LAST
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix windowA
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b CHAR(1), d FLOAT);
+ INSERT INTO t1 VALUES
+ (1, 'A', 5.4),
+ (2, 'B', 5.55),
+ (3, 'C', 8.0),
+ (4, 'D', 10.25),
+ (5, 'E', 10.26),
+ (6, 'N', NULL),
+ (7, 'N', NULL);
+} {}
+
+do_execsql_test 1.1 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS LAST
+ RANGE BETWEEN 2.50 PRECEDING AND 2.25 FOLLOWING)
+ ORDER BY +d DESC NULLS LAST, +a;
+} [list \
+ 5 E 10.26 ED \
+ 4 D 10.25 EDC \
+ 3 C 8.0 EDC \
+ 2 B 5.55 CBA \
+ 1 A 5.4 BA \
+ 6 N NULL NN \
+ 7 N NULL NN \
+]
+
+do_execsql_test 1.2 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS FIRST
+ RANGE BETWEEN 2.50 PRECEDING AND 2.25 FOLLOWING)
+ ORDER BY +d DESC NULLS FIRST, +a;
+} [list \
+ 6 N NULL NN \
+ 7 N NULL NN \
+ 5 E 10.26 ED \
+ 4 D 10.25 EDC \
+ 3 C 8.0 EDC \
+ 2 B 5.55 CBA \
+ 1 A 5.4 BA \
+]
+
+do_execsql_test 1.3 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS LAST
+ RANGE BETWEEN 2.50 PRECEDING AND UNBOUNDED FOLLOWING)
+ ORDER BY +d DESC NULLS LAST, +a;
+} [list \
+ 5 E 10.26 EDCBANN \
+ 4 D 10.25 EDCBANN \
+ 3 C 8.0 EDCBANN \
+ 2 B 5.55 CBANN \
+ 1 A 5.4 BANN \
+ 6 N NULL NN \
+ 7 N NULL NN \
+]
+
+do_execsql_test 1.4 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS FIRST
+ RANGE BETWEEN 2.50 PRECEDING AND UNBOUNDED FOLLOWING)
+ ORDER BY +d DESC NULLS FIRST, +a;
+} [list \
+ 6 N NULL NNEDCBA \
+ 7 N NULL NNEDCBA \
+ 5 E 10.26 EDCBA \
+ 4 D 10.25 EDCBA \
+ 3 C 8.0 EDCBA \
+ 2 B 5.55 CBA \
+ 1 A 5.4 BA \
+]
+
+do_execsql_test 1.5 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS LAST
+ RANGE BETWEEN 2.50 PRECEDING AND CURRENT ROW)
+ ORDER BY +d DESC NULLS LAST, +a;
+} [list \
+ 5 E 10.26 E \
+ 4 D 10.25 ED \
+ 3 C 8.0 EDC \
+ 2 B 5.55 CB \
+ 1 A 5.4 BA \
+ 6 N NULL NN \
+ 7 N NULL NN \
+]
+
+do_execsql_test 1.6 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS FIRST
+ RANGE BETWEEN 2.50 PRECEDING AND CURRENT ROW)
+ ORDER BY +d DESC NULLS FIRST, +a;
+} [list \
+ 6 N NULL NN \
+ 7 N NULL NN \
+ 5 E 10.26 E \
+ 4 D 10.25 ED \
+ 3 C 8.0 EDC \
+ 2 B 5.55 CB \
+ 1 A 5.4 BA \
+]
+
+do_execsql_test 2.1 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS LAST
+ RANGE BETWEEN UNBOUNDED PRECEDING AND 2.25 FOLLOWING)
+ ORDER BY +d DESC NULLS LAST, +a;
+} [list \
+ 5 E 10.26 ED \
+ 4 D 10.25 EDC \
+ 3 C 8.0 EDC \
+ 2 B 5.55 EDCBA \
+ 1 A 5.4 EDCBA \
+ 6 N NULL EDCBANN \
+ 7 N NULL EDCBANN \
+]
+
+do_execsql_test 2.2 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS FIRST
+ RANGE BETWEEN UNBOUNDED PRECEDING AND 2.25 FOLLOWING)
+ ORDER BY +d DESC NULLS FIRST, +a;
+} [list \
+ 6 N NULL NN \
+ 7 N NULL NN \
+ 5 E 10.26 NNED \
+ 4 D 10.25 NNEDC \
+ 3 C 8.0 NNEDC \
+ 2 B 5.55 NNEDCBA \
+ 1 A 5.4 NNEDCBA \
+]
+
+do_execsql_test 2.3 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS LAST
+ RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ ORDER BY +d DESC NULLS LAST, +a;
+} [list \
+ 5 E 10.26 EDCBANN \
+ 4 D 10.25 EDCBANN \
+ 3 C 8.0 EDCBANN \
+ 2 B 5.55 EDCBANN \
+ 1 A 5.4 EDCBANN \
+ 6 N NULL EDCBANN \
+ 7 N NULL EDCBANN \
+]
+
+do_execsql_test 2.4 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS FIRST
+ RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
+ ORDER BY +d DESC NULLS FIRST, +a;
+} [list \
+ 6 N NULL NNEDCBA \
+ 7 N NULL NNEDCBA \
+ 5 E 10.26 NNEDCBA \
+ 4 D 10.25 NNEDCBA \
+ 3 C 8.0 NNEDCBA \
+ 2 B 5.55 NNEDCBA \
+ 1 A 5.4 NNEDCBA \
+]
+
+do_execsql_test 2.5 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS LAST
+ RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ ORDER BY +d DESC NULLS LAST, +a;
+} [list \
+ 5 E 10.26 E \
+ 4 D 10.25 ED \
+ 3 C 8.0 EDC \
+ 2 B 5.55 EDCB \
+ 1 A 5.4 EDCBA \
+ 6 N NULL EDCBANN \
+ 7 N NULL EDCBANN \
+]
+
+do_execsql_test 2.6 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS FIRST
+ RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+ ORDER BY +d DESC NULLS FIRST, +a;
+} [list \
+ 6 N NULL NN \
+ 7 N NULL NN \
+ 5 E 10.26 NNE \
+ 4 D 10.25 NNED \
+ 3 C 8.0 NNEDC \
+ 2 B 5.55 NNEDCB \
+ 1 A 5.4 NNEDCBA \
+]
+
+
+do_execsql_test 3.1 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND 2.25 FOLLOWING)
+ ORDER BY +d DESC NULLS LAST, +a;
+} [list \
+ 5 E 10.26 ED \
+ 4 D 10.25 DC \
+ 3 C 8.0 C \
+ 2 B 5.55 BA \
+ 1 A 5.4 A \
+ 6 N NULL NN \
+ 7 N NULL NN \
+]
+
+do_execsql_test 3.2 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND 2.25 FOLLOWING)
+ ORDER BY +d DESC NULLS FIRST, +a;
+} [list \
+ 6 N NULL NN \
+ 7 N NULL NN \
+ 5 E 10.26 ED \
+ 4 D 10.25 DC \
+ 3 C 8.0 C \
+ 2 B 5.55 BA \
+ 1 A 5.4 A \
+]
+
+do_execsql_test 3.3 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS LAST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ ORDER BY +d DESC NULLS LAST, +a;
+} [list \
+ 5 E 10.26 EDCBANN \
+ 4 D 10.25 DCBANN \
+ 3 C 8.0 CBANN \
+ 2 B 5.55 BANN \
+ 1 A 5.4 ANN \
+ 6 N NULL NN \
+ 7 N NULL NN \
+]
+
+do_execsql_test 3.4 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS FIRST
+ RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ ORDER BY +d DESC NULLS FIRST, +a;
+} [list \
+ 6 N NULL NNEDCBA \
+ 7 N NULL NNEDCBA \
+ 5 E 10.26 EDCBA \
+ 4 D 10.25 DCBA \
+ 3 C 8.0 CBA \
+ 2 B 5.55 BA \
+ 1 A 5.4 A \
+]
+
+do_execsql_test 4.0 {
+ SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
+ WINDOW w1 AS
+ (ORDER BY d DESC NULLS FIRST
+ RANGE BETWEEN 2.50 PRECEDING AND 0.5 PRECEDING)
+ ORDER BY +d DESC NULLS FIRST, +a;
+} [list \
+ 6 N NULL NN \
+ 7 N NULL NN \
+ 5 E 10.26 {} \
+ 4 D 10.25 {} \
+ 3 C 8.0 ED \
+ 2 B 5.55 C \
+ 1 A 5.4 {} \
+]
+
+
+finish_test
diff --git a/test/windowB.test b/test/windowB.test
new file mode 100644
index 0000000..0a9aef7
--- /dev/null
+++ b/test/windowB.test
@@ -0,0 +1,413 @@
+# 2019-08-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.
+#
+#***********************************************************************
+# Test cases for RANGE BETWEEN and especially with NULLS LAST
+# and for varying separator handling by group_concat().
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix windowB
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(NULL, 1);
+ INSERT INTO t1 VALUES(NULL, 2);
+ INSERT INTO t1 VALUES(NULL, 3);
+} {}
+
+foreach {tn win} {
+ 1 { ORDER BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING }
+ 2 { ORDER BY a NULLS LAST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING }
+ 3 { ORDER BY a DESC RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING }
+ 4 { ORDER BY a DESC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING }
+
+ 5 { ORDER BY a NULLS LAST RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING }
+ 6 { ORDER BY a DESC NULLS FIRST RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING }
+
+ 7 { ORDER BY a NULLS LAST RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING }
+ 8 { ORDER BY a DESC NULLS FIRST RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING }
+} {
+ do_execsql_test 1.$tn "
+ SELECT sum(b) OVER win FROM t1
+ WINDOW win AS ( $win )
+ " {6 6 6}
+}
+
+do_execsql_test 1.2 {
+ SELECT sum(b) OVER win FROM t1
+ WINDOW win AS (
+ ORDER BY a DESC NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ )
+} {6 6 6}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, NULL);
+ INSERT INTO t1 VALUES(2, 45);
+ INSERT INTO t1 VALUES(3, 66.2);
+ INSERT INTO t1 VALUES(4, 'hello world');
+ INSERT INTO t1 VALUES(5, 'hello world');
+ INSERT INTO t1 VALUES(6, X'1234');
+ INSERT INTO t1 VALUES(7, X'1234');
+ INSERT INTO t1 VALUES(8, NULL);
+}
+
+foreach {tn win} {
+ 1 "ORDER BY b RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING"
+ 2 "ORDER BY b RANGE BETWEEN 2 FOLLOWING AND 2 FOLLOWING"
+ 3 "ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING"
+ 4 "ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 2 FOLLOWING"
+} {
+ do_execsql_test 2.1.$tn "
+ SELECT a, sum(a) OVER win FROM t1
+ WINDOW win AS ( $win )
+ ORDER BY 1
+ " {1 9 2 {} 3 {} 4 9 5 9 6 13 7 13 8 9}
+}
+
+#-------------------------------------------------------------------------
+ifcapable json1 {
+ reset_db
+ do_execsql_test 3.0 {
+ CREATE TABLE testjson(id INTEGER PRIMARY KEY, j TEXT, x TEXT);
+ INSERT INTO testjson VALUES(1, '{"a":1}', 'a');
+ INSERT INTO testjson VALUES(2, '{"b":2}', 'b');
+ INSERT INTO testjson VALUES(3, '{"c":3}', 'c');
+ INSERT INTO testjson VALUES(4, '{"d":4}', 'd');
+ }
+
+ do_execsql_test 3.1 {
+ SELECT json_group_array(json(j)) FROM testjson;
+ } {
+ {[{"a":1},{"b":2},{"c":3},{"d":4}]}
+ }
+
+ do_execsql_test 3.2 {
+ SELECT json_group_array(json(j)) OVER (ORDER BY id) FROM testjson;
+ } {
+ {[{"a":1}]}
+ {[{"a":1},{"b":2}]}
+ {[{"a":1},{"b":2},{"c":3}]}
+ {[{"a":1},{"b":2},{"c":3},{"d":4}]}
+ }
+
+ do_execsql_test 3.3 {
+ SELECT json_group_array(json(j)) OVER (
+ ORDER BY id RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ EXCLUDE TIES
+ ) FROM testjson;
+ } {
+ {[{"a":1}]}
+ {[{"a":1},{"b":2}]}
+ {[{"a":1},{"b":2},{"c":3}]}
+ {[{"a":1},{"b":2},{"c":3},{"d":4}]}
+ }
+
+ do_execsql_test 3.4 {
+ SELECT json_group_array(json(j)) OVER (
+ ORDER BY id ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM testjson;
+ } {
+ {[{"a":1},{"b":2}]}
+ {[{"a":1},{"b":2},{"c":3}]}
+ {[{"b":2},{"c":3},{"d":4}]}
+ {[{"c":3},{"d":4}]}
+ }
+
+ do_execsql_test 3.5 {
+ SELECT json_group_array(json(j)) OVER (
+ ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING
+ ) FROM testjson;
+ } {
+ {[]}
+ {[{"a":1}]}
+ {[{"a":1},{"b":2}]}
+ {[{"b":2},{"c":3}]}
+ }
+
+ do_execsql_test 3.5a {
+ UPDATE testjson SET j = replace(j,char(125),',"e":9'||char(125));
+ SELECT j FROM testjson;
+ } {
+ {{"a":1,"e":9}}
+ {{"b":2,"e":9}}
+ {{"c":3,"e":9}}
+ {{"d":4,"e":9}}
+ }
+ do_execsql_test 3.5b {
+ SELECT group_concat(x,'') OVER (
+ ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING
+ ) FROM testjson ORDER BY id;
+ } {bc cd d {}}
+ do_execsql_test 3.5c {
+ SELECT json_group_array(json(j)) OVER (
+ ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING
+ ) FROM testjson;
+ } {
+ {[{"b":2,"e":9},{"c":3,"e":9}]}
+ {[{"c":3,"e":9},{"d":4,"e":9}]}
+ {[{"d":4,"e":9}]}
+ {[]}
+ }
+ do_execsql_test 3.5d {
+ SELECT json_group_object(x,json(j)) OVER (
+ ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING
+ ) FROM testjson;
+ } {
+ {{"b":{"b":2,"e":9},"c":{"c":3,"e":9}}}
+ {{"c":{"c":3,"e":9},"d":{"d":4,"e":9}}}
+ {{"d":{"d":4,"e":9}}}
+ {{}}
+ }
+
+ do_execsql_test 3.7b {
+ SELECT group_concat(x,'') FILTER (WHERE id!=2) OVER (
+ ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING
+ ) FROM testjson;
+ } {{} a a c}
+
+ do_execsql_test 3.7c {
+ SELECT json_group_array(json(j)) FILTER (WHERE id!=2) OVER (
+ ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING
+ ) FROM testjson
+ } {
+ {[]}
+ {[{"a":1,"e":9}]}
+ {[{"a":1,"e":9}]}
+ {[{"c":3,"e":9}]}
+ }
+ do_execsql_test 3.7d {
+ SELECT json_group_object(x,json(j)) FILTER (WHERE id!=2) OVER (
+ ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING
+ ) FROM testjson
+ } {
+ {{}}
+ {{"a":{"a":1,"e":9}}}
+ {{"a":{"a":1,"e":9}}}
+ {{"c":{"c":3,"e":9}}}
+ }
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE x(a);
+ INSERT INTO x VALUES(1);
+ INSERT INTO x VALUES(2);
+}
+
+do_execsql_test 4.1 {
+ WITH y AS (
+ SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION BY a)
+ )
+ SELECT * FROM y;
+} {
+ 1 1
+}
+
+do_catchsql_test 4.2 {
+ WITH y AS (
+ SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION
+ BY fake_column))
+ SELECT * FROM y;
+} {1 {no such column: fake_column}}
+
+do_catchsql_test 4.3 {
+ SELECT 1 WINDOW win AS (PARTITION BY fake_column);
+} {0 1}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a, c);
+ CREATE INDEX i1 ON t1(a);
+
+ INSERT INTO t1 VALUES(0, 421);
+ INSERT INTO t1 VALUES(1, 844);
+ INSERT INTO t1 VALUES(2, 1001);
+}
+
+do_execsql_test 5.1 {
+ SELECT a, sum(c) OVER (
+ ORDER BY a RANGE BETWEEN 0 PRECEDING AND 3 PRECEDING
+ ) FROM t1;
+} {0 {} 1 {} 2 {}}
+
+do_execsql_test 5.2 {
+ INSERT INTO t1 VALUES(NULL, 123);
+ INSERT INTO t1 VALUES(NULL, 111);
+ INSERT INTO t1 VALUES('xyz', 222);
+ INSERT INTO t1 VALUES('xyz', 333);
+
+ SELECT a, sum(c) OVER (
+ ORDER BY a RANGE BETWEEN 0 PRECEDING AND 3 PRECEDING
+ ) FROM t1;
+} {{} 234 {} 234 0 {} 1 {} 2 {} xyz 555 xyz 555}
+
+do_execsql_test 5.3 {
+ SELECT a, sum(c) OVER (
+ ORDER BY a RANGE BETWEEN 2 FOLLOWING AND 0 FOLLOWING
+ ) FROM t1;
+} {{} 234 {} 234 0 {} 1 {} 2 {} xyz 555 xyz 555}
+
+do_execsql_test 5.4 {
+ SELECT a, sum(c) OVER (
+ ORDER BY a RANGE BETWEEN 0 PRECEDING AND 3 PRECEDING EXCLUDE NO OTHERS
+ ) FROM t1;
+} {{} 234 {} 234 0 {} 1 {} 2 {} xyz 555 xyz 555}
+
+do_execsql_test 5.5 {
+ SELECT a, sum(c) OVER (
+ ORDER BY a RANGE BETWEEN 2 FOLLOWING AND 0 FOLLOWING EXCLUDE NO OTHERS
+ ) FROM t1;
+} {{} 234 {} 234 0 {} 1 {} 2 {} xyz 555 xyz 555}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 6.0 {
+ CREATE TABLE t1(a, c);
+ CREATE INDEX i1 ON t1(a);
+
+ INSERT INTO t1 VALUES(7, 997);
+ INSERT INTO t1 VALUES(8, 997);
+ INSERT INTO t1 VALUES('abc', 1001);
+}
+do_execsql_test 6.1 {
+ SELECT a, sum(c) OVER (
+ ORDER BY a RANGE BETWEEN 2 FOLLOWING AND 0 FOLLOWING
+ ) FROM t1;
+} {7 {} 8 {} abc 1001}
+do_execsql_test 6.2 {
+ SELECT a, sum(c) OVER (
+ ORDER BY a RANGE BETWEEN 2 FOLLOWING AND 0 FOLLOWING EXCLUDE NO OTHERS
+ ) FROM t1;
+} {7 {} 8 {} abc 1001}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 7.0 {
+ CREATE TABLE t1(a, c);
+ CREATE INDEX i1 ON t1(a);
+
+ INSERT INTO t1 VALUES(NULL, 46);
+ INSERT INTO t1 VALUES(NULL, 45);
+ INSERT INTO t1 VALUES(7, 997);
+ INSERT INTO t1 VALUES(7, 1000);
+ INSERT INTO t1 VALUES(8, 997);
+ INSERT INTO t1 VALUES(8, 1000);
+ INSERT INTO t1 VALUES('abc', 1001);
+ INSERT INTO t1 VALUES('abc', 1004);
+ INSERT INTO t1 VALUES('xyz', 3333);
+}
+
+do_execsql_test 7.1 {
+ SELECT a, max(c) OVER (
+ ORDER BY a RANGE BETWEEN 2 FOLLOWING AND 0 FOLLOWING
+ ) FROM t1;
+} {{} 46 {} 46 7 {} 7 {} 8 {} 8 {} abc 1004 abc 1004 xyz 3333}
+do_execsql_test 7.2 {
+ SELECT a, min(c) OVER (
+ ORDER BY a RANGE BETWEEN 2 FOLLOWING AND 0 FOLLOWING
+ ) FROM t1;
+} {{} 45 {} 45 7 {} 7 {} 8 {} 8 {} abc 1001 abc 1001 xyz 3333}
+
+do_execsql_test 7.3 {
+ SELECT a, max(c) OVER (
+ ORDER BY a RANGE BETWEEN 0 PRECEDING AND 2 PRECEDING
+ ) FROM t1;
+} {{} 46 {} 46 7 {} 7 {} 8 {} 8 {} abc 1004 abc 1004 xyz 3333}
+do_execsql_test 7.4 {
+ SELECT a, min(c) OVER (
+ ORDER BY a RANGE BETWEEN 0 PRECEDING AND 2 PRECEDING
+ ) FROM t1;
+} {{} 45 {} 45 7 {} 7 {} 8 {} 8 {} abc 1001 abc 1001 xyz 3333}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 8.0 {
+ BEGIN TRANSACTION;
+ CREATE TABLE t1(a, c);
+ INSERT INTO t1 VALUES('aa', 111);
+ INSERT INTO t1 VALUES('BB', 660);
+ INSERT INTO t1 VALUES('CC', 938);
+ INSERT INTO t1 VALUES('dd', 979);
+ COMMIT;
+
+ CREATE INDEX i1 ON t1(a COLLATE nocase);
+}
+
+do_execsql_test 8.1 {
+ SELECT sum(c) OVER
+ (ORDER BY a COLLATE nocase RANGE BETWEEN 10.0 PRECEDING AND 5.0 PRECEDING)
+ FROM t1;
+} {111 660 938 979}
+
+do_execsql_test 9.0 {
+ CREATE TABLE seps(x);
+ INSERT INTO seps(x) VALUES ('1'), ('22'), ('333'), ('4444');
+ SELECT group_concat('-', x)
+ OVER ( ORDER BY x ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING )
+ FROM seps;
+} {-22- -22-333- -333-4444- -4444-}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 10.1 {
+ CREATE TABLE t1(i INTEGER PRIMARY KEY, v);
+ INSERT INTO t1 VALUES( 1, 'one' );
+ INSERT INTO t1 VALUES( 2, 'two' );
+}
+
+do_execsql_test 10.2 {
+ SELECT
+ json_group_array( v ) OVER w,
+ json_group_array( v ) OVER w
+ FROM t1
+ window w as (
+ range between unbounded preceding and unbounded following
+ )
+} {
+ {["one","two"]}
+ {["one","two"]}
+ {["one","two"]}
+ {["one","two"]}
+}
+
+do_execsql_test 10.3 {
+ SELECT
+ group_concat( v ) OVER w,
+ json_group_array( v ) OVER w,
+ json_group_array( v ) OVER w,
+ group_concat( v ) OVER w
+ FROM t1
+ window w as (
+ range between unbounded preceding and unbounded following
+ )
+} {
+ one,two
+ {["one","two"]}
+ {["one","two"]}
+ one,two
+
+ one,two
+ {["one","two"]}
+ {["one","two"]}
+ one,two
+}
+
+finish_test
diff --git a/test/windowC.test b/test/windowC.test
new file mode 100644
index 0000000..013876f
--- /dev/null
+++ b/test/windowC.test
@@ -0,0 +1,85 @@
+# 2021-09-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.
+#
+#***********************************************************************
+# Test cases for varying separator handling by group_concat().
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix windowC
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE x1(i INTEGER PRIMARY KEY, x);
+}
+
+foreach {tn bBlob seps} {
+ 1 0 {a b c def g}
+ 2 0 {abcdefg {} {} abcdefg}
+ 3 0 {a bc def ghij klmno pqrstu}
+ 4 1 {a bc def ghij klmno pqrstu}
+ 5 1 {, , , , , , , , , , , , ....... , ,}
+} {
+ foreach type {text blob} {
+ do_test 1.$type.$tn.1 {
+ execsql { DELETE FROM x1 }
+ foreach s $seps {
+ if {$type=="text"} {
+ execsql {INSERT INTO x1 VALUES(NULL, $s)}
+ } else {
+ execsql {INSERT INTO x1 VALUES(NULL, CAST ($s AS blob))}
+ }
+ }
+ } {}
+
+ foreach {tn2 win} {
+ 1 "ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING"
+ 2 "ROWS BETWEEN 2 PRECEDING AND CURRENT ROW"
+ 3 "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING"
+ } {
+ do_test 1.$type.$tn.2.$tn2 {
+ db eval "
+ SELECT group_concat('val', x) OVER ( ORDER BY i $win ) AS val FROM x1
+ " {
+ if {[string range $val 0 2]!="val"
+ || [string range $val end-2 end]!="val"
+ } {
+ error "unexpected return value: $val"
+ }
+ }
+ } {}
+ }
+ }
+}
+
+# 2021-10-12 dbsqlfuzz 6c31db077a14149a7b22a1069294bdb068be8a96
+#
+reset_db
+do_execsql_test 2.0 {
+ PRAGMA encoding=UTF16le;
+ WITH separator(x) AS (VALUES(',a,'),(',bc,')),
+ value(y) AS (VALUES(1),(x'5585d09013455178cd11ce4a'))
+ SELECT group_concat(y,x) OVER (ORDER BY x ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM separator, value;
+} {{} 1 蕕郐䔓硑ᇍ䫎 1}
+reset_db
+do_execsql_test 2.1 {
+ PRAGMA encoding=UTF16be;
+ WITH separator(x) AS (VALUES(',a,'),(',bc,')),
+ value(y) AS (VALUES(1),(x'5585d09013455178cd11ce4a'))
+ SELECT group_concat(y,x) OVER (ORDER BY x ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
+ FROM separator, value;
+} {{} 1 喅킐ፅ典촑칊 1}
+
+finish_test
diff --git a/test/windowD.test b/test/windowD.test
new file mode 100644
index 0000000..f2ec36a
--- /dev/null
+++ b/test/windowD.test
@@ -0,0 +1,94 @@
+# 2022 June 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix windowD
+
+
+do_execsql_test 1.0 {
+ CREATE TABLE t0(c0 TEXT);
+ CREATE VIEW v0(c0, c1)
+ AS SELECT CUME_DIST() OVER (PARTITION BY t0.c0), TRUE FROM t0;
+ INSERT INTO t0 VALUES ('x');
+}
+
+do_execsql_test 1.1 {
+ SELECT ('500') IS (v0.c1) FROM v0;
+} {
+ 0
+}
+
+do_execsql_test 1.2 {
+ SELECT (('500') IS (v0.c1)) FROM v0, t0;
+} {
+ 0
+}
+
+do_execsql_test 1.2 {
+ SELECT (('500') IS (v0.c1)) IS FALSE FROM v0;
+} {
+ 1
+}
+
+do_execsql_test 1.3 {
+ SELECT * FROM v0;
+} {
+ 1.0 1
+}
+
+do_execsql_test 1.4 {
+ SELECT * FROM v0 WHERE ('500' IS v0.c1) IS FALSE;
+} {
+ 1.0 1
+}
+
+#-------------------------------------------------------------------------
+
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('value');
+ CREATE VIEW v1(a, b, c, d) AS SELECT 1, 2, TRUE, FALSE FROM t1;
+}
+
+do_execsql_test 2.1 {
+ SELECT 500 IS a, 500 IS b, 500 IS c, 500 IS d FROM v1
+} {0 0 0 0}
+
+do_execsql_test 2.2 {
+ SELECT * FROM v1 WHERE 500 IS c;
+} {}
+
+do_execsql_test 2.3 {
+ SELECT * FROM v1 WHERE 500 IS d;
+} {}
+
+do_execsql_test 2.4 {
+ CREATE VIEW v2 AS SELECT max(x) OVER () AS a, TRUE AS c FROM t1;
+}
+
+do_execsql_test 2.5 {
+ SELECT 500 IS c FROM v2;
+} 0
+
+do_execsql_test 2.6 {
+ SELECT * FROM v2 WHERE 500 IS c;
+} {}
+
+
+
+
+
+
+finish_test
+
diff --git a/test/windowE.test b/test/windowE.test
new file mode 100644
index 0000000..f20bcda
--- /dev/null
+++ b/test/windowE.test
@@ -0,0 +1,58 @@
+# 2022 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
+set testprefix windowE
+
+proc custom {a b} { return [string compare $a $b] }
+db collate custom custom
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT COLLATE custom);
+ 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');
+ INSERT INTO t1 VALUES(6, 'six');
+ CREATE INDEX t1b ON t1(b);
+}
+
+do_execsql_test 1.1 {
+ SELECT * FROM t1
+} {
+ 1 one 2 two 3 three 4 four 5 five 6 six
+}
+
+do_execsql_test 1.2 {
+ SELECT group_concat(a,',') OVER win FROM t1
+ WINDOW win AS (
+ ORDER BY b RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ )
+} {
+ 5 4 1 6 3 2
+}
+
+proc custom {a b} { return [string compare $b $a] }
+
+do_execsql_test 1.3 {
+ SELECT group_concat(a,',') OVER win FROM t1
+ WINDOW win AS (
+ ORDER BY b RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
+ )
+} {
+ 5 5,4 5,4,1 5,4,1,6 5,4,1,6,3 5,4,1,6,3,2
+}
+
+finish_test
+
diff --git a/test/windowerr.tcl b/test/windowerr.tcl
new file mode 100644
index 0000000..294e68d
--- /dev/null
+++ b/test/windowerr.tcl
@@ -0,0 +1,72 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+source [file join [file dirname $argv0] pg_common.tcl]
+
+#=========================================================================
+
+start_test windowerr "2019 March 01"
+ifcapable !windowfunc
+
+execsql_test 1.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 2);
+ INSERT INTO t1 VALUES(3, 3);
+ INSERT INTO t1 VALUES(4, 4);
+ INSERT INTO t1 VALUES(5, 5);
+}
+
+foreach {tn frame} {
+ 1 "ORDER BY a ROWS BETWEEN -1 PRECEDING AND 1 FOLLOWING"
+ 2 "ORDER BY a ROWS BETWEEN 1 PRECEDING AND -1 FOLLOWING"
+
+ 3 "ORDER BY a RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING"
+ 4 "ORDER BY a RANGE BETWEEN 1 PRECEDING AND -1 FOLLOWING"
+
+ 5 "ORDER BY a GROUPS BETWEEN -1 PRECEDING AND 1 FOLLOWING"
+ 6 "ORDER BY a GROUPS BETWEEN 1 PRECEDING AND -1 FOLLOWING"
+
+ 7 "ORDER BY a,b RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING"
+
+ 8 "PARTITION BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING"
+} {
+ errorsql_test 1.$tn "
+ SELECT a, sum(b) OVER (
+ $frame
+ ) FROM t1 ORDER BY 1
+ "
+}
+errorsql_test 2.1 {
+ SELECT sum( sum(a) OVER () ) FROM t1;
+}
+
+errorsql_test 2.2 {
+ SELECT sum(a) OVER () AS xyz FROM t1 ORDER BY sum(xyz);
+}
+
+errorsql_test 3.0 {
+ SELECT sum(a) OVER win FROM t1
+ WINDOW win AS (ROWS BETWEEN 'hello' PRECEDING AND 10 FOLLOWING)
+}
+errorsql_test 3.2 {
+ SELECT sum(a) OVER win FROM t1
+ WINDOW win AS (ROWS BETWEEN 10 PRECEDING AND x'ABCD' FOLLOWING)
+}
+
+errorsql_test 3.3 {
+ SELECT row_number(a) OVER () FROM t1;
+}
+
+finish_test
+
diff --git a/test/windowerr.test b/test/windowerr.test
new file mode 100644
index 0000000..40d994d
--- /dev/null
+++ b/test/windowerr.test
@@ -0,0 +1,116 @@
+# 2019 March 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 file implements regression tests for SQLite library.
+#
+
+####################################################
+# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
+####################################################
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix windowerr
+
+ifcapable !windowfunc { finish_test ; return }
+do_execsql_test 1.0 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a INTEGER, b INTEGER);
+ INSERT INTO t1 VALUES(1, 1);
+ INSERT INTO t1 VALUES(2, 2);
+ INSERT INTO t1 VALUES(3, 3);
+ INSERT INTO t1 VALUES(4, 4);
+ INSERT INTO t1 VALUES(5, 5);
+} {}
+
+# PG says ERROR: frame starting offset must not be negative
+do_test 1.1 { catch { execsql {
+ SELECT a, sum(b) OVER (
+ ORDER BY a ROWS BETWEEN -1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1
+} } } 1
+
+# PG says ERROR: frame ending offset must not be negative
+do_test 1.2 { catch { execsql {
+ SELECT a, sum(b) OVER (
+ ORDER BY a ROWS BETWEEN 1 PRECEDING AND -1 FOLLOWING
+ ) FROM t1 ORDER BY 1
+} } } 1
+
+# PG says ERROR: invalid preceding or following size in window function
+do_test 1.3 { catch { execsql {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1
+} } } 1
+
+# PG says ERROR: invalid preceding or following size in window function
+do_test 1.4 { catch { execsql {
+ SELECT a, sum(b) OVER (
+ ORDER BY a RANGE BETWEEN 1 PRECEDING AND -1 FOLLOWING
+ ) FROM t1 ORDER BY 1
+} } } 1
+
+# PG says ERROR: frame starting offset must not be negative
+do_test 1.5 { catch { execsql {
+ SELECT a, sum(b) OVER (
+ ORDER BY a GROUPS BETWEEN -1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1
+} } } 1
+
+# PG says ERROR: frame ending offset must not be negative
+do_test 1.6 { catch { execsql {
+ SELECT a, sum(b) OVER (
+ ORDER BY a GROUPS BETWEEN 1 PRECEDING AND -1 FOLLOWING
+ ) FROM t1 ORDER BY 1
+} } } 1
+
+# PG says ERROR: RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column
+do_test 1.7 { catch { execsql {
+ SELECT a, sum(b) OVER (
+ ORDER BY a,b RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1
+} } } 1
+
+# PG says ERROR: RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column
+do_test 1.8 { catch { execsql {
+ SELECT a, sum(b) OVER (
+ PARTITION BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1 ORDER BY 1
+} } } 1
+
+# PG says ERROR: aggregate function calls cannot contain window function calls
+do_test 2.1 { catch { execsql {
+ SELECT sum( sum(a) OVER () ) FROM t1;
+} } } 1
+
+# PG says ERROR: column "xyz" does not exist
+do_test 2.2 { catch { execsql {
+ SELECT sum(a) OVER () AS xyz FROM t1 ORDER BY sum(xyz);
+} } } 1
+
+# PG says ERROR: invalid input syntax for integer: "hello"
+do_test 3.0 { catch { execsql {
+ SELECT sum(a) OVER win FROM t1
+ WINDOW win AS (ROWS BETWEEN 'hello' PRECEDING AND 10 FOLLOWING)
+} } } 1
+
+# PG says ERROR: argument of ROWS must be type bigint, not type bit
+do_test 3.2 { catch { execsql {
+ SELECT sum(a) OVER win FROM t1
+ WINDOW win AS (ROWS BETWEEN 10 PRECEDING AND x'ABCD' FOLLOWING)
+} } } 1
+
+# PG says ERROR: function row_number(integer) does not exist
+do_test 3.3 { catch { execsql {
+ SELECT row_number(a) OVER () FROM t1;
+} } } 1
+
+finish_test
diff --git a/test/windowfault.test b/test/windowfault.test
new file mode 100644
index 0000000..5340ce0
--- /dev/null
+++ b/test/windowfault.test
@@ -0,0 +1,334 @@
+# 2018 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 implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix windowfault
+
+ifcapable !windowfunc {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b, c, d);
+ INSERT INTO t1 VALUES(1, 2, 3, 4);
+ INSERT INTO t1 VALUES(5, 6, 7, 8);
+ INSERT INTO t1 VALUES(9, 10, 11, 12);
+}
+faultsim_save_and_close
+
+do_faultsim_test 1 -start 1 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT row_number() OVER win,
+ rank() OVER win,
+ dense_rank() OVER win,
+ ntile(2) OVER win,
+ first_value(d) OVER win,
+ last_value(d) OVER win,
+ nth_value(d,2) OVER win,
+ lead(d) OVER win,
+ lag(d) OVER win,
+ max(d) OVER win,
+ min(d) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY a)
+ }
+} -test {
+ faultsim_test_result {0 {1 1 1 1 4 4 {} 8 {} 4 4 2 2 2 1 4 8 8 12 4 8 4 3 3 3 2 4 12 8 {} 8 12 4}}
+}
+
+do_faultsim_test 1.1 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT row_number() OVER win,
+ rank() OVER win,
+ dense_rank() OVER win
+ FROM t1
+ WINDOW win AS (PARTITION BY c<7 ORDER BY a)
+ }
+} -test {
+ faultsim_test_result {0 {1 1 1 2 2 2 1 1 1}}
+}
+
+do_faultsim_test 1.2 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT ntile(105)
+ OVER ( RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
+ FROM t1
+ }
+} -test {
+ faultsim_test_result {0 {1 2 3}}
+}
+
+do_faultsim_test 2 -start 1 -faults oom-* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT round(percent_rank() OVER win, 2),
+ round(cume_dist() OVER win, 2)
+ FROM t1
+ WINDOW win AS (ORDER BY a)
+ }
+} -test {
+ faultsim_test_result {0 {0.0 0.33 0.5 0.67 1.0 1.0}}
+}
+
+do_faultsim_test 3 -faults oom-* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT min(d) OVER win, max(d) OVER win
+ FROM t1
+ WINDOW win AS (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
+ }
+} -test {
+ faultsim_test_result {0 {4 12 8 12 12 12}}
+}
+
+do_faultsim_test 4 -faults oom-* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ CREATE VIEW aaa AS
+ SELECT min(d) OVER w, max(d) OVER w
+ FROM t1
+ WINDOW w AS (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING);
+ SELECT * FROM aaa;
+ }
+} -test {
+ faultsim_test_result {0 {4 12 8 12 12 12}}
+}
+
+do_faultsim_test 5 -start 1 -faults oom-* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT last_value(a) OVER win1,
+ last_value(a) OVER win2
+ FROM t1
+ WINDOW win1 AS (ORDER BY a ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING),
+ win2 AS (ORDER BY a)
+ }
+} -test {
+ faultsim_test_result {0 {5 1 9 5 9 9}}
+}
+
+do_faultsim_test 6 -faults oom-* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT percent_rank() OVER (), cume_dist() OVER () FROM t1
+ }
+} -test {
+ faultsim_test_result {0 {0.0 1.0 0.0 1.0 0.0 1.0}}
+}
+
+do_faultsim_test 7 -faults oom-* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT percent_rank() OVER (), cume_dist() OVER () FROM t1
+ }
+} -test {
+ faultsim_test_result {0 {0.0 1.0 0.0 1.0 0.0 1.0}}
+}
+
+do_faultsim_test 8 -faults oom-t* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql {
+ SELECT a, sum(b) OVER win1 FROM t1
+ WINDOW win1 AS (PARTITION BY a ),
+ win2 AS (PARTITION BY b )
+ ORDER BY a;
+ }
+} -test {
+ faultsim_test_result {0 {1 2 5 6 9 10}}
+}
+
+#-------------------------------------------------------------------------
+# The following test causes a cursor in REQURESEEK state to be passed
+# to sqlite3BtreeDelete(). An error is simulated within the seek operation
+# to restore the cursors position.
+#
+reset_db
+set big [string repeat x 900]
+do_execsql_test 9.0 {
+ PRAGMA page_size = 512;
+ PRAGMA cache_size = 2;
+ CREATE TABLE t(x INTEGER PRIMARY KEY, y TEXT);
+ WITH s(i) AS (
+ VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1900
+ )
+ INSERT INTO t(y) SELECT $big FROM s;
+}
+db close
+
+testvfs tvfs -default 1
+tvfs script vfs_callback
+tvfs filter xRead
+
+sqlite3 db test.db
+proc vfs_callback {method file args} {
+ if {$file=="" && [info exists ::tmp_read_fail]} {
+ incr ::tmp_read_fail -1
+ if {$::tmp_read_fail<=0} {
+ return "SQLITE_IOERR"
+ }
+ }
+ return "SQLITE_OK"
+}
+
+set FAULTSIM(tmpread) [list \
+ -injectstart tmpread_injectstart \
+ -injectstop tmpread_injectstop \
+ -injecterrlist {{1 {disk I/O error}}} \
+]
+proc tmpread_injectstart {iFail} {
+ set ::tmp_read_fail $iFail
+}
+proc tmpread_injectstop {} {
+ set ret [expr $::tmp_read_fail<=0]
+ unset -nocomplain ::tmp_read_fail
+ return $ret
+}
+
+set L [db eval {SELECT 0.0 FROM t}]
+do_faultsim_test 9 -end 25 -faults tmpread -body {
+ execsql {
+ SELECT sum(y) OVER win FROM t
+ WINDOW win AS (
+ ORDER BY x ROWS BETWEEN UNBOUNDED PRECEDING AND 1800 FOLLOWING
+ )
+ }
+} -test {
+ faultsim_test_result [list 0 $::L]
+}
+
+catch {db close}
+tvfs delete
+
+reset_db
+do_execsql_test 10.0 {
+ CREATE TABLE t1(a, b, c, d);
+ CREATE TABLE t2(a, b, c, d);
+}
+
+do_faultsim_test 10 -faults oom* -prep {
+} -body {
+ execsql {
+ SELECT row_number() OVER win
+ FROM t1
+ WINDOW win AS (
+ ORDER BY (
+ SELECT percent_rank() OVER win2 FROM t2
+ WINDOW win2 AS (ORDER BY a)
+ )
+ )
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 11.0 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(c0 INTEGER UNIQUE);
+ INSERT INTO t0 VALUES(0);
+} {}
+
+do_faultsim_test 11.1 -faults oom* -prep {
+} -body {
+ execsql {
+ SELECT * FROM t0 WHERE
+ (0, t0.c0) IN (SELECT DENSE_RANK() OVER(), LAG(0) OVER() FROM t0);
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 11.2 -faults oom* -prep {
+} -body {
+ execsql {
+ VALUES(false),(current_date collate binary)
+ intersect
+ values(count() not like group_concat(cast(cast(0e00 as text) as integer) <= NULL || 0.4e-0 || 0x8 & true ) over () collate rtrim);
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 12.0 {
+ CREATE TABLE t1(a, b, c);
+} {}
+do_faultsim_test 12 -faults oom* -prep {
+} -body {
+ execsql {
+ WITH v(a, b, row_number) AS (
+ SELECT a, b, row_number() OVER (PARTITION BY a COLLATE nocase ORDER BY b) FROM t1
+ )
+ SELECT * FROM v WHERE a=2
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 13.0 {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b);
+ INSERT INTO t1 VALUES(1, '1', 'a');
+ INSERT INTO t1 VALUES(2, '22', 'b');
+ INSERT INTO t1 VALUES(3, '333', 'c');
+ INSERT INTO t1 VALUES(4, '4444', 'dddd');
+ INSERT INTO t1 VALUES(5, '55555', 'e');
+ INSERT INTO t1 VALUES(6, '666666', 'f');
+ INSERT INTO t1 VALUES(7, '7777777', 'gggggggggg');
+} {}
+
+set queryres [list {*}{
+ 1b22
+ 1b22c333
+ 22c333dddd4444
+ 333dddd4444e55555
+ 4444e55555f666666
+ 55555f666666gggggggggg7777777
+ 666666gggggggggg7777777
+}]
+do_execsql_test 13.1 {
+ SELECT group_concat(a, b) OVER (
+ ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1
+} $queryres
+
+do_faultsim_test 13 -faults oom* -prep {
+} -body {
+ execsql {
+ SELECT group_concat(a, b) OVER (
+ ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ ) FROM t1
+ }
+} -test {
+ faultsim_test_result [list 0 $::queryres]
+}
+
+finish_test
diff --git a/test/windowpushd.test b/test/windowpushd.test
new file mode 100644
index 0000000..f2e04d7
--- /dev/null
+++ b/test/windowpushd.test
@@ -0,0 +1,236 @@
+# 2021 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 push-down optimization when
+# WHERE constraints are pushed down into a sub-query that uses
+# window functions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix windowpushd
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(id INTEGER PRIMARY KEY, grp_id);
+ CREATE INDEX i1 ON t1(grp_id);
+ CREATE VIEW lll AS SELECT
+ row_number() OVER (PARTITION BY grp_id),
+ grp_id, id
+ FROM t1
+}
+
+do_execsql_test 1.1 {
+ INSERT INTO t1 VALUES
+ (1, 2), (2, 3), (3, 3), (4, 1), (5, 1),
+ (6, 1), (7, 1), (8, 1), (9, 3), (10, 3),
+ (11, 2), (12, 3), (13, 3), (14, 2), (15, 1),
+ (16, 2), (17, 1), (18, 2), (19, 3), (20, 2)
+}
+
+do_execsql_test 1.2 {
+ SELECT * FROM lll
+} {
+ 1 1 4 2 1 5 3 1 6 4 1 7 5 1 8 6 1 15 7 1 17
+ 1 2 1 2 2 11 3 2 14 4 2 16 5 2 18 6 2 20
+ 1 3 2 2 3 3 3 3 9 4 3 10 5 3 12 6 3 13 7 3 19
+}
+
+do_execsql_test 1.3 {
+ SELECT * FROM lll WHERE grp_id=2
+} {
+ 1 2 1 2 2 11 3 2 14 4 2 16 5 2 18 6 2 20
+}
+
+do_eqp_test 1.4 {
+ SELECT * FROM lll WHERE grp_id=2
+} {SEARCH t1 USING COVERING INDEX i1 (grp_id=?)}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 2.0 {
+ CREATE TABLE t1(a, b, c, d);
+ INSERT INTO t1 VALUES('A', 'C', 1, 0.1);
+ INSERT INTO t1 VALUES('A', 'D', 2, 0.2);
+ INSERT INTO t1 VALUES('A', 'E', 3, 0.3);
+ INSERT INTO t1 VALUES('A', 'C', 4, 0.4);
+ INSERT INTO t1 VALUES('B', 'D', 5, 0.5);
+ INSERT INTO t1 VALUES('B', 'E', 6, 0.6);
+ INSERT INTO t1 VALUES('B', 'C', 7, 0.7);
+ INSERT INTO t1 VALUES('B', 'D', 8, 0.8);
+ INSERT INTO t1 VALUES('C', 'E', 9, 0.9);
+ INSERT INTO t1 VALUES('C', 'C', 10, 1.0);
+ INSERT INTO t1 VALUES('C', 'D', 11, 1.1);
+ INSERT INTO t1 VALUES('C', 'E', 12, 1.2);
+
+ CREATE INDEX i1 ON t1(a);
+ CREATE INDEX i2 ON t1(b);
+
+ CREATE VIEW v1 AS SELECT a, c, max(c) OVER (PARTITION BY a) FROM t1;
+
+ CREATE VIEW v2 AS SELECT a, c,
+ max(c) OVER (PARTITION BY a),
+ row_number() OVER ()
+ FROM t1;
+
+ CREATE VIEW v3 AS SELECT b, d,
+ max(d) OVER (PARTITION BY b),
+ row_number() OVER (PARTITION BY b)
+ FROM t1;
+
+ CREATE TABLE t2(x, y, z);
+ INSERT INTO t2 VALUES('W', 3, 1);
+ INSERT INTO t2 VALUES('W', 2, 2);
+ INSERT INTO t2 VALUES('X', 1, 4);
+ INSERT INTO t2 VALUES('X', 5, 7);
+ INSERT INTO t2 VALUES('Y', 1, 9);
+ INSERT INTO t2 VALUES('Y', 4, 2);
+ INSERT INTO t2 VALUES('Z', 3, 3);
+ INSERT INTO t2 VALUES('Z', 3, 4);
+}
+
+foreach tn {0 1} {
+ optimization_control db push-down $tn
+
+ do_execsql_test 2.$tn.1.1 {
+ SELECT * FROM v1;
+ } {
+ A 1 4 A 2 4 A 3 4 A 4 4
+ B 5 8 B 6 8 B 7 8 B 8 8
+ C 9 12 C 10 12 C 11 12 C 12 12
+ }
+
+ do_execsql_test 2.$tn.1.2 {
+ SELECT * FROM v1 WHERE a IN ('A', 'B');
+ } {
+ A 1 4 A 2 4 A 3 4 A 4 4
+ B 5 8 B 6 8 B 7 8 B 8 8
+ }
+
+ do_execsql_test 2.$tn.1.3 {
+ SELECT * FROM v1 WHERE a IS 'C'
+ } {
+ C 9 12 C 10 12 C 11 12 C 12 12
+ }
+
+ if {$tn==1} {
+ do_eqp_test 2.$tn.1.4 {
+ SELECT * FROM v1 WHERE a IN ('A', 'B');
+ } {USING INDEX i1 (a=?)}
+
+ do_eqp_test 2.$tn.1.5 {
+ SELECT * FROM v1 WHERE a = 'c' COLLATE nocase
+ } {USING INDEX i1}
+ }
+
+ do_execsql_test 2.$tn.2.1 {
+ SELECT * FROM v2;
+ } {
+ A 1 4 1 A 2 4 2 A 3 4 3 A 4 4 4
+ B 5 8 5 B 6 8 6 B 7 8 7 B 8 8 8
+ C 9 12 9 C 10 12 10 C 11 12 11 C 12 12 12
+ }
+
+ do_execsql_test 2.$tn.2.2 {
+ SELECT * FROM v2 WHERE a = 'C';
+ } {
+ C 9 12 9 C 10 12 10 C 11 12 11 C 12 12 12
+ }
+
+ do_execsql_test 2.$tn.3.1 { SELECT * FROM v3; } {
+ C 0.1 1.0 1 C 0.4 1.0 2 C 0.7 1.0 3 C 1.0 1.0 4
+ D 0.2 1.1 1 D 0.5 1.1 2 D 0.8 1.1 3 D 1.1 1.1 4
+ E 0.3 1.2 1 E 0.6 1.2 2 E 0.9 1.2 3 E 1.2 1.2 4
+ }
+
+ do_execsql_test 2.$tn.3.2 { SELECT * FROM v3 WHERE b<'E' } {
+ C 0.1 1.0 1 C 0.4 1.0 2 C 0.7 1.0 3 C 1.0 1.0 4
+ D 0.2 1.1 1 D 0.5 1.1 2 D 0.8 1.1 3 D 1.1 1.1 4
+ }
+
+ if {$tn==1} {
+ do_eqp_test 2.$tn.3.3 {
+ SELECT * FROM v3 WHERE b='E'
+ } {SEARCH t1 USING INDEX i2 (b=?)}
+ do_eqp_test 2.$tn.3.4 {
+ SELECT * FROM v3 WHERE b>'C'
+ } {SEARCH t1 USING INDEX i2 (b>?)}
+ }
+
+ do_execsql_test 2.$tn.3.5 { SELECT * FROM v3 WHERE d<0.55; } {
+ C 0.1 1.0 1 C 0.4 1.0 2
+ D 0.2 1.1 1 D 0.5 1.1 2
+ E 0.3 1.2 1
+ }
+ if {$tn==1} {
+ do_eqp_test 2.$tn.3.6 {
+ SELECT * FROM v3 WHERE d<0.55
+ } {SCAN t1 USING INDEX i2}
+ }
+
+ do_execsql_test 2.$tn.4.1 {
+ SELECT * FROM (
+ SELECT x, sum(y) AS s, max(z) AS m
+ FROM t2 GROUP BY x
+ )
+ } {
+ W 5 2
+ X 6 7
+ Y 5 9
+ Z 6 4
+ }
+
+ do_execsql_test 2.$tn.4.1 {
+ SELECT * FROM (
+ SELECT x, sum(y) AS s, max(z) AS m,
+ max( max(z) ) OVER (PARTITION BY sum(y)
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ )
+ FROM t2 GROUP BY x
+ )
+ } {
+ W 5 2 9
+ Y 5 9 9
+ X 6 7 7
+ Z 6 4 7
+ }
+
+ do_execsql_test 2.$tn.4.2 {
+ SELECT * FROM (
+ SELECT x, sum(y) AS s, max(z) AS m,
+ max( max(z) ) OVER (PARTITION BY sum(y)
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ )
+ FROM t2 GROUP BY x
+ ) WHERE s=6
+ } {
+ X 6 7 7
+ Z 6 4 7
+ }
+
+ do_execsql_test 2.$tn.4.3 {
+ SELECT * FROM (
+ SELECT x, sum(y) AS s, max(z) AS m,
+ max( max(z) ) OVER (PARTITION BY sum(y)
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ )
+ FROM t2 GROUP BY x
+ ) WHERE s<6
+ } {
+ W 5 2 9
+ Y 5 9 9
+ }
+
+}
+
+
+
+
+finish_test
diff --git a/test/with1.test b/test/with1.test
new file mode 100644
index 0000000..91cbc79
--- /dev/null
+++ b/test/with1.test
@@ -0,0 +1,1240 @@
+# 2014 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 WITH clause.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix with1
+
+ifcapable {!cte} {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x INTEGER, y INTEGER);
+ WITH x(a) AS ( SELECT * FROM t1) SELECT 10
+} {10}
+
+do_execsql_test 1.1 {
+ SELECT * FROM ( WITH x AS ( SELECT * FROM t1) SELECT 10 );
+} {10}
+
+do_execsql_test 1.2 {
+ WITH x(a) AS ( SELECT * FROM t1) INSERT INTO t1 VALUES(1,2);
+} {}
+
+do_execsql_test 1.3 {
+ WITH x(a) AS ( SELECT * FROM t1) DELETE FROM t1;
+} {}
+
+do_execsql_test 1.4 {
+ WITH x(a) AS ( SELECT * FROM t1) UPDATE t1 SET x = y;
+} {}
+
+#--------------------------------------------------------------------------
+
+do_execsql_test 2.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ WITH tmp AS ( SELECT * FROM t1 ) SELECT x FROM tmp;
+} {1 2}
+
+do_execsql_test 2.2 {
+ WITH tmp(a) AS ( SELECT * FROM t1 ) SELECT a FROM tmp;
+} {1 2}
+
+do_execsql_test 2.3 {
+ SELECT * FROM (
+ WITH tmp(a) AS ( SELECT * FROM t1 ) SELECT a FROM tmp
+ );
+} {1 2}
+
+do_execsql_test 2.4 {
+ WITH tmp1(a) AS ( SELECT * FROM t1 ),
+ tmp2(x) AS ( SELECT * FROM tmp1)
+ SELECT * FROM tmp2;
+} {1 2}
+
+do_execsql_test 2.5 {
+ WITH tmp2(x) AS ( SELECT * FROM tmp1),
+ tmp1(a) AS ( SELECT * FROM t1 )
+ SELECT * FROM tmp2;
+} {1 2}
+
+#-------------------------------------------------------------------------
+do_catchsql_test 3.1 {
+ WITH tmp2(x) AS ( SELECT * FROM tmp1 ),
+ tmp1(a) AS ( SELECT * FROM tmp2 )
+ SELECT * FROM tmp1;
+} {1 {circular reference: tmp1}}
+
+do_catchsql_test 3.2 {
+ CREATE TABLE t2(x INTEGER);
+ WITH tmp(a) AS (SELECT * FROM t1),
+ tmp(a) AS (SELECT * FROM t1)
+ SELECT * FROM tmp;
+} {1 {duplicate WITH table name: tmp}}
+
+do_execsql_test 3.3 {
+ CREATE TABLE t3(x);
+ CREATE TABLE t4(x);
+
+ INSERT INTO t3 VALUES('T3');
+ INSERT INTO t4 VALUES('T4');
+
+ WITH t3(a) AS (SELECT * FROM t4)
+ SELECT * FROM t3;
+} {T4}
+
+do_execsql_test 3.4 {
+ WITH tmp AS ( SELECT * FROM t3 ),
+ tmp2 AS ( WITH tmp AS ( SELECT * FROM t4 ) SELECT * FROM tmp )
+ SELECT * FROM tmp2;
+} {T4}
+
+do_execsql_test 3.5 {
+ WITH tmp AS ( SELECT * FROM t3 ),
+ tmp2 AS ( WITH xxxx AS ( SELECT * FROM t4 ) SELECT * FROM tmp )
+ SELECT * FROM tmp2;
+} {T3}
+
+do_catchsql_test 3.6 {
+ WITH tmp AS ( SELECT * FROM t3 ),
+ SELECT * FROM tmp;
+} {1 {near "SELECT": syntax error}}
+
+#-------------------------------------------------------------------------
+do_execsql_test 4.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ INSERT INTO t1 VALUES(3);
+ INSERT INTO t1 VALUES(4);
+
+ WITH dset AS ( SELECT 2 UNION ALL SELECT 4 )
+ DELETE FROM t1 WHERE x IN dset;
+ SELECT * FROM t1;
+} {1 3}
+
+do_execsql_test 4.2 {
+ WITH iset AS ( SELECT 2 UNION ALL SELECT 4 )
+ INSERT INTO t1 SELECT * FROM iset;
+ SELECT * FROM t1;
+} {1 3 2 4}
+
+do_execsql_test 4.3 {
+ WITH uset(a, b) AS ( SELECT 2, 8 UNION ALL SELECT 4, 9 )
+ UPDATE t1 SET x = COALESCE( (SELECT b FROM uset WHERE a=x), x );
+ SELECT * FROM t1;
+} {1 3 8 9}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 5.1 {
+ WITH i(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM i)
+ SELECT x FROM i LIMIT 10;
+} {1 2 3 4 5 6 7 8 9 10}
+
+do_catchsql_test 5.2 {
+ WITH i(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM i ORDER BY 1)
+ SELECT x FROM i LIMIT 10;
+} {0 {1 2 3 4 5 6 7 8 9 10}}
+
+do_execsql_test 5.2.1 {
+ CREATE TABLE edge(xfrom, xto, seq, PRIMARY KEY(xfrom, xto)) WITHOUT ROWID;
+ INSERT INTO edge VALUES(0, 1, 10);
+ INSERT INTO edge VALUES(1, 2, 20);
+ INSERT INTO edge VALUES(0, 3, 30);
+ INSERT INTO edge VALUES(2, 4, 40);
+ INSERT INTO edge VALUES(3, 4, 40);
+ INSERT INTO edge VALUES(2, 5, 50);
+ INSERT INTO edge VALUES(3, 6, 60);
+ INSERT INTO edge VALUES(5, 7, 70);
+ INSERT INTO edge VALUES(3, 7, 70);
+ INSERT INTO edge VALUES(4, 8, 80);
+ INSERT INTO edge VALUES(7, 8, 80);
+ INSERT INTO edge VALUES(8, 9, 90);
+
+ WITH RECURSIVE
+ ancest(id, mtime) AS
+ (VALUES(0, 0)
+ UNION
+ SELECT edge.xto, edge.seq FROM edge, ancest
+ WHERE edge.xfrom=ancest.id
+ ORDER BY 2
+ )
+ SELECT * FROM ancest;
+} {0 0 1 10 2 20 3 30 4 40 5 50 6 60 7 70 8 80 9 90}
+do_execsql_test 5.2.2 {
+ WITH RECURSIVE
+ ancest(id, mtime) AS
+ (VALUES(0, 0)
+ UNION ALL
+ SELECT edge.xto, edge.seq FROM edge, ancest
+ WHERE edge.xfrom=ancest.id
+ ORDER BY 2
+ )
+ SELECT * FROM ancest;
+} {0 0 1 10 2 20 3 30 4 40 4 40 5 50 6 60 7 70 7 70 8 80 8 80 8 80 8 80 9 90 9 90 9 90 9 90}
+do_execsql_test 5.2.3 {
+ WITH RECURSIVE
+ ancest(id, mtime) AS
+ (VALUES(0, 0)
+ UNION ALL
+ SELECT edge.xto, edge.seq FROM edge, ancest
+ WHERE edge.xfrom=ancest.id
+ ORDER BY 2 LIMIT 4 OFFSET 2
+ )
+ SELECT * FROM ancest;
+} {2 20 3 30 4 40 4 40}
+
+do_catchsql_test 5.3 {
+ WITH i(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM i LIMIT 5)
+ SELECT x FROM i;
+} {0 {1 2 3 4 5}}
+
+do_execsql_test 5.4 {
+ WITH i(x) AS ( VALUES(1) UNION ALL SELECT (x+1)%10 FROM i)
+ SELECT x FROM i LIMIT 20;
+} {1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0}
+
+do_execsql_test 5.5 {
+ WITH i(x) AS ( VALUES(1) UNION SELECT (x+1)%10 FROM i)
+ SELECT x FROM i LIMIT 20;
+} {1 2 3 4 5 6 7 8 9 0}
+
+do_catchsql_test 5.6.1 {
+ WITH i(x, y) AS ( VALUES(1) )
+ SELECT * FROM i;
+} {1 {table i has 1 values for 2 columns}}
+
+do_catchsql_test 5.6.2 {
+ WITH i(x) AS ( VALUES(1,2) )
+ SELECT * FROM i;
+} {1 {table i has 2 values for 1 columns}}
+
+do_catchsql_test 5.6.3 {
+ CREATE TABLE t5(a, b);
+ WITH i(x) AS ( SELECT * FROM t5 )
+ SELECT * FROM i;
+} {1 {table i has 2 values for 1 columns}}
+
+do_catchsql_test 5.6.4 {
+ WITH i(x) AS ( SELECT 1, 2 UNION ALL SELECT 1 )
+ SELECT * FROM i;
+} {1 {table i has 2 values for 1 columns}}
+
+do_catchsql_test 5.6.5 {
+ WITH i(x) AS ( SELECT 1 UNION ALL SELECT 1, 2 )
+ SELECT * FROM i;
+} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}
+
+do_catchsql_test 5.6.6 {
+ WITH i(x) AS ( SELECT 1 UNION ALL SELECT x+1, x*2 FROM i )
+ SELECT * FROM i;
+} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}
+
+do_catchsql_test 5.6.7 {
+ WITH i(x) AS ( SELECT 1, 2 UNION SELECT x+1 FROM i )
+ SELECT * FROM i;
+} {1 {table i has 2 values for 1 columns}}
+
+#-------------------------------------------------------------------------
+#
+do_execsql_test 6.1 {
+ CREATE TABLE f(
+ id INTEGER PRIMARY KEY, parentid REFERENCES f, name TEXT
+ );
+
+ INSERT INTO f VALUES(0, NULL, '');
+ INSERT INTO f VALUES(1, 0, 'bin');
+ INSERT INTO f VALUES(2, 1, 'true');
+ INSERT INTO f VALUES(3, 1, 'false');
+ INSERT INTO f VALUES(4, 1, 'ls');
+ INSERT INTO f VALUES(5, 1, 'grep');
+ INSERT INTO f VALUES(6, 0, 'etc');
+ INSERT INTO f VALUES(7, 6, 'rc.d');
+ INSERT INTO f VALUES(8, 7, 'rc.apache');
+ INSERT INTO f VALUES(9, 7, 'rc.samba');
+ INSERT INTO f VALUES(10, 0, 'home');
+ INSERT INTO f VALUES(11, 10, 'dan');
+ INSERT INTO f VALUES(12, 11, 'public_html');
+ INSERT INTO f VALUES(13, 12, 'index.html');
+ INSERT INTO f VALUES(14, 13, 'logo.gif');
+}
+
+do_execsql_test 6.2 {
+ WITH flat(fid, fpath) AS (
+ SELECT id, '' FROM f WHERE parentid IS NULL
+ UNION ALL
+ SELECT id, fpath || '/' || name FROM f, flat WHERE parentid=fid
+ )
+ SELECT fpath FROM flat WHERE fpath!='' ORDER BY 1;
+} {
+ /bin
+ /bin/false /bin/grep /bin/ls /bin/true
+ /etc
+ /etc/rc.d
+ /etc/rc.d/rc.apache /etc/rc.d/rc.samba
+ /home
+ /home/dan
+ /home/dan/public_html
+ /home/dan/public_html/index.html
+ /home/dan/public_html/index.html/logo.gif
+}
+
+do_execsql_test 6.3 {
+ WITH flat(fid, fpath) AS (
+ SELECT id, '' FROM f WHERE parentid IS NULL
+ UNION ALL
+ SELECT id, fpath || '/' || name FROM f, flat WHERE parentid=fid
+ )
+ SELECT count(*) FROM flat;
+} {15}
+
+do_execsql_test 6.4 {
+ WITH x(i) AS (
+ SELECT 1
+ UNION ALL
+ SELECT i+1 FROM x WHERE i<10
+ )
+ SELECT count(*) FROM x
+} {10}
+
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 7.1 {
+ CREATE TABLE tree(i, p);
+ INSERT INTO tree VALUES(1, NULL);
+ INSERT INTO tree VALUES(2, 1);
+ INSERT INTO tree VALUES(3, 1);
+ INSERT INTO tree VALUES(4, 2);
+ INSERT INTO tree VALUES(5, 4);
+}
+
+do_execsql_test 7.2 {
+ WITH t(id, path) AS (
+ SELECT i, '' FROM tree WHERE p IS NULL
+ UNION ALL
+ SELECT i, path || '/' || i FROM tree, t WHERE p = id
+ )
+ SELECT path FROM t;
+} {{} /2 /3 /2/4 /2/4/5}
+
+do_execsql_test 7.3 {
+ WITH t(id) AS (
+ VALUES(2)
+ UNION ALL
+ SELECT i FROM tree, t WHERE p = id
+ )
+ SELECT id FROM t;
+} {2 4 5}
+
+do_catchsql_test 7.4 {
+ WITH t(id) AS (
+ VALUES(2)
+ UNION ALL
+ SELECT i FROM tree WHERE p IN (SELECT id FROM t)
+ )
+ SELECT id FROM t;
+} {1 {circular reference: t}}
+
+do_catchsql_test 7.5 {
+ WITH t(id) AS (
+ VALUES(2)
+ UNION ALL
+ SELECT i FROM tree, t WHERE p = id AND p IN (SELECT id FROM t)
+ )
+ SELECT id FROM t;
+} {1 {multiple recursive references: t}}
+
+do_catchsql_test 7.6 {
+ WITH t(id) AS (
+ SELECT i FROM tree WHERE 2 IN (SELECT id FROM t)
+ UNION ALL
+ SELECT i FROM tree, t WHERE p = id
+ )
+ SELECT id FROM t;
+} {1 {circular reference: t}}
+
+# Compute the mandelbrot set using a recursive query
+#
+do_execsql_test 8.1-mandelbrot {
+ WITH RECURSIVE
+ xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2),
+ yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1.0),
+ m(iter, cx, cy, x, y) AS (
+ SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis
+ UNION ALL
+ SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m
+ WHERE (x*x + y*y) < 4.0 AND iter<28
+ ),
+ m2(iter, cx, cy) AS (
+ SELECT max(iter), cx, cy FROM m GROUP BY cx, cy
+ ),
+ a(t) AS (
+ SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '')
+ FROM m2 GROUP BY cy
+ )
+ SELECT group_concat(rtrim(t),x'0a') FROM a;
+} {{ ....#
+ ..#*..
+ ..+####+.
+ .......+####.... +
+ ..##+*##########+.++++
+ .+.##################+.
+ .............+###################+.+
+ ..++..#.....*#####################+.
+ ...+#######++#######################.
+ ....+*################################.
+ #############################################...
+ ....+*################################.
+ ...+#######++#######################.
+ ..++..#.....*#####################+.
+ .............+###################+.+
+ .+.##################+.
+ ..##+*##########+.++++
+ .......+####.... +
+ ..+####+.
+ ..#*..
+ ....#
+ +.}}
+
+# Solve a sudoku puzzle using a recursive query
+#
+do_execsql_test 8.2-soduko {
+ WITH RECURSIVE
+ input(sud) AS (
+ VALUES('53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79')
+ ),
+
+ /* A table filled with digits 1..9, inclusive. */
+ digits(z, lp) AS (
+ VALUES('1', 1)
+ UNION ALL SELECT
+ CAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9
+ ),
+
+ /* The tricky bit. */
+ x(s, ind) AS (
+ SELECT sud, instr(sud, '.') FROM input
+ UNION ALL
+ SELECT
+ substr(s, 1, ind-1) || z || substr(s, ind+1),
+ instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )
+ FROM x, digits AS z
+ WHERE ind>0
+ AND NOT EXISTS (
+ SELECT 1
+ FROM digits AS lp
+ WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)
+ OR z.z = substr(s, ((ind-1)%9) + (lp-1)*9 + 1, 1)
+ OR z.z = substr(s, (((ind-1)/3) % 3) * 3
+ + ((ind-1)/27) * 27 + lp
+ + ((lp-1) / 3) * 6, 1)
+ )
+ )
+ SELECT s FROM x WHERE ind=0;
+} {534678912672195348198342567859761423426853791713924856961537284287419635345286179}
+
+#--------------------------------------------------------------------------
+# Some tests that use LIMIT and OFFSET in the definition of recursive CTEs.
+#
+set I [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
+proc limit_test {tn iLimit iOffset} {
+ if {$iOffset < 0} { set iOffset 0 }
+ if {$iLimit < 0 } {
+ set result [lrange $::I $iOffset end]
+ } else {
+ set result [lrange $::I $iOffset [expr $iLimit+$iOffset-1]]
+ }
+ uplevel [list do_execsql_test $tn [subst -nocommands {
+ WITH ii(a) AS (
+ VALUES(1)
+ UNION ALL
+ SELECT a+1 FROM ii WHERE a<20
+ LIMIT $iLimit OFFSET $iOffset
+ )
+ SELECT * FROM ii
+ }] $result]
+}
+
+limit_test 9.1 20 0
+limit_test 9.2 0 0
+limit_test 9.3 19 1
+limit_test 9.4 20 -1
+limit_test 9.5 5 5
+limit_test 9.6 0 -1
+limit_test 9.7 40 -1
+limit_test 9.8 -1 -1
+limit_test 9.9 -1 -1
+
+#--------------------------------------------------------------------------
+# Test the ORDER BY clause on recursive tables.
+#
+
+do_execsql_test 10.1 {
+ DROP TABLE IF EXISTS tree;
+ CREATE TABLE tree(id INTEGER PRIMARY KEY, parentid, payload);
+}
+
+proc insert_into_tree {L} {
+ db eval { DELETE FROM tree }
+ foreach key $L {
+ unset -nocomplain parentid
+ foreach seg [split $key /] {
+ if {$seg==""} continue
+ set id [db one {
+ SELECT id FROM tree WHERE parentid IS $parentid AND payload=$seg
+ }]
+ if {$id==""} {
+ db eval { INSERT INTO tree VALUES(NULL, $parentid, $seg) }
+ set parentid [db last_insert_rowid]
+ } else {
+ set parentid $id
+ }
+ }
+ }
+}
+
+insert_into_tree {
+ /a/a/a
+ /a/b/c
+ /a/b/c/d
+ /a/b/d
+}
+do_execsql_test 10.2 {
+ WITH flat(fid, p) AS (
+ SELECT id, '/' || payload FROM tree WHERE parentid IS NULL
+ UNION ALL
+ SELECT id, p || '/' || payload FROM flat, tree WHERE parentid=fid
+ )
+ SELECT p FROM flat ORDER BY p;
+} {
+ /a /a/a /a/a/a
+ /a/b /a/b/c /a/b/c/d
+ /a/b/d
+}
+
+# Scan the tree-structure currently stored in table tree. Return a list
+# of nodes visited.
+#
+proc scan_tree {bDepthFirst bReverse} {
+
+ set order "ORDER BY "
+ if {$bDepthFirst==0} { append order "2 ASC," }
+ if {$bReverse==0} {
+ append order " 3 ASC"
+ } else {
+ append order " 3 DESC"
+ }
+
+ db eval "
+ WITH flat(fid, depth, p) AS (
+ SELECT id, 1, '/' || payload FROM tree WHERE parentid IS NULL
+ UNION ALL
+ SELECT id, depth+1, p||'/'||payload FROM flat, tree WHERE parentid=fid
+ $order
+ )
+ SELECT p FROM flat;
+ "
+}
+
+insert_into_tree {
+ /a/b
+ /a/b/c
+ /a/d
+ /a/d/e
+ /a/d/f
+ /g/h
+}
+
+# Breadth first, siblings in ascending order.
+#
+do_test 10.3 {
+ scan_tree 0 0
+} [list {*}{
+ /a /g
+ /a/b /a/d /g/h
+ /a/b/c /a/d/e /a/d/f
+}]
+
+# Depth first, siblings in ascending order.
+#
+do_test 10.4 {
+ scan_tree 1 0
+} [list {*}{
+ /a /a/b /a/b/c
+ /a/d /a/d/e
+ /a/d/f
+ /g /g/h
+}]
+
+# Breadth first, siblings in descending order.
+#
+do_test 10.5 {
+ scan_tree 0 1
+} [list {*}{
+ /g /a
+ /g/h /a/d /a/b
+ /a/d/f /a/d/e /a/b/c
+}]
+
+# Depth first, siblings in ascending order.
+#
+do_test 10.6 {
+ scan_tree 1 1
+} [list {*}{
+ /g /g/h
+ /a /a/d /a/d/f
+ /a/d/e
+ /a/b /a/b/c
+}]
+
+
+# Test name resolution in ORDER BY clauses.
+#
+do_catchsql_test 10.7.1 {
+ WITH t(a) AS (
+ SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY a
+ )
+ SELECT * FROM t
+} {1 {1st ORDER BY term does not match any column in the result set}}
+do_execsql_test 10.7.2 {
+ WITH t(a) AS (
+ SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY b
+ )
+ SELECT * FROM t
+} {1 2 3 4 5}
+do_execsql_test 10.7.3 {
+ WITH t(a) AS (
+ SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY c
+ )
+ SELECT * FROM t
+} {1 2 3 4 5}
+
+# Test COLLATE clauses attached to ORDER BY.
+#
+insert_into_tree {
+ /a/b
+ /a/C
+ /a/d
+ /B/e
+ /B/F
+ /B/g
+ /c/h
+ /c/I
+ /c/j
+}
+
+do_execsql_test 10.8.1 {
+ WITH flat(fid, depth, p) AS (
+ SELECT id, 1, '/' || payload FROM tree WHERE parentid IS NULL
+ UNION ALL
+ SELECT id, depth+1, p||'/'||payload FROM flat, tree WHERE parentid=fid
+ ORDER BY 2, 3 COLLATE nocase
+ )
+ SELECT p FROM flat;
+} {
+ /a /B /c
+ /a/b /a/C /a/d /B/e /B/F /B/g /c/h /c/I /c/j
+}
+do_execsql_test 10.8.2 {
+ WITH flat(fid, depth, p) AS (
+ SELECT id, 1, ('/' || payload) COLLATE nocase
+ FROM tree WHERE parentid IS NULL
+ UNION ALL
+ SELECT id, depth+1, (p||'/'||payload)
+ FROM flat, tree WHERE parentid=fid
+ ORDER BY 2, 3
+ )
+ SELECT p FROM flat;
+} {
+ /a /B /c
+ /a/b /a/C /a/d /B/e /B/F /B/g /c/h /c/I /c/j
+}
+
+do_execsql_test 10.8.3 {
+ WITH flat(fid, depth, p) AS (
+ SELECT id, 1, ('/' || payload)
+ FROM tree WHERE parentid IS NULL
+ UNION ALL
+ SELECT id, depth+1, (p||'/'||payload) COLLATE nocase
+ FROM flat, tree WHERE parentid=fid
+ ORDER BY 2, 3
+ )
+ SELECT p FROM flat;
+} {
+ /a /B /c
+ /a/b /a/C /a/d /B/e /B/F /B/g /c/h /c/I /c/j
+}
+
+do_execsql_test 10.8.4.1 {
+ CREATE TABLE tst(a,b);
+ INSERT INTO tst VALUES('a', 'A');
+ INSERT INTO tst VALUES('b', 'B');
+ INSERT INTO tst VALUES('c', 'C');
+ SELECT a COLLATE nocase FROM tst UNION ALL SELECT b FROM tst ORDER BY 1;
+} {a A b B c C}
+do_execsql_test 10.8.4.2 {
+ SELECT a FROM tst UNION ALL SELECT b COLLATE nocase FROM tst ORDER BY 1;
+} {A B C a b c}
+do_execsql_test 10.8.4.3 {
+ SELECT a||'' FROM tst UNION ALL SELECT b COLLATE nocase FROM tst ORDER BY 1;
+} {a A b B c C}
+
+# Test cases to illustrate on the ORDER BY clause on a recursive query can be
+# used to control depth-first versus breath-first search in a tree.
+#
+do_execsql_test 11.1 {
+ CREATE TABLE org(
+ name TEXT PRIMARY KEY,
+ boss TEXT REFERENCES org
+ ) WITHOUT ROWID;
+ INSERT INTO org VALUES('Alice',NULL);
+ INSERT INTO org VALUES('Bob','Alice');
+ INSERT INTO org VALUES('Cindy','Alice');
+ INSERT INTO org VALUES('Dave','Bob');
+ INSERT INTO org VALUES('Emma','Bob');
+ INSERT INTO org VALUES('Fred','Cindy');
+ INSERT INTO org VALUES('Gail','Cindy');
+ INSERT INTO org VALUES('Harry','Dave');
+ INSERT INTO org VALUES('Ingrid','Dave');
+ INSERT INTO org VALUES('Jim','Emma');
+ INSERT INTO org VALUES('Kate','Emma');
+ INSERT INTO org VALUES('Lanny','Fred');
+ INSERT INTO org VALUES('Mary','Fred');
+ INSERT INTO org VALUES('Noland','Gail');
+ INSERT INTO org VALUES('Olivia','Gail');
+ -- The above are all under Alice. Add a few more records for people
+ -- not in Alice's group, just to prove that they won't be selected.
+ INSERT INTO org VALUES('Xaviar',NULL);
+ INSERT INTO org VALUES('Xia','Xaviar');
+ INSERT INTO org VALUES('Xerxes','Xaviar');
+ INSERT INTO org VALUES('Xena','Xia');
+ -- Find all members of Alice's group, breath-first order
+ WITH RECURSIVE
+ under_alice(name,level) AS (
+ VALUES('Alice','0')
+ UNION ALL
+ SELECT org.name, under_alice.level+1
+ FROM org, under_alice
+ WHERE org.boss=under_alice.name
+ ORDER BY 2
+ )
+ SELECT group_concat(substr('...............',1,level*3) || name,x'0a')
+ FROM under_alice;
+} {{Alice
+...Bob
+...Cindy
+......Dave
+......Emma
+......Fred
+......Gail
+.........Harry
+.........Ingrid
+.........Jim
+.........Kate
+.........Lanny
+.........Mary
+.........Noland
+.........Olivia}}
+
+# The previous query used "ORDER BY level" to yield a breath-first search.
+# Change that to "ORDER BY level DESC" for a depth-first search.
+#
+do_execsql_test 11.2 {
+ WITH RECURSIVE
+ under_alice(name,level) AS (
+ VALUES('Alice','0')
+ UNION ALL
+ SELECT org.name, under_alice.level+1
+ FROM org, under_alice
+ WHERE org.boss=under_alice.name
+ ORDER BY 2 DESC
+ )
+ SELECT group_concat(substr('...............',1,level*3) || name,x'0a')
+ FROM under_alice;
+} {{Alice
+...Bob
+......Dave
+.........Harry
+.........Ingrid
+......Emma
+.........Jim
+.........Kate
+...Cindy
+......Fred
+.........Lanny
+.........Mary
+......Gail
+.........Noland
+.........Olivia}}
+
+# Without an ORDER BY clause, the recursive query should use a FIFO,
+# resulting in a breath-first search.
+#
+do_execsql_test 11.3 {
+ WITH RECURSIVE
+ under_alice(name,level) AS (
+ VALUES('Alice','0')
+ UNION ALL
+ SELECT org.name, under_alice.level+1
+ FROM org, under_alice
+ WHERE org.boss=under_alice.name
+ )
+ SELECT group_concat(substr('...............',1,level*3) || name,x'0a')
+ FROM under_alice;
+} {{Alice
+...Bob
+...Cindy
+......Dave
+......Emma
+......Fred
+......Gail
+.........Harry
+.........Ingrid
+.........Jim
+.........Kate
+.........Lanny
+.........Mary
+.........Noland
+.........Olivia}}
+
+#--------------------------------------------------------------------------
+# Ticket [31a19d11b97088296ac104aaff113a9790394927] (2014-02-09)
+# Name resolution issue with compound SELECTs and Common Table Expressions
+#
+do_execsql_test 12.1 {
+WITH RECURSIVE
+ t1(x) AS (VALUES(2) UNION ALL SELECT x+2 FROM t1 WHERE x<20),
+ t2(y) AS (VALUES(3) UNION ALL SELECT y+3 FROM t2 WHERE y<20)
+SELECT x FROM t1 EXCEPT SELECT y FROM t2 ORDER BY 1;
+} {2 4 8 10 14 16 20}
+
+# 2015-03-21
+# Column wildcards on the LHS of a recursive table expression
+#
+do_catchsql_test 13.1 {
+ WITH RECURSIVE c(i) AS (SELECT * UNION ALL SELECT i+1 FROM c WHERE i<10)
+ SELECT i FROM c;
+} {1 {no tables specified}}
+do_catchsql_test 13.2 {
+ WITH RECURSIVE c(i) AS (SELECT 5,* UNION ALL SELECT i+1 FROM c WHERE i<10)
+ SELECT i FROM c;
+} {1 {no tables specified}}
+do_catchsql_test 13.3 {
+ WITH RECURSIVE c(i,j) AS (SELECT 5,* UNION ALL SELECT i+1,11 FROM c WHERE i<10)
+ SELECT i FROM c;
+} {1 {table c has 1 values for 2 columns}}
+
+# 2015-04-12
+#
+do_execsql_test 14.1 {
+ WITH x AS (SELECT * FROM t) SELECT 0 EXCEPT SELECT 0 ORDER BY 1 COLLATE binary;
+} {}
+
+# 2015-05-27: Do not allow rowid usage within a CTE
+#
+do_catchsql_test 15.1 {
+ WITH RECURSIVE
+ d(x) AS (VALUES(1) UNION ALL SELECT rowid+1 FROM d WHERE rowid<10)
+ SELECT x FROM d;
+} {1 {no such column: rowid}}
+
+# 2015-07-05: Do not allow aggregate recursive queries
+#
+do_catchsql_test 16.1 {
+ WITH RECURSIVE
+ i(x) AS (VALUES(1) UNION SELECT count(*) FROM i)
+ SELECT * FROM i;
+} {1 {recursive aggregate queries not supported}}
+
+# Or window-function recursive queries. Ticket e8275b41.
+#
+ifcapable windowfunc {
+ do_catchsql_test 16.2 {
+ WITH RECURSIVE
+ i(x) AS (VALUES(1) UNION SELECT count(*) OVER () FROM i)
+ SELECT * FROM i;
+ } {1 {cannot use window functions in recursive queries}}
+ do_catchsql_test 16.3 {
+ WITH RECURSIVE
+ t(id, parent) AS (VALUES(1,2)),
+ q(id, parent, rn) AS (
+ VALUES(1,2,3)
+ UNION ALL
+ SELECT t.*, ROW_NUMBER() OVER (ORDER BY t.id) AS rn
+ FROM q JOIN t ON t.parent = q.id
+ )
+ SELECT * FROM q;
+ } {1 {cannot use window functions in recursive queries}}
+}
+
+#-------------------------------------------------------------------------
+do_execsql_test 17.1 {
+ WITH x(a) AS (
+ WITH y(b) AS (SELECT 10)
+ SELECT 9 UNION ALL SELECT * FROM y
+ )
+ SELECT * FROM x
+} {9 10}
+
+do_execsql_test 17.2 {
+ WITH x AS (
+ WITH y(b) AS (SELECT 10)
+ SELECT * FROM y UNION ALL SELECT * FROM y
+ )
+ SELECT * FROM x
+} {10 10}
+
+do_test 17.2 {
+ db eval {
+ WITH x AS (
+ WITH y(b) AS (SELECT 10)
+ SELECT * FROM y UNION ALL SELECT * FROM y
+ )
+ SELECT * FROM x
+ } A {
+ # no op
+ }
+ set A(*)
+} {b}
+
+do_catchsql_test 17.3 {
+ WITH i AS (
+ WITH j AS (SELECT 5)
+ SELECT 5 FROM i UNION SELECT 8 FROM i
+ )
+ SELECT * FROM i;
+} {1 {circular reference: i}}
+
+do_catchsql_test 17.4 {
+ WITH i AS (
+ WITH j AS (SELECT 5)
+ SELECT 5 FROM t1 UNION SELECT 8 FROM t11
+ )
+ SELECT * FROM i;
+} {1 {no such table: t11}}
+
+do_execsql_test 17.5 {
+ WITH
+ x1 AS (SELECT 10),
+ x2 AS (SELECT * FROM x1),
+ x3 AS (
+ WITH x1 AS (SELECT 11)
+ SELECT * FROM x2 UNION ALL SELECT * FROM x2
+ )
+ SELECT * FROM x3;
+} {10 10}
+
+do_execsql_test 17.6 {
+ WITH
+ x1 AS (SELECT 10),
+ x2 AS (SELECT * FROM x1),
+ x3 AS (
+ WITH x1 AS (SELECT 11)
+ SELECT * FROM x2 UNION ALL SELECT * FROM x1
+ )
+ SELECT * FROM x3;
+} {10 11}
+
+do_execsql_test 17.7 {
+ WITH
+ x1 AS (SELECT 10),
+ x2 AS (SELECT * FROM x1),
+ x3 AS (
+ WITH
+ x1 AS ( SELECT 11 ),
+ x4 AS ( SELECT * FROM x2 )
+ SELECT * FROM x4 UNION ALL SELECT * FROM x1
+ )
+ SELECT * FROM x3;
+} {10 11}
+
+do_execsql_test 17.8 {
+ WITH
+ x1 AS (SELECT 10),
+ x2 AS (SELECT * FROM x1),
+ x3 AS (
+ WITH
+ x1 AS ( SELECT 11 ),
+ x4 AS ( SELECT * FROM x2 )
+ SELECT * FROM x4 UNION ALL SELECT * FROM x1
+ )
+ SELECT * FROM x3;
+} {10 11}
+
+do_execsql_test 17.9 {
+ WITH
+ x1 AS (SELECT 10),
+ x2 AS (SELECT 11),
+ x3 AS (
+ SELECT * FROM x1 UNION ALL SELECT * FROM x2
+ ),
+ x4 AS (
+ WITH
+ x1 AS (SELECT 12),
+ x2 AS (SELECT 13)
+ SELECT * FROM x3
+ )
+ SELECT * FROM x4;
+} {10 11}
+
+# Added to test a fix to a faulty assert() discovered by libFuzzer.
+#
+do_execsql_test 18.1 {
+ WITH xyz(x) AS (VALUES(NULL) UNION SELECT round(1<x) FROM xyz ORDER BY 1)
+ SELECT quote(x) FROM xyz;
+} {NULL}
+do_execsql_test 18.2 {
+ WITH xyz(x) AS (
+ SELECT printf('%d', 5) * NULL
+ UNION SELECT round(1<1+x)
+ FROM xyz ORDER BY 1
+ )
+ SELECT 1 FROM xyz;
+} 1
+
+# EXPLAIN QUERY PLAN on a self-join of a CTE
+#
+do_execsql_test 19.1a {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+}
+do_eqp_test 19.1b {
+ WITH
+ x1(a) AS (values(100))
+ INSERT INTO t1(x)
+ SELECT * FROM (WITH x2(y) AS (SELECT * FROM x1) SELECT y+a FROM x1, x2);
+ SELECT * FROM t1;
+} {
+ QUERY PLAN
+ |--MATERIALIZE x1
+ | `--SCAN CONSTANT ROW
+ |--SCAN x1
+ `--SCAN x1
+}
+
+# 2017-10-28.
+# See check-in https://sqlite.org/src/info/0926df095faf72c2
+# Tried to optimize co-routine processing by changing a Copy opcode
+# into SCopy. But OSSFuzz found two (similar) cases where that optimization
+# does not work.
+#
+do_execsql_test 20.1 {
+ WITH c(i)AS(VALUES(9)UNION SELECT~i FROM c)SELECT max(5)>i fROM c;
+} {0}
+do_execsql_test 20.2 {
+ WITH c(i)AS(VALUES(5)UNIoN SELECT 0)SELECT min(1)-i fROM c;
+} {1}
+
+# 2018-12-26
+# Two different CTE tables with the same name appear in within a single FROM
+# clause due to the query-flattener optimization. make sure this does not cause
+# problems. This problem was discovered by Matt Denton.
+#
+do_execsql_test 21.1 {
+ WITH RECURSIVE t21(a,b) AS (
+ WITH t21(x) AS (VALUES(1))
+ SELECT x, x FROM t21 ORDER BY 1
+ )
+ SELECT * FROM t21 AS tA, t21 AS tB
+} {1 1 1 1}
+do_execsql_test 21.1b {
+ /* This variant from chromium bug 922312 on 2019-01-16 */
+ WITH RECURSIVE t21(a,b) AS (
+ WITH t21(x) AS (VALUES(1))
+ SELECT x, x FROM t21 ORDER BY 1 LIMIT 5
+ )
+ SELECT * FROM t21 AS tA, t21 AS tB
+} {1 1 1 1}
+do_execsql_test 21.2 {
+ SELECT printf('',
+ EXISTS (WITH RECURSIVE Table0 AS (WITH Table0 AS (SELECT DISTINCT 1)
+ SELECT *, * FROM Table0 ORDER BY 1 DESC)
+ SELECT * FROM Table0 NATURAL JOIN Table0));
+} {{}}
+
+# 2019-01-17
+# Make sure crazy nexted CTE joins terminate with an error quickly.
+#
+do_catchsql_test 22.1 {
+ WITH RECURSIVE c AS NOT MATERIALIZED (
+ WITH RECURSIVE c AS NOT MATERIALIZED (
+ WITH RECURSIVE c AS NOT MATERIALIZED (
+ WITH RECURSIVE c AS NOT MATERIALIZED (
+ WITH c AS (VALUES(0))
+ SELECT 1 FROM c LEFT JOIN c ON ltrim(1)
+ )
+ SELECT 1 FROM c,c,c,c,c,c,c,c,c
+ )
+ SELECT 2 FROM c,c,c,c,c,c,c,c,c
+ )
+ SELECT 3 FROM c,c,c,c,c,c,c,c,c
+ )
+ SELECT 4 FROM c,c,c,c,c,c,c,c,c;
+} {1 {too many FROM clause terms, max: 200}}
+
+# 2019-05-22
+# ticket https://www.sqlite.org/src/tktview/ce823231949d3abf42453c8f20
+#
+sqlite3 db :memory:
+do_execsql_test 23.1 {
+ CREATE TABLE t1(id INTEGER NULL PRIMARY KEY, name Text);
+ INSERT INTO t1 VALUES (1, 'john');
+ INSERT INTO t1 VALUES (2, 'james');
+ INSERT INTO t1 VALUES (3, 'jingle');
+ INSERT INTO t1 VALUES (4, 'himer');
+ INSERT INTO t1 VALUES (5, 'smith');
+ CREATE VIEW v2 AS
+ WITH t4(Name) AS (VALUES ('A'), ('B'))
+ SELECT Name Name FROM t4;
+ CREATE VIEW v3 AS
+ WITH t4(Att, Val, Act) AS (VALUES
+ ('C', 'D', 'E'),
+ ('F', 'G', 'H')
+ )
+ SELECT D.Id Id, P.Name Protocol, T.Att Att, T.Val Val, T.Act Act
+ FROM t1 D
+ CROSS JOIN v2 P
+ CROSS JOIN t4 T;
+ SELECT * FROM v3;
+} {1 A C D E 1 A F G H 1 B C D E 1 B F G H 2 A C D E 2 A F G H 2 B C D E 2 B F G H 3 A C D E 3 A F G H 3 B C D E 3 B F G H 4 A C D E 4 A F G H 4 B C D E 4 B F G H 5 A C D E 5 A F G H 5 B C D E 5 B F G H}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 24.1 {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIEW v1 AS SELECT max(a), min(b) FROM t1 GROUP BY c;
+}
+do_test 24.1 {
+ set program [db eval {EXPLAIN SELECT 1 FROM v1,v1,v1}]
+ expr [lsearch $program OpenDup]>0
+} {1}
+do_execsql_test 24.2 {
+ ATTACH "" AS aux;
+ CREATE VIEW aux.v3 AS VALUES(1);
+ CREATE VIEW main.v3 AS VALUES(3);
+
+ CREATE VIEW aux.v2 AS SELECT * FROM v3;
+ CREATE VIEW main.v2 AS SELECT * FROM v3;
+
+ SELECT * FROM main.v2 AS a, aux.v2 AS b, aux.v2 AS c, main.v2 AS d;
+} {
+ 3 1 1 3
+}
+
+# 2020-01-02 chromium ticket 1033461
+# Do not allow the generated name of a CTE be "true" or "false" as
+# such a label might be later confused for the boolean literals of
+# the same name, causing inconsistencies in the abstract syntax
+# tree. This problem first arose in version 3.23.0 when SQLite
+# began recognizing "true" and "false" as boolean literals, but also
+# had to continue to recognize "true" and "false" as identifiers for
+# backwards compatibility.
+#
+foreach {id dual} {
+ 1 {CREATE TABLE dual AS SELECT 'X' AS dummy}
+ 2 {CREATE TEMP TABLE dual AS SELECT 'X' AS dummy}
+ 3 {CREATE VIEW dual(dummy) AS VALUES('X')}
+ 4 {CREATE TEMP VIEW dual(dummy) AS VALUES('X')}
+} {
+ reset_db
+ db eval $dual
+ do_execsql_test 25.$id {
+ WITH cte1 AS (
+ SELECT TRUE, (
+ WITH cte2 AS (SELECT avg(DISTINCT TRUE) FROM dual)
+ SELECT 2571 FROM cte2
+ ) AS subquery1
+ FROM dual
+ GROUP BY 1
+ )
+ SELECT (SELECT 1324 FROM cte1) FROM cte1;
+ } {1324}
+}
+
+do_catchsql_test 26.0 {
+ WITH i(x) AS (
+ VALUES(1) UNION ALL SELECT x+1 FRO, a.b,O. * ,I¬i O, a.b,O. * ORDER BY 1
+ )
+ SELECT x,O. * O FROM i ¬I,I? 10;
+} {1 {near "O": syntax error}}
+
+# 2020-09-17 ticket c51489c3b8f919c5
+# DISTINCT cannot be ignored in a UNION ALL recursive CTE
+#
+reset_db
+do_execsql_test 26.1 {
+ CREATE TABLE t (label VARCHAR(10), step INTEGER);
+ INSERT INTO T VALUES('a', 1);
+ INSERT INTO T VALUES('a', 1);
+ INSERT INTO T VALUES('b', 1);
+ WITH RECURSIVE cte(label, step) AS (
+ SELECT DISTINCT * FROM t
+ UNION ALL
+ SELECT label, step + 1 FROM cte WHERE step < 3
+ )
+ SELECT * FROM cte ORDER BY +label, +step;
+} {a 1 a 2 a 3 b 1 b 2 b 3}
+do_execsql_test 26.2 {
+ WITH RECURSIVE cte(label, step) AS (
+ SELECT * FROM t
+ UNION
+ SELECT label, step + 1 FROM cte WHERE step < 3
+ )
+ SELECT * FROM cte ORDER BY +label, +step;
+} {a 1 a 2 a 3 b 1 b 2 b 3}
+do_execsql_test 26.3 {
+ CREATE TABLE tworow(x);
+ INSERT INTO tworow(x) VALUES(1),(2);
+ DELETE FROM t WHERE rowid=2;
+ WITH RECURSIVE cte(label, step) AS (
+ SELECT * FROM t
+ UNION ALL
+ SELECT DISTINCT label, step + 1 FROM cte, tworow WHERE step < 3
+ )
+ SELECT * FROM cte ORDER BY +label, +step;
+} {a 1 a 2 a 3 b 1 b 2 b 3}
+
+# 2021-05-20
+# forum post https://sqlite.org/forum/forumpost/8590e3f6dc
+#
+reset_db
+do_execsql_test 27.1 {
+ CREATE TABLE t1(k);
+ CREATE TABLE log(k, cte_map, main_map);
+ CREATE TABLE map(k, v);
+ INSERT INTO map VALUES(1, 'main1'), (2, 'main2');
+
+ CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
+ INSERT INTO log
+ WITH map(k,v) AS (VALUES(1,'cte1'),(2,'cte2'))
+ SELECT
+ new.k,
+ (SELECT v FROM map WHERE k=new.k),
+ (SELECT v FROM main.map WHERE k=new.k);
+ END;
+
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+ SELECT k, cte_map, main_map, '|' FROM log ORDER BY k;
+} {1 cte1 main1 | 2 cte2 main2 |}
+
+finish_test
diff --git a/test/with2.test b/test/with2.test
new file mode 100644
index 0000000..660df52
--- /dev/null
+++ b/test/with2.test
@@ -0,0 +1,628 @@
+# 2014 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 WITH clause.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix with2
+
+ifcapable {!cte} {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(2);
+}
+
+do_execsql_test 1.1 {
+ WITH x1 AS (SELECT * FROM t1)
+ SELECT sum(a) FROM x1;
+} {3}
+
+do_execsql_test 1.2 {
+ WITH x1 AS (SELECT * FROM t1)
+ SELECT (SELECT sum(a) FROM x1);
+} {3}
+
+do_execsql_test 1.3 {
+ WITH x1 AS (SELECT * FROM t1)
+ SELECT (SELECT sum(a) FROM x1);
+} {3}
+
+do_execsql_test 1.4 {
+ CREATE TABLE t2(i);
+ INSERT INTO t2 VALUES(2);
+ INSERT INTO t2 VALUES(3);
+ INSERT INTO t2 VALUES(5);
+
+ WITH x1 AS (SELECT i FROM t2),
+ i(a) AS (
+ SELECT min(i)-1 FROM x1 UNION SELECT a+1 FROM i WHERE a<10
+ )
+ SELECT a FROM i WHERE a NOT IN x1
+} {1 4 6 7 8 9 10}
+
+do_execsql_test 1.5 {
+ WITH x1 AS (SELECT a FROM t1),
+ x2 AS (SELECT i FROM t2),
+ x3 AS (SELECT * FROM x1, x2 WHERE x1.a IN x2 AND x2.i IN x1)
+ SELECT * FROM x3
+} {2 2}
+
+do_execsql_test 1.6 {
+ CREATE TABLE t3 AS SELECT 3 AS x;
+ CREATE TABLE t4 AS SELECT 4 AS x;
+
+ WITH x1 AS (SELECT * FROM t3),
+ x2 AS (
+ WITH t3 AS (SELECT * FROM t4)
+ SELECT * FROM x1
+ )
+ SELECT * FROM x2;
+} {3}
+
+do_execsql_test 1.7 {
+ WITH x2 AS (
+ WITH t3 AS (SELECT * FROM t4)
+ SELECT * FROM t3
+ )
+ SELECT * FROM x2;
+} {4}
+
+do_execsql_test 1.8 {
+ WITH x2 AS (
+ WITH t3 AS (SELECT * FROM t4)
+ SELECT * FROM main.t3
+ )
+ SELECT * FROM x2;
+} {3}
+
+do_execsql_test 1.9 {
+ WITH x1 AS (SELECT * FROM t1)
+ SELECT (SELECT sum(a) FROM x1), (SELECT max(a) FROM x1);
+} {3 2}
+
+do_execsql_test 1.10 {
+ WITH x1 AS (SELECT * FROM t1)
+ SELECT (SELECT sum(a) FROM x1), (SELECT max(a) FROM x1), a FROM x1;
+} {3 2 1 3 2 2}
+
+do_execsql_test 1.11 {
+ WITH
+ i(x) AS (
+ WITH
+ j(x) AS ( SELECT * FROM i ),
+ i(x) AS ( SELECT * FROM t1 )
+ SELECT * FROM j
+ )
+ SELECT * FROM i;
+} {1 2}
+
+do_execsql_test 1.12 {
+ WITH r(i) AS (
+ VALUES('.')
+ UNION ALL
+ SELECT i || '.' FROM r, (
+ SELECT x FROM x INTERSECT SELECT y FROM y
+ ) WHERE length(i) < 10
+ ),
+ x(x) AS ( VALUES(1) UNION ALL VALUES(2) UNION ALL VALUES(3) ),
+ y(y) AS ( VALUES(2) UNION ALL VALUES(4) UNION ALL VALUES(6) )
+
+ SELECT * FROM r;
+} {. .. ... .... ..... ...... ....... ........ ......... ..........}
+
+do_execsql_test 1.13 {
+ WITH r(i) AS (
+ VALUES('.')
+ UNION ALL
+ SELECT i || '.' FROM r, ( SELECT x FROM x WHERE x=2 ) WHERE length(i) < 10
+ ),
+ x(x) AS ( VALUES(1) UNION ALL VALUES(2) UNION ALL VALUES(3) )
+
+ SELECT * FROM r ORDER BY length(i) DESC;
+} {.......... ......... ........ ....... ...... ..... .... ... .. .}
+
+do_execsql_test 1.14 {
+ WITH
+ t4(x) AS (
+ VALUES(4)
+ UNION ALL
+ SELECT x+1 FROM t4 WHERE x<10
+ )
+ SELECT * FROM t4;
+} {4 5 6 7 8 9 10}
+
+do_execsql_test 1.15 {
+ WITH
+ t4(x) AS (
+ VALUES(4)
+ UNION ALL
+ SELECT x+1 FROM main.t4 WHERE x<10
+ )
+ SELECT * FROM t4;
+} {4 5}
+
+do_catchsql_test 1.16 {
+ WITH
+ t4(x) AS (
+ VALUES(4)
+ UNION ALL
+ SELECT x+1 FROM t4, main.t4, t4 WHERE x<10
+ )
+ SELECT * FROM t4;
+} {1 {multiple references to recursive table: t4}}
+
+
+#---------------------------------------------------------------------------
+# Check that variables can be used in CTEs.
+#
+set ::min [expr 3]
+set ::max [expr 9]
+do_execsql_test 2.1 {
+ WITH i(x) AS (
+ VALUES($min) UNION ALL SELECT x+1 FROM i WHERE x < $max
+ )
+ SELECT * FROM i;
+} {3 4 5 6 7 8 9}
+
+do_execsql_test 2.2 {
+ WITH i(x) AS (
+ VALUES($min) UNION ALL SELECT x+1 FROM i WHERE x < $max
+ )
+ SELECT x FROM i JOIN i AS j USING (x);
+} {3 4 5 6 7 8 9}
+
+#---------------------------------------------------------------------------
+# Check that circular references are rejected.
+#
+do_catchsql_test 3.1 {
+ WITH i(x, y) AS ( VALUES(1, (SELECT x FROM i)) )
+ SELECT * FROM i;
+} {1 {circular reference: i}}
+
+do_catchsql_test 3.2 {
+ WITH
+ i(x) AS ( SELECT * FROM j ),
+ j(x) AS ( SELECT * FROM k ),
+ k(x) AS ( SELECT * FROM i )
+ SELECT * FROM i;
+} {1 {circular reference: i}}
+
+do_catchsql_test 3.3 {
+ WITH
+ i(x) AS ( SELECT * FROM (SELECT * FROM j) ),
+ j(x) AS ( SELECT * FROM (SELECT * FROM i) )
+ SELECT * FROM i;
+} {1 {circular reference: i}}
+
+do_catchsql_test 3.4 {
+ WITH
+ i(x) AS ( SELECT * FROM (SELECT * FROM j) ),
+ j(x) AS ( SELECT * FROM (SELECT * FROM i) )
+ SELECT * FROM j;
+} {1 {circular reference: j}}
+
+do_catchsql_test 3.5 {
+ WITH
+ i(x) AS (
+ WITH j(x) AS ( SELECT * FROM i )
+ SELECT * FROM j
+ )
+ SELECT * FROM i;
+} {1 {circular reference: i}}
+
+#---------------------------------------------------------------------------
+# Try empty and very long column lists.
+#
+do_catchsql_test 4.1 {
+ WITH x() AS ( SELECT 1,2,3 )
+ SELECT * FROM x;
+} {1 {near ")": syntax error}}
+
+proc genstmt {n} {
+ for {set i 1} {$i<=$n} {incr i} {
+ lappend cols "c$i"
+ lappend vals $i
+ }
+ return "
+ WITH x([join $cols ,]) AS (SELECT [join $vals ,])
+ SELECT (c$n == $n) FROM x
+ "
+}
+
+do_execsql_test 4.2 [genstmt 10] 1
+do_execsql_test 4.3 [genstmt 100] 1
+do_execsql_test 4.4 [genstmt 255] 1
+set nLimit [sqlite3_limit db SQLITE_LIMIT_COLUMN -1]
+do_execsql_test 4.5 [genstmt [expr $nLimit-1]] 1
+do_execsql_test 4.6 [genstmt $nLimit] 1
+do_catchsql_test 4.7 [genstmt [expr $nLimit+1]] \
+ {1 {too many columns in result set}}
+
+#---------------------------------------------------------------------------
+# Check that adding a WITH clause to an INSERT disables the xfer
+# optimization.
+#
+proc do_xfer_test {tn bXfer sql {res {}}} {
+ set ::sqlite3_xferopt_count 0
+ uplevel [list do_test $tn [subst -nocommands {
+ set dres [db eval {$sql}]
+ list [set ::sqlite3_xferopt_count] [set dres]
+ }] [list $bXfer $res]]
+}
+
+do_execsql_test 5.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+}
+
+do_xfer_test 5.2 1 { INSERT INTO t1 SELECT * FROM t2 }
+do_xfer_test 5.3 0 { INSERT INTO t1 SELECT a, b FROM t2 }
+do_xfer_test 5.4 0 { INSERT INTO t1 SELECT b, a FROM t2 }
+do_xfer_test 5.5 0 {
+ WITH x AS (SELECT a, b FROM t2) INSERT INTO t1 SELECT * FROM x
+}
+do_xfer_test 5.6 0 {
+ WITH x AS (SELECT a, b FROM t2) INSERT INTO t1 SELECT * FROM t2
+}
+do_xfer_test 5.7 0 {
+ INSERT INTO t1 WITH x AS ( SELECT * FROM t2 ) SELECT * FROM x
+}
+do_xfer_test 5.8 0 {
+ INSERT INTO t1 WITH x(a,b) AS ( SELECT * FROM t2 ) SELECT * FROM x
+}
+
+#---------------------------------------------------------------------------
+# Check that syntax (and other) errors in statements with WITH clauses
+# attached to them do not cause problems (e.g. memory leaks).
+#
+do_execsql_test 6.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+}
+
+do_catchsql_test 6.2 {
+ WITH x AS (SELECT * FROM t1)
+ INSERT INTO t2 VALUES(1, 2,);
+} {1 {near ")": syntax error}}
+
+do_catchsql_test 6.3 {
+ WITH x AS (SELECT * FROM t1)
+ INSERT INTO t2 SELECT a, b, FROM t1;
+} {1 {near "FROM": syntax error}}
+
+do_catchsql_test 6.3 {
+ WITH x AS (SELECT * FROM t1)
+ INSERT INTO t2 SELECT a, b FROM abc;
+} {1 {no such table: abc}}
+
+do_catchsql_test 6.4 {
+ WITH x AS (SELECT * FROM t1)
+ INSERT INTO t2 SELECT a, b, FROM t1 a a a;
+} {1 {near "FROM": syntax error}}
+
+do_catchsql_test 6.5 {
+ WITH x AS (SELECT * FROM t1)
+ DELETE FROM t2 WHERE;
+} {1 {near ";": syntax error}}
+
+do_catchsql_test 6.6 {
+ WITH x AS (SELECT * FROM t1) DELETE FROM t2 WHERE
+} {1 {incomplete input}}
+
+do_catchsql_test 6.7 {
+ WITH x AS (SELECT * FROM t1) DELETE FROM t2 WHRE 1;
+} {/1 {near .* syntax error}/}
+
+do_catchsql_test 6.8 {
+ WITH x AS (SELECT * FROM t1) UPDATE t2 SET a = 10, b = ;
+} {/1 {near .* syntax error}/}
+
+do_catchsql_test 6.9 {
+ WITH x AS (SELECT * FROM t1) UPDATE t2 SET a = 10, b = 1 WHERE a===b;
+} {/1 {near .* syntax error}/}
+
+do_catchsql_test 6.10 {
+ WITH x(a,b) AS (
+ SELECT 1, 1
+ UNION ALL
+ SELECT a*b,a+b FROM x WHERE c=2
+ )
+ SELECT * FROM x
+} {1 {no such column: c}}
+
+#-------------------------------------------------------------------------
+# Recursive queries in IN(...) expressions.
+#
+do_execsql_test 7.1 {
+ CREATE TABLE t5(x INTEGER);
+ CREATE TABLE t6(y INTEGER);
+
+ WITH s(x) AS ( VALUES(7) UNION ALL SELECT x+7 FROM s WHERE x<49 )
+ INSERT INTO t5
+ SELECT * FROM s;
+
+ INSERT INTO t6
+ WITH s(x) AS ( VALUES(2) UNION ALL SELECT x+2 FROM s WHERE x<49 )
+ SELECT * FROM s;
+}
+
+do_execsql_test 7.2 {
+ SELECT * FROM t6 WHERE y IN (SELECT x FROM t5)
+} {14 28 42}
+
+do_execsql_test 7.3 {
+ WITH ss AS (SELECT x FROM t5)
+ SELECT * FROM t6 WHERE y IN (SELECT x FROM ss)
+} {14 28 42}
+
+do_execsql_test 7.4 {
+ WITH ss(x) AS ( VALUES(7) UNION ALL SELECT x+7 FROM ss WHERE x<49 )
+ SELECT * FROM t6 WHERE y IN (SELECT x FROM ss)
+} {14 28 42}
+
+do_execsql_test 7.5 {
+ SELECT * FROM t6 WHERE y IN (
+ WITH ss(x) AS ( VALUES(7) UNION ALL SELECT x+7 FROM ss WHERE x<49 )
+ SELECT x FROM ss
+ )
+} {14 28 42}
+
+#-------------------------------------------------------------------------
+# At one point the following was causing an assertion failure and a
+# memory leak.
+#
+do_execsql_test 8.1 {
+ CREATE TABLE t7(y);
+ INSERT INTO t7 VALUES(NULL);
+ CREATE VIEW v AS SELECT * FROM t7 ORDER BY y;
+}
+
+do_execsql_test 8.2 {
+ WITH q(a) AS (
+ SELECT 1
+ UNION
+ SELECT a+1 FROM q, v WHERE a<5
+ )
+ SELECT * FROM q;
+} {1 2 3 4 5}
+
+do_execsql_test 8.3 {
+ WITH q(a) AS (
+ SELECT 1
+ UNION ALL
+ SELECT a+1 FROM q, v WHERE a<5
+ )
+ SELECT * FROM q;
+} {1 2 3 4 5}
+
+# 2021-03-18
+# Ticket bb8a9fd4a9b7fce5
+reset_db
+do_execsql_test 9.1 {
+ WITH xyz(a) AS (
+ WITH abc AS ( SELECT 1234 ) SELECT * FROM abc
+ )
+ SELECT * FROM xyz AS one, xyz AS two, (
+ SELECT * FROM xyz UNION ALL SELECT * FROM xyz
+ );
+} {1234 1234 1234 1234 1234 1234}
+ifcapable vtab {
+load_static_extension db series
+do_execsql_test 9.2 {
+ WITH
+ cst(rsx, rsy) AS (
+ SELECT 100, 100
+ ),
+ cst2(minx, maxx, stepx, miny, maxy, stepy, qualitativex, qualitativey) AS (
+ SELECT NULL, NULL, NULL, NULL, NULL, NULL, 0, 0
+ ),
+ ds0(m, n, x, y, x2, y2, title, size, mark, label, markmode) AS (
+ SELECT 1, 2, 3, 4, 5, 6, 7 , 8, 9, 10, 11
+ ),
+ ds(m, n, x, y, x2, y2, title, size, mark, label, markmode) AS (
+ SELECT m, n, x,
+ y, x2,
+ y2,
+ title, size, mark, label, markmode
+ FROM ds0
+ WINDOW w AS (PARTITION BY m, x ORDER BY n)
+ ),
+ d(m, n, x, y, x2, y2, labelx,labely,title,size,mark,label,markmode) AS (
+ SELECT m, n, x, y, x2, y2, x, y, title, size, mark, label, markmode
+ FROM ds, cst2
+ ),
+ ylabels(y, label) AS (
+ SELECT y, MIN(labely) FROM d GROUP BY y
+ ),
+ yaxis(maxy, miny, stepy , minstepy) AS (
+ WITH
+ xt0(minx, maxx) AS (
+ SELECT coalesce(miny, min(min(y2),
+ min(y))), coalesce(maxy, max(max(y2),
+ max(y))) + qualitativey
+ FROM d, cst2
+ ),
+ xt1(mx, mn) AS (SELECT maxx, minx FROM xt0),
+ xt2(mx, mn, step) AS (SELECT mx, mn, (mx-mn) FROM xt1),
+
+ xt3(mx, mn, ms) AS (
+ SELECT mx, mn, first_value(rs) OVER (order by x desc) AS ms
+ FROM (SELECT mx, mn, step, f,(mx-mn) as rng,
+ 1.0*step/f as rs, 1.0*(mx-mn)/(step/f) AS x
+ FROM xt2, (SELECT 1 AS f UNION ALL SELECT 2
+ UNION ALL SELECT 4
+ UNION ALL SELECT 5)) AS src
+ WHERE x < 10 limit 1),
+ xt4(minstepy) AS (
+ SELECT MIN(abs(y2-y)) FROM d WHERE y2 != y
+ )
+ SELECT (mx/ms)*ms, (mn/ms)*ms, coalesce(stepy, ms),
+ coalesce(minstepy, ms, stepy) FROM xt3, cst2,xt4
+ ),
+ distinct_mark_n_m(mark, ze, zem, title) AS (
+ SELECT DISTINCT mark, n AS ze, m AS zem, title FROM ds0
+ ),
+ facet0(m, mi, title, radial) AS (
+ SELECT md, row_number() OVER () - 1, title, 'radial'
+ IN (SELECT mark FROM distinct_mark_n_m WHERE zem = md)
+ FROM (SELECT DISTINCT zem AS md, title AS title
+ FROM distinct_mark_n_m ORDER BY 2, 1)
+ ),
+ facet(m, mi, xorigin, yorigin, title, radial) AS (
+ SELECT m, mi,
+ rsx * 1.2 * IFNULL(CASE WHEN (
+ 0
+ ) > 0 THEN mi / (
+ 0
+ ) ELSE mi % (
+ 2
+ ) END, mi),
+ rsy * 1.2 * IFNULL(CASE WHEN (
+ 2
+ ) > 0 THEN mi / (
+ 2
+ ) ELSE mi / (
+ 0
+ ) END, 0),
+ title, radial FROM facet0, cst
+ ),
+ radygrid(m, mi, tty, wty, ttx, ttx2, xorigin, yorigin) AS (
+ SELECT m, mi, rsy / 2 / ((maxy-miny)/stepy) * (value-1) AS tty,
+ coalesce(NULL, miny + stepy * (value-1)) AS wty,
+ xorigin, xorigin+rsx, xorigin + rsx / 2,
+ yorigin + rsy / 2
+ FROM generate_series(1), yaxis, cst,
+ facet LEFT JOIN ylabels ON ylabels.y = (miny + (value-1) * stepy)
+ WHERE radial AND stop = 1+1.0*(maxy-miny)/stepy
+ ),
+ ypos(m, mi, pcx, pcy, radial) AS (
+ SELECT m, mi, xorigin, yorigin + CASE
+ WHEN 0 BETWEEN miny AND maxy THEN
+ rsy - (0 - miny) * rsy / (maxy-miny)
+ WHEN 0 >= maxy THEN 0
+ ELSE rsy
+ END, radial FROM yaxis, cst, facet WHERE NOT radial
+ UNION ALL
+ SELECT m, mi, xorigin + rsx / 2, yorigin + (CASE
+ WHEN 0 BETWEEN miny AND maxy THEN
+ rsy - (0 - miny) * rsy / 2 / (maxy-miny)
+ WHEN 0 >= maxy THEN 0
+ ELSE rsy
+ END ) / 2, radial FROM yaxis, cst, facet WHERE radial
+ )
+ SELECT * FROM radygrid , ypos;
+} {}
+} ;# end ifcapable vtab
+
+# 2021-03-19
+# dbsqlfuzz 01b8355086998f0a452cb31208e80b9d29ca739a
+#
+# Correlated CTEs should not be materialized.
+#
+reset_db
+do_execsql_test 10.1 {
+ SELECT 1 AS c WHERE (
+ SELECT (
+ WITH t1(a) AS (VALUES( c ))
+ SELECT ( SELECT t1a.a FROM t1 AS t1a, t1 AS t1x )
+ FROM t1 AS xyz GROUP BY 1
+ )
+ )
+} {1}
+
+# 2021-05-21
+# Forum post https://sqlite.org/forum/forumpost/aa4a7a3980
+#
+ifcapable altertable {
+reset_db
+ do_execsql_test 11.1 {
+ CREATE TABLE t1(a);
+ CREATE VIEW v2(c) AS
+ WITH x AS (
+ WITH y AS (
+ WITH z AS(SELECT * FROM t1)
+ SELECT * FROM v2
+ ) SELECT a
+ ) SELECT * from t1;
+ ALTER TABLE t1 RENAME COLUMN a TO b;
+ SELECT sql FROM sqlite_schema WHERE name='t1';
+ } {{CREATE TABLE t1(b)}}
+ do_catchsql_test 11.2 {
+ INSERT INTO t1 VALUES(55);
+ SELECT * FROM v2;
+ } {0 55}
+ do_catchsql_test 11.3 {
+ DROP VIEW v2;
+ CREATE VIEW v2(c) AS
+ WITH x AS (
+ WITH y AS (
+ WITH z AS(SELECT * FROM t1)
+ SELECT * FROM v2
+ ) SELECT a
+ ) SELECT * from t1, x;
+ SELECT * FROM v2;
+ } {1 {no such column: a}}
+ do_catchsql_test 11.4 {
+ DROP VIEW v2;
+ CREATE VIEW v2(c) AS
+ WITH x AS (
+ WITH y AS (
+ WITH z AS(SELECT * FROM t1)
+ SELECT * FROM v2
+ ) SELECT *
+ ) SELECT * from t1, x;
+ SELECT * FROM v2;
+ } {1 {no tables specified}}
+ do_catchsql_test 11.5 {
+ WITH x AS (
+ WITH y AS (
+ WITH z AS(SELECT * FROM t1)
+ SELECT * FROM no_such_table
+ ) SELECT a
+ ) SELECT * from t1;
+ } {0 55}
+}
+
+# 2021-05-23 dbsqlfuzz 6b7a144674e215f06ddfeb9042c873d9ee956ac0 */
+reset_db
+ifcapable altertable {
+ do_execsql_test 12.1 {
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES(1),('hello'),(4.25),(NULL),(x'3c626c6f623e');
+ CREATE VIEW v2(c) AS WITH x AS (WITH y AS (WITH z AS(SELECT * FROM t1) SELECT * FROM v2) SELECT a) SELECT * from t1;
+ CREATE VIEW v3(c) AS WITH x AS (WITH y AS (WITH z AS(SELECT * FROM v2) SELECT * FROM v3) SELECT a) SELECT * from t1;
+ ALTER TABLE t1 RENAME TO t1x;
+ SELECT quote(c) FROM v3;
+ } {1 'hello' 4.25 NULL X'3C626C6F623E'}
+}
+
+# 2021-08-11 https://sqlite.org/forum/forumpost/d496c3d29bc93736
+reset_db
+do_execsql_test 13.1 {
+ WITH
+ t1(x) AS (SELECT 111),
+ t2(y) AS (SELECT 222),
+ t3(z) AS (SELECT * FROM t2 WHERE false UNION ALL SELECT * FROM t2)
+ SELECT * FROM t1, t3;
+} {111 222}
+
+finish_test
diff --git a/test/with3.test b/test/with3.test
new file mode 100644
index 0000000..1aed92a
--- /dev/null
+++ b/test/with3.test
@@ -0,0 +1,247 @@
+# 2015-11-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 file is testing the WITH clause.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix with3
+
+ifcapable {!cte} {
+ finish_test
+ return
+}
+
+# Test problems found by Kostya Serebryany using
+# LibFuzzer. (http://llvm.org/docs/LibFuzzer.html)
+#
+do_catchsql_test 1.0 {
+ WITH i(x) AS (
+ WITH j AS (SELECT 10)
+ SELECT 5 FROM t0 UNION SELECT 8 FROM m
+ )
+ SELECT * FROM i;
+} {1 {no such table: m}}
+
+# 2019-11-09 dbfuzzcheck find
+do_catchsql_test 1.1 {
+ CREATE VIEW v1(x,y) AS
+ WITH t1(a,b) AS (VALUES(1,2))
+ SELECT * FROM nosuchtable JOIN t1;
+ SELECT * FROM v1;
+} {1 {no such table: main.nosuchtable}}
+
+# Additional test cases that came out of the work to
+# fix for Kostya's problem.
+#
+do_execsql_test 2.0 {
+ WITH
+ x1 AS (SELECT 10),
+ x2 AS (SELECT 11),
+ x3 AS (
+ SELECT * FROM x1 UNION ALL SELECT * FROM x2
+ ),
+ x4 AS (
+ WITH
+ x1 AS (SELECT 12),
+ x2 AS (SELECT 13)
+ SELECT * FROM x3
+ )
+ SELECT * FROM x4;
+
+} {10 11}
+
+do_execsql_test 2.1 {
+ CREATE TABLE t1(x);
+ WITH
+ x1(a) AS (values(100))
+ INSERT INTO t1(x)
+ SELECT * FROM (WITH x2(y) AS (SELECT * FROM x1) SELECT y+a FROM x1, x2);
+ SELECT * FROM t1;
+} {200}
+
+#-------------------------------------------------------------------------
+# Test that the planner notices LIMIT clauses on recursive WITH queries.
+#
+
+ifcapable analyze {
+ do_execsql_test 3.1.1 {
+ CREATE TABLE y1(a, b);
+ CREATE INDEX y1a ON y1(a);
+
+ WITH cnt(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM cnt LIMIT 1000)
+ INSERT INTO y1 SELECT i%10, i FROM cnt;
+ ANALYZE;
+
+ }
+
+ do_eqp_test 3.1.2 {
+ WITH cnt(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM cnt LIMIT 1)
+ SELECT * FROM cnt, y1 WHERE i=a
+ } [string map {"\n " \n} {
+ QUERY PLAN
+ |--MATERIALIZE cnt
+ | |--SETUP
+ | | `--SCAN CONSTANT ROW
+ | `--RECURSIVE STEP
+ | `--SCAN cnt
+ |--SCAN cnt
+ `--SEARCH y1 USING INDEX y1a (a=?)
+ }]
+
+ do_eqp_test 3.1.3 {
+ WITH cnt(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM cnt LIMIT 1000000)
+ SELECT * FROM cnt, y1 WHERE i=a
+ } [string map {"\n " \n} {
+ QUERY PLAN
+ |--MATERIALIZE cnt
+ | |--SETUP
+ | | `--SCAN CONSTANT ROW
+ | `--RECURSIVE STEP
+ | `--SCAN cnt
+ |--SCAN y1
+ `--SEARCH cnt USING AUTOMATIC COVERING INDEX (i=?)
+ }]
+}
+
+do_execsql_test 3.2.1 {
+ CREATE TABLE w1(pk INTEGER PRIMARY KEY, x INTEGER);
+ CREATE TABLE w2(pk INTEGER PRIMARY KEY);
+}
+
+do_eqp_test 3.2.2 {
+ WITH RECURSIVE c(w,id) AS (SELECT 0, (SELECT pk FROM w2 LIMIT 1)
+ UNION ALL SELECT c.w + 1, x FROM w1, c LIMIT 1)
+ SELECT * FROM c, w2, w1
+ WHERE c.id=w2.pk AND c.id=w1.pk;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c
+ | |--SETUP
+ | | |--SCAN CONSTANT ROW
+ | | `--SCALAR SUBQUERY xxxxxx
+ | | `--SCAN w2
+ | `--RECURSIVE STEP
+ | |--SCAN c
+ | `--SCAN w1
+ |--SCAN c
+ |--SEARCH w2 USING INTEGER PRIMARY KEY (rowid=?)
+ `--SEARCH w1 USING INTEGER PRIMARY KEY (rowid=?)
+}
+
+do_execsql_test 4.0 {
+ WITH t5(t5col1) AS (
+ SELECT (
+ WITH t3(t3col1) AS (
+ WITH t2 AS (
+ WITH t1 AS (SELECT 1 AS c1 GROUP BY 1)
+ SELECT a.c1 FROM t1 AS a, t1 AS b
+ WHERE anoncol1 = 1
+ )
+ SELECT (SELECT 1 FROM t2) FROM t2
+ )
+ SELECT t3col1 FROM t3 WHERE t3col1
+ ) FROM (SELECT 1 AS anoncol1)
+ )
+ SELECT t5col1, t5col1 FROM t5
+} {1 1}
+do_execsql_test 4.1 {
+ SELECT EXISTS (
+ WITH RECURSIVE Table0 AS (
+ WITH RECURSIVE Table0(Col0) AS (SELECT ALL 1 )
+ SELECT ALL (
+ WITH RECURSIVE Table0 AS (
+ WITH RECURSIVE Table0 AS (
+ WITH RECURSIVE Table0 AS (SELECT DISTINCT 1 GROUP BY 1 )
+ SELECT DISTINCT * FROM Table0 NATURAL INNER JOIN Table0
+ WHERE Col0 = 1
+ )
+ SELECT ALL (SELECT DISTINCT * FROM Table0) FROM Table0 WHERE Col0 = 1
+ )
+ SELECT ALL * FROM Table0 NATURAL INNER JOIN Table0
+ ) FROM Table0 )
+ SELECT DISTINCT * FROM Table0 NATURAL INNER JOIN Table0
+ );
+} {1}
+
+# 2020-01-18 chrome ticket 1043236
+# Correct handling of the sequence:
+# OP_OpenEphem
+# OP_OpenDup
+# Op_OpenEphem
+# OP_OpenDup
+#
+do_execsql_test 4.2 {
+ SELECT (
+ WITH t1(a) AS (VALUES(1))
+ SELECT (
+ WITH t2(b) AS (
+ WITH t3(c) AS (
+ WITH t4(d) AS (VALUES('elvis'))
+ SELECT t4a.d FROM t4 AS t4a JOIN t4 AS t4b LEFT JOIN t4 AS t4c
+ )
+ SELECT c FROM t3 WHERE a = 1
+ )
+ SELECT t2a.b FROM t2 AS t2a JOIN t2 AS t2x
+ )
+ FROM t1 GROUP BY 1
+ )
+ GROUP BY 1;
+} {elvis}
+
+# 2021-02-13
+# Avoid manifesting the same CTE multiple times.
+#
+do_eqp_test 5.1 {
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<1)
+ SELECT x1.x||x2.x||x3.x||x4.x FROM c AS x1, c AS x2, c AS x3, c AS x4
+ ORDER BY 1;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c
+ | |--SETUP
+ | | `--SCAN CONSTANT ROW
+ | `--RECURSIVE STEP
+ | `--SCAN c
+ |--SCAN x1
+ |--SCAN x2
+ |--SCAN x3
+ |--SCAN x4
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_execsql_test 5.2 {
+ WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<1)
+ SELECT x1.x||x2.x||x3.x||x4.x FROM c AS x1, c AS x2, c AS x3, c AS x4
+ ORDER BY 1;
+} {0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111}
+
+#-------------------------------------------------------------------------
+# At one point this would incorrectly report "circular reference: cte1"
+#
+do_catchsql_test 6.0 {
+ with
+ cte1(x, y) AS ( select 1, 2, 3 ),
+ cte2(z) as ( select 1 from cte1 )
+ select * from cte2, cte1;
+} {1 {table cte1 has 3 values for 2 columns}}
+
+do_catchsql_test 6.1 {
+ with
+ cte1(x, y) AS ( select 1, 2, 3 ),
+ cte2(z) as ( select 1 from cte1 UNION ALL SELECT z+1 FROM cte2 WHERE z<5)
+ select * from cte2, cte1;
+} {1 {table cte1 has 3 values for 2 columns}}
+
+
+
+
+finish_test
diff --git a/test/with4.test b/test/with4.test
new file mode 100644
index 0000000..b0eeba6
--- /dev/null
+++ b/test/with4.test
@@ -0,0 +1,52 @@
+# 2018-02-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 WITH clause in TRIGGERs and VIEWs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix with4
+
+ifcapable {!cte} {
+ finish_test
+ return
+}
+
+do_execsql_test 100 {
+ ATTACH ':memory:' AS aux;
+ CREATE TABLE main.t1(a,b);
+ CREATE TABLE aux.t2(x,y);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t2 VALUES(3,4);
+} {}
+do_catchsql_test 110 {
+ CREATE VIEW v1 AS SELECT * FROM t1, aux.t2;
+} {1 {view v1 cannot reference objects in database aux}}
+do_catchsql_test 120 {
+ CREATE VIEW v2 AS WITH v(m,n) AS (SELECT x,y FROM aux.t2) SELECT * FROM t1, v;
+} {1 {view v2 cannot reference objects in database aux}}
+do_catchsql_test 130 {
+ CREATE VIEW v2 AS WITH v(m,n) AS (SELECT 5,?2) SELECT * FROM t1, v;
+} {1 {parameters are not allowed in views}}
+
+do_catchsql_test 200 {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ WITH v(m,n) AS (SELECT x,y FROM aux.t2) SELECT * FROM t1, v;
+ END;
+} {1 {trigger r1 cannot reference objects in database aux}}
+do_catchsql_test 210 {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ WITH v(m,n) AS (SELECT 5,?2) SELECT * FROM t1, v;
+ END;
+} {1 {trigger cannot use variables}}
+
+finish_test
diff --git a/test/with5.test b/test/with5.test
new file mode 100644
index 0000000..430c5f2
--- /dev/null
+++ b/test/with5.test
@@ -0,0 +1,194 @@
+# 2020-10-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 recursive common table expressions with
+# multiple recursive terms in the compound select.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix with5
+
+ifcapable {!cte} {
+ finish_test
+ return
+}
+
+do_execsql_test 100 {
+ CREATE TABLE link(aa INT, bb INT);
+ CREATE INDEX link_f ON link(aa,bb);
+ CREATE INDEX link_t ON link(bb,aa);
+ INSERT INTO link(aa,bb) VALUES
+ (1,3),
+ (5,3),
+ (7,1),
+ (7,9),
+ (9,9),
+ (5,11),
+ (11,7),
+ (2,4),
+ (4,6),
+ (8,6);
+} {}
+do_execsql_test 110 {
+ WITH RECURSIVE closure(x) AS (
+ VALUES(1)
+ UNION
+ SELECT aa FROM closure, link WHERE link.bb=closure.x
+ UNION
+ SELECT bb FROM closure, link WHERE link.aa=closure.x
+ )
+ SELECT x FROM closure ORDER BY x;
+} {1 3 5 7 9 11}
+do_execsql_test 111 {
+ WITH RECURSIVE closure(x) AS (
+ VALUES(1)
+ UNION
+ SELECT aa FROM link, closure WHERE link.bb=closure.x
+ UNION
+ SELECT bb FROM closure, link WHERE link.aa=closure.x
+ )
+ SELECT x FROM closure ORDER BY x;
+} {1 3 5 7 9 11}
+do_execsql_test 112 {
+ WITH RECURSIVE closure(x) AS (
+ VALUES(1)
+ UNION
+ SELECT bb FROM closure, link WHERE link.aa=closure.x
+ UNION
+ SELECT aa FROM link, closure WHERE link.bb=closure.x
+ )
+ SELECT x FROM closure ORDER BY x;
+} {1 3 5 7 9 11}
+do_execsql_test 113 {
+ WITH RECURSIVE closure(x) AS (
+ VALUES(1),(200),(300),(400)
+ INTERSECT
+ VALUES(1)
+ UNION
+ SELECT bb FROM closure, link WHERE link.aa=closure.x
+ UNION
+ SELECT aa FROM link, closure WHERE link.bb=closure.x
+ )
+ SELECT x FROM closure ORDER BY x;
+} {1 3 5 7 9 11}
+do_execsql_test 114 {
+ WITH RECURSIVE closure(x) AS (
+ VALUES(1),(200),(300),(400)
+ UNION ALL
+ VALUES(2)
+ UNION
+ SELECT bb FROM closure, link WHERE link.aa=closure.x
+ UNION
+ SELECT aa FROM link, closure WHERE link.bb=closure.x
+ )
+ SELECT x FROM closure ORDER BY x;
+} {1 2 3 4 5 6 7 8 9 11 200 300 400}
+
+do_catchsql_test 120 {
+ WITH RECURSIVE closure(x) AS (
+ VALUES(1),(200),(300),(400)
+ UNION ALL
+ VALUES(2)
+ UNION ALL
+ SELECT bb FROM closure, link WHERE link.aa=closure.x
+ UNION
+ SELECT aa FROM link, closure WHERE link.bb=closure.x
+ )
+ SELECT x FROM closure ORDER BY x;
+} {1 {circular reference: closure}}
+do_catchsql_test 121 {
+ WITH RECURSIVE closure(x) AS (
+ VALUES(1),(200),(300),(400)
+ UNION ALL
+ VALUES(2)
+ UNION
+ SELECT bb FROM closure, link WHERE link.aa=closure.x
+ UNION ALL
+ SELECT aa FROM link, closure WHERE link.bb=closure.x
+ )
+ SELECT x FROM closure ORDER BY x;
+} {1 {circular reference: closure}}
+
+do_execsql_test 130 {
+ WITH RECURSIVE closure(x) AS (
+ SELECT 1 AS x
+ UNION
+ SELECT aa FROM link JOIN closure ON bb=x
+ UNION
+ SELECT bb FROM link JOIN closure on aa=x
+ ORDER BY x LIMIT 4
+ )
+ SELECT * FROM closure;
+} {1 3 5 7}
+do_execsql_test 131 {
+ WITH RECURSIVE closure(x) AS (
+ SELECT 1 AS x
+ UNION ALL
+ SELECT 2
+ UNION
+ SELECT aa FROM link JOIN closure ON bb=x
+ UNION
+ SELECT bb FROM link JOIN closure on aa=x
+ ORDER BY x LIMIT 4
+ )
+ SELECT * FROM closure;
+} {1 2 3 4}
+
+do_execsql_test 200 {
+ CREATE TABLE linkA(aa1,aa2);
+ INSERT INTO linkA(aa1,aa2) VALUES(1,3),(5,7),(9,11);
+ CREATE TABLE linkB(bb1,bb2);
+ INSERT INTO linkB(bb1,bb2) VALUES(7,9),(11,13),(3,5);
+ CREATE TABLE linkC(cc1,cc2);
+ INSERT INTO linkC(cc1,cc2) VALUES(1,2),(2,4),(6,8);
+ CREATE TABLE linkD(dd1,dd2);
+ INSERT INTO linkD(dd1,dd2) VALUES(4,6),(100,110);
+} {}
+do_execsql_test 210 {
+ WITH RECURSIVE closure(x) AS (
+ VALUES(1)
+ UNION ALL
+ SELECT aa2 FROM linkA JOIN closure ON x=aa1
+ UNION ALL
+ SELECT bb2 FROM linkB JOIN closure ON x=bb1
+ UNION ALL
+ SELECT cc2 FROM linkC JOIN closure ON x=cc1
+ UNION ALL
+ SELECT dd2 FROM linkD JOIN closure ON x=dd1
+ )
+ SELECT x FROM closure ORDER BY +x;
+} {1 2 3 4 5 6 7 8 9 11 13}
+do_execsql_test 220 {
+ CREATE TABLE linkA_ipk(aa1 INTEGER PRIMARY KEY,aa2);
+ INSERT INTO linkA_ipk(aa1,aa2) SELECT aa1, aa2 FROM linkA;
+ CREATE TABLE linkB_ipk(bb1 INTEGER PRIMARY KEY,bb2);
+ INSERT INTO linkB_ipk(bb1,bb2) SELECT bb1, bb2 FROM linkB;
+ CREATE TABLE linkC_ipk(cc1 INTEGER PRIMARY KEY,cc2);
+ INSERT INTO linkC_ipk(cc1,cc2) SELECT cc1, cc2 FROM linkC;
+ CREATE TABLE linkD_ipk(dd1 INTEGER PRIMARY KEY,dd2);
+ INSERT INTO linkD_ipk(dd1,dd2) SELECT dd1, dd2 FROM linkD;
+ WITH RECURSIVE closure(x) AS (
+ VALUES(1)
+ UNION ALL
+ SELECT aa2 FROM linkA_ipk JOIN closure ON x=aa1
+ UNION ALL
+ SELECT bb2 FROM linkB_ipk JOIN closure ON x=bb1
+ UNION ALL
+ SELECT cc2 FROM linkC_ipk JOIN closure ON x=cc1
+ UNION ALL
+ SELECT dd2 FROM linkD_ipk JOIN closure ON x=dd1
+ )
+ SELECT x FROM closure ORDER BY +x;
+} {1 2 3 4 5 6 7 8 9 11 13}
+
+
+finish_test
diff --git a/test/with6.test b/test/with6.test
new file mode 100644
index 0000000..20e518b
--- /dev/null
+++ b/test/with6.test
@@ -0,0 +1,322 @@
+# 2021-02-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 the MATERIALIZED hint to common table expressions
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix with6
+
+ifcapable {!cte} {
+ finish_test
+ return
+}
+
+do_execsql_test 100 {
+ WITH c(x) AS (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x FROM c c1, c c2, c c3;
+} {000 001 010 011 100 101 110 111}
+do_eqp_test 101 {
+ WITH c(x) AS (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x FROM c c1, c c2, c c3;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c
+ | `--SCAN 2 CONSTANT ROWS
+ |--SCAN c1
+ |--SCAN c2
+ `--SCAN c3
+}
+
+do_execsql_test 110 {
+ WITH c(x) AS MATERIALIZED (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x FROM c c1, c c2, c c3;
+} {000 001 010 011 100 101 110 111}
+do_eqp_test 111 {
+ WITH c(x) AS MATERIALIZED (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x FROM c c1, c c2, c c3;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c
+ | `--SCAN 2 CONSTANT ROWS
+ |--SCAN c1
+ |--SCAN c2
+ `--SCAN c3
+}
+
+# Even though the CTE is not materialized, the self-join optimization
+# kicks in and does the materialization for us.
+#
+do_execsql_test 120 {
+ WITH c(x) AS NOT MATERIALIZED (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x FROM c c1, c c2, c c3;
+} {000 001 010 011 100 101 110 111}
+do_eqp_test 121 {
+ WITH c(x) AS NOT MATERIALIZED (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x FROM c c1, c c2, c c3;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c
+ | `--SCAN 2 CONSTANT ROWS
+ |--SCAN c1
+ |--SCAN c2
+ `--SCAN c3
+}
+
+do_execsql_test 130 {
+ WITH c(x) AS NOT MATERIALIZED (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x
+ FROM (SELECT x FROM c LIMIT 5) AS c1,
+ (SELECT x FROM c LIMIT 5) AS c2,
+ (SELECT x FROM c LIMIT 5) AS c3;
+} {000 001 010 011 100 101 110 111}
+do_eqp_test 131 {
+ WITH c(x) AS NOT MATERIALIZED (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x
+ FROM (SELECT x FROM c LIMIT 5) AS c1,
+ (SELECT x FROM c LIMIT 5) AS c2,
+ (SELECT x FROM c LIMIT 5) AS c3;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c1
+ | |--CO-ROUTINE c
+ | | `--SCAN 2 CONSTANT ROWS
+ | `--SCAN c
+ |--MATERIALIZE c2
+ | |--CO-ROUTINE c
+ | | `--SCAN 2 CONSTANT ROWS
+ | `--SCAN c
+ |--MATERIALIZE c3
+ | |--CO-ROUTINE c
+ | | `--SCAN 2 CONSTANT ROWS
+ | `--SCAN c
+ |--SCAN c1
+ |--SCAN c2
+ `--SCAN c3
+}
+
+# The (SELECT x FROM c LIMIT N) subqueries get materialized once each.
+# Show multiple materializations are shown. But there is only one
+# materialization for c, shown by the "SCAN 2 CONSTANT ROWS" line.
+#
+do_execsql_test 140 {
+ WITH c(x) AS MATERIALIZED (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x
+ FROM (SELECT x FROM c LIMIT 5) AS c1,
+ (SELECT x FROM c LIMIT 6) AS c2,
+ (SELECT x FROM c LIMIT 7) AS c3;
+} {000 001 010 011 100 101 110 111}
+do_eqp_test 141 {
+ WITH c(x) AS MATERIALIZED (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x
+ FROM (SELECT x FROM c LIMIT 5) AS c1,
+ (SELECT x FROM c LIMIT 6) AS c2,
+ (SELECT x FROM c LIMIT 7) AS c3;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c1
+ | |--MATERIALIZE c
+ | | `--SCAN 2 CONSTANT ROWS
+ | `--SCAN c
+ |--MATERIALIZE c2
+ | `--SCAN c
+ |--MATERIALIZE c3
+ | `--SCAN c
+ |--SCAN c1
+ |--SCAN c2
+ `--SCAN c3
+}
+
+do_execsql_test 150 {
+ WITH c(x) AS (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x
+ FROM (SELECT x FROM c LIMIT 5) AS c1,
+ (SELECT x FROM c LIMIT 6) AS c2,
+ (SELECT x FROM c LIMIT 7) AS c3;
+} {000 001 010 011 100 101 110 111}
+do_eqp_test 151 {
+ WITH c(x) AS (VALUES(0),(1))
+ SELECT c1.x||c2.x||c3.x
+ FROM (SELECT x FROM c LIMIT 5) AS c1,
+ (SELECT x FROM c LIMIT 6) AS c2,
+ (SELECT x FROM c LIMIT 7) AS c3;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c1
+ | |--MATERIALIZE c
+ | | `--SCAN 2 CONSTANT ROWS
+ | `--SCAN c
+ |--MATERIALIZE c2
+ | `--SCAN c
+ |--MATERIALIZE c3
+ | `--SCAN c
+ |--SCAN c1
+ |--SCAN c2
+ `--SCAN c3
+}
+
+do_execsql_test 160 {
+ WITH c(x) AS (VALUES(0),(1))
+ SELECT c2.x + 100*(SELECT sum(x+1) FROM c WHERE c.x<=c2.x)
+ FROM c AS c2 WHERE c2.x<10;
+} {100 301}
+do_eqp_test 161 {
+ WITH c(x) AS (VALUES(0),(1))
+ SELECT c2.x + 100*(SELECT sum(x+1) FROM c WHERE c.x<=c2.x)
+ FROM c AS c2 WHERE c2.x<10;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c
+ | `--SCAN 2 CONSTANT ROWS
+ |--SCAN c2
+ `--CORRELATED SCALAR SUBQUERY xxxxxx
+ `--SCAN c
+}
+
+do_execsql_test 170 {
+ WITH c(x) AS NOT MATERIALIZED (VALUES(0),(1))
+ SELECT c2.x + 100*(SELECT sum(x+1) FROM c WHERE c.x<=c2.x)
+ FROM c AS c2 WHERE c2.x<10;
+} {100 301}
+do_eqp_test 171 {
+ WITH c(x) AS NOT MATERIALIZED (VALUES(0),(1))
+ SELECT c2.x + 100*(SELECT sum(x+1) FROM c WHERE c.x<=c2.x)
+ FROM c AS c2 WHERE c2.x<10;
+} {
+ QUERY PLAN
+ |--CO-ROUTINE c
+ | `--SCAN 2 CONSTANT ROWS
+ |--SCAN c2
+ `--CORRELATED SCALAR SUBQUERY xxxxxx
+ |--CO-ROUTINE c
+ | `--SCAN 2 CONSTANT ROWS
+ `--SCAN c
+}
+
+
+do_execsql_test 200 {
+ CREATE TABLE t1(x);
+ INSERT INTO t1(x) VALUES(4);
+ CREATE VIEW t2(y) AS
+ WITH c(z) AS (VALUES(4),(5),(6))
+ SELECT c1.z+c2.z*100+t1.x*10000
+ FROM t1,
+ (SELECT z FROM c LIMIT 5) AS c1,
+ (SELECT z FROM c LIMIT 5) AS c2;
+ SELECT y FROM t2 ORDER BY y;
+} {40404 40405 40406 40504 40505 40506 40604 40605 40606}
+do_execsql_test 210 {
+ DROP VIEW t2;
+ CREATE VIEW t2(y) AS
+ WITH c(z) AS NOT MATERIALIZED (VALUES(4),(5),(6))
+ SELECT c1.z+c2.z*100+t1.x*10000
+ FROM t1,
+ (SELECT z FROM c LIMIT 5) AS c1,
+ (SELECT z FROM c LIMIT 5) AS c2;
+ SELECT y FROM t2 ORDER BY y;
+} {40404 40405 40406 40504 40505 40506 40604 40605 40606}
+do_eqp_test 211 {
+ SELECT y FROM t2 ORDER BY y;
+} {
+ QUERY PLAN
+ |--MATERIALIZE c1
+ | |--CO-ROUTINE c
+ | | `--SCAN 3 CONSTANT ROWS
+ | `--SCAN c
+ |--MATERIALIZE c2
+ | |--CO-ROUTINE c
+ | | `--SCAN 3 CONSTANT ROWS
+ | `--SCAN c
+ |--SCAN c1
+ |--SCAN c2
+ |--SCAN t1
+ `--USE TEMP B-TREE FOR ORDER BY
+}
+do_execsql_test 220 {
+ DROP VIEW t2;
+ CREATE VIEW t2(y) AS
+ WITH c(z) AS MATERIALIZED (VALUES(4),(5),(6))
+ SELECT c1.z+c2.z*100+t1.x*10000
+ FROM t1,
+ (SELECT z FROM c LIMIT 5) AS c1,
+ (SELECT z FROM c LIMIT 5) AS c2;
+ SELECT y FROM t2 ORDER BY y;
+} {40404 40405 40406 40504 40505 40506 40604 40605 40606}
+
+# 2022-04-22: Do not allow flattening of a MATERIALIZED CTE into
+# an outer query.
+#
+reset_db
+db null -
+do_execsql_test 300 {
+ CREATE TABLE t2(a INT,b INT,d INT); INSERT INTO t2 VALUES(4,5,6),(7,8,9);
+ CREATE TABLE t3(a INT,b INT,e INT); INSERT INTO t3 VALUES(3,3,3),(8,8,8);
+} {}
+do_execsql_test 310 {
+ WITH t23 AS MATERIALIZED (SELECT * FROM t2 FULL JOIN t3 USING(b))
+ SELECT * FROM t23;
+} {
+ 4 5 6 - -
+ 7 8 9 8 8
+ - 3 - 3 3
+}
+do_eqp_test 311 {
+ WITH t23 AS MATERIALIZED (SELECT * FROM t2 FULL JOIN t3 USING(b))
+ SELECT * FROM t23;
+} {
+ QUERY PLAN
+ |--MATERIALIZE t23
+ | |--SCAN t2
+ | |--SCAN t3 LEFT-JOIN
+ | `--RIGHT-JOIN t3
+ | `--SCAN t3
+ `--SCAN t23
+}
+do_execsql_test 320 {
+ WITH t23 AS NOT MATERIALIZED (SELECT * FROM t2 FULL JOIN t3 USING(b))
+ SELECT * FROM t23;
+} {
+ 4 5 6 - -
+ 7 8 9 8 8
+ - 3 - 3 3
+}
+do_eqp_test 321 {
+ WITH t23 AS NOT MATERIALIZED (SELECT * FROM t2 FULL JOIN t3 USING(b))
+ SELECT * FROM t23;
+} {
+ QUERY PLAN
+ |--SCAN t2
+ |--SCAN t3 LEFT-JOIN
+ `--RIGHT-JOIN t3
+ `--SCAN t3
+}
+do_execsql_test 330 {
+ WITH t23 AS (SELECT * FROM t2 FULL JOIN t3 USING(b))
+ SELECT * FROM t23;
+} {
+ 4 5 6 - -
+ 7 8 9 8 8
+ - 3 - 3 3
+}
+do_eqp_test 331 {
+ WITH t23 AS (SELECT * FROM t2 FULL JOIN t3 USING(b))
+ SELECT * FROM t23;
+} {
+ QUERY PLAN
+ |--SCAN t2
+ |--SCAN t3 LEFT-JOIN
+ `--RIGHT-JOIN t3
+ `--SCAN t3
+}
+
+
+finish_test
diff --git a/test/withM.test b/test/withM.test
new file mode 100644
index 0000000..78b757f
--- /dev/null
+++ b/test/withM.test
@@ -0,0 +1,74 @@
+# 2014 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 WITH clause.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set ::testprefix withM
+
+ifcapable {!cte} {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x INTEGER, y INTEGER);
+ INSERT INTO t1 VALUES(123, 456);
+}
+
+do_faultsim_test withM-1.1 -prep {
+ sqlite3 db test.db
+} -body {
+ execsql {
+ WITH tmp AS ( SELECT * FROM t1 )
+ SELECT * FROM tmp;
+ }
+} -test {
+ faultsim_test_result {0 {123 456}}
+ db close
+}
+
+do_faultsim_test withM-1.2 -prep {
+ sqlite3 db test.db
+} -body {
+ execsql {
+ WITH w1 AS ( SELECT * FROM t1 ),
+ w2 AS (
+ WITH w3 AS ( SELECT * FROM w1 )
+ SELECT * FROM w3
+ )
+ SELECT * FROM w2;
+ }
+} -test {
+ faultsim_test_result {0 {123 456}}
+ db close
+}
+
+do_faultsim_test withM-1.3 -prep {
+ sqlite3 db test.db
+} -body {
+ execsql {
+ WITH w1(a,b) AS (
+ SELECT 1, 1
+ UNION ALL
+ SELECT a+1, b + 2*a + 1 FROM w1
+ )
+ SELECT * FROM w1 LIMIT 5;
+ }
+} -test {
+ faultsim_test_result {0 {1 1 2 4 3 9 4 16 5 25}}
+ db close
+}
+
+finish_test
diff --git a/test/without_rowid1.test b/test/without_rowid1.test
new file mode 100644
index 0000000..3c33f73
--- /dev/null
+++ b/test/without_rowid1.test
@@ -0,0 +1,490 @@
+# 2013-10-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 WITHOUT ROWID tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix without_rowid1
+
+proc do_execsql_test_if_vtab {tn sql {res {}}} {
+ ifcapable vtab { uplevel [list do_execsql_test $tn $sql $res] }
+}
+
+# Create and query a WITHOUT ROWID table.
+#
+do_execsql_test without_rowid1-1.0 {
+ CREATE TABLE t1(a,b,c,d, PRIMARY KEY(c,a)) WITHOUT ROWID;
+ CREATE INDEX t1bd ON t1(b, d);
+ INSERT INTO t1 VALUES('journal','sherman','ammonia','helena');
+ INSERT INTO t1 VALUES('dynamic','juliet','flipper','command');
+ INSERT INTO t1 VALUES('journal','sherman','gamma','patriot');
+ INSERT INTO t1 VALUES('arctic','sleep','ammonia','helena');
+ SELECT *, '|' FROM t1 ORDER BY c, a;
+} {arctic sleep ammonia helena | journal sherman ammonia helena | dynamic juliet flipper command | journal sherman gamma patriot |}
+
+integrity_check without_rowid1-1.0ic
+
+do_execsql_test_if_vtab without_rowid1-1.0ixi {
+ SELECT name, key FROM pragma_index_xinfo('t1');
+} {c 1 a 1 b 0 d 0}
+do_execsql_test_if_vtab without_rowid1-1.0tl {
+ SELECT wr FROM pragma_table_list('t1');
+} {1}
+
+do_execsql_test without_rowid1-1.1 {
+ SELECT *, '|' FROM t1 ORDER BY +c, a;
+} {arctic sleep ammonia helena | journal sherman ammonia helena | dynamic juliet flipper command | journal sherman gamma patriot |}
+
+do_execsql_test without_rowid1-1.2 {
+ SELECT *, '|' FROM t1 ORDER BY c DESC, a DESC;
+} {journal sherman gamma patriot | dynamic juliet flipper command | journal sherman ammonia helena | arctic sleep ammonia helena |}
+
+do_execsql_test without_rowid1-1.11 {
+ SELECT *, '|' FROM t1 ORDER BY b, d;
+} {dynamic juliet flipper command | journal sherman ammonia helena | journal sherman gamma patriot | arctic sleep ammonia helena |}
+
+do_execsql_test without_rowid1-1.12 {
+ SELECT *, '|' FROM t1 ORDER BY +b, d;
+} {dynamic juliet flipper command | journal sherman ammonia helena | journal sherman gamma patriot | arctic sleep ammonia helena |}
+
+# Trying to insert a duplicate PRIMARY KEY fails.
+#
+do_test without_rowid1-1.21 {
+ catchsql {
+ INSERT INTO t1 VALUES('dynamic','phone','flipper','harvard');
+ }
+} {1 {UNIQUE constraint failed: t1.c, t1.a}}
+
+# REPLACE INTO works, however.
+#
+do_execsql_test without_rowid1-1.22 {
+ REPLACE INTO t1 VALUES('dynamic','phone','flipper','harvard');
+ SELECT *, '|' FROM t1 ORDER BY c, a;
+} {arctic sleep ammonia helena | journal sherman ammonia helena | dynamic phone flipper harvard | journal sherman gamma patriot |}
+
+do_execsql_test without_rowid1-1.23 {
+ SELECT *, '|' FROM t1 ORDER BY b, d;
+} {dynamic phone flipper harvard | journal sherman ammonia helena | journal sherman gamma patriot | arctic sleep ammonia helena |}
+
+# UPDATE statements.
+#
+do_execsql_test without_rowid1-1.31 {
+ UPDATE t1 SET d=3.1415926 WHERE a='journal';
+ SELECT *, '|' FROM t1 ORDER BY c, a;
+} {arctic sleep ammonia helena | journal sherman ammonia 3.1415926 | dynamic phone flipper harvard | journal sherman gamma 3.1415926 |}
+do_execsql_test without_rowid1-1.32 {
+ SELECT *, '|' FROM t1 ORDER BY b, d;
+} {dynamic phone flipper harvard | journal sherman ammonia 3.1415926 | journal sherman gamma 3.1415926 | arctic sleep ammonia helena |}
+
+do_execsql_test without_rowid1-1.35 {
+ UPDATE t1 SET a=1250 WHERE b='phone';
+ SELECT *, '|' FROM t1 ORDER BY c, a;
+} {arctic sleep ammonia helena | journal sherman ammonia 3.1415926 | 1250 phone flipper harvard | journal sherman gamma 3.1415926 |}
+integrity_check without_rowid1-1.36
+
+do_execsql_test without_rowid1-1.37 {
+ SELECT *, '|' FROM t1 ORDER BY b, d;
+} {1250 phone flipper harvard | journal sherman ammonia 3.1415926 | journal sherman gamma 3.1415926 | arctic sleep ammonia helena |}
+
+do_execsql_test without_rowid1-1.40 {
+ VACUUM;
+ SELECT *, '|' FROM t1 ORDER BY b, d;
+} {1250 phone flipper harvard | journal sherman ammonia 3.1415926 | journal sherman gamma 3.1415926 | arctic sleep ammonia helena |}
+integrity_check without_rowid1-1.41
+
+# Verify that ANALYZE works
+#
+do_execsql_test without_rowid1-1.50 {
+ ANALYZE;
+ SELECT * FROM sqlite_stat1 ORDER BY idx;
+} {t1 t1 {4 2 1} t1 t1bd {4 2 2}}
+ifcapable stat4 {
+ do_execsql_test without_rowid1-1.52 {
+ SELECT DISTINCT tbl, idx FROM sqlite_stat4 ORDER BY idx;
+ } {t1 t1 t1 t1bd}
+}
+
+#----------
+
+do_execsql_test 2.1.1 {
+ CREATE TABLE t4 (a COLLATE nocase PRIMARY KEY, b) WITHOUT ROWID;
+ INSERT INTO t4 VALUES('abc', 'def');
+ SELECT * FROM t4;
+} {abc def}
+do_execsql_test 2.1.2 {
+ UPDATE t4 SET a = 'ABC';
+ SELECT * FROM t4;
+} {ABC def}
+do_execsql_test_if_vtab 2.1.3 {
+ SELECT name, coll, key FROM pragma_index_xinfo('t4');
+} {a nocase 1 b BINARY 0}
+
+do_execsql_test 2.2.1 {
+ DROP TABLE t4;
+ CREATE TABLE t4 (b, a COLLATE nocase PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t4(a, b) VALUES('abc', 'def');
+ SELECT * FROM t4;
+} {def abc}
+
+do_execsql_test 2.2.2 {
+ UPDATE t4 SET a = 'ABC', b = 'xyz';
+ SELECT * FROM t4;
+} {xyz ABC}
+
+do_execsql_test_if_vtab 2.2.3 {
+ SELECT name, coll, key FROM pragma_index_xinfo('t4');
+} {a nocase 1 b BINARY 0}
+
+
+do_execsql_test 2.3.1 {
+ CREATE TABLE t5 (a, b, PRIMARY KEY(b, a)) WITHOUT ROWID;
+ INSERT INTO t5(a, b) VALUES('abc', 'def');
+ UPDATE t5 SET a='abc', b='def';
+} {}
+
+do_execsql_test_if_vtab 2.3.2 {
+ SELECT name, coll, key FROM pragma_index_xinfo('t5');
+} {b BINARY 1 a BINARY 1}
+
+
+do_execsql_test 2.4.1 {
+ CREATE TABLE t6 (
+ a COLLATE nocase, b, c UNIQUE, PRIMARY KEY(b, a)
+ ) WITHOUT ROWID;
+
+ INSERT INTO t6(a, b, c) VALUES('abc', 'def', 'ghi');
+ UPDATE t6 SET a='ABC', c='ghi';
+} {}
+
+do_execsql_test 2.4.2 {
+ SELECT * FROM t6 ORDER BY b, a;
+ SELECT * FROM t6 ORDER BY c;
+} {ABC def ghi ABC def ghi}
+
+do_execsql_test_if_vtab 2.4.3 {
+ SELECT name, coll, key FROM pragma_index_xinfo('t6');
+} {b BINARY 1 a nocase 1 c BINARY 0}
+
+
+#-------------------------------------------------------------------------
+# Unless the destination table is completely empty, the xfer optimization
+# is disabled for WITHOUT ROWID tables. The following tests check for
+# some problems that might occur if this were not the case.
+#
+reset_db
+do_execsql_test 3.1.1 {
+ CREATE TABLE t1(a, b, PRIMARY KEY(a)) WITHOUT ROWID;
+ CREATE UNIQUE INDEX i1 ON t1(b);
+
+ CREATE TABLE t2(a, b, PRIMARY KEY(a)) WITHOUT ROWID;
+ CREATE UNIQUE INDEX i2 ON t2(b);
+
+ INSERT INTO t1 VALUES('one', 'two');
+ INSERT INTO t2 VALUES('three', 'two');
+}
+
+do_execsql_test 3.1.2 {
+ INSERT OR REPLACE INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+} {three two}
+
+do_execsql_test 3.1.3 {
+ DELETE FROM t1;
+ INSERT INTO t1 SELECT * FROM t2;
+ SELECT * FROM t1;
+} {three two}
+
+do_catchsql_test 3.1.4 {
+ INSERT INTO t2 VALUES('four', 'four');
+ INSERT INTO t2 VALUES('six', 'two');
+ INSERT INTO t1 SELECT * FROM t2;
+} {1 {UNIQUE constraint failed: t2.b}}
+
+do_execsql_test 3.1.5 {
+ CREATE TABLE t3(a PRIMARY KEY);
+ CREATE TABLE t4(a PRIMARY KEY);
+
+ INSERT INTO t4 VALUES('i');
+ INSERT INTO t4 VALUES('ii');
+ INSERT INTO t4 VALUES('iii');
+
+ INSERT INTO t3 SELECT * FROM t4;
+ SELECT * FROM t3;
+} {i ii iii}
+
+############################################################################
+# Ticket [c34d0557f740c450709d6e33df72d4f3f651a3cc]
+# Name resolution issue with WITHOUT ROWID
+#
+do_execsql_test 4.1 {
+ CREATE TABLE t41(a PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t41 VALUES('abc');
+ CREATE TABLE t42(x);
+ INSERT INTO t42 VALUES('xyz');
+ SELECT t42.rowid FROM t41, t42;
+} {1}
+do_execsql_test 4.2 {
+ SELECT t42.rowid FROM t42, t41;
+} {1}
+
+
+#--------------------------------------------------------------------------
+# The following tests verify that the trailing PK fields added to each
+# entry in an index on a WITHOUT ROWID table are used correctly.
+#
+do_execsql_test 5.0 {
+ CREATE TABLE t45(a PRIMARY KEY, b, c) WITHOUT ROWID;
+ CREATE INDEX i45 ON t45(b);
+
+ INSERT INTO t45 VALUES(2, 'one', 'x');
+ INSERT INTO t45 VALUES(4, 'one', 'x');
+ INSERT INTO t45 VALUES(6, 'one', 'x');
+ INSERT INTO t45 VALUES(8, 'one', 'x');
+ INSERT INTO t45 VALUES(10, 'one', 'x');
+
+ INSERT INTO t45 VALUES(1, 'two', 'x');
+ INSERT INTO t45 VALUES(3, 'two', 'x');
+ INSERT INTO t45 VALUES(5, 'two', 'x');
+ INSERT INTO t45 VALUES(7, 'two', 'x');
+ INSERT INTO t45 VALUES(9, 'two', 'x');
+}
+
+do_eqp_test 5.1 {
+ SELECT * FROM t45 WHERE b=? AND a>?
+} {USING INDEX i45 (b=? AND a>?)}
+
+do_execsql_test 5.2 {
+ SELECT * FROM t45 WHERE b='two' AND a>4
+} {5 two x 7 two x 9 two x}
+
+do_execsql_test 5.3 {
+ SELECT * FROM t45 WHERE b='one' AND a<8
+} { 2 one x 4 one x 6 one x }
+
+do_execsql_test 5.4 {
+ CREATE TABLE t46(a, b, c, d, PRIMARY KEY(a, b)) WITHOUT ROWID;
+ WITH r(x) AS (
+ SELECT 1 UNION ALL SELECT x+1 FROM r WHERE x<100
+ )
+ INSERT INTO t46 SELECT x / 20, x % 20, x % 10, x FROM r;
+}
+
+set queries {
+ 1 2 "c = 5 AND a = 1" {i46 (c=? AND a=?)}
+ 2 6 "c = 4 AND a < 3" {i46 (c=? AND a<?)}
+ 3 4 "c = 2 AND a >= 3" {i46 (c=? AND a>?)}
+ 4 1 "c = 2 AND a = 1 AND b<10" {i46 (c=? AND a=? AND b<?)}
+ 5 1 "c = 0 AND a = 0 AND b>5" {i46 (c=? AND a=? AND b>?)}
+}
+
+foreach {tn cnt where eqp} $queries {
+ do_execsql_test 5.5.$tn.1 "SELECT count(*) FROM t46 WHERE $where" $cnt
+}
+
+do_execsql_test 5.6 {
+ CREATE INDEX i46 ON t46(c);
+}
+
+foreach {tn cnt where eqp} $queries {
+ do_execsql_test 5.7.$tn.1 "SELECT count(*) FROM t46 WHERE $where" $cnt
+ do_eqp_test 5.7.$tn.2 "SELECT count(*) FROM t46 WHERE $where" $eqp
+}
+
+#-------------------------------------------------------------------------
+# Check that redundant UNIQUE constraints do not cause a problem.
+#
+do_execsql_test 6.0 {
+ CREATE TABLE t47(a, b UNIQUE PRIMARY KEY) WITHOUT ROWID;
+ CREATE INDEX i47 ON t47(a);
+ INSERT INTO t47 VALUES(1, 2);
+ INSERT INTO t47 VALUES(2, 4);
+ INSERT INTO t47 VALUES(3, 6);
+ INSERT INTO t47 VALUES(4, 8);
+
+ VACUUM;
+ PRAGMA integrity_check;
+ SELECT name FROM sqlite_master WHERE tbl_name = 't47';
+} {ok t47 i47}
+
+do_execsql_test 6.1 {
+ CREATE TABLE t48(
+ a UNIQUE UNIQUE,
+ b UNIQUE,
+ PRIMARY KEY(a),
+ UNIQUE(a)
+ ) WITHOUT ROWID;
+ INSERT INTO t48 VALUES('a', 'b'), ('c', 'd'), ('e', 'f');
+ VACUUM;
+ PRAGMA integrity_check;
+ SELECT name FROM sqlite_master WHERE tbl_name = 't48';
+} {
+ ok t48 sqlite_autoindex_t48_2
+}
+
+# 2015-05-28: CHECK constraints can refer to the rowid in a
+# rowid table, but not in a WITHOUT ROWID table.
+#
+do_execsql_test 7.1 {
+ CREATE TABLE t70a(
+ a INT CHECK( rowid!=33 ),
+ b TEXT PRIMARY KEY
+ );
+ INSERT INTO t70a(a,b) VALUES(99,'hello');
+} {}
+do_catchsql_test 7.2 {
+ INSERT INTO t70a(rowid,a,b) VALUES(33,99,'xyzzy');
+} {1 {CHECK constraint failed: rowid!=33}}
+do_catchsql_test 7.3 {
+ CREATE TABLE t70b(
+ a INT CHECK( rowid!=33 ),
+ b TEXT PRIMARY KEY
+ ) WITHOUT ROWID;
+} {1 {no such column: rowid}}
+
+# 2017-07-30: OSSFuzz discovered that an extra entry was being
+# added in the sqlite_master table for an "INTEGER PRIMARY KEY UNIQUE"
+# WITHOUT ROWID table. Make sure this has now been fixed.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test 8.1 {
+ CREATE TABLE t1(x INTEGER PRIMARY KEY UNIQUE, b) WITHOUT ROWID;
+ CREATE INDEX t1x ON t1(x);
+ INSERT INTO t1(x,b) VALUES('funny','buffalo');
+ SELECT type, name, '|' FROM sqlite_master;
+} {table t1 | index t1x |}
+
+# 2018-04-05: OSSFuzz found that the following was accessing an
+# unintialized memory cell. Which was not actually causing a
+# malfunction, but does cause an assert() to fail.
+#
+do_execsql_test 9.0 {
+ CREATE TABLE t2(b, c, PRIMARY KEY(b,c)) WITHOUT ROWID;
+ CREATE UNIQUE INDEX t2b ON t2(b);
+ UPDATE t2 SET b=1 WHERE b='';
+}
+
+do_execsql_test 10.1 {
+ DELETE FROM t2 WHERE b=1
+}
+
+#-------------------------------------------------------------------------
+# UNIQUE constraint violation in an UPDATE with a multi-column PK.
+#
+reset_db
+do_execsql_test 10.0 {
+ CREATE TABLE t1(a, b, c UNIQUE, PRIMARY KEY(a, b)) WITHOUT ROWID;
+ INSERT INTO t1 VALUES('a', 'a', 1);
+ INSERT INTO t1 VALUES('a', 'b', 2);
+ INSERT INTO t1 VALUES('b', 'a', 3);
+ INSERT INTO t1 VALUES('b', 'b', 4);
+}
+
+do_catchsql_test 10.1 {
+ UPDATE t1 SET c=1 WHERE (a, b) = ('a', 'a');
+} {0 {}}
+do_catchsql_test 10.2 {
+ UPDATE t1 SET c=1 WHERE (a, b) = ('a', 'b');
+} {1 {UNIQUE constraint failed: t1.c}}
+do_catchsql_test 10.3 {
+ UPDATE t1 SET c=1 WHERE (a, b) = ('b', 'a');
+} {1 {UNIQUE constraint failed: t1.c}}
+do_catchsql_test 10.4 {
+ UPDATE t1 SET c=1 WHERE (a, b) = ('b', 'b');
+} {1 {UNIQUE constraint failed: t1.c}}
+do_catchsql_test 10.5 {
+ UPDATE t1 SET c=1 WHERE (a, b) = ('c', 'c');
+} {0 {}}
+
+do_execsql_test 10.6 {
+ CREATE TRIGGER t1_tr BEFORE UPDATE ON t1 BEGIN
+ DELETE FROM t1 WHERE a = new.a;
+ END;
+ UPDATE t1 SET c = c+1 WHERE a = 'a';
+ SELECT * FROM t1;
+} {b a 3 b b 4}
+
+# 2019-04-29 ticket https://www.sqlite.org/src/info/3182d3879020ef3
+do_execsql_test 11.1 {
+ CREATE TABLE t11(a TEXT PRIMARY KEY, b INT) WITHOUT ROWID;
+ CREATE INDEX t11a ON t11(a COLLATE NOCASE);
+ INSERT INTO t11(a,b) VALUES ('A',1),('a',2);
+ PRAGMA integrity_check;
+ SELECT a FROM t11 ORDER BY a COLLATE binary;
+} {ok A a}
+
+# 2019-05-13 ticket https://www.sqlite.org/src/info/bba7b69f9849b5b
+do_execsql_test 12.1 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0 (c0 INTEGER PRIMARY KEY DESC, c1 UNIQUE DEFAULT NULL) WITHOUT ROWID;
+ INSERT INTO t0(c0) VALUES (1), (2), (3), (4), (5);
+ REINDEX;
+ PRAGMA integrity_check;
+} {ok}
+
+# 2019-11-07 ticket https://www.sqlite.org/src/info/302027baf1374498
+# The xferCompatibleIndex() function confuses a PRIMARY KEY index
+# with a UNIQUE index.
+#
+do_execsql_test 13.10 {
+ DROP TABLE IF EXISTS t0;
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t0(
+ c0,
+ c1 UNIQUE,
+ PRIMARY KEY(c1, c1)
+ ) WITHOUT ROWID;
+ INSERT INTO t0(c0,c1) VALUES('abc','xyz');
+ CREATE TABLE t1(
+ c0,
+ c1 UNIQUE,
+ PRIMARY KEY(c1, c1)
+ ) WITHOUT ROWID;
+ INSERT INTO t1 SELECT * FROM t0;
+ PRAGMA integrity_check;
+ SELECT * FROM t0, t1;
+} {ok abc xyz abc xyz}
+
+# 2021-05-13 https://sqlite.org/forum/forumpost/6c8960f545
+reset_db
+ifcapable altertable {
+ do_execsql_test 14.1 {
+ CREATE TABLE t1(a INT PRIMARY KEY) WITHOUT ROWID;
+ INSERT INTO t1(a) VALUES(10);
+ ALTER TABLE t1 ADD COLUMN b INT;
+ SELECT * FROM t1 WHERE a=20 OR (a=10 AND b=10);
+ } {}
+ do_execsql_test 14.2 {
+ CREATE TABLE dual AS SELECT 'X' AS dummy;
+ EXPLAIN QUERY PLAN SELECT * FROM dual, t1 WHERE a=10 AND b=10;
+ } {~/b=/}
+}
+
+# 2022-01-01 https://sqlite.org/forum/forumpost/b03d86f951 PoC #1
+# Omit an assert() from 2013 that no longer serves any purpose and
+# is no longer always true.
+#
+ifcapable altertable {
+ reset_db
+ do_execsql_test 15.1 {
+ PRAGMA writable_schema=ON;
+ CREATE TABLE sqlite_sequence (name PRIMARY KEY) WITHOUT ROWID;
+ PRAGMA writable_schema=OFF;
+ CREATE TABLE c1(x);
+ INSERT INTO sqlite_sequence(name) VALUES('c0'),('c1'),('c2');
+ ALTER TABLE c1 RENAME TO a;
+ SELECT name FROM sqlite_sequence ORDER BY +name;
+ } {a c0 c2}
+}
+finish_test
diff --git a/test/without_rowid2.test b/test/without_rowid2.test
new file mode 100644
index 0000000..5ba1a23
--- /dev/null
+++ b/test/without_rowid2.test
@@ -0,0 +1,125 @@
+# 2013-11-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 WITHOUT ROWID tables, and especially
+# FOREIGN KEY constraints.
+#
+
+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 without_rowid2-1.0 {
+ execsql {
+ CREATE TABLE t1(
+ a INT PRIMARY KEY,
+ b INT
+ REFERENCES t1 ON DELETE CASCADE
+ REFERENCES t2,
+ c TEXT,
+ FOREIGN KEY (b,c) REFERENCES t2(x,y) ON UPDATE CASCADE
+ ) WITHOUT rowid;
+ }
+} {}
+do_test without_rowid2-1.1 {
+ execsql {
+ CREATE TABLE t2(
+ x INT PRIMARY KEY,
+ y TEXT
+ ) WITHOUT rowid;
+ }
+} {}
+do_test without_rowid2-1.2 {
+ execsql {
+ CREATE TABLE t3(
+ a INT REFERENCES t2,
+ b INT REFERENCES t1,
+ FOREIGN KEY (a,b) REFERENCES t2(x,y)
+ );
+ }
+} {}
+
+do_test without_rowid2-2.1 {
+ execsql {
+ CREATE TABLE t4(a int primary key) WITHOUT rowid;
+ 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 without_rowid2-3.1 {
+ execsql {
+ CREATE TABLE t5(a PRIMARY KEY, b, c) WITHOUT rowid;
+ 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 without_rowid2-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 without_rowid2-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 without_rowid2-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} \
+]
+do_test without_rowid2-3.5 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 0 0}
+
+finish_test
diff --git a/test/without_rowid3.test b/test/without_rowid3.test
new file mode 100644
index 0000000..f768745
--- /dev/null
+++ b/test/without_rowid3.test
@@ -0,0 +1,2111 @@
+# 2013-11-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.
+#
+# This file implements tests for foreign keys on WITHOUT ROWID
+# tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!foreignkey||!trigger} {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Test structure:
+#
+# without_rowid3-1.*: Simple tests to check that immediate and deferred foreign key
+# constraints work when not inside a transaction.
+#
+# without_rowid3-2.*: Tests to verify that deferred foreign keys work inside
+# explicit transactions (i.e that processing really is deferred).
+#
+# without_rowid3-3.*: Tests that a statement transaction is rolled back if an
+# immediate foreign key constraint is violated.
+#
+# without_rowid3-4.*: Test that FK actions may recurse even when recursive triggers
+# are disabled.
+#
+# without_rowid3-5.*: Check that if foreign-keys are enabled, it is not possible
+# to write to an FK column using the incremental blob API.
+#
+# without_rowid3-6.*: Test that FK processing is automatically disabled when
+# running VACUUM.
+#
+# without_rowid3-7.*: Test using an IPK as the key in the child (referencing) table.
+#
+# without_rowid3-8.*: Test that enabling/disabling foreign key support while a
+# transaction is active is not possible.
+#
+# without_rowid3-9.*: Test SET DEFAULT actions.
+#
+# without_rowid3-10.*: Test errors.
+#
+# without_rowid3-11.*: Test CASCADE actions.
+#
+# without_rowid3-12.*: Test RESTRICT actions.
+#
+# without_rowid3-13.*: Test that FK processing is performed when a row is REPLACED by
+# an UPDATE or INSERT statement.
+#
+# without_rowid3-14.*: Test the ALTER TABLE and DROP TABLE commands.
+#
+# without_rowid3-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.
+#
+# without_rowid3-16.*: Test that rows that refer to themselves may be inserted,
+# updated and deleted.
+#
+# without_rowid3-17.*: Test that the "count_changes" pragma does not interfere with
+# FK constraint processing.
+#
+# without_rowid3-18.*: Test that the authorization callback is invoked when processing
+# FK constraints.
+#
+# without_rowid3-20.*: Test that ON CONFLICT clauses specified as part of statements
+# do not affect the operation of FK constraints.
+#
+# without_rowid3-genfkey.*: Tests that were used with the shell tool .genfkey
+# command. Recycled to test the built-in implementation.
+#
+# without_rowid3-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) WITHOUT rowid;
+ CREATE TABLE t2(c REFERENCES t1(a) /D/ , d);
+
+ CREATE TABLE t3(a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE TABLE t4(c REFERENCES t3 /D/, d);
+
+ CREATE TABLE t7(a, b INT PRIMARY KEY) WITHOUT rowid;
+ 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.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 - "t10" referencing "t9"}}
+}
+
+do_test without_rowid3-1.1.0 {
+ execsql [string map {/D/ {}} $FkeySimpleSchema]
+} {}
+foreach {tn zSql res} $FkeySimpleTests {
+ do_test without_rowid3-1.1.$tn.1 { catchsql $zSql } $res
+ do_test without_rowid3-1.1.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}
+ do_test without_rowid3-1.1.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}
+ do_test without_rowid3-1.1.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}
+ do_test without_rowid3-1.1.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}
+ do_test without_rowid3-1.1.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}
+ do_test without_rowid3-1.1.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}
+}
+drop_all_tables
+
+do_test without_rowid3-1.2.0 {
+ execsql [string map {/D/ {DEFERRABLE INITIALLY DEFERRED}} $FkeySimpleSchema]
+} {}
+foreach {tn zSql res} $FkeySimpleTests {
+ do_test without_rowid3-1.2.$tn { catchsql $zSql } $res
+ do_test without_rowid3-1.2.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}
+ do_test without_rowid3-1.2.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}
+ do_test without_rowid3-1.2.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}
+ do_test without_rowid3-1.2.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}
+ do_test without_rowid3-1.2.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}
+ do_test without_rowid3-1.2.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}
+}
+drop_all_tables
+
+do_test without_rowid3-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 without_rowid3-1.3.$tn { catchsql $zSql } $res
+ do_test without_rowid3-1.3.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}
+ do_test without_rowid3-1.3.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}
+ do_test without_rowid3-1.3.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}
+ do_test without_rowid3-1.3.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}
+ do_test without_rowid3-1.3.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}
+ do_test without_rowid3-1.3.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}
+}
+execsql { PRAGMA count_changes = 0 }
+drop_all_tables
+
+do_test without_rowid3-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 without_rowid3-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 without_rowid3-1.5.1 {
+ execsql {
+ CREATE TABLE i(i INT PRIMARY KEY) WITHOUT rowid;
+ 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 without_rowid3-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 without_rowid3-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 without_rowid3-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 without_rowid3-1.7.1 {
+ execsql {
+ CREATE TABLE i(i TEXT COLLATE nocase PRIMARY KEY) WITHOUT rowid;
+ 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 without_rowid3-1.7.2 {
+ execsql {
+ CREATE TABLE i(i TEXT PRIMARY KEY) WITHOUT rowid; -- 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 without_rowid3-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 without_rowid3-2.*) contains tests to check that the
+# deferred foreign key constraint logic works.
+#
+proc without_rowid3-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 without_rowid3-2.$tn [list catchsql $sql] $expected
+ if {$nocommit} {
+ do_test without_rowid3-2.${tn}c {
+ catchsql COMMIT
+ } {1 {FOREIGN KEY constraint failed}}
+ }
+}
+
+without_rowid3-2-test 1 0 {
+ CREATE TABLE node(
+ nodeid PRIMARY KEY,
+ parent REFERENCES node DEFERRABLE INITIALLY DEFERRED
+ ) WITHOUT rowid;
+ CREATE TABLE leaf(
+ cellid PRIMARY KEY,
+ parent REFERENCES node DEFERRABLE INITIALLY DEFERRED
+ ) WITHOUT rowid;
+}
+
+without_rowid3-2-test 1 0 "INSERT INTO node VALUES(1, 0)" FKV
+without_rowid3-2-test 2 0 "BEGIN"
+without_rowid3-2-test 3 1 "INSERT INTO node VALUES(1, 0)"
+without_rowid3-2-test 4 0 "UPDATE node SET parent = NULL"
+without_rowid3-2-test 5 0 "COMMIT"
+without_rowid3-2-test 6 0 "SELECT * FROM node" {1 {}}
+
+without_rowid3-2-test 7 0 "BEGIN"
+without_rowid3-2-test 8 1 "INSERT INTO leaf VALUES('a', 2)"
+without_rowid3-2-test 9 1 "INSERT INTO node VALUES(2, 0)"
+without_rowid3-2-test 10 0 "UPDATE node SET parent = 1 WHERE nodeid = 2"
+without_rowid3-2-test 11 0 "COMMIT"
+without_rowid3-2-test 12 0 "SELECT * FROM node" {1 {} 2 1}
+without_rowid3-2-test 13 0 "SELECT * FROM leaf" {a 2}
+
+without_rowid3-2-test 14 0 "BEGIN"
+without_rowid3-2-test 15 1 "DELETE FROM node WHERE nodeid = 2"
+without_rowid3-2-test 16 0 "INSERT INTO node VALUES(2, NULL)"
+without_rowid3-2-test 17 0 "COMMIT"
+without_rowid3-2-test 18 0 "SELECT * FROM node" {1 {} 2 {}}
+without_rowid3-2-test 19 0 "SELECT * FROM leaf" {a 2}
+
+without_rowid3-2-test 20 0 "BEGIN"
+without_rowid3-2-test 21 0 "INSERT INTO leaf VALUES('b', 1)"
+without_rowid3-2-test 22 0 "SAVEPOINT save"
+without_rowid3-2-test 23 0 "DELETE FROM node WHERE nodeid = 1"
+without_rowid3-2-test 24 0 "ROLLBACK TO save"
+without_rowid3-2-test 25 0 "COMMIT"
+without_rowid3-2-test 26 0 "SELECT * FROM node" {1 {} 2 {}}
+without_rowid3-2-test 27 0 "SELECT * FROM leaf" {a 2 b 1}
+
+without_rowid3-2-test 28 0 "BEGIN"
+without_rowid3-2-test 29 0 "INSERT INTO leaf VALUES('c', 1)"
+without_rowid3-2-test 30 0 "SAVEPOINT save"
+without_rowid3-2-test 31 0 "DELETE FROM node WHERE nodeid = 1"
+without_rowid3-2-test 32 1 "RELEASE save"
+without_rowid3-2-test 33 1 "DELETE FROM leaf WHERE cellid = 'b'"
+without_rowid3-2-test 34 0 "DELETE FROM leaf WHERE cellid = 'c'"
+without_rowid3-2-test 35 0 "COMMIT"
+without_rowid3-2-test 36 0 "SELECT * FROM node" {2 {}}
+without_rowid3-2-test 37 0 "SELECT * FROM leaf" {a 2}
+
+without_rowid3-2-test 38 0 "SAVEPOINT outer"
+without_rowid3-2-test 39 1 "INSERT INTO leaf VALUES('d', 3)"
+without_rowid3-2-test 40 1 "RELEASE outer" FKV
+without_rowid3-2-test 41 1 "INSERT INTO leaf VALUES('e', 3)"
+without_rowid3-2-test 42 0 "INSERT INTO node VALUES(3, 2)"
+without_rowid3-2-test 43 0 "RELEASE outer"
+
+without_rowid3-2-test 44 0 "SAVEPOINT outer"
+without_rowid3-2-test 45 1 "DELETE FROM node WHERE nodeid=3"
+without_rowid3-2-test 47 0 "INSERT INTO node VALUES(3, 2)"
+without_rowid3-2-test 48 0 "ROLLBACK TO outer"
+without_rowid3-2-test 49 0 "RELEASE outer"
+
+without_rowid3-2-test 50 0 "SAVEPOINT outer"
+without_rowid3-2-test 51 1 "INSERT INTO leaf VALUES('f', 4)"
+without_rowid3-2-test 52 1 "SAVEPOINT inner"
+without_rowid3-2-test 53 1 "INSERT INTO leaf VALUES('g', 4)"
+without_rowid3-2-test 54 1 "RELEASE outer" FKV
+without_rowid3-2-test 55 1 "ROLLBACK TO inner"
+without_rowid3-2-test 56 0 "COMMIT" FKV
+without_rowid3-2-test 57 0 "INSERT INTO node VALUES(4, NULL)"
+without_rowid3-2-test 58 0 "RELEASE outer"
+without_rowid3-2-test 59 0 "SELECT * FROM node" {2 {} 3 2 4 {}}
+without_rowid3-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.
+#
+without_rowid3-2-test 61 0 "BEGIN"
+without_rowid3-2-test 62 0 "DELETE FROM leaf"
+without_rowid3-2-test 63 0 "DELETE FROM node"
+without_rowid3-2-test 64 1 "INSERT INTO leaf VALUES('a', 1)"
+without_rowid3-2-test 65 1 "INSERT INTO leaf VALUES('b', 2)"
+without_rowid3-2-test 66 1 "INSERT INTO leaf VALUES('c', 1)"
+do_test without_rowid3-2-test-67 {
+ catchsql "INSERT INTO node SELECT parent, 3 FROM leaf"
+} {1 {UNIQUE constraint failed: node.nodeid}}
+without_rowid3-2-test 68 0 "COMMIT" FKV
+without_rowid3-2-test 69 1 "INSERT INTO node VALUES(1, NULL)"
+without_rowid3-2-test 70 0 "INSERT INTO node VALUES(2, NULL)"
+without_rowid3-2-test 71 0 "COMMIT"
+
+without_rowid3-2-test 72 0 "BEGIN"
+without_rowid3-2-test 73 1 "DELETE FROM node"
+without_rowid3-2-test 74 0 "INSERT INTO node(nodeid) SELECT DISTINCT parent FROM leaf"
+without_rowid3-2-test 75 0 "COMMIT"
+
+#-------------------------------------------------------------------------
+# Test cases without_rowid3-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.
+#
+# without_rowid3-3.1.*: Test UPDATE statements.
+# without_rowid3-3.2.*: Test DELETE statements.
+#
+drop_all_tables
+do_test without_rowid3-3.1.1 {
+ execsql {
+ CREATE TABLE ab(a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE TABLE cd(
+ c PRIMARY KEY REFERENCES ab ON UPDATE CASCADE ON DELETE CASCADE,
+ d
+ ) WITHOUT rowid;
+ CREATE TABLE ef(
+ e REFERENCES cd ON UPDATE CASCADE,
+ f, CHECK (e!=5)
+ );
+ }
+} {}
+do_test without_rowid3-3.1.2 {
+ execsql {
+ INSERT INTO ab VALUES(1, 'b');
+ INSERT INTO cd VALUES(1, 'd');
+ INSERT INTO ef VALUES(1, 'e');
+ }
+} {}
+do_test without_rowid3-3.1.3 {
+ catchsql { UPDATE ab SET a = 5 }
+} {1 {CHECK constraint failed: e!=5}}
+do_test without_rowid3-3.1.4 {
+ execsql { SELECT * FROM ab }
+} {1 b}
+do_test without_rowid3-3.1.4 {
+ execsql BEGIN;
+ catchsql { UPDATE ab SET a = 5 }
+} {1 {CHECK constraint failed: e!=5}}
+do_test without_rowid3-3.1.5 {
+ execsql COMMIT;
+ execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
+} {1 b 1 d 1 e}
+
+do_test without_rowid3-3.2.1 {
+ execsql BEGIN;
+ catchsql { DELETE FROM ab }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-3.2.2 {
+ execsql COMMIT
+ execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
+} {1 b 1 d 1 e}
+
+#-------------------------------------------------------------------------
+# Test cases without_rowid3-4.* test that recursive foreign key actions
+# (i.e. CASCADE) are allowed even if recursive triggers are disabled.
+#
+drop_all_tables
+do_test without_rowid3-4.1 {
+ execsql {
+ CREATE TABLE t1(
+ node PRIMARY KEY,
+ parent REFERENCES t1 ON DELETE CASCADE
+ ) WITHOUT rowid;
+ CREATE TABLE t2(node PRIMARY KEY, parent) WITHOUT rowid;
+ 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 without_rowid3-4.2 {
+ execsql { PRAGMA recursive_triggers = off }
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE node = 1;
+ SELECT node FROM t1;
+ }
+} {}
+do_test without_rowid3-4.3 {
+ execsql {
+ DELETE FROM t2 WHERE node = 1;
+ SELECT node FROM t2;
+ ROLLBACK;
+ }
+} {4 5 6 7}
+do_test without_rowid3-4.4 {
+ execsql { PRAGMA recursive_triggers = on }
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE node = 1;
+ SELECT node FROM t1;
+ }
+} {}
+do_test without_rowid3-4.3 {
+ execsql {
+ DELETE FROM t2 WHERE node = 1;
+ SELECT node FROM t2;
+ ROLLBACK;
+ }
+} {}
+
+#-------------------------------------------------------------------------
+# Test cases without_rowid3-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 without_rowid3-5.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1(a)) WITHOUT rowid;
+ INSERT INTO t1 VALUES('hello', 'world');
+ INSERT INTO t2 VALUES('key', 'hello');
+ }
+ } {}
+ do_test without_rowid3-5.2 {
+ set rc [catch { set fd [db incrblob t2 b 1] } msg]
+ list $rc $msg
+ } {1 {cannot open table without rowid: t2}}
+ do_test without_rowid3-5.5 {
+ execsql { PRAGMA foreign_keys = on }
+ } {}
+}
+
+drop_all_tables
+ifcapable vacuum {
+ do_test without_rowid3-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 INT PRIMARY KEY as the child key
+# of a foreign constraint.
+#
+drop_all_tables
+do_test without_rowid3-7.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE TABLE t2(c INT PRIMARY KEY REFERENCES t1, b) WITHOUT rowid;
+ }
+} {}
+do_test without_rowid3-7.2 {
+ catchsql { INSERT INTO t2 VALUES(1, 'A'); }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-7.3 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(2, 3);
+ INSERT INTO t2 VALUES(1, 'A');
+ }
+} {}
+do_test without_rowid3-7.4 {
+ execsql { UPDATE t2 SET c = 2 }
+} {}
+do_test without_rowid3-7.5 {
+ catchsql { UPDATE t2 SET c = 3 }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-7.6 {
+ catchsql { DELETE FROM t1 WHERE a = 2 }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-7.7 {
+ execsql { DELETE FROM t1 WHERE a = 1 }
+} {}
+do_test without_rowid3-7.8 {
+ catchsql { UPDATE t1 SET a = 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 without_rowid3-8-test {tn zSql value} {
+ do_test without_rowid3-2.8.$tn.1 [list execsql $zSql] {}
+ do_test without_rowid3-2.8.$tn.2 { execsql "PRAGMA foreign_keys" } $value
+}
+without_rowid3-8-test 1 { PRAGMA foreign_keys = 0 } 0
+without_rowid3-8-test 2 { PRAGMA foreign_keys = 1 } 1
+without_rowid3-8-test 3 { BEGIN } 1
+without_rowid3-8-test 4 { PRAGMA foreign_keys = 0 } 1
+without_rowid3-8-test 5 { COMMIT } 1
+without_rowid3-8-test 6 { PRAGMA foreign_keys = 0 } 0
+without_rowid3-8-test 7 { BEGIN } 0
+without_rowid3-8-test 8 { PRAGMA foreign_keys = 1 } 0
+without_rowid3-8-test 9 { COMMIT } 0
+without_rowid3-8-test 10 { PRAGMA foreign_keys = 1 } 1
+without_rowid3-8-test 11 { PRAGMA foreign_keys = off } 0
+without_rowid3-8-test 12 { PRAGMA foreign_keys = on } 1
+without_rowid3-8-test 13 { PRAGMA foreign_keys = no } 0
+without_rowid3-8-test 14 { PRAGMA foreign_keys = yes } 1
+without_rowid3-8-test 15 { PRAGMA foreign_keys = false } 0
+without_rowid3-8-test 16 { PRAGMA foreign_keys = true } 1
+
+#-------------------------------------------------------------------------
+# The following tests, without_rowid3-9.*, test SET DEFAULT actions.
+#
+drop_all_tables
+do_test without_rowid3-9.1.1 {
+ execsql {
+ CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT rowid;
+ CREATE TABLE t2(
+ c INT PRIMARY KEY,
+ d INTEGER DEFAULT 1 REFERENCES t1 ON DELETE SET DEFAULT
+ ) WITHOUT rowid;
+ DELETE FROM t1;
+ }
+} {}
+do_test without_rowid3-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 without_rowid3-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 without_rowid3-9.1.4 {
+ execsql { SELECT * FROM t1 }
+} {2 two}
+do_test without_rowid3-9.1.5 {
+ catchsql { DELETE FROM t1 }
+} {1 {FOREIGN KEY constraint failed}}
+
+do_test without_rowid3-9.2.1 {
+ execsql {
+ CREATE TABLE pp(a, b, c, PRIMARY KEY(b, c)) WITHOUT rowid;
+ 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 without_rowid3-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 without_rowid3-9.2.3 {
+ execsql {
+ DELETE FROM pp WHERE a = 4;
+ SELECT * FROM cc;
+ }
+} {{} A {} {} B {} 3 A 2 3 B 2}
+
+#-------------------------------------------------------------------------
+# The following tests, without_rowid3-10.*, test "foreign key mismatch" and
+# other errors.
+#
+set tn 0
+foreach zSql [list {
+ CREATE TABLE p(a PRIMARY KEY, b) WITHOUT rowid;
+ 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)) WITHOUT rowid;
+ 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 without_rowid3-10.1.[incr tn] {
+ execsql $zSql
+ catchsql { INSERT INTO c DEFAULT VALUES }
+ } {/1 {foreign key mismatch - "c" referencing "."}/}
+}
+
+# "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 without_rowid3-10.2.1 {
+ drop_all_tables
+ catchsql {
+ CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE TABLE t2(c, d, FOREIGN KEY(rowid) REFERENCES t1(a));
+ }
+} {1 {unknown column "rowid" in foreign key definition}}
+do_test without_rowid3-10.2.2 {
+ drop_all_tables
+ catchsql {
+ CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE TABLE t2(rowid, d, FOREIGN KEY(rowid) REFERENCES t1(a));
+ }
+} {0 {}}
+do_test without_rowid3-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 - "t2" referencing "t1"}}
+do_test without_rowid3-10.2.2 {
+ drop_all_tables
+ catchsql {
+ CREATE TABLE t1(rowid PRIMARY KEY, b) WITHOUT rowid;
+ 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, without_rowid3-11.*, test CASCADE actions.
+#
+drop_all_tables
+do_test without_rowid3-11.1.1 {
+ execsql {
+ CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT rowid;
+ 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, without_rowid3-12.*, test RESTRICT actions.
+#
+drop_all_tables
+do_test without_rowid3-12.1.1 {
+ execsql {
+ CREATE TABLE t1(a, b PRIMARY KEY) WITHOUT rowid;
+ 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 without_rowid3-12.1.2 {
+ execsql "BEGIN"
+ execsql "INSERT INTO t2 VALUES('two')"
+} {}
+do_test without_rowid3-12.1.3 {
+ execsql "UPDATE t1 SET b = 'four' WHERE b = 'one'"
+} {}
+do_test without_rowid3-12.1.4 {
+ catchsql "UPDATE t1 SET b = 'five' WHERE b = 'two'"
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-12.1.5 {
+ execsql "DELETE FROM t1 WHERE b = 'two'"
+} {}
+do_test without_rowid3-12.1.6 {
+ catchsql "COMMIT"
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-12.1.7 {
+ execsql {
+ INSERT INTO t1 VALUES(2, 'two');
+ COMMIT;
+ }
+} {}
+
+drop_all_tables
+do_test without_rowid3-12.2.1 {
+ execsql {
+ CREATE TABLE t1(x COLLATE NOCASE PRIMARY KEY) WITHOUT rowid;
+ 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 without_rowid3-12.2.2 {
+ execsql { DELETE FROM t1 }
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+} {A B a b}
+do_test without_rowid3-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 without_rowid3-12.2.4 {
+ execsql {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+ }
+} {A B a b}
+
+drop_all_tables
+do_test without_rowid3-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)
+ ) WITHOUT rowid;
+ 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 without_rowid3-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 without_rowid3-12.3.3 {
+ catchsql { INSERT INTO down(c39, c38) VALUES('yes', 'no') }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-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 without_rowid3-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, without_rowid3-13.*, test that FK processing is performed
+# when rows are REPLACEd.
+#
+drop_all_tables
+do_test without_rowid3-13.1.1 {
+ execsql {
+ CREATE TABLE pp(a UNIQUE, b, c, PRIMARY KEY(b, c)) WITHOUT rowid;
+ 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)"
+} {
+ do_test without_rowid3-13.1.$tn.1 {
+ catchsql $stmt
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-13.1.$tn.2 {
+ execsql {
+ SELECT * FROM pp;
+ SELECT * FROM cc;
+ }
+ } {1 2 3 2 3 1}
+ do_test without_rowid3-13.1.$tn.3 {
+ execsql BEGIN;
+ catchsql $stmt
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-13.1.$tn.4 {
+ execsql {
+ COMMIT;
+ SELECT * FROM pp;
+ SELECT * FROM cc;
+ }
+ } {1 2 3 2 3 1}
+}
+
+#-------------------------------------------------------------------------
+# The following tests, without_rowid3-14.*, test that the "DROP TABLE" and "ALTER
+# TABLE" commands work as expected wrt foreign key constraints.
+#
+# without_rowid3-14.1*: ALTER TABLE ADD COLUMN
+# without_rowid3-14.2*: ALTER TABLE RENAME TABLE
+# without_rowid3-14.3*: DROP TABLE
+#
+drop_all_tables
+ifcapable altertable {
+ do_test without_rowid3-14.1.1 {
+ # Adding a column with a REFERENCES clause is not supported.
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY) WITHOUT rowid;
+ CREATE TABLE t2(a, b);
+ INSERT INTO t2(a,b) VALUES(1,2);
+ }
+ catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }
+ } {0 {}}
+ do_test without_rowid3-14.1.2 {
+ catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }
+ } {0 {}}
+ do_test without_rowid3-14.1.3 {
+ catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}
+ } {0 {}}
+ do_test without_rowid3-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 without_rowid3-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 without_rowid3-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_schema 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_table(
+ 'main', 'table', 't1', $zCreate, $zOld, $zNew, 0
+ )}
+ }
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+ do_test without_rowid3-14.2.1.1 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+ do_test without_rowid3-14.2.1.2 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
+ } {{CREATE TABLE t1(a REFERENCES t2)}}
+ do_test without_rowid3-14.2.1.3 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+
+ # Test ALTER TABLE RENAME TABLE a bit.
+ #
+ do_test without_rowid3-14.2.2.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid;
+ CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)
+ WITHOUT rowid;
+ CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);
+ }
+ execsql { SELECT sql FROM sqlite_schema WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)
+ WITHOUT rowid} \
+ {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \
+ ]
+ do_test without_rowid3-14.2.2.2 {
+ execsql { ALTER TABLE t1 RENAME TO t4 }
+ execsql { SELECT sql FROM sqlite_schema WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4") WITHOUT rowid} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)
+ WITHOUT rowid} \
+ {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
+ ]
+ do_test without_rowid3-14.2.2.3 {
+ catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-14.2.2.4 {
+ execsql { INSERT INTO t4 VALUES(1, NULL) }
+ } {}
+ do_test without_rowid3-14.2.2.5 {
+ catchsql { UPDATE t4 SET b = 5 }
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-14.2.2.6 {
+ catchsql { UPDATE t4 SET b = 1 }
+ } {0 {}}
+ do_test without_rowid3-14.2.2.7 {
+ execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
+ } {}
+
+ # Repeat for TEMP tables
+ #
+ drop_all_tables
+ do_test without_rowid3-14.1tmp.1 {
+ # Adding a column with a REFERENCES clause is not supported.
+ execsql {
+ CREATE TEMP TABLE t1(a PRIMARY KEY) WITHOUT rowid;
+ CREATE TEMP TABLE t2(a, b);
+ INSERT INTO temp.t2(a,b) VALUES(1,2);
+ }
+ catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }
+ } {0 {}}
+ do_test without_rowid3-14.1tmp.2 {
+ catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }
+ } {0 {}}
+ do_test without_rowid3-14.1tmp.3 {
+ catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}
+ } {0 {}}
+ do_test without_rowid3-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 without_rowid3-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 without_rowid3-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 temp.sqlite_schema 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)}}
+
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+ do_test without_rowid3-14.2tmp.1.1 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+ do_test without_rowid3-14.2tmp.1.2 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
+ } {{CREATE TABLE t1(a REFERENCES t2)}}
+ do_test without_rowid3-14.2tmp.1.3 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+
+ # Test ALTER TABLE RENAME TABLE a bit.
+ #
+ do_test without_rowid3-14.2tmp.2.1 {
+ drop_all_tables
+ execsql {
+ CREATE TEMP TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid;
+ CREATE TEMP TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)
+ WITHOUT rowid;
+ CREATE TEMP TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);
+ }
+ execsql { SELECT sql FROM sqlite_temp_schema WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)
+ WITHOUT rowid} \
+ {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \
+ ]
+ do_test without_rowid3-14.2tmp.2.2 {
+ execsql { ALTER TABLE t1 RENAME TO t4 }
+ execsql { SELECT sql FROM temp.sqlite_schema WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4") WITHOUT rowid} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)
+ WITHOUT rowid} \
+ {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
+ ]
+ do_test without_rowid3-14.2tmp.2.3 {
+ catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-14.2tmp.2.4 {
+ execsql { INSERT INTO t4 VALUES(1, NULL) }
+ } {}
+ do_test without_rowid3-14.2tmp.2.5 {
+ catchsql { UPDATE t4 SET b = 5 }
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-14.2tmp.2.6 {
+ catchsql { UPDATE t4 SET b = 1 }
+ } {0 {}}
+ do_test without_rowid3-14.2tmp.2.7 {
+ execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
+ } {}
+
+ # Repeat for ATTACH-ed tables
+ #
+ drop_all_tables
+ do_test without_rowid3-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) WITHOUT rowid;
+ CREATE TABLE aux.t2(a, b);
+ INSERT INTO aux.t2(a,b) VALUES(1,2);
+ }
+ catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }
+ } {0 {}}
+ do_test without_rowid3-14.1aux.2 {
+ catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }
+ } {0 {}}
+ do_test without_rowid3-14.1aux.3 {
+ catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}
+ } {0 {}}
+ do_test without_rowid3-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 without_rowid3-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 without_rowid3-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_schema 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)}}
+
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+ do_test without_rowid3-14.2aux.1.1 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+ do_test without_rowid3-14.2aux.1.2 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
+ } {{CREATE TABLE t1(a REFERENCES t2)}}
+ do_test without_rowid3-14.2aux.1.3 {
+ test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
+ } {{CREATE TABLE t1(a REFERENCES "t3")}}
+ sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
+
+ # Test ALTER TABLE RENAME TABLE a bit.
+ #
+ do_test without_rowid3-14.2aux.2.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE aux.t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid;
+ CREATE TABLE aux.t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)
+ WITHOUT rowid;
+ CREATE TABLE aux.t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);
+ }
+ execsql { SELECT sql FROM aux.sqlite_schema WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)
+ WITHOUT rowid} \
+ {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)} \
+ ]
+ do_test without_rowid3-14.2aux.2.2 {
+ execsql { ALTER TABLE t1 RENAME TO t4 }
+ execsql { SELECT sql FROM aux.sqlite_schema WHERE type = 'table'}
+ } [list \
+ {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4") WITHOUT rowid} \
+ {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)
+ WITHOUT rowid} \
+ {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
+ ]
+ do_test without_rowid3-14.2aux.2.3 {
+ catchsql { INSERT INTO t3 VALUES(1, 2, 3) }
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-14.2aux.2.4 {
+ execsql { INSERT INTO t4 VALUES(1, NULL) }
+ } {}
+ do_test without_rowid3-14.2aux.2.5 {
+ catchsql { UPDATE t4 SET b = 5 }
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-14.2aux.2.6 {
+ catchsql { UPDATE t4 SET b = 1 }
+ } {0 {}}
+ do_test without_rowid3-14.2aux.2.7 {
+ execsql { INSERT INTO t3 VALUES(1, NULL, 1) }
+ } {}
+}
+
+do_test without_rowid3-2.14.3.1 {
+ drop_all_tables
+ execsql {
+ CREATE TABLE t1(a, b REFERENCES nosuchtable);
+ DROP TABLE t1;
+ }
+} {}
+do_test without_rowid3-2.14.3.2 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;
+ INSERT INTO t1 VALUES('a', 1);
+ CREATE TABLE t2(x REFERENCES t1);
+ INSERT INTO t2 VALUES('a');
+ }
+} {}
+do_test without_rowid3-2.14.3.3 {
+ catchsql { DROP TABLE t1 }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-2.14.3.4 {
+ execsql {
+ DELETE FROM t2;
+ DROP TABLE t1;
+ }
+} {}
+do_test without_rowid3-2.14.3.4 {
+ catchsql { INSERT INTO t2 VALUES('x') }
+} {1 {no such table: main.t1}}
+do_test without_rowid3-2.14.3.5 {
+ execsql {
+ CREATE TABLE t1(x PRIMARY KEY) WITHOUT rowid;
+ INSERT INTO t1 VALUES('x');
+ }
+ execsql { INSERT INTO t2 VALUES('x') }
+} {}
+do_test without_rowid3-2.14.3.6 {
+ catchsql { DROP TABLE t1 }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-2.14.3.7 {
+ execsql {
+ DROP TABLE t2;
+ DROP TABLE t1;
+ }
+} {}
+do_test without_rowid3-2.14.3.8 {
+ execsql {
+ CREATE TABLE pp(x, y, PRIMARY KEY(x, y)) WITHOUT ROWID;
+ CREATE TABLE cc(a, b, FOREIGN KEY(a, b) REFERENCES pp(x, z));
+ }
+ catchsql { INSERT INTO cc VALUES(1, 2) }
+} {1 {foreign key mismatch - "cc" referencing "pp"}}
+do_test without_rowid3-2.14.3.9 {
+ execsql { DROP TABLE cc }
+} {}
+do_test without_rowid3-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)) WITHOUT rowid;
+ INSERT INTO pp VALUES(1, 'a', 'b');
+ COMMIT;
+ }
+} {}
+do_test without_rowid3-2.14.3.11 {
+ execsql {
+ BEGIN;
+ DROP TABLE cc;
+ DROP TABLE pp;
+ COMMIT;
+ }
+} {}
+do_test without_rowid3-2.14.3.12 {
+ execsql {
+ CREATE TABLE b1(a, b);
+ CREATE TABLE b2(a, b REFERENCES b1);
+ DROP TABLE b1;
+ }
+} {}
+do_test without_rowid3-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 without_rowid3-2.14.4.1 {
+ execsql {
+ CREATE TABLE t1(x REFERENCES v);
+ CREATE VIEW v AS SELECT * FROM t1;
+ }
+} {}
+do_test without_rowid3-2.14.4.2 {
+ execsql {
+ DROP VIEW v;
+ }
+} {}
+ifcapable vtab {
+ register_echo_module db
+ do_test without_rowid3-2.14.4.3 {
+ execsql { CREATE VIRTUAL TABLE v USING echo(t1) }
+ } {}
+ do_test without_rowid3-2.14.4.2 {
+ execsql {
+ DROP TABLE v;
+ }
+ } {}
+}
+
+#-------------------------------------------------------------------------
+# The following tests, without_rowid3-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 without_rowid3-15.1.1 {
+ execsql {
+ CREATE TABLE pp(a PRIMARY KEY, b) WITHOUT rowid;
+ 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 without_rowid3-15.1.2 {
+ execsqlS { INSERT INTO pp VALUES(3, 'three') }
+} {0}
+do_test without_rowid3-15.1.3 {
+ execsql {
+ BEGIN;
+ INSERT INTO cc VALUES('see', 4); -- Violates deferred constraint
+ }
+ execsqlS { INSERT INTO pp VALUES(5, 'five') }
+} {2}
+do_test without_rowid3-15.1.4 {
+ execsql { DELETE FROM cc WHERE x = 'see' }
+ execsqlS { INSERT INTO pp VALUES(6, 'six') }
+} {0}
+do_test without_rowid3-15.1.5 {
+ execsql COMMIT
+} {}
+do_test without_rowid3-15.1.6 {
+ execsql BEGIN
+ execsqlS {
+ DELETE FROM cc WHERE x = 'neung';
+ ROLLBACK;
+ }
+} {1}
+do_test without_rowid3-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, without_rowid3-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))
+ WITHOUT rowid }
+ 2 { CREATE TABLE self(a PRIMARY KEY, b REFERENCES self(a)) WITHOUT rowid }
+ 3 { CREATE TABLE self(a UNIQUE, b INT PRIMARY KEY REFERENCES self(a))
+ WITHOUT rowid }
+} {
+ drop_all_tables
+ do_test without_rowid3-16.1.$tn.1 {
+ execsql $zSchema
+ execsql { INSERT INTO self VALUES(13, 13) }
+ } {}
+ do_test without_rowid3-16.1.$tn.2 {
+ execsql { UPDATE self SET a = 14, b = 14 }
+ } {}
+
+ do_test without_rowid3-16.1.$tn.3 {
+ catchsql { UPDATE self SET b = 15 }
+ } {1 {FOREIGN KEY constraint failed}}
+
+ do_test without_rowid3-16.1.$tn.4 {
+ catchsql { UPDATE self SET a = 15 }
+ } {1 {FOREIGN KEY constraint failed}}
+
+ do_test without_rowid3-16.1.$tn.5 {
+ catchsql { UPDATE self SET a = 15, b = 16 }
+ } {1 {FOREIGN KEY constraint failed}}
+
+ do_test without_rowid3-16.1.$tn.6 {
+ catchsql { UPDATE self SET a = 17, b = 17 }
+ } {0 {}}
+
+ do_test without_rowid3-16.1.$tn.7 {
+ execsql { DELETE FROM self }
+ } {}
+ do_test without_rowid3-16.1.$tn.8 {
+ catchsql { INSERT INTO self VALUES(20, 21) }
+ } {1 {FOREIGN KEY constraint failed}}
+}
+
+# Additional tests cases using multi-column self-referential
+# FOREIGN KEY constraints.
+#
+drop_all_tables
+do_execsql_test without_rowid3-16.4.1.1 {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE t1(a,b,c,d,e,f,
+ UNIQUE (a,b),
+ PRIMARY KEY (e,c),
+ FOREIGN KEY (d,f) REFERENCES t1(e,c)
+ ) WITHOUT rowid;
+ INSERT INTO t1 VALUES(1,2,3,5,5,3);
+ INSERT INTO t1 VALUES(2,3,4,6,6,4);
+ INSERT INTO t1 VALUES('x','y',1.5,'fizzle','fizzle',1.5);
+ SELECT *, '|' FROM t1 ORDER BY a, b;
+} {1 2 3 5 5 3 | 2 3 4 6 6 4 | x y 1.5 fizzle fizzle 1.5 |}
+
+do_execsql_test without_rowid3-16.4.1.2 {
+ UPDATE t1 SET c=99, f=99 WHERE a=1;
+ SELECT *, '|' FROM t1 ORDER BY a, b;
+} {1 2 99 5 5 99 | 2 3 4 6 6 4 | x y 1.5 fizzle fizzle 1.5 |}
+
+do_execsql_test without_rowid3-16.4.1.3 {
+ UPDATE t1 SET e=876, d=876 WHERE a=2;
+ SELECT *, '|' FROM t1 ORDER BY a, b;
+} {1 2 99 5 5 99 | 2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}
+
+do_test without_rowid3-16.4.1.4 {
+ catchsql {
+ UPDATE t1 SET c=11, e=22 WHERE a=1;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+
+do_test without_rowid3-16.4.1.5 {
+ catchsql {
+ UPDATE t1 SET d=11, f=22 WHERE a=1;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+
+do_execsql_test without_rowid3-16.4.1.6 {
+ DELETE FROM t1 WHERE a=1;
+ SELECT *, '|' FROM t1 ORDER BY a, b;
+} {2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}
+
+do_execsql_test without_rowid3-16.4.2.1 {
+ DROP TABLE t1;
+ CREATE TABLE t1(a,b,c,d,e,f,
+ PRIMARY KEY (a,b),
+ UNIQUE (e,c),
+ FOREIGN KEY (d,f) REFERENCES t1(e,c)
+ ) WITHOUT rowid;
+ INSERT INTO t1 VALUES(1,2,3,5,5,3);
+ INSERT INTO t1 VALUES(2,3,4,6,6,4);
+ INSERT INTO t1 VALUES('x','y',1.5,'fizzle','fizzle',1.5);
+ SELECT *, '|' FROM t1 ORDER BY a, b;
+} {1 2 3 5 5 3 | 2 3 4 6 6 4 | x y 1.5 fizzle fizzle 1.5 |}
+
+do_execsql_test without_rowid3-16.4.2.2 {
+ UPDATE t1 SET c=99, f=99 WHERE a=1;
+ SELECT *, '|' FROM t1 ORDER BY a, b;
+} {1 2 99 5 5 99 | 2 3 4 6 6 4 | x y 1.5 fizzle fizzle 1.5 |}
+
+do_execsql_test without_rowid3-16.4.2.3 {
+ UPDATE t1 SET e=876, d=876 WHERE a=2;
+ SELECT *, '|' FROM t1 ORDER BY a, b;
+} {1 2 99 5 5 99 | 2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}
+
+do_test without_rowid3-16.4.2.4 {
+ catchsql {
+ UPDATE t1 SET c=11, e=22 WHERE a=1;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+
+do_test without_rowid3-16.4.2.5 {
+ catchsql {
+ UPDATE t1 SET d=11, f=22 WHERE a=1;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+
+do_execsql_test without_rowid3-16.4.2.6 {
+ DELETE FROM t1 WHERE a=1;
+ SELECT *, '|' FROM t1 ORDER BY a, b;
+} {2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}
+
+
+#-------------------------------------------------------------------------
+# This next block of tests, without_rowid3-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 without_rowid3-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 without_rowid3-17.1.2 {
+ set STMT [sqlite3_prepare_v2 db "INSERT INTO two VALUES(4, 5, 6)" -1 dummy]
+ sqlite3_step $STMT
+} {SQLITE_CONSTRAINT}
+verify_ex_errcode without_rowid3-17.1.2b SQLITE_CONSTRAINT_FOREIGNKEY
+ifcapable autoreset {
+ do_test without_rowid3-17.1.3 {
+ sqlite3_step $STMT
+ } {SQLITE_CONSTRAINT}
+ verify_ex_errcode without_rowid3-17.1.3b SQLITE_CONSTRAINT_FOREIGNKEY
+} else {
+ do_test without_rowid3-17.1.3 {
+ sqlite3_step $STMT
+ } {SQLITE_MISUSE}
+}
+do_test without_rowid3-17.1.4 {
+ sqlite3_finalize $STMT
+} {SQLITE_CONSTRAINT}
+verify_ex_errcode without_rowid3-17.1.4b SQLITE_CONSTRAINT_FOREIGNKEY
+do_test without_rowid3-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 without_rowid3-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 without_rowid3-17.1.7 {
+ execsql { SELECT * FROM one }
+} {1 2 3 2 3 4 3 4 5 0 0 0}
+do_test without_rowid3-17.1.8 {
+ execsql { SELECT * FROM two }
+} {1 2 3 2 3 4 3 4 5}
+do_test without_rowid3-17.1.9 {
+ execsql COMMIT
+} {}
+do_test without_rowid3-17.1.10 {
+ execsql {
+ CREATE TABLE three(
+ g, h, i,
+ FOREIGN KEY(h, i) REFERENCES one(b, c) DEFERRABLE INITIALLY DEFERRED
+ );
+ }
+} {}
+do_test without_rowid3-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 without_rowid3-17.1.12 {
+ sqlite3_column_text $STMT 0
+} {1}
+do_test without_rowid3-17.1.13 {
+ sqlite3_step $STMT
+} {SQLITE_CONSTRAINT}
+verify_ex_errcode without_rowid3-17.1.13b SQLITE_CONSTRAINT_FOREIGNKEY
+do_test without_rowid3-17.1.14 {
+ sqlite3_finalize $STMT
+} {SQLITE_CONSTRAINT}
+verify_ex_errcode without_rowid3-17.1.14b SQLITE_CONSTRAINT_FOREIGNKEY
+
+drop_all_tables
+do_test without_rowid3-17.2.1 {
+ execsql {
+ CREATE TABLE high("a'b!" PRIMARY KEY, b) WITHOUT rowid;
+ CREATE TABLE low(
+ c,
+ "d&6" REFERENCES high ON UPDATE CASCADE ON DELETE CASCADE
+ );
+ }
+} {}
+do_test without_rowid3-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 without_rowid3-17.2.3 {
+ execsql { UPDATE high SET "a'b!" = 'c' }
+} {1}
+do_test without_rowid3-17.2.4 {
+ db changes
+} {1}
+do_test without_rowid3-17.2.5 {
+ expr [db total_changes] - $nTotal
+} {2}
+do_test without_rowid3-17.2.6 {
+ execsql { SELECT * FROM high ; SELECT * FROM low }
+} {c b b c}
+do_test without_rowid3-17.2.7 {
+ execsql { DELETE FROM high }
+} {1}
+do_test without_rowid3-17.2.8 {
+ db changes
+} {1}
+do_test without_rowid3-17.2.9 {
+ expr [db total_changes] - $nTotal
+} {4}
+do_test without_rowid3-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 without_rowid3-18.1 {
+ execsql {
+ CREATE TABLE long(a, b PRIMARY KEY, c) WITHOUT rowid;
+ 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 [lrange $args 0 4]; 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 without_rowid3-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 without_rowid3-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 without_rowid3-18.4 {
+ execsql { INSERT INTO mid VALUES(1, 3, 2) }
+ set authargs
+ } {SQLITE_INSERT mid {} main {} SQLITE_READ long b main {}}
+
+ do_test without_rowid3-18.5 {
+ execsql {
+ CREATE TABLE nought(a, b PRIMARY KEY, c) WITHOUT rowid;
+ 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 without_rowid3-18.6 {
+ execsql {SELECT * FROM cross}
+ } {0 5 0}
+
+ do_test without_rowid3-18.7 {
+ execsql {
+ CREATE TABLE one(a INT PRIMARY KEY, b) WITHOUT rowid;
+ 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 without_rowid3-18.8 {
+ catchsql { INSERT INTO short VALUES(1, 3, 2) }
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-18.9 {
+ execsql { INSERT INTO short VALUES(1, 3, NULL) }
+ } {}
+ do_test without_rowid3-18.10 {
+ execsql { SELECT * FROM short }
+ } {1 3 2 1 3 {}}
+ do_test without_rowid3-18.11 {
+ catchsql { UPDATE short SET f = 2 WHERE f IS NULL }
+ } {1 {FOREIGN KEY constraint failed}}
+
+ db auth {}
+ unset authargs
+}
+
+
+do_test without_rowid3-19.1 {
+ execsql {
+ CREATE TABLE main(id INT PRIMARY KEY) WITHOUT rowid;
+ 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 without_rowid3-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}
+verify_ex_errcode without_rowid3-19.2b SQLITE_CONSTRAINT_FOREIGNKEY
+do_test without_rowid3-19.3 {
+ sqlite3_reset $S
+} {SQLITE_CONSTRAINT}
+verify_ex_errcode without_rowid3-19.3b SQLITE_CONSTRAINT_FOREIGNKEY
+do_test without_rowid3-19.4 {
+ sqlite3_bind_int $S 1 1
+ sqlite3_step $S
+} {SQLITE_DONE}
+do_test without_rowid3-19.4 {
+ sqlite3_finalize $S
+} {SQLITE_OK}
+
+drop_all_tables
+do_test without_rowid3-20.1 {
+ execsql {
+ CREATE TABLE pp(a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE TABLE cc(c PRIMARY KEY, d REFERENCES pp) WITHOUT rowid;
+ }
+} {}
+
+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 without_rowid3-20.2.$tn.1 {
+ catchsql "$insert INTO cc VALUES(1, 2)"
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-20.2.$tn.2 {
+ execsql { SELECT * FROM cc }
+ } {}
+ do_test without_rowid3-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 without_rowid3-20.2.$tn.4 {
+ execsql { COMMIT ; SELECT * FROM cc }
+ } {1 2}
+ do_test without_rowid3-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 without_rowid3-20.3.$tn.1 {
+ execsql {
+ INSERT INTO pp VALUES(2, 'two');
+ INSERT INTO cc VALUES(1, 2);
+ }
+ } {}
+ do_test without_rowid3-20.3.$tn.2 {
+ catchsql "$update pp SET a = 1"
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-20.3.$tn.3 {
+ execsql { SELECT * FROM pp }
+ } {2 two}
+ do_test without_rowid3-20.3.$tn.4 {
+ catchsql "$update cc SET d = 1"
+ } {1 {FOREIGN KEY constraint failed}}
+ do_test without_rowid3-20.3.$tn.5 {
+ execsql { SELECT * FROM cc }
+ } {1 2}
+ do_test without_rowid3-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 without_rowid3-20.3.$tn.7 {
+ execsql { COMMIT ; SELECT * FROM pp }
+ } {2 two 3 three}
+ do_test without_rowid3-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 without_rowid3-20.3.$tn.9 {
+ execsql { COMMIT ; SELECT * FROM cc }
+ } {1 2 2 2}
+ do_test without_rowid3-20.3.$tn.10 {
+ execsql { DELETE FROM cc ; DELETE FROM pp }
+ } {}
+}
+
+#-------------------------------------------------------------------------
+# The following block of tests, those prefixed with "without_rowid3-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 without_rowid3-genfkey.1.1 {
+ execsql {
+ CREATE TABLE t1(a INT PRIMARY KEY, b, c, UNIQUE(b, c)) WITHOUT rowid;
+ CREATE TABLE t2(e REFERENCES t1, f);
+ CREATE TABLE t3(g, h, i, FOREIGN KEY (h, i) REFERENCES t1(b, c));
+ }
+} {}
+do_test without_rowid3-genfkey.1.2 {
+ catchsql { INSERT INTO t2 VALUES(1, 2) }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-genfkey.1.3 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 2, 3);
+ INSERT INTO t2 VALUES(1, 2);
+ }
+} {}
+do_test without_rowid3-genfkey.1.4 {
+ execsql { INSERT INTO t2 VALUES(NULL, 3) }
+} {}
+do_test without_rowid3-genfkey.1.5 {
+ catchsql { UPDATE t2 SET e = 5 WHERE e IS NULL }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-genfkey.1.6 {
+ execsql { UPDATE t2 SET e = 1 WHERE e IS NULL }
+} {}
+do_test without_rowid3-genfkey.1.7 {
+ execsql { UPDATE t2 SET e = NULL WHERE f = 3 }
+} {}
+do_test without_rowid3-genfkey.1.8 {
+ catchsql { UPDATE t1 SET a = 10 }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-genfkey.1.9 {
+ catchsql { UPDATE t1 SET a = NULL }
+} {1 {NOT NULL constraint failed: t1.a}}
+do_test without_rowid3-genfkey.1.10 {
+ catchsql { DELETE FROM t1 }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-genfkey.1.11 {
+ execsql { UPDATE t2 SET e = NULL }
+} {}
+do_test without_rowid3-genfkey.1.12 {
+ execsql {
+ UPDATE t1 SET a = 10;
+ DELETE FROM t1;
+ DELETE FROM t2;
+ }
+} {}
+do_test without_rowid3-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 without_rowid3-genfkey.1.14 {
+ catchsql { INSERT INTO t3 VALUES(3, 1, 4) }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-genfkey.1.15 {
+ execsql {
+ INSERT INTO t1 VALUES(1, 1, 4);
+ INSERT INTO t3 VALUES(3, 1, 4);
+ }
+} {}
+do_test without_rowid3-genfkey.1.16 {
+ catchsql { DELETE FROM t1 }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-genfkey.1.17 {
+ catchsql { UPDATE t1 SET b = 10}
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-genfkey.1.18 {
+ execsql { UPDATE t1 SET a = 10}
+} {}
+do_test without_rowid3-genfkey.1.19 {
+ catchsql { UPDATE t3 SET h = 'hello' WHERE i = 3}
+} {1 {FOREIGN KEY constraint failed}}
+
+drop_all_tables
+do_test without_rowid3-genfkey.2.1 {
+ execsql {
+ CREATE TABLE t1(a INT PRIMARY KEY, b, c, UNIQUE(b, c)) WITHOUT rowid;
+ 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 without_rowid3-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 without_rowid3-genfkey.2.3 {
+ execsql {
+ UPDATE t1 SET a = 2 WHERE a = 1;
+ SELECT * FROM t2;
+ }
+} {2 one 4 four}
+do_test without_rowid3-genfkey.2.4 {
+ execsql {
+ DELETE FROM t1 WHERE a = 4;
+ SELECT * FROM t2;
+ }
+} {2 one}
+
+do_test without_rowid3-genfkey.2.5 {
+ execsql {
+ INSERT INTO t3 VALUES('hello', 2, 3);
+ UPDATE t1 SET c = 2;
+ SELECT * FROM t3;
+ }
+} {hello 2 2}
+do_test without_rowid3-genfkey.2.6 {
+ execsql {
+ DELETE FROM t1;
+ SELECT * FROM t3;
+ }
+} {}
+
+drop_all_tables
+do_test without_rowid3-genfkey.3.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(c, b)) WITHOUT rowid;
+ 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 without_rowid3-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 without_rowid3-genfkey.3.3 {
+ execsql {
+ UPDATE t1 SET a = 2 WHERE a = 1;
+ SELECT * FROM t2;
+ }
+} {{} one 4 four}
+do_test without_rowid3-genfkey.3.4 {
+ execsql {
+ DELETE FROM t1 WHERE a = 4;
+ SELECT * FROM t2;
+ }
+} {{} one {} four}
+do_test without_rowid3-genfkey.3.5 {
+ execsql {
+ INSERT INTO t3 VALUES('hello', 2, 3);
+ UPDATE t1 SET c = 2;
+ SELECT * FROM t3;
+ }
+} {hello {} {}}
+do_test without_rowid3-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 without_rowid3-dd08e5.1.1 {
+ execsql {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE tdd08(a INTEGER PRIMARY KEY, b) WITHOUT rowid;
+ 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 without_rowid3-dd08e5.1.2 {
+ catchsql {
+ DELETE FROM tdd08;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-dd08e5.1.3 {
+ execsql {
+ SELECT * FROM tdd08;
+ }
+} {200 300}
+do_test without_rowid3-dd08e5.1.4 {
+ catchsql {
+ INSERT INTO tdd08_b VALUES(400,500,300);
+ }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-dd08e5.1.5 {
+ catchsql {
+ UPDATE tdd08_b SET x=x+1;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-dd08e5.1.6 {
+ catchsql {
+ UPDATE tdd08 SET a=a+1;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+
+#-------------------------------------------------------------------------
+# Verify that ticket ce7c133ea6cc9ccdc1a60d80441f80b6180f5eba
+# fixed.
+#
+do_test without_rowid3-ce7c13.1.1 {
+ execsql {
+ CREATE TABLE tce71(a INTEGER PRIMARY KEY, b) WITHOUT rowid;
+ 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 without_rowid3-ce7c13.1.2 {
+ catchsql {
+ UPDATE tce71 set b = 201 where a = 100;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-ce7c13.1.3 {
+ catchsql {
+ UPDATE tce71 set a = 101 where a = 100;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-ce7c13.1.4 {
+ execsql {
+ CREATE TABLE tce73(a INTEGER PRIMARY KEY, b, UNIQUE(a,b)) WITHOUT rowid;
+ 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 without_rowid3-ce7c13.1.5 {
+ catchsql {
+ UPDATE tce73 set b = 201 where a = 100;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+do_test without_rowid3-ce7c13.1.6 {
+ catchsql {
+ UPDATE tce73 set a = 101 where a = 100;
+ }
+} {1 {FOREIGN KEY constraint failed}}
+
+# Confirm that changes() works on WITHOUT ROWID tables that use the
+# xfer optimization.
+#
+db close
+sqlite3 db :memory:
+do_execsql_test without_rowid3-30.1 {
+ CREATE TABLE t1(a,b,PRIMARY KEY(a,b)) WITHOUT ROWID;
+ CREATE TABLE t2(a,b,PRIMARY KEY(a,b)) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1,2),(3,4),(5,6);
+ SELECT changes();
+} {3}
+do_execsql_test without_rowid3-30.2 {
+ INSERT INTO t2 SELECT * FROM t1;
+ SELECT changes();
+} {3}
+
+finish_test
diff --git a/test/without_rowid4.test b/test/without_rowid4.test
new file mode 100644
index 0000000..d8c2d69
--- /dev/null
+++ b/test/without_rowid4.test
@@ -0,0 +1,764 @@
+# 2013-11-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.
+#
+#***********************************************************************
+#
+# Regression testing of FOR EACH ROW table triggers on WITHOUT ROWID
+# tables.
+#
+# 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.
+#
+# without_rowid4-1.1.*: ON UPDATE trigger execution model.
+# without_rowid4-1.2.*: DELETE trigger execution model.
+# without_rowid4-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.
+#
+# without_rowid4-3.1: UPDATE OF triggers
+# without_rowid4-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.
+#
+# without_rowid4-4.1: Trivial cascading trigger
+# without_rowid4-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
+# without_rowid4-6.1[a-f]: INSERT statements
+# without_rowid4-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 INTEGER PRIMARY KEY, b) WITHOUT rowid;} \
+ {CREATE TABLE tbl (a, b PRIMARY KEY) WITHOUT rowid;} \
+ {CREATE TABLE tbl (a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE INDEX tbl_idx ON tbl(b);} \
+ ]
+ ifcapable tempdb {
+ lappend tbl_definitions \
+ {CREATE TEMP TABLE tbl (a PRIMARY KEY, b) WITHOUT rowid;
+ CREATE INDEX tbl_idx ON tbl(b);}
+ lappend tbl_definitions \
+ {CREATE TEMP TABLE tbl (a PRIMARY KEY, b) WITHOUT rowid}
+ lappend tbl_definitions \
+ {CREATE TEMPORARY TABLE tbl (a INTEGER PRIMARY KEY, b) WITHOUT rowid;}
+ }
+ 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 without_rowid4-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 without_rowid4-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 without_rowid4-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 without_rowid4-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) WITHOUT rowid;
+ 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 without_rowid4-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 without_rowid4-2.$ii-after "execsql {$statement $query}" $after_data
+ execsql "DROP TRIGGER the_trigger;"
+
+ integrity_check without_rowid4-2.$ii-integrity
+ }
+}
+catchsql {
+ DROP TABLE tbl;
+ DROP TABLE log;
+}
+
+# 3.
+
+# without_rowid4-3.1: UPDATE OF triggers
+execsql {
+ CREATE TABLE tbl (a, b, c, d, PRIMARY KEY(a,b,c,d)) WITHOUT rowid;
+ 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 without_rowid4-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;
+}
+
+# without_rowid4-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 without_rowid4-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 without_rowid4-3.3
+
+# Simple cascaded trigger
+execsql {
+ CREATE TABLE tblA(a, b, PRIMARY KEY(a,b)) WITHOUT rowid;
+ CREATE TABLE tblB(a, b, PRIMARY KEY(a,b)) WITHOUT rowid;
+ CREATE TABLE tblC(a, b, PRIMARY KEY(a,b)) WITHOUT rowid;
+
+ 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 without_rowid4-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, PRIMARY KEY(c,a,b)) WITHOUT rowid;
+ CREATE TRIGGER tbl_trig BEFORE INSERT ON tbl
+ BEGIN
+ INSERT INTO tbl VALUES (new.a, new.b, new.c+1);
+ END;
+}
+do_test without_rowid4-4.2 {
+ execsql {
+ INSERT INTO tbl VALUES (1, 2, 3);
+ select * from tbl;
+ }
+} {1 2 3 1 2 4}
+execsql {
+ DROP TABLE tbl;
+}
+
+# 5.
+execsql {
+ CREATE TABLE tbl(a, b, c, PRIMARY KEY(c,a,b)) WITHOUT rowid;
+ 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 without_rowid4-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) WITHOUT rowid;
+ CREATE TRIGGER ai_tbl AFTER INSERT ON tbl BEGIN
+ INSERT OR IGNORE INTO tbl values (new.a, 0, 0);
+ END;
+ }
+ do_test without_rowid4-6.1a {
+ execsql {
+ BEGIN;
+ INSERT INTO tbl values (1, 2, 3);
+ SELECT * from tbl;
+ }
+ } {1 2 3}
+ do_test without_rowid4-6.1b {
+ catchsql {
+ INSERT OR ABORT INTO tbl values (2, 2, 3);
+ }
+ } {1 {UNIQUE constraint failed: tbl.a}}
+ do_test without_rowid4-6.1c {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {1 2 3}
+ do_test without_rowid4-6.1d {
+ catchsql {
+ INSERT OR FAIL INTO tbl values (2, 2, 3);
+ }
+ } {1 {UNIQUE constraint failed: tbl.a}}
+ do_test without_rowid4-6.1e {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {1 2 3 2 2 3}
+ do_test without_rowid4-6.1f {
+ execsql {
+ INSERT OR REPLACE INTO tbl values (2, 2, 3);
+ SELECT * from tbl;
+ }
+ } {1 2 3 2 0 0}
+ do_test without_rowid4-6.1g {
+ catchsql {
+ INSERT OR ROLLBACK INTO tbl values (3, 2, 3);
+ }
+ } {1 {UNIQUE constraint failed: tbl.a}}
+ do_test without_rowid4-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 without_rowid4-6.2a {
+ execsql {
+ BEGIN;
+ UPDATE tbl SET a = 1 WHERE a = 4;
+ SELECT * from tbl;
+ }
+ } {1 2 10 6 3 4}
+ do_test without_rowid4-6.2b {
+ catchsql {
+ UPDATE OR ABORT tbl SET a = 4 WHERE a = 1;
+ }
+ } {1 {UNIQUE constraint failed: tbl.a}}
+ do_test without_rowid4-6.2c {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {1 2 10 6 3 4}
+ do_test without_rowid4-6.2d {
+ catchsql {
+ UPDATE OR FAIL tbl SET a = 4 WHERE a = 1;
+ }
+ } {1 {UNIQUE constraint failed: tbl.a}}
+ do_test without_rowid4-6.2e {
+ execsql {
+ SELECT * from tbl;
+ }
+ } {4 2 10 6 3 4}
+ do_test without_rowid4-6.2f.1 {
+ execsql {
+ UPDATE OR REPLACE tbl SET a = 1 WHERE a = 4;
+ SELECT * from tbl;
+ }
+ } {1 3 10}
+ do_test without_rowid4-6.2f.2 {
+ execsql {
+ INSERT INTO tbl VALUES (2, 3, 4);
+ SELECT * FROM tbl;
+ }
+ } {1 3 10 2 3 4}
+ do_test without_rowid4-6.2g {
+ catchsql {
+ UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1;
+ }
+ } {1 {UNIQUE constraint failed: tbl.a}}
+ do_test without_rowid4-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 without_rowid4-7.1 {
+ execsql {
+ CREATE TABLE ab(a, b, PRIMARY KEY(a,b)) WITHOUT rowid;
+ CREATE TABLE cd(c, d, PRIMARY KEY(c,d)) WITHOUT rowid;
+ 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 without_rowid4-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 without_rowid4-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 without_rowid4-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 without_rowid4-8.1 {
+ execsql {
+ CREATE TABLE t1(a,b,c, PRIMARY KEY(a,b,c)) WITHOUT rowid;
+ 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 without_rowid4-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 without_rowid4-8.3 {
+ execsql {
+ DELETE FROM v1 WHERE x=3;
+ SELECT * FROM v1log;
+ }
+} {3 {} 5 {} 4 {}}
+do_test without_rowid4-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 without_rowid4-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 without_rowid4-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 without_rowid4-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 without_rowid4-9.9
+
+finish_test
diff --git a/test/without_rowid5.test b/test/without_rowid5.test
new file mode 100644
index 0000000..d1c4944
--- /dev/null
+++ b/test/without_rowid5.test
@@ -0,0 +1,289 @@
+# 2013-11-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.
+#
+#***********************************************************************
+#
+# Requirements testing for WITHOUT ROWID tables.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !incrblob {
+ finish_test
+ return
+}
+
+# EVIDENCE-OF: R-36924-43758 By default, every row in SQLite has a
+# special column, usually called the "rowid", that uniquely identifies
+# that row within the table.
+#
+# EVIDENCE-OF: R-32341-39358 However if the phrase "WITHOUT ROWID" is
+# added to the end of a CREATE TABLE statement, then the special "rowid"
+# column is omitted.
+#
+do_execsql_test without_rowid5-1.1 {
+ CREATE TABLE t1(a PRIMARY KEY,b,c);
+ CREATE TABLE t1w(a PRIMARY KEY,b,c) WITHOUT ROWID;
+ INSERT INTO t1 VALUES(1565,681,1148),(1429,1190,1619),(425,358,1306);
+ INSERT INTO t1w SELECT a,b,c FROM t1;
+ SELECT rowid, _rowid_, oid FROM t1 ORDER BY a DESC;
+} {1 1 1 2 2 2 3 3 3}
+do_catchsql_test without_rowid5-1.2 {
+ SELECT rowid FROM t1w;
+} {1 {no such column: rowid}}
+do_catchsql_test without_rowid5-1.3 {
+ SELECT _rowid_ FROM t1w;
+} {1 {no such column: _rowid_}}
+do_catchsql_test without_rowid5-1.4 {
+ SELECT oid FROM t1w;
+} {1 {no such column: oid}}
+
+# EVIDENCE-OF: R-00217-01605 To create a WITHOUT ROWID table, simply add
+# the keywords "WITHOUT ROWID" to the end of the CREATE TABLE statement.
+# For example: CREATE TABLE IF NOT EXISTS wordcount( word TEXT PRIMARY
+# KEY, cnt INTEGER ) WITHOUT ROWID;
+#
+do_execsql_test without_rowid5-2.1 {
+ CREATE TABLE IF NOT EXISTS wordcount(
+ word TEXT PRIMARY KEY,
+ cnt INTEGER
+ ) WITHOUT ROWID;
+ INSERT INTO wordcount VALUES('one',1);
+} {}
+do_catchsql_test without_rowid5-2.2 {
+ SELECT rowid FROM wordcount;
+} {1 {no such column: rowid}}
+
+# EVIDENCE-OF: R-24770-17719 As with all SQL syntax, the case of the
+# keywords does not matter. One can write "WITHOUT rowid" or "without
+# rowid" or "WiThOuT rOwId" and it will mean the same thing.
+#
+do_execsql_test without_rowid5-2.3 {
+ CREATE TABLE IF NOT EXISTS wordcount_b(
+ word TEXT PRIMARY KEY,
+ cnt INTEGER
+ ) WITHOUT rowid;
+ INSERT INTO wordcount_b VALUES('one',1);
+} {}
+do_catchsql_test without_rowid5-2.4 {
+ SELECT rowid FROM wordcount_b;
+} {1 {no such column: rowid}}
+do_execsql_test without_rowid5-2.5 {
+ CREATE TABLE IF NOT EXISTS wordcount_c(
+ word TEXT PRIMARY KEY,
+ cnt INTEGER
+ ) without rowid;
+ INSERT INTO wordcount_c VALUES('one',1);
+} {}
+do_catchsql_test without_rowid5-2.6 {
+ SELECT rowid FROM wordcount_c;
+} {1 {no such column: rowid}}
+do_execsql_test without_rowid5-2.7 {
+ CREATE TABLE IF NOT EXISTS wordcount_d(
+ word TEXT PRIMARY KEY,
+ cnt INTEGER
+ ) WITHOUT rowid;
+ INSERT INTO wordcount_d VALUES('one',1);
+} {}
+do_catchsql_test without_rowid5-2.8 {
+ SELECT rowid FROM wordcount_d;
+} {1 {no such column: rowid}}
+
+# EVIDENCE-OF: R-01418-51310 However, only "rowid" works as the keyword
+# in the CREATE TABLE statement.
+#
+do_catchsql_test without_rowid5-3.1 {
+ CREATE TABLE IF NOT EXISTS error1(
+ word TEXT PRIMARY KEY,
+ cnt INTEGER
+ ) WITHOUT _rowid_;
+} {1 {unknown table option: _rowid_}}
+do_catchsql_test without_rowid5-3.2 {
+ CREATE TABLE IF NOT EXISTS error2(
+ word TEXT PRIMARY KEY,
+ cnt INTEGER
+ ) WITHOUT oid;
+} {1 {unknown table option: oid}}
+
+# EVIDENCE-OF: R-58033-17334 An error is raised if a CREATE TABLE
+# statement with the WITHOUT ROWID clause lacks a PRIMARY KEY.
+#
+# EVIDENCE-OF: R-63443-09418 Every WITHOUT ROWID table must have a
+# PRIMARY KEY.
+#
+# EVIDENCE-OF: R-27966-31616 An attempt to create a WITHOUT ROWID table
+# without a PRIMARY KEY results in an error.
+#
+do_catchsql_test without_rowid5-4.1 {
+ CREATE TABLE IF NOT EXISTS error3(
+ word TEXT UNIQUE,
+ cnt INTEGER
+ ) WITHOUT ROWID;
+} {1 {PRIMARY KEY missing on table error3}}
+
+# EVIDENCE-OF: R-48230-36247 The special behaviors associated "INTEGER
+# PRIMARY KEY" do not apply on WITHOUT ROWID tables.
+#
+do_execsql_test without_rowid5-5.1 {
+ CREATE TABLE ipk(key INTEGER PRIMARY KEY, val TEXT) WITHOUT ROWID;
+ INSERT INTO ipk VALUES('rival','bonus'); -- ok to insert non-integer key
+ SELECT * FROM ipk;
+} {rival bonus}
+do_catchsql_test without_rowid5-5.2a {
+ BEGIN;
+ INSERT INTO ipk VALUES(NULL,'sample'); -- no automatic generation of keys
+} {1 {NOT NULL constraint failed: ipk.key}}
+do_execsql_test without_rowid5-5.2b {
+ ROLLBACK;
+} {}
+
+# EVIDENCE-OF: R-33142-02092 AUTOINCREMENT does not work on WITHOUT
+# ROWID tables.
+#
+# EVIDENCE-OF: R-53084-07740 An error is raised if the "AUTOINCREMENT"
+# keyword is used in the CREATE TABLE statement for a WITHOUT ROWID
+# table.
+#
+do_catchsql_test without_rowid5-5.3 {
+ CREATE TABLE ipk2(key INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT)WITHOUT ROWID;
+} {1 {AUTOINCREMENT not allowed on WITHOUT ROWID tables}}
+
+# EVIDENCE-OF: R-27831-00579 NOT NULL is enforced on every column of the
+# PRIMARY KEY in a WITHOUT ROWID table.
+#
+# EVIDENCE-OF: R-29781-51289 So, ordinary rowid tables in SQLite violate
+# the SQL standard and allow NULL values in PRIMARY KEY fields.
+#
+# EVIDENCE-OF: R-27472-62612 But WITHOUT ROWID tables do follow the
+# standard and will throw an error on any attempt to insert a NULL into
+# a PRIMARY KEY column.
+#
+do_execsql_test without_rowid5-5.4 {
+ CREATE TABLE nn(a, b, c, d, e, PRIMARY KEY(c,a,e));
+ CREATE TABLE nnw(a, b, c, d, e, PRIMARY KEY(c,a,e)) WITHOUT ROWID;
+ INSERT INTO nn VALUES(1,2,3,4,5);
+ INSERT INTO nnw VALUES(1,2,3,4,5);
+} {}
+do_execsql_test without_rowid5-5.5 {
+ INSERT INTO nn VALUES(NULL, 3,4,5,6);
+ INSERT INTO nn VALUES(3,4,NULL,7,8);
+ INSERT INTO nn VALUES(4,5,6,7,NULL);
+ SELECT count(*) FROM nn;
+} {4}
+do_catchsql_test without_rowid5-5.6 {
+ INSERT INTO nnw VALUES(NULL, 3,4,5,6);
+} {1 {NOT NULL constraint failed: nnw.a}}
+do_catchsql_test without_rowid5-5.7 {
+ INSERT INTO nnw VALUES(3,4,NULL,7,8)
+} {1 {NOT NULL constraint failed: nnw.c}}
+do_catchsql_test without_rowid5-5.8 {
+ INSERT INTO nnw VALUES(4,5,6,7,NULL)
+} {1 {NOT NULL constraint failed: nnw.e}}
+do_execsql_test without_rowid5-5.9 {
+ SELECT count(*) FROM nnw;
+} {1}
+
+# Ticket f2be158c57aaa8c6 (2021-08-18)
+# NOT NULL ON CONFLICT clauses work on WITHOUT ROWID tables now.
+#
+do_test without_rowid5-5.100 {
+ db eval {
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t5(
+ a INT NOT NULL ON CONFLICT ROLLBACK,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a,b)
+ ) WITHOUT ROWID;
+ BEGIN;
+ INSERT INTO t5(a,b,c) VALUES(1,2,3);
+ }
+ catch {db eval {INSERT INTO t5(a,b,c) VALUES(NULL,6,7);}}
+ db eval {
+ SELECT * FROM t5;
+ }
+} {}
+do_test without_rowid5-5.101 {
+ db eval {
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t5(
+ a INT NOT NULL ON CONFLICT ABORT,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a,b)
+ ) WITHOUT ROWID;
+ BEGIN;
+ INSERT INTO t5(a,b,c) VALUES(1,2,3);
+ }
+ catch {db eval {INSERT INTO t5(a,b,c) VALUES(NULL,6,7);}}
+ db eval {
+ COMMIT;
+ SELECT * FROM t5;
+ }
+} {1 2 3}
+do_test without_rowid5-5.102 {
+ db eval {
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t5(
+ a INT NOT NULL ON CONFLICT FAIL,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a,b)
+ ) WITHOUT ROWID;
+ }
+ catch {db eval {INSERT INTO t5(a,b,c) VALUES(1,2,3),(NULL,4,5),(6,7,8);}}
+ db eval {
+ SELECT * FROM t5;
+ }
+} {1 2 3}
+do_test without_rowid5-5.103 {
+ db eval {
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t5(
+ a INT NOT NULL ON CONFLICT IGNORE,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a,b)
+ ) WITHOUT ROWID;
+ INSERT INTO t5(a,b,c) VALUES(1,2,3),(NULL,4,5),(6,7,8);
+ SELECT * FROM t5;
+ }
+} {1 2 3 6 7 8}
+do_test without_rowid5-5.104 {
+ db eval {
+ DROP TABLE IF EXISTS t5;
+ CREATE TABLE t5(
+ a INT NOT NULL ON CONFLICT REPLACE DEFAULT 3,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a,b)
+ ) WITHOUT ROWID;
+ INSERT INTO t5(a,b,c) VALUES(1,2,3),(NULL,4,5),(6,7,8);
+ SELECT * FROM t5;
+ }
+} {1 2 3 3 4 5 6 7 8}
+
+
+# EVIDENCE-OF: R-12643-30541 The incremental blob I/O mechanism does not
+# work for WITHOUT ROWID tables.
+#
+# EVIDENCE-OF: R-40134-30296 Table zTable is a WITHOUT ROWID table
+#
+do_execsql_test without_rowid5-6.1 {
+ CREATE TABLE b1(a INTEGER PRIMARY KEY, b BLOB) WITHOUT ROWID;
+ INSERT INTO b1 VALUES(1,x'0102030405060708090a0b0c0d0e0f');
+} {}
+do_test without_rowid5-6.2 {
+ set rc [catch {db incrblob b1 b 1} msg]
+ lappend rc $msg
+} {1 {cannot open table without rowid: b1}}
+
+
+finish_test
diff --git a/test/without_rowid6.test b/test/without_rowid6.test
new file mode 100644
index 0000000..06fc743
--- /dev/null
+++ b/test/without_rowid6.test
@@ -0,0 +1,134 @@
+# 2014-12-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.
+#
+#***********************************************************************
+#
+# Verify that WITHOUT ROWID tables work correctly when the PRIMARY KEY
+# has redundant columns.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc do_execsql_test_if_vtab {tn sql {res {}}} {
+ ifcapable vtab { uplevel [list do_execsql_test $tn $sql $res] }
+}
+
+do_execsql_test without_rowid6-100 {
+ CREATE TABLE t1(a,b,c,d,e, PRIMARY KEY(a,b,c,a,b,c,d,a,b,c)) WITHOUT ROWID;
+ CREATE INDEX t1a ON t1(b, b);
+ WITH RECURSIVE
+ c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<1000)
+ INSERT INTO t1(a,b,c,d,e) SELECT i, i+1000, printf('x%dy',i), 0, 0 FROM c;
+ ANALYZE;
+} {}
+do_execsql_test_if_vtab without_rowid6-101 {
+ SELECT name, key FROM pragma_index_xinfo('t1');
+} {a 1 b 1 c 1 d 1 e 0}
+do_execsql_test without_rowid6-110 {
+ SELECT c FROM t1 WHERE a=123;
+} {x123y}
+do_execsql_test without_rowid6-120 {
+ SELECT c FROM t1 WHERE b=1123;
+} {x123y}
+do_execsql_test without_rowid6-130 {
+ SELECT c FROM t1 ORDER BY a DESC LIMIT 5;
+} {x1000y x999y x998y x997y x996y}
+do_execsql_test without_rowid6-140 {
+ SELECT c FROM t1 ORDER BY b LIMIT 5;
+} {x1y x2y x3y x4y x5y}
+
+# Column t1.b starts out as a unique index, but that index is
+# subsequently converted into a PRIMARY KEY.
+#
+do_execsql_test without_rowid6-200 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(
+ a UNIQUE,
+ b UNIQUE,
+ c UNIQUE,
+ PRIMARY KEY(b)
+ ) WITHOUT ROWID;
+ INSERT INTO t1(a,b,c) VALUES(1,8,3),(4,5,6),(7,2,9);
+ SELECT a FROM t1 WHERE b>3 ORDER BY b;
+} {4 1}
+do_execsql_test_if_vtab without_rowid6-201 {
+ SELECT name, key FROM pragma_index_xinfo('t1');
+} {b 1 a 0 c 0}
+do_execsql_test without_rowid6-210 {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE b>3 ORDER BY b;
+} {/SEARCH t1 USING PRIMARY KEY .b>../}
+do_execsql_test without_rowid6-220 {
+ PRAGMA index_list(t1);
+} {/sqlite_autoindex_t1_2 1 pk/}
+
+do_execsql_test without_rowid6-300 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(
+ a UNIQUE,
+ b PRIMARY KEY,
+ c UNIQUE,
+ UNIQUE(b)
+ ) WITHOUT ROWID;
+ INSERT INTO t1(a,b,c) VALUES(1,8,3),(4,5,6),(7,2,9);
+ SELECT a FROM t1 WHERE b>3 ORDER BY b;
+} {4 1}
+do_execsql_test without_rowid6-310 {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE b>3 ORDER BY b;
+} {/SEARCH t1 USING PRIMARY KEY .b>../}
+do_execsql_test without_rowid6-320 {
+ PRAGMA index_list(t1);
+} {/sqlite_autoindex_t1_2 1 pk/}
+
+do_execsql_test without_rowid6-400 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(
+ a UNIQUE,
+ b UNIQUE PRIMARY KEY,
+ c UNIQUE
+ ) WITHOUT ROWID;
+ INSERT INTO t1(a,b,c) VALUES(1,8,3),(4,5,6),(7,2,9);
+ SELECT a FROM t1 WHERE b>3 ORDER BY b;
+} {4 1}
+do_execsql_test without_rowid6-410 {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE b>3 ORDER BY b;
+} {/SEARCH t1 USING PRIMARY KEY .b>../}
+do_execsql_test without_rowid6-420 {
+ PRAGMA index_list(t1);
+} {/sqlite_autoindex_t1_2 1 pk/}
+
+do_execsql_test without_rowid6-500 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b,c,
+ UNIQUE(b,c),
+ PRIMARY KEY(b,c)
+ ) WITHOUT ROWID;
+ INSERT INTO t1(a,b,c) VALUES(1,8,3),(4,5,6),(7,2,9);
+ SELECT a FROM t1 WHERE b>3 ORDER BY b;
+} {4 1}
+do_execsql_test_if_vtab without_rowid6-501 {
+ SELECT name, key FROM pragma_index_xinfo('t1');
+} {b 1 c 1 a 0}
+do_execsql_test without_rowid6-510 {
+ EXPLAIN QUERY PLAN
+ SELECT a FROM t1 WHERE b>3 ORDER BY b;
+} {/SEARCH t1 USING PRIMARY KEY .b>../}
+do_execsql_test without_rowid6-520 {
+ PRAGMA index_list(t1);
+} {/sqlite_autoindex_t1_1 1 pk/}
+
+do_catchsql_test without_rowid6-600 {
+ CREATE TABLE t6(a,b,c,PRIMARY KEY(a,rowid,b))WITHOUT ROWID;
+} {1 {no such column: rowid}}
+
+
+finish_test
diff --git a/test/without_rowid7.test b/test/without_rowid7.test
new file mode 100644
index 0000000..56e9fb4
--- /dev/null
+++ b/test/without_rowid7.test
@@ -0,0 +1,60 @@
+# 2019 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.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix without_rowid7
+
+proc do_execsql_test_if_vtab {tn sql {res {}}} {
+ ifcapable vtab { uplevel [list do_execsql_test $tn $sql $res] }
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a, b COLLATE nocase, PRIMARY KEY(a, a, b)) WITHOUT ROWID;
+}
+
+do_catchsql_test 1.1 {
+ INSERT INTO t1 VALUES(1, 'one'), (1, 'ONE');
+} {1 {UNIQUE constraint failed: t1.a, t1.b}}
+
+
+do_execsql_test 2.0 {
+ CREATE TABLE t2(a, b, PRIMARY KEY(a COLLATE nocase, a)) WITHOUT ROWID;
+}
+
+do_execsql_test 2.1 {
+ INSERT INTO t2 VALUES(1, 'one');
+ SELECT b FROM t2;
+} {one}
+
+do_execsql_test 2.2a {
+ PRAGMA index_info(t2);
+} {0 0 a 1 0 a}
+do_execsql_test_if_vtab 2.2b {
+ SELECT *, '|' FROM pragma_index_info('t2');
+} {0 0 a | 1 0 a |}
+do_execsql_test 2.3a {
+ PRAGMA index_xinfo(t2);
+} {0 0 a 0 nocase 1 1 0 a 0 BINARY 1 2 1 b 0 BINARY 0}
+do_execsql_test_if_vtab 2.3b {
+ SELECT *, '|' FROM pragma_index_xinfo('t2');
+} {0 0 a 0 nocase 1 | 1 0 a 0 BINARY 1 | 2 1 b 0 BINARY 0 |}
+
+do_execsql_test 2.4 {
+ CREATE TABLE t3(a, b, PRIMARY KEY(a COLLATE nocase, a));
+ PRAGMA index_info(t3);
+} {}
+
+
+
+finish_test
diff --git a/test/wordcount.c b/test/wordcount.c
new file mode 100644
index 0000000..4a21d25
--- /dev/null
+++ b/test/wordcount.c
@@ -0,0 +1,659 @@
+/*
+** This C program extracts all "words" from an input document and adds them
+** to an SQLite database. A "word" is any contiguous sequence of alphabetic
+** characters. All digits, punctuation, and whitespace characters are
+** word separators. The database stores a single entry for each distinct
+** word together with a count of the number of occurrences of that word.
+** A fresh database is created automatically on each run.
+**
+** wordcount DATABASE INPUTFILE
+**
+** The INPUTFILE name can be omitted, in which case input it taken from
+** standard input.
+**
+** Option:
+**
+**
+** Modes:
+**
+** Insert mode means:
+** (1) INSERT OR IGNORE INTO wordcount VALUES($new,1)
+** (2) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new -- if (1) is a noop
+**
+** Update mode means:
+** (1) INSERT OR IGNORE INTO wordcount VALUES($new,0)
+** (2) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new
+**
+** Replace mode means:
+** (1) REPLACE INTO wordcount
+** VALUES($new,ifnull((SELECT cnt FROM wordcount WHERE word=$new),0)+1);
+**
+** Upsert mode means:
+** (1) INSERT INTO wordcount VALUES($new,1)
+** ON CONFLICT(word) DO UPDATE SET cnt=cnt+1
+**
+** Select mode means:
+** (1) SELECT 1 FROM wordcount WHERE word=$new
+** (2) INSERT INTO wordcount VALUES($new,1) -- if (1) returns nothing
+** (3) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new --if (1) return TRUE
+**
+** Delete mode means:
+** (1) DELETE FROM wordcount WHERE word=$new
+**
+** Query mode means:
+** (1) SELECT cnt FROM wordcount WHERE word=$new
+**
+** Note that delete mode and query mode are only useful for preexisting
+** databases. The wordcount table is created using IF NOT EXISTS so this
+** utility can be run multiple times on the same database file. The
+** --without-rowid, --nocase, and --pagesize parameters are only effective
+** when creating a new database and are harmless no-ops on preexisting
+** databases.
+**
+******************************************************************************
+**
+** Compile as follows:
+**
+** gcc -I. wordcount.c sqlite3.c -ldl -lpthreads
+**
+** Or:
+**
+** gcc -I. -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
+** wordcount.c sqlite3.c
+*/
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include "sqlite3.h"
+#ifndef _WIN32
+# include <unistd.h>
+#else
+# include <io.h>
+#endif
+#define ISALPHA(X) isalpha((unsigned char)(X))
+
+const char zHelp[] =
+"Usage: wordcount [OPTIONS] DATABASE [INPUT]\n"
+" --all Repeat the test for all test modes\n"
+" --cachesize NNN Use a cache size of NNN\n"
+" --commit NNN Commit after every NNN operations\n"
+" --delete Use DELETE mode\n"
+" --insert Use INSERT mode (the default)\n"
+" --journal MMMM Use PRAGMA journal_mode=MMMM\n"
+" --nocase Add the NOCASE collating sequence to the words.\n"
+" --nosync Use PRAGMA synchronous=OFF\n"
+" --pagesize NNN Use a page size of NNN\n"
+" --query Use QUERY mode\n"
+" --replace Use REPLACE mode\n"
+" --select Use SELECT mode\n"
+" --stats Show sqlite3_status() results at the end.\n"
+" --summary Show summary information on the collected data.\n"
+" --tag NAME Tag all output using NAME. Use only stdout.\n"
+" --timer Time the operation of this program\n"
+" --trace Enable sqlite3_trace() output.\n"
+" --update Use UPDATE mode\n"
+" --upsert Use UPSERT mode\n"
+" --without-rowid Use a WITHOUT ROWID table to store the words.\n"
+;
+
+/* Output tag */
+char *zTag = "--";
+
+/* Return the current wall-clock time */
+static sqlite3_int64 realTime(void){
+ static sqlite3_vfs *clockVfs = 0;
+ sqlite3_int64 t;
+ if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
+ if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){
+ clockVfs->xCurrentTimeInt64(clockVfs, &t);
+ }else{
+ double r;
+ clockVfs->xCurrentTime(clockVfs, &r);
+ t = (sqlite3_int64)(r*86400000.0);
+ }
+ return t;
+}
+
+/* Print an error message and exit */
+static void fatal_error(const char *zMsg, ...){
+ va_list ap;
+ va_start(ap, zMsg);
+ vfprintf(stderr, zMsg, ap);
+ va_end(ap);
+ exit(1);
+}
+
+/* Print a usage message and quit */
+static void usage(void){
+ printf("%s",zHelp);
+ exit(0);
+}
+
+/* The sqlite3_trace() callback function */
+static void traceCallback(void *NotUsed, const char *zSql){
+ printf("%s;\n", zSql);
+}
+
+/* An sqlite3_exec() callback that prints results on standard output,
+** each column separated by a single space. */
+static int printResult(void *NotUsed, int nArg, char **azArg, char **azNm){
+ int i;
+ printf("%s", zTag);
+ for(i=0; i<nArg; i++){
+ printf(" %s", azArg[i] ? azArg[i] : "(null)");
+ }
+ printf("\n");
+ return 0;
+}
+
+
+/*
+** Add one character to a hash
+*/
+static void addCharToHash(unsigned int *a, unsigned char x){
+ if( a[0]<4 ){
+ a[1] = (a[1]<<8) | x;
+ a[0]++;
+ }else{
+ a[2] = (a[2]<<8) | x;
+ a[0]++;
+ if( a[0]==8 ){
+ a[3] += a[1] + a[4];
+ a[4] += a[2] + a[3];
+ a[0] = a[1] = a[2] = 0;
+ }
+ }
+}
+
+/*
+** Compute the final hash value.
+*/
+static void finalHash(unsigned int *a, char *z){
+ a[3] += a[1] + a[4] + a[0];
+ a[4] += a[2] + a[3];
+ sqlite3_snprintf(17, z, "%08x%08x", a[3], a[4]);
+}
+
+
+/*
+** Implementation of a checksum() aggregate SQL function
+*/
+static void checksumStep(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ const unsigned char *zVal;
+ int nVal, i, j;
+ unsigned int *a;
+ a = (unsigned*)sqlite3_aggregate_context(context, sizeof(unsigned int)*5);
+
+ if( a ){
+ for(i=0; i<argc; i++){
+ nVal = sqlite3_value_bytes(argv[i]);
+ zVal = (const unsigned char*)sqlite3_value_text(argv[i]);
+ if( zVal ) for(j=0; j<nVal; j++) addCharToHash(a, zVal[j]);
+ addCharToHash(a, '|');
+ }
+ addCharToHash(a, '\n');
+ }
+}
+static void checksumFinalize(sqlite3_context *context){
+ unsigned int *a;
+ char zResult[24];
+ a = sqlite3_aggregate_context(context, 0);
+ if( a ){
+ finalHash(a, zResult);
+ sqlite3_result_text(context, zResult, -1, SQLITE_TRANSIENT);
+ }
+}
+
+/* Define operating modes */
+#define MODE_INSERT 0
+#define MODE_REPLACE 1
+#define MODE_UPSERT 2
+#define MODE_SELECT 3
+#define MODE_UPDATE 4
+#define MODE_DELETE 5
+#define MODE_QUERY 6
+#define MODE_COUNT 7
+#define MODE_ALL (-1)
+
+/* Mode names */
+static const char *azMode[] = {
+ "--insert",
+ "--replace",
+ "--upsert",
+ "--select",
+ "--update",
+ "--delete",
+ "--query"
+};
+
+/*
+** Determine if another iteration of the test is required. Return true
+** if so. Return zero if all iterations have finished.
+*/
+static int allLoop(
+ int iMode, /* The selected test mode */
+ int *piLoopCnt, /* Iteration loop counter */
+ int *piMode2, /* The test mode to use on the next iteration */
+ int *pUseWithoutRowid /* Whether or not to use --without-rowid */
+){
+ int i;
+ if( iMode!=MODE_ALL ){
+ if( *piLoopCnt ) return 0;
+ *piMode2 = iMode;
+ *piLoopCnt = 1;
+ return 1;
+ }
+ if( (*piLoopCnt)>=MODE_COUNT*2 ) return 0;
+ i = (*piLoopCnt)++;
+ *pUseWithoutRowid = i&1;
+ *piMode2 = i>>1;
+ return 1;
+}
+
+int main(int argc, char **argv){
+ const char *zFileToRead = 0; /* Input file. NULL for stdin */
+ const char *zDbName = 0; /* Name of the database file to create */
+ int useWithoutRowid = 0; /* True for --without-rowid */
+ int iMode = MODE_INSERT; /* One of MODE_xxxxx */
+ int iMode2; /* Mode to use for current --all iteration */
+ int iLoopCnt = 0; /* Which iteration when running --all */
+ int useNocase = 0; /* True for --nocase */
+ int doTrace = 0; /* True for --trace */
+ int showStats = 0; /* True for --stats */
+ int showSummary = 0; /* True for --summary */
+ int showTimer = 0; /* True for --timer */
+ int cacheSize = 0; /* Desired cache size. 0 means default */
+ int pageSize = 0; /* Desired page size. 0 means default */
+ int commitInterval = 0; /* How often to commit. 0 means never */
+ int noSync = 0; /* True for --nosync */
+ const char *zJMode = 0; /* Journal mode */
+ int nOp = 0; /* Operation counter */
+ int i, j; /* Loop counters */
+ sqlite3 *db; /* The SQLite database connection */
+ char *zSql; /* Constructed SQL statement */
+ sqlite3_stmt *pInsert = 0; /* The INSERT statement */
+ sqlite3_stmt *pUpdate = 0; /* The UPDATE statement */
+ sqlite3_stmt *pSelect = 0; /* The SELECT statement */
+ sqlite3_stmt *pDelete = 0; /* The DELETE statement */
+ FILE *in; /* The open input file */
+ int rc; /* Return code from an SQLite interface */
+ int iCur, iHiwtr; /* Statistics values, current and "highwater" */
+ FILE *pTimer = stderr; /* Output channel for the timer */
+ sqlite3_int64 sumCnt = 0; /* Sum in QUERY mode */
+ sqlite3_int64 startTime; /* Time of start */
+ sqlite3_int64 totalTime = 0; /* Total time */
+ char zInput[2000]; /* A single line of input */
+
+ /* Process command-line arguments */
+ for(i=1; i<argc; i++){
+ const char *z = argv[i];
+ if( z[0]=='-' ){
+ do{ z++; }while( z[0]=='-' );
+ if( strcmp(z,"without-rowid")==0 ){
+ useWithoutRowid = 1;
+ }else if( strcmp(z,"replace")==0 ){
+ iMode = MODE_REPLACE;
+ }else if( strcmp(z,"upsert")==0 ){
+ iMode = MODE_UPSERT;
+ }else if( strcmp(z,"select")==0 ){
+ iMode = MODE_SELECT;
+ }else if( strcmp(z,"insert")==0 ){
+ iMode = MODE_INSERT;
+ }else if( strcmp(z,"update")==0 ){
+ iMode = MODE_UPDATE;
+ }else if( strcmp(z,"delete")==0 ){
+ iMode = MODE_DELETE;
+ }else if( strcmp(z,"query")==0 ){
+ iMode = MODE_QUERY;
+ }else if( strcmp(z,"all")==0 ){
+ iMode = MODE_ALL;
+ showTimer = -99;
+ }else if( strcmp(z,"nocase")==0 ){
+ useNocase = 1;
+ }else if( strcmp(z,"trace")==0 ){
+ doTrace = 1;
+ }else if( strcmp(z,"nosync")==0 ){
+ noSync = 1;
+ }else if( strcmp(z,"stats")==0 ){
+ showStats = 1;
+ }else if( strcmp(z,"summary")==0 ){
+ showSummary = 1;
+ }else if( strcmp(z,"timer")==0 ){
+ showTimer = i;
+ }else if( strcmp(z,"cachesize")==0 && i<argc-1 ){
+ i++;
+ cacheSize = atoi(argv[i]);
+ }else if( strcmp(z,"pagesize")==0 && i<argc-1 ){
+ i++;
+ pageSize = atoi(argv[i]);
+ }else if( strcmp(z,"commit")==0 && i<argc-1 ){
+ i++;
+ commitInterval = atoi(argv[i]);
+ }else if( strcmp(z,"journal")==0 && i<argc-1 ){
+ zJMode = argv[++i];
+ }else if( strcmp(z,"tag")==0 && i<argc-1 ){
+ zTag = argv[++i];
+ pTimer = stdout;
+ }else if( strcmp(z, "help")==0 || strcmp(z,"?")==0 ){
+ usage();
+ }else{
+ fatal_error("unknown option: \"%s\"\n"
+ "Use --help for a list of options\n",
+ argv[i]);
+ }
+ }else if( zDbName==0 ){
+ zDbName = argv[i];
+ }else if( zFileToRead==0 ){
+ zFileToRead = argv[i];
+ }else{
+ fatal_error("surplus argument: \"%s\"\n", argv[i]);
+ }
+ }
+ if( zDbName==0 ){
+ usage();
+ }
+ startTime = realTime();
+
+ /* Open the database and the input file */
+ if( zDbName[0] && strcmp(zDbName,":memory:")!=0 ){
+ unlink(zDbName);
+ }
+ if( sqlite3_open(zDbName, &db) ){
+ fatal_error("Cannot open database file: %s\n", zDbName);
+ }
+ if( zFileToRead ){
+ in = fopen(zFileToRead, "rb");
+ if( in==0 ){
+ fatal_error("Could not open input file \"%s\"\n", zFileToRead);
+ }
+ }else{
+ if( iMode==MODE_ALL ){
+ fatal_error("The --all mode cannot be used with stdin\n");
+ }
+ in = stdin;
+ }
+
+ /* Set database connection options */
+ if( doTrace ) sqlite3_trace(db, traceCallback, 0);
+ if( pageSize ){
+ zSql = sqlite3_mprintf("PRAGMA page_size=%d", pageSize);
+ sqlite3_exec(db, zSql, 0, 0, 0);
+ sqlite3_free(zSql);
+ }
+ if( cacheSize ){
+ zSql = sqlite3_mprintf("PRAGMA cache_size=%d", cacheSize);
+ sqlite3_exec(db, zSql, 0, 0, 0);
+ sqlite3_free(zSql);
+ }
+ if( noSync ) sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0);
+ if( zJMode ){
+ zSql = sqlite3_mprintf("PRAGMA journal_mode=%s", zJMode);
+ sqlite3_exec(db, zSql, 0, 0, 0);
+ sqlite3_free(zSql);
+ }
+
+ iLoopCnt = 0;
+ while( allLoop(iMode, &iLoopCnt, &iMode2, &useWithoutRowid) ){
+ /* Delete prior content in --all mode */
+ if( iMode==MODE_ALL ){
+ if( sqlite3_exec(db, "DROP TABLE IF EXISTS wordcount; VACUUM;",0,0,0) ){
+ fatal_error("Could not clean up prior iteration\n");
+ }
+ startTime = realTime();
+ rewind(in);
+ }
+
+ /* Construct the "wordcount" table into which to put the words */
+ if( sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, 0) ){
+ fatal_error("Could not start a transaction\n");
+ }
+ zSql = sqlite3_mprintf(
+ "CREATE TABLE IF NOT EXISTS wordcount(\n"
+ " word TEXT PRIMARY KEY COLLATE %s,\n"
+ " cnt INTEGER\n"
+ ")%s",
+ useNocase ? "nocase" : "binary",
+ useWithoutRowid ? " WITHOUT ROWID" : ""
+ );
+ if( zSql==0 ) fatal_error("out of memory\n");
+ rc = sqlite3_exec(db, zSql, 0, 0, 0);
+ if( rc ) fatal_error("Could not create the wordcount table: %s.\n",
+ sqlite3_errmsg(db));
+ sqlite3_free(zSql);
+
+ /* Prepare SQL statements that will be needed */
+ if( iMode2==MODE_QUERY ){
+ rc = sqlite3_prepare_v2(db,
+ "SELECT cnt FROM wordcount WHERE word=?1",
+ -1, &pSelect, 0);
+ if( rc ) fatal_error("Could not prepare the SELECT statement: %s\n",
+ sqlite3_errmsg(db));
+ }
+ if( iMode2==MODE_SELECT ){
+ rc = sqlite3_prepare_v2(db,
+ "SELECT 1 FROM wordcount WHERE word=?1",
+ -1, &pSelect, 0);
+ if( rc ) fatal_error("Could not prepare the SELECT statement: %s\n",
+ sqlite3_errmsg(db));
+ rc = sqlite3_prepare_v2(db,
+ "INSERT INTO wordcount(word,cnt) VALUES(?1,1)",
+ -1, &pInsert, 0);
+ if( rc ) fatal_error("Could not prepare the INSERT statement: %s\n",
+ sqlite3_errmsg(db));
+ }
+ if( iMode2==MODE_SELECT || iMode2==MODE_UPDATE || iMode2==MODE_INSERT ){
+ rc = sqlite3_prepare_v2(db,
+ "UPDATE wordcount SET cnt=cnt+1 WHERE word=?1",
+ -1, &pUpdate, 0);
+ if( rc ) fatal_error("Could not prepare the UPDATE statement: %s\n",
+ sqlite3_errmsg(db));
+ }
+ if( iMode2==MODE_INSERT ){
+ rc = sqlite3_prepare_v2(db,
+ "INSERT OR IGNORE INTO wordcount(word,cnt) VALUES(?1,1)",
+ -1, &pInsert, 0);
+ if( rc ) fatal_error("Could not prepare the INSERT statement: %s\n",
+ sqlite3_errmsg(db));
+ }
+ if( iMode2==MODE_UPDATE ){
+ rc = sqlite3_prepare_v2(db,
+ "INSERT OR IGNORE INTO wordcount(word,cnt) VALUES(?1,0)",
+ -1, &pInsert, 0);
+ if( rc ) fatal_error("Could not prepare the INSERT statement: %s\n",
+ sqlite3_errmsg(db));
+ }
+ if( iMode2==MODE_REPLACE ){
+ rc = sqlite3_prepare_v2(db,
+ "REPLACE INTO wordcount(word,cnt)"
+ "VALUES(?1,coalesce((SELECT cnt FROM wordcount WHERE word=?1),0)+1)",
+ -1, &pInsert, 0);
+ if( rc ) fatal_error("Could not prepare the REPLACE statement: %s\n",
+ sqlite3_errmsg(db));
+ }
+ if( iMode2==MODE_UPSERT ){
+ rc = sqlite3_prepare_v2(db,
+ "INSERT INTO wordcount(word,cnt) VALUES(?1,1) "
+ "ON CONFLICT(word) DO UPDATE SET cnt=cnt+1",
+ -1, &pInsert, 0);
+ if( rc ) fatal_error("Could not prepare the UPSERT statement: %s\n",
+ sqlite3_errmsg(db));
+ }
+ if( iMode2==MODE_DELETE ){
+ rc = sqlite3_prepare_v2(db,
+ "DELETE FROM wordcount WHERE word=?1",
+ -1, &pDelete, 0);
+ if( rc ) fatal_error("Could not prepare the DELETE statement: %s\n",
+ sqlite3_errmsg(db));
+ }
+
+ /* Process the input file */
+ while( fgets(zInput, sizeof(zInput), in) ){
+ for(i=0; zInput[i]; i++){
+ if( !ISALPHA(zInput[i]) ) continue;
+ for(j=i+1; ISALPHA(zInput[j]); j++){}
+
+ /* Found a new word at zInput[i] that is j-i bytes long.
+ ** Process it into the wordcount table. */
+ if( iMode2==MODE_DELETE ){
+ sqlite3_bind_text(pDelete, 1, zInput+i, j-i, SQLITE_STATIC);
+ if( sqlite3_step(pDelete)!=SQLITE_DONE ){
+ fatal_error("DELETE failed: %s\n", sqlite3_errmsg(db));
+ }
+ sqlite3_reset(pDelete);
+ }else if( iMode2==MODE_SELECT ){
+ sqlite3_bind_text(pSelect, 1, zInput+i, j-i, SQLITE_STATIC);
+ rc = sqlite3_step(pSelect);
+ sqlite3_reset(pSelect);
+ if( rc==SQLITE_ROW ){
+ sqlite3_bind_text(pUpdate, 1, zInput+i, j-i, SQLITE_STATIC);
+ if( sqlite3_step(pUpdate)!=SQLITE_DONE ){
+ fatal_error("UPDATE failed: %s\n", sqlite3_errmsg(db));
+ }
+ sqlite3_reset(pUpdate);
+ }else if( rc==SQLITE_DONE ){
+ sqlite3_bind_text(pInsert, 1, zInput+i, j-i, SQLITE_STATIC);
+ if( sqlite3_step(pInsert)!=SQLITE_DONE ){
+ fatal_error("Insert failed: %s\n", sqlite3_errmsg(db));
+ }
+ sqlite3_reset(pInsert);
+ }else{
+ fatal_error("SELECT failed: %s\n", sqlite3_errmsg(db));
+ }
+ }else if( iMode2==MODE_QUERY ){
+ sqlite3_bind_text(pSelect, 1, zInput+i, j-i, SQLITE_STATIC);
+ if( sqlite3_step(pSelect)==SQLITE_ROW ){
+ sumCnt += sqlite3_column_int64(pSelect, 0);
+ }
+ sqlite3_reset(pSelect);
+ }else{
+ sqlite3_bind_text(pInsert, 1, zInput+i, j-i, SQLITE_STATIC);
+ if( sqlite3_step(pInsert)!=SQLITE_DONE ){
+ fatal_error("INSERT failed: %s\n", sqlite3_errmsg(db));
+ }
+ sqlite3_reset(pInsert);
+ if( iMode2==MODE_UPDATE
+ || (iMode2==MODE_INSERT && sqlite3_changes(db)==0)
+ ){
+ sqlite3_bind_text(pUpdate, 1, zInput+i, j-i, SQLITE_STATIC);
+ if( sqlite3_step(pUpdate)!=SQLITE_DONE ){
+ fatal_error("UPDATE failed: %s\n", sqlite3_errmsg(db));
+ }
+ sqlite3_reset(pUpdate);
+ }
+ }
+ i = j-1;
+
+ /* Increment the operation counter. Do a COMMIT if it is time. */
+ nOp++;
+ if( commitInterval>0 && (nOp%commitInterval)==0 ){
+ sqlite3_exec(db, "COMMIT; BEGIN IMMEDIATE", 0, 0, 0);
+ }
+ }
+ }
+ sqlite3_exec(db, "COMMIT", 0, 0, 0);
+ sqlite3_finalize(pInsert); pInsert = 0;
+ sqlite3_finalize(pUpdate); pUpdate = 0;
+ sqlite3_finalize(pSelect); pSelect = 0;
+ sqlite3_finalize(pDelete); pDelete = 0;
+
+ if( iMode2==MODE_QUERY && iMode!=MODE_ALL ){
+ printf("%s sum of cnt: %lld\n", zTag, sumCnt);
+ rc = sqlite3_prepare_v2(db,"SELECT sum(cnt*cnt) FROM wordcount", -1,
+ &pSelect, 0);
+ if( rc==SQLITE_OK && sqlite3_step(pSelect)==SQLITE_ROW ){
+ printf("%s double-check: %lld\n", zTag,sqlite3_column_int64(pSelect,0));
+ }
+ sqlite3_finalize(pSelect);
+ }
+
+
+ if( showTimer ){
+ sqlite3_int64 elapseTime = realTime() - startTime;
+ totalTime += elapseTime;
+ fprintf(pTimer, "%3d.%03d wordcount", (int)(elapseTime/1000),
+ (int)(elapseTime%1000));
+ if( iMode==MODE_ALL ){
+ fprintf(pTimer, " %s%s\n", azMode[iMode2],
+ useWithoutRowid? " --without-rowid" : "");
+ }else{
+ for(i=1; i<argc; i++) if( i!=showTimer ) fprintf(pTimer," %s",argv[i]);
+ fprintf(pTimer, "\n");
+ }
+ }
+
+ if( showSummary ){
+ sqlite3_create_function(db, "checksum", -1, SQLITE_UTF8, 0,
+ 0, checksumStep, checksumFinalize);
+ sqlite3_exec(db,
+ "SELECT 'count(*): ', count(*) FROM wordcount;\n"
+ "SELECT 'sum(cnt): ', sum(cnt) FROM wordcount;\n"
+ "SELECT 'max(cnt): ', max(cnt) FROM wordcount;\n"
+ "SELECT 'avg(cnt): ', avg(cnt) FROM wordcount;\n"
+ "SELECT 'sum(cnt=1):', sum(cnt=1) FROM wordcount;\n"
+ "SELECT 'top 10: ', group_concat(word, ', ') FROM "
+ "(SELECT word FROM wordcount ORDER BY cnt DESC, word LIMIT 10);\n"
+ "SELECT 'checksum: ', checksum(word, cnt) FROM "
+ "(SELECT word, cnt FROM wordcount ORDER BY word);\n"
+ "PRAGMA integrity_check;\n",
+ printResult, 0, 0);
+ }
+ } /* End the --all loop */
+
+ /* Close the input file after the last read */
+ if( zFileToRead ) fclose(in);
+
+ /* In --all mode, so the total time */
+ if( iMode==MODE_ALL && showTimer ){
+ fprintf(pTimer, "%3d.%03d wordcount --all\n", (int)(totalTime/1000),
+ (int)(totalTime%1000));
+ }
+
+ /* Database connection statistics printed after both prepared statements
+ ** have been finalized */
+ if( showStats ){
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, 0);
+ printf("%s Lookaside Slots Used: %d (max %d)\n", zTag, iCur,iHiwtr);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, 0);
+ printf("%s Successful lookasides: %d\n", zTag, iHiwtr);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur,&iHiwtr,0);
+ printf("%s Lookaside size faults: %d\n", zTag, iHiwtr);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur,&iHiwtr,0);
+ printf("%s Lookaside OOM faults: %d\n", zTag, iHiwtr);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, 0);
+ printf("%s Pager Heap Usage: %d bytes\n", zTag, iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
+ printf("%s Page cache hits: %d\n", zTag, iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
+ printf("%s Page cache misses: %d\n", zTag, iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
+ printf("%s Page cache writes: %d\n", zTag, iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, 0);
+ printf("%s Schema Heap Usage: %d bytes\n", zTag, iCur);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, 0);
+ printf("%s Statement Heap Usage: %d bytes\n", zTag, iCur);
+ }
+
+ sqlite3_close(db);
+
+ /* Global memory usage statistics printed after the database connection
+ ** has closed. Memory usage should be zero at this point. */
+ if( showStats ){
+ sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, 0);
+ printf("%s Memory Used (bytes): %d (max %d)\n", zTag,iCur,iHiwtr);
+ sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, 0);
+ printf("%s Outstanding Allocations: %d (max %d)\n",zTag,iCur,iHiwtr);
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, 0);
+ printf("%s Pcache Overflow Bytes: %d (max %d)\n",zTag,iCur,iHiwtr);
+ sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, 0);
+ printf("%s Largest Allocation: %d bytes\n",zTag,iHiwtr);
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, 0);
+ printf("%s Largest Pcache Allocation: %d bytes\n",zTag,iHiwtr);
+ }
+ return 0;
+}
diff --git a/test/writecrash.test b/test/writecrash.test
new file mode 100644
index 0000000..01bc4db
--- /dev/null
+++ b/test/writecrash.test
@@ -0,0 +1,68 @@
+# 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.
+#
+#***********************************************************************
+#
+# Test the outcome of a writer crashing within a call to the VFS
+# xWrite function.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix writecrash
+
+do_not_use_codec
+
+
+if {$tcl_platform(platform)=="windows"} {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE);
+ WITH s(i) AS (
+ VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100
+ )
+ INSERT INTO t1 SELECT NULL, randomblob(900) FROM s;
+} {}
+
+set bGo 1
+for {set tn 1} {$bGo} {incr tn} {
+
+db close
+sqlite3 db test.db
+
+ do_test 1.$tn.1 {
+ set res [crash_on_write $tn {
+ UPDATE t1 SET b = randomblob(899) WHERE (a%3)==0
+ }]
+ set bGo 0
+ if {[string match {1 {child killed:*}} $res]} {
+ set res {0 {}}
+ set bGo 1
+ }
+ set res
+ } {0 {}}
+
+#db close
+#sqlite3 db test.db
+
+ do_execsql_test 1.$tn.2 { PRAGMA integrity_check } {ok}
+
+db close
+sqlite3 db test.db
+
+ do_execsql_test 1.$tn.3 { PRAGMA integrity_check } {ok}
+}
+
+
+
+finish_test
diff --git a/test/zeroblob.test b/test/zeroblob.test
new file mode 100644
index 0000000..df234ee
--- /dev/null
+++ b/test/zeroblob.test
@@ -0,0 +1,343 @@
+# 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
+set testprefix zeroblob
+
+# ifcapable !incrblob { finish_test return }
+
+test_set_config_pagecache 0 0
+
+# 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));
+ }
+} {}
+
+ifcapable incrblob {
+ do_test zeroblob-1.1.1 {
+ set ::sqlite3_max_blobsize
+ } {10}
+ do_test zeroblob-1.1.2 {
+ expr {[sqlite3_memory_highwater]<$::memused+35000}
+ } {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));
+ }
+} {}
+ifcapable incrblob {
+ do_test zeroblob-1.5.1 {
+ 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));
+ }
+} {}
+ifcapable incrblob {
+ do_test zeroblob-1.7.1 {
+ 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}
+ifcapable incrblob {
+ 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}
+
+# Oversized zeroblob records
+#
+do_test zeroblob-10.1 {
+ db eval {
+ CREATE TABLE t10(a,b,c);
+ }
+ catchsql {INSERT INTO t10 VALUES(zeroblob(1e9),zeroblob(1e9),zeroblob(1e9))}
+} {1 {string or blob too big}}
+
+#-------------------------------------------------------------------------
+# Test the zeroblob() function on its own with negative or oversized
+# arguments.
+#
+do_execsql_test 11.0 {
+ SELECT length(zeroblob(-1444444444444444));
+} {0}
+do_catchsql_test 11.1 {
+ SELECT zeroblob(5000 * 1024 * 1024);
+} {1 {string or blob too big}}
+do_catchsql_test 11.2 {
+ SELECT quote(zeroblob(5000 * 1024 * 1024));
+} {1 {string or blob too big}}
+do_catchsql_test 11.3 {
+ SELECT quote(zeroblob(-1444444444444444));
+} {0 X''}
+do_catchsql_test 11.4 {
+ SELECT quote(test_zeroblob(-1));
+} {0 X''}
+
+#-------------------------------------------------------------------------
+# Test the sqlite3_bind_zeroblob64() API.
+#
+proc bind_and_run {stmt nZero} {
+ sqlite3_bind_zeroblob64 $stmt 1 $nZero
+ sqlite3_step $stmt
+ set ret [sqlite3_column_int $stmt 0]
+ sqlite3_reset $stmt
+ set ret
+}
+set stmt [sqlite3_prepare db "SELECT length(?)" -1 dummy]
+
+do_test 12.1 { bind_and_run $stmt 40 } 40
+do_test 12.2 { bind_and_run $stmt 0 } 0
+do_test 12.3 { bind_and_run $stmt 1000 } 1000
+
+do_test 12.4 {
+ list [catch { bind_and_run $stmt [expr 5000 * 1024 * 1024] } msg] $msg
+} {1 SQLITE_TOOBIG}
+do_test 12.5 {
+ sqlite3_step $stmt
+ set ret [sqlite3_column_int $stmt 0]
+ sqlite3_reset $stmt
+ set ret
+} {1000}
+
+sqlite3_finalize $stmt
+
+# 2019-01-25 https://sqlite.org/src/tktview/bb4bdb9f7f654b0bb9f34cfbac
+# Zeroblob truncated by an index on expression
+#
+do_execsql_test 13.100 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b,c);
+ CREATE INDEX t1bbc ON t1(b, b+c);
+ INSERT INTO t1(a,b,c) VALUES(1,zeroblob(8),3);
+ SELECT a, quote(b), length(b), c FROM t1;
+} {1 X'0000000000000000' 8 3}
+
+test_restore_config_pagecache
+finish_test
diff --git a/test/zeroblobfault.test b/test/zeroblobfault.test
new file mode 100644
index 0000000..0ae5bea
--- /dev/null
+++ b/test/zeroblobfault.test
@@ -0,0 +1,28 @@
+# 2021 November 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.
+#
+#***********************************************************************
+#
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set testprefix zeroblobfault
+set quoted_res [db one { SELECT quote(zeroblob(2000)) }]
+
+do_faultsim_test 1 -prep {
+ sqlite3 db test.db
+} -body {
+ execsql { SELECT quote(zeroblob(2000)) }
+} -test {
+ faultsim_test_result [list 0 $::quoted_res]
+}
+
+finish_test
diff --git a/test/zerodamage.test b/test/zerodamage.test
new file mode 100644
index 0000000..83bae73
--- /dev/null
+++ b/test/zerodamage.test
@@ -0,0 +1,122 @@
+# 2011 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 tests of the SQLITE_IOCAP_POWERSAFE_OVERWRITE property
+# and the SQLITE_FCNTL_POWERSAFE_OVERWRITE file-control for manipulating it.
+#
+# The name of this file comes from the fact that we used to call the
+# POWERSAFE_OVERWRITE property ZERO_DAMAGE.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix zerodamage
+
+ifcapable !vtab {
+ finish_test
+ return
+}
+
+# POWERSAFE_OVERWRITE defaults to true
+#
+do_test zerodamage-1.0 {
+ file_control_powersafe_overwrite db -1
+} {0 1}
+
+# Check the ability to turn zero-damage on and off.
+#
+do_test zerodamage-1.1 {
+ file_control_powersafe_overwrite db 0
+ file_control_powersafe_overwrite db -1
+} {0 0}
+do_test zerodamage-1.2 {
+ file_control_powersafe_overwrite db 1
+ file_control_powersafe_overwrite db -1
+} {0 1}
+
+# Run a transaction with zero-damage on, a small page size and a much larger
+# sectorsize. Verify that the maximum journal size is small - that the
+# rollback journal is not being padded.
+#
+do_test zerodamage-2.0 {
+ db close
+ testvfs tv -default 1
+ tv sectorsize 8192
+ sqlite3 db file:test.db?psow=TRUE -uri 1
+ unset -nocomplain ::max_journal_size
+ set ::max_journal_size 0
+ proc xDeleteCallback {method file args} {
+ set sz [file size $file]
+ if {$sz>$::max_journal_size} {set ::max_journal_size $sz}
+ }
+ tv filter xDelete
+ tv script xDeleteCallback
+ load_static_extension db wholenumber
+ db eval {
+ PRAGMA page_size=1024;
+ PRAGMA journal_mode=DELETE;
+ PRAGMA cache_size=5;
+ CREATE VIRTUAL TABLE nums USING wholenumber;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 SELECT value, randomblob(100) FROM nums
+ WHERE value BETWEEN 1 AND 400;
+ }
+ set ::max_journal_size 0
+ db eval {
+ UPDATE t1 SET y=randomblob(50) WHERE x=123;
+ }
+ concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size]
+} [list 0 1 [expr ([atomic_batch_write test.db]==0)*2576]]
+
+# Repeat the previous step with zero-damage turned off. This time the
+# maximum rollback journal size should be much larger.
+#
+do_test zerodamage-2.1 {
+ set ::max_journal_size 0
+ db close
+ sqlite3 db file:test.db?psow=FALSE -uri 1
+ db eval {
+ UPDATE t1 SET y=randomblob(50) WHERE x=124;
+ }
+ concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size]
+} [list 0 0 [expr ([atomic_batch_write test.db]==0)*24704]]
+
+if {[wal_is_capable]} {
+ # Run a WAL-mode transaction with POWERSAFE_OVERWRITE on to verify that the
+ # WAL file does not get too big.
+ #
+ do_test zerodamage-3.0 {
+ db eval {
+ PRAGMA journal_mode=WAL;
+ }
+ db close
+ sqlite3 db file:test.db?psow=TRUE -uri 1
+ db eval {
+ UPDATE t1 SET y=randomblob(50) WHERE x=124;
+ }
+ file size test.db-wal
+ } {1080}
+
+ # Repeat the previous with POWERSAFE_OVERWRITE off. Verify that the WAL file
+ # is padded.
+ #
+ do_test zerodamage-3.1 {
+ db close
+ sqlite3 db file:test.db?psow=FALSE -uri 1
+ db eval {
+ PRAGMA synchronous=FULL;
+ UPDATE t1 SET y=randomblob(50) WHERE x=124;
+ }
+ file size test.db-wal
+ } {16800}
+}
+
+finish_test
diff --git a/test/zipfile.test b/test/zipfile.test
new file mode 100644
index 0000000..8749f17
--- /dev/null
+++ b/test/zipfile.test
@@ -0,0 +1,858 @@
+# 2017 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.
+#
+#***********************************************************************
+#
+
+package require Tcl 8.6
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix zipfile
+
+ifcapable !vtab {
+ finish_test; return
+}
+if {[catch {load_static_extension db zipfile} error]} {
+ puts "Skipping zipfile tests, hit load error: $error"
+ finish_test; return
+}
+if {[catch {load_static_extension db fileio} error]} {
+ puts "Skipping zipfile tests, hit load error: $error"
+ finish_test; return
+}
+
+proc readfile {f} {
+ set fd [open $f]
+ fconfigure $fd -translation binary -encoding binary
+ set data [read $fd]
+ close $fd
+ set data
+}
+
+unset -nocomplain ::UNZIP
+
+if {[catch {exec unzip} msg]==0 && \
+ [regexp -line {^UnZip \d+\.\d+ .*? Info-ZIP\.} $msg]} {
+ set ::UNZIP unzip
+ proc fix_stat_mode {name mode} {
+ if {$::tcl_platform(platform)=="windows"} {
+ #
+ # NOTE: Set or unset the write bits of the file permissions
+ # based on the read-only attribute because the Win32
+ # version of UnZip does this.
+ #
+ set writebits 0x12; # 0o22
+ set result $mode
+ if {[file attributes $name -readonly]} {
+ set result [expr {$result | $writebits}]
+ } else {
+ set result [expr {$result & ~$writebits}]
+ }
+ return $result
+ } else {
+ return $mode
+ }
+ }
+ proc do_unzip {file} {
+ forcedelete test_unzip
+ file mkdir test_unzip
+ exec $::UNZIP -d test_unzip $file
+
+ db func modefix fix_stat_mode
+
+ set res [db eval {
+ SELECT replace(name,'test_unzip/',''),modefix(name,mode),mtime,data
+ FROM fsdir('test_unzip')
+ WHERE name!='test_unzip'
+ ORDER BY name
+ }]
+ set res
+ }
+}
+
+
+# The argument is a blob (not a hex string) containing a zip archive.
+# This proc removes the extended timestamp fields from the archive
+# and returns the result.
+#
+proc remove_timestamps {blob} {
+ set hex [binary encode hex $blob]
+ set hex [string map {55540500 00000500} $hex]
+ binary decode hex $hex
+}
+
+
+# Argument $file is the name of a zip archive on disk. This function
+# executes test cases to check that the results of each of the following
+# are the same:
+#
+# SELECT * FROM zipfile($file)
+# SELECT * FROM zipfile( readfile($file) )
+# SELECT * FROM zipfile(
+# (SELECT zipfile(name,mode,mtime,data,method) FROM zipfile($file))
+# )
+#
+proc do_zipfile_blob_test {tn file} {
+
+ db func r readfile
+ set q1 {SELECT name,mode,mtime,method,quote(data) FROM zipfile($file)}
+ set q2 {SELECT name,mode,mtime,method,quote(data) FROM zipfile( r($file) )}
+ set q3 {SELECT name,mode,mtime,method,quote(data) FROM zipfile(
+ ( SELECT zipfile(name,mode,mtime,data,method) FROM zipfile($file) )
+ )}
+
+
+ set r1 [db eval $q1]
+ set r2 [db eval $q2]
+ set r3 [db eval $q3]
+ #puts $r1
+ #puts $r2
+ #puts $r3
+
+ uplevel [list do_test $tn.1 [list set {} $r2] $r1]
+ uplevel [list do_test $tn.2 [list set {} $r3] $r1]
+}
+
+# Argument $file is a zip file on disk. This command runs tests to:
+#
+# 1. Unpack the archive with unix command [unzip] and compare the
+# results to reading the same archive using the zipfile() table
+# valued function.
+#
+# 2. Creates a new archive with the same contents using the zipfile()
+# aggregate function as follows:
+#
+# SELECT writefile('test_unzip.zip',
+# ( SELECT zipfile(name,mode,mtime,data,method) FROM zipfile($file) )
+# );
+#
+# Then tests that unpacking the new archive using [unzip] produces
+# the same results as in (1).
+#
+proc do_unzip_test {tn file} {
+ db func sss strip_slash
+
+ db eval {
+ SELECT writefile('test_unzip.zip',
+ ( SELECT zipfile(name,mode,mtime,data,method) FROM zipfile($file) )
+ );
+ }
+
+ set r1 [db eval {
+ SELECT sss(name),mode,mtime,data FROM zipfile($file) ORDER BY name
+ }]
+ set r2 [do_unzip $file]
+ set r3 [do_unzip test_unzip.zip]
+
+ uplevel [list do_test $tn.1 [list set {} $r2] $r1]
+ uplevel [list do_test $tn.2 [list set {} $r3] $r1]
+}
+proc strip_slash {in} { regsub {/$} $in {} }
+
+proc do_zip_tests {tn file} {
+ uplevel do_zipfile_blob_test $tn.1 $file
+ if {[info exists ::UNZIP]} {
+ uplevel do_unzip_test $tn.2 $file
+ }
+}
+
+forcedelete test.zip
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE temp.zz USING zipfile('test.zip');
+ PRAGMA table_info(zz);
+} {
+ 0 name {} 1 {} 1
+ 1 mode {} 0 {} 0
+ 2 mtime {} 0 {} 0
+ 3 sz {} 0 {} 0
+ 4 rawdata {} 0 {} 0
+ 5 data {} 0 {} 0
+ 6 method {} 0 {} 0
+}
+
+do_catchsql_test 1.1.0.1 {
+ INSERT INTO zz(name, mode, mtime, sz, rawdata, method)
+ VALUES('f.txt', '-rw-r--r--', 1000000000, 5, 'abcde', 0);
+} {1 {rawdata must be NULL}}
+do_catchsql_test 1.1.0.2 {
+ INSERT INTO zz(name, mtime, sz, data, method)
+ VALUES('g.txt', 1000000002, 5, '12345', 0);
+} {1 {sz must be NULL}}
+do_catchsql_test 1.1.0.3 {
+ INSERT INTO zz(name, mtime, rawdata, method)
+ VALUES('g.txt', 1000000002, '12345', 0);
+} {1 {rawdata must be NULL}}
+do_catchsql_test 1.1.0.4 {
+ INSERT INTO zz(name, data, method)
+ VALUES('g.txt', '12345', 7);
+} {1 {unknown compression method: 7}}
+
+do_execsql_test 1.1.1 {
+ INSERT INTO zz(name, mode, mtime, data, method)
+ VALUES('f.txt', '-rw-r--r--', 1000000000, 'abcde', 0);
+}
+do_execsql_test 1.1.2 {
+ INSERT INTO zz(name, mode, mtime, data, method)
+ VALUES('g.txt', NULL, 1000000002, '12345', 0);
+}
+
+do_execsql_test 1.2 {
+ SELECT name, mtime, data FROM zipfile('test.zip')
+} {
+ f.txt 1000000000 abcde
+ g.txt 1000000002 12345
+}
+do_zip_tests 1.2a test.zip
+
+do_execsql_test 1.3 {
+ INSERT INTO zz(name, mode, mtime, data) VALUES('h.txt',
+ '-rw-r--r--', 1000000004, 'aaaaaaaaaabbbbbbbbbb'
+ );
+}
+do_zip_tests 1.3a test.zip
+
+do_execsql_test 1.4 {
+ SELECT name, mtime, data, method FROM zipfile('test.zip');
+} {
+ f.txt 1000000000 abcde 0
+ g.txt 1000000002 12345 0
+ h.txt 1000000004 aaaaaaaaaabbbbbbbbbb 8
+}
+
+ifcapable json1 {
+ do_execsql_test 1.4.1 {
+ SELECT name, json_extract( zipfile_cds(z) , '$.crc32')!=0
+ FROM zipfile('test.zip');
+ } {
+ f.txt 1
+ g.txt 1
+ h.txt 1
+ }
+}
+do_catchsql_test 1.4.2 {
+ SELECT zipfile_cds(mode) FROM zipfile('test.zip');
+} {0 {{} {} {}}}
+
+do_execsql_test 1.5.1 {
+ BEGIN;
+ INSERT INTO zz(name, mode, mtime, data, method)
+ VALUES('i.txt', '-rw-r--r--', 1000000006, 'zxcvb', 0);
+ SELECT name FROM zz;
+ COMMIT;
+} {f.txt g.txt h.txt i.txt}
+do_execsql_test 1.5.2 {
+ SELECT name FROM zz;
+} {f.txt g.txt h.txt i.txt}
+do_execsql_test 1.5.3 {
+ SELECT data FROM zz WHERE name='i.txt';
+} {zxcvb}
+
+do_execsql_test 1.6.0 {
+ DELETE FROM zz WHERE name='g.txt';
+ SELECT name FROM zz;
+} {f.txt h.txt i.txt}
+
+do_execsql_test 1.6.1 {
+ SELECT name, mode, mtime, data, method FROM zipfile('test.zip');
+} {
+ f.txt 33188 1000000000 abcde 0
+ h.txt 33188 1000000004 aaaaaaaaaabbbbbbbbbb 8
+ i.txt 33188 1000000006 zxcvb 0
+}
+do_zip_tests 1.6.1a test.zip
+
+do_execsql_test 1.6.2 {
+ UPDATE zz SET mtime=4 WHERE name='i.txt';
+ SELECT name, mode, mtime, data, method FROM zipfile('test.zip');
+} {
+ f.txt 33188 1000000000 abcde 0
+ h.txt 33188 1000000004 aaaaaaaaaabbbbbbbbbb 8
+ i.txt 33188 4 zxcvb 0
+}
+
+if {$::tcl_platform(platform)=="unix"} {
+ set modes -rw-r--r-x
+ set perms 33189
+} else {
+ set modes -rw-r--r--; # no execute bits on Win32
+ set perms 33188
+}
+
+do_execsql_test 1.6.3 {
+ UPDATE zz SET mode=$modes WHERE name='h.txt';
+ SELECT name, mode, mtime, data, method FROM zipfile('test.zip');
+} [string map [list %perms% $perms] {
+ f.txt 33188 1000000000 abcde 0
+ h.txt %perms% 1000000004 aaaaaaaaaabbbbbbbbbb 8
+ i.txt 33188 4 zxcvb 0
+}]
+do_zip_tests 1.6.3a test.zip
+
+do_execsql_test 1.6.4 {
+ UPDATE zz SET name = 'blue.txt' WHERE name='f.txt';
+ SELECT name, mode, mtime, data, method FROM zipfile('test.zip');
+} [string map [list %perms% $perms] {
+ blue.txt 33188 1000000000 abcde 0
+ h.txt %perms% 1000000004 aaaaaaaaaabbbbbbbbbb 8
+ i.txt 33188 4 zxcvb 0
+}]
+do_zip_tests 1.6.4a test.zip
+
+do_execsql_test 1.6.5 {
+ UPDATE zz SET data = 'edcba' WHERE name='blue.txt';
+ SELECT name, mode, mtime, data, method FROM zipfile('test.zip');
+} [string map [list %perms% $perms] {
+ blue.txt 33188 1000000000 edcba 0
+ h.txt %perms% 1000000004 aaaaaaaaaabbbbbbbbbb 8
+ i.txt 33188 4 zxcvb 0
+}]
+
+do_execsql_test 1.6.6 {
+ UPDATE zz SET mode=NULL, data = NULL WHERE name='blue.txt';
+ SELECT name, mode, mtime, data, method FROM zipfile('test.zip');
+} [string map [list %perms% $perms] {
+ blue.txt/ 16877 1000000000 {} 0
+ h.txt %perms% 1000000004 aaaaaaaaaabbbbbbbbbb 8
+ i.txt 33188 4 zxcvb 0
+}]
+
+do_catchsql_test 1.6.7 {
+ UPDATE zz SET data=NULL WHERE name='i.txt'
+} {1 {zipfile: mode does not match data}}
+do_execsql_test 1.6.8 {
+ SELECT name, mode, mtime, data, method FROM zipfile('test.zip');
+} [string map [list %perms% $perms] {
+ blue.txt/ 16877 1000000000 {} 0
+ h.txt %perms% 1000000004 aaaaaaaaaabbbbbbbbbb 8
+ i.txt 33188 4 zxcvb 0
+}]
+
+do_execsql_test 1.6.9 {
+ UPDATE zz SET data = '' WHERE name='i.txt';
+ SELECT name,mode,mtime,data,method from zipfile('test.zip');
+} [string map [list %perms% $perms] {
+ blue.txt/ 16877 1000000000 {} 0
+ h.txt %perms% 1000000004 aaaaaaaaaabbbbbbbbbb 8
+ i.txt 33188 4 {} 0
+}]
+
+do_execsql_test 1.6.10 {
+ SELECT a.name, a.data
+ FROM zz AS a, zz AS b
+ WHERE a.name=+b.name AND +a.mode=b.mode
+} {
+ blue.txt/ {}
+ h.txt aaaaaaaaaabbbbbbbbbb
+ i.txt {}
+}
+
+do_execsql_test 1.6.11 {
+ SELECT name, data FROM zz WHERE name LIKE '%txt'
+} {
+ h.txt aaaaaaaaaabbbbbbbbbb
+ i.txt {}
+}
+
+do_execsql_test 1.7 {
+ DELETE FROM zz;
+ SELECT * FROM zz;
+} {}
+
+#-------------------------------------------------------------------------
+db close
+forcedelete test.zip
+reset_db
+load_static_extension db fileio
+load_static_extension db zipfile
+do_execsql_test 2.1 {
+ CREATE VIRTUAL TABLE zzz USING zipfile('test.zip');
+ INSERT INTO zzz(name, mode) VALUES('dirname', 'drwxr-xr-x');
+ SELECT name, mode, data FROM zzz;
+} {dirname/ 16877 {}}
+do_execsql_test 2.2 {
+ INSERT INTO zzz(name, data) VALUES('dirname2', NULL);
+ INSERT INTO zzz(name, data) VALUES('dirname2/file1.txt', 'abcdefghijklmnop');
+ SELECT name, mode, data FROM zzz;
+} {
+ dirname/ 16877 {}
+ dirname2/ 16877 {}
+ dirname2/file1.txt 33188 abcdefghijklmnop
+}
+
+do_catchsql_test 2.3 {
+ UPDATE zzz SET name = 'dirname3' WHERE name = 'dirname/';
+} {0 {}}
+do_execsql_test 2.4 {
+ SELECT name, mode, data FROM zzz;
+} {
+ dirname3/ 16877 {}
+ dirname2/ 16877 {}
+ dirname2/file1.txt 33188 abcdefghijklmnop
+}
+do_zip_tests 2.4a test.zip
+
+# Check that the [unzip] utility can unpack our archive.
+#
+if {[info exists ::UNZIP]} {
+ do_test 2.5.1 {
+ forcedelete dirname
+ forcedelete dirname2
+ if {$::tcl_platform(platform)=="unix"} {
+ set null /dev/null
+ } else {
+ set null NUL
+ }
+ set rc [catch { exec $::UNZIP test.zip > $null } msg]
+ list $rc $msg
+ } {0 {}}
+ do_test 2.5.2 { file isdir dirname3 } 1
+ do_test 2.5.3 { file isdir dirname2 } 1
+ do_test 2.5.4 { file isdir dirname2/file1.txt } 0
+ do_test 2.5.5 {
+ set fd [open dirname2/file1.txt]
+ set data [read $fd]
+ close $fd
+ set data
+ } {abcdefghijklmnop}
+}
+
+#-------------------------------------------------------------------------
+reset_db
+forcedelete test.zip
+load_static_extension db zipfile
+load_static_extension db fileio
+
+do_execsql_test 3.0 {
+ CREATE VIRTUAL TABLE temp.x1 USING zipfile('test.zip');
+ INSERT INTO x1(name, data) VALUES('dir1/', NULL);
+ INSERT INTO x1(name, data) VALUES('file1', '1234');
+ INSERT INTO x1(name, data) VALUES('dir1/file2', '5678');
+}
+foreach {tn fname} {
+ 1 dir1
+ 2 file1
+ 3 dir1/file2
+} {
+ do_catchsql_test 3.1.$tn.0 {
+ INSERT INTO x1(name, data) VALUES($fname, NULL);
+ } [list 1 "duplicate name: \"$fname/\""]
+ do_catchsql_test 3.1.$tn.1 {
+ INSERT INTO x1(name, data) VALUES($fname || '/', NULL);
+ } [list 1 "duplicate name: \"$fname/\""]
+ do_catchsql_test 3.1.$tn.2 {
+ INSERT INTO x1(name, data) VALUES($fname, 'abcd');
+ } [list 1 "duplicate name: \"$fname\""]
+}
+
+do_catchsql_test 3.2 {
+ SELECT rowid FROM x1
+} {1 {no such column: rowid}}
+
+#-------------------------------------------------------------------------
+# Test some error conditions.
+#
+do_catchsql_test 4.1 {
+ CREATE VIRTUAL TABLE yyy USING zipfile();
+} {1 {zipfile constructor requires one argument}}
+do_catchsql_test 4.2 {
+ CREATE VIRTUAL TABLE yyy USING zipfile('test.zip', 'test.zip');
+} {1 {zipfile constructor requires one argument}}
+
+do_catchsql_test 4.3 {
+ SELECT * FROM zipfile()
+} {1 {zipfile() function requires an argument}}
+
+do_catchsql_test 4.4 {
+ SELECT * FROM zipfile('/path/that/does/not/exist')
+} {1 {cannot open file: /path/that/does/not/exist}}
+
+foreach {tn mode} {
+ 1 abcd
+ 2 brwxrwxrwx
+ 3 lrwxrrxrwx
+} {
+ do_catchsql_test 4.5.$tn {
+ WITH m(m) AS ( SELECT $mode)
+ SELECT zipfile('a.txt', m, 1000, 'xyz') FROM m
+ } [list 1 "zipfile: parse error in mode: $mode"]
+}
+
+do_catchsql_test 4.6 {
+ WITH c(name,data) AS ( SELECT 'a.txt', 'abc')
+ SELECT zipfile(name) FROM c
+} {1 {wrong number of arguments to function zipfile()}}
+
+do_catchsql_test 4.7 {
+ WITH c(name,data) AS (
+ SELECT 'a.txt', 'abc' UNION ALL
+ SELECT NULL, 'def'
+ )
+ SELECT zipfile(name,data) FROM c
+} {1 {first argument to zipfile() must be non-NULL}}
+
+do_catchsql_test 4.8 {
+ WITH c(name,data,method) AS (
+ SELECT 'a.txt', 'abc', 0
+ UNION SELECT 'b.txt', 'def', 8
+ UNION SELECT 'c.txt', 'ghi', 16
+ )
+ SELECT zipfile(name,NULL,NULL,data,method) FROM c
+} {1 {illegal method value: 16}}
+
+do_catchsql_test 4.9 {
+ WITH c(name,data) AS (
+ SELECT 'a.txt', 'abc'
+ UNION SELECT 'b.txt', 'def'
+ UNION SELECT 'c.txt/', 'ghi'
+ )
+ SELECT zipfile(name,NULL,NULL,data) FROM c
+} {1 {non-directory name must not end with /}}
+
+#--------------------------------------------------------------------------
+
+db func rt remove_timestamps
+do_execsql_test 5.0 {
+ WITH c(name,mtime,data) AS (
+ SELECT 'a.txt', 946684800, 'abc'
+ )
+ SELECT name,mtime,data FROM zipfile(
+ ( SELECT rt( zipfile(name,NULL,mtime,data,NULL) ) FROM c )
+ )
+} {
+ a.txt 946684800 abc
+}
+
+if {[info exists ::UNZIP]} {
+ifcapable datetime {
+ forcedelete test1.zip test2.zip
+ do_test 6.0 {
+ execsql {
+ WITH c(name,mtime,data) AS (
+ SELECT 'a.txt', 946684800, 'abc' UNION ALL
+ SELECT 'b.txt', 1000000000, 'abc' UNION ALL
+ SELECT 'c.txt', 1111111000, 'abc'
+ )
+ SELECT writefile('test1.zip', rt( zipfile(name, NULL, mtime, data) ) ),
+ writefile('test2.zip', ( zipfile(name, NULL, mtime, data) ) )
+ FROM c;
+ }
+ forcedelete test_unzip
+ file mkdir test_unzip
+ exec $::UNZIP -d test_unzip test1.zip
+
+ db eval {
+ SELECT name, strftime('%s', mtime, 'unixepoch', 'localtime')
+ FROM fsdir('test_unzip') WHERE name!='test_unzip'
+ ORDER BY name
+ }
+ } [list {*}{
+ test_unzip/a.txt 946684800
+ test_unzip/b.txt 1000000000
+ test_unzip/c.txt 1111111000
+ }]
+
+ # fsdir() issue reported on the mailing list on 2018-03-14 by Jack Thaw.
+ do_test 6.0b {
+ db eval {
+ SELECT sum(name LIKE '%/a.txt')
+ FROM (VALUES(1),(2),(3)) CROSS JOIN fsdir('test_unzip')
+ }
+ } {3}
+
+ do_execsql_test 6.1 {
+ SELECT name, mtime, data FROM zipfile('test1.zip')
+ } {
+ a.txt 946684800 abc
+ b.txt 1000000000 abc
+ c.txt 1111111000 abc
+ }
+
+ do_test 6.2 {
+ forcedelete test_unzip
+ file mkdir test_unzip
+ exec $::UNZIP -d test_unzip test2.zip
+
+ db eval {
+ SELECT name, mtime
+ FROM fsdir('test_unzip') WHERE name!='test_unzip'
+ ORDER BY name
+ }
+ } [list {*}{
+ test_unzip/a.txt 946684800
+ test_unzip/b.txt 1000000000
+ test_unzip/c.txt 1111111000
+ }]
+
+ do_execsql_test 6.3 {
+ SELECT name, mtime, sz, rawdata, data FROM zipfile('test2.zip')
+ } {
+ a.txt 946684800 3 abc abc
+ b.txt 1000000000 3 abc abc
+ c.txt 1111111000 3 abc abc
+ }
+}
+}
+
+#-------------------------------------------------------------------------
+# Force an IO error by truncating the zip archive to zero bytes in size
+# while it is being read.
+forcedelete test.zip
+do_test 7.0 {
+ execsql {
+ WITH c(name,data) AS (
+ SELECT '1', randomblob(1000000) UNION ALL
+ SELECT '2', randomblob(1000000) UNION ALL
+ SELECT '3', randomblob(1000000)
+ )
+ SELECT writefile('test.zip', zipfile(name, data) ) FROM c;
+ }
+
+ list [catch {
+ db eval { SELECT name, data FROM zipfile('test.zip') } {
+ if {$name==2} { close [open test.zip w+] }
+ }
+ } msg] $msg
+} {1 {error in fread()}}
+
+forcedelete test.zip
+do_execsql_test 8.0.1 {
+ CREATE VIRTUAL TABLE zz USING zipfile('test.zip');
+ BEGIN;
+ INSERT INTO zz(name, data) VALUES('a.txt', '1');
+ INSERT INTO zz(name, data) VALUES('b.txt', '2');
+ INSERT INTO zz(name, data) VALUES('c.txt', '1');
+ INSERT INTO zz(name, data) VALUES('d.txt', '2');
+ SELECT name, data FROM zz;
+} {
+ a.txt 1 b.txt 2 c.txt 1 d.txt 2
+}
+do_test 8.0.2 {
+ db eval { SELECT name, data FROM zz } {
+ if { $data=="2" } { db eval { DELETE FROM zz WHERE name=$name } }
+ }
+ execsql { SELECT name, data FROM zz }
+} {a.txt 1 c.txt 1}
+do_test 8.0.3 {
+ db eval { SELECT name, data FROM zz } {
+ db eval { DELETE FROM zz WHERE name=$name }
+ }
+ execsql { SELECT name, data FROM zz }
+} {}
+execsql COMMIT
+
+catch { forcedelete test_unzip }
+catch { file mkdir test_unzip }
+do_execsql_test 8.1.1 {
+ CREATE VIRTUAL TABLE nogood USING zipfile('test_unzip');
+}
+do_catchsql_test 8.1.2 {
+ INSERT INTO nogood(name, data) VALUES('abc', 'def');
+} {1 {zipfile: failed to open file test_unzip for writing}}
+
+do_execsql_test 8.2.1 {
+ DROP TABLE nogood;
+ BEGIN;
+ CREATE VIRTUAL TABLE nogood USING zipfile('test_unzip');
+}
+do_catchsql_test 8.2.2 {
+ INSERT INTO nogood(name, data) VALUES('abc', 'def');
+} {1 {zipfile: failed to open file test_unzip for writing}}
+do_execsql_test 8.2.3 {
+ COMMIT;
+}
+
+forcedelete test.zip
+do_execsql_test 8.3.1 {
+ BEGIN;
+ CREATE VIRTUAL TABLE ok USING zipfile('test.zip');
+ INSERT INTO ok(name, data) VALUES ('sqlite3', 'elf');
+ COMMIT;
+}
+
+#-------------------------------------------------------------------------
+# Test that the zipfile aggregate correctly adds and removes "/" from
+# the ends of directory file names.
+do_execsql_test 9.0 {
+ WITH src(nm) AS (
+ VALUES('dir1') UNION ALL
+ VALUES('dir2/') UNION ALL
+ VALUES('dir3//') UNION ALL
+ VALUES('dir4///') UNION ALL
+ VALUES('/')
+ )
+ SELECT name FROM zipfile((SELECT zipfile(nm, NULL) FROM src))
+} {dir1/ dir2/ dir3/ dir4/ /}
+
+#-------------------------------------------------------------------------
+# INSERT OR REPLACE and INSERT OR IGNORE
+#
+catch {db close}
+forcedelete test.zip test.db
+sqlite3 db :memory:
+load_static_extension db zipfile
+load_static_extension db fileio
+
+do_execsql_test 10.0 {
+ CREATE VIRTUAL TABLE z USING zipfile('test.zip');
+} {}
+do_catchsql_test 10.1 {
+ INSERT INTO z(name,data) VALUES('a0','one'),('a0','two');
+} {1 {duplicate name: "a0"}}
+do_execsql_test 10.2 {
+ SELECT name, data FROM z;
+} {a0 one}
+do_execsql_test 10.3 {
+ REPLACE INTO z(name,data) VALUES('a0','three'),('a0','four');
+} {}
+do_execsql_test 10.4 {
+ SELECT name, data FROM z;
+} {a0 four}
+do_execsql_test 10.5 {
+ INSERT OR IGNORE INTO z(name,data) VALUES('a0','five'),('a0','six');
+} {}
+do_execsql_test 10.6 {
+ SELECT name, data FROM z;
+} {a0 four}
+
+do_execsql_test 11.1 {
+ DELETE FROM z;
+} {}
+do_execsql_test 11.2 {
+ SELECT name, data FROM z;
+} {}
+do_execsql_test 11.3 {
+ INSERT INTO z (name,data) VALUES ('b0','one');
+ SELECT name, data FROM z;
+} {b0 one}
+do_execsql_test 11.4 {
+ UPDATE z SET name = 'b1' WHERE name = 'b0';
+ SELECT name, data FROM z;
+} {b1 one}
+do_execsql_test 11.5 {
+ INSERT INTO z (name,data) VALUES ('b0','one');
+ SELECT name, data FROM z ORDER BY name;
+} {b0 one b1 one}
+do_catchsql_test 11.6 {
+ UPDATE z SET name = 'b1' WHERE name = 'b0';
+} {1 {duplicate name: "b1"}}
+do_execsql_test 11.7 {
+ UPDATE z SET data = 'two' WHERE name = 'b0';
+ SELECT name, data FROM z ORDER BY name;
+} {b0 two b1 one}
+do_catchsql_test 11.8 {
+ UPDATE z SET name = 'b1';
+} {1 {duplicate name: "b1"}}
+do_catchsql_test 11.9 {
+ UPDATE z SET name = 'b2';
+} {1 {duplicate name: "b2"}}
+do_execsql_test 11.10 {
+ UPDATE z SET name = name;
+ SELECT name, data FROM z ORDER BY name;
+} {b0 two b2 one}
+do_execsql_test 11.11 {
+ UPDATE z SET name = name || 'suffix';
+ SELECT name, data FROM z ORDER BY name;
+} {b0suffix two b2suffix one}
+
+
+if {$tcl_platform(platform)!="windows"} {
+ do_test 12.0 {
+ catch { file delete -force subdir }
+ foreach {path sz} {
+ subdir/x1.txt 143
+ subdir/x2.txt 153
+ } {
+ set dir [file dirname $path]
+ catch { file mkdir $dir }
+ set fd [open $path w]
+ puts -nonewline $fd [string repeat 1 $sz]
+ close $fd
+ }
+ } {}
+
+ do_execsql_test 12.1 {
+ SELECT name FROM fsdir('subdir') ORDER BY 1;
+ } {subdir subdir/x1.txt subdir/x2.txt}
+
+ do_execsql_test 12.2 {
+ CREATE TABLE d AS SELECT 'subdir' d;
+ CREATE TABLE x AS SELECT 1 x;
+ }
+
+ do_execsql_test 12.4 {
+ SELECT name FROM d JOIN x JOIN fsdir(d) ORDER BY 1;
+ } {subdir subdir/x1.txt subdir/x2.txt}
+
+ do_execsql_test 12.5 {
+ SELECT name FROM d JOIN x JOIN fsdir('.', d) ORDER BY 1;
+ } {. ./x1.txt ./x2.txt}
+}
+
+# 2019-12-18 Yongheng and Rui fuzzer
+#
+do_execsql_test 13.10 {
+ DROP TABLE IF EXISTS t0;
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t0(a,b,c,d,e,f,g);
+ REPLACE INTO t0(c,b,f) VALUES(10,10,10);
+ CREATE VIRTUAL TABLE t1 USING zipfile('h.zip');
+ REPLACE INTO t1 SELECT * FROM t0;
+ SELECT quote(name),quote(mode),quote(mtime),quote(sz),quote(rawdata),
+ quote(data),quote(method) FROM t1;
+} {'' 10 10 2 X'3130' X'3130' 0}
+
+# 2019-12-23 Yongheng and Rui fuzzer
+# Run using valgrind to see the problem.
+#
+do_execsql_test 14.10 {
+ DROP TABLE t1;
+ CREATE TABLE t1(x char);
+ INSERT INTO t1(x) VALUES('1');
+ INSERT INTO t1(x) SELECT zipfile(x, 'xyz') FROM t1;
+ INSERT INTO t1(x) SELECT zipfile(x, 'uvw') FROM t1;
+ SELECT count(*) FROM t1;
+ PRAGMA integrity_check;
+} {3 ok}
+
+# 2019-12-26 More problems in zipfile from the Yongheng and Rui fuzzer
+#
+do_execsql_test 15.10 {
+ DROP TABLE IF EXISTS t1;
+ CREATE VIRTUAL TABLE t1 USING zipfile(null);
+ REPLACE INTO t1 VALUES(null,null,0,null,null,null,null);
+} {}
+do_execsql_test 15.20 {
+ DROP TABLE IF EXISTS t2;
+ CREATE VIRTUAL TABLE t2 USING zipfile(null);
+ REPLACE INTO t2 values(null,null,null,null,null,10,null);
+} {}
+
+# 2020-01-02 Yongheng fuzzer discovery
+#
+do_catchsql_test 16.10 {
+ DELETE FROM zipfile;
+} {1 {zipfile: missing filename}}
+do_catchsql_test 16.20 {
+ REPLACE INTO zipfile VALUES(null,null,null,null,null,123,null);
+} {1 {zipfile: missing filename}}
+
+# 2021-04-22 forum https://sqlite.org/forum/forumpost/d82289d69f
+do_execsql_test 17.1 {
+ WITH vlist(x) AS (
+ VALUES(9223372036854775807),
+ (-9223372036854775808),
+ (9223372036854775806),
+ (-9223372036854775807)
+ )
+ SELECT DISTINCT typeof(zipfile(0,0,x,0)) FROM vlist;
+} {blob}
+
+
+finish_test
diff --git a/test/zipfile2.test b/test/zipfile2.test
new file mode 100644
index 0000000..987e4f0
--- /dev/null
+++ b/test/zipfile2.test
@@ -0,0 +1,243 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+package require Tcl 8.6
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix zipfile2
+
+ifcapable !vtab {
+ finish_test; return
+}
+if {[catch {load_static_extension db zipfile} error]} {
+ puts "Skipping zipfile2 tests, hit load error: $error"
+ finish_test; return
+}
+
+proc blobliteral {str} {
+ set concat [string map {" " "" "\n" ""} $str]
+ return "X'$concat'"
+}
+
+proc blob {str} {
+ binary decode hex $str
+}
+
+proc findall {needle haystack} {
+ set L [list]
+ set start 0
+ while { [set idx [string first $needle $haystack $start]]>=0 } {
+ lappend L $idx
+ set start [expr $idx+1]
+ }
+ set L
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE aaa USING zipfile('testzip');
+ CREATE VIRTUAL TABLE bbb USING zipfile("testzip");
+ CREATE VIRTUAL TABLE ccc USING zipfile(`testzip`);
+ CREATE VIRTUAL TABLE ddd USING zipfile([testzip]);
+ CREATE VIRTUAL TABLE eee USING zipfile(testzip);
+ CREATE VIRTUAL TABLE fff USING zipfile('test''zip');
+}
+
+do_test 2.0 {
+ forcedelete testdir
+ file mkdir testdir
+ execsql { CREATE VIRTUAL TABLE hhh USING zipfile('testdir') }
+ lindex [catchsql {
+ SELECT * FROM hhh;
+ INSERT INTO hhh(name, data) VALUES('1.txt', 'file data');
+ }] 0
+} 1
+
+
+set archive {
+ 504B0304140000080000D4A52BEC09F3B6E0110000001100000005000900612E
+ 747874555405000140420F00636F6E74656E7473206F6620612E747874504B03
+ 04140000080000D4A52BECD98916A7110000001100000005000900622E747874
+ 555405000140420F00636F6E74656E7473206F6620622E747874504B01021E03
+ 140000080000D4A52BEC09F3B6E0110000001100000005000900000000000000
+ 0000A48100000000612E747874555405000140420F00504B01021E0314000008
+ 0000D4A52BECD98916A71100000011000000050009000000000000000000A481
+ 3D000000622E747874555405000140420F00504B050600000000020002007800
+ 00007A0000000000
+}
+
+if 0 {
+ # This test is broken - the archive generated is slightly different
+ # depending on the zlib version used.
+ do_execsql_test 3.1 {
+ WITH contents(name,mtime,data) AS (
+ VALUES('a.txt', 1000000, 'contents of a.txt') UNION ALL
+ VALUES('b.txt', 1000000, 'contents of b.txt')
+ ) SELECT quote( zipfile(name,NULL,mtime,data) ) FROM contents;
+ } [blobliteral $archive]
+}
+
+
+set blob [blob $archive]
+do_execsql_test 3.2 {
+ SELECT name,mtime,data FROM zipfile($blob)
+} {
+ a.txt 1000000 {contents of a.txt}
+ b.txt 1000000 {contents of b.txt}
+}
+
+# Corrupt each of the 0x50 0x4B (ascii "PK") headers in the file
+# Test that in each case this causes an error.
+#
+set L [findall 504B $archive]
+for {set i 0} {$i < [llength $L]} {incr i} {
+ set idx [lindex $L $i]
+ set a [string replace $archive $idx [expr $idx+3] 0000]
+ set blob [blob $a]
+ do_catchsql_test 3.3.$i {
+ SELECT name,mtime,data FROM zipfile($blob)
+ } {/1 .*/}
+}
+
+# Change the "extra info id" for all extended-timestamp fields.
+set L [findall 5554 $archive]
+for {set i 0} {$i < [llength $L]} {incr i} {
+ set idx [lindex $L $i]
+ set a [string replace $archive $idx [expr $idx+3] 1234]
+ set blob [blob $a]
+ do_execsql_test 3.4.$i {
+ SELECT name,data FROM zipfile($blob)
+ } {
+ a.txt {contents of a.txt}
+ b.txt {contents of b.txt}
+ }
+}
+
+for {set i 0} {$i < [llength $L]} {incr i} {
+ set idx [lindex $L $i]
+ set a [string replace $archive [expr $idx+8] [expr $idx+9] 00]
+ set blob [blob $a]
+ do_execsql_test 3.5.$i {
+ SELECT name,data FROM zipfile($blob)
+ } {
+ a.txt {contents of a.txt}
+ b.txt {contents of b.txt}
+ }
+}
+
+# set blob [db one {
+# WITH contents(name,mtime,data) AS (
+# VALUES('a.txt', 1000000, 'aaaaaaaaaaaaaaaaaaaaaaa')
+# ) SELECT quote( zipfile(name,NULL,mtime,data) ) FROM contents;
+# }]
+# set blob [string range $blob 2 end]
+# set blob [string range $blob 0 end-1]
+# while {[string length $blob]>0} {
+# puts [string range $blob 0 63]
+# set blob [string range $blob 64 end]
+# }
+# exit
+
+set archive2 {
+ 504B0304140000080800D4A52BEC08F54C6E050000001700000005000900612E
+ 747874555405000140420F004B4CC40A00504B01021E03140000080800D4A52B
+ EC08F54C6E0500000017000000050009000000000000000000A4810000000061
+ 2E747874555405000140420F00504B050600000000010001003C000000310000
+ 000000
+}
+set blob [blob $archive2]
+do_execsql_test 4.0 {
+ SELECT name,mtime,data,method FROM zipfile($blob)
+} {
+ a.txt 1000000 aaaaaaaaaaaaaaaaaaaaaaa 8
+}
+
+set L [findall 17000000 $archive2]
+set a $archive2
+foreach i $L { set a [string replace $a $i [expr $i+7] 16000000] }
+set blob [blob $a]
+do_catchsql_test 4.1 {
+ SELECT name,mtime,data,method FROM zipfile($blob)
+} {1 {inflate() failed (0)}}
+
+# Check the response to an unknown compression method (set data to NULL).
+set blob [blob [string map {0800 0900} $archive2]]
+do_execsql_test 4.2 {
+ SELECT name,mtime,data IS NULL,method FROM zipfile($blob)
+} {a.txt 1000000 1 9}
+
+# Corrupt the EOCDS signature bytes in various ways.
+foreach {tn sub} {
+ 1 {504B0500}
+ 2 {504B0006}
+ 3 {50000506}
+ 4 {004B0506}
+} {
+ set blob [blob [string map [list 504B0506 $sub] $archive2]]
+ do_catchsql_test 4.3.$tn {
+ SELECT * FROM zipfile($blob)
+ } {1 {cannot find end of central directory record}}
+}
+
+#-------------------------------------------------------------------------
+# Test that a zero-length file with a '/' at the end is treated as
+# a directory (data IS NULL). Even if the mode doesn't indicate
+# that it is a directory.
+
+do_test 5.0 {
+ set blob [db one {
+ WITH c(n, d) AS (
+ SELECT 'notadir', ''
+ )
+ SELECT zipfile(n, d) FROM c
+ }]
+
+ set hex [binary encode hex $blob]
+ set hex [string map {6e6f7461646972 6e6f746164692f} $hex]
+ set blob2 [binary decode hex $hex]
+
+ execsql { SELECT name, data IS NULL FROM zipfile($blob2) }
+} {notadi/ 1}
+
+#-------------------------------------------------------------------------
+# Test that duplicate entries may not be created using UPDATE
+# statements.
+#
+forcedelete test.zip
+do_execsql_test 6.0 {
+ CREATE VIRTUAL TABLE temp.zip USING zipfile('test.zip');
+ INSERT INTO temp.zip (name,data) VALUES ('test1','test');
+ INSERT INTO temp.zip (name,data) VALUES ('test2','test');
+}
+do_catchsql_test 6.1 {
+ UPDATE temp.zip SET name='test1' WHERE name='test2'
+} {1 {duplicate name: "test1"}}
+
+forcedelete test.zip
+do_catchsql_test 6.2 {
+ DROP TABLE zip;
+ CREATE VIRTUAL TABLE temp.zip USING zipfile('test.zip');
+ INSERT INTO temp.zip (name,data) VALUES ('test','test');
+ UPDATE temp.zip set name=name||'new' where name='test';
+ INSERT INTO temp.zip (name,data) VALUES ('test','test');
+ UPDATE temp.zip set name=name||'new' where name='test';
+} {1 {duplicate name: "testnew"}}
+
+forcedelete test.zip
+do_execsql_test 6.3 {
+ INSERT INTO temp.zip (name,data) VALUES ('test1','test');
+ INSERT INTO temp.zip (name,data) VALUES ('test2','test');
+ UPDATE OR REPLACE zip SET name='test2' WHERE name='test1';
+ SELECT name FROM zip;
+} {test2}
+
+finish_test
diff --git a/test/zipfilefault.test b/test/zipfilefault.test
new file mode 100644
index 0000000..f5e2cd5
--- /dev/null
+++ b/test/zipfilefault.test
@@ -0,0 +1,166 @@
+# 2018 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix zipfilefault
+
+ifcapable !vtab {
+ finish_test; return
+}
+if {[catch {load_static_extension db zipfile} error]} {
+ puts "Skipping zipfile2 tests, hit load error: $error"
+ finish_test; return
+}
+
+faultsim_save_and_close
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+ load_static_extension db zipfile
+ execsql { DROP TABLE IF EXISTS aaa }
+} -body {
+ execsql { CREATE VIRTUAL TABLE aaa USING zipfile('test.zip') }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+forcedelete test.zip
+sqlite3 db test.db
+load_static_extension db zipfile
+do_execsql_test 2.0 {
+ CREATE VIRTUAL TABLE setup USING zipfile('test.zip');
+ INSERT INTO setup(name, data) VALUES('a.txt', '1234567890');
+}
+
+do_faultsim_test 2.1 -faults oom* -body {
+ execsql { SELECT name,data FROM zipfile('test.zip') }
+} -test {
+ faultsim_test_result {0 {a.txt 1234567890}}
+}
+ifcapable json1 {
+ do_faultsim_test 2.2 -faults oom* -body {
+ execsql {
+ SELECT json_extract( zipfile_cds(z), '$.version-made-by' )
+ FROM zipfile('test.zip')
+ }
+ } -test {
+ faultsim_test_result {0 798}
+ }
+}
+
+forcedelete test.zip
+reset_db
+load_static_extension db zipfile
+do_execsql_test 3.0 {
+ CREATE VIRTUAL TABLE setup USING zipfile('test.zip');
+ INSERT INTO setup(name, data) VALUES('a.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+}
+
+do_faultsim_test 3 -faults oom* -body {
+ execsql { SELECT name,data FROM zipfile('test.zip') }
+} -test {
+ faultsim_test_result {0 {a.txt aaaaaaaaaaaaaaaaaaaaaaaaaaaa}}
+}
+
+do_faultsim_test 4 -faults oom* -body {
+ execsql {
+ WITH c(n, d) AS (
+ SELECT 1, 'aaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb'
+ )
+ SELECT name, data FROM zipfile(
+ (SELECT zipfile(n, d) FROM c)
+ );
+ }
+} -test {
+ faultsim_test_result {0 {1 aaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb}}
+}
+
+reset_db
+sqlite3_db_config_lookaside db 0 0 0
+load_static_extension db zipfile
+
+do_execsql_test 5.0 {
+ CREATE VIRTUAL TABLE setup USING zipfile('test.zip')
+}
+
+do_faultsim_test 5.1 -faults oom* -prep {
+ forcedelete test.zip
+} -body {
+ execsql {
+ INSERT INTO setup(name, data)
+ VALUES('a.txt', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 5.2 -faults oom* -prep {
+ forcedelete test.zip
+} -body {
+ execsql {
+ INSERT INTO setup(name, data) VALUES('dir', NULL)
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 5.3 -faults oom* -prep {
+ forcedelete test.zip
+ execsql {
+ DROP TABLE IF EXISTS setup;
+ BEGIN;
+ CREATE VIRTUAL TABLE setup USING zipfile('test.zip')
+ }
+} -body {
+ execsql {
+ INSERT INTO setup(name, data) VALUES('dir', NULL)
+ }
+} -test {
+ catchsql { COMMIT }
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 6.1 -faults oom* -body {
+ execsql {
+ WITH c(n, d) AS (
+ VALUES('a.txt', '1234567890') UNION ALL
+ VALUES('dir', NULL)
+ )
+ SELECT zipfile(n, d) IS NULL FROM c;
+ }
+} -test {
+ faultsim_test_result {0 0}
+}
+
+set big [string repeat 0123456789 1000]
+do_faultsim_test 6.2 -faults oom* -body {
+ execsql {
+ WITH c(n, d) AS (
+ VALUES('a.txt', $big)
+ )
+ SELECT zipfile(n, NULL, NULL, d, 0) IS NULL FROM c;
+ }
+} -test {
+ faultsim_test_result {0 0}
+}
+
+do_faultsim_test 7.0 -faults oom* -prep {
+ catch { db close }
+ sqlite3 db ""
+} -body {
+ load_static_extension db zipfile
+} -test {
+}
+
+
+finish_test